(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))t(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&t(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function t(r){if(r.ep)return;r.ep=!0;const o=e(r);fetch(r.href,o)}})();function qe(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Nt={exports:{}},Pe=typeof Reflect=="object"?Reflect:null,Vt=Pe&&typeof Pe.apply=="function"?Pe.apply:function(i,e,t){return Function.prototype.apply.call(i,e,t)},rt;Pe&&typeof Pe.ownKeys=="function"?rt=Pe.ownKeys:Object.getOwnPropertySymbols?rt=function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:rt=function(i){return Object.getOwnPropertyNames(i)};function Sr(n){console&&console.warn&&console.warn(n)}var Li=Number.isNaN||function(i){return i!==i};function N(){N.init.call(this)}Nt.exports=N;Nt.exports.once=Lr;N.EventEmitter=N;N.prototype._events=void 0;N.prototype._eventsCount=0;N.prototype._maxListeners=void 0;var qt=10;function ot(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(N,"defaultMaxListeners",{enumerable:!0,get:function(){return qt},set:function(n){if(typeof n!="number"||n<0||Li(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");qt=n}});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(i){if(typeof i!="number"||i<0||Li(i))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+i+".");return this._maxListeners=i,this};function Di(n){return n._maxListeners===void 0?N.defaultMaxListeners:n._maxListeners}N.prototype.getMaxListeners=function(){return Di(this)};N.prototype.emit=function(i){for(var e=[],t=1;t0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[i];if(u===void 0)return!1;if(typeof u=="function")Vt(u,this,e);else for(var h=u.length,d=Pi(u,h),t=0;t0&&a.length>r&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(i)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=n,s.type=i,s.count=a.length,Sr(s)}return n}N.prototype.addListener=function(i,e){return xi(this,i,e,!1)};N.prototype.on=N.prototype.addListener;N.prototype.prependListener=function(i,e){return xi(this,i,e,!0)};function Rr(){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 Gi(n,i,e){var t={fired:!1,wrapFn:void 0,target:n,type:i,listener:e},r=Rr.bind(t);return r.listener=e,t.wrapFn=r,r}N.prototype.once=function(i,e){return ot(e),this.on(i,Gi(this,i,e)),this};N.prototype.prependOnceListener=function(i,e){return ot(e),this.prependListener(i,Gi(this,i,e)),this};N.prototype.removeListener=function(i,e){var t,r,o,a,s;if(ot(e),r=this._events,r===void 0)return this;if(t=r[i],t===void 0)return this;if(t===e||t.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[i],r.removeListener&&this.emit("removeListener",i,t.listener||e));else if(typeof t!="function"){for(o=-1,a=t.length-1;a>=0;a--)if(t[a]===e||t[a].listener===e){s=t[a].listener,o=a;break}if(o<0)return this;o===0?t.shift():Cr(t,o),t.length===1&&(r[i]=t[0]),r.removeListener!==void 0&&this.emit("removeListener",i,s||e)}return this};N.prototype.off=N.prototype.removeListener;N.prototype.removeAllListeners=function(i){var e,t,r;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[i]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[i]),this;if(arguments.length===0){var o=Object.keys(t),a;for(r=0;r=0;r--)this.removeListener(i,e[r]);return this};function Fi(n,i,e){var t=n._events;if(t===void 0)return[];var r=t[i];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?kr(r):Pi(r,r.length)}N.prototype.listeners=function(i){return Fi(this,i,!0)};N.prototype.rawListeners=function(i){return Fi(this,i,!1)};N.listenerCount=function(n,i){return typeof n.listenerCount=="function"?n.listenerCount(i):Ni.call(n,i)};N.prototype.listenerCount=Ni;function Ni(n){var i=this._events;if(i!==void 0){var e=i[n];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}N.prototype.eventNames=function(){return this._eventsCount>0?rt(this._events):[]};function Pi(n,i){for(var e=new Array(i),t=0;t=i?{done:!0}:{done:!1,value:n[e++]}})};ye.empty=function(){var n=new ye(function(){return{done:!0}});return n};ye.fromSequence=function(n){var i=0,e=n.length;return new ye(function(){return i>=e?{done:!0}:{done:!1,value:n[i++]}})};ye.is=function(n){return n instanceof ye?!0:typeof n=="object"&&n!==null&&typeof n.next=="function"};var at=ye;const oe=qe(at);var st={};st.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u";st.SYMBOL_SUPPORT=typeof Symbol<"u";var xr=at,Oi=st,Gr=Oi.ARRAY_BUFFER_SUPPORT,Fr=Oi.SYMBOL_SUPPORT;function Nr(n){return typeof n=="string"||Array.isArray(n)||Gr&&ArrayBuffer.isView(n)?xr.fromSequence(n):typeof n!="object"||n===null?null:Fr&&typeof n[Symbol.iterator]=="function"?n[Symbol.iterator]():typeof n.next=="function"?n:null}var Ui=function(i){var e=Nr(i);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},Pr=Ui,Ir=function(i,e){for(var t=arguments.length>1?e:1/0,r=t!==1/0?new Array(t):[],o,a=0,s=Pr(i);;){if(a===t)return r;if(o=s.next(),o.done)return a!==e&&(r.length=a),r;r[a++]=o.value}};const Pt=qe(Ir);var zr=at,Or=Ui,Ur=function(){var i=arguments,e=null,t=-1;return new zr(function(){var o=null;do{if(e===null){if(t++,t>=i.length)return{done:!0};e=Or(i[t])}if(o=e.next(),o.done===!0){e=null;continue}break}while(!0);return o})};const Se=qe(Ur);function $r(){const n=arguments[0];for(let i=1,e=arguments.length;in++}class It extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class R extends It{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,R.prototype.constructor)}}class E extends It{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,E.prototype.constructor)}}class D extends It{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}function kt(n,i){this.key=n,this.attributes=i,this.clear()}kt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.directedSelfLoops=0,this.undirectedSelfLoops=0,this.in={},this.out={},this.undirected={}};function zt(n,i){this.key=n,this.attributes=i,this.clear()}zt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};zt.prototype.upgradeToMixed=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}};function Ot(n,i){this.key=n,this.attributes=i,this.clear()}Ot.prototype.clear=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}};Ot.prototype.upgradeToMixed=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};function Bi(n,i,e,t,r){this.key=i,this.attributes=r,this.undirected=n,this.source=e,this.target=t}function Mi(n,i,e,t,r,o,a){const s=n.multi;let u="out",h="in";i&&(u=h="undirected");let d,c;if(s){if(d=o[u],c=d[r],typeof c>"u"&&(c=new Set,d[r]=c),c.add(e),t===r&&i)return;d=a[h],typeof d[t]>"u"&&(d[t]=c)}else{if(o[u][r]=e,t===r&&i)return;a[h][t]=e}}function Hr(n,i,e){const t=n.multi,{source:r,target:o}=e,a=r.key,s=o.key,u=i?"undirected":"out",h=r[u],d=i?"undirected":"in";if(s in h)if(t){const l=h[s];l.size===1?(delete h[s],delete o[d][a]):l.delete(e)}else delete h[s];if(t)return;const c=o[d];delete c[a]}function Wr(n){const i=n._nodes.values();let e;for(;e=i.next(),e.done!==!0;)e.value.clear()}function jr(n){n._nodes.forEach((i,e)=>{if(i.out)for(const t in i.out){const r=new Set;r.add(i.out[t]),i.out[t]=r,n._nodes.get(t).in[e]=r}if(i.undirected)for(const t in i.undirected){if(t>e)continue;const r=new Set;r.add(i.undirected[t]),i.undirected[t]=r,n._nodes.get(t).undirected[e]=r}})}const Hi=0,Wi=1,Vr=2,ji=3;function Re(n,i,e,t,r,o,a){let s,u,h,d;if(t=""+t,e===Hi){if(s=n._nodes.get(t),!s)throw new E(`Graph.${i}: could not find the "${t}" node in the graph.`);h=r,d=o}else if(e===ji){if(r=""+r,u=n._edges.get(r),!u)throw new E(`Graph.${i}: could not find the "${r}" edge in the graph.`);const c=u.source.key,l=u.target.key;if(t===c)s=u.target;else if(t===l)s=u.source;else throw new E(`Graph.${i}: the "${t}" node is not attached to the "${r}" edge (${c}, ${l}).`);h=o,d=a}else{if(u=n._edges.get(t),!u)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);e===Wi?s=u.source:s=u.target,h=r,d=o}return[s,h,d]}function qr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);return a.attributes[s]}}function Yr(n,i,e){n.prototype[i]=function(t,r){const[o]=Re(this,i,e,t,r);return o.attributes}}function Kr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);return a.attributes.hasOwnProperty(s)}}function Zr(n,i,e){n.prototype[i]=function(t,r,o,a){const[s,u,h]=Re(this,i,e,t,r,o,a);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Xr(n,i,e){n.prototype[i]=function(t,r,o,a){const[s,u,h]=Re(this,i,e,t,r,o,a);if(typeof h!="function")throw new R(`Graph.${i}: updater should be a function.`);const d=s.attributes,c=h(d[u]);return d[u]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Qr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Jr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);if(!q(s))throw new R(`Graph.${i}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function en(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);if(!q(s))throw new R(`Graph.${i}: provided attributes are not a plain object.`);return W(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function tn(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Re(this,i,e,t,r,o);if(typeof s!="function")throw new R(`Graph.${i}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const rn=[{name:n=>`get${n}Attribute`,attacher:qr},{name:n=>`get${n}Attributes`,attacher:Yr},{name:n=>`has${n}Attribute`,attacher:Kr},{name:n=>`set${n}Attribute`,attacher:Zr},{name:n=>`update${n}Attribute`,attacher:Xr},{name:n=>`remove${n}Attribute`,attacher:Qr},{name:n=>`replace${n}Attributes`,attacher:Jr},{name:n=>`merge${n}Attributes`,attacher:en},{name:n=>`update${n}Attributes`,attacher:tn}];function nn(n){rn.forEach(function({name:i,attacher:e}){e(n,i("Node"),Hi),e(n,i("Source"),Wi),e(n,i("Target"),Vr),e(n,i("Opposite"),ji)})}function on(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: 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 a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes[r]}}function an(n,i,e){n.prototype[i]=function(t){let r;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new D(`Graph.${i}: 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 o=""+t,a=""+arguments[1];if(r=be(this,o,a,e),!r)throw new E(`Graph.${i}: could not find an edge for the given path ("${o}" - "${a}").`)}else if(t=""+t,r=this._edges.get(t),!r)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&r.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return r.attributes}}function sn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: 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 a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes.hasOwnProperty(r)}}function un(n,i,e){n.prototype[i]=function(t,r,o){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: 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=""+t,u=""+r;if(r=arguments[2],o=arguments[3],a=be(this,s,u,e),!a)throw new E(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else if(t=""+t,a=this._edges.get(t),!a)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&a.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return a.attributes[r]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:r}),this}}function hn(n,i,e){n.prototype[i]=function(t,r,o){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new D(`Graph.${i}: 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=""+t,u=""+r;if(r=arguments[2],o=arguments[3],a=be(this,s,u,e),!a)throw new E(`Graph.${i}: could not find an edge for the given path ("${s}" - "${u}").`)}else if(t=""+t,a=this._edges.get(t),!a)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(typeof o!="function")throw new R(`Graph.${i}: updater should be a function.`);if(e!=="mixed"&&a.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return a.attributes[r]=o(a.attributes[r]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:r}),this}}function dn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: 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 a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}function cn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: 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 a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(!q(r))throw new R(`Graph.${i}: provided attributes are not a plain object.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function ln(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: 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 a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(!q(r))throw new R(`Graph.${i}: provided attributes are not a plain object.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return W(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}function fn(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new D(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new D(`Graph.${i}: 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 a=""+t,s=""+r;if(r=arguments[2],o=be(this,a,s,e),!o)throw new E(`Graph.${i}: could not find an edge for the given path ("${a}" - "${s}").`)}else if(t=""+t,o=this._edges.get(t),!o)throw new E(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(typeof r!="function")throw new R(`Graph.${i}: provided updater is not a function.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new E(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const gn=[{name:n=>`get${n}Attribute`,attacher:on},{name:n=>`get${n}Attributes`,attacher:an},{name:n=>`has${n}Attribute`,attacher:sn},{name:n=>`set${n}Attribute`,attacher:un},{name:n=>`update${n}Attribute`,attacher:hn},{name:n=>`remove${n}Attribute`,attacher:dn},{name:n=>`replace${n}Attributes`,attacher:cn},{name:n=>`merge${n}Attributes`,attacher:ln},{name:n=>`update${n}Attributes`,attacher:fn}];function pn(n){gn.forEach(function({name:i,attacher:e}){e(n,i("Edge"),"mixed"),e(n,i("DirectedEdge"),"directed"),e(n,i("UndirectedEdge"),"undirected")})}const vn=[{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 mn(n,i){for(const e in i)n.push(i[e].key)}function yn(n,i){for(const e in i)i[e].forEach(t=>n.push(t.key))}function bn(n,i,e){for(const t in n){if(t===e)continue;const r=n[t];i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected)}}function wn(n,i,e){for(const t in n)t!==e&&n[t].forEach(r=>i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected))}function En(n,i,e){let t=!1;for(const r in n){if(r===e)continue;const o=n[r];if(t=i(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),t)return o.key}}function _n(n,i,e){let t,r,o,a,s,u=!1;for(const h in n)if(h!==e){for(t=n[h].values();r=t.next(),r.done!==!0;)if(o=r.value,a=o.source,s=o.target,u=i(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected),u)return o.key}}function ct(n,i){const e=Object.keys(n),t=e.length;let r=null,o=0;return new oe(function a(){let s;if(r){const u=r.next();if(u.done)return r=null,o++,a();s=u.value}else{if(o>=t)return{done:!0};const u=e[o];if(u===i)return o++,a();if(s=n[u],s instanceof Set)return r=s.values(),a();o++}return{done:!1,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}}})}function Tn(n,i,e){const t=i[e];t&&n.push(t.key)}function An(n,i,e){const t=i[e];t&&t.forEach(r=>n.push(r.key))}function Sn(n,i,e){const t=n[i];if(!t)return;const r=t.source,o=t.target;e(t.key,t.attributes,r.key,o.key,r.attributes,o.attributes,t.undirected)}function Rn(n,i,e){const t=n[i];t&&t.forEach(r=>e(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected))}function Cn(n,i,e){const t=n[i];if(!t)return;const r=t.source,o=t.target;if(e(t.key,t.attributes,r.key,o.key,r.attributes,o.attributes,t.undirected))return t.key}function kn(n,i,e){const t=n[i];if(!t)return;let r=!1;const o=t.values();let a,s;for(;a=o.next(),a.done!==!0;)if(s=a.value,r=e(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r)return s.key}function lt(n,i){const e=n[i];if(e instanceof Set){const t=e.values();return new oe(function(){const r=t.next();if(r.done)return r;const o=r.value;return{done:!1,value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected}}})}return oe.of([e.key,e.attributes,e.source.key,e.target.key,e.source.attributes,e.target.attributes])}function Ln(n,i){if(n.size===0)return[];if(i==="mixed"||i===n.type)return typeof Array.from=="function"?Array.from(n._edges.keys()):Pt(n._edges.keys(),n._edges.size);const e=i==="undirected"?n.undirectedSize:n.directedSize,t=new Array(e),r=i==="undirected",o=n._edges.values();let a=0,s,u;for(;s=o.next(),s.done!==!0;)u=s.value,u.undirected===r&&(t[a++]=u.key);return t}function Dn(n,i,e){if(n.size===0)return;const t=i!=="mixed"&&i!==n.type,r=i==="undirected";let o,a;const s=n._edges.values();for(;o=s.next(),o.done!==!0;){if(a=o.value,t&&a.undirected!==r)continue;const{key:u,attributes:h,source:d,target:c}=a;e(u,h,d.key,c.key,d.attributes,c.attributes,a.undirected)}}function xn(n,i,e){if(n.size===0)return;const t=i!=="mixed"&&i!==n.type,r=i==="undirected";let o,a,s=!1;const u=n._edges.values();for(;o=u.next(),o.done!==!0;){if(a=o.value,t&&a.undirected!==r)continue;const{key:h,attributes:d,source:c,target:l}=a;if(s=e(h,d,c.key,l.key,c.attributes,l.attributes,a.undirected),s)return h}}function Gn(n,i){if(n.size===0)return oe.empty();const e=i!=="mixed"&&i!==n.type,t=i==="undirected",r=n._edges.values();return new oe(function(){let a,s;for(;;){if(a=r.next(),a.done)return a;if(s=a.value,!(e&&s.undirected!==t))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 Fn(n,i,e,t){const r=[],o=n?yn:mn;return i!=="undirected"&&(e!=="out"&&o(r,t.in),e!=="in"&&o(r,t.out),!e&&t.directedSelfLoops>0&&r.splice(r.lastIndexOf(t.key),1)),i!=="directed"&&o(r,t.undirected),r}function Nn(n,i,e,t,r){const o=n?wn:bn;i!=="undirected"&&(e!=="out"&&o(t.in,r),e!=="in"&&o(t.out,r,e?null:t.key)),i!=="directed"&&o(t.undirected,r)}function Pn(n,i,e,t,r){const o=n?_n:En;let a;if(i!=="undirected"&&(e!=="out"&&(a=o(t.in,r),a)||e!=="in"&&(a=o(t.out,r,e?null:t.key),a))||i!=="directed"&&(a=o(t.undirected,r),a))return a}function In(n,i,e){let t=oe.empty();return n!=="undirected"&&(i!=="out"&&typeof e.in<"u"&&(t=Se(t,ct(e.in))),i!=="in"&&typeof e.out<"u"&&(t=Se(t,ct(e.out,i?null:e.key)))),n!=="directed"&&typeof e.undirected<"u"&&(t=Se(t,ct(e.undirected))),t}function zn(n,i,e,t,r){const o=i?An:Tn,a=[];return n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&o(a,t.in,r),typeof t.out<"u"&&e!=="in"&&o(a,t.out,r),!e&&t.directedSelfLoops>0&&a.splice(a.lastIndexOf(t.key),1)),n!=="directed"&&typeof t.undirected<"u"&&o(a,t.undirected,r),a}function On(n,i,e,t,r,o){const a=i?Rn:Sn;n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&a(t.in,r,o),t.key!==r&&typeof t.out<"u"&&e!=="in"&&a(t.out,r,o)),n!=="directed"&&typeof t.undirected<"u"&&a(t.undirected,r,o)}function Un(n,i,e,t,r,o){const a=i?kn:Cn;let s;if(n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&(s=a(t.in,r,o),s)||t.key!==r&&typeof t.out<"u"&&e!=="in"&&(s=a(t.out,r,o,e?null:t.key),s))||n!=="directed"&&typeof t.undirected<"u"&&(s=a(t.undirected,r,o),s))return s}function $n(n,i,e,t){let r=oe.empty();return n!=="undirected"&&(typeof e.in<"u"&&i!=="out"&&t in e.in&&(r=Se(r,lt(e.in,t))),typeof e.out<"u"&&i!=="in"&&t in e.out&&(r=Se(r,lt(e.out,t)))),n!=="directed"&&typeof e.undirected<"u"&&t in e.undirected&&(r=Se(r,lt(e.undirected,t))),r}function Bn(n,i){const{name:e,type:t,direction:r}=i;n.prototype[e]=function(o,a){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];if(!arguments.length)return Ln(this,t);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new E(`Graph.${e}: could not find the "${o}" node in the graph.`);return Fn(this.multi,t==="mixed"?this.type:t,r,s)}if(arguments.length===2){o=""+o,a=""+a;const s=this._nodes.get(o);if(!s)throw new E(`Graph.${e}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new E(`Graph.${e}: could not find the "${a}" target node in the graph.`);return zn(t,this.multi,r,s,a)}throw new R(`Graph.${e}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Mn(n,i){const{name:e,type:t,direction:r}=i,o="forEach"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[o]=function(h,d,c){if(!(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)){if(arguments.length===1)return c=h,Dn(this,t,c);if(arguments.length===2){h=""+h,c=d;const l=this._nodes.get(h);if(typeof l>"u")throw new E(`Graph.${o}: could not find the "${h}" node in the graph.`);return Nn(this.multi,t==="mixed"?this.type:t,r,l,c)}if(arguments.length===3){h=""+h,d=""+d;const l=this._nodes.get(h);if(!l)throw new E(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(d))throw new E(`Graph.${o}: could not find the "${d}" target node in the graph.`);return On(t,this.multi,r,l,d,c)}throw new R(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const a="map"+e[0].toUpperCase()+e.slice(1);n.prototype[a]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop();let c;if(h.length===0){let l=0;t!=="directed"&&(l+=this.undirectedSize),t!=="undirected"&&(l+=this.directedSize),c=new Array(l);let f=0;h.push((y,w,_,k,p,v,m)=>{c[f++]=d(y,w,_,k,p,v,m)})}else c=[],h.push((l,f,y,w,_,k,p)=>{c.push(d(l,f,y,w,_,k,p))});return this[o].apply(this,h),c};const s="filter"+e[0].toUpperCase()+e.slice(1);n.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop(),c=[];return h.push((l,f,y,w,_,k,p)=>{d(l,f,y,w,_,k,p)&&c.push(l)}),this[o].apply(this,h),c};const u="reduce"+e[0].toUpperCase()+e.slice(1);n.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new R(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.length-2]!="function")throw new R(`Graph.${u}: 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,c;h.length===2?(d=h[0],c=h[1],h=[]):h.length===3?(d=h[1],c=h[2],h=[h[0]]):h.length===4&&(d=h[2],c=h[3],h=[h[0],h[1]]);let l=c;return h.push((f,y,w,_,k,p,v)=>{l=d(l,f,y,w,_,k,p,v)}),this[o].apply(this,h),l}}function Hn(n,i){const{name:e,type:t,direction:r}=i,o="find"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[o]=function(u,h,d){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return!1;if(arguments.length===1)return d=u,xn(this,t,d);if(arguments.length===2){u=""+u,d=h;const c=this._nodes.get(u);if(typeof c>"u")throw new E(`Graph.${o}: could not find the "${u}" node in the graph.`);return Pn(this.multi,t==="mixed"?this.type:t,r,c,d)}if(arguments.length===3){u=""+u,h=""+h;const c=this._nodes.get(u);if(!c)throw new E(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new E(`Graph.${o}: could not find the "${h}" target node in the graph.`);return Un(t,this.multi,r,c,h,d)}throw new R(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const a="some"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((c,l,f,y,w,_,k)=>h(c,l,f,y,w,_,k)),!!this[o].apply(this,u)};const s="every"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),h=u.pop();return u.push((c,l,f,y,w,_,k)=>!h(c,l,f,y,w,_,k)),!this[o].apply(this,u)}}function Wn(n,i){const{name:e,type:t,direction:r}=i,o=e.slice(0,-1)+"Entries";n.prototype[o]=function(a,s){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return oe.empty();if(!arguments.length)return Gn(this,t);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new E(`Graph.${o}: could not find the "${a}" node in the graph.`);return In(t,r,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new E(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new E(`Graph.${o}: could not find the "${s}" target node in the graph.`);return $n(t,r,u,s)}throw new R(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function jn(n){vn.forEach(i=>{Bn(n,i),Mn(n,i),Hn(n,i),Wn(n,i)})}const Vn=[{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 ft(n,i){if(!(typeof i>"u"))for(const e in i)n.add(e)}function qn(n,i,e){if(n!=="mixed"){if(n==="undirected")return Object.keys(e.undirected);if(typeof i=="string")return Object.keys(e[i])}const t=new Set;return n!=="undirected"&&(i!=="out"&&ft(t,e.in),i!=="in"&&ft(t,e.out)),n!=="directed"&&ft(t,e.undirected),Pt(t.values(),t.size)}function Kt(n,i,e){for(const t in i){let r=i[t];r instanceof Set&&(r=r.values().next().value);const o=r.source,a=r.target,s=o===n?a:o;e(s.key,s.attributes)}}function gt(n,i,e,t){for(const r in e){let o=e[r];o instanceof Set&&(o=o.values().next().value);const a=o.source,s=o.target,u=a===i?s:a;n.has(u.key)||(n.add(u.key),t(u.key,u.attributes))}}function Zt(n,i,e){for(const t in i){let r=i[t];r instanceof Set&&(r=r.values().next().value);const o=r.source,a=r.target,s=o===n?a:o;if(e(s.key,s.attributes))return s.key}}function pt(n,i,e,t){for(const r in e){let o=e[r];o instanceof Set&&(o=o.values().next().value);const a=o.source,s=o.target,u=a===i?s:a;if(n.has(u.key))continue;if(n.add(u.key),t(u.key,u.attributes))return u.key}}function Yn(n,i,e,t){if(n!=="mixed"){if(n==="undirected")return Kt(e,e.undirected,t);if(typeof i=="string")return Kt(e,e[i],t)}const r=new Set;n!=="undirected"&&(i!=="out"&>(r,e,e.in,t),i!=="in"&>(r,e,e.out,t)),n!=="directed"&>(r,e,e.undirected,t)}function Kn(n,i,e,t){if(n!=="mixed"){if(n==="undirected")return Zt(e,e.undirected,t);if(typeof i=="string")return Zt(e,e[i],t)}const r=new Set;let o;if(n!=="undirected"&&(i!=="out"&&(o=pt(r,e,e.in,t),o)||i!=="in"&&(o=pt(r,e,e.out,t),o))||n!=="directed"&&(o=pt(r,e,e.undirected,t),o))return o}function Xt(n,i){const e=Object.keys(i),t=e.length;let r=0;return new oe(function(){if(r>=t)return{done:!0};let o=i[e[r++]];o instanceof Set&&(o=o.values().next().value);const a=o.source,s=o.target,u=a===n?s:a;return{done:!1,value:{neighbor:u.key,attributes:u.attributes}}})}function vt(n,i,e){const t=Object.keys(e),r=t.length;let o=0;return new oe(function a(){if(o>=r)return{done:!0};let s=e[t[o++]];s instanceof Set&&(s=s.values().next().value);const u=s.source,h=s.target,d=u===i?h:u;return n.has(d.key)?a():(n.add(d.key),{done:!1,value:{neighbor:d.key,attributes:d.attributes}})})}function Zn(n,i,e){if(n!=="mixed"){if(n==="undirected")return Xt(e,e.undirected);if(typeof i=="string")return Xt(e,e[i])}let t=oe.empty();const r=new Set;return n!=="undirected"&&(i!=="out"&&(t=Se(t,vt(r,e,e.in))),i!=="in"&&(t=Se(t,vt(r,e,e.out)))),n!=="directed"&&(t=Se(t,vt(r,e,e.undirected))),t}function Xn(n,i){const{name:e,type:t,direction:r}=i;n.prototype[e]=function(o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new E(`Graph.${e}: could not find the "${o}" node in the graph.`);return qn(t==="mixed"?this.type:t,r,a)}}function Qn(n,i){const{name:e,type:t,direction:r}=i,o="forEach"+e[0].toUpperCase()+e.slice(1,-1);n.prototype[o]=function(h,d){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;h=""+h;const c=this._nodes.get(h);if(typeof c>"u")throw new E(`Graph.${o}: could not find the "${h}" node in the graph.`);Yn(t==="mixed"?this.type:t,r,c,d)};const a="map"+e[0].toUpperCase()+e.slice(1);n.prototype[a]=function(h,d){const c=[];return this[o](h,(l,f)=>{c.push(d(l,f))}),c};const s="filter"+e[0].toUpperCase()+e.slice(1);n.prototype[s]=function(h,d){const c=[];return this[o](h,(l,f)=>{d(l,f)&&c.push(l)}),c};const u="reduce"+e[0].toUpperCase()+e.slice(1);n.prototype[u]=function(h,d,c){if(arguments.length<3)throw new R(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l=c;return this[o](h,(f,y)=>{l=d(l,f,y)}),l}}function Jn(n,i){const{name:e,type:t,direction:r}=i,o=e[0].toUpperCase()+e.slice(1,-1),a="find"+o;n.prototype[a]=function(h,d){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;h=""+h;const c=this._nodes.get(h);if(typeof c>"u")throw new E(`Graph.${a}: could not find the "${h}" node in the graph.`);return Kn(t==="mixed"?this.type:t,r,c,d)};const s="some"+o;n.prototype[s]=function(h,d){return!!this[a](h,d)};const u="every"+o;n.prototype[u]=function(h,d){return!this[a](h,(l,f)=>!d(l,f))}}function eo(n,i){const{name:e,type:t,direction:r}=i,o=e.slice(0,-1)+"Entries";n.prototype[o]=function(a){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return oe.empty();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new E(`Graph.${o}: could not find the "${a}" node in the graph.`);return Zn(t==="mixed"?this.type:t,r,s)}}function to(n){Vn.forEach(i=>{Xn(n,i),Qn(n,i),Jn(n,i),eo(n,i)})}function Ze(n,i,e,t,r){const o=t._nodes.values(),a=t.type;let s,u,h,d,c,l;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){d=u.out;for(h in d)c=d[h],l=c.target,f=!0,r(u.key,l.key,u.attributes,l.attributes,c.key,c.attributes,c.undirected)}if(a!=="directed"){d=u.undirected;for(h in d)i&&u.key>h||(c=d[h],l=c.target,l.key!==h&&(l=c.source),f=!0,r(u.key,l.key,u.attributes,l.attributes,c.key,c.attributes,c.undirected))}e&&!f&&r(u.key,null,u.attributes,null,null,null,null)}}function Xe(n,i,e,t,r){const o=t._nodes.values(),a=t.type;let s,u,h,d,c,l,f,y;for(;s=o.next(),s.done!==!0;){let w=!1;if(u=s.value,a!=="undirected"){l=u.out;for(h in l)for(d=l[h].values();c=d.next(),c.done!==!0;)f=c.value,y=f.target,w=!0,r(u.key,y.key,u.attributes,y.attributes,f.key,f.attributes,f.undirected)}if(a!=="directed"){l=u.undirected;for(h in l)if(!(i&&u.key>h))for(d=l[h].values();c=d.next(),c.done!==!0;)f=c.value,y=f.target,y.key!==h&&(y=f.source),w=!0,r(u.key,y.key,u.attributes,y.attributes,f.key,f.attributes,f.undirected)}e&&!w&&r(u.key,null,u.attributes,null,null,null,null)}}function Qt(n,i){const e={key:n};return $i(i.attributes)||(e.attributes=W({},i.attributes)),e}function Jt(n,i){const e={key:n,source:i.source.key,target:i.target.key};return $i(i.attributes)||(e.attributes=W({},i.attributes)),i.undirected&&(e.undirected=!0),e}function io(n){return q(n)?"key"in n?"attributes"in n&&(!q(n.attributes)||n.attributes===null)?"invalid-attributes":null:"no-key":"not-object"}function ro(n){return q(n)?"source"in n?"target"in n?"attributes"in n&&(!q(n.attributes)||n.attributes===null)?"invalid-attributes":"undirected"in n&&typeof n.undirected!="boolean"?"invalid-undirected":null:"no-target":"no-source":"not-object"}const no=Mr(),oo=new Set(["directed","undirected","mixed"]),ei=new Set(["domain","_events","_eventsCount","_maxListeners"]),ao=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],so={allowSelfLoops:!0,multi:!1,type:"mixed"};function uo(n,i,e){if(e&&!q(e))throw new R(`Graph.addNode: invalid attributes. Expecting an object but got "${e}"`);if(i=""+i,e=e||{},n._nodes.has(i))throw new D(`Graph.addNode: the "${i}" node already exist in the graph.`);const t=new n.NodeDataClass(i,e);return n._nodes.set(i,t),n.emit("nodeAdded",{key:i,attributes:e}),t}function ti(n,i,e){const t=new n.NodeDataClass(i,e);return n._nodes.set(i,t),n.emit("nodeAdded",{key:i,attributes:e}),t}function Vi(n,i,e,t,r,o,a,s){if(!t&&n.type==="undirected")throw new D(`Graph.${i}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(t&&n.type==="directed")throw new D(`Graph.${i}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!q(s))throw new R(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!n.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(o),h=n._nodes.get(a);if(!u)throw new E(`Graph.${i}: source node "${o}" not found.`);if(!h)throw new E(`Graph.${i}: target node "${a}" not found.`);const d={key:null,undirected:t,source:o,target:a,attributes:s};if(e)r=n._edgeKeyGenerator();else if(r=""+r,n._edges.has(r))throw new D(`Graph.${i}: the "${r}" edge already exists in the graph.`);if(!n.multi&&(t?typeof u.undirected[a]<"u":typeof u.out[a]<"u"))throw new D(`Graph.${i}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const c=new Bi(t,r,u,h,s);return n._edges.set(r,c),o===a?t?(u.undirectedSelfLoops++,n._undirectedSelfLoopCount++):(u.directedSelfLoops++,n._directedSelfLoopCount++):t?(u.undirectedDegree++,h.undirectedDegree++):(u.outDegree++,h.inDegree++),Mi(n,t,c,o,a,u,h),t?n._undirectedSize++:n._directedSize++,d.key=r,n.emit("edgeAdded",d),r}function ho(n,i,e,t,r,o,a,s,u){if(!t&&n.type==="undirected")throw new D(`Graph.${i}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(t&&n.type==="directed")throw new D(`Graph.${i}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new R(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!q(s))throw new R(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let h;if(u&&(h=s,s=void 0),!n.allowSelfLoops&&o===a)throw new D(`Graph.${i}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=n._nodes.get(o),c=n._nodes.get(a),l,f;if(!e&&(l=n._edges.get(r),l)){if((l.source.key!==o||l.target.key!==a)&&(!t||l.source.key!==a||l.target.key!==o))throw new D(`Graph.${i}: inconsistency detected when attempting to merge the "${r}" edge with "${o}" source & "${a}" target vs. ("${l.source.key}", "${l.target.key}").`);f=l}if(!f&&!n.multi&&d&&(f=t?d.undirected[a]:d.out[a]),f){const k=[f.key,!1,!1,!1];if(u?!h:!s)return k;if(u){const p=f.attributes;f.attributes=h(p),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else W(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return k}s=s||{},u&&h&&(s=h(s));const y={key:null,undirected:t,source:o,target:a,attributes:s};if(e)r=n._edgeKeyGenerator();else if(r=""+r,n._edges.has(r))throw new D(`Graph.${i}: the "${r}" edge already exists in the graph.`);let w=!1,_=!1;return d||(d=ti(n,o,{}),w=!0,o===a&&(c=d,_=!0)),c||(c=ti(n,a,{}),_=!0),l=new Bi(t,r,d,c,s),n._edges.set(r,l),o===a?t?(d.undirectedSelfLoops++,n._undirectedSelfLoopCount++):(d.directedSelfLoops++,n._directedSelfLoopCount++):t?(d.undirectedDegree++,c.undirectedDegree++):(d.outDegree++,c.inDegree++),Mi(n,t,l,o,a,d,c),t?n._undirectedSize++:n._directedSize++,y.key=r,n.emit("edgeAdded",y),[r,!0,w,_]}class I extends zi.EventEmitter{constructor(i){if(super(),i=W({},so,i),typeof i.multi!="boolean")throw new R(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!oo.has(i.type))throw new R(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new R(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const e=i.type==="mixed"?kt:i.type==="directed"?zt:Ot;re(this,"NodeDataClass",e);const t=no();let r=0;const o=()=>{let a;do a="geid_"+t+"_"+r++;while(this._edges.has(a));return a};re(this,"_attributes",{}),re(this,"_nodes",new Map),re(this,"_edges",new Map),re(this,"_directedSize",0),re(this,"_undirectedSize",0),re(this,"_directedSelfLoopCount",0),re(this,"_undirectedSelfLoopCount",0),re(this,"_edgeKeyGenerator",o),re(this,"_options",i),ei.forEach(a=>re(this,a,this[a])),ne(this,"order",()=>this._nodes.size),ne(this,"size",()=>this._edges.size),ne(this,"directedSize",()=>this._directedSize),ne(this,"undirectedSize",()=>this._undirectedSize),ne(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ne(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ne(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ne(this,"multi",this._options.multi),ne(this,"type",this._options.type),ne(this,"allowSelfLoops",this._options.allowSelfLoops),ne(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(i){return this._nodes.has(""+i)}hasDirectedEdge(i,e){if(this.type==="undirected")return!1;if(arguments.length===1){const t=""+i,r=this._edges.get(t);return!!r&&!r.undirected}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)return!1;const r=t.out[e];return r?this.multi?!!r.size:!0:!1}throw new R(`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(i,e){if(this.type==="directed")return!1;if(arguments.length===1){const t=""+i,r=this._edges.get(t);return!!r&&r.undirected}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)return!1;const r=t.undirected[e];return r?this.multi?!!r.size:!0:!1}throw new R(`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(i,e){if(arguments.length===1){const t=""+i;return this._edges.has(t)}else if(arguments.length===2){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)return!1;let r=typeof t.out<"u"&&t.out[e];return r||(r=typeof t.undirected<"u"&&t.undirected[e]),r?this.multi?!!r.size:!0:!1}throw new R(`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(i,e){if(this.type==="undirected")return;if(i=""+i,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 t=this._nodes.get(i);if(!t)throw new E(`Graph.directedEdge: could not find the "${i}" 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=t.out&&t.out[e]||void 0;if(r)return r.key}undirectedEdge(i,e){if(this.type==="directed")return;if(i=""+i,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 t=this._nodes.get(i);if(!t)throw new E(`Graph.undirectedEdge: could not find the "${i}" 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=t.undirected&&t.undirected[e]||void 0;if(r)return r.key}edge(i,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.");i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.edge: could not find the "${i}" 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=t.out&&t.out[e]||t.undirected&&t.undirected[e]||void 0;if(r)return r.key}areDirectedNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areDirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.in||e in t.out}areOutNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areOutNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.out}areInNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areInNeighbors: could not find the "${i}" node in the graph.`);return this.type==="undirected"?!1:e in t.in}areUndirectedNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areUndirectedNeighbors: could not find the "${i}" node in the graph.`);return this.type==="directed"?!1:e in t.undirected}areNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&(e in t.in||e in t.out)||this.type!=="directed"&&e in t.undirected}areInboundNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areInboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&e in t.in||this.type!=="directed"&&e in t.undirected}areOutboundNeighbors(i,e){i=""+i,e=""+e;const t=this._nodes.get(i);if(!t)throw new E(`Graph.areOutboundNeighbors: could not find the "${i}" node in the graph.`);return this.type!=="undirected"&&e in t.out||this.type!=="directed"&&e in t.undirected}inDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.inDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.directedSelfLoops}outDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.outDegree: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.outDegree+e.directedSelfLoops}directedDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.directedDegree: could not find the "${i}" node in the graph.`);if(this.type==="undirected")return 0;const t=e.directedSelfLoops,r=e.inDegree+t,o=e.outDegree+t;return r+o}undirectedDegree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.undirectedDegree: could not find the "${i}" node in the graph.`);if(this.type==="directed")return 0;const t=e.undirectedSelfLoops;return e.undirectedDegree+t*2}degree(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.degree: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree+e.undirectedSelfLoops*2),this.type!=="undirected"&&(t+=e.inDegree+e.outDegree+e.directedSelfLoops*2),t}inDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.inDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree}outDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.outDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.outDegree}directedDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.directedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="undirected"?0:e.inDegree+e.outDegree}undirectedDegreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);return this.type==="directed"?0:e.undirectedDegree}degreeWithoutSelfLoops(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.degreeWithoutSelfLoops: could not find the "${i}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=e.undirectedDegree),this.type!=="undirected"&&(t+=e.inDegree+e.outDegree),t}source(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.source: could not find the "${i}" edge in the graph.`);return e.source.key}target(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.target: could not find the "${i}" edge in the graph.`);return e.target.key}extremities(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.extremities: could not find the "${i}" edge in the graph.`);return[e.source.key,e.target.key]}opposite(i,e){i=""+i,e=""+e;const t=this._edges.get(e);if(!t)throw new E(`Graph.opposite: could not find the "${e}" edge in the graph.`);const r=t.source.key,o=t.target.key;if(i===r)return o;if(i===o)return r;throw new E(`Graph.opposite: the "${i}" node is not attached to the "${e}" edge (${r}, ${o}).`)}hasExtremity(i,e){i=""+i,e=""+e;const t=this._edges.get(i);if(!t)throw new E(`Graph.hasExtremity: could not find the "${i}" edge in the graph.`);return t.source.key===e||t.target.key===e}isUndirected(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.isUndirected: could not find the "${i}" edge in the graph.`);return e.undirected}isDirected(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.isDirected: could not find the "${i}" edge in the graph.`);return!e.undirected}isSelfLoop(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return e.source===e.target}addNode(i,e){return uo(this,i,e).key}mergeNode(i,e){if(e&&!q(e))throw new R(`Graph.mergeNode: invalid attributes. Expecting an object but got "${e}"`);i=""+i,e=e||{};let t=this._nodes.get(i);return t?(e&&(W(t.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:i,attributes:t.attributes,data:e})),[i,!1]):(t=new this.NodeDataClass(i,e),this._nodes.set(i,t),this.emit("nodeAdded",{key:i,attributes:e}),[i,!0])}updateNode(i,e){if(e&&typeof e!="function")throw new R(`Graph.updateNode: invalid updater function. Expecting a function but got "${e}"`);i=""+i;let t=this._nodes.get(i);if(t){if(e){const o=t.attributes;t.attributes=e(o),this.emit("nodeAttributesUpdated",{type:"replace",key:i,attributes:t.attributes})}return[i,!1]}const r=e?e({}):{};return t=new this.NodeDataClass(i,r),this._nodes.set(i,t),this.emit("nodeAdded",{key:i,attributes:r}),[i,!0]}dropNode(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.dropNode: could not find the "${i}" node in the graph.`);this.forEachEdge(i,t=>{this.dropEdge(t)}),this._nodes.delete(i),this.emit("nodeDropped",{key:i,attributes:e.attributes})}dropEdge(i){let e;if(arguments.length>1){const s=""+arguments[0],u=""+arguments[1];if(e=be(this,s,u,this.type),!e)throw new E(`Graph.dropEdge: could not find the "${s}" -> "${u}" edge in the graph.`)}else if(i=""+i,e=this._edges.get(i),!e)throw new E(`Graph.dropEdge: could not find the "${i}" edge in the graph.`);this._edges.delete(e.key);const{source:t,target:r,attributes:o}=e,a=e.undirected;return t===r?a?(t.undirectedSelfLoops--,this._undirectedSelfLoopCount--):(t.directedSelfLoops--,this._directedSelfLoopCount--):a?(t.undirectedDegree--,r.undirectedDegree--):(t.outDegree--,r.inDegree--),Hr(this,a,e),a?this._undirectedSize--:this._directedSize--,this.emit("edgeDropped",{key:i,attributes:o,source:t.key,target:r.key,undirected:a}),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){Wr(this),this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(i){return this._attributes[i]}getAttributes(){return this._attributes}hasAttribute(i){return this._attributes.hasOwnProperty(i)}setAttribute(i,e){return this._attributes[i]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}updateAttribute(i,e){if(typeof e!="function")throw new R("Graph.updateAttribute: updater should be a function.");const t=this._attributes[i];return this._attributes[i]=e(t),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:i}),this}removeAttribute(i){return delete this._attributes[i],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:i}),this}replaceAttributes(i){if(!q(i))throw new R("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=i,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(i){if(!q(i))throw new R("Graph.mergeAttributes: provided attributes are not a plain object.");return W(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new R("Graph.updateAttributes: provided updater is not a function.");return this._attributes=i(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(i,e){if(typeof i!="function")throw new R("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!Yt(e))throw new R("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const t=this._nodes.values();let r,o;for(;r=t.next(),r.done!==!0;)o=r.value,o.attributes=i(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})}updateEachEdgeAttributes(i,e){if(typeof i!="function")throw new R("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!Yt(e))throw new R("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const t=this._edges.values();let r,o,a,s;for(;r=t.next(),r.done!==!0;)o=r.value,a=o.source,s=o.target,o.attributes=i(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})}forEachAdjacencyEntry(i){if(typeof i!="function")throw new R("Graph.forEachAdjacencyEntry: expecting a callback.");this.multi?Xe(!1,!1,!1,this,i):Ze(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new R("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");this.multi?Xe(!1,!1,!0,this,i):Ze(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new R("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");this.multi?Xe(!1,!0,!1,this,i):Ze(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new R("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");this.multi?Xe(!1,!0,!0,this,i):Ze(!1,!0,!0,this,i)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):Pt(this._nodes.keys(),this._nodes.size)}forEachNode(i){if(typeof i!="function")throw new R("Graph.forEachNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)r=t.value,i(r.key,r.attributes)}findNode(i){if(typeof i!="function")throw new R("Graph.findNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)if(r=t.value,i(r.key,r.attributes))return r.key}mapNodes(i){if(typeof i!="function")throw new R("Graph.mapNode: expecting a callback.");const e=this._nodes.values();let t,r;const o=new Array(this.order);let a=0;for(;t=e.next(),t.done!==!0;)r=t.value,o[a++]=i(r.key,r.attributes);return o}someNode(i){if(typeof i!="function")throw new R("Graph.someNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)if(r=t.value,i(r.key,r.attributes))return!0;return!1}everyNode(i){if(typeof i!="function")throw new R("Graph.everyNode: expecting a callback.");const e=this._nodes.values();let t,r;for(;t=e.next(),t.done!==!0;)if(r=t.value,!i(r.key,r.attributes))return!1;return!0}filterNodes(i){if(typeof i!="function")throw new R("Graph.filterNodes: expecting a callback.");const e=this._nodes.values();let t,r;const o=[];for(;t=e.next(),t.done!==!0;)r=t.value,i(r.key,r.attributes)&&o.push(r.key);return o}reduceNodes(i,e){if(typeof i!="function")throw new R("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new R("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 t=e;const r=this._nodes.values();let o,a;for(;o=r.next(),o.done!==!0;)a=o.value,t=i(t,a.key,a.attributes);return t}nodeEntries(){const i=this._nodes.values();return new oe(()=>{const e=i.next();if(e.done)return e;const t=e.value;return{value:{node:t.key,attributes:t.attributes},done:!1}})}exportNode(i){i=""+i;const e=this._nodes.get(i);if(!e)throw new E(`Graph.exportNode: could not find the "${i}" node in the graph.`);return Qt(i,e)}exportEdge(i){i=""+i;const e=this._edges.get(i);if(!e)throw new E(`Graph.exportEdge: could not find the "${i}" edge in the graph.`);return Jt(i,e)}export(){const i=new Array(this._nodes.size);let e=0;this._nodes.forEach((r,o)=>{i[e++]=Qt(o,r)});const t=new Array(this._edges.size);return e=0,this._edges.forEach((r,o)=>{t[e++]=Jt(o,r)}),{attributes:this.getAttributes(),nodes:i,edges:t,options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops}}}importNode(i,e=!1){const t=io(i);if(t){if(t==="not-object")throw new R('Graph.importNode: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(t==="no-key")throw new R("Graph.importNode: no key provided.");if(t==="invalid-attributes")throw new R("Graph.importNode: invalid attributes. Attributes should be a plain object, null or omitted.")}const{key:r,attributes:o={}}=i;return e?this.mergeNode(r,o):this.addNode(r,o),this}importEdge(i,e=!1){const t=ro(i);if(t){if(t==="not-object")throw new R('Graph.importEdge: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(t==="no-source")throw new R("Graph.importEdge: missing souce.");if(t==="no-target")throw new R("Graph.importEdge: missing target.");if(t==="invalid-attributes")throw new R("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if(t==="invalid-undirected")throw new R("Graph.importEdge: invalid undirected. Undirected should be boolean or omitted.")}const{source:r,target:o,attributes:a={},undirected:s=!1}=i;let u;return"key"in i?(u=e?s?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:s?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,u.call(this,i.key,r,o,a)):(u=e?s?this.mergeUndirectedEdge:this.mergeDirectedEdge:s?this.addUndirectedEdge:this.addDirectedEdge,u.call(this,r,o,a)),this}import(i,e=!1){if(Br(i))return this.import(i.export(),e),this;if(!q(i))throw new R("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!q(i.attributes))throw new R("Graph.import: invalid attributes. Expecting a plain object.");e?this.mergeAttributes(i.attributes):this.replaceAttributes(i.attributes)}let t,r,o;if(i.nodes){if(o=i.nodes,!Array.isArray(o))throw new R("Graph.import: invalid nodes. Expecting an array.");for(t=0,r=o.length;t{const o=W({},t.attributes);t=new e.NodeDataClass(r,o),e._nodes.set(r,t)}),e}copy(){const i=this.emptyCopy(),e=this._edges.values();let t,r;for(;t=e.next(),t.done!==!0;)r=t.value,Vi(i,"copy",!1,r.undirected,r.key,r.source.key,r.target.key,W({},r.attributes));return i}upgradeToMixed(){return this.type==="mixed"?this:(this._nodes.forEach(i=>i.upgradeToMixed()),this._options.type="mixed",ne(this,"type",this._options.type),re(this,"NodeDataClass",kt),this)}upgradeToMulti(){return this.multi?this:(this._options.multi=!0,ne(this,"multi",!0),jr(this),this)}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const i={};this._nodes.forEach((o,a)=>{i[a]=o.attributes});const e={},t={};this._edges.forEach((o,a)=>{const s=o.undirected?"--":"->";let u="",h=o.source.key,d=o.target.key,c;o.undirected&&h>d&&(c=h,h=d,d=c);const l=`(${h})${s}(${d})`;a.startsWith("geid_")?this.multi&&(typeof t[l]>"u"?t[l]=0:t[l]++,u+=`${t[l]}. `):u+=`[${a}]: `,u+=l,e[u]=o.attributes});const r={};for(const o in this)this.hasOwnProperty(o)&&!ei.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(r[o]=this[o]);return r.attributes=this._attributes,r.nodes=i,r.edges=e,re(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(I.prototype[Symbol.for("nodejs.util.inspect.custom")]=I.prototype.inspect);ao.forEach(n=>{["add","merge","update"].forEach(i=>{const e=n.name(i),t=i==="add"?Vi:ho;n.generateKey?I.prototype[e]=function(r,o,a){return t(this,e,!0,(n.type||this.type)==="undirected",null,r,o,a,i==="update")}:I.prototype[e]=function(r,o,a,s){return t(this,e,!1,(n.type||this.type)==="undirected",r,o,a,s,i==="update")}})});nn(I);pn(I);jn(I);to(I);class qi extends I{constructor(i){const e=W({type:"directed"},i);if("multi"in e&&e.multi!==!1)throw new R("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="directed")throw new R('DirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Yi extends I{constructor(i){const e=W({type:"undirected"},i);if("multi"in e&&e.multi!==!1)throw new R("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="undirected")throw new R('UndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Ki extends I{constructor(i){const e=W({multi:!0},i);if("multi"in e&&e.multi!==!0)throw new R("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(e)}}class Zi extends I{constructor(i){const e=W({type:"directed",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new R("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="directed")throw new R('MultiDirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Xi extends I{constructor(i){const e=W({type:"undirected",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new R("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="undirected")throw new R('MultiUndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}function Ue(n){n.from=function(i,e){const t=W({},i.options,e),r=new n(t);return r.import(i),r}}Ue(I);Ue(qi);Ue(Yi);Ue(Ki);Ue(Zi);Ue(Xi);I.Graph=I;I.DirectedGraph=qi;I.UndirectedGraph=Yi;I.MultiGraph=Ki;I.MultiDirectedGraph=Zi;I.MultiUndirectedGraph=Xi;I.InvalidArgumentsGraphError=R;I.NotFoundGraphError=E;I.UsageGraphError=D;function co(n,i){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var t=e.call(n,i);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function je(n){var i=co(n,"string");return typeof i=="symbol"?i:i+""}function K(n,i){if(!(n instanceof i))throw new TypeError("Cannot call a class as a function")}function ii(n,i){for(var e=0;en.length)&&(i=n.length);for(var e=0,t=Array(i);e>>16,e=(n&65280)>>>8,t=n&255,r=255,o=tr(i,e,t,r);return bt[n]=o,o}function ri(n,i,e,t){return e+(i<<8)+(n<<16)}function ni(n,i,e,t,r,o){var a=Math.floor(e/o*r),s=Math.floor(n.drawingBufferHeight/o-t/o*r),u=new Uint8Array(4);n.bindFramebuffer(n.FRAMEBUFFER,i),n.readPixels(a,s,1,1,n.RGBA,n.UNSIGNED_BYTE,u);var h=Oe(u,4),d=h[0],c=h[1],l=h[2],f=h[3];return[d,c,l,f]}function b(n,i,e){return(i=je(i))in n?Object.defineProperty(n,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[i]=e,n}function oi(n,i){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(n);i&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,t)}return e}function C(n){for(var i=1;im){var L="…";for(h=h+L,A=n.measureText(h).width;A>m&&h.length>1;)h=h.slice(0,-2)+L,A=n.measureText(h).width;if(h.length<4)return}var T;p>0?v>0?T=Math.acos(p/m):T=Math.asin(v/m):v>0?T=Math.acos(p/m)+Math.PI:T=Math.asin(p/m)+Math.PI/2,n.save(),n.translate(_,k),n.rotate(T),n.fillText(h,-A/2,i.size/2+o),n.restore()}}}function ar(n,i,e){if(i.label){var t=e.labelSize,r=e.labelFont,o=e.labelWeight,a=e.labelColor.attribute?i[e.labelColor.attribute]||e.labelColor.color||"#000":e.labelColor.color;n.fillStyle=a,n.font="".concat(o," ").concat(t,"px ").concat(r),n.fillText(i.label,i.x+i.size+3,i.y+t/3)}}function Do(n,i,e){var t=e.labelSize,r=e.labelFont,o=e.labelWeight;n.font="".concat(o," ").concat(t,"px ").concat(r),n.fillStyle="#FFF",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=8,n.shadowColor="#000";var a=2;if(typeof i.label=="string"){var s=n.measureText(i.label).width,u=Math.round(s+5),h=Math.round(t+2*a),d=Math.max(i.size,t/2)+a,c=Math.asin(h/2/d),l=Math.sqrt(Math.abs(Math.pow(d,2)-Math.pow(h/2,2)));n.beginPath(),n.moveTo(i.x+l,i.y+h/2),n.lineTo(i.x+d+u,i.y+h/2),n.lineTo(i.x+d+u,i.y-h/2),n.lineTo(i.x+l,i.y-h/2),n.arc(i.x,i.y,d,c,-c),n.closePath(),n.fill()}else n.beginPath(),n.arc(i.x,i.y,i.size+a,0,Math.PI*2),n.closePath(),n.fill();n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,ar(n,i,e)}var xo=` precision highp float; varying vec4 v_color; varying vec2 v_diffVector; varying float v_radius; uniform float u_correctionRatio; const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0); void main(void) { float border = u_correctionRatio * 2.0; float dist = length(v_diffVector) - v_radius + border; // No antialiasing for picking mode: #ifdef PICKING_MODE if (dist > border) gl_FragColor = transparent; else gl_FragColor = v_color; #else float t = 0.0; if (dist > border) t = 1.0; else if (dist > 0.0) t = dist / border; gl_FragColor = mix(v_color, transparent, t); #endif } `,Go=xo,Fo=` attribute vec4 a_id; attribute vec4 a_color; attribute vec2 a_position; attribute float a_size; attribute float a_angle; uniform mat3 u_matrix; uniform float u_sizeRatio; uniform float u_correctionRatio; varying vec4 v_color; varying vec2 v_diffVector; varying float v_radius; varying float v_border; const float bias = 255.0 / 254.0; void main() { float size = a_size * u_correctionRatio / u_sizeRatio * 4.0; vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle)); vec2 position = a_position + diffVector; gl_Position = vec4( (u_matrix * vec3(position, 1)).xy, 0, 1 ); v_diffVector = diffVector; v_radius = size / 2.0; #ifdef PICKING_MODE // For picking mode, we use the ID as the color: v_color = a_id; #else // For normal mode, we use the color: v_color = a_color; #endif v_color.a *= bias; } `,No=Fo,sr=WebGLRenderingContext,ui=sr.UNSIGNED_BYTE,Et=sr.FLOAT,Po=["u_sizeRatio","u_correctionRatio","u_matrix"],ut=function(n){function i(){return K(this,i),he(this,i,arguments)}return de(i,n),Z(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:No,FRAGMENT_SHADER_SOURCE:Go,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Po,ATTRIBUTES:[{name:"a_position",size:2,type:Et},{name:"a_size",size:1,type:Et},{name:"a_color",size:4,type:ui,normalized:!0},{name:"a_id",size:4,type:ui,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Et}],CONSTANT_DATA:[[i.ANGLE_1],[i.ANGLE_2],[i.ANGLE_3]]}}},{key:"processVisibleItem",value:function(t,r,o){var a=this.array,s=Ye(o.color);a[r++]=o.x,a[r++]=o.y,a[r++]=o.size,a[r++]=s,a[r++]=t}},{key:"setUniforms",value:function(t,r){var o=r.gl,a=r.uniformLocations,s=a.u_sizeRatio,u=a.u_correctionRatio,h=a.u_matrix;o.uniform1f(u,t.correctionRatio),o.uniform1f(s,t.sizeRatio),o.uniformMatrix3fv(h,!1,t.matrix)}}])}(Co);b(ut,"ANGLE_1",0);b(ut,"ANGLE_2",2*Math.PI/3);b(ut,"ANGLE_3",4*Math.PI/3);var Io=` precision mediump float; varying vec4 v_color; void main(void) { gl_FragColor = v_color; } `,zo=Io,Oo=` attribute vec2 a_position; attribute vec2 a_normal; attribute float a_radius; attribute vec3 a_barycentric; #ifdef PICKING_MODE attribute vec4 a_id; #else attribute vec4 a_color; #endif uniform mat3 u_matrix; uniform float u_sizeRatio; uniform float u_correctionRatio; uniform float u_minEdgeThickness; uniform float u_lengthToThicknessRatio; uniform float u_widenessToThicknessRatio; varying vec4 v_color; const float bias = 255.0 / 254.0; void main() { float minThickness = u_minEdgeThickness; float normalLength = length(a_normal); vec2 unitNormal = a_normal / normalLength; // These first computations are taken from edge.vert.glsl and // edge.clamped.vert.glsl. Please read it to get better comments on what's // happening: float pixelsThickness = max(normalLength / u_sizeRatio, minThickness); float webGLThickness = pixelsThickness * u_correctionRatio; float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio; float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0; float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio; float da = a_barycentric.x; float db = a_barycentric.y; float dc = a_barycentric.z; vec2 delta = vec2( da * (webGLNodeRadius * unitNormal.y) + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x) + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x), da * (-webGLNodeRadius * unitNormal.x) + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y) + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y) ); vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy; gl_Position = vec4(position, 0, 1); #ifdef PICKING_MODE // For picking mode, we use the ID as the color: v_color = a_id; #else // For normal mode, we use the color: v_color = a_color; #endif v_color.a *= bias; } `,Uo=Oo,ur=WebGLRenderingContext,hi=ur.UNSIGNED_BYTE,Je=ur.FLOAT,$o=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],hr={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function dr(n){var i=C(C({},hr),{});return function(e){function t(){return K(this,t),he(this,t,arguments)}return de(t,e),Z(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Uo,FRAGMENT_SHADER_SOURCE:zo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$o,ATTRIBUTES:[{name:"a_position",size:2,type:Je},{name:"a_normal",size:2,type:Je},{name:"a_radius",size:1,type:Je},{name:"a_color",size:4,type:hi,normalized:!0},{name:"a_id",size:4,type:hi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Je}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,h){if(i.extremity==="source"){var d=[u,s];s=d[0],u=d[1]}var c=h.size||1,l=u.size||1,f=s.x,y=s.y,w=u.x,_=u.y,k=Ye(h.color),p=w-f,v=_-y,m=p*p+v*v,A=0,L=0;m&&(m=1/Math.sqrt(m),A=-v*m*c,L=p*m*c);var T=this.array;T[a++]=w,T[a++]=_,T[a++]=-A,T[a++]=-L,T[a++]=l,T[a++]=k,T[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,d=u.u_sizeRatio,c=u.u_correctionRatio,l=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,y=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(d,o.sizeRatio),s.uniform1f(c,o.correctionRatio),s.uniform1f(l,o.minEdgeThickness),s.uniform1f(f,i.lengthToThicknessRatio),s.uniform1f(y,i.widenessToThicknessRatio)}}])}(Ut)}dr();var Bo=` precision mediump float; varying vec4 v_color; varying vec2 v_normal; varying float v_thickness; varying float v_feather; const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0); void main(void) { // We only handle antialiasing for normal mode: #ifdef PICKING_MODE gl_FragColor = v_color; #else float dist = length(v_normal) * v_thickness; float t = smoothstep( v_thickness - v_feather, v_thickness, dist ); gl_FragColor = mix(v_color, transparent, t); #endif } `,cr=Bo,Mo=` attribute vec4 a_id; attribute vec4 a_color; attribute vec2 a_normal; attribute float a_normalCoef; attribute vec2 a_positionStart; attribute vec2 a_positionEnd; attribute float a_positionCoef; attribute float a_radius; attribute float a_radiusCoef; uniform mat3 u_matrix; uniform float u_zoomRatio; uniform float u_sizeRatio; uniform float u_pixelRatio; uniform float u_correctionRatio; uniform float u_minEdgeThickness; uniform float u_lengthToThicknessRatio; uniform float u_feather; varying vec4 v_color; varying vec2 v_normal; varying float v_thickness; varying float v_feather; const float bias = 255.0 / 254.0; void main() { float minThickness = u_minEdgeThickness; float radius = a_radius * a_radiusCoef; vec2 normal = a_normal * a_normalCoef; vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef; float normalLength = length(normal); vec2 unitNormal = normal / normalLength; // These first computations are taken from edge.vert.glsl. Please read it to // get better comments on what's happening: float pixelsThickness = max(normalLength, minThickness * u_sizeRatio); float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio; // Here, we move the point to leave space for the arrow head: float direction = sign(radius); float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio; float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0; vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength); // Here is the proper position of the vertex gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1); v_thickness = webGLThickness / u_zoomRatio; v_normal = unitNormal; v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0; #ifdef PICKING_MODE // For picking mode, we use the ID as the color: v_color = a_id; #else // For normal mode, we use the color: v_color = a_color; #endif v_color.a *= bias; } `,Ho=Mo,lr=WebGLRenderingContext,di=lr.UNSIGNED_BYTE,Ge=lr.FLOAT,Wo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],jo={lengthToThicknessRatio:hr.lengthToThicknessRatio};function fr(n){var i=C(C({},jo),{});return function(e){function t(){return K(this,t),he(this,t,arguments)}return de(t,e),Z(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ho,FRAGMENT_SHADER_SOURCE:cr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Wo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ge},{name:"a_positionEnd",size:2,type:Ge},{name:"a_normal",size:2,type:Ge},{name:"a_color",size:4,type:di,normalized:!0},{name:"a_id",size:4,type:di,normalized:!0},{name:"a_radius",size:1,type:Ge}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ge},{name:"a_normalCoef",size:1,type:Ge},{name:"a_radiusCoef",size:1,type:Ge}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,u,h){var d=h.size||1,c=s.x,l=s.y,f=u.x,y=u.y,w=Ye(h.color),_=f-c,k=y-l,p=u.size||1,v=_*_+k*k,m=0,A=0;v&&(v=1/Math.sqrt(v),m=-k*v*d,A=_*v*d);var L=this.array;L[a++]=c,L[a++]=l,L[a++]=f,L[a++]=y,L[a++]=m,L[a++]=A,L[a++]=w,L[a++]=o,L[a++]=p}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,d=u.u_zoomRatio,c=u.u_feather,l=u.u_pixelRatio,f=u.u_correctionRatio,y=u.u_sizeRatio,w=u.u_minEdgeThickness,_=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(d,o.zoomRatio),s.uniform1f(y,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(l,o.pixelRatio),s.uniform1f(c,o.antiAliasingFeather),s.uniform1f(w,o.minEdgeThickness),s.uniform1f(_,i.lengthToThicknessRatio)}}])}(Ut)}fr();function Vo(n){return ko([fr(),dr()])}var qo=Vo(),Yo=qo,Ko=` attribute vec4 a_id; attribute vec4 a_color; attribute vec2 a_normal; attribute float a_normalCoef; attribute vec2 a_positionStart; attribute vec2 a_positionEnd; attribute float a_positionCoef; uniform mat3 u_matrix; uniform float u_sizeRatio; uniform float u_zoomRatio; uniform float u_pixelRatio; uniform float u_correctionRatio; uniform float u_minEdgeThickness; uniform float u_feather; varying vec4 v_color; varying vec2 v_normal; varying float v_thickness; varying float v_feather; const float bias = 255.0 / 254.0; void main() { float minThickness = u_minEdgeThickness; vec2 normal = a_normal * a_normalCoef; vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef; float normalLength = length(normal); vec2 unitNormal = normal / normalLength; // We require edges to be at least "minThickness" pixels thick *on screen* // (so we need to compensate the size ratio): float pixelsThickness = max(normalLength, minThickness * u_sizeRatio); // Then, we need to retrieve the normalized thickness of the edge in the WebGL // referential (in a ([0, 1], [0, 1]) space), using our "magic" correction // ratio: float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio; // Here is the proper position of the vertex gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1); // For the fragment shader though, we need a thickness that takes the "magic" // correction ratio into account (as in webGLThickness), but so that the // antialiasing effect does not depend on the zoom level. So here's yet // another thickness version: v_thickness = webGLThickness / u_zoomRatio; v_normal = unitNormal; v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0; #ifdef PICKING_MODE // For picking mode, we use the ID as the color: v_color = a_id; #else // For normal mode, we use the color: v_color = a_color; #endif v_color.a *= bias; } `,Zo=Ko,gr=WebGLRenderingContext,ci=gr.UNSIGNED_BYTE,$e=gr.FLOAT,Xo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Qo=function(n){function i(){return K(this,i),he(this,i,arguments)}return de(i,n),Z(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Zo,FRAGMENT_SHADER_SOURCE:cr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Xo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:$e},{name:"a_positionEnd",size:2,type:$e},{name:"a_normal",size:2,type:$e},{name:"a_color",size:4,type:ci,normalized:!0},{name:"a_id",size:4,type:ci,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:$e},{name:"a_normalCoef",size:1,type:$e}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(t,r,o,a,s){var u=s.size||1,h=o.x,d=o.y,c=a.x,l=a.y,f=Ye(s.color),y=c-h,w=l-d,_=y*y+w*w,k=0,p=0;_&&(_=1/Math.sqrt(_),k=-w*_*u,p=y*_*u);var v=this.array;v[r++]=h,v[r++]=d,v[r++]=c,v[r++]=l,v[r++]=k,v[r++]=p,v[r++]=f,v[r++]=t}},{key:"setUniforms",value:function(t,r){var o=r.gl,a=r.uniformLocations,s=a.u_matrix,u=a.u_zoomRatio,h=a.u_feather,d=a.u_pixelRatio,c=a.u_correctionRatio,l=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,t.matrix),o.uniform1f(u,t.zoomRatio),o.uniform1f(l,t.sizeRatio),o.uniform1f(c,t.correctionRatio),o.uniform1f(d,t.pixelRatio),o.uniform1f(h,t.antiAliasingFeather),o.uniform1f(f,t.minEdgeThickness)}}])}(Ut),$t=function(n){function i(){var e;return K(this,i),e=he(this,i),e.rawEmitter=e,e}return de(i,n),Z(i)}(zi.EventEmitter),Bt=function(i){return i!==null&&typeof i=="object"&&typeof i.addUndirectedEdgeWithKey=="function"&&typeof i.dropNode=="function"&&typeof i.multi=="boolean"};const Jo=qe(Bt);var ea=function(i){return i},ta=function(i){return i*i},ia=function(i){return i*(2-i)},ra=function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)},na=function(i){return i*i*i},oa=function(i){return--i*i*i+1},aa=function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)},sa={linear:ea,quadraticIn:ta,quadraticOut:ia,quadraticInOut:ra,cubicIn:na,cubicOut:oa,cubicInOut:aa},ua={easing:"quadraticInOut",duration:150};function ge(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function et(n,i,e){return n[0]=i,n[4]=typeof e=="number"?e:i,n}function li(n,i){var e=Math.sin(i),t=Math.cos(i);return n[0]=t,n[1]=e,n[3]=-e,n[4]=t,n}function fi(n,i,e){return n[6]=i,n[7]=e,n}function Ce(n,i){var e=n[0],t=n[1],r=n[2],o=n[3],a=n[4],s=n[5],u=n[6],h=n[7],d=n[8],c=i[0],l=i[1],f=i[2],y=i[3],w=i[4],_=i[5],k=i[6],p=i[7],v=i[8];return n[0]=c*e+l*o+f*u,n[1]=c*t+l*a+f*h,n[2]=c*r+l*s+f*d,n[3]=y*e+w*o+_*u,n[4]=y*t+w*a+_*h,n[5]=y*r+w*s+_*d,n[6]=k*e+p*o+v*u,n[7]=k*t+p*a+v*h,n[8]=k*r+p*s+v*d,n}function Gt(n,i){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,t=n[0],r=n[1],o=n[3],a=n[4],s=n[6],u=n[7],h=i.x,d=i.y;return{x:h*t+d*o+s*e,y:h*r+d*a+u*e}}function ha(n,i){var e=n.height/n.width,t=i.height/i.width;return e<1&&t>1||e>1&&t<1?1:Math.min(Math.max(t,1/t),Math.max(1/e,e))}function Be(n,i,e,t,r){var o=n.angle,a=n.ratio,s=n.x,u=n.y,h=i.width,d=i.height,c=ge(),l=Math.min(h,d)-2*t,f=ha(i,e);return r?(Ce(c,fi(ge(),s,u)),Ce(c,et(ge(),a)),Ce(c,li(ge(),o)),Ce(c,et(ge(),h/l/2/f,d/l/2/f))):(Ce(c,et(ge(),2*(l/h)*f,2*(l/d)*f)),Ce(c,li(ge(),-o)),Ce(c,et(ge(),1/a)),Ce(c,fi(ge(),-s,-u))),c}function da(n,i,e){var t=Gt(n,{x:Math.cos(i.angle),y:Math.sin(i.angle)},0),r=t.x,o=t.y;return 1/Math.sqrt(Math.pow(r,2)+Math.pow(o,2))/e.width}function ca(n){if(!n.order)return{x:[0,1],y:[0,1]};var i=1/0,e=-1/0,t=1/0,r=-1/0;return n.forEachNode(function(o,a){var s=a.x,u=a.y;se&&(e=s),ur&&(r=u)}),{x:[i,e],y:[t,r]}}function la(n){if(!Jo(n))throw new Error("Sigma: invalid graph instance.");n.forEachNode(function(i,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Sigma: Coordinates of node ".concat(i," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function fa(n,i,e){var t=document.createElement(n);if(i)for(var r in i)t.style[r]=i[r];if(e)for(var o in e)t.setAttribute(o,e[o]);return t}function gi(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function pi(n,i,e){return e.sort(function(t,r){var o=i(t)||0,a=i(r)||0;return oa?1:0})}function vi(n){var i=Oe(n.x,2),e=i[0],t=i[1],r=Oe(n.y,2),o=r[0],a=r[1],s=Math.max(t-e,a-o),u=(t+e)/2,h=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(u)&&(u=0),isNaN(h)&&(h=0);var d=function(l){return{x:.5+(l.x-u)/s,y:.5+(l.y-h)/s}};return d.applyTo=function(c){c.x=.5+(c.x-u)/s,c.y=.5+(c.y-h)/s},d.inverse=function(c){return{x:u+s*(c.x-.5),y:h+s*(c.y-.5)}},d.ratio=s,d}function Ft(n){"@babel/helpers - typeof";return Ft=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Ft(n)}function mi(n,i){var e=i.size;if(e!==0){var t=n.length;n.length+=e;var r=0;i.forEach(function(o){n[t+r]=o,r++})}}function _t(n){n=n||{};for(var i=0,e=arguments.length<=1?0:arguments.length-1;i1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return r.animate(t,o,f)});if(this.enabled){var s=C(C({},ua),o),u=this.validateState(t),h=typeof s.easing=="function"?s.easing:sa[s.easing],d=Date.now(),c=this.getState(),l=function(){var y=(Date.now()-d)/s.duration;if(y>=1){r.nextFrame=null,r.setState(u),r.animationCallback&&(r.animationCallback.call(null),r.animationCallback=void 0);return}var w=h(y),_={};typeof u.x=="number"&&(_.x=c.x+(u.x-c.x)*w),typeof u.y=="number"&&(_.y=c.y+(u.y-c.y)*w),r.enabledRotation&&typeof u.angle=="number"&&(_.angle=c.angle+(u.angle-c.angle)*w),typeof u.ratio=="number"&&(_.ratio=c.ratio+(u.ratio-c.ratio)*w),r.setState(_),r.nextFrame=requestAnimationFrame(l)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(l)):l(),this.animationCallback=a}}},{key:"animatedZoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio/t}):this.animate({ratio:this.ratio/(t.factor||tt)},t):this.animate({ratio:this.ratio/tt})}},{key:"animatedUnzoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio*t}):this.animate({ratio:this.ratio*(t.factor||tt)},t):this.animate({ratio:this.ratio*tt})}},{key:"animatedReset",value:function(t){return this.animate({x:.5,y:.5,ratio:1,angle:0},t)}},{key:"copy",value:function(){return i.from(this.getState())}}],[{key:"from",value:function(t){var r=new i;return r.setState(t)}}])}($t);function pe(n,i){var e=i.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}function Te(n,i){var e=C(C({},pe(n,i)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n});return e}function Me(n){var i="x"in n?n:C(C({},n.touches[0]||n.previousTouches[0]),{},{original:n.original,sigmaDefaultPrevented:n.sigmaDefaultPrevented,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0,i.sigmaDefaultPrevented=!0}});return i}function ma(n,i){return C(C({},Te(n,i)),{},{delta:pr(n)})}var ya=2;function nt(n){for(var i=[],e=0,t=Math.min(n.length,ya);e0;r.draggedEvents=0,c&&r.renderer.getSetting("hideEdgesOnMove")&&r.renderer.refresh()},0),this.emit("mouseup",Te(t,this.container))}}},{key:"handleMove",value:function(t){var r=this;if(this.enabled){var o=Te(t,this.container);if(this.emit("mousemovebody",o),(t.target===this.container||t.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.movingTimeout=null,r.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=pe(t,this.container),u=s.x,h=s.y,d=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),c=this.renderer.viewportToFramedGraph({x:u,y:h}),l=d.x-c.x,f=d.y-c.y,y=a.getState(),w=y.x+l,_=y.y+f;a.setState({x:w,y:_}),this.lastMouseX=u,this.lastMouseY=h,t.preventDefault(),t.stopPropagation()}}}},{key:"handleLeave",value:function(t){this.emit("mouseleave",Te(t,this.container))}},{key:"handleEnter",value:function(t){this.emit("mouseenter",Te(t,this.container))}},{key:"handleWheel",value:function(t){var r=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=pr(t);if(a){var s=ma(t,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){t.preventDefault(),t.stopPropagation();return}var u=o.getState().ratio,h=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,d=o.getBoundedRatio(u*h),c=a>0?1:-1,l=Date.now();u!==d&&(t.preventDefault(),t.stopPropagation(),!(this.currentWheelDirection===c&&this.lastWheelTriggerTime&&l-this.lastWheelTriggerTimet.size?-1:e.sizet.key?1:-1}}])}(),Ei=function(){function n(){K(this,n),b(this,"width",0),b(this,"height",0),b(this,"cellSize",0),b(this,"columns",0),b(this,"rows",0),b(this,"cells",{})}return Z(n,[{key:"resizeAndClear",value:function(e,t){this.width=e.width,this.height=e.height,this.cellSize=t,this.columns=Math.ceil(e.width/t),this.rows=Math.ceil(e.height/t),this.cells={}}},{key:"getIndex",value:function(e){var t=Math.floor(e.x/this.cellSize),r=Math.floor(e.y/this.cellSize);return r*this.columns+t}},{key:"add",value:function(e,t,r){var o=new wi(e,t),a=this.getIndex(r),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var e in this.cells){var t=this.cells[e];t.sort(wi.compare)}}},{key:"getLabelsToDisplay",value:function(e,t){var r=this.cellSize*this.cellSize,o=r/e/e,a=o*t/r,s=Math.ceil(a),u=[];for(var h in this.cells)for(var d=this.cells[h],c=0;c2&&arguments[2]!==void 0?arguments[2]:{};if(K(this,i),r=he(this,i),b(r,"elements",{}),b(r,"canvasContexts",{}),b(r,"webGLContexts",{}),b(r,"pickingLayers",new Set),b(r,"textures",{}),b(r,"frameBuffers",{}),b(r,"activeListeners",{}),b(r,"labelGrid",new Ei),b(r,"nodeDataCache",{}),b(r,"edgeDataCache",{}),b(r,"nodeProgramIndex",{}),b(r,"edgeProgramIndex",{}),b(r,"nodesWithForcedLabels",new Set),b(r,"edgesWithForcedLabels",new Set),b(r,"nodeExtent",{x:[0,1],y:[0,1]}),b(r,"nodeZExtent",[1/0,-1/0]),b(r,"edgeZExtent",[1/0,-1/0]),b(r,"matrix",ge()),b(r,"invMatrix",ge()),b(r,"correctionRatio",1),b(r,"customBBox",null),b(r,"normalizationFunction",vi({x:[0,1],y:[0,1]})),b(r,"graphToViewportRatio",1),b(r,"itemIDsIndex",{}),b(r,"nodeIndices",{}),b(r,"edgeIndices",{}),b(r,"width",0),b(r,"height",0),b(r,"pixelRatio",gi()),b(r,"pickingDownSizingRatio",2*r.pixelRatio),b(r,"displayedNodeLabels",new Set),b(r,"displayedEdgeLabels",new Set),b(r,"highlightedNodes",new Set),b(r,"hoveredNode",null),b(r,"hoveredEdge",null),b(r,"renderFrame",null),b(r,"renderHighlightedNodesFrame",null),b(r,"needToProcess",!1),b(r,"checkEdgesEventsFrame",null),b(r,"nodePrograms",{}),b(r,"nodeHoverPrograms",{}),b(r,"edgePrograms",{}),r.settings=va(o),Tt(r.settings),la(e),!(t instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");r.graph=e,r.container=t,r.createWebGLContext("edges",{picking:o.enableEdgeEvents}),r.createCanvasContext("edgeLabels"),r.createWebGLContext("nodes",{picking:!0}),r.createCanvasContext("labels"),r.createCanvasContext("hovers"),r.createWebGLContext("hoverNodes"),r.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),r.resize();for(var a in r.settings.nodeProgramClasses)r.registerNodeProgram(a,r.settings.nodeProgramClasses[a],r.settings.nodeHoverProgramClasses[a]);for(var s in r.settings.edgeProgramClasses)r.registerEdgeProgram(s,r.settings.edgeProgramClasses[s]);return r.camera=new yi,r.bindCameraHandlers(),r.mouseCaptor=new Ea(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new Aa(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return de(i,n),Z(i,[{key:"registerNodeProgram",value:function(t,r,o){return this.nodePrograms[t]&&this.nodePrograms[t].kill(),this.nodeHoverPrograms[t]&&this.nodeHoverPrograms[t].kill(),this.nodePrograms[t]=new r(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[t]=new(o||r)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(t,r){return this.edgePrograms[t]&&this.edgePrograms[t].kill(),this.edgePrograms[t]=new r(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(t){if(this.nodePrograms[t]){var r=this.nodePrograms,o=r[t],a=At(r,[t].map(je));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[t]){var s=this.nodeHoverPrograms,u=s[t],h=At(s,[t].map(je));u.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(t){if(this.edgePrograms[t]){var r=this.edgePrograms,o=r[t],a=At(r,[t].map(je));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(t){var r=this.webGLContexts[t],o=this.frameBuffers[t],a=this.textures[t];a&&r.deleteTexture(a);var s=r.createTexture();return r.bindFramebuffer(r.FRAMEBUFFER,o),r.bindTexture(r.TEXTURE_2D,s),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,s,0),this.textures[t]=s,this}},{key:"bindCameraHandlers",value:function(){var t=this;return this.activeListeners.camera=function(){t.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(t){var r=t.x,o=t.y,a=ni(this.webGLContexts.nodes,this.frameBuffers.nodes,r,o,this.pixelRatio,this.pickingDownSizingRatio),s=ri.apply(void 0,bi(a)),u=this.itemIDsIndex[s];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var t=this;this.activeListeners.handleResize=function(){t.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=Me(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},u=t.getNodeAtPosition(a);if(u&&t.hoveredNode!==u&&!t.nodeDataCache[u].hidden){t.hoveredNode&&t.emit("leaveNode",C(C({},s),{},{node:t.hoveredNode})),t.hoveredNode=u,t.emit("enterNode",C(C({},s),{},{node:u})),t.scheduleHighlightedNodesRender();return}if(t.hoveredNode&&t.getNodeAtPosition(a)!==t.hoveredNode){var h=t.hoveredNode;t.hoveredNode=null,t.emit("leaveNode",C(C({},s),{},{node:h})),t.scheduleHighlightedNodesRender();return}if(t.settings.enableEdgeEvents){var d=t.hoveredNode?null:t.getEdgeAtPoint(s.event.x,s.event.y);d!==t.hoveredEdge&&(t.hoveredEdge&&t.emit("leaveEdge",C(C({},s),{},{edge:t.hoveredEdge})),d&&t.emit("enterEdge",C(C({},s),{},{edge:d})),t.hoveredEdge=d)}},this.activeListeners.handleMoveBody=function(o){var a=Me(o);t.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Me(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};t.hoveredNode&&(t.emit("leaveNode",C(C({},s),{},{node:t.hoveredNode})),t.scheduleHighlightedNodesRender()),t.settings.enableEdgeEvents&&t.hoveredEdge&&(t.emit("leaveEdge",C(C({},s),{},{edge:t.hoveredEdge})),t.scheduleHighlightedNodesRender()),t.emit("leaveStage",C({},s))},this.activeListeners.handleEnter=function(o){var a=Me(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};t.emit("enterStage",C({},s))};var r=function(a){return function(s){var u=Me(s),h={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},d=t.getNodeAtPosition(u);if(d)return t.emit("".concat(a,"Node"),C(C({},h),{},{node:d}));if(t.settings.enableEdgeEvents){var c=t.getEdgeAtPoint(u.x,u.y);if(c)return t.emit("".concat(a,"Edge"),C(C({},h),{},{edge:c}))}return t.emit("".concat(a,"Stage"),h)}};return this.activeListeners.handleClick=r("click"),this.activeListeners.handleRightClick=r("rightClick"),this.activeListeners.handleDoubleClick=r("doubleClick"),this.activeListeners.handleWheel=r("wheel"),this.activeListeners.handleDown=r("down"),this.activeListeners.handleUp=r("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var t=this,r=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;t.graph.forEachNode(function(d){return t.updateNode(d)});var h=!u||u.some(function(d){return o.has(d)});t.refresh({partialGraph:{nodes:r.nodes()},skipIndexation:!h,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,u=(s=a.hints)===null||s===void 0?void 0:s.attributes;t.graph.forEachEdge(function(d){return t.updateEdge(d)});var h=u&&["zIndex","type"].some(function(d){return u==null?void 0:u.includes(d)});t.refresh({partialGraph:{edges:r.edges()},skipIndexation:!h,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;t.addNode(s),t.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;t.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;t.removeNode(s),t.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;t.addEdge(s),t.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;t.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;t.removeEdge(s),t.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){t.clearEdgeState(),t.clearEdgeIndices(),t.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){t.clearEdgeState(),t.clearNodeState(),t.clearEdgeIndices(),t.clearNodeIndices(),t.refresh({schedule:!0})},r.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var t=this.graph;t.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),t.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),t.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),t.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),t.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),t.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),t.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),t.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),t.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),t.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(t,r){var o=ni(this.webGLContexts.edges,this.frameBuffers.edges,t,r,this.pixelRatio,this.pickingDownSizingRatio),a=ri.apply(void 0,bi(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var t=this;this.emit("beforeProcess");var r=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=ca(this.graph),!this.settings.autoRescale){var s=a.width,u=a.height,h=this.nodeExtent,d=h.x,c=h.y;this.nodeExtent={x:[(d[0]+d[1])/2-s/2,(d[0]+d[1])/2+s/2],y:[(c[0]+c[1])/2-u/2,(c[0]+c[1])/2+u/2]}}this.normalizationFunction=vi(this.customBBox||this.nodeExtent);var l=new yi,f=Be(l.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var y={},w={},_={},k={},p=1,v=r.nodes(),m=0,A=v.length;m1&&arguments[1]!==void 0?arguments[1]:{},o=r.tolerance,a=o===void 0?0:o,s=r.boundaries,u=C({},t),h=s||this.nodeExtent,d=Oe(h.x,2),c=d[0],l=d[1],f=Oe(h.y,2),y=f[0],w=f[1],_=[this.graphToViewport({x:c,y},{cameraState:t}),this.graphToViewport({x:l,y},{cameraState:t}),this.graphToViewport({x:c,y:w},{cameraState:t}),this.graphToViewport({x:l,y:w},{cameraState:t})],k=1/0,p=-1/0,v=1/0,m=-1/0;_.forEach(function(P){var j=P.x,ae=P.y;k=Math.min(k,j),p=Math.max(p,j),v=Math.min(v,ae),m=Math.max(m,ae)});var A=p-k,L=m-v,T=this.getDimensions(),S=T.width,g=T.height,z=0,$=0;if(A>=S?pa&&(z=k-a):p>S+a?z=p-(S+a):k<-a&&(z=k+a),L>=g?ma&&($=v-a):m>g+a?$=m-(g+a):v<-a&&($=v+a),z||$){var O=this.viewportToFramedGraph({x:0,y:0},{cameraState:t}),J=this.viewportToFramedGraph({x:z,y:$},{cameraState:t});z=J.x-O.x,$=J.y-O.y,u.x+=z,u.y+=$}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var t=this.camera.getState(),r=this.labelGrid.getLabelsToDisplay(t.ratio,this.settings.labelDensity);mi(r,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=r.length;athis.width+_i||l<-Ti||l>this.height+Ti)){this.displayedNodeLabels.add(u);var y=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[h.type],_=(w==null?void 0:w.drawLabel)||y;_(o,C(C({key:u},h),{},{size:f,x:c,y:l}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var t=this.canvasContexts.edgeLabels;t.clearRect(0,0,this.width,this.height);var r=La({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});mi(r,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=r.length;athis.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(t){this.addNode(t);var r=this.nodeDataCache[t];this.normalizationFunction.applyTo(r)}},{key:"removeNode",value:function(t){delete this.nodeDataCache[t],delete this.nodeProgramIndex[t],this.highlightedNodes.delete(t),this.hoveredNode===t&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(t)}},{key:"addEdge",value:function(t){var r=Object.assign({},this.graph.getEdgeAttributes(t));this.settings.edgeReducer&&(r=this.settings.edgeReducer(t,r));var o=xa(this.settings,t,r);this.edgeDataCache[t]=o,this.edgesWithForcedLabels.delete(t),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(t),this.settings.zIndex&&(o.zIndexthis.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(t){this.addEdge(t)}},{key:"removeEdge",value:function(t){delete this.edgeDataCache[t],delete this.edgeProgramIndex[t],this.hoveredEdge===t&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(t)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Ei,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(t,r,o){var a=this.nodeDataCache[t],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(r,o,a),this.nodeProgramIndex[t]=o}},{key:"addEdgeToProgram",value:function(t,r,o){var a=this.edgeDataCache[t],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var u=this.graph.extremities(t),h=this.nodeDataCache[u[0]],d=this.nodeDataCache[u[1]];s.process(r,o,h,d,a),this.edgeProgramIndex[t]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var t=this.settings,r=t.stagePadding,o=t.autoRescale;return o&&r||0}},{key:"createLayer",value:function(t,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[t])throw new Error('Sigma: a layer named "'.concat(t,'" already exists'));var a=fa(r,{position:"absolute"},{class:"sigma-".concat(t)});return o.style&&Object.assign(a.style,o.style),this.elements[t]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(t,"canvas",r)}},{key:"createCanvasContext",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(t,r),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[t]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=(r==null?void 0:r.canvas)||this.createCanvas(t,r);r.hidden&&o.remove();var a=C({preserveDrawingBuffer:!1,antialias:!1},r),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var u=s;if(this.webGLContexts[t]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),r.picking){this.pickingLayers.add(t);var h=u.createFramebuffer();if(!h)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(t));this.frameBuffers[t]=h}return u}},{key:"killLayer",value:function(t){var r=this.elements[t];if(!r)throw new Error("Sigma: cannot kill layer ".concat(t,", which does not exist"));if(this.webGLContexts[t]){var o,a=this.webGLContexts[t];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[t]}else this.canvasContexts[t]&&delete this.canvasContexts[t];return r.remove(),delete this.elements[t],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(t){this.unbindCameraHandlers(),this.camera=t,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(t){t!==this.graph&&(this.hoveredNode&&!t.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!t.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=t,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var t=this.customBBox||this.nodeExtent;return{width:t.x[1]-t.x[0]||1,height:t.y[1]-t.y[0]||1}}},{key:"getNodeDisplayData",value:function(t){var r=this.nodeDataCache[t];return r?Object.assign({},r):void 0}},{key:"getEdgeDisplayData",value:function(t){var r=this.edgeDataCache[t];return r?Object.assign({},r):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return C({},this.settings)}},{key:"getSetting",value:function(t){return this.settings[t]}},{key:"setSetting",value:function(t,r){var o=C({},this.settings);return this.settings[t]=r,Tt(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(t,r){return this.setSetting(t,r(this.settings[t])),this}},{key:"setSettings",value:function(t){var r=C({},this.settings);return this.settings=C(C({},this.settings),t),Tt(this.settings),this.handleSettingsUpdate(r),this.scheduleRefresh(),this}},{key:"resize",value:function(t){var r=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=gi(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!t&&r===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var h in this.webGLContexts){this.elements[h].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[h].setAttribute("height",this.height*this.pixelRatio+"px");var d=this.webGLContexts[h];if(d.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(h)){var c=this.textures[h];c&&d.deleteTexture(c)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(t){var r=this,o=(t==null?void 0:t.skipIndexation)!==void 0?t==null?void 0:t.skipIndexation:!1,a=(t==null?void 0:t.schedule)!==void 0?t.schedule:!1,s=!t||!t.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(m){return r.addNode(m)}),this.graph.forEachEdge(function(m){return r.addEdge(m)});else{for(var u,h,d=((u=t.partialGraph)===null||u===void 0?void 0:u.nodes)||[],c=0,l=(d==null?void 0:d.length)||0;c1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!!r.graphDimensions,a=r.matrix?r.matrix:o?Be(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding()):this.matrix,s=Gt(a,t);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!r.graphDimensions,a=r.matrix?r.matrix:o?Be(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding(),!0):this.invMatrix,s=Gt(a,{x:t.x/this.width*2-1,y:1-t.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(t,r))}},{key:"graphToViewport",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(t),r)}},{key:"getGraphToViewportRatio",value:function(){var t={x:0,y:0},r={x:1,y:1},o=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),a=this.graphToViewport(t),s=this.graphToViewport(r),u=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(t){return this.customBBox=t,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var t=this.container;t.firstChild;)t.removeChild(t.firstChild);for(var r in this.nodePrograms)this.nodePrograms[r].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return t/this.settings.zoomToSizeRatioFunction(r)*(this.getSetting("itemSizesReference")==="positions"?r*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var t={};for(var r in this.elements)this.elements[r]instanceof HTMLCanvasElement&&(t[r]=this.elements[r]);return t}}])}($t),Fa=Ga,ht={};function Na(n){return typeof n!="number"||isNaN(n)?1:n}function Pa(n,i){var e={},t=function(a){return typeof a>"u"?i:a};typeof i=="function"&&(t=i);var r=function(a){return t(a[n])},o=function(){return t(void 0)};return typeof n=="string"?(e.fromAttributes=r,e.fromGraph=function(a,s){return r(a.getNodeAttributes(s))},e.fromEntry=function(a,s){return r(s)}):typeof n=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},e.fromGraph=function(a,s){return t(n(s,a.getNodeAttributes(s)))},e.fromEntry=function(a,s){return t(n(a,s))}):(e.fromAttributes=o,e.fromGraph=o,e.fromEntry=o),e}function mr(n,i){var e={},t=function(a){return typeof a>"u"?i:a};typeof i=="function"&&(t=i);var r=function(a){return t(a[n])},o=function(){return t(void 0)};return typeof n=="string"?(e.fromAttributes=r,e.fromGraph=function(a,s){return r(a.getEdgeAttributes(s))},e.fromEntry=function(a,s){return r(s)},e.fromPartialEntry=e.fromEntry,e.fromMinimalEntry=e.fromEntry):typeof n=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},e.fromGraph=function(a,s){var u=a.extremities(s);return t(n(s,a.getEdgeAttributes(s),u[0],u[1],a.getNodeAttributes(u[0]),a.getNodeAttributes(u[1]),a.isUndirected(s)))},e.fromEntry=function(a,s,u,h,d,c,l){return t(n(a,s,u,h,d,c,l))},e.fromPartialEntry=function(a,s,u,h){return t(n(a,s,u,h))},e.fromMinimalEntry=function(a,s){return t(n(a,s))}):(e.fromAttributes=o,e.fromGraph=o,e.fromEntry=o,e.fromMinimalEntry=o),e}ht.createNodeValueGetter=Pa;ht.createEdgeValueGetter=mr;ht.createEdgeWeightGetter=function(n){return mr(n,Na)};var H=0,U=1,x=2,G=3,Ee=4,_e=5,F=6,Ai=7,it=8,Si=9,Ia=0,za=1,Oa=2,V=0,ue=1,Q=2,Fe=3,ke=4,B=5,te=6,ve=7,me=8,Ri=3,fe=10,Ua=3,Y=9,St=10,$a=function(i,e,t){var r,o,a,s,u,h,d,c,l,f,y=e.length,w=t.length,_=i.adjustSizes,k=i.barnesHutTheta*i.barnesHutTheta,p,v,m,A,L,T,S,g=[];for(a=0;ace?(O-=(we-ce)/2,J=O+we):(z-=(ce-we)/2,$=z+ce),g[0+V]=-1,g[0+ue]=(z+$)/2,g[0+Q]=(O+J)/2,g[0+Fe]=Math.max($-z,J-O),g[0+ke]=-1,g[0+B]=-1,g[0+te]=0,g[0+ve]=0,g[0+me]=0,r=1,a=0;a=0){e[a+H]=0)if(T=Math.pow(e[a+H]-g[o+ve],2)+Math.pow(e[a+U]-g[o+me],2),f=g[o+Fe],4*f*f/T0?(S=v*e[a+F]*g[o+te]/T,e[a+x]+=m*S,e[a+G]+=A*S):T<0&&(S=-v*e[a+F]*g[o+te]/Math.sqrt(T),e[a+x]+=m*S,e[a+G]+=A*S):T>0&&(S=v*e[a+F]*g[o+te]/T,e[a+x]+=m*S,e[a+G]+=A*S),o=g[o+ke],o<0)break;continue}else{o=g[o+B];continue}else{if(h=g[o+V],h>=0&&h!==a&&(m=e[a+H]-e[h+H],A=e[a+U]-e[h+U],T=m*m+A*A,_===!0?T>0?(S=v*e[a+F]*e[h+F]/T,e[a+x]+=m*S,e[a+G]+=A*S):T<0&&(S=-v*e[a+F]*e[h+F]/Math.sqrt(T),e[a+x]+=m*S,e[a+G]+=A*S):T>0&&(S=v*e[a+F]*e[h+F]/T,e[a+x]+=m*S,e[a+G]+=A*S)),o=g[o+ke],o<0)break;continue}else for(v=i.scalingRatio,s=0;s0?(S=v*e[s+F]*e[u+F]/T/T,e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S):T<0&&(S=100*v*e[s+F]*e[u+F],e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S)):(T=Math.sqrt(m*m+A*A),T>0&&(S=v*e[s+F]*e[u+F]/T/T,e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S));for(l=i.gravity/i.scalingRatio,v=i.scalingRatio,a=0;a0&&(S=v*e[a+F]*l):T>0&&(S=v*e[a+F]*l/T),e[a+x]-=m*S,e[a+G]-=A*S;for(v=1*(i.outboundAttractionDistribution?p:1),d=0;d0&&(S=-v*L*Math.log(1+T)/T/e[s+F]):T>0&&(S=-v*L*Math.log(1+T)/T):i.outboundAttractionDistribution?T>0&&(S=-v*L/e[s+F]):T>0&&(S=-v*L)):(T=Math.sqrt(Math.pow(m,2)+Math.pow(A,2)),i.linLogMode?i.outboundAttractionDistribution?T>0&&(S=-v*L*Math.log(1+T)/T/e[s+F]):T>0&&(S=-v*L*Math.log(1+T)/T):i.outboundAttractionDistribution?(T=1,S=-v*L/e[s+F]):(T=1,S=-v*L)),T>0&&(e[s+x]+=m*S,e[s+G]+=A*S,e[u+x]-=m*S,e[u+G]-=A*S);var se,ee,ie,le,X,Ne;if(_===!0)for(a=0;aSt&&(e[a+x]=e[a+x]*St/se,e[a+G]=e[a+G]*St/se),ee=e[a+F]*Math.sqrt((e[a+Ee]-e[a+x])*(e[a+Ee]-e[a+x])+(e[a+_e]-e[a+G])*(e[a+_e]-e[a+G])),ie=Math.sqrt((e[a+Ee]+e[a+x])*(e[a+Ee]+e[a+x])+(e[a+_e]+e[a+G])*(e[a+_e]+e[a+G]))/2,le=.1*Math.log(1+ie)/(1+Math.sqrt(ee)),X=e[a+H]+e[a+x]*(le/i.slowDown),e[a+H]=X,Ne=e[a+U]+e[a+G]*(le/i.slowDown),e[a+U]=Ne);else for(a=0;a=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in n&&typeof n.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in n&&!(typeof n.gravity=="number"&&n.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in n&&!(typeof n.slowDown=="number"||n.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in n&&typeof n.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in n&&!(typeof n.barnesHutTheta=="number"&&n.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};De.graphToByteArrays=function(n,i){var e=n.order,t=n.size,r={},o,a=new Float32Array(e*Ve),s=new Float32Array(t*Ci);return o=0,n.forEachNode(function(u,h){r[u]=o,a[o]=h.x,a[o+1]=h.y,a[o+2]=0,a[o+3]=0,a[o+4]=0,a[o+5]=0,a[o+6]=1,a[o+7]=1,a[o+8]=h.size||1,a[o+9]=h.fixed?1:0,o+=Ve}),o=0,n.forEachEdge(function(u,h,d,c,l,f,y){var w=r[d],_=r[c],k=i(u,h,d,c,l,f,y);a[w+6]+=k,a[_+6]+=k,s[o]=w,s[o+1]=_,s[o+2]=k,o+=Ci}),{nodes:a,edges:s}};De.assignLayoutChanges=function(n,i,e){var t=0;n.updateEachNodeAttributes(function(r,o){return o.x=i[t],o.y=i[t+1],t+=Ve,e?e(r,o):o})};De.readGraphPositions=function(n,i){var e=0;n.forEachNode(function(t,r){i[e]=r.x,i[e+1]=r.y,e+=Ve})};De.collectLayoutChanges=function(n,i,e){for(var t=n.nodes(),r={},o=0,a=0,s=i.length;o2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(i)}}var Ht=yr.bind(null,!1);Ht.assign=yr.bind(null,!0);Ht.inferSettings=Va;var qa=Ht;const Ya=qe(qa);var Ke={},br=st,Ka=br.ARRAY_BUFFER_SUPPORT,Za=br.SYMBOL_SUPPORT,Xa=function(i,e){var t,r,o,a,s;if(!i)throw new Error("obliterator/forEach: invalid iterable.");if(typeof e!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(i)||Ka&&ArrayBuffer.isView(i)||typeof i=="string"||i.toString()==="[object Arguments]"){for(o=0,a=i.length;o 4294967295 is not supported.")},n.getSignedPointerArray=function(u){var h=u-1;return h<=r?Int8Array:h<=o?Int16Array:h<=a?Int32Array:Float64Array},n.getNumberType=function(u){return u===(u|0)?Math.sign(u)===-1?u<=127&&u>=-128?Int8Array:u<=32767&&u>=-32768?Int16Array:Int32Array:u<=255?Uint8Array:u<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};n.getMinimalRepresentation=function(u,h){var d=null,c=0,l,f,y,w,_;for(w=0,_=u.length;w<_;w++)y=h?h(u[w]):u[w],f=n.getNumberType(y),l=s[f.name],l>c&&(c=l,d=f);return d},n.isTypedArray=function(u){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(u)},n.concat=function(){var u=0,h,d,c;for(h=0,c=arguments.length;h=this.capacity&&(i-=this.capacity),this.items[i]=n,++this.size};M.prototype.unshift=function(n){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var i=this.start-1;return this.start===0&&(i=this.capacity-1),this.items[i]=n,this.start=i,++this.size};M.prototype.pop=function(){if(this.size!==0){this.size--;var n=this.start+this.size;return n>=this.capacity&&(n-=this.capacity),this.items[n]}};M.prototype.shift=function(){if(this.size!==0){var n=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[n]}};M.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]};M.prototype.peekLast=function(){if(this.size!==0){var n=this.start+this.size-1;return n>=this.capacity&&(n-=this.capacity),this.items[n]}};M.prototype.get=function(n){if(!(this.size===0||n>=this.capacity))return n=this.start+n,n>=this.capacity&&(n-=this.capacity),this.items[n]};M.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var e=this.capacity,t=this.size,r=this.start,o=0;o=e)return{done:!0};var o=n[t];return t++,r++,t===i&&(t=0),{value:o,done:!1}})};M.prototype.entries=function(){var n=this.items,i=this.capacity,e=this.size,t=this.start,r=0;return new Tr(function(){if(r>=e)return{done:!0};var o=n[t];return t++,t===i&&(t=0),{value:[r++,o],done:!1}})};typeof Symbol<"u"&&(M.prototype[Symbol.iterator]=M.prototype.values);M.prototype.inspect=function(){var n=this.toArray();return n.type=this.ArrayClass.name,n.capacity=this.capacity,Object.defineProperty(n,"constructor",{value:M,enumerable:!1}),n};typeof Symbol<"u"&&(M.prototype[Symbol.for("nodejs.util.inspect.custom")]=M.prototype.inspect);M.from=function(n,i,e){if(arguments.length<3&&(e=Rt.guessLength(n),typeof e!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var t=new M(i,e);if(Rt.isArrayLike(n)){var r,o;for(r=0,o=n.length;re.add(r)),n.forEachNeighbor(i,r=>e.add(r)),e.add(i);const t=[];n.forEachNode(r=>{e.has(r)||t.push(r)}),t.forEach(r=>{n.hasNode(r)&&n.dropNode(r)})}(async function(){const i=await ps(),e=new I;i.nodes.forEach(p=>{const v=Ct[p.type]||{color:"#666"},m=p.id===Le;e.addNode(p.id,{label:p.label||p.id,size:Math.log(p.size*10)+1,color:v.color,domainType:p.type,url:p.url||null,x:Math.random()-.5,y:Math.random()-.5,root:m,type:"circle"})}),i.edges.forEach(p=>{const v=cs[p.type]||{color:"#71716f88",size:1};e.addEdgeWithKey(p.id||`${p.source}->${p.target}`,p.source,p.target,{label:p.type,color:v.color,size:v.size,domainType:p.type})}),typeof Le<"u"&&Le!==null&&Le!==""&&vs(e,Le),Ya.assign(e,{iterations:1e3,settings:{barnesHutOptimize:!0,outboundAttractionDistribution:!0,strongGravityMode:!0,adjustSizes:!0}});const r=document.getElementById("sigma-container"),o=new Fa(e,r,{renderLabels:!0,nodeReducer:(p,v)=>{const m=!!v.highlight;return v.root,{...v,size:(v.size||1)*(m?fs:1)}},edgeReducer:(p,v)=>{const m=!!v.highlight;return{...v,color:m?ls:v.color,size:(v.size||1)*(m?gs:1),hidden:v.hidden}}});o.getCamera();function a(p,v){p.forEachEdge((m,A)=>{const L=p.getNodeAttribute(p.source(m),"hidden"),T=p.getNodeAttribute(p.target(m),"hidden");p.setEdgeAttribute(m,"hidden",L||T)}),v.refresh()}const s=document.getElementById("sigma-controls-list")||(()=>{const p=document.createElement("div");return p.id="sigma-controls-list",document.getElementById("sigma-node-type-controls").appendChild(p),p})(),u=new Map;e.forEachNode((p,v)=>{const m=v.domainType||"unknown";u.has(m)||u.set(m,{key:m,color:Ct[m]&&Ct[m].color||"#666"})});const h=Array.from(u.values()).sort((p,v)=>{const m=p.key.toString().toLowerCase(),A=v.key.toString().toLowerCase();return mA?1:0}),d=p=>p.charAt(0).toUpperCase()+p.slice(1);h.forEach(p=>{const v=p.key,m=`toggle-${v}`,A=document.createElement("div");A.style.marginBottom="2px";const L=document.createElement("input");L.type="checkbox",L.id=m,L.checked=!0,L.style.marginRight="6px";const T=p.color,S=document.createElement("span");S.style.display="inline-block",S.style.width="12px",S.style.height="12px",S.style.borderRadius="50%",S.style.backgroundColor=T,S.style.marginRight="8px",S.style.verticalAlign="middle";const g=document.createElement("label");g.htmlFor=m,g.textContent=d(v),g.style.verticalAlign="middle",A.appendChild(L),A.appendChild(S),A.appendChild(g),s.appendChild(A),L.addEventListener("change",()=>{const z=!L.checked;e.forEachNode(($,O)=>{(O.domainType||"unknown")===v&&e.setNodeAttribute($,"hidden",z)}),a(e,o)})});let c=null,l=0;const f=400,y=4e3;let w=null;function _(){c&&(e.forEachNode(p=>e.removeNodeAttribute(p,"selected")),e.forEachEdge(p=>e.removeEdgeAttribute(p,"selected")),c=null,o.refresh(),w&&(clearTimeout(w),w=null))}function k(p){c=p,e.forEachNode(v=>e.setNodeAttribute(v,"selected",v===p)),e.forEachEdge(v=>{const m=e.source(v),A=e.target(v),L=m===p||A===p;e.setEdgeAttribute(v,"selected",L),L&&(e.setNodeAttribute(m,"selected",!0),e.setNodeAttribute(A,"selected",!0))}),o.refresh(),w&&clearTimeout(w),w=setTimeout(_,y)}a(e,o),o.on("downNode",({node:p,event:v})=>{const m=Date.now(),A=e.getNodeAttribute(p,"url");if(c===p){A?window.location.href=A:k(p),l=0;return}if(m-l{e.forEachNode(v=>e.setNodeAttribute(v,"highlight",v===p)),e.forEachEdge((v,m)=>{const A=e.source(v),L=e.target(v),T=A===p||L===p;e.setEdgeAttribute(v,"highlight",T),T&&(e.setNodeAttribute(A,"highlight",!0),e.setNodeAttribute(L,"highlight",!0))}),o.refresh()}),o.on("leaveNode",()=>{e.forEachNode(p=>e.removeNodeAttribute(p,"highlight")),e.forEachEdge(p=>e.removeEdgeAttribute(p,"highlight")),o.refresh()}),o.getContainer().addEventListener("pointerdown",p=>{p.target===o.getContainer()&&_()}),Le&&e.hasNode(Le)&&o.emit("enterNode",{node:Le})})();