diff --git a/dist/complexviewer.js b/dist/complexviewer.js index 879bfda..49060ab 100644 --- a/dist/complexviewer.js +++ b/dist/complexviewer.js @@ -1,3 +1,3 @@ -!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.complexviewer=n():t.complexviewer=n()}(window,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=10)}([function(t,n,e){var r,i;!function(){var o={version:"3.5.17"},a=[].slice,s=function(t){return a.call(t)},u=this.document;function c(t){return t&&(t.ownerDocument||t.document||t).documentElement}function l(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(u)try{s(u.documentElement.childNodes)[0].nodeType}catch(t){s=function(t){for(var n=t.length,e=new Array(n);n--;)e[n]=t[n];return e}}if(Date.now||(Date.now=function(){return+new Date}),u)try{u.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var h=this.Element.prototype,f=h.setAttribute,p=h.setAttributeNS,y=this.CSSStyleDeclaration.prototype,d=y.setProperty;h.setAttribute=function(t,n){f.call(this,t,n+"")},h.setAttributeNS=function(t,n,e){p.call(this,t,n,e+"")},y.setProperty=function(t,n,e){d.call(this,t,n+"",e)}}function g(t,n){return tn?1:t>=n?0:NaN}function v(t){return null===t?NaN:+t}function x(t){return!isNaN(t)}function m(t){return{left:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);r>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);r>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}o.ascending=g,o.descending=function(t,n){return nt?1:n>=t?0:NaN},o.min=function(t,n){var e,r,i=-1,o=t.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ir&&(e=r)}else{for(;++i=r){e=r;break}for(;++ir&&(e=r)}return e},o.max=function(t,n){var e,r,i=-1,o=t.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ie&&(e=r)}else{for(;++i=r){e=r;break}for(;++ie&&(e=r)}return e},o.extent=function(t,n){var e,r,i,o=-1,a=t.length;if(1===arguments.length){for(;++o=r){e=i=r;break}for(;++or&&(e=r),i=r){e=i=r;break}for(;++or&&(e=r),i1)return a/(u-1)},o.deviation=function(){var t=o.variance.apply(this,arguments);return t?Math.sqrt(t):t};var b=m(g);function w(t){return t.length}o.bisectLeft=b.left,o.bisect=o.bisectRight=b.right,o.bisector=function(t){return m(1===t.length?function(n,e){return g(t(n),e)}:t)},o.shuffle=function(t,n,e){(o=arguments.length)<3&&(e=t.length,o<2&&(n=0));for(var r,i,o=e-n;o;)i=Math.random()*o--|0,r=t[o+n],t[o+n]=t[i+n],t[i+n]=r;return t},o.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},o.pairs=function(t){for(var n=0,e=t.length-1,r=t[0],i=new Array(e<0?0:e);n=0;)for(n=(r=t[i]).length;--n>=0;)e[--a]=r[n];return e};var _=Math.abs;function S(t){for(var n=1;t*n%1;)n*=10;return n}function M(t,n){for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}function k(){this._=Object.create(null)}o.range=function(t,n,e){if(arguments.length<3&&(e=1,arguments.length<2&&(n=t,t=0)),(n-t)/e==1/0)throw new Error("infinite range");var r,i=[],o=S(_(e)),a=-1;if(t*=o,n*=o,(e*=o)<0)for(;(r=t+e*++a)>n;)i.push(r/o);else for(;(r=t+e*++a)=r.length)return n?n.call(e,o):t?o.sort(t):o;for(var u,c,l,h,f=-1,p=o.length,y=r[s++],d=new k;++f=r.length)return n;var o=[],a=i[e++];return n.forEach((function(n,r){o.push({key:n,values:t(r,e)})})),a?o.sort((function(t,n){return a(t.key,n.key)})):o}(a(o.map,t,0),0)},e.key=function(t){return r.push(t),e},e.sortKeys=function(t){return i[r.length-1]=t,e},e.sortValues=function(n){return t=n,e},e.rollup=function(t){return n=t,e},e},o.set=function(t){var n=new I;if(t)for(var e=0,r=t.length;e=0&&(r=t.slice(e+1),t=t.slice(0,e)),t)return arguments.length<2?this[t].on(r):this[t].on(r,n);if(2===arguments.length){if(null==n)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},o.event=null,o.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,U={}.__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};function X(t){return U(t,W),t}var Z=function(t,n){return n.querySelector(t)},Y=function(t,n){return n.querySelectorAll(t)},K=function(t,n){var e=t.matches||t[O(t,"matchesSelector")];return(K=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(Z=function(t,n){return Sizzle(t,n)[0]||null},Y=Sizzle,K=Sizzle.matchesSelector),o.selection=function(){return o.select(u.documentElement)};var W=o.selection.prototype=[];function $(t){return"function"==typeof t?t:function(){return Z(t,this)}}function J(t){return"function"==typeof t?t:function(){return Y(t,this)}}W.select=function(t){var n,e,r,i,o=[];t=$(t);for(var a=-1,s=this.length;++a=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),tt.hasOwnProperty(e)?{space:tt[e],local:t}:t}},W.attr=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node();return(t=o.ns.qualify(t)).local?e.getAttributeNS(t.space,t.local):e.getAttribute(t)}for(n in t)this.each(nt(n,t[n]));return this}return this.each(nt(t,n))},W.classed=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node(),r=(t=it(t)).length,i=-1;if(n=e.classList){for(;++i=0;)(e=r[i])&&(o&&o!==e.nextSibling&&o.parentNode.insertBefore(e,o),o=e);return this},W.sort=function(t){t=pt.apply(this,arguments);for(var n=-1,e=this.length;++n=n&&(n=i+1);!(a=s[n])&&++n0&&(t=t.slice(0,i));var u=mt.get(t);function c(){var n=this[r];n&&(this.removeEventListener(t,n,n.$),delete this[r])}return u&&(t=u,a=wt),i?n?function(){var i=a(n,s(arguments));c.call(this),this.addEventListener(t,this[r]=i,i.$=e),i._=n}:c:n?R:function(){var n,e=new RegExp("^__on([^.]+)"+o.requote(t)+"$");for(var r in this)if(n=r.match(e)){var i=this[r];this.removeEventListener(n[1],i,i.$),delete this[r]}}}o.selection.enter=dt,o.selection.enter.prototype=gt,gt.append=W.append,gt.empty=W.empty,gt.node=W.node,gt.call=W.call,gt.size=W.size,gt.select=function(t){for(var n,e,r,i,o,a=[],s=-1,u=this.length;++s0?1:t<0?-1:0}function qt(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function Rt(t){return t>1?0:t<-1?Ct:Math.acos(t)}function jt(t){return t>1?It:t<-1?-It:Math.asin(t)}function Gt(t){return((t=Math.exp(t))+1/t)/2}function Vt(t){return(t=Math.sin(t/2))*t}var Bt=Math.SQRT2;o.interpolateZoom=function(t,n){var e,r,i=t[0],o=t[1],a=t[2],s=n[0],u=n[1],c=n[2],l=s-i,h=u-o,f=l*l+h*h;if(f0&&(t=t.transition().duration(d)),t.call(_.event)}function A(){s&&s.domain(a.range().map((function(t){return(t-f.x)/f.k})).map(a.invert)),h&&h.domain(c.range().map((function(t){return(t-f.y)/f.k})).map(c.invert))}function L(t){g++||t({type:"zoomstart"})}function N(t){A(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function C(t){--g||(t({type:"zoomend"}),n=null)}function P(){var t=this,n=w.of(t,arguments),e=0,r=o.select(l(t)).on(x,s).on(m,u),i=S(o.mouse(t)),a=Mt(t);function s(){e=1,k(o.mouse(t),i),N(n)}function u(){r.on(x,null).on(m,null),a(e),C(n)}ws.call(t),L(n)}function T(){var t,n=this,e=w.of(n,arguments),r={},a=0,s=".zoom-"+o.event.changedTouches[0].identifier,u="touchmove"+s,c="touchend"+s,l=[],h=o.select(n),p=Mt(n);function y(){var e=o.touches(n);return t=f.k,e.forEach((function(t){t.identifier in r&&(r[t.identifier]=S(t))})),e}function d(){var t=o.event.target;o.select(t).on(u,g).on(c,x),l.push(t);for(var e=o.event.changedTouches,s=0,h=e.length;s1){v=p[0];var m=p[1],b=v[0]-m[0],w=v[1]-m[1];a=b*b+w*w}}function g(){var s,u,c,l,h=o.touches(n);ws.call(n);for(var f=0,p=h.length;f360?t-=360:t<0&&(t+=360),t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,n=isNaN(n)||n<0?0:n>1?1:n,r=2*(e=e<0?0:e>1?1:e)-(i=e<=.5?e*(1+n):e+n-e*n),new un(o(t+120),o(t),o(t-120))}function Wt(t,n,e){return this instanceof Wt?(this.h=+t,this.c=+n,void(this.l=+e)):arguments.length<2?t instanceof Wt?new Wt(t.h,t.c,t.l):rn(t instanceof Qt?t.l:(t=dn((t=o.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new Wt(t,n,e)}Yt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Zt(this.h,this.s,this.l/t)},Yt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Zt(this.h,this.s,t*this.l)},Yt.rgb=function(){return Kt(this.h,this.s,this.l)},o.hcl=Wt;var $t=Wt.prototype=new Xt;function Jt(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),new Qt(e,Math.cos(t*=zt)*n,Math.sin(t)*n)}function Qt(t,n,e){return this instanceof Qt?(this.l=+t,this.a=+n,void(this.b=+e)):arguments.length<2?t instanceof Qt?new Qt(t.l,t.a,t.b):t instanceof Wt?Jt(t.h,t.c,t.l):dn((t=un(t)).r,t.g,t.b):new Qt(t,n,e)}$t.brighter=function(t){return new Wt(this.h,this.c,Math.min(100,this.l+tn*(arguments.length?t:1)))},$t.darker=function(t){return new Wt(this.h,this.c,Math.max(0,this.l-tn*(arguments.length?t:1)))},$t.rgb=function(){return Jt(this.h,this.c,this.l).rgb()},o.lab=Qt;var tn=18,nn=Qt.prototype=new Xt;function en(t,n,e){var r=(t+16)/116,i=r+n/500,o=r-e/200;return new un(sn(3.2404542*(i=.95047*on(i))-1.5371385*(r=1*on(r))-.4985314*(o=1.08883*on(o))),sn(-.969266*i+1.8760108*r+.041556*o),sn(.0556434*i-.2040259*r+1.0572252*o))}function rn(t,n,e){return t>0?new Wt(Math.atan2(e,n)*Dt,Math.sqrt(n*n+e*e),t):new Wt(NaN,NaN,t)}function on(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function an(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function sn(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function un(t,n,e){return this instanceof un?(this.r=~~t,this.g=~~n,void(this.b=~~e)):arguments.length<2?t instanceof un?new un(t.r,t.g,t.b):pn(""+t,un,Kt):new un(t,n,e)}function cn(t){return new un(t>>16,t>>8&255,255&t)}function ln(t){return cn(t)+""}nn.brighter=function(t){return new Qt(Math.min(100,this.l+tn*(arguments.length?t:1)),this.a,this.b)},nn.darker=function(t){return new Qt(Math.max(0,this.l-tn*(arguments.length?t:1)),this.a,this.b)},nn.rgb=function(){return en(this.l,this.a,this.b)},o.rgb=un;var hn=un.prototype=new Xt;function fn(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function pn(t,n,e){var r,i,o,a=0,s=0,u=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return n(vn(i[0]),vn(i[1]),vn(i[2]))}return(o=xn.get(t))?n(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(a=(3840&o)>>4,a|=a>>4,s=240&o,s|=s>>4,u=15&o,u|=u<<4):7===t.length&&(a=(16711680&o)>>16,s=(65280&o)>>8,u=255&o)),n(a,s,u))}function yn(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),s=a-o,u=(a+o)/2;return s?(i=u<.5?s/(a+o):s/(2-a-o),r=t==a?(n-e)/s+(n0&&u<1?0:r),new Zt(r,i,u)}function dn(t,n,e){var r=an((.4124564*(t=gn(t))+.3575761*(n=gn(n))+.1804375*(e=gn(e)))/.95047),i=an((.2126729*t+.7151522*n+.072175*e)/1);return Qt(116*i-16,500*(r-i),200*(i-an((.0193339*t+.119192*n+.9503041*e)/1.08883)))}function gn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function vn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}hn.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&n=200&&n<300||304===n){try{t=e.call(i,c)}catch(t){return void a.error.call(i,t)}a.load.call(i,t)}else a.error.call(i,c)}return this.XDomainRequest&&!("withCredentials"in c)&&/^(http(s)?:)?\/\//.test(t)&&(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=h:c.onreadystatechange=function(){c.readyState>3&&h()},c.onprogress=function(t){var n=o.event;o.event=t;try{a.progress.call(i,c)}finally{o.event=n}},i.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?u[t]:(null==n?delete u[t]:u[t]=n+"",i)},i.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",i):n},i.responseType=function(t){return arguments.length?(l=t,i):l},i.response=function(t){return e=t,i},["get","post"].forEach((function(t){i[t]=function(){return i.send.apply(i,[t].concat(s(arguments)))}})),i.send=function(e,r,o){if(2===arguments.length&&"function"==typeof r&&(o=r,r=null),c.open(e,t,!0),null==n||"accept"in u||(u.accept=n+",*/*"),c.setRequestHeader)for(var s in u)c.setRequestHeader(s,u[s]);return null!=n&&c.overrideMimeType&&c.overrideMimeType(n),null!=l&&(c.responseType=l),null!=o&&i.on("error",o).on("load",(function(t){o(null,t)})),a.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},o.rebind(i,a,"on"),null==r?i:i.get(function(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}(r))}xn.forEach((function(t,n){xn.set(t,cn(n))})),o.functor=mn,o.xhr=bn(z),o.dsv=function(t,n){var e=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function i(t,e,r){arguments.length<3&&(r=e,e=null);var i=wn(t,n,null==e?o:a(e),r);return i.row=function(t){return arguments.length?i.response(null==(e=t)?o:a(t)):e},i}function o(t){return i.parse(t.responseText)}function a(t){return function(n){return i.parse(n.responseText,t)}}function s(n){return n.map(u).join(t)}function u(t){return e.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,n){var e;return i.parseRows(t,(function(t,r){if(e)return e(t,r-1);var i=new Function("d","return {"+t.map((function(t,n){return JSON.stringify(t)+": d["+n+"]"})).join(",")+"}");e=n?function(t,e){return n(i(t),e)}:i}))},i.parseRows=function(t,n){var e,i,o={},a={},s=[],u=t.length,c=0,l=0;function h(){if(c>=u)return a;if(i)return i=!1,o;var n=c;if(34===t.charCodeAt(n)){for(var e=n;e++24?(isFinite(n)&&(clearTimeout(kn),kn=setTimeout(Ln,n)),Mn=0):(Mn=1,En(Ln))}function Nn(){for(var t=Date.now(),n=_n;n;)t>=n.t&&n.c(t-n.t)&&(n.c=null),n=n.n;return t}function Cn(){for(var t,n=_n,e=1/0;n;)n.c?(n.t8?function(t){return t/e}:function(t){return t*e},symbol:t}}));function In(t){var n=t.decimal,e=t.thousands,r=t.grouping,i=t.currency,a=r&&e?function(t,n){for(var i=t.length,o=[],a=0,s=r[0],u=0;i>0&&s>0&&(u+s+1>n&&(s=Math.max(1,n-u)),o.push(t.substring(i-=s,i+s)),!((u+=s+1)>n));)s=r[a=(a+1)%r.length];return o.reverse().join(e)}:z;return function(t){var e=zn.exec(t),r=e[1]||" ",s=e[2]||">",u=e[3]||"-",c=e[4]||"",l=e[5],h=+e[6],f=e[7],p=e[8],y=e[9],d=1,g="",v="",x=!1,m=!0;switch(p&&(p=+p.substring(1)),(l||"0"===r&&"="===s)&&(l=r="0",s="="),y){case"n":f=!0,y="g";break;case"%":d=100,v="%",y="f";break;case"p":d=100,v="%",y="r";break;case"b":case"o":case"x":case"X":"#"===c&&(g="0"+y.toLowerCase());case"c":m=!1;case"d":x=!0,p=0;break;case"s":d=-1,y="r"}"$"===c&&(g=i[0],v=i[1]),"r"!=y||p||(y="g"),null!=p&&("g"==y?p=Math.max(1,Math.min(21,p)):"e"!=y&&"f"!=y||(p=Math.max(0,Math.min(20,p)))),y=Dn.get(y)||On;var b=l&&f;return function(t){var e=v;if(x&&t%1)return"";var i=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===u?"":u;if(d<0){var c=o.formatPrefix(t,p);t=c.scale(t),e=c.symbol+v}else t*=d;var w,_,S=(t=y(t,p)).lastIndexOf(".");if(S<0){var M=m?t.lastIndexOf("e"):-1;M<0?(w=t,_=""):(w=t.substring(0,M),_=t.substring(M))}else w=t.substring(0,S),_=n+t.substring(S+1);!l&&f&&(w=a(w,1/0));var k=g.length+w.length+_.length+(b?0:i.length),E=k"===s?E+i+t:"^"===s?E.substring(0,k>>=1)+i+t+E.substring(k):i+(b?t:E+t))+e}}}o.formatPrefix=function(t,n){var e=0;return(t=+t)&&(t<0&&(t*=-1),n&&(t=o.round(t,Pn(t,n))),e=1+Math.floor(1e-12+Math.log(t)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),Tn[8+e/3]};var zn=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Dn=o.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(t,n){return(t=o.round(t,Pn(t,n))).toFixed(Math.max(0,Math.min(20,Pn(t*(1+1e-15),n))))}});function On(t){return t+""}var qn=o.time={},Rn=Date;function jn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}jn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Gn.setUTCDate.apply(this._,arguments)},setDay:function(){Gn.setUTCDay.apply(this._,arguments)},setFullYear:function(){Gn.setUTCFullYear.apply(this._,arguments)},setHours:function(){Gn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Gn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Gn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Gn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Gn.setUTCSeconds.apply(this._,arguments)},setTime:function(){Gn.setTime.apply(this._,arguments)}};var Gn=Date.prototype;function Vn(t,n,e){function r(n){var e=t(n),r=o(e,1);return n-e1)for(;a=c)return-1;if(37===(i=n.charCodeAt(s++))){if(a=n.charAt(s++),!(o=_[a in Hn?n.charAt(s++):a])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}l.utc=function(t){var n=l(t);function e(t){try{var e=new(Rn=jn);return e._=t,n(e)}finally{Rn=Date}}return e.parse=function(t){try{Rn=jn;var e=n.parse(t);return e&&e._}finally{Rn=Date}},e.toString=n.toString,e},l.multi=l.utc.multi=he;var f=o.map(),p=Yn(a),y=Kn(a),d=Yn(s),g=Kn(s),v=Yn(u),x=Kn(u),m=Yn(c),b=Kn(c);i.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return s[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:l(n),d:function(t,n){return Zn(t.getDate(),n,2)},e:function(t,n){return Zn(t.getDate(),n,2)},H:function(t,n){return Zn(t.getHours(),n,2)},I:function(t,n){return Zn(t.getHours()%12||12,n,2)},j:function(t,n){return Zn(1+qn.dayOfYear(t),n,3)},L:function(t,n){return Zn(t.getMilliseconds(),n,3)},m:function(t,n){return Zn(t.getMonth()+1,n,2)},M:function(t,n){return Zn(t.getMinutes(),n,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,n){return Zn(t.getSeconds(),n,2)},U:function(t,n){return Zn(qn.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return Zn(qn.mondayOfYear(t),n,2)},x:l(e),X:l(r),y:function(t,n){return Zn(t.getFullYear()%100,n,2)},Y:function(t,n){return Zn(t.getFullYear()%1e4,n,4)},Z:ce,"%":function(){return"%"}},_={a:function(t,n,e){d.lastIndex=0;var r=d.exec(n.slice(e));return r?(t.w=g.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(t,n,e){p.lastIndex=0;var r=p.exec(n.slice(e));return r?(t.w=y.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){m.lastIndex=0;var r=m.exec(n.slice(e));return r?(t.m=b.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(t,n,e){v.lastIndex=0;var r=v.exec(n.slice(e));return r?(t.m=x.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,n,e){return h(t,w.c.toString(),n,e)},d:re,e:re,H:oe,I:oe,j:ie,L:ue,m:ee,M:ae,p:function(t,n,e){var r=f.get(n.slice(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)},S:se,U:$n,w:Wn,W:Jn,x:function(t,n,e){return h(t,w.x.toString(),n,e)},X:function(t,n,e){return h(t,w.X.toString(),n,e)},y:te,Y:Qn,Z:ne,"%":le};return l}qn.year=Vn((function(t){return(t=qn.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),qn.years=qn.year.range,qn.years.utc=qn.year.utc.range,qn.day=Vn((function(t){var n=new Rn(2e3,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n}),(function(t,n){t.setDate(t.getDate()+n)}),(function(t){return t.getDate()-1})),qn.days=qn.day.range,qn.days.utc=qn.day.utc.range,qn.dayOfYear=function(t){var n=qn.year(t);return Math.floor((t-n-6e4*(t.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(t,n){n=7-n;var e=qn[t]=Vn((function(t){return(t=qn.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t}),(function(t,n){t.setDate(t.getDate()+7*Math.floor(n))}),(function(t){var e=qn.year(t).getDay();return Math.floor((qn.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));qn[t+"s"]=e.range,qn[t+"s"].utc=e.utc.range,qn[t+"OfYear"]=function(t){var e=qn.year(t).getDay();return Math.floor((qn.dayOfYear(t)+(e+n)%7)/7)}})),qn.week=qn.sunday,qn.weeks=qn.sunday.range,qn.weeks.utc=qn.sunday.utc.range,qn.weekOfYear=qn.sundayOfYear;var Hn={"-":"",_:" ",0:"0"},Un=/^\s*\d+/,Xn=/^%/;function Zn(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o68?1900:2e3),e+i[0].length):-1}function ne(t,n,e){return/^[+-]\d{4}$/.test(n=n.slice(e,e+5))?(t.Z=-n,e+5):-1}function ee(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function re(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function ie(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+3));return r?(t.j=+r[0],e+r[0].length):-1}function oe(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function ae(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function se(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function ue(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function ce(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=_(n)/60|0,i=_(n)%60;return e+Zn(r,"0",2)+Zn(i,"0",2)}function le(t,n,e){Xn.lastIndex=0;var r=Xn.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function he(t){for(var n=t.length,e=-1;++e=0?1:-1,s=a*o,u=Math.cos(n),c=Math.sin(n),l=i*c,h=r*u+l*Math.cos(s),f=l*a*Math.sin(s);Ie.add(Math.atan2(f,h)),e=t,r=u,i=c}ze.point=function(a,s){ze.point=o,e=(t=a)*zt,r=Math.cos(s=(n=s)*zt/2+Ct/4),i=Math.sin(s)},ze.lineEnd=function(){o(t,n)}}function Oe(t){var n=t[0],e=t[1],r=Math.cos(e);return[r*Math.cos(n),r*Math.sin(n),Math.sin(e)]}function qe(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Re(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function je(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Ge(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Ve(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function Be(t){return[Math.atan2(t[1],t[0]),jt(t[2])]}function Fe(t,n){return _(t[0]-n[0])Lt?r=90:c<-Lt&&(n=-90),h[0]=t,h[1]=e}};function p(i,o){l.push(h=[t=i,e=i]),or&&(r=o)}function y(o,a){var s=Oe([o*zt,a*zt]);if(u){var c=Re(u,s),l=Re([c[1],-c[0],0],c);Ve(l),l=Be(l);var h=o-i,f=h>0?1:-1,y=l[0]*Dt*f,d=_(h)>180;if(d^(f*ir&&(r=g);else if(d^(f*i<(y=(y+360)%360-180)&&yr&&(r=a);d?ob(t,e)&&(e=o):b(o,e)>b(t,e)&&(t=o):e>=t?(oe&&(e=o)):o>i?b(t,o)>b(t,e)&&(e=o):b(o,e)>b(t,e)&&(t=o)}else p(o,a);u=s,i=o}function d(){f.point=y}function g(){h[0]=t,h[1]=e,f.point=p,u=null}function v(t,n){if(u){var e=t-i;c+=_(e)>180?e+(e>0?360:-360):e}else a=t,s=n;ze.point(t,n),y(t,n)}function x(){ze.lineStart()}function m(){v(a,s),ze.lineEnd(),_(c)>Lt&&(t=-(e=180)),h[0]=t,h[1]=e,u=null}function b(t,n){return(n-=t)<0?n+360:n}function w(t,n){return t[0]-n[0]}function S(t,n){return n[0]<=n[1]?n[0]<=t&&t<=n[1]:tb(d[0],d[1])&&(d[1]=p[1]),b(p[0],d[1])>b(d[0],d[1])&&(d[0]=p[0])):s.push(d=p);for(var u,c,p,y=-1/0,d=(a=0,s[c=s.length-1]);a<=c;d=p,++a)p=s[a],(u=b(d[1],p[0]))>y&&(y=u,t=p[0],e=d[1])}return l=h=null,t===1/0||n===1/0?[[NaN,NaN],[NaN,NaN]]:[[t,n],[e,r]]}}(),o.geo.centroid=function(t){_e=Se=Me=ke=Ee=Ae=Le=Ne=Ce=Pe=Te=0,o.geo.stream(t,He);var n=Ce,e=Pe,r=Te,i=n*n+e*e+r*r;return i=0;--s)i.point((h=l[s])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}l=(p=p.o).z,y=!y}while(!p.v);i.lineEnd()}}}function Qe(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,S=_*w,M=S>Ct,k=y*m;if(Ie.add(Math.atan2(k*_*Math.sin(S),d*b+k*Math.cos(S))),o+=M?w+_*Pt:w,M^f>=e^v>=e){var E=Re(Oe(h),Oe(t));Ve(E);var A=Re(i,E);Ve(A);var L=(M^w>=0?-1:1)*jt(A[2]);(r>L||r===L&&(E[0]||E[1]))&&(a+=M^w>=0?1:-1)}if(!g++)break;f=v,y=m,d=b,h=t}}return(o<-Lt||o0){for(m||(a.polygonStart(),m=!0),a.lineStart();++o1&&2&n&&e.push(e.pop().concat(e.shift())),s.push(e.filter(er))}return l}}function er(t){return t.length>1}function rr(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:R,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function ir(t,n){return((t=t.x)[0]<0?t[1]-It-Lt:It-t[1])-((n=n.x)[0]<0?n[1]-It-Lt:It-n[1])}var or=nr($e,(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var s=o>0?Ct:-Ct,u=_(o-e);_(u-Ct)0?It:-It),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),n=0):i!==s&&u>=Ct&&(_(e-i)Lt?Math.atan((Math.sin(n)*(o=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(n))*Math.sin(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),n=0),t.point(e=o,r=a),i=s},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*It,r.point(-Ct,i),r.point(0,i),r.point(Ct,i),r.point(Ct,0),r.point(Ct,-i),r.point(0,-i),r.point(-Ct,-i),r.point(-Ct,0),r.point(-Ct,i);else if(_(t[0]-n[0])>Lt){var o=t[0]0,r=_(n)>Lt;return nr(i,(function(t){var n,s,u,c,l;return{lineStart:function(){c=u=!1,l=1},point:function(h,f){var p,y=[h,f],d=i(h,f),g=e?d?0:a(h,f):d?a(h+(h<0?Ct:-Ct),f):0;if(!n&&(c=u=d)&&t.lineStart(),d!==u&&(p=o(n,y),(Fe(n,p)||Fe(y,p))&&(y[0]+=Lt,y[1]+=Lt,d=i(y[0],y[1]))),d!==u)l=0,d?(t.lineStart(),p=o(y,n),t.point(p[0],p[1])):(p=o(n,y),t.point(p[0],p[1]),t.lineEnd()),n=p;else if(r&&n&&e^d){var v;g&s||!(v=o(y,n,!0))||(l=0,e?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!d||n&&Fe(n,y)||t.point(y[0],y[1]),n=y,u=d,s=g},lineEnd:function(){u&&t.lineEnd(),n=null},clean:function(){return l|(c&&u)<<1}}}),Br(t,6*zt),e?[0,-t]:[-Ct,t-Ct]);function i(t,e){return Math.cos(t)*Math.cos(e)>n}function o(t,e,r){var i=[1,0,0],o=Re(Oe(t),Oe(e)),a=qe(o,o),s=o[0],u=a-s*s;if(!u)return!r&&t;var c=n*a/u,l=-n*s/u,h=Re(i,o),f=Ge(i,c);je(f,Ge(o,l));var p=h,y=qe(f,p),d=qe(p,p),g=y*y-d*(qe(f,f)-1);if(!(g<0)){var v=Math.sqrt(g),x=Ge(p,(-y-v)/d);if(je(x,f),x=Be(x),!r)return x;var m,b=t[0],w=e[0],S=t[1],M=e[1];w0^x[1]<(_(x[0]-b)Ct^(b<=x[0]&&x[0]<=w)){var A=Ge(p,(-y+v)/d);return je(A,f),[x,Be(A)]}}}function a(n,r){var i=e?t:Ct-t,o=0;return n<-i?o|=1:n>i&&(o|=2),r<-i?o|=4:r>i&&(o|=8),o}}function sr(t,n,e,r){return function(i){var o,a=i.a,s=i.b,u=a.x,c=a.y,l=0,h=1,f=s.x-u,p=s.y-c;if(o=t-u,f||!(o>0)){if(o/=f,f<0){if(o0){if(o>h)return;o>l&&(l=o)}if(o=e-u,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>l&&(l=o)}else if(f>0){if(o0)){if(o/=p,p<0){if(o0){if(o>h)return;o>l&&(l=o)}if(o=r-c,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>l&&(l=o)}else if(p>0){if(o0&&(i.a={x:u+l*f,y:c+l*p}),h<1&&(i.b={x:u+h*f,y:c+h*p}),i}}}}}}function ur(t,n,e,r){return function(u){var c,l,h,f,p,y,d,g,v,x,m,b=u,w=rr(),_=sr(t,n,e,r),S={point:E,lineStart:function(){S.point=A,l&&l.push(h=[]);x=!0,v=!1,d=g=NaN},lineEnd:function(){c&&(A(f,p),y&&v&&w.rejoin(),c.push(w.buffer()));S.point=E,v&&u.lineEnd()},polygonStart:function(){u=w,c=[],l=[],m=!0},polygonEnd:function(){u=b,c=o.merge(c);var n=function(t){for(var n=0,e=l.length,r=t[1],i=0;ir&&qt(c,o,t)>0&&++n:o[1]<=r&&qt(c,o,t)<0&&--n,c=o;return 0!==n}([t,r]),e=m&&n,i=c.length;(e||i)&&(u.polygonStart(),e&&(u.lineStart(),M(null,null,1,u),u.lineEnd()),i&&Je(c,a,n,M,u),u.polygonEnd()),c=l=h=null}};function M(o,a,u,c){var l=0,h=0;if(null==o||(l=i(o,u))!==(h=i(a,u))||s(o,a)<0^u>0)do{c.point(0===l||3===l?t:e,l>1?r:n)}while((l=(l+u+4)%4)!==h);else c.point(a[0],a[1])}function k(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function E(t,n){k(t,n)&&u.point(t,n)}function A(t,n){var e=k(t=Math.max(-1e9,Math.min(1e9,t)),n=Math.max(-1e9,Math.min(1e9,n)));if(l&&h.push([t,n]),x)f=t,p=n,y=e,x=!1,e&&(u.lineStart(),u.point(t,n));else if(e&&v)u.point(t,n);else{var r={a:{x:d,y:g},b:{x:t,y:n}};_(r)?(v||(u.lineStart(),u.point(r.a.x,r.a.y)),u.point(r.b.x,r.b.y),e||u.lineEnd(),m=!1):e&&(u.lineStart(),u.point(t,n),m=!1)}d=t,g=n,v=e}return S};function i(r,i){return _(r[0]-t)0?0:3:_(r[0]-e)0?2:1:_(r[1]-n)0?1:0:i>0?3:2}function a(t,n){return s(t.x,n.x)}function s(t,n){var e=i(t,1),r=i(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}}function cr(t){var n=0,e=Ct/3,r=zr(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Ct/180,e=t[1]*Ct/180):[n/Ct*180,e/Ct*180]},i}function lr(t,n){var e=Math.sin(t),r=(e+Math.sin(n))/2,i=1+e*(2*r-e),o=Math.sqrt(i)/r;function a(t,n){var e=Math.sqrt(i-2*r*Math.sin(n))/r;return[e*Math.sin(t*=r),o-e*Math.cos(t)]}return a.invert=function(t,n){var e=o-n;return[Math.atan2(t,e)/r,jt((i-(t*t+e*e)*r*r)/(2*r))]},a}o.geo.clipExtent=function(){var t,n,e,r,i,o,a={stream:function(t){return i&&(i.valid=!1),(i=o(t)).valid=!0,i},extent:function(s){return arguments.length?(o=ur(t=+s[0][0],n=+s[0][1],e=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(o.geo.conicEqualArea=function(){return cr(lr)}).raw=lr,o.geo.albers=function(){return o.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},o.geo.albersUsa=function(){var t,n,e,r,i=o.geo.albers(),a=o.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=o.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),u={point:function(n,e){t=[n,e]}};function c(i){var o=i[0],a=i[1];return t=null,n(o,a),t||(e(o,a),t)||r(o,a),t}return c.invert=function(t){var n=i.scale(),e=i.translate(),r=(t[0]-e[0])/n,o=(t[1]-e[1])/n;return(o>=.12&&o<.234&&r>=-.425&&r<-.214?a:o>=.166&&o<.234&&r>=-.214&&r<-.115?s:i).invert(t)},c.stream=function(t){var n=i.stream(t),e=a.stream(t),r=s.stream(t);return{point:function(t,i){n.point(t,i),e.point(t,i),r.point(t,i)},sphere:function(){n.sphere(),e.sphere(),r.sphere()},lineStart:function(){n.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){n.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){n.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){n.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),a.precision(t),s.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),a.scale(.35*t),s.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var o=i.scale(),l=+t[0],h=+t[1];return n=i.translate(t).clipExtent([[l-.455*o,h-.238*o],[l+.455*o,h+.238*o]]).stream(u).point,e=a.translate([l-.307*o,h+.201*o]).clipExtent([[l-.425*o+Lt,h+.12*o+Lt],[l-.214*o-Lt,h+.234*o-Lt]]).stream(u).point,r=s.translate([l-.205*o,h+.212*o]).clipExtent([[l-.214*o+Lt,h+.166*o+Lt],[l-.115*o-Lt,h+.234*o-Lt]]).stream(u).point,c},c.scale(1070)};var hr,fr,pr,yr,dr,gr,vr={point:R,lineStart:R,lineEnd:R,polygonStart:function(){fr=0,vr.lineStart=xr},polygonEnd:function(){vr.lineStart=vr.lineEnd=vr.point=R,hr+=_(fr/2)}};function xr(){var t,n,e,r;function i(t,n){fr+=r*t-e*n,e=t,r=n}vr.point=function(o,a){vr.point=i,t=e=o,n=r=a},vr.lineEnd=function(){i(t,n)}}var mr={point:function(t,n){tdr&&(dr=t);ngr&&(gr=n)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function br(){var t=wr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=wr(n),e},result:function(){if(n.length){var t=n.join("");return n=[],t}}};function r(e,r){n.push("M",e,",",r,t)}function i(t,r){n.push("M",t,",",r),e.point=o}function o(t,e){n.push("L",t,",",e)}function a(){e.point=r}function s(){n.push("Z")}return e}function wr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var _r,Sr={point:Mr,lineStart:kr,lineEnd:Er,polygonStart:function(){Sr.lineStart=Ar},polygonEnd:function(){Sr.point=Mr,Sr.lineStart=kr,Sr.lineEnd=Er}};function Mr(t,n){Me+=t,ke+=n,++Ee}function kr(){var t,n;function e(e,r){var i=e-t,o=r-n,a=Math.sqrt(i*i+o*o);Ae+=a*(t+e)/2,Le+=a*(n+r)/2,Ne+=a,Mr(t=e,n=r)}Sr.point=function(r,i){Sr.point=e,Mr(t=r,n=i)}}function Er(){Sr.point=Mr}function Ar(){var t,n,e,r;function i(t,n){var i=t-e,o=n-r,a=Math.sqrt(i*i+o*o);Ae+=a*(e+t)/2,Le+=a*(r+n)/2,Ne+=a,Ce+=(a=r*t-e*n)*(e+t),Pe+=a*(r+n),Te+=3*a,Mr(e=t,r=n)}Sr.point=function(o,a){Sr.point=i,Mr(t=e=o,n=r=a)},Sr.lineEnd=function(){i(t,n)}}function Lr(t){var n=4.5,e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:R};function r(e,r){t.moveTo(e+n,r),t.arc(e,r,n,0,Pt)}function i(n,r){t.moveTo(n,r),e.point=o}function o(n,e){t.lineTo(n,e)}function a(){e.point=r}function s(){t.closePath()}return e}function Nr(t){var n=.5,e=Math.cos(30*zt),r=16;function i(t){return(r?a:o)(t)}function o(n){return Tr(n,(function(e,r){e=t(e,r),n.point(e[0],e[1])}))}function a(n){var e,i,o,a,u,c,l,h,f,p,y,d,g={point:v,lineStart:x,lineEnd:b,polygonStart:function(){n.polygonStart(),g.lineStart=w},polygonEnd:function(){n.polygonEnd(),g.lineStart=x}};function v(e,r){e=t(e,r),n.point(e[0],e[1])}function x(){h=NaN,g.point=m,n.lineStart()}function m(e,i){var o=Oe([e,i]),a=t(e,i);s(h,f,l,p,y,d,h=a[0],f=a[1],l=e,p=o[0],y=o[1],d=o[2],r,n),n.point(h,f)}function b(){g.point=v,n.lineEnd()}function w(){x(),g.point=_,g.lineEnd=S}function _(t,n){m(e=t,n),i=h,o=f,a=p,u=y,c=d,g.point=m}function S(){s(h,f,l,p,y,d,i,o,e,a,u,c,r,n),g.lineEnd=b,b()}return g}function s(r,i,o,a,u,c,l,h,f,p,y,d,g,v){var x=l-r,m=h-i,b=x*x+m*m;if(b>4*n&&g--){var w=a+p,S=u+y,M=c+d,k=Math.sqrt(w*w+S*S+M*M),E=Math.asin(M/=k),A=_(_(M)-1)n||_((x*P+m*T)/b-.5)>.3||a*p+u*y+c*d0&&16,i):Math.sqrt(n)},i}function Cr(t){var n=Nr((function(n,e){return t([n*Dt,e*Dt])}));return function(t){return Dr(n(t))}}function Pr(t){this.stream=t}function Tr(t,n){return{point:n,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Ir(t){return zr((function(){return t}))()}function zr(t){var n,e,r,i,a,s,u=Nr((function(t,e){return[(t=n(t,e))[0]*c+i,a-t[1]*c]})),c=150,l=480,h=250,f=0,p=0,y=0,d=0,g=0,v=or,x=z,m=null,b=null;function w(t){return[(t=r(t[0]*zt,t[1]*zt))[0]*c+i,a-t[1]*c]}function _(t){return(t=r.invert((t[0]-i)/c,(a-t[1])/c))&&[t[0]*Dt,t[1]*Dt]}function S(){r=We(e=Rr(y,d,g),n);var t=n(f,p);return i=l-t[0]*c,a=h+t[1]*c,M()}function M(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Dr(v(e,u(x(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(v=null==t?(m=t,or):ar((m=+t)*zt),M()):m},w.clipExtent=function(t){return arguments.length?(b=t,x=t?ur(t[0][0],t[0][1],t[1][0],t[1][1]):z,M()):b},w.scale=function(t){return arguments.length?(c=+t,S()):c},w.translate=function(t){return arguments.length?(l=+t[0],h=+t[1],S()):[l,h]},w.center=function(t){return arguments.length?(f=t[0]%360*zt,p=t[1]%360*zt,S()):[f*Dt,p*Dt]},w.rotate=function(t){return arguments.length?(y=t[0]%360*zt,d=t[1]%360*zt,g=t.length>2?t[2]%360*zt:0,S()):[y*Dt,d*Dt,g*Dt]},o.rebind(w,u,"precision"),function(){return n=t.apply(this,arguments),w.invert=n.invert&&_,S()}}function Dr(t){return Tr(t,(function(n,e){t.point(n*zt,e*zt)}))}function Or(t,n){return[t,n]}function qr(t,n){return[t>Ct?t-Pt:t<-Ct?t+Pt:t,n]}function Rr(t,n,e){return t?n||e?We(Gr(t),Vr(n,e)):Gr(t):n||e?Vr(n,e):qr}function jr(t){return function(n,e){return[(n+=t)>Ct?n-Pt:n<-Ct?n+Pt:n,e]}}function Gr(t){var n=jr(t);return n.invert=jr(-t),n}function Vr(t,n){var e=Math.cos(t),r=Math.sin(t),i=Math.cos(n),o=Math.sin(n);function a(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,c=Math.sin(n),l=c*e+s*r;return[Math.atan2(u*i-l*o,s*e-c*r),jt(l*i+u*o)]}return a.invert=function(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,c=Math.sin(n),l=c*i-u*o;return[Math.atan2(u*i+c*o,s*e+l*r),jt(l*e-s*r)]},a}function Br(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,s){var u=a*n;null!=i?(i=Fr(e,i),o=Fr(e,o),(a>0?io)&&(i+=a*Pt)):(i=t+a*Pt,o=t-.5*u);for(var c,l=i;a>0?l>o:l2?t[2]*zt:0),n.invert=function(n){return(n=t.invert(n[0]*zt,n[1]*zt))[0]*=Dt,n[1]*=Dt,n},n},qr.invert=Or,o.geo.circle=function(){var t,n,e=[0,0],r=6;function i(){var t="function"==typeof e?e.apply(this,arguments):e,r=Rr(-t[0]*zt,-t[1]*zt,0).invert,i=[];return n(null,null,1,{point:function(t,n){i.push(t=r(t,n)),t[0]*=Dt,t[1]*=Dt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(e=t,i):e},i.angle=function(e){return arguments.length?(n=Br((t=+e)*zt,r*zt),i):t},i.precision=function(e){return arguments.length?(n=Br(t*zt,(r=+e)*zt),i):r},i.angle(90)},o.geo.distance=function(t,n){var e,r=(n[0]-t[0])*zt,i=t[1]*zt,o=n[1]*zt,a=Math.sin(r),s=Math.cos(r),u=Math.sin(i),c=Math.cos(i),l=Math.sin(o),h=Math.cos(o);return Math.atan2(Math.sqrt((e=h*a)*e+(e=c*l-u*h*s)*e),u*l+c*h*s)},o.geo.graticule=function(){var t,n,e,r,i,a,s,u,c,l,h,f,p=10,y=p,d=90,g=360,v=2.5;function x(){return{type:"MultiLineString",coordinates:m()}}function m(){return o.range(Math.ceil(r/d)*d,e,d).map(h).concat(o.range(Math.ceil(u/g)*g,s,g).map(f)).concat(o.range(Math.ceil(n/p)*p,t,p).filter((function(t){return _(t%d)>Lt})).map(c)).concat(o.range(Math.ceil(a/y)*y,i,y).filter((function(t){return _(t%g)>Lt})).map(l))}return x.lines=function(){return m().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(r).concat(f(s).slice(1),h(e).reverse().slice(1),f(u).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],s=+t[1][1],r>e&&(t=r,r=e,e=t),u>s&&(t=u,u=s,s=t),x.precision(v)):[[r,u],[e,s]]},x.minorExtent=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],a=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),a>i&&(e=a,a=i,i=e),x.precision(v)):[[n,a],[t,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(d=+t[0],g=+t[1],x):[d,g]},x.minorStep=function(t){return arguments.length?(p=+t[0],y=+t[1],x):[p,y]},x.precision=function(o){return arguments.length?(v=+o,c=Hr(a,i,90),l=Ur(n,t,v),h=Hr(u,s,90),f=Ur(r,e,v),x):v},x.majorExtent([[-180,-90+Lt],[180,90-Lt]]).minorExtent([[-180,-80-Lt],[180,80+Lt]])},o.geo.greatArc=function(){var t,n,e=Xr,r=Zr;function i(){return{type:"LineString",coordinates:[t||e.apply(this,arguments),n||r.apply(this,arguments)]}}return i.distance=function(){return o.geo.distance(t||e.apply(this,arguments),n||r.apply(this,arguments))},i.source=function(n){return arguments.length?(e=n,t="function"==typeof n?null:n,i):e},i.target=function(t){return arguments.length?(r=t,n="function"==typeof t?null:t,i):r},i.precision=function(){return arguments.length?i:0},i},o.geo.interpolate=function(t,n){return e=t[0]*zt,r=t[1]*zt,i=n[0]*zt,o=n[1]*zt,a=Math.cos(r),s=Math.sin(r),u=Math.cos(o),c=Math.sin(o),l=a*Math.cos(e),h=a*Math.sin(e),f=u*Math.cos(i),p=u*Math.sin(i),y=2*Math.asin(Math.sqrt(Vt(o-r)+a*u*Vt(i-e))),d=1/Math.sin(y),(g=y?function(t){var n=Math.sin(t*=y)*d,e=Math.sin(y-t)*d,r=e*l+n*f,i=e*h+n*p,o=e*s+n*c;return[Math.atan2(i,r)*Dt,Math.atan2(o,Math.sqrt(r*r+i*i))*Dt]}:function(){return[e*Dt,r*Dt]}).distance=y,g;var e,r,i,o,a,s,u,c,l,h,f,p,y,d,g},o.geo.length=function(t){return _r=0,o.geo.stream(t,Yr),_r};var Yr={sphere:R,point:R,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=zt),a=Math.cos(i),s=_((r*=zt)-t),u=Math.cos(s);_r+=Math.atan2(Math.sqrt((s=a*Math.sin(s))*s+(s=e*o-n*a*u)*s),n*o+e*a*u),t=r,n=o,e=a}Yr.point=function(i,o){t=i*zt,n=Math.sin(o*=zt),e=Math.cos(o),Yr.point=r},Yr.lineEnd=function(){Yr.point=Yr.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Kr(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),o=t(r*i);return[o*i*Math.sin(n),o*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),o=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*o,r*a),Math.asin(r&&e*o/r)]},e}var Wr=Kr((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(o.geo.azimuthalEqualArea=function(){return Ir(Wr)}).raw=Wr;var $r=Kr((function(t){var n=Math.acos(t);return n&&n/Math.sin(n)}),z);function Jr(t,n){var e=Math.cos(t),r=function(t){return Math.tan(Ct/4+t/2)},i=t===n?Math.sin(t):Math.log(e/Math.cos(n))/Math.log(r(n)/r(t)),o=e*Math.pow(r(t),i)/i;if(!i)return ni;function a(t,n){o>0?n<-It+Lt&&(n=-It+Lt):n>It-Lt&&(n=It-Lt);var e=o/Math.pow(r(n),i);return[e*Math.sin(i*t),o-e*Math.cos(i*t)]}return a.invert=function(t,n){var e=o-n,r=Ot(i)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/i,2*Math.atan(Math.pow(o/r,1/i))-It]},a}function Qr(t,n){var e=Math.cos(t),r=t===n?Math.sin(t):(e-Math.cos(n))/(n-t),i=e/r+t;if(_(r)1&&qt(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ci(t,n){return t[0]-n[0]||t[1]-n[1]}(o.geo.stereographic=function(){return Ir(ii)}).raw=ii,oi.invert=function(t,n){return[-n,2*Math.atan(Math.exp(t))-It]},(o.geo.transverseMercator=function(){var t=ei(oi),n=t.center,e=t.rotate;return t.center=function(t){return t?n([-t[1],t[0]]):[(t=n())[1],-t[0]]},t.rotate=function(t){return t?e([t[0],t[1],t.length>2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90])}).raw=oi,o.geom={},o.geom.hull=function(t){var n=ai,e=si;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=mn(n),o=mn(e),a=t.length,s=[],u=[];for(r=0;r=0;--r)p.push(t[s[c[r]][2]]);for(r=+h;rLt)s=s.L;else{if(!((i=o-Ai(s,a))>Lt)){r>-Lt?(n=s.P,e=s):i>-Lt?(n=s,e=s.N):n=e=s;break}if(!s.R){n=s;break}s=s.R}var u=_i(t);if(gi.insert(n,u),n||e){if(n===e)return Ti(n),e=_i(n.site),gi.insert(u,e),u.edge=e.edge=Di(n.site,u.site),Pi(n),void Pi(e);if(e){Ti(n),Ti(e);var c=n.site,l=c.x,h=c.y,f=t.x-l,p=t.y-h,y=e.site,d=y.x-l,g=y.y-h,v=2*(f*g-p*d),x=f*f+p*p,m=d*d+g*g,b={x:(g*x-p*m)/v+l,y:(f*m-d*x)/v+h};qi(e.edge,c,y,b),u.edge=Di(c,t,null,b),e.edge=Di(t,y,null,b),Pi(n),Pi(e)}else u.edge=Di(n.site,u.site)}}function Ei(t,n){var e=t.site,r=e.x,i=e.y,o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var s=(e=a.site).x,u=e.y,c=u-n;if(!c)return s;var l=s-r,h=1/o-1/c,f=l/c;return h?(-f+Math.sqrt(f*f-2*h*(l*l/(-2*c)-u+c/2+i-o/2)))/h+r:(r+s)/2}function Ai(t,n){var e=t.N;if(e)return Ei(e,n);var r=t.site;return r.y===n?r.x:1/0}function Li(t){this.site=t,this.edges=[]}function Ni(t,n){return n.angle-t.angle}function Ci(){Gi(this),this.x=this.y=this.arc=this.site=this.cy=null}function Pi(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i.x,s=i.y,u=r.x-a,c=r.y-s,l=o.x-a,h=2*(u*(g=o.y-s)-c*l);if(!(h>=-Nt)){var f=u*u+c*c,p=l*l+g*g,y=(g*f-c*p)/h,d=(u*p-l*f)/h,g=d+s,v=bi.pop()||new Ci;v.arc=t,v.site=i,v.x=y+a,v.y=g+Math.sqrt(y*y+d*d),v.cy=g,t.circle=v;for(var x=null,m=xi._;m;)if(v.y=s)return;if(f>y){if(o){if(o.y>=c)return}else o={x:g,y:u};e={x:g,y:c}}else{if(o){if(o.y1)if(f>y){if(o){if(o.y>=c)return}else o={x:(u-i)/r,y:u};e={x:(c-i)/r,y:c}}else{if(o){if(o.y=s)return}else o={x:a,y:r*a+i};e={x:s,y:r*s+i}}else{if(o){if(o.xLt||_(i-e)>Lt)&&(s.splice(a,0,new Ri(Oi(o.site,l,_(r-h)Lt?{x:h,y:_(n-h)Lt?{x:_(e-y)Lt?{x:f,y:_(n-f)Lt?{x:_(e-p)=e&&c.x<=i&&c.y>=r&&c.y<=a?[[e,a],[i,a],[i,r],[e,r]]:[]).point=t[s]})),n}function s(t){return t.map((function(t,n){return{x:Math.round(r(t,n)/Lt)*Lt,y:Math.round(i(t,n)/Lt)*Lt,i:n}}))}return a.links=function(t){return Hi(s(t)).edges.filter((function(t){return t.l&&t.r})).map((function(n){return{source:t[n.l.i],target:t[n.r.i]}}))},a.triangles=function(t){var n=[];return Hi(s(t)).cells.forEach((function(e,r){for(var i,o,a,s,u=e.site,c=e.edges.sort(Ni),l=-1,h=c.length,f=c[h-1].edge,p=f.l===u?f.r:f.l;++lo||h>a||f=w)<<1|n>=b,S=_+4;_o&&(i=n.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(e=e[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Qi(e,r)})),o=eo.lastIndex;return od&&(d=u.x),u.y>g&&(g=u.y),c.push(u.x),l.push(u.y);else for(h=0;hd&&(d=m),b>g&&(g=b),c.push(m),l.push(b)}var w=d-p,S=g-y;function M(t,n,e,r,i,o,a,s){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var u=t.x,c=t.y;if(null!=u)if(_(u-e)+_(c-r)<.01)k(t,n,e,r,i,o,a,s);else{var l=t.point;t.x=t.y=t.point=null,k(t,l,u,c,i,o,a,s),k(t,n,e,r,i,o,a,s)}else t.x=e,t.y=r,t.point=n}else k(t,n,e,r,i,o,a,s)}function k(t,n,e,r,i,o,a,s){var u=.5*(i+a),c=.5*(o+s),l=e>=u,h=r>=c,f=h<<1|l;t.leaf=!1,l?i=u:a=u,h?o=c:s=c,M(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,s)}w>S?g=y+w:d=p+S;var E={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(E,t,+v(t,++h),+x(t,h),p,y,d,g)},visit:function(t){Ki(t,E,p,y,d,g)},find:function(t){return Wi(E,t[0],t[1],p,y,d,g)}};if(h=-1,null==n){for(;++h=0&&!(e=o.interpolators[r](t,n)););return e}function io(t,n){var e,r=[],i=[],o=t.length,a=n.length,s=Math.min(t.length,n.length);for(e=0;e=1?1:t(n)}}function co(t){return function(n){return 1-t(1-n)}}function lo(t){return function(n){return.5*(n<.5?t(2*n):2-t(2-2*n))}}function ho(t){return t*t}function fo(t){return t*t*t}function po(t){if(t<=0)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(t<.5?e:3*(t-n)+e-.75)}function yo(t){return 1-Math.cos(t*It)}function go(t){return Math.pow(2,10*(t-1))}function vo(t){return 1-Math.sqrt(1-t*t)}function xo(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function mo(t,n){return n-=t,function(e){return Math.round(t+n*e)}}function bo(t){var n,e,r,i=[t.a,t.b],o=[t.c,t.d],a=_o(i),s=wo(i,o),u=_o(((n=o)[0]+=(r=-s)*(e=i)[0],n[1]+=r*e[1],n))||0;i[0]*o[1]=0?t.slice(0,n):t,r=n>=0?t.slice(n+1):"in";return e=ao.get(e)||oo,uo((r=so.get(r)||z)(e.apply(null,a.call(arguments,1))))},o.interpolateHcl=function(t,n){t=o.hcl(t),n=o.hcl(n);var e=t.h,r=t.c,i=t.l,a=n.h-e,s=n.c-r,u=n.l-i;isNaN(s)&&(s=0,r=isNaN(r)?n.c:r);isNaN(a)?(a=0,e=isNaN(e)?n.h:e):a>180?a-=360:a<-180&&(a+=360);return function(t){return Jt(e+a*t,r+s*t,i+u*t)+""}},o.interpolateHsl=function(t,n){t=o.hsl(t),n=o.hsl(n);var e=t.h,r=t.s,i=t.l,a=n.h-e,s=n.s-r,u=n.l-i;isNaN(s)&&(s=0,r=isNaN(r)?n.s:r);isNaN(a)?(a=0,e=isNaN(e)?n.h:e):a>180?a-=360:a<-180&&(a+=360);return function(t){return Kt(e+a*t,r+s*t,i+u*t)+""}},o.interpolateLab=function(t,n){t=o.lab(t),n=o.lab(n);var e=t.l,r=t.a,i=t.b,a=n.l-e,s=n.a-r,u=n.b-i;return function(t){return en(e+a*t,r+s*t,i+u*t)+""}},o.interpolateRound=mo,o.transform=function(t){var n=u.createElementNS(o.ns.prefix.svg,"g");return(o.transform=function(t){if(null!=t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate()}return new bo(e?e.matrix:So)})(t)},bo.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var So={a:1,b:0,c:0,d:1,e:0,f:0};function Mo(t){return t.length?t.pop()+",":""}function ko(t,n){var e=[],r=[];return t=o.transform(t),n=o.transform(n),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push("translate(",null,",",null,")");r.push({i:i-4,x:Qi(t[0],n[0])},{i:i-2,x:Qi(t[1],n[1])})}else(n[0]||n[1])&&e.push("translate("+n+")")}(t.translate,n.translate,e,r),function(t,n,e,r){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),r.push({i:e.push(Mo(e)+"rotate(",null,")")-2,x:Qi(t,n)})):n&&e.push(Mo(e)+"rotate("+n+")")}(t.rotate,n.rotate,e,r),function(t,n,e,r){t!==n?r.push({i:e.push(Mo(e)+"skewX(",null,")")-2,x:Qi(t,n)}):n&&e.push(Mo(e)+"skewX("+n+")")}(t.skew,n.skew,e,r),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push(Mo(e)+"scale(",null,",",null,")");r.push({i:i-4,x:Qi(t[0],n[0])},{i:i-2,x:Qi(t[1],n[1])})}else 1===n[0]&&1===n[1]||e.push(Mo(e)+"scale("+n+")")}(t.scale,n.scale,e,r),t=n=null,function(t){for(var n,i=-1,o=r.length;++i0?e=n:(t.c=null,t.t=NaN,t=null,u.end({type:"end",alpha:e=0})):n>0&&(u.start({type:"start",alpha:e=n}),t=An(s.tick)),s):e},s.start=function(){var t,n,e,o=v.length,u=x.length,l=c[0],y=c[1];for(t=0;t=0;)e.push(i[r])}function jo(t,n){for(var e=[t],r=[];null!=(t=e.pop());)if(r.push(t),(o=t.children)&&(i=o.length))for(var i,o,a=-1;++a=0;)a.push(l=c[u]),l.parent=o,l.depth=o.depth+1;e&&(o.value=0),o.children=c}else e&&(o.value=+e.call(r,o,o.depth)||0),delete o.children;return jo(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),s}return r.sort=function(n){return arguments.length?(t=n,r):t},r.children=function(t){return arguments.length?(n=t,r):n},r.value=function(t){return arguments.length?(e=t,r):e},r.revalue=function(t){return e&&(Ro(t,(function(t){t.children&&(t.value=0)})),jo(t,(function(t){var n;t.children||(t.value=+e.call(r,t,t.depth)||0),(n=t.parent)&&(n.value+=t.value)}))),t},r},o.layout.partition=function(){var t=o.layout.hierarchy(),n=[1,1];function e(e,r){var i=t.call(this,e,r);return function t(n,e,r,i){var o=n.children;if(n.x=e,n.y=n.depth*i,n.dx=r,n.dy=i,o&&(a=o.length)){var a,s,u,c=-1;for(r=n.value?r/n.value:0;++cs&&(s=r),a.push(r)}for(e=0;ei&&(r=e,i=n);return r}function Qo(t){return t.reduce(ta,0)}function ta(t,n){return t+n[1]}function na(t,n){return ea(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function ea(t,n){for(var e=-1,r=+t[0],i=(t[1]-r)/n,o=[];++e<=n;)o[e]=i*e+r;return o}function ra(t){return[o.min(t),o.max(t)]}function ia(t,n){return t.value-n.value}function oa(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function aa(t,n){t._pack_next=n,n._pack_prev=t}function sa(t,n){var e=n.x-t.x,r=n.y-t.y,i=t.r+n.r;return.999*i*i>e*e+r*r}function ua(t){if((n=t.children)&&(u=n.length)){var n,e,r,i,o,a,s,u,c=1/0,l=-1/0,h=1/0,f=-1/0;if(n.forEach(ca),(e=n[0]).x=-e.r,e.y=0,m(e),u>1&&((r=n[1]).x=r.r,r.y=0,m(r),u>2))for(ha(e,r,i=n[2]),m(i),oa(e,i),e._pack_prev=i,oa(i,r),r=e._pack_next,o=3;o0)for(a=-1;++a=h[0]&&u<=h[1]&&((s=c[o.bisect(f,u,1,y)-1]).y+=d,s.push(i[a]));return c}return i.value=function(t){return arguments.length?(n=t,i):n},i.range=function(t){return arguments.length?(e=mn(t),i):e},i.bins=function(t){return arguments.length?(r="number"==typeof t?function(n){return ea(n,t)}:mn(t),i):r},i.frequency=function(n){return arguments.length?(t=!!n,i):t},i},o.layout.pack=function(){var t,n=o.layout.hierarchy().sort(ia),e=0,r=[1,1];function i(i,o){var a=n.call(this,i,o),s=a[0],u=r[0],c=r[1],l=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(s.x=s.y=0,jo(s,(function(t){t.r=+l(t.value)})),jo(s,ua),e){var h=e*(t?1:Math.max(2*s.r/u,2*s.r/c))/2;jo(s,(function(t){t.r+=h})),jo(s,ua),jo(s,(function(t){t.r-=h}))}return function t(n,e,r,i){var o=n.children;if(n.x=e+=i*n.x,n.y=r+=i*n.y,n.r*=i,o)for(var a=-1,s=o.length;++ap.x&&(p=t),t.depth>y.depth&&(y=t)}));var d=n(f,p)/2-f.x,g=e[0]/(p.x+n(p,f)/2+d),v=e[1]/(y.depth||1);Ro(l,(function(t){t.x=(t.x+d)*g,t.y=t.depth*v}))}return c}function a(t){var e=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(e.length){!function(t){var n,e=0,r=0,i=t.children,o=i.length;for(;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(t);var o=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+n(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+n(t._,i._));t.parent.A=function(t,e,r){if(e){for(var i,o=t,a=t,s=e,u=o.parent.children[0],c=o.m,l=a.m,h=s.m,f=u.m;s=ya(s),o=pa(o),s&&o;)u=pa(u),(a=ya(a)).a=t,(i=s.z+h-o.z-c+n(s._,o._))>0&&(da(ga(s,t,r),t,i),c+=i,l+=i),h+=s.m,c+=o.m,f+=u.m,l+=a.m;s&&!ya(a)&&(a.t=s,a.m+=h-l),o&&!pa(u)&&(u.t=o,u.m+=c-f,r=t)}return r}(t,i,t.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=e[0],t.y=t.depth*e[1]}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(r=null==(e=t)?u:null,i):r?null:e},i.nodeSize=function(t){return arguments.length?(r=null==(e=t)?null:u,i):r?e:null},qo(i,t)},o.layout.cluster=function(){var t=o.layout.hierarchy().sort(null).value(null),n=fa,e=[1,1],r=!1;function i(i,a){var s,u=t.call(this,i,a),c=u[0],l=0;jo(c,(function(t){var e=t.children;e&&e.length?(t.x=function(t){return t.reduce((function(t,n){return t+n.x}),0)/t.length}(e),t.y=function(t){return 1+o.max(t,(function(t){return t.y}))}(e)):(t.x=s?l+=n(t,s):0,t.y=0,s=t)}));var h=function t(n){var e=n.children;return e&&e.length?t(e[0]):n}(c),f=function t(n){var e,r=n.children;return r&&(e=r.length)?t(r[e-1]):n}(c),p=h.x-n(h,f)/2,y=f.x+n(f,h)/2;return jo(c,r?function(t){t.x=(t.x-c.x)*e[0],t.y=(c.y-t.y)*e[1]}:function(t){t.x=(t.x-p)/(y-p)*e[0],t.y=(1-(c.y?t.y/c.y:1))*e[1]}),u}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(r=null==(e=t),i):r?null:e},i.nodeSize=function(t){return arguments.length?(r=null!=(e=t),i):r?e:null},qo(i,t)},o.layout.treemap=function(){var t,n=o.layout.hierarchy(),e=Math.round,r=[1,1],i=null,a=va,s=!1,u="squarify",c=.5*(1+Math.sqrt(5));function l(t,n){for(var e,r,i=-1,o=t.length;++i0;)s.push(e=c[i-1]),s.area+=e.area,"squarify"!==u||(r=p(s,d))<=f?(c.pop(),f=r):(s.area-=s.pop().area,y(s,d,o,!1),d=Math.min(o.dx,o.dy),s.length=s.area=0,f=1/0);s.length&&(y(s,d,o,!0),s.length=s.area=0),n.forEach(h)}}function f(t){var n=t.children;if(n&&n.length){var e,r=a(t),i=n.slice(),o=[];for(l(i,r.dx*r.dy/t.value),o.area=0;e=i.pop();)o.push(e),o.area+=e.area,null!=e.z&&(y(o,e.z?r.dx:r.dy,r,!i.length),o.length=o.area=0);n.forEach(f)}}function p(t,n){for(var e,r=t.area,i=0,o=1/0,a=-1,s=t.length;++ai&&(i=e));return n*=n,(r*=r)?Math.max(n*i*c/r,r/(n*o*c)):1/0}function y(t,n,r,i){var o,a=-1,s=t.length,u=r.x,c=r.y,l=n?e(t.area/n):0;if(n==r.dx){for((i||l>r.dy)&&(l=r.dy);++ar.dx)&&(l=r.dx);++a1);return t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=o.random.normal.apply(o,arguments);return function(){return Math.exp(t())}},bates:function(t){var n=o.random.irwinHall(t);return function(){return n()/t}},irwinHall:function(t){return function(){for(var n=0,e=0;e2?ka:wa,s=i?Ao:Eo;return o=t(n,e,s,r),a=t(e,n,s,ro),u}function u(t){return o(t)}return u.invert=function(t){return a(t)},u.domain=function(t){return arguments.length?(n=t.map(Number),s()):n},u.range=function(t){return arguments.length?(e=t,s()):e},u.rangeRound=function(t){return u.range(t).interpolate(mo)},u.clamp=function(t){return arguments.length?(i=t,s()):i},u.interpolate=function(t){return arguments.length?(r=t,s()):r},u.ticks=function(t){return Na(n,t)},u.tickFormat=function(t,e){return Ca(n,t,e)},u.nice=function(t){return Aa(n,t),s()},u.copy=function(){return t(n,e,r,i)},s()}([0,1],[0,1],ro,!1)};var Pa={s:1,g:1,p:1,r:1,e:1};function Ta(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}o.scale.log=function(){return function t(n,e,r,i){function a(t){return(r?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function s(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function u(t){return n(a(t))}return u.invert=function(t){return s(n.invert(t))},u.domain=function(t){return arguments.length?(r=t[0]>=0,n.domain((i=t.map(Number)).map(a)),u):i},u.base=function(t){return arguments.length?(e=+t,n.domain(i.map(a)),u):e},u.nice=function(){var t=_a(i.map(a),r?Math:za);return n.domain(t),i=t.map(s),u},u.ticks=function(){var t=ma(i),n=[],o=t[0],u=t[1],c=Math.floor(a(o)),l=Math.ceil(a(u)),h=e%1?2:e;if(isFinite(l-c)){if(r){for(;c0;f--)n.push(s(c)*f);for(c=0;n[c]u;l--);n=n.slice(c,l)}return n},u.tickFormat=function(t,n){if(!arguments.length)return Ia;arguments.length<2?n=Ia:"function"!=typeof n&&(n=o.format(n));var r=Math.max(1,e*t/u.ticks().length);return function(t){var i=t/s(Math.round(a(t)));return i*e0?r[t-1]:n[0],th?0:1;if(c=Tt)return u(c,p)+(s?u(s,1-p):"")+"Z";var y,d,g,v,x,m,b,w,_,S,M,k,E=0,A=0,L=[];if((v=(+a.apply(this,arguments)||0)/2)&&(g=r===Va?Math.sqrt(s*s+c*c):+r.apply(this,arguments),p||(A*=-1),c&&(A=jt(g/c*Math.sin(v))),s&&(E=jt(g/s*Math.sin(v)))),c){x=c*Math.cos(l+A),m=c*Math.sin(l+A),b=c*Math.cos(h-A),w=c*Math.sin(h-A);var N=Math.abs(h-l-2*A)<=Ct?0:1;if(A&&Za(x,m,b,w)===p^N){var C=(l+h)/2;x=c*Math.cos(C),m=c*Math.sin(C),b=w=null}}else x=m=0;if(s){_=s*Math.cos(h-E),S=s*Math.sin(h-E),M=s*Math.cos(l+E),k=s*Math.sin(l+E);var P=Math.abs(l-h+2*E)<=Ct?0:1;if(E&&Za(_,S,M,k)===1-p^P){var T=(l+h)/2;_=s*Math.cos(T),S=s*Math.sin(T),M=k=null}}else _=S=0;if(f>Lt&&(y=Math.min(Math.abs(c-s)/2,+e.apply(this,arguments)))>.001){d=s0?0:1}function Ya(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],s=(i?r:-r)/Math.sqrt(o*o+a*a),u=s*a,c=-s*o,l=t[0]+u,h=t[1]+c,f=n[0]+u,p=n[1]+c,y=(l+f)/2,d=(h+p)/2,g=f-l,v=p-h,x=g*g+v*v,m=e-r,b=l*p-f*h,w=(v<0?-1:1)*Math.sqrt(Math.max(0,m*m*x-b*b)),_=(b*v-g*w)/x,S=(-b*g-v*w)/x,M=(b*v+g*w)/x,k=(-b*g+v*w)/x,E=_-y,A=S-d,L=M-y,N=k-d;return E*E+A*A>L*L+N*N&&(_=M,S=k),[[_-u,S-c],[_*e/m,S*e/m]]}function Ka(t){var n=ai,e=si,r=$e,i=$a,o=i.key,a=.7;function s(o){var s,u=[],c=[],l=-1,h=o.length,f=mn(n),p=mn(e);function y(){u.push("M",i(t(c),a))}for(;++l1&&i.push("H",r[0]);return i.join("")},"step-before":Qa,"step-after":ts,basis:rs,"basis-open":function(t){if(t.length<4)return $a(t);var n,e=[],r=-1,i=t.length,o=[0],a=[0];for(;++r<3;)n=t[r],o.push(n[0]),a.push(n[1]);e.push(is(ss,o)+","+is(ss,a)),--r;for(;++r9&&(i=3*n/Math.sqrt(i),a[s]=i*e,a[s+1]=i*r));s=-1;for(;++s<=u;)i=(t[Math.min(u,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+a[s]*a[s])),o.push([i||0,a[s]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function Ja(t){return t.join("L")+"Z"}function Qa(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n1){s=n[1],o=t[u],u++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-s[0])+","+(o[1]-s[1])+","+o[0]+","+o[1];for(var c=2;cCt)+",1 "+n}function u(t,n,e,r){return"Q 0,0 "+r}return o.radius=function(t){return arguments.length?(e=mn(t),o):e},o.source=function(n){return arguments.length?(t=mn(n),o):t},o.target=function(t){return arguments.length?(n=mn(t),o):n},o.startAngle=function(t){return arguments.length?(r=mn(t),o):r},o.endAngle=function(t){return arguments.length?(i=mn(t),o):i},o},o.svg.diagonal=function(){var t=Xr,n=Zr,e=ps;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),s=(o.y+a.y)/2,u=[o,{x:o.x,y:s},{x:a.x,y:s},a];return"M"+(u=u.map(e))[0]+"C"+u[1]+" "+u[2]+" "+u[3]}return r.source=function(n){return arguments.length?(t=mn(n),r):t},r.target=function(t){return arguments.length?(n=mn(t),r):n},r.projection=function(t){return arguments.length?(e=t,r):e},r},o.svg.diagonal.radial=function(){var t=o.svg.diagonal(),n=ps,e=t.projection;return t.projection=function(t){return arguments.length?e(ys(n=t)):n},t},o.svg.symbol=function(){var t=gs,n=ds;function e(e,r){return(xs.get(t.call(this,e,r))||vs)(n.call(this,e,r))}return e.type=function(n){return arguments.length?(t=mn(n),e):t},e.size=function(t){return arguments.length?(n=mn(t),e):n},e};var xs=o.map({circle:vs,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*bs)),e=n*bs;return"M0,"+-n+"L"+e+",0 0,"+n+" "+-e+",0Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/ms),e=n*ms/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/ms),e=n*ms/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});o.svg.symbolTypes=xs.keys();var ms=Math.sqrt(3),bs=Math.tan(30*zt);W.transition=function(t){for(var n,e,r=Ms||++As,i=Cs(t),o=[],a=ks||{time:Date.now(),ease:po,delay:0,duration:250},s=-1,u=this.length;++s0;)c[--f].call(t,a);if(o>=1)return h.event&&h.event.end.call(t,t.__data__,n),--l.count?delete l[r]:delete t[e],1}h||(o=i.time,a=An((function(t){var n=h.delay;if(a.t=n+o,n<=t)return f(t-n);a.c=f}),0,o),h=l[r]={tween:new k,time:o,timer:a,delay:i.delay,duration:i.duration,ease:i.ease,index:n},i=null,++l.count)}Es.call=W.call,Es.empty=W.empty,Es.node=W.node,Es.size=W.size,o.transition=function(t,n){return t&&t.transition?Ms?t.transition(n):t:o.selection().transition(t)},o.transition.prototype=Es,Es.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=$(t);for(var s=-1,u=this.length;++srect,.s>rect").attr("width",a[1]-a[0])}function d(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function g(){var h,g,v=this,x=o.select(o.event.target),m=e.of(v,arguments),b=o.select(v),w=x.datum(),_=!/^(n|s)$/.test(w)&&r,S=!/^(e|w)$/.test(w)&&i,M=x.classed("extent"),k=Mt(v),E=o.mouse(v),A=o.select(l(v)).on("keydown.brush",C).on("keyup.brush",P);if(o.event.changedTouches?A.on("touchmove.brush",T).on("touchend.brush",z):A.on("mousemove.brush",T).on("mouseup.brush",z),b.interrupt().selectAll("*").interrupt(),M)E[0]=a[0]-E[0],E[1]=s[0]-E[1];else if(w){var L=+/w$/.test(w),N=+/^n/.test(w);g=[a[1-L]-E[0],s[1-N]-E[1]],E[0]=a[L],E[1]=s[N]}else o.event.altKey&&(h=E.slice());function C(){32==o.event.keyCode&&(M||(h=null,E[0]-=a[1],E[1]-=s[1],M=2),V())}function P(){32==o.event.keyCode&&2==M&&(E[0]+=a[1],E[1]+=s[1],M=0,V())}function T(){var t=o.mouse(v),n=!1;g&&(t[0]+=g[0],t[1]+=g[1]),M||(o.event.altKey?(h||(h=[(a[0]+a[1])/2,(s[0]+s[1])/2]),E[0]=a[+(t[0]1?{floor:function(n){for(;s(n=t.floor(n));)n=Fs(n-1);return n},ceil:function(n){for(;s(n=t.ceil(n));)n=Fs(+n+1);return n}}:t))},r.ticks=function(t,n){var e=ma(r.domain()),o=null==t?i(e,10):"number"==typeof t?i(e,t):!t.range&&[{range:t},n];return o&&(t=o[0],n=o[1]),t.range(e[0],Fs(+e[1]+1),n<1?1:n)},r.tickFormat=function(){return e},r.copy=function(){return Bs(t.copy(),n,e)},Ea(r,t)}function Fs(t){return new Date(t)}Rs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Vs:Gs,Vs.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Vs.toString=Gs.toString,qn.second=Vn((function(t){return new Rn(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),qn.seconds=qn.second.range,qn.seconds.utc=qn.second.utc.range,qn.minute=Vn((function(t){return new Rn(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),qn.minutes=qn.minute.range,qn.minutes.utc=qn.minute.utc.range,qn.hour=Vn((function(t){var n=t.getTimezoneOffset()/60;return new Rn(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),qn.hours=qn.hour.range,qn.hours.utc=qn.hour.utc.range,qn.month=Vn((function(t){return(t=qn.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),qn.months=qn.month.range,qn.months.utc=qn.month.utc.range;var Hs=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Us=[[qn.second,1],[qn.second,5],[qn.second,15],[qn.second,30],[qn.minute,1],[qn.minute,5],[qn.minute,15],[qn.minute,30],[qn.hour,1],[qn.hour,3],[qn.hour,6],[qn.hour,12],[qn.day,1],[qn.day,2],[qn.week,1],[qn.month,1],[qn.month,3],[qn.year,1]],Xs=Rs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",$e]]),Zs={range:function(t,n,e){return o.range(Math.ceil(t/e)*e,+n,e).map(Fs)},floor:z,ceil:z};Us.year=qn.year,qn.scale=function(){return Bs(o.scale.linear(),Us,Xs)};var Ys=Us.map((function(t){return[t[0].utc,t[1]]})),Ks=js.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",$e]]);function Ws(t){return JSON.parse(t.responseText)}function $s(t){var n=u.createRange();return n.selectNode(u.body),n.createContextualFragment(t.responseText)}Ys.year=qn.year.utc,qn.scale.utc=function(){return Bs(o.scale.linear(),Ys,Ks)},o.text=bn((function(t){return t.responseText})),o.json=function(t,n){return wn(t,"application/json",Ws,n)},o.html=function(t,n){return wn(t,"text/html",$s,n)},o.xml=bn((function(t){return t.responseXML})),this.d3=o,void 0===(i="function"==typeof(r=o)?r.call(n,e,n,t):r)||(t.exports=i)}()},function(t,n){function e(t,n){this.x=t||0,this.y=n||0,Object.freeze(this)}e.prototype.distance=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},e.prototype.manhattanDistance=function(t){var n=this.sub(t).abs();return n.x+n.y},e.prototype.abs=function(){return new e(Math.abs(this.x),Math.abs(this.y))},e.prototype.equals=function(t){return this.x===t.x&&this.y===t.y},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.sub=function(t){return new e(this.x-t.x,this.y-t.y)},t.exports=e},function(t,n,e){var r=e(1);function i(t){arguments.length>0&&this.init(t)}i.prototype.init=function(t){this.status=t,this.points=new Array},i.prototype.appendPoint=function(t){this.points.push(t)},i.prototype.appendPoints=function(t){this.points=this.points.concat(t)},i.intersectShapes=function(t,n){var e,r=t.getIntersectionParams(),o=n.getIntersectionParams();if(null!=r&&null!=o)if("Path"==r.name)e=i.intersectPathShape(t,n);else if("Path"==o.name)e=i.intersectPathShape(n,t);else{var a,s;if(r.name0&&N.length>0){t:for(var C=0;C0&&(v.status="Intersection"),v},i.intersectBezier2Bezier3=function(t,n,e,o,a,s,u){var c,l,h,f,p,y,d,g,v,x,m,b=new i("No Intersection");c=n.multiply(-2),p=t.add(c.add(e)),c=t.multiply(-2),l=n.multiply(2),y=c.add(l),d=new r(t.x,t.y),c=o.multiply(-1),l=a.multiply(3),h=s.multiply(-3),f=c.add(l.add(h.add(u))),g=new Vector2D(f.x,f.y),c=o.multiply(3),l=a.multiply(-6),h=s.multiply(3),f=c.add(l.add(h)),v=new Vector2D(f.x,f.y),c=o.multiply(-3),l=a.multiply(3),h=c.add(l),x=new Vector2D(h.x,h.y),m=new Vector2D(o.x,o.y);for(var w=d.x*d.x,_=d.y*d.y,S=y.x*y.x,M=y.y*y.y,k=p.x*p.x,E=p.y*p.y,A=m.x*m.x,L=m.y*m.y,N=x.x*x.x,C=x.y*x.y,P=v.x*v.x,T=v.y*v.y,I=g.x*g.x,z=g.y*g.y,D=new Polynomial(-2*p.x*p.y*g.x*g.y+k*z+E*I,-2*p.x*p.y*v.x*g.y-2*p.x*p.y*v.y*g.x+2*E*v.x*g.x+2*k*v.y*g.y,-2*p.x*x.x*p.y*g.y-2*p.x*p.y*x.y*g.x-2*p.x*p.y*v.x*v.y+2*x.x*E*g.x+E*P+k*(2*x.y*g.y+T),2*d.x*p.x*p.y*g.y+2*d.y*p.x*p.y*g.x+y.x*y.y*p.x*g.y+y.x*y.y*p.y*g.x-2*m.x*p.x*p.y*g.y-2*p.x*m.y*p.y*g.x-2*p.x*x.x*p.y*v.y-2*p.x*p.y*x.y*v.x-2*d.x*E*g.x-2*d.y*k*g.y+2*m.x*E*g.x+2*x.x*E*v.x-M*p.x*g.x-S*p.y*g.y+k*(2*m.y*g.y+2*x.y*v.y),2*d.x*p.x*p.y*v.y+2*d.y*p.x*p.y*v.x+y.x*y.y*p.x*v.y+y.x*y.y*p.y*v.x-2*m.x*p.x*p.y*v.y-2*p.x*m.y*p.y*v.x-2*p.x*x.x*p.y*x.y-2*d.x*E*v.x-2*d.y*k*v.y+2*m.x*E*v.x-M*p.x*v.x-S*p.y*v.y+N*E+k*(2*m.y*v.y+C),2*d.x*p.x*p.y*x.y+2*d.y*p.x*x.x*p.y+y.x*y.y*p.x*x.y+y.x*y.y*x.x*p.y-2*m.x*p.x*p.y*x.y-2*p.x*m.y*x.x*p.y-2*d.x*x.x*E-2*d.y*k*x.y+2*m.x*x.x*E-M*p.x*x.x-S*p.y*x.y+2*k*m.y*x.y,-2*d.x*d.y*p.x*p.y-d.x*y.x*y.y*p.y-d.y*y.x*y.y*p.x+2*d.x*p.x*m.y*p.y+2*d.y*m.x*p.x*p.y+y.x*m.x*y.y*p.y+y.x*y.y*p.x*m.y-2*m.x*p.x*m.y*p.y-2*d.x*m.x*E+d.x*M*p.x+d.y*S*p.y-2*d.y*k*m.y-m.x*M*p.x-S*m.y*p.y+w*E+_*k+A*E+k*L).getRootsInInterval(0,1),O=0;O0&&j.length>0){t:for(var G=0;G0&&(b.status="Intersection"),b},i.intersectBezier2Circle=function(t,n,e,r,o){return i.intersectBezier2Ellipse(t,n,e,r,o,o)},i.intersectBezier2Ellipse=function(t,n,e,o,a,s){var u,c,l,h,f,p=new i("No Intersection");u=n.multiply(-2),l=t.add(u.add(e)),u=t.multiply(-2),c=n.multiply(2),h=u.add(c),f=new r(t.x,t.y);for(var y=a*a,d=s*s,g=new Polynomial(d*l.x*l.x+y*l.y*l.y,2*(d*l.x*h.x+y*l.y*h.y),d*(2*l.x*f.x+h.x*h.x)+y*(2*l.y*f.y+h.y*h.y)-2*(d*o.x*l.x+y*o.y*l.y),2*(d*h.x*(f.x-o.x)+y*h.y*(f.y-o.y)),d*(f.x*f.x+o.x*o.x)+y*(f.y*f.y+o.y*o.y)-2*(d*o.x*f.x+y*o.y*f.y)-y*d).getRoots(),v=0;v0&&(p.status="Intersection"),p},i.intersectBezier2Line=function(t,n,e,o,a){var s,u,c,l,h,f,p,y=o.min(a),d=o.max(a),g=new i("No Intersection");s=n.multiply(-2),c=t.add(s.add(e)),s=t.multiply(-2),u=n.multiply(2),l=s.add(u),h=new r(t.x,t.y),p=new Vector2D(o.y-a.y,a.x-o.x),f=o.x*a.y-a.x*o.y,roots=new Polynomial(p.dot(c),p.dot(l),p.dot(h)+f).getRoots();for(var v=0;v0&&(o.status="Intersection"),o},i.intersectBezier2Rectangle=function(t,n,e,o,a){var s=o.min(a),u=o.max(a),c=new r(u.x,s.y),l=new r(s.x,u.y),h=i.intersectBezier2Line(t,n,e,s,c),f=i.intersectBezier2Line(t,n,e,c,u),p=i.intersectBezier2Line(t,n,e,u,l),y=i.intersectBezier2Line(t,n,e,l,s),d=new i("No Intersection");return d.appendPoints(h.points),d.appendPoints(f.points),d.appendPoints(p.points),d.appendPoints(y.points),d.points.length>0&&(d.status="Intersection"),d},i.intersectBezier3Bezier3=function(t,n,e,r,o,a,s,u){var c,l,h,f,p,y,d,g,v,x,m,b,w=new i("No Intersection");c=t.multiply(-1),l=n.multiply(3),h=e.multiply(-3),f=c.add(l.add(h.add(r))),p=new Vector2D(f.x,f.y),c=t.multiply(3),l=n.multiply(-6),h=e.multiply(3),f=c.add(l.add(h)),y=new Vector2D(f.x,f.y),c=t.multiply(-3),l=n.multiply(3),h=c.add(l),d=new Vector2D(h.x,h.y),g=new Vector2D(t.x,t.y),c=o.multiply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.y*p.y-2*g.y*E*d.y*p.x*p.y-g.y*E*y.x*y.y*p.y-2*g.y*C*b.y*y.y*p.x-2*d.x*b.x*L*p.x*p.y-d.x*d.y*C*b.y*p.y+3*b.x*d.y*b.y*y.y*z-2*b.x*y.x*b.y*T*p.x-b.x*L*y.x*y.y*p.x+3*M*d.x*y.x*p.x*p.y+3*d.x*y.x*G*p.x*p.y+2*b.x*C*b.y*y.y*p.y-3*_*d.y*y.y*p.x*p.y+2*E*d.y*b.y*p.x*p.y+E*y.x*b.y*y.y*p.y-3*R*d.y*y.y*p.x*p.y-S*q+k*D+j*q-V*D-3*g.x*R*q-g.x*N*z+3*_*b.x*q+g.y*A*O+3*g.y*G*D+b.x*N*z+_*I*p.x-3*M*b.y*D-M*P*p.y+R*I*p.x-A*b.y*O-P*G*p.y-g.x*E*d.y*O+g.y*d.x*L*z-3*g.x*M*z*p.y-g.x*L*C*p.y+g.y*E*T*p.x-d.x*L*b.y*z+3*_*g.y*p.x*O+_*d.x*y.y*O+2*_*d.y*y.x*O-2*M*d.x*y.y*z-M*d.y*y.x*z+E*b.x*d.y*O-3*g.x*G*z*p.y+3*g.y*R*p.x*O+d.x*R*y.y*O-2*d.x*G*y.y*z+b.x*L*C*p.y-d.y*y.x*G*z-_*y.x*T*p.y-3*_*b.y*p.x*O+3*M*b.x*z*p.y+M*C*y.y*p.x-E*b.y*T*p.x+2*R*d.y*y.x*O+3*b.x*G*z*p.y-R*y.x*T*p.y-3*R*b.y*p.x*O+C*G*y.y*p.x).getRootsInInterval(0,1),Q=0;Q0&&et.length>0){t:for(var rt=0;rt0&&(w.status="Intersection"),w},i.intersectBezier3Circle=function(t,n,e,r,o,a){return i.intersectBezier3Ellipse(t,n,e,r,o,a,a)},i.intersectBezier3Ellipse=function(t,n,e,r,o,a,s){var u,c,l,h,f,p,y,d,g=new i("No Intersection");u=t.multiply(-1),c=n.multiply(3),l=e.multiply(-3),h=u.add(c.add(l.add(r))),f=new Vector2D(h.x,h.y),u=t.multiply(3),c=n.multiply(-6),l=e.multiply(3),h=u.add(c.add(l)),p=new Vector2D(h.x,h.y),u=t.multiply(-3),c=n.multiply(3),l=u.add(c),y=new Vector2D(l.x,l.y),d=new Vector2D(t.x,t.y);for(var v=a*a,x=s*s,m=new Polynomial(f.x*f.x*x+f.y*f.y*v,2*(f.x*p.x*x+f.y*p.y*v),2*(f.x*y.x*x+f.y*y.y*v)+p.x*p.x*x+p.y*p.y*v,2*f.x*x*(d.x-o.x)+2*f.y*v*(d.y-o.y)+2*(p.x*y.x*x+p.y*y.y*v),2*p.x*x*(d.x-o.x)+2*p.y*v*(d.y-o.y)+y.x*y.x*x+y.y*y.y*v,2*y.x*x*(d.x-o.x)+2*y.y*v*(d.y-o.y),d.x*d.x*x-2*d.y*o.y*v-2*d.x*o.x*x+d.y*d.y*v+o.x*o.x*x+o.y*o.y*v-v*x).getRootsInInterval(0,1),b=0;b0&&(g.status="Intersection"),g},i.intersectBezier3Line=function(t,n,e,r,o,a){var s,u,c,l,h,f,p,y,d,g,v=o.min(a),x=o.max(a),m=new i("No Intersection");s=t.multiply(-1),u=n.multiply(3),c=e.multiply(-3),l=s.add(u.add(c.add(r))),h=new Vector2D(l.x,l.y),s=t.multiply(3),u=n.multiply(-6),c=e.multiply(3),l=s.add(u.add(c)),f=new Vector2D(l.x,l.y),s=t.multiply(-3),u=n.multiply(3),c=s.add(u),p=new Vector2D(c.x,c.y),y=new Vector2D(t.x,t.y),g=new Vector2D(o.y-a.y,a.x-o.x),d=o.x*a.y-a.x*o.y,roots=new Polynomial(g.dot(h),g.dot(f),g.dot(p),g.dot(y)+d).getRoots();for(var b=0;b0&&(a.status="Intersection"),a},i.intersectBezier3Rectangle=function(t,n,e,o,a,s){var u=a.min(s),c=a.max(s),l=new r(c.x,u.y),h=new r(u.x,c.y),f=i.intersectBezier3Line(t,n,e,o,u,l),p=i.intersectBezier3Line(t,n,e,o,l,c),y=i.intersectBezier3Line(t,n,e,o,c,h),d=i.intersectBezier3Line(t,n,e,o,h,u),g=new i("No Intersection");return g.appendPoints(f.points),g.appendPoints(p.points),g.appendPoints(y.points),g.appendPoints(d.points),g.points.length>0&&(g.status="Intersection"),g},i.intersectCircleCircle=function(t,n,e,o){var a,s=n+o,u=Math.abs(n-o),c=t.distanceFrom(e);if(c>s)a=new i("Outside");else if(c1)&&(h<0||h>1)?o=new i(l<0&&h<0||l>1&&h>1?"Outside":"Inside"):(o=new i("Intersection"),0<=l&&l<=1&&o.points.push(e.lerp(r,l)),0<=h&&h<=1&&o.points.push(e.lerp(r,h)))}return o},i.intersectCirclePolygon=function(t,n,e){for(var r,o=new i("No Intersection"),a=e.length,s=0;s0?o.status="Intersection":o.status=r.status,o},i.intersectCircleRectangle=function(t,n,e,o){var a=e.min(o),s=e.max(o),u=new r(s.x,a.y),c=new r(a.x,s.y),l=i.intersectCircleLine(t,n,a,u),h=i.intersectCircleLine(t,n,u,s),f=i.intersectCircleLine(t,n,s,c),p=i.intersectCircleLine(t,n,c,a),y=new i("No Intersection");return y.appendPoints(l.points),y.appendPoints(h.points),y.appendPoints(f.points),y.appendPoints(p.points),y.points.length>0?y.status="Intersection":y.status=l.status,y},i.intersectEllipseEllipse=function(t,n,e,o,a,s){for(var u=[e*e,0,n*n,-2*e*e*t.x,-2*n*n*t.y,e*e*t.x*t.x+n*n*t.y*t.y-n*n*e*e],c=[s*s,0,a*a,-2*s*s*o.x,-2*a*a*o.y,s*s*o.x*o.x+a*a*o.y*o.y-a*a*s*s],l=i.bezout(u,c).getRoots(),h=.001*(u[0]*u[0]+2*u[1]*u[1]+u[2]*u[2]),f=.001*(c[0]*c[0]+2*c[1]*c[1]+c[2]*c[2]),p=new i("No Intersection"),y=0;y0&&(p.status="Intersection"),p},i.intersectEllipseLine=function(t,n,e,r,o){var a,s=new Vector2D(r.x,r.y),u=Vector2D.fromPoints(r,o),c=new Vector2D(t.x,t.y),l=s.subtract(c),h=new Vector2D(u.x/(n*n),u.y/(e*e)),f=new Vector2D(l.x/(n*n),l.y/(e*e)),p=u.dot(h),y=u.dot(f),d=y*y-p*(t=l.dot(f)-1);if(d<0)a=new i("Outside");else if(d>0){var g=Math.sqrt(d),v=(-y-g)/p,x=(-y+g)/p;(v<0||11&&x>1?"Outside":"Inside"):(a=new i("Intersection"),0<=v&&v<=1&&a.appendPoint(r.lerp(o,v)),0<=x&&x<=1&&a.appendPoint(r.lerp(o,x)))}else{var m=-y/p;0<=m&&m<=1?(a=new i("Intersection")).appendPoint(r.lerp(o,m)):a=new i("Outside")}return a},i.intersectEllipsePolygon=function(t,n,e,r){for(var o=new i("No Intersection"),a=r.length,s=0;s0&&(o.status="Intersection"),o},i.intersectEllipseRectangle=function(t,n,e,o,a){var s=o.min(a),u=o.max(a),c=new r(u.x,s.y),l=new r(s.x,u.y),h=i.intersectEllipseLine(t,n,e,s,c),f=i.intersectEllipseLine(t,n,e,c,u),p=i.intersectEllipseLine(t,n,e,u,l),y=i.intersectEllipseLine(t,n,e,l,s),d=new i("No Intersection");return d.appendPoints(h.points),d.appendPoints(f.points),d.appendPoints(p.points),d.appendPoints(y.points),d.points.length>0&&(d.status="Intersection"),d},i.intersectLineLine=function(t,n,e,o){var a,s=(o.x-e.x)*(t.y-e.y)-(o.y-e.y)*(t.x-e.x),u=(n.x-t.x)*(t.y-e.y)-(n.y-t.y)*(t.x-e.x),c=(o.y-e.y)*(n.x-t.x)-(o.x-e.x)*(n.y-t.y);if(0!=c){var l=s/c,h=u/c;0<=l&&l<=1&&0<=h&&h<=1?(a=new i("Intersection")).points.push(new r(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y))):a=new i("No Intersection")}else a=new i(0==s||0==u?"Coincident":"Parallel");return a},i.intersectLinePolygon=function(t,n,e){for(var r=new i("No Intersection"),o=e.length,a=0;a0&&(r.status="Intersection"),r},i.intersectLineRectangle=function(t,n,e,o){var a=e.min(o),s=e.max(o),u=new r(s.x,a.y),c=new r(a.x,s.y),l=i.intersectLineLine(a,u,t,n),h=i.intersectLineLine(u,s,t,n),f=i.intersectLineLine(s,c,t,n),p=i.intersectLineLine(c,a,t,n),y=new i("No Intersection");return y.appendPoints(l.points),y.appendPoints(h.points),y.appendPoints(f.points),y.appendPoints(p.points),y.points.length>0&&(y.status="Intersection"),y},i.intersectPolygonPolygon=function(t,n){for(var e=new i("No Intersection"),r=t.length,o=0;o0&&(e.status="Intersection"),e},i.intersectPolygonRectangle=function(t,n,e){var o=n.min(e),a=n.max(e),s=new r(a.x,o.y),u=new r(o.x,a.y),c=i.intersectLinePolygon(o,s,t),l=i.intersectLinePolygon(s,a,t),h=i.intersectLinePolygon(a,u,t),f=i.intersectLinePolygon(u,o,t),p=new i("No Intersection");return p.appendPoints(c.points),p.appendPoints(l.points),p.appendPoints(h.points),p.appendPoints(f.points),p.points.length>0&&(p.status="Intersection"),p},i.intersectRayRay=function(t,n,e,o){var a,s=(o.x-e.x)*(t.y-e.y)-(o.y-e.y)*(t.x-e.x),u=(n.x-t.x)*(t.y-e.y)-(n.y-t.y)*(t.x-e.x),c=(o.y-e.y)*(n.x-t.x)-(o.x-e.x)*(n.y-t.y);if(0!=c){var l=s/c;(a=new i("Intersection")).points.push(new r(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y)))}else a=new i(0==s||0==u?"Coincident":"Parallel");return a},i.intersectRectangleRectangle=function(t,n,e,o){var a=t.min(n),s=t.max(n),u=new r(s.x,a.y),c=new r(a.x,s.y),l=i.intersectLineRectangle(a,u,e,o),h=i.intersectLineRectangle(u,s,e,o),f=i.intersectLineRectangle(s,c,e,o),p=i.intersectLineRectangle(c,a,e,o),y=new i("No Intersection");return y.appendPoints(l.points),y.appendPoints(h.points),y.appendPoints(f.points),y.appendPoints(p.points),y.points.length>0&&(y.status="Intersection"),y},i.bezout=function(t,n){var e=t[0]*n[1]-n[0]*t[1],r=t[0]*n[2]-n[0]*t[2],i=t[0]*n[3]-n[0]*t[3],o=t[0]*n[4]-n[0]*t[4],a=t[0]*n[5]-n[0]*t[5],s=t[1]*n[2]-n[1]*t[2],u=t[1]*n[4]-n[1]*t[4],c=t[1]*n[5]-n[1]*t[5],l=t[2]*n[3]-n[2]*t[3],h=t[3]*n[4]-n[3]*t[4],f=t[3]*n[5]-n[3]*t[5],p=c+h,y=u-l;return new Polynomial(e*s-r*r,e*y+i*s-2*r*o,e*p+i*y-o*o-2*r*a,e*f+i*p-2*o*a,i*f-a*a)},t.exports=i},function(t){t.exports=JSON.parse('{"a":"2.0.3"}')},function(t,n,e){var r,i,o,a;function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}a=function(){return function t(n,e,r){function i(a,s){if(!e[a]){if(!n[a]){if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=e[a]={exports:{}};n[a][0].call(c.exports,(function(t){return i(n[a][1][t]||t)}),c,c.exports,t,n,e,r)}return e[a].exports}for(var o=!1,a=0;as;){var u=n[s][a];u>0&&u1e-9)break;var p=this.offsetDir();for(r=0;r1&&y>d||!isFinite(d))for(r=0;r1&&(g=1);var v=d*d,x=2*g*(y-d)/(v*y),m=h*y,b=2*-g/(v*m);for(isFinite(x)||console.log(x),r=0;r0?E-(N+1)*_:E-(N-1)*_;-w0;)for(var i=n;i-- >0;)e(r,i)},t.prototype.matrixApply=function(n){t.mApply(this.k,this.n,n)},t.prototype.computeNextPosition=function(t,n){var e=this;this.computeDerivatives(t);var r=this.computeStepSize(this.g);if(this.stepAndProject(t,n,this.g,r),this.project){this.matrixApply((function(r,i){return e.e[r][i]=t[r][i]-n[r][i]}));var i=this.computeStepSize(this.e);i=Math.max(.2,Math.min(i,1)),this.stepAndProject(t,n,this.e,i)}},t.prototype.run=function(t){for(var n=Number.MAX_VALUE,e=!1;!e&&t-- >0;){var r=this.rungeKutta();e=Math.abs(n/r-1)>16)/this.range},t.prototype.getNextBetween=function(t,n){return t+this.getNext()*(n-t)},t}();e.PseudoRandom=o},{}],8:[function(t,n,e){"use strict";var r,i=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});Object.defineProperty(e,"__esModule",{value:!0});var o=t("./rectangle"),a=function(){};e.Point=a;var s=function(t,n,e,r){this.x1=t,this.y1=n,this.x2=e,this.y2=r};e.LineSegment=s;var u=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n}(a);function c(t,n,e){return(n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y)}function l(t,n,e){return c(t,n,e)>0}function h(t,n,e){return c(t,n,e)<0}function f(t,n){var e,r,i,o,a=n.length-1;if(h(t,n[1],n[0])&&!l(t,n[a-1],n[0]))return 0;for(e=0,r=a;;){if(r-e==1)return l(t,n[e],n[r])?e:r;if((o=h(t,n[(i=Math.floor((e+r)/2))+1],n[i]))&&!l(t,n[i-1],n[i]))return i;l(t,n[e+1],n[e])?o||l(t,n[e],n[i])?r=i:e=i:o&&h(t,n[e],n[i])?r=i:e=i}}function p(t,n){var e,r,i,o,a=n.length-1;if(l(t,n[a-1],n[0])&&!h(t,n[1],n[0]))return 0;for(e=0,r=a;;){if(r-e==1)return h(t,n[e],n[r])?e:r;if(o=h(t,n[(i=Math.floor((e+r)/2))+1],n[i]),l(t,n[i-1],n[i])&&!o)return i;h(t,n[e+1],n[e])?o?h(t,n[e],n[i])?r=i:e=i:r=i:o?e=i:l(t,n[e],n[i])?r=i:e=i}}function y(t,n,e,r,i,o){var a,s;s=r(t[a=e(n[0],t)],n);for(var u=!1;!u;){for(u=!0;a===t.length-1&&(a=0),!i(n[s],t[a],t[a+1]);)++a;for(;0===s&&(s=n.length-1),!o(t[a],n[s],n[s-1]);)--s,u=!1}return{t1:a,t2:s}}function d(t,n){return y(t,n,f,p,l,h)}e.PolyPoint=u,e.isLeft=c,e.ConvexHull=function(t){var n,e=t.slice(0).sort((function(t,n){return t.x!==n.x?n.x-t.x:n.y-t.y})),r=t.length,i=e[0].x;for(n=1;n=0&&e[n].x===l;n--);for(s=n+1,n=o;++n<=s;)if(!(c(e[0],e[s],e[n])>=0&&n1&&!(c(a[a.length-2],a[a.length-1],e[n])>0);)a.length-=1;0!=n&&a.push(e[n])}u!=s&&a.push(e[u]);var h=a.length;for(n=s;--n>=o;)if(!(c(e[u],e[o],e[n])>=0&&n>o)){for(;a.length>h&&!(c(a[a.length-2],a[a.length-1],e[n])>0);)a.length-=1;0!=n&&a.push(e[n])}}return a},e.clockwiseRadialSweep=function(t,n,e){n.slice(0).sort((function(n,e){return Math.atan2(n.y-t.y,n.x-t.x)-Math.atan2(e.y-t.y,e.x-t.x)})).forEach(e)},e.tangent_PolyPolyC=y,e.LRtangent_PolyPolyC=function(t,n){var e=d(n,t);return{t1:e.t2,t2:e.t1}},e.RLtangent_PolyPolyC=d,e.LLtangent_PolyPolyC=function(t,n){return y(t,n,p,p,h,h)},e.RRtangent_PolyPolyC=function(t,n){return y(t,n,f,f,l,l)};var g=function(t,n){this.t1=t,this.t2=n};e.BiTangent=g;var v=function(){};e.BiTangents=v;var x=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n}(a);e.TVGPoint=x;var m=function(t,n,e,r){this.id=t,this.polyid=n,this.polyvertid=e,this.p=r,r.vv=this};e.VisibilityVertex=m;var b=function(){function t(t,n){this.source=t,this.target=n}return t.prototype.length=function(){var t=this.source.p.x-this.target.p.x,n=this.source.p.y-this.target.p.y;return Math.sqrt(t*t+n*n)},t}();e.VisibilityEdge=b;var w=function(){function t(t,n){if(this.P=t,this.V=[],this.E=[],n)this.V=n.V.slice(0),this.E=n.E.slice(0);else{for(var e=t.length,r=0;r0&&this.E.push(new b(i[o-1].vv,s))}i.length>1&&this.E.push(new b(i[0].vv,i[i.length-1].vv))}for(r=0;r0)return!0;return!1},t}();function _(t,n){for(var e=[],r=1,i=n.length;r=0&&d>=0&&x<0&&m>=0&&b>=0&&w<0?i.ll=new g(o,a):y<=0&&d<=0&&x>0&&m<=0&&b<=0&&w>0?i.rr=new g(o,a):y<=0&&d>0&&x<=0&&m>=0&&b<0&&w>=0?i.rl=new g(o,a):y>=0&&d<0&&x>=0&&m<=0&&b>0&&w<=0&&(i.lr=new g(o,a))}return i}function M(t,n){return!t.every((function(t){return!function(t,n){for(var e=1,r=n.length;e0)return!0}return!1}},{"./rectangle":17}],9:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t("./rectangle"),i=t("./vpsc"),o=t("./shortestpaths"),a=function(t,n,e){this.id=t,this.rect=n,this.children=e,this.leaf=void 0===e||0===e.length};e.NodeWrapper=a;var s=function(t,n,e,r,i){void 0===r&&(r=null),void 0===i&&(i=null),this.id=t,this.x=n,this.y=e,this.node=r,this.line=i};e.Vert=s;var u=function(){function t(n,e){this.s=n,this.t=e;var r=t.findMatch(n,e),i=e.slice(0).reverse(),o=t.findMatch(n,i);r.length>=o.length?(this.length=r.length,this.si=r.si,this.ti=r.ti,this.reversed=!1):(this.length=o.length,this.si=o.si,this.ti=e.length-o.ti-o.length,this.reversed=!0)}return t.findMatch=function(t,n){for(var e=t.length,r=n.length,i={length:0,si:-1,ti:-1},o=new Array(e),a=0;ai.length&&(i.length=u,i.si=a-u+1,i.ti=s-u+1)}else o[a][s]=0}return i},t.prototype.getSequence=function(){return this.length>=0?this.s.slice(this.si,this.si+this.length):[]},t}();e.LongestCommonSubsequence=u;var c=function(){function t(t,n,e){var i=this;void 0===e&&(e=12),this.originalnodes=t,this.groupPadding=e,this.leaves=null,this.nodes=t.map((function(t,e){return new a(e,n.getBounds(t),n.getChildren(t))})),this.leaves=this.nodes.filter((function(t){return t.leaf})),this.groups=this.nodes.filter((function(t){return!t.leaf})),this.cols=this.getGridLines("x"),this.rows=this.getGridLines("y"),this.groups.forEach((function(t){return t.children.forEach((function(n){return i.nodes[n].parent=t}))})),this.root={children:[]},this.nodes.forEach((function(t){void 0===t.parent&&(t.parent=i.root,i.root.children.push(t.id)),t.ports=[]})),this.backToFront=this.nodes.slice(0),this.backToFront.sort((function(t,n){return i.getDepth(t)-i.getDepth(n)})),this.backToFront.slice(0).reverse().filter((function(t){return!t.leaf})).forEach((function(t){var n=r.Rectangle.empty();t.children.forEach((function(t){return n=n.union(i.nodes[t].rect)})),t.rect=n.inflate(i.groupPadding)}));var o=this.midPoints(this.cols.map((function(t){return t.pos}))),u=this.midPoints(this.rows.map((function(t){return t.pos}))),c=o[0],l=o[o.length-1],h=u[0],f=u[u.length-1],p=this.rows.map((function(t){return{x1:c,x2:l,y1:t.pos,y2:t.pos}})).concat(u.map((function(t){return{x1:c,x2:l,y1:t,y2:t}}))),y=this.cols.map((function(t){return{x1:t.pos,x2:t.pos,y1:h,y2:f}})).concat(o.map((function(t){return{x1:t,x2:t,y1:h,y2:f}}))),d=p.concat(y);d.forEach((function(t){return t.verts=[]})),this.verts=[],this.edges=[],p.forEach((function(t){return y.forEach((function(n){var e=new s(i.verts.length,n.x1,t.y1);t.verts.push(e),n.verts.push(e),i.verts.push(e);for(var r=i.backToFront.length;r-- >0;){var o=i.backToFront[r],a=o.rect,u=Math.abs(e.x-a.cx()),c=Math.abs(e.y-a.cy());if(u0;){var r=e.filter((function(n){return n.rect["overlap"+t.toUpperCase()](e[0].rect)})),i={nodes:r,pos:this.avg(r.map((function(n){return n.rect["c"+t]()})))};n.push(i),i.nodes.forEach((function(t){return e.splice(e.indexOf(t),1)}))}return n.sort((function(t,n){return t.pos-n.pos})),n},t.prototype.getDepth=function(t){for(var n=0;t.parent!==this.root;)n++,t=t.parent;return n},t.prototype.midPoints=function(t){for(var n=t[1]-t[0],e=[t[0]-n/2],r=1;r.1)&&(c={pos:h[0][n],segments:[]},u.push(c)),c.segments.push(h)}return u},t.nudgeSegs=function(t,n,e,r,o,a){var s=r.length;if(!(s<=1)){for(var u=r.map((function(n){return new i.Variable(n[0][t])})),c=[],l=0;l=0&&c.push(new i.Constraint(u[g],u[v],a))}new i.Solver(u,c).solve(),u.forEach((function(n,i){var o=r[i],a=n.position();o[0][t]=o[1][t]=a;var s=e[o.edgeid];o.i>0&&(s[o.i-1][1][t]=a),o.iMath.PI||i<-Math.PI)&&(i=r-e),i},t.isLeft=function(t,n,e){return(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x)<=0},t.getOrder=function(t){for(var n={},e=0;e=c.length||h.ti+h.length>=l.length)?e.push({l:r,r:i}):(h.si+h.length>=c.length||h.ti+h.length>=l.length?(o=c[h.si+1],s=c[h.si-1],a=l[h.ti-1]):(o=c[h.si+h.length-2],a=c[h.si+h.length],s=l[h.ti+h.length]),t.isLeft(o,a,s)?e.push({l:i,r:r}):e.push({l:r,r:i})))}return t.getOrder(e)},t.makeSegments=function(t){function n(t){return{x:t.x,y:t.y}}for(var e=function(t,n,e){return Math.abs((n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x))<.001},r=[],i=n(t[0]),o=1;o1&&l>1?1e3:0})).reverse().map((function(t){return e.verts[t]}));return l.push(this.nodes[i.id].ports[0]),l.filter((function(t,n){return!(n0&&t.node===i&&l[n-1].node===i)}))},t.getRoutePath=function(n,e,r,i){var o,a,s,u={routepath:"M "+n[0][0].x+" "+n[0][0].y+" ",arrowpath:""};if(n.length>1)for(var c=0;c0?l-=f/Math.abs(f)*e:h-=p/Math.abs(p)*e,u.routepath+="L "+l+" "+h+" ";var y=n[c+1],d=y[0].x,g=y[0].y;f=y[1].x-d,p=y[1].y-g;var v,x,m=t.angleBetween2Lines(o,y)<0?1:0;Math.abs(f)>0?(v=d+f/Math.abs(f)*e,x=g):(v=d,x=g+p/Math.abs(p)*e);var b=Math.abs(v-l),w=Math.abs(x-h);u.routepath+="A "+b+" "+w+" 0 0 "+m+" "+v+" "+x+" "}else{var _=[l,h];Math.abs(f)>0?(a=[l-=f/Math.abs(f)*i,h+r],s=[l,h-r]):(a=[l+r,h-=p/Math.abs(p)*i],s=[l-r,h]),u.routepath+="L "+l+" "+h+" ",i>0&&(u.arrowpath="M "+_[0]+" "+_[1]+" L "+a[0]+" "+a[1]+" L "+s[0]+" "+s[1])}}else l=(o=n[0])[1].x,h=o[1].y,f=l-o[0].x,p=h-o[0].y,_=[l,h],Math.abs(f)>0?(a=[l-=f/Math.abs(f)*i,h+r],s=[l,h-r]):(a=[l+r,h-=p/Math.abs(p)*i],s=[l-r,h]),u.routepath+="L "+l+" "+h+" ",i>0&&(u.arrowpath="M "+_[0]+" "+_[1]+" L "+a[0]+" "+a[1]+" L "+s[0]+" "+s[1]);return u},t}();e.GridRouter=c},{"./rectangle":17,"./shortestpaths":18,"./vpsc":19}],10:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=10,i=(1+Math.sqrt(5))/2,o=1e-4;e.applyPacking=function(t,n,e,a,s,u){void 0===s&&(s=1),void 0===u&&(u=!0);var c=n,l=e,h=(s=void 0!==s?s:1,a=void 0!==a?a:0,0),f=0,p=0,y=0,d=[];function g(t,n){d=[],h=0,f=0,y=0;for(var e=0;e=t.height&&d[i].x+d[i].width+t.width+r-n<=o){e=d[i];break}d.push(t),void 0!==e?(t.x=e.x+e.width+r,t.y=e.bottom,t.space_left=t.height,t.bottom=t.y,e.space_left-=t.height+r,e.bottom+=t.height+r):(t.y=y,y+=t.height+r,t.x=0,t.bottom=t.y,t.space_left=t.height),t.y+t.height-f>-o&&(f=t.y+t.height-0),t.x+t.width-h>-o&&(h=t.x+t.width-0)}0!=t.length&&(function(t){t.forEach((function(t){var n,e,r,i,o;n=t,e=Number.MAX_VALUE,r=Number.MAX_VALUE,i=0,o=0,n.array.forEach((function(t){var n=void 0!==t.width?t.width:a,s=void 0!==t.height?t.height:a;n/=2,s/=2,i=Math.max(t.x+n,i),e=Math.min(t.x-n,e),o=Math.max(t.y+s,o),r=Math.min(t.y-s,r)})),n.width=i-e,n.height=o-r}))}(t),function(t,n){var e=Number.POSITIVE_INFINITY,a=0;t.sort((function(t,n){return n.height-t.height})),p=t.reduce((function(t,n){return t.widthp||d>o;){if(1!=f){var v=u-(u-s)/i;l=g(t,v)}if(0!=f){var x=s+(u-s)/i;h=g(t,x)}if(y=Math.abs(v-x),d=Math.abs(l-h),lh?(s=v,v=x,l=h,f=1):(u=x,x=v,h=l,f=0),c++>100)break}g(t,a)}(t),u&&function(t){t.forEach((function(t){var n={x:0,y:0};t.array.forEach((function(t){n.x+=t.x,n.y+=t.y})),n.x/=t.array.length,n.y/=t.array.length;var e=n.x-t.width/2,r=n.y-t.height/2,i=t.x-e+c/2-h/2,o=t.y-r+l/2-f/2;t.array.forEach((function(t){t.x+=i,t.y+=o}))}))}(t))},e.separateGraphs=function(t,n){for(var e={},r={},i=[],o=0,a=0;a0){var n=0;this._links.forEach((function(t){n=Math.max(n,t.source,t.target)})),this._nodes=new Array(++n);for(var e=0;e0?t:0:t>0&&(this._running||(this._running=!0,this.trigger({type:r.start,alpha:this._alpha=t}),this.kick())),this):this._alpha},t.prototype.getLinkLength=function(t){return"function"==typeof this._linkDistance?+this._linkDistance(t):this._linkDistance},t.setLinkLength=function(t,n){t.length=n},t.prototype.getLinkType=function(t){return"function"==typeof this._linkType?this._linkType(t):0},t.prototype.symmetricDiffLinkLengths=function(t,n){var e=this;return void 0===n&&(n=1),this.linkDistance((function(n){return t*n.length})),this._linkLengthCalculator=function(){return o.symmetricDiffLinkLengths(e._links,e.linkAccessor,n)},this},t.prototype.jaccardLinkLengths=function(t,n){var e=this;return void 0===n&&(n=1),this.linkDistance((function(n){return t*n.length})),this._linkLengthCalculator=function(){return o.jaccardLinkLengths(e._links,e.linkAccessor,n)},this},t.prototype.start=function(n,e,r,i,c,l){var h=this;void 0===n&&(n=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===c&&(c=!0),void 0===l&&(l=!0);var f,p=this.nodes().length,y=p+2*this._groups.length,d=(this._links.length,this._canvasSize[0]),g=this._canvasSize[1],v=new Array(y),x=new Array(y),m=null,b=this._avoidOverlaps;this._nodes.forEach((function(t,n){t.index=n,void 0===t.x&&(t.x=d/2,t.y=g/2),v[n]=t.x,x[n]=t.y})),this._linkLengthCalculator&&this._linkLengthCalculator(),this._distanceMatrix?f=this._distanceMatrix:(f=new u.Calculator(y,this._links,t.getSourceIndex,t.getTargetIndex,(function(t){return h.getLinkLength(t)})).DistanceMatrix(),m=a.Descent.createSquareMatrix(y,(function(){return 2})),this._links.forEach((function(t){"number"==typeof t.source&&(t.source=h._nodes[t.source]),"number"==typeof t.target&&(t.target=h._nodes[t.target])})),this._links.forEach((function(n){var e=t.getSourceIndex(n),r=t.getTargetIndex(n);m[e][r]=m[r][e]=n.weight||1})));var w=a.Descent.createSquareMatrix(y,(function(t,n){return f[t][n]}));if(this._rootGroup&&void 0!==this._rootGroup.groups){var _=p;this._groups.forEach((function(t){!function(t,n,e,r){m[t][n]=m[n][t]=e,w[t][n]=w[n][t]=r}(_,_+1,h._groupCompactness,.1),void 0===t.bounds?(v[_]=d/2,x[_++]=g/2,v[_]=d/2,x[_++]=g/2):(v[_]=t.bounds.x,x[_++]=t.bounds.y,v[_]=t.bounds.X,x[_++]=t.bounds.Y)}))}else this._rootGroup={leaves:this._nodes,groups:[]};var S=this._constraints||[];for(this._directedLinkConstraints&&(this.linkAccessor.getMinSeparation=this._directedLinkConstraints.getMinSeparation,S=S.concat(o.generateDirectedEdgeConstraints(p,this._links,this._directedLinkConstraints.axis,this.linkAccessor))),this.avoidOverlaps(!1),this._descent=new a.Descent([v,x],w),this._descent.locks.clear(),_=0;_0&&(this._descent.project=new s.Projection(this._nodes,this._groups,this._rootGroup,S).projectFunctions()),this._descent.run(e),this.separateOverlappingComponents(d,g,l),this.avoidOverlaps(b),b&&(this._nodes.forEach((function(t,n){t.x=v[n],t.y=x[n]})),this._descent.project=new s.Projection(this._nodes,this._groups,this._rootGroup,S,!0).projectFunctions(),this._nodes.forEach((function(t,n){v[n]=t.x,x[n]=t.y}))),this._descent.G=m,this._descent.run(r),i){this._descent.snapStrength=1e3,this._descent.snapGridSize=this._nodes[0].width,this._descent.numGridSnapNodes=p,this._descent.scaleSnapByMaxH=p!=y;var E=a.Descent.createSquareMatrix(y,(function(t,n){return t>=p||n>=p?m[t][n]:0}));this._descent.G=E,this._descent.run(i)}return this.updateNodePositions(),this.separateOverlappingComponents(d,g,l),c?this.resume():this},t.prototype.initialLayout=function(n,e,r){if(this._groups.length>0&&n>0){var i=this._nodes.length,o=this._links.map((function(t){return{source:t.source.index,target:t.target.index}})),a=this._nodes.map((function(t){return{index:t.index}}));this._groups.forEach((function(t,n){a.push({index:t.index=i+n})})),this._groups.forEach((function(t,n){void 0!==t.leaves&&t.leaves.forEach((function(n){return o.push({source:t.index,target:n.index})})),void 0!==t.groups&&t.groups.forEach((function(n){return o.push({source:t.index,target:n.index})}))})),(new t).size(this.size()).nodes(a).links(o).avoidOverlaps(!1).linkDistance(this.linkDistance()).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(n,0,0,0,!1),this._nodes.forEach((function(t){e[t.index]=a[t.index].x,r[t.index]=a[t.index].y}))}else this._descent.run(n)},t.prototype.separateOverlappingComponents=function(t,n,e){var r=this;if(void 0===e&&(e=!0),!this._distanceMatrix&&this._handleDisconnected){var i=this._descent.x[0],o=this._descent.x[1];this._nodes.forEach((function(t,n){t.x=i[n],t.y=o[n]}));var a=l.separateGraphs(this._nodes,this._links);l.applyPacking(a,t,n,this._defaultNodeSize,n/t,e),this._nodes.forEach((function(t,n){r._descent.x[0][n]=t.x,r._descent.x[1][n]=t.y,t.bounds&&(t.bounds.setXCentre(t.x),t.bounds.setYCentre(t.y))}))}},t.prototype.resume=function(){return this.alpha(.1)},t.prototype.stop=function(){return this.alpha(0)},t.prototype.prepareEdgeRouting=function(t){void 0===t&&(t=0),this._visibilityGraph=new c.TangentVisibilityGraph(this._nodes.map((function(n){return n.bounds.inflate(-t).vertices()})))},t.prototype.routeEdge=function(t,n,e){void 0===n&&(n=5);var r=[],i=new c.TangentVisibilityGraph(this._visibilityGraph.P,{V:this._visibilityGraph.V,E:this._visibilityGraph.E}),o={x:t.source.x,y:t.source.y},a={x:t.target.x,y:t.target.y},l=i.addPoint(o,t.source.index),h=i.addPoint(a,t.target.index);i.addEdgeIfVisible(o,a,t.source.index,t.target.index),void 0!==e&&e(i);var f=new u.Calculator(i.V.length,i.E,(function(t){return t.source.id}),(function(t){return t.target.id}),(function(t){return t.length()})).PathFromNodeToNode(l.id,h.id);if(1===f.length||f.length===i.V.length){var p=s.makeEdgeBetween(t.source.innerBounds,t.target.innerBounds,n);r=[p.sourceIntersection,p.arrowStart]}else{for(var y=f.length-2,d=i.V[f[y]].p,g=i.V[f[0]].p,v=(r=[t.source.innerBounds.rayIntersection(d.x,d.y)],y);v>=0;--v)r.push(i.V[f[v]].p);r.push(s.makeEdgeTo(g,t.target.innerBounds,n))}return r},t.getSourceIndex=function(t){return"number"==typeof t.source?t.source:t.source.index},t.getTargetIndex=function(t){return"number"==typeof t.target?t.target:t.target.index},t.linkId=function(n){return t.getSourceIndex(n)+"-"+t.getTargetIndex(n)},t.dragStart=function(n){h(n)?t.storeOffset(n,t.dragOrigin(n)):(t.stopNode(n),n.fixed|=2)},t.stopNode=function(t){t.px=t.x,t.py=t.y},t.storeOffset=function(n,e){void 0!==n.leaves&&n.leaves.forEach((function(n){n.fixed|=2,t.stopNode(n),n._dragGroupOffsetX=n.x-e.x,n._dragGroupOffsetY=n.y-e.y})),void 0!==n.groups&&n.groups.forEach((function(n){return t.storeOffset(n,e)}))},t.dragOrigin=function(t){return h(t)?{x:t.bounds.cx(),y:t.bounds.cy()}:t},t.drag=function(n,e){h(n)?(void 0!==n.leaves&&n.leaves.forEach((function(t){n.bounds.setXCentre(e.x),n.bounds.setYCentre(e.y),t.px=t._dragGroupOffsetX+e.x,t.py=t._dragGroupOffsetY+e.y})),void 0!==n.groups&&n.groups.forEach((function(n){return t.drag(n,e)}))):(n.px=e.x,n.py=e.y)},t.dragEnd=function(n){h(n)?(void 0!==n.leaves&&n.leaves.forEach((function(n){t.dragEnd(n),delete n._dragGroupOffsetX,delete n._dragGroupOffsetY})),void 0!==n.groups&&n.groups.forEach(t.dragEnd)):n.fixed&=-7},t.mouseOver=function(t){t.fixed|=4,t.px=t.x,t.py=t.y},t.mouseOut=function(t){t.fixed&=-5},t}();e.Layout=f},{"./descent":7,"./geom":8,"./handledisconnected":10,"./linklengths":13,"./powergraph":14,"./rectangle":17,"./shortestpaths":18}],12:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t("./shortestpaths"),i=t("./descent"),o=t("./rectangle"),a=t("./linklengths"),s=function(){function t(t,n){this.source=t,this.target=n}return t.prototype.actualLength=function(t){var n=this;return Math.sqrt(t.reduce((function(t,e){var r=e[n.target]-e[n.source];return t+r*r}),0))},t}();e.Link3D=s;var u=function(t,n,e){void 0===t&&(t=0),void 0===n&&(n=0),void 0===e&&(e=0),this.x=t,this.y=n,this.z=e};e.Node3D=u;var c=function(){function t(n,e,r){var i=this;void 0===r&&(r=1),this.nodes=n,this.links=e,this.idealLinkLength=r,this.constraints=null,this.useJaccardLinkLengths=!0,this.result=new Array(t.k);for(var o=0;o=this.R))return this.merge(n.a,n.b,t),!0}},t.prototype.nEdges=function(t,n){var e=t.incoming.intersection(n.incoming),r=t.outgoing.intersection(n.outgoing);return this.R-e.count()-r.count()},t.prototype.getGroupHierarchy=function(t){var n=this,e=[];return function t(n,e,r){n.forAll((function(n){if(n.isLeaf())e.leaves||(e.leaves=[]),e.leaves.push(n.id);else{var i=e;if(n.gid=r.length,!n.isIsland()||n.isPredefined()){if(i={id:n.gid},n.isPredefined())for(var o in n.definition)i[o]=n.definition[o];e.groups||(e.groups=[]),e.groups.push(n.gid),r.push(i)}t(n.children,i,r)}}))}(this.roots[0],{},e),this.allEdges().forEach((function(i){var o=n.modules[i.source],a=n.modules[i.target];t.push(new r(void 0===o.gid?i.source:e[o.gid],void 0===a.gid?i.target:e[a.gid],i.type))})),e},t.prototype.allEdges=function(){var n=[];return t.getEdges(this.roots[0],n),n},t.getEdges=function(n,e){n.forAll((function(n){n.getEdges(e),t.getEdges(n.children,e)}))},t}();e.Configuration=i;var o=function(){function t(t,n,e,r,i){void 0===n&&(n=new u),void 0===e&&(e=new u),void 0===r&&(r=new s),this.id=t,this.outgoing=n,this.incoming=e,this.children=r,this.definition=i}return t.prototype.getEdges=function(t){var n=this;this.outgoing.forAll((function(e,i){e.forAll((function(e){t.push(new r(n.id,e.id,i))}))}))},t.prototype.isLeaf=function(){return 0===this.children.count()},t.prototype.isIsland=function(){return 0===this.outgoing.count()&&0===this.incoming.count()},t.prototype.isPredefined=function(){return void 0!==this.definition},t}();function a(t,n){var e={};for(var r in t)r in n&&(e[r]=t[r]);return e}e.Module=o;var s=function(){function t(){this.table={}}return t.prototype.count=function(){return Object.keys(this.table).length},t.prototype.intersection=function(n){var e=new t;return e.table=a(this.table,n.table),e},t.prototype.intersectionCount=function(t){return this.intersection(t).count()},t.prototype.contains=function(t){return t in this.table},t.prototype.add=function(t){this.table[t.id]=t},t.prototype.remove=function(t){delete this.table[t.id]},t.prototype.forAll=function(t){for(var n in this.table)t(this.table[n])},t.prototype.modules=function(){var t=[];return this.forAll((function(n){n.isPredefined()||t.push(n)})),t},t}();e.ModuleSet=s;var u=function(){function t(){this.sets={},this.n=0}return t.prototype.count=function(){return this.n},t.prototype.contains=function(t){var n=!1;return this.forAllModules((function(e){n||e.id!=t||(n=!0)})),n},t.prototype.add=function(t,n){(t in this.sets?this.sets[t]:this.sets[t]=new s).add(n),++this.n},t.prototype.remove=function(t,n){var e=this.sets[t];e.remove(n),0===e.count()&&delete this.sets[t],--this.n},t.prototype.forAll=function(t){for(var n in this.sets)t(this.sets[n],Number(n))},t.prototype.forAllModules=function(t){this.forAll((function(n,e){return n.forAll(t)}))},t.prototype.intersection=function(n){var e=new t;return this.forAll((function(t,r){if(r in n.sets){var i=t.intersection(n.sets[r]),o=i.count();o>0&&(e.sets[r]=i,e.n+=o)}})),e},t}();e.LinkSets=u,e.getGroups=function(t,n,e,r){for(var o=t.length,a=new i(o,n,e,r);a.greedyMerge(););var s=[],u=a.getGroupHierarchy(s);return s.forEach((function(n){var e=function(e){var r=n[e];"number"==typeof r&&(n[e]=t[r])};e("source"),e("target")})),{groups:u,powerEdges:s}}},{}],15:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this.elem=t,this.subheaps=[]}return t.prototype.toString=function(t){for(var n="",e=!1,r=0;r0)}return null}}return t.prototype.clear=function(){this._root=null,this.size=0},t.prototype.find=function(t){for(var n=this._root;null!==n;){var e=this._comparator(t,n.data);if(0===e)return n.data;n=n.get_child(e>0)}return null},t.prototype.lowerBound=function(t){return this._bound(t,this._comparator)},t.prototype.upperBound=function(t){var n=this._comparator;return this._bound(t,(function(t,e){return n(e,t)}))},t.prototype.min=function(){var t=this._root;if(null===t)return null;for(;null!==t.left;)t=t.left;return t.data},t.prototype.max=function(){var t=this._root;if(null===t)return null;for(;null!==t.right;)t=t.right;return t.data},t.prototype.iterator=function(){return new a(this)},t.prototype.each=function(t){for(var n,e=this.iterator();null!==(n=e.next());)t(n)},t.prototype.reach=function(t){for(var n,e=this.iterator();null!==(n=e.prev());)t(n)},t.prototype._bound=function(t,n){for(var e=this._root,r=this.iterator();null!==e;){var i=this._comparator(t,e.data);if(0===i)return r._cursor=e,r;r._ancestors.push(e),e=e.get_child(i>0)}for(var o=r._ancestors.length-1;o>=0;--o)if(n(t,(e=r._ancestors[o]).data)>0)return r._cursor=e,r._ancestors.length=o,r;return r._ancestors.length=0,r},t}();e.TreeBase=o;var a=function(){function t(t){this._tree=t,this._ancestors=[],this._cursor=null}return t.prototype.data=function(){return null!==this._cursor?this._cursor.data:null},t.prototype.next=function(){if(null===this._cursor){var t=this._tree._root;null!==t&&this._minNode(t)}else{var n;if(null===this._cursor.right)do{if(n=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.right===n);else this._ancestors.push(this._cursor),this._minNode(this._cursor.right)}return null!==this._cursor?this._cursor.data:null},t.prototype.prev=function(){if(null===this._cursor){var t=this._tree._root;null!==t&&this._maxNode(t)}else{var n;if(null===this._cursor.left)do{if(n=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.left===n);else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left)}return null!==this._cursor?this._cursor.data:null},t.prototype._minNode=function(t){for(;null!==t.left;)this._ancestors.push(t),t=t.left;this._cursor=t},t.prototype._maxNode=function(t){for(;null!==t.right;)this._ancestors.push(t),t=t.right;this._cursor=t},t}();e.Iterator=a;var s=function(){function t(t){this.data=t,this.left=null,this.right=null,this.red=!0}return t.prototype.get_child=function(t){return t?this.right:this.left},t.prototype.set_child=function(t,n){t?this.right=n:this.left=n},t}(),u=function(t){function n(n){var e=t.call(this)||this;return e._root=null,e._comparator=n,e.size=0,e}return i(n,t),n.prototype.insert=function(t){var e=!1;if(null===this._root)this._root=new s(t),e=!0,this.size++;else{var r=new s(void 0),i=!1,o=!1,a=null,u=r,c=null,l=this._root;for(u.right=this._root;;){if(null===l?(l=new s(t),c.set_child(i,l),e=!0,this.size++):n.is_red(l.left)&&n.is_red(l.right)&&(l.red=!0,l.left.red=!1,l.right.red=!1),n.is_red(l)&&n.is_red(c)){var h=u.right===a;l===c.get_child(o)?u.set_child(h,n.single_rotate(a,!o)):u.set_child(h,n.double_rotate(a,!o))}var f=this._comparator(l.data,t);if(0===f)break;o=i,i=f<0,null!==a&&(u=a),a=c,c=l,l=l.get_child(i)}this._root=r.right}return this._root.red=!1,e},n.prototype.remove=function(t){if(null===this._root)return!1;var e=new s(void 0),r=e;r.right=this._root;for(var i=null,o=null,a=null,u=!0;null!==r.get_child(u);){var c=u;o=i,i=r,r=r.get_child(u);var l=this._comparator(t,r.data);if(u=l>0,0===l&&(a=r),!n.is_red(r)&&!n.is_red(r.get_child(u)))if(n.is_red(r.get_child(!u))){var h=n.single_rotate(r,u);i.set_child(c,h),i=h}else if(!n.is_red(r.get_child(!u))){var f=i.get_child(!c);if(null!==f)if(n.is_red(f.get_child(!c))||n.is_red(f.get_child(c))){var p=o.right===i;n.is_red(f.get_child(c))?o.set_child(p,n.double_rotate(i,c)):n.is_red(f.get_child(!c))&&o.set_child(p,n.single_rotate(i,c));var y=o.get_child(p);y.red=!0,r.red=!0,y.left.red=!1,y.right.red=!1}else i.red=!1,f.red=!0,r.red=!0}}return null!==a&&(a.data=r.data,i.set_child(i.right===r,r.get_child(null===r.left)),this.size--),this._root=e.right,null!==this._root&&(this._root.red=!1),null!==a},n.is_red=function(t){return null!==t&&t.red},n.single_rotate=function(t,n){var e=t.get_child(!n);return t.set_child(!n,e.get_child(n)),e.set_child(n,t),t.red=!0,e.red=!1,e},n.double_rotate=function(t,e){return t.set_child(!e,n.single_rotate(t.get_child(!e),!e)),n.single_rotate(t,e)},n}(o);e.RBTree=u},{}],17:[function(t,n,e){"use strict";var r,i=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});Object.defineProperty(e,"__esModule",{value:!0});var o=t("./vpsc"),a=t("./rbtree");function s(t){return t.bounds=void 0!==t.leaves?t.leaves.reduce((function(t,n){return n.bounds.union(t)}),u.empty()):u.empty(),void 0!==t.groups&&(t.bounds=t.groups.reduce((function(t,n){return s(n).union(t)}),t.bounds)),t.bounds=t.bounds.inflate(t.padding),t.bounds}e.computeGroupBounds=s;var u=function(){function t(t,n,e,r){this.x=t,this.X=n,this.y=e,this.Y=r}return t.empty=function(){return new t(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)},t.prototype.cx=function(){return(this.x+this.X)/2},t.prototype.cy=function(){return(this.y+this.Y)/2},t.prototype.overlapX=function(t){var n=this.cx(),e=t.cx();return n<=e&&t.x0?e[0]:null},t.prototype.vertices=function(){return[{x:this.x,y:this.y},{x:this.X,y:this.y},{x:this.X,y:this.Y},{x:this.x,y:this.Y}]},t.lineIntersection=function(t,n,e,r,i,o,a,s){var u=e-t,c=a-i,l=r-n,h=s-o,f=h*u-c*l;if(0==f)return null;var p=t-i,y=n-o,d=(c*y-h*p)/f,g=(u*y-l*p)/f;return d>=0&&d<=1&&g>=0&&g<=1?{x:t+d*u,y:n+d*l}:null},t.prototype.inflate=function(n){return new t(this.x-n,this.X+n,this.y-n,this.Y+n)},t}();e.Rectangle=u,e.makeEdgeBetween=function(t,n,e){var r=t.rayIntersection(n.cx(),n.cy())||{x:t.cx(),y:t.cy()},i=n.rayIntersection(t.cx(),t.cy())||{x:n.cx(),y:n.cy()},o=i.x-r.x,a=i.y-r.y,s=Math.sqrt(o*o+a*a),u=s-e;return{sourceIntersection:r,targetIntersection:i,arrowStart:{x:r.x+u*o/s,y:r.y+u*a/s}}},e.makeEdgeTo=function(t,n,e){var r=n.rayIntersection(t.x,t.y);r||(r={x:n.cx(),y:n.cy()});var i=r.x-t.x,o=r.y-t.y,a=Math.sqrt(i*i+o*o);return{x:r.x-e*i/a,y:r.y-e*o/a}};var c=function(t,n,e){this.v=t,this.r=n,this.pos=e,this.prev=f(),this.next=f()},l=function(t,n,e){this.isOpen=t,this.v=n,this.pos=e};function h(t,n){return t.pos>n.pos?1:t.pos0&&(t[e].insert(i),i[r].insert(t))};e("next","prev"),e("prev","next")}};function d(t,n,e,r){void 0===r&&(r=!1);var i=t.padding,o=void 0!==t.groups?t.groups.length:0,a=void 0!==t.leaves?t.leaves.length:0,s=o?t.groups.reduce((function(t,r){return t.concat(d(r,n,e,!0))}),[]):[],u=(r?2:0)+a+o,c=new Array(u),l=new Array(u),h=0,f=function(t,n){l[h]=t,c[h++]=n};if(r){var p=t.bounds,y=n.getCentre(p),v=n.getSize(p)/2,x=n.getOpen(p),m=n.getClose(p),b=y-v+i/2,w=y+v-i/2;t.minVar.desiredPosition=b,f(n.makeRect(x,m,b,i),t.minVar),t.maxVar.desiredPosition=w,f(n.makeRect(x,m,w,i),t.maxVar)}a&&t.leaves.forEach((function(t){return f(t.bounds,t.variable)})),o&&t.groups.forEach((function(t){var e=t.bounds;f(n.makeRect(n.getOpen(e),n.getClose(e),n.getCentre(e),n.getSize(e)),t.minVar)}));var _=g(l,c,n,e);return o&&(c.forEach((function(t){t.cOut=[],t.cIn=[]})),_.forEach((function(t){t.left.cOut.push(t),t.right.cIn.push(t)})),t.groups.forEach((function(t){var e=(t.padding-n.getSize(t.bounds))/2;t.minVar.cIn.forEach((function(t){return t.gap+=e})),t.minVar.cOut.forEach((function(n){n.left=t.maxVar,n.gap+=e}))}))),s.concat(_)}function g(t,n,e,r){var i,a=t.length,s=2*a;console.assert(n.length>=a);var u=new Array(s);for(i=0;it[e]&&(t[e]=n)}o=t}))}},t.prototype.createAlignment=function(t){var n=this,e=this.nodes[t.offsets[0].node].variable;this.makeFeasible(t);var r="x"===t.axis?this.xConstraints:this.yConstraints;t.offsets.slice(1).forEach((function(t){var i=n.nodes[t.node].variable;r.push(new o.Constraint(e,i,t.offset,!0))}))},t.prototype.createConstraints=function(t){var n=this,e=function(t){return void 0===t.type||"separation"===t.type};this.xConstraints=t.filter((function(t){return"x"===t.axis&&e(t)})).map((function(t){return n.createSeparation(t)})),this.yConstraints=t.filter((function(t){return"y"===t.axis&&e(t)})).map((function(t){return n.createSeparation(t)})),t.filter((function(t){return"alignment"===t.type})).forEach((function(t){return n.createAlignment(t)}))},t.prototype.setupVariablesAndBounds=function(t,n,e,r){this.nodes.forEach((function(i,o){i.fixed?(i.variable.weight=i.fixedWeight?i.fixedWeight:1e3,e[o]=r(i)):i.variable.weight=1;var a=(i.width||0)/2,s=(i.height||0)/2,c=t[o],l=n[o];i.bounds=new u(c-a,c+a,l-s,l+s)}))},t.prototype.xProject=function(t,n,e){(this.rootGroup||this.avoidOverlaps||this.xConstraints)&&this.project(t,n,t,e,(function(t){return t.px}),this.xConstraints,m,(function(t){return t.bounds.setXCentre(e[t.variable.index]=t.variable.position())}),(function(t){var n=e[t.minVar.index]=t.minVar.position(),r=e[t.maxVar.index]=t.maxVar.position(),i=t.padding/2;t.bounds.x=n-i,t.bounds.X=r+i}))},t.prototype.yProject=function(t,n,e){(this.rootGroup||this.yConstraints)&&this.project(t,n,n,e,(function(t){return t.py}),this.yConstraints,b,(function(t){return t.bounds.setYCentre(e[t.variable.index]=t.variable.position())}),(function(t){var n=e[t.minVar.index]=t.minVar.position(),r=e[t.maxVar.index]=t.maxVar.position(),i=t.padding/2;t.bounds.y=n-i,t.bounds.Y=r+i}))},t.prototype.projectFunctions=function(){var t=this;return[function(n,e,r){return t.xProject(n,e,r)},function(n,e,r){return t.yProject(n,e,r)}]},t.prototype.project=function(t,n,e,r,i,o,a,u,c){this.setupVariablesAndBounds(t,n,r,i),this.rootGroup&&this.avoidOverlaps&&(s(this.rootGroup),o=o.concat(a(this.rootGroup))),this.solve(this.variables,o,e,r),this.nodes.forEach(u),this.rootGroup&&this.avoidOverlaps&&(this.groups.forEach(c),s(this.rootGroup))},t.prototype.solve=function(t,n,e,r){var i=new o.Solver(t,n);i.setStartingPositions(e),i.setDesiredPositions(r),i.solve()},t}();e.Projection=_},{"./rbtree":16,"./vpsc":19}],18:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t("./pqueue"),i=function(t,n){this.id=t,this.distance=n},o=function(t){this.id=t,this.neighbours=[]},a=function(t,n,e){this.node=t,this.prev=n,this.d=e},s=function(){function t(t,n,e,r,a){this.n=t,this.es=n,this.neighbours=new Array(this.n);for(var s=this.n;s--;)this.neighbours[s]=new o(s);for(s=this.es.length;s--;){var u=this.es[s],c=e(u),l=r(u),h=a(u);this.neighbours[c].neighbours.push(new i(l,h)),this.neighbours[l].neighbours.push(new i(c,h))}}return t.prototype.DistanceMatrix=function(){for(var t=new Array(this.n),n=0;nh&&(c.d=h,c.prev=s,e.reduceKey(c.q,c,(function(t,n){return t.q=n})))}}return o},t}();e.Calculator=s},{"./pqueue":15}],19:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this.scale=t,this.AB=0,this.AD=0,this.A2=0}return t.prototype.addVariable=function(t){var n=this.scale/t.scale,e=t.offset/t.scale,r=t.weight;this.AB+=r*n*e,this.AD+=r*n*t.desiredPosition,this.A2+=r*n*n},t.prototype.getPosn=function(){return(this.AD-this.AB)/this.A2},t}();e.PositionStats=r;var i=function(){function t(t,n,e,r){void 0===r&&(r=!1),this.left=t,this.right=n,this.gap=e,this.equality=r,this.active=!1,this.unsatisfiable=!1,this.left=t,this.right=n,this.gap=e,this.equality=r}return t.prototype.slack=function(){return this.unsatisfiable?Number.MAX_VALUE:this.right.scale*this.right.position()-this.gap-this.left.scale*this.left.position()},t}();e.Constraint=i;var o=function(){function t(t,n,e){void 0===n&&(n=1),void 0===e&&(e=1),this.desiredPosition=t,this.weight=n,this.scale=e,this.offset=0}return t.prototype.dfdv=function(){return 2*this.weight*(this.position()-this.desiredPosition)},t.prototype.position=function(){return(this.block.ps.scale*this.block.posn+this.offset)/this.scale},t.prototype.visitNeighbours=function(t,n){var e=function(e,r){return e.active&&t!==r&&n(e,r)};this.cOut.forEach((function(t){return e(t,t.right)})),this.cIn.forEach((function(t){return e(t,t.left)}))},t}();e.Variable=o;var a=function(){function t(t){this.vars=[],t.offset=0,this.ps=new r(t.scale),this.addVariable(t)}return t.prototype.addVariable=function(t){t.block=this,this.vars.push(t),this.ps.addVariable(t),this.posn=this.ps.getPosn()},t.prototype.updateWeightedPosition=function(){this.ps.AB=this.ps.AD=this.ps.A2=0;for(var t=0,n=this.vars.length;t=0?this.inactive.push(n):this.bs.merge(n)}}},t.prototype.solve=function(){this.satisfy();for(var t=Number.MAX_VALUE,n=this.bs.cost();Math.abs(t-n)>1e-4;)this.satisfy(),t=n,n=this.bs.cost();return n},t.LAGRANGIAN_TOLERANCE=-1e-4,t.ZERO_UPPERBOUND=-1e-10,t}();e.Solver=u,e.removeOverlapInOneDimension=function(t,n,e){for(var r=t.map((function(t){return new o(t.desiredCenter)})),a=[],s=t.length,c=0;c=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function f(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e-1&&(this.uncertainBegin=0,this.begin=e(o.substring(1,o.length))),a.indexOf(">")>-1&&(this.end=e(a.substring(1,o.length)),this.uncertainEnd=t.size),o.indexOf(">")>-1&&a.indexOf("<")>-1&&(this.uncertainBegin=e(o.substring(1,o.length)),this.begin=e(a.substring(1,o.length)),this.end=null)}}function g(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,n)||x(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=x(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function x(t,n){if(t){if("string"==typeof t)return m(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?m(t,n):void 0}}function m(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e25&&(this.labelText=this.labelText.substr(0,16)+"..."),this.labelText=this.name,this.labelTextNode=document.createTextNode(this.labelText),this.labelSVG.appendChild(this.labelTextNode),this.labelSVG.setAttribute("transform","translate( -"+this.getSymbolRadius()+" "+"-5)"),this.upperGroup.appendChild(this.labelSVG)},p.prototype.initOutline=function(){this.outline.classList.add("outline"),this.upperGroup.appendChild(this.outline)},p.prototype.initListeners=function(){var t=this;this.upperGroup.onmousedown=function(n){t.mouseDown(n)},this.upperGroup.onmouseenter=function(n){t.mouseOver(n)},this.upperGroup.onmouseleave=function(n){t.mouseOut(n)},this.upperGroup.ontouchstart=function(n){t.touchStart(n)}},p.prototype.addStoichiometryLabel=function(t){this.labelSVG&&(this.labelSVG.childNodes[0].data=this.labelSVG.childNodes[0].data+" ["+t+"]")},p.prototype.mouseDown=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.app.d3cola.stop(),this.app.dragElement=this,this.app.dragStart=t,!1},p.prototype.touchStart=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.app.d3cola.stop(),this.app.dragElement=this,this.app.dragStart=t,!1},p.prototype.mouseOver=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.showHighlight(!0),this.app.notifyHoverListeners([this.json.id]),!1},p.prototype.mouseOut=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.showHighlight(!1),this.app.hideTooltip(),this.app.notifyHoverListeners([]),!1},p.prototype.getSymbolRadius=function(){return 15},p.prototype.showHighlight=function(){},p.prototype.getPosition=function(){return[this.ix,this.iy]},p.prototype.setPosition=function(t,n){this.px=this.ix,this.py=this.iy;var e=this.width/2-this.getSymbolRadius();this.expanded&&(e-=this.size/2*this.stickZoom),this.ix=t+e,this.iy=n,this.upperGroup.setAttribute("transform","translate("+this.ix+" "+this.iy+")")},p.prototype.changePosition=function(t,n){this.px=this.ix,this.py=this.iy,this.ix-=t,this.iy-=n,this.upperGroup.setAttribute("transform","translate("+this.ix+" "+this.iy+")")},p.prototype.getAggregateSelfLinkPath=function(){var t=this.getSymbolRadius()+7,n=y(t,70),e=y(t,20),r=y(t,85),i=y(t,5);return"M 0,0 Q "+r.x+","+-r.y+" "+n.x+","+-n.y+" A "+t+" "+t+" 0 0 1 "+e.x+","+-e.y+" Q "+i.x+","+-i.y+" 0,0"},p.prototype.checkLinks=function(){function t(t){var n,e=h(t.values());try{for(e.s();!(n=e.n()).done;){n.value.check()}}catch(t){e.e(t)}finally{e.f()}}t(this.binaryLinks),t(this.sequenceLinks),this.selfLink&&this.selfLink.check()},p.prototype.setAllLinkCoordinates=function(){var t,n=h(this.naryLinks.values());try{for(n.s();!(t=n.n()).done;){t.value.setLinkCoordinates()}}catch(t){n.e(t)}finally{n.f()}var e,r=h(this.binaryLinks.values());try{for(r.s();!(e=r.n()).done;){e.value.setLinkCoordinates()}}catch(t){r.e(t)}finally{r.f()}this.selfLink&&this.selfLink.setLinkCoordinates();var i,o=h(this.sequenceLinks.values());try{for(o.s();!(i=o.n()).done;){i.value.setLinkCoordinates()}}catch(t){o.e(t)}finally{o.f()}},d.prototype.toString=function(){return this.sequenceDatumString},d.prototype.overlaps=function(t){if(this.participant===t.participant){var n=this.uncertainBegin||this.begin||this.end||this.uncertainEnd,e=this.uncertainEnd||this.end||this.begin||this.uncertainBegin,r=t.uncertainBegin||t.begin||t.end;if(n<=(t.uncertainEnd||t.end||t.begin)&&r<=e)return!0}return!1},b.STICKHEIGHT=20,b.MAXSIZE=0,b.transitionTime=650,b.prototype=new p,b.prototype.getSymbolRadius=function(){return 15},b.prototype.showHighlight=function(t){this.highlight.setAttribute("stroke-opacity",t?"1":"0")},b.minXDist=30,b.prototype.setStickScale=function(t,n){var e=this.stickZoom,r=this.ix-n.x,i=this.iy-n.y,o=r*t/e-r,a=i*t/e-i;0!==this.rotation&&180!==this.rotation||(a=0);var s=this.ix+o,u=this.iy+a;this.stickZoom=t,this.scale(),this.setPosition(s,u),this.setAllLinkCoordinates()},b.prototype.scale=function(){var t=this.size*this.stickZoom;if(this.expanded){var n=i.transform(this.labelSVG.getAttribute("transform")),e=this.app.svgElement.createSVGMatrix().rotate(n.rotate).translate(-(this.size/2*this.stickZoom+(this.nTerminusFeature?25:10)),-5);this.labelSVG.transform.baseVal.initialize(this.app.svgElement.createSVGTransformFromMatrix(e)),this.updateAnnotationRectanglesNoTransition(),i.select(this.background).attr("width",t).attr("x",this.getResXWithStickZoom(.5)),i.select(this.outline).attr("width",t).attr("x",this.getResXWithStickZoom(.5)),i.select(this.highlight).attr("width",t+5).attr("x",this.getResXWithStickZoom(.5)-2.5),this.setScaleGroup()}},b.prototype.setScaleGroup=function(){this.upperGroup.appendChild(this.ticks),this.ticks.textContent="",this.scaleLabels=[];for(var t=-1,n=this.getResXWithStickZoom(this.size),e=1;e<=this.size;e++){if(1===e||e%100==0&&200*this.stickZoom>b.minXDist||e%10==0&&20*this.stickZoom>b.minXDist){var r=this.getResXWithStickZoom(e);(this.stickZoom>=8||1!==e)&&s(this,r),0===(t=(t+1)%2)&&r+b.minXDist=8){var i=document.createElementNS(c,"g");i.setAttribute("transform","translate("+this.getResXWithStickZoom(e)+" 0)");var o=document.createElementNS(c,"text");o.classList.add("label","sequence"),o.setAttribute("x","0"),o.setAttribute("y","3"),o.appendChild(document.createTextNode(this.sequence[e-1])),i.appendChild(o),this.scaleLabels.push(o),this.ticks.appendChild(i)}}function a(t,n,e){var r=document.createElementNS(c,"g");r.setAttribute("transform","translate("+e+" 0)");var i=document.createElementNS(c,"text");i.classList.add("label","scale-label"),i.setAttribute("x","0"),i.setAttribute("y",b.STICKHEIGHT+4),i.appendChild(document.createTextNode(n)),r.appendChild(i),t.scaleLabels.push(i),t.ticks.appendChild(r)}function s(t,n){var e=document.createElementNS(c,"line");e.classList.add("tick"),e.setAttribute("x1",n),e.setAttribute("y1","5"),e.setAttribute("x2",n),e.setAttribute("y2","10"),t.ticks.appendChild(e)}a(this,this.size,n),this.stickZoom>=8&&s(this,n)},b.prototype.setForm=function(t,n){!0!==this.busy&&(1===t?this.toStick():this.toCircle(n))},b.prototype.toCircle=function(t){this.busy=!0;var n=this.getSymbolRadius();i.select(this.background).transition().attr("x",-n).attr("y",-n).attr("width",2*n).attr("height",2*n).attr("rx",n).attr("ry",n).duration(b.transitionTime),i.select(this.outline).transition().attr("x",-n).attr("y",-n).attr("width",2*n).attr("height",2*n).attr("rx",n).attr("ry",n).duration(b.transitionTime),i.select(this.highlight).transition().attr("width",2*n+5).attr("height",2*n+5).attr("x",-n-2.5).attr("y",-n-2.5).attr("rx",n+2.5).attr("ry",n+2.5).duration(b.transitionTime);var e=i.interpolate(this.stickZoom,0),r=i.transform(this.labelSVG.getAttribute("transform")).translate[0],o=i.interpolate(r,-(n+5)),a=null,s=null;null!=t&&(a=i.interpolate(this.ix,t.x),s=i.interpolate(this.iy,t.y));var u=this;i.select(this.ticks).transition().attr("opacity",0).duration(b.transitionTime/4).each("end",(function(){i.select(this).selectAll("*").remove()}));var c,l=v(this.annotationSets);try{for(l.s();!(c=l.n()).done;){var h=g(c.value,2),f=h[0],p=h[1];if(!0===this.app.annotationSetsShown.get(f)){var y,d=v(p);try{for(d.s();!(y=d.n()).done;){var x=y.value;if(x.fuzzyStart){var m=x.fuzzyStart;i.select(m).transition().attr("d",this.getAnnotationPieSlicePath(x.seqDatum.uncertainBegin,x.seqDatum.begin,x,!1)).duration(b.transitionTime)}if(x.certain){var w=x.certain;i.select(w).transition().attr("d",this.getAnnotationPieSlicePath(x.seqDatum.begin,x.seqDatum.end,x,!1)).duration(b.transitionTime)}if(x.fuzzyEnd){var _=x.fuzzyEnd;i.select(_).transition().attr("d",this.getAnnotationPieSlicePath(x.seqDatum.end,x.seqDatum.uncertainEnd,x,!1)).duration(b.transitionTime)}}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){l.e(t)}finally{l.f()}var S=this.stickZoom,M=this.rotation,k=i.ease("cubic-in-out");i.timer((function(t){return function t(n){var r=i.transform(u.labelSVG.getAttribute("transform")),c=u.app.svgElement.createSVGMatrix().rotate(r.rotate).translate(o(k(n)),-5);u.labelSVG.transform.baseVal.initialize(u.app.svgElement.createSVGTransformFromMatrix(c)),null!==a&&u.setPosition(a(k(n)),s(k(n)));if(u.stickZoom=e(k(n)),u.setAllLinkCoordinates(),1===n){u.expanded=!1,u.checkLinks();var l,h=v(u.annotationSets);try{for(h.s();!(l=h.n()).done;){var f=g(l.value,2),p=f[0],y=f[1];if(!0===u.app.annotationSetsShown.get(p)){var d,x=v(y);try{for(x.s();!(d=x.n()).done;){var m=d.value;if(m.fuzzyStart){var b=m.fuzzyStart;i.select(b).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.uncertainBegin,m.seqDatum.begin,m))}if(m.certain){var w=m.certain;i.select(w).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.begin,m.seqDatum.end,m))}if(m.fuzzyEnd){var _=m.fuzzyEnd;i.select(_).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.end,m.seqDatum.uncertainEnd,m))}}}catch(t){x.e(t)}finally{x.f()}}}}catch(t){h.e(t)}finally{h.f()}return u.stickZoom=S,u.rotation=M,u.busy=!1,!0}return n>1&&t(1)}(t/b.transitionTime)}))},b.prototype.toStick=function(){this.busy=!0,this.expanded=!0;var t=this.size*this.stickZoom,n=this.getSymbolRadius(),e=i.interpolate(2*n,t),r=i.interpolate(0,this.stickZoom),o=i.interpolate(-(n+5),-(this.size/2*this.stickZoom+(this.nTerminusFeature?25:10))),a=this.stickZoom;this.stickZoom=0,this.checkLinks(),this.stickZoom=a,i.select(this.background).transition().attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0).duration(b.transitionTime),i.select(this.outline).transition().attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0).duration(b.transitionTime),i.select(this.highlight).transition().attr("width",t+5).attr("height",b.STICKHEIGHT+5).attr("x",this.getResXWithStickZoom(.5)-2.5).attr("y",-b.STICKHEIGHT/2-2.5).attr("rx",0).attr("ry",0).duration(b.transitionTime);var s,u=v(this.annotationSets);try{for(u.s();!(s=u.n()).done;){var c=g(s.value,2),l=c[0],h=c[1];if(!0===this.app.annotationSetsShown.get(l)){var f,p=v(h);try{for(p.s();!(f=p.n()).done;){var y=f.value;if(y.fuzzyStart){var d=y.fuzzyStart;d.setAttribute("d",this.getAnnotationPieSlicePath(y.seqDatum.uncertainBegin,y.seqDatum.begin,y,!1)),i.select(d).transition().attr("d",this.getAnnotationRectPath(y.seqDatum.uncertainBegin,y.seqDatum.begin,y)).duration(b.transitionTime)}if(y.certain){var x=y.certain,m=y.seqDatum.begin,w=y.seqDatum.end;y.seqDatum.uncertainBegin&&(m+=1),y.seqDatum.uncertainEnd&&(w-=1),x.setAttribute("d",this.getAnnotationPieSlicePath(m,w,y,!1)),i.select(x).transition().attr("d",this.getAnnotationRectPath(m,w,y)).duration(b.transitionTime)}if(y.fuzzyEnd){var _=y.fuzzyEnd;_.setAttribute("d",this.getAnnotationPieSlicePath(y.seqDatum.end,y.seqDatum.uncertainEnd,y,!1)),i.select(_).transition().attr("d",this.getAnnotationRectPath(y.seqDatum.end,y.seqDatum.uncertainEnd,y)).duration(b.transitionTime)}}}catch(t){p.e(t)}finally{p.f()}}}}catch(t){u.e(t)}finally{u.f()}var S=this,M=i.ease("cubic-in-out");i.timer((function(t){return function t(n){var a=i.transform(S.labelSVG.getAttribute("transform")),s=S.app.svgElement.createSVGMatrix().rotate(a.rotate).translate(o(M(n)),-5);S.labelSVG.transform.baseVal.initialize(S.app.svgElement.createSVGTransformFromMatrix(s));var u=e(M(n));return i.select(S.highlight).attr("width",u).attr("x",-u/2+.5*S.stickZoom),i.select(S.outline).attr("width",u).attr("x",-u/2+.5*S.stickZoom),i.select(S.background).attr("width",u).attr("x",-u/2+.5*S.stickZoom),S.stickZoom=r(M(n)),S.setAllLinkCoordinates(),1===n?(S.updateAnnotationRectanglesNoTransition(),S.busy=!1,!0):n>1&&t(1)}(t/b.transitionTime)})),i.select(this.ticks).attr("opacity",0),this.setScaleGroup(),i.select(this.ticks).transition().attr("opacity",1).delay(.8*b.transitionTime).duration(b.transitionTime/2)},b.prototype.toStickNoTransition=function(){this.busy=!0,this.expanded=!0;var t=this.size*this.stickZoom,n=this.getSymbolRadius(),e=i.interpolate(2*n,t),r=i.interpolate(-(n+5),-(this.size/2*this.stickZoom+(this.nTerminusFeature?25:10)));this.checkLinks(),i.select(this.background).attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0),i.select(this.outline).attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0),i.select(this.highlight).attr("width",t+5).attr("height",b.STICKHEIGHT+5).attr("x",this.getResXWithStickZoom(.5)-2.5).attr("y",-b.STICKHEIGHT/2-2.5).attr("rx",0).attr("ry",0);this.updateAnnotationRectanglesNoTransition();var o=i.transform(this.labelSVG.getAttribute("transform")),a=this.app.svgElement.createSVGMatrix().rotate(o.rotate).translate(r(1),-5);this.labelSVG.transform.baseVal.initialize(this.app.svgElement.createSVGTransformFromMatrix(a));var s=e(1);i.select(this.highlight).attr("width",s).attr("x",-s/2+.5*this.stickZoom),i.select(this.outline).attr("width",s).attr("x",-s/2+.5*this.stickZoom),i.select(this.background).attr("width",s).attr("x",-s/2+.5*this.stickZoom),this.setAllLinkCoordinates(),this.setScaleGroup(),i.select(this.ticks).attr("opacity",1),this.busy=!1},b.prototype.updateAnnotationRectanglesNoTransition=function(){var t,n=v(this.annotationSets);try{for(n.s();!(t=n.n()).done;){var e=g(t.value,2),r=e[0],o=e[1];if(!0===this.app.annotationSetsShown.get(r)){var a,s=v(o);try{for(s.s();!(a=s.n()).done;){var u=a.value;if(u.fuzzyStart){var c=u.fuzzyStart;i.select(c).attr("d",this.getAnnotationRectPath(u.seqDatum.uncertainBegin,u.seqDatum.begin,u))}if(u.certain){var l=u.seqDatum.begin,h=u.seqDatum.end;u.seqDatum.uncertainBegin&&(l+=1),u.seqDatum.uncertainEnd&&(h-=1),u.certain.setAttribute("d",this.getAnnotationRectPath(l,h,u))}if(u.fuzzyEnd){var f=u.fuzzyEnd;i.select(f).attr("d",this.getAnnotationRectPath(u.seqDatum.end,u.seqDatum.uncertainEnd,u))}}}catch(t){s.e(t)}finally{s.f()}}}}catch(t){n.e(t)}finally{n.f()}},b.prototype.getResXWithStickZoom=function(t){return"n-n"===t?-this.size/2*this.stickZoom-20:"c-c"===t?this.size/2*this.stickZoom+20:(t-this.size/2)*this.stickZoom},b.prototype.getResidueCoordinates=function(t,n){void 0===t&&console.error("ERROR: residue number is undefined");var e,r=this.getResXWithStickZoom(1*t);if(0!==r){var i=Math.abs(r),o=Math.acos(r/i),a=this.rotation/360*Math.PI*2;r=i*Math.cos(a+o),e=i*Math.sin(a+o),void 0!==n&&(r+=n*Math.cos(a+Math.PI/2),e+=n*Math.sin(a+Math.PI/2))}else e=n;return[r+=this.ix,e+=this.iy]},b.prototype.clearPositionalFeatures=function(){this.annotations=[],this.annotationTypes=[],this.annotationsSvgGroup.textContent=""},b.prototype.updatePositionalFeatures=function(){var t=this,n=function(n){var e=n.target.correspondingUseElement?n.target.correspondingUseElement:n.target;t.app.preventDefaultsAndStopPropagation(n),t.app.setTooltip(e.name,e.getAttribute("fill")),t.showHighlight(!0)},e=-1,r=[];function i(t,n){var e,r=v(t);try{for(r.s();!(e=r.n()).done;){if(e.value.seqDatum.overlaps(n.seqDatum))return!0}}catch(t){r.e(t)}finally{r.f()}return!1}var o,a=v(this.annotationSets);try{for(a.s();!(o=a.n()).done;){var s=g(o.value,2),u=s[0],l=s[1];if(!0===this.app.annotationSetsShown.get(u)){l&&l.length>0&&(r[++e]=[]);var h,f=new Set,p=v(Array.from(l.values()).sort((function(t,n){var e=t.description,r=n.description;return er?1:0})));try{for(p.s();!(h=p.n()).done;){var y=h.value;if(!f.has(y.toString()))if(f.add(y.toString()),"n-n"===y.seqDatum.sequenceDatumString||"c-c"===y.seqDatum.sequenceDatumString)y.rung=-1;else{var d=r[e];i(d,y)&&(r[++e]=[],d=r[e]),y.rung=e,d.push(y)}}}catch(t){p.e(t)}finally{p.f()}}}}catch(t){a.e(t)}finally{a.f()}this.rungCount=e+1;var x,m=v(this.annotationSets);try{for(m.s();!(x=m.n()).done;){var b=g(x.value,2),w=b[0],_=b[1];if(!0===this.app.annotationSetsShown.get(w)){var S,M=new Set,k=v(_.values());try{for(k.s();!(S=k.n()).done;){var E=S.value;if(!M.has(E.toString())){M.add(E.toString());var A=E.toString();if(E.seqDatum.uncertainBegin&&(E.fuzzyStart=document.createElementNS(c,"path"),this.expanded?E.fuzzyStart.setAttribute("d",this.getAnnotationRectPath(E.seqDatum.uncertainBegin,E.seqDatum.begin,E)):E.fuzzyStart.setAttribute("d",this.getAnnotationPieSlicePath(E.seqDatum.uncertainBegin,E.seqDatum.begin,E)),E.fuzzyStart.setAttribute("stroke-width","1"),E.fuzzyStart.setAttribute("fill-opacity","0.6"),E.fuzzyStart.name=A,E.fuzzyStart.onmouseover=n,this.annotationsSvgGroup.appendChild(E.fuzzyStart)),E.seqDatum.begin&&E.seqDatum.end){E.certain=document.createElementNS(c,"path");var L=E.seqDatum.begin,N=E.seqDatum.end;E.seqDatum.uncertainBegin&&(L+=1),E.seqDatum.uncertainEnd&&(N-=1),this.expanded?E.certain.setAttribute("d",this.getAnnotationRectPath(L,N,E)):E.certain.setAttribute("d",this.getAnnotationPieSlicePath(L,N,E)),E.certain.setAttribute("stroke-width","1"),E.certain.name=A,E.certain.onmouseover=n,this.annotationsSvgGroup.appendChild(E.certain)}E.seqDatum.uncertainEnd&&(E.fuzzyEnd=document.createElementNS(c,"path"),this.expanded?E.fuzzyEnd.setAttribute("d",this.getAnnotationRectPath(E.seqDatum.end,E.seqDatum.uncertainEnd,E)):E.fuzzyEnd.setAttribute("d",this.getAnnotationPieSlicePath(E.seqDatum.end,E.seqDatum.uncertainEnd,E)),E.fuzzyEnd.setAttribute("stroke-width","1"),E.fuzzyEnd.setAttribute("fill-opacity","0.6"),E.fuzzyEnd.name=A,E.fuzzyEnd.onmouseover=n,this.annotationsSvgGroup.appendChild(E.fuzzyEnd))}}}catch(t){k.e(t)}finally{k.f()}}}}catch(t){m.e(t)}finally{m.f()}},b.stepsInArc=5,b.prototype.getAnnotationPieSlicePath=function(t,n,e){var r,i,o,a,s,u=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],c=this.getSymbolRadius(),h=e.rung;-1===h?(i=0,r=c):r=(i=h*(o=c/this.rungCount))+o,"n-n"===t?(a=-20,s=0):"c-c"===n?(a=0,s=20):(a=(t-1)/this.size*360,s=(n-1)/this.size*360);var f=0;(s-a>180||s===a)&&(f=1);var p=l([0,i],[0,0],a-180),y=l([0,r],[0,0],a-180),d=l([0,r],[0,0],s-180),g=l([0,i],[0,0],s-180),v="M"+p[0]+","+p[1]+" L"+y[0]+","+y[1];if(u)v+=" A"+r+","+r+" 0 "+f+" 1 "+d[0]+","+d[1];else for(var x=0;x<=b.stepsInArc;x++){var m=a+(s-a)/b.stepsInArc*x,w=l([0,r],[0,0],m-180);v+=" L"+w[0]+","+w[1]}if(u)v+=" L"+g[0]+","+g[1],v+=" A"+i+","+i+" 0 "+f+" 0 "+p[0]+","+p[1];else for(var _=b.stepsInArc;_>=0;_--){var S=a+(s-a)/b.stepsInArc*_,M=l([0,i],[0,0],S-180);v+=" L"+M[0]+","+M[1]}return v+=" Z"},b.prototype.getAnnotationRectPath=function(t,n,e){var r,i,o,a,s,u=e.rung;-1===u?(i=b.STICKHEIGHT/2,r=-b.STICKHEIGHT/2):(o=b.STICKHEIGHT/this.rungCount,i=(r=-b.STICKHEIGHT/2+u*o)+o),"n-n"===t?(a=this.getResXWithStickZoom(.5)-20,s=20):"c-c"===n?(a=this.getResXWithStickZoom(this.size+.5),s=20):(a=this.getResXWithStickZoom(t-.5),s=(n-t+1)*this.stickZoom);for(var c="M"+a+","+i+" L"+a+","+r,l=0;l<=b.stepsInArc;l++){c+=" L "+(a+s*(l/b.stepsInArc))+","+r}for(var h=b.stepsInArc;h>=0;h--){c+=" L "+(a+s*(h/b.stepsInArc))+","+i}return c+=" Z"},w.prototype=new b,_.prototype=new p,S.prototype=new p,S.prototype.getSymbolRadius=function(){return 21},M.prototype=new p,k.prototype=new p;var E=e(1),A=e(2);function L(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=function(t,n){if(!t)return;if("string"==typeof t)return N(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return N(t,n)}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function N(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function z(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function j(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e1)return t})).forEach((function(n){if(F(e,"id",n.interactorRef))for(var i=function(e){var i=JSON.parse(JSON.stringify(n));i.id=i.id+"_"+e,i.cloneParentID=n.id,i.cloneIteration=e,n.cloned=!0,i.features&&i.features.forEach((function(t){t.clonedfrom=t.id,t.id=t.id+"_"+e,t.sequenceData.forEach((function(t){t.participantRef=i.id}))})),t.participants.push(i),r.push(i)},o=0;o-1){var i=JSON.parse(JSON.stringify(e));i.id=e.id+"_"+n.id,i.linkedFeatures=[],i.linkedFeatures.push(n.id),F(t.participants,"id",i.parentParticipant).features.push(i)}}))}))})),n.forEach((function(t){t.participants.forEach((function(t){t.stoichiometry=null}))})),t}function F(t,n,e){for(var r=0;r=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function U(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e2&&void 0!==arguments[2])||arguments[2];(t="object"===X(t)?t:JSON.parse(t)).data=t.data.reverse(),n.features=new Map;var r=new Map;n.proteinCount=0,n.interactors=new Map;var i,o=H(t.data);try{for(o.s();!(i=o.n()).done;){var a=i.value;"interactor"===a.object&&(n.interactors.set(a.id,a),0===a.id.indexOf("uniprotkb_")&&n.proteinCount++)}}catch(t){o.e(t)}finally{o.f()}e?xt():wt();var s,c=H(t.data);try{for(c.s();!(s=c.n()).done;){var l=s.value;if("interaction"===l.object){var h,f=H(l.participants);try{for(f.s();!(h=f.n()).done;){var p=h.value,y=new Array(0);p.features&&(y=p.features);var g,v=H(y);try{for(v.s();!(g=v.n()).done;){var x=g.value,m=x.sequenceData;if(x.linkedFeatures)for(var b=x.linkedFeatures,E=b.length,A=0;Ar&&(r=u.stoichiometry-0)}}catch(t){s.e(t)}finally{s.f()}}}}catch(t){i.e(t)}finally{i.f()}r<30&&(t=B(t)),bt();var c,l=H(t.data);try{for(l.s();!(c=l.n()).done;){var h=c.value;if("interaction"===h.object){var f=h.id||_t(h),p=n.allNaryLinks.get(f);void 0===p&&(p=new O(f,n),n.allNaryLinks.set(f,p),h.naryId=f);var y,d=H(h.participants);try{for(d.s();!(y=d.n()).done;){var g=y.value,v=g.interactorRef,x=v+"("+g.id+")",m=n.participants.get(x);if(void 0===m)m=mt(n.interactors.get(v),x,v),n.participants.set(x,m);if(m.naryLinks.set(f,p),-1===p.participants.indexOf(m)&&p.participants.push(m),g.stoichiometry)n.participants.get(x).addStoichiometryLabel(g.stoichiometry)}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){l.e(t)}finally{l.f()}}function mt(e,i,o){var a;if(void 0===e||"MI:1302"===e.type.id){var s,u=!1,c=H(t.data);try{for(c.s();!(s=c.n()).done;){var l=s.value;if("interaction"===l.object&&l.id===o){u=!0;break}}}catch(t){c.e(t)}finally{c.f()}u?(a=new C(i,n,o),r.set(i,a)):a=new P(i,n,o,e)}else"MI:1304"===e.type.id||"MI:1305"===e.type.id||"MI:1307"===e.type.id||"MI:1306"===e.type.id?a=new T(i,n,e,e.label):"MI:1100"===e.type.id||"MI:0904"===e.type.id||"MI:0328"===e.type.id?a=new _(i,n,e,e.label):"MI:0326"===e.type.id||"MI:0327"===e.type.id?a=new w(i,n,e,e.label,e.sequence):"MI:0250"===e.type.id?a=new S(i,n,e,e.label):"MI:0320"===e.type.id||"MI:0321"===e.type.id||"MI:0322"===e.type.id||"MI:0323"===e.type.id||"MI:2190"===e.type.id||"MI:0324"===e.type.id||"MI:0679"===e.type.id||"MI:0608"===e.type.id||"MI:0611"===e.type.id||"MI:0610"===e.type.id||"MI:0607"===e.type.id||"MI:0609"===e.type.id||"MI:0325"===e.type.id||"IA:2966"===e.type.id||"MI:0318"===e.type.id?a=new k(i,n,e,e.label):"MI:0319"===e.type.id||"MI:0681"===e.type.id||"MI:0680"===e.type.id?a=new M(i,n,e,e.label):alert("Unrecognised type:"+e.type.name);return a}function bt(){var e,r=H(t.data);try{for(r.s();!(e=r.n()).done;){var i=e.value;if("interaction"===i.object){var o,a=H(i.participants);try{for(a.s();!(o=a.n()).done;){var s=o.value,u=new Array(0);s.features&&(u=s.features);for(var c=u.length,l=0;l<"+u:u+"><"+s;var c=n.allSequenceLinks.get(a);if(void 0===c){var l,h=[],f=H(t);try{for(f.s();!(l=f.n()).done;){var p=l.value;h.push(new d(St(p),p.pos))}}catch(t){f.e(t)}finally{f.f()}var y,g=[],v=H(r);try{for(v.s();!(y=v.n()).done;){var x=y.value;g.push(new d(St(x),x.pos))}}catch(t){v.e(t)}finally{v.f()}c=new q(a,h,g,n,i),n.allSequenceLinks.set(a,c)}var m=_t(i);return n.allNaryLinks.get(m).sequenceLinks.set(a,c),c}function kt(t,e){var r="-"+t.id+"-"+t.id,i=n.allUnaryLinks.get(r);void 0===i&&(i=new V(r,n,t),n.allUnaryLinks.set(r,i),t.appLink=i);var o=_t(e);return n.allNaryLinks.get(o).unaryLinks.set(r,i),i}function Et(t,e,r){var i,o,a;t.idr)&&(r=c)}if(!isNaN(parseFloat(a.uncertainEnd))&&isFinite(a.uncertainEnd)){var l=1*a.uncertainEnd;(null===r||l>r)&&(r=l)}}return n.getResidueCoordinates((e+r)/2,0)}var r,i,o=this.fromSequenceData[0].participant,a=this.toSequenceData[0].participant;o.expanded&&(r=e(this.fromSequenceData,o)),a.expanded&&(i=e(this.toSequenceData,a)),o.expanded||(r=o.getPosition(i)),a.expanded||(i=a.getPosition(r));var s=r,u=i,c=r[0]-i[0],l=r[1]-i[1],h=Math.atan2(l,c)/(2*Math.PI)*360;h<0&&(h+=360);var f=h-o.rotation;f<0&&(f+=360);var p=10;f<180&&(p=-10);var y=o.rotation/360*Math.PI*2;f>180&&(y-=Math.PI),(f=h-a.rotation)<0&&(f+=360);var d=10;f>180&&(d=-10);var g=a.rotation/360*Math.PI*2;f<180&&(g-=Math.PI);var v=[r[0]+30*Math.sin(y)*this.app.z,r[1]-30*Math.cos(y)*this.app.z];o.expanded||(v=r);var x=[i[0]+30*Math.sin(g)*this.app.z,i[1]-30*Math.cos(g)*this.app.z];a.expanded||(x=i);for(var m,b=[(v[0]+x[0])/2,(v[1]+x[1])/2],w=this.fromSequenceData.length,_=this.toSequenceData.length,S="M"+b[0]+","+b[1],M="M"+b[0]+","+b[1],k=0;k=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function $(t,n){if(t){if("string"==typeof t)return J(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?J(t,n):void 0}}function J(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=0;)et.pruneInvisibleSubtrees(i[a],o[a])}}},parentChain:function(t,n){for(var e=t.ownerDocument||document,r=[];t.parentNode!==e&&null!==t.parentNode;)t=t.parentNode,r.push({id:t.id,class:t.getAttribute("class")||""});return r.forEach((function(t){var e={id:!1,class:!1},r=t.class.split(" ").filter((function(t){return t.length>0}));n.forEach((function(n){for(var i=0;i=0){e.class=!0;break}t.id&&n.indexOf("#"+t.id)>=0&&(e.id=!0)})),Object.keys(e).forEach((function(n){e[n]||(t[n]=void 0)}))})),r},usedStyles:function(t,n,e){for(var r,i=[],o=(t.ownerDocument||document).styleSheets,a=0;a0),n&&!e||(u|=t.matches(r.selectorText))}catch(t){console.warn("CSS selector error: "+r.selectorText+". Often angular issue.",t)}u&&i.push(r.cssText)}}return i},makeXMLStr:function(t,n){var e=t.serializeToString(n);return e=e.split('xmlns="http://www.w3.org/1999/xhtml"').join("")}};function rt(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,n)||ot(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function it(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=ot(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function ot(t,n){if(t){if("string"==typeof t)return at(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?at(t,n):void 0}}function at(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function ct(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);eComplexViewer "+r.a+"by Rappsilber Laboratory",this.acknowledgement.appendChild(h),h.setAttribute("font-size","8pt"),this.svgElement.appendChild(this.acknowledgement),this.naryLinks=document.createElementNS(c,"g"),this.naryLinks.setAttribute("id","naryLinks"),this.container.appendChild(this.naryLinks),this.p_pLinksWide=document.createElementNS(c,"g"),this.p_pLinksWide.setAttribute("id","p_pLinksWide"),this.container.appendChild(this.p_pLinksWide),this.highlights=document.createElementNS(c,"g"),this.highlights.setAttribute("class","highlights"),this.container.appendChild(this.highlights),this.res_resLinks=document.createElementNS(c,"g"),this.res_resLinks.setAttribute("id","res_resLinks"),this.container.appendChild(this.res_resLinks),this.p_pLinks=document.createElementNS(c,"g"),this.p_pLinks.setAttribute("id","p_pLinks"),this.container.appendChild(this.p_pLinks),this.proteinUpper=document.createElementNS(c,"g"),this.proteinUpper.setAttribute("id","proteinUpper"),this.container.appendChild(this.proteinUpper),this.selfRes_resLinks=document.createElementNS(c,"g"),this.selfRes_resLinks.setAttribute("id","res_resLinks"),this.container.appendChild(this.selfRes_resLinks),this.svgElement.appendChild(this.container),this.tooltip=document.createElementNS(c,"text"),this.tooltip.setAttribute("x","0"),this.tooltip.setAttribute("y","0");var f=document.createTextNode("tooltip");this.tooltip.classList.add("label","tooltip"),this.tooltip.appendChild(f),this.tooltip_bg=document.createElementNS(c,"rect"),this.tooltip_bg.classList.add("tooltip-background"),this.tooltip_subBg=document.createElementNS(c,"rect"),this.tooltip_subBg.classList.add("tooltip-sub-background"),this.svgElement.appendChild(this.tooltip_subBg),this.svgElement.appendChild(this.tooltip_bg),this.svgElement.appendChild(this.tooltip),this.annotationSetsShown=new Map,this.annotationSetsShown.set("Interactor",!1),this.annotationSetsShown.set("UniprotKB",!1),this.annotationSetsShown.set("Superfamily",!1),this.annotationSetsShown.set("MI Features",!0),this.clear()}lt.prototype.createHatchedFill=function(t,n){if(!this.checkedHatchNames.has(t)){var e=this.defs.append("pattern").attr("id",t).attr("patternUnits","userSpaceOnUse").attr("x",0).attr("y",0).attr("width",12).attr("height",12).attr("patternTransform","rotate(45)");e.append("rect").attr("x",0).attr("y",2).attr("width",12).attr("height",4).attr("fill",n),e.append("rect").attr("x",0).attr("y",8).attr("width",12).attr("height",4).attr("fill",n),this.checkedHatchNames.add(t)}},lt.prototype.clear=function(){this.d3cola.stop();var t,n=[],e=ut(a);try{for(e.s();!(t=e.n()).done;){var r=t.value,o=i.hsl(r);o.l=.9,n.push(o+"")}}catch(t){e.e(t)}finally{e.f()}O.naryColors=i.scale.ordinal().range(n),this.defs.textContent="",this.checkedHatchNames=new Set,this.naryLinks.textContent="",this.p_pLinksWide.textContent="",this.highlights.textContent="",this.p_pLinks.textContent="",this.res_resLinks.textContent="",this.proteinUpper.textContent="",this.selfRes_resLinks.textContent="",this.dragElement=null,this.dragStart={},this.participants=new Map,this.allNaryLinks=new Map,this.allBinaryLinks=new Map,this.allUnaryLinks=new Map,this.allSequenceLinks=new Map,this.complexes=[],this.proteinCount=0,this.z=1,this.hideTooltip(),this.state=this.STATES.MOUSE_UP},lt.prototype.collapseProtein=function(){i.select(".custom-menu-margin").style("display","none"),this.contextMenuProt.setForm(0,this.contextMenuPoint),this.contextMenuProt=null},lt.prototype.init=function(){this.d3cola.stop();var t,n=0,e=ut(this.participants.values());try{for(e.s();!(t=e.n()).done;){var r=t.value;r.size>n&&(n=r.size)}}catch(t){e.e(t)}finally{e.f()}var o,a,s,u=.8*this.svgElement.parentNode.clientWidth/n;this.defaultBarScale=(o=this.barScales,a=u,0===(s=(0,i.bisector((function(t){return t})).left)(o,a))||1===s?o[1]:s===o.length?o[o.length-1]:o[s-1]);var c,l=ut(this.participants.values());try{for(l.s();!(c=l.n()).done;){var h=c.value;"complex"!=h.type&&(h.setPosition(-500,-500),this.proteinUpper.appendChild(h.upperGroup))}}catch(t){l.e(t)}finally{l.f()}var f,p=ut(this.participants.values());try{for(p.s();!(f=p.n()).done;){var y=f.value;"protein"===y.type&&(y.stickZoom=this.defaultBarScale,this.participants.size<4&&y.toStickNoTransition())}}catch(t){p.e(t)}finally{p.f()}this.updateAnnotations();var d=this;!function(t,n){var e,r=Array.from(t.participants.values()).filter((function(t){return"protein"===t.type})),i=0,o=r.length,a=W(r);try{for(a.s();!(e=a.n()).done;){var s=e.value,u=new RegExp("[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}![-]","i").exec(s.json.identifier.id);u&&u[0]==s.json.identifier.id.trim()&&(tt(s,(function(){++i===o&&n()})),Q(s,(function(){++i===o&&n()})))}}catch(t){a.e(t)}finally{a.f()}}(this,(function(){d.updateAnnotations()})),this.checkLinks(),this.autoLayout()},lt.prototype.zoomToExtent=function(){var t=this.svgElement.parentNode.clientWidth,n=this.svgElement.parentNode.clientHeight,e=this.container.getBBox(),r=(t/e.width).toFixed(4)-0,i=(n/e.height).toFixed(4)-0;if((ithis.z&&(o=this.z);var a=-e.x+20/o,s=-e.y+20/o;this.container.setAttribute("transform","scale("+o+") translate("+a+" "+s+") "),this.z=this.container.getCTM().inverse().a}else{var u=t-e.width,c=n-e.height,l=u/2-e.x,h=c/2-e.y;this.container.setAttribute("transform","scale(1) translate("+l+" "+h+")"),this.z=1}this.acknowledgement.setAttribute("transform","translate("+(t-150)+", "+(n-30)+")")},lt.prototype.mouseDown=function(t){return t.preventDefault(),this.d3cola.stop(),this.dragStart=t,!1},lt.prototype.touchStart=function(t){return t.preventDefault(),this.d3cola.stop(),this.dragStart=t,!1},lt.prototype.mouseMove=function(t){this.move(t)},lt.prototype.touchMove=function(t){this.move(t)},lt.prototype.move=function(t){var n=this.getEventPoint(t),e=this.mouseToSVG(n.x,n.y);if(null!=this.dragElement){this.hideTooltip();var r=this.getEventPoint(this.dragStart),i=this.mouseToSVG(r.x,r.y),o=i.x-e.x,a=i.y-e.y;if(this.state===this.STATES.DRAGGING){if(this.dragElement.ix)this.dragElement.changePosition(o,a),this.dragElement.setAllLinkCoordinates();else{var s,u=ut(this.dragElement.participants);try{for(u.s();!(s=u.n()).done;){s.value.changePosition(o,a)}}catch(t){u.e(t)}finally{u.f()}this.setAllLinkCoordinates()}this.dragStart=t}else Math.sqrt(o*o+a*a)>5*this.z&&(this.state=this.STATES.DRAGGING)}else this.showTooltip(n);return!1},lt.prototype.mouseUp=function(t){var n=(new Date).getTime();this.preventDefaultsAndStopPropagation(t);var e=this.getEventPoint(t);isNaN(e.x)&&(e=this.getEventPoint(this.dragStart));var r=this.mouseToSVG(e.x,e.y);if(this.dragElement&&"protein"===this.dragElement.type&&this.state!==this.STATES.DRAGGING&&this.state!==this.STATES.ROTATING)if(this.dragElement.expanded){this.contextMenuProt=this.dragElement,this.contextMenuPoint=r;var o,a,s=i.select(".custom-menu-margin");t.pageX?(o=t.pageX,a=t.pageY):(o=this.dragStart.touches[0].pageX,a=this.dragStart.touches[0].pageY),s.style("top",a-20+"px").style("left",o-20+"px").style("display","block"),i.select(".scaleButton_"+100*this.dragElement.stickZoom).property("checked",!0)}else this.dragElement.setForm(1);return this.dragElement=null,this.dragStart={},this.state=this.STATES.MOUSE_UP,this.lastMouseUp=n,!1},lt.prototype.getEventPoint=function(t){var n,e,r=this.svgElement.createSVGPoint(),i=this.svgElement.parentNode,o=0,a=0;do{o+=i.offsetTop||0,a+=i.offsetLeft||0,i=i.offsetParent}while(i);return t.touches&&t.touches.length>0?(n=t.touches[0].pageX,e=t.touches[0].pageY):t.pageX&&(n=t.pageX,e=t.pageY),r.x=n-a,r.y=e-o,r},lt.prototype.preventDefaultsAndStopPropagation=function(t){t.stopPropagation&&t.stopPropagation(),null!=t.cancelBubble&&(t.cancelBubble=!0),t.preventDefault&&t.preventDefault()},lt.prototype.autoLayout=function(){this.d3cola.stop();var t,n=this,e=ut(n.participants.values());try{for(e.s();!(t=e.n()).done;){var r=t.value;delete r.x,delete r.y,delete r.px,delete r.py,delete r.bounds,r.fixed=0}}catch(t){e.e(t)}finally{e.f()}var o,a=[],s=ut(n.participants.values());try{for(s.s();!(o=s.n()).done;){var u=o.value;u.binaryLinks.size>2&&"complex"!==u.type&&a.push(u)}}catch(t){s.e(t)}finally{s.f()}var c=Array.from(n.participants.values()).filter((function(t){return"complex"!==t.type}));function l(t,e){var r={};r.nodes=t,r.links=[];var o,a={},s=0,u=ut(t);try{for(u.s();!(o=u.n()).done;){a[o.value.id]=s,s++}}catch(t){u.e(t)}finally{u.f()}var h,f=ut(n.allBinaryLinks.values());try{for(f.s();!(h=f.n()).done;){var p=h.value,y=p.participants[0],d=p.participants[1],g=y,v=d;if(g!==v&&-1!==t.indexOf(g)&&-1!==t.indexOf(v)){var x={};x.source=a[y.id],x.target=a[d.id],x.id=p.id,r.links.push(x)}}}catch(t){f.e(t)}finally{f.f()}var m=[];if(!e&&n.complexes){var b,w=ut(n.complexes);try{for(w.s();!(b=w.n()).done;){var _=b.value;_.leaves=[],_.groups=[];var S,M=ut(_.naryLink.participants);try{for(M.s();!(S=M.n()).done;){var k=S.value;"complex"!==k.type&&_.leaves.push(r.nodes.indexOf(k))}}catch(t){M.e(t)}finally{M.f()}m.push(_)}}catch(t){w.e(t)}finally{w.f()}var E,A=ut(n.complexes);try{for(A.s();!(E=A.n()).done;){var L,N=E.value,C=ut(N.naryLink.participants);try{for(C.s();!(L=C.n()).done;){var P=L.value;"complex"===P.type&&N.groups.push(m.indexOf(P))}}catch(t){C.e(t)}finally{C.f()}}}catch(t){A.e(t)}finally{A.f()}}delete n.d3cola._lastStress,delete n.d3cola._alpha,delete n.d3cola._descent,delete n.d3cola._rootGroup;var T,I,z=t.length<30?30:20,D=n.svgElement.parentNode.clientWidth,O=n.svgElement.parentNode.clientHeight;n.d3cola.size([O-40,D-40]).nodes(r.nodes).groups(m).links(r.links).avoidOverlaps(!0),n.debug&&((T=i.select(n.container).selectAll(".group").data(m)).enter().append("rect").classed("group",!0).attr({rx:5,ry:5}).style("stroke","blue").style("fill","none"),(I=i.select(n.container).selectAll(".node").data(r.nodes)).enter().append("rect").classed("node",!0).attr({rx:5,ry:5}).style("stroke","red").style("fill","none"),T.exit().remove(),I.exit().remove());var q=Date.now();n.d3cola.symmetricDiffLinkLengths(z).on("tick",(function(){if(Date.now()-q>750){ +!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.complexviewer=n():t.complexviewer=n()}(window,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=10)}([function(t,n,e){var r,i;!function(){var o={version:"3.5.17"},a=[].slice,s=function(t){return a.call(t)},u=this.document;function c(t){return t&&(t.ownerDocument||t.document||t).documentElement}function l(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(u)try{s(u.documentElement.childNodes)[0].nodeType}catch(t){s=function(t){for(var n=t.length,e=new Array(n);n--;)e[n]=t[n];return e}}if(Date.now||(Date.now=function(){return+new Date}),u)try{u.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var h=this.Element.prototype,f=h.setAttribute,p=h.setAttributeNS,y=this.CSSStyleDeclaration.prototype,d=y.setProperty;h.setAttribute=function(t,n){f.call(this,t,n+"")},h.setAttributeNS=function(t,n,e){p.call(this,t,n,e+"")},y.setProperty=function(t,n,e){d.call(this,t,n+"",e)}}function g(t,n){return tn?1:t>=n?0:NaN}function v(t){return null===t?NaN:+t}function x(t){return!isNaN(t)}function m(t){return{left:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);r>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);r>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}o.ascending=g,o.descending=function(t,n){return nt?1:n>=t?0:NaN},o.min=function(t,n){var e,r,i=-1,o=t.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ir&&(e=r)}else{for(;++i=r){e=r;break}for(;++ir&&(e=r)}return e},o.max=function(t,n){var e,r,i=-1,o=t.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ie&&(e=r)}else{for(;++i=r){e=r;break}for(;++ie&&(e=r)}return e},o.extent=function(t,n){var e,r,i,o=-1,a=t.length;if(1===arguments.length){for(;++o=r){e=i=r;break}for(;++or&&(e=r),i=r){e=i=r;break}for(;++or&&(e=r),i1)return a/(u-1)},o.deviation=function(){var t=o.variance.apply(this,arguments);return t?Math.sqrt(t):t};var b=m(g);function w(t){return t.length}o.bisectLeft=b.left,o.bisect=o.bisectRight=b.right,o.bisector=function(t){return m(1===t.length?function(n,e){return g(t(n),e)}:t)},o.shuffle=function(t,n,e){(o=arguments.length)<3&&(e=t.length,o<2&&(n=0));for(var r,i,o=e-n;o;)i=Math.random()*o--|0,r=t[o+n],t[o+n]=t[i+n],t[i+n]=r;return t},o.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},o.pairs=function(t){for(var n=0,e=t.length-1,r=t[0],i=new Array(e<0?0:e);n=0;)for(n=(r=t[i]).length;--n>=0;)e[--a]=r[n];return e};var S=Math.abs;function _(t){for(var n=1;t*n%1;)n*=10;return n}function M(t,n){for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}function k(){this._=Object.create(null)}o.range=function(t,n,e){if(arguments.length<3&&(e=1,arguments.length<2&&(n=t,t=0)),(n-t)/e==1/0)throw new Error("infinite range");var r,i=[],o=_(S(e)),a=-1;if(t*=o,n*=o,(e*=o)<0)for(;(r=t+e*++a)>n;)i.push(r/o);else for(;(r=t+e*++a)=r.length)return n?n.call(e,o):t?o.sort(t):o;for(var u,c,l,h,f=-1,p=o.length,y=r[s++],d=new k;++f=r.length)return n;var o=[],a=i[e++];return n.forEach((function(n,r){o.push({key:n,values:t(r,e)})})),a?o.sort((function(t,n){return a(t.key,n.key)})):o}(a(o.map,t,0),0)},e.key=function(t){return r.push(t),e},e.sortKeys=function(t){return i[r.length-1]=t,e},e.sortValues=function(n){return t=n,e},e.rollup=function(t){return n=t,e},e},o.set=function(t){var n=new I;if(t)for(var e=0,r=t.length;e=0&&(r=t.slice(e+1),t=t.slice(0,e)),t)return arguments.length<2?this[t].on(r):this[t].on(r,n);if(2===arguments.length){if(null==n)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},o.event=null,o.requote=function(t){return t.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,U={}.__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};function X(t){return U(t,W),t}var Z=function(t,n){return n.querySelector(t)},Y=function(t,n){return n.querySelectorAll(t)},K=function(t,n){var e=t.matches||t[O(t,"matchesSelector")];return(K=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(Z=function(t,n){return Sizzle(t,n)[0]||null},Y=Sizzle,K=Sizzle.matchesSelector),o.selection=function(){return o.select(u.documentElement)};var W=o.selection.prototype=[];function $(t){return"function"==typeof t?t:function(){return Z(t,this)}}function J(t){return"function"==typeof t?t:function(){return Y(t,this)}}W.select=function(t){var n,e,r,i,o=[];t=$(t);for(var a=-1,s=this.length;++a=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),tt.hasOwnProperty(e)?{space:tt[e],local:t}:t}},W.attr=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node();return(t=o.ns.qualify(t)).local?e.getAttributeNS(t.space,t.local):e.getAttribute(t)}for(n in t)this.each(nt(n,t[n]));return this}return this.each(nt(t,n))},W.classed=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node(),r=(t=it(t)).length,i=-1;if(n=e.classList){for(;++i=0;)(e=r[i])&&(o&&o!==e.nextSibling&&o.parentNode.insertBefore(e,o),o=e);return this},W.sort=function(t){t=pt.apply(this,arguments);for(var n=-1,e=this.length;++n=n&&(n=i+1);!(a=s[n])&&++n0&&(t=t.slice(0,i));var u=mt.get(t);function c(){var n=this[r];n&&(this.removeEventListener(t,n,n.$),delete this[r])}return u&&(t=u,a=wt),i?n?function(){var i=a(n,s(arguments));c.call(this),this.addEventListener(t,this[r]=i,i.$=e),i._=n}:c:n?R:function(){var n,e=new RegExp("^__on([^.]+)"+o.requote(t)+"$");for(var r in this)if(n=r.match(e)){var i=this[r];this.removeEventListener(n[1],i,i.$),delete this[r]}}}o.selection.enter=dt,o.selection.enter.prototype=gt,gt.append=W.append,gt.empty=W.empty,gt.node=W.node,gt.call=W.call,gt.size=W.size,gt.select=function(t){for(var n,e,r,i,o,a=[],s=-1,u=this.length;++s0?1:t<0?-1:0}function qt(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function Rt(t){return t>1?0:t<-1?Pt:Math.acos(t)}function Gt(t){return t>1?It:t<-1?-It:Math.asin(t)}function jt(t){return((t=Math.exp(t))+1/t)/2}function Vt(t){return(t=Math.sin(t/2))*t}var Bt=Math.SQRT2;o.interpolateZoom=function(t,n){var e,r,i=t[0],o=t[1],a=t[2],s=n[0],u=n[1],c=n[2],l=s-i,h=u-o,f=l*l+h*h;if(f0&&(t=t.transition().duration(d)),t.call(S.event)}function A(){s&&s.domain(a.range().map((function(t){return(t-f.x)/f.k})).map(a.invert)),h&&h.domain(c.range().map((function(t){return(t-f.y)/f.k})).map(c.invert))}function L(t){g++||t({type:"zoomstart"})}function N(t){A(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function P(t){--g||(t({type:"zoomend"}),n=null)}function C(){var t=this,n=w.of(t,arguments),e=0,r=o.select(l(t)).on(x,s).on(m,u),i=_(o.mouse(t)),a=Mt(t);function s(){e=1,k(o.mouse(t),i),N(n)}function u(){r.on(x,null).on(m,null),a(e),P(n)}ws.call(t),L(n)}function T(){var t,n=this,e=w.of(n,arguments),r={},a=0,s=".zoom-"+o.event.changedTouches[0].identifier,u="touchmove"+s,c="touchend"+s,l=[],h=o.select(n),p=Mt(n);function y(){var e=o.touches(n);return t=f.k,e.forEach((function(t){t.identifier in r&&(r[t.identifier]=_(t))})),e}function d(){var t=o.event.target;o.select(t).on(u,g).on(c,x),l.push(t);for(var e=o.event.changedTouches,s=0,h=e.length;s1){v=p[0];var m=p[1],b=v[0]-m[0],w=v[1]-m[1];a=b*b+w*w}}function g(){var s,u,c,l,h=o.touches(n);ws.call(n);for(var f=0,p=h.length;f360?t-=360:t<0&&(t+=360),t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,n=isNaN(n)||n<0?0:n>1?1:n,r=2*(e=e<0?0:e>1?1:e)-(i=e<=.5?e*(1+n):e+n-e*n),new un(o(t+120),o(t),o(t-120))}function Wt(t,n,e){return this instanceof Wt?(this.h=+t,this.c=+n,void(this.l=+e)):arguments.length<2?t instanceof Wt?new Wt(t.h,t.c,t.l):rn(t instanceof Qt?t.l:(t=dn((t=o.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new Wt(t,n,e)}Yt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new Zt(this.h,this.s,this.l/t)},Yt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Zt(this.h,this.s,t*this.l)},Yt.rgb=function(){return Kt(this.h,this.s,this.l)},o.hcl=Wt;var $t=Wt.prototype=new Xt;function Jt(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),new Qt(e,Math.cos(t*=zt)*n,Math.sin(t)*n)}function Qt(t,n,e){return this instanceof Qt?(this.l=+t,this.a=+n,void(this.b=+e)):arguments.length<2?t instanceof Qt?new Qt(t.l,t.a,t.b):t instanceof Wt?Jt(t.h,t.c,t.l):dn((t=un(t)).r,t.g,t.b):new Qt(t,n,e)}$t.brighter=function(t){return new Wt(this.h,this.c,Math.min(100,this.l+tn*(arguments.length?t:1)))},$t.darker=function(t){return new Wt(this.h,this.c,Math.max(0,this.l-tn*(arguments.length?t:1)))},$t.rgb=function(){return Jt(this.h,this.c,this.l).rgb()},o.lab=Qt;var tn=18,nn=Qt.prototype=new Xt;function en(t,n,e){var r=(t+16)/116,i=r+n/500,o=r-e/200;return new un(sn(3.2404542*(i=.95047*on(i))-1.5371385*(r=1*on(r))-.4985314*(o=1.08883*on(o))),sn(-.969266*i+1.8760108*r+.041556*o),sn(.0556434*i-.2040259*r+1.0572252*o))}function rn(t,n,e){return t>0?new Wt(Math.atan2(e,n)*Dt,Math.sqrt(n*n+e*e),t):new Wt(NaN,NaN,t)}function on(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function an(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function sn(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function un(t,n,e){return this instanceof un?(this.r=~~t,this.g=~~n,void(this.b=~~e)):arguments.length<2?t instanceof un?new un(t.r,t.g,t.b):pn(""+t,un,Kt):new un(t,n,e)}function cn(t){return new un(t>>16,t>>8&255,255&t)}function ln(t){return cn(t)+""}nn.brighter=function(t){return new Qt(Math.min(100,this.l+tn*(arguments.length?t:1)),this.a,this.b)},nn.darker=function(t){return new Qt(Math.max(0,this.l-tn*(arguments.length?t:1)),this.a,this.b)},nn.rgb=function(){return en(this.l,this.a,this.b)},o.rgb=un;var hn=un.prototype=new Xt;function fn(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function pn(t,n,e){var r,i,o,a=0,s=0,u=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return n(vn(i[0]),vn(i[1]),vn(i[2]))}return(o=xn.get(t))?n(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(a=(3840&o)>>4,a|=a>>4,s=240&o,s|=s>>4,u=15&o,u|=u<<4):7===t.length&&(a=(16711680&o)>>16,s=(65280&o)>>8,u=255&o)),n(a,s,u))}function yn(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),s=a-o,u=(a+o)/2;return s?(i=u<.5?s/(a+o):s/(2-a-o),r=t==a?(n-e)/s+(n0&&u<1?0:r),new Zt(r,i,u)}function dn(t,n,e){var r=an((.4124564*(t=gn(t))+.3575761*(n=gn(n))+.1804375*(e=gn(e)))/.95047),i=an((.2126729*t+.7151522*n+.072175*e)/1);return Qt(116*i-16,500*(r-i),200*(i-an((.0193339*t+.119192*n+.9503041*e)/1.08883)))}function gn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function vn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}hn.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&n=200&&n<300||304===n){try{t=e.call(i,c)}catch(t){return void a.error.call(i,t)}a.load.call(i,t)}else a.error.call(i,c)}return this.XDomainRequest&&!("withCredentials"in c)&&/^(http(s)?:)?\/\//.test(t)&&(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=h:c.onreadystatechange=function(){c.readyState>3&&h()},c.onprogress=function(t){var n=o.event;o.event=t;try{a.progress.call(i,c)}finally{o.event=n}},i.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?u[t]:(null==n?delete u[t]:u[t]=n+"",i)},i.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",i):n},i.responseType=function(t){return arguments.length?(l=t,i):l},i.response=function(t){return e=t,i},["get","post"].forEach((function(t){i[t]=function(){return i.send.apply(i,[t].concat(s(arguments)))}})),i.send=function(e,r,o){if(2===arguments.length&&"function"==typeof r&&(o=r,r=null),c.open(e,t,!0),null==n||"accept"in u||(u.accept=n+",*/*"),c.setRequestHeader)for(var s in u)c.setRequestHeader(s,u[s]);return null!=n&&c.overrideMimeType&&c.overrideMimeType(n),null!=l&&(c.responseType=l),null!=o&&i.on("error",o).on("load",(function(t){o(null,t)})),a.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},o.rebind(i,a,"on"),null==r?i:i.get(function(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}(r))}xn.forEach((function(t,n){xn.set(t,cn(n))})),o.functor=mn,o.xhr=bn(z),o.dsv=function(t,n){var e=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function i(t,e,r){arguments.length<3&&(r=e,e=null);var i=wn(t,n,null==e?o:a(e),r);return i.row=function(t){return arguments.length?i.response(null==(e=t)?o:a(t)):e},i}function o(t){return i.parse(t.responseText)}function a(t){return function(n){return i.parse(n.responseText,t)}}function s(n){return n.map(u).join(t)}function u(t){return e.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,n){var e;return i.parseRows(t,(function(t,r){if(e)return e(t,r-1);var i=new Function("d","return {"+t.map((function(t,n){return JSON.stringify(t)+": d["+n+"]"})).join(",")+"}");e=n?function(t,e){return n(i(t),e)}:i}))},i.parseRows=function(t,n){var e,i,o={},a={},s=[],u=t.length,c=0,l=0;function h(){if(c>=u)return a;if(i)return i=!1,o;var n=c;if(34===t.charCodeAt(n)){for(var e=n;e++24?(isFinite(n)&&(clearTimeout(kn),kn=setTimeout(Ln,n)),Mn=0):(Mn=1,En(Ln))}function Nn(){for(var t=Date.now(),n=Sn;n;)t>=n.t&&n.c(t-n.t)&&(n.c=null),n=n.n;return t}function Pn(){for(var t,n=Sn,e=1/0;n;)n.c?(n.t8?function(t){return t/e}:function(t){return t*e},symbol:t}}));function In(t){var n=t.decimal,e=t.thousands,r=t.grouping,i=t.currency,a=r&&e?function(t,n){for(var i=t.length,o=[],a=0,s=r[0],u=0;i>0&&s>0&&(u+s+1>n&&(s=Math.max(1,n-u)),o.push(t.substring(i-=s,i+s)),!((u+=s+1)>n));)s=r[a=(a+1)%r.length];return o.reverse().join(e)}:z;return function(t){var e=zn.exec(t),r=e[1]||" ",s=e[2]||">",u=e[3]||"-",c=e[4]||"",l=e[5],h=+e[6],f=e[7],p=e[8],y=e[9],d=1,g="",v="",x=!1,m=!0;switch(p&&(p=+p.substring(1)),(l||"0"===r&&"="===s)&&(l=r="0",s="="),y){case"n":f=!0,y="g";break;case"%":d=100,v="%",y="f";break;case"p":d=100,v="%",y="r";break;case"b":case"o":case"x":case"X":"#"===c&&(g="0"+y.toLowerCase());case"c":m=!1;case"d":x=!0,p=0;break;case"s":d=-1,y="r"}"$"===c&&(g=i[0],v=i[1]),"r"!=y||p||(y="g"),null!=p&&("g"==y?p=Math.max(1,Math.min(21,p)):"e"!=y&&"f"!=y||(p=Math.max(0,Math.min(20,p)))),y=Dn.get(y)||On;var b=l&&f;return function(t){var e=v;if(x&&t%1)return"";var i=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===u?"":u;if(d<0){var c=o.formatPrefix(t,p);t=c.scale(t),e=c.symbol+v}else t*=d;var w,S,_=(t=y(t,p)).lastIndexOf(".");if(_<0){var M=m?t.lastIndexOf("e"):-1;M<0?(w=t,S=""):(w=t.substring(0,M),S=t.substring(M))}else w=t.substring(0,_),S=n+t.substring(_+1);!l&&f&&(w=a(w,1/0));var k=g.length+w.length+S.length+(b?0:i.length),E=k"===s?E+i+t:"^"===s?E.substring(0,k>>=1)+i+t+E.substring(k):i+(b?t:E+t))+e}}}o.formatPrefix=function(t,n){var e=0;return(t=+t)&&(t<0&&(t*=-1),n&&(t=o.round(t,Cn(t,n))),e=1+Math.floor(1e-12+Math.log(t)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),Tn[8+e/3]};var zn=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Dn=o.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(t,n){return(t=o.round(t,Cn(t,n))).toFixed(Math.max(0,Math.min(20,Cn(t*(1+1e-15),n))))}});function On(t){return t+""}var qn=o.time={},Rn=Date;function Gn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Gn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){jn.setUTCDate.apply(this._,arguments)},setDay:function(){jn.setUTCDay.apply(this._,arguments)},setFullYear:function(){jn.setUTCFullYear.apply(this._,arguments)},setHours:function(){jn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){jn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){jn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){jn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){jn.setUTCSeconds.apply(this._,arguments)},setTime:function(){jn.setTime.apply(this._,arguments)}};var jn=Date.prototype;function Vn(t,n,e){function r(n){var e=t(n),r=o(e,1);return n-e1)for(;a=c)return-1;if(37===(i=n.charCodeAt(s++))){if(a=n.charAt(s++),!(o=S[a in Hn?n.charAt(s++):a])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}l.utc=function(t){var n=l(t);function e(t){try{var e=new(Rn=Gn);return e._=t,n(e)}finally{Rn=Date}}return e.parse=function(t){try{Rn=Gn;var e=n.parse(t);return e&&e._}finally{Rn=Date}},e.toString=n.toString,e},l.multi=l.utc.multi=he;var f=o.map(),p=Yn(a),y=Kn(a),d=Yn(s),g=Kn(s),v=Yn(u),x=Kn(u),m=Yn(c),b=Kn(c);i.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return s[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:l(n),d:function(t,n){return Zn(t.getDate(),n,2)},e:function(t,n){return Zn(t.getDate(),n,2)},H:function(t,n){return Zn(t.getHours(),n,2)},I:function(t,n){return Zn(t.getHours()%12||12,n,2)},j:function(t,n){return Zn(1+qn.dayOfYear(t),n,3)},L:function(t,n){return Zn(t.getMilliseconds(),n,3)},m:function(t,n){return Zn(t.getMonth()+1,n,2)},M:function(t,n){return Zn(t.getMinutes(),n,2)},p:function(t){return i[+(t.getHours()>=12)]},S:function(t,n){return Zn(t.getSeconds(),n,2)},U:function(t,n){return Zn(qn.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return Zn(qn.mondayOfYear(t),n,2)},x:l(e),X:l(r),y:function(t,n){return Zn(t.getFullYear()%100,n,2)},Y:function(t,n){return Zn(t.getFullYear()%1e4,n,4)},Z:ce,"%":function(){return"%"}},S={a:function(t,n,e){d.lastIndex=0;var r=d.exec(n.slice(e));return r?(t.w=g.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(t,n,e){p.lastIndex=0;var r=p.exec(n.slice(e));return r?(t.w=y.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){m.lastIndex=0;var r=m.exec(n.slice(e));return r?(t.m=b.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(t,n,e){v.lastIndex=0;var r=v.exec(n.slice(e));return r?(t.m=x.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,n,e){return h(t,w.c.toString(),n,e)},d:re,e:re,H:oe,I:oe,j:ie,L:ue,m:ee,M:ae,p:function(t,n,e){var r=f.get(n.slice(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)},S:se,U:$n,w:Wn,W:Jn,x:function(t,n,e){return h(t,w.x.toString(),n,e)},X:function(t,n,e){return h(t,w.X.toString(),n,e)},y:te,Y:Qn,Z:ne,"%":le};return l}qn.year=Vn((function(t){return(t=qn.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),qn.years=qn.year.range,qn.years.utc=qn.year.utc.range,qn.day=Vn((function(t){var n=new Rn(2e3,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n}),(function(t,n){t.setDate(t.getDate()+n)}),(function(t){return t.getDate()-1})),qn.days=qn.day.range,qn.days.utc=qn.day.utc.range,qn.dayOfYear=function(t){var n=qn.year(t);return Math.floor((t-n-6e4*(t.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(t,n){n=7-n;var e=qn[t]=Vn((function(t){return(t=qn.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t}),(function(t,n){t.setDate(t.getDate()+7*Math.floor(n))}),(function(t){var e=qn.year(t).getDay();return Math.floor((qn.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));qn[t+"s"]=e.range,qn[t+"s"].utc=e.utc.range,qn[t+"OfYear"]=function(t){var e=qn.year(t).getDay();return Math.floor((qn.dayOfYear(t)+(e+n)%7)/7)}})),qn.week=qn.sunday,qn.weeks=qn.sunday.range,qn.weeks.utc=qn.sunday.utc.range,qn.weekOfYear=qn.sundayOfYear;var Hn={"-":"",_:" ",0:"0"},Un=/^\s*\d+/,Xn=/^%/;function Zn(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o68?1900:2e3),e+i[0].length):-1}function ne(t,n,e){return/^[+-]\d{4}$/.test(n=n.slice(e,e+5))?(t.Z=-n,e+5):-1}function ee(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function re(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function ie(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+3));return r?(t.j=+r[0],e+r[0].length):-1}function oe(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function ae(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function se(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function ue(t,n,e){Un.lastIndex=0;var r=Un.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function ce(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=S(n)/60|0,i=S(n)%60;return e+Zn(r,"0",2)+Zn(i,"0",2)}function le(t,n,e){Xn.lastIndex=0;var r=Xn.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function he(t){for(var n=t.length,e=-1;++e=0?1:-1,s=a*o,u=Math.cos(n),c=Math.sin(n),l=i*c,h=r*u+l*Math.cos(s),f=l*a*Math.sin(s);Ie.add(Math.atan2(f,h)),e=t,r=u,i=c}ze.point=function(a,s){ze.point=o,e=(t=a)*zt,r=Math.cos(s=(n=s)*zt/2+Pt/4),i=Math.sin(s)},ze.lineEnd=function(){o(t,n)}}function Oe(t){var n=t[0],e=t[1],r=Math.cos(e);return[r*Math.cos(n),r*Math.sin(n),Math.sin(e)]}function qe(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Re(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Ge(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function je(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Ve(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function Be(t){return[Math.atan2(t[1],t[0]),Gt(t[2])]}function Fe(t,n){return S(t[0]-n[0])Lt?r=90:c<-Lt&&(n=-90),h[0]=t,h[1]=e}};function p(i,o){l.push(h=[t=i,e=i]),or&&(r=o)}function y(o,a){var s=Oe([o*zt,a*zt]);if(u){var c=Re(u,s),l=Re([c[1],-c[0],0],c);Ve(l),l=Be(l);var h=o-i,f=h>0?1:-1,y=l[0]*Dt*f,d=S(h)>180;if(d^(f*ir&&(r=g);else if(d^(f*i<(y=(y+360)%360-180)&&yr&&(r=a);d?ob(t,e)&&(e=o):b(o,e)>b(t,e)&&(t=o):e>=t?(oe&&(e=o)):o>i?b(t,o)>b(t,e)&&(e=o):b(o,e)>b(t,e)&&(t=o)}else p(o,a);u=s,i=o}function d(){f.point=y}function g(){h[0]=t,h[1]=e,f.point=p,u=null}function v(t,n){if(u){var e=t-i;c+=S(e)>180?e+(e>0?360:-360):e}else a=t,s=n;ze.point(t,n),y(t,n)}function x(){ze.lineStart()}function m(){v(a,s),ze.lineEnd(),S(c)>Lt&&(t=-(e=180)),h[0]=t,h[1]=e,u=null}function b(t,n){return(n-=t)<0?n+360:n}function w(t,n){return t[0]-n[0]}function _(t,n){return n[0]<=n[1]?n[0]<=t&&t<=n[1]:tb(d[0],d[1])&&(d[1]=p[1]),b(p[0],d[1])>b(d[0],d[1])&&(d[0]=p[0])):s.push(d=p);for(var u,c,p,y=-1/0,d=(a=0,s[c=s.length-1]);a<=c;d=p,++a)p=s[a],(u=b(d[1],p[0]))>y&&(y=u,t=p[0],e=d[1])}return l=h=null,t===1/0||n===1/0?[[NaN,NaN],[NaN,NaN]]:[[t,n],[e,r]]}}(),o.geo.centroid=function(t){Se=_e=Me=ke=Ee=Ae=Le=Ne=Pe=Ce=Te=0,o.geo.stream(t,He);var n=Pe,e=Ce,r=Te,i=n*n+e*e+r*r;return i=0;--s)i.point((h=l[s])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}l=(p=p.o).z,y=!y}while(!p.v);i.lineEnd()}}}function Qe(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,_=S*w,M=_>Pt,k=y*m;if(Ie.add(Math.atan2(k*S*Math.sin(_),d*b+k*Math.cos(_))),o+=M?w+S*Ct:w,M^f>=e^v>=e){var E=Re(Oe(h),Oe(t));Ve(E);var A=Re(i,E);Ve(A);var L=(M^w>=0?-1:1)*Gt(A[2]);(r>L||r===L&&(E[0]||E[1]))&&(a+=M^w>=0?1:-1)}if(!g++)break;f=v,y=m,d=b,h=t}}return(o<-Lt||o0){for(m||(a.polygonStart(),m=!0),a.lineStart();++o1&&2&n&&e.push(e.pop().concat(e.shift())),s.push(e.filter(er))}return l}}function er(t){return t.length>1}function rr(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:R,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function ir(t,n){return((t=t.x)[0]<0?t[1]-It-Lt:It-t[1])-((n=n.x)[0]<0?n[1]-It-Lt:It-n[1])}var or=nr($e,(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var s=o>0?Pt:-Pt,u=S(o-e);S(u-Pt)0?It:-It),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),n=0):i!==s&&u>=Pt&&(S(e-i)Lt?Math.atan((Math.sin(n)*(o=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(n))*Math.sin(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),n=0),t.point(e=o,r=a),i=s},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*It,r.point(-Pt,i),r.point(0,i),r.point(Pt,i),r.point(Pt,0),r.point(Pt,-i),r.point(0,-i),r.point(-Pt,-i),r.point(-Pt,0),r.point(-Pt,i);else if(S(t[0]-n[0])>Lt){var o=t[0]0,r=S(n)>Lt;return nr(i,(function(t){var n,s,u,c,l;return{lineStart:function(){c=u=!1,l=1},point:function(h,f){var p,y=[h,f],d=i(h,f),g=e?d?0:a(h,f):d?a(h+(h<0?Pt:-Pt),f):0;if(!n&&(c=u=d)&&t.lineStart(),d!==u&&(p=o(n,y),(Fe(n,p)||Fe(y,p))&&(y[0]+=Lt,y[1]+=Lt,d=i(y[0],y[1]))),d!==u)l=0,d?(t.lineStart(),p=o(y,n),t.point(p[0],p[1])):(p=o(n,y),t.point(p[0],p[1]),t.lineEnd()),n=p;else if(r&&n&&e^d){var v;g&s||!(v=o(y,n,!0))||(l=0,e?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!d||n&&Fe(n,y)||t.point(y[0],y[1]),n=y,u=d,s=g},lineEnd:function(){u&&t.lineEnd(),n=null},clean:function(){return l|(c&&u)<<1}}}),Br(t,6*zt),e?[0,-t]:[-Pt,t-Pt]);function i(t,e){return Math.cos(t)*Math.cos(e)>n}function o(t,e,r){var i=[1,0,0],o=Re(Oe(t),Oe(e)),a=qe(o,o),s=o[0],u=a-s*s;if(!u)return!r&&t;var c=n*a/u,l=-n*s/u,h=Re(i,o),f=je(i,c);Ge(f,je(o,l));var p=h,y=qe(f,p),d=qe(p,p),g=y*y-d*(qe(f,f)-1);if(!(g<0)){var v=Math.sqrt(g),x=je(p,(-y-v)/d);if(Ge(x,f),x=Be(x),!r)return x;var m,b=t[0],w=e[0],_=t[1],M=e[1];w0^x[1]<(S(x[0]-b)Pt^(b<=x[0]&&x[0]<=w)){var A=je(p,(-y+v)/d);return Ge(A,f),[x,Be(A)]}}}function a(n,r){var i=e?t:Pt-t,o=0;return n<-i?o|=1:n>i&&(o|=2),r<-i?o|=4:r>i&&(o|=8),o}}function sr(t,n,e,r){return function(i){var o,a=i.a,s=i.b,u=a.x,c=a.y,l=0,h=1,f=s.x-u,p=s.y-c;if(o=t-u,f||!(o>0)){if(o/=f,f<0){if(o0){if(o>h)return;o>l&&(l=o)}if(o=e-u,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>l&&(l=o)}else if(f>0){if(o0)){if(o/=p,p<0){if(o0){if(o>h)return;o>l&&(l=o)}if(o=r-c,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>l&&(l=o)}else if(p>0){if(o0&&(i.a={x:u+l*f,y:c+l*p}),h<1&&(i.b={x:u+h*f,y:c+h*p}),i}}}}}}function ur(t,n,e,r){return function(u){var c,l,h,f,p,y,d,g,v,x,m,b=u,w=rr(),S=sr(t,n,e,r),_={point:E,lineStart:function(){_.point=A,l&&l.push(h=[]);x=!0,v=!1,d=g=NaN},lineEnd:function(){c&&(A(f,p),y&&v&&w.rejoin(),c.push(w.buffer()));_.point=E,v&&u.lineEnd()},polygonStart:function(){u=w,c=[],l=[],m=!0},polygonEnd:function(){u=b,c=o.merge(c);var n=function(t){for(var n=0,e=l.length,r=t[1],i=0;ir&&qt(c,o,t)>0&&++n:o[1]<=r&&qt(c,o,t)<0&&--n,c=o;return 0!==n}([t,r]),e=m&&n,i=c.length;(e||i)&&(u.polygonStart(),e&&(u.lineStart(),M(null,null,1,u),u.lineEnd()),i&&Je(c,a,n,M,u),u.polygonEnd()),c=l=h=null}};function M(o,a,u,c){var l=0,h=0;if(null==o||(l=i(o,u))!==(h=i(a,u))||s(o,a)<0^u>0)do{c.point(0===l||3===l?t:e,l>1?r:n)}while((l=(l+u+4)%4)!==h);else c.point(a[0],a[1])}function k(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function E(t,n){k(t,n)&&u.point(t,n)}function A(t,n){var e=k(t=Math.max(-1e9,Math.min(1e9,t)),n=Math.max(-1e9,Math.min(1e9,n)));if(l&&h.push([t,n]),x)f=t,p=n,y=e,x=!1,e&&(u.lineStart(),u.point(t,n));else if(e&&v)u.point(t,n);else{var r={a:{x:d,y:g},b:{x:t,y:n}};S(r)?(v||(u.lineStart(),u.point(r.a.x,r.a.y)),u.point(r.b.x,r.b.y),e||u.lineEnd(),m=!1):e&&(u.lineStart(),u.point(t,n),m=!1)}d=t,g=n,v=e}return _};function i(r,i){return S(r[0]-t)0?0:3:S(r[0]-e)0?2:1:S(r[1]-n)0?1:0:i>0?3:2}function a(t,n){return s(t.x,n.x)}function s(t,n){var e=i(t,1),r=i(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}}function cr(t){var n=0,e=Pt/3,r=zr(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Pt/180,e=t[1]*Pt/180):[n/Pt*180,e/Pt*180]},i}function lr(t,n){var e=Math.sin(t),r=(e+Math.sin(n))/2,i=1+e*(2*r-e),o=Math.sqrt(i)/r;function a(t,n){var e=Math.sqrt(i-2*r*Math.sin(n))/r;return[e*Math.sin(t*=r),o-e*Math.cos(t)]}return a.invert=function(t,n){var e=o-n;return[Math.atan2(t,e)/r,Gt((i-(t*t+e*e)*r*r)/(2*r))]},a}o.geo.clipExtent=function(){var t,n,e,r,i,o,a={stream:function(t){return i&&(i.valid=!1),(i=o(t)).valid=!0,i},extent:function(s){return arguments.length?(o=ur(t=+s[0][0],n=+s[0][1],e=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(o.geo.conicEqualArea=function(){return cr(lr)}).raw=lr,o.geo.albers=function(){return o.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},o.geo.albersUsa=function(){var t,n,e,r,i=o.geo.albers(),a=o.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=o.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),u={point:function(n,e){t=[n,e]}};function c(i){var o=i[0],a=i[1];return t=null,n(o,a),t||(e(o,a),t)||r(o,a),t}return c.invert=function(t){var n=i.scale(),e=i.translate(),r=(t[0]-e[0])/n,o=(t[1]-e[1])/n;return(o>=.12&&o<.234&&r>=-.425&&r<-.214?a:o>=.166&&o<.234&&r>=-.214&&r<-.115?s:i).invert(t)},c.stream=function(t){var n=i.stream(t),e=a.stream(t),r=s.stream(t);return{point:function(t,i){n.point(t,i),e.point(t,i),r.point(t,i)},sphere:function(){n.sphere(),e.sphere(),r.sphere()},lineStart:function(){n.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){n.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){n.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){n.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},c.precision=function(t){return arguments.length?(i.precision(t),a.precision(t),s.precision(t),c):i.precision()},c.scale=function(t){return arguments.length?(i.scale(t),a.scale(.35*t),s.scale(t),c.translate(i.translate())):i.scale()},c.translate=function(t){if(!arguments.length)return i.translate();var o=i.scale(),l=+t[0],h=+t[1];return n=i.translate(t).clipExtent([[l-.455*o,h-.238*o],[l+.455*o,h+.238*o]]).stream(u).point,e=a.translate([l-.307*o,h+.201*o]).clipExtent([[l-.425*o+Lt,h+.12*o+Lt],[l-.214*o-Lt,h+.234*o-Lt]]).stream(u).point,r=s.translate([l-.205*o,h+.212*o]).clipExtent([[l-.214*o+Lt,h+.166*o+Lt],[l-.115*o-Lt,h+.234*o-Lt]]).stream(u).point,c},c.scale(1070)};var hr,fr,pr,yr,dr,gr,vr={point:R,lineStart:R,lineEnd:R,polygonStart:function(){fr=0,vr.lineStart=xr},polygonEnd:function(){vr.lineStart=vr.lineEnd=vr.point=R,hr+=S(fr/2)}};function xr(){var t,n,e,r;function i(t,n){fr+=r*t-e*n,e=t,r=n}vr.point=function(o,a){vr.point=i,t=e=o,n=r=a},vr.lineEnd=function(){i(t,n)}}var mr={point:function(t,n){tdr&&(dr=t);ngr&&(gr=n)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function br(){var t=wr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=wr(n),e},result:function(){if(n.length){var t=n.join("");return n=[],t}}};function r(e,r){n.push("M",e,",",r,t)}function i(t,r){n.push("M",t,",",r),e.point=o}function o(t,e){n.push("L",t,",",e)}function a(){e.point=r}function s(){n.push("Z")}return e}function wr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var Sr,_r={point:Mr,lineStart:kr,lineEnd:Er,polygonStart:function(){_r.lineStart=Ar},polygonEnd:function(){_r.point=Mr,_r.lineStart=kr,_r.lineEnd=Er}};function Mr(t,n){Me+=t,ke+=n,++Ee}function kr(){var t,n;function e(e,r){var i=e-t,o=r-n,a=Math.sqrt(i*i+o*o);Ae+=a*(t+e)/2,Le+=a*(n+r)/2,Ne+=a,Mr(t=e,n=r)}_r.point=function(r,i){_r.point=e,Mr(t=r,n=i)}}function Er(){_r.point=Mr}function Ar(){var t,n,e,r;function i(t,n){var i=t-e,o=n-r,a=Math.sqrt(i*i+o*o);Ae+=a*(e+t)/2,Le+=a*(r+n)/2,Ne+=a,Pe+=(a=r*t-e*n)*(e+t),Ce+=a*(r+n),Te+=3*a,Mr(e=t,r=n)}_r.point=function(o,a){_r.point=i,Mr(t=e=o,n=r=a)},_r.lineEnd=function(){i(t,n)}}function Lr(t){var n=4.5,e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:R};function r(e,r){t.moveTo(e+n,r),t.arc(e,r,n,0,Ct)}function i(n,r){t.moveTo(n,r),e.point=o}function o(n,e){t.lineTo(n,e)}function a(){e.point=r}function s(){t.closePath()}return e}function Nr(t){var n=.5,e=Math.cos(30*zt),r=16;function i(t){return(r?a:o)(t)}function o(n){return Tr(n,(function(e,r){e=t(e,r),n.point(e[0],e[1])}))}function a(n){var e,i,o,a,u,c,l,h,f,p,y,d,g={point:v,lineStart:x,lineEnd:b,polygonStart:function(){n.polygonStart(),g.lineStart=w},polygonEnd:function(){n.polygonEnd(),g.lineStart=x}};function v(e,r){e=t(e,r),n.point(e[0],e[1])}function x(){h=NaN,g.point=m,n.lineStart()}function m(e,i){var o=Oe([e,i]),a=t(e,i);s(h,f,l,p,y,d,h=a[0],f=a[1],l=e,p=o[0],y=o[1],d=o[2],r,n),n.point(h,f)}function b(){g.point=v,n.lineEnd()}function w(){x(),g.point=S,g.lineEnd=_}function S(t,n){m(e=t,n),i=h,o=f,a=p,u=y,c=d,g.point=m}function _(){s(h,f,l,p,y,d,i,o,e,a,u,c,r,n),g.lineEnd=b,b()}return g}function s(r,i,o,a,u,c,l,h,f,p,y,d,g,v){var x=l-r,m=h-i,b=x*x+m*m;if(b>4*n&&g--){var w=a+p,_=u+y,M=c+d,k=Math.sqrt(w*w+_*_+M*M),E=Math.asin(M/=k),A=S(S(M)-1)n||S((x*C+m*T)/b-.5)>.3||a*p+u*y+c*d0&&16,i):Math.sqrt(n)},i}function Pr(t){var n=Nr((function(n,e){return t([n*Dt,e*Dt])}));return function(t){return Dr(n(t))}}function Cr(t){this.stream=t}function Tr(t,n){return{point:n,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Ir(t){return zr((function(){return t}))()}function zr(t){var n,e,r,i,a,s,u=Nr((function(t,e){return[(t=n(t,e))[0]*c+i,a-t[1]*c]})),c=150,l=480,h=250,f=0,p=0,y=0,d=0,g=0,v=or,x=z,m=null,b=null;function w(t){return[(t=r(t[0]*zt,t[1]*zt))[0]*c+i,a-t[1]*c]}function S(t){return(t=r.invert((t[0]-i)/c,(a-t[1])/c))&&[t[0]*Dt,t[1]*Dt]}function _(){r=We(e=Rr(y,d,g),n);var t=n(f,p);return i=l-t[0]*c,a=h+t[1]*c,M()}function M(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Dr(v(e,u(x(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(v=null==t?(m=t,or):ar((m=+t)*zt),M()):m},w.clipExtent=function(t){return arguments.length?(b=t,x=t?ur(t[0][0],t[0][1],t[1][0],t[1][1]):z,M()):b},w.scale=function(t){return arguments.length?(c=+t,_()):c},w.translate=function(t){return arguments.length?(l=+t[0],h=+t[1],_()):[l,h]},w.center=function(t){return arguments.length?(f=t[0]%360*zt,p=t[1]%360*zt,_()):[f*Dt,p*Dt]},w.rotate=function(t){return arguments.length?(y=t[0]%360*zt,d=t[1]%360*zt,g=t.length>2?t[2]%360*zt:0,_()):[y*Dt,d*Dt,g*Dt]},o.rebind(w,u,"precision"),function(){return n=t.apply(this,arguments),w.invert=n.invert&&S,_()}}function Dr(t){return Tr(t,(function(n,e){t.point(n*zt,e*zt)}))}function Or(t,n){return[t,n]}function qr(t,n){return[t>Pt?t-Ct:t<-Pt?t+Ct:t,n]}function Rr(t,n,e){return t?n||e?We(jr(t),Vr(n,e)):jr(t):n||e?Vr(n,e):qr}function Gr(t){return function(n,e){return[(n+=t)>Pt?n-Ct:n<-Pt?n+Ct:n,e]}}function jr(t){var n=Gr(t);return n.invert=Gr(-t),n}function Vr(t,n){var e=Math.cos(t),r=Math.sin(t),i=Math.cos(n),o=Math.sin(n);function a(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,c=Math.sin(n),l=c*e+s*r;return[Math.atan2(u*i-l*o,s*e-c*r),Gt(l*i+u*o)]}return a.invert=function(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,c=Math.sin(n),l=c*i-u*o;return[Math.atan2(u*i+c*o,s*e+l*r),Gt(l*e-s*r)]},a}function Br(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,s){var u=a*n;null!=i?(i=Fr(e,i),o=Fr(e,o),(a>0?io)&&(i+=a*Ct)):(i=t+a*Ct,o=t-.5*u);for(var c,l=i;a>0?l>o:l2?t[2]*zt:0),n.invert=function(n){return(n=t.invert(n[0]*zt,n[1]*zt))[0]*=Dt,n[1]*=Dt,n},n},qr.invert=Or,o.geo.circle=function(){var t,n,e=[0,0],r=6;function i(){var t="function"==typeof e?e.apply(this,arguments):e,r=Rr(-t[0]*zt,-t[1]*zt,0).invert,i=[];return n(null,null,1,{point:function(t,n){i.push(t=r(t,n)),t[0]*=Dt,t[1]*=Dt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(e=t,i):e},i.angle=function(e){return arguments.length?(n=Br((t=+e)*zt,r*zt),i):t},i.precision=function(e){return arguments.length?(n=Br(t*zt,(r=+e)*zt),i):r},i.angle(90)},o.geo.distance=function(t,n){var e,r=(n[0]-t[0])*zt,i=t[1]*zt,o=n[1]*zt,a=Math.sin(r),s=Math.cos(r),u=Math.sin(i),c=Math.cos(i),l=Math.sin(o),h=Math.cos(o);return Math.atan2(Math.sqrt((e=h*a)*e+(e=c*l-u*h*s)*e),u*l+c*h*s)},o.geo.graticule=function(){var t,n,e,r,i,a,s,u,c,l,h,f,p=10,y=p,d=90,g=360,v=2.5;function x(){return{type:"MultiLineString",coordinates:m()}}function m(){return o.range(Math.ceil(r/d)*d,e,d).map(h).concat(o.range(Math.ceil(u/g)*g,s,g).map(f)).concat(o.range(Math.ceil(n/p)*p,t,p).filter((function(t){return S(t%d)>Lt})).map(c)).concat(o.range(Math.ceil(a/y)*y,i,y).filter((function(t){return S(t%g)>Lt})).map(l))}return x.lines=function(){return m().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(r).concat(f(s).slice(1),h(e).reverse().slice(1),f(u).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],s=+t[1][1],r>e&&(t=r,r=e,e=t),u>s&&(t=u,u=s,s=t),x.precision(v)):[[r,u],[e,s]]},x.minorExtent=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],a=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),a>i&&(e=a,a=i,i=e),x.precision(v)):[[n,a],[t,i]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(d=+t[0],g=+t[1],x):[d,g]},x.minorStep=function(t){return arguments.length?(p=+t[0],y=+t[1],x):[p,y]},x.precision=function(o){return arguments.length?(v=+o,c=Hr(a,i,90),l=Ur(n,t,v),h=Hr(u,s,90),f=Ur(r,e,v),x):v},x.majorExtent([[-180,-90+Lt],[180,90-Lt]]).minorExtent([[-180,-80-Lt],[180,80+Lt]])},o.geo.greatArc=function(){var t,n,e=Xr,r=Zr;function i(){return{type:"LineString",coordinates:[t||e.apply(this,arguments),n||r.apply(this,arguments)]}}return i.distance=function(){return o.geo.distance(t||e.apply(this,arguments),n||r.apply(this,arguments))},i.source=function(n){return arguments.length?(e=n,t="function"==typeof n?null:n,i):e},i.target=function(t){return arguments.length?(r=t,n="function"==typeof t?null:t,i):r},i.precision=function(){return arguments.length?i:0},i},o.geo.interpolate=function(t,n){return e=t[0]*zt,r=t[1]*zt,i=n[0]*zt,o=n[1]*zt,a=Math.cos(r),s=Math.sin(r),u=Math.cos(o),c=Math.sin(o),l=a*Math.cos(e),h=a*Math.sin(e),f=u*Math.cos(i),p=u*Math.sin(i),y=2*Math.asin(Math.sqrt(Vt(o-r)+a*u*Vt(i-e))),d=1/Math.sin(y),(g=y?function(t){var n=Math.sin(t*=y)*d,e=Math.sin(y-t)*d,r=e*l+n*f,i=e*h+n*p,o=e*s+n*c;return[Math.atan2(i,r)*Dt,Math.atan2(o,Math.sqrt(r*r+i*i))*Dt]}:function(){return[e*Dt,r*Dt]}).distance=y,g;var e,r,i,o,a,s,u,c,l,h,f,p,y,d,g},o.geo.length=function(t){return Sr=0,o.geo.stream(t,Yr),Sr};var Yr={sphere:R,point:R,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=zt),a=Math.cos(i),s=S((r*=zt)-t),u=Math.cos(s);Sr+=Math.atan2(Math.sqrt((s=a*Math.sin(s))*s+(s=e*o-n*a*u)*s),n*o+e*a*u),t=r,n=o,e=a}Yr.point=function(i,o){t=i*zt,n=Math.sin(o*=zt),e=Math.cos(o),Yr.point=r},Yr.lineEnd=function(){Yr.point=Yr.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Kr(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),o=t(r*i);return[o*i*Math.sin(n),o*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),o=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*o,r*a),Math.asin(r&&e*o/r)]},e}var Wr=Kr((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(o.geo.azimuthalEqualArea=function(){return Ir(Wr)}).raw=Wr;var $r=Kr((function(t){var n=Math.acos(t);return n&&n/Math.sin(n)}),z);function Jr(t,n){var e=Math.cos(t),r=function(t){return Math.tan(Pt/4+t/2)},i=t===n?Math.sin(t):Math.log(e/Math.cos(n))/Math.log(r(n)/r(t)),o=e*Math.pow(r(t),i)/i;if(!i)return ni;function a(t,n){o>0?n<-It+Lt&&(n=-It+Lt):n>It-Lt&&(n=It-Lt);var e=o/Math.pow(r(n),i);return[e*Math.sin(i*t),o-e*Math.cos(i*t)]}return a.invert=function(t,n){var e=o-n,r=Ot(i)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/i,2*Math.atan(Math.pow(o/r,1/i))-It]},a}function Qr(t,n){var e=Math.cos(t),r=t===n?Math.sin(t):(e-Math.cos(n))/(n-t),i=e/r+t;if(S(r)1&&qt(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ci(t,n){return t[0]-n[0]||t[1]-n[1]}(o.geo.stereographic=function(){return Ir(ii)}).raw=ii,oi.invert=function(t,n){return[-n,2*Math.atan(Math.exp(t))-It]},(o.geo.transverseMercator=function(){var t=ei(oi),n=t.center,e=t.rotate;return t.center=function(t){return t?n([-t[1],t[0]]):[(t=n())[1],-t[0]]},t.rotate=function(t){return t?e([t[0],t[1],t.length>2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90])}).raw=oi,o.geom={},o.geom.hull=function(t){var n=ai,e=si;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=mn(n),o=mn(e),a=t.length,s=[],u=[];for(r=0;r=0;--r)p.push(t[s[c[r]][2]]);for(r=+h;rLt)s=s.L;else{if(!((i=o-Ai(s,a))>Lt)){r>-Lt?(n=s.P,e=s):i>-Lt?(n=s,e=s.N):n=e=s;break}if(!s.R){n=s;break}s=s.R}var u=Si(t);if(gi.insert(n,u),n||e){if(n===e)return Ti(n),e=Si(n.site),gi.insert(u,e),u.edge=e.edge=Di(n.site,u.site),Ci(n),void Ci(e);if(e){Ti(n),Ti(e);var c=n.site,l=c.x,h=c.y,f=t.x-l,p=t.y-h,y=e.site,d=y.x-l,g=y.y-h,v=2*(f*g-p*d),x=f*f+p*p,m=d*d+g*g,b={x:(g*x-p*m)/v+l,y:(f*m-d*x)/v+h};qi(e.edge,c,y,b),u.edge=Di(c,t,null,b),e.edge=Di(t,y,null,b),Ci(n),Ci(e)}else u.edge=Di(n.site,u.site)}}function Ei(t,n){var e=t.site,r=e.x,i=e.y,o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var s=(e=a.site).x,u=e.y,c=u-n;if(!c)return s;var l=s-r,h=1/o-1/c,f=l/c;return h?(-f+Math.sqrt(f*f-2*h*(l*l/(-2*c)-u+c/2+i-o/2)))/h+r:(r+s)/2}function Ai(t,n){var e=t.N;if(e)return Ei(e,n);var r=t.site;return r.y===n?r.x:1/0}function Li(t){this.site=t,this.edges=[]}function Ni(t,n){return n.angle-t.angle}function Pi(){ji(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ci(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i.x,s=i.y,u=r.x-a,c=r.y-s,l=o.x-a,h=2*(u*(g=o.y-s)-c*l);if(!(h>=-Nt)){var f=u*u+c*c,p=l*l+g*g,y=(g*f-c*p)/h,d=(u*p-l*f)/h,g=d+s,v=bi.pop()||new Pi;v.arc=t,v.site=i,v.x=y+a,v.y=g+Math.sqrt(y*y+d*d),v.cy=g,t.circle=v;for(var x=null,m=xi._;m;)if(v.y=s)return;if(f>y){if(o){if(o.y>=c)return}else o={x:g,y:u};e={x:g,y:c}}else{if(o){if(o.y1)if(f>y){if(o){if(o.y>=c)return}else o={x:(u-i)/r,y:u};e={x:(c-i)/r,y:c}}else{if(o){if(o.y=s)return}else o={x:a,y:r*a+i};e={x:s,y:r*s+i}}else{if(o){if(o.xLt||S(i-e)>Lt)&&(s.splice(a,0,new Ri(Oi(o.site,l,S(r-h)Lt?{x:h,y:S(n-h)Lt?{x:S(e-y)Lt?{x:f,y:S(n-f)Lt?{x:S(e-p)=e&&c.x<=i&&c.y>=r&&c.y<=a?[[e,a],[i,a],[i,r],[e,r]]:[]).point=t[s]})),n}function s(t){return t.map((function(t,n){return{x:Math.round(r(t,n)/Lt)*Lt,y:Math.round(i(t,n)/Lt)*Lt,i:n}}))}return a.links=function(t){return Hi(s(t)).edges.filter((function(t){return t.l&&t.r})).map((function(n){return{source:t[n.l.i],target:t[n.r.i]}}))},a.triangles=function(t){var n=[];return Hi(s(t)).cells.forEach((function(e,r){for(var i,o,a,s,u=e.site,c=e.edges.sort(Ni),l=-1,h=c.length,f=c[h-1].edge,p=f.l===u?f.r:f.l;++lo||h>a||f=w)<<1|n>=b,_=S+4;S<_;++S)if(c=m[3&S])switch(3&S){case 0:t(c,l,h,b,w);break;case 1:t(c,b,h,f,w);break;case 2:t(c,l,w,b,p);break;case 3:t(c,b,w,f,p)}}}(t,r,i,o,a),s}function $i(t,n){t=o.rgb(t),n=o.rgb(n);var e=t.r,r=t.g,i=t.b,a=n.r-e,s=n.g-r,u=n.b-i;return function(t){return"#"+fn(Math.round(e+a*t))+fn(Math.round(r+s*t))+fn(Math.round(i+u*t))}}function Ji(t,n){var e,r={},i={};for(e in t)e in n?r[e]=ro(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}}function Qi(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}function to(t,n){var e,r,i,o=no.lastIndex=eo.lastIndex=0,a=-1,s=[],u=[];for(t+="",n+="";(e=no.exec(t))&&(r=eo.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(e=e[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Qi(e,r)})),o=eo.lastIndex;return od&&(d=u.x),u.y>g&&(g=u.y),c.push(u.x),l.push(u.y);else for(h=0;hd&&(d=m),b>g&&(g=b),c.push(m),l.push(b)}var w=d-p,_=g-y;function M(t,n,e,r,i,o,a,s){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var u=t.x,c=t.y;if(null!=u)if(S(u-e)+S(c-r)<.01)k(t,n,e,r,i,o,a,s);else{var l=t.point;t.x=t.y=t.point=null,k(t,l,u,c,i,o,a,s),k(t,n,e,r,i,o,a,s)}else t.x=e,t.y=r,t.point=n}else k(t,n,e,r,i,o,a,s)}function k(t,n,e,r,i,o,a,s){var u=.5*(i+a),c=.5*(o+s),l=e>=u,h=r>=c,f=h<<1|l;t.leaf=!1,l?i=u:a=u,h?o=c:s=c,M(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,s)}w>_?g=y+w:d=p+_;var E={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){M(E,t,+v(t,++h),+x(t,h),p,y,d,g)},visit:function(t){Ki(t,E,p,y,d,g)},find:function(t){return Wi(E,t[0],t[1],p,y,d,g)}};if(h=-1,null==n){for(;++h=0&&!(e=o.interpolators[r](t,n)););return e}function io(t,n){var e,r=[],i=[],o=t.length,a=n.length,s=Math.min(t.length,n.length);for(e=0;e=1?1:t(n)}}function co(t){return function(n){return 1-t(1-n)}}function lo(t){return function(n){return.5*(n<.5?t(2*n):2-t(2-2*n))}}function ho(t){return t*t}function fo(t){return t*t*t}function po(t){if(t<=0)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(t<.5?e:3*(t-n)+e-.75)}function yo(t){return 1-Math.cos(t*It)}function go(t){return Math.pow(2,10*(t-1))}function vo(t){return 1-Math.sqrt(1-t*t)}function xo(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function mo(t,n){return n-=t,function(e){return Math.round(t+n*e)}}function bo(t){var n,e,r,i=[t.a,t.b],o=[t.c,t.d],a=So(i),s=wo(i,o),u=So(((n=o)[0]+=(r=-s)*(e=i)[0],n[1]+=r*e[1],n))||0;i[0]*o[1]=0?t.slice(0,n):t,r=n>=0?t.slice(n+1):"in";return e=ao.get(e)||oo,uo((r=so.get(r)||z)(e.apply(null,a.call(arguments,1))))},o.interpolateHcl=function(t,n){t=o.hcl(t),n=o.hcl(n);var e=t.h,r=t.c,i=t.l,a=n.h-e,s=n.c-r,u=n.l-i;isNaN(s)&&(s=0,r=isNaN(r)?n.c:r);isNaN(a)?(a=0,e=isNaN(e)?n.h:e):a>180?a-=360:a<-180&&(a+=360);return function(t){return Jt(e+a*t,r+s*t,i+u*t)+""}},o.interpolateHsl=function(t,n){t=o.hsl(t),n=o.hsl(n);var e=t.h,r=t.s,i=t.l,a=n.h-e,s=n.s-r,u=n.l-i;isNaN(s)&&(s=0,r=isNaN(r)?n.s:r);isNaN(a)?(a=0,e=isNaN(e)?n.h:e):a>180?a-=360:a<-180&&(a+=360);return function(t){return Kt(e+a*t,r+s*t,i+u*t)+""}},o.interpolateLab=function(t,n){t=o.lab(t),n=o.lab(n);var e=t.l,r=t.a,i=t.b,a=n.l-e,s=n.a-r,u=n.b-i;return function(t){return en(e+a*t,r+s*t,i+u*t)+""}},o.interpolateRound=mo,o.transform=function(t){var n=u.createElementNS(o.ns.prefix.svg,"g");return(o.transform=function(t){if(null!=t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate()}return new bo(e?e.matrix:_o)})(t)},bo.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var _o={a:1,b:0,c:0,d:1,e:0,f:0};function Mo(t){return t.length?t.pop()+",":""}function ko(t,n){var e=[],r=[];return t=o.transform(t),n=o.transform(n),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push("translate(",null,",",null,")");r.push({i:i-4,x:Qi(t[0],n[0])},{i:i-2,x:Qi(t[1],n[1])})}else(n[0]||n[1])&&e.push("translate("+n+")")}(t.translate,n.translate,e,r),function(t,n,e,r){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),r.push({i:e.push(Mo(e)+"rotate(",null,")")-2,x:Qi(t,n)})):n&&e.push(Mo(e)+"rotate("+n+")")}(t.rotate,n.rotate,e,r),function(t,n,e,r){t!==n?r.push({i:e.push(Mo(e)+"skewX(",null,")")-2,x:Qi(t,n)}):n&&e.push(Mo(e)+"skewX("+n+")")}(t.skew,n.skew,e,r),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push(Mo(e)+"scale(",null,",",null,")");r.push({i:i-4,x:Qi(t[0],n[0])},{i:i-2,x:Qi(t[1],n[1])})}else 1===n[0]&&1===n[1]||e.push(Mo(e)+"scale("+n+")")}(t.scale,n.scale,e,r),t=n=null,function(t){for(var n,i=-1,o=r.length;++i0?e=n:(t.c=null,t.t=NaN,t=null,u.end({type:"end",alpha:e=0})):n>0&&(u.start({type:"start",alpha:e=n}),t=An(s.tick)),s):e},s.start=function(){var t,n,e,o=v.length,u=x.length,l=c[0],y=c[1];for(t=0;t=0;)e.push(i[r])}function Go(t,n){for(var e=[t],r=[];null!=(t=e.pop());)if(r.push(t),(o=t.children)&&(i=o.length))for(var i,o,a=-1;++a=0;)a.push(l=c[u]),l.parent=o,l.depth=o.depth+1;e&&(o.value=0),o.children=c}else e&&(o.value=+e.call(r,o,o.depth)||0),delete o.children;return Go(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),s}return r.sort=function(n){return arguments.length?(t=n,r):t},r.children=function(t){return arguments.length?(n=t,r):n},r.value=function(t){return arguments.length?(e=t,r):e},r.revalue=function(t){return e&&(Ro(t,(function(t){t.children&&(t.value=0)})),Go(t,(function(t){var n;t.children||(t.value=+e.call(r,t,t.depth)||0),(n=t.parent)&&(n.value+=t.value)}))),t},r},o.layout.partition=function(){var t=o.layout.hierarchy(),n=[1,1];function e(e,r){var i=t.call(this,e,r);return function t(n,e,r,i){var o=n.children;if(n.x=e,n.y=n.depth*i,n.dx=r,n.dy=i,o&&(a=o.length)){var a,s,u,c=-1;for(r=n.value?r/n.value:0;++cs&&(s=r),a.push(r)}for(e=0;ei&&(r=e,i=n);return r}function Qo(t){return t.reduce(ta,0)}function ta(t,n){return t+n[1]}function na(t,n){return ea(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function ea(t,n){for(var e=-1,r=+t[0],i=(t[1]-r)/n,o=[];++e<=n;)o[e]=i*e+r;return o}function ra(t){return[o.min(t),o.max(t)]}function ia(t,n){return t.value-n.value}function oa(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function aa(t,n){t._pack_next=n,n._pack_prev=t}function sa(t,n){var e=n.x-t.x,r=n.y-t.y,i=t.r+n.r;return.999*i*i>e*e+r*r}function ua(t){if((n=t.children)&&(u=n.length)){var n,e,r,i,o,a,s,u,c=1/0,l=-1/0,h=1/0,f=-1/0;if(n.forEach(ca),(e=n[0]).x=-e.r,e.y=0,m(e),u>1&&((r=n[1]).x=r.r,r.y=0,m(r),u>2))for(ha(e,r,i=n[2]),m(i),oa(e,i),e._pack_prev=i,oa(i,r),r=e._pack_next,o=3;o0)for(a=-1;++a=h[0]&&u<=h[1]&&((s=c[o.bisect(f,u,1,y)-1]).y+=d,s.push(i[a]));return c}return i.value=function(t){return arguments.length?(n=t,i):n},i.range=function(t){return arguments.length?(e=mn(t),i):e},i.bins=function(t){return arguments.length?(r="number"==typeof t?function(n){return ea(n,t)}:mn(t),i):r},i.frequency=function(n){return arguments.length?(t=!!n,i):t},i},o.layout.pack=function(){var t,n=o.layout.hierarchy().sort(ia),e=0,r=[1,1];function i(i,o){var a=n.call(this,i,o),s=a[0],u=r[0],c=r[1],l=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(s.x=s.y=0,Go(s,(function(t){t.r=+l(t.value)})),Go(s,ua),e){var h=e*(t?1:Math.max(2*s.r/u,2*s.r/c))/2;Go(s,(function(t){t.r+=h})),Go(s,ua),Go(s,(function(t){t.r-=h}))}return function t(n,e,r,i){var o=n.children;if(n.x=e+=i*n.x,n.y=r+=i*n.y,n.r*=i,o)for(var a=-1,s=o.length;++ap.x&&(p=t),t.depth>y.depth&&(y=t)}));var d=n(f,p)/2-f.x,g=e[0]/(p.x+n(p,f)/2+d),v=e[1]/(y.depth||1);Ro(l,(function(t){t.x=(t.x+d)*g,t.y=t.depth*v}))}return c}function a(t){var e=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(e.length){!function(t){var n,e=0,r=0,i=t.children,o=i.length;for(;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(t);var o=(e[0].z+e[e.length-1].z)/2;i?(t.z=i.z+n(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+n(t._,i._));t.parent.A=function(t,e,r){if(e){for(var i,o=t,a=t,s=e,u=o.parent.children[0],c=o.m,l=a.m,h=s.m,f=u.m;s=ya(s),o=pa(o),s&&o;)u=pa(u),(a=ya(a)).a=t,(i=s.z+h-o.z-c+n(s._,o._))>0&&(da(ga(s,t,r),t,i),c+=i,l+=i),h+=s.m,c+=o.m,f+=u.m,l+=a.m;s&&!ya(a)&&(a.t=s,a.m+=h-l),o&&!pa(u)&&(u.t=o,u.m+=c-f,r=t)}return r}(t,i,t.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=e[0],t.y=t.depth*e[1]}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(r=null==(e=t)?u:null,i):r?null:e},i.nodeSize=function(t){return arguments.length?(r=null==(e=t)?null:u,i):r?e:null},qo(i,t)},o.layout.cluster=function(){var t=o.layout.hierarchy().sort(null).value(null),n=fa,e=[1,1],r=!1;function i(i,a){var s,u=t.call(this,i,a),c=u[0],l=0;Go(c,(function(t){var e=t.children;e&&e.length?(t.x=function(t){return t.reduce((function(t,n){return t+n.x}),0)/t.length}(e),t.y=function(t){return 1+o.max(t,(function(t){return t.y}))}(e)):(t.x=s?l+=n(t,s):0,t.y=0,s=t)}));var h=function t(n){var e=n.children;return e&&e.length?t(e[0]):n}(c),f=function t(n){var e,r=n.children;return r&&(e=r.length)?t(r[e-1]):n}(c),p=h.x-n(h,f)/2,y=f.x+n(f,h)/2;return Go(c,r?function(t){t.x=(t.x-c.x)*e[0],t.y=(c.y-t.y)*e[1]}:function(t){t.x=(t.x-p)/(y-p)*e[0],t.y=(1-(c.y?t.y/c.y:1))*e[1]}),u}return i.separation=function(t){return arguments.length?(n=t,i):n},i.size=function(t){return arguments.length?(r=null==(e=t),i):r?null:e},i.nodeSize=function(t){return arguments.length?(r=null!=(e=t),i):r?e:null},qo(i,t)},o.layout.treemap=function(){var t,n=o.layout.hierarchy(),e=Math.round,r=[1,1],i=null,a=va,s=!1,u="squarify",c=.5*(1+Math.sqrt(5));function l(t,n){for(var e,r,i=-1,o=t.length;++i0;)s.push(e=c[i-1]),s.area+=e.area,"squarify"!==u||(r=p(s,d))<=f?(c.pop(),f=r):(s.area-=s.pop().area,y(s,d,o,!1),d=Math.min(o.dx,o.dy),s.length=s.area=0,f=1/0);s.length&&(y(s,d,o,!0),s.length=s.area=0),n.forEach(h)}}function f(t){var n=t.children;if(n&&n.length){var e,r=a(t),i=n.slice(),o=[];for(l(i,r.dx*r.dy/t.value),o.area=0;e=i.pop();)o.push(e),o.area+=e.area,null!=e.z&&(y(o,e.z?r.dx:r.dy,r,!i.length),o.length=o.area=0);n.forEach(f)}}function p(t,n){for(var e,r=t.area,i=0,o=1/0,a=-1,s=t.length;++ai&&(i=e));return n*=n,(r*=r)?Math.max(n*i*c/r,r/(n*o*c)):1/0}function y(t,n,r,i){var o,a=-1,s=t.length,u=r.x,c=r.y,l=n?e(t.area/n):0;if(n==r.dx){for((i||l>r.dy)&&(l=r.dy);++ar.dx)&&(l=r.dx);++a1);return t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=o.random.normal.apply(o,arguments);return function(){return Math.exp(t())}},bates:function(t){var n=o.random.irwinHall(t);return function(){return n()/t}},irwinHall:function(t){return function(){for(var n=0,e=0;e2?ka:wa,s=i?Ao:Eo;return o=t(n,e,s,r),a=t(e,n,s,ro),u}function u(t){return o(t)}return u.invert=function(t){return a(t)},u.domain=function(t){return arguments.length?(n=t.map(Number),s()):n},u.range=function(t){return arguments.length?(e=t,s()):e},u.rangeRound=function(t){return u.range(t).interpolate(mo)},u.clamp=function(t){return arguments.length?(i=t,s()):i},u.interpolate=function(t){return arguments.length?(r=t,s()):r},u.ticks=function(t){return Na(n,t)},u.tickFormat=function(t,e){return Pa(n,t,e)},u.nice=function(t){return Aa(n,t),s()},u.copy=function(){return t(n,e,r,i)},s()}([0,1],[0,1],ro,!1)};var Ca={s:1,g:1,p:1,r:1,e:1};function Ta(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}o.scale.log=function(){return function t(n,e,r,i){function a(t){return(r?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function s(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function u(t){return n(a(t))}return u.invert=function(t){return s(n.invert(t))},u.domain=function(t){return arguments.length?(r=t[0]>=0,n.domain((i=t.map(Number)).map(a)),u):i},u.base=function(t){return arguments.length?(e=+t,n.domain(i.map(a)),u):e},u.nice=function(){var t=Sa(i.map(a),r?Math:za);return n.domain(t),i=t.map(s),u},u.ticks=function(){var t=ma(i),n=[],o=t[0],u=t[1],c=Math.floor(a(o)),l=Math.ceil(a(u)),h=e%1?2:e;if(isFinite(l-c)){if(r){for(;c0;f--)n.push(s(c)*f);for(c=0;n[c]u;l--);n=n.slice(c,l)}return n},u.tickFormat=function(t,n){if(!arguments.length)return Ia;arguments.length<2?n=Ia:"function"!=typeof n&&(n=o.format(n));var r=Math.max(1,e*t/u.ticks().length);return function(t){var i=t/s(Math.round(a(t)));return i*e0?r[t-1]:n[0],th?0:1;if(c=Tt)return u(c,p)+(s?u(s,1-p):"")+"Z";var y,d,g,v,x,m,b,w,S,_,M,k,E=0,A=0,L=[];if((v=(+a.apply(this,arguments)||0)/2)&&(g=r===Va?Math.sqrt(s*s+c*c):+r.apply(this,arguments),p||(A*=-1),c&&(A=Gt(g/c*Math.sin(v))),s&&(E=Gt(g/s*Math.sin(v)))),c){x=c*Math.cos(l+A),m=c*Math.sin(l+A),b=c*Math.cos(h-A),w=c*Math.sin(h-A);var N=Math.abs(h-l-2*A)<=Pt?0:1;if(A&&Za(x,m,b,w)===p^N){var P=(l+h)/2;x=c*Math.cos(P),m=c*Math.sin(P),b=w=null}}else x=m=0;if(s){S=s*Math.cos(h-E),_=s*Math.sin(h-E),M=s*Math.cos(l+E),k=s*Math.sin(l+E);var C=Math.abs(l-h+2*E)<=Pt?0:1;if(E&&Za(S,_,M,k)===1-p^C){var T=(l+h)/2;S=s*Math.cos(T),_=s*Math.sin(T),M=k=null}}else S=_=0;if(f>Lt&&(y=Math.min(Math.abs(c-s)/2,+e.apply(this,arguments)))>.001){d=s0?0:1}function Ya(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],s=(i?r:-r)/Math.sqrt(o*o+a*a),u=s*a,c=-s*o,l=t[0]+u,h=t[1]+c,f=n[0]+u,p=n[1]+c,y=(l+f)/2,d=(h+p)/2,g=f-l,v=p-h,x=g*g+v*v,m=e-r,b=l*p-f*h,w=(v<0?-1:1)*Math.sqrt(Math.max(0,m*m*x-b*b)),S=(b*v-g*w)/x,_=(-b*g-v*w)/x,M=(b*v+g*w)/x,k=(-b*g+v*w)/x,E=S-y,A=_-d,L=M-y,N=k-d;return E*E+A*A>L*L+N*N&&(S=M,_=k),[[S-u,_-c],[S*e/m,_*e/m]]}function Ka(t){var n=ai,e=si,r=$e,i=$a,o=i.key,a=.7;function s(o){var s,u=[],c=[],l=-1,h=o.length,f=mn(n),p=mn(e);function y(){u.push("M",i(t(c),a))}for(;++l1&&i.push("H",r[0]);return i.join("")},"step-before":Qa,"step-after":ts,basis:rs,"basis-open":function(t){if(t.length<4)return $a(t);var n,e=[],r=-1,i=t.length,o=[0],a=[0];for(;++r<3;)n=t[r],o.push(n[0]),a.push(n[1]);e.push(is(ss,o)+","+is(ss,a)),--r;for(;++r9&&(i=3*n/Math.sqrt(i),a[s]=i*e,a[s+1]=i*r));s=-1;for(;++s<=u;)i=(t[Math.min(u,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+a[s]*a[s])),o.push([i||0,a[s]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function Ja(t){return t.join("L")+"Z"}function Qa(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n1){s=n[1],o=t[u],u++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-s[0])+","+(o[1]-s[1])+","+o[0]+","+o[1];for(var c=2;cPt)+",1 "+n}function u(t,n,e,r){return"Q 0,0 "+r}return o.radius=function(t){return arguments.length?(e=mn(t),o):e},o.source=function(n){return arguments.length?(t=mn(n),o):t},o.target=function(t){return arguments.length?(n=mn(t),o):n},o.startAngle=function(t){return arguments.length?(r=mn(t),o):r},o.endAngle=function(t){return arguments.length?(i=mn(t),o):i},o},o.svg.diagonal=function(){var t=Xr,n=Zr,e=ps;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),s=(o.y+a.y)/2,u=[o,{x:o.x,y:s},{x:a.x,y:s},a];return"M"+(u=u.map(e))[0]+"C"+u[1]+" "+u[2]+" "+u[3]}return r.source=function(n){return arguments.length?(t=mn(n),r):t},r.target=function(t){return arguments.length?(n=mn(t),r):n},r.projection=function(t){return arguments.length?(e=t,r):e},r},o.svg.diagonal.radial=function(){var t=o.svg.diagonal(),n=ps,e=t.projection;return t.projection=function(t){return arguments.length?e(ys(n=t)):n},t},o.svg.symbol=function(){var t=gs,n=ds;function e(e,r){return(xs.get(t.call(this,e,r))||vs)(n.call(this,e,r))}return e.type=function(n){return arguments.length?(t=mn(n),e):t},e.size=function(t){return arguments.length?(n=mn(t),e):n},e};var xs=o.map({circle:vs,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*bs)),e=n*bs;return"M0,"+-n+"L"+e+",0 0,"+n+" "+-e+",0Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/ms),e=n*ms/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/ms),e=n*ms/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});o.svg.symbolTypes=xs.keys();var ms=Math.sqrt(3),bs=Math.tan(30*zt);W.transition=function(t){for(var n,e,r=Ms||++As,i=Ps(t),o=[],a=ks||{time:Date.now(),ease:po,delay:0,duration:250},s=-1,u=this.length;++s0;)c[--f].call(t,a);if(o>=1)return h.event&&h.event.end.call(t,t.__data__,n),--l.count?delete l[r]:delete t[e],1}h||(o=i.time,a=An((function(t){var n=h.delay;if(a.t=n+o,n<=t)return f(t-n);a.c=f}),0,o),h=l[r]={tween:new k,time:o,timer:a,delay:i.delay,duration:i.duration,ease:i.ease,index:n},i=null,++l.count)}Es.call=W.call,Es.empty=W.empty,Es.node=W.node,Es.size=W.size,o.transition=function(t,n){return t&&t.transition?Ms?t.transition(n):t:o.selection().transition(t)},o.transition.prototype=Es,Es.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=$(t);for(var s=-1,u=this.length;++srect,.s>rect").attr("width",a[1]-a[0])}function d(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function g(){var h,g,v=this,x=o.select(o.event.target),m=e.of(v,arguments),b=o.select(v),w=x.datum(),S=!/^(n|s)$/.test(w)&&r,_=!/^(e|w)$/.test(w)&&i,M=x.classed("extent"),k=Mt(v),E=o.mouse(v),A=o.select(l(v)).on("keydown.brush",P).on("keyup.brush",C);if(o.event.changedTouches?A.on("touchmove.brush",T).on("touchend.brush",z):A.on("mousemove.brush",T).on("mouseup.brush",z),b.interrupt().selectAll("*").interrupt(),M)E[0]=a[0]-E[0],E[1]=s[0]-E[1];else if(w){var L=+/w$/.test(w),N=+/^n/.test(w);g=[a[1-L]-E[0],s[1-N]-E[1]],E[0]=a[L],E[1]=s[N]}else o.event.altKey&&(h=E.slice());function P(){32==o.event.keyCode&&(M||(h=null,E[0]-=a[1],E[1]-=s[1],M=2),V())}function C(){32==o.event.keyCode&&2==M&&(E[0]+=a[1],E[1]+=s[1],M=0,V())}function T(){var t=o.mouse(v),n=!1;g&&(t[0]+=g[0],t[1]+=g[1]),M||(o.event.altKey?(h||(h=[(a[0]+a[1])/2,(s[0]+s[1])/2]),E[0]=a[+(t[0]1?{floor:function(n){for(;s(n=t.floor(n));)n=Fs(n-1);return n},ceil:function(n){for(;s(n=t.ceil(n));)n=Fs(+n+1);return n}}:t))},r.ticks=function(t,n){var e=ma(r.domain()),o=null==t?i(e,10):"number"==typeof t?i(e,t):!t.range&&[{range:t},n];return o&&(t=o[0],n=o[1]),t.range(e[0],Fs(+e[1]+1),n<1?1:n)},r.tickFormat=function(){return e},r.copy=function(){return Bs(t.copy(),n,e)},Ea(r,t)}function Fs(t){return new Date(t)}Rs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Vs:js,Vs.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Vs.toString=js.toString,qn.second=Vn((function(t){return new Rn(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),qn.seconds=qn.second.range,qn.seconds.utc=qn.second.utc.range,qn.minute=Vn((function(t){return new Rn(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),qn.minutes=qn.minute.range,qn.minutes.utc=qn.minute.utc.range,qn.hour=Vn((function(t){var n=t.getTimezoneOffset()/60;return new Rn(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),qn.hours=qn.hour.range,qn.hours.utc=qn.hour.utc.range,qn.month=Vn((function(t){return(t=qn.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),qn.months=qn.month.range,qn.months.utc=qn.month.utc.range;var Hs=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Us=[[qn.second,1],[qn.second,5],[qn.second,15],[qn.second,30],[qn.minute,1],[qn.minute,5],[qn.minute,15],[qn.minute,30],[qn.hour,1],[qn.hour,3],[qn.hour,6],[qn.hour,12],[qn.day,1],[qn.day,2],[qn.week,1],[qn.month,1],[qn.month,3],[qn.year,1]],Xs=Rs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",$e]]),Zs={range:function(t,n,e){return o.range(Math.ceil(t/e)*e,+n,e).map(Fs)},floor:z,ceil:z};Us.year=qn.year,qn.scale=function(){return Bs(o.scale.linear(),Us,Xs)};var Ys=Us.map((function(t){return[t[0].utc,t[1]]})),Ks=Gs.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",$e]]);function Ws(t){return JSON.parse(t.responseText)}function $s(t){var n=u.createRange();return n.selectNode(u.body),n.createContextualFragment(t.responseText)}Ys.year=qn.year.utc,qn.scale.utc=function(){return Bs(o.scale.linear(),Ys,Ks)},o.text=bn((function(t){return t.responseText})),o.json=function(t,n){return wn(t,"application/json",Ws,n)},o.html=function(t,n){return wn(t,"text/html",$s,n)},o.xml=bn((function(t){return t.responseXML})),this.d3=o,void 0===(i="function"==typeof(r=o)?r.call(n,e,n,t):r)||(t.exports=i)}()},function(t,n){function e(t,n){this.x=t||0,this.y=n||0,Object.freeze(this)}e.prototype.distance=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},e.prototype.manhattanDistance=function(t){var n=this.sub(t).abs();return n.x+n.y},e.prototype.abs=function(){return new e(Math.abs(this.x),Math.abs(this.y))},e.prototype.equals=function(t){return this.x===t.x&&this.y===t.y},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.sub=function(t){return new e(this.x-t.x,this.y-t.y)},t.exports=e},function(t,n,e){var r=e(1);function i(t){arguments.length>0&&this.init(t)}i.prototype.init=function(t){this.status=t,this.points=new Array},i.prototype.appendPoint=function(t){this.points.push(t)},i.prototype.appendPoints=function(t){this.points=this.points.concat(t)},i.intersectShapes=function(t,n){var e,r=t.getIntersectionParams(),o=n.getIntersectionParams();if(null!=r&&null!=o)if("Path"==r.name)e=i.intersectPathShape(t,n);else if("Path"==o.name)e=i.intersectPathShape(n,t);else{var a,s;if(r.name0&&N.length>0){t:for(var P=0;P0&&(v.status="Intersection"),v},i.intersectBezier2Bezier3=function(t,n,e,o,a,s,u){var c,l,h,f,p,y,d,g,v,x,m,b=new i("No Intersection");c=n.multiply(-2),p=t.add(c.add(e)),c=t.multiply(-2),l=n.multiply(2),y=c.add(l),d=new r(t.x,t.y),c=o.multiply(-1),l=a.multiply(3),h=s.multiply(-3),f=c.add(l.add(h.add(u))),g=new Vector2D(f.x,f.y),c=o.multiply(3),l=a.multiply(-6),h=s.multiply(3),f=c.add(l.add(h)),v=new Vector2D(f.x,f.y),c=o.multiply(-3),l=a.multiply(3),h=c.add(l),x=new Vector2D(h.x,h.y),m=new Vector2D(o.x,o.y);for(var w=d.x*d.x,S=d.y*d.y,_=y.x*y.x,M=y.y*y.y,k=p.x*p.x,E=p.y*p.y,A=m.x*m.x,L=m.y*m.y,N=x.x*x.x,P=x.y*x.y,C=v.x*v.x,T=v.y*v.y,I=g.x*g.x,z=g.y*g.y,D=new Polynomial(-2*p.x*p.y*g.x*g.y+k*z+E*I,-2*p.x*p.y*v.x*g.y-2*p.x*p.y*v.y*g.x+2*E*v.x*g.x+2*k*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ezier2Ellipse=function(t,n,e,o,a,s){var u,c,l,h,f,p=new i("No Intersection");u=n.multiply(-2),l=t.add(u.add(e)),u=t.multiply(-2),c=n.multiply(2),h=u.add(c),f=new r(t.x,t.y);for(var y=a*a,d=s*s,g=new Polynomial(d*l.x*l.x+y*l.y*l.y,2*(d*l.x*h.x+y*l.y*h.y),d*(2*l.x*f.x+h.x*h.x)+y*(2*l.y*f.y+h.y*h.y)-2*(d*o.x*l.x+y*o.y*l.y),2*(d*h.x*(f.x-o.x)+y*h.y*(f.y-o.y)),d*(f.x*f.x+o.x*o.x)+y*(f.y*f.y+o.y*o.y)-2*(d*o.x*f.x+y*o.y*f.y)-y*d).getRoots(),v=0;v0&&(p.status="Intersection"),p},i.intersectBezier2Line=function(t,n,e,o,a){var s,u,c,l,h,f,p,y=o.min(a),d=o.max(a),g=new i("No Intersection");s=n.multiply(-2),c=t.add(s.add(e)),s=t.multiply(-2),u=n.multiply(2),l=s.add(u),h=new r(t.x,t.y),p=new Vector2D(o.y-a.y,a.x-o.x),f=o.x*a.y-a.x*o.y,roots=new Polynomial(p.dot(c),p.dot(l),p.dot(h)+f).getRoots();for(var v=0;v0&&(o.status="Intersection"),o},i.intersectBezier2Rectangle=function(t,n,e,o,a){var s=o.min(a),u=o.max(a),c=new r(u.x,s.y),l=new r(s.x,u.y),h=i.intersectBezier2Line(t,n,e,s,c),f=i.intersectBezier2Line(t,n,e,c,u),p=i.intersectBezier2Line(t,n,e,u,l),y=i.intersectBezier2Line(t,n,e,l,s),d=new i("No Intersection");return d.appendPoints(h.points),d.appendPoints(f.points),d.appendPoints(p.points),d.appendPoints(y.points),d.points.length>0&&(d.status="Intersection"),d},i.intersectBezier3Bezier3=function(t,n,e,r,o,a,s,u){var c,l,h,f,p,y,d,g,v,x,m,b,w=new i("No Intersection");c=t.multiply(-1),l=n.multiply(3),h=e.multiply(-3),f=c.add(l.add(h.add(r))),p=new Vector2D(f.x,f.y),c=t.multiply(3),l=n.multiply(-6),h=e.multiply(3),f=c.add(l.add(h)),y=new Vector2D(f.x,f.y),c=t.multiply(-3),l=n.multiply(3),h=c.add(l),d=new Vector2D(h.x,h.y),g=new Vector2D(t.x,t.y),c=o.multiply(-1),l=a.multiply(3),h=s.multiply(-3),f=c.add(l.add(h.add(u))),v=new Vector2D(f.x,f.y),c=o.multiply(3),l=a.multiply(-6),h=s.multiply(3),f=c.add(l.add(h)),x=new Vector2D(f.x,f.y),c=o.multiply(-3),l=a.multiply(3),h=c.add(l),m=new Vector2D(h.x,h.y),b=new Vector2D(o.x,o.y);for(var S=g.x*g.x,_=g.x*g.x*g.x,M=g.y*g.y,k=g.y*g.y*g.y,E=d.x*d.x,A=d.x*d.x*d.x,L=d.y*d.y,N=d.y*d.y*d.y,P=y.x*y.x,C=y.x*y.x*y.x,T=y.y*y.y,I=y.y*y.y*y.y,z=p.x*p.x,D=p.x*p.x*p.x,O=p.y*p.y,q=p.y*p.y*p.y,R=b.x*b.x,G=b.x*b.x*b.x,j=b.y*b.y,V=b.y*b.y*b.y,B=m.x*m.x,F=m.x*m.x*m.x,H=m.y*m.y,U=x.x*x.x,X=x.x*x.x*x.x,Z=x.y*x.y,Y=v.x*v.x,K=v.x*v.x*v.x,W=v.y*v.y,$=v.y*v.y*v.y,J=new Polynomial(-D*$+q*K-3*p.x*O*Y*v.y+3*z*p.y*v.x*W,-6*p.x*x.x*O*v.x*v.y+6*z*p.y*x.y*v.x*v.y+3*x.x*q*Y-3*D*x.y*W-3*p.x*O*x.y*Y+3*z*x.x*p.y*W,-6*m.x*p.x*O*v.x*v.y-6*p.x*x.x*O*x.y*v.x+6*z*x.x*p.y*x.y*v.y+3*m.x*q*Y+3*U*q*v.x+3*m.x*z*p.y*W-3*p.x*m.y*O*Y-3*p.x*U*O*v.y+z*p.y*v.x*(6*m.y*v.y+3*Z)+D*(-m.y*W-2*Z*v.y-v.y*(2*m.y*v.y+Z)),d.x*y.y*p.x*p.y*v.x*v.y-d.y*y.x*p.x*p.y*v.x*v.y+6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a,s){var u,c,l,h,f,p,y,d,g=new i("No Intersection");u=t.multiply(-1),c=n.multiply(3),l=e.multiply(-3),h=u.add(c.add(l.add(r))),f=new Vector2D(h.x,h.y),u=t.multiply(3),c=n.multiply(-6),l=e.multiply(3),h=u.add(c.add(l)),p=new Vector2D(h.x,h.y),u=t.multiply(-3),c=n.multiply(3),l=u.add(c),y=new Vector2D(l.x,l.y),d=new Vector2D(t.x,t.y);for(var v=a*a,x=s*s,m=new Polynomial(f.x*f.x*x+f.y*f.y*v,2*(f.x*p.x*x+f.y*p.y*v),2*(f.x*y.x*x+f.y*y.y*v)+p.x*p.x*x+p.y*p.y*v,2*f.x*x*(d.x-o.x)+2*f.y*v*(d.y-o.y)+2*(p.x*y.x*x+p.y*y.y*v),2*p.x*x*(d.x-o.x)+2*p.y*v*(d.y-o.y)+y.x*y.x*x+y.y*y.y*v,2*y.x*x*(d.x-o.x)+2*y.y*v*(d.y-o.y),d.x*d.x*x-2*d.y*o.y*v-2*d.x*o.x*x+d.y*d.y*v+o.x*o.x*x+o.y*o.y*v-v*x).getRootsInInterval(0,1),b=0;b0&&(g.status="Intersection"),g},i.intersectBezier3Line=function(t,n,e,r,o,a){var s,u,c,l,h,f,p,y,d,g,v=o.min(a),x=o.max(a),m=new i("No Intersection");s=t.multiply(-1),u=n.multiply(3),c=e.multiply(-3),l=s.add(u.add(c.add(r))),h=new Vector2D(l.x,l.y),s=t.multiply(3),u=n.multiply(-6),c=e.multiply(3),l=s.add(u.add(c)),f=new Vector2D(l.x,l.y),s=t.multiply(-3),u=n.multiply(3),c=s.add(u),p=new Vector2D(c.x,c.y),y=new Vector2D(t.x,t.y),g=new Vector2D(o.y-a.y,a.x-o.x),d=o.x*a.y-a.x*o.y,roots=new Polynomial(g.dot(h),g.dot(f),g.dot(p),g.dot(y)+d).getRoots();for(var b=0;b0&&(a.status="Intersection"),a},i.intersectBezier3Rectangle=function(t,n,e,o,a,s){var u=a.min(s),c=a.max(s),l=new r(c.x,u.y),h=new r(u.x,c.y),f=i.intersectBezier3Line(t,n,e,o,u,l),p=i.intersectBezier3Line(t,n,e,o,l,c),y=i.intersectBezier3Line(t,n,e,o,c,h),d=i.intersectBezier3Line(t,n,e,o,h,u),g=new i("No Intersection");return g.appendPoints(f.points),g.appendPoints(p.points),g.appendPoints(y.points),g.appendPoints(d.points),g.points.length>0&&(g.status="Intersection"),g},i.intersectCircleCircle=function(t,n,e,o){var a,s=n+o,u=Math.abs(n-o),c=t.distanceFrom(e);if(c>s)a=new i("Outside");else if(c1)&&(h<0||h>1)?o=new i(l<0&&h<0||l>1&&h>1?"Outside":"Inside"):(o=new i("Intersection"),0<=l&&l<=1&&o.points.push(e.lerp(r,l)),0<=h&&h<=1&&o.points.push(e.lerp(r,h)))}return o},i.intersectCirclePolygon=function(t,n,e){for(var r,o=new i("No Intersection"),a=e.length,s=0;s0?o.status="Intersection":o.status=r.status,o},i.intersectCircleRectangle=function(t,n,e,o){var a=e.min(o),s=e.max(o),u=new r(s.x,a.y),c=new r(a.x,s.y),l=i.intersectCircleLine(t,n,a,u),h=i.intersectCircleLine(t,n,u,s),f=i.intersectCircleLine(t,n,s,c),p=i.intersectCircleLine(t,n,c,a),y=new i("No Intersection");return y.appendPoints(l.points),y.appendPoints(h.points),y.appendPoints(f.points),y.appendPoints(p.points),y.points.length>0?y.status="Intersection":y.status=l.status,y},i.intersectEllipseEllipse=function(t,n,e,o,a,s){for(var u=[e*e,0,n*n,-2*e*e*t.x,-2*n*n*t.y,e*e*t.x*t.x+n*n*t.y*t.y-n*n*e*e],c=[s*s,0,a*a,-2*s*s*o.x,-2*a*a*o.y,s*s*o.x*o.x+a*a*o.y*o.y-a*a*s*s],l=i.bezout(u,c).getRoots(),h=.001*(u[0]*u[0]+2*u[1]*u[1]+u[2]*u[2]),f=.001*(c[0]*c[0]+2*c[1]*c[1]+c[2]*c[2]),p=new i("No Intersection"),y=0;y0&&(p.status="Intersection"),p},i.intersectEllipseLine=function(t,n,e,r,o){var a,s=new Vector2D(r.x,r.y),u=Vector2D.fromPoints(r,o),c=new Vector2D(t.x,t.y),l=s.subtract(c),h=new Vector2D(u.x/(n*n),u.y/(e*e)),f=new Vector2D(l.x/(n*n),l.y/(e*e)),p=u.dot(h),y=u.dot(f),d=y*y-p*(t=l.dot(f)-1);if(d<0)a=new i("Outside");else if(d>0){var g=Math.sqrt(d),v=(-y-g)/p,x=(-y+g)/p;(v<0||11&&x>1?"Outside":"Inside"):(a=new i("Intersection"),0<=v&&v<=1&&a.appendPoint(r.lerp(o,v)),0<=x&&x<=1&&a.appendPoint(r.lerp(o,x)))}else{var m=-y/p;0<=m&&m<=1?(a=new i("Intersection")).appendPoint(r.lerp(o,m)):a=new i("Outside")}return a},i.intersectEllipsePolygon=function(t,n,e,r){for(var o=new i("No Intersection"),a=r.length,s=0;s0&&(o.status="Intersection"),o},i.intersectEllipseRectangle=function(t,n,e,o,a){var s=o.min(a),u=o.max(a),c=new r(u.x,s.y),l=new r(s.x,u.y),h=i.intersectEllipseLine(t,n,e,s,c),f=i.intersectEllipseLine(t,n,e,c,u),p=i.intersectEllipseLine(t,n,e,u,l),y=i.intersectEllipseLine(t,n,e,l,s),d=new i("No Intersection");return d.appendPoints(h.points),d.appendPoints(f.points),d.appendPoints(p.points),d.appendPoints(y.points),d.points.length>0&&(d.status="Intersection"),d},i.intersectLineLine=function(t,n,e,o){var a,s=(o.x-e.x)*(t.y-e.y)-(o.y-e.y)*(t.x-e.x),u=(n.x-t.x)*(t.y-e.y)-(n.y-t.y)*(t.x-e.x),c=(o.y-e.y)*(n.x-t.x)-(o.x-e.x)*(n.y-t.y);if(0!=c){var l=s/c,h=u/c;0<=l&&l<=1&&0<=h&&h<=1?(a=new i("Intersection")).points.push(new r(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y))):a=new i("No Intersection")}else a=new i(0==s||0==u?"Coincident":"Parallel");return a},i.intersectLinePolygon=function(t,n,e){for(var r=new i("No Intersection"),o=e.length,a=0;a0&&(r.status="Intersection"),r},i.intersectLineRectangle=function(t,n,e,o){var a=e.min(o),s=e.max(o),u=new r(s.x,a.y),c=new r(a.x,s.y),l=i.intersectLineLine(a,u,t,n),h=i.intersectLineLine(u,s,t,n),f=i.intersectLineLine(s,c,t,n),p=i.intersectLineLine(c,a,t,n),y=new i("No Intersection");return y.appendPoints(l.points),y.appendPoints(h.points),y.appendPoints(f.points),y.appendPoints(p.points),y.points.length>0&&(y.status="Intersection"),y},i.intersectPolygonPolygon=function(t,n){for(var e=new i("No Intersection"),r=t.length,o=0;o0&&(e.status="Intersection"),e},i.intersectPolygonRectangle=function(t,n,e){var o=n.min(e),a=n.max(e),s=new r(a.x,o.y),u=new r(o.x,a.y),c=i.intersectLinePolygon(o,s,t),l=i.intersectLinePolygon(s,a,t),h=i.intersectLinePolygon(a,u,t),f=i.intersectLinePolygon(u,o,t),p=new i("No Intersection");return p.appendPoints(c.points),p.appendPoints(l.points),p.appendPoints(h.points),p.appendPoints(f.points),p.points.length>0&&(p.status="Intersection"),p},i.intersectRayRay=function(t,n,e,o){var a,s=(o.x-e.x)*(t.y-e.y)-(o.y-e.y)*(t.x-e.x),u=(n.x-t.x)*(t.y-e.y)-(n.y-t.y)*(t.x-e.x),c=(o.y-e.y)*(n.x-t.x)-(o.x-e.x)*(n.y-t.y);if(0!=c){var l=s/c;(a=new i("Intersection")).points.push(new r(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y)))}else a=new i(0==s||0==u?"Coincident":"Parallel");return a},i.intersectRectangleRectangle=function(t,n,e,o){var a=t.min(n),s=t.max(n),u=new r(s.x,a.y),c=new r(a.x,s.y),l=i.intersectLineRectangle(a,u,e,o),h=i.intersectLineRectangle(u,s,e,o),f=i.intersectLineRectangle(s,c,e,o),p=i.intersectLineRectangle(c,a,e,o),y=new i("No Intersection");return y.appendPoints(l.points),y.appendPoints(h.points),y.appendPoints(f.points),y.appendPoints(p.points),y.points.length>0&&(y.status="Intersection"),y},i.bezout=function(t,n){var e=t[0]*n[1]-n[0]*t[1],r=t[0]*n[2]-n[0]*t[2],i=t[0]*n[3]-n[0]*t[3],o=t[0]*n[4]-n[0]*t[4],a=t[0]*n[5]-n[0]*t[5],s=t[1]*n[2]-n[1]*t[2],u=t[1]*n[4]-n[1]*t[4],c=t[1]*n[5]-n[1]*t[5],l=t[2]*n[3]-n[2]*t[3],h=t[3]*n[4]-n[3]*t[4],f=t[3]*n[5]-n[3]*t[5],p=c+h,y=u-l;return new Polynomial(e*s-r*r,e*y+i*s-2*r*o,e*p+i*y-o*o-2*r*a,e*f+i*p-2*o*a,i*f-a*a)},t.exports=i},function(t){t.exports=JSON.parse('{"a":"2.0.4"}')},function(t,n,e){var r,i,o,a;function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}a=function(){return function t(n,e,r){function i(a,s){if(!e[a]){if(!n[a]){if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=e[a]={exports:{}};n[a][0].call(c.exports,(function(t){return i(n[a][1][t]||t)}),c,c.exports,t,n,e,r)}return e[a].exports}for(var o=!1,a=0;as;){var u=n[s][a];u>0&&u1e-9)break;var p=this.offsetDir();for(r=0;r1&&y>d||!isFinite(d))for(r=0;r1&&(g=1);var v=d*d,x=2*g*(y-d)/(v*y),m=h*y,b=2*-g/(v*m);for(isFinite(x)||console.log(x),r=0;r0?E-(N+1)*S:E-(N-1)*S;-w0;)for(var i=n;i-- >0;)e(r,i)},t.prototype.matrixApply=function(n){t.mApply(this.k,this.n,n)},t.prototype.computeNextPosition=function(t,n){var e=this;this.computeDerivatives(t);var r=this.computeStepSize(this.g);if(this.stepAndProject(t,n,this.g,r),this.project){this.matrixApply((function(r,i){return e.e[r][i]=t[r][i]-n[r][i]}));var i=this.computeStepSize(this.e);i=Math.max(.2,Math.min(i,1)),this.stepAndProject(t,n,this.e,i)}},t.prototype.run=function(t){for(var n=Number.MAX_VALUE,e=!1;!e&&t-- >0;){var r=this.rungeKutta();e=Math.abs(n/r-1)>16)/this.range},t.prototype.getNextBetween=function(t,n){return t+this.getNext()*(n-t)},t}();e.PseudoRandom=o},{}],8:[function(t,n,e){"use strict";var r,i=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});Object.defineProperty(e,"__esModule",{value:!0});var o=t("./rectangle"),a=function(){};e.Point=a;var s=function(t,n,e,r){this.x1=t,this.y1=n,this.x2=e,this.y2=r};e.LineSegment=s;var u=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n}(a);function c(t,n,e){return(n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y)}function l(t,n,e){return c(t,n,e)>0}function h(t,n,e){return c(t,n,e)<0}function f(t,n){var e,r,i,o,a=n.length-1;if(h(t,n[1],n[0])&&!l(t,n[a-1],n[0]))return 0;for(e=0,r=a;;){if(r-e==1)return l(t,n[e],n[r])?e:r;if((o=h(t,n[(i=Math.floor((e+r)/2))+1],n[i]))&&!l(t,n[i-1],n[i]))return i;l(t,n[e+1],n[e])?o||l(t,n[e],n[i])?r=i:e=i:o&&h(t,n[e],n[i])?r=i:e=i}}function p(t,n){var e,r,i,o,a=n.length-1;if(l(t,n[a-1],n[0])&&!h(t,n[1],n[0]))return 0;for(e=0,r=a;;){if(r-e==1)return h(t,n[e],n[r])?e:r;if(o=h(t,n[(i=Math.floor((e+r)/2))+1],n[i]),l(t,n[i-1],n[i])&&!o)return i;h(t,n[e+1],n[e])?o?h(t,n[e],n[i])?r=i:e=i:r=i:o?e=i:l(t,n[e],n[i])?r=i:e=i}}function y(t,n,e,r,i,o){var a,s;s=r(t[a=e(n[0],t)],n);for(var u=!1;!u;){for(u=!0;a===t.length-1&&(a=0),!i(n[s],t[a],t[a+1]);)++a;for(;0===s&&(s=n.length-1),!o(t[a],n[s],n[s-1]);)--s,u=!1}return{t1:a,t2:s}}function d(t,n){return y(t,n,f,p,l,h)}e.PolyPoint=u,e.isLeft=c,e.ConvexHull=function(t){var n,e=t.slice(0).sort((function(t,n){return t.x!==n.x?n.x-t.x:n.y-t.y})),r=t.length,i=e[0].x;for(n=1;n=0&&e[n].x===l;n--);for(s=n+1,n=o;++n<=s;)if(!(c(e[0],e[s],e[n])>=0&&n1&&!(c(a[a.length-2],a[a.length-1],e[n])>0);)a.length-=1;0!=n&&a.push(e[n])}u!=s&&a.push(e[u]);var h=a.length;for(n=s;--n>=o;)if(!(c(e[u],e[o],e[n])>=0&&n>o)){for(;a.length>h&&!(c(a[a.length-2],a[a.length-1],e[n])>0);)a.length-=1;0!=n&&a.push(e[n])}}return a},e.clockwiseRadialSweep=function(t,n,e){n.slice(0).sort((function(n,e){return Math.atan2(n.y-t.y,n.x-t.x)-Math.atan2(e.y-t.y,e.x-t.x)})).forEach(e)},e.tangent_PolyPolyC=y,e.LRtangent_PolyPolyC=function(t,n){var e=d(n,t);return{t1:e.t2,t2:e.t1}},e.RLtangent_PolyPolyC=d,e.LLtangent_PolyPolyC=function(t,n){return y(t,n,p,p,h,h)},e.RRtangent_PolyPolyC=function(t,n){return y(t,n,f,f,l,l)};var g=function(t,n){this.t1=t,this.t2=n};e.BiTangent=g;var v=function(){};e.BiTangents=v;var x=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n}(a);e.TVGPoint=x;var m=function(t,n,e,r){this.id=t,this.polyid=n,this.polyvertid=e,this.p=r,r.vv=this};e.VisibilityVertex=m;var b=function(){function t(t,n){this.source=t,this.target=n}return t.prototype.length=function(){var t=this.source.p.x-this.target.p.x,n=this.source.p.y-this.target.p.y;return Math.sqrt(t*t+n*n)},t}();e.VisibilityEdge=b;var w=function(){function t(t,n){if(this.P=t,this.V=[],this.E=[],n)this.V=n.V.slice(0),this.E=n.E.slice(0);else{for(var e=t.length,r=0;r0&&this.E.push(new b(i[o-1].vv,s))}i.length>1&&this.E.push(new b(i[0].vv,i[i.length-1].vv))}for(r=0;r0)return!0;return!1},t}();function S(t,n){for(var e=[],r=1,i=n.length;r=0&&d>=0&&x<0&&m>=0&&b>=0&&w<0?i.ll=new g(o,a):y<=0&&d<=0&&x>0&&m<=0&&b<=0&&w>0?i.rr=new g(o,a):y<=0&&d>0&&x<=0&&m>=0&&b<0&&w>=0?i.rl=new g(o,a):y>=0&&d<0&&x>=0&&m<=0&&b>0&&w<=0&&(i.lr=new g(o,a))}return i}function M(t,n){return!t.every((function(t){return!function(t,n){for(var e=1,r=n.length;e0)return!0}return!1}},{"./rectangle":17}],9:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t("./rectangle"),i=t("./vpsc"),o=t("./shortestpaths"),a=function(t,n,e){this.id=t,this.rect=n,this.children=e,this.leaf=void 0===e||0===e.length};e.NodeWrapper=a;var s=function(t,n,e,r,i){void 0===r&&(r=null),void 0===i&&(i=null),this.id=t,this.x=n,this.y=e,this.node=r,this.line=i};e.Vert=s;var u=function(){function t(n,e){this.s=n,this.t=e;var r=t.findMatch(n,e),i=e.slice(0).reverse(),o=t.findMatch(n,i);r.length>=o.length?(this.length=r.length,this.si=r.si,this.ti=r.ti,this.reversed=!1):(this.length=o.length,this.si=o.si,this.ti=e.length-o.ti-o.length,this.reversed=!0)}return t.findMatch=function(t,n){for(var e=t.length,r=n.length,i={length:0,si:-1,ti:-1},o=new Array(e),a=0;ai.length&&(i.length=u,i.si=a-u+1,i.ti=s-u+1)}else o[a][s]=0}return i},t.prototype.getSequence=function(){return this.length>=0?this.s.slice(this.si,this.si+this.length):[]},t}();e.LongestCommonSubsequence=u;var c=function(){function t(t,n,e){var i=this;void 0===e&&(e=12),this.originalnodes=t,this.groupPadding=e,this.leaves=null,this.nodes=t.map((function(t,e){return new a(e,n.getBounds(t),n.getChildren(t))})),this.leaves=this.nodes.filter((function(t){return t.leaf})),this.groups=this.nodes.filter((function(t){return!t.leaf})),this.cols=this.getGridLines("x"),this.rows=this.getGridLines("y"),this.groups.forEach((function(t){return t.children.forEach((function(n){return i.nodes[n].parent=t}))})),this.root={children:[]},this.nodes.forEach((function(t){void 0===t.parent&&(t.parent=i.root,i.root.children.push(t.id)),t.ports=[]})),this.backToFront=this.nodes.slice(0),this.backToFront.sort((function(t,n){return i.getDepth(t)-i.getDepth(n)})),this.backToFront.slice(0).reverse().filter((function(t){return!t.leaf})).forEach((function(t){var n=r.Rectangle.empty();t.children.forEach((function(t){return n=n.union(i.nodes[t].rect)})),t.rect=n.inflate(i.groupPadding)}));var o=this.midPoints(this.cols.map((function(t){return t.pos}))),u=this.midPoints(this.rows.map((function(t){return t.pos}))),c=o[0],l=o[o.length-1],h=u[0],f=u[u.length-1],p=this.rows.map((function(t){return{x1:c,x2:l,y1:t.pos,y2:t.pos}})).concat(u.map((function(t){return{x1:c,x2:l,y1:t,y2:t}}))),y=this.cols.map((function(t){return{x1:t.pos,x2:t.pos,y1:h,y2:f}})).concat(o.map((function(t){return{x1:t,x2:t,y1:h,y2:f}}))),d=p.concat(y);d.forEach((function(t){return t.verts=[]})),this.verts=[],this.edges=[],p.forEach((function(t){return y.forEach((function(n){var e=new s(i.verts.length,n.x1,t.y1);t.verts.push(e),n.verts.push(e),i.verts.push(e);for(var r=i.backToFront.length;r-- >0;){var o=i.backToFront[r],a=o.rect,u=Math.abs(e.x-a.cx()),c=Math.abs(e.y-a.cy());if(u0;){var r=e.filter((function(n){return n.rect["overlap"+t.toUpperCase()](e[0].rect)})),i={nodes:r,pos:this.avg(r.map((function(n){return n.rect["c"+t]()})))};n.push(i),i.nodes.forEach((function(t){return e.splice(e.indexOf(t),1)}))}return n.sort((function(t,n){return t.pos-n.pos})),n},t.prototype.getDepth=function(t){for(var n=0;t.parent!==this.root;)n++,t=t.parent;return n},t.prototype.midPoints=function(t){for(var n=t[1]-t[0],e=[t[0]-n/2],r=1;r.1)&&(c={pos:h[0][n],segments:[]},u.push(c)),c.segments.push(h)}return u},t.nudgeSegs=function(t,n,e,r,o,a){var s=r.length;if(!(s<=1)){for(var u=r.map((function(n){return new i.Variable(n[0][t])})),c=[],l=0;l=0&&c.push(new i.Constraint(u[g],u[v],a))}new i.Solver(u,c).solve(),u.forEach((function(n,i){var o=r[i],a=n.position();o[0][t]=o[1][t]=a;var s=e[o.edgeid];o.i>0&&(s[o.i-1][1][t]=a),o.iMath.PI||i<-Math.PI)&&(i=r-e),i},t.isLeft=function(t,n,e){return(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x)<=0},t.getOrder=function(t){for(var n={},e=0;e=c.length||h.ti+h.length>=l.length)?e.push({l:r,r:i}):(h.si+h.length>=c.length||h.ti+h.length>=l.length?(o=c[h.si+1],s=c[h.si-1],a=l[h.ti-1]):(o=c[h.si+h.length-2],a=c[h.si+h.length],s=l[h.ti+h.length]),t.isLeft(o,a,s)?e.push({l:i,r:r}):e.push({l:r,r:i})))}return t.getOrder(e)},t.makeSegments=function(t){function n(t){return{x:t.x,y:t.y}}for(var e=function(t,n,e){return Math.abs((n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x))<.001},r=[],i=n(t[0]),o=1;o1&&l>1?1e3:0})).reverse().map((function(t){return e.verts[t]}));return l.push(this.nodes[i.id].ports[0]),l.filter((function(t,n){return!(n0&&t.node===i&&l[n-1].node===i)}))},t.getRoutePath=function(n,e,r,i){var o,a,s,u={routepath:"M "+n[0][0].x+" "+n[0][0].y+" ",arrowpath:""};if(n.length>1)for(var c=0;c0?l-=f/Math.abs(f)*e:h-=p/Math.abs(p)*e,u.routepath+="L "+l+" "+h+" ";var y=n[c+1],d=y[0].x,g=y[0].y;f=y[1].x-d,p=y[1].y-g;var v,x,m=t.angleBetween2Lines(o,y)<0?1:0;Math.abs(f)>0?(v=d+f/Math.abs(f)*e,x=g):(v=d,x=g+p/Math.abs(p)*e);var b=Math.abs(v-l),w=Math.abs(x-h);u.routepath+="A "+b+" "+w+" 0 0 "+m+" "+v+" "+x+" "}else{var S=[l,h];Math.abs(f)>0?(a=[l-=f/Math.abs(f)*i,h+r],s=[l,h-r]):(a=[l+r,h-=p/Math.abs(p)*i],s=[l-r,h]),u.routepath+="L "+l+" "+h+" ",i>0&&(u.arrowpath="M "+S[0]+" "+S[1]+" L "+a[0]+" "+a[1]+" L "+s[0]+" "+s[1])}}else l=(o=n[0])[1].x,h=o[1].y,f=l-o[0].x,p=h-o[0].y,S=[l,h],Math.abs(f)>0?(a=[l-=f/Math.abs(f)*i,h+r],s=[l,h-r]):(a=[l+r,h-=p/Math.abs(p)*i],s=[l-r,h]),u.routepath+="L "+l+" "+h+" ",i>0&&(u.arrowpath="M "+S[0]+" "+S[1]+" L "+a[0]+" "+a[1]+" L "+s[0]+" "+s[1]);return u},t}();e.GridRouter=c},{"./rectangle":17,"./shortestpaths":18,"./vpsc":19}],10:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=10,i=(1+Math.sqrt(5))/2,o=1e-4;e.applyPacking=function(t,n,e,a,s,u){void 0===s&&(s=1),void 0===u&&(u=!0);var c=n,l=e,h=(s=void 0!==s?s:1,a=void 0!==a?a:0,0),f=0,p=0,y=0,d=[];function g(t,n){d=[],h=0,f=0,y=0;for(var e=0;e=t.height&&d[i].x+d[i].width+t.width+r-n<=o){e=d[i];break}d.push(t),void 0!==e?(t.x=e.x+e.width+r,t.y=e.bottom,t.space_left=t.height,t.bottom=t.y,e.space_left-=t.height+r,e.bottom+=t.height+r):(t.y=y,y+=t.height+r,t.x=0,t.bottom=t.y,t.space_left=t.height),t.y+t.height-f>-o&&(f=t.y+t.height-0),t.x+t.width-h>-o&&(h=t.x+t.width-0)}0!=t.length&&(function(t){t.forEach((function(t){var n,e,r,i,o;n=t,e=Number.MAX_VALUE,r=Number.MAX_VALUE,i=0,o=0,n.array.forEach((function(t){var n=void 0!==t.width?t.width:a,s=void 0!==t.height?t.height:a;n/=2,s/=2,i=Math.max(t.x+n,i),e=Math.min(t.x-n,e),o=Math.max(t.y+s,o),r=Math.min(t.y-s,r)})),n.width=i-e,n.height=o-r}))}(t),function(t,n){var e=Number.POSITIVE_INFINITY,a=0;t.sort((function(t,n){return n.height-t.height})),p=t.reduce((function(t,n){return t.widthp||d>o;){if(1!=f){var v=u-(u-s)/i;l=g(t,v)}if(0!=f){var x=s+(u-s)/i;h=g(t,x)}if(y=Math.abs(v-x),d=Math.abs(l-h),lh?(s=v,v=x,l=h,f=1):(u=x,x=v,h=l,f=0),c++>100)break}g(t,a)}(t),u&&function(t){t.forEach((function(t){var n={x:0,y:0};t.array.forEach((function(t){n.x+=t.x,n.y+=t.y})),n.x/=t.array.length,n.y/=t.array.length;var e=n.x-t.width/2,r=n.y-t.height/2,i=t.x-e+c/2-h/2,o=t.y-r+l/2-f/2;t.array.forEach((function(t){t.x+=i,t.y+=o}))}))}(t))},e.separateGraphs=function(t,n){for(var e={},r={},i=[],o=0,a=0;a0){var n=0;this._links.forEach((function(t){n=Math.max(n,t.source,t.target)})),this._nodes=new Array(++n);for(var e=0;e0?t:0:t>0&&(this._running||(this._running=!0,this.trigger({type:r.start,alpha:this._alpha=t}),this.kick())),this):this._alpha},t.prototype.getLinkLength=function(t){return"function"==typeof this._linkDistance?+this._linkDistance(t):this._linkDistance},t.setLinkLength=function(t,n){t.length=n},t.prototype.getLinkType=function(t){return"function"==typeof this._linkType?this._linkType(t):0},t.prototype.symmetricDiffLinkLengths=function(t,n){var e=this;return void 0===n&&(n=1),this.linkDistance((function(n){return t*n.length})),this._linkLengthCalculator=function(){return o.symmetricDiffLinkLengths(e._links,e.linkAccessor,n)},this},t.prototype.jaccardLinkLengths=function(t,n){var e=this;return void 0===n&&(n=1),this.linkDistance((function(n){return t*n.length})),this._linkLengthCalculator=function(){return o.jaccardLinkLengths(e._links,e.linkAccessor,n)},this},t.prototype.start=function(n,e,r,i,c,l){var h=this;void 0===n&&(n=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===c&&(c=!0),void 0===l&&(l=!0);var f,p=this.nodes().length,y=p+2*this._groups.length,d=(this._links.length,this._canvasSize[0]),g=this._canvasSize[1],v=new Array(y),x=new Array(y),m=null,b=this._avoidOverlaps;this._nodes.forEach((function(t,n){t.index=n,void 0===t.x&&(t.x=d/2,t.y=g/2),v[n]=t.x,x[n]=t.y})),this._linkLengthCalculator&&this._linkLengthCalculator(),this._distanceMatrix?f=this._distanceMatrix:(f=new u.Calculator(y,this._links,t.getSourceIndex,t.getTargetIndex,(function(t){return h.getLinkLength(t)})).DistanceMatrix(),m=a.Descent.createSquareMatrix(y,(function(){return 2})),this._links.forEach((function(t){"number"==typeof t.source&&(t.source=h._nodes[t.source]),"number"==typeof t.target&&(t.target=h._nodes[t.target])})),this._links.forEach((function(n){var e=t.getSourceIndex(n),r=t.getTargetIndex(n);m[e][r]=m[r][e]=n.weight||1})));var w=a.Descent.createSquareMatrix(y,(function(t,n){return f[t][n]}));if(this._rootGroup&&void 0!==this._rootGroup.groups){var S=p;this._groups.forEach((function(t){!function(t,n,e,r){m[t][n]=m[n][t]=e,w[t][n]=w[n][t]=r}(S,S+1,h._groupCompactness,.1),void 0===t.bounds?(v[S]=d/2,x[S++]=g/2,v[S]=d/2,x[S++]=g/2):(v[S]=t.bounds.x,x[S++]=t.bounds.y,v[S]=t.bounds.X,x[S++]=t.bounds.Y)}))}else this._rootGroup={leaves:this._nodes,groups:[]};var _=this._constraints||[];for(this._directedLinkConstraints&&(this.linkAccessor.getMinSeparation=this._directedLinkConstraints.getMinSeparation,_=_.concat(o.generateDirectedEdgeConstraints(p,this._links,this._directedLinkConstraints.axis,this.linkAccessor))),this.avoidOverlaps(!1),this._descent=new a.Descent([v,x],w),this._descent.locks.clear(),S=0;S0&&(this._descent.project=new s.Projection(this._nodes,this._groups,this._rootGroup,_).projectFunctions()),this._descent.run(e),this.separateOverlappingComponents(d,g,l),this.avoidOverlaps(b),b&&(this._nodes.forEach((function(t,n){t.x=v[n],t.y=x[n]})),this._descent.project=new s.Projection(this._nodes,this._groups,this._rootGroup,_,!0).projectFunctions(),this._nodes.forEach((function(t,n){v[n]=t.x,x[n]=t.y}))),this._descent.G=m,this._descent.run(r),i){this._descent.snapStrength=1e3,this._descent.snapGridSize=this._nodes[0].width,this._descent.numGridSnapNodes=p,this._descent.scaleSnapByMaxH=p!=y;var E=a.Descent.createSquareMatrix(y,(function(t,n){return t>=p||n>=p?m[t][n]:0}));this._descent.G=E,this._descent.run(i)}return this.updateNodePositions(),this.separateOverlappingComponents(d,g,l),c?this.resume():this},t.prototype.initialLayout=function(n,e,r){if(this._groups.length>0&&n>0){var i=this._nodes.length,o=this._links.map((function(t){return{source:t.source.index,target:t.target.index}})),a=this._nodes.map((function(t){return{index:t.index}}));this._groups.forEach((function(t,n){a.push({index:t.index=i+n})})),this._groups.forEach((function(t,n){void 0!==t.leaves&&t.leaves.forEach((function(n){return o.push({source:t.index,target:n.index})})),void 0!==t.groups&&t.groups.forEach((function(n){return o.push({source:t.index,target:n.index})}))})),(new t).size(this.size()).nodes(a).links(o).avoidOverlaps(!1).linkDistance(this.linkDistance()).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(n,0,0,0,!1),this._nodes.forEach((function(t){e[t.index]=a[t.index].x,r[t.index]=a[t.index].y}))}else this._descent.run(n)},t.prototype.separateOverlappingComponents=function(t,n,e){var r=this;if(void 0===e&&(e=!0),!this._distanceMatrix&&this._handleDisconnected){var i=this._descent.x[0],o=this._descent.x[1];this._nodes.forEach((function(t,n){t.x=i[n],t.y=o[n]}));var a=l.separateGraphs(this._nodes,this._links);l.applyPacking(a,t,n,this._defaultNodeSize,n/t,e),this._nodes.forEach((function(t,n){r._descent.x[0][n]=t.x,r._descent.x[1][n]=t.y,t.bounds&&(t.bounds.setXCentre(t.x),t.bounds.setYCentre(t.y))}))}},t.prototype.resume=function(){return this.alpha(.1)},t.prototype.stop=function(){return this.alpha(0)},t.prototype.prepareEdgeRouting=function(t){void 0===t&&(t=0),this._visibilityGraph=new c.TangentVisibilityGraph(this._nodes.map((function(n){return n.bounds.inflate(-t).vertices()})))},t.prototype.routeEdge=function(t,n,e){void 0===n&&(n=5);var r=[],i=new c.TangentVisibilityGraph(this._visibilityGraph.P,{V:this._visibilityGraph.V,E:this._visibilityGraph.E}),o={x:t.source.x,y:t.source.y},a={x:t.target.x,y:t.target.y},l=i.addPoint(o,t.source.index),h=i.addPoint(a,t.target.index);i.addEdgeIfVisible(o,a,t.source.index,t.target.index),void 0!==e&&e(i);var f=new u.Calculator(i.V.length,i.E,(function(t){return t.source.id}),(function(t){return t.target.id}),(function(t){return t.length()})).PathFromNodeToNode(l.id,h.id);if(1===f.length||f.length===i.V.length){var p=s.makeEdgeBetween(t.source.innerBounds,t.target.innerBounds,n);r=[p.sourceIntersection,p.arrowStart]}else{for(var y=f.length-2,d=i.V[f[y]].p,g=i.V[f[0]].p,v=(r=[t.source.innerBounds.rayIntersection(d.x,d.y)],y);v>=0;--v)r.push(i.V[f[v]].p);r.push(s.makeEdgeTo(g,t.target.innerBounds,n))}return r},t.getSourceIndex=function(t){return"number"==typeof t.source?t.source:t.source.index},t.getTargetIndex=function(t){return"number"==typeof t.target?t.target:t.target.index},t.linkId=function(n){return t.getSourceIndex(n)+"-"+t.getTargetIndex(n)},t.dragStart=function(n){h(n)?t.storeOffset(n,t.dragOrigin(n)):(t.stopNode(n),n.fixed|=2)},t.stopNode=function(t){t.px=t.x,t.py=t.y},t.storeOffset=function(n,e){void 0!==n.leaves&&n.leaves.forEach((function(n){n.fixed|=2,t.stopNode(n),n._dragGroupOffsetX=n.x-e.x,n._dragGroupOffsetY=n.y-e.y})),void 0!==n.groups&&n.groups.forEach((function(n){return t.storeOffset(n,e)}))},t.dragOrigin=function(t){return h(t)?{x:t.bounds.cx(),y:t.bounds.cy()}:t},t.drag=function(n,e){h(n)?(void 0!==n.leaves&&n.leaves.forEach((function(t){n.bounds.setXCentre(e.x),n.bounds.setYCentre(e.y),t.px=t._dragGroupOffsetX+e.x,t.py=t._dragGroupOffsetY+e.y})),void 0!==n.groups&&n.groups.forEach((function(n){return t.drag(n,e)}))):(n.px=e.x,n.py=e.y)},t.dragEnd=function(n){h(n)?(void 0!==n.leaves&&n.leaves.forEach((function(n){t.dragEnd(n),delete n._dragGroupOffsetX,delete n._dragGroupOffsetY})),void 0!==n.groups&&n.groups.forEach(t.dragEnd)):n.fixed&=-7},t.mouseOver=function(t){t.fixed|=4,t.px=t.x,t.py=t.y},t.mouseOut=function(t){t.fixed&=-5},t}();e.Layout=f},{"./descent":7,"./geom":8,"./handledisconnected":10,"./linklengths":13,"./powergraph":14,"./rectangle":17,"./shortestpaths":18}],12:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t("./shortestpaths"),i=t("./descent"),o=t("./rectangle"),a=t("./linklengths"),s=function(){function t(t,n){this.source=t,this.target=n}return t.prototype.actualLength=function(t){var n=this;return Math.sqrt(t.reduce((function(t,e){var r=e[n.target]-e[n.source];return t+r*r}),0))},t}();e.Link3D=s;var u=function(t,n,e){void 0===t&&(t=0),void 0===n&&(n=0),void 0===e&&(e=0),this.x=t,this.y=n,this.z=e};e.Node3D=u;var c=function(){function t(n,e,r){var i=this;void 0===r&&(r=1),this.nodes=n,this.links=e,this.idealLinkLength=r,this.constraints=null,this.useJaccardLinkLengths=!0,this.result=new Array(t.k);for(var o=0;o=this.R))return this.merge(n.a,n.b,t),!0}},t.prototype.nEdges=function(t,n){var e=t.incoming.intersection(n.incoming),r=t.outgoing.intersection(n.outgoing);return this.R-e.count()-r.count()},t.prototype.getGroupHierarchy=function(t){var n=this,e=[];return function t(n,e,r){n.forAll((function(n){if(n.isLeaf())e.leaves||(e.leaves=[]),e.leaves.push(n.id);else{var i=e;if(n.gid=r.length,!n.isIsland()||n.isPredefined()){if(i={id:n.gid},n.isPredefined())for(var o in n.definition)i[o]=n.definition[o];e.groups||(e.groups=[]),e.groups.push(n.gid),r.push(i)}t(n.children,i,r)}}))}(this.roots[0],{},e),this.allEdges().forEach((function(i){var o=n.modules[i.source],a=n.modules[i.target];t.push(new r(void 0===o.gid?i.source:e[o.gid],void 0===a.gid?i.target:e[a.gid],i.type))})),e},t.prototype.allEdges=function(){var n=[];return t.getEdges(this.roots[0],n),n},t.getEdges=function(n,e){n.forAll((function(n){n.getEdges(e),t.getEdges(n.children,e)}))},t}();e.Configuration=i;var o=function(){function t(t,n,e,r,i){void 0===n&&(n=new u),void 0===e&&(e=new u),void 0===r&&(r=new s),this.id=t,this.outgoing=n,this.incoming=e,this.children=r,this.definition=i}return t.prototype.getEdges=function(t){var n=this;this.outgoing.forAll((function(e,i){e.forAll((function(e){t.push(new r(n.id,e.id,i))}))}))},t.prototype.isLeaf=function(){return 0===this.children.count()},t.prototype.isIsland=function(){return 0===this.outgoing.count()&&0===this.incoming.count()},t.prototype.isPredefined=function(){return void 0!==this.definition},t}();function a(t,n){var e={};for(var r in t)r in n&&(e[r]=t[r]);return e}e.Module=o;var s=function(){function t(){this.table={}}return t.prototype.count=function(){return Object.keys(this.table).length},t.prototype.intersection=function(n){var e=new t;return e.table=a(this.table,n.table),e},t.prototype.intersectionCount=function(t){return this.intersection(t).count()},t.prototype.contains=function(t){return t in this.table},t.prototype.add=function(t){this.table[t.id]=t},t.prototype.remove=function(t){delete this.table[t.id]},t.prototype.forAll=function(t){for(var n in this.table)t(this.table[n])},t.prototype.modules=function(){var t=[];return this.forAll((function(n){n.isPredefined()||t.push(n)})),t},t}();e.ModuleSet=s;var u=function(){function t(){this.sets={},this.n=0}return t.prototype.count=function(){return this.n},t.prototype.contains=function(t){var n=!1;return this.forAllModules((function(e){n||e.id!=t||(n=!0)})),n},t.prototype.add=function(t,n){(t in this.sets?this.sets[t]:this.sets[t]=new s).add(n),++this.n},t.prototype.remove=function(t,n){var e=this.sets[t];e.remove(n),0===e.count()&&delete this.sets[t],--this.n},t.prototype.forAll=function(t){for(var n in this.sets)t(this.sets[n],Number(n))},t.prototype.forAllModules=function(t){this.forAll((function(n,e){return n.forAll(t)}))},t.prototype.intersection=function(n){var e=new t;return this.forAll((function(t,r){if(r in n.sets){var i=t.intersection(n.sets[r]),o=i.count();o>0&&(e.sets[r]=i,e.n+=o)}})),e},t}();e.LinkSets=u,e.getGroups=function(t,n,e,r){for(var o=t.length,a=new i(o,n,e,r);a.greedyMerge(););var s=[],u=a.getGroupHierarchy(s);return s.forEach((function(n){var e=function(e){var r=n[e];"number"==typeof r&&(n[e]=t[r])};e("source"),e("target")})),{groups:u,powerEdges:s}}},{}],15:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this.elem=t,this.subheaps=[]}return t.prototype.toString=function(t){for(var n="",e=!1,r=0;r0)}return null}}return t.prototype.clear=function(){this._root=null,this.size=0},t.prototype.find=function(t){for(var n=this._root;null!==n;){var e=this._comparator(t,n.data);if(0===e)return n.data;n=n.get_child(e>0)}return null},t.prototype.lowerBound=function(t){return this._bound(t,this._comparator)},t.prototype.upperBound=function(t){var n=this._comparator;return this._bound(t,(function(t,e){return n(e,t)}))},t.prototype.min=function(){var t=this._root;if(null===t)return null;for(;null!==t.left;)t=t.left;return t.data},t.prototype.max=function(){var t=this._root;if(null===t)return null;for(;null!==t.right;)t=t.right;return t.data},t.prototype.iterator=function(){return new a(this)},t.prototype.each=function(t){for(var n,e=this.iterator();null!==(n=e.next());)t(n)},t.prototype.reach=function(t){for(var n,e=this.iterator();null!==(n=e.prev());)t(n)},t.prototype._bound=function(t,n){for(var e=this._root,r=this.iterator();null!==e;){var i=this._comparator(t,e.data);if(0===i)return r._cursor=e,r;r._ancestors.push(e),e=e.get_child(i>0)}for(var o=r._ancestors.length-1;o>=0;--o)if(n(t,(e=r._ancestors[o]).data)>0)return r._cursor=e,r._ancestors.length=o,r;return r._ancestors.length=0,r},t}();e.TreeBase=o;var a=function(){function t(t){this._tree=t,this._ancestors=[],this._cursor=null}return t.prototype.data=function(){return null!==this._cursor?this._cursor.data:null},t.prototype.next=function(){if(null===this._cursor){var t=this._tree._root;null!==t&&this._minNode(t)}else{var n;if(null===this._cursor.right)do{if(n=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.right===n);else this._ancestors.push(this._cursor),this._minNode(this._cursor.right)}return null!==this._cursor?this._cursor.data:null},t.prototype.prev=function(){if(null===this._cursor){var t=this._tree._root;null!==t&&this._maxNode(t)}else{var n;if(null===this._cursor.left)do{if(n=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.left===n);else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left)}return null!==this._cursor?this._cursor.data:null},t.prototype._minNode=function(t){for(;null!==t.left;)this._ancestors.push(t),t=t.left;this._cursor=t},t.prototype._maxNode=function(t){for(;null!==t.right;)this._ancestors.push(t),t=t.right;this._cursor=t},t}();e.Iterator=a;var s=function(){function t(t){this.data=t,this.left=null,this.right=null,this.red=!0}return t.prototype.get_child=function(t){return t?this.right:this.left},t.prototype.set_child=function(t,n){t?this.right=n:this.left=n},t}(),u=function(t){function n(n){var e=t.call(this)||this;return e._root=null,e._comparator=n,e.size=0,e}return i(n,t),n.prototype.insert=function(t){var e=!1;if(null===this._root)this._root=new s(t),e=!0,this.size++;else{var r=new s(void 0),i=!1,o=!1,a=null,u=r,c=null,l=this._root;for(u.right=this._root;;){if(null===l?(l=new s(t),c.set_child(i,l),e=!0,this.size++):n.is_red(l.left)&&n.is_red(l.right)&&(l.red=!0,l.left.red=!1,l.right.red=!1),n.is_red(l)&&n.is_red(c)){var h=u.right===a;l===c.get_child(o)?u.set_child(h,n.single_rotate(a,!o)):u.set_child(h,n.double_rotate(a,!o))}var f=this._comparator(l.data,t);if(0===f)break;o=i,i=f<0,null!==a&&(u=a),a=c,c=l,l=l.get_child(i)}this._root=r.right}return this._root.red=!1,e},n.prototype.remove=function(t){if(null===this._root)return!1;var e=new s(void 0),r=e;r.right=this._root;for(var i=null,o=null,a=null,u=!0;null!==r.get_child(u);){var c=u;o=i,i=r,r=r.get_child(u);var l=this._comparator(t,r.data);if(u=l>0,0===l&&(a=r),!n.is_red(r)&&!n.is_red(r.get_child(u)))if(n.is_red(r.get_child(!u))){var h=n.single_rotate(r,u);i.set_child(c,h),i=h}else if(!n.is_red(r.get_child(!u))){var f=i.get_child(!c);if(null!==f)if(n.is_red(f.get_child(!c))||n.is_red(f.get_child(c))){var p=o.right===i;n.is_red(f.get_child(c))?o.set_child(p,n.double_rotate(i,c)):n.is_red(f.get_child(!c))&&o.set_child(p,n.single_rotate(i,c));var y=o.get_child(p);y.red=!0,r.red=!0,y.left.red=!1,y.right.red=!1}else i.red=!1,f.red=!0,r.red=!0}}return null!==a&&(a.data=r.data,i.set_child(i.right===r,r.get_child(null===r.left)),this.size--),this._root=e.right,null!==this._root&&(this._root.red=!1),null!==a},n.is_red=function(t){return null!==t&&t.red},n.single_rotate=function(t,n){var e=t.get_child(!n);return t.set_child(!n,e.get_child(n)),e.set_child(n,t),t.red=!0,e.red=!1,e},n.double_rotate=function(t,e){return t.set_child(!e,n.single_rotate(t.get_child(!e),!e)),n.single_rotate(t,e)},n}(o);e.RBTree=u},{}],17:[function(t,n,e){"use strict";var r,i=this&&this.__extends||(r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)},function(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)});Object.defineProperty(e,"__esModule",{value:!0});var o=t("./vpsc"),a=t("./rbtree");function s(t){return t.bounds=void 0!==t.leaves?t.leaves.reduce((function(t,n){return n.bounds.union(t)}),u.empty()):u.empty(),void 0!==t.groups&&(t.bounds=t.groups.reduce((function(t,n){return s(n).union(t)}),t.bounds)),t.bounds=t.bounds.inflate(t.padding),t.bounds}e.computeGroupBounds=s;var u=function(){function t(t,n,e,r){this.x=t,this.X=n,this.y=e,this.Y=r}return t.empty=function(){return new t(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)},t.prototype.cx=function(){return(this.x+this.X)/2},t.prototype.cy=function(){return(this.y+this.Y)/2},t.prototype.overlapX=function(t){var n=this.cx(),e=t.cx();return n<=e&&t.x0?e[0]:null},t.prototype.vertices=function(){return[{x:this.x,y:this.y},{x:this.X,y:this.y},{x:this.X,y:this.Y},{x:this.x,y:this.Y}]},t.lineIntersection=function(t,n,e,r,i,o,a,s){var u=e-t,c=a-i,l=r-n,h=s-o,f=h*u-c*l;if(0==f)return null;var p=t-i,y=n-o,d=(c*y-h*p)/f,g=(u*y-l*p)/f;return d>=0&&d<=1&&g>=0&&g<=1?{x:t+d*u,y:n+d*l}:null},t.prototype.inflate=function(n){return new t(this.x-n,this.X+n,this.y-n,this.Y+n)},t}();e.Rectangle=u,e.makeEdgeBetween=function(t,n,e){var r=t.rayIntersection(n.cx(),n.cy())||{x:t.cx(),y:t.cy()},i=n.rayIntersection(t.cx(),t.cy())||{x:n.cx(),y:n.cy()},o=i.x-r.x,a=i.y-r.y,s=Math.sqrt(o*o+a*a),u=s-e;return{sourceIntersection:r,targetIntersection:i,arrowStart:{x:r.x+u*o/s,y:r.y+u*a/s}}},e.makeEdgeTo=function(t,n,e){var r=n.rayIntersection(t.x,t.y);r||(r={x:n.cx(),y:n.cy()});var i=r.x-t.x,o=r.y-t.y,a=Math.sqrt(i*i+o*o);return{x:r.x-e*i/a,y:r.y-e*o/a}};var c=function(t,n,e){this.v=t,this.r=n,this.pos=e,this.prev=f(),this.next=f()},l=function(t,n,e){this.isOpen=t,this.v=n,this.pos=e};function h(t,n){return t.pos>n.pos?1:t.pos0&&(t[e].insert(i),i[r].insert(t))};e("next","prev"),e("prev","next")}};function d(t,n,e,r){void 0===r&&(r=!1);var i=t.padding,o=void 0!==t.groups?t.groups.length:0,a=void 0!==t.leaves?t.leaves.length:0,s=o?t.groups.reduce((function(t,r){return t.concat(d(r,n,e,!0))}),[]):[],u=(r?2:0)+a+o,c=new Array(u),l=new Array(u),h=0,f=function(t,n){l[h]=t,c[h++]=n};if(r){var p=t.bounds,y=n.getCentre(p),v=n.getSize(p)/2,x=n.getOpen(p),m=n.getClose(p),b=y-v+i/2,w=y+v-i/2;t.minVar.desiredPosition=b,f(n.makeRect(x,m,b,i),t.minVar),t.maxVar.desiredPosition=w,f(n.makeRect(x,m,w,i),t.maxVar)}a&&t.leaves.forEach((function(t){return f(t.bounds,t.variable)})),o&&t.groups.forEach((function(t){var e=t.bounds;f(n.makeRect(n.getOpen(e),n.getClose(e),n.getCentre(e),n.getSize(e)),t.minVar)}));var S=g(l,c,n,e);return o&&(c.forEach((function(t){t.cOut=[],t.cIn=[]})),S.forEach((function(t){t.left.cOut.push(t),t.right.cIn.push(t)})),t.groups.forEach((function(t){var e=(t.padding-n.getSize(t.bounds))/2;t.minVar.cIn.forEach((function(t){return t.gap+=e})),t.minVar.cOut.forEach((function(n){n.left=t.maxVar,n.gap+=e}))}))),s.concat(S)}function g(t,n,e,r){var i,a=t.length,s=2*a;console.assert(n.length>=a);var u=new Array(s);for(i=0;it[e]&&(t[e]=n)}o=t}))}},t.prototype.createAlignment=function(t){var n=this,e=this.nodes[t.offsets[0].node].variable;this.makeFeasible(t);var r="x"===t.axis?this.xConstraints:this.yConstraints;t.offsets.slice(1).forEach((function(t){var i=n.nodes[t.node].variable;r.push(new o.Constraint(e,i,t.offset,!0))}))},t.prototype.createConstraints=function(t){var n=this,e=function(t){return void 0===t.type||"separation"===t.type};this.xConstraints=t.filter((function(t){return"x"===t.axis&&e(t)})).map((function(t){return n.createSeparation(t)})),this.yConstraints=t.filter((function(t){return"y"===t.axis&&e(t)})).map((function(t){return n.createSeparation(t)})),t.filter((function(t){return"alignment"===t.type})).forEach((function(t){return n.createAlignment(t)}))},t.prototype.setupVariablesAndBounds=function(t,n,e,r){this.nodes.forEach((function(i,o){i.fixed?(i.variable.weight=i.fixedWeight?i.fixedWeight:1e3,e[o]=r(i)):i.variable.weight=1;var a=(i.width||0)/2,s=(i.height||0)/2,c=t[o],l=n[o];i.bounds=new u(c-a,c+a,l-s,l+s)}))},t.prototype.xProject=function(t,n,e){(this.rootGroup||this.avoidOverlaps||this.xConstraints)&&this.project(t,n,t,e,(function(t){return t.px}),this.xConstraints,m,(function(t){return t.bounds.setXCentre(e[t.variable.index]=t.variable.position())}),(function(t){var n=e[t.minVar.index]=t.minVar.position(),r=e[t.maxVar.index]=t.maxVar.position(),i=t.padding/2;t.bounds.x=n-i,t.bounds.X=r+i}))},t.prototype.yProject=function(t,n,e){(this.rootGroup||this.yConstraints)&&this.project(t,n,n,e,(function(t){return t.py}),this.yConstraints,b,(function(t){return t.bounds.setYCentre(e[t.variable.index]=t.variable.position())}),(function(t){var n=e[t.minVar.index]=t.minVar.position(),r=e[t.maxVar.index]=t.maxVar.position(),i=t.padding/2;t.bounds.y=n-i,t.bounds.Y=r+i}))},t.prototype.projectFunctions=function(){var t=this;return[function(n,e,r){return t.xProject(n,e,r)},function(n,e,r){return t.yProject(n,e,r)}]},t.prototype.project=function(t,n,e,r,i,o,a,u,c){this.setupVariablesAndBounds(t,n,r,i),this.rootGroup&&this.avoidOverlaps&&(s(this.rootGroup),o=o.concat(a(this.rootGroup))),this.solve(this.variables,o,e,r),this.nodes.forEach(u),this.rootGroup&&this.avoidOverlaps&&(this.groups.forEach(c),s(this.rootGroup))},t.prototype.solve=function(t,n,e,r){var i=new o.Solver(t,n);i.setStartingPositions(e),i.setDesiredPositions(r),i.solve()},t}();e.Projection=S},{"./rbtree":16,"./vpsc":19}],18:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t("./pqueue"),i=function(t,n){this.id=t,this.distance=n},o=function(t){this.id=t,this.neighbours=[]},a=function(t,n,e){this.node=t,this.prev=n,this.d=e},s=function(){function t(t,n,e,r,a){this.n=t,this.es=n,this.neighbours=new Array(this.n);for(var s=this.n;s--;)this.neighbours[s]=new o(s);for(s=this.es.length;s--;){var u=this.es[s],c=e(u),l=r(u),h=a(u);this.neighbours[c].neighbours.push(new i(l,h)),this.neighbours[l].neighbours.push(new i(c,h))}}return t.prototype.DistanceMatrix=function(){for(var t=new Array(this.n),n=0;nh&&(c.d=h,c.prev=s,e.reduceKey(c.q,c,(function(t,n){return t.q=n})))}}return o},t}();e.Calculator=s},{"./pqueue":15}],19:[function(t,n,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this.scale=t,this.AB=0,this.AD=0,this.A2=0}return t.prototype.addVariable=function(t){var n=this.scale/t.scale,e=t.offset/t.scale,r=t.weight;this.AB+=r*n*e,this.AD+=r*n*t.desiredPosition,this.A2+=r*n*n},t.prototype.getPosn=function(){return(this.AD-this.AB)/this.A2},t}();e.PositionStats=r;var i=function(){function t(t,n,e,r){void 0===r&&(r=!1),this.left=t,this.right=n,this.gap=e,this.equality=r,this.active=!1,this.unsatisfiable=!1,this.left=t,this.right=n,this.gap=e,this.equality=r}return t.prototype.slack=function(){return this.unsatisfiable?Number.MAX_VALUE:this.right.scale*this.right.position()-this.gap-this.left.scale*this.left.position()},t}();e.Constraint=i;var o=function(){function t(t,n,e){void 0===n&&(n=1),void 0===e&&(e=1),this.desiredPosition=t,this.weight=n,this.scale=e,this.offset=0}return t.prototype.dfdv=function(){return 2*this.weight*(this.position()-this.desiredPosition)},t.prototype.position=function(){return(this.block.ps.scale*this.block.posn+this.offset)/this.scale},t.prototype.visitNeighbours=function(t,n){var e=function(e,r){return e.active&&t!==r&&n(e,r)};this.cOut.forEach((function(t){return e(t,t.right)})),this.cIn.forEach((function(t){return e(t,t.left)}))},t}();e.Variable=o;var a=function(){function t(t){this.vars=[],t.offset=0,this.ps=new r(t.scale),this.addVariable(t)}return t.prototype.addVariable=function(t){t.block=this,this.vars.push(t),this.ps.addVariable(t),this.posn=this.ps.getPosn()},t.prototype.updateWeightedPosition=function(){this.ps.AB=this.ps.AD=this.ps.A2=0;for(var t=0,n=this.vars.length;t=0?this.inactive.push(n):this.bs.merge(n)}}},t.prototype.solve=function(){this.satisfy();for(var t=Number.MAX_VALUE,n=this.bs.cost();Math.abs(t-n)>1e-4;)this.satisfy(),t=n,n=this.bs.cost();return n},t.LAGRANGIAN_TOLERANCE=-1e-4,t.ZERO_UPPERBOUND=-1e-10,t}();e.Solver=u,e.removeOverlapInOneDimension=function(t,n,e){for(var r=t.map((function(t){return new o(t.desiredCenter)})),a=[],s=t.length,c=0;c=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function f(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e-1&&(this.uncertainBegin=0,this.begin=e(o.substring(1,o.length))),a.indexOf(">")>-1&&(this.end=e(a.substring(1,o.length)),this.uncertainEnd=t.size),o.indexOf(">")>-1&&a.indexOf("<")>-1&&(this.uncertainBegin=e(o.substring(1,o.length)),this.begin=e(a.substring(1,o.length)),this.end=null)}}function g(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,n)||x(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=x(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function x(t,n){if(t){if("string"==typeof t)return m(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?m(t,n):void 0}}function m(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e25&&(this.labelText=this.labelText.substr(0,16)+"..."),this.labelText=this.name,this.labelTextNode=document.createTextNode(this.labelText),this.labelSVG.appendChild(this.labelTextNode),this.labelSVG.setAttribute("transform","translate( -"+this.getSymbolRadius()+" "+"-5)"),this.upperGroup.appendChild(this.labelSVG)},p.prototype.initOutline=function(){this.outline.classList.add("outline"),this.upperGroup.appendChild(this.outline)},p.prototype.initListeners=function(){var t=this;this.upperGroup.onmousedown=function(n){t.mouseDown(n)},this.upperGroup.onmouseenter=function(n){t.mouseOver(n)},this.upperGroup.onmouseleave=function(n){t.mouseOut(n)},this.upperGroup.ontouchstart=function(n){t.touchStart(n)}},p.prototype.addStoichiometryLabel=function(t){this.labelSVG&&(this.labelSVG.childNodes[0].data=this.labelSVG.childNodes[0].data+" ["+t+"]")},p.prototype.mouseDown=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.app.d3cola.stop(),this.app.dragElement=this,this.app.dragStart=t,!1},p.prototype.touchStart=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.app.d3cola.stop(),this.app.dragElement=this,this.app.dragStart=t,!1},p.prototype.mouseOver=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.showHighlight(!0),this.app.notifyHoverListeners([this.json.id]),!1},p.prototype.mouseOut=function(t){return this.app.preventDefaultsAndStopPropagation(t),this.showHighlight(!1),this.app.hideTooltip(),this.app.notifyHoverListeners([]),!1},p.prototype.getSymbolRadius=function(){return 15},p.prototype.showHighlight=function(){},p.prototype.getPosition=function(){return[this.ix,this.iy]},p.prototype.setPosition=function(t,n){this.px=this.ix,this.py=this.iy;var e=this.width/2-this.getSymbolRadius();this.expanded&&(e-=this.size/2*this.stickZoom),this.ix=t+e,this.iy=n,this.upperGroup.setAttribute("transform","translate("+this.ix+" "+this.iy+")")},p.prototype.changePosition=function(t,n){this.px=this.ix,this.py=this.iy,this.ix-=t,this.iy-=n,this.upperGroup.setAttribute("transform","translate("+this.ix+" "+this.iy+")")},p.prototype.getAggregateSelfLinkPath=function(){var t=this.getSymbolRadius()+7,n=y(t,70),e=y(t,20),r=y(t,85),i=y(t,5);return"M 0,0 Q "+r.x+","+-r.y+" "+n.x+","+-n.y+" A "+t+" "+t+" 0 0 1 "+e.x+","+-e.y+" Q "+i.x+","+-i.y+" 0,0"},p.prototype.checkLinks=function(){function t(t){var n,e=h(t.values());try{for(e.s();!(n=e.n()).done;){n.value.check()}}catch(t){e.e(t)}finally{e.f()}}t(this.binaryLinks),t(this.sequenceLinks),this.selfLink&&this.selfLink.check()},p.prototype.setAllLinkCoordinates=function(){var t,n=h(this.naryLinks.values());try{for(n.s();!(t=n.n()).done;){t.value.setLinkCoordinates()}}catch(t){n.e(t)}finally{n.f()}var e,r=h(this.binaryLinks.values());try{for(r.s();!(e=r.n()).done;){e.value.setLinkCoordinates()}}catch(t){r.e(t)}finally{r.f()}this.selfLink&&this.selfLink.setLinkCoordinates();var i,o=h(this.sequenceLinks.values());try{for(o.s();!(i=o.n()).done;){i.value.setLinkCoordinates()}}catch(t){o.e(t)}finally{o.f()}},d.prototype.toString=function(){return this.sequenceDatumString},d.prototype.overlaps=function(t){if(this.participant===t.participant){var n=this.uncertainBegin||this.begin||this.end||this.uncertainEnd,e=this.uncertainEnd||this.end||this.begin||this.uncertainBegin,r=t.uncertainBegin||t.begin||t.end;if(n<=(t.uncertainEnd||t.end||t.begin)&&r<=e)return!0}return!1},b.STICKHEIGHT=20,b.MAXSIZE=0,b.transitionTime=650,b.prototype=new p,b.prototype.getSymbolRadius=function(){return 15},b.prototype.showHighlight=function(t){this.highlight.setAttribute("stroke-opacity",t?"1":"0")},b.minXDist=30,b.prototype.setStickScale=function(t,n){var e=this.stickZoom,r=this.ix-n.x,i=this.iy-n.y,o=r*t/e-r,a=i*t/e-i;0!==this.rotation&&180!==this.rotation||(a=0);var s=this.ix+o,u=this.iy+a;this.stickZoom=t,this.scale(),this.setPosition(s,u),this.setAllLinkCoordinates()},b.prototype.scale=function(){var t=this.size*this.stickZoom;if(this.expanded){var n=i.transform(this.labelSVG.getAttribute("transform")),e=this.app.svgElement.createSVGMatrix().rotate(n.rotate).translate(-(this.size/2*this.stickZoom+(this.nTerminusFeature?25:10)),-5);this.labelSVG.transform.baseVal.initialize(this.app.svgElement.createSVGTransformFromMatrix(e)),this.updateAnnotationRectanglesNoTransition(),i.select(this.background).attr("width",t).attr("x",this.getResXWithStickZoom(.5)),i.select(this.outline).attr("width",t).attr("x",this.getResXWithStickZoom(.5)),i.select(this.highlight).attr("width",t+5).attr("x",this.getResXWithStickZoom(.5)-2.5),this.setScaleGroup()}},b.prototype.setScaleGroup=function(){this.upperGroup.appendChild(this.ticks),this.ticks.textContent="",this.scaleLabels=[];for(var t=-1,n=this.getResXWithStickZoom(this.size),e=1;e<=this.size;e++){if(1===e||e%100==0&&200*this.stickZoom>b.minXDist||e%10==0&&20*this.stickZoom>b.minXDist){var r=this.getResXWithStickZoom(e);(this.stickZoom>=8||1!==e)&&s(this,r),0===(t=(t+1)%2)&&r+b.minXDist=8){var i=document.createElementNS(c,"g");i.setAttribute("transform","translate("+this.getResXWithStickZoom(e)+" 0)");var o=document.createElementNS(c,"text");o.classList.add("label","sequence"),o.setAttribute("x","0"),o.setAttribute("y","3"),o.appendChild(document.createTextNode(this.sequence[e-1])),i.appendChild(o),this.scaleLabels.push(o),this.ticks.appendChild(i)}}function a(t,n,e){var r=document.createElementNS(c,"g");r.setAttribute("transform","translate("+e+" 0)");var i=document.createElementNS(c,"text");i.classList.add("label","scale-label"),i.setAttribute("x","0"),i.setAttribute("y",b.STICKHEIGHT+4),i.appendChild(document.createTextNode(n)),r.appendChild(i),t.scaleLabels.push(i),t.ticks.appendChild(r)}function s(t,n){var e=document.createElementNS(c,"line");e.classList.add("tick"),e.setAttribute("x1",n),e.setAttribute("y1","5"),e.setAttribute("x2",n),e.setAttribute("y2","10"),t.ticks.appendChild(e)}a(this,this.size,n),this.stickZoom>=8&&s(this,n)},b.prototype.setForm=function(t,n){!0!==this.busy&&(1===t?this.toStick():this.toCircle(n))},b.prototype.toCircle=function(t){this.busy=!0;var n=this.getSymbolRadius();i.select(this.background).transition().attr("x",-n).attr("y",-n).attr("width",2*n).attr("height",2*n).attr("rx",n).attr("ry",n).duration(b.transitionTime),i.select(this.outline).transition().attr("x",-n).attr("y",-n).attr("width",2*n).attr("height",2*n).attr("rx",n).attr("ry",n).duration(b.transitionTime),i.select(this.highlight).transition().attr("width",2*n+5).attr("height",2*n+5).attr("x",-n-2.5).attr("y",-n-2.5).attr("rx",n+2.5).attr("ry",n+2.5).duration(b.transitionTime);var e=i.interpolate(this.stickZoom,0),r=i.transform(this.labelSVG.getAttribute("transform")).translate[0],o=i.interpolate(r,-(n+5)),a=null,s=null;null!=t&&(a=i.interpolate(this.ix,t.x),s=i.interpolate(this.iy,t.y));var u=this;i.select(this.ticks).transition().attr("opacity",0).duration(b.transitionTime/4).each("end",(function(){i.select(this).selectAll("*").remove()}));var c,l=v(this.annotationSets);try{for(l.s();!(c=l.n()).done;){var h=g(c.value,2),f=h[0],p=h[1];if(!0===this.app.annotationSetsShown.get(f)){var y,d=v(p);try{for(d.s();!(y=d.n()).done;){var x=y.value;if(x.fuzzyStart){var m=x.fuzzyStart;i.select(m).transition().attr("d",this.getAnnotationPieSlicePath(x.seqDatum.uncertainBegin,x.seqDatum.begin,x,!1)).duration(b.transitionTime)}if(x.certain){var w=x.certain;i.select(w).transition().attr("d",this.getAnnotationPieSlicePath(x.seqDatum.begin,x.seqDatum.end,x,!1)).duration(b.transitionTime)}if(x.fuzzyEnd){var S=x.fuzzyEnd;i.select(S).transition().attr("d",this.getAnnotationPieSlicePath(x.seqDatum.end,x.seqDatum.uncertainEnd,x,!1)).duration(b.transitionTime)}}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){l.e(t)}finally{l.f()}var _=this.stickZoom,M=this.rotation,k=i.ease("cubic-in-out");i.timer((function(t){return function t(n){var r=i.transform(u.labelSVG.getAttribute("transform")),c=u.app.svgElement.createSVGMatrix().rotate(r.rotate).translate(o(k(n)),-5);u.labelSVG.transform.baseVal.initialize(u.app.svgElement.createSVGTransformFromMatrix(c)),null!==a&&u.setPosition(a(k(n)),s(k(n)));if(u.stickZoom=e(k(n)),u.setAllLinkCoordinates(),1===n){u.expanded=!1,u.checkLinks();var l,h=v(u.annotationSets);try{for(h.s();!(l=h.n()).done;){var f=g(l.value,2),p=f[0],y=f[1];if(!0===u.app.annotationSetsShown.get(p)){var d,x=v(y);try{for(x.s();!(d=x.n()).done;){var m=d.value;if(m.fuzzyStart){var b=m.fuzzyStart;i.select(b).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.uncertainBegin,m.seqDatum.begin,m))}if(m.certain){var w=m.certain;i.select(w).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.begin,m.seqDatum.end,m))}if(m.fuzzyEnd){var S=m.fuzzyEnd;i.select(S).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.end,m.seqDatum.uncertainEnd,m))}}}catch(t){x.e(t)}finally{x.f()}}}}catch(t){h.e(t)}finally{h.f()}return u.stickZoom=_,u.rotation=M,u.busy=!1,!0}return n>1&&t(1)}(t/b.transitionTime)}))},b.prototype.toCircleNoTransition=function(t){var n=this.getSymbolRadius();i.select(this.background).attr("x",-n).attr("y",-n).attr("width",2*n).attr("height",2*n).attr("rx",n).attr("ry",n),i.select(this.outline).attr("x",-n).attr("y",-n).attr("width",2*n).attr("height",2*n).attr("rx",n).attr("ry",n),i.select(this.highlight).attr("width",2*n+5).attr("height",2*n+5).attr("x",-n-2.5).attr("y",-n-2.5).attr("rx",n+2.5).attr("ry",n+2.5);var e=i.interpolate(this.stickZoom,0),r=i.transform(this.labelSVG.getAttribute("transform")).translate[0],o=i.interpolate(r,-(n+5)),a=null,s=null;null!=t&&(a=i.interpolate(this.ix,t.x),s=i.interpolate(this.iy,t.y));var u=this;i.select(this.ticks).transition().attr("opacity",0).duration(b.transitionTime/4).each("end",(function(){i.select(this).selectAll("*").remove()}));var c,l=v(this.annotationSets);try{for(l.s();!(c=l.n()).done;){var h=g(c.value,2),f=h[0],p=h[1];if(!0===this.app.annotationSetsShown.get(f)){var y,d=v(p);try{for(d.s();!(y=d.n()).done;){var x=y.value;if(x.fuzzyStart){var m=x.fuzzyStart;i.select(m).attr("d",this.getAnnotationPieSlicePath(x.seqDatum.uncertainBegin,x.seqDatum.begin,x,!1))}if(x.certain){var w=x.certain;i.select(w).attr("d",this.getAnnotationPieSlicePath(x.seqDatum.begin,x.seqDatum.end,x,!1))}if(x.fuzzyEnd){var S=x.fuzzyEnd;i.select(S).attr("d",this.getAnnotationPieSlicePath(x.seqDatum.end,x.seqDatum.uncertainEnd,x,!1))}}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){l.e(t)}finally{l.f()}var _=this.stickZoom,M=this.rotation,k=i.ease("cubic-in-out");!function t(n){var r=i.transform(u.labelSVG.getAttribute("transform")),c=u.app.svgElement.createSVGMatrix().rotate(r.rotate).translate(o(k(n)),-5);u.labelSVG.transform.baseVal.initialize(u.app.svgElement.createSVGTransformFromMatrix(c)),null!==a&&u.setPosition(a(k(n)),s(k(n)));if(u.stickZoom=e(k(n)),u.setAllLinkCoordinates(),1===n){u.expanded=!1,u.checkLinks();var l,h=v(u.annotationSets);try{for(h.s();!(l=h.n()).done;){var f=g(l.value,2),p=f[0],y=f[1];if(!0===u.app.annotationSetsShown.get(p)){var d,x=v(y);try{for(x.s();!(d=x.n()).done;){var m=d.value;if(m.fuzzyStart){var b=m.fuzzyStart;i.select(b).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.uncertainBegin,m.seqDatum.begin,m))}if(m.certain){var w=m.certain;i.select(w).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.begin,m.seqDatum.end,m))}if(m.fuzzyEnd){var S=m.fuzzyEnd;i.select(S).attr("d",u.getAnnotationPieSlicePath(m.seqDatum.end,m.seqDatum.uncertainEnd,m))}}}catch(t){x.e(t)}finally{x.f()}}}}catch(t){h.e(t)}finally{h.f()}return u.stickZoom=_,u.rotation=M,u.busy=!1,!0}return n>1&&t(1)}(1)},b.prototype.toStick=function(){this.busy=!0,this.expanded=!0;var t=this.size*this.stickZoom,n=this.getSymbolRadius(),e=i.interpolate(2*n,t),r=i.interpolate(0,this.stickZoom),o=i.interpolate(-(n+5),-(this.size/2*this.stickZoom+(this.nTerminusFeature?25:10))),a=this.stickZoom;this.stickZoom=0,this.checkLinks(),this.stickZoom=a,i.select(this.background).transition().attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0).duration(b.transitionTime),i.select(this.outline).transition().attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0).duration(b.transitionTime),i.select(this.highlight).transition().attr("width",t+5).attr("height",b.STICKHEIGHT+5).attr("x",this.getResXWithStickZoom(.5)-2.5).attr("y",-b.STICKHEIGHT/2-2.5).attr("rx",0).attr("ry",0).duration(b.transitionTime);var s,u=v(this.annotationSets);try{for(u.s();!(s=u.n()).done;){var c=g(s.value,2),l=c[0],h=c[1];if(!0===this.app.annotationSetsShown.get(l)){var f,p=v(h);try{for(p.s();!(f=p.n()).done;){var y=f.value;if(y.fuzzyStart){var d=y.fuzzyStart;d.setAttribute("d",this.getAnnotationPieSlicePath(y.seqDatum.uncertainBegin,y.seqDatum.begin,y,!1)),i.select(d).transition().attr("d",this.getAnnotationRectPath(y.seqDatum.uncertainBegin,y.seqDatum.begin,y)).duration(b.transitionTime)}if(y.certain){var x=y.certain,m=y.seqDatum.begin,w=y.seqDatum.end;y.seqDatum.uncertainBegin&&(m+=1),y.seqDatum.uncertainEnd&&(w-=1),x.setAttribute("d",this.getAnnotationPieSlicePath(m,w,y,!1)),i.select(x).transition().attr("d",this.getAnnotationRectPath(m,w,y)).duration(b.transitionTime)}if(y.fuzzyEnd){var S=y.fuzzyEnd;S.setAttribute("d",this.getAnnotationPieSlicePath(y.seqDatum.end,y.seqDatum.uncertainEnd,y,!1)),i.select(S).transition().attr("d",this.getAnnotationRectPath(y.seqDatum.end,y.seqDatum.uncertainEnd,y)).duration(b.transitionTime)}}}catch(t){p.e(t)}finally{p.f()}}}}catch(t){u.e(t)}finally{u.f()}var _=this,M=i.ease("cubic-in-out");i.timer((function(t){return function t(n){var a=i.transform(_.labelSVG.getAttribute("transform")),s=_.app.svgElement.createSVGMatrix().rotate(a.rotate).translate(o(M(n)),-5);_.labelSVG.transform.baseVal.initialize(_.app.svgElement.createSVGTransformFromMatrix(s));var u=e(M(n));return i.select(_.highlight).attr("width",u).attr("x",-u/2+.5*_.stickZoom),i.select(_.outline).attr("width",u).attr("x",-u/2+.5*_.stickZoom),i.select(_.background).attr("width",u).attr("x",-u/2+.5*_.stickZoom),_.stickZoom=r(M(n)),_.setAllLinkCoordinates(),1===n?(_.updateAnnotationRectanglesNoTransition(),_.busy=!1,!0):n>1&&t(1)}(t/b.transitionTime)})),i.select(this.ticks).attr("opacity",0),this.setScaleGroup(),i.select(this.ticks).transition().attr("opacity",1).delay(.8*b.transitionTime).duration(b.transitionTime/2)},b.prototype.toStickNoTransition=function(){this.busy=!0,this.expanded=!0;var t=this.size*this.stickZoom,n=this.getSymbolRadius(),e=i.interpolate(2*n,t),r=i.interpolate(-(n+5),-(this.size/2*this.stickZoom+(this.nTerminusFeature?25:10)));this.checkLinks(),i.select(this.background).attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0),i.select(this.outline).attr("height",b.STICKHEIGHT).attr("y",-b.STICKHEIGHT/2).attr("rx",0).attr("ry",0),i.select(this.highlight).attr("width",t+5).attr("height",b.STICKHEIGHT+5).attr("x",this.getResXWithStickZoom(.5)-2.5).attr("y",-b.STICKHEIGHT/2-2.5).attr("rx",0).attr("ry",0);this.updateAnnotationRectanglesNoTransition();var o=i.transform(this.labelSVG.getAttribute("transform")),a=this.app.svgElement.createSVGMatrix().rotate(o.rotate).translate(r(1),-5);this.labelSVG.transform.baseVal.initialize(this.app.svgElement.createSVGTransformFromMatrix(a));var s=e(1);i.select(this.highlight).attr("width",s).attr("x",-s/2+.5*this.stickZoom),i.select(this.outline).attr("width",s).attr("x",-s/2+.5*this.stickZoom),i.select(this.background).attr("width",s).attr("x",-s/2+.5*this.stickZoom),this.setAllLinkCoordinates(),this.setScaleGroup(),i.select(this.ticks).attr("opacity",1),this.busy=!1},b.prototype.updateAnnotationRectanglesNoTransition=function(){var t,n=v(this.annotationSets);try{for(n.s();!(t=n.n()).done;){var e=g(t.value,2),r=e[0],o=e[1];if(!0===this.app.annotationSetsShown.get(r)){var a,s=v(o);try{for(s.s();!(a=s.n()).done;){var u=a.value;if(u.fuzzyStart){var c=u.fuzzyStart;i.select(c).attr("d",this.getAnnotationRectPath(u.seqDatum.uncertainBegin,u.seqDatum.begin,u))}if(u.certain){var l=u.seqDatum.begin,h=u.seqDatum.end;u.seqDatum.uncertainBegin&&(l+=1),u.seqDatum.uncertainEnd&&(h-=1),u.certain.setAttribute("d",this.getAnnotationRectPath(l,h,u))}if(u.fuzzyEnd){var f=u.fuzzyEnd;i.select(f).attr("d",this.getAnnotationRectPath(u.seqDatum.end,u.seqDatum.uncertainEnd,u))}}}catch(t){s.e(t)}finally{s.f()}}}}catch(t){n.e(t)}finally{n.f()}},b.prototype.getResXWithStickZoom=function(t){return"n-n"===t?-this.size/2*this.stickZoom-20:"c-c"===t?this.size/2*this.stickZoom+20:(t-this.size/2)*this.stickZoom},b.prototype.getResidueCoordinates=function(t,n){void 0===t&&console.error("ERROR: residue number is undefined");var e,r=this.getResXWithStickZoom(1*t);if(0!==r){var i=Math.abs(r),o=Math.acos(r/i),a=this.rotation/360*Math.PI*2;r=i*Math.cos(a+o),e=i*Math.sin(a+o),void 0!==n&&(r+=n*Math.cos(a+Math.PI/2),e+=n*Math.sin(a+Math.PI/2))}else e=n;return[r+=this.ix,e+=this.iy]},b.prototype.clearPositionalFeatures=function(){this.annotations=[],this.annotationTypes=[],this.annotationsSvgGroup.textContent=""},b.prototype.updatePositionalFeatures=function(){var t=this,n=function(n){var e=n.target.correspondingUseElement?n.target.correspondingUseElement:n.target;t.app.preventDefaultsAndStopPropagation(n),t.app.setTooltip(e.name,e.getAttribute("fill")),t.showHighlight(!0)},e=-1,r=[];function i(t,n){var e,r=v(t);try{for(r.s();!(e=r.n()).done;){if(e.value.seqDatum.overlaps(n.seqDatum))return!0}}catch(t){r.e(t)}finally{r.f()}return!1}var o,a=v(this.annotationSets);try{for(a.s();!(o=a.n()).done;){var s=g(o.value,2),u=s[0],l=s[1];if(!0===this.app.annotationSetsShown.get(u)){l&&l.length>0&&(r[++e]=[]);var h,f=new Set,p=v(Array.from(l.values()).sort((function(t,n){var e=t.description,r=n.description;return er?1:0})));try{for(p.s();!(h=p.n()).done;){var y=h.value;if(!f.has(y.toString()))if(f.add(y.toString()),"n-n"===y.seqDatum.sequenceDatumString||"c-c"===y.seqDatum.sequenceDatumString)y.rung=-1;else{var d=r[e];i(d,y)&&(r[++e]=[],d=r[e]),y.rung=e,d.push(y)}}}catch(t){p.e(t)}finally{p.f()}}}}catch(t){a.e(t)}finally{a.f()}this.rungCount=e+1;var x,m=v(this.annotationSets);try{for(m.s();!(x=m.n()).done;){var b=g(x.value,2),w=b[0],S=b[1];if(!0===this.app.annotationSetsShown.get(w)){var _,M=new Set,k=v(S.values());try{for(k.s();!(_=k.n()).done;){var E=_.value;if(!M.has(E.toString())){M.add(E.toString());var A=E.toString();if(E.seqDatum.uncertainBegin&&(E.fuzzyStart=document.createElementNS(c,"path"),this.expanded?E.fuzzyStart.setAttribute("d",this.getAnnotationRectPath(E.seqDatum.uncertainBegin,E.seqDatum.begin,E)):E.fuzzyStart.setAttribute("d",this.getAnnotationPieSlicePath(E.seqDatum.uncertainBegin,E.seqDatum.begin,E)),E.fuzzyStart.setAttribute("stroke-width","1"),E.fuzzyStart.setAttribute("fill-opacity","0.6"),E.fuzzyStart.name=A,E.fuzzyStart.onmouseover=n,this.annotationsSvgGroup.appendChild(E.fuzzyStart)),E.seqDatum.begin&&E.seqDatum.end){E.certain=document.createElementNS(c,"path");var L=E.seqDatum.begin,N=E.seqDatum.end;E.seqDatum.uncertainBegin&&(L+=1),E.seqDatum.uncertainEnd&&(N-=1),this.expanded?E.certain.setAttribute("d",this.getAnnotationRectPath(L,N,E)):E.certain.setAttribute("d",this.getAnnotationPieSlicePath(L,N,E)),E.certain.setAttribute("stroke-width","1"),E.certain.name=A,E.certain.onmouseover=n,this.annotationsSvgGroup.appendChild(E.certain)}E.seqDatum.uncertainEnd&&(E.fuzzyEnd=document.createElementNS(c,"path"),this.expanded?E.fuzzyEnd.setAttribute("d",this.getAnnotationRectPath(E.seqDatum.end,E.seqDatum.uncertainEnd,E)):E.fuzzyEnd.setAttribute("d",this.getAnnotationPieSlicePath(E.seqDatum.end,E.seqDatum.uncertainEnd,E)),E.fuzzyEnd.setAttribute("stroke-width","1"),E.fuzzyEnd.setAttribute("fill-opacity","0.6"),E.fuzzyEnd.name=A,E.fuzzyEnd.onmouseover=n,this.annotationsSvgGroup.appendChild(E.fuzzyEnd))}}}catch(t){k.e(t)}finally{k.f()}}}}catch(t){m.e(t)}finally{m.f()}},b.stepsInArc=5,b.prototype.getAnnotationPieSlicePath=function(t,n,e){var r,i,o,a,s,u=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],c=this.getSymbolRadius(),h=e.rung;-1===h?(i=0,r=c):r=(i=h*(o=c/this.rungCount))+o,"n-n"===t?(a=-20,s=0):"c-c"===n?(a=0,s=20):(a=(t-1)/this.size*360,s=(n-1)/this.size*360);var f=0;(s-a>180||s===a)&&(f=1);var p=l([0,i],[0,0],a-180),y=l([0,r],[0,0],a-180),d=l([0,r],[0,0],s-180),g=l([0,i],[0,0],s-180),v="M"+p[0]+","+p[1]+" L"+y[0]+","+y[1];if(u)v+=" A"+r+","+r+" 0 "+f+" 1 "+d[0]+","+d[1];else for(var x=0;x<=b.stepsInArc;x++){var m=a+(s-a)/b.stepsInArc*x,w=l([0,r],[0,0],m-180);v+=" L"+w[0]+","+w[1]}if(u)v+=" L"+g[0]+","+g[1],v+=" A"+i+","+i+" 0 "+f+" 0 "+p[0]+","+p[1];else for(var S=b.stepsInArc;S>=0;S--){var _=a+(s-a)/b.stepsInArc*S,M=l([0,i],[0,0],_-180);v+=" L"+M[0]+","+M[1]}return v+=" Z"},b.prototype.getAnnotationRectPath=function(t,n,e){var r,i,o,a,s,u=e.rung;-1===u?(i=b.STICKHEIGHT/2,r=-b.STICKHEIGHT/2):(o=b.STICKHEIGHT/this.rungCount,i=(r=-b.STICKHEIGHT/2+u*o)+o),"n-n"===t?(a=this.getResXWithStickZoom(.5)-20,s=20):"c-c"===n?(a=this.getResXWithStickZoom(this.size+.5),s=20):(a=this.getResXWithStickZoom(t-.5),s=(n-t+1)*this.stickZoom);for(var c="M"+a+","+i+" L"+a+","+r,l=0;l<=b.stepsInArc;l++){c+=" L "+(a+s*(l/b.stepsInArc))+","+r}for(var h=b.stepsInArc;h>=0;h--){c+=" L "+(a+s*(h/b.stepsInArc))+","+i}return c+=" Z"},w.prototype=new b,S.prototype=new p,_.prototype=new p,_.prototype.getSymbolRadius=function(){return 21},M.prototype=new p,k.prototype=new p;var E=e(1),A=e(2);function L(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=function(t,n){if(!t)return;if("string"==typeof t)return N(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return N(t,n)}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function N(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function z(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function G(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e1)return t})).forEach((function(n){if(F(e,"id",n.interactorRef))for(var i=function(e){var i=JSON.parse(JSON.stringify(n));i.id=i.id+"_"+e,i.cloneParentID=n.id,i.cloneIteration=e,n.cloned=!0,i.features&&i.features.forEach((function(t){t.clonedfrom=t.id,t.id=t.id+"_"+e,t.sequenceData.forEach((function(t){t.participantRef=i.id}))})),t.participants.push(i),r.push(i)},o=0;o-1){var i=JSON.parse(JSON.stringify(e));i.id=e.id+"_"+n.id,i.linkedFeatures=[],i.linkedFeatures.push(n.id),F(t.participants,"id",i.parentParticipant).features.push(i)}}))}))})),n.forEach((function(t){t.participants.forEach((function(t){t.stoichiometry=null}))})),t}function F(t,n,e){for(var r=0;r=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function U(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e2&&void 0!==arguments[2])||arguments[2];(t="object"===X(t)?t:JSON.parse(t)).data=t.data.reverse(),n.features=new Map;var r=new Map;n.proteinCount=0,n.interactors=new Map;var i,o=H(t.data);try{for(o.s();!(i=o.n()).done;){var a=i.value;"interactor"===a.object&&(n.interactors.set(a.id,a),0===a.id.indexOf("uniprotkb_")&&n.proteinCount++)}}catch(t){o.e(t)}finally{o.f()}e?xt():wt();var s,c=H(t.data);try{for(c.s();!(s=c.n()).done;){var l=s.value;if("interaction"===l.object){var h,f=H(l.participants);try{for(f.s();!(h=f.n()).done;){var p=h.value,y=new Array(0);p.features&&(y=p.features);var g,v=H(y);try{for(v.s();!(g=v.n()).done;){var x=g.value,m=x.sequenceData;if(x.linkedFeatures)for(var b=x.linkedFeatures,E=b.length,A=0;Ar&&(r=u.stoichiometry-0)}}catch(t){s.e(t)}finally{s.f()}}}}catch(t){i.e(t)}finally{i.f()}r<30&&(t=B(t)),bt();var c,l=H(t.data);try{for(l.s();!(c=l.n()).done;){var h=c.value;if("interaction"===h.object){var f=h.id||St(h),p=n.allNaryLinks.get(f);void 0===p&&(p=new O(f,n),n.allNaryLinks.set(f,p),h.naryId=f);var y,d=H(h.participants);try{for(d.s();!(y=d.n()).done;){var g=y.value,v=g.interactorRef,x=v+"("+g.id+")",m=n.participants.get(x);if(void 0===m)m=mt(n.interactors.get(v),x,v),n.participants.set(x,m);if(m.naryLinks.set(f,p),-1===p.participants.indexOf(m)&&p.participants.push(m),g.stoichiometry)n.participants.get(x).addStoichiometryLabel(g.stoichiometry)}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){l.e(t)}finally{l.f()}}function mt(e,i,o){var a;if(void 0===e||"MI:1302"===e.type.id){var s,u=!1,c=H(t.data);try{for(c.s();!(s=c.n()).done;){var l=s.value;if("interaction"===l.object&&l.id===o){u=!0;break}}}catch(t){c.e(t)}finally{c.f()}u?(a=new P(i,n,o),r.set(i,a)):a=new C(i,n,o,e)}else"MI:1304"===e.type.id||"MI:1305"===e.type.id||"MI:1307"===e.type.id||"MI:1306"===e.type.id?a=new T(i,n,e,e.label):"MI:1100"===e.type.id||"MI:0904"===e.type.id||"MI:0328"===e.type.id?a=new S(i,n,e,e.label):"MI:0326"===e.type.id||"MI:0327"===e.type.id?a=new w(i,n,e,e.label,e.sequence):"MI:0250"===e.type.id?a=new _(i,n,e,e.label):"MI:0320"===e.type.id||"MI:0321"===e.type.id||"MI:0322"===e.type.id||"MI:0323"===e.type.id||"MI:2190"===e.type.id||"MI:0324"===e.type.id||"MI:0679"===e.type.id||"MI:0608"===e.type.id||"MI:0611"===e.type.id||"MI:0610"===e.type.id||"MI:0607"===e.type.id||"MI:0609"===e.type.id||"MI:0325"===e.type.id||"IA:2966"===e.type.id||"MI:0318"===e.type.id?a=new k(i,n,e,e.label):"MI:0319"===e.type.id||"MI:0681"===e.type.id||"MI:0680"===e.type.id?a=new M(i,n,e,e.label):alert("Unrecognised type:"+e.type.name);return a}function bt(){var e,r=H(t.data);try{for(r.s();!(e=r.n()).done;){var i=e.value;if("interaction"===i.object){var o,a=H(i.participants);try{for(a.s();!(o=a.n()).done;){var s=o.value,u=new Array(0);s.features&&(u=s.features);for(var c=u.length,l=0;l<"+u:u+"><"+s;var c=n.allSequenceLinks.get(a);if(void 0===c){var l,h=[],f=H(t);try{for(f.s();!(l=f.n()).done;){var p=l.value;h.push(new d(_t(p),p.pos))}}catch(t){f.e(t)}finally{f.f()}var y,g=[],v=H(r);try{for(v.s();!(y=v.n()).done;){var x=y.value;g.push(new d(_t(x),x.pos))}}catch(t){v.e(t)}finally{v.f()}c=new q(a,h,g,n,i),n.allSequenceLinks.set(a,c)}var m=St(i);return n.allNaryLinks.get(m).sequenceLinks.set(a,c),c}function kt(t,e){var r="-"+t.id+"-"+t.id,i=n.allUnaryLinks.get(r);void 0===i&&(i=new V(r,n,t),n.allUnaryLinks.set(r,i),t.appLink=i);var o=St(e);return n.allNaryLinks.get(o).unaryLinks.set(r,i),i}function Et(t,e,r){var i,o,a;t.idr)&&(r=c)}if(!isNaN(parseFloat(a.uncertainEnd))&&isFinite(a.uncertainEnd)){var l=1*a.uncertainEnd;(null===r||l>r)&&(r=l)}}return n.getResidueCoordinates((e+r)/2,0)}var r,i,o=this.fromSequenceData[0].participant,a=this.toSequenceData[0].participant;o.expanded&&(r=e(this.fromSequenceData,o)),a.expanded&&(i=e(this.toSequenceData,a)),o.expanded||(r=o.getPosition(i)),a.expanded||(i=a.getPosition(r));var s=r,u=i,c=r[0]-i[0],l=r[1]-i[1],h=Math.atan2(l,c)/(2*Math.PI)*360;h<0&&(h+=360);var f=h-o.rotation;f<0&&(f+=360);var p=10;f<180&&(p=-10);var y=o.rotation/360*Math.PI*2;f>180&&(y-=Math.PI),(f=h-a.rotation)<0&&(f+=360);var d=10;f>180&&(d=-10);var g=a.rotation/360*Math.PI*2;f<180&&(g-=Math.PI);var v=[r[0]+30*Math.sin(y)*this.app.z,r[1]-30*Math.cos(y)*this.app.z];o.expanded||(v=r);var x=[i[0]+30*Math.sin(g)*this.app.z,i[1]-30*Math.cos(g)*this.app.z];a.expanded||(x=i);for(var m,b=[(v[0]+x[0])/2,(v[1]+x[1])/2],w=this.fromSequenceData.length,S=this.toSequenceData.length,_="M"+b[0]+","+b[1],M="M"+b[0]+","+b[1],k=0;k=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function $(t,n){if(t){if("string"==typeof t)return J(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?J(t,n):void 0}}function J(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=0;)et.pruneInvisibleSubtrees(i[a],o[a])}}},parentChain:function(t,n){for(var e=t.ownerDocument||document,r=[];t.parentNode!==e&&null!==t.parentNode;)t=t.parentNode,r.push({id:t.id,class:t.getAttribute("class")||""});return r.forEach((function(t){var e={id:!1,class:!1},r=t.class.split(" ").filter((function(t){return t.length>0}));n.forEach((function(n){for(var i=0;i=0){e.class=!0;break}t.id&&n.indexOf("#"+t.id)>=0&&(e.id=!0)})),Object.keys(e).forEach((function(n){e[n]||(t[n]=void 0)}))})),r},usedStyles:function(t,n,e){for(var r,i=[],o=(t.ownerDocument||document).styleSheets,a=0;a0),n&&!e||(u|=t.matches(r.selectorText))}catch(t){console.warn("CSS selector error: "+r.selectorText+". Often angular issue.",t)}u&&i.push(r.cssText)}}return i},makeXMLStr:function(t,n){var e=t.serializeToString(n);return e=e.split('xmlns="http://www.w3.org/1999/xhtml"').join("")}};function rt(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,n)||ot(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function it(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=ot(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function ot(t,n){if(t){if("string"==typeof t)return at(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?at(t,n):void 0}}function at(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}function ct(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);eComplexViewer "+r.a+"by Rappsilber Laboratory",this.acknowledgement.appendChild(h),h.setAttribute("font-size","8pt"),this.svgElement.appendChild(this.acknowledgement),this.naryLinks=document.createElementNS(c,"g"),this.naryLinks.setAttribute("id","naryLinks"),this.container.appendChild(this.naryLinks),this.p_pLinksWide=document.createElementNS(c,"g"),this.p_pLinksWide.setAttribute("id","p_pLinksWide"),this.container.appendChild(this.p_pLinksWide),this.highlights=document.createElementNS(c,"g"),this.highlights.setAttribute("class","highlights"),this.container.appendChild(this.highlights),this.res_resLinks=document.createElementNS(c,"g"),this.res_resLinks.setAttribute("id","res_resLinks"),this.container.appendChild(this.res_resLinks),this.p_pLinks=document.createElementNS(c,"g"),this.p_pLinks.setAttribute("id","p_pLinks"),this.container.appendChild(this.p_pLinks),this.proteinUpper=document.createElementNS(c,"g"),this.proteinUpper.setAttribute("id","proteinUpper"),this.container.appendChild(this.proteinUpper),this.selfRes_resLinks=document.createElementNS(c,"g"),this.selfRes_resLinks.setAttribute("id","res_resLinks"),this.container.appendChild(this.selfRes_resLinks),this.svgElement.appendChild(this.container),this.tooltip=document.createElementNS(c,"text"),this.tooltip.setAttribute("x","0"),this.tooltip.setAttribute("y","0");var f=document.createTextNode("tooltip");this.tooltip.classList.add("label","tooltip"),this.tooltip.appendChild(f),this.tooltip_bg=document.createElementNS(c,"rect"),this.tooltip_bg.classList.add("tooltip-background"),this.tooltip_subBg=document.createElementNS(c,"rect"),this.tooltip_subBg.classList.add("tooltip-sub-background"),this.svgElement.appendChild(this.tooltip_subBg),this.svgElement.appendChild(this.tooltip_bg),this.svgElement.appendChild(this.tooltip),this.annotationSetsShown=new Map,this.annotationSetsShown.set("Interactor",!1),this.annotationSetsShown.set("UniprotKB",!1),this.annotationSetsShown.set("Superfamily",!1),this.annotationSetsShown.set("MI Features",!0),this.clear()}lt.prototype.createHatchedFill=function(t,n){if(!this.checkedHatchNames.has(t)){var e=this.defs.append("pattern").attr("id",t).attr("patternUnits","userSpaceOnUse").attr("x",0).attr("y",0).attr("width",12).attr("height",12).attr("patternTransform","rotate(45)");e.append("rect").attr("x",0).attr("y",2).attr("width",12).attr("height",4).attr("fill",n),e.append("rect").attr("x",0).attr("y",8).attr("width",12).attr("height",4).attr("fill",n),this.checkedHatchNames.add(t)}},lt.prototype.clear=function(){this.d3cola.stop();var t,n=[],e=ut(a);try{for(e.s();!(t=e.n()).done;){var r=t.value,o=i.hsl(r);o.l=.9,n.push(o+"")}}catch(t){e.e(t)}finally{e.f()}O.naryColors=i.scale.ordinal().range(n),this.defs.textContent="",this.checkedHatchNames=new Set,this.naryLinks.textContent="",this.p_pLinksWide.textContent="",this.highlights.textContent="",this.p_pLinks.textContent="",this.res_resLinks.textContent="",this.proteinUpper.textContent="",this.selfRes_resLinks.textContent="",this.dragElement=null,this.dragStart={},this.participants=new Map,this.allNaryLinks=new Map,this.allBinaryLinks=new Map,this.allUnaryLinks=new Map,this.allSequenceLinks=new Map,this.complexes=[],this.proteinCount=0,this.z=1,this.hideTooltip(),this.state=this.STATES.MOUSE_UP},lt.prototype.collapseProtein=function(){i.select(".custom-menu-margin").style("display","none"),this.contextMenuProt.setForm(0,this.contextMenuPoint),this.contextMenuProt=null},lt.prototype.init=function(){this.d3cola.stop();var t,n=0,e=ut(this.participants.values());try{for(e.s();!(t=e.n()).done;){var r=t.value;r.size>n&&(n=r.size)}}catch(t){e.e(t)}finally{e.f()}var o,a,s,u=.8*this.svgElement.parentNode.clientWidth/n;this.defaultBarScale=(o=this.barScales,a=u,0===(s=(0,i.bisector((function(t){return t})).left)(o,a))||1===s?o[1]:s===o.length?o[o.length-1]:o[s-1]);var c,l=ut(this.participants.values());try{for(l.s();!(c=l.n()).done;){var h=c.value;"complex"!=h.type&&(h.setPosition(-500,-500),this.proteinUpper.appendChild(h.upperGroup))}}catch(t){l.e(t)}finally{l.f()}var f,p=ut(this.participants.values());try{for(p.s();!(f=p.n()).done;){var y=f.value;"protein"===y.type&&(y.stickZoom=this.defaultBarScale,this.participants.size<4&&y.toStickNoTransition())}}catch(t){p.e(t)}finally{p.f()}this.updateAnnotations();var d=this;!function(t,n){var e,r=Array.from(t.participants.values()).filter((function(t){return"protein"===t.type})),i=0,o=r.length,a=W(r);try{for(a.s();!(e=a.n()).done;){var s=e.value,u=new RegExp("[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}![-]","i").exec(s.json.identifier.id);u&&u[0]==s.json.identifier.id.trim()&&(tt(s,(function(){++i===o&&n()})),Q(s,(function(){++i===o&&n()})))}}catch(t){a.e(t)}finally{a.f()}}(this,(function(){d.updateAnnotations()})),this.checkLinks(),this.autoLayout()},lt.prototype.zoomToExtent=function(){var t=this.svgElement.parentNode.clientWidth,n=this.svgElement.parentNode.clientHeight,e=this.container.getBBox(),r=(t/e.width).toFixed(4)-0,i=(n/e.height).toFixed(4)-0;if((ithis.z&&(o=this.z);var a=-e.x+20/o,s=-e.y+20/o;this.container.setAttribute("transform","scale("+o+") translate("+a+" "+s+") "),this.z=this.container.getCTM().inverse().a}else{var u=t-e.width,c=n-e.height,l=u/2-e.x,h=c/2-e.y;this.container.setAttribute("transform","scale(1) translate("+l+" "+h+")"),this.z=1}this.acknowledgement.setAttribute("transform","translate("+(t-150)+", "+(n-30)+")")},lt.prototype.mouseDown=function(t){return t.preventDefault(),this.d3cola.stop(),this.dragStart=t,!1},lt.prototype.touchStart=function(t){return t.preventDefault(),this.d3cola.stop(),this.dragStart=t,!1},lt.prototype.mouseMove=function(t){this.move(t)},lt.prototype.touchMove=function(t){this.move(t)},lt.prototype.move=function(t){var n=this.getEventPoint(t),e=this.mouseToSVG(n.x,n.y);if(null!=this.dragElement){this.hideTooltip();var r=this.getEventPoint(this.dragStart),i=this.mouseToSVG(r.x,r.y),o=i.x-e.x,a=i.y-e.y;if(this.state===this.STATES.DRAGGING){if(this.dragElement.ix)this.dragElement.changePosition(o,a),this.dragElement.setAllLinkCoordinates();else{var s,u=ut(this.dragElement.participants);try{for(u.s();!(s=u.n()).done;){s.value.changePosition(o,a)}}catch(t){u.e(t)}finally{u.f()}this.setAllLinkCoordinates()}this.dragStart=t}else Math.sqrt(o*o+a*a)>5*this.z&&(this.state=this.STATES.DRAGGING)}else this.showTooltip(n);return!1},lt.prototype.mouseUp=function(t){var n=(new Date).getTime();this.preventDefaultsAndStopPropagation(t);var e=this.getEventPoint(t);isNaN(e.x)&&(e=this.getEventPoint(this.dragStart));var r=this.mouseToSVG(e.x,e.y);if(this.dragElement&&"protein"===this.dragElement.type&&this.state!==this.STATES.DRAGGING&&this.state!==this.STATES.ROTATING)if(this.dragElement.expanded){this.contextMenuProt=this.dragElement,this.contextMenuPoint=r;var o,a,s=i.select(".custom-menu-margin");t.pageX?(o=t.pageX,a=t.pageY):(o=this.dragStart.touches[0].pageX,a=this.dragStart.touches[0].pageY),s.style("top",a-20+"px").style("left",o-20+"px").style("display","block"),i.select(".scaleButton_"+100*this.dragElement.stickZoom).property("checked",!0)}else this.dragElement.setForm(1);return this.dragElement=null,this.dragStart={},this.state=this.STATES.MOUSE_UP,this.lastMouseUp=n,!1},lt.prototype.getEventPoint=function(t){var n,e,r=this.svgElement.createSVGPoint(),i=this.svgElement.parentNode,o=0,a=0;do{o+=i.offsetTop||0,a+=i.offsetLeft||0,i=i.offsetParent}while(i);return t.touches&&t.touches.length>0?(n=t.touches[0].pageX,e=t.touches[0].pageY):t.pageX&&(n=t.pageX,e=t.pageY),r.x=n-a,r.y=e-o,r},lt.prototype.preventDefaultsAndStopPropagation=function(t){t.stopPropagation&&t.stopPropagation(),null!=t.cancelBubble&&(t.cancelBubble=!0),t.preventDefault&&t.preventDefault()},lt.prototype.autoLayout=function(){this.d3cola.stop();var t,n=this,e=ut(n.participants.values());try{for(e.s();!(t=e.n()).done;){var r=t.value;delete r.x,delete r.y,delete r.px,delete r.py,delete r.bounds,r.fixed=0}}catch(t){e.e(t)}finally{e.f()}var o,a=[],s=ut(n.participants.values());try{for(s.s();!(o=s.n()).done;){var u=o.value;u.binaryLinks.size>2&&"complex"!==u.type&&a.push(u)}}catch(t){s.e(t)}finally{s.f()}var c=Array.from(n.participants.values()).filter((function(t){return"complex"!==t.type}));function l(t,e){var r={};r.nodes=t,r.links=[];var o,a={},s=0,u=ut(t);try{for(u.s();!(o=u.n()).done;){a[o.value.id]=s,s++}}catch(t){u.e(t)}finally{u.f()}var h,f=ut(n.allBinaryLinks.values());try{for(f.s();!(h=f.n()).done;){var p=h.value,y=p.participants[0],d=p.participants[1],g=y,v=d;if(g!==v&&-1!==t.indexOf(g)&&-1!==t.indexOf(v)){var x={};x.source=a[y.id],x.target=a[d.id],x.id=p.id,r.links.push(x)}}}catch(t){f.e(t)}finally{f.f()}var m=[];if(!e&&n.complexes){var b,w=ut(n.complexes);try{for(w.s();!(b=w.n()).done;){var S=b.value;S.leaves=[],S.groups=[];var _,M=ut(S.naryLink.participants);try{for(M.s();!(_=M.n()).done;){var k=_.value;"complex"!==k.type&&S.leaves.push(r.nodes.indexOf(k))}}catch(t){M.e(t)}finally{M.f()}m.push(S)}}catch(t){w.e(t)}finally{w.f()}var E,A=ut(n.complexes);try{for(A.s();!(E=A.n()).done;){var L,N=E.value,P=ut(N.naryLink.participants);try{for(P.s();!(L=P.n()).done;){var C=L.value;"complex"===C.type&&N.groups.push(m.indexOf(C))}}catch(t){P.e(t)}finally{P.f()}}}catch(t){A.e(t)}finally{A.f()}}delete n.d3cola._lastStress,delete n.d3cola._alpha,delete n.d3cola._descent,delete n.d3cola._rootGroup;var T,I,z=t.length<30?30:20,D=n.svgElement.parentNode.clientWidth,O=n.svgElement.parentNode.clientHeight;n.d3cola.size([O-40,D-40]).nodes(r.nodes).groups(m).links(r.links).avoidOverlaps(!0),n.debug&&((T=i.select(n.container).selectAll(".group").data(m)).enter().append("rect").classed("group",!0).attr({rx:5,ry:5}).style("stroke","blue").style("fill","none"),(I=i.select(n.container).selectAll(".node").data(r.nodes)).enter().append("rect").classed("node",!0).attr({rx:5,ry:5}).style("stroke","red").style("fill","none"),T.exit().remove(),I.exit().remove());var q=Date.now();n.d3cola.symmetricDiffLinkLengths(z).on("tick",(function(){if(Date.now()-q>750){ //!preRun) { -var t,e=ut(n.d3cola.nodes());try{for(e.s();!(t=e.n()).done;){var r=t.value;r.setPosition(r.x,r.y)}}catch(t){e.e(t)}finally{e.f()}n.setAllLinkCoordinates(),n.zoomToExtent(),n.debug&&(T.attr({x:function(t){return t.bounds.x},y:function(t){return t.bounds.y},width:function(t){return t.bounds.width()},height:function(t){return t.bounds.height()}}),I.attr({x:function(t){return t.bounds.x},y:function(t){return t.bounds.y},width:function(t){return t.bounds.width()},height:function(t){return t.bounds.height()}}))}})).on("end",(function(){if(e)l(c,!1);else{var r,i=ut(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;o.setPosition(o.x,o.y)}}catch(t){i.e(t)}finally{i.f()}n.setAllLinkCoordinates(),n.zoomToExtent()}})),e?n.d3cola.start(23,23,0,0,!0):n.d3cola.start(0,23,23,0,!0)}a.length3&&n.participants.size<9?l(a,!0):l(c,n.complexes.length>0)},lt.prototype.getSVG=function(){var t=[i.select(this.el).selectAll("svg").node()],n=et.capture(t);return et.makeXMLStr(new XMLSerializer,n[0])},lt.prototype.mouseToSVG=function(t,n){var e=this.svgElement.createSVGPoint();return e.x=t,e.y=n,e.matrixTransform(this.container.getCTM().inverse())},lt.prototype.readMIJSON=function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Z(t,this,n),this.init()},lt.prototype.checkLinks=function(){var t,n=ut(this.allNaryLinks.values());try{for(n.s();!(t=n.n()).done;){t.value.check()}}catch(t){n.e(t)}finally{n.f()}var e,r=ut(this.allBinaryLinks.values());try{for(r.s();!(e=r.n()).done;){e.value.check()}}catch(t){r.e(t)}finally{r.f()}var i,o=ut(this.allUnaryLinks.values());try{for(o.s();!(i=o.n()).done;){i.value.check()}}catch(t){o.e(t)}finally{o.f()}var a,s=ut(this.allSequenceLinks.values());try{for(s.s();!(a=s.n()).done;){a.value.check()}}catch(t){s.e(t)}finally{s.f()}},lt.prototype.setAllLinkCoordinates=function(){var t,n=ut(this.allNaryLinks.values());try{for(n.s();!(t=n.n()).done;){t.value.setLinkCoordinates()}}catch(t){n.e(t)}finally{n.f()}var e,r=ut(this.allBinaryLinks.values());try{for(r.s();!(e=r.n()).done;){e.value.setLinkCoordinates()}}catch(t){r.e(t)}finally{r.f()}var i,o=ut(this.allUnaryLinks.values());try{for(o.s();!(i=o.n()).done;){i.value.setLinkCoordinates()}}catch(t){o.e(t)}finally{o.f()}var a,s=ut(this.allSequenceLinks.values());try{for(s.s();!(a=s.n()).done;){a.value.setLinkCoordinates()}}catch(t){s.e(t)}finally{s.f()}},lt.prototype.showTooltip=function(t){var n,e,r=this.tooltip.getComputedTextLength()+16,i=this.svgElement.parentNode.clientWidth,o=this.svgElement.parentNode.clientHeight;n=t.x+20+r3&&n.participants.size<9?l(a,!0):l(c,n.complexes.length>0)},lt.prototype.getSVG=function(){var t=[i.select(this.el).selectAll("svg").node()],n=et.capture(t);return et.makeXMLStr(new XMLSerializer,n[0])},lt.prototype.mouseToSVG=function(t,n){var e=this.svgElement.createSVGPoint();return e.x=t,e.y=n,e.matrixTransform(this.container.getCTM().inverse())},lt.prototype.readMIJSON=function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Z(t,this,n),this.init()},lt.prototype.checkLinks=function(){var t,n=ut(this.allNaryLinks.values());try{for(n.s();!(t=n.n()).done;){t.value.check()}}catch(t){n.e(t)}finally{n.f()}var e,r=ut(this.allBinaryLinks.values());try{for(r.s();!(e=r.n()).done;){e.value.check()}}catch(t){r.e(t)}finally{r.f()}var i,o=ut(this.allUnaryLinks.values());try{for(o.s();!(i=o.n()).done;){i.value.check()}}catch(t){o.e(t)}finally{o.f()}var a,s=ut(this.allSequenceLinks.values());try{for(s.s();!(a=s.n()).done;){a.value.check()}}catch(t){s.e(t)}finally{s.f()}},lt.prototype.setAllLinkCoordinates=function(){var t,n=ut(this.allNaryLinks.values());try{for(n.s();!(t=n.n()).done;){t.value.setLinkCoordinates()}}catch(t){n.e(t)}finally{n.f()}var e,r=ut(this.allBinaryLinks.values());try{for(r.s();!(e=r.n()).done;){e.value.setLinkCoordinates()}}catch(t){r.e(t)}finally{r.f()}var i,o=ut(this.allUnaryLinks.values());try{for(o.s();!(i=o.n()).done;){i.value.setLinkCoordinates()}}catch(t){o.e(t)}finally{o.f()}var a,s=ut(this.allSequenceLinks.values());try{for(s.s();!(a=s.n()).done;){a.value.setLinkCoordinates()}}catch(t){s.e(t)}finally{s.f()}},lt.prototype.showTooltip=function(t){var n,e,r=this.tooltip.getComputedTextLength()+16,i=this.svgElement.parentNode.clientWidth,o=this.svgElement.parentNode.clientHeight;n=t.x+20+r 180) ? this.rotation - 360 : this.rotation, 0); + const labelTransform = d3.transform(this.labelSVG.getAttribute("transform")); + const labelStartPoint = labelTransform.translate[0]; + const labelTranslateInterpol = d3.interpolate(labelStartPoint, -(r + 5)); + + let xInterpol = null, + yInterpol = null; + if (typeof svgP !== "undefined" && svgP !== null) { + xInterpol = d3.interpolate(this.ix, svgP.x); + yInterpol = d3.interpolate(this.iy, svgP.y); + } + + const self = this; + d3.select(this.ticks).transition().attr("opacity", 0).duration(Polymer.transitionTime / 4) + .each("end", + function () { + d3.select(this).selectAll("*").remove(); + } + ); + + for (let [annotationType, annotations] of this.annotationSets) { + if (this.app.annotationSetsShown.get(annotationType) === true) { + for (let anno of annotations) { + if (anno.fuzzyStart) { + const fuzzyStart = anno.fuzzyStart; + d3.select(fuzzyStart).attr("d", this.getAnnotationPieSlicePath(anno.seqDatum.uncertainBegin, anno.seqDatum.begin, anno, false)); + // .duration(Polymer.transitionTime); + } + + if (anno.certain) { + const certain = anno.certain; + d3.select(certain).attr("d", this.getAnnotationPieSlicePath(anno.seqDatum.begin, anno.seqDatum.end, anno, false)); + // .duration(Polymer.transitionTime); + } + + if (anno.fuzzyEnd) { + const fuzzyEnd = anno.fuzzyEnd; + d3.select(fuzzyEnd).attr("d", this.getAnnotationPieSlicePath(anno.seqDatum.end, anno.seqDatum.uncertainEnd, anno, false)); + // .duration(Polymer.transitionTime); + } + } + } + } + + const originalStickZoom = this.stickZoom; + const originalRotation = this.rotation; + const cubicInOut = d3.ease("cubic-in-out"); + // d3.timer(function (elapsed) { + // return update(elapsed / Polymer.transitionTime); + // }); + update(1); + + + function update(interp) { + const labelTransform = d3.transform(self.labelSVG.getAttribute("transform")); + const k = self.app.svgElement.createSVGMatrix().rotate(labelTransform.rotate).translate(labelTranslateInterpol(cubicInOut(interp)), LABEL_Y); //.scale(z).translate(-c.x, -c.y); + self.labelSVG.transform.baseVal.initialize(self.app.svgElement.createSVGTransformFromMatrix(k)); + //~ + if (xInterpol !== null) { + self.setPosition(xInterpol(cubicInOut(interp)), yInterpol(cubicInOut(interp))); + } + + self.stickZoom = stickZoomInterpol(cubicInOut(interp)); + self.setAllLinkCoordinates(); + + if (interp === 1) { // finished - tidy up + self.expanded = false; + self.checkLinks(); + + for (let [annotationType, annotations] of self.annotationSets) { + if (self.app.annotationSetsShown.get(annotationType) === true) { + for (let anno of annotations) { + if (anno.fuzzyStart) { + const fuzzyStart = anno.fuzzyStart; + d3.select(fuzzyStart).attr("d", self.getAnnotationPieSlicePath(anno.seqDatum.uncertainBegin, anno.seqDatum.begin, anno)); + } + + if (anno.certain) { + const certain = anno.certain; + d3.select(certain).attr("d", self.getAnnotationPieSlicePath(anno.seqDatum.begin, anno.seqDatum.end, anno)); + } + + if (anno.fuzzyEnd) { + const fuzzyEnd = anno.fuzzyEnd; + d3.select(fuzzyEnd).attr("d", self.getAnnotationPieSlicePath(anno.seqDatum.end, anno.seqDatum.uncertainEnd, anno)); + } + } + } + } + + self.stickZoom = originalStickZoom; + self.rotation = originalRotation; + self.busy = false; + return true; + } else if (interp > 1) { + return update(1); + } else { + return false; + } + } +}; + Polymer.prototype.toStick = function () { this.busy = true; this.expanded = true;