www-from-model/static/graph.js
Michael Hanke 585bc90d79
All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 30s
chore: update graph visualization logic
2026-03-07 10:57:19 +01:00

312 lines
170 KiB (Stored with Git Annex)
JavaScript

(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 We(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Rt={exports:{}},Ge=typeof Reflect=="object"?Reflect:null,Ot=Ge&&typeof Ge.apply=="function"?Ge.apply:function(i,e,t){return Function.prototype.apply.call(i,e,t)},Qe;Ge&&typeof Ge.ownKeys=="function"?Qe=Ge.ownKeys:Object.getOwnPropertySymbols?Qe=function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:Qe=function(i){return Object.getOwnPropertyNames(i)};function dr(n){console&&console.warn&&console.warn(n)}var bi=Number.isNaN||function(i){return i!==i};function P(){P.init.call(this)}Rt.exports=P;Rt.exports.once=gr;P.EventEmitter=P;P.prototype._events=void 0;P.prototype._eventsCount=0;P.prototype._maxListeners=void 0;var $t=10;function tt(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(P,"defaultMaxListeners",{enumerable:!0,get:function(){return $t},set:function(n){if(typeof n!="number"||n<0||bi(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");$t=n}});P.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};P.prototype.setMaxListeners=function(i){if(typeof i!="number"||i<0||bi(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 wi(n){return n._maxListeners===void 0?P.defaultMaxListeners:n._maxListeners}P.prototype.getMaxListeners=function(){return wi(this)};P.prototype.emit=function(i){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);var r=i==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var a;if(e.length>0&&(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")Ot(u,this,e);else for(var h=u.length,d=Ai(u,h),t=0;t<h;++t)Ot(d[t],this,e);return!0};function Ei(n,i,e,t){var r,o,a;if(tt(e),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",i,e.listener?e.listener:e),o=n._events),a=o[i]),a===void 0)a=o[i]=e,++n._eventsCount;else if(typeof a=="function"?a=o[i]=t?[e,a]:[a,e]:t?a.unshift(e):a.push(e),r=wi(n),r>0&&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,dr(s)}return n}P.prototype.addListener=function(i,e){return Ei(this,i,e,!1)};P.prototype.on=P.prototype.addListener;P.prototype.prependListener=function(i,e){return Ei(this,i,e,!0)};function lr(){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 _i(n,i,e){var t={fired:!1,wrapFn:void 0,target:n,type:i,listener:e},r=lr.bind(t);return r.listener=e,t.wrapFn=r,r}P.prototype.once=function(i,e){return tt(e),this.on(i,_i(this,i,e)),this};P.prototype.prependOnceListener=function(i,e){return tt(e),this.prependListener(i,_i(this,i,e)),this};P.prototype.removeListener=function(i,e){var t,r,o,a,s;if(tt(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};P.prototype.off=P.prototype.removeListener;P.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<o.length;++r)a=o[r],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=t[i],typeof e=="function")this.removeListener(i,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(i,e[r]);return this};function Ti(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?fr(r):Ai(r,r.length)}P.prototype.listeners=function(i){return Ti(this,i,!0)};P.prototype.rawListeners=function(i){return Ti(this,i,!1)};P.listenerCount=function(n,i){return typeof n.listenerCount=="function"?n.listenerCount(i):Si.call(n,i)};P.prototype.listenerCount=Si;function Si(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}P.prototype.eventNames=function(){return this._eventsCount>0?Qe(this._events):[]};function Ai(n,i){for(var e=new Array(i),t=0;t<i;++t)e[t]=n[t];return e}function cr(n,i){for(;i+1<n.length;i++)n[i]=n[i+1];n.pop()}function fr(n){for(var i=new Array(n.length),e=0;e<i.length;++e)i[e]=n[e].listener||n[e];return i}function gr(n,i){return new Promise(function(e,t){function r(a){n.removeListener(i,o),t(a)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),e([].slice.call(arguments))}Ri(n,i,o,{once:!0}),i!=="error"&&pr(n,r,{once:!0})})}function pr(n,i,e){typeof n.on=="function"&&Ri(n,"error",i,e)}function Ri(n,i,e,t){if(typeof n.on=="function")t.once?n.once(i,e):n.on(i,e);else if(typeof n.addEventListener=="function")n.addEventListener(i,function r(o){t.once&&n.removeEventListener(i,r),e(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var ki=Rt.exports;function me(n){if(typeof n!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=n}typeof Symbol<"u"&&(me.prototype[Symbol.iterator]=function(){return this});me.of=function(){var n=arguments,i=n.length,e=0;return new me(function(){return e>=i?{done:!0}:{done:!1,value:n[e++]}})};me.empty=function(){var n=new me(function(){return{done:!0}});return n};me.fromSequence=function(n){var i=0,e=n.length;return new me(function(){return i>=e?{done:!0}:{done:!1,value:n[i++]}})};me.is=function(n){return n instanceof me?!0:typeof n=="object"&&n!==null&&typeof n.next=="function"};var kt=me;const ne=We(kt);var Ct={};Ct.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u";Ct.SYMBOL_SUPPORT=typeof Symbol<"u";var vr=kt,Ci=Ct,mr=Ci.ARRAY_BUFFER_SUPPORT,yr=Ci.SYMBOL_SUPPORT;function br(n){return typeof n=="string"||Array.isArray(n)||mr&&ArrayBuffer.isView(n)?vr.fromSequence(n):typeof n!="object"||n===null?null:yr&&typeof n[Symbol.iterator]=="function"?n[Symbol.iterator]():typeof n.next=="function"?n:null}var Li=function(i){var e=br(i);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},wr=Li,Er=function(i,e){for(var t=arguments.length>1?e:1/0,r=t!==1/0?new Array(t):[],o,a=0,s=wr(i);;){if(a===t)return r;if(o=s.next(),o.done)return a!==e&&(r.length=a),r;r[a++]=o.value}};const Lt=We(Er);var _r=kt,Tr=Li,Sr=function(){var i=arguments,e=null,t=-1;return new _r(function(){var o=null;do{if(e===null){if(t++,t>=i.length)return{done:!0};e=Tr(i[t])}if(o=e.next(),o.done===!0){e=null;continue}break}while(!0);return o})};const Se=We(Sr);function Ar(){const n=arguments[0];for(let i=1,e=arguments.length;i<e;i++)if(arguments[i])for(const t in arguments[i])n[t]=arguments[i][t];return n}let H=Ar;typeof Object.assign=="function"&&(H=Object.assign);function ye(n,i,e,t){const r=n._nodes.get(i);let o=null;return r&&(t==="mixed"?o=r.out&&r.out[e]||r.undirected&&r.undirected[e]:t==="directed"?o=r.out&&r.out[e]:o=r.undirected&&r.undirected[e]),o}function Rr(n){return n!==null&&typeof n=="object"&&typeof n.addUndirectedEdgeWithKey=="function"&&typeof n.dropNode=="function"}function V(n){return typeof n=="object"&&n!==null&&n.constructor===Object}function Di(n){let i;for(i in n)return!1;return!0}function ie(n,i,e){Object.defineProperty(n,i,{enumerable:!1,configurable:!1,writable:!0,value:e})}function re(n,i,e){const t={enumerable:!0,configurable:!0};typeof e=="function"?t.get=e:(t.value=e,t.writable=!1),Object.defineProperty(n,i,t)}function zt(n){return!(!V(n)||n.attributes&&!Array.isArray(n.attributes))}function kr(){let n=Math.floor(Math.random()*256)&255;return()=>n++}class Dt extends Error{constructor(i){super(),this.name="GraphError",this.message=i}}class T extends Dt{constructor(i){super(i),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,T.prototype.constructor)}}class y extends Dt{constructor(i){super(i),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,y.prototype.constructor)}}class L extends Dt{constructor(i){super(i),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,L.prototype.constructor)}}function wt(n,i){this.key=n,this.attributes=i,this.clear()}wt.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 xt(n,i){this.key=n,this.attributes=i,this.clear()}xt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};xt.prototype.upgradeToMixed=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}};function Gt(n,i){this.key=n,this.attributes=i,this.clear()}Gt.prototype.clear=function(){this.undirectedDegree=0,this.undirectedSelfLoops=0,this.undirected={}};Gt.prototype.upgradeToMixed=function(){this.inDegree=0,this.outDegree=0,this.directedSelfLoops=0,this.in={},this.out={}};function xi(n,i,e,t,r){this.key=i,this.attributes=r,this.undirected=n,this.source=e,this.target=t}function Gi(n,i,e,t,r,o,a){const s=n.multi;let u="out",h="in";i&&(u=h="undirected");let d,l;if(s){if(d=o[u],l=d[r],typeof l>"u"&&(l=new Set,d[r]=l),l.add(e),t===r&&i)return;d=a[h],typeof d[t]>"u"&&(d[t]=l)}else{if(o[u][r]=e,t===r&&i)return;a[h][t]=e}}function Cr(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 c=h[s];c.size===1?(delete h[s],delete o[d][a]):c.delete(e)}else delete h[s];if(t)return;const l=o[d];delete l[a]}function Lr(n){const i=n._nodes.values();let e;for(;e=i.next(),e.done!==!0;)e.value.clear()}function Dr(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 Fi=0,Pi=1,xr=2,Ni=3;function Ae(n,i,e,t,r,o,a){let s,u,h,d;if(t=""+t,e===Fi){if(s=n._nodes.get(t),!s)throw new y(`Graph.${i}: could not find the "${t}" node in the graph.`);h=r,d=o}else if(e===Ni){if(r=""+r,u=n._edges.get(r),!u)throw new y(`Graph.${i}: could not find the "${r}" edge in the graph.`);const l=u.source.key,c=u.target.key;if(t===l)s=u.target;else if(t===c)s=u.source;else throw new y(`Graph.${i}: the "${t}" node is not attached to the "${r}" edge (${l}, ${c}).`);h=o,d=a}else{if(u=n._edges.get(t),!u)throw new y(`Graph.${i}: could not find the "${t}" edge in the graph.`);e===Pi?s=u.source:s=u.target,h=r,d=o}return[s,h,d]}function Gr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Ae(this,i,e,t,r,o);return a.attributes[s]}}function Fr(n,i,e){n.prototype[i]=function(t,r){const[o]=Ae(this,i,e,t,r);return o.attributes}}function Pr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Ae(this,i,e,t,r,o);return a.attributes.hasOwnProperty(s)}}function Nr(n,i,e){n.prototype[i]=function(t,r,o,a){const[s,u,h]=Ae(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 Ir(n,i,e){n.prototype[i]=function(t,r,o,a){const[s,u,h]=Ae(this,i,e,t,r,o,a);if(typeof h!="function")throw new T(`Graph.${i}: updater should be a function.`);const d=s.attributes,l=h(d[u]);return d[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Or(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Ae(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 $r(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Ae(this,i,e,t,r,o);if(!V(s))throw new T(`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 zr(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Ae(this,i,e,t,r,o);if(!V(s))throw new T(`Graph.${i}: provided attributes are not a plain object.`);return H(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Ur(n,i,e){n.prototype[i]=function(t,r,o){const[a,s]=Ae(this,i,e,t,r,o);if(typeof s!="function")throw new T(`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 Br=[{name:n=>`get${n}Attribute`,attacher:Gr},{name:n=>`get${n}Attributes`,attacher:Fr},{name:n=>`has${n}Attribute`,attacher:Pr},{name:n=>`set${n}Attribute`,attacher:Nr},{name:n=>`update${n}Attribute`,attacher:Ir},{name:n=>`remove${n}Attribute`,attacher:Or},{name:n=>`replace${n}Attributes`,attacher:$r},{name:n=>`merge${n}Attributes`,attacher:zr},{name:n=>`update${n}Attributes`,attacher:Ur}];function Mr(n){Br.forEach(function({name:i,attacher:e}){e(n,i("Node"),Fi),e(n,i("Source"),Pi),e(n,i("Target"),xr),e(n,i("Opposite"),Ni)})}function Hr(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new L(`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=ye(this,a,s,e),!o)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new y(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes[r]}}function Wr(n,i,e){n.prototype[i]=function(t){let r;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new L(`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=ye(this,o,a,e),!r)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&r.undirected!==(e==="undirected"))throw new y(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return r.attributes}}function jr(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new L(`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=ye(this,a,s,e),!o)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new y(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return o.attributes.hasOwnProperty(r)}}function Vr(n,i,e){n.prototype[i]=function(t,r,o){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new L(`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=ye(this,s,u,e),!a)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&a.undirected!==(e==="undirected"))throw new y(`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 Yr(n,i,e){n.prototype[i]=function(t,r,o){let a;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new L(`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=ye(this,s,u,e),!a)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(typeof o!="function")throw new T(`Graph.${i}: updater should be a function.`);if(e!=="mixed"&&a.undirected!==(e==="undirected"))throw new y(`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 Kr(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new L(`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=ye(this,a,s,e),!o)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new y(`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 Zr(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new L(`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=ye(this,a,s,e),!o)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(!V(r))throw new T(`Graph.${i}: provided attributes are not a plain object.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new y(`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 qr(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new L(`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=ye(this,a,s,e),!o)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(!V(r))throw new T(`Graph.${i}: provided attributes are not a plain object.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new y(`Graph.${i}: could not find the "${t}" ${e} edge in the graph.`);return H(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}function Xr(n,i,e){n.prototype[i]=function(t,r){let o;if(this.type!=="mixed"&&e!=="mixed"&&e!==this.type)throw new L(`Graph.${i}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new L(`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=ye(this,a,s,e),!o)throw new y(`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 y(`Graph.${i}: could not find the "${t}" edge in the graph.`);if(typeof r!="function")throw new T(`Graph.${i}: provided updater is not a function.`);if(e!=="mixed"&&o.undirected!==(e==="undirected"))throw new y(`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 Jr=[{name:n=>`get${n}Attribute`,attacher:Hr},{name:n=>`get${n}Attributes`,attacher:Wr},{name:n=>`has${n}Attribute`,attacher:jr},{name:n=>`set${n}Attribute`,attacher:Vr},{name:n=>`update${n}Attribute`,attacher:Yr},{name:n=>`remove${n}Attribute`,attacher:Kr},{name:n=>`replace${n}Attributes`,attacher:Zr},{name:n=>`merge${n}Attributes`,attacher:qr},{name:n=>`update${n}Attributes`,attacher:Xr}];function Qr(n){Jr.forEach(function({name:i,attacher:e}){e(n,i("Edge"),"mixed"),e(n,i("DirectedEdge"),"directed"),e(n,i("UndirectedEdge"),"undirected")})}const en=[{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 tn(n,i){for(const e in i)n.push(i[e].key)}function rn(n,i){for(const e in i)i[e].forEach(t=>n.push(t.key))}function nn(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 on(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 an(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 sn(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 ot(n,i){const e=Object.keys(n),t=e.length;let r=null,o=0;return new ne(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 un(n,i,e){const t=i[e];t&&n.push(t.key)}function hn(n,i,e){const t=i[e];t&&t.forEach(r=>n.push(r.key))}function dn(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 ln(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 fn(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 at(n,i){const e=n[i];if(e instanceof Set){const t=e.values();return new ne(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 ne.of([e.key,e.attributes,e.source.key,e.target.key,e.source.attributes,e.target.attributes])}function gn(n,i){if(n.size===0)return[];if(i==="mixed"||i===n.type)return typeof Array.from=="function"?Array.from(n._edges.keys()):Lt(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 pn(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:l}=a;e(u,h,d.key,l.key,d.attributes,l.attributes,a.undirected)}}function vn(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:l,target:c}=a;if(s=e(h,d,l.key,c.key,l.attributes,c.attributes,a.undirected),s)return h}}function mn(n,i){if(n.size===0)return ne.empty();const e=i!=="mixed"&&i!==n.type,t=i==="undirected",r=n._edges.values();return new ne(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 yn(n,i,e,t){const r=[],o=n?rn:tn;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 bn(n,i,e,t,r){const o=n?on:nn;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 wn(n,i,e,t,r){const o=n?sn:an;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 En(n,i,e){let t=ne.empty();return n!=="undirected"&&(i!=="out"&&typeof e.in<"u"&&(t=Se(t,ot(e.in))),i!=="in"&&typeof e.out<"u"&&(t=Se(t,ot(e.out,i?null:e.key)))),n!=="directed"&&typeof e.undirected<"u"&&(t=Se(t,ot(e.undirected))),t}function _n(n,i,e,t,r){const o=i?hn:un,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 Tn(n,i,e,t,r,o){const a=i?ln:dn;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 Sn(n,i,e,t,r,o){const a=i?fn: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 An(n,i,e,t){let r=ne.empty();return n!=="undirected"&&(typeof e.in<"u"&&i!=="out"&&t in e.in&&(r=Se(r,at(e.in,t))),typeof e.out<"u"&&i!=="in"&&t in e.out&&(r=Se(r,at(e.out,t)))),n!=="directed"&&typeof e.undirected<"u"&&t in e.undirected&&(r=Se(r,at(e.undirected,t))),r}function Rn(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 gn(this,t);if(arguments.length===1){o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new y(`Graph.${e}: could not find the "${o}" node in the graph.`);return yn(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 y(`Graph.${e}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new y(`Graph.${e}: could not find the "${a}" target node in the graph.`);return _n(t,this.multi,r,s,a)}throw new T(`Graph.${e}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function kn(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,l){if(!(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)){if(arguments.length===1)return l=h,pn(this,t,l);if(arguments.length===2){h=""+h,l=d;const c=this._nodes.get(h);if(typeof c>"u")throw new y(`Graph.${o}: could not find the "${h}" node in the graph.`);return bn(this.multi,t==="mixed"?this.type:t,r,c,l)}if(arguments.length===3){h=""+h,d=""+d;const c=this._nodes.get(h);if(!c)throw new y(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(d))throw new y(`Graph.${o}: could not find the "${d}" target node in the graph.`);return Tn(t,this.multi,r,c,d,l)}throw new T(`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 l;if(h.length===0){let c=0;t!=="directed"&&(c+=this.undirectedSize),t!=="undirected"&&(c+=this.directedSize),l=new Array(c);let f=0;h.push((p,m,w,k,S,b,E)=>{l[f++]=d(p,m,w,k,S,b,E)})}else l=[],h.push((c,f,p,m,w,k,S)=>{l.push(d(c,f,p,m,w,k,S))});return this[o].apply(this,h),l};const s="filter"+e[0].toUpperCase()+e.slice(1);n.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop(),l=[];return h.push((c,f,p,m,w,k,S)=>{d(c,f,p,m,w,k,S)&&l.push(c)}),this[o].apply(this,h),l};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 T(`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 T(`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,l;h.length===2?(d=h[0],l=h[1],h=[]):h.length===3?(d=h[1],l=h[2],h=[h[0]]):h.length===4&&(d=h[2],l=h[3],h=[h[0],h[1]]);let c=l;return h.push((f,p,m,w,k,S,b)=>{c=d(c,f,p,m,w,k,S,b)}),this[o].apply(this,h),c}}function Cn(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,vn(this,t,d);if(arguments.length===2){u=""+u,d=h;const l=this._nodes.get(u);if(typeof l>"u")throw new y(`Graph.${o}: could not find the "${u}" node in the graph.`);return wn(this.multi,t==="mixed"?this.type:t,r,l,d)}if(arguments.length===3){u=""+u,h=""+h;const l=this._nodes.get(u);if(!l)throw new y(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new y(`Graph.${o}: could not find the "${h}" target node in the graph.`);return Sn(t,this.multi,r,l,h,d)}throw new T(`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((l,c,f,p,m,w,k)=>h(l,c,f,p,m,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((l,c,f,p,m,w,k)=>!h(l,c,f,p,m,w,k)),!this[o].apply(this,u)}}function Ln(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 ne.empty();if(!arguments.length)return mn(this,t);if(arguments.length===1){a=""+a;const u=this._nodes.get(a);if(!u)throw new y(`Graph.${o}: could not find the "${a}" node in the graph.`);return En(t,r,u)}if(arguments.length===2){a=""+a,s=""+s;const u=this._nodes.get(a);if(!u)throw new y(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new y(`Graph.${o}: could not find the "${s}" target node in the graph.`);return An(t,r,u,s)}throw new T(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Dn(n){en.forEach(i=>{Rn(n,i),kn(n,i),Cn(n,i),Ln(n,i)})}const xn=[{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 st(n,i){if(!(typeof i>"u"))for(const e in i)n.add(e)}function Gn(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"&&st(t,e.in),i!=="in"&&st(t,e.out)),n!=="directed"&&st(t,e.undirected),Lt(t.values(),t.size)}function Ut(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 ut(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 Bt(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 ht(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 Fn(n,i,e,t){if(n!=="mixed"){if(n==="undirected")return Ut(e,e.undirected,t);if(typeof i=="string")return Ut(e,e[i],t)}const r=new Set;n!=="undirected"&&(i!=="out"&&ut(r,e,e.in,t),i!=="in"&&ut(r,e,e.out,t)),n!=="directed"&&ut(r,e,e.undirected,t)}function Pn(n,i,e,t){if(n!=="mixed"){if(n==="undirected")return Bt(e,e.undirected,t);if(typeof i=="string")return Bt(e,e[i],t)}const r=new Set;let o;if(n!=="undirected"&&(i!=="out"&&(o=ht(r,e,e.in,t),o)||i!=="in"&&(o=ht(r,e,e.out,t),o))||n!=="directed"&&(o=ht(r,e,e.undirected,t),o))return o}function Mt(n,i){const e=Object.keys(i),t=e.length;let r=0;return new ne(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 dt(n,i,e){const t=Object.keys(e),r=t.length;let o=0;return new ne(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 Nn(n,i,e){if(n!=="mixed"){if(n==="undirected")return Mt(e,e.undirected);if(typeof i=="string")return Mt(e,e[i])}let t=ne.empty();const r=new Set;return n!=="undirected"&&(i!=="out"&&(t=Se(t,dt(r,e,e.in))),i!=="in"&&(t=Se(t,dt(r,e,e.out)))),n!=="directed"&&(t=Se(t,dt(r,e,e.undirected))),t}function In(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 y(`Graph.${e}: could not find the "${o}" node in the graph.`);return Gn(t==="mixed"?this.type:t,r,a)}}function On(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 l=this._nodes.get(h);if(typeof l>"u")throw new y(`Graph.${o}: could not find the "${h}" node in the graph.`);Fn(t==="mixed"?this.type:t,r,l,d)};const a="map"+e[0].toUpperCase()+e.slice(1);n.prototype[a]=function(h,d){const l=[];return this[o](h,(c,f)=>{l.push(d(c,f))}),l};const s="filter"+e[0].toUpperCase()+e.slice(1);n.prototype[s]=function(h,d){const l=[];return this[o](h,(c,f)=>{d(c,f)&&l.push(c)}),l};const u="reduce"+e[0].toUpperCase()+e.slice(1);n.prototype[u]=function(h,d,l){if(arguments.length<3)throw new T(`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 c=l;return this[o](h,(f,p)=>{c=d(c,f,p)}),c}}function $n(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 l=this._nodes.get(h);if(typeof l>"u")throw new y(`Graph.${a}: could not find the "${h}" node in the graph.`);return Pn(t==="mixed"?this.type:t,r,l,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,(c,f)=>!d(c,f))}}function zn(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 ne.empty();a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new y(`Graph.${o}: could not find the "${a}" node in the graph.`);return Nn(t==="mixed"?this.type:t,r,s)}}function Un(n){xn.forEach(i=>{In(n,i),On(n,i),$n(n,i),zn(n,i)})}function Ve(n,i,e,t,r){const o=t._nodes.values(),a=t.type;let s,u,h,d,l,c;for(;s=o.next(),s.done!==!0;){let f=!1;if(u=s.value,a!=="undirected"){d=u.out;for(h in d)l=d[h],c=l.target,f=!0,r(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected)}if(a!=="directed"){d=u.undirected;for(h in d)i&&u.key>h||(l=d[h],c=l.target,c.key!==h&&(c=l.source),f=!0,r(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected))}e&&!f&&r(u.key,null,u.attributes,null,null,null,null)}}function Ye(n,i,e,t,r){const o=t._nodes.values(),a=t.type;let s,u,h,d,l,c,f,p;for(;s=o.next(),s.done!==!0;){let m=!1;if(u=s.value,a!=="undirected"){c=u.out;for(h in c)for(d=c[h].values();l=d.next(),l.done!==!0;)f=l.value,p=f.target,m=!0,r(u.key,p.key,u.attributes,p.attributes,f.key,f.attributes,f.undirected)}if(a!=="directed"){c=u.undirected;for(h in c)if(!(i&&u.key>h))for(d=c[h].values();l=d.next(),l.done!==!0;)f=l.value,p=f.target,p.key!==h&&(p=f.source),m=!0,r(u.key,p.key,u.attributes,p.attributes,f.key,f.attributes,f.undirected)}e&&!m&&r(u.key,null,u.attributes,null,null,null,null)}}function Ht(n,i){const e={key:n};return Di(i.attributes)||(e.attributes=H({},i.attributes)),e}function Wt(n,i){const e={key:n,source:i.source.key,target:i.target.key};return Di(i.attributes)||(e.attributes=H({},i.attributes)),i.undirected&&(e.undirected=!0),e}function Bn(n){return V(n)?"key"in n?"attributes"in n&&(!V(n.attributes)||n.attributes===null)?"invalid-attributes":null:"no-key":"not-object"}function Mn(n){return V(n)?"source"in n?"target"in n?"attributes"in n&&(!V(n.attributes)||n.attributes===null)?"invalid-attributes":"undirected"in n&&typeof n.undirected!="boolean"?"invalid-undirected":null:"no-target":"no-source":"not-object"}const Hn=kr(),Wn=new Set(["directed","undirected","mixed"]),jt=new Set(["domain","_events","_eventsCount","_maxListeners"]),jn=[{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"}],Vn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Yn(n,i,e){if(e&&!V(e))throw new T(`Graph.addNode: invalid attributes. Expecting an object but got "${e}"`);if(i=""+i,e=e||{},n._nodes.has(i))throw new L(`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 Vt(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 Ii(n,i,e,t,r,o,a,s){if(!t&&n.type==="undirected")throw new L(`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 L(`Graph.${i}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!V(s))throw new T(`Graph.${i}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!n.allowSelfLoops&&o===a)throw new L(`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 y(`Graph.${i}: source node "${o}" not found.`);if(!h)throw new y(`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 L(`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 L(`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 l=new xi(t,r,u,h,s);return n._edges.set(r,l),o===a?t?(u.undirectedSelfLoops++,n._undirectedSelfLoopCount++):(u.directedSelfLoops++,n._directedSelfLoopCount++):t?(u.undirectedDegree++,h.undirectedDegree++):(u.outDegree++,h.inDegree++),Gi(n,t,l,o,a,u,h),t?n._undirectedSize++:n._directedSize++,d.key=r,n.emit("edgeAdded",d),r}function Kn(n,i,e,t,r,o,a,s,u){if(!t&&n.type==="undirected")throw new L(`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 L(`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 T(`Graph.${i}: invalid updater function. Expecting a function but got "${s}"`)}else if(!V(s))throw new T(`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 L(`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),l=n._nodes.get(a),c,f;if(!e&&(c=n._edges.get(r),c)){if((c.source.key!==o||c.target.key!==a)&&(!t||c.source.key!==a||c.target.key!==o))throw new L(`Graph.${i}: inconsistency detected when attempting to merge the "${r}" edge with "${o}" source & "${a}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}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 S=f.attributes;f.attributes=h(S),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else H(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 p={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 L(`Graph.${i}: the "${r}" edge already exists in the graph.`);let m=!1,w=!1;return d||(d=Vt(n,o,{}),m=!0,o===a&&(l=d,w=!0)),l||(l=Vt(n,a,{}),w=!0),c=new xi(t,r,d,l,s),n._edges.set(r,c),o===a?t?(d.undirectedSelfLoops++,n._undirectedSelfLoopCount++):(d.directedSelfLoops++,n._directedSelfLoopCount++):t?(d.undirectedDegree++,l.undirectedDegree++):(d.outDegree++,l.inDegree++),Gi(n,t,c,o,a,d,l),t?n._undirectedSize++:n._directedSize++,p.key=r,n.emit("edgeAdded",p),[r,!0,m,w]}class I extends ki.EventEmitter{constructor(i){if(super(),i=H({},Vn,i),typeof i.multi!="boolean")throw new T(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${i.multi}".`);if(!Wn.has(i.type))throw new T(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${i.type}".`);if(typeof i.allowSelfLoops!="boolean")throw new T(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${i.allowSelfLoops}".`);const e=i.type==="mixed"?wt:i.type==="directed"?xt:Gt;ie(this,"NodeDataClass",e);const t=Hn();let r=0;const o=()=>{let a;do a="geid_"+t+"_"+r++;while(this._edges.has(a));return a};ie(this,"_attributes",{}),ie(this,"_nodes",new Map),ie(this,"_edges",new Map),ie(this,"_directedSize",0),ie(this,"_undirectedSize",0),ie(this,"_directedSelfLoopCount",0),ie(this,"_undirectedSelfLoopCount",0),ie(this,"_edgeKeyGenerator",o),ie(this,"_options",i),jt.forEach(a=>ie(this,a,this[a])),re(this,"order",()=>this._nodes.size),re(this,"size",()=>this._edges.size),re(this,"directedSize",()=>this._directedSize),re(this,"undirectedSize",()=>this._undirectedSize),re(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),re(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),re(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),re(this,"multi",this._options.multi),re(this,"type",this._options.type),re(this,"allowSelfLoops",this._options.allowSelfLoops),re(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 T(`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 T(`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 T(`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 L("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 y(`Graph.directedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new y(`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 L("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 y(`Graph.undirectedEdge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new y(`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 L("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 y(`Graph.edge: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(e))throw new y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`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 y(`Graph.isSelfLoop: could not find the "${i}" edge in the graph.`);return e.source===e.target}addNode(i,e){return Yn(this,i,e).key}mergeNode(i,e){if(e&&!V(e))throw new T(`Graph.mergeNode: invalid attributes. Expecting an object but got "${e}"`);i=""+i,e=e||{};let t=this._nodes.get(i);return t?(e&&(H(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 T(`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 y(`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=ye(this,s,u,this.type),!e)throw new y(`Graph.dropEdge: could not find the "${s}" -> "${u}" edge in the graph.`)}else if(i=""+i,e=this._edges.get(i),!e)throw new y(`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--),Cr(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(){Lr(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 T("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(!V(i))throw new T("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(!V(i))throw new T("Graph.mergeAttributes: provided attributes are not a plain object.");return H(this._attributes,i),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:i}),this}updateAttributes(i){if(typeof i!="function")throw new T("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 T("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!zt(e))throw new T("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 T("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!zt(e))throw new T("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 T("Graph.forEachAdjacencyEntry: expecting a callback.");this.multi?Ye(!1,!1,!1,this,i):Ve(!1,!1,!1,this,i)}forEachAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new T("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");this.multi?Ye(!1,!1,!0,this,i):Ve(!1,!1,!0,this,i)}forEachAssymetricAdjacencyEntry(i){if(typeof i!="function")throw new T("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");this.multi?Ye(!1,!0,!1,this,i):Ve(!1,!0,!1,this,i)}forEachAssymetricAdjacencyEntryWithOrphans(i){if(typeof i!="function")throw new T("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");this.multi?Ye(!1,!0,!0,this,i):Ve(!1,!0,!0,this,i)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):Lt(this._nodes.keys(),this._nodes.size)}forEachNode(i){if(typeof i!="function")throw new T("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 T("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 T("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 T("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 T("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 T("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 T("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new T("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 ne(()=>{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 y(`Graph.exportNode: could not find the "${i}" node in the graph.`);return Ht(i,e)}exportEdge(i){i=""+i;const e=this._edges.get(i);if(!e)throw new y(`Graph.exportEdge: could not find the "${i}" edge in the graph.`);return Wt(i,e)}export(){const i=new Array(this._nodes.size);let e=0;this._nodes.forEach((r,o)=>{i[e++]=Ht(o,r)});const t=new Array(this._edges.size);return e=0,this._edges.forEach((r,o)=>{t[e++]=Wt(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=Bn(i);if(t){if(t==="not-object")throw new T('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 T("Graph.importNode: no key provided.");if(t==="invalid-attributes")throw new T("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=Mn(i);if(t){if(t==="not-object")throw new T('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 T("Graph.importEdge: missing souce.");if(t==="no-target")throw new T("Graph.importEdge: missing target.");if(t==="invalid-attributes")throw new T("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if(t==="invalid-undirected")throw new T("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(Rr(i))return this.import(i.export(),e),this;if(!V(i))throw new T("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(i.attributes){if(!V(i.attributes))throw new T("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 T("Graph.import: invalid nodes. Expecting an array.");for(t=0,r=o.length;t<r;t++)this.importNode(o[t],e)}if(i.edges){if(o=i.edges,!Array.isArray(o))throw new T("Graph.import: invalid edges. Expecting an array.");for(t=0,r=o.length;t<r;t++)this.importEdge(o[t],e)}return this}nullCopy(i){const e=new I(H({},this._options,i));return e.replaceAttributes(H({},this.getAttributes())),e}emptyCopy(i){const e=this.nullCopy(i);return this._nodes.forEach((t,r)=>{const o=H({},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,Ii(i,"copy",!1,r.undirected,r.key,r.source.key,r.target.key,H({},r.attributes));return i}upgradeToMixed(){return this.type==="mixed"?this:(this._nodes.forEach(i=>i.upgradeToMixed()),this._options.type="mixed",re(this,"type",this._options.type),ie(this,"NodeDataClass",wt),this)}upgradeToMulti(){return this.multi?this:(this._options.multi=!0,re(this,"multi",!0),Dr(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,l;o.undirected&&h>d&&(l=h,h=d,d=l);const c=`(${h})${s}(${d})`;a.startsWith("geid_")?this.multi&&(typeof t[c]>"u"?t[c]=0:t[c]++,u+=`${t[c]}. `):u+=`[${a}]: `,u+=c,e[u]=o.attributes});const r={};for(const o in this)this.hasOwnProperty(o)&&!jt.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(r[o]=this[o]);return r.attributes=this._attributes,r.nodes=i,r.edges=e,ie(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(I.prototype[Symbol.for("nodejs.util.inspect.custom")]=I.prototype.inspect);jn.forEach(n=>{["add","merge","update"].forEach(i=>{const e=n.name(i),t=i==="add"?Ii:Kn;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")}})});Mr(I);Qr(I);Dn(I);Un(I);class Oi extends I{constructor(i){const e=H({type:"directed"},i);if("multi"in e&&e.multi!==!1)throw new T("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="directed")throw new T('DirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class $i extends I{constructor(i){const e=H({type:"undirected"},i);if("multi"in e&&e.multi!==!1)throw new T("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(e.type!=="undirected")throw new T('UndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class zi extends I{constructor(i){const e=H({multi:!0},i);if("multi"in e&&e.multi!==!0)throw new T("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(e)}}class Ui extends I{constructor(i){const e=H({type:"directed",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new T("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="directed")throw new T('MultiDirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}class Bi extends I{constructor(i){const e=H({type:"undirected",multi:!0},i);if("multi"in e&&e.multi!==!0)throw new T("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(e.type!=="undirected")throw new T('MultiUndirectedGraph.from: inconsistent "'+e.type+'" type in given options!');super(e)}}function Ie(n){n.from=function(i,e){const t=H({},i.options,e),r=new n(t);return r.import(i),r}}Ie(I);Ie(Oi);Ie($i);Ie(zi);Ie(Ui);Ie(Bi);I.Graph=I;I.DirectedGraph=Oi;I.UndirectedGraph=$i;I.MultiGraph=zi;I.MultiDirectedGraph=Ui;I.MultiUndirectedGraph=Bi;I.InvalidArgumentsGraphError=T;I.NotFoundGraphError=y;I.UsageGraphError=L;function Zn(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 Me(n){var i=Zn(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 Yt(n,i){for(var e=0;e<i.length;e++){var t=i[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(n,Me(t.key),t)}}function Z(n,i,e){return i&&Yt(n.prototype,i),e&&Yt(n,e),Object.defineProperty(n,"prototype",{writable:!1}),n}function Pe(n){return Pe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Pe(n)}function Mi(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Mi=function(){return!!n})()}function qn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Xn(n,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return qn(n)}function ue(n,i,e){return i=Pe(i),Xn(n,Mi()?Reflect.construct(i,e||[],Pe(n).constructor):i.apply(n,e))}function Et(n,i){return Et=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Et(n,i)}function he(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&Et(n,i)}function Jn(n){if(Array.isArray(n))return n}function Qn(n,i){var e=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(e!=null){var t,r,o,a,s=[],u=!0,h=!1;try{if(o=(e=e.call(n)).next,i===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(t=o.call(e)).done)&&(s.push(t.value),s.length!==i);u=!0);}catch(d){h=!0,r=d}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(h)throw r}}return s}}function _t(n,i){(i==null||i>n.length)&&(i=n.length);for(var e=0,t=Array(i);e<i;e++)t[e]=n[e];return t}function Hi(n,i){if(n){if(typeof n=="string")return _t(n,i);var e={}.toString.call(n).slice(8,-1);return e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set"?Array.from(n):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_t(n,i):void 0}}function eo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ne(n,i){return Jn(n)||Qn(n,i)||Hi(n,i)||eo()}var lt={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},Wi=new Int8Array(4),ct=new Int32Array(Wi.buffer,0,1),to=new Float32Array(Wi.buffer,0,1),io=/^\s*rgba?\s*\(/,ro=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function no(n){var i=0,e=0,t=0,r=1;if(n[0]==="#")n.length===4?(i=parseInt(n.charAt(1)+n.charAt(1),16),e=parseInt(n.charAt(2)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(3),16)):(i=parseInt(n.charAt(1)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(4),16),t=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(r=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(io.test(n)){var o=n.match(ro);o&&(i=+o[1],e=+o[2],t=+o[3],o[4]&&(r=+o[4]))}return{r:i,g:e,b:t,a:r}}var Fe={};for(var Ke in lt)Fe[Ke]=je(lt[Ke]),Fe[lt[Ke]]=Fe[Ke];function ji(n,i,e,t,r){return ct[0]=t<<24|e<<16|i<<8|n,ct[0]=ct[0]&4278190079,to[0]}function je(n){if(n=n.toLowerCase(),typeof Fe[n]<"u")return Fe[n];var i=no(n),e=i.r,t=i.g,r=i.b,o=i.a;o=o*255|0;var a=ji(e,t,r,o);return Fe[n]=a,a}var ft={};function Vi(n){if(typeof ft[n]<"u")return ft[n];var i=(n&16711680)>>>16,e=(n&65280)>>>8,t=n&255,r=255,o=ji(i,e,t,r);return ft[n]=o,o}function Kt(n,i,e,t){return e+(i<<8)+(n<<16)}function Zt(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=Ne(u,4),d=h[0],l=h[1],c=h[2],f=h[3];return[d,l,c,f]}function v(n,i,e){return(i=Me(i))in n?Object.defineProperty(n,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[i]=e,n}function qt(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 R(n){for(var i=1;i<arguments.length;i++){var e=arguments[i]!=null?arguments[i]:{};i%2?qt(Object(e),!0).forEach(function(t){v(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):qt(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function oo(n,i){for(;!{}.hasOwnProperty.call(n,i)&&(n=Pe(n))!==null;);return n}function Tt(){return Tt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,i,e){var t=oo(n,i);if(t){var r=Object.getOwnPropertyDescriptor(t,i);return r.get?r.get.call(arguments.length<3?n:e):r.value}},Tt.apply(null,arguments)}function Yi(n,i,e,t){var r=Tt(Pe(n.prototype),i,e);return typeof r=="function"?function(o){return r.apply(e,o)}:r}function ao(n){return n.normalized?1:n.size}function gt(n){var i=0;return n.forEach(function(e){return i+=ao(e)}),i}function Ki(n,i,e){var t=n==="VERTEX"?i.VERTEX_SHADER:i.FRAGMENT_SHADER,r=i.createShader(t);if(r===null)throw new Error("loadShader: error while creating the shader");i.shaderSource(r,e),i.compileShader(r);var o=i.getShaderParameter(r,i.COMPILE_STATUS);if(!o){var a=i.getShaderInfoLog(r);throw i.deleteShader(r),new Error(`loadShader: error while compiling the shader:
`.concat(a,`
`).concat(e))}return r}function so(n,i){return Ki("VERTEX",n,i)}function uo(n,i){return Ki("FRAGMENT",n,i)}function ho(n,i){var e=n.createProgram();if(e===null)throw new Error("loadProgram: error while creating the program.");var t,r;for(t=0,r=i.length;t<r;t++)n.attachShader(e,i[t]);n.linkProgram(e);var o=n.getProgramParameter(e,n.LINK_STATUS);if(!o)throw n.deleteProgram(e),new Error("loadProgram: error while linking the program.");return e}function Xt(n){var i=n.gl,e=n.buffer,t=n.program,r=n.vertexShader,o=n.fragmentShader;i.deleteShader(r),i.deleteShader(o),i.deleteProgram(t),i.deleteBuffer(e)}var Jt=`#define PICKING_MODE
`,lo=v(v(v(v(v(v(v(v({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),Zi=function(){function n(i,e,t){K(this,n),v(this,"array",new Float32Array),v(this,"constantArray",new Float32Array),v(this,"capacity",0),v(this,"verticesCount",0);var r=this.getDefinition();if(this.VERTICES=r.VERTICES,this.VERTEX_SHADER_SOURCE=r.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=r.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=r.UNIFORMS,this.ATTRIBUTES=r.ATTRIBUTES,this.METHOD=r.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in r?r.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in r?r.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in r,this.ATTRIBUTES_ITEMS_COUNT=gt(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=t,this.normalProgram=this.getProgramInfo("normal",i,r.VERTEX_SHADER_SOURCE,r.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=e?this.getProgramInfo("pick",i,Jt+r.VERTEX_SHADER_SOURCE,Jt+r.FRAGMENT_SHADER_SOURCE,e):null,this.isInstanced){var o=gt(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var u=0;u<s.length;u++)this.constantArray[a*o+u]=s[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return Z(n,[{key:"kill",value:function(){Xt(this.normalProgram),this.pickProgram&&(Xt(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(e,t,r,o,a){var s=this.getDefinition(),u=t.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var h=so(t,r),d=uo(t,o),l=ho(t,[h,d]),c={};s.UNIFORMS.forEach(function(m){var w=t.getUniformLocation(l,m);w&&(c[m]=w)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=t.getAttribLocation(l,m.name)});var p;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=t.getAttribLocation(l,m.name)}),p=t.createBuffer(),p===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:e,program:l,gl:t,frameBuffer:a,buffer:u,constantBuffer:p||{},uniformLocations:c,attributeLocations:f,isPicking:e==="pick",vertexShader:h,fragmentShader:d}}},{key:"bindProgram",value:function(e){var t=this,r=0,o=e.gl,a=e.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,e.constantBuffer),r=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return r+=t.bindAttribute(s,e,r,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,e.buffer),r=0,this.ATTRIBUTES.forEach(function(s){return r+=t.bindAttribute(s,e,r,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),r=0,this.ATTRIBUTES.forEach(function(s){return r+=t.bindAttribute(s,e,r)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(e){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(r){return t.unbindAttribute(r,e,!1)}),this.ATTRIBUTES.forEach(function(r){return t.unbindAttribute(r,e,!0)})):this.ATTRIBUTES.forEach(function(r){return t.unbindAttribute(r,e)})}},{key:"bindAttribute",value:function(e,t,r,o){var a=lo[e.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(e.type,'"'));var s=t.attributeLocations[e.name],u=t.gl;if(s!==-1){u.enableVertexAttribArray(s);var h=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:gt(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(s,e.size,e.type,e.normalized||!1,h,r),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(s,1);else{var d=u.getExtension("ANGLE_instanced_arrays");d&&d.vertexAttribDivisorANGLE(s,1)}}return e.size*a}},{key:"unbindAttribute",value:function(e,t,r){var o=t.attributeLocations[e.name],a=t.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&r))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(e){e!==this.capacity&&(this.capacity=e,this.verticesCount=this.VERTICES*e,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(e,t){var r=t.gl,o=t.program;r.enable(r.BLEND),r.useProgram(o),this.setUniforms(e,t),this.drawWebGL(this.METHOD,t)}},{key:"render",value:function(e){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,e.width*e.pixelRatio/e.downSizingRatio,e.height*e.pixelRatio/e.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(R(R({},e),{},{pixelRatio:e.pixelRatio/e.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,e.width*e.pixelRatio,e.height*e.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(e,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(e,t){var r=t.gl,o=t.frameBuffer;if(r.bindFramebuffer(r.FRAMEBUFFER,o),!this.isInstanced)r.drawArrays(e,0,this.verticesCount);else if(r instanceof WebGL2RenderingContext)r.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{var a=r.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}])}(),co=function(n){function i(){return K(this,i),ue(this,i,arguments)}return he(i,n),Z(i,[{key:"kill",value:function(){Yi(i,"kill",this)([])}},{key:"process",value:function(t,r,o){var a=r*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(Vi(t),a,o)}}])}(Zi),Ft=function(n){function i(){var e;K(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e=ue(this,i,[].concat(r)),v(e,"drawLabel",void 0),e}return he(i,n),Z(i,[{key:"kill",value:function(){Yi(i,"kill",this)([])}},{key:"process",value:function(t,r,o,a,s){var u=r*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var h=u+this.STRIDE;u<h;u++)this.array[u]=0;return}return this.processVisibleItem(Vi(t),u,o,a,s)}}])}(Zi);function fo(n,i){return function(){function e(t,r,o){K(this,e),v(this,"drawLabel",i),this.programs=n.map(function(a){return new a(t,r,o)})}return Z(e,[{key:"reallocate",value:function(r){this.programs.forEach(function(o){return o.reallocate(r)})}},{key:"process",value:function(r,o,a,s,u){this.programs.forEach(function(h){return h.process(r,o,a,s,u)})}},{key:"render",value:function(r){this.programs.forEach(function(o){return o.render(r)})}},{key:"kill",value:function(){this.programs.forEach(function(r){return r.kill()})}}])}()}function go(n,i,e,t,r){var o=r.edgeLabelSize,a=r.edgeLabelFont,s=r.edgeLabelWeight,u=r.edgeLabelColor.attribute?i[r.edgeLabelColor.attribute]||r.edgeLabelColor.color||"#000":r.edgeLabelColor.color,h=i.label;if(h){n.fillStyle=u,n.font="".concat(s," ").concat(o,"px ").concat(a);var d=e.size,l=t.size,c=e.x,f=e.y,p=t.x,m=t.y,w=(c+p)/2,k=(f+m)/2,S=p-c,b=m-f,E=Math.sqrt(S*S+b*b);if(!(E<d+l)){c+=S*d/E,f+=b*d/E,p-=S*l/E,m-=b*l/E,w=(c+p)/2,k=(f+m)/2,S=p-c,b=m-f,E=Math.sqrt(S*S+b*b);var C=n.measureText(h).width;if(C>E){var D="…";for(h=h+D,C=n.measureText(h).width;C>E&&h.length>1;)h=h.slice(0,-2)+D,C=n.measureText(h).width;if(h.length<4)return}var _;S>0?b>0?_=Math.acos(S/E):_=Math.asin(b/E):b>0?_=Math.acos(S/E)+Math.PI:_=Math.asin(S/E)+Math.PI/2,n.save(),n.translate(w,k),n.rotate(_),n.fillText(h,-C/2,i.size/2+o),n.restore()}}}function qi(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 po(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,l=Math.asin(h/2/d),c=Math.sqrt(Math.abs(Math.pow(d,2)-Math.pow(h/2,2)));n.beginPath(),n.moveTo(i.x+c,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+c,i.y-h/2),n.arc(i.x,i.y,d,l,-l),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,qi(n,i,e)}var vo=`
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
}
`,mo=vo,yo=`
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;
}
`,bo=yo,Xi=WebGLRenderingContext,Qt=Xi.UNSIGNED_BYTE,pt=Xi.FLOAT,wo=["u_sizeRatio","u_correctionRatio","u_matrix"],it=function(n){function i(){return K(this,i),ue(this,i,arguments)}return he(i,n),Z(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:bo,FRAGMENT_SHADER_SOURCE:mo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:wo,ATTRIBUTES:[{name:"a_position",size:2,type:pt},{name:"a_size",size:1,type:pt},{name:"a_color",size:4,type:Qt,normalized:!0},{name:"a_id",size:4,type:Qt,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:pt}],CONSTANT_DATA:[[i.ANGLE_1],[i.ANGLE_2],[i.ANGLE_3]]}}},{key:"processVisibleItem",value:function(t,r,o){var a=this.array,s=je(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);v(it,"ANGLE_1",0);v(it,"ANGLE_2",2*Math.PI/3);v(it,"ANGLE_3",4*Math.PI/3);var Eo=`
precision mediump float;
varying vec4 v_color;
void main(void) {
gl_FragColor = v_color;
}
`,_o=Eo,To=`
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;
}
`,So=To,Ji=WebGLRenderingContext,ei=Ji.UNSIGNED_BYTE,Ze=Ji.FLOAT,Ao=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Qi={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function er(n){var i=R(R({},Qi),{});return function(e){function t(){return K(this,t),ue(this,t,arguments)}return he(t,e),Z(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:So,FRAGMENT_SHADER_SOURCE:_o,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ao,ATTRIBUTES:[{name:"a_position",size:2,type:Ze},{name:"a_normal",size:2,type:Ze},{name:"a_radius",size:1,type:Ze},{name:"a_color",size:4,type:ei,normalized:!0},{name:"a_id",size:4,type:ei,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Ze}],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 l=h.size||1,c=u.size||1,f=s.x,p=s.y,m=u.x,w=u.y,k=je(h.color),S=m-f,b=w-p,E=S*S+b*b,C=0,D=0;E&&(E=1/Math.sqrt(E),C=-b*E*l,D=S*E*l);var _=this.array;_[a++]=m,_[a++]=w,_[a++]=-C,_[a++]=-D,_[a++]=c,_[a++]=k,_[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,d=u.u_sizeRatio,l=u.u_correctionRatio,c=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,p=u.u_widenessToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(d,o.sizeRatio),s.uniform1f(l,o.correctionRatio),s.uniform1f(c,o.minEdgeThickness),s.uniform1f(f,i.lengthToThicknessRatio),s.uniform1f(p,i.widenessToThicknessRatio)}}])}(Ft)}er();var Ro=`
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
}
`,tr=Ro,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;
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;
}
`,Co=ko,ir=WebGLRenderingContext,ti=ir.UNSIGNED_BYTE,Le=ir.FLOAT,Lo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Do={lengthToThicknessRatio:Qi.lengthToThicknessRatio};function rr(n){var i=R(R({},Do),{});return function(e){function t(){return K(this,t),ue(this,t,arguments)}return he(t,e),Z(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Co,FRAGMENT_SHADER_SOURCE:tr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Lo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Le},{name:"a_positionEnd",size:2,type:Le},{name:"a_normal",size:2,type:Le},{name:"a_color",size:4,type:ti,normalized:!0},{name:"a_id",size:4,type:ti,normalized:!0},{name:"a_radius",size:1,type:Le}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Le},{name:"a_normalCoef",size:1,type:Le},{name:"a_radiusCoef",size:1,type:Le}],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,l=s.x,c=s.y,f=u.x,p=u.y,m=je(h.color),w=f-l,k=p-c,S=u.size||1,b=w*w+k*k,E=0,C=0;b&&(b=1/Math.sqrt(b),E=-k*b*d,C=w*b*d);var D=this.array;D[a++]=l,D[a++]=c,D[a++]=f,D[a++]=p,D[a++]=E,D[a++]=C,D[a++]=m,D[a++]=o,D[a++]=S}},{key:"setUniforms",value:function(o,a){var s=a.gl,u=a.uniformLocations,h=u.u_matrix,d=u.u_zoomRatio,l=u.u_feather,c=u.u_pixelRatio,f=u.u_correctionRatio,p=u.u_sizeRatio,m=u.u_minEdgeThickness,w=u.u_lengthToThicknessRatio;s.uniformMatrix3fv(h,!1,o.matrix),s.uniform1f(d,o.zoomRatio),s.uniform1f(p,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(c,o.pixelRatio),s.uniform1f(l,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(w,i.lengthToThicknessRatio)}}])}(Ft)}rr();function xo(n){return fo([rr(),er()])}var Go=xo(),Fo=Go,Po=`
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;
}
`,No=Po,nr=WebGLRenderingContext,ii=nr.UNSIGNED_BYTE,Oe=nr.FLOAT,Io=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Oo=function(n){function i(){return K(this,i),ue(this,i,arguments)}return he(i,n),Z(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:No,FRAGMENT_SHADER_SOURCE:tr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Io,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Oe},{name:"a_positionEnd",size:2,type:Oe},{name:"a_normal",size:2,type:Oe},{name:"a_color",size:4,type:ii,normalized:!0},{name:"a_id",size:4,type:ii,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Oe},{name:"a_normalCoef",size:1,type:Oe}],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,l=a.x,c=a.y,f=je(s.color),p=l-h,m=c-d,w=p*p+m*m,k=0,S=0;w&&(w=1/Math.sqrt(w),k=-m*w*u,S=p*w*u);var b=this.array;b[r++]=h,b[r++]=d,b[r++]=l,b[r++]=c,b[r++]=k,b[r++]=S,b[r++]=f,b[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,l=a.u_correctionRatio,c=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,t.matrix),o.uniform1f(u,t.zoomRatio),o.uniform1f(c,t.sizeRatio),o.uniform1f(l,t.correctionRatio),o.uniform1f(d,t.pixelRatio),o.uniform1f(h,t.antiAliasingFeather),o.uniform1f(f,t.minEdgeThickness)}}])}(Ft),Pt=function(n){function i(){var e;return K(this,i),e=ue(this,i),e.rawEmitter=e,e}return he(i,n),Z(i)}(ki.EventEmitter),or=function(i){return i!==null&&typeof i=="object"&&typeof i.addUndirectedEdgeWithKey=="function"&&typeof i.dropNode=="function"&&typeof i.multi=="boolean"};const $o=We(or);var zo=function(i){return i},Uo=function(i){return i*i},Bo=function(i){return i*(2-i)},Mo=function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)},Ho=function(i){return i*i*i},Wo=function(i){return--i*i*i+1},jo=function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)},Vo={linear:zo,quadraticIn:Uo,quadraticOut:Bo,quadraticInOut:Mo,cubicIn:Ho,cubicOut:Wo,cubicInOut:jo},Yo={easing:"quadraticInOut",duration:150};function fe(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function qe(n,i,e){return n[0]=i,n[4]=typeof e=="number"?e:i,n}function ri(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 ni(n,i,e){return n[6]=i,n[7]=e,n}function Re(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],l=i[0],c=i[1],f=i[2],p=i[3],m=i[4],w=i[5],k=i[6],S=i[7],b=i[8];return n[0]=l*e+c*o+f*u,n[1]=l*t+c*a+f*h,n[2]=l*r+c*s+f*d,n[3]=p*e+m*o+w*u,n[4]=p*t+m*a+w*h,n[5]=p*r+m*s+w*d,n[6]=k*e+S*o+b*u,n[7]=k*t+S*a+b*h,n[8]=k*r+S*s+b*d,n}function St(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 Ko(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 $e(n,i,e,t,r){var o=n.angle,a=n.ratio,s=n.x,u=n.y,h=i.width,d=i.height,l=fe(),c=Math.min(h,d)-2*t,f=Ko(i,e);return r?(Re(l,ni(fe(),s,u)),Re(l,qe(fe(),a)),Re(l,ri(fe(),o)),Re(l,qe(fe(),h/c/2/f,d/c/2/f))):(Re(l,qe(fe(),2*(c/h)*f,2*(c/d)*f)),Re(l,ri(fe(),-o)),Re(l,qe(fe(),1/a)),Re(l,ni(fe(),-s,-u))),l}function Zo(n,i,e){var t=St(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 qo(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;s<i&&(i=s),s>e&&(e=s),u<t&&(t=u),u>r&&(r=u)}),{x:[i,e],y:[t,r]}}function Xo(n){if(!$o(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 Jo(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 oi(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function ai(n,i,e){return e.sort(function(t,r){var o=i(t)||0,a=i(r)||0;return o<a?-1:o>a?1:0})}function si(n){var i=Ne(n.x,2),e=i[0],t=i[1],r=Ne(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(c){return{x:.5+(c.x-u)/s,y:.5+(c.y-h)/s}};return d.applyTo=function(l){l.x=.5+(l.x-u)/s,l.y=.5+(l.y-h)/s},d.inverse=function(l){return{x:u+s*(l.x-.5),y:h+s*(l.y-.5)}},d.ratio=s,d}function At(n){"@babel/helpers - typeof";return At=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},At(n)}function ui(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 vt(n){n=n||{};for(var i=0,e=arguments.length<=1?0:arguments.length-1;i<e;i++){var t=i+1<1||arguments.length<=i+1?void 0:arguments[i+1];t&&Object.assign(n,t)}return n}var Nt={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:go,defaultDrawNodeLabel:qi,defaultDrawNodeHover:po,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Qo={circle:it},ea={arrow:Fo,line:Oo};function mt(n){if(typeof n.labelDensity!="number"||n.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var i=n.minCameraRatio,e=n.maxCameraRatio;if(typeof i=="number"&&typeof e=="number"&&e<i)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function ta(n){var i=vt({},Nt,n);return i.nodeProgramClasses=vt({},Qo,i.nodeProgramClasses),i.edgeProgramClasses=vt({},ea,i.edgeProgramClasses),i}var Xe=1.5,hi=function(n){function i(){var e;return K(this,i),e=ue(this,i),v(e,"x",.5),v(e,"y",.5),v(e,"angle",0),v(e,"ratio",1),v(e,"minRatio",null),v(e,"maxRatio",null),v(e,"enabledZooming",!0),v(e,"enabledPanning",!0),v(e,"enabledRotation",!0),v(e,"clean",null),v(e,"nextFrame",null),v(e,"previousState",null),v(e,"enabled",!0),e.previousState=e.getState(),e}return he(i,n),Z(i,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(t){return this.x===t.x&&this.y===t.y&&this.ratio===t.ratio&&this.angle===t.angle}},{key:"getPreviousState",value:function(){var t=this.previousState;return t?{x:t.x,y:t.y,angle:t.angle,ratio:t.ratio}:null}},{key:"getBoundedRatio",value:function(t){var r=t;return typeof this.minRatio=="number"&&(r=Math.max(r,this.minRatio)),typeof this.maxRatio=="number"&&(r=Math.min(r,this.maxRatio)),r}},{key:"validateState",value:function(t){var r={};return this.enabledPanning&&typeof t.x=="number"&&(r.x=t.x),this.enabledPanning&&typeof t.y=="number"&&(r.y=t.y),this.enabledZooming&&typeof t.ratio=="number"&&(r.ratio=this.getBoundedRatio(t.ratio)),this.enabledRotation&&typeof t.angle=="number"&&(r.angle=t.angle),this.clean?this.clean(R(R({},this.getState()),r)):r}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(t){if(!this.enabled)return this;this.previousState=this.getState();var r=this.validateState(t);return typeof r.x=="number"&&(this.x=r.x),typeof r.y=="number"&&(this.y=r.y),typeof r.ratio=="number"&&(this.ratio=r.ratio),typeof r.angle=="number"&&(this.angle=r.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(t){return this.setState(t(this.getState())),this}},{key:"animate",value:function(t){var r=this,o=arguments.length>1&&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=R(R({},Yo),o),u=this.validateState(t),h=typeof s.easing=="function"?s.easing:Vo[s.easing],d=Date.now(),l=this.getState(),c=function(){var p=(Date.now()-d)/s.duration;if(p>=1){r.nextFrame=null,r.setState(u),r.animationCallback&&(r.animationCallback.call(null),r.animationCallback=void 0);return}var m=h(p),w={};typeof u.x=="number"&&(w.x=l.x+(u.x-l.x)*m),typeof u.y=="number"&&(w.y=l.y+(u.y-l.y)*m),r.enabledRotation&&typeof u.angle=="number"&&(w.angle=l.angle+(u.angle-l.angle)*m),typeof u.ratio=="number"&&(w.ratio=l.ratio+(u.ratio-l.ratio)*m),r.setState(w),r.nextFrame=requestAnimationFrame(c)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(c)):c(),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||Xe)},t):this.animate({ratio:this.ratio/Xe})}},{key:"animatedUnzoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio*t}):this.animate({ratio:this.ratio*(t.factor||Xe)},t):this.animate({ratio:this.ratio*Xe})}},{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)}}])}(Pt);function ge(n,i){var e=i.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}function _e(n,i){var e=R(R({},ge(n,i)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:n});return e}function ze(n){var i="x"in n?n:R(R({},n.touches[0]||n.previousTouches[0]),{},{original:n.original,sigmaDefaultPrevented:n.sigmaDefaultPrevented,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0,i.sigmaDefaultPrevented=!0}});return i}function ia(n,i){return R(R({},_e(n,i)),{},{delta:ar(n)})}var ra=2;function et(n){for(var i=[],e=0,t=Math.min(n.length,ra);e<t;e++)i.push(n[e]);return i}function Ue(n,i,e){var t={touches:et(n.touches).map(function(r){return ge(r,e)}),previousTouches:i.map(function(r){return ge(r,e)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:n};return t}function ar(n){if(typeof n.deltaY<"u")return n.deltaY*-3/360;if(typeof n.detail<"u")return n.detail/-9;throw new Error("Captor: could not extract delta from event.")}var sr=function(n){function i(e,t){var r;return K(this,i),r=ue(this,i),r.container=e,r.renderer=t,r}return he(i,n),Z(i)}(Pt),na=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],oa=na.reduce(function(n,i){return R(R({},n),{},v({},i,Nt[i]))},{}),aa=function(n){function i(e,t){var r;return K(this,i),r=ue(this,i,[e,t]),v(r,"enabled",!0),v(r,"draggedEvents",0),v(r,"downStartTime",null),v(r,"lastMouseX",null),v(r,"lastMouseY",null),v(r,"isMouseDown",!1),v(r,"isMoving",!1),v(r,"movingTimeout",null),v(r,"startCameraState",null),v(r,"clicks",0),v(r,"doubleClickTimeout",null),v(r,"currentWheelDirection",0),v(r,"settings",oa),r.handleClick=r.handleClick.bind(r),r.handleRightClick=r.handleRightClick.bind(r),r.handleDown=r.handleDown.bind(r),r.handleUp=r.handleUp.bind(r),r.handleMove=r.handleMove.bind(r),r.handleWheel=r.handleWheel.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleEnter=r.handleEnter.bind(r),e.addEventListener("click",r.handleClick,{capture:!1}),e.addEventListener("contextmenu",r.handleRightClick,{capture:!1}),e.addEventListener("mousedown",r.handleDown,{capture:!1}),e.addEventListener("wheel",r.handleWheel,{capture:!1}),e.addEventListener("mouseleave",r.handleLeave,{capture:!1}),e.addEventListener("mouseenter",r.handleEnter,{capture:!1}),document.addEventListener("mousemove",r.handleMove,{capture:!1}),document.addEventListener("mouseup",r.handleUp,{capture:!1}),r}return he(i,n),Z(i,[{key:"kill",value:function(){var t=this.container;t.removeEventListener("click",this.handleClick),t.removeEventListener("contextmenu",this.handleRightClick),t.removeEventListener("mousedown",this.handleDown),t.removeEventListener("wheel",this.handleWheel),t.removeEventListener("mouseleave",this.handleLeave),t.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(t){var r=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(t);setTimeout(function(){r.clicks=0,r.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",_e(t,this.container))}}},{key:"handleRightClick",value:function(t){this.enabled&&this.emit("rightClick",_e(t,this.container))}},{key:"handleDoubleClick",value:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var r=_e(t,this.container);if(this.emit("doubleClick",r),!r.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(ge(t,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(t){if(this.enabled){if(t.button===0){this.startCameraState=this.renderer.getCamera().getState();var r=ge(t,this.container),o=r.x,a=r.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",_e(t,this.container))}}},{key:"handleUp",value:function(t){var r=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=ge(t,this.container),s=a.x,u=a.y,h=o.getState(),d=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:h.x+this.settings.inertiaRatio*(h.x-d.x),y:h.y+this.settings.inertiaRatio*(h.y-d.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==u)&&o.setState({x:h.x,y:h.y}),this.isMoving=!1,setTimeout(function(){var l=r.draggedEvents>0;r.draggedEvents=0,l&&r.renderer.getSetting("hideEdgesOnMove")&&r.renderer.refresh()},0),this.emit("mouseup",_e(t,this.container))}}},{key:"handleMove",value:function(t){var r=this;if(this.enabled){var o=_e(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=ge(t,this.container),u=s.x,h=s.y,d=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),l=this.renderer.viewportToFramedGraph({x:u,y:h}),c=d.x-l.x,f=d.y-l.y,p=a.getState(),m=p.x+c,w=p.y+f;a.setState({x:m,y:w}),this.lastMouseX=u,this.lastMouseY=h,t.preventDefault(),t.stopPropagation()}}}},{key:"handleLeave",value:function(t){this.emit("mouseleave",_e(t,this.container))}},{key:"handleEnter",value:function(t){this.emit("mouseenter",_e(t,this.container))}},{key:"handleWheel",value:function(t){var r=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=ar(t);if(a){var s=ia(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),l=a>0?1:-1,c=Date.now();u!==d&&(t.preventDefault(),t.stopPropagation(),!(this.currentWheelDirection===l&&this.lastWheelTriggerTime&&c-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(ge(t,this.container),d),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){r.currentWheelDirection=0}),this.currentWheelDirection=l,this.lastWheelTriggerTime=c))}}}},{key:"setSettings",value:function(t){this.settings=t}}])}(sr),sa=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],ua=sa.reduce(function(n,i){return R(R({},n),{},v({},i,Nt[i]))},{}),ha=function(n){function i(e,t){var r;return K(this,i),r=ue(this,i,[e,t]),v(r,"enabled",!0),v(r,"isMoving",!1),v(r,"hasMoved",!1),v(r,"touchMode",0),v(r,"startTouchesPositions",[]),v(r,"lastTouches",[]),v(r,"lastTap",null),v(r,"settings",ua),r.handleStart=r.handleStart.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleMove=r.handleMove.bind(r),e.addEventListener("touchstart",r.handleStart,{capture:!1}),e.addEventListener("touchcancel",r.handleLeave,{capture:!1}),document.addEventListener("touchend",r.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",r.handleMove,{capture:!1,passive:!1}),r}return he(i,n),Z(i,[{key:"kill",value:function(){var t=this.container;t.removeEventListener("touchstart",this.handleStart),t.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(t){var r=this;if(this.enabled){t.preventDefault();var o=et(t.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return ge(f,r.container)}),this.touchMode===2){var a=Ne(this.startTouchesPositions,2),s=a[0],u=s.x,h=s.y,d=a[1],l=d.x,c=d.y;this.startTouchesAngle=Math.atan2(c-h,l-u),this.startTouchesDistance=Math.sqrt(Math.pow(l-u,2)+Math.pow(c-h,2))}this.emit("touchdown",Ue(t,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(t){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(t.cancelable&&t.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(t.touches.length===1){this.handleStart(t),t.preventDefault();break}case 1:if(this.isMoving){var r=this.renderer.getCamera(),o=r.getState(),a=r.getPreviousState()||{x:0,y:0};r.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",Ue(t,this.lastTouches,this.container)),!t.touches.length){var s=ge(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],h=Math.pow(s.x-u.x,2)+Math.pow(s.y-u.y,2);if(!t.touches.length&&h<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var d=Ue(t,this.lastTouches,this.container);if(this.emit("doubletap",d),this.lastTap=null,!d.sigmaDefaultPrevented){var l=this.renderer.getCamera(),c=l.getBoundedRatio(l.getState().ratio/this.settings.doubleClickZoomingRatio);l.animate(this.renderer.getViewportZoomedState(s,c),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=Ue(t,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=et(t.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(t){var r=this;if(!(!this.enabled||!this.startTouchesPositions.length)){t.preventDefault();var o=et(t.touches),a=o.map(function(te){return ge(te,r.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var u=Ue(t,s,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(te,le){var q=r.startTouchesPositions[le];return q&&(te.x!==q.x||te.y!==q.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.isMoving=!1},this.settings.dragTimeout);var h=this.renderer.getCamera(),d=this.startCameraState,l=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var c=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=c.x,p=c.y,m=this.renderer.viewportToFramedGraph(a[0]),w=m.x,k=m.y;h.setState({x:d.x+f-w,y:d.y+p-k});break}case 2:{var S={x:.5,y:.5,angle:0,ratio:1},b=a[0],E=b.x,C=b.y,D=a[1],_=D.x,A=D.y,g=Math.atan2(A-C,_-E)-this.startTouchesAngle,$=Math.hypot(A-C,_-E)/this.startTouchesDistance,B=h.getBoundedRatio(d.ratio/$);S.ratio=B,S.angle=d.angle+g;var z=this.getDimensions(),J=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:d}),N=Math.min(z.width,z.height)-2*l,W=N/z.width,oe=N/z.height,be=B/N,de=E-N/2/W,ae=C-N/2/oe,Q=[de*Math.cos(-S.angle)-ae*Math.sin(-S.angle),ae*Math.cos(-S.angle)+de*Math.sin(-S.angle)];de=Q[0],ae=Q[1],S.x=J.x-de*be,S.y=J.y+ae*be,h.setState(S);break}}}}}},{key:"setSettings",value:function(t){this.settings=t}}])}(sr);function da(n){if(Array.isArray(n))return _t(n)}function la(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function ca(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function di(n){return da(n)||la(n)||Hi(n)||ca()}function fa(n,i){if(n==null)return{};var e={};for(var t in n)if({}.hasOwnProperty.call(n,t)){if(i.indexOf(t)!==-1)continue;e[t]=n[t]}return e}function yt(n,i){if(n==null)return{};var e,t,r=fa(n,i);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(t=0;t<o.length;t++)e=o[t],i.indexOf(e)===-1&&{}.propertyIsEnumerable.call(n,e)&&(r[e]=n[e])}return r}var li=function(){function n(i,e){K(this,n),this.key=i,this.size=e}return Z(n,null,[{key:"compare",value:function(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}])}(),ci=function(){function n(){K(this,n),v(this,"width",0),v(this,"height",0),v(this,"cellSize",0),v(this,"columns",0),v(this,"rows",0),v(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 li(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(li.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],l=0;l<Math.min(s,d.length);l++)u.push(d[l].key);return u}}])}();function ga(n){var i=n.graph,e=n.hoveredNode,t=n.highlightedNodes,r=n.displayedNodeLabels,o=[];return i.forEachEdge(function(a,s,u,h){(u===e||h===e||t.has(u)||t.has(h)||r.has(u)&&r.has(h))&&o.push(a)}),o}var fi=150,gi=50,Te=Object.prototype.hasOwnProperty;function pa(n,i,e){if(!Te.call(e,"x")||!Te.call(e,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(i,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return e.color||(e.color=n.defaultNodeColor),!e.label&&e.label!==""&&(e.label=null),e.label!==void 0&&e.label!==null?e.label=""+e.label:e.label=null,e.size||(e.size=2),Te.call(e,"hidden")||(e.hidden=!1),Te.call(e,"highlighted")||(e.highlighted=!1),Te.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=n.defaultNodeType),e.zIndex||(e.zIndex=0),e}function va(n,i,e){return e.color||(e.color=n.defaultEdgeColor),e.label||(e.label=""),e.size||(e.size=.5),Te.call(e,"hidden")||(e.hidden=!1),Te.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=n.defaultEdgeType),e.zIndex||(e.zIndex=0),e}var ma=function(n){function i(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(K(this,i),r=ue(this,i),v(r,"elements",{}),v(r,"canvasContexts",{}),v(r,"webGLContexts",{}),v(r,"pickingLayers",new Set),v(r,"textures",{}),v(r,"frameBuffers",{}),v(r,"activeListeners",{}),v(r,"labelGrid",new ci),v(r,"nodeDataCache",{}),v(r,"edgeDataCache",{}),v(r,"nodeProgramIndex",{}),v(r,"edgeProgramIndex",{}),v(r,"nodesWithForcedLabels",new Set),v(r,"edgesWithForcedLabels",new Set),v(r,"nodeExtent",{x:[0,1],y:[0,1]}),v(r,"nodeZExtent",[1/0,-1/0]),v(r,"edgeZExtent",[1/0,-1/0]),v(r,"matrix",fe()),v(r,"invMatrix",fe()),v(r,"correctionRatio",1),v(r,"customBBox",null),v(r,"normalizationFunction",si({x:[0,1],y:[0,1]})),v(r,"graphToViewportRatio",1),v(r,"itemIDsIndex",{}),v(r,"nodeIndices",{}),v(r,"edgeIndices",{}),v(r,"width",0),v(r,"height",0),v(r,"pixelRatio",oi()),v(r,"pickingDownSizingRatio",2*r.pixelRatio),v(r,"displayedNodeLabels",new Set),v(r,"displayedEdgeLabels",new Set),v(r,"highlightedNodes",new Set),v(r,"hoveredNode",null),v(r,"hoveredEdge",null),v(r,"renderFrame",null),v(r,"renderHighlightedNodesFrame",null),v(r,"needToProcess",!1),v(r,"checkEdgesEventsFrame",null),v(r,"nodePrograms",{}),v(r,"nodeHoverPrograms",{}),v(r,"edgePrograms",{}),r.settings=ta(o),mt(r.settings),Xo(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 hi,r.bindCameraHandlers(),r.mouseCaptor=new aa(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new ha(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return he(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=yt(r,[t].map(Me));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[t]){var s=this.nodeHoverPrograms,u=s[t],h=yt(s,[t].map(Me));u.kill(),this.nodePrograms=h}return this}},{key:"unregisterEdgeProgram",value:function(t){if(this.edgePrograms[t]){var r=this.edgePrograms,o=r[t],a=yt(r,[t].map(Me));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=Zt(this.webGLContexts.nodes,this.frameBuffers.nodes,r,o,this.pixelRatio,this.pickingDownSizingRatio),s=Kt.apply(void 0,di(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=ze(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",R(R({},s),{},{node:t.hoveredNode})),t.hoveredNode=u,t.emit("enterNode",R(R({},s),{},{node:u})),t.scheduleHighlightedNodesRender();return}if(t.hoveredNode&&t.getNodeAtPosition(a)!==t.hoveredNode){var h=t.hoveredNode;t.hoveredNode=null,t.emit("leaveNode",R(R({},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",R(R({},s),{},{edge:t.hoveredEdge})),d&&t.emit("enterEdge",R(R({},s),{},{edge:d})),t.hoveredEdge=d)}},this.activeListeners.handleMoveBody=function(o){var a=ze(o);t.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=ze(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};t.hoveredNode&&(t.emit("leaveNode",R(R({},s),{},{node:t.hoveredNode})),t.scheduleHighlightedNodesRender()),t.settings.enableEdgeEvents&&t.hoveredEdge&&(t.emit("leaveEdge",R(R({},s),{},{edge:t.hoveredEdge})),t.scheduleHighlightedNodesRender()),t.emit("leaveStage",R({},s))},this.activeListeners.handleEnter=function(o){var a=ze(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};t.emit("enterStage",R({},s))};var r=function(a){return function(s){var u=ze(s),h={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},d=t.getNodeAtPosition(u);if(d)return t.emit("".concat(a,"Node"),R(R({},h),{},{node:d}));if(t.settings.enableEdgeEvents){var l=t.getEdgeAtPoint(u.x,u.y);if(l)return t.emit("".concat(a,"Edge"),R(R({},h),{},{edge:l}))}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=Zt(this.webGLContexts.edges,this.frameBuffers.edges,t,r,this.pixelRatio,this.pickingDownSizingRatio),a=Kt.apply(void 0,di(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=qo(this.graph),!this.settings.autoRescale){var s=a.width,u=a.height,h=this.nodeExtent,d=h.x,l=h.y;this.nodeExtent={x:[(d[0]+d[1])/2-s/2,(d[0]+d[1])/2+s/2],y:[(l[0]+l[1])/2-u/2,(l[0]+l[1])/2+u/2]}}this.normalizationFunction=si(this.customBBox||this.nodeExtent);var c=new hi,f=$e(c.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var p={},m={},w={},k={},S=1,b=r.nodes(),E=0,C=b.length;E<C;E++){var D=b[E],_=this.nodeDataCache[D],A=r.getNodeAttributes(D);_.x=A.x,_.y=A.y,this.normalizationFunction.applyTo(_),typeof _.label=="string"&&!_.hidden&&this.labelGrid.add(D,_.size,this.framedGraphToViewport(_,{matrix:f})),p[_.type]=(p[_.type]||0)+1}this.labelGrid.organize();for(var g in this.nodePrograms){if(!Te.call(this.nodePrograms,g))throw new Error('Sigma: could not find a suitable program for node type "'.concat(g,'"!'));this.nodePrograms[g].reallocate(p[g]||0),p[g]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=ai(this.nodeZExtent,function(nt){return t.nodeDataCache[nt].zIndex},b));for(var $=0,B=b.length;$<B;$++){var z=b[$];m[z]=S,k[m[z]]={type:"node",id:z},S++;var J=this.nodeDataCache[z];this.addNodeToProgram(z,m[z],p[J.type]++)}for(var N={},W=r.edges(),oe=0,be=W.length;oe<be;oe++){var de=W[oe],ae=this.edgeDataCache[de];N[ae.type]=(N[ae.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(W=ai(this.edgeZExtent,function(nt){return t.edgeDataCache[nt].zIndex},W));for(var Q in this.edgePrograms){if(!Te.call(this.edgePrograms,Q))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Q,'"!'));this.edgePrograms[Q].reallocate(N[Q]||0),N[Q]=0}for(var te=0,le=W.length;te<le;te++){var q=W[te];w[q]=S,k[w[q]]={type:"edge",id:q},S++;var xe=this.edgeDataCache[q];this.addEdgeToProgram(q,w[q],N[xe.type]++)}return this.itemIDsIndex=k,this.nodeIndices=m,this.edgeIndices=w,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(t){var r=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(d){return r.cleanCameraState(d,o.cameraPanBoundaries&&At(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),t){if(t.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==t.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in t.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(t.nodeProgramClasses!==o.nodeProgramClasses||t.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==t.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==t.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var h in t.nodeProgramClasses)o.nodeProgramClasses[h]||this.unregisterNodeProgram(h)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=r.tolerance,a=o===void 0?0:o,s=r.boundaries,u=R({},t),h=s||this.nodeExtent,d=Ne(h.x,2),l=d[0],c=d[1],f=Ne(h.y,2),p=f[0],m=f[1],w=[this.graphToViewport({x:l,y:p},{cameraState:t}),this.graphToViewport({x:c,y:p},{cameraState:t}),this.graphToViewport({x:l,y:m},{cameraState:t}),this.graphToViewport({x:c,y:m},{cameraState:t})],k=1/0,S=-1/0,b=1/0,E=-1/0;w.forEach(function(N){var W=N.x,oe=N.y;k=Math.min(k,W),S=Math.max(S,W),b=Math.min(b,oe),E=Math.max(E,oe)});var C=S-k,D=E-b,_=this.getDimensions(),A=_.width,g=_.height,$=0,B=0;if(C>=A?S<A-a?$=S-(A-a):k>a&&($=k-a):S>A+a?$=S-(A+a):k<-a&&($=k+a),D>=g?E<g-a?B=E-(g-a):b>a&&(B=b-a):E>g+a?B=E-(g+a):b<-a&&(B=b+a),$||B){var z=this.viewportToFramedGraph({x:0,y:0},{cameraState:t}),J=this.viewportToFramedGraph({x:$,y:B},{cameraState:t});$=J.x-z.x,B=J.y-z.y,u.x+=$,u.y+=B}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);ui(r,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=r.length;a<s;a++){var u=r[a],h=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!h.hidden){var d=this.framedGraphToViewport(h),l=d.x,c=d.y,f=this.scaleSize(h.size);if(!(!h.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(l<-fi||l>this.width+fi||c<-gi||c>this.height+gi)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[h.type],w=(m==null?void 0:m.drawLabel)||p;w(o,R(R({key:u},h),{},{size:f,x:l,y:c}),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=ga({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ui(r,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=r.length;a<s;a++){var u=r[a],h=this.graph.extremities(u),d=this.nodeDataCache[h[0]],l=this.nodeDataCache[h[1]],c=this.edgeDataCache[u];if(!o.has(u)&&!(c.hidden||d.hidden||l.hidden)){var f=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[c.type],m=(p==null?void 0:p.drawLabel)||f;m(t,R(R({key:u},c),{},{size:this.scaleSize(c.size)}),R(R(R({key:h[0]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),R(R(R({key:h[1]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var t=this,r=this.canvasContexts.hovers;r.clearRect(0,0,this.width,this.height);var o=function(f){var p=t.nodeDataCache[f],m=t.framedGraphToViewport(p),w=m.x,k=m.y,S=t.scaleSize(p.size),b=t.settings.defaultDrawNodeHover,E=t.nodePrograms[p.type],C=(E==null?void 0:E.drawHover)||b;C(r,R(R({key:f},p),{},{size:S,x:w,y:k}),t.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(c){c!==t.hoveredNode&&a.push(c)}),a.forEach(function(c){return o(c)});var s={};a.forEach(function(c){var f=t.nodeDataCache[c].type;s[f]=(s[f]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(s[u]||0),s[u]=0;a.forEach(function(c){var f=t.nodeDataCache[c];t.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var h=this.getRenderParams();for(var d in this.nodeHoverPrograms){var l=this.nodeHoverPrograms[d];l.render(h)}}},{key:"scheduleHighlightedNodesRender",value:function(){var t=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){t.renderHighlightedNodesFrame=null,t.renderHighlightedNodes(),t.renderEdgeLabels()}))}},{key:"render",value:function(){var t=this;this.emit("beforeRender");var r=function(){return t.emit("afterRender"),t};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(w){return t.resetWebGLTexture(w)}),!this.graph.order)return r();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),u=this.getDimensions(),h=this.getGraphDimensions(),d=this.getStagePadding();this.matrix=$e(s,u,h,d),this.invMatrix=$e(s,u,h,d,!0),this.correctionRatio=Zo(this.matrix,s,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var l=this.getRenderParams();for(var c in this.nodePrograms){var f=this.nodePrograms[c];f.render(l)}if(!this.settings.hideEdgesOnMove||!a)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(l)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),r()}},{key:"addNode",value:function(t){var r=Object.assign({},this.graph.getNodeAttributes(t));this.settings.nodeReducer&&(r=this.settings.nodeReducer(t,r));var o=pa(this.settings,t,r);this.nodeDataCache[t]=o,this.nodesWithForcedLabels.delete(t),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(t),this.highlightedNodes.delete(t),o.highlighted&&!o.hidden&&this.highlightedNodes.add(t),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.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=va(this.settings,t,r);this.edgeDataCache[t]=o,this.edgesWithForcedLabels.delete(t),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(t),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.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 ci,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=Jo(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=R({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 R({},this.settings)}},{key:"getSetting",value:function(t){return this.settings[t]}},{key:"setSetting",value:function(t,r){var o=R({},this.settings);return this.settings[t]=r,mt(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=R({},this.settings);return this.settings=R(R({},this.settings),t),mt(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=oi(),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 l=this.textures[h];l&&d.deleteTexture(l)}}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(E){return r.addNode(E)}),this.graph.forEachEdge(function(E){return r.addEdge(E)});else{for(var u,h,d=((u=t.partialGraph)===null||u===void 0?void 0:u.nodes)||[],l=0,c=(d==null?void 0:d.length)||0;l<c;l++){var f=d[l];if(this.updateNode(f),o){var p=this.nodeProgramIndex[f];if(p===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],p)}}for(var m=(t==null||(h=t.partialGraph)===null||h===void 0?void 0:h.edges)||[],w=0,k=m.length;w<k;w++){var S=m[w];if(this.updateEdge(S),o){var b=this.edgeProgramIndex[S];if(b===void 0)throw new Error('Sigma: edge "'.concat(S,`" can't be repaint`));this.addEdgeToProgram(S,this.edgeIndices[S],b)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var t=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){t.render()})),this}},{key:"scheduleRefresh",value:function(t){return this.refresh(R(R({},t),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(t,r){var o=this.camera.getState(),a=o.ratio,s=o.angle,u=o.x,h=o.y,d=this.settings,l=d.minCameraRatio,c=d.maxCameraRatio;typeof c=="number"&&(r=Math.min(r,c)),typeof l=="number"&&(r=Math.max(r,l));var f=r/a,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(t),w=this.viewportToFramedGraph(p);return{angle:s,x:(m.x-w.x)*(1-f)+u,y:(m.y-w.y)*(1-f)+h,ratio:r}}},{key:"viewRectangle",value:function(){var t=this.viewportToFramedGraph({x:0,y:0}),r=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:t.x,y1:t.y,x2:r.x,y2:r.y,height:r.y-o.y}}},{key:"framedGraphToViewport",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?$e(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding()):this.matrix,s=St(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?$e(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding(),!0):this.invMatrix,s=St(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}}])}(Pt),ya=ma,rt={};function ba(n){return typeof n!="number"||isNaN(n)?1:n}function wa(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 ur(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,l,c){return t(n(a,s,u,h,d,l,c))},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}rt.createNodeValueGetter=wa;rt.createEdgeValueGetter=ur;rt.createEdgeWeightGetter=function(n){return ur(n,ba)};var M=0,O=1,x=2,G=3,we=4,Ee=5,F=6,pi=7,Je=8,vi=9,Ea=0,_a=1,Ta=2,j=0,se=1,X=2,De=3,ke=4,U=5,ee=6,pe=7,ve=8,mi=3,ce=10,Sa=3,Y=9,bt=10,Aa=function(i,e,t){var r,o,a,s,u,h,d,l,c,f,p=e.length,m=t.length,w=i.adjustSizes,k=i.barnesHutTheta*i.barnesHutTheta,S,b,E,C,D,_,A,g=[];for(a=0;a<p;a+=ce)e[a+we]=e[a+x],e[a+Ee]=e[a+G],e[a+x]=0,e[a+G]=0;if(i.outboundAttractionDistribution){for(S=0,a=0;a<p;a+=ce)S+=e[a+F];S/=p/ce}if(i.barnesHutOptimize){var $=1/0,B=-1/0,z=1/0,J=-1/0,N,W,oe;for(a=0;a<p;a+=ce)$=Math.min($,e[a+M]),B=Math.max(B,e[a+M]),z=Math.min(z,e[a+O]),J=Math.max(J,e[a+O]);var be=B-$,de=J-z;for(be>de?(z-=(be-de)/2,J=z+be):($-=(de-be)/2,B=$+de),g[0+j]=-1,g[0+se]=($+B)/2,g[0+X]=(z+J)/2,g[0+De]=Math.max(B-$,J-z),g[0+ke]=-1,g[0+U]=-1,g[0+ee]=0,g[0+pe]=0,g[0+ve]=0,r=1,a=0;a<p;a+=ce)for(o=0,oe=mi;;)if(g[o+U]>=0){e[a+M]<g[o+se]?e[a+O]<g[o+X]?N=g[o+U]:N=g[o+U]+Y:e[a+O]<g[o+X]?N=g[o+U]+Y*2:N=g[o+U]+Y*3,g[o+pe]=(g[o+pe]*g[o+ee]+e[a+M]*e[a+F])/(g[o+ee]+e[a+F]),g[o+ve]=(g[o+ve]*g[o+ee]+e[a+O]*e[a+F])/(g[o+ee]+e[a+F]),g[o+ee]+=e[a+F],o=N;continue}else if(g[o+j]<0){g[o+j]=a;break}else{if(g[o+U]=r*Y,l=g[o+De]/2,c=g[o+U],g[c+j]=-1,g[c+se]=g[o+se]-l,g[c+X]=g[o+X]-l,g[c+De]=l,g[c+ke]=c+Y,g[c+U]=-1,g[c+ee]=0,g[c+pe]=0,g[c+ve]=0,c+=Y,g[c+j]=-1,g[c+se]=g[o+se]-l,g[c+X]=g[o+X]+l,g[c+De]=l,g[c+ke]=c+Y,g[c+U]=-1,g[c+ee]=0,g[c+pe]=0,g[c+ve]=0,c+=Y,g[c+j]=-1,g[c+se]=g[o+se]+l,g[c+X]=g[o+X]-l,g[c+De]=l,g[c+ke]=c+Y,g[c+U]=-1,g[c+ee]=0,g[c+pe]=0,g[c+ve]=0,c+=Y,g[c+j]=-1,g[c+se]=g[o+se]+l,g[c+X]=g[o+X]+l,g[c+De]=l,g[c+ke]=g[o+ke],g[c+U]=-1,g[c+ee]=0,g[c+pe]=0,g[c+ve]=0,r+=4,e[g[o+j]+M]<g[o+se]?e[g[o+j]+O]<g[o+X]?N=g[o+U]:N=g[o+U]+Y:e[g[o+j]+O]<g[o+X]?N=g[o+U]+Y*2:N=g[o+U]+Y*3,g[o+ee]=e[g[o+j]+F],g[o+pe]=e[g[o+j]+M],g[o+ve]=e[g[o+j]+O],g[N+j]=g[o+j],g[o+j]=-1,e[a+M]<g[o+se]?e[a+O]<g[o+X]?W=g[o+U]:W=g[o+U]+Y:e[a+O]<g[o+X]?W=g[o+U]+Y*2:W=g[o+U]+Y*3,N===W)if(oe--){o=N;continue}else{oe=mi;break}g[W+j]=a;break}}if(i.barnesHutOptimize)for(b=i.scalingRatio,a=0;a<p;a+=ce)for(o=0;;)if(g[o+U]>=0)if(_=Math.pow(e[a+M]-g[o+pe],2)+Math.pow(e[a+O]-g[o+ve],2),f=g[o+De],4*f*f/_<k){if(E=e[a+M]-g[o+pe],C=e[a+O]-g[o+ve],w===!0?_>0?(A=b*e[a+F]*g[o+ee]/_,e[a+x]+=E*A,e[a+G]+=C*A):_<0&&(A=-b*e[a+F]*g[o+ee]/Math.sqrt(_),e[a+x]+=E*A,e[a+G]+=C*A):_>0&&(A=b*e[a+F]*g[o+ee]/_,e[a+x]+=E*A,e[a+G]+=C*A),o=g[o+ke],o<0)break;continue}else{o=g[o+U];continue}else{if(h=g[o+j],h>=0&&h!==a&&(E=e[a+M]-e[h+M],C=e[a+O]-e[h+O],_=E*E+C*C,w===!0?_>0?(A=b*e[a+F]*e[h+F]/_,e[a+x]+=E*A,e[a+G]+=C*A):_<0&&(A=-b*e[a+F]*e[h+F]/Math.sqrt(_),e[a+x]+=E*A,e[a+G]+=C*A):_>0&&(A=b*e[a+F]*e[h+F]/_,e[a+x]+=E*A,e[a+G]+=C*A)),o=g[o+ke],o<0)break;continue}else for(b=i.scalingRatio,s=0;s<p;s+=ce)for(u=0;u<s;u+=ce)E=e[s+M]-e[u+M],C=e[s+O]-e[u+O],w===!0?(_=Math.sqrt(E*E+C*C)-e[s+Je]-e[u+Je],_>0?(A=b*e[s+F]*e[u+F]/_/_,e[s+x]+=E*A,e[s+G]+=C*A,e[u+x]-=E*A,e[u+G]-=C*A):_<0&&(A=100*b*e[s+F]*e[u+F],e[s+x]+=E*A,e[s+G]+=C*A,e[u+x]-=E*A,e[u+G]-=C*A)):(_=Math.sqrt(E*E+C*C),_>0&&(A=b*e[s+F]*e[u+F]/_/_,e[s+x]+=E*A,e[s+G]+=C*A,e[u+x]-=E*A,e[u+G]-=C*A));for(c=i.gravity/i.scalingRatio,b=i.scalingRatio,a=0;a<p;a+=ce)A=0,E=e[a+M],C=e[a+O],_=Math.sqrt(Math.pow(E,2)+Math.pow(C,2)),i.strongGravityMode?_>0&&(A=b*e[a+F]*c):_>0&&(A=b*e[a+F]*c/_),e[a+x]-=E*A,e[a+G]-=C*A;for(b=1*(i.outboundAttractionDistribution?S:1),d=0;d<m;d+=Sa)s=t[d+Ea],u=t[d+_a],l=t[d+Ta],D=Math.pow(l,i.edgeWeightInfluence),E=e[s+M]-e[u+M],C=e[s+O]-e[u+O],w===!0?(_=Math.sqrt(E*E+C*C)-e[s+Je]-e[u+Je],i.linLogMode?i.outboundAttractionDistribution?_>0&&(A=-b*D*Math.log(1+_)/_/e[s+F]):_>0&&(A=-b*D*Math.log(1+_)/_):i.outboundAttractionDistribution?_>0&&(A=-b*D/e[s+F]):_>0&&(A=-b*D)):(_=Math.sqrt(Math.pow(E,2)+Math.pow(C,2)),i.linLogMode?i.outboundAttractionDistribution?_>0&&(A=-b*D*Math.log(1+_)/_/e[s+F]):_>0&&(A=-b*D*Math.log(1+_)/_):i.outboundAttractionDistribution?(_=1,A=-b*D/e[s+F]):(_=1,A=-b*D)),_>0&&(e[s+x]+=E*A,e[s+G]+=C*A,e[u+x]-=E*A,e[u+G]-=C*A);var ae,Q,te,le,q,xe;if(w===!0)for(a=0;a<p;a+=ce)e[a+vi]!==1&&(ae=Math.sqrt(Math.pow(e[a+x],2)+Math.pow(e[a+G],2)),ae>bt&&(e[a+x]=e[a+x]*bt/ae,e[a+G]=e[a+G]*bt/ae),Q=e[a+F]*Math.sqrt((e[a+we]-e[a+x])*(e[a+we]-e[a+x])+(e[a+Ee]-e[a+G])*(e[a+Ee]-e[a+G])),te=Math.sqrt((e[a+we]+e[a+x])*(e[a+we]+e[a+x])+(e[a+Ee]+e[a+G])*(e[a+Ee]+e[a+G]))/2,le=.1*Math.log(1+te)/(1+Math.sqrt(Q)),q=e[a+M]+e[a+x]*(le/i.slowDown),e[a+M]=q,xe=e[a+O]+e[a+G]*(le/i.slowDown),e[a+O]=xe);else for(a=0;a<p;a+=ce)e[a+vi]!==1&&(Q=e[a+F]*Math.sqrt((e[a+we]-e[a+x])*(e[a+we]-e[a+x])+(e[a+Ee]-e[a+G])*(e[a+Ee]-e[a+G])),te=Math.sqrt((e[a+we]+e[a+x])*(e[a+we]+e[a+x])+(e[a+Ee]+e[a+G])*(e[a+Ee]+e[a+G]))/2,le=e[a+pi]*Math.log(1+te)/(1+Math.sqrt(Q)),e[a+pi]=Math.min(1,Math.sqrt(le*(Math.pow(e[a+x],2)+Math.pow(e[a+G],2))/(1+Math.sqrt(Q)))),q=e[a+M]+e[a+x]*(le/i.slowDown),e[a+M]=q,xe=e[a+O]+e[a+G]*(le/i.slowDown),e[a+O]=xe);return{}},Ce={},He=10,yi=3;Ce.assign=function(n){n=n||{};var i=Array.prototype.slice.call(arguments).slice(1),e,t,r;for(e=0,r=i.length;e<r;e++)if(i[e])for(t in i[e])n[t]=i[e][t];return n};Ce.validateSettings=function(n){return"linLogMode"in n&&typeof n.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in n&&typeof n.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in n&&typeof n.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in n&&typeof n.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in n&&!(typeof n.scalingRatio=="number"&&n.scalingRatio>=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};Ce.graphToByteArrays=function(n,i){var e=n.order,t=n.size,r={},o,a=new Float32Array(e*He),s=new Float32Array(t*yi);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+=He}),o=0,n.forEachEdge(function(u,h,d,l,c,f,p){var m=r[d],w=r[l],k=i(u,h,d,l,c,f,p);a[m+6]+=k,a[w+6]+=k,s[o]=m,s[o+1]=w,s[o+2]=k,o+=yi}),{nodes:a,edges:s}};Ce.assignLayoutChanges=function(n,i,e){var t=0;n.updateEachNodeAttributes(function(r,o){return o.x=i[t],o.y=i[t+1],t+=He,e?e(r,o):o})};Ce.readGraphPositions=function(n,i){var e=0;n.forEachNode(function(t,r){i[e]=r.x,i[e+1]=r.y,e+=He})};Ce.collectLayoutChanges=function(n,i,e){for(var t=n.nodes(),r={},o=0,a=0,s=i.length;o<s;o+=He){if(e){var u=Object.assign({},n.getNodeAttributes(t[a]));u.x=i[o],u.y=i[o+1],u=e(t[a],u),r[t[a]]={x:u.x,y:u.y}}else r[t[a]]={x:i[o],y:i[o+1]};a++}return r};Ce.createWorker=function(i){var e=window.URL||window.webkitURL,t=i.toString(),r=e.createObjectURL(new Blob(["("+t+").call(this);"],{type:"text/javascript"})),o=new Worker(r);return e.revokeObjectURL(r),o};var Ra={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5},ka=or,Ca=rt.createEdgeWeightGetter,La=Aa,Be=Ce,Da=Ra;function hr(n,i,e){if(!ka(i))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof e=="number"&&(e={iterations:e});var t=e.iterations;if(typeof t!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(t<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var r=Ca("getEdgeWeight"in e?e.getEdgeWeight:"weight").fromEntry,o=typeof e.outputReducer=="function"?e.outputReducer:null,a=Be.assign({},Da,e.settings),s=Be.validateSettings(a);if(s)throw new Error("graphology-layout-forceatlas2: "+s.message);var u=Be.graphToByteArrays(i,r),h;for(h=0;h<t;h++)La(a,u.nodes,u.edges);if(n){Be.assignLayoutChanges(i,u.nodes,o);return}return Be.collectLayoutChanges(i,u.nodes)}function xa(n){var i=typeof n=="number"?n:n.order;return{barnesHutOptimize:i>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(i)}}var It=hr.bind(null,!1);It.assign=hr.bind(null,!0);It.inferSettings=xa;var Ga=It;const Fa=We(Ga),Pa={instrument:{color:"#1f78b4"},organization:{color:"#33a02c"},person:{color:"#ff7f00"},project:{color:"#6a3d9a"},publication:{color:"#dd4444"}},Na={http:{color:"#999",size:1},sql:{color:"#e31a1c",size:2},rpc:{color:"#b15928",size:1.5}};async function Ia(){const n=await fetch("graph.json");if(!n.ok)throw new Error("Failed to load graph.json");return n.json()}(async function(){const i=await Ia(),e=new I;i.nodes.forEach(d=>{const l=Pa[d.type]||{color:"#666"};e.addNode(d.id,{label:d.label||d.id,size:Math.log(d.size*10)+1,color:l.color,domainType:d.type,url:d.url||null,x:Math.random()-.5,y:Math.random()-.5,type:"circle"})}),i.edges.forEach(d=>{const l=Na[d.type]||{color:"#ccc",size:1};e.addEdgeWithKey(d.id||`${d.source}->${d.target}`,d.source,d.target,{label:d.type,color:l.color,size:l.size,domainType:d.type})});const t=document.getElementById("sigma-container"),r=new ya(e,t,{renderLabels:!0}),o=r.getCamera();Fa.assign(e,{iterations:1e3,settings:{barnesHutOptimize:!0,outboundAttractionDistribution:!0,slowDown:10,adjustSizes:!0}});function s(d,l){d.forEachEdge((c,f)=>{const p=d.getNodeAttribute(d.source(c),"hidden"),m=d.getNodeAttribute(d.target(c),"hidden");d.setEdgeAttribute(c,"hidden",p||m)}),l.refresh()}const u=document.getElementById("sigma-controls-list")||(()=>{const d=document.createElement("div");return d.id="sigma-controls-list",document.getElementById("sigma-node-type-controls").appendChild(d),d})(),h=new Set;e.forEachNode((d,l)=>{h.add(l.domainType||"unknown")}),h.forEach(d=>{const l=`toggle-${d}`,c=document.createElement("div");c.style.marginBottom="6px";const f=document.createElement("input");f.type="checkbox",f.id=l,f.checked=!0,f.style.marginRight="6px";const p=document.createElement("label");p.htmlFor=l,p.textContent=d,c.appendChild(f),c.appendChild(p),u.appendChild(c),f.addEventListener("change",()=>{const m=!f.checked;e.forEachNode((w,k)=>{(k.domainType||"unknown")===d&&e.setNodeAttribute(w,"hidden",m)}),s(e,r)})}),s(e,r),r.on("downNode",({node:d,event:l})=>{const c=e.getNodeAttribute(d,"url");if(c)location.href=c;else{const f=e.getNodeAttribute(d,"x"),p=e.getNodeAttribute(d,"y");o.animate({x:f,y:p,ratio:.5},{duration:600})}}),r.on("enterNode",({node:d})=>{const l=e.getNodeAttribute(d,"domainType");e.forEachNode(c=>e.setNodeAttribute(c,"highlight",e.getNodeAttribute(c,"domainType")===l)),e.forEachEdge(c=>e.setEdgeAttribute(c,"highlight",e.getEdgeAttribute(c,"domainType")===l)),r.refresh()}),r.on("leaveNode",()=>{e.forEachNode(d=>e.removeNodeAttribute(d,"highlight")),e.forEachEdge(d=>e.removeEdgeAttribute(d,"highlight")),r.refresh()})})();