graphgarden-web 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/graphgarden.iife.js +434 -0
- package/dist/graphgarden.iife.js.map +7 -0
- package/dist/graphgarden.js +434 -0
- package/dist/graphgarden.js.map +7 -0
- package/dist/index.d.ts +67 -0
- package/dist/test-setup.d.ts +0 -0
- package/package.json +44 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
"use strict";(()=>{var Di=Object.create;var On=Object.defineProperty;var Pi=Object.getOwnPropertyDescriptor;var Fi=Object.getOwnPropertyNames;var Ni=Object.getPrototypeOf,Oi=Object.prototype.hasOwnProperty;var $e=(i,o)=>()=>(o||i((o={exports:{}}).exports,o),o.exports);var zi=(i,o,e,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of Fi(o))!Oi.call(i,n)&&n!==e&&On(i,n,{get:()=>o[n],enumerable:!(t=Pi(o,n))||t.enumerable});return i};var ot=(i,o,e)=>(e=i!=null?Di(Ni(i)):{},zi(o||!i||!i.__esModule?On(e,"default",{value:i,enumerable:!0}):e,i));var zn=$e((qt,Kt)=>{(function(i,o){typeof qt=="object"&&typeof Kt<"u"?Kt.exports=o():typeof define=="function"&&define.amd?define(o):(i=typeof globalThis<"u"?globalThis:i||self).graphology=o()})(qt,(function(){"use strict";function i(h){return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},i(h)}function o(h,l){h.prototype=Object.create(l.prototype),h.prototype.constructor=h,t(h,l)}function e(h){return e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(l){return l.__proto__||Object.getPrototypeOf(l)},e(h)}function t(h,l){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,r){return c.__proto__=r,c},t(h,l)}function n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch{return!1}}function u(h,l,c){return u=n()?Reflect.construct.bind():function(r,a,d){var g=[null];g.push.apply(g,a);var v=new(Function.bind.apply(r,g));return d&&t(v,d.prototype),v},u.apply(null,arguments)}function s(h){var l=typeof Map=="function"?new Map:void 0;return s=function(c){if(c===null||(r=c,Function.toString.call(r).indexOf("[native code]")===-1))return c;var r;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(l!==void 0){if(l.has(c))return l.get(c);l.set(c,a)}function a(){return u(c,arguments,e(this).constructor)}return a.prototype=Object.create(c.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),t(a,c)},s(h)}function f(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}var p=function(){for(var h=arguments[0],l=1,c=arguments.length;l<c;l++)if(arguments[l])for(var r in arguments[l])h[r]=arguments[l][r];return h};function m(h,l,c,r){var a=h._nodes.get(l),d=null;return a?d=r==="mixed"?a.out&&a.out[c]||a.undirected&&a.undirected[c]:r==="directed"?a.out&&a.out[c]:a.undirected&&a.undirected[c]:d}function b(h){return i(h)==="object"&&h!==null}function E(h){var l;for(l in h)return!1;return!0}function w(h,l,c){Object.defineProperty(h,l,{enumerable:!1,configurable:!1,writable:!0,value:c})}function S(h,l,c){var r={enumerable:!0,configurable:!0};typeof c=="function"?r.get=c:(r.value=c,r.writable=!1),Object.defineProperty(h,l,r)}function x(h){return!!b(h)&&!(h.attributes&&!Array.isArray(h.attributes))}typeof Object.assign=="function"&&(p=Object.assign);var N,O={exports:{}},H=typeof Reflect=="object"?Reflect:null,I=H&&typeof H.apply=="function"?H.apply:function(h,l,c){return Function.prototype.apply.call(h,l,c)};N=H&&typeof H.ownKeys=="function"?H.ownKeys:Object.getOwnPropertySymbols?function(h){return Object.getOwnPropertyNames(h).concat(Object.getOwnPropertySymbols(h))}:function(h){return Object.getOwnPropertyNames(h)};var G=Number.isNaN||function(h){return h!=h};function T(){T.init.call(this)}O.exports=T,O.exports.once=function(h,l){return new Promise((function(c,r){function a(g){h.removeListener(l,d),r(g)}function d(){typeof h.removeListener=="function"&&h.removeListener("error",a),c([].slice.call(arguments))}q(h,l,d,{once:!0}),l!=="error"&&(function(g,v,y){typeof g.on=="function"&&q(g,"error",v,y)})(h,a,{once:!0})}))},T.EventEmitter=T,T.prototype._events=void 0,T.prototype._eventsCount=0,T.prototype._maxListeners=void 0;var B=10;function V(h){if(typeof h!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof h)}function L(h){return h._maxListeners===void 0?T.defaultMaxListeners:h._maxListeners}function M(h,l,c,r){var a,d,g,v;if(V(c),(d=h._events)===void 0?(d=h._events=Object.create(null),h._eventsCount=0):(d.newListener!==void 0&&(h.emit("newListener",l,c.listener?c.listener:c),d=h._events),g=d[l]),g===void 0)g=d[l]=c,++h._eventsCount;else if(typeof g=="function"?g=d[l]=r?[c,g]:[g,c]:r?g.unshift(c):g.push(c),(a=L(h))>0&&g.length>a&&!g.warned){g.warned=!0;var y=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(l)+" listeners added. Use emitter.setMaxListeners() to increase limit");y.name="MaxListenersExceededWarning",y.emitter=h,y.type=l,y.count=g.length,v=y,console&&console.warn&&console.warn(v)}return h}function _(){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 ee(h,l,c){var r={fired:!1,wrapFn:void 0,target:h,type:l,listener:c},a=_.bind(r);return a.listener=c,r.wrapFn=a,a}function ie(h,l,c){var r=h._events;if(r===void 0)return[];var a=r[l];return a===void 0?[]:typeof a=="function"?c?[a.listener||a]:[a]:c?(function(d){for(var g=new Array(d.length),v=0;v<g.length;++v)g[v]=d[v].listener||d[v];return g})(a):ge(a,a.length)}function te(h){var l=this._events;if(l!==void 0){var c=l[h];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}function ge(h,l){for(var c=new Array(l),r=0;r<l;++r)c[r]=h[r];return c}function q(h,l,c,r){if(typeof h.on=="function")r.once?h.once(l,c):h.on(l,c);else{if(typeof h.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof h);h.addEventListener(l,(function a(d){r.once&&h.removeEventListener(l,a),c(d)}))}}function X(h){if(typeof h!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=h}Object.defineProperty(T,"defaultMaxListeners",{enumerable:!0,get:function(){return B},set:function(h){if(typeof h!="number"||h<0||G(h))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+h+".");B=h}}),T.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},T.prototype.setMaxListeners=function(h){if(typeof h!="number"||h<0||G(h))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+h+".");return this._maxListeners=h,this},T.prototype.getMaxListeners=function(){return L(this)},T.prototype.emit=function(h){for(var l=[],c=1;c<arguments.length;c++)l.push(arguments[c]);var r=h==="error",a=this._events;if(a!==void 0)r=r&&a.error===void 0;else if(!r)return!1;if(r){var d;if(l.length>0&&(d=l[0]),d instanceof Error)throw d;var g=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw g.context=d,g}var v=a[h];if(v===void 0)return!1;if(typeof v=="function")I(v,this,l);else{var y=v.length,A=ge(v,y);for(c=0;c<y;++c)I(A[c],this,l)}return!0},T.prototype.addListener=function(h,l){return M(this,h,l,!1)},T.prototype.on=T.prototype.addListener,T.prototype.prependListener=function(h,l){return M(this,h,l,!0)},T.prototype.once=function(h,l){return V(l),this.on(h,ee(this,h,l)),this},T.prototype.prependOnceListener=function(h,l){return V(l),this.prependListener(h,ee(this,h,l)),this},T.prototype.removeListener=function(h,l){var c,r,a,d,g;if(V(l),(r=this._events)===void 0)return this;if((c=r[h])===void 0)return this;if(c===l||c.listener===l)--this._eventsCount==0?this._events=Object.create(null):(delete r[h],r.removeListener&&this.emit("removeListener",h,c.listener||l));else if(typeof c!="function"){for(a=-1,d=c.length-1;d>=0;d--)if(c[d]===l||c[d].listener===l){g=c[d].listener,a=d;break}if(a<0)return this;a===0?c.shift():(function(v,y){for(;y+1<v.length;y++)v[y]=v[y+1];v.pop()})(c,a),c.length===1&&(r[h]=c[0]),r.removeListener!==void 0&&this.emit("removeListener",h,g||l)}return this},T.prototype.off=T.prototype.removeListener,T.prototype.removeAllListeners=function(h){var l,c,r;if((c=this._events)===void 0)return this;if(c.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):c[h]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete c[h]),this;if(arguments.length===0){var a,d=Object.keys(c);for(r=0;r<d.length;++r)(a=d[r])!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(l=c[h])=="function")this.removeListener(h,l);else if(l!==void 0)for(r=l.length-1;r>=0;r--)this.removeListener(h,l[r]);return this},T.prototype.listeners=function(h){return ie(this,h,!0)},T.prototype.rawListeners=function(h){return ie(this,h,!1)},T.listenerCount=function(h,l){return typeof h.listenerCount=="function"?h.listenerCount(l):te.call(h,l)},T.prototype.listenerCount=te,T.prototype.eventNames=function(){return this._eventsCount>0?N(this._events):[]},typeof Symbol<"u"&&(X.prototype[Symbol.iterator]=function(){return this}),X.of=function(){var h=arguments,l=h.length,c=0;return new X((function(){return c>=l?{done:!0}:{done:!1,value:h[c++]}}))},X.empty=function(){return new X((function(){return{done:!0}}))},X.fromSequence=function(h){var l=0,c=h.length;return new X((function(){return l>=c?{done:!0}:{done:!1,value:h[l++]}}))},X.is=function(h){return h instanceof X||typeof h=="object"&&h!==null&&typeof h.next=="function"};var Q=X,Te={};Te.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",Te.SYMBOL_SUPPORT=typeof Symbol<"u";var Ce=Q,be=Te,me=be.ARRAY_BUFFER_SUPPORT,we=be.SYMBOL_SUPPORT,_e=function(h){var l=(function(c){return typeof c=="string"||Array.isArray(c)||me&&ArrayBuffer.isView(c)?Ce.fromSequence(c):typeof c!="object"||c===null?null:we&&typeof c[Symbol.iterator]=="function"?c[Symbol.iterator]():typeof c.next=="function"?c:null})(h);if(!l)throw new Error("obliterator: target is not iterable nor a valid iterator.");return l},pe=_e,Oe=function(h,l){for(var c,r=arguments.length>1?l:1/0,a=r!==1/0?new Array(r):[],d=0,g=pe(h);;){if(d===r)return a;if((c=g.next()).done)return d!==l&&(a.length=d),a;a[d++]=c.value}},Xe=(function(h){function l(c){var r;return(r=h.call(this)||this).name="GraphError",r.message=c,r}return o(l,h),l})(s(Error)),z=(function(h){function l(c){var r;return(r=h.call(this,c)||this).name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(f(r),l.prototype.constructor),r}return o(l,h),l})(Xe),D=(function(h){function l(c){var r;return(r=h.call(this,c)||this).name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(f(r),l.prototype.constructor),r}return o(l,h),l})(Xe),W=(function(h){function l(c){var r;return(r=h.call(this,c)||this).name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(f(r),l.prototype.constructor),r}return o(l,h),l})(Xe);function _n(h,l){this.key=h,this.attributes=l,this.clear()}function Rn(h,l){this.key=h,this.attributes=l,this.clear()}function Tn(h,l){this.key=h,this.attributes=l,this.clear()}function nt(h,l,c,r,a){this.key=l,this.attributes=a,this.undirected=h,this.source=c,this.target=r}_n.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},Rn.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},Tn.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},nt.prototype.attach=function(){var h="out",l="in";this.undirected&&(h=l="undirected");var c=this.source.key,r=this.target.key;this.source[h][r]=this,this.undirected&&c===r||(this.target[l][c]=this)},nt.prototype.attachMulti=function(){var h="out",l="in",c=this.source.key,r=this.target.key;this.undirected&&(h=l="undirected");var a=this.source[h],d=a[r];if(d===void 0)return a[r]=this,void(this.undirected&&c===r||(this.target[l][c]=this));d.previous=this,this.next=d,a[r]=this,this.target[l][c]=this},nt.prototype.detach=function(){var h=this.source.key,l=this.target.key,c="out",r="in";this.undirected&&(c=r="undirected"),delete this.source[c][l],delete this.target[r][h]},nt.prototype.detachMulti=function(){var h=this.source.key,l=this.target.key,c="out",r="in";this.undirected&&(c=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[c][l],delete this.target[r][h]):(this.next.previous=void 0,this.source[c][l]=this.next,this.target[r][h]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function ze(h,l,c,r,a,d,g){var v,y,A,C;if(r=""+r,c===0){if(!(v=h._nodes.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" node in the graph.'));A=a,C=d}else if(c===3){if(a=""+a,!(y=h._edges.get(a)))throw new D("Graph.".concat(l,': could not find the "').concat(a,'" edge in the graph.'));var R=y.source.key,P=y.target.key;if(r===R)v=y.target;else{if(r!==P)throw new D("Graph.".concat(l,': the "').concat(r,'" node is not attached to the "').concat(a,'" edge (').concat(R,", ").concat(P,")."));v=y.source}A=d,C=g}else{if(!(y=h._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'));v=c===1?y.source:y.target,A=a,C=d}return[v,A,C]}var ui=[{name:function(h){return"get".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g=ze(this,l,c,r,a,d),v=g[0],y=g[1];return v.attributes[y]}}},{name:function(h){return"get".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a){return ze(this,l,c,r,a)[0].attributes}}},{name:function(h){return"has".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g=ze(this,l,c,r,a,d),v=g[0],y=g[1];return v.attributes.hasOwnProperty(y)}}},{name:function(h){return"set".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d,g){var v=ze(this,l,c,r,a,d,g),y=v[0],A=v[1],C=v[2];return y.attributes[A]=C,this.emit("nodeAttributesUpdated",{key:y.key,type:"set",attributes:y.attributes,name:A}),this}}},{name:function(h){return"update".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d,g){var v=ze(this,l,c,r,a,d,g),y=v[0],A=v[1],C=v[2];if(typeof C!="function")throw new z("Graph.".concat(l,": updater should be a function."));var R=y.attributes,P=C(R[A]);return R[A]=P,this.emit("nodeAttributesUpdated",{key:y.key,type:"set",attributes:y.attributes,name:A}),this}}},{name:function(h){return"remove".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g=ze(this,l,c,r,a,d),v=g[0],y=g[1];return delete v.attributes[y],this.emit("nodeAttributesUpdated",{key:v.key,type:"remove",attributes:v.attributes,name:y}),this}}},{name:function(h){return"replace".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g=ze(this,l,c,r,a,d),v=g[0],y=g[1];if(!b(y))throw new z("Graph.".concat(l,": provided attributes are not a plain object."));return v.attributes=y,this.emit("nodeAttributesUpdated",{key:v.key,type:"replace",attributes:v.attributes}),this}}},{name:function(h){return"merge".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g=ze(this,l,c,r,a,d),v=g[0],y=g[1];if(!b(y))throw new z("Graph.".concat(l,": provided attributes are not a plain object."));return p(v.attributes,y),this.emit("nodeAttributesUpdated",{key:v.key,type:"merge",attributes:v.attributes,data:y}),this}}},{name:function(h){return"update".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g=ze(this,l,c,r,a,d),v=g[0],y=g[1];if(typeof y!="function")throw new z("Graph.".concat(l,": provided updater is not a function."));return v.attributes=y(v.attributes),this.emit("nodeAttributesUpdated",{key:v.key,type:"update",attributes:v.attributes}),this}}}],hi=[{name:function(h){return"get".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+r,v=""+a;if(a=arguments[2],!(d=m(this,g,v,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(d=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}return d.attributes[a]}}},{name:function(h){return"get".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r){var a;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var d=""+r,g=""+arguments[1];if(!(a=m(this,d,g,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(d,'" - "').concat(g,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(a=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}return a.attributes}}},{name:function(h){return"has".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+r,v=""+a;if(a=arguments[2],!(d=m(this,g,v,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(d=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}return d.attributes.hasOwnProperty(a)}}},{name:function(h){return"set".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var v=""+r,y=""+a;if(a=arguments[2],d=arguments[3],!(g=m(this,v,y,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(v,'" - "').concat(y,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(g=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}return g.attributes[a]=d,this.emit("edgeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:a}),this}}},{name:function(h){return"update".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a,d){var g;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var v=""+r,y=""+a;if(a=arguments[2],d=arguments[3],!(g=m(this,v,y,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(v,'" - "').concat(y,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(g=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}if(typeof d!="function")throw new z("Graph.".concat(l,": updater should be a function."));return g.attributes[a]=d(g.attributes[a]),this.emit("edgeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:a}),this}}},{name:function(h){return"remove".concat(h,"Attribute")},attacher:function(h,l,c){h.prototype[l]=function(r,a){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+r,v=""+a;if(a=arguments[2],!(d=m(this,g,v,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(d=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}return delete d.attributes[a],this.emit("edgeAttributesUpdated",{key:d.key,type:"remove",attributes:d.attributes,name:a}),this}}},{name:function(h){return"replace".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+r,v=""+a;if(a=arguments[2],!(d=m(this,g,v,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(d=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}if(!b(a))throw new z("Graph.".concat(l,": provided attributes are not a plain object."));return d.attributes=a,this.emit("edgeAttributesUpdated",{key:d.key,type:"replace",attributes:d.attributes}),this}}},{name:function(h){return"merge".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+r,v=""+a;if(a=arguments[2],!(d=m(this,g,v,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(d=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}if(!b(a))throw new z("Graph.".concat(l,": provided attributes are not a plain object."));return p(d.attributes,a),this.emit("edgeAttributesUpdated",{key:d.key,type:"merge",attributes:d.attributes,data:a}),this}}},{name:function(h){return"update".concat(h,"Attributes")},attacher:function(h,l,c){h.prototype[l]=function(r,a){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new W("Graph.".concat(l,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new W("Graph.".concat(l,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+r,v=""+a;if(a=arguments[2],!(d=m(this,g,v,c)))throw new D("Graph.".concat(l,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new W("Graph.".concat(l,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(r=""+r,!(d=this._edges.get(r)))throw new D("Graph.".concat(l,': could not find the "').concat(r,'" edge in the graph.'))}if(typeof a!="function")throw new z("Graph.".concat(l,": provided updater is not a function."));return d.attributes=a(d.attributes),this.emit("edgeAttributesUpdated",{key:d.key,type:"update",attributes:d.attributes}),this}}}],ci=Q,di=_e,Ue=function(){var h=arguments,l=null,c=-1;return new ci((function(){for(var r=null;;){if(l===null){if(++c>=h.length)return{done:!0};l=di(h[c])}if((r=l.next()).done!==!0)break;l=null}return r}))},li=[{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 fi(h,l,c,r){var a=!1;for(var d in l)if(d!==r){var g=l[d];if(a=c(g.key,g.attributes,g.source.key,g.target.key,g.source.attributes,g.target.attributes,g.undirected),h&&a)return g.key}}function gi(h,l,c,r){var a,d,g,v=!1;for(var y in l)if(y!==r){a=l[y];do{if(d=a.source,g=a.target,v=c(a.key,a.attributes,d.key,g.key,d.attributes,g.attributes,a.undirected),h&&v)return a.key;a=a.next}while(a!==void 0)}}function Wt(h,l){var c,r=Object.keys(h),a=r.length,d=0;return new Q((function(){do if(c)c=c.next;else{if(d>=a)return{done:!0};var g=r[d++];if(g===l){c=void 0;continue}c=h[g]}while(!c);return{done:!1,value:{edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected}}}))}function pi(h,l,c,r){var a=l[c];if(a){var d=a.source,g=a.target;return r(a.key,a.attributes,d.key,g.key,d.attributes,g.attributes,a.undirected)&&h?a.key:void 0}}function vi(h,l,c,r){var a=l[c];if(a){var d=!1;do{if(d=r(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),h&&d)return a.key;a=a.next}while(a!==void 0)}}function jt(h,l){var c=h[l];return c.next!==void 0?new Q((function(){if(!c)return{done:!0};var r={edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected};return c=c.next,{done:!1,value:r}})):Q.of({edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected})}function mi(h,l){if(h.size===0)return[];if(l==="mixed"||l===h.type)return typeof Array.from=="function"?Array.from(h._edges.keys()):Oe(h._edges.keys(),h._edges.size);for(var c,r,a=l==="undirected"?h.undirectedSize:h.directedSize,d=new Array(a),g=l==="undirected",v=h._edges.values(),y=0;(c=v.next()).done!==!0;)(r=c.value).undirected===g&&(d[y++]=r.key);return d}function Cn(h,l,c,r){if(l.size!==0){for(var a,d,g=c!=="mixed"&&c!==l.type,v=c==="undirected",y=!1,A=l._edges.values();(a=A.next()).done!==!0;)if(d=a.value,!g||d.undirected===v){var C=d,R=C.key,P=C.attributes,F=C.source,j=C.target;if(y=r(R,P,F.key,j.key,F.attributes,j.attributes,d.undirected),h&&y)return R}}}function yi(h,l){if(h.size===0)return Q.empty();var c=l!=="mixed"&&l!==h.type,r=l==="undirected",a=h._edges.values();return new Q((function(){for(var d,g;;){if((d=a.next()).done)return d;if(g=d.value,!c||g.undirected===r)break}return{value:{edge:g.key,attributes:g.attributes,source:g.source.key,target:g.target.key,sourceAttributes:g.source.attributes,targetAttributes:g.target.attributes,undirected:g.undirected},done:!1}}))}function Vt(h,l,c,r,a,d){var g,v=l?gi:fi;if(c!=="undirected"&&(r!=="out"&&(g=v(h,a.in,d),h&&g)||r!=="in"&&(g=v(h,a.out,d,r?void 0:a.key),h&&g))||c!=="directed"&&(g=v(h,a.undirected,d),h&&g))return g}function bi(h,l,c,r){var a=[];return Vt(!1,h,l,c,r,(function(d){a.push(d)})),a}function wi(h,l,c){var r=Q.empty();return h!=="undirected"&&(l!=="out"&&c.in!==void 0&&(r=Ue(r,Wt(c.in))),l!=="in"&&c.out!==void 0&&(r=Ue(r,Wt(c.out,l?void 0:c.key)))),h!=="directed"&&c.undirected!==void 0&&(r=Ue(r,Wt(c.undirected))),r}function $t(h,l,c,r,a,d,g){var v,y=c?vi:pi;if(l!=="undirected"&&(a.in!==void 0&&r!=="out"&&(v=y(h,a.in,d,g),h&&v)||a.out!==void 0&&r!=="in"&&(r||a.key!==d)&&(v=y(h,a.out,d,g),h&&v))||l!=="directed"&&a.undirected!==void 0&&(v=y(h,a.undirected,d,g),h&&v))return v}function Ei(h,l,c,r,a){var d=[];return $t(!1,h,l,c,r,a,(function(g){d.push(g)})),d}function _i(h,l,c,r){var a=Q.empty();return h!=="undirected"&&(c.in!==void 0&&l!=="out"&&r in c.in&&(a=Ue(a,jt(c.in,r))),c.out!==void 0&&l!=="in"&&r in c.out&&(l||c.key!==r)&&(a=Ue(a,jt(c.out,r)))),h!=="directed"&&c.undirected!==void 0&&r in c.undirected&&(a=Ue(a,jt(c.undirected,r))),a}var Ri=[{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 Et(){this.A=null,this.B=null}function ct(h,l,c,r,a){for(var d in r){var g=r[d],v=g.source,y=g.target,A=v===c?y:v;if(!l||!l.has(A.key)){var C=a(A.key,A.attributes);if(h&&C)return A.key}}}function Yt(h,l,c,r,a){if(l!=="mixed"){if(l==="undirected")return ct(h,null,r,r.undirected,a);if(typeof c=="string")return ct(h,null,r,r[c],a)}var d,g=new Et;if(l!=="undirected"){if(c!=="out"){if(d=ct(h,null,r,r.in,a),h&&d)return d;g.wrap(r.in)}if(c!=="in"){if(d=ct(h,g,r,r.out,a),h&&d)return d;g.wrap(r.out)}}if(l!=="directed"&&(d=ct(h,g,r,r.undirected,a),h&&d))return d}function dt(h,l,c){var r=Object.keys(c),a=r.length,d=0;return new Q((function(){var g=null;do{if(d>=a)return h&&h.wrap(c),{done:!0};var v=c[r[d++]],y=v.source,A=v.target;g=y===l?A:y,h&&h.has(g.key)&&(g=null)}while(g===null);return{done:!1,value:{neighbor:g.key,attributes:g.attributes}}}))}function Ti(h,l){var c=l.name,r=l.type,a=l.direction;h.prototype[c]=function(d){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];d=""+d;var g=this._nodes.get(d);if(g===void 0)throw new D("Graph.".concat(c,': could not find the "').concat(d,'" node in the graph.'));return(function(v,y,A){if(v!=="mixed"){if(v==="undirected")return Object.keys(A.undirected);if(typeof y=="string")return Object.keys(A[y])}var C=[];return Yt(!1,v,y,A,(function(R){C.push(R)})),C})(r==="mixed"?this.type:r,a,g)}}function Ci(h,l){var c=l.name,r=l.type,a=l.direction,d=c.slice(0,-1)+"Entries";h.prototype[d]=function(g){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Q.empty();g=""+g;var v=this._nodes.get(g);if(v===void 0)throw new D("Graph.".concat(d,': could not find the "').concat(g,'" node in the graph.'));return(function(y,A,C){if(y!=="mixed"){if(y==="undirected")return dt(null,C,C.undirected);if(typeof A=="string")return dt(null,C,C[A])}var R=Q.empty(),P=new Et;return y!=="undirected"&&(A!=="out"&&(R=Ue(R,dt(P,C,C.in))),A!=="in"&&(R=Ue(R,dt(P,C,C.out)))),y!=="directed"&&(R=Ue(R,dt(P,C,C.undirected))),R})(r==="mixed"?this.type:r,a,v)}}function _t(h,l,c,r,a){for(var d,g,v,y,A,C,R,P=r._nodes.values(),F=r.type;(d=P.next()).done!==!0;){var j=!1;if(g=d.value,F!=="undirected")for(v in y=g.out){A=y[v];do{if(C=A.target,j=!0,R=a(g.key,C.key,g.attributes,C.attributes,A.key,A.attributes,A.undirected),h&&R)return A;A=A.next}while(A)}if(F!=="directed"){for(v in y=g.undirected)if(!(l&&g.key>v)){A=y[v];do{if((C=A.target).key!==v&&(C=A.source),j=!0,R=a(g.key,C.key,g.attributes,C.attributes,A.key,A.attributes,A.undirected),h&&R)return A;A=A.next}while(A)}}if(c&&!j&&(R=a(g.key,null,g.attributes,null,null,null,null),h&&R))return null}}function Si(h){if(!b(h))throw new z('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in h))throw new z("Graph.import: serialized node is missing its key.");if("attributes"in h&&(!b(h.attributes)||h.attributes===null))throw new z("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Ai(h){if(!b(h))throw new z('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in h))throw new z("Graph.import: serialized edge is missing its source.");if(!("target"in h))throw new z("Graph.import: serialized edge is missing its target.");if("attributes"in h&&(!b(h.attributes)||h.attributes===null))throw new z("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in h&&typeof h.undirected!="boolean")throw new z("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}Et.prototype.wrap=function(h){this.A===null?this.A=h:this.B===null&&(this.B=h)},Et.prototype.has=function(h){return this.A!==null&&h in this.A||this.B!==null&&h in this.B};var Sn,ki=(Sn=255&Math.floor(256*Math.random()),function(){return Sn++}),Li=new Set(["directed","undirected","mixed"]),An=new Set(["domain","_events","_eventsCount","_maxListeners"]),Gi={allowSelfLoops:!0,multi:!1,type:"mixed"};function kn(h,l,c){var r=new h.NodeDataClass(l,c);return h._nodes.set(l,r),h.emit("nodeAdded",{key:l,attributes:c}),r}function Ln(h,l,c,r,a,d,g,v){if(!r&&h.type==="undirected")throw new W("Graph.".concat(l,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&h.type==="directed")throw new W("Graph.".concat(l,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(v&&!b(v))throw new z("Graph.".concat(l,': invalid attributes. Expecting an object but got "').concat(v,'"'));if(d=""+d,g=""+g,v=v||{},!h.allowSelfLoops&&d===g)throw new W("Graph.".concat(l,': source & target are the same ("').concat(d,`"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`));var y=h._nodes.get(d),A=h._nodes.get(g);if(!y)throw new D("Graph.".concat(l,': source node "').concat(d,'" not found.'));if(!A)throw new D("Graph.".concat(l,': target node "').concat(g,'" not found.'));var C={key:null,undirected:r,source:d,target:g,attributes:v};if(c)a=h._edgeKeyGenerator();else if(a=""+a,h._edges.has(a))throw new W("Graph.".concat(l,': the "').concat(a,'" edge already exists in the graph.'));if(!h.multi&&(r?y.undirected[g]!==void 0:y.out[g]!==void 0))throw new W("Graph.".concat(l,': an edge linking "').concat(d,'" to "').concat(g,`" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`));var R=new nt(r,a,y,A,v);h._edges.set(a,R);var P=d===g;return r?(y.undirectedDegree++,A.undirectedDegree++,P&&(y.undirectedLoops++,h._undirectedSelfLoopCount++)):(y.outDegree++,A.inDegree++,P&&(y.directedLoops++,h._directedSelfLoopCount++)),h.multi?R.attachMulti():R.attach(),r?h._undirectedSize++:h._directedSize++,C.key=a,h.emit("edgeAdded",C),a}function xi(h,l,c,r,a,d,g,v,y){if(!r&&h.type==="undirected")throw new W("Graph.".concat(l,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(r&&h.type==="directed")throw new W("Graph.".concat(l,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(v){if(y){if(typeof v!="function")throw new z("Graph.".concat(l,': invalid updater function. Expecting a function but got "').concat(v,'"'))}else if(!b(v))throw new z("Graph.".concat(l,': invalid attributes. Expecting an object but got "').concat(v,'"'))}var A;if(d=""+d,g=""+g,y&&(A=v,v=void 0),!h.allowSelfLoops&&d===g)throw new W("Graph.".concat(l,': source & target are the same ("').concat(d,`"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`));var C,R,P=h._nodes.get(d),F=h._nodes.get(g);if(!c&&(C=h._edges.get(a))){if(!(C.source.key===d&&C.target.key===g||r&&C.source.key===g&&C.target.key===d))throw new W("Graph.".concat(l,': inconsistency detected when attempting to merge the "').concat(a,'" edge with "').concat(d,'" source & "').concat(g,'" target vs. ("').concat(C.source.key,'", "').concat(C.target.key,'").'));R=C}if(R||h.multi||!P||(R=r?P.undirected[g]:P.out[g]),R){var j=[R.key,!1,!1,!1];if(y?!A:!v)return j;if(y){var K=R.attributes;R.attributes=A(K),h.emit("edgeAttributesUpdated",{type:"replace",key:R.key,attributes:R.attributes})}else p(R.attributes,v),h.emit("edgeAttributesUpdated",{type:"merge",key:R.key,attributes:R.attributes,data:v});return j}v=v||{},y&&A&&(v=A(v));var re={key:null,undirected:r,source:d,target:g,attributes:v};if(c)a=h._edgeKeyGenerator();else if(a=""+a,h._edges.has(a))throw new W("Graph.".concat(l,': the "').concat(a,'" edge already exists in the graph.'));var ve=!1,ce=!1;P||(P=kn(h,d,{}),ve=!0,d===g&&(F=P,ce=!0)),F||(F=kn(h,g,{}),ce=!0),C=new nt(r,a,P,F,v),h._edges.set(a,C);var Se=d===g;return r?(P.undirectedDegree++,F.undirectedDegree++,Se&&(P.undirectedLoops++,h._undirectedSelfLoopCount++)):(P.outDegree++,F.inDegree++,Se&&(P.directedLoops++,h._directedSelfLoopCount++)),h.multi?C.attachMulti():C.attach(),r?h._undirectedSize++:h._directedSize++,re.key=a,h.emit("edgeAdded",re),[a,!0,ve,ce]}function rt(h,l){h._edges.delete(l.key);var c=l.source,r=l.target,a=l.attributes,d=l.undirected,g=c===r;d?(c.undirectedDegree--,r.undirectedDegree--,g&&(c.undirectedLoops--,h._undirectedSelfLoopCount--)):(c.outDegree--,r.inDegree--,g&&(c.directedLoops--,h._directedSelfLoopCount--)),h.multi?l.detachMulti():l.detach(),d?h._undirectedSize--:h._directedSize--,h.emit("edgeDropped",{key:l.key,attributes:a,source:c.key,target:r.key,undirected:d})}var ne=(function(h){function l(r){var a;if(a=h.call(this)||this,typeof(r=p({},Gi,r)).multi!="boolean")throw new z(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "`.concat(r.multi,'".'));if(!Li.has(r.type))throw new z(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "`.concat(r.type,'".'));if(typeof r.allowSelfLoops!="boolean")throw new z(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "`.concat(r.allowSelfLoops,'".'));var d=r.type==="mixed"?_n:r.type==="directed"?Rn:Tn;w(f(a),"NodeDataClass",d);var g="geid_"+ki()+"_",v=0;return w(f(a),"_attributes",{}),w(f(a),"_nodes",new Map),w(f(a),"_edges",new Map),w(f(a),"_directedSize",0),w(f(a),"_undirectedSize",0),w(f(a),"_directedSelfLoopCount",0),w(f(a),"_undirectedSelfLoopCount",0),w(f(a),"_edgeKeyGenerator",(function(){var y;do y=g+v++;while(a._edges.has(y));return y})),w(f(a),"_options",r),An.forEach((function(y){return w(f(a),y,a[y])})),S(f(a),"order",(function(){return a._nodes.size})),S(f(a),"size",(function(){return a._edges.size})),S(f(a),"directedSize",(function(){return a._directedSize})),S(f(a),"undirectedSize",(function(){return a._undirectedSize})),S(f(a),"selfLoopCount",(function(){return a._directedSelfLoopCount+a._undirectedSelfLoopCount})),S(f(a),"directedSelfLoopCount",(function(){return a._directedSelfLoopCount})),S(f(a),"undirectedSelfLoopCount",(function(){return a._undirectedSelfLoopCount})),S(f(a),"multi",a._options.multi),S(f(a),"type",a._options.type),S(f(a),"allowSelfLoops",a._options.allowSelfLoops),S(f(a),"implementation",(function(){return"graphology"})),a}o(l,h);var c=l.prototype;return c._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},c.hasNode=function(r){return this._nodes.has(""+r)},c.hasDirectedEdge=function(r,a){if(this.type==="undirected")return!1;if(arguments.length===1){var d=""+r,g=this._edges.get(d);return!!g&&!g.undirected}if(arguments.length===2){r=""+r,a=""+a;var v=this._nodes.get(r);return!!v&&v.out.hasOwnProperty(a)}throw new z("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.hasUndirectedEdge=function(r,a){if(this.type==="directed")return!1;if(arguments.length===1){var d=""+r,g=this._edges.get(d);return!!g&&g.undirected}if(arguments.length===2){r=""+r,a=""+a;var v=this._nodes.get(r);return!!v&&v.undirected.hasOwnProperty(a)}throw new z("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.hasEdge=function(r,a){if(arguments.length===1){var d=""+r;return this._edges.has(d)}if(arguments.length===2){r=""+r,a=""+a;var g=this._nodes.get(r);return!!g&&(g.out!==void 0&&g.out.hasOwnProperty(a)||g.undirected!==void 0&&g.undirected.hasOwnProperty(a))}throw new z("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.directedEdge=function(r,a){if(this.type!=="undirected"){if(r=""+r,a=""+a,this.multi)throw new W("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var d=this._nodes.get(r);if(!d)throw new D('Graph.directedEdge: could not find the "'.concat(r,'" source node in the graph.'));if(!this._nodes.has(a))throw new D('Graph.directedEdge: could not find the "'.concat(a,'" target node in the graph.'));var g=d.out&&d.out[a]||void 0;return g?g.key:void 0}},c.undirectedEdge=function(r,a){if(this.type!=="directed"){if(r=""+r,a=""+a,this.multi)throw new W("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var d=this._nodes.get(r);if(!d)throw new D('Graph.undirectedEdge: could not find the "'.concat(r,'" source node in the graph.'));if(!this._nodes.has(a))throw new D('Graph.undirectedEdge: could not find the "'.concat(a,'" target node in the graph.'));var g=d.undirected&&d.undirected[a]||void 0;return g?g.key:void 0}},c.edge=function(r,a){if(this.multi)throw new W("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.edge: could not find the "'.concat(r,'" source node in the graph.'));if(!this._nodes.has(a))throw new D('Graph.edge: could not find the "'.concat(a,'" target node in the graph.'));var g=d.out&&d.out[a]||d.undirected&&d.undirected[a]||void 0;if(g)return g.key},c.areDirectedNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areDirectedNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="undirected"&&(a in d.in||a in d.out)},c.areOutNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areOutNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="undirected"&&a in d.out},c.areInNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areInNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="undirected"&&a in d.in},c.areUndirectedNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areUndirectedNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="directed"&&a in d.undirected},c.areNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="undirected"&&(a in d.in||a in d.out)||this.type!=="directed"&&a in d.undirected},c.areInboundNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areInboundNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="undirected"&&a in d.in||this.type!=="directed"&&a in d.undirected},c.areOutboundNeighbors=function(r,a){r=""+r,a=""+a;var d=this._nodes.get(r);if(!d)throw new D('Graph.areOutboundNeighbors: could not find the "'.concat(r,'" node in the graph.'));return this.type!=="undirected"&&a in d.out||this.type!=="directed"&&a in d.undirected},c.inDegree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.inDegree: could not find the "'.concat(r,'" node in the graph.'));return this.type==="undirected"?0:a.inDegree},c.outDegree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.outDegree: could not find the "'.concat(r,'" node in the graph.'));return this.type==="undirected"?0:a.outDegree},c.directedDegree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.directedDegree: could not find the "'.concat(r,'" node in the graph.'));return this.type==="undirected"?0:a.inDegree+a.outDegree},c.undirectedDegree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.undirectedDegree: could not find the "'.concat(r,'" node in the graph.'));return this.type==="directed"?0:a.undirectedDegree},c.inboundDegree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.inboundDegree: could not find the "'.concat(r,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=a.undirectedDegree),this.type!=="undirected"&&(d+=a.inDegree),d},c.outboundDegree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.outboundDegree: could not find the "'.concat(r,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=a.undirectedDegree),this.type!=="undirected"&&(d+=a.outDegree),d},c.degree=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.degree: could not find the "'.concat(r,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=a.undirectedDegree),this.type!=="undirected"&&(d+=a.inDegree+a.outDegree),d},c.inDegreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));return this.type==="undirected"?0:a.inDegree-a.directedLoops},c.outDegreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));return this.type==="undirected"?0:a.outDegree-a.directedLoops},c.directedDegreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));return this.type==="undirected"?0:a.inDegree+a.outDegree-2*a.directedLoops},c.undirectedDegreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));return this.type==="directed"?0:a.undirectedDegree-2*a.undirectedLoops},c.inboundDegreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=a.undirectedDegree,g+=2*a.undirectedLoops),this.type!=="undirected"&&(d+=a.inDegree,g+=a.directedLoops),d-g},c.outboundDegreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=a.undirectedDegree,g+=2*a.undirectedLoops),this.type!=="undirected"&&(d+=a.outDegree,g+=a.directedLoops),d-g},c.degreeWithoutSelfLoops=function(r){r=""+r;var a=this._nodes.get(r);if(!a)throw new D('Graph.degreeWithoutSelfLoops: could not find the "'.concat(r,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=a.undirectedDegree,g+=2*a.undirectedLoops),this.type!=="undirected"&&(d+=a.inDegree+a.outDegree,g+=2*a.directedLoops),d-g},c.source=function(r){r=""+r;var a=this._edges.get(r);if(!a)throw new D('Graph.source: could not find the "'.concat(r,'" edge in the graph.'));return a.source.key},c.target=function(r){r=""+r;var a=this._edges.get(r);if(!a)throw new D('Graph.target: could not find the "'.concat(r,'" edge in the graph.'));return a.target.key},c.extremities=function(r){r=""+r;var a=this._edges.get(r);if(!a)throw new D('Graph.extremities: could not find the "'.concat(r,'" edge in the graph.'));return[a.source.key,a.target.key]},c.opposite=function(r,a){r=""+r,a=""+a;var d=this._edges.get(a);if(!d)throw new D('Graph.opposite: could not find the "'.concat(a,'" edge in the graph.'));var g=d.source.key,v=d.target.key;if(r===g)return v;if(r===v)return g;throw new D('Graph.opposite: the "'.concat(r,'" node is not attached to the "').concat(a,'" edge (').concat(g,", ").concat(v,")."))},c.hasExtremity=function(r,a){r=""+r,a=""+a;var d=this._edges.get(r);if(!d)throw new D('Graph.hasExtremity: could not find the "'.concat(r,'" edge in the graph.'));return d.source.key===a||d.target.key===a},c.isUndirected=function(r){r=""+r;var a=this._edges.get(r);if(!a)throw new D('Graph.isUndirected: could not find the "'.concat(r,'" edge in the graph.'));return a.undirected},c.isDirected=function(r){r=""+r;var a=this._edges.get(r);if(!a)throw new D('Graph.isDirected: could not find the "'.concat(r,'" edge in the graph.'));return!a.undirected},c.isSelfLoop=function(r){r=""+r;var a=this._edges.get(r);if(!a)throw new D('Graph.isSelfLoop: could not find the "'.concat(r,'" edge in the graph.'));return a.source===a.target},c.addNode=function(r,a){var d=(function(g,v,y){if(y&&!b(y))throw new z('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(y,'"'));if(v=""+v,y=y||{},g._nodes.has(v))throw new W('Graph.addNode: the "'.concat(v,'" node already exist in the graph.'));var A=new g.NodeDataClass(v,y);return g._nodes.set(v,A),g.emit("nodeAdded",{key:v,attributes:y}),A})(this,r,a);return d.key},c.mergeNode=function(r,a){if(a&&!b(a))throw new z('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(a,'"'));r=""+r,a=a||{};var d=this._nodes.get(r);return d?(a&&(p(d.attributes,a),this.emit("nodeAttributesUpdated",{type:"merge",key:r,attributes:d.attributes,data:a})),[r,!1]):(d=new this.NodeDataClass(r,a),this._nodes.set(r,d),this.emit("nodeAdded",{key:r,attributes:a}),[r,!0])},c.updateNode=function(r,a){if(a&&typeof a!="function")throw new z('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(a,'"'));r=""+r;var d=this._nodes.get(r);if(d){if(a){var g=d.attributes;d.attributes=a(g),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:d.attributes})}return[r,!1]}var v=a?a({}):{};return d=new this.NodeDataClass(r,v),this._nodes.set(r,d),this.emit("nodeAdded",{key:r,attributes:v}),[r,!0]},c.dropNode=function(r){r=""+r;var a,d=this._nodes.get(r);if(!d)throw new D('Graph.dropNode: could not find the "'.concat(r,'" node in the graph.'));if(this.type!=="undirected"){for(var g in d.out){a=d.out[g];do rt(this,a),a=a.next;while(a)}for(var v in d.in){a=d.in[v];do rt(this,a),a=a.next;while(a)}}if(this.type!=="directed")for(var y in d.undirected){a=d.undirected[y];do rt(this,a),a=a.next;while(a)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:d.attributes})},c.dropEdge=function(r){var a;if(arguments.length>1){var d=""+arguments[0],g=""+arguments[1];if(!(a=m(this,d,g,this.type)))throw new D('Graph.dropEdge: could not find the "'.concat(d,'" -> "').concat(g,'" edge in the graph.'))}else if(r=""+r,!(a=this._edges.get(r)))throw new D('Graph.dropEdge: could not find the "'.concat(r,'" edge in the graph.'));return rt(this,a),this},c.dropDirectedEdge=function(r,a){if(arguments.length<2)throw new W("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var d=m(this,r=""+r,a=""+a,"directed");if(!d)throw new D('Graph.dropDirectedEdge: could not find a "'.concat(r,'" -> "').concat(a,'" edge in the graph.'));return rt(this,d),this},c.dropUndirectedEdge=function(r,a){if(arguments.length<2)throw new W("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new W("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var d=m(this,r,a,"undirected");if(!d)throw new D('Graph.dropUndirectedEdge: could not find a "'.concat(r,'" -> "').concat(a,'" edge in the graph.'));return rt(this,d),this},c.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},c.clearEdges=function(){for(var r,a=this._nodes.values();(r=a.next()).done!==!0;)r.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},c.getAttribute=function(r){return this._attributes[r]},c.getAttributes=function(){return this._attributes},c.hasAttribute=function(r){return this._attributes.hasOwnProperty(r)},c.setAttribute=function(r,a){return this._attributes[r]=a,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this},c.updateAttribute=function(r,a){if(typeof a!="function")throw new z("Graph.updateAttribute: updater should be a function.");var d=this._attributes[r];return this._attributes[r]=a(d),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this},c.removeAttribute=function(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this},c.replaceAttributes=function(r){if(!b(r))throw new z("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},c.mergeAttributes=function(r){if(!b(r))throw new z("Graph.mergeAttributes: provided attributes are not a plain object.");return p(this._attributes,r),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:r}),this},c.updateAttributes=function(r){if(typeof r!="function")throw new z("Graph.updateAttributes: provided updater is not a function.");return this._attributes=r(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},c.updateEachNodeAttributes=function(r,a){if(typeof r!="function")throw new z("Graph.updateEachNodeAttributes: expecting an updater function.");if(a&&!x(a))throw new z("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var d,g,v=this._nodes.values();(d=v.next()).done!==!0;)(g=d.value).attributes=r(g.key,g.attributes);this.emit("eachNodeAttributesUpdated",{hints:a||null})},c.updateEachEdgeAttributes=function(r,a){if(typeof r!="function")throw new z("Graph.updateEachEdgeAttributes: expecting an updater function.");if(a&&!x(a))throw new z("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var d,g,v,y,A=this._edges.values();(d=A.next()).done!==!0;)v=(g=d.value).source,y=g.target,g.attributes=r(g.key,g.attributes,v.key,y.key,v.attributes,y.attributes,g.undirected);this.emit("eachEdgeAttributesUpdated",{hints:a||null})},c.forEachAdjacencyEntry=function(r){if(typeof r!="function")throw new z("Graph.forEachAdjacencyEntry: expecting a callback.");_t(!1,!1,!1,this,r)},c.forEachAdjacencyEntryWithOrphans=function(r){if(typeof r!="function")throw new z("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");_t(!1,!1,!0,this,r)},c.forEachAssymetricAdjacencyEntry=function(r){if(typeof r!="function")throw new z("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");_t(!1,!0,!1,this,r)},c.forEachAssymetricAdjacencyEntryWithOrphans=function(r){if(typeof r!="function")throw new z("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");_t(!1,!0,!0,this,r)},c.nodes=function(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):Oe(this._nodes.keys(),this._nodes.size)},c.forEachNode=function(r){if(typeof r!="function")throw new z("Graph.forEachNode: expecting a callback.");for(var a,d,g=this._nodes.values();(a=g.next()).done!==!0;)r((d=a.value).key,d.attributes)},c.findNode=function(r){if(typeof r!="function")throw new z("Graph.findNode: expecting a callback.");for(var a,d,g=this._nodes.values();(a=g.next()).done!==!0;)if(r((d=a.value).key,d.attributes))return d.key},c.mapNodes=function(r){if(typeof r!="function")throw new z("Graph.mapNode: expecting a callback.");for(var a,d,g=this._nodes.values(),v=new Array(this.order),y=0;(a=g.next()).done!==!0;)d=a.value,v[y++]=r(d.key,d.attributes);return v},c.someNode=function(r){if(typeof r!="function")throw new z("Graph.someNode: expecting a callback.");for(var a,d,g=this._nodes.values();(a=g.next()).done!==!0;)if(r((d=a.value).key,d.attributes))return!0;return!1},c.everyNode=function(r){if(typeof r!="function")throw new z("Graph.everyNode: expecting a callback.");for(var a,d,g=this._nodes.values();(a=g.next()).done!==!0;)if(!r((d=a.value).key,d.attributes))return!1;return!0},c.filterNodes=function(r){if(typeof r!="function")throw new z("Graph.filterNodes: expecting a callback.");for(var a,d,g=this._nodes.values(),v=[];(a=g.next()).done!==!0;)r((d=a.value).key,d.attributes)&&v.push(d.key);return v},c.reduceNodes=function(r,a){if(typeof r!="function")throw new z("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new z("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.");for(var d,g,v=a,y=this._nodes.values();(d=y.next()).done!==!0;)v=r(v,(g=d.value).key,g.attributes);return v},c.nodeEntries=function(){var r=this._nodes.values();return new Q((function(){var a=r.next();if(a.done)return a;var d=a.value;return{value:{node:d.key,attributes:d.attributes},done:!1}}))},c.export=function(){var r=this,a=new Array(this._nodes.size),d=0;this._nodes.forEach((function(v,y){a[d++]=(function(A,C){var R={key:A};return E(C.attributes)||(R.attributes=p({},C.attributes)),R})(y,v)}));var g=new Array(this._edges.size);return d=0,this._edges.forEach((function(v,y){g[d++]=(function(A,C,R){var P={key:C,source:R.source.key,target:R.target.key};return E(R.attributes)||(P.attributes=p({},R.attributes)),A==="mixed"&&R.undirected&&(P.undirected=!0),P})(r.type,y,v)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:a,edges:g}},c.import=function(r){var a,d,g,v,y,A=this,C=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(r instanceof l)return r.forEachNode((function(Ae,xe){C?A.mergeNode(Ae,xe):A.addNode(Ae,xe)})),r.forEachEdge((function(Ae,xe,Rt,Tt,Sa,Aa,Nn){C?Nn?A.mergeUndirectedEdgeWithKey(Ae,Rt,Tt,xe):A.mergeDirectedEdgeWithKey(Ae,Rt,Tt,xe):Nn?A.addUndirectedEdgeWithKey(Ae,Rt,Tt,xe):A.addDirectedEdgeWithKey(Ae,Rt,Tt,xe)})),this;if(!b(r))throw new z("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!b(r.attributes))throw new z("Graph.import: invalid attributes. Expecting a plain object.");C?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}if(r.nodes){if(g=r.nodes,!Array.isArray(g))throw new z("Graph.import: invalid nodes. Expecting an array.");for(a=0,d=g.length;a<d;a++){Si(v=g[a]);var R=v,P=R.key,F=R.attributes;C?this.mergeNode(P,F):this.addNode(P,F)}}if(r.edges){var j=!1;if(this.type==="undirected"&&(j=!0),g=r.edges,!Array.isArray(g))throw new z("Graph.import: invalid edges. Expecting an array.");for(a=0,d=g.length;a<d;a++){Ai(y=g[a]);var K=y,re=K.source,ve=K.target,ce=K.attributes,Se=K.undirected,ke=Se===void 0?j:Se;"key"in y?(C?ke?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:ke?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,y.key,re,ve,ce):(C?ke?this.mergeUndirectedEdge:this.mergeDirectedEdge:ke?this.addUndirectedEdge:this.addDirectedEdge).call(this,re,ve,ce)}}return this},c.nullCopy=function(r){var a=new l(p({},this._options,r));return a.replaceAttributes(p({},this.getAttributes())),a},c.emptyCopy=function(r){var a=this.nullCopy(r);return this._nodes.forEach((function(d,g){var v=p({},d.attributes);d=new a.NodeDataClass(g,v),a._nodes.set(g,d)})),a},c.copy=function(r){if(typeof(r=r||{}).type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new W('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(r.type,'" because this would mean losing information about the current graph.'));if(typeof r.multi=="boolean"&&r.multi!==this.multi&&r.multi!==!0)throw new W("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof r.allowSelfLoops=="boolean"&&r.allowSelfLoops!==this.allowSelfLoops&&r.allowSelfLoops!==!0)throw new W("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var a,d,g=this.emptyCopy(r),v=this._edges.values();(a=v.next()).done!==!0;)Ln(g,"copy",!1,(d=a.value).undirected,d.key,d.source.key,d.target.key,p({},d.attributes));return g},c.toJSON=function(){return this.export()},c.toString=function(){return"[object Graph]"},c.inspect=function(){var r=this,a={};this._nodes.forEach((function(A,C){a[C]=A.attributes}));var d={},g={};this._edges.forEach((function(A,C){var R,P=A.undirected?"--":"->",F="",j=A.source.key,K=A.target.key;A.undirected&&j>K&&(R=j,j=K,K=R);var re="(".concat(j,")").concat(P,"(").concat(K,")");C.startsWith("geid_")?r.multi&&(g[re]===void 0?g[re]=0:g[re]++,F+="".concat(g[re],". ")):F+="[".concat(C,"]: "),d[F+=re]=A.attributes}));var v={};for(var y in this)this.hasOwnProperty(y)&&!An.has(y)&&typeof this[y]!="function"&&i(y)!=="symbol"&&(v[y]=this[y]);return v.attributes=this._attributes,v.nodes=a,v.edges=d,w(v,"constructor",this.constructor),v},l})(O.exports.EventEmitter);typeof Symbol<"u"&&(ne.prototype[Symbol.for("nodejs.util.inspect.custom")]=ne.prototype.inspect),[{name:function(h){return"".concat(h,"Edge")},generateKey:!0},{name:function(h){return"".concat(h,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(h){return"".concat(h,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(h){return"".concat(h,"EdgeWithKey")}},{name:function(h){return"".concat(h,"DirectedEdgeWithKey")},type:"directed"},{name:function(h){return"".concat(h,"UndirectedEdgeWithKey")},type:"undirected"}].forEach((function(h){["add","merge","update"].forEach((function(l){var c=h.name(l),r=l==="add"?Ln:xi;h.generateKey?ne.prototype[c]=function(a,d,g){return r(this,c,!0,(h.type||this.type)==="undirected",null,a,d,g,l==="update")}:ne.prototype[c]=function(a,d,g,v){return r(this,c,!1,(h.type||this.type)==="undirected",a,d,g,v,l==="update")}}))})),(function(h){ui.forEach((function(l){var c=l.name,r=l.attacher;r(h,c("Node"),0),r(h,c("Source"),1),r(h,c("Target"),2),r(h,c("Opposite"),3)}))})(ne),(function(h){hi.forEach((function(l){var c=l.name,r=l.attacher;r(h,c("Edge"),"mixed"),r(h,c("DirectedEdge"),"directed"),r(h,c("UndirectedEdge"),"undirected")}))})(ne),(function(h){li.forEach((function(l){(function(c,r){var a=r.name,d=r.type,g=r.direction;c.prototype[a]=function(v,y){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return[];if(!arguments.length)return mi(this,d);if(arguments.length===1){v=""+v;var A=this._nodes.get(v);if(A===void 0)throw new D("Graph.".concat(a,': could not find the "').concat(v,'" node in the graph.'));return bi(this.multi,d==="mixed"?this.type:d,g,A)}if(arguments.length===2){v=""+v,y=""+y;var C=this._nodes.get(v);if(!C)throw new D("Graph.".concat(a,': could not find the "').concat(v,'" source node in the graph.'));if(!this._nodes.has(y))throw new D("Graph.".concat(a,': could not find the "').concat(y,'" target node in the graph.'));return Ei(d,this.multi,g,C,y)}throw new z("Graph.".concat(a,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}})(h,l),(function(c,r){var a=r.name,d=r.type,g=r.direction,v="forEach"+a[0].toUpperCase()+a.slice(1,-1);c.prototype[v]=function(R,P,F){if(d==="mixed"||this.type==="mixed"||d===this.type){if(arguments.length===1)return Cn(!1,this,d,F=R);if(arguments.length===2){R=""+R,F=P;var j=this._nodes.get(R);if(j===void 0)throw new D("Graph.".concat(v,': could not find the "').concat(R,'" node in the graph.'));return Vt(!1,this.multi,d==="mixed"?this.type:d,g,j,F)}if(arguments.length===3){R=""+R,P=""+P;var K=this._nodes.get(R);if(!K)throw new D("Graph.".concat(v,': could not find the "').concat(R,'" source node in the graph.'));if(!this._nodes.has(P))throw new D("Graph.".concat(v,': could not find the "').concat(P,'" target node in the graph.'));return $t(!1,d,this.multi,g,K,P,F)}throw new z("Graph.".concat(v,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var y="map"+a[0].toUpperCase()+a.slice(1);c.prototype[y]=function(){var R,P=Array.prototype.slice.call(arguments),F=P.pop();if(P.length===0){var j=0;d!=="directed"&&(j+=this.undirectedSize),d!=="undirected"&&(j+=this.directedSize),R=new Array(j);var K=0;P.push((function(re,ve,ce,Se,ke,Ae,xe){R[K++]=F(re,ve,ce,Se,ke,Ae,xe)}))}else R=[],P.push((function(re,ve,ce,Se,ke,Ae,xe){R.push(F(re,ve,ce,Se,ke,Ae,xe))}));return this[v].apply(this,P),R};var A="filter"+a[0].toUpperCase()+a.slice(1);c.prototype[A]=function(){var R=Array.prototype.slice.call(arguments),P=R.pop(),F=[];return R.push((function(j,K,re,ve,ce,Se,ke){P(j,K,re,ve,ce,Se,ke)&&F.push(j)})),this[v].apply(this,R),F};var C="reduce"+a[0].toUpperCase()+a.slice(1);c.prototype[C]=function(){var R,P,F=Array.prototype.slice.call(arguments);if(F.length<2||F.length>4)throw new z("Graph.".concat(C,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(F.length,")."));if(typeof F[F.length-1]=="function"&&typeof F[F.length-2]!="function")throw new z("Graph.".concat(C,": 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."));F.length===2?(R=F[0],P=F[1],F=[]):F.length===3?(R=F[1],P=F[2],F=[F[0]]):F.length===4&&(R=F[2],P=F[3],F=[F[0],F[1]]);var j=P;return F.push((function(K,re,ve,ce,Se,ke,Ae){j=R(j,K,re,ve,ce,Se,ke,Ae)})),this[v].apply(this,F),j}})(h,l),(function(c,r){var a=r.name,d=r.type,g=r.direction,v="find"+a[0].toUpperCase()+a.slice(1,-1);c.prototype[v]=function(C,R,P){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return!1;if(arguments.length===1)return Cn(!0,this,d,P=C);if(arguments.length===2){C=""+C,P=R;var F=this._nodes.get(C);if(F===void 0)throw new D("Graph.".concat(v,': could not find the "').concat(C,'" node in the graph.'));return Vt(!0,this.multi,d==="mixed"?this.type:d,g,F,P)}if(arguments.length===3){C=""+C,R=""+R;var j=this._nodes.get(C);if(!j)throw new D("Graph.".concat(v,': could not find the "').concat(C,'" source node in the graph.'));if(!this._nodes.has(R))throw new D("Graph.".concat(v,': could not find the "').concat(R,'" target node in the graph.'));return $t(!0,d,this.multi,g,j,R,P)}throw new z("Graph.".concat(v,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var y="some"+a[0].toUpperCase()+a.slice(1,-1);c.prototype[y]=function(){var C=Array.prototype.slice.call(arguments),R=C.pop();return C.push((function(P,F,j,K,re,ve,ce){return R(P,F,j,K,re,ve,ce)})),!!this[v].apply(this,C)};var A="every"+a[0].toUpperCase()+a.slice(1,-1);c.prototype[A]=function(){var C=Array.prototype.slice.call(arguments),R=C.pop();return C.push((function(P,F,j,K,re,ve,ce){return!R(P,F,j,K,re,ve,ce)})),!this[v].apply(this,C)}})(h,l),(function(c,r){var a=r.name,d=r.type,g=r.direction,v=a.slice(0,-1)+"Entries";c.prototype[v]=function(y,A){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return Q.empty();if(!arguments.length)return yi(this,d);if(arguments.length===1){y=""+y;var C=this._nodes.get(y);if(!C)throw new D("Graph.".concat(v,': could not find the "').concat(y,'" node in the graph.'));return wi(d,g,C)}if(arguments.length===2){y=""+y,A=""+A;var R=this._nodes.get(y);if(!R)throw new D("Graph.".concat(v,': could not find the "').concat(y,'" source node in the graph.'));if(!this._nodes.has(A))throw new D("Graph.".concat(v,': could not find the "').concat(A,'" target node in the graph.'));return _i(d,g,R,A)}throw new z("Graph.".concat(v,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}})(h,l)}))})(ne),(function(h){Ri.forEach((function(l){Ti(h,l),(function(c,r){var a=r.name,d=r.type,g=r.direction,v="forEach"+a[0].toUpperCase()+a.slice(1,-1);c.prototype[v]=function(R,P){if(d==="mixed"||this.type==="mixed"||d===this.type){R=""+R;var F=this._nodes.get(R);if(F===void 0)throw new D("Graph.".concat(v,': could not find the "').concat(R,'" node in the graph.'));Yt(!1,d==="mixed"?this.type:d,g,F,P)}};var y="map"+a[0].toUpperCase()+a.slice(1);c.prototype[y]=function(R,P){var F=[];return this[v](R,(function(j,K){F.push(P(j,K))})),F};var A="filter"+a[0].toUpperCase()+a.slice(1);c.prototype[A]=function(R,P){var F=[];return this[v](R,(function(j,K){P(j,K)&&F.push(j)})),F};var C="reduce"+a[0].toUpperCase()+a.slice(1);c.prototype[C]=function(R,P,F){if(arguments.length<3)throw new z("Graph.".concat(C,": 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."));var j=F;return this[v](R,(function(K,re){j=P(j,K,re)})),j}})(h,l),(function(c,r){var a=r.name,d=r.type,g=r.direction,v=a[0].toUpperCase()+a.slice(1,-1),y="find"+v;c.prototype[y]=function(R,P){if(d==="mixed"||this.type==="mixed"||d===this.type){R=""+R;var F=this._nodes.get(R);if(F===void 0)throw new D("Graph.".concat(y,': could not find the "').concat(R,'" node in the graph.'));return Yt(!0,d==="mixed"?this.type:d,g,F,P)}};var A="some"+v;c.prototype[A]=function(R,P){return!!this[y](R,P)};var C="every"+v;c.prototype[C]=function(R,P){return!this[y](R,(function(F,j){return!P(F,j)}))}})(h,l),Ci(h,l)}))})(ne);var Gn=(function(h){function l(c){var r=p({type:"directed"},c);if("multi"in r&&r.multi!==!1)throw new z("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(r.type!=="directed")throw new z('DirectedGraph.from: inconsistent "'+r.type+'" type in given options!');return h.call(this,r)||this}return o(l,h),l})(ne),xn=(function(h){function l(c){var r=p({type:"undirected"},c);if("multi"in r&&r.multi!==!1)throw new z("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(r.type!=="undirected")throw new z('UndirectedGraph.from: inconsistent "'+r.type+'" type in given options!');return h.call(this,r)||this}return o(l,h),l})(ne),Dn=(function(h){function l(c){var r=p({multi:!0},c);if("multi"in r&&r.multi!==!0)throw new z("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return h.call(this,r)||this}return o(l,h),l})(ne),Pn=(function(h){function l(c){var r=p({type:"directed",multi:!0},c);if("multi"in r&&r.multi!==!0)throw new z("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(r.type!=="directed")throw new z('MultiDirectedGraph.from: inconsistent "'+r.type+'" type in given options!');return h.call(this,r)||this}return o(l,h),l})(ne),Fn=(function(h){function l(c){var r=p({type:"undirected",multi:!0},c);if("multi"in r&&r.multi!==!0)throw new z("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(r.type!=="undirected")throw new z('MultiUndirectedGraph.from: inconsistent "'+r.type+'" type in given options!');return h.call(this,r)||this}return o(l,h),l})(ne);function it(h){h.from=function(l,c){var r=p({},l.options,c),a=new h(r);return a.import(l),a}}return it(ne),it(Gn),it(xn),it(Dn),it(Pn),it(Fn),ne.Graph=ne,ne.DirectedGraph=Gn,ne.UndirectedGraph=xn,ne.MultiGraph=Dn,ne.MultiDirectedGraph=Pn,ne.MultiUndirectedGraph=Fn,ne.InvalidArgumentsGraphError=z,ne.NotFoundGraphError=D,ne.UsageGraphError=W,ne}))});var Ct=$e((La,Un)=>{Un.exports=function(o){return o!==null&&typeof o=="object"&&typeof o.addUndirectedEdgeWithKey=="function"&&typeof o.dropNode=="function"&&typeof o.multi=="boolean"}});var Mn=$e(St=>{function Ui(i){return typeof i!="number"||isNaN(i)?1:i}function Ii(i,o){var e={},t=function(s){return typeof s>"u"?o:s};typeof o=="function"&&(t=o);var n=function(s){return t(s[i])},u=function(){return t(void 0)};return typeof i=="string"?(e.fromAttributes=n,e.fromGraph=function(s,f){return n(s.getNodeAttributes(f))},e.fromEntry=function(s,f){return n(f)}):typeof i=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},e.fromGraph=function(s,f){return t(i(f,s.getNodeAttributes(f)))},e.fromEntry=function(s,f){return t(i(s,f))}):(e.fromAttributes=u,e.fromGraph=u,e.fromEntry=u),e}function In(i,o){var e={},t=function(s){return typeof s>"u"?o:s};typeof o=="function"&&(t=o);var n=function(s){return t(s[i])},u=function(){return t(void 0)};return typeof i=="string"?(e.fromAttributes=n,e.fromGraph=function(s,f){return n(s.getEdgeAttributes(f))},e.fromEntry=function(s,f){return n(f)},e.fromPartialEntry=e.fromEntry,e.fromMinimalEntry=e.fromEntry):typeof i=="function"?(e.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},e.fromGraph=function(s,f){var p=s.extremities(f);return t(i(f,s.getEdgeAttributes(f),p[0],p[1],s.getNodeAttributes(p[0]),s.getNodeAttributes(p[1]),s.isUndirected(f)))},e.fromEntry=function(s,f,p,m,b,E,w){return t(i(s,f,p,m,b,E,w))},e.fromPartialEntry=function(s,f,p,m){return t(i(s,f,p,m))},e.fromMinimalEntry=function(s,f){return t(i(s,f))}):(e.fromAttributes=u,e.fromGraph=u,e.fromEntry=u,e.fromMinimalEntry=u),e}St.createNodeValueGetter=Ii;St.createEdgeValueGetter=In;St.createEdgeWeightGetter=function(i){return In(i,Ui)}});var Vn=$e((xa,jn)=>{var he=0,oe=1,$=2,Y=3,Ie=4,Me=5,Z=6,Bn=7,At=8,Hn=9,Mi=0,Bi=1,Hi=2,de=0,Le=1,Ee=2,Je=3,Ye=4,ae=5,Re=6,Fe=7,Ne=8,Wn=3,De=10,Wi=3,ye=9,Zt=10;jn.exports=function(o,e,t){var n,u,s,f,p,m,b,E,w,S,x=e.length,N=t.length,O=o.adjustSizes,H=o.barnesHutTheta*o.barnesHutTheta,I,G,T,B,V,L,M,_=[];for(s=0;s<x;s+=De)e[s+Ie]=e[s+$],e[s+Me]=e[s+Y],e[s+$]=0,e[s+Y]=0;if(o.outboundAttractionDistribution){for(I=0,s=0;s<x;s+=De)I+=e[s+Z];I/=x/De}if(o.barnesHutOptimize){var ee=1/0,ie=-1/0,te=1/0,ge=-1/0,q,X,Q;for(s=0;s<x;s+=De)ee=Math.min(ee,e[s+he]),ie=Math.max(ie,e[s+he]),te=Math.min(te,e[s+oe]),ge=Math.max(ge,e[s+oe]);var Te=ie-ee,Ce=ge-te;for(Te>Ce?(te-=(Te-Ce)/2,ge=te+Te):(ee-=(Ce-Te)/2,ie=ee+Ce),_[0+de]=-1,_[0+Le]=(ee+ie)/2,_[0+Ee]=(te+ge)/2,_[0+Je]=Math.max(ie-ee,ge-te),_[0+Ye]=-1,_[0+ae]=-1,_[0+Re]=0,_[0+Fe]=0,_[0+Ne]=0,n=1,s=0;s<x;s+=De)for(u=0,Q=Wn;;)if(_[u+ae]>=0){e[s+he]<_[u+Le]?e[s+oe]<_[u+Ee]?q=_[u+ae]:q=_[u+ae]+ye:e[s+oe]<_[u+Ee]?q=_[u+ae]+ye*2:q=_[u+ae]+ye*3,_[u+Fe]=(_[u+Fe]*_[u+Re]+e[s+he]*e[s+Z])/(_[u+Re]+e[s+Z]),_[u+Ne]=(_[u+Ne]*_[u+Re]+e[s+oe]*e[s+Z])/(_[u+Re]+e[s+Z]),_[u+Re]+=e[s+Z],u=q;continue}else if(_[u+de]<0){_[u+de]=s;break}else{if(_[u+ae]=n*ye,E=_[u+Je]/2,w=_[u+ae],_[w+de]=-1,_[w+Le]=_[u+Le]-E,_[w+Ee]=_[u+Ee]-E,_[w+Je]=E,_[w+Ye]=w+ye,_[w+ae]=-1,_[w+Re]=0,_[w+Fe]=0,_[w+Ne]=0,w+=ye,_[w+de]=-1,_[w+Le]=_[u+Le]-E,_[w+Ee]=_[u+Ee]+E,_[w+Je]=E,_[w+Ye]=w+ye,_[w+ae]=-1,_[w+Re]=0,_[w+Fe]=0,_[w+Ne]=0,w+=ye,_[w+de]=-1,_[w+Le]=_[u+Le]+E,_[w+Ee]=_[u+Ee]-E,_[w+Je]=E,_[w+Ye]=w+ye,_[w+ae]=-1,_[w+Re]=0,_[w+Fe]=0,_[w+Ne]=0,w+=ye,_[w+de]=-1,_[w+Le]=_[u+Le]+E,_[w+Ee]=_[u+Ee]+E,_[w+Je]=E,_[w+Ye]=_[u+Ye],_[w+ae]=-1,_[w+Re]=0,_[w+Fe]=0,_[w+Ne]=0,n+=4,e[_[u+de]+he]<_[u+Le]?e[_[u+de]+oe]<_[u+Ee]?q=_[u+ae]:q=_[u+ae]+ye:e[_[u+de]+oe]<_[u+Ee]?q=_[u+ae]+ye*2:q=_[u+ae]+ye*3,_[u+Re]=e[_[u+de]+Z],_[u+Fe]=e[_[u+de]+he],_[u+Ne]=e[_[u+de]+oe],_[q+de]=_[u+de],_[u+de]=-1,e[s+he]<_[u+Le]?e[s+oe]<_[u+Ee]?X=_[u+ae]:X=_[u+ae]+ye:e[s+oe]<_[u+Ee]?X=_[u+ae]+ye*2:X=_[u+ae]+ye*3,q===X)if(Q--){u=q;continue}else{Q=Wn;break}_[X+de]=s;break}}if(o.barnesHutOptimize)for(G=o.scalingRatio,s=0;s<x;s+=De)for(u=0;;)if(_[u+ae]>=0)if(L=Math.pow(e[s+he]-_[u+Fe],2)+Math.pow(e[s+oe]-_[u+Ne],2),S=_[u+Je],4*S*S/L<H){if(T=e[s+he]-_[u+Fe],B=e[s+oe]-_[u+Ne],O===!0?L>0?(M=G*e[s+Z]*_[u+Re]/L,e[s+$]+=T*M,e[s+Y]+=B*M):L<0&&(M=-G*e[s+Z]*_[u+Re]/Math.sqrt(L),e[s+$]+=T*M,e[s+Y]+=B*M):L>0&&(M=G*e[s+Z]*_[u+Re]/L,e[s+$]+=T*M,e[s+Y]+=B*M),u=_[u+Ye],u<0)break;continue}else{u=_[u+ae];continue}else{if(m=_[u+de],m>=0&&m!==s&&(T=e[s+he]-e[m+he],B=e[s+oe]-e[m+oe],L=T*T+B*B,O===!0?L>0?(M=G*e[s+Z]*e[m+Z]/L,e[s+$]+=T*M,e[s+Y]+=B*M):L<0&&(M=-G*e[s+Z]*e[m+Z]/Math.sqrt(L),e[s+$]+=T*M,e[s+Y]+=B*M):L>0&&(M=G*e[s+Z]*e[m+Z]/L,e[s+$]+=T*M,e[s+Y]+=B*M)),u=_[u+Ye],u<0)break;continue}else for(G=o.scalingRatio,f=0;f<x;f+=De)for(p=0;p<f;p+=De)T=e[f+he]-e[p+he],B=e[f+oe]-e[p+oe],O===!0?(L=Math.sqrt(T*T+B*B)-e[f+At]-e[p+At],L>0?(M=G*e[f+Z]*e[p+Z]/L/L,e[f+$]+=T*M,e[f+Y]+=B*M,e[p+$]-=T*M,e[p+Y]-=B*M):L<0&&(M=100*G*e[f+Z]*e[p+Z],e[f+$]+=T*M,e[f+Y]+=B*M,e[p+$]-=T*M,e[p+Y]-=B*M)):(L=Math.sqrt(T*T+B*B),L>0&&(M=G*e[f+Z]*e[p+Z]/L/L,e[f+$]+=T*M,e[f+Y]+=B*M,e[p+$]-=T*M,e[p+Y]-=B*M));for(w=o.gravity/o.scalingRatio,G=o.scalingRatio,s=0;s<x;s+=De)M=0,T=e[s+he],B=e[s+oe],L=Math.sqrt(Math.pow(T,2)+Math.pow(B,2)),o.strongGravityMode?L>0&&(M=G*e[s+Z]*w):L>0&&(M=G*e[s+Z]*w/L),e[s+$]-=T*M,e[s+Y]-=B*M;for(G=1*(o.outboundAttractionDistribution?I:1),b=0;b<N;b+=Wi)f=t[b+Mi],p=t[b+Bi],E=t[b+Hi],V=Math.pow(E,o.edgeWeightInfluence),T=e[f+he]-e[p+he],B=e[f+oe]-e[p+oe],O===!0?(L=Math.sqrt(T*T+B*B)-e[f+At]-e[p+At],o.linLogMode?o.outboundAttractionDistribution?L>0&&(M=-G*V*Math.log(1+L)/L/e[f+Z]):L>0&&(M=-G*V*Math.log(1+L)/L):o.outboundAttractionDistribution?L>0&&(M=-G*V/e[f+Z]):L>0&&(M=-G*V)):(L=Math.sqrt(Math.pow(T,2)+Math.pow(B,2)),o.linLogMode?o.outboundAttractionDistribution?L>0&&(M=-G*V*Math.log(1+L)/L/e[f+Z]):L>0&&(M=-G*V*Math.log(1+L)/L):o.outboundAttractionDistribution?(L=1,M=-G*V/e[f+Z]):(L=1,M=-G*V)),L>0&&(e[f+$]+=T*M,e[f+Y]+=B*M,e[p+$]-=T*M,e[p+Y]-=B*M);var be,me,we,_e,pe,Oe;if(O===!0)for(s=0;s<x;s+=De)e[s+Hn]!==1&&(be=Math.sqrt(Math.pow(e[s+$],2)+Math.pow(e[s+Y],2)),be>Zt&&(e[s+$]=e[s+$]*Zt/be,e[s+Y]=e[s+Y]*Zt/be),me=e[s+Z]*Math.sqrt((e[s+Ie]-e[s+$])*(e[s+Ie]-e[s+$])+(e[s+Me]-e[s+Y])*(e[s+Me]-e[s+Y])),we=Math.sqrt((e[s+Ie]+e[s+$])*(e[s+Ie]+e[s+$])+(e[s+Me]+e[s+Y])*(e[s+Me]+e[s+Y]))/2,_e=.1*Math.log(1+we)/(1+Math.sqrt(me)),pe=e[s+he]+e[s+$]*(_e/o.slowDown),e[s+he]=pe,Oe=e[s+oe]+e[s+Y]*(_e/o.slowDown),e[s+oe]=Oe);else for(s=0;s<x;s+=De)e[s+Hn]!==1&&(me=e[s+Z]*Math.sqrt((e[s+Ie]-e[s+$])*(e[s+Ie]-e[s+$])+(e[s+Me]-e[s+Y])*(e[s+Me]-e[s+Y])),we=Math.sqrt((e[s+Ie]+e[s+$])*(e[s+Ie]+e[s+$])+(e[s+Me]+e[s+Y])*(e[s+Me]+e[s+Y]))/2,_e=e[s+Bn]*Math.log(1+we)/(1+Math.sqrt(me)),e[s+Bn]=Math.min(1,Math.sqrt(_e*(Math.pow(e[s+$],2)+Math.pow(e[s+Y],2))/(1+Math.sqrt(me)))),pe=e[s+he]+e[s+$]*(_e/o.slowDown),e[s+he]=pe,Oe=e[s+oe]+e[s+Y]*(_e/o.slowDown),e[s+oe]=Oe);return{}}});var Yn=$e(qe=>{var lt=10,$n=3;qe.assign=function(i){i=i||{};var o=Array.prototype.slice.call(arguments).slice(1),e,t,n;for(e=0,n=o.length;e<n;e++)if(o[e])for(t in o[e])i[t]=o[e][t];return i};qe.validateSettings=function(i){return"linLogMode"in i&&typeof i.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in i&&typeof i.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in i&&typeof i.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in i&&typeof i.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in i&&!(typeof i.scalingRatio=="number"&&i.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in i&&typeof i.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in i&&!(typeof i.gravity=="number"&&i.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in i&&!(typeof i.slowDown=="number"||i.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in i&&typeof i.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in i&&!(typeof i.barnesHutTheta=="number"&&i.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};qe.graphToByteArrays=function(i,o){var e=i.order,t=i.size,n={},u,s=new Float32Array(e*lt),f=new Float32Array(t*$n);return u=0,i.forEachNode(function(p,m){n[p]=u,s[u]=m.x,s[u+1]=m.y,s[u+2]=0,s[u+3]=0,s[u+4]=0,s[u+5]=0,s[u+6]=1,s[u+7]=1,s[u+8]=m.size||1,s[u+9]=m.fixed?1:0,u+=lt}),u=0,i.forEachEdge(function(p,m,b,E,w,S,x){var N=n[b],O=n[E],H=o(p,m,b,E,w,S,x);s[N+6]+=H,s[O+6]+=H,f[u]=N,f[u+1]=O,f[u+2]=H,u+=$n}),{nodes:s,edges:f}};qe.assignLayoutChanges=function(i,o,e){var t=0;i.updateEachNodeAttributes(function(n,u){return u.x=o[t],u.y=o[t+1],t+=lt,e?e(n,u):u})};qe.readGraphPositions=function(i,o){var e=0;i.forEachNode(function(t,n){o[e]=n.x,o[e+1]=n.y,e+=lt})};qe.collectLayoutChanges=function(i,o,e){for(var t=i.nodes(),n={},u=0,s=0,f=o.length;u<f;u+=lt){if(e){var p=Object.assign({},i.getNodeAttributes(t[s]));p.x=o[u],p.y=o[u+1],p=e(t[s],p),n[t[s]]={x:p.x,y:p.y}}else n[t[s]]={x:o[u],y:o[u+1]};s++}return n};qe.createWorker=function(o){var e=window.URL||window.webkitURL,t=o.toString(),n=e.createObjectURL(new Blob(["("+t+").call(this);"],{type:"text/javascript"})),u=new Worker(n);return e.revokeObjectURL(n),u}});var Kn=$e((Pa,qn)=>{qn.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}});var Jn=$e((Fa,Xn)=>{var ji=Ct(),Vi=Mn().createEdgeWeightGetter,$i=Vn(),ft=Yn(),Yi=Kn();function Zn(i,o,e){if(!ji(o))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 n=Vi("getEdgeWeight"in e?e.getEdgeWeight:"weight").fromEntry,u=typeof e.outputReducer=="function"?e.outputReducer:null,s=ft.assign({},Yi,e.settings),f=ft.validateSettings(s);if(f)throw new Error("graphology-layout-forceatlas2: "+f.message);var p=ft.graphToByteArrays(o,n),m;for(m=0;m<t;m++)$i(s,p.nodes,p.edges);if(i){ft.assignLayoutChanges(o,p.nodes,u);return}return ft.collectLayoutChanges(o,p.nodes)}function qi(i){var o=typeof i=="number"?i:i.order;return{barnesHutOptimize:o>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(o)}}var Xt=Zn.bind(null,!1);Xt.assign=Zn.bind(null,!0);Xt.inferSettings=qi;Xn.exports=Xt});var fn=$e((Ha,ln)=>{"use strict";var ut=typeof Reflect=="object"?Reflect:null,Rr=ut&&typeof ut.apply=="function"?ut.apply:function(o,e,t){return Function.prototype.apply.call(o,e,t)},Dt;ut&&typeof ut.ownKeys=="function"?Dt=ut.ownKeys:Object.getOwnPropertySymbols?Dt=function(o){return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o))}:Dt=function(o){return Object.getOwnPropertyNames(o)};function Do(i){console&&console.warn&&console.warn(i)}var Cr=Number.isNaN||function(o){return o!==o};function J(){J.init.call(this)}ln.exports=J;ln.exports.once=Oo;J.EventEmitter=J;J.prototype._events=void 0;J.prototype._eventsCount=0;J.prototype._maxListeners=void 0;var Tr=10;function Pt(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(J,"defaultMaxListeners",{enumerable:!0,get:function(){return Tr},set:function(i){if(typeof i!="number"||i<0||Cr(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");Tr=i}});J.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};J.prototype.setMaxListeners=function(o){if(typeof o!="number"||o<0||Cr(o))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+o+".");return this._maxListeners=o,this};function Sr(i){return i._maxListeners===void 0?J.defaultMaxListeners:i._maxListeners}J.prototype.getMaxListeners=function(){return Sr(this)};J.prototype.emit=function(o){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);var n=o==="error",u=this._events;if(u!==void 0)n=n&&u.error===void 0;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var f=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw f.context=s,f}var p=u[o];if(p===void 0)return!1;if(typeof p=="function")Rr(p,this,e);else for(var m=p.length,b=xr(p,m),t=0;t<m;++t)Rr(b[t],this,e);return!0};function Ar(i,o,e,t){var n,u,s;if(Pt(e),u=i._events,u===void 0?(u=i._events=Object.create(null),i._eventsCount=0):(u.newListener!==void 0&&(i.emit("newListener",o,e.listener?e.listener:e),u=i._events),s=u[o]),s===void 0)s=u[o]=e,++i._eventsCount;else if(typeof s=="function"?s=u[o]=t?[e,s]:[s,e]:t?s.unshift(e):s.push(e),n=Sr(i),n>0&&s.length>n&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(o)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=i,f.type=o,f.count=s.length,Do(f)}return i}J.prototype.addListener=function(o,e){return Ar(this,o,e,!1)};J.prototype.on=J.prototype.addListener;J.prototype.prependListener=function(o,e){return Ar(this,o,e,!0)};function Po(){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 kr(i,o,e){var t={fired:!1,wrapFn:void 0,target:i,type:o,listener:e},n=Po.bind(t);return n.listener=e,t.wrapFn=n,n}J.prototype.once=function(o,e){return Pt(e),this.on(o,kr(this,o,e)),this};J.prototype.prependOnceListener=function(o,e){return Pt(e),this.prependListener(o,kr(this,o,e)),this};J.prototype.removeListener=function(o,e){var t,n,u,s,f;if(Pt(e),n=this._events,n===void 0)return this;if(t=n[o],t===void 0)return this;if(t===e||t.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete n[o],n.removeListener&&this.emit("removeListener",o,t.listener||e));else if(typeof t!="function"){for(u=-1,s=t.length-1;s>=0;s--)if(t[s]===e||t[s].listener===e){f=t[s].listener,u=s;break}if(u<0)return this;u===0?t.shift():Fo(t,u),t.length===1&&(n[o]=t[0]),n.removeListener!==void 0&&this.emit("removeListener",o,f||e)}return this};J.prototype.off=J.prototype.removeListener;J.prototype.removeAllListeners=function(o){var e,t,n;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[o]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[o]),this;if(arguments.length===0){var u=Object.keys(t),s;for(n=0;n<u.length;++n)s=u[n],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=t[o],typeof e=="function")this.removeListener(o,e);else if(e!==void 0)for(n=e.length-1;n>=0;n--)this.removeListener(o,e[n]);return this};function Lr(i,o,e){var t=i._events;if(t===void 0)return[];var n=t[o];return n===void 0?[]:typeof n=="function"?e?[n.listener||n]:[n]:e?No(n):xr(n,n.length)}J.prototype.listeners=function(o){return Lr(this,o,!0)};J.prototype.rawListeners=function(o){return Lr(this,o,!1)};J.listenerCount=function(i,o){return typeof i.listenerCount=="function"?i.listenerCount(o):Gr.call(i,o)};J.prototype.listenerCount=Gr;function Gr(i){var o=this._events;if(o!==void 0){var e=o[i];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}J.prototype.eventNames=function(){return this._eventsCount>0?Dt(this._events):[]};function xr(i,o){for(var e=new Array(o),t=0;t<o;++t)e[t]=i[t];return e}function Fo(i,o){for(;o+1<i.length;o++)i[o]=i[o+1];i.pop()}function No(i){for(var o=new Array(i.length),e=0;e<o.length;++e)o[e]=i[e].listener||i[e];return o}function Oo(i,o){return new Promise(function(e,t){function n(s){i.removeListener(o,u),t(s)}function u(){typeof i.removeListener=="function"&&i.removeListener("error",n),e([].slice.call(arguments))}Dr(i,o,u,{once:!0}),o!=="error"&&zo(i,n,{once:!0})})}function zo(i,o,e){typeof i.on=="function"&&Dr(i,"error",o,e)}function Dr(i,o,e,t){if(typeof i.on=="function")t.once?i.once(o,e):i.on(o,e);else if(typeof i.addEventListener=="function")i.addEventListener(o,function n(u){t.once&&i.removeEventListener(o,n),e(u)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}});var ai=ot(zn(),1),wn=ot(Jn(),1);function Ki(i,o){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var t=e.call(i,o||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(i)}function et(i){var o=Ki(i,"string");return typeof o=="symbol"?o:o+""}function se(i,o){if(!(i instanceof o))throw new TypeError("Cannot call a class as a function")}function Qn(i,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,et(t.key),t)}}function ue(i,o,e){return o&&Qn(i.prototype,o),e&&Qn(i,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function Qe(i){return Qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Qe(i)}function er(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(er=function(){return!!i})()}function Zi(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Xi(i,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Zi(i)}function le(i,o,e){return o=Qe(o),Xi(i,er()?Reflect.construct(o,e||[],Qe(i).constructor):o.apply(i,e))}function Jt(i,o){return Jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Jt(i,o)}function fe(i,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(o&&o.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),o&&Jt(i,o)}function Ji(i){if(Array.isArray(i))return i}function Qi(i,o){var e=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(e!=null){var t,n,u,s,f=[],p=!0,m=!1;try{if(u=(e=e.call(i)).next,o===0){if(Object(e)!==e)return;p=!1}else for(;!(p=(t=u.call(e)).done)&&(f.push(t.value),f.length!==o);p=!0);}catch(b){m=!0,n=b}finally{try{if(!p&&e.return!=null&&(s=e.return(),Object(s)!==s))return}finally{if(m)throw n}}return f}}function kt(i,o){(o==null||o>i.length)&&(o=i.length);for(var e=0,t=Array(o);e<o;e++)t[e]=i[e];return t}function nn(i,o){if(i){if(typeof i=="string")return kt(i,o);var e={}.toString.call(i).slice(8,-1);return e==="Object"&&i.constructor&&(e=i.constructor.name),e==="Map"||e==="Set"?Array.from(i):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?kt(i,o):void 0}}function eo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ke(i,o){return Ji(i)||Qi(i,o)||nn(i,o)||eo()}var Qt={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"};var tr=new Int8Array(4),en=new Int32Array(tr.buffer,0,1),to=new Float32Array(tr.buffer,0,1),no=/^\s*rgba?\s*\(/,ro=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function io(i){var o=0,e=0,t=0,n=1;if(i[0]==="#")i.length===4?(o=parseInt(i.charAt(1)+i.charAt(1),16),e=parseInt(i.charAt(2)+i.charAt(2),16),t=parseInt(i.charAt(3)+i.charAt(3),16)):(o=parseInt(i.charAt(1)+i.charAt(2),16),e=parseInt(i.charAt(3)+i.charAt(4),16),t=parseInt(i.charAt(5)+i.charAt(6),16)),i.length===9&&(n=parseInt(i.charAt(7)+i.charAt(8),16)/255);else if(no.test(i)){var u=i.match(ro);u&&(o=+u[1],e=+u[2],t=+u[3],u[4]&&(n=+u[4]))}return{r:o,g:e,b:t,a:n}}var at={};for(gt in Qt)at[gt]=Be(Qt[gt]),at[Qt[gt]]=at[gt];var gt;function nr(i,o,e,t,n){return en[0]=t<<24|e<<16|o<<8|i,n&&(en[0]=en[0]&4278190079),to[0]}function Be(i){if(i=i.toLowerCase(),typeof at[i]<"u")return at[i];var o=io(i),e=o.r,t=o.g,n=o.b,u=o.a;u=u*255|0;var s=nr(e,t,n,u,!0);return at[i]=s,s}var tn={};function rn(i){if(typeof tn[i]<"u")return tn[i];var o=(i&16711680)>>>16,e=(i&65280)>>>8,t=i&255,n=255,u=nr(o,e,t,n,!0);return tn[i]=u,u}function on(i,o,e,t){return e+(o<<8)+(i<<16)}function an(i,o,e,t,n,u){var s=Math.floor(e/u*n),f=Math.floor(i.drawingBufferHeight/u-t/u*n),p=new Uint8Array(4);i.bindFramebuffer(i.FRAMEBUFFER,o),i.readPixels(s,f,1,1,i.RGBA,i.UNSIGNED_BYTE,p);var m=Ke(p,4),b=m[0],E=m[1],w=m[2],S=m[3];return[b,E,w,S]}function k(i,o,e){return(o=et(o))in i?Object.defineProperty(i,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[o]=e,i}function rr(i,o){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(i);o&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(i,n).enumerable})),e.push.apply(e,t)}return e}function U(i){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?rr(Object(e),!0).forEach(function(t){k(i,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):rr(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))})}return i}function oo(i,o){for(;!{}.hasOwnProperty.call(i,o)&&(i=Qe(i))!==null;);return i}function hn(){return hn=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(i,o,e){var t=oo(i,o);if(t){var n=Object.getOwnPropertyDescriptor(t,o);return n.get?n.get.call(arguments.length<3?i:e):n.value}},hn.apply(null,arguments)}function cr(i,o,e,t){var n=hn(Qe(1&t?i.prototype:i),o,e);return 2&t&&typeof n=="function"?function(u){return n.apply(e,u)}:n}function ao(i){return i.normalized?1:i.size}function sn(i){var o=0;return i.forEach(function(e){return o+=ao(e)}),o}function dr(i,o,e){var t=i==="VERTEX"?o.VERTEX_SHADER:o.FRAGMENT_SHADER,n=o.createShader(t);if(n===null)throw new Error("loadShader: error while creating the shader");o.shaderSource(n,e),o.compileShader(n);var u=o.getShaderParameter(n,o.COMPILE_STATUS);if(!u){var s=o.getShaderInfoLog(n);throw o.deleteShader(n),new Error(`loadShader: error while compiling the shader:
|
|
3
|
+
`.concat(s,`
|
|
4
|
+
`).concat(e))}return n}function so(i,o){return dr("VERTEX",i,o)}function uo(i,o){return dr("FRAGMENT",i,o)}function ho(i,o){var e=i.createProgram();if(e===null)throw new Error("loadProgram: error while creating the program.");var t,n;for(t=0,n=o.length;t<n;t++)i.attachShader(e,o[t]);i.linkProgram(e);var u=i.getProgramParameter(e,i.LINK_STATUS);if(!u)throw i.deleteProgram(e),new Error("loadProgram: error while linking the program.");return e}function ir(i){var o=i.gl,e=i.buffer,t=i.program,n=i.vertexShader,u=i.fragmentShader;o.deleteShader(n),o.deleteShader(u),o.deleteProgram(t),o.deleteBuffer(e)}var or=`#define PICKING_MODE
|
|
5
|
+
`,co=k(k(k(k(k(k(k(k({},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);var lr=(function(){function i(o,e,t){se(this,i),k(this,"array",new Float32Array),k(this,"constantArray",new Float32Array),k(this,"capacity",0),k(this,"verticesCount",0);var n=this.getDefinition();if(this.VERTICES=n.VERTICES,this.VERTEX_SHADER_SOURCE=n.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=n.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=n.UNIFORMS,this.ATTRIBUTES=n.ATTRIBUTES,this.METHOD=n.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in n?n.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in n?n.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in n,this.ATTRIBUTES_ITEMS_COUNT=sn(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=t,this.normalProgram=this.getProgramInfo("normal",o,n.VERTEX_SHADER_SOURCE,n.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=e?this.getProgramInfo("pick",o,or+n.VERTEX_SHADER_SOURCE,or+n.FRAGMENT_SHADER_SOURCE,e):null,this.isInstanced){var u=sn(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*u);for(var s=0;s<this.CONSTANT_DATA.length;s++){var f=this.CONSTANT_DATA[s];if(f.length!==u)throw new Error("Program: error while getting constant data (one vector has ".concat(f.length," items instead of ").concat(u,")"));for(var p=0;p<f.length;p++)this.constantArray[s*u+p]=f[p]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return ue(i,[{key:"kill",value:function(){ir(this.normalProgram),this.pickProgram&&(ir(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(e,t,n,u,s){var f=this.getDefinition(),p=t.createBuffer();if(p===null)throw new Error("Program: error while creating the WebGL buffer.");var m=so(t,n),b=uo(t,u),E=ho(t,[m,b]),w={};f.UNIFORMS.forEach(function(N){var O=t.getUniformLocation(E,N);O&&(w[N]=O)});var S={};f.ATTRIBUTES.forEach(function(N){S[N.name]=t.getAttribLocation(E,N.name)});var x;if("CONSTANT_ATTRIBUTES"in f&&(f.CONSTANT_ATTRIBUTES.forEach(function(N){S[N.name]=t.getAttribLocation(E,N.name)}),x=t.createBuffer(),x===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:e,program:E,gl:t,frameBuffer:s,buffer:p,constantBuffer:x||{},uniformLocations:w,attributeLocations:S,isPicking:e==="pick",vertexShader:m,fragmentShader:b}}},{key:"bindProgram",value:function(e){var t=this,n=0,u=e.gl,s=e.buffer;this.isInstanced?(u.bindBuffer(u.ARRAY_BUFFER,e.constantBuffer),n=0,this.CONSTANT_ATTRIBUTES.forEach(function(f){return n+=t.bindAttribute(f,e,n,!1)}),u.bufferData(u.ARRAY_BUFFER,this.constantArray,u.STATIC_DRAW),u.bindBuffer(u.ARRAY_BUFFER,e.buffer),n=0,this.ATTRIBUTES.forEach(function(f){return n+=t.bindAttribute(f,e,n,!0)}),u.bufferData(u.ARRAY_BUFFER,this.array,u.DYNAMIC_DRAW)):(u.bindBuffer(u.ARRAY_BUFFER,s),n=0,this.ATTRIBUTES.forEach(function(f){return n+=t.bindAttribute(f,e,n)}),u.bufferData(u.ARRAY_BUFFER,this.array,u.DYNAMIC_DRAW)),u.bindBuffer(u.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(e){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!1)}),this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!0)})):this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e)})}},{key:"bindAttribute",value:function(e,t,n,u){var s=co[e.type];if(typeof s!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(e.type,'"'));var f=t.attributeLocations[e.name],p=t.gl;if(f!==-1){p.enableVertexAttribArray(f);var m=this.isInstanced?(u?this.ATTRIBUTES_ITEMS_COUNT:sn(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(p.vertexAttribPointer(f,e.size,e.type,e.normalized||!1,m,n),this.isInstanced&&u)if(p instanceof WebGL2RenderingContext)p.vertexAttribDivisor(f,1);else{var b=p.getExtension("ANGLE_instanced_arrays");b&&b.vertexAttribDivisorANGLE(f,1)}}return e.size*s}},{key:"unbindAttribute",value:function(e,t,n){var u=t.attributeLocations[e.name],s=t.gl;if(u!==-1&&(s.disableVertexAttribArray(u),this.isInstanced&&n))if(s instanceof WebGL2RenderingContext)s.vertexAttribDivisor(u,0);else{var f=s.getExtension("ANGLE_instanced_arrays");f&&f.vertexAttribDivisorANGLE(u,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 n=t.gl,u=t.program;n.enable(n.BLEND),n.useProgram(u),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(U(U({},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 n=t.gl,u=t.frameBuffer;if(n.bindFramebuffer(n.FRAMEBUFFER,u),!this.isInstanced)n.drawArrays(e,0,this.verticesCount);else if(n instanceof WebGL2RenderingContext)n.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{var s=n.getExtension("ANGLE_instanced_arrays");s&&s.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}])})();var fr=(function(i){function o(){return se(this,o),le(this,o,arguments)}return fe(o,i),ue(o,[{key:"kill",value:function(){cr(o,"kill",this,3)([])}},{key:"process",value:function(t,n,u){var s=n*this.STRIDE;if(u.hidden){for(var f=s+this.STRIDE;s<f;s++)this.array[s]=0;return}return this.processVisibleItem(rn(t),s,u)}}])})(lr);var st=(function(i){function o(){var e;se(this,o);for(var t=arguments.length,n=new Array(t),u=0;u<t;u++)n[u]=arguments[u];return e=le(this,o,[].concat(n)),k(e,"drawLabel",void 0),e}return fe(o,i),ue(o,[{key:"kill",value:function(){cr(o,"kill",this,3)([])}},{key:"process",value:function(t,n,u,s,f){var p=n*this.STRIDE;if(f.hidden||u.hidden||s.hidden){for(var m=p+this.STRIDE;p<m;p++)this.array[p]=0;return}return this.processVisibleItem(rn(t),p,u,s,f)}}])})(lr);function cn(i,o){return(function(){function e(t,n,u){se(this,e),k(this,"drawLabel",o),this.programs=i.map(function(s){return new s(t,n,u)})}return ue(e,[{key:"reallocate",value:function(n){this.programs.forEach(function(u){return u.reallocate(n)})}},{key:"process",value:function(n,u,s,f,p){this.programs.forEach(function(m){return m.process(n,u,s,f,p)})}},{key:"render",value:function(n){this.programs.forEach(function(u){return u.render(n)})}},{key:"kill",value:function(){this.programs.forEach(function(n){return n.kill()})}}])})()}function gr(i,o,e,t,n){var u=n.edgeLabelSize,s=n.edgeLabelFont,f=n.edgeLabelWeight,p=n.edgeLabelColor.attribute?o[n.edgeLabelColor.attribute]||n.edgeLabelColor.color||"#000":n.edgeLabelColor.color,m=o.label;if(m){i.fillStyle=p,i.font="".concat(f," ").concat(u,"px ").concat(s);var b=e.size,E=t.size,w=e.x,S=e.y,x=t.x,N=t.y,O=(w+x)/2,H=(S+N)/2,I=x-w,G=N-S,T=Math.sqrt(I*I+G*G);if(!(T<b+E)){w+=I*b/T,S+=G*b/T,x-=I*E/T,N-=G*E/T,O=(w+x)/2,H=(S+N)/2,I=x-w,G=N-S,T=Math.sqrt(I*I+G*G);var B=i.measureText(m).width;if(B>T){var V="\u2026";for(m=m+V,B=i.measureText(m).width;B>T&&m.length>1;)m=m.slice(0,-2)+V,B=i.measureText(m).width;if(m.length<4)return}var L;I>0?G>0?L=Math.acos(I/T):L=Math.asin(G/T):G>0?L=Math.acos(I/T)+Math.PI:L=Math.asin(I/T)+Math.PI/2,i.save(),i.translate(O,H),i.rotate(L),i.fillText(m,-B/2,o.size/2+u),i.restore()}}}function dn(i,o,e){if(o.label){var t=e.labelSize,n=e.labelFont,u=e.labelWeight,s=e.labelColor.attribute?o[e.labelColor.attribute]||e.labelColor.color||"#000":e.labelColor.color;i.fillStyle=s,i.font="".concat(u," ").concat(t,"px ").concat(n),i.fillText(o.label,o.x+o.size+3,o.y+t/3)}}function pr(i,o,e){var t=e.labelSize,n=e.labelFont,u=e.labelWeight;i.font="".concat(u," ").concat(t,"px ").concat(n),i.fillStyle="#FFF",i.shadowOffsetX=0,i.shadowOffsetY=0,i.shadowBlur=8,i.shadowColor="#000";var s=2;if(typeof o.label=="string"){var f=i.measureText(o.label).width,p=Math.round(f+5),m=Math.round(t+2*s),b=Math.max(o.size,t/2)+s,E=Math.asin(m/2/b),w=Math.sqrt(Math.abs(Math.pow(b,2)-Math.pow(m/2,2)));i.beginPath(),i.moveTo(o.x+w,o.y+m/2),i.lineTo(o.x+b+p,o.y+m/2),i.lineTo(o.x+b+p,o.y-m/2),i.lineTo(o.x+w,o.y-m/2),i.arc(o.x,o.y,b,E,-E),i.closePath(),i.fill()}else i.beginPath(),i.arc(o.x,o.y,o.size+s,0,Math.PI*2),i.closePath(),i.fill();i.shadowOffsetX=0,i.shadowOffsetY=0,i.shadowBlur=0,dn(i,o,e)}var lo=`
|
|
6
|
+
precision highp float;
|
|
7
|
+
|
|
8
|
+
varying vec4 v_color;
|
|
9
|
+
varying vec2 v_diffVector;
|
|
10
|
+
varying float v_radius;
|
|
11
|
+
|
|
12
|
+
uniform float u_correctionRatio;
|
|
13
|
+
|
|
14
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
15
|
+
|
|
16
|
+
void main(void) {
|
|
17
|
+
float border = u_correctionRatio * 2.0;
|
|
18
|
+
float dist = length(v_diffVector) - v_radius + border;
|
|
19
|
+
|
|
20
|
+
// No antialiasing for picking mode:
|
|
21
|
+
#ifdef PICKING_MODE
|
|
22
|
+
if (dist > border)
|
|
23
|
+
gl_FragColor = transparent;
|
|
24
|
+
else
|
|
25
|
+
gl_FragColor = v_color;
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
float t = 0.0;
|
|
29
|
+
if (dist > border)
|
|
30
|
+
t = 1.0;
|
|
31
|
+
else if (dist > 0.0)
|
|
32
|
+
t = dist / border;
|
|
33
|
+
|
|
34
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
`,fo=lo,go=`
|
|
38
|
+
attribute vec4 a_id;
|
|
39
|
+
attribute vec4 a_color;
|
|
40
|
+
attribute vec2 a_position;
|
|
41
|
+
attribute float a_size;
|
|
42
|
+
attribute float a_angle;
|
|
43
|
+
|
|
44
|
+
uniform mat3 u_matrix;
|
|
45
|
+
uniform float u_sizeRatio;
|
|
46
|
+
uniform float u_correctionRatio;
|
|
47
|
+
|
|
48
|
+
varying vec4 v_color;
|
|
49
|
+
varying vec2 v_diffVector;
|
|
50
|
+
varying float v_radius;
|
|
51
|
+
varying float v_border;
|
|
52
|
+
|
|
53
|
+
const float bias = 255.0 / 254.0;
|
|
54
|
+
|
|
55
|
+
void main() {
|
|
56
|
+
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
57
|
+
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
58
|
+
vec2 position = a_position + diffVector;
|
|
59
|
+
gl_Position = vec4(
|
|
60
|
+
(u_matrix * vec3(position, 1)).xy,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
v_diffVector = diffVector;
|
|
66
|
+
v_radius = size / 2.0;
|
|
67
|
+
|
|
68
|
+
#ifdef PICKING_MODE
|
|
69
|
+
// For picking mode, we use the ID as the color:
|
|
70
|
+
v_color = a_id;
|
|
71
|
+
#else
|
|
72
|
+
// For normal mode, we use the color:
|
|
73
|
+
v_color = a_color;
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
v_color.a *= bias;
|
|
77
|
+
}
|
|
78
|
+
`,po=go,vr=WebGLRenderingContext,ar=vr.UNSIGNED_BYTE,un=vr.FLOAT,vo=["u_sizeRatio","u_correctionRatio","u_matrix"],vt=(function(i){function o(){return se(this,o),le(this,o,arguments)}return fe(o,i),ue(o,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:po,FRAGMENT_SHADER_SOURCE:fo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vo,ATTRIBUTES:[{name:"a_position",size:2,type:un},{name:"a_size",size:1,type:un},{name:"a_color",size:4,type:ar,normalized:!0},{name:"a_id",size:4,type:ar,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:un}],CONSTANT_DATA:[[o.ANGLE_1],[o.ANGLE_2],[o.ANGLE_3]]}}},{key:"processVisibleItem",value:function(t,n,u){var s=this.array,f=Be(u.color);s[n++]=u.x,s[n++]=u.y,s[n++]=u.size,s[n++]=f,s[n++]=t}},{key:"setUniforms",value:function(t,n){var u=n.gl,s=n.uniformLocations,f=s.u_sizeRatio,p=s.u_correctionRatio,m=s.u_matrix;u.uniform1f(p,t.correctionRatio),u.uniform1f(f,t.sizeRatio),u.uniformMatrix3fv(m,!1,t.matrix)}}])})(fr);k(vt,"ANGLE_1",0);k(vt,"ANGLE_2",2*Math.PI/3);k(vt,"ANGLE_3",4*Math.PI/3);var mo=`
|
|
79
|
+
precision mediump float;
|
|
80
|
+
|
|
81
|
+
varying vec4 v_color;
|
|
82
|
+
|
|
83
|
+
void main(void) {
|
|
84
|
+
gl_FragColor = v_color;
|
|
85
|
+
}
|
|
86
|
+
`,yo=mo,bo=`
|
|
87
|
+
attribute vec2 a_position;
|
|
88
|
+
attribute vec2 a_normal;
|
|
89
|
+
attribute float a_radius;
|
|
90
|
+
attribute vec3 a_barycentric;
|
|
91
|
+
|
|
92
|
+
#ifdef PICKING_MODE
|
|
93
|
+
attribute vec4 a_id;
|
|
94
|
+
#else
|
|
95
|
+
attribute vec4 a_color;
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
uniform mat3 u_matrix;
|
|
99
|
+
uniform float u_sizeRatio;
|
|
100
|
+
uniform float u_correctionRatio;
|
|
101
|
+
uniform float u_minEdgeThickness;
|
|
102
|
+
uniform float u_lengthToThicknessRatio;
|
|
103
|
+
uniform float u_widenessToThicknessRatio;
|
|
104
|
+
|
|
105
|
+
varying vec4 v_color;
|
|
106
|
+
|
|
107
|
+
const float bias = 255.0 / 254.0;
|
|
108
|
+
|
|
109
|
+
void main() {
|
|
110
|
+
float minThickness = u_minEdgeThickness;
|
|
111
|
+
|
|
112
|
+
float normalLength = length(a_normal);
|
|
113
|
+
vec2 unitNormal = a_normal / normalLength;
|
|
114
|
+
|
|
115
|
+
// These first computations are taken from edge.vert.glsl and
|
|
116
|
+
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
117
|
+
// happening:
|
|
118
|
+
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
119
|
+
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
120
|
+
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
121
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
122
|
+
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
123
|
+
|
|
124
|
+
float da = a_barycentric.x;
|
|
125
|
+
float db = a_barycentric.y;
|
|
126
|
+
float dc = a_barycentric.z;
|
|
127
|
+
|
|
128
|
+
vec2 delta = vec2(
|
|
129
|
+
da * (webGLNodeRadius * unitNormal.y)
|
|
130
|
+
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
131
|
+
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
132
|
+
|
|
133
|
+
da * (-webGLNodeRadius * unitNormal.x)
|
|
134
|
+
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
135
|
+
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
139
|
+
|
|
140
|
+
gl_Position = vec4(position, 0, 1);
|
|
141
|
+
|
|
142
|
+
#ifdef PICKING_MODE
|
|
143
|
+
// For picking mode, we use the ID as the color:
|
|
144
|
+
v_color = a_id;
|
|
145
|
+
#else
|
|
146
|
+
// For normal mode, we use the color:
|
|
147
|
+
v_color = a_color;
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
v_color.a *= bias;
|
|
151
|
+
}
|
|
152
|
+
`,wo=bo,mr=WebGLRenderingContext,sr=mr.UNSIGNED_BYTE,Lt=mr.FLOAT,Eo=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Gt={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function mt(i){var o=U(U({},Gt),i||{});return(function(e){function t(){return se(this,t),le(this,t,arguments)}return fe(t,e),ue(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:wo,FRAGMENT_SHADER_SOURCE:yo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Eo,ATTRIBUTES:[{name:"a_position",size:2,type:Lt},{name:"a_normal",size:2,type:Lt},{name:"a_radius",size:1,type:Lt},{name:"a_color",size:4,type:sr,normalized:!0},{name:"a_id",size:4,type:sr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Lt}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(u,s,f,p,m){if(o.extremity==="source"){var b=[p,f];f=b[0],p=b[1]}var E=m.size||1,w=p.size||1,S=f.x,x=f.y,N=p.x,O=p.y,H=Be(m.color),I=N-S,G=O-x,T=I*I+G*G,B=0,V=0;T&&(T=1/Math.sqrt(T),B=-G*T*E,V=I*T*E);var L=this.array;L[s++]=N,L[s++]=O,L[s++]=-B,L[s++]=-V,L[s++]=w,L[s++]=H,L[s++]=u}},{key:"setUniforms",value:function(u,s){var f=s.gl,p=s.uniformLocations,m=p.u_matrix,b=p.u_sizeRatio,E=p.u_correctionRatio,w=p.u_minEdgeThickness,S=p.u_lengthToThicknessRatio,x=p.u_widenessToThicknessRatio;f.uniformMatrix3fv(m,!1,u.matrix),f.uniform1f(b,u.sizeRatio),f.uniform1f(E,u.correctionRatio),f.uniform1f(w,u.minEdgeThickness),f.uniform1f(S,o.lengthToThicknessRatio),f.uniform1f(x,o.widenessToThicknessRatio)}}])})(st)}var Ia=mt();var _o=`
|
|
153
|
+
precision mediump float;
|
|
154
|
+
|
|
155
|
+
varying vec4 v_color;
|
|
156
|
+
varying vec2 v_normal;
|
|
157
|
+
varying float v_thickness;
|
|
158
|
+
varying float v_feather;
|
|
159
|
+
|
|
160
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
161
|
+
|
|
162
|
+
void main(void) {
|
|
163
|
+
// We only handle antialiasing for normal mode:
|
|
164
|
+
#ifdef PICKING_MODE
|
|
165
|
+
gl_FragColor = v_color;
|
|
166
|
+
#else
|
|
167
|
+
float dist = length(v_normal) * v_thickness;
|
|
168
|
+
|
|
169
|
+
float t = smoothstep(
|
|
170
|
+
v_thickness - v_feather,
|
|
171
|
+
v_thickness,
|
|
172
|
+
dist
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
176
|
+
#endif
|
|
177
|
+
}
|
|
178
|
+
`,xt=_o,Ro=`
|
|
179
|
+
attribute vec4 a_id;
|
|
180
|
+
attribute vec4 a_color;
|
|
181
|
+
attribute vec2 a_normal;
|
|
182
|
+
attribute float a_normalCoef;
|
|
183
|
+
attribute vec2 a_positionStart;
|
|
184
|
+
attribute vec2 a_positionEnd;
|
|
185
|
+
attribute float a_positionCoef;
|
|
186
|
+
attribute float a_radius;
|
|
187
|
+
attribute float a_radiusCoef;
|
|
188
|
+
|
|
189
|
+
uniform mat3 u_matrix;
|
|
190
|
+
uniform float u_zoomRatio;
|
|
191
|
+
uniform float u_sizeRatio;
|
|
192
|
+
uniform float u_pixelRatio;
|
|
193
|
+
uniform float u_correctionRatio;
|
|
194
|
+
uniform float u_minEdgeThickness;
|
|
195
|
+
uniform float u_lengthToThicknessRatio;
|
|
196
|
+
uniform float u_feather;
|
|
197
|
+
|
|
198
|
+
varying vec4 v_color;
|
|
199
|
+
varying vec2 v_normal;
|
|
200
|
+
varying float v_thickness;
|
|
201
|
+
varying float v_feather;
|
|
202
|
+
|
|
203
|
+
const float bias = 255.0 / 254.0;
|
|
204
|
+
|
|
205
|
+
void main() {
|
|
206
|
+
float minThickness = u_minEdgeThickness;
|
|
207
|
+
|
|
208
|
+
float radius = a_radius * a_radiusCoef;
|
|
209
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
210
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
211
|
+
|
|
212
|
+
float normalLength = length(normal);
|
|
213
|
+
vec2 unitNormal = normal / normalLength;
|
|
214
|
+
|
|
215
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
216
|
+
// get better comments on what's happening:
|
|
217
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
218
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
219
|
+
|
|
220
|
+
// Here, we move the point to leave space for the arrow head:
|
|
221
|
+
float direction = sign(radius);
|
|
222
|
+
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
223
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
224
|
+
|
|
225
|
+
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
226
|
+
|
|
227
|
+
// Here is the proper position of the vertex
|
|
228
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
229
|
+
|
|
230
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
231
|
+
|
|
232
|
+
v_normal = unitNormal;
|
|
233
|
+
|
|
234
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
235
|
+
|
|
236
|
+
#ifdef PICKING_MODE
|
|
237
|
+
// For picking mode, we use the ID as the color:
|
|
238
|
+
v_color = a_id;
|
|
239
|
+
#else
|
|
240
|
+
// For normal mode, we use the color:
|
|
241
|
+
v_color = a_color;
|
|
242
|
+
#endif
|
|
243
|
+
|
|
244
|
+
v_color.a *= bias;
|
|
245
|
+
}
|
|
246
|
+
`,To=Ro,yr=WebGLRenderingContext,ur=yr.UNSIGNED_BYTE,tt=yr.FLOAT,Co=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],So={lengthToThicknessRatio:Gt.lengthToThicknessRatio};function br(i){var o=U(U({},So),i||{});return(function(e){function t(){return se(this,t),le(this,t,arguments)}return fe(t,e),ue(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:To,FRAGMENT_SHADER_SOURCE:xt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Co,ATTRIBUTES:[{name:"a_positionStart",size:2,type:tt},{name:"a_positionEnd",size:2,type:tt},{name:"a_normal",size:2,type:tt},{name:"a_color",size:4,type:ur,normalized:!0},{name:"a_id",size:4,type:ur,normalized:!0},{name:"a_radius",size:1,type:tt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:tt},{name:"a_normalCoef",size:1,type:tt},{name:"a_radiusCoef",size:1,type:tt}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(u,s,f,p,m){var b=m.size||1,E=f.x,w=f.y,S=p.x,x=p.y,N=Be(m.color),O=S-E,H=x-w,I=p.size||1,G=O*O+H*H,T=0,B=0;G&&(G=1/Math.sqrt(G),T=-H*G*b,B=O*G*b);var V=this.array;V[s++]=E,V[s++]=w,V[s++]=S,V[s++]=x,V[s++]=T,V[s++]=B,V[s++]=N,V[s++]=u,V[s++]=I}},{key:"setUniforms",value:function(u,s){var f=s.gl,p=s.uniformLocations,m=p.u_matrix,b=p.u_zoomRatio,E=p.u_feather,w=p.u_pixelRatio,S=p.u_correctionRatio,x=p.u_sizeRatio,N=p.u_minEdgeThickness,O=p.u_lengthToThicknessRatio;f.uniformMatrix3fv(m,!1,u.matrix),f.uniform1f(b,u.zoomRatio),f.uniform1f(x,u.sizeRatio),f.uniform1f(S,u.correctionRatio),f.uniform1f(w,u.pixelRatio),f.uniform1f(E,u.antiAliasingFeather),f.uniform1f(N,u.minEdgeThickness),f.uniform1f(O,o.lengthToThicknessRatio)}}])})(st)}var Ma=br();function Ao(i){return cn([br(i),mt(i)])}var ko=Ao(),wr=ko,Lo=`
|
|
247
|
+
attribute vec4 a_id;
|
|
248
|
+
attribute vec4 a_color;
|
|
249
|
+
attribute vec2 a_normal;
|
|
250
|
+
attribute float a_normalCoef;
|
|
251
|
+
attribute vec2 a_positionStart;
|
|
252
|
+
attribute vec2 a_positionEnd;
|
|
253
|
+
attribute float a_positionCoef;
|
|
254
|
+
|
|
255
|
+
uniform mat3 u_matrix;
|
|
256
|
+
uniform float u_sizeRatio;
|
|
257
|
+
uniform float u_zoomRatio;
|
|
258
|
+
uniform float u_pixelRatio;
|
|
259
|
+
uniform float u_correctionRatio;
|
|
260
|
+
uniform float u_minEdgeThickness;
|
|
261
|
+
uniform float u_feather;
|
|
262
|
+
|
|
263
|
+
varying vec4 v_color;
|
|
264
|
+
varying vec2 v_normal;
|
|
265
|
+
varying float v_thickness;
|
|
266
|
+
varying float v_feather;
|
|
267
|
+
|
|
268
|
+
const float bias = 255.0 / 254.0;
|
|
269
|
+
|
|
270
|
+
void main() {
|
|
271
|
+
float minThickness = u_minEdgeThickness;
|
|
272
|
+
|
|
273
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
274
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
275
|
+
|
|
276
|
+
float normalLength = length(normal);
|
|
277
|
+
vec2 unitNormal = normal / normalLength;
|
|
278
|
+
|
|
279
|
+
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
280
|
+
// (so we need to compensate the size ratio):
|
|
281
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
282
|
+
|
|
283
|
+
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
284
|
+
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
285
|
+
// ratio:
|
|
286
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
287
|
+
|
|
288
|
+
// Here is the proper position of the vertex
|
|
289
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
290
|
+
|
|
291
|
+
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
292
|
+
// correction ratio into account (as in webGLThickness), but so that the
|
|
293
|
+
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
294
|
+
// another thickness version:
|
|
295
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
296
|
+
|
|
297
|
+
v_normal = unitNormal;
|
|
298
|
+
|
|
299
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
300
|
+
|
|
301
|
+
#ifdef PICKING_MODE
|
|
302
|
+
// For picking mode, we use the ID as the color:
|
|
303
|
+
v_color = a_id;
|
|
304
|
+
#else
|
|
305
|
+
// For normal mode, we use the color:
|
|
306
|
+
v_color = a_color;
|
|
307
|
+
#endif
|
|
308
|
+
|
|
309
|
+
v_color.a *= bias;
|
|
310
|
+
}
|
|
311
|
+
`,Go=Lo,Er=WebGLRenderingContext,hr=Er.UNSIGNED_BYTE,pt=Er.FLOAT,xo=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],_r=(function(i){function o(){return se(this,o),le(this,o,arguments)}return fe(o,i),ue(o,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Go,FRAGMENT_SHADER_SOURCE:xt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:xo,ATTRIBUTES:[{name:"a_positionStart",size:2,type:pt},{name:"a_positionEnd",size:2,type:pt},{name:"a_normal",size:2,type:pt},{name:"a_color",size:4,type:hr,normalized:!0},{name:"a_id",size:4,type:hr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:pt},{name:"a_normalCoef",size:1,type:pt}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(t,n,u,s,f){var p=f.size||1,m=u.x,b=u.y,E=s.x,w=s.y,S=Be(f.color),x=E-m,N=w-b,O=x*x+N*N,H=0,I=0;O&&(O=1/Math.sqrt(O),H=-N*O*p,I=x*O*p);var G=this.array;G[n++]=m,G[n++]=b,G[n++]=E,G[n++]=w,G[n++]=H,G[n++]=I,G[n++]=S,G[n++]=t}},{key:"setUniforms",value:function(t,n){var u=n.gl,s=n.uniformLocations,f=s.u_matrix,p=s.u_zoomRatio,m=s.u_feather,b=s.u_pixelRatio,E=s.u_correctionRatio,w=s.u_sizeRatio,S=s.u_minEdgeThickness;u.uniformMatrix3fv(f,!1,t.matrix),u.uniform1f(p,t.zoomRatio),u.uniform1f(w,t.sizeRatio),u.uniform1f(E,t.correctionRatio),u.uniform1f(b,t.pixelRatio),u.uniform1f(m,t.antiAliasingFeather),u.uniform1f(S,t.minEdgeThickness)}}])})(st);var Pr=ot(fn()),Ft=(function(i){function o(){var e;return se(this,o),e=le(this,o),e.rawEmitter=e,e}return fe(o,i),ue(o)})(Pr.EventEmitter);var Or=ot(Ct());var Uo=function(o){return o},Io=function(o){return o*o},Mo=function(o){return o*(2-o)},Bo=function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)},Ho=function(o){return o*o*o},Wo=function(o){return--o*o*o+1},jo=function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)},zr={linear:Uo,quadraticIn:Io,quadraticOut:Mo,quadraticInOut:Bo,cubicIn:Ho,cubicOut:Wo,cubicInOut:jo},Ur={easing:"quadraticInOut",duration:150};function Ge(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Nt(i,o,e){return i[0]=o,i[4]=typeof e=="number"?e:o,i}function Fr(i,o){var e=Math.sin(o),t=Math.cos(o);return i[0]=t,i[1]=e,i[3]=-e,i[4]=t,i}function Nr(i,o,e){return i[6]=o,i[7]=e,i}function Ze(i,o){var e=i[0],t=i[1],n=i[2],u=i[3],s=i[4],f=i[5],p=i[6],m=i[7],b=i[8],E=o[0],w=o[1],S=o[2],x=o[3],N=o[4],O=o[5],H=o[6],I=o[7],G=o[8];return i[0]=E*e+w*u+S*p,i[1]=E*t+w*s+S*m,i[2]=E*n+w*f+S*b,i[3]=x*e+N*u+O*p,i[4]=x*t+N*s+O*m,i[5]=x*n+N*f+O*b,i[6]=H*e+I*u+G*p,i[7]=H*t+I*s+G*m,i[8]=H*n+I*f+G*b,i}function Ot(i,o){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,t=i[0],n=i[1],u=i[3],s=i[4],f=i[6],p=i[7],m=o.x,b=o.y;return{x:m*t+b*u+f*e,y:m*n+b*s+p*e}}function Vo(i,o){var e=i.height/i.width,t=o.height/o.width;return e<1&&t>1||e>1&&t<1?1:Math.min(Math.max(t,1/t),Math.max(1/e,e))}function ht(i,o,e,t,n){var u=i.angle,s=i.ratio,f=i.x,p=i.y,m=o.width,b=o.height,E=Ge(),w=Math.min(m,b)-2*t,S=Vo(o,e);return n?(Ze(E,Nr(Ge(),f,p)),Ze(E,Nt(Ge(),s)),Ze(E,Fr(Ge(),u)),Ze(E,Nt(Ge(),m/w/2/S,b/w/2/S))):(Ze(E,Nt(Ge(),2*(w/m)*S,2*(w/b)*S)),Ze(E,Fr(Ge(),-u)),Ze(E,Nt(Ge(),1/s)),Ze(E,Nr(Ge(),-f,-p))),E}function Ir(i,o,e){var t=Ot(i,{x:Math.cos(o.angle),y:Math.sin(o.angle)},0),n=t.x,u=t.y;return 1/Math.sqrt(Math.pow(n,2)+Math.pow(u,2))/e.width}function Mr(i){if(!i.order)return{x:[0,1],y:[0,1]};var o=1/0,e=-1/0,t=1/0,n=-1/0;return i.forEachNode(function(u,s){var f=s.x,p=s.y;f<o&&(o=f),f>e&&(e=f),p<t&&(t=p),p>n&&(n=p)}),{x:[o,e],y:[t,n]}}function Br(i){if(!(0,Or.default)(i))throw new Error("Sigma: invalid graph instance.");i.forEachNode(function(o,e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Sigma: Coordinates of node ".concat(o," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Hr(i,o,e){var t=document.createElement(i);if(o)for(var n in o)t.style[n]=o[n];if(e)for(var u in e)t.setAttribute(u,e[u]);return t}function gn(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function pn(i,o,e){return e.sort(function(t,n){var u=o(t)||0,s=o(n)||0;return u<s?-1:u>s?1:0})}function vn(i){var o=Ke(i.x,2),e=o[0],t=o[1],n=Ke(i.y,2),u=n[0],s=n[1],f=Math.max(t-e,s-u),p=(t+e)/2,m=(s+u)/2;(f===0||Math.abs(f)===1/0||isNaN(f))&&(f=1),isNaN(p)&&(p=0),isNaN(m)&&(m=0);var b=function(w){return{x:.5+(w.x-p)/f,y:.5+(w.y-m)/f}};return b.applyTo=function(E){E.x=.5+(E.x-p)/f,E.y=.5+(E.y-m)/f},b.inverse=function(E){return{x:p+f*(E.x-.5),y:m+f*(E.y-.5)}},b.ratio=f,b}function zt(i){"@babel/helpers - typeof";return zt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},zt(i)}function mn(i,o){var e=o.size;if(e!==0){var t=i.length;i.length+=e;var n=0;o.forEach(function(u){i[t+n]=u,n++})}}function Ut(i){i=i||{};for(var o=0,e=arguments.length<=1?0:arguments.length-1;o<e;o++){var t=o+1<1||arguments.length<=o+1?void 0:arguments[o+1];t&&Object.assign(i,t)}return i}var It={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:gr,defaultDrawNodeLabel:dn,defaultDrawNodeHover:pr,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:{}},$o={circle:vt},Yo={arrow:wr,line:_r};function Mt(i){if(typeof i.labelDensity!="number"||i.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var o=i.minCameraRatio,e=i.maxCameraRatio;if(typeof o=="number"&&typeof e=="number"&&e<o)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Wr(i){var o=Ut({},It,i);return o.nodeProgramClasses=Ut({},$o,o.nodeProgramClasses),o.edgeProgramClasses=Ut({},Yo,o.edgeProgramClasses),o}var is=ot(fn()),os=ot(Ct()),Bt=1.5,jr=(function(i){function o(){var e;return se(this,o),e=le(this,o),k(e,"x",.5),k(e,"y",.5),k(e,"angle",0),k(e,"ratio",1),k(e,"minRatio",null),k(e,"maxRatio",null),k(e,"enabledZooming",!0),k(e,"enabledPanning",!0),k(e,"enabledRotation",!0),k(e,"clean",null),k(e,"nextFrame",null),k(e,"previousState",null),k(e,"enabled",!0),e.previousState=e.getState(),e}return fe(o,i),ue(o,[{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 n=t;return typeof this.minRatio=="number"&&(n=Math.max(n,this.minRatio)),typeof this.maxRatio=="number"&&(n=Math.min(n,this.maxRatio)),n}},{key:"validateState",value:function(t){var n={};return this.enabledPanning&&typeof t.x=="number"&&(n.x=t.x),this.enabledPanning&&typeof t.y=="number"&&(n.y=t.y),this.enabledZooming&&typeof t.ratio=="number"&&(n.ratio=this.getBoundedRatio(t.ratio)),this.enabledRotation&&typeof t.angle=="number"&&(n.angle=t.angle),this.clean?this.clean(U(U({},this.getState()),n)):n}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(t){if(!this.enabled)return this;this.previousState=this.getState();var n=this.validateState(t);return typeof n.x=="number"&&(this.x=n.x),typeof n.y=="number"&&(this.y=n.y),typeof n.ratio=="number"&&(this.ratio=n.ratio),typeof n.angle=="number"&&(this.angle=n.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 n=this,u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(S){return n.animate(t,u,S)});if(this.enabled){var f=U(U({},Ur),u),p=this.validateState(t),m=typeof f.easing=="function"?f.easing:zr[f.easing],b=Date.now(),E=this.getState(),w=function(){var x=(Date.now()-b)/f.duration;if(x>=1){n.nextFrame=null,n.setState(p),n.animationCallback&&(n.animationCallback.call(null),n.animationCallback=void 0);return}var N=m(x),O={};typeof p.x=="number"&&(O.x=E.x+(p.x-E.x)*N),typeof p.y=="number"&&(O.y=E.y+(p.y-E.y)*N),n.enabledRotation&&typeof p.angle=="number"&&(O.angle=E.angle+(p.angle-E.angle)*N),typeof p.ratio=="number"&&(O.ratio=E.ratio+(p.ratio-E.ratio)*N),n.setState(O),n.nextFrame=requestAnimationFrame(w)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(w)):w(),this.animationCallback=s}}},{key:"animatedZoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio/t}):this.animate({ratio:this.ratio/(t.factor||Bt)},t):this.animate({ratio:this.ratio/Bt})}},{key:"animatedUnzoom",value:function(t){return t?typeof t=="number"?this.animate({ratio:this.ratio*t}):this.animate({ratio:this.ratio*(t.factor||Bt)},t):this.animate({ratio:this.ratio*Bt})}},{key:"animatedReset",value:function(t){return this.animate({x:.5,y:.5,ratio:1,angle:0},t)}},{key:"copy",value:function(){return o.from(this.getState())}}],[{key:"from",value:function(t){var n=new o;return n.setState(t)}}])})(Ft);function Pe(i,o){var e=o.getBoundingClientRect();return{x:i.clientX-e.left,y:i.clientY-e.top}}function He(i,o){var e=U(U({},Pe(i,o)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0},original:i});return e}function yt(i){var o="x"in i?i:U(U({},i.touches[0]||i.previousTouches[0]),{},{original:i.original,sigmaDefaultPrevented:i.sigmaDefaultPrevented,preventSigmaDefault:function(){i.sigmaDefaultPrevented=!0,o.sigmaDefaultPrevented=!0}});return o}function qo(i,o){return U(U({},He(i,o)),{},{delta:Zr(i)})}var Ko=2;function Ht(i){for(var o=[],e=0,t=Math.min(i.length,Ko);e<t;e++)o.push(i[e]);return o}function bt(i,o,e){var t={touches:Ht(i.touches).map(function(n){return Pe(n,e)}),previousTouches:o.map(function(n){return Pe(n,e)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0},original:i};return t}function Zr(i){if(typeof i.deltaY<"u")return i.deltaY*-3/360;if(typeof i.detail<"u")return i.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Xr=(function(i){function o(e,t){var n;return se(this,o),n=le(this,o),n.container=e,n.renderer=t,n}return fe(o,i),ue(o)})(Ft),Zo=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Xo=Zo.reduce(function(i,o){return U(U({},i),{},k({},o,It[o]))},{}),Jo=(function(i){function o(e,t){var n;return se(this,o),n=le(this,o,[e,t]),k(n,"enabled",!0),k(n,"draggedEvents",0),k(n,"downStartTime",null),k(n,"lastMouseX",null),k(n,"lastMouseY",null),k(n,"isMouseDown",!1),k(n,"isMoving",!1),k(n,"movingTimeout",null),k(n,"startCameraState",null),k(n,"clicks",0),k(n,"doubleClickTimeout",null),k(n,"currentWheelDirection",0),k(n,"settings",Xo),n.handleClick=n.handleClick.bind(n),n.handleRightClick=n.handleRightClick.bind(n),n.handleDown=n.handleDown.bind(n),n.handleUp=n.handleUp.bind(n),n.handleMove=n.handleMove.bind(n),n.handleWheel=n.handleWheel.bind(n),n.handleLeave=n.handleLeave.bind(n),n.handleEnter=n.handleEnter.bind(n),e.addEventListener("click",n.handleClick,{capture:!1}),e.addEventListener("contextmenu",n.handleRightClick,{capture:!1}),e.addEventListener("mousedown",n.handleDown,{capture:!1}),e.addEventListener("wheel",n.handleWheel,{capture:!1}),e.addEventListener("mouseleave",n.handleLeave,{capture:!1}),e.addEventListener("mouseenter",n.handleEnter,{capture:!1}),document.addEventListener("mousemove",n.handleMove,{capture:!1}),document.addEventListener("mouseup",n.handleUp,{capture:!1}),n}return fe(o,i),ue(o,[{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 n=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(){n.clicks=0,n.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",He(t,this.container))}}},{key:"handleRightClick",value:function(t){this.enabled&&this.emit("rightClick",He(t,this.container))}},{key:"handleDoubleClick",value:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var n=He(t,this.container);if(this.emit("doubleClick",n),!n.sigmaDefaultPrevented){var u=this.renderer.getCamera(),s=u.getBoundedRatio(u.getState().ratio/this.settings.doubleClickZoomingRatio);u.animate(this.renderer.getViewportZoomedState(Pe(t,this.container),s),{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 n=Pe(t,this.container),u=n.x,s=n.y;this.lastMouseX=u,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",He(t,this.container))}}},{key:"handleUp",value:function(t){var n=this;if(!(!this.enabled||!this.isMouseDown)){var u=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=Pe(t,this.container),f=s.x,p=s.y,m=u.getState(),b=u.getPreviousState()||{x:0,y:0};this.isMoving?u.animate({x:m.x+this.settings.inertiaRatio*(m.x-b.x),y:m.y+this.settings.inertiaRatio*(m.y-b.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==f||this.lastMouseY!==p)&&u.setState({x:m.x,y:m.y}),this.isMoving=!1,setTimeout(function(){var E=n.draggedEvents>0;n.draggedEvents=0,E&&n.renderer.getSetting("hideEdgesOnMove")&&n.renderer.refresh()},0),this.emit("mouseup",He(t,this.container))}}},{key:"handleMove",value:function(t){var n=this;if(this.enabled){var u=He(t,this.container);if(this.emit("mousemovebody",u),(t.target===this.container||t.composedPath()[0]===this.container)&&this.emit("mousemove",u),!u.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){n.movingTimeout=null,n.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),f=Pe(t,this.container),p=f.x,m=f.y,b=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),E=this.renderer.viewportToFramedGraph({x:p,y:m}),w=b.x-E.x,S=b.y-E.y,x=s.getState(),N=x.x+w,O=x.y+S;s.setState({x:N,y:O}),this.lastMouseX=p,this.lastMouseY=m,t.preventDefault(),t.stopPropagation()}}}},{key:"handleLeave",value:function(t){this.emit("mouseleave",He(t,this.container))}},{key:"handleEnter",value:function(t){this.emit("mouseenter",He(t,this.container))}},{key:"handleWheel",value:function(t){var n=this,u=this.renderer.getCamera();if(!(!this.enabled||!u.enabledZooming)){var s=Zr(t);if(s){var f=qo(t,this.container);if(this.emit("wheel",f),f.sigmaDefaultPrevented){t.preventDefault(),t.stopPropagation();return}var p=u.getState().ratio,m=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,b=u.getBoundedRatio(p*m),E=s>0?1:-1,w=Date.now();p!==b&&(t.preventDefault(),t.stopPropagation(),!(this.currentWheelDirection===E&&this.lastWheelTriggerTime&&w-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(u.animate(this.renderer.getViewportZoomedState(Pe(t,this.container),b),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){n.currentWheelDirection=0}),this.currentWheelDirection=E,this.lastWheelTriggerTime=w))}}}},{key:"setSettings",value:function(t){this.settings=t}}])})(Xr),Qo=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],ea=Qo.reduce(function(i,o){return U(U({},i),{},k({},o,It[o]))},{}),ta=(function(i){function o(e,t){var n;return se(this,o),n=le(this,o,[e,t]),k(n,"enabled",!0),k(n,"isMoving",!1),k(n,"hasMoved",!1),k(n,"touchMode",0),k(n,"startTouchesPositions",[]),k(n,"lastTouches",[]),k(n,"lastTap",null),k(n,"settings",ea),n.handleStart=n.handleStart.bind(n),n.handleLeave=n.handleLeave.bind(n),n.handleMove=n.handleMove.bind(n),e.addEventListener("touchstart",n.handleStart,{capture:!1}),e.addEventListener("touchcancel",n.handleLeave,{capture:!1}),document.addEventListener("touchend",n.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",n.handleMove,{capture:!1,passive:!1}),n}return fe(o,i),ue(o,[{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 n=this;if(this.enabled){t.preventDefault();var u=Ht(t.touches);if(this.touchMode=u.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=u.map(function(S){return Pe(S,n.container)}),this.touchMode===2){var s=Ke(this.startTouchesPositions,2),f=s[0],p=f.x,m=f.y,b=s[1],E=b.x,w=b.y;this.startTouchesAngle=Math.atan2(w-m,E-p),this.startTouchesDistance=Math.sqrt(Math.pow(E-p,2)+Math.pow(w-m,2))}this.emit("touchdown",bt(t,this.lastTouches,this.container)),this.lastTouches=u,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 n=this.renderer.getCamera(),u=n.getState(),s=n.getPreviousState()||{x:0,y:0};n.animate({x:u.x+this.settings.inertiaRatio*(u.x-s.x),y:u.y+this.settings.inertiaRatio*(u.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",bt(t,this.lastTouches,this.container)),!t.touches.length){var f=Pe(this.lastTouches[0],this.container),p=this.startTouchesPositions[0],m=Math.pow(f.x-p.x,2)+Math.pow(f.y-p.y,2);if(!t.touches.length&&m<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var b=bt(t,this.lastTouches,this.container);if(this.emit("doubletap",b),this.lastTap=null,!b.sigmaDefaultPrevented){var E=this.renderer.getCamera(),w=E.getBoundedRatio(E.getState().ratio/this.settings.doubleClickZoomingRatio);E.animate(this.renderer.getViewportZoomedState(f,w),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var S=bt(t,this.lastTouches,this.container);this.emit("tap",S),this.lastTap={time:Date.now(),position:S.touches[0]||S.previousTouches[0]}}}this.lastTouches=Ht(t.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(t){var n=this;if(!(!this.enabled||!this.startTouchesPositions.length)){t.preventDefault();var u=Ht(t.touches),s=u.map(function(we){return Pe(we,n.container)}),f=this.lastTouches;this.lastTouches=u,this.lastTouchesPositions=s;var p=bt(t,f,this.container);if(this.emit("touchmove",p),!p.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(we,_e){var pe=n.startTouchesPositions[_e];return pe&&(we.x!==pe.x||we.y!==pe.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){n.isMoving=!1},this.settings.dragTimeout);var m=this.renderer.getCamera(),b=this.startCameraState,E=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var w=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),S=w.x,x=w.y,N=this.renderer.viewportToFramedGraph(s[0]),O=N.x,H=N.y;m.setState({x:b.x+S-O,y:b.y+x-H});break}case 2:{var I={x:.5,y:.5,angle:0,ratio:1},G=s[0],T=G.x,B=G.y,V=s[1],L=V.x,M=V.y,_=Math.atan2(M-B,L-T)-this.startTouchesAngle,ee=Math.hypot(M-B,L-T)/this.startTouchesDistance,ie=m.getBoundedRatio(b.ratio/ee);I.ratio=ie,I.angle=b.angle+_;var te=this.getDimensions(),ge=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:b}),q=Math.min(te.width,te.height)-2*E,X=q/te.width,Q=q/te.height,Te=ie/q,Ce=T-q/2/X,be=B-q/2/Q,me=[Ce*Math.cos(-I.angle)-be*Math.sin(-I.angle),be*Math.cos(-I.angle)+Ce*Math.sin(-I.angle)];Ce=me[0],be=me[1],I.x=ge.x-Ce*Te,I.y=ge.y+be*Te,m.setState(I);break}}}}}},{key:"setSettings",value:function(t){this.settings=t}}])})(Xr);function na(i){if(Array.isArray(i))return kt(i)}function ra(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function ia(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
312
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vr(i){return na(i)||ra(i)||nn(i)||ia()}function oa(i,o){if(i==null)return{};var e={};for(var t in i)if({}.hasOwnProperty.call(i,t)){if(o.indexOf(t)!==-1)continue;e[t]=i[t]}return e}function yn(i,o){if(i==null)return{};var e,t,n=oa(i,o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(i);for(t=0;t<u.length;t++)e=u[t],o.indexOf(e)===-1&&{}.propertyIsEnumerable.call(i,e)&&(n[e]=i[e])}return n}var $r=(function(){function i(o,e){se(this,i),this.key=o,this.size=e}return ue(i,null,[{key:"compare",value:function(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}])})(),Yr=(function(){function i(){se(this,i),k(this,"width",0),k(this,"height",0),k(this,"cellSize",0),k(this,"columns",0),k(this,"rows",0),k(this,"cells",{})}return ue(i,[{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),n=Math.floor(e.y/this.cellSize);return n*this.columns+t}},{key:"add",value:function(e,t,n){var u=new $r(e,t),s=this.getIndex(n),f=this.cells[s];f||(f=[],this.cells[s]=f),f.push(u)}},{key:"organize",value:function(){for(var e in this.cells){var t=this.cells[e];t.sort($r.compare)}}},{key:"getLabelsToDisplay",value:function(e,t){var n=this.cellSize*this.cellSize,u=n/e/e,s=u*t/n,f=Math.ceil(s),p=[];for(var m in this.cells)for(var b=this.cells[m],E=0;E<Math.min(f,b.length);E++)p.push(b[E].key);return p}}])})();function aa(i){var o=i.graph,e=i.hoveredNode,t=i.highlightedNodes,n=i.displayedNodeLabels,u=[];return o.forEachEdge(function(s,f,p,m){(p===e||m===e||t.has(p)||t.has(m)||n.has(p)&&n.has(m))&&u.push(s)}),u}var qr=150,Kr=50,We=Object.prototype.hasOwnProperty;function sa(i,o,e){if(!We.call(e,"x")||!We.call(e,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(o,'". 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=i.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),We.call(e,"hidden")||(e.hidden=!1),We.call(e,"highlighted")||(e.highlighted=!1),We.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=i.defaultNodeType),e.zIndex||(e.zIndex=0),e}function ua(i,o,e){return e.color||(e.color=i.defaultEdgeColor),e.label||(e.label=""),e.size||(e.size=.5),We.call(e,"hidden")||(e.hidden=!1),We.call(e,"forceLabel")||(e.forceLabel=!1),(!e.type||e.type==="")&&(e.type=i.defaultEdgeType),e.zIndex||(e.zIndex=0),e}var ha=(function(i){function o(e,t){var n,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(se(this,o),n=le(this,o),k(n,"elements",{}),k(n,"canvasContexts",{}),k(n,"webGLContexts",{}),k(n,"pickingLayers",new Set),k(n,"textures",{}),k(n,"frameBuffers",{}),k(n,"activeListeners",{}),k(n,"labelGrid",new Yr),k(n,"nodeDataCache",{}),k(n,"edgeDataCache",{}),k(n,"nodeProgramIndex",{}),k(n,"edgeProgramIndex",{}),k(n,"nodesWithForcedLabels",new Set),k(n,"edgesWithForcedLabels",new Set),k(n,"nodeExtent",{x:[0,1],y:[0,1]}),k(n,"nodeZExtent",[1/0,-1/0]),k(n,"edgeZExtent",[1/0,-1/0]),k(n,"matrix",Ge()),k(n,"invMatrix",Ge()),k(n,"correctionRatio",1),k(n,"customBBox",null),k(n,"normalizationFunction",vn({x:[0,1],y:[0,1]})),k(n,"graphToViewportRatio",1),k(n,"itemIDsIndex",{}),k(n,"nodeIndices",{}),k(n,"edgeIndices",{}),k(n,"width",0),k(n,"height",0),k(n,"pixelRatio",gn()),k(n,"pickingDownSizingRatio",2*n.pixelRatio),k(n,"displayedNodeLabels",new Set),k(n,"displayedEdgeLabels",new Set),k(n,"highlightedNodes",new Set),k(n,"hoveredNode",null),k(n,"hoveredEdge",null),k(n,"renderFrame",null),k(n,"renderHighlightedNodesFrame",null),k(n,"needToProcess",!1),k(n,"checkEdgesEventsFrame",null),k(n,"nodePrograms",{}),k(n,"nodeHoverPrograms",{}),k(n,"edgePrograms",{}),n.settings=Wr(u),Mt(n.settings),Br(e),!(t instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");n.graph=e,n.container=t,n.createWebGLContext("edges",{picking:u.enableEdgeEvents}),n.createCanvasContext("edgeLabels"),n.createWebGLContext("nodes",{picking:!0}),n.createCanvasContext("labels"),n.createCanvasContext("hovers"),n.createWebGLContext("hoverNodes"),n.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),n.resize();for(var s in n.settings.nodeProgramClasses)n.registerNodeProgram(s,n.settings.nodeProgramClasses[s],n.settings.nodeHoverProgramClasses[s]);for(var f in n.settings.edgeProgramClasses)n.registerEdgeProgram(f,n.settings.edgeProgramClasses[f]);return n.camera=new jr,n.bindCameraHandlers(),n.mouseCaptor=new Jo(n.elements.mouse,n),n.mouseCaptor.setSettings(n.settings),n.touchCaptor=new ta(n.elements.mouse,n),n.touchCaptor.setSettings(n.settings),n.bindEventHandlers(),n.bindGraphHandlers(),n.handleSettingsUpdate(),n.refresh(),n}return fe(o,i),ue(o,[{key:"registerNodeProgram",value:function(t,n,u){return this.nodePrograms[t]&&this.nodePrograms[t].kill(),this.nodeHoverPrograms[t]&&this.nodeHoverPrograms[t].kill(),this.nodePrograms[t]=new n(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[t]=new(u||n)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(t,n){return this.edgePrograms[t]&&this.edgePrograms[t].kill(),this.edgePrograms[t]=new n(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(t){if(this.nodePrograms[t]){var n=this.nodePrograms,u=n[t],s=yn(n,[t].map(et));u.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[t]){var f=this.nodeHoverPrograms,p=f[t],m=yn(f,[t].map(et));p.kill(),this.nodePrograms=m}return this}},{key:"unregisterEdgeProgram",value:function(t){if(this.edgePrograms[t]){var n=this.edgePrograms,u=n[t],s=yn(n,[t].map(et));u.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(t){var n=this.webGLContexts[t],u=this.frameBuffers[t],s=this.textures[t];s&&n.deleteTexture(s);var f=n.createTexture();return n.bindFramebuffer(n.FRAMEBUFFER,u),n.bindTexture(n.TEXTURE_2D,f),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,f,0),this.textures[t]=f,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 n=t.x,u=t.y,s=an(this.webGLContexts.nodes,this.frameBuffers.nodes,n,u,this.pixelRatio,this.pickingDownSizingRatio),f=on.apply(void 0,Vr(s)),p=this.itemIDsIndex[f];return p&&p.type==="node"?p.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(u){var s=yt(u),f={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},p=t.getNodeAtPosition(s);if(p&&t.hoveredNode!==p&&!t.nodeDataCache[p].hidden){t.hoveredNode&&t.emit("leaveNode",U(U({},f),{},{node:t.hoveredNode})),t.hoveredNode=p,t.emit("enterNode",U(U({},f),{},{node:p})),t.scheduleHighlightedNodesRender();return}if(t.hoveredNode&&t.getNodeAtPosition(s)!==t.hoveredNode){var m=t.hoveredNode;t.hoveredNode=null,t.emit("leaveNode",U(U({},f),{},{node:m})),t.scheduleHighlightedNodesRender();return}if(t.settings.enableEdgeEvents){var b=t.hoveredNode?null:t.getEdgeAtPoint(f.event.x,f.event.y);b!==t.hoveredEdge&&(t.hoveredEdge&&t.emit("leaveEdge",U(U({},f),{},{edge:t.hoveredEdge})),b&&t.emit("enterEdge",U(U({},f),{},{edge:b})),t.hoveredEdge=b)}},this.activeListeners.handleMoveBody=function(u){var s=yt(u);t.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(u){var s=yt(u),f={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};t.hoveredNode&&(t.emit("leaveNode",U(U({},f),{},{node:t.hoveredNode})),t.scheduleHighlightedNodesRender()),t.settings.enableEdgeEvents&&t.hoveredEdge&&(t.emit("leaveEdge",U(U({},f),{},{edge:t.hoveredEdge})),t.scheduleHighlightedNodesRender()),t.emit("leaveStage",U({},f))},this.activeListeners.handleEnter=function(u){var s=yt(u),f={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};t.emit("enterStage",U({},f))};var n=function(s){return function(f){var p=yt(f),m={event:p,preventSigmaDefault:function(){p.preventSigmaDefault()}},b=t.getNodeAtPosition(p);if(b)return t.emit("".concat(s,"Node"),U(U({},m),{},{node:b}));if(t.settings.enableEdgeEvents){var E=t.getEdgeAtPoint(p.x,p.y);if(E)return t.emit("".concat(s,"Edge"),U(U({},m),{},{edge:E}))}return t.emit("".concat(s,"Stage"),m)}};return this.activeListeners.handleClick=n("click"),this.activeListeners.handleRightClick=n("rightClick"),this.activeListeners.handleDoubleClick=n("doubleClick"),this.activeListeners.handleWheel=n("wheel"),this.activeListeners.handleDown=n("down"),this.activeListeners.handleUp=n("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,n=this.graph,u=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var f,p=(f=s.hints)===null||f===void 0?void 0:f.attributes;t.graph.forEachNode(function(b){return t.updateNode(b)});var m=!p||p.some(function(b){return u.has(b)});t.refresh({partialGraph:{nodes:n.nodes()},skipIndexation:!m,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var f,p=(f=s.hints)===null||f===void 0?void 0:f.attributes;t.graph.forEachEdge(function(b){return t.updateEdge(b)});var m=p&&["zIndex","type"].some(function(b){return p?.includes(b)});t.refresh({partialGraph:{edges:n.edges()},skipIndexation:!m,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var f=s.key;t.addNode(f),t.refresh({partialGraph:{nodes:[f]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var f=s.key;t.refresh({partialGraph:{nodes:[f]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var f=s.key;t.removeNode(f),t.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var f=s.key;t.addEdge(f),t.refresh({partialGraph:{edges:[f]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var f=s.key;t.refresh({partialGraph:{edges:[f]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var f=s.key;t.removeEdge(f),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})},n.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.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,n){var u=an(this.webGLContexts.edges,this.frameBuffers.edges,t,n,this.pixelRatio,this.pickingDownSizingRatio),s=on.apply(void 0,Vr(u)),f=this.itemIDsIndex[s];return f&&f.type==="edge"?f.id:null}},{key:"process",value:function(){var t=this;this.emit("beforeProcess");var n=this.graph,u=this.settings,s=this.getDimensions();if(this.nodeExtent=Mr(this.graph),!this.settings.autoRescale){var f=s.width,p=s.height,m=this.nodeExtent,b=m.x,E=m.y;this.nodeExtent={x:[(b[0]+b[1])/2-f/2,(b[0]+b[1])/2+f/2],y:[(E[0]+E[1])/2-p/2,(E[0]+E[1])/2+p/2]}}this.normalizationFunction=vn(this.customBBox||this.nodeExtent);var w=new jr,S=ht(w.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,u.labelGridCellSize);for(var x={},N={},O={},H={},I=1,G=n.nodes(),T=0,B=G.length;T<B;T++){var V=G[T],L=this.nodeDataCache[V],M=n.getNodeAttributes(V);L.x=M.x,L.y=M.y,this.normalizationFunction.applyTo(L),typeof L.label=="string"&&!L.hidden&&this.labelGrid.add(V,L.size,this.framedGraphToViewport(L,{matrix:S})),x[L.type]=(x[L.type]||0)+1}this.labelGrid.organize();for(var _ in this.nodePrograms){if(!We.call(this.nodePrograms,_))throw new Error('Sigma: could not find a suitable program for node type "'.concat(_,'"!'));this.nodePrograms[_].reallocate(x[_]||0),x[_]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(G=pn(this.nodeZExtent,function(Xe){return t.nodeDataCache[Xe].zIndex},G));for(var ee=0,ie=G.length;ee<ie;ee++){var te=G[ee];N[te]=I,H[N[te]]={type:"node",id:te},I++;var ge=this.nodeDataCache[te];this.addNodeToProgram(te,N[te],x[ge.type]++)}for(var q={},X=n.edges(),Q=0,Te=X.length;Q<Te;Q++){var Ce=X[Q],be=this.edgeDataCache[Ce];q[be.type]=(q[be.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(X=pn(this.edgeZExtent,function(Xe){return t.edgeDataCache[Xe].zIndex},X));for(var me in this.edgePrograms){if(!We.call(this.edgePrograms,me))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(me,'"!'));this.edgePrograms[me].reallocate(q[me]||0),q[me]=0}for(var we=0,_e=X.length;we<_e;we++){var pe=X[we];O[pe]=I,H[O[pe]]={type:"edge",id:pe},I++;var Oe=this.edgeDataCache[pe];this.addEdgeToProgram(pe,O[pe],q[Oe.type]++)}return this.itemIDsIndex=H,this.nodeIndices=N,this.edgeIndices=O,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(t){var n=this,u=this.settings;if(this.camera.minRatio=u.minCameraRatio,this.camera.maxRatio=u.maxCameraRatio,this.camera.enabledZooming=u.enableCameraZooming,this.camera.enabledPanning=u.enableCameraPanning,this.camera.enabledRotation=u.enableCameraRotation,u.cameraPanBoundaries?this.camera.clean=function(b){return n.cleanCameraState(b,u.cameraPanBoundaries&&zt(u.cameraPanBoundaries)==="object"?u.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),t){if(t.edgeProgramClasses!==u.edgeProgramClasses){for(var s in u.edgeProgramClasses)u.edgeProgramClasses[s]!==t.edgeProgramClasses[s]&&this.registerEdgeProgram(s,u.edgeProgramClasses[s]);for(var f in t.edgeProgramClasses)u.edgeProgramClasses[f]||this.unregisterEdgeProgram(f)}if(t.nodeProgramClasses!==u.nodeProgramClasses||t.nodeHoverProgramClasses!==u.nodeHoverProgramClasses){for(var p in u.nodeProgramClasses)(u.nodeProgramClasses[p]!==t.nodeProgramClasses[p]||u.nodeHoverProgramClasses[p]!==t.nodeHoverProgramClasses[p])&&this.registerNodeProgram(p,u.nodeProgramClasses[p],u.nodeHoverProgramClasses[p]);for(var m in t.nodeProgramClasses)u.nodeProgramClasses[m]||this.unregisterNodeProgram(m)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=n.tolerance,s=u===void 0?0:u,f=n.boundaries,p=U({},t),m=f||this.nodeExtent,b=Ke(m.x,2),E=b[0],w=b[1],S=Ke(m.y,2),x=S[0],N=S[1],O=[this.graphToViewport({x:E,y:x},{cameraState:t}),this.graphToViewport({x:w,y:x},{cameraState:t}),this.graphToViewport({x:E,y:N},{cameraState:t}),this.graphToViewport({x:w,y:N},{cameraState:t})],H=1/0,I=-1/0,G=1/0,T=-1/0;O.forEach(function(q){var X=q.x,Q=q.y;H=Math.min(H,X),I=Math.max(I,X),G=Math.min(G,Q),T=Math.max(T,Q)});var B=I-H,V=T-G,L=this.getDimensions(),M=L.width,_=L.height,ee=0,ie=0;if(B>=M?I<M-s?ee=I-(M-s):H>s&&(ee=H-s):I>M+s?ee=I-(M+s):H<-s&&(ee=H+s),V>=_?T<_-s?ie=T-(_-s):G>s&&(ie=G-s):T>_+s?ie=T-(_+s):G<-s&&(ie=G+s),ee||ie){var te=this.viewportToFramedGraph({x:0,y:0},{cameraState:t}),ge=this.viewportToFramedGraph({x:ee,y:ie},{cameraState:t});ee=ge.x-te.x,ie=ge.y-te.y,p.x+=ee,p.y+=ie}return p}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var t=this.camera.getState(),n=this.labelGrid.getLabelsToDisplay(t.ratio,this.settings.labelDensity);mn(n,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var u=this.canvasContexts.labels,s=0,f=n.length;s<f;s++){var p=n[s],m=this.nodeDataCache[p];if(!this.displayedNodeLabels.has(p)&&!m.hidden){var b=this.framedGraphToViewport(m),E=b.x,w=b.y,S=this.scaleSize(m.size);if(!(!m.forceLabel&&S<this.settings.labelRenderedSizeThreshold)&&!(E<-qr||E>this.width+qr||w<-Kr||w>this.height+Kr)){this.displayedNodeLabels.add(p);var x=this.settings.defaultDrawNodeLabel,N=this.nodePrograms[m.type],O=N?.drawLabel||x;O(u,U(U({key:p},m),{},{size:S,x:E,y:w}),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 n=aa({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});mn(n,this.edgesWithForcedLabels);for(var u=new Set,s=0,f=n.length;s<f;s++){var p=n[s],m=this.graph.extremities(p),b=this.nodeDataCache[m[0]],E=this.nodeDataCache[m[1]],w=this.edgeDataCache[p];if(!u.has(p)&&!(w.hidden||b.hidden||E.hidden)){var S=this.settings.defaultDrawEdgeLabel,x=this.edgePrograms[w.type],N=x?.drawLabel||S;N(t,U(U({key:p},w),{},{size:this.scaleSize(w.size)}),U(U(U({key:m[0]},b),this.framedGraphToViewport(b)),{},{size:this.scaleSize(b.size)}),U(U(U({key:m[1]},E),this.framedGraphToViewport(E)),{},{size:this.scaleSize(E.size)}),this.settings),u.add(p)}}return this.displayedEdgeLabels=u,this}},{key:"renderHighlightedNodes",value:function(){var t=this,n=this.canvasContexts.hovers;n.clearRect(0,0,this.width,this.height);var u=function(S){var x=t.nodeDataCache[S],N=t.framedGraphToViewport(x),O=N.x,H=N.y,I=t.scaleSize(x.size),G=t.settings.defaultDrawNodeHover,T=t.nodePrograms[x.type],B=T?.drawHover||G;B(n,U(U({key:S},x),{},{size:I,x:O,y:H}),t.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(w){w!==t.hoveredNode&&s.push(w)}),s.forEach(function(w){return u(w)});var f={};s.forEach(function(w){var S=t.nodeDataCache[w].type;f[S]=(f[S]||0)+1});for(var p in this.nodeHoverPrograms)this.nodeHoverPrograms[p].reallocate(f[p]||0),f[p]=0;s.forEach(function(w){var S=t.nodeDataCache[w];t.nodeHoverPrograms[S.type].process(0,f[S.type]++,S)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var m=this.getRenderParams();for(var b in this.nodeHoverPrograms){var E=this.nodeHoverPrograms[b];E.render(m)}}},{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 n=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(O){return t.resetWebGLTexture(O)}),!this.graph.order)return n();var u=this.mouseCaptor,s=this.camera.isAnimated()||u.isMoving||u.draggedEvents||u.currentWheelDirection,f=this.camera.getState(),p=this.getDimensions(),m=this.getGraphDimensions(),b=this.getStagePadding();this.matrix=ht(f,p,m,b),this.invMatrix=ht(f,p,m,b,!0),this.correctionRatio=Ir(this.matrix,f,p),this.graphToViewportRatio=this.getGraphToViewportRatio();var E=this.getRenderParams();for(var w in this.nodePrograms){var S=this.nodePrograms[w];S.render(E)}if(!this.settings.hideEdgesOnMove||!s)for(var x in this.edgePrograms){var N=this.edgePrograms[x];N.render(E)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),n()}},{key:"addNode",value:function(t){var n=Object.assign({},this.graph.getNodeAttributes(t));this.settings.nodeReducer&&(n=this.settings.nodeReducer(t,n));var u=sa(this.settings,t,n);this.nodeDataCache[t]=u,this.nodesWithForcedLabels.delete(t),u.forceLabel&&!u.hidden&&this.nodesWithForcedLabels.add(t),this.highlightedNodes.delete(t),u.highlighted&&!u.hidden&&this.highlightedNodes.add(t),this.settings.zIndex&&(u.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=u.zIndex),u.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=u.zIndex))}},{key:"updateNode",value:function(t){this.addNode(t);var n=this.nodeDataCache[t];this.normalizationFunction.applyTo(n)}},{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 n=Object.assign({},this.graph.getEdgeAttributes(t));this.settings.edgeReducer&&(n=this.settings.edgeReducer(t,n));var u=ua(this.settings,t,n);this.edgeDataCache[t]=u,this.edgesWithForcedLabels.delete(t),u.forceLabel&&!u.hidden&&this.edgesWithForcedLabels.add(t),this.settings.zIndex&&(u.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=u.zIndex),u.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=u.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 Yr,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,n,u){var s=this.nodeDataCache[t],f=this.nodePrograms[s.type];if(!f)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));f.process(n,u,s),this.nodeProgramIndex[t]=u}},{key:"addEdgeToProgram",value:function(t,n,u){var s=this.edgeDataCache[t],f=this.edgePrograms[s.type];if(!f)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var p=this.graph.extremities(t),m=this.nodeDataCache[p[0]],b=this.nodeDataCache[p[1]];f.process(n,u,m,b,s),this.edgeProgramIndex[t]=u}},{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,n=t.stagePadding,u=t.autoRescale;return u&&n||0}},{key:"createLayer",value:function(t,n){var u=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 s=Hr(n,{position:"absolute"},{class:"sigma-".concat(t)});return u.style&&Object.assign(s.style,u.style),this.elements[t]=s,"beforeLayer"in u&&u.beforeLayer?this.elements[u.beforeLayer].before(s):"afterLayer"in u&&u.afterLayer?this.elements[u.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(t,"canvas",n)}},{key:"createCanvasContext",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=this.createCanvas(t,n),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[t]=u.getContext("2d",s),this}},{key:"createWebGLContext",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=n?.canvas||this.createCanvas(t,n);n.hidden&&u.remove();var s=U({preserveDrawingBuffer:!1,antialias:!1},n),f;f=u.getContext("webgl2",s),f||(f=u.getContext("webgl",s)),f||(f=u.getContext("experimental-webgl",s));var p=f;if(this.webGLContexts[t]=p,p.blendFunc(p.ONE,p.ONE_MINUS_SRC_ALPHA),n.picking){this.pickingLayers.add(t);var m=p.createFramebuffer();if(!m)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(t));this.frameBuffers[t]=m}return p}},{key:"killLayer",value:function(t){var n=this.elements[t];if(!n)throw new Error("Sigma: cannot kill layer ".concat(t,", which does not exist"));if(this.webGLContexts[t]){var u,s=this.webGLContexts[t];(u=s.getExtension("WEBGL_lose_context"))===null||u===void 0||u.loseContext(),delete this.webGLContexts[t]}else this.canvasContexts[t]&&delete this.canvasContexts[t];return n.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 n=this.nodeDataCache[t];return n?Object.assign({},n):void 0}},{key:"getEdgeDisplayData",value:function(t){var n=this.edgeDataCache[t];return n?Object.assign({},n):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 U({},this.settings)}},{key:"getSetting",value:function(t){return this.settings[t]}},{key:"setSetting",value:function(t,n){var u=U({},this.settings);return this.settings[t]=n,Mt(this.settings),this.handleSettingsUpdate(u),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(t,n){return this.setSetting(t,n(this.settings[t])),this}},{key:"setSettings",value:function(t){var n=U({},this.settings);return this.settings=U(U({},this.settings),t),Mt(this.settings),this.handleSettingsUpdate(n),this.scheduleRefresh(),this}},{key:"resize",value:function(t){var n=this.width,u=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=gn(),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&&n===this.width&&u===this.height)return this;for(var s in this.elements){var f=this.elements[s];f.style.width=this.width+"px",f.style.height=this.height+"px"}for(var p in this.canvasContexts)this.elements[p].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[p].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[p].scale(this.pixelRatio,this.pixelRatio);for(var m in this.webGLContexts){this.elements[m].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[m].setAttribute("height",this.height*this.pixelRatio+"px");var b=this.webGLContexts[m];if(b.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(m)){var E=this.textures[m];E&&b.deleteTexture(E)}}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 n=this,u=t?.skipIndexation!==void 0?t?.skipIndexation:!1,s=t?.schedule!==void 0?t.schedule:!1,f=!t||!t.partialGraph;if(f)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(T){return n.addNode(T)}),this.graph.forEachEdge(function(T){return n.addEdge(T)});else{for(var p,m,b=((p=t.partialGraph)===null||p===void 0?void 0:p.nodes)||[],E=0,w=b?.length||0;E<w;E++){var S=b[E];if(this.updateNode(S),u){var x=this.nodeProgramIndex[S];if(x===void 0)throw new Error('Sigma: node "'.concat(S,`" can't be repaint`));this.addNodeToProgram(S,this.nodeIndices[S],x)}}for(var N=(t==null||(m=t.partialGraph)===null||m===void 0?void 0:m.edges)||[],O=0,H=N.length;O<H;O++){var I=N[O];if(this.updateEdge(I),u){var G=this.edgeProgramIndex[I];if(G===void 0)throw new Error('Sigma: edge "'.concat(I,`" can't be repaint`));this.addEdgeToProgram(I,this.edgeIndices[I],G)}}}return(f||!u)&&(this.needToProcess=!0),s?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(U(U({},t),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(t,n){var u=this.camera.getState(),s=u.ratio,f=u.angle,p=u.x,m=u.y,b=this.settings,E=b.minCameraRatio,w=b.maxCameraRatio;typeof w=="number"&&(n=Math.min(n,w)),typeof E=="number"&&(n=Math.max(n,E));var S=n/s,x={x:this.width/2,y:this.height/2},N=this.viewportToFramedGraph(t),O=this.viewportToFramedGraph(x);return{angle:f,x:(N.x-O.x)*(1-S)+p,y:(N.y-O.y)*(1-S)+m,ratio:n}}},{key:"viewRectangle",value:function(){var t=this.viewportToFramedGraph({x:0,y:0}),n=this.viewportToFramedGraph({x:this.width,y:0}),u=this.viewportToFramedGraph({x:0,y:this.height});return{x1:t.x,y1:t.y,x2:n.x,y2:n.y,height:n.y-u.y}}},{key:"framedGraphToViewport",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=!!n.cameraState||!!n.viewportDimensions||!!n.graphDimensions,s=n.matrix?n.matrix:u?ht(n.cameraState||this.camera.getState(),n.viewportDimensions||this.getDimensions(),n.graphDimensions||this.getGraphDimensions(),n.padding||this.getStagePadding()):this.matrix,f=Ot(s,t);return{x:(1+f.x)*this.width/2,y:(1-f.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=!!n.cameraState||!!n.viewportDimensions||!n.graphDimensions,s=n.matrix?n.matrix:u?ht(n.cameraState||this.camera.getState(),n.viewportDimensions||this.getDimensions(),n.graphDimensions||this.getGraphDimensions(),n.padding||this.getStagePadding(),!0):this.invMatrix,f=Ot(s,{x:t.x/this.width*2-1,y:1-t.y/this.height*2});return isNaN(f.x)&&(f.x=0),isNaN(f.y)&&(f.y=0),f}},{key:"viewportToGraph",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(t,n))}},{key:"graphToViewport",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(t),n)}},{key:"getGraphToViewportRatio",value:function(){var t={x:0,y:0},n={x:1,y:1},u=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),s=this.graphToViewport(t),f=this.graphToViewport(n),p=Math.sqrt(Math.pow(s.x-f.x,2)+Math.pow(s.y-f.y,2));return p/u}},{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 n in this.nodePrograms)this.nodePrograms[n].kill();for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var f in this.elements)this.killLayer(f);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return t/this.settings.zoomToSizeRatioFunction(n)*(this.getSetting("itemSizesReference")==="positions"?n*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var t={};for(var n in this.elements)this.elements[n]instanceof HTMLCanvasElement&&(t[n]=this.elements[n]);return t}}])})(Ft),Jr=ha;var ti=WebGLRenderingContext,cs=ti.UNSIGNED_BYTE,ds=ti.FLOAT;var ca=`
|
|
313
|
+
attribute vec4 a_id;
|
|
314
|
+
attribute vec4 a_color;
|
|
315
|
+
attribute vec2 a_normal;
|
|
316
|
+
attribute float a_normalCoef;
|
|
317
|
+
attribute vec2 a_positionStart;
|
|
318
|
+
attribute vec2 a_positionEnd;
|
|
319
|
+
attribute float a_positionCoef;
|
|
320
|
+
attribute float a_sourceRadius;
|
|
321
|
+
attribute float a_targetRadius;
|
|
322
|
+
attribute float a_sourceRadiusCoef;
|
|
323
|
+
attribute float a_targetRadiusCoef;
|
|
324
|
+
|
|
325
|
+
uniform mat3 u_matrix;
|
|
326
|
+
uniform float u_zoomRatio;
|
|
327
|
+
uniform float u_sizeRatio;
|
|
328
|
+
uniform float u_pixelRatio;
|
|
329
|
+
uniform float u_correctionRatio;
|
|
330
|
+
uniform float u_minEdgeThickness;
|
|
331
|
+
uniform float u_lengthToThicknessRatio;
|
|
332
|
+
uniform float u_feather;
|
|
333
|
+
|
|
334
|
+
varying vec4 v_color;
|
|
335
|
+
varying vec2 v_normal;
|
|
336
|
+
varying float v_thickness;
|
|
337
|
+
varying float v_feather;
|
|
338
|
+
|
|
339
|
+
const float bias = 255.0 / 254.0;
|
|
340
|
+
|
|
341
|
+
void main() {
|
|
342
|
+
float minThickness = u_minEdgeThickness;
|
|
343
|
+
|
|
344
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
345
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
346
|
+
|
|
347
|
+
float normalLength = length(normal);
|
|
348
|
+
vec2 unitNormal = normal / normalLength;
|
|
349
|
+
|
|
350
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
351
|
+
// get better comments on what's happening:
|
|
352
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
353
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
354
|
+
|
|
355
|
+
// Here, we move the point to leave space for the arrow heads:
|
|
356
|
+
// Source arrow head
|
|
357
|
+
float sourceRadius = a_sourceRadius * a_sourceRadiusCoef;
|
|
358
|
+
float sourceDirection = sign(sourceRadius);
|
|
359
|
+
float webGLSourceRadius = sourceDirection * sourceRadius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
360
|
+
float webGLSourceArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
361
|
+
vec2 sourceCompensationVector =
|
|
362
|
+
vec2(-sourceDirection * unitNormal.y, sourceDirection * unitNormal.x)
|
|
363
|
+
* (webGLSourceRadius + webGLSourceArrowHeadLength);
|
|
364
|
+
|
|
365
|
+
// Target arrow head
|
|
366
|
+
float targetRadius = a_targetRadius * a_targetRadiusCoef;
|
|
367
|
+
float targetDirection = sign(targetRadius);
|
|
368
|
+
float webGLTargetRadius = targetDirection * targetRadius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
369
|
+
float webGLTargetArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
370
|
+
vec2 targetCompensationVector =
|
|
371
|
+
vec2(-targetDirection * unitNormal.y, targetDirection * unitNormal.x)
|
|
372
|
+
* (webGLTargetRadius + webGLTargetArrowHeadLength);
|
|
373
|
+
|
|
374
|
+
// Here is the proper position of the vertex
|
|
375
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + sourceCompensationVector + targetCompensationVector, 1)).xy, 0, 1);
|
|
376
|
+
|
|
377
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
378
|
+
|
|
379
|
+
v_normal = unitNormal;
|
|
380
|
+
|
|
381
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
382
|
+
|
|
383
|
+
#ifdef PICKING_MODE
|
|
384
|
+
// For picking mode, we use the ID as the color:
|
|
385
|
+
v_color = a_id;
|
|
386
|
+
#else
|
|
387
|
+
// For normal mode, we use the color:
|
|
388
|
+
v_color = a_color;
|
|
389
|
+
#endif
|
|
390
|
+
|
|
391
|
+
v_color.a *= bias;
|
|
392
|
+
}
|
|
393
|
+
`,da=ca,ni=WebGLRenderingContext,Qr=ni.UNSIGNED_BYTE,je=ni.FLOAT,la=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],fa={lengthToThicknessRatio:Gt.lengthToThicknessRatio};function ri(i){var o=U(U({},fa),i||{});return(function(e){function t(){return se(this,t),le(this,t,arguments)}return fe(t,e),ue(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:da,FRAGMENT_SHADER_SOURCE:xt,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:la,ATTRIBUTES:[{name:"a_positionStart",size:2,type:je},{name:"a_positionEnd",size:2,type:je},{name:"a_normal",size:2,type:je},{name:"a_color",size:4,type:Qr,normalized:!0},{name:"a_id",size:4,type:Qr,normalized:!0},{name:"a_sourceRadius",size:1,type:je},{name:"a_targetRadius",size:1,type:je}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:je},{name:"a_normalCoef",size:1,type:je},{name:"a_sourceRadiusCoef",size:1,type:je},{name:"a_targetRadiusCoef",size:1,type:je}],CONSTANT_DATA:[[0,1,-1,0],[0,-1,1,0],[1,1,0,1],[1,1,0,1],[0,-1,1,0],[1,-1,0,-1]]}}},{key:"processVisibleItem",value:function(u,s,f,p,m){var b=m.size||1,E=f.x,w=f.y,S=p.x,x=p.y,N=Be(m.color),O=S-E,H=x-w,I=f.size||1,G=p.size||1,T=O*O+H*H,B=0,V=0;T&&(T=1/Math.sqrt(T),B=-H*T*b,V=O*T*b);var L=this.array;L[s++]=E,L[s++]=w,L[s++]=S,L[s++]=x,L[s++]=B,L[s++]=V,L[s++]=N,L[s++]=u,L[s++]=I,L[s++]=G}},{key:"setUniforms",value:function(u,s){var f=s.gl,p=s.uniformLocations,m=p.u_matrix,b=p.u_zoomRatio,E=p.u_feather,w=p.u_pixelRatio,S=p.u_correctionRatio,x=p.u_sizeRatio,N=p.u_minEdgeThickness,O=p.u_lengthToThicknessRatio;f.uniformMatrix3fv(m,!1,u.matrix),f.uniform1f(b,u.zoomRatio),f.uniform1f(x,u.sizeRatio),f.uniform1f(S,u.correctionRatio),f.uniform1f(w,u.pixelRatio),f.uniform1f(E,u.antiAliasingFeather),f.uniform1f(N,u.minEdgeThickness),f.uniform1f(O,o.lengthToThicknessRatio)}}])})(st)}var ls=ri();function ga(i){return cn([ri(i),mt(i),mt(U(U({},i),{},{extremity:"source"}))])}var fs=ga();var pa=`
|
|
394
|
+
precision mediump float;
|
|
395
|
+
|
|
396
|
+
varying vec4 v_color;
|
|
397
|
+
|
|
398
|
+
void main(void) {
|
|
399
|
+
gl_FragColor = v_color;
|
|
400
|
+
}
|
|
401
|
+
`,va=pa,ma=`
|
|
402
|
+
attribute vec4 a_id;
|
|
403
|
+
attribute vec4 a_color;
|
|
404
|
+
attribute vec2 a_position;
|
|
405
|
+
|
|
406
|
+
uniform mat3 u_matrix;
|
|
407
|
+
|
|
408
|
+
varying vec4 v_color;
|
|
409
|
+
|
|
410
|
+
const float bias = 255.0 / 254.0;
|
|
411
|
+
|
|
412
|
+
void main() {
|
|
413
|
+
// Scale from [[-1 1] [-1 1]] to the container:
|
|
414
|
+
gl_Position = vec4(
|
|
415
|
+
(u_matrix * vec3(a_position, 1)).xy,
|
|
416
|
+
0,
|
|
417
|
+
1
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
#ifdef PICKING_MODE
|
|
421
|
+
// For picking mode, we use the ID as the color:
|
|
422
|
+
v_color = a_id;
|
|
423
|
+
#else
|
|
424
|
+
// For normal mode, we use the color:
|
|
425
|
+
v_color = a_color;
|
|
426
|
+
#endif
|
|
427
|
+
|
|
428
|
+
v_color.a *= bias;
|
|
429
|
+
}
|
|
430
|
+
`,ya=ma,ii=WebGLRenderingContext,ei=ii.UNSIGNED_BYTE,ba=ii.FLOAT,wa=["u_matrix"],bn=(function(i){function o(){return se(this,o),le(this,o,arguments)}return fe(o,i),ue(o,[{key:"getDefinition",value:function(){return{VERTICES:2,VERTEX_SHADER_SOURCE:ya,FRAGMENT_SHADER_SOURCE:va,METHOD:WebGLRenderingContext.LINES,UNIFORMS:wa,ATTRIBUTES:[{name:"a_position",size:2,type:ba},{name:"a_color",size:4,type:ei,normalized:!0},{name:"a_id",size:4,type:ei,normalized:!0}]}}},{key:"processVisibleItem",value:function(t,n,u,s,f){var p=this.array,m=u.x,b=u.y,E=s.x,w=s.y,S=Be(f.color);p[n++]=m,p[n++]=b,p[n++]=S,p[n++]=t,p[n++]=E,p[n++]=w,p[n++]=S,p[n++]=t}},{key:"setUniforms",value:function(t,n){var u=n.gl,s=n.uniformLocations,f=s.u_matrix;u.uniformMatrix3fv(f,!1,t.matrix)}}])})(st);var oi=WebGLRenderingContext,gs=oi.UNSIGNED_BYTE,ps=oi.FLOAT;var En="/.well-known/graphgarden.json",Ve={localNodeColor:"#6366f1",friendNodeColor:"#f59e0b",internalEdgeColor:"#94a3b8",friendEdgeColor:"#fbbf24",labelColor:"#334155",nodeSize:4,edgeSize:.5,labelSize:12,iterations:200};function Ea(i){return typeof i=="object"&&i!==null&&typeof i.url=="string"&&typeof i.title=="string"}function _a(i){return typeof i=="object"&&i!==null&&typeof i.source=="string"&&typeof i.target=="string"&&(i.type==="internal"||i.type==="friend")}function si(i){if(typeof i!="object"||i===null)return!1;let o=i;if(typeof o.version!="string"||typeof o.generated_at!="string"||typeof o.base_url!="string"||typeof o.site!="object"||o.site===null)return!1;let e=o.site;return!(typeof e.title!="string"||e.description!==void 0&&typeof e.description!="string"||e.language!==void 0&&typeof e.language!="string"||!Array.isArray(o.nodes)||!o.nodes.every(Ea)||!Array.isArray(o.edges)||!o.edges.every(_a))}function Ra(i,o){let e=new ai.default;e.replaceAttributes({base_url:i.base_url,site:i.site});for(let t of i.nodes){let n=new URL(t.url,i.base_url).href;e.mergeNode(n,{title:t.title,label:t.title,size:o.nodeSize,color:o.localNodeColor})}for(let t of i.edges){let n=new URL(t.source,i.base_url).href,u=new URL(t.target,i.base_url).href;e.mergeNode(n,{size:o.nodeSize}),e.mergeNode(u,{size:o.nodeSize,...t.type==="friend"&&{color:o.friendNodeColor}});let s=t.type==="friend"?o.friendEdgeColor:o.internalEdgeColor;e.mergeDirectedEdge(n,u,{type:t.type,color:s,size:o.edgeSize})}return e}function Ta(i,o){i.order!==0&&(i.forEachNode(e=>{i.mergeNodeAttributes(e,{x:Math.random()*100,y:Math.random()*100})}),wn.default.assign(i,{iterations:o,settings:wn.default.inferSettings(i)}))}async function Ca(i,o){let e=new Set;i.forEachEdge((n,u,s,f)=>{if(u.type==="friend")try{e.add(new URL(f).origin)}catch{console.warn(`fetchFriendGraphs: invalid friend target URL: ${f}`)}});let t=await Promise.allSettled([...e].map(async n=>{let u=await fetch(`${n}${En}`);if(!u.ok)return console.warn(`fetchFriendGraphs: ${n} responded ${u.status} ${u.statusText}`),null;let s=await u.json();return si(s)?s:(console.warn(`fetchFriendGraphs: ${n} returned an invalid GraphGarden file`),null)}));for(let n of t){if(n.status==="rejected"){console.warn("fetchFriendGraphs: fetch failed:",n.reason);continue}let u=n.value;if(u)try{for(let s of u.nodes){let f=new URL(s.url,u.base_url).href;i.mergeNode(f,{title:s.title,label:s.title,size:o.nodeSize,color:o.friendNodeColor})}for(let s of u.edges){let f=new URL(s.source,u.base_url).href,p=new URL(s.target,u.base_url).href;i.mergeNode(f,{size:o.nodeSize}),i.mergeNode(p,{size:o.nodeSize,...s.type==="friend"&&{color:o.friendNodeColor}});let m=s.type==="friend"?o.friendEdgeColor:o.internalEdgeColor;i.mergeDirectedEdge(f,p,{type:s.type,color:m,size:o.edgeSize})}}catch(s){console.warn(`fetchFriendGraphs: failed to merge friend file (base_url: ${u.base_url}):`,s)}}return i}var wt=class extends HTMLElement{static tagName="graph-garden";graph=null;renderer=null;container=null;async connectedCallback(){let o=this.shadowRoot??this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=`
|
|
431
|
+
:host { display: block; }
|
|
432
|
+
div { width: 100%; height: 100%; position: relative; }
|
|
433
|
+
`,o.appendChild(e),this.container=document.createElement("div"),o.appendChild(this.container);try{let t=await fetch(En);if(!t.ok){console.error(`<graph-garden> failed to fetch ${En}: ${t.status} ${t.statusText}`);return}let n=await t.json();if(!si(n)){console.error("<graph-garden> fetched file does not match the GraphGarden protocol shape");return}let u=this.resolveConfig();this.graph=Ra(n,u),await Ca(this.graph,u),Ta(this.graph,u.iterations),this.initRenderer(u)}catch(t){console.error("<graph-garden> error during initialization:",t)}}disconnectedCallback(){this.renderer?.kill(),this.renderer=null,this.graph?.clear(),this.graph=null,this.shadowRoot&&(this.shadowRoot.innerHTML=""),this.container=null}resolveConfig(){let o=(t,n)=>getComputedStyle(this).getPropertyValue(t).trim()||n,e=(t,n)=>{let u=this.getAttribute(t);if(u===null)return n;let s=Number(u);return Number.isFinite(s)&&s>0?s:n};return{localNodeColor:o("--gg-local-node-color",Ve.localNodeColor),friendNodeColor:o("--gg-friend-node-color",Ve.friendNodeColor),internalEdgeColor:o("--gg-internal-edge-color",Ve.internalEdgeColor),friendEdgeColor:o("--gg-friend-edge-color",Ve.friendEdgeColor),labelColor:o("--gg-label-color",Ve.labelColor),nodeSize:e("node-size",Ve.nodeSize),edgeSize:e("edge-size",Ve.edgeSize),labelSize:e("label-size",Ve.labelSize),iterations:e("iterations",Ve.iterations)}}initRenderer(o){if(!(!this.graph||!this.container))try{this.renderer=new Jr(this.graph,this.container,{edgeProgramClasses:{internal:bn,friend:bn},defaultEdgeColor:o.internalEdgeColor,labelColor:{color:o.labelColor},labelSize:o.labelSize,renderEdgeLabels:!1}),this.renderer.on("clickNode",({node:e})=>{window.location.href=e}),this.renderer.on("enterNode",()=>{this.container&&(this.container.style.cursor="pointer")}),this.renderer.on("leaveNode",()=>{this.container&&(this.container.style.cursor="default")})}catch(e){console.warn("<graph-garden> could not initialize Sigma renderer:",e)}}};customElements.get(wt.tagName)||customElements.define(wt.tagName,wt);})();
|
|
434
|
+
//# sourceMappingURL=graphgarden.iife.js.map
|