Comparing version 2.0.0-alpha16 to 2.0.0-alpha17
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Sigma=t():e.Sigma=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!i(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,i,s,l,h;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(r=this._events[e],a(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),r.apply(this,s)}else if(o(r))for(s=Array.prototype.slice.call(arguments,1),h=r.slice(),i=h.length,l=0;l<i;l++)h[l].apply(this,s);return!0},r.prototype.addListener=function(e,t){var i;if(!n(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(i=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,i,a,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,i=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=s;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(0),l=r(12),h=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(l),u=r(4),c={easing:"quadraticInOut",duration:150},d=function(e){function t(){n(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.x=.5,e.y=.5,e.angle=0,e.ratio=1,e.nextFrame=null,e.previousState=e.getState(),e.enabled=!0,e}return o(t,e),a(t,[{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:"getPreviousState",value:function(){var e=this.previousState;return{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"graphToViewport",value:function(e,t,r){var n=Math.min(e.width,e.height),i=n/e.width,o=n/e.height;return{x:(t-this.x+this.ratio/2/i)*(n/this.ratio),y:(this.y-r+this.ratio/2/o)*(n/this.ratio)}}},{key:"viewportToGraph",value:function(e,t,r){var n=Math.min(e.width,e.height),i=n/e.width,o=n/e.height;return{x:this.ratio/n*t+this.x-this.ratio/2/i,y:-(this.ratio/n*r-this.y-this.ratio/2/o)}}},{key:"viewRectangle",value:function(e){var t=0*e.width/8,r=0*e.height/8,n=this.viewportToGraph(e,0-t,0-r),i=this.viewportToGraph(e,e.width+t,0-r),o=this.viewportToGraph(e,0,e.height+r);return{x1:n.x,y1:n.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"setState",value:function(e){return this.enabled?(this.previousState=this.getState(),"x"in e&&(this.x=e.x),"y"in e&&(this.y=e.y),"angle"in e&&(this.angle=e.angle),"ratio"in e&&(this.ratio=e.ratio),this.emit("updated",this.getState()),this):this}},{key:"animate",value:function(e,t,r){var n=this;if(!this.enabled)return this;t=(0,u.assign)({},c,t);var i="function"==typeof t.easing?t.easing:h[t.easing];this.nextFrame&&cancelAnimationFrame(this.nextFrame);var o=Date.now(),a=this.getState(),s=function s(){var l=(Date.now()-o)/t.duration;if(l>=1)return n.nextFrame=null,n.setState(e),void("function"==typeof r&&r());var h=i(l),u={};"x"in e&&(u.x=a.x+(e.x-a.x)*h),"y"in e&&(u.y=a.y+(e.y-a.y)*h),"angle"in e&&(u.angle=a.angle+(e.angle-a.angle)*h),"ratio"in e&&(u.ratio=a.ratio+(e.ratio-a.ratio)*h),n.setState(u),n.nextFrame=requestAnimationFrame(s)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.nextFrame=requestAnimationFrame(s)):s()}},{key:"animatedZoom",value:function(e){return e?"number"==typeof e?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||1.5)},e):this.animate({ratio:this.ratio/1.5})}},{key:"animatedUnzoom",value:function(e){return e?"number"==typeof e?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||1.5)},e):this.animate({ratio:1.5*this.ratio})}},{key:"animatedReset",value:function(e){return this.animate({x:0,y:0,ratio:1,angle:0},e)}}]),t}(s.EventEmitter);t.default=d},function(e,t,r){"use strict";function n(e){if(void 0!==s[e])return s[e];var t=0,r=0,n=0,i=1;if("#"===e[0])4===e.length?(t=parseInt(e.charAt(1)+e.charAt(1),16),r=parseInt(e.charAt(2)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(4),16),n=parseInt(e.charAt(5)+e.charAt(6),16));else if(c.test(e)){var o=e.match(d);t=+o[1],r=+o[2],n=+o[3],o[4]&&(i=+o[4])}i=255*i|0;var a=4278190079&(i<<24|n<<16|r<<8|t);h[0]=a;var l=u[0];return s[e]=l,l}function i(e,t){var r=e.angle,n=e.ratio,i=e.x,o=e.y,s=t.width,l=t.height,h=(0,a.identity)(),u=Math.min(s,l),c=(0,a.translate)((0,a.identity)(),-i,-o),d=(0,a.scale)((0,a.identity)(),1/n),f=(0,a.rotate)((0,a.identity)(),-r),v=(0,a.scale)((0,a.identity)(),u/s*2,u/l*2);return(0,a.multiply)(h,v),(0,a.multiply)(h,f),(0,a.multiply)(h,d),(0,a.multiply)(h,c),h}function o(e,t,r,n){var i=n||new Uint8Array(4);return e.readPixels(t,r,1,1,e.RGBA,e.UNSIGNED_BYTE,i),i}Object.defineProperty(t,"__esModule",{value:!0}),t.floatColor=n,t.matrixFromCamera=i,t.extractPixel=o;var a=r(21),s={},l=new Int8Array(4),h=new Int32Array(l.buffer,0,1),u=new Float32Array(l.buffer,0,1),c=/^\s*rgba?\s*\(/,d=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=r(0),s=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),t}(a.EventEmitter);t.default=s},function(e,t,r){"use strict";function n(e){e=e||{};for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var i=0,o=r.length;i<o;i++)if(r[i])for(var a in r[i])e[a]=r[i][a];return e}Object.defineProperty(t,"__esModule",{value:!0}),t.assign=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,r,n){return e===r||t===n}function o(e,t,r,n,i,o,a){return e<n+o&&e+r>n&&t<i+a&&t+r>i}function a(e,t,r,n,i,o,a,s){return e<i+a&&e+r>i&&t<o+s&&t+n>o}function s(e,t,r,n,i,o){var a=r+i/2,s=n+o/2,l=t<s,h=e<a;return l?h?w:_:h?x:E}function l(e,t){for(var r=[0,0];r.length;){var n=r.pop(),i=r.pop(),o=4*i+v,a=4*i+2*v,s=4*i+3*v,l=4*i+4*v,h=t[i+g],u=t[i+y],c=t[i+m],d=t[i+b],f=c/2,p=d/2;t[o+g]=h,t[o+y]=u,t[o+m]=f,t[o+b]=p,t[a+g]=h+f,t[a+y]=u,t[a+m]=f,t[a+b]=p,t[s+g]=h,t[s+y]=u+p,t[s+m]=f,t[s+b]=p,t[l+g]=h+f,t[l+y]=u+p,t[l+m]=f,t[l+b]=p,n<e-1&&(r.push(l,n+1),r.push(s,n+1),r.push(a,n+1),r.push(o,n+1))}}function h(e,t,r,n,i,a,s){for(var l=i-s,h=a-s,u=2*s,c=0,d=0;;){if(c>=e)return r[d]=r[d]||[],void r[d].push(n);var f=4*d+v,p=4*d+2*v,w=4*d+3*v,_=4*d+4*v,x=o(l,h,u,t[f+g],t[f+y],t[f+m],t[f+b]),E=o(l,h,u,t[p+g],t[p+y],t[p+m],t[p+b]),A=o(l,h,u,t[w+g],t[w+y],t[w+m],t[w+b]),L=o(l,h,u,t[_+g],t[_+y],t[_+m],t[_+b]),P=x+E+A+L;if(0===P)throw new Error("sigma/quadtree.insertNode: no collision (level: "+c+", key: "+n+", x: "+i+", y: "+a+", size: "+s+").");if(3===P)throw new Error("sigma/quadtree.insertNode: 3 impossible collisions (level: "+c+", key: "+n+", x: "+i+", y: "+a+", size: "+s+").");if(P>1)return r[d]=r[d]||[],void r[d].push(n);c++,x&&(d=f),E&&(d=p),A&&(d=w),L&&(d=_)}}function u(e,t,r,n,i,o,s){for(var l=[0,0],h=[],u=void 0;l.length;){var c=l.pop(),d=l.pop();if(u=r[d],u&&(0,f.default)(h,u),!(c>=e)){var p=4*d+v,w=4*d+2*v,_=4*d+3*v,x=4*d+4*v,E=a(n,i,o,s,t[p+g],t[p+y],t[p+m],t[p+b]),A=a(n,i,o,s,t[w+g],t[w+y],t[w+m],t[w+b]),L=a(n,i,o,s,t[_+g],t[_+y],t[_+m],t[_+b]),P=a(n,i,o,s,t[x+g],t[x+y],t[x+m],t[x+b]);E&&l.push(p,c+1),A&&l.push(w,c+1),L&&l.push(_,c+1),P&&l.push(x,c+1)}}return h}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),d=r(13),f=function(e){return e&&e.__esModule?e:{default:e}}(d),v=4,p=5,g=0,y=1,m=2,b=3,w=1,_=2,x=3,E=4,A=function(){function e(t){n(this,e),t=t||{};var r=Math.pow(4,p);this.data=new Float32Array(v*((4*r-1)/3)),this.containers={},this.cache=null,this.lastRectangle=null,t.boundaries?this.resize(t.boundaries):this.resize({x:0,y:0,width:1,height:1}),"function"==typeof t.filter&&(this.nodeFilter=t.filter)}return c(e,[{key:"add",value:function(e,t,r,n){return h(p,this.data,this.containers,e,t,r,n),this}},{key:"resize",value:function(e){this.clear(),this.data[g]=e.x,this.data[y]=e.y,this.data[m]=e.width,this.data[b]=e.height,l(p,this.data)}},{key:"clear",value:function(){return this.containers={},this}},{key:"point",value:function(e,t){var r=[],n=0,i=0;do{this.containers[n]&&r.push.apply(r,this.containers[n]);n=4*n+s(e,t,this.data[n+g],this.data[n+y],this.data[n+m],this.data[n+b])*v,i++}while(i<=p);return r}},{key:"rectangle",value:function(e,t,r,n,o){var a=this.lastRectangle;if(a&&e===a.x1&&r===a.x2&&t===a.y1&&n===a.y2&&o===a.height)return this.cache;if(this.lastRectangle={x1:e,y1:t,x2:r,y2:n,height:o},!i(e,t,r,n))throw new Error("sigma/quadtree.rectangle: shifted view is not yet implemented.");var s=u(p,this.data,this.containers,e,t,Math.abs(e-r)||Math.abs(t-n),o);return this.cache=s,this.cache}}]),e}();t.default=A},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(1),h=n(l),u=r(14),c=n(u),d=r(15),f=function(e){function t(e,r){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return n.container=e,n.camera=r,n.enabled=!0,n.hasDragged=!1,n.downStartTime=null,n.lastMouseX=null,n.lastMouseY=null,n.isMouseDown=!1,n.isMoving=!1,n.movingTimeout=null,n.startCameraState=null,n.lastCameraState=null,n.clicks=0,n.doubleClickTimeout=null,n.wheelLock=!1,n.handleClick=n.handleClick.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.handleOut=n.handleOut.bind(n),e.addEventListener("click",n.handleClick,!1),e.addEventListener("mousedown",n.handleDown,!1),e.addEventListener("mousemove",n.handleMove,!1),e.addEventListener("DOMMouseScroll",n.handleWheel,!1),e.addEventListener("mousewheel",n.handleWheel,!1),e.addEventListener("mouseout",n.handleOut,!1),document.addEventListener("mouseup",n.handleUp,!1),n}return a(t,e),s(t,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("mousemove",this.handleMove),e.removeEventListener("DOMMouseScroll",this.handleWheel),e.removeEventListener("mousewheel",this.handleWheel),e.removeEventListener("mouseout",this.handleOut),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var t=this;if(this.enabled){if(2===++this.clicks)return this.clicks=0,clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null,this.handleDoubleClick(e);setTimeout(function(){t.clicks=0,t.doubleClickTimeout=null},300),this.emit("click",(0,d.getMouseCoords)(e))}}},{key:"handleDoubleClick",value:function(e){if(this.enabled){var t=(0,d.getCenter)(e),r=this.camera.getState(),n=r.ratio/2.2,i={width:this.container.offsetWidth,height:this.container.offsetHeight},o=(0,d.getX)(e),a=(0,d.getY)(e),s=new h.default;s.ratio=n,s.x=r.x,s.y=r.y;var l=this.camera.viewportToGraph(i,o,a),u=this.camera.viewportToGraph(i,t.x,t.y),c=s.viewportToGraph(i,o,a),f=s.viewportToGraph(i,t.x,t.y),v=c.x-f.x-l.x+u.x,p=c.y-f.y-l.y+u.y;return this.camera.animate({x:r.x-v,y:r.y-p,ratio:n},{easing:"quadraticInOut",duration:200}),e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation(),!1}}},{key:"handleDown",value:function(e){this.enabled&&(this.startCameraState=this.camera.getState(),this.lastCameraState=this.startCameraState,this.lastMouseX=(0,d.getX)(e),this.lastMouseY=(0,d.getY)(e),this.hasDragged=!1,this.downStartTime=Date.now(),e.which,this.isMouseDown=!0,this.emit("mousedown",(0,d.getMouseCoords)(e)))}},{key:"handleUp",value:function(e){if(this.enabled&&this.isMouseDown){this.isMouseDown=!1,this.movingTimeout&&(this.movingTimeout=null,clearTimeout(this.movingTimeout));var t=(0,d.getX)(e),r=(0,d.getY)(e),n=this.camera.getState(),i=this.camera.getPreviousState();this.isMoving?this.camera.animate({x:n.x+3*(n.x-i.x),y:n.y+3*(n.y-i.y)},{duration:200,easing:"quadraticOut"}):this.lastMouseX===t&&this.lastMouseY===r||this.camera.setState({x:n.x,y:n.y}),this.isMoving=!1,this.hasDragged=!1,this.emit("mouseup",(0,d.getMouseCoords)(e))}}},{key:"handleMove",value:function(e){var t=this;if(this.enabled){if(this.emit("mousemove",(0,d.getMouseCoords)(e)),this.isMouseDown){this.isMoving=!0,this.hasDragged=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=setTimeout(function(){t.movingTimeout=null,t.isMoving=!1},200);var r={width:this.container.offsetWidth,height:this.container.offsetHeight},n=(0,d.getX)(e),i=(0,d.getY)(e),o=this.camera.viewportToGraph(r,this.lastMouseX,this.lastMouseY),a=this.camera.viewportToGraph(r,n,i),s=o.x-a.x,l=o.y-a.y,h=this.camera.getState(),u=h.x+s,c=h.y+l;this.camera.setState({x:u,y:c}),this.lastMouseX=n,this.lastMouseY=i}return e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation(),!1}}},{key:"handleWheel",value:function(e){var t=this;if(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation(),!this.enabled)return!1;var r=(0,d.getWheelDelta)(e);if(!r)return!1;if(this.wheelLock)return!1;this.wheelLock=!0;var n=r>0?1/1.7:1.7,i=this.camera.getState(),o=n*i.ratio,a=(0,d.getCenter)(e),s={width:this.container.offsetWidth,height:this.container.offsetHeight},l=(0,d.getX)(e),u=(0,d.getY)(e),c=new h.default;c.ratio=o,c.x=i.x,c.y=i.y;var f=this.camera.viewportToGraph(s,l,u),v=this.camera.viewportToGraph(s,a.x,a.y),p=c.viewportToGraph(s,l,u),g=c.viewportToGraph(s,a.x,a.y),y=p.x-g.x-f.x+v.x,m=p.y-g.y-f.y+v.y;return this.camera.animate({x:i.x-y,y:i.y-m,ratio:o},{easing:"linear",duration:200},function(){return t.wheelLock=!1}),!1}},{key:"handleOut",value:function(){}}]),t}(c.default);t.default=f},function(e,t,r){"use strict";function n(e,t){var r=document.createElement(e);if(!t)return r;for(var n in t)if("style"===n)for(var i in t[n])r.style[i]=t[n][i];else r.setAttribute(n,t[n]);return r}function i(){var e=window.screen;return void 0!==e.deviceXDPI&&void 0!==e.logicalXDPI&&e.deviceXDPI>e.logicalXDPI?e.systemXDPI/e.logicalXDPI:void 0!==window.devicePixelRatio?window.devicePixelRatio:1}function o(e){var t=a(e.x,2),r=t[0],n=t[1],i=a(e.y,2),o=i[0],s=i[1],l=Math.max(n-r,s-o),h=(n+r)/2,u=(s+o)/2,c=function(e){return{x:.5+(e.x-h)/l,y:.5+(e.y-u)/l}};return c.applyTo=function(e){e.x=.5+(e.x-h)/l,e.y=.5+(e.y-u)/l},c.inverse=function(e){return{x:h+l*(e.x-.5),y:u+l*(e.y-.5)}},c.ratio=l,c}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.createElement=n,t.getPixelRatio=i,t.createNormalizationFunction=o},function(e,t){e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNodes&&"boolean"==typeof e.multi}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return function(){function t(r){i(this,t),this.programs=e.map(function(e){return new e(r)})}return a(t,[{key:"allocate",value:function(e){this.programs.forEach(function(t){return t.allocate(e)})}},{key:"process",value:function(){var e=arguments;this.programs.forEach(function(t){return t.process.apply(t,n(e))})}},{key:"computeIndices",value:function(){this.programs.forEach(function(e){"function"==typeof e.computeIndices&&e.computeIndices()})}},{key:"bufferData",value:function(){this.programs.forEach(function(e){return e.bufferData()})}},{key:"render",value:function(){var e=arguments;this.programs.forEach(function(t){t.bind(),t.bufferData(),t.render.apply(t,n(e))})}}]),t}()}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.createCompoundProgram=o;var s=r(20),l=function(){function e(t,r,n){i(this,e),this.vertexShaderSource=r,this.fragmentShaderSource=n,this.load(t)}return a(e,[{key:"load",value:function(e){return this.vertexShader=(0,s.loadVertexShader)(e,this.vertexShaderSource),this.fragmentShader=(0,s.loadFragmentShader)(e,this.fragmentShaderSource),this.program=(0,s.loadProgram)(e,[this.vertexShader,this.fragmentShader]),this.program}}]),e}();t.default=l},function(e,t,r){"use strict";function n(e,t,r){var n=r.labelSize,i=r.labelFont,o=r.labelWeight;e.fillStyle="#000",e.font=o+" "+n+"px "+i,e.fillText(t.label,t.x+t.size+3,t.y+n/3)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLRenderer=t.MouseCaptor=t.QuadTree=t.Camera=t.Renderer=void 0;var i=r(3),o=n(i),a=r(1),s=n(a),l=r(5),h=n(l),u=r(6),c=n(u),d=r(16),f=n(d);t.Renderer=o.default,t.Camera=s.default,t.QuadTree=h.default,t.MouseCaptor=c.default,t.WebGLRenderer=f.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.linear=function(e){return e},t.quadraticIn=function(e){return e*e},t.quadraticOut=function(e){return e*(2-e)},t.quadraticInOut=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},t.cubicIn=function(e){return e*e*e},t.cubicOut=function(e){return--e*e*e+1},t.cubicInOut=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},function(e,t){e.exports=function(e,t){var r=e.length,n=t.length;if(0!==n){e.length+=t.length;for(var i=0;i<n;i++)e[r+i]=t[i]}}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=r(0),s=function(e){function t(e,r){n(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.container=e,o.camera=r,o}return o(t,e),t}(a.EventEmitter);t.default=s},function(e,t,r){"use strict";function n(e){if(void 0!==e.offsetX)return e.offsetX;if(void 0!==e.layerX)return e.layerX;if(void 0!==e.clientX)return e.clientX;throw new Error("sigma/captors/utils.getX: could not extract x from event.")}function i(e){if(void 0!==e.offsetY)return e.offsetY;if(void 0!==e.layerY)return e.layerY;if(void 0!==e.clientY)return e.clientY;throw new Error("sigma/captors/utils.getY: could not extract y from event.")}function o(e){var t=e.target.ownerSVGElement?e.target.ownerSVGElement.width:e.target.width;if("number"==typeof t)return t;if(void 0!==t&&void 0!==t.baseVal)return t.baseVal.value;throw new Error("sigma/captors/utils.getWidth: could not extract width from event.")}function a(e){var t=e.target.ownerSVGElement?e.target.ownerSVGElement.height:e.target.height;if("number"==typeof t)return t;if(void 0!==t&&void 0!==t.baseVal)return t.baseVal.value;throw new Error("sigma/captors/utils.getHeight: could not extract height from event.")}function s(e){var t=-1!==e.target.namespaceURI.indexOf("svg")?1:(0,u.getPixelRatio)();return{x:o(e)/(2*t),y:a(e)/(2*t)}}function l(e){return{x:n(e),y:i(e),clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey}}function h(e){if(void 0!==e.wheelDelta)return e.wheelDelta/360;if(void 0!==e.detail)return e.detail/-9;throw new Error("sigma/captors/utils.getDelta: could not extract delta from event.")}Object.defineProperty(t,"__esModule",{value:!0}),t.getX=n,t.getY=i,t.getWidth=o,t.getHeight=a,t.getCenter=s,t.getMouseCoords=l,t.getWheelDelta=h;var u=r(7)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(17),h=r(8),u=n(h),c=r(3),d=n(c),f=r(1),v=n(f),p=r(6),g=n(p),y=r(5),m=n(y),b=r(18),w=r(19),_=n(w),x=r(24),E=n(x),A=r(10),L=n(A),P=r(27),T=n(P),M=r(4),k=r(7),S=r(2),O=r(29),C=r(30),D=(0,k.getPixelRatio)(),R=(0,k.getPixelRatio)(),N={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,defaultNodeColor:"#999",defaultEdgeColor:"#ccc",labelFont:"Arial",labelSize:14,labelWeight:"normal",nodeReducer:null,edgeReducer:null,zIndex:!1},F=function(e){function t(e,r,n){i(this,t);var a=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(n=n||{},a.settings=(0,M.assign)({},N,n),!(0,u.default)(e))throw new Error("sigma/renderers/webgl: invalid graph instance.");if(!(r instanceof HTMLElement))throw new Error("sigma/renderers/webgl: container should be an html element.");a.graph=e,a.captors={},a.container=r,a.elements={},a.contexts={},a.listeners={},a.quadtree=new m.default,a.nodeDataCache={},a.edgeDataCache={},a.nodeExtent=null,a.edgeExtent=null,a.initializeCache(),a.normalizationFunction=null,a.width=0,a.height=0,a.highlightedNodes=new Set,a.previousVisibleNodes=new Set,a.displayedLabels=new Set,a.hoveredNode=null,a.wasRenderedInThisFrame=!1,a.renderFrame=null,a.renderHighlightedNodesFrame=null,a.needToProcess=!1,a.needToSoftProcess=!1,a.createContext("edges"),a.createContext("nodes"),a.createContext("labels",!1),a.createContext("hovers",!1),a.createContext("mouse",!1);var s=a.contexts.nodes;return s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.enable(s.BLEND),s=a.contexts.edges,s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.enable(s.BLEND),a.nodePrograms={def:new _.default(a.contexts.nodes)},a.edgePrograms={def:new E.default(a.contexts.edges)},a.resize(),a.camera=new v.default({width:a.width,height:a.height}),a.bindCameraHandlers(),a.captors={mouse:new g.default(a.elements.mouse,a.camera)},a.bindEventHandlers(),a.bindGraphHandlers(),a.process(),a.render(),a}return a(t,e),s(t,[{key:"createContext",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(0,k.createElement)("canvas",{class:"sigma-"+e,style:{position:"absolute"}});this.elements[e]=r,this.container.appendChild(r);var n={preserveDrawingBuffer:!1,antialias:!1},i=void 0;return t?(i=r.getContext("webgl",n),i||(i=r.getContext("webgl",n)),i||(i=r.getContext("experimental-webgl",n))):i=r.getContext("2d",n),this.contexts[e]=i,this}},{key:"initializeCache",value:function(){for(var e=this.graph,t=e.nodes(),r=0,n=t.length;r<n;r++)this.nodeDataCache[t[r]]=new b.NodeDisplayData(r,this.settings);for(var i=e.edges(),o=0,a=i.length;o<a;o++)this.edgeDataCache[i[o]]=new b.EdgeDisplayData(o,this.settings)}},{key:"bindCameraHandlers",value:function(){var e=this;return this.listeners.camera=function(){e.scheduleRender()},this.camera.on("updated",this.listeners.camera),this}},{key:"bindEventHandlers",value:function(){var e=this;this.listeners.handleResize=function(){e.needToSoftProcess=!0,e.scheduleRender()},window.addEventListener("resize",this.listeners.handleResize);var t=function(e,t,r,n,i){return e>r-i&&e<r+i&&t>n-i&&t<n+i&&Math.sqrt(Math.pow(e-r,2)+Math.pow(t-n,2))<i},r=function(t,r){var n=e.camera.viewportToGraph(e,t,r);return e.quadtree.point(n.x,1-n.y)};return this.listeners.handleMove=function(n){for(var i=Math.pow(e.camera.getState().ratio,.5),o=r(n.x,n.y),a=1/0,s=null,l=0,h=o.length;l<h;l++){var u=o[l],c=e.nodeDataCache[u],d=e.camera.graphToViewport(e,c.x,c.y),f=c.size/i;if(t(n.x,n.y,d.x,d.y,f)){var v=Math.sqrt(Math.pow(n.x-d.x,2)+Math.pow(n.y-d.y,2));v<a&&(a=v,s=u)}}if(s)return e.hoveredNode=s,e.emit("overNode",{node:s}),e.scheduleHighlightedNodesRender();if(e.hoveredNode){var p=e.nodeDataCache[e.hoveredNode],g=e.camera.graphToViewport(e,p.x,p.y),y=p.size/i;if(!t(n.x,n.y,g.x,g.y,y))return e.hoveredNode=null,e.emit("outNode",{node:e.hoveredNode}),e.scheduleHighlightedNodesRender()}},this.listeners.handleDown=function(n){for(var i=Math.pow(e.camera.getState().ratio,.5),o=r(n.x,n.y),a=0,s=o.length;a<s;a++){var l=o[a],h=e.nodeDataCache[l],u=e.camera.graphToViewport(e,h.x,h.y),c=h.size/i;if(t(n.x,n.y,u.x,u.y,c))return e.emit("downNode",{node:l})}},this.listeners.handleClick=function(n){for(var i=Math.pow(e.camera.getState().ratio,.5),o=r(n.x,n.y),a=0,s=o.length;a<s;a++){var l=o[a],h=e.nodeDataCache[l],u=e.camera.graphToViewport(e,h.x,h.y),c=h.size/i;if(t(n.x,n.y,u.x,u.y,c))return e.emit("clickNode",{node:l})}return e.emit("clickStage")},this.captors.mouse.on("mousemove",this.listeners.handleMove),this.captors.mouse.on("mousedown",this.listeners.handleDown),this.captors.mouse.on("click",this.listeners.handleClick),this}},{key:"bindGraphHandlers",value:function(){var e=this,t=this.graph;return this.listeners.graphUpdate=function(){e.needToProcess=!0,e.scheduleRender()},this.listeners.softGraphUpdate=function(){e.needToSoftProcess=!0,e.scheduleRender()},t.on("nodeAdded",this.listeners.graphUpdate),t.on("nodeDropped",this.listeners.graphUpdate),t.on("nodeAttributesUpdated",this.listeners.softGraphUpdate),t.on("edgeAdded",this.listeners.graphUpdate),t.on("nodeDropped",this.listeners.graphUpdate),t.on("edgeAttributesUpdated",this.listeners.softGraphUpdate),t.on("cleared",this.listeners.graphUpdate),this}},{key:"process",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.graph,r=this.settings;this.quadtree.clear();var n=["x","y"];this.settings.zIndex&&(n.push("z"),this.edgeExtent=(0,l.edgeExtent)(t,["z"])),this.nodeExtent=(0,l.nodeExtent)(t,n),this.normalizationFunction=(0,k.createNormalizationFunction)(this.nodeExtent);var i=this.nodePrograms.def;e||i.allocate(t.order);var o=t.nodes();this.settings.zIndex&&(o=(0,C.zIndexOrdering)(this.edgeExtent.z,function(e){return t.getNodeAttribute(e,"z")},o));for(var a=0,s=o.length;a<s;a++){var h=o[a],u=t.getNodeAttributes(h),c=this.nodeDataCache[h];r.nodeReducer&&(u=r.nodeReducer(h,u)),c.assign(u),this.normalizationFunction.applyTo(c),this.quadtree.add(h,c.x,1-c.y,c.size/this.width),i.process(c,a),c.index=a}i.bufferData();var d=this.edgePrograms.def;e||d.allocate(t.size);var f=t.edges();this.settings.zIndex&&(f=(0,C.zIndexOrdering)(this.edgeExtent.z,function(e){return t.getEdgeAttribute(e,"z")},f));for(var v=0,p=f.length;v<p;v++){var g=f[v],y=t.getEdgeAttributes(g),m=this.edgeDataCache[g];r.edgeReducer&&(y=r.edgeReducer(g,y)),m.assign(y);var b=t.extremities(g),w=this.nodeDataCache[b[0]],_=this.nodeDataCache[b[1]];d.process(w,_,m,v),m.index=v}return e||"function"!=typeof d.computeIndices||d.computeIndices(),d.bufferData(),this}},{key:"processNode",value:function(e){var t=this.nodePrograms.def,r=this.graph.getNodeAttributes(e);return t.process(r,this.nodeDataCache[e].index),this}},{key:"processEdge",value:function(e){var t=this.graph,r=this.edgePrograms.def,n=t.getEdgeAttributes(e),i=t.extremities(e),o=t.getNodeAttributes(i[0]),a=t.getNodeAttributes(i[1]);return r.process(o,a,n,this.edgeDataCache[e].index),this}},{key:"getCamera",value:function(){return this.camera}},{key:"getMouseCaptor",value:function(){return this.captors.mouse}},{key:"resize",value:function(e,t){var r=this.width,n=this.height;if(arguments.length>1?(this.width=e,this.height=t):(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight),0===this.width)throw new Error("sigma/renderers/webgl: container as no width.");if(0===this.height)throw new Error("sigma/renderers/webgl: container as no height.");if(r===this.width&&n===this.height)return this;for(var i in this.elements){var o=this.elements[i];o.style.width=this.width+"px",o.style.height=this.height+"px"}for(var a in this.contexts){var s=this.contexts[a];s.scale?(this.elements[a].setAttribute("width",this.width*D+"px"),this.elements[a].setAttribute("height",this.height*D+"px"),1!==D&&s.scale(D,D)):(this.elements[a].setAttribute("width",this.width*R+"px"),this.elements[a].setAttribute("height",this.height*R+"px")),s.viewport&&s.viewport(0,0,this.width*R,this.height*R)}return this}},{key:"clear",value:function(){return this.contexts.labels.clearRect(0,0,this.width,this.height),this}},{key:"render",value:function(){this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null,this.needToProcess=!1,this.needToSoftProcess=!1);var e=this.camera.isAnimated()||this.captors.mouse.isMoving||this.captors.mouse.hasDragged||this.captors.mouse.wheelLock;this.resize(),this.clear();var t=this.camera.getState(),r=(0,S.matrixFromCamera)(t,{width:this.width,height:this.height}),n=void 0;if(n=this.nodePrograms.def,n.render({matrix:r,width:this.width,height:this.height,ratio:t.ratio,nodesPowRatio:.5,scalingRatio:R}),this.settings.hideEdgesOnMove&&e||(n=this.edgePrograms.def,n.render({matrix:r,width:this.width,height:this.height,ratio:t.ratio,nodesPowRatio:.5,edgesPowRatio:.5,scalingRatio:R})),this.settings.hideLabelsOnMove&&e)return this;var i=void 0;if(t.ratio>=1)i=this.graph.nodes();else{var o=this.camera.viewRectangle(this);i=this.quadtree.rectangle(o.x1,1-o.y1,o.x2,1-o.y2,o.height)}if(!this.settings.renderLabels)return this;for(var a=(0,O.labelsToDisplayFromGrid)({cache:this.nodeDataCache,camera:this.camera,displayedLabels:this.displayedLabels,previousVisibleNodes:this.previousVisibleNodes,visibleNodes:i,dimensions:this}),s=this.contexts.labels,l=Math.pow(t.ratio,.5),h=0,u=a.length;h<u;h++){var c=this.nodeDataCache[a[h]],d=this.camera.graphToViewport(this,c.x,c.y),f=d.x,v=d.y,p=c.size/l;(0,L.default)(s,{label:c.label,size:p,x:f,y:v},this.settings)}return this.previousVisibleNodes=new Set(i),this.displayedLabels=new Set(a),this.renderHighlightedNodes(),this}},{key:"renderHighlightedNodes",value:function(){var e=this,t=this.camera,r=Math.pow(t.getState().ratio,.5),n=this.contexts.hovers;n.clearRect(0,0,this.width,this.height);var i=function(i){var o=e.nodeDataCache[i],a=t.graphToViewport(e,o.x,o.y),s=a.x,l=a.y,h=o.size/r;(0,T.default)(n,{label:o.label,color:o.color,size:h,x:s,y:l},e.settings)};this.hoveredNode&&i(this.hoveredNode),this.highlightedNodes.forEach(i)}},{key:"scheduleRender",value:function(){var e=this;if(this.renderFrame)return this;this.renderFrame=requestAnimationFrame(function(){(e.needToProcess||e.needToSoftProcess)&&e.process(e.needToSoftProcess),e.renderFrame=null,e.needToProcess=!1,e.needToSoftProcess=!1,e.render()})}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;if(this.renderHighlightedNodesFrame||this.renderFrame)return this;this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes()})}},{key:"refresh",value:function(){return this.needToSoftProcess=!0,this.scheduleRender(),this}},{key:"highlightNode",value:function(e){return this.highlightedNodes.add(e),this.scheduleHighlightedNodesRender(),this}},{key:"unhighlightNode",value:function(e){return this.highlightedNodes.delete(e),this.scheduleHighlightedNodesRender(),this}},{key:"kill",value:function(){var e=this.graph;this.camera.removeListener("updated",this.listeners.camera),window.removeEventListener("resize",this.listeners.handleResize),this.captors.mouse.kill(),e.removeListener("nodeAdded",this.listeners.graphUpdate),e.removeListener("nodeDropped",this.listeners.graphUpdate),e.removeListener("nodeAttributesUpdated",this.listeners.softGraphUpdate),e.removeListener("edgeAdded",this.listeners.graphUpdate),e.removeListener("nodeDropped",this.listeners.graphUpdate),e.removeListener("edgeAttributesUpdated",this.listeners.softGraphUpdate),e.removeListener("cleared",this.listeners.graphUpdate),this.quadtree=null,this.nodeDataCache=null,this.edgeDataCache=null,this.highlightedNodes=null,this.previousVisibleNodes=null,this.displayedLabels=null;for(var t=this.container;t.firstChild;)t.removeChild(t.firstChild)}}]),t}(d.default);t.default=F},function(e,t,r){function n(e,t){if(!o(e))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,n,i,a,s,l,h,u=[].concat(t),c=e.nodes(),d={};for(s=0;s<u.length;s++)a=u[s],d[a]=[1/0,-1/0];for(l=0,h=c.length;l<h;l++)for(r=c[l],n=e.getNodeAttributes(r),s=0;s<u.length;s++)a=u[s],i=n[a],i<d[a][0]&&(d[a][0]=i),i>d[a][1]&&(d[a][1]=i);return"string"==typeof t?d[t]:d}function i(e,t){if(!o(e))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,n,i,a,s,l,h,u=[].concat(t),c=e.edges(),d={};for(s=0;s<u.length;s++)a=u[s],d[a]=[1/0,-1/0];for(l=0,h=c.length;l<h;l++)for(r=c[l],n=e.getEdgeAttributes(r),s=0;s<u.length;s++)a=u[s],i=n[a],i<d[a][0]&&(d[a][0]=i),i>d[a][1]&&(d[a][1]=i);return"string"==typeof t?d[t]:d}var o=r(8),a=n;a.nodeExtent=n,a.edgeExtent=i,e.exports=a},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.NodeDisplayData=function(){function e(t,r){n(this,e),this.index=t,this.x=0,this.y=0,this.size=2,this.color=r.defaultNodeColor,this.hidden=!1,this.label=""}return i(e,[{key:"assign",value:function(e){"x"in e&&(this.x=e.x),"y"in e&&(this.y=e.y),"size"in e&&(this.size=e.size),"color"in e&&(this.color=e.color),"hidden"in e&&(this.hidden=e.hidden),"label"in e&&(this.label=e.label)}}]),e}(),t.EdgeDisplayData=function(){function e(t,r){n(this,e),this.index=t,this.size=1,this.color=r.defaultEdgeColor,this.hidden=!1}return i(e,[{key:"assign",value:function(e){"size"in e&&(this.size=e.size),"color"in e&&(this.color=e.color),"hidden"in e&&(this.hidden=e.hidden)}}]),e}()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(9),h=n(l),u=r(2),c=r(22),d=n(c),f=r(23),v=n(f),p=4,g=function(e){function t(e){i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,d.default,v.default));r.gl=e,r.array=null,r.buffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,r.buffer);var n=r.program;return r.positionLocation=e.getAttribLocation(n,"a_position"),r.sizeLocation=e.getAttribLocation(n,"a_size"),r.colorLocation=e.getAttribLocation(n,"a_color"),r.matrixLocation=e.getUniformLocation(n,"u_matrix"),r.ratioLocation=e.getUniformLocation(n,"u_ratio"),r.scaleLocation=e.getUniformLocation(n,"u_scale"),e.enableVertexAttribArray(r.positionLocation),e.enableVertexAttribArray(r.sizeLocation),e.enableVertexAttribArray(r.colorLocation),e.vertexAttribPointer(r.positionLocation,2,e.FLOAT,!1,p*Float32Array.BYTES_PER_ELEMENT,0),e.vertexAttribPointer(r.sizeLocation,1,e.FLOAT,!1,p*Float32Array.BYTES_PER_ELEMENT,8),e.vertexAttribPointer(r.colorLocation,4,e.UNSIGNED_BYTE,!0,p*Float32Array.BYTES_PER_ELEMENT,12),r}return a(t,e),s(t,[{key:"allocate",value:function(e){this.array=new Float32Array(1*p*e)}},{key:"process",value:function(e,t){var r=(0,u.floatColor)(e.color),n=1*t*p,i=this.array;if(e.hidden)return i[n++]=0,i[n++]=0,i[n++]=0,void(i[n++]=0);i[n++]=e.x,i[n++]=e.y,i[n++]=e.size,i[n]=r}},{key:"bufferData",value:function(){var e=this.gl;e.bufferData(e.ARRAY_BUFFER,this.array,e.DYNAMIC_DRAW)}},{key:"render",value:function(e){var t=this.gl,r=this.program;t.useProgram(r),t.uniform1f(this.ratioLocation,1/Math.pow(e.ratio,e.nodesPowRatio)),t.uniform1f(this.scaleLocation,e.scalingRatio),t.uniformMatrix3fv(this.matrixLocation,!1,e.matrix),t.drawArrays(t.POINTS,0,this.array.length/p)}}]),t}(h.default);t.default=g},function(e,t,r){"use strict";function n(e,t,r){var n="VERTEX"===e?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(n);if(t.shaderSource(i,r),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){var o=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error("sigma/renderers/weblg/shaders/utils.loadShader: error while compiling the shader:\n"+o+"\n"+r)}return i}function i(e,t){var r=e.createProgram(),n=void 0,i=void 0;for(n=0,i=t.length;n<i;n++)e.attachShader(r,t[n]);if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw e.deleteProgram(r),new Error("sigma/renderers/weblg/shaders/utils.loadProgram: error while linking the program.");return r}Object.defineProperty(t,"__esModule",{value:!0}),t.loadProgram=i;var o=n.bind(null,"VERTEX"),a=n.bind(null,"FRAGMENT");t.loadVertexShader=o,t.loadFragmentShader=a},function(e,t,r){"use strict";function n(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function i(e,t,r){return e[0]=t,e[4]=arguments.length>2?r:t,e}function o(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[3]=-r,e[4]=n,e}function a(e,t,r){return e[6]=t,e[7]=r,e}function s(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=t[0],d=t[1],f=t[2],v=t[3],p=t[4],g=t[5],y=t[6],m=t[7],b=t[8];return e[0]=c*r+d*o+f*l,e[1]=c*n+d*a+f*h,e[2]=c*i+d*s+f*u,e[3]=v*r+p*o+g*l,e[4]=v*n+p*a+g*h,e[5]=v*i+p*s+g*u,e[6]=y*r+m*o+b*l,e[7]=y*n+m*a+b*h,e[8]=y*i+m*s+b*u,e}Object.defineProperty(t,"__esModule",{value:!0}),t.identity=n,t.scale=i,t.rotate=o,t.translate=a,t.multiply=s},function(e,t){e.exports="attribute vec2 a_position;\nattribute float a_size;\nattribute vec4 a_color;\n\nuniform float u_ratio;\nuniform float u_scale;\nuniform mat3 u_matrix;\n\nvarying vec4 v_color;\nvarying float v_border;\n\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n gl_Position = vec4(\n (u_matrix * vec3(a_position, 1)).xy,\n 0,\n 1\n );\n\n // Multiply the point size twice:\n // - x SCALING_RATIO to correct the canvas scaling\n // - x 2 to correct the formulae\n gl_PointSize = a_size * u_ratio * u_scale * 2.0;\n\n v_border = (1.0 / u_ratio) * (0.5 / a_size);\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},function(e,t){e.exports="precision mediump float;\n\nvarying vec4 v_color;\nvarying float v_border;\n\nconst float radius = 0.5;\n\nvoid main(void) {\n vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0);\n vec2 m = gl_PointCoord - vec2(0.5, 0.5);\n float dist = radius - length(m);\n\n float t = 0.0;\n if (dist > v_border)\n t = 1.0;\n else if (dist > 0.0)\n t = dist / v_border;\n\n // gl_FragColor = mix(color0, v_color, t);\n gl_FragColor = mix(color0, v_color, t);\n}\n"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(9),h=n(l),u=r(2),c=r(25),d=n(c),f=r(26),v=n(f),p=function(e){function t(e){i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,d.default,v.default));r.gl=e,r.array=null,r.indicesArray=null,r.buffer=e.createBuffer(),r.indicesBuffer=e.createBuffer(),r.positionLocation=e.getAttribLocation(r.program,"a_position"),r.normalLocation=e.getAttribLocation(r.program,"a_normal"),r.thicknessLocation=e.getAttribLocation(r.program,"a_thickness"),r.colorLocation=e.getAttribLocation(r.program,"a_color"),r.resolutionLocation=e.getUniformLocation(r.program,"u_resolution"),r.ratioLocation=e.getUniformLocation(r.program,"u_ratio"),r.matrixLocation=e.getUniformLocation(r.program,"u_matrix"),r.scaleLocation=e.getUniformLocation(r.program,"u_scale"),r.bind();var n="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,a=n||e.getExtension("OES_element_index_uint");return r.canUse32BitsIndices=!!a,r.IndicesArray=r.canUse32BitsIndices?Uint32Array:Uint16Array,r.indicesType=r.canUse32BitsIndices?e.UNSIGNED_INT:e.UNSIGNED_SHORT,r}return a(t,e),s(t,[{key:"bind",value:function(){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indicesBuffer),e.enableVertexAttribArray(this.positionLocation),e.enableVertexAttribArray(this.normalLocation),e.enableVertexAttribArray(this.thicknessLocation),e.enableVertexAttribArray(this.colorLocation),e.vertexAttribPointer(this.positionLocation,2,e.FLOAT,!1,6*Float32Array.BYTES_PER_ELEMENT,0),e.vertexAttribPointer(this.normalLocation,2,e.FLOAT,!1,6*Float32Array.BYTES_PER_ELEMENT,8),e.vertexAttribPointer(this.thicknessLocation,1,e.FLOAT,!1,6*Float32Array.BYTES_PER_ELEMENT,16),e.vertexAttribPointer(this.colorLocation,4,e.UNSIGNED_BYTE,!0,6*Float32Array.BYTES_PER_ELEMENT,20)}},{key:"allocate",value:function(e){this.array=new Float32Array(24*e)}},{key:"process",value:function(e,t,r,n){if(e.hidden||t.hidden||r.hidden)for(var i=24*n,o=i+24;i<o;i++)this.array[i]=0;else{var a=r.size||1,s=e.x,l=e.y,h=t.x,c=t.y,d=(0,u.floatColor)(r.color),f=h-s,v=c-l,p=f*f+v*v,g=0,y=0;p&&(p=1/Math.sqrt(p),g=-v*p,y=f*p);var m=24*n,b=this.array;b[m++]=s,b[m++]=l,b[m++]=g,b[m++]=y,b[m++]=a,b[m++]=d,b[m++]=s,b[m++]=l,b[m++]=-g,b[m++]=-y,b[m++]=a,b[m++]=d,b[m++]=h,b[m++]=c,b[m++]=g,b[m++]=y,b[m++]=a,b[m++]=d,b[m++]=h,b[m++]=c,b[m++]=-g,b[m++]=-y,b[m++]=a,b[m]=d}}},{key:"computeIndices",value:function(){for(var e=this.array.length/6,t=e+e/2,r=new this.IndicesArray(t),n=0,i=0;n<e;n+=4)r[i++]=n,r[i++]=n+1,r[i++]=n+2,r[i++]=n+2,r[i++]=n+1,r[i++]=n+3;this.indicesArray=r}},{key:"bufferData",value:function(){var e=this.gl;e.bufferData(e.ARRAY_BUFFER,this.array,e.DYNAMIC_DRAW),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indicesArray,e.STATIC_DRAW)}},{key:"render",value:function(e){var t=this.gl,r=this.program;t.useProgram(r),t.uniform2f(this.resolutionLocation,e.width,e.height),t.uniform1f(this.ratioLocation,e.ratio),t.uniformMatrix3fv(this.matrixLocation,!1,e.matrix),t.uniform1f(this.scaleLocation,e.scalingRatio),t.drawElements(t.TRIANGLES,this.indicesArray.length,this.indicesType,0)}}]),t}(h.default);t.default=p},function(e,t){e.exports="attribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_thickness;\nattribute vec4 a_color;\n\nuniform vec2 u_resolution;\nuniform float u_ratio;\nuniform mat3 u_matrix;\nuniform float u_scale;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float feather = 0.8;\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n // Computing thickness in pixels\n float pow_ratio = 1.0 / pow(u_ratio, 0.5);\n float thickness = a_thickness / 2.0 * pow_ratio / u_scale;\n\n // Adding a small feather for AA\n thickness += feather;\n\n // Computing delta relative to viewport\n vec2 delta = (a_normal * thickness) / u_resolution;\n\n vec2 position = (u_matrix * vec3(a_position, 1)).xy;\n position += delta;\n\n // Applying\n gl_Position = vec4(position, 0, 1);\n\n v_normal = a_normal;\n v_thickness = thickness;\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},function(e,t){e.exports="precision mediump float;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float feather = 0.8;\nconst vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main(void) {\n float dist = length(v_normal) * v_thickness;\n\n float t = smoothstep(\n v_thickness - feather,\n v_thickness,\n dist\n );\n\n gl_FragColor = mix(v_color, color0, t);\n}\n"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){var n=r.labelSize,i=r.labelFont,o=r.labelWeight;e.font=o+" "+n+"px "+i,e.beginPath(),e.fillStyle="#fff",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var s=e.measureText(t.label).width,h=Math.round(t.x-n/2-2),u=Math.round(t.y-n/2-2),c=Math.round(s+n/2+t.size+9),d=Math.round(n+4),f=Math.round(n/2+2);e.moveTo(h,u+f),e.moveTo(h,u+f),e.arcTo(h,u,h+f,u,f),e.lineTo(h+c,u),e.lineTo(h+c,u+d),e.lineTo(h+f,u+d),e.arcTo(h,u+d,h,u+d-f,f),e.lineTo(h,u+f),e.closePath(),e.fill(),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,(0,a.default)(e,t),(0,l.default)(e,t,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var o=r(28),a=n(o),s=r(10),l=n(s)},function(e,t,r){"use strict";function n(e,t){e.fillStyle=t.color,e.beginPath(),e.arc(t.x,t.y,t.size,0,i,!0),e.closePath(),e.fill()}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var i=2*Math.PI},function(e,t,r){"use strict";var n={width:200,height:150},i={width:400,height:300};t.labelsToDisplayFromGrid=function(e){var t=e.cache,r=e.camera,o=e.displayedLabels,a=e.previousVisibleNodes,s=e.visibleNodes,l=e.dimensions,h=r.getState(),u=r.getPreviousState(),c=h.ratio<u.ratio,d=h.x!==u.x||h.y!==u.x,f=h.ratio>u.ratio,v=!c&&!f&&h.ratio>=1;if(f&&Math.trunc(10*h.ratio)%3!=0)return Array.from(o);if(v&&0!==o.size)return Array.from(o);for(var p=h.ratio>=1.3?i:n,g=l.width%p.width,y=p.width+g/Math.floor(l.width/p.width),m=l.height%p.height,b=p.height+m/Math.floor(l.height/p.height),w={},_=new Set,x=[],E=0,A=s.length;E<A;E++){var L=s[E],P=t[L];if(!d||c||f||o.has(L)||!a.has(L)){var T=r.graphToViewport(l,P.x,P.y),M=Math.floor(T.x/y),k=Math.floor(T.y/b),S=M+";"+k;if((c||d&&!f)&&o.has(L))_.add(S),x.push(L);else if(!_.has(S))if(void 0===w[S])w[S]=L;else{var O=w[S],C=t[O];(P.size>C.size||P.size===C.size&&L>O)&&(w[S]=L)}}}for(var D in w)x.push(w[D]);return x}},function(e,t,r){"use strict";t.zIndexOrdering=function(e,t,r){return r.sort(function(e,r){var n=t(e)||0,i=t(r)||0;return n<i?-1:n>i?1:0})}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Sigma=t():e.Sigma=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=r(1),l=r(12),h=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(l),u=r(4),c={easing:"quadraticInOut",duration:150},d=function(e){function t(){n(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.x=.5,e.y=.5,e.angle=0,e.ratio=1,e.nextFrame=null,e.previousState=e.getState(),e.enabled=!0,e}return o(t,e),a(t,[{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:"getPreviousState",value:function(){var e=this.previousState;return{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"graphToViewport",value:function(e,t,r){var n=Math.min(e.width,e.height),i=n/e.width,o=n/e.height;return{x:(t-this.x+this.ratio/2/i)*(n/this.ratio),y:(this.y-r+this.ratio/2/o)*(n/this.ratio)}}},{key:"viewportToGraph",value:function(e,t,r){var n=Math.min(e.width,e.height),i=n/e.width,o=n/e.height;return{x:this.ratio/n*t+this.x-this.ratio/2/i,y:-(this.ratio/n*r-this.y-this.ratio/2/o)}}},{key:"viewRectangle",value:function(e){var t=0*e.width/8,r=0*e.height/8,n=this.viewportToGraph(e,0-t,0-r),i=this.viewportToGraph(e,e.width+t,0-r),o=this.viewportToGraph(e,0,e.height+r);return{x1:n.x,y1:n.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"setState",value:function(e){return this.enabled?(this.previousState=this.getState(),"x"in e&&(this.x=e.x),"y"in e&&(this.y=e.y),"angle"in e&&(this.angle=e.angle),"ratio"in e&&(this.ratio=e.ratio),this.emit("updated",this.getState()),this):this}},{key:"animate",value:function(e,t,r){var n=this;if(!this.enabled)return this;t=(0,u.assign)({},c,t);var i="function"==typeof t.easing?t.easing:h[t.easing];this.nextFrame&&cancelAnimationFrame(this.nextFrame);var o=Date.now(),a=this.getState(),s=function s(){var l=(Date.now()-o)/t.duration;if(l>=1)return n.nextFrame=null,n.setState(e),void("function"==typeof r&&r());var h=i(l),u={};"x"in e&&(u.x=a.x+(e.x-a.x)*h),"y"in e&&(u.y=a.y+(e.y-a.y)*h),"angle"in e&&(u.angle=a.angle+(e.angle-a.angle)*h),"ratio"in e&&(u.ratio=a.ratio+(e.ratio-a.ratio)*h),n.setState(u),n.nextFrame=requestAnimationFrame(s)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.nextFrame=requestAnimationFrame(s)):s()}},{key:"animatedZoom",value:function(e){return e?"number"==typeof e?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||1.5)},e):this.animate({ratio:this.ratio/1.5})}},{key:"animatedUnzoom",value:function(e){return e?"number"==typeof e?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||1.5)},e):this.animate({ratio:1.5*this.ratio})}},{key:"animatedReset",value:function(e){return this.animate({x:0,y:0,ratio:1,angle:0},e)}}]),t}(s.EventEmitter);t.default=d},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!i(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,i,s,l,h;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(r=this._events[e],a(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),r.apply(this,s)}else if(o(r))for(s=Array.prototype.slice.call(arguments,1),h=r.slice(),i=h.length,l=0;l<i;l++)h[l].apply(this,s);return!0},r.prototype.addListener=function(e,t){var i;if(!n(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(i=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,i,a,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,i=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=s;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";function n(e){if(void 0!==l[e])return l[e];var t=0,r=0,n=0,i=1;if("#"===e[0])4===e.length?(t=parseInt(e.charAt(1)+e.charAt(1),16),r=parseInt(e.charAt(2)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(4),16),n=parseInt(e.charAt(5)+e.charAt(6),16));else if(d.test(e)){var o=e.match(f);t=+o[1],r=+o[2],n=+o[3],o[4]&&(i=+o[4])}i=255*i|0;var a=4278190079&(i<<24|n<<16|r<<8|t);u[0]=a;var s=c[0];return l[e]=s,s}function i(e,t){var r=e.angle,n=e.ratio,i=e.x,o=e.y,a=t.width,l=t.height,h=(0,s.identity)(),u=Math.min(a,l),c=(0,s.translate)((0,s.identity)(),-i,-o),d=(0,s.scale)((0,s.identity)(),1/n),f=(0,s.rotate)((0,s.identity)(),-r),v=(0,s.scale)((0,s.identity)(),u/a*2,u/l*2);return(0,s.multiply)(h,v),(0,s.multiply)(h,f),(0,s.multiply)(h,d),(0,s.multiply)(h,c),h}function o(e,t,r,n){var i=n||new Uint8Array(4);return e.readPixels(t,r,1,1,e.RGBA,e.UNSIGNED_BYTE,i),i}function a(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||!!e.getExtension("OES_element_index_uint")}Object.defineProperty(t,"__esModule",{value:!0}),t.floatColor=n,t.matrixFromCamera=i,t.extractPixel=o,t.canUse32BitsIndices=a;var s=r(21),l={},h=new Int8Array(4),u=new Int32Array(h.buffer,0,1),c=new Float32Array(h.buffer,0,1),d=/^\s*rgba?\s*\(/,f=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=r(1),s=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),t}(a.EventEmitter);t.default=s},function(e,t,r){"use strict";function n(e){e=e||{};for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var i=0,o=r.length;i<o;i++)if(r[i])for(var a in r[i])e[a]=r[i][a];return e}Object.defineProperty(t,"__esModule",{value:!0}),t.assign=n},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,r,n){return e===r||t===n}function o(e,t,r,n,i,o,a){return e<n+o&&e+r>n&&t<i+a&&t+r>i}function a(e,t,r,n,i,o,a,s){return e<i+a&&e+r>i&&t<o+s&&t+n>o}function s(e,t,r,n,i,o){var a=r+i/2,s=n+o/2,l=t<s,h=e<a;return l?h?w:x:h?_:E}function l(e,t){for(var r=[0,0];r.length;){var n=r.pop(),i=r.pop(),o=4*i+v,a=4*i+2*v,s=4*i+3*v,l=4*i+4*v,h=t[i+g],u=t[i+y],c=t[i+m],d=t[i+b],f=c/2,p=d/2;t[o+g]=h,t[o+y]=u,t[o+m]=f,t[o+b]=p,t[a+g]=h+f,t[a+y]=u,t[a+m]=f,t[a+b]=p,t[s+g]=h,t[s+y]=u+p,t[s+m]=f,t[s+b]=p,t[l+g]=h+f,t[l+y]=u+p,t[l+m]=f,t[l+b]=p,n<e-1&&(r.push(l,n+1),r.push(s,n+1),r.push(a,n+1),r.push(o,n+1))}}function h(e,t,r,n,i,a,s){for(var l=i-s,h=a-s,u=2*s,c=0,d=0;;){if(c>=e)return r[d]=r[d]||[],void r[d].push(n);var f=4*d+v,p=4*d+2*v,w=4*d+3*v,x=4*d+4*v,_=o(l,h,u,t[f+g],t[f+y],t[f+m],t[f+b]),E=o(l,h,u,t[p+g],t[p+y],t[p+m],t[p+b]),A=o(l,h,u,t[w+g],t[w+y],t[w+m],t[w+b]),L=o(l,h,u,t[x+g],t[x+y],t[x+m],t[x+b]),T=_+E+A+L;if(0===T)throw new Error("sigma/quadtree.insertNode: no collision (level: "+c+", key: "+n+", x: "+i+", y: "+a+", size: "+s+").");if(3===T)throw new Error("sigma/quadtree.insertNode: 3 impossible collisions (level: "+c+", key: "+n+", x: "+i+", y: "+a+", size: "+s+").");if(T>1)return r[d]=r[d]||[],void r[d].push(n);c++,_&&(d=f),E&&(d=p),A&&(d=w),L&&(d=x)}}function u(e,t,r,n,i,o,s){for(var l=[0,0],h=[],u=void 0;l.length;){var c=l.pop(),d=l.pop();if(u=r[d],u&&(0,f.default)(h,u),!(c>=e)){var p=4*d+v,w=4*d+2*v,x=4*d+3*v,_=4*d+4*v,E=a(n,i,o,s,t[p+g],t[p+y],t[p+m],t[p+b]),A=a(n,i,o,s,t[w+g],t[w+y],t[w+m],t[w+b]),L=a(n,i,o,s,t[x+g],t[x+y],t[x+m],t[x+b]),T=a(n,i,o,s,t[_+g],t[_+y],t[_+m],t[_+b]);E&&l.push(p,c+1),A&&l.push(w,c+1),L&&l.push(x,c+1),T&&l.push(_,c+1)}}return h}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),d=r(13),f=function(e){return e&&e.__esModule?e:{default:e}}(d),v=4,p=5,g=0,y=1,m=2,b=3,w=1,x=2,_=3,E=4,A=function(){function e(t){n(this,e),t=t||{};var r=Math.pow(4,p);this.data=new Float32Array(v*((4*r-1)/3)),this.containers={},this.cache=null,this.lastRectangle=null,t.boundaries?this.resize(t.boundaries):this.resize({x:0,y:0,width:1,height:1}),"function"==typeof t.filter&&(this.nodeFilter=t.filter)}return c(e,[{key:"add",value:function(e,t,r,n){return h(p,this.data,this.containers,e,t,r,n),this}},{key:"resize",value:function(e){this.clear(),this.data[g]=e.x,this.data[y]=e.y,this.data[m]=e.width,this.data[b]=e.height,l(p,this.data)}},{key:"clear",value:function(){return this.containers={},this}},{key:"point",value:function(e,t){var r=[],n=0,i=0;do{this.containers[n]&&r.push.apply(r,this.containers[n]);n=4*n+s(e,t,this.data[n+g],this.data[n+y],this.data[n+m],this.data[n+b])*v,i++}while(i<=p);return r}},{key:"rectangle",value:function(e,t,r,n,o){var a=this.lastRectangle;if(a&&e===a.x1&&r===a.x2&&t===a.y1&&n===a.y2&&o===a.height)return this.cache;if(this.lastRectangle={x1:e,y1:t,x2:r,y2:n,height:o},!i(e,t,r,n))throw new Error("sigma/quadtree.rectangle: shifted view is not yet implemented.");var s=u(p,this.data,this.containers,e,t,Math.abs(e-r)||Math.abs(t-n),o);return this.cache=s,this.cache}}]),e}();t.default=A},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(0),h=n(l),u=r(14),c=n(u),d=r(15),f=function(e){function t(e,r){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r));return n.container=e,n.camera=r,n.enabled=!0,n.hasDragged=!1,n.downStartTime=null,n.lastMouseX=null,n.lastMouseY=null,n.isMouseDown=!1,n.isMoving=!1,n.movingTimeout=null,n.startCameraState=null,n.lastCameraState=null,n.clicks=0,n.doubleClickTimeout=null,n.wheelLock=!1,n.handleClick=n.handleClick.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.handleOut=n.handleOut.bind(n),e.addEventListener("click",n.handleClick,!1),e.addEventListener("mousedown",n.handleDown,!1),e.addEventListener("mousemove",n.handleMove,!1),e.addEventListener("DOMMouseScroll",n.handleWheel,!1),e.addEventListener("mousewheel",n.handleWheel,!1),e.addEventListener("mouseout",n.handleOut,!1),document.addEventListener("mouseup",n.handleUp,!1),n}return a(t,e),s(t,[{key:"kill",value:function(){var e=this.container;e.removeEventListener("click",this.handleClick),e.removeEventListener("mousedown",this.handleDown),e.removeEventListener("mousemove",this.handleMove),e.removeEventListener("DOMMouseScroll",this.handleWheel),e.removeEventListener("mousewheel",this.handleWheel),e.removeEventListener("mouseout",this.handleOut),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(e){var t=this;if(this.enabled){if(2===++this.clicks)return this.clicks=0,clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null,this.handleDoubleClick(e);setTimeout(function(){t.clicks=0,t.doubleClickTimeout=null},300),this.emit("click",(0,d.getMouseCoords)(e))}}},{key:"handleDoubleClick",value:function(e){if(this.enabled){var t=(0,d.getCenter)(e),r=this.camera.getState(),n=r.ratio/2.2,i={width:this.container.offsetWidth,height:this.container.offsetHeight},o=(0,d.getX)(e),a=(0,d.getY)(e),s=new h.default;s.ratio=n,s.x=r.x,s.y=r.y;var l=this.camera.viewportToGraph(i,o,a),u=this.camera.viewportToGraph(i,t.x,t.y),c=s.viewportToGraph(i,o,a),f=s.viewportToGraph(i,t.x,t.y),v=c.x-f.x-l.x+u.x,p=c.y-f.y-l.y+u.y;return this.camera.animate({x:r.x-v,y:r.y-p,ratio:n},{easing:"quadraticInOut",duration:200}),e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation(),!1}}},{key:"handleDown",value:function(e){this.enabled&&(this.startCameraState=this.camera.getState(),this.lastCameraState=this.startCameraState,this.lastMouseX=(0,d.getX)(e),this.lastMouseY=(0,d.getY)(e),this.hasDragged=!1,this.downStartTime=Date.now(),e.which,this.isMouseDown=!0,this.emit("mousedown",(0,d.getMouseCoords)(e)))}},{key:"handleUp",value:function(e){if(this.enabled&&this.isMouseDown){this.isMouseDown=!1,this.movingTimeout&&(this.movingTimeout=null,clearTimeout(this.movingTimeout));var t=(0,d.getX)(e),r=(0,d.getY)(e),n=this.camera.getState(),i=this.camera.getPreviousState();this.isMoving?this.camera.animate({x:n.x+3*(n.x-i.x),y:n.y+3*(n.y-i.y)},{duration:200,easing:"quadraticOut"}):this.lastMouseX===t&&this.lastMouseY===r||this.camera.setState({x:n.x,y:n.y}),this.isMoving=!1,this.hasDragged=!1,this.emit("mouseup",(0,d.getMouseCoords)(e))}}},{key:"handleMove",value:function(e){var t=this;if(this.enabled){if(this.emit("mousemove",(0,d.getMouseCoords)(e)),this.isMouseDown){this.isMoving=!0,this.hasDragged=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=setTimeout(function(){t.movingTimeout=null,t.isMoving=!1},200);var r={width:this.container.offsetWidth,height:this.container.offsetHeight},n=(0,d.getX)(e),i=(0,d.getY)(e),o=this.camera.viewportToGraph(r,this.lastMouseX,this.lastMouseY),a=this.camera.viewportToGraph(r,n,i),s=o.x-a.x,l=o.y-a.y,h=this.camera.getState(),u=h.x+s,c=h.y+l;this.camera.setState({x:u,y:c}),this.lastMouseX=n,this.lastMouseY=i}return e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation(),!1}}},{key:"handleWheel",value:function(e){var t=this;if(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation(),!this.enabled)return!1;var r=(0,d.getWheelDelta)(e);if(!r)return!1;if(this.wheelLock)return!1;this.wheelLock=!0;var n=r>0?1/1.7:1.7,i=this.camera.getState(),o=n*i.ratio,a=(0,d.getCenter)(e),s={width:this.container.offsetWidth,height:this.container.offsetHeight},l=(0,d.getX)(e),u=(0,d.getY)(e),c=new h.default;c.ratio=o,c.x=i.x,c.y=i.y;var f=this.camera.viewportToGraph(s,l,u),v=this.camera.viewportToGraph(s,a.x,a.y),p=c.viewportToGraph(s,l,u),g=c.viewportToGraph(s,a.x,a.y),y=p.x-g.x-f.x+v.x,m=p.y-g.y-f.y+v.y;return this.camera.animate({x:i.x-y,y:i.y-m,ratio:o},{easing:"linear",duration:200},function(){return t.wheelLock=!1}),!1}},{key:"handleOut",value:function(){}}]),t}(c.default);t.default=f},function(e,t,r){"use strict";function n(e,t){var r=document.createElement(e);if(!t)return r;for(var n in t)if("style"===n)for(var i in t[n])r.style[i]=t[n][i];else r.setAttribute(n,t[n]);return r}function i(){var e=window.screen;return void 0!==e.deviceXDPI&&void 0!==e.logicalXDPI&&e.deviceXDPI>e.logicalXDPI?e.systemXDPI/e.logicalXDPI:void 0!==window.devicePixelRatio?window.devicePixelRatio:1}function o(e){var t=a(e.x,2),r=t[0],n=t[1],i=a(e.y,2),o=i[0],s=i[1],l=Math.max(n-r,s-o),h=(n+r)/2,u=(s+o)/2,c=function(e){return{x:.5+(e.x-h)/l,y:.5+(e.y-u)/l}};return c.applyTo=function(e){e.x=.5+(e.x-h)/l,e.y=.5+(e.y-u)/l},c.inverse=function(e){return{x:h+l*(e.x-.5),y:u+l*(e.y-.5)}},c.ratio=l,c}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.createElement=n,t.getPixelRatio=i,t.createNormalizationFunction=o},function(e,t){e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNodes&&"boolean"==typeof e.multi}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return function(){function t(r){i(this,t),this.programs=e.map(function(e){return new e(r)})}return a(t,[{key:"allocate",value:function(e){this.programs.forEach(function(t){return t.allocate(e)})}},{key:"process",value:function(){var e=arguments;this.programs.forEach(function(t){return t.process.apply(t,n(e))})}},{key:"computeIndices",value:function(){this.programs.forEach(function(e){"function"==typeof e.computeIndices&&e.computeIndices()})}},{key:"bufferData",value:function(){this.programs.forEach(function(e){return e.bufferData()})}},{key:"render",value:function(){var e=arguments;this.programs.forEach(function(t){t.bind(),t.bufferData(),t.render.apply(t,n(e))})}}]),t}()}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.createCompoundProgram=o;var s=r(20),l=function(){function e(t,r,n){i(this,e),this.vertexShaderSource=r,this.fragmentShaderSource=n,this.load(t)}return a(e,[{key:"load",value:function(e){return this.vertexShader=(0,s.loadVertexShader)(e,this.vertexShaderSource),this.fragmentShader=(0,s.loadFragmentShader)(e,this.fragmentShaderSource),this.program=(0,s.loadProgram)(e,[this.vertexShader,this.fragmentShader]),this.program}}]),e}();t.default=l},function(e,t,r){"use strict";function n(e,t,r){var n=r.labelSize,i=r.labelFont,o=r.labelWeight;e.fillStyle="#000",e.font=o+" "+n+"px "+i,e.fillText(t.label,t.x+t.size+3,t.y+n/3)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLRenderer=t.MouseCaptor=t.QuadTree=t.Camera=t.Renderer=void 0;var i=r(3),o=n(i),a=r(0),s=n(a),l=r(5),h=n(l),u=r(6),c=n(u),d=r(16),f=n(d);t.Renderer=o.default,t.Camera=s.default,t.QuadTree=h.default,t.MouseCaptor=c.default,t.WebGLRenderer=f.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.linear=function(e){return e},t.quadraticIn=function(e){return e*e},t.quadraticOut=function(e){return e*(2-e)},t.quadraticInOut=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},t.cubicIn=function(e){return e*e*e},t.cubicOut=function(e){return--e*e*e+1},t.cubicInOut=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},function(e,t){e.exports=function(e,t){var r=e.length,n=t.length;if(0!==n){e.length+=t.length;for(var i=0;i<n;i++)e[r+i]=t[i]}}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=r(1),s=function(e){function t(e,r){n(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.container=e,o.camera=r,o}return o(t,e),t}(a.EventEmitter);t.default=s},function(e,t,r){"use strict";function n(e){if(void 0!==e.offsetX)return e.offsetX;if(void 0!==e.layerX)return e.layerX;if(void 0!==e.clientX)return e.clientX;throw new Error("sigma/captors/utils.getX: could not extract x from event.")}function i(e){if(void 0!==e.offsetY)return e.offsetY;if(void 0!==e.layerY)return e.layerY;if(void 0!==e.clientY)return e.clientY;throw new Error("sigma/captors/utils.getY: could not extract y from event.")}function o(e){var t=e.target.ownerSVGElement?e.target.ownerSVGElement.width:e.target.width;if("number"==typeof t)return t;if(void 0!==t&&void 0!==t.baseVal)return t.baseVal.value;throw new Error("sigma/captors/utils.getWidth: could not extract width from event.")}function a(e){var t=e.target.ownerSVGElement?e.target.ownerSVGElement.height:e.target.height;if("number"==typeof t)return t;if(void 0!==t&&void 0!==t.baseVal)return t.baseVal.value;throw new Error("sigma/captors/utils.getHeight: could not extract height from event.")}function s(e){var t=-1!==e.target.namespaceURI.indexOf("svg")?1:(0,u.getPixelRatio)();return{x:o(e)/(2*t),y:a(e)/(2*t)}}function l(e){return{x:n(e),y:i(e),clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey}}function h(e){if(void 0!==e.wheelDelta)return e.wheelDelta/360;if(void 0!==e.detail)return e.detail/-9;throw new Error("sigma/captors/utils.getDelta: could not extract delta from event.")}Object.defineProperty(t,"__esModule",{value:!0}),t.getX=n,t.getY=i,t.getWidth=o,t.getHeight=a,t.getCenter=s,t.getMouseCoords=l,t.getWheelDelta=h;var u=r(7)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(17),h=r(8),u=n(h),c=r(3),d=n(c),f=r(0),v=n(f),p=r(6),g=n(p),y=r(5),m=n(y),b=r(18),w=r(19),x=n(w),_=r(24),E=n(_),A=r(10),L=n(A),T=r(27),P=n(T),k=r(4),M=r(7),O=r(2),S=r(29),C=r(30),D=(0,M.getPixelRatio)(),R=(0,M.getPixelRatio)(),N={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,defaultNodeColor:"#999",defaultEdgeColor:"#ccc",labelFont:"Arial",labelSize:14,labelWeight:"normal",nodeReducer:null,edgeReducer:null,zIndex:!1},z=function(e){function t(e,r,n){i(this,t);var a=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(n=n||{},a.settings=(0,k.assign)({},N,n),!(0,u.default)(e))throw new Error("sigma/renderers/webgl: invalid graph instance.");if(!(r instanceof HTMLElement))throw new Error("sigma/renderers/webgl: container should be an html element.");a.graph=e,a.captors={},a.container=r,a.elements={},a.contexts={},a.listeners={},a.quadtree=new m.default,a.nodeDataCache={},a.edgeDataCache={},a.nodeExtent=null,a.edgeExtent=null,a.initializeCache(),a.normalizationFunction=null,a.width=0,a.height=0,a.highlightedNodes=new Set,a.displayedLabels=new Set,a.hoveredNode=null,a.wasRenderedInThisFrame=!1,a.renderFrame=null,a.renderHighlightedNodesFrame=null,a.needToProcess=!1,a.needToSoftProcess=!1,a.createContext("edges"),a.createContext("nodes"),a.createContext("labels",!1),a.createContext("hovers",!1),a.createContext("mouse",!1);var s=a.contexts.nodes;return s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.enable(s.BLEND),s=a.contexts.edges,s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.enable(s.BLEND),a.nodePrograms={def:new x.default(a.contexts.nodes)},a.edgePrograms={def:new E.default(a.contexts.edges)},a.resize(),a.camera=new v.default({width:a.width,height:a.height}),a.bindCameraHandlers(),a.captors={mouse:new g.default(a.elements.mouse,a.camera)},a.bindEventHandlers(),a.bindGraphHandlers(),a.process(),a.render(),a}return a(t,e),s(t,[{key:"createContext",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(0,M.createElement)("canvas",{class:"sigma-"+e,style:{position:"absolute"}});this.elements[e]=r,this.container.appendChild(r);var n={preserveDrawingBuffer:!1,antialias:!1},i=void 0;return t?(i=r.getContext("webgl2",n),i||(i=r.getContext("webgl",n)),i||(i=r.getContext("experimental-webgl",n))):i=r.getContext("2d",n),this.contexts[e]=i,this}},{key:"initializeCache",value:function(){for(var e=this.graph,t=e.nodes(),r=0,n=t.length;r<n;r++)this.nodeDataCache[t[r]]=new b.NodeDisplayData(r,this.settings);for(var i=e.edges(),o=0,a=i.length;o<a;o++)this.edgeDataCache[i[o]]=new b.EdgeDisplayData(o,this.settings)}},{key:"bindCameraHandlers",value:function(){var e=this;return this.listeners.camera=function(){e.scheduleRender()},this.camera.on("updated",this.listeners.camera),this}},{key:"bindEventHandlers",value:function(){var e=this;this.listeners.handleResize=function(){e.needToSoftProcess=!0,e.scheduleRender()},window.addEventListener("resize",this.listeners.handleResize);var t=function(e,t,r,n,i){return e>r-i&&e<r+i&&t>n-i&&t<n+i&&Math.sqrt(Math.pow(e-r,2)+Math.pow(t-n,2))<i},r=function(t,r){var n=e.camera.viewportToGraph(e,t,r);return e.quadtree.point(n.x,1-n.y)};return this.listeners.handleMove=function(n){for(var i=Math.pow(e.camera.getState().ratio,.5),o=r(n.x,n.y),a=1/0,s=null,l=0,h=o.length;l<h;l++){var u=o[l],c=e.nodeDataCache[u],d=e.camera.graphToViewport(e,c.x,c.y),f=c.size/i;if(t(n.x,n.y,d.x,d.y,f)){var v=Math.sqrt(Math.pow(n.x-d.x,2)+Math.pow(n.y-d.y,2));v<a&&(a=v,s=u)}}if(s)return e.hoveredNode=s,e.emit("overNode",{node:s}),e.scheduleHighlightedNodesRender();if(e.hoveredNode){var p=e.nodeDataCache[e.hoveredNode],g=e.camera.graphToViewport(e,p.x,p.y),y=p.size/i;if(!t(n.x,n.y,g.x,g.y,y))return e.hoveredNode=null,e.emit("outNode",{node:e.hoveredNode}),e.scheduleHighlightedNodesRender()}},this.listeners.handleDown=function(n){for(var i=Math.pow(e.camera.getState().ratio,.5),o=r(n.x,n.y),a=0,s=o.length;a<s;a++){var l=o[a],h=e.nodeDataCache[l],u=e.camera.graphToViewport(e,h.x,h.y),c=h.size/i;if(t(n.x,n.y,u.x,u.y,c))return e.emit("downNode",{node:l})}},this.listeners.handleClick=function(n){for(var i=Math.pow(e.camera.getState().ratio,.5),o=r(n.x,n.y),a=0,s=o.length;a<s;a++){var l=o[a],h=e.nodeDataCache[l],u=e.camera.graphToViewport(e,h.x,h.y),c=h.size/i;if(t(n.x,n.y,u.x,u.y,c))return e.emit("clickNode",{node:l})}return e.emit("clickStage")},this.captors.mouse.on("mousemove",this.listeners.handleMove),this.captors.mouse.on("mousedown",this.listeners.handleDown),this.captors.mouse.on("click",this.listeners.handleClick),this}},{key:"bindGraphHandlers",value:function(){var e=this,t=this.graph;return this.listeners.graphUpdate=function(){e.needToProcess=!0,e.scheduleRender()},this.listeners.softGraphUpdate=function(){e.needToSoftProcess=!0,e.scheduleRender()},t.on("nodeAdded",this.listeners.graphUpdate),t.on("nodeDropped",this.listeners.graphUpdate),t.on("nodeAttributesUpdated",this.listeners.softGraphUpdate),t.on("edgeAdded",this.listeners.graphUpdate),t.on("nodeDropped",this.listeners.graphUpdate),t.on("edgeAttributesUpdated",this.listeners.softGraphUpdate),t.on("cleared",this.listeners.graphUpdate),this}},{key:"process",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.graph,r=this.settings;this.quadtree.clear();var n=["x","y"];this.settings.zIndex&&(n.push("z"),this.edgeExtent=(0,l.edgeExtent)(t,["z"])),this.nodeExtent=(0,l.nodeExtent)(t,n),this.normalizationFunction=(0,M.createNormalizationFunction)(this.nodeExtent);var i=this.nodePrograms.def;e||i.allocate(t.order);var o=t.nodes();this.settings.zIndex&&(o=(0,C.zIndexOrdering)(this.edgeExtent.z,function(e){return t.getNodeAttribute(e,"z")},o));for(var a=0,s=o.length;a<s;a++){var h=o[a],u=t.getNodeAttributes(h),c=this.nodeDataCache[h];r.nodeReducer&&(u=r.nodeReducer(h,u)),c.assign(u),this.normalizationFunction.applyTo(c),this.quadtree.add(h,c.x,1-c.y,c.size/this.width),i.process(c,a),c.index=a}i.bufferData();var d=this.edgePrograms.def;e||d.allocate(t.size);var f=t.edges();this.settings.zIndex&&(f=(0,C.zIndexOrdering)(this.edgeExtent.z,function(e){return t.getEdgeAttribute(e,"z")},f));for(var v=0,p=f.length;v<p;v++){var g=f[v],y=t.getEdgeAttributes(g),m=this.edgeDataCache[g];r.edgeReducer&&(y=r.edgeReducer(g,y)),m.assign(y);var b=t.extremities(g),w=this.nodeDataCache[b[0]],x=this.nodeDataCache[b[1]];d.process(w,x,m,v),m.index=v}return e||"function"!=typeof d.computeIndices||d.computeIndices(),d.bufferData(),this}},{key:"processNode",value:function(e){var t=this.nodePrograms.def,r=this.graph.getNodeAttributes(e);return t.process(r,this.nodeDataCache[e].index),this}},{key:"processEdge",value:function(e){var t=this.graph,r=this.edgePrograms.def,n=t.getEdgeAttributes(e),i=t.extremities(e),o=t.getNodeAttributes(i[0]),a=t.getNodeAttributes(i[1]);return r.process(o,a,n,this.edgeDataCache[e].index),this}},{key:"getCamera",value:function(){return this.camera}},{key:"getMouseCaptor",value:function(){return this.captors.mouse}},{key:"resize",value:function(e,t){var r=this.width,n=this.height;if(arguments.length>1?(this.width=e,this.height=t):(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight),0===this.width)throw new Error("sigma/renderers/webgl: container as no width.");if(0===this.height)throw new Error("sigma/renderers/webgl: container as no height.");if(r===this.width&&n===this.height)return this;for(var i in this.elements){var o=this.elements[i];o.style.width=this.width+"px",o.style.height=this.height+"px"}for(var a in this.contexts){var s=this.contexts[a];s.scale?(this.elements[a].setAttribute("width",this.width*D+"px"),this.elements[a].setAttribute("height",this.height*D+"px"),1!==D&&s.scale(D,D)):(this.elements[a].setAttribute("width",this.width*R+"px"),this.elements[a].setAttribute("height",this.height*R+"px")),s.viewport&&s.viewport(0,0,this.width*R,this.height*R)}return this}},{key:"clear",value:function(){return this.contexts.labels.clearRect(0,0,this.width,this.height),this}},{key:"render",value:function(){this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null,this.needToProcess=!1,this.needToSoftProcess=!1);var e=this.camera.isAnimated()||this.captors.mouse.isMoving||this.captors.mouse.hasDragged||this.captors.mouse.wheelLock;this.resize(),this.clear();var t=this.camera.getState(),r=(0,O.matrixFromCamera)(t,{width:this.width,height:this.height}),n=void 0;if(n=this.nodePrograms.def,n.render({matrix:r,width:this.width,height:this.height,ratio:t.ratio,nodesPowRatio:.5,scalingRatio:R}),this.settings.hideEdgesOnMove&&e||(n=this.edgePrograms.def,n.render({matrix:r,width:this.width,height:this.height,ratio:t.ratio,nodesPowRatio:.5,edgesPowRatio:.5,scalingRatio:R})),this.settings.hideLabelsOnMove&&e)return this;var i=void 0;if(t.ratio>=1)i=this.graph.nodes();else{var o=this.camera.viewRectangle(this);i=this.quadtree.rectangle(o.x1,1-o.y1,o.x2,1-o.y2,o.height)}if(!this.settings.renderLabels)return this;for(var a=(0,S.labelsToDisplayFromGrid)({cache:this.nodeDataCache,camera:this.camera,displayedLabels:this.displayedLabels,visibleNodes:i,dimensions:this,graph:this.graph}),s=this.contexts.labels,l=Math.pow(t.ratio,.5),h=0,u=a.length;h<u;h++){var c=this.nodeDataCache[a[h]],d=this.camera.graphToViewport(this,c.x,c.y),f=d.x,v=d.y,p=c.size/l;(0,L.default)(s,{label:c.label,size:p,x:f,y:v},this.settings)}return this.displayedLabels=new Set(a),this.renderHighlightedNodes(),this}},{key:"renderHighlightedNodes",value:function(){var e=this,t=this.camera,r=Math.pow(t.getState().ratio,.5),n=this.contexts.hovers;n.clearRect(0,0,this.width,this.height);var i=function(i){var o=e.nodeDataCache[i],a=t.graphToViewport(e,o.x,o.y),s=a.x,l=a.y,h=o.size/r;(0,P.default)(n,{label:o.label,color:o.color,size:h,x:s,y:l},e.settings)};this.hoveredNode&&i(this.hoveredNode),this.highlightedNodes.forEach(i)}},{key:"scheduleRender",value:function(){var e=this;if(this.renderFrame)return this;this.renderFrame=requestAnimationFrame(function(){(e.needToProcess||e.needToSoftProcess)&&e.process(e.needToSoftProcess),e.renderFrame=null,e.needToProcess=!1,e.needToSoftProcess=!1,e.render()})}},{key:"scheduleHighlightedNodesRender",value:function(){var e=this;if(this.renderHighlightedNodesFrame||this.renderFrame)return this;this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes()})}},{key:"refresh",value:function(){return this.needToSoftProcess=!0,this.scheduleRender(),this}},{key:"highlightNode",value:function(e){return this.highlightedNodes.add(e),this.scheduleHighlightedNodesRender(),this}},{key:"unhighlightNode",value:function(e){return this.highlightedNodes.delete(e),this.scheduleHighlightedNodesRender(),this}},{key:"kill",value:function(){var e=this.graph;this.camera.removeListener("updated",this.listeners.camera),window.removeEventListener("resize",this.listeners.handleResize),this.captors.mouse.kill(),e.removeListener("nodeAdded",this.listeners.graphUpdate),e.removeListener("nodeDropped",this.listeners.graphUpdate),e.removeListener("nodeAttributesUpdated",this.listeners.softGraphUpdate),e.removeListener("edgeAdded",this.listeners.graphUpdate),e.removeListener("nodeDropped",this.listeners.graphUpdate),e.removeListener("edgeAttributesUpdated",this.listeners.softGraphUpdate),e.removeListener("cleared",this.listeners.graphUpdate),this.quadtree=null,this.nodeDataCache=null,this.edgeDataCache=null,this.highlightedNodes=null,this.previousVisibleNodes=null,this.displayedLabels=null;for(var t=this.container;t.firstChild;)t.removeChild(t.firstChild)}}]),t}(d.default);t.default=z},function(e,t,r){function n(e,t){if(!o(e))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,n,i,a,s,l,h,u=[].concat(t),c=e.nodes(),d={};for(s=0;s<u.length;s++)a=u[s],d[a]=[1/0,-1/0];for(l=0,h=c.length;l<h;l++)for(r=c[l],n=e.getNodeAttributes(r),s=0;s<u.length;s++)a=u[s],i=n[a],i<d[a][0]&&(d[a][0]=i),i>d[a][1]&&(d[a][1]=i);return"string"==typeof t?d[t]:d}function i(e,t){if(!o(e))throw new Error("graphology-metrics/extent: the given graph is not a valid graphology instance.");var r,n,i,a,s,l,h,u=[].concat(t),c=e.edges(),d={};for(s=0;s<u.length;s++)a=u[s],d[a]=[1/0,-1/0];for(l=0,h=c.length;l<h;l++)for(r=c[l],n=e.getEdgeAttributes(r),s=0;s<u.length;s++)a=u[s],i=n[a],i<d[a][0]&&(d[a][0]=i),i>d[a][1]&&(d[a][1]=i);return"string"==typeof t?d[t]:d}var o=r(8),a=n;a.nodeExtent=n,a.edgeExtent=i,e.exports=a},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.NodeDisplayData=function(){function e(t,r){n(this,e),this.index=t,this.x=0,this.y=0,this.size=2,this.color=r.defaultNodeColor,this.hidden=!1,this.label=""}return i(e,[{key:"assign",value:function(e){"x"in e&&(this.x=e.x),"y"in e&&(this.y=e.y),"size"in e&&(this.size=e.size),"color"in e&&(this.color=e.color),"hidden"in e&&(this.hidden=e.hidden),"label"in e&&(this.label=e.label)}}]),e}(),t.EdgeDisplayData=function(){function e(t,r){n(this,e),this.index=t,this.size=1,this.color=r.defaultEdgeColor,this.hidden=!1}return i(e,[{key:"assign",value:function(e){"size"in e&&(this.size=e.size),"color"in e&&(this.color=e.color),"hidden"in e&&(this.hidden=e.hidden)}}]),e}()},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(9),h=n(l),u=r(2),c=r(22),d=n(c),f=r(23),v=n(f),p=4,g=function(e){function t(e){i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,d.default,v.default));r.gl=e,r.array=null,r.buffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,r.buffer);var n=r.program;return r.positionLocation=e.getAttribLocation(n,"a_position"),r.sizeLocation=e.getAttribLocation(n,"a_size"),r.colorLocation=e.getAttribLocation(n,"a_color"),r.matrixLocation=e.getUniformLocation(n,"u_matrix"),r.ratioLocation=e.getUniformLocation(n,"u_ratio"),r.scaleLocation=e.getUniformLocation(n,"u_scale"),e.enableVertexAttribArray(r.positionLocation),e.enableVertexAttribArray(r.sizeLocation),e.enableVertexAttribArray(r.colorLocation),e.vertexAttribPointer(r.positionLocation,2,e.FLOAT,!1,p*Float32Array.BYTES_PER_ELEMENT,0),e.vertexAttribPointer(r.sizeLocation,1,e.FLOAT,!1,p*Float32Array.BYTES_PER_ELEMENT,8),e.vertexAttribPointer(r.colorLocation,4,e.UNSIGNED_BYTE,!0,p*Float32Array.BYTES_PER_ELEMENT,12),r}return a(t,e),s(t,[{key:"allocate",value:function(e){this.array=new Float32Array(1*p*e)}},{key:"process",value:function(e,t){var r=(0,u.floatColor)(e.color),n=1*t*p,i=this.array;if(e.hidden)return i[n++]=0,i[n++]=0,i[n++]=0,void(i[n++]=0);i[n++]=e.x,i[n++]=e.y,i[n++]=e.size,i[n]=r}},{key:"bufferData",value:function(){var e=this.gl;e.bufferData(e.ARRAY_BUFFER,this.array,e.DYNAMIC_DRAW)}},{key:"render",value:function(e){var t=this.gl,r=this.program;t.useProgram(r),t.uniform1f(this.ratioLocation,1/Math.pow(e.ratio,e.nodesPowRatio)),t.uniform1f(this.scaleLocation,e.scalingRatio),t.uniformMatrix3fv(this.matrixLocation,!1,e.matrix),t.drawArrays(t.POINTS,0,this.array.length/p)}}]),t}(h.default);t.default=g},function(e,t,r){"use strict";function n(e,t,r){var n="VERTEX"===e?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(n);if(t.shaderSource(i,r),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){var o=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error("sigma/renderers/weblg/shaders/utils.loadShader: error while compiling the shader:\n"+o+"\n"+r)}return i}function i(e,t){var r=e.createProgram(),n=void 0,i=void 0;for(n=0,i=t.length;n<i;n++)e.attachShader(r,t[n]);if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw e.deleteProgram(r),new Error("sigma/renderers/weblg/shaders/utils.loadProgram: error while linking the program.");return r}Object.defineProperty(t,"__esModule",{value:!0}),t.loadProgram=i;var o=n.bind(null,"VERTEX"),a=n.bind(null,"FRAGMENT");t.loadVertexShader=o,t.loadFragmentShader=a},function(e,t,r){"use strict";function n(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function i(e,t,r){return e[0]=t,e[4]=arguments.length>2?r:t,e}function o(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[3]=-r,e[4]=n,e}function a(e,t,r){return e[6]=t,e[7]=r,e}function s(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=t[0],d=t[1],f=t[2],v=t[3],p=t[4],g=t[5],y=t[6],m=t[7],b=t[8];return e[0]=c*r+d*o+f*l,e[1]=c*n+d*a+f*h,e[2]=c*i+d*s+f*u,e[3]=v*r+p*o+g*l,e[4]=v*n+p*a+g*h,e[5]=v*i+p*s+g*u,e[6]=y*r+m*o+b*l,e[7]=y*n+m*a+b*h,e[8]=y*i+m*s+b*u,e}Object.defineProperty(t,"__esModule",{value:!0}),t.identity=n,t.scale=i,t.rotate=o,t.translate=a,t.multiply=s},function(e,t){e.exports="attribute vec2 a_position;\nattribute float a_size;\nattribute vec4 a_color;\n\nuniform float u_ratio;\nuniform float u_scale;\nuniform mat3 u_matrix;\n\nvarying vec4 v_color;\nvarying float v_border;\n\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n gl_Position = vec4(\n (u_matrix * vec3(a_position, 1)).xy,\n 0,\n 1\n );\n\n // Multiply the point size twice:\n // - x SCALING_RATIO to correct the canvas scaling\n // - x 2 to correct the formulae\n gl_PointSize = a_size * u_ratio * u_scale * 2.0;\n\n v_border = (1.0 / u_ratio) * (0.5 / a_size);\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},function(e,t){e.exports="precision mediump float;\n\nvarying vec4 v_color;\nvarying float v_border;\n\nconst float radius = 0.5;\n\nvoid main(void) {\n vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0);\n vec2 m = gl_PointCoord - vec2(0.5, 0.5);\n float dist = radius - length(m);\n\n float t = 0.0;\n if (dist > v_border)\n t = 1.0;\n else if (dist > 0.0)\n t = dist / v_border;\n\n // gl_FragColor = mix(color0, v_color, t);\n gl_FragColor = mix(color0, v_color, t);\n}\n"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),l=r(9),h=n(l),u=r(2),c=r(25),d=n(c),f=r(26),v=n(f),p=function(e){function t(e){i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,d.default,v.default));return r.gl=e,r.array=null,r.indicesArray=null,r.buffer=e.createBuffer(),r.indicesBuffer=e.createBuffer(),r.positionLocation=e.getAttribLocation(r.program,"a_position"),r.normalLocation=e.getAttribLocation(r.program,"a_normal"),r.thicknessLocation=e.getAttribLocation(r.program,"a_thickness"),r.colorLocation=e.getAttribLocation(r.program,"a_color"),r.resolutionLocation=e.getUniformLocation(r.program,"u_resolution"),r.ratioLocation=e.getUniformLocation(r.program,"u_ratio"),r.matrixLocation=e.getUniformLocation(r.program,"u_matrix"),r.scaleLocation=e.getUniformLocation(r.program,"u_scale"),r.bind(),r.canUse32BitsIndices=(0,u.canUse32BitsIndices)(e),r.IndicesArray=r.canUse32BitsIndices?Uint32Array:Uint16Array,r.indicesType=r.canUse32BitsIndices?e.UNSIGNED_INT:e.UNSIGNED_SHORT,r}return a(t,e),s(t,[{key:"bind",value:function(){var e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indicesBuffer),e.enableVertexAttribArray(this.positionLocation),e.enableVertexAttribArray(this.normalLocation),e.enableVertexAttribArray(this.thicknessLocation),e.enableVertexAttribArray(this.colorLocation),e.vertexAttribPointer(this.positionLocation,2,e.FLOAT,!1,6*Float32Array.BYTES_PER_ELEMENT,0),e.vertexAttribPointer(this.normalLocation,2,e.FLOAT,!1,6*Float32Array.BYTES_PER_ELEMENT,8),e.vertexAttribPointer(this.thicknessLocation,1,e.FLOAT,!1,6*Float32Array.BYTES_PER_ELEMENT,16),e.vertexAttribPointer(this.colorLocation,4,e.UNSIGNED_BYTE,!0,6*Float32Array.BYTES_PER_ELEMENT,20)}},{key:"allocate",value:function(e){this.array=new Float32Array(24*e)}},{key:"process",value:function(e,t,r,n){if(e.hidden||t.hidden||r.hidden)for(var i=24*n,o=i+24;i<o;i++)this.array[i]=0;else{var a=r.size||1,s=e.x,l=e.y,h=t.x,c=t.y,d=(0,u.floatColor)(r.color),f=h-s,v=c-l,p=f*f+v*v,g=0,y=0;p&&(p=1/Math.sqrt(p),g=-v*p,y=f*p);var m=24*n,b=this.array;b[m++]=s,b[m++]=l,b[m++]=g,b[m++]=y,b[m++]=a,b[m++]=d,b[m++]=s,b[m++]=l,b[m++]=-g,b[m++]=-y,b[m++]=a,b[m++]=d,b[m++]=h,b[m++]=c,b[m++]=g,b[m++]=y,b[m++]=a,b[m++]=d,b[m++]=h,b[m++]=c,b[m++]=-g,b[m++]=-y,b[m++]=a,b[m]=d}}},{key:"computeIndices",value:function(){for(var e=this.array.length/6,t=e+e/2,r=new this.IndicesArray(t),n=0,i=0;n<e;n+=4)r[i++]=n,r[i++]=n+1,r[i++]=n+2,r[i++]=n+2,r[i++]=n+1,r[i++]=n+3;this.indicesArray=r}},{key:"bufferData",value:function(){var e=this.gl;e.bufferData(e.ARRAY_BUFFER,this.array,e.DYNAMIC_DRAW),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indicesArray,e.STATIC_DRAW)}},{key:"render",value:function(e){var t=this.gl,r=this.program;t.useProgram(r),t.uniform2f(this.resolutionLocation,e.width,e.height),t.uniform1f(this.ratioLocation,e.ratio),t.uniformMatrix3fv(this.matrixLocation,!1,e.matrix),t.uniform1f(this.scaleLocation,e.scalingRatio),t.drawElements(t.TRIANGLES,this.indicesArray.length,this.indicesType,0)}}]),t}(h.default);t.default=p},function(e,t){e.exports="attribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_thickness;\nattribute vec4 a_color;\n\nuniform vec2 u_resolution;\nuniform float u_ratio;\nuniform mat3 u_matrix;\nuniform float u_scale;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float min_thickness = 1.8;\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n\n // Computing thickness in pixels\n float pow_ratio = 1.0 / pow(u_ratio, 0.5);\n float thickness = a_thickness * pow_ratio / u_scale;\n\n // Min thickness for AA\n thickness = max(min_thickness, thickness);\n\n // Computing delta relative to viewport\n vec2 delta = (a_normal * thickness) / u_resolution;\n\n vec2 position = (u_matrix * vec3(a_position, 1)).xy;\n position += delta;\n\n // Applying\n gl_Position = vec4(position, 0, 1);\n\n v_normal = a_normal;\n v_thickness = thickness;\n\n // Extract the color:\n v_color = a_color;\n v_color.a *= bias;\n}\n"},function(e,t){e.exports="precision mediump float;\n\nvarying vec4 v_color;\nvarying vec2 v_normal;\nvarying float v_thickness;\n\nconst float feather = 2.6;\nconst vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main(void) {\n float dist = length(v_normal) * v_thickness;\n\n float t = smoothstep(\n v_thickness - feather,\n v_thickness,\n dist\n );\n\n gl_FragColor = mix(v_color, color0, t);\n}\n"},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){var n=r.labelSize,i=r.labelFont,o=r.labelWeight;e.font=o+" "+n+"px "+i,e.beginPath(),e.fillStyle="#fff",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var s=e.measureText(t.label).width,h=Math.round(t.x-n/2-2),u=Math.round(t.y-n/2-2),c=Math.round(s+n/2+t.size+9),d=Math.round(n+4),f=Math.round(n/2+2);e.moveTo(h,u+f),e.moveTo(h,u+f),e.arcTo(h,u,h+f,u,f),e.lineTo(h+c,u),e.lineTo(h+c,u+d),e.lineTo(h+f,u+d),e.arcTo(h,u+d,h,u+d-f,f),e.lineTo(h,u+f),e.closePath(),e.fill(),e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,(0,a.default)(e,t),(0,l.default)(e,t,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var o=r(28),a=n(o),s=r(10),l=n(s)},function(e,t,r){"use strict";function n(e,t){e.fillStyle=t.color,e.beginPath(),e.arc(t.x,t.y,t.size,0,i,!0),e.closePath(),e.fill()}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var i=2*Math.PI},function(e,t,r){"use strict";function n(e,t,r,n,i,o,a,s){return e<i+a&&e+r>i&&t<o+s&&t+n>o}var i=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(i),a={width:250,height:175},s={width:400,height:300};t.labelsToDisplayFromGrid=function(e){var t=e.cache,r=e.camera,i=e.displayedLabels,l=e.visibleNodes,h=e.dimensions,u=e.graph,c=r.getState(),d=r.getPreviousState(),f=new o.default;f.setState(d);var v=c.x===d.x&&c.y===d.y&&c.ratio===d.ratio,p=c.ratio<d.ratio,g=c.x!==d.x||c.y!==d.y,y=c.ratio>d.ratio,m=!p&&!y&&c.ratio>=1,b=g&&i.size&&!p&&!y;if(y&&Math.trunc(100*c.ratio)%5!=0)return Array.from(i);if((m||v)&&0!==i.size)return Array.from(i);if(p&&c.ratio>=1)return Array.from(i);for(var w=c.ratio>=1.3?s:a,x=h.width%w.width,_=w.width+x/Math.floor(h.width/w.width),E=h.height%w.height,A=w.height+E/Math.floor(h.height/w.height),L=h.width+_,T=h.height+A,P=-_,k=-A,M=h.width+_/2,O=h.height+A/2,S=-_/2,C=-A/2,D=[],R={},N=-1/0,z=null,F=0,j=l.length;F<j;F++){var I=l[F],U=t[I],G=r.graphToViewport(h,U.x,U.y);if(!(G.x<P||G.x>L||G.y<k||G.y>T)){if(U.size>N&&(N=U.size,z=I),b){var Y=f.graphToViewport(h,U.x,U.y);if(Y.x>=S&&Y.x<=M&&Y.y>=C&&Y.y<=O&&!i.has(I))continue}var B=Math.floor(G.x/_),V=Math.floor(G.y/A),X=B+"§"+V;if(void 0===R[X])R[X]=I;else{var H=R[X],W=t[H];if(i.size>0){var q=i.has(I),K=i.has(H);if(!q&&K)continue;if(q&&!K){R[X]=I;continue}if((b||p)&&q&&K){D.push(I);continue}}var Q=!1;if(U.size>W.size)Q=!0;else if(U.size===W.size){var Z=u.degree(I),$=u.degree(H);Z>$?Q=!0:Z===$&&I>H&&(Q=!0)}Q&&(R[X]=I)}}}var J=D.some(function(e){return e===z});for(var ee in R){var te=R[ee];te===z&&(J=!0),D.push(te)}!J&&z&&D.push(z);for(var re=new Set,ne=0,ie=D.length;ne<ie;ne++){var oe=D[ne],ae=t[oe],se=r.graphToViewport(h,ae.x,ae.y);if(!re.has(oe))for(var le=ne+1;le<ie;le++){var he=D[le],ue=t[he],ce=r.graphToViewport(h,ue.x,ue.y),de=n(se.x,se.y,8*ae.label.length,14,ce.x,ce.y,8*ue.label.length,14);de&&(ae.size<ue.size?re.add(oe):re.add(he))}}return D.filter(function(e){return!re.has(e)})}},function(e,t,r){"use strict";t.zIndexOrdering=function(e,t,r){return r.sort(function(e,r){var n=t(e)||0,i=t(r)||0;return n<i?-1:n>i?1:0})}}])}); |
'use strict'; | ||
/** | ||
* Sigma.js Labels Heuristics | ||
* =========================== | ||
* | ||
* Miscelleneous heuristics related to label display. | ||
*/ | ||
var _camera = require('../camera'); | ||
var _camera2 = _interopRequireDefault(_camera); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -16,8 +15,14 @@ * Constants. | ||
var DEFAULT_CELL = { | ||
width: 200, | ||
height: 150 | ||
width: 250, | ||
height: 175 | ||
}; | ||
// Dimensions of an unzoomed cell. This one is usually smaller than the normal | ||
// Dimensions of an unzoomed cell. This one is usually larger than the normal | ||
// one to account for the fact that labels will more likely collide. | ||
/** | ||
* Sigma.js Labels Heuristics | ||
* =========================== | ||
* | ||
* Miscelleneous heuristics related to label display. | ||
*/ | ||
var DEFAULT_UNZOOMED_CELL = { | ||
@@ -28,17 +33,17 @@ width: 400, | ||
// TODO: use degree as secondary tie-breaker | ||
/** | ||
* Helpers. | ||
*/ | ||
function collision(x1, y1, w1, h1, x2, y2, w2, h2) { | ||
return x1 < x2 + w2 && x1 + w1 > x2 && y1 < y2 + h2 && y1 + h1 > y2; | ||
} | ||
// TODO: cache camera position of selected nodes to avoid costly computations | ||
// in anti-collision step | ||
// TODO: minSize to be displayed | ||
// TOOD: document a little bit more so future people can understand this mess | ||
/** | ||
* Label grid heuristic selecting labels to display according to the following | ||
* parameters: | ||
* 1) Only one label per grid cell. | ||
* 2) Greater labels win. | ||
* 3) Already displayed label should stay displayed. | ||
* Label grid heuristic selecting labels to display. | ||
* | ||
* Note: It is possible to apply a size threshold to the labels (but should | ||
* really be done at quad level for performance). | ||
* | ||
* Note: It might be possible to not use last displayed labels by measurements | ||
* and a margin. | ||
* | ||
* @param {object} params - Parameters: | ||
@@ -48,4 +53,4 @@ * @param {object} cache - Cache storing nodes' data. | ||
* @param {Set} displayedLabels - Currently displayed labels. | ||
* @param {Set} previousVisibleNodes - Nodes visible last render. | ||
* @param {Array} visibleNodes - Nodes visible for this render. | ||
* @param {Graph} graph - The rendered graph. | ||
* @return {Array} - The selected labels. | ||
@@ -57,5 +62,5 @@ */ | ||
displayedLabels = params.displayedLabels, | ||
previousVisibleNodes = params.previousVisibleNodes, | ||
visibleNodes = params.visibleNodes, | ||
dimensions = params.dimensions; | ||
dimensions = params.dimensions, | ||
graph = params.graph; | ||
@@ -65,33 +70,52 @@ | ||
previousCameraState = camera.getPreviousState(); | ||
var previousCamera = new _camera2.default(); | ||
previousCamera.setState(previousCameraState); | ||
// Camera hasn't moved? | ||
var still = cameraState.x === previousCameraState.x && cameraState.y === previousCameraState.y && cameraState.ratio === previousCameraState.ratio; | ||
// State | ||
// TODO: the panning is false because of not working y condition, though | ||
// if I fix it, the whole heuristic fails. I am saddness... :( | ||
var zooming = cameraState.ratio < previousCameraState.ratio, | ||
panning = cameraState.x !== previousCameraState.x || cameraState.y !== previousCameraState.x, | ||
panning = cameraState.x !== previousCameraState.x || cameraState.y !== previousCameraState.y, | ||
unzooming = cameraState.ratio > previousCameraState.ratio, | ||
unzoomedPanning = !zooming && !unzooming && cameraState.ratio >= 1; | ||
unzoomedPanning = !zooming && !unzooming && cameraState.ratio >= 1, | ||
zoomedPanning = panning && displayedLabels.size && !zooming && !unzooming; | ||
// Trick to discretize unzooming | ||
if (unzooming && Math.trunc(cameraState.ratio * 10) % 3 !== 0) return Array.from(displayedLabels); | ||
if (unzooming && Math.trunc(cameraState.ratio * 100) % 5 !== 0) return Array.from(displayedLabels); | ||
// If panning while unzoomed, we shouldn't change label selection | ||
if (unzoomedPanning && displayedLabels.size !== 0) return Array.from(displayedLabels); | ||
if ((unzoomedPanning || still) && displayedLabels.size !== 0) return Array.from(displayedLabels); | ||
// Selecting cell | ||
var baseCell = cameraState.ratio >= 1.3 ? DEFAULT_UNZOOMED_CELL : DEFAULT_CELL; | ||
// When unzoomed & zooming | ||
if (zooming && cameraState.ratio >= 1) return Array.from(displayedLabels); | ||
// Adapting cell dimensions | ||
var cellWidthRemainder = dimensions.width % baseCell.width; | ||
var cellWidth = baseCell.width + cellWidthRemainder / Math.floor(dimensions.width / baseCell.width); | ||
var cell = cameraState.ratio >= 1.3 ? DEFAULT_UNZOOMED_CELL : DEFAULT_CELL; | ||
var cellHeightRemainder = dimensions.height % baseCell.height; | ||
var cellHeight = baseCell.height + cellHeightRemainder / Math.floor(dimensions.height / baseCell.height); | ||
var cwr = dimensions.width % cell.width; | ||
var cellWidth = cell.width + cwr / Math.floor(dimensions.width / cell.width); | ||
// Building the grid | ||
var grid = {}; | ||
var chr = dimensions.height % cell.height; | ||
var cellHeight = cell.height + chr / Math.floor(dimensions.height / cell.height); | ||
var worthyBuckets = new Set(); | ||
var adjustedWidth = dimensions.width + cellWidth, | ||
adjustedHeight = dimensions.height + cellHeight, | ||
adjustedX = -cellWidth, | ||
adjustedY = -cellHeight; | ||
var panningWidth = dimensions.width + cellWidth / 2, | ||
panningHeight = dimensions.height + cellHeight / 2, | ||
panningX = -(cellWidth / 2), | ||
panningY = -(cellHeight / 2); | ||
// console.log(cellWidth, cellHeight, dimensions.width / cellWidth, dimensions.height / cellHeight); | ||
var worthyLabels = []; | ||
var grid = {}; | ||
// Selecting worthy labels | ||
var maxSize = -Infinity, | ||
biggestNode = null; | ||
for (var i = 0, l = visibleNodes.length; i < l; i++) { | ||
@@ -101,31 +125,36 @@ var node = visibleNodes[i], | ||
// When panning, we should not consider nodes that were previously shown | ||
if (panning && !zooming && !unzooming) { | ||
if (!displayedLabels.has(node) && previousVisibleNodes.has(node)) continue; | ||
} | ||
// Finding our node's cell in the grid | ||
// TODO: pass dimensions to the function | ||
var pos = camera.graphToViewport(dimensions, nodeData.x, nodeData.y); | ||
var xKey = Math.floor(pos.x / cellWidth), | ||
yKey = Math.floor(pos.y / cellHeight); | ||
// Node is not actually visible on screen | ||
// NOTE: can optimize margin on the right side (only if we know where the labels go) | ||
if (pos.x < adjustedX || pos.x > adjustedWidth || pos.y < adjustedY || pos.y > adjustedHeight) continue; | ||
// NOTE: there seems to be overflowing keys but this is actually a good | ||
// thing since it means we grasp margins. | ||
var key = xKey + ';' + yKey; | ||
// Keeping track of the maximum node size for certain cases | ||
if (nodeData.size > maxSize) { | ||
maxSize = nodeData.size; | ||
biggestNode = node; | ||
} | ||
// When zooming or panning, we aim at keeping the already displayed labels | ||
if ((zooming || panning && !unzooming) && displayedLabels.has(node)) { | ||
worthyBuckets.add(key); | ||
worthyLabels.push(node); | ||
continue; | ||
// If panning when zoomed, we consider only displayed labels and newly | ||
// visible nodes | ||
if (zoomedPanning) { | ||
var ppos = previousCamera.graphToViewport(dimensions, nodeData.x, nodeData.y); | ||
// Was node visible earlier? | ||
if (ppos.x >= panningX && ppos.x <= panningWidth && ppos.y >= panningY && ppos.y <= panningHeight) { | ||
// Was the label displayed? | ||
if (!displayedLabels.has(node)) continue; | ||
} | ||
} | ||
if (worthyBuckets.has(key)) continue; | ||
var xKey = Math.floor(pos.x / cellWidth), | ||
yKey = Math.floor(pos.y / cellHeight); | ||
// Label resolution | ||
var key = xKey + '\xA7' + yKey; | ||
if (typeof grid[key] === 'undefined') { | ||
// The cell is empty | ||
// This cell is not yet occupied | ||
grid[key] = node; | ||
@@ -138,7 +167,42 @@ } else { | ||
// In case of size equality, we use the node's key so that the | ||
// We prefer already displayed labels | ||
if (displayedLabels.size > 0) { | ||
var n1 = displayedLabels.has(node), | ||
n2 = displayedLabels.has(currentNode); | ||
if (!n1 && n2) { | ||
continue; | ||
} | ||
if (n1 && !n2) { | ||
grid[key] = node; | ||
continue; | ||
} | ||
if ((zoomedPanning || zooming) && n1 && n2) { | ||
worthyLabels.push(node); | ||
continue; | ||
} | ||
} | ||
// In case of size & degree equality, we use the node's key so that the | ||
// process remains deterministic | ||
if (nodeData.size > currentNodeData.size || nodeData.size === currentNodeData.size && node > currentNode) { | ||
grid[key] = node; | ||
var won = false; | ||
if (nodeData.size > currentNodeData.size) { | ||
won = true; | ||
} else if (nodeData.size === currentNodeData.size) { | ||
var nodeDegree = graph.degree(node), | ||
currentNodeDegree = graph.degree(currentNode); | ||
if (nodeDegree > currentNodeDegree) { | ||
won = true; | ||
} else if (nodeDegree === currentNodeDegree) { | ||
if (node > currentNode) won = true; | ||
} | ||
} | ||
if (won) grid[key] = node; | ||
} | ||
@@ -148,5 +212,48 @@ } | ||
// Compiling the labels | ||
var biggestNodeShown = worthyLabels.some(function (node) { | ||
return node === biggestNode; | ||
}); | ||
for (var _key in grid) { | ||
worthyLabels.push(grid[_key]); | ||
}return worthyLabels; | ||
var _node = grid[_key]; | ||
if (_node === biggestNode) biggestNodeShown = true; | ||
worthyLabels.push(_node); | ||
} | ||
// Always keeping biggest node shown on screen | ||
if (!biggestNodeShown && biggestNode) worthyLabels.push(biggestNode); | ||
// Basic anti-collision | ||
var collisions = new Set(); | ||
for (var _i = 0, _l = worthyLabels.length; _i < _l; _i++) { | ||
var _n = worthyLabels[_i], | ||
d1 = cache[_n], | ||
p1 = camera.graphToViewport(dimensions, d1.x, d1.y); | ||
if (collisions.has(_n)) continue; | ||
for (var j = _i + 1; j < _l; j++) { | ||
var _n2 = worthyLabels[j], | ||
d2 = cache[_n2], | ||
p2 = camera.graphToViewport(dimensions, d2.x, d2.y); | ||
var c = collision(p1.x, p1.y, d1.label.length * 8, 14, p2.x, p2.y, d2.label.length * 8, 14); | ||
if (c) { | ||
// NOTE: add degree as tie-breaker here if required in the future | ||
if (d1.size < d2.size) collisions.add(_n);else collisions.add(_n2); | ||
} | ||
} | ||
} | ||
// console.log(collisions) | ||
return worthyLabels.filter(function (l) { | ||
return !collisions.has(l); | ||
}); | ||
}; |
{ | ||
"name": "sigma", | ||
"version": "2.0.0-alpha16", | ||
"version": "2.0.0-alpha17", | ||
"description": "A JavaScript library dedicated to graph drawing.", | ||
"homepage": "http://sigmajs.org", | ||
"bugs": "http://github.com/jacomyal/sigma.js/issues", | ||
"main": "sigma.js", | ||
"main": "endpoint.js", | ||
"scripts": { | ||
@@ -36,2 +36,8 @@ "build": "webpack --colors --progress && webpack --colors --progress -p", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@yomguithereal/helpers": "^1.0.0", | ||
"events": "^2.1.0", | ||
"graphology-metrics": "1.6.0", | ||
"graphology-utils": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
@@ -46,9 +52,9 @@ "@yomguithereal/eslint-config": "^4.0.0", | ||
"chroma-js": "^1.3.6", | ||
"d3-scale": "^2.1.0", | ||
"d3-scale": "^2.1.2", | ||
"eslint": "^4.19.1", | ||
"faker": "^4.1.0", | ||
"glob": "^7.1.2", | ||
"glob": "^7.1.3", | ||
"graphology": "^0.11.4", | ||
"graphology-generators": "^0.9.0", | ||
"graphology-gexf": "^0.4.0", | ||
"graphology-gexf": "^0.5.0", | ||
"graphology-layout": "0.1.0", | ||
@@ -84,9 +90,3 @@ "graphology-layout-forceatlas2": "^0.1.1", | ||
"extends": "@yomguithereal/eslint-config/es7" | ||
}, | ||
"dependencies": { | ||
"@yomguithereal/helpers": "^1.0.0", | ||
"events": "^2.0.0", | ||
"graphology-metrics": "1.6.0", | ||
"graphology-utils": "^1.3.0" | ||
} | ||
} |
@@ -42,2 +42,4 @@ 'use strict'; | ||
// NOTE: probably can do faster using spatial hashing | ||
/** | ||
@@ -44,0 +46,0 @@ * Constants. |
@@ -156,3 +156,2 @@ 'use strict'; | ||
_this.highlightedNodes = new Set(); | ||
_this.previousVisibleNodes = new Set(); | ||
_this.displayedLabels = new Set(); | ||
@@ -261,3 +260,3 @@ _this.hoveredNode = null; | ||
// First we try webgl2 for an easy performance boost | ||
context = element.getContext('webgl', contextOptions); | ||
context = element.getContext('webgl2', contextOptions); | ||
@@ -849,5 +848,5 @@ // Else we fall back to webgl | ||
displayedLabels: this.displayedLabels, | ||
previousVisibleNodes: this.previousVisibleNodes, | ||
visibleNodes: visibleNodes, | ||
dimensions: this | ||
dimensions: this, | ||
graph: this.graph | ||
}); | ||
@@ -886,3 +885,2 @@ | ||
// Caching visible nodes and displayed labels | ||
this.previousVisibleNodes = new Set(visibleNodes); | ||
this.displayedLabels = new Set(labelsToDisplay); | ||
@@ -889,0 +887,0 @@ |
@@ -82,7 +82,3 @@ 'use strict'; | ||
// NOTE: when using webgl2, the extension is enabled by default | ||
var webgl2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; | ||
var extension = webgl2 || gl.getExtension('OES_element_index_uint'); | ||
_this.canUse32BitsIndices = !!extension; | ||
_this.canUse32BitsIndices = (0, _utils.canUse32BitsIndices)(gl); | ||
_this.IndicesArray = _this.canUse32BitsIndices ? Uint32Array : Uint16Array; | ||
@@ -89,0 +85,0 @@ _this.indicesType = _this.canUse32BitsIndices ? gl.UNSIGNED_INT : gl.UNSIGNED_SHORT; |
@@ -88,7 +88,3 @@ 'use strict'; | ||
// NOTE: when using webgl2, the extension is enabled by default | ||
var webgl2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; | ||
var extension = webgl2 || gl.getExtension('OES_element_index_uint'); | ||
_this.canUse32BitsIndices = !!extension; | ||
_this.canUse32BitsIndices = (0, _utils.canUse32BitsIndices)(gl); | ||
_this.IndicesArray = _this.canUse32BitsIndices ? Uint32Array : Uint16Array; | ||
@@ -95,0 +91,0 @@ _this.indicesType = _this.canUse32BitsIndices ? gl.UNSIGNED_INT : gl.UNSIGNED_SHORT; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
exports.extractPixel = extractPixel; | ||
exports.canUse32BitsIndices = canUse32BitsIndices; | ||
@@ -119,2 +120,11 @@ var _matrices = require('./matrices'); | ||
return data; | ||
} | ||
/** | ||
* Function used to know whether given webgl context can use 32 bits indices. | ||
*/ | ||
function canUse32BitsIndices(gl) { | ||
var webgl2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext; | ||
return webgl2 || !!gl.getExtension('OES_element_index_uint'); | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1341343
24459
Updatedevents@^2.1.0