From 6aa49c4af9989ec2c7d0d427ee817eef70ead5b5 Mon Sep 17 00:00:00 2001 From: lxsang Date: Fri, 15 Jan 2021 20:45:45 +0100 Subject: [PATCH] quit app when service is closed --- SystemControl/build/debug/main.js | 2 +- SystemControl/build/debug/package.json | 2 +- SystemControl/build/release/SystemControl.zip | Bin 294336 -> 294362 bytes SystemControl/coffees/SysmondService.coffee | 1 + SystemControl/package.json | 2 +- packages.json | 4 ++-- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/SystemControl/build/debug/main.js b/SystemControl/build/debug/main.js index ee52c5b..e376eaa 100644 --- a/SystemControl/build/debug/main.js +++ b/SystemControl/build/debug/main.js @@ -1 +1 @@ -var t,n,e;(function(){var t,n;t=class extends OS.application.BaseService{constructor(t){super("SysmondService",t),this.text=__("{0}%",(0).toString()),this.iconclass="fa fa-android",this.app=void 0,this.onmenuselect=t=>this.openApp()}setting(){return this.systemsetting.applications.SystemControl}init(){var t;return t=()=>{if(Antunnel.tunnel){if(!this.setting().topic)return;return this.tunnel=Antunnel.tunnel,this.sub=new Antunnel.Subscriber(this.setting().topic),this.sub.onopen=()=>console.log("Subscribed to notification channel"),this.sub.onerror=t=>this.error(__("Error: {0}",new TextDecoder("utf-8").decode(t.data)),t),this.sub.onmessage=t=>{var n;return t.data&&(n=JSON.parse(new TextDecoder("utf-8").decode(t.data))),this.text=__("{0}%",Math.round(n.battery_percent).toString()),this.app&&this.app.feed(n),this.update()},this.sub.onclose=()=>(this.sub=void 0,this.notify(__("Unsubscribed to the notification service")),this.quit()),Antunnel.tunnel.subscribe(this.sub)}return this.error(__("The Antunnel service is not started, please start it first")),this._gui.pushService("Antunnel/AntunnelService").catch(t=>this.error(t.toString(),t)),this.quit()},this.setting().topic?t():(console.log("Open dialog"),this._gui.openDialog("PromptDialog",{title:__("Enter topic name"),label:__("Please enter topic name")}).then(n=>(this.setting().topic=n,t())))}openApp(){if(!this.app)return this._gui.launch("SystemControl",[])}execute(t){}awake(){}cleanup(){if(this.sub)return this.sub.close()}},this.OS.register("SysmondService",t),(n=class extends this.OS.application.BaseApplication{constructor(t){super("SystemControl",t)}main(){return this.diskchart=$(this.find("disk-area")).epoch({type:"time.gauge",value:0}),this.on("resize",()=>{var t;if(t=this.find("cpu-area"),this.cpu&&($(t).children().hide(),this.cpu.option("width",$(t).width()),this.cpu.option("height",$(t).height()),$(t).children().show()),t=this.find("battery-area"),t=this.find("memory-area"),this.memory&&($(t).children().hide(),this.memory.option("width",$(t).width()),this.memory.option("height",$(t).height()),$(t).children().show()),t=this.find("network-area"),this.network&&($(t).children().hide(),this.network.option("width",$(t).width()),this.network.option("height",$(t).height()),$(t).children().show()),t=this.find("temp-area"),this.temp&&($(t).children().hide(),this.temp.option("width",$(t).width()),this.temp.option("height",$(t).height()),$(t).children().show()),t=this.find("battery-area"),this.battery)return $(t).children().hide(),this.battery.option("width",$(t).width()),this.battery.option("height",$(t).height()),$(t).children().show()}),this._gui.pushService("SystemControl/SysmondService",[]).then(t=>(this.service=t,t.app=this)).catch(t=>this.error(__("Unable to start sysmond service"),t))}streamline(t,n,e,r){var i,o,a,u,s,l,c,h,f;if(o=0,l=$(this.find(t+"-text")),!this[t]){for(f={type:"time.line",axes:["bottom","left","right"]},e&&(f.range=e),i=[],u=0,c=n.length;u").addClass("legend-color").addClass("ref").addClass("category"+(o+1)).appendTo(l),$("
").addClass("legend-label").appendTo(l).text(r?r[o]:`${t}-${o}`),$("
").addClass("legend-value").appendTo(l),o+=1;f.data=i,this[t]=$(this.find(t+"-area")).epoch(f)}for(s=0,h=n.length;sm?v:m],this.streamline("memory",s,l,["RAM (GB)","SWAP (GB)"]),h=0,f=0,i=0,a=(g=t.net).length;in?1:t>=n?0:NaN}function f(t){return null===t?NaN:+t}function p(t){return!isNaN(t)}function g(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}}}t.ascending=h,t.descending=function(t,n){return nt?1:n>=t?0:NaN},t.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},t.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},t.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/(s-1)},t.deviation=function(){var n=t.variance.apply(this,arguments);return n?Math.sqrt(n):n};var d=g(h);function y(t){return t.length}t.bisectLeft=d.left,t.bisect=t.bisectRight=d.right,t.bisector=function(t){return g(1===t.length?function(n,e){return h(t(n),e)}:t)},t.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},t.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},t.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 v=Math.abs;function m(t){for(var n=1;t*n%1;)n*=10;return n}function x(t,n){for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}function _(){this._=Object.create(null)}function w(t){return"__proto__"==(t+="")||"\0"===t[0]?"\0"+t:t}function b(t){return"\0"===(t+="")[0]?t.slice(1):t}function M(t){return w(t)in this._}function k(t){return(t=w(t))in this._&&delete this._[t]}function E(){var t=[];for(var n in this._)t.push(b(n));return t}function S(){var t=0;for(var n in this._)++t;return t}function A(){for(var t in this._)return!1;return!0}function C(){this._=Object.create(null)}function N(t){return t}function T(t,n,e){return function(){var r=e.apply(n,arguments);return r===n?t:r}}function F(t,n){if(n in t)return n;n=n.charAt(0).toUpperCase()+n.slice(1);for(var e=0,r=L.length;en;)i.push(r/o);else for(;(r=t+e*++a)=i.length)return e?e.call(r,o):n?o.sort(n):o;for(var s,l,c,h,f=-1,p=o.length,g=i[u++],d=new _;++f=i.length)return n;var r=[],a=o[e++];return n.forEach((function(n,i){r.push({key:n,values:t(i,e)})})),a?r.sort((function(t,n){return a(t.key,n.key)})):r}(a(t.map,n,0),0)},r.key=function(t){return i.push(t),r},r.sortKeys=function(t){return o[i.length-1]=t,r},r.sortValues=function(t){return n=t,r},r.rollup=function(t){return e=t,r},r},t.set=function(t){var n=new C;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}},t.event=null,t.requote=function(t){return t.replace(O,"\\$&")};var O=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,I={}.__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};function H(t){return I(t,$),t}var j=function(t,n){return n.querySelector(t)},V=function(t,n){return n.querySelectorAll(t)},B=function(t,n){var e=t.matches||t[F(t,"matchesSelector")];return(B=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(j=function(t,n){return Sizzle(t,n)[0]||null},V=Sizzle,B=Sizzle.matchesSelector),t.selection=function(){return t.select(r.documentElement)};var $=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return j(t,this)}}function W(t){return"function"==typeof t?t:function(){return V(t,this)}}$.select=function(t){var n,e,r,i,o=[];t=Y(t);for(var a=-1,u=this.length;++a=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),X.hasOwnProperty(e)?{space:X[e],local:t}:t}},$.attr=function(n,e){if(arguments.length<2){if("string"==typeof n){var r=this.node();return(n=t.ns.qualify(n)).local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}for(e in n)this.each(G(e,n[e]));return this}return this.each(G(n,e))},$.classed=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node(),r=(t=K(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},$.sort=function(t){t=st.apply(this,arguments);for(var n=-1,e=this.length;++n=n&&(n=i+1);!(a=u[n])&&++n0&&(n=n.slice(0,a));var s=gt.get(n);function l(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}return s&&(n=s,u=yt),a?r?function(){var t=u(r,e(arguments));l.call(this),this.addEventListener(n,this[o]=t,t.$=i),t._=r}:l:r?z:function(){var e,r=new RegExp("^__on([^.]+)"+t.requote(n)+"$");for(var i in this)if(e=i.match(r)){var o=this[i];this.removeEventListener(e[1],o,o.$),delete this[i]}}}t.selection.enter=ct,t.selection.enter.prototype=ht,ht.append=$.append,ht.empty=$.empty,ht.node=$.node,ht.call=$.call,ht.size=$.size,ht.select=function(t){for(var n,e,r,i,o,a=[],u=-1,s=this.length;++u0?1:t<0?-1:0}function Lt(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function zt(t){return t>1?0:t<-1?Et:Math.acos(t)}function Dt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function Pt(t){return(t=Math.sin(t/2))*t}var qt=Math.SQRT2;t.interpolateZoom=function(t,n){var e,r,i=t[0],o=t[1],a=t[2],u=n[0],s=n[1],l=n[2],c=u-i,h=s-o,f=c*c+h*h;if(f0&&(n=n.transition().duration(d)),n.call(b.event)}function A(){l&&l.domain(s.range().map((function(t){return(t-f.x)/f.k})).map(s.invert)),h&&h.domain(c.range().map((function(t){return(t-f.y)/f.k})).map(c.invert))}function C(t){y++||t({type:"zoomstart"})}function N(t){A(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function T(t){--y||(t({type:"zoomend"}),e=null)}function F(){var n=this,e=w.of(n,arguments),r=0,i=t.select(o(n)).on(m,s).on(x,l),a=M(t.mouse(n)),u=xt(n);function s(){r=1,E(t.mouse(n),a),N(e)}function l(){i.on(m,null).on(x,null),u(r),T(e)}du.call(n),C(e)}function L(){var n,e=this,r=w.of(e,arguments),i={},o=0,a=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+a,l="touchend"+a,c=[],h=t.select(e),p=xt(e);function g(){var r=t.touches(e);return n=f.k,r.forEach((function(t){t.identifier in i&&(i[t.identifier]=M(t))})),r}function d(){var n=t.event.target;t.select(n).on(s,y).on(l,m),c.push(n);for(var r=t.event.changedTouches,a=0,h=r.length;a1){v=p[0];var x=p[1],_=v[0]-x[0],w=v[1]-x[1];o=_*_+w*w}}function y(){var a,s,l,c,h=t.touches(e);du.call(e);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 en(o(t+120),o(t),o(t-120))}function $t(n,e,r){return this instanceof $t?(this.h=+n,this.c=+e,void(this.l=+r)):arguments.length<2?n instanceof $t?new $t(n.h,n.c,n.l):Jt(n instanceof Zt?n.l:(n=cn((n=t.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new $t(n,e,r)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new jt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new jt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Bt(this.h,this.s,this.l)},t.hcl=$t;var Yt=$t.prototype=new Ht;function Wt(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),new Zt(e,Math.cos(t*=Nt)*n,Math.sin(t)*n)}function Zt(t,n,e){return this instanceof Zt?(this.l=+t,this.a=+n,void(this.b=+e)):arguments.length<2?t instanceof Zt?new Zt(t.l,t.a,t.b):t instanceof $t?Wt(t.h,t.c,t.l):cn((t=en(t)).r,t.g,t.b):new Zt(t,n,e)}Yt.brighter=function(t){return new $t(this.h,this.c,Math.min(100,this.l+Xt*(arguments.length?t:1)))},Yt.darker=function(t){return new $t(this.h,this.c,Math.max(0,this.l-Xt*(arguments.length?t:1)))},Yt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Zt;var Xt=18,Gt=Zt.prototype=new Ht;function Qt(t,n,e){var r=(t+16)/116,i=r+n/500,o=r-e/200;return new en(nn(3.2404542*(i=.95047*Kt(i))-1.5371385*(r=1*Kt(r))-.4985314*(o=1.08883*Kt(o))),nn(-.969266*i+1.8760108*r+.041556*o),nn(.0556434*i-.2040259*r+1.0572252*o))}function Jt(t,n,e){return t>0?new $t(Math.atan2(e,n)*Tt,Math.sqrt(n*n+e*e),t):new $t(NaN,NaN,t)}function Kt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function tn(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function nn(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function en(t,n,e){return this instanceof en?(this.r=~~t,this.g=~~n,void(this.b=~~e)):arguments.length<2?t instanceof en?new en(t.r,t.g,t.b):sn(""+t,en,Bt):new en(t,n,e)}function rn(t){return new en(t>>16,t>>8&255,255&t)}function on(t){return rn(t)+""}Gt.brighter=function(t){return new Zt(Math.min(100,this.l+Xt*(arguments.length?t:1)),this.a,this.b)},Gt.darker=function(t){return new Zt(Math.max(0,this.l-Xt*(arguments.length?t:1)),this.a,this.b)},Gt.rgb=function(){return Qt(this.l,this.a,this.b)},t.rgb=en;var an=en.prototype=new Ht;function un(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function sn(t,n,e){var r,i,o,a=0,u=0,s=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(fn(i[0]),fn(i[1]),fn(i[2]))}return(o=pn.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,u=240&o,u|=u>>4,s=15&o,s|=s<<4):7===t.length&&(a=(16711680&o)>>16,u=(65280&o)>>8,s=255&o)),n(a,u,s))}function ln(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),u=a-o,s=(a+o)/2;return u?(i=s<.5?u/(a+o):u/(2-a-o),r=t==a?(n-e)/u+(n0&&s<1?0:r),new jt(r,i,s)}function cn(t,n,e){var r=tn((.4124564*(t=hn(t))+.3575761*(n=hn(n))+.1804375*(e=hn(e)))/.95047),i=tn((.2126729*t+.7151522*n+.072175*e)/1);return Zt(116*i-16,500*(r-i),200*(i-tn((.0193339*t+.119192*n+.9503041*e)/1.08883)))}function hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function fn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}an.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=i.call(a,l)}catch(t){return void u.error.call(a,t)}u.load.call(a,t)}else u.error.call(a,l)}return this.XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(n)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=h:l.onreadystatechange=function(){l.readyState>3&&h()},l.onprogress=function(n){var e=t.event;t.event=n;try{u.progress.call(a,l)}finally{t.event=e}},a.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==n?delete s[t]:s[t]=n+"",a)},a.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",a):r},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return i=t,a},["get","post"].forEach((function(t){a[t]=function(){return a.send.apply(a,[t].concat(e(arguments)))}})),a.send=function(t,e,i){if(2===arguments.length&&"function"==typeof e&&(i=e,e=null),l.open(t,n,!0),null==r||"accept"in s||(s.accept=r+",*/*"),l.setRequestHeader)for(var o in s)l.setRequestHeader(o,s[o]);return null!=r&&l.overrideMimeType&&l.overrideMimeType(r),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",(function(t){i(null,t)})),u.beforesend.call(a,l),l.send(null==e?null:e),a},a.abort=function(){return l.abort(),a},t.rebind(a,u,"on"),null==o?a:a.get(function(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}(o))}pn.forEach((function(t,n){pn.set(t,rn(n))})),t.functor=gn,t.xhr=dn(N),t.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=yn(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 u(n){return n.map(s).join(t)}function s(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={},u=[],s=t.length,l=0,c=0;function h(){if(l>=s)return a;if(i)return i=!1,o;var n=l;if(34===t.charCodeAt(n)){for(var e=n;e++24?(isFinite(n)&&(clearTimeout(_n),_n=setTimeout(Mn,n)),xn=0):(xn=1,wn(Mn))}function kn(){for(var t=Date.now(),n=vn;n;)t>=n.t&&n.c(t-n.t)&&(n.c=null),n=n.n;return t}function En(){for(var t,n=vn,e=1/0;n;)n.c?(n.t8?function(t){return t/e}:function(t){return t*e},symbol:t}}));function Cn(n){var e=n.decimal,r=n.thousands,i=n.grouping,o=n.currency,a=i&&r?function(t,n){for(var e=t.length,o=[],a=0,u=i[0],s=0;e>0&&u>0&&(s+u+1>n&&(u=Math.max(1,n-s)),o.push(t.substring(e-=u,e+u)),!((s+=u+1)>n));)u=i[a=(a+1)%i.length];return o.reverse().join(r)}:N;return function(n){var r=Nn.exec(n),i=r[1]||" ",u=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],h=+r[6],f=r[7],p=r[8],g=r[9],d=1,y="",v="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(c||"0"===i&&"="===u)&&(c=i="0",u="="),g){case"n":f=!0,g="g";break;case"%":d=100,v="%",g="f";break;case"p":d=100,v="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(y="0"+g.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":d=-1,g="r"}"$"===l&&(y=o[0],v=o[1]),"r"!=g||p||(g="g"),null!=p&&("g"==g?p=Math.max(1,Math.min(21,p)):"e"!=g&&"f"!=g||(p=Math.max(0,Math.min(20,p)))),g=Tn.get(g)||Fn;var _=c&&f;return function(n){var r=v;if(m&&n%1)return"";var o=n<0||0===n&&1/n<0?(n=-n,"-"):"-"===s?"":s;if(d<0){var l=t.formatPrefix(n,p);n=l.scale(n),r=l.symbol+v}else n*=d;var w,b,M=(n=g(n,p)).lastIndexOf(".");if(M<0){var k=x?n.lastIndexOf("e"):-1;k<0?(w=n,b=""):(w=n.substring(0,k),b=n.substring(k))}else w=n.substring(0,M),b=e+n.substring(M+1);!c&&f&&(w=a(w,1/0));var E=y.length+w.length+b.length+(_?0:o.length),S=E"===u?S+o+n:"^"===u?S.substring(0,E>>=1)+o+n+S.substring(E):o+(_?n:S+n))+r}}}t.formatPrefix=function(n,e){var r=0;return(n=+n)&&(n<0&&(n*=-1),e&&(n=t.round(n,Sn(n,e))),r=1+Math.floor(1e-12+Math.log(n)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),An[8+r/3]};var Nn=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Tn=t.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(n,e){return(n=t.round(n,Sn(n,e))).toFixed(Math.max(0,Math.min(20,Sn(n*(1+1e-15),e))))}});function Fn(t){return t+""}var Ln=t.time={},zn=Date;function Dn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Dn.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(){Rn.setUTCDate.apply(this._,arguments)},setDay:function(){Rn.setUTCDay.apply(this._,arguments)},setFullYear:function(){Rn.setUTCFullYear.apply(this._,arguments)},setHours:function(){Rn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Rn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Rn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Rn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Rn.setUTCSeconds.apply(this._,arguments)},setTime:function(){Rn.setTime.apply(this._,arguments)}};var Rn=Date.prototype;function Pn(t,n,e){function r(n){var e=t(n),r=o(e,1);return n-e1)for(;a=l)return-1;if(37===(i=n.charCodeAt(u++))){if(a=n.charAt(u++),!(o=b[a in On?n.charAt(u++):a])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}c.utc=function(t){var n=c(t);function e(t){try{var e=new(zn=Dn);return e._=t,n(e)}finally{zn=Date}}return e.parse=function(t){try{zn=Dn;var e=n.parse(t);return e&&e._}finally{zn=Date}},e.toString=n.toString,e},c.multi=c.utc.multi=ae;var f=t.map(),p=Vn(a),g=Bn(a),d=Vn(u),y=Bn(u),v=Vn(s),m=Bn(s),x=Vn(l),_=Bn(l);o.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return u[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:c(e),d:function(t,n){return jn(t.getDate(),n,2)},e:function(t,n){return jn(t.getDate(),n,2)},H:function(t,n){return jn(t.getHours(),n,2)},I:function(t,n){return jn(t.getHours()%12||12,n,2)},j:function(t,n){return jn(1+Ln.dayOfYear(t),n,3)},L:function(t,n){return jn(t.getMilliseconds(),n,3)},m:function(t,n){return jn(t.getMonth()+1,n,2)},M:function(t,n){return jn(t.getMinutes(),n,2)},p:function(t){return o[+(t.getHours()>=12)]},S:function(t,n){return jn(t.getSeconds(),n,2)},U:function(t,n){return jn(Ln.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return jn(Ln.mondayOfYear(t),n,2)},x:c(r),X:c(i),y:function(t,n){return jn(t.getFullYear()%100,n,2)},Y:function(t,n){return jn(t.getFullYear()%1e4,n,4)},Z:ie,"%":function(){return"%"}},b={a:function(t,n,e){d.lastIndex=0;var r=d.exec(n.slice(e));return r?(t.w=y.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=g.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){x.lastIndex=0;var r=x.exec(n.slice(e));return r?(t.m=_.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=m.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,n,e){return h(t,w.c.toString(),n,e)},d:Jn,e:Jn,H:te,I:te,j:Kn,L:re,m:Qn,M:ne,p:function(t,n,e){var r=f.get(n.slice(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)},S:ee,U:Yn,w:$n,W:Wn,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:Xn,Y:Zn,Z:Gn,"%":oe};return c}Ln.year=Pn((function(t){return(t=Ln.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),Ln.years=Ln.year.range,Ln.years.utc=Ln.year.utc.range,Ln.day=Pn((function(t){var n=new zn(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})),Ln.days=Ln.day.range,Ln.days.utc=Ln.day.utc.range,Ln.dayOfYear=function(t){var n=Ln.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=Ln[t]=Pn((function(t){return(t=Ln.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=Ln.year(t).getDay();return Math.floor((Ln.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));Ln[t+"s"]=e.range,Ln[t+"s"].utc=e.utc.range,Ln[t+"OfYear"]=function(t){var e=Ln.year(t).getDay();return Math.floor((Ln.dayOfYear(t)+(e+n)%7)/7)}})),Ln.week=Ln.sunday,Ln.weeks=Ln.sunday.range,Ln.weeks.utc=Ln.sunday.utc.range,Ln.weekOfYear=Ln.sundayOfYear;var On={"-":"",_:" ",0:"0"},In=/^\s*\d+/,Hn=/^%/;function jn(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 Gn(t,n,e){return/^[+-]\d{4}$/.test(n=n.slice(e,e+5))?(t.Z=-n,e+5):-1}function Qn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function Jn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function Kn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+3));return r?(t.j=+r[0],e+r[0].length):-1}function te(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function ne(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function ee(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function re(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function ie(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=v(n)/60|0,i=v(n)%60;return e+jn(r,"0",2)+jn(i,"0",2)}function oe(t,n,e){Hn.lastIndex=0;var r=Hn.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function ae(t){for(var n=t.length,e=-1;++e=0?1:-1,u=a*o,s=Math.cos(n),l=Math.sin(n),c=i*l,h=r*s+c*Math.cos(u),f=c*a*Math.sin(u);Ce.add(Math.atan2(f,h)),e=t,r=s,i=l}Ne.point=function(a,u){Ne.point=o,e=(t=a)*Nt,r=Math.cos(u=(n=u)*Nt/2+Et/4),i=Math.sin(u)},Ne.lineEnd=function(){o(t,n)}}function Fe(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 Le(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ze(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 De(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Re(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Pe(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 qe(t){return[Math.atan2(t[1],t[0]),Dt(t[2])]}function Ue(t,n){return v(t[0]-n[0])Mt?i=90:l<-Mt&&(e=-90),h[0]=n,h[1]=r}};function p(t,o){c.push(h=[n=t,r=t]),oi&&(i=o)}function g(t,a){var u=Fe([t*Nt,a*Nt]);if(s){var l=ze(s,u),c=ze([l[1],-l[0],0],l);Pe(c),c=qe(c);var h=t-o,f=h>0?1:-1,g=c[0]*Tt*f,d=v(h)>180;if(d^(f*oi&&(i=y);else if(d^(f*o<(g=(g+360)%360-180)&&gi&&(i=a);d?tw(n,r)&&(r=t):w(t,r)>w(n,r)&&(n=t):r>=n?(tr&&(r=t)):t>o?w(n,t)>w(n,r)&&(r=t):w(t,r)>w(n,r)&&(n=t)}else p(t,a);s=u,o=t}function d(){f.point=g}function y(){h[0]=n,h[1]=r,f.point=p,s=null}function m(t,n){if(s){var e=t-o;l+=v(e)>180?e+(e>0?360:-360):e}else a=t,u=n;Ne.point(t,n),g(t,n)}function x(){Ne.lineStart()}function _(){m(a,u),Ne.lineEnd(),v(l)>Mt&&(n=-(r=180)),h[0]=n,h[1]=r,s=null}function w(t,n){return(n-=t)<0?n+360:n}function b(t,n){return t[0]-n[0]}function M(t,n){return n[0]<=n[1]?n[0]<=t&&t<=n[1]:tw(d[0],d[1])&&(d[1]=p[1]),w(p[0],d[1])>w(d[0],d[1])&&(d[0]=p[0])):u.push(d=p);for(var s,l,p,g=-1/0,d=(a=0,u[l=u.length-1]);a<=l;d=p,++a)p=u[a],(s=w(d[1],p[0]))>g&&(g=s,n=p[0],r=d[1])}return c=h=null,n===1/0||e===1/0?[[NaN,NaN],[NaN,NaN]]:[[n,e],[r,i]]}}(),t.geo.centroid=function(n){ve=me=xe=_e=we=be=Me=ke=Ee=Se=Ae=0,t.geo.stream(n,Oe);var e=Ee,r=Se,i=Ae,o=e*e+r*r+i*i;return o=0;--u)i.point((h=c[u])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}c=(p=p.o).z,g=!g}while(!p.v);i.lineEnd()}}}function Ze(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,M=b*w,k=M>Et,E=g*x;if(Ce.add(Math.atan2(E*b*Math.sin(M),d*_+E*Math.cos(M))),o+=k?w+b*St:w,k^f>=e^v>=e){var S=ze(Fe(h),Fe(t));Pe(S);var A=ze(i,S);Pe(A);var C=(k^w>=0?-1:1)*Dt(A[2]);(r>C||r===C&&(S[0]||S[1]))&&(a+=k^w>=0?1:-1)}if(!y++)break;f=v,g=x,d=_,h=t}}return(o<-Mt||o0){for(x||(a.polygonStart(),x=!0),a.lineStart();++o1&&2&n&&e.push(e.pop().concat(e.shift())),u.push(e.filter(Qe))}return c}}function Qe(t){return t.length>1}function Je(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:z,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function Ke(t,n){return((t=t.x)[0]<0?t[1]-Ct-Mt:Ct-t[1])-((n=n.x)[0]<0?n[1]-Ct-Mt:Ct-n[1])}var tr=Ge(Ye,(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?Et:-Et,s=v(o-e);v(s-Et)0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&s>=Et&&(v(e-i)Mt?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(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*Ct,r.point(-Et,i),r.point(0,i),r.point(Et,i),r.point(Et,0),r.point(Et,-i),r.point(0,-i),r.point(-Et,-i),r.point(-Et,0),r.point(-Et,i);else if(v(t[0]-n[0])>Mt){var o=t[0]0,r=v(n)>Mt;return Ge(i,(function(t){var n,u,s,l,c;return{lineStart:function(){l=s=!1,c=1},point:function(h,f){var p,g=[h,f],d=i(h,f),y=e?d?0:a(h,f):d?a(h+(h<0?Et:-Et),f):0;if(!n&&(l=s=d)&&t.lineStart(),d!==s&&(p=o(n,g),(Ue(n,p)||Ue(g,p))&&(g[0]+=Mt,g[1]+=Mt,d=i(g[0],g[1]))),d!==s)c=0,d?(t.lineStart(),p=o(g,n),t.point(p[0],p[1])):(p=o(n,g),t.point(p[0],p[1]),t.lineEnd()),n=p;else if(r&&n&&e^d){var v;y&u||!(v=o(g,n,!0))||(c=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&&Ue(n,g)||t.point(g[0],g[1]),n=g,s=d,u=y},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return c|(l&&s)<<1}}}),qr(t,6*Nt),e?[0,-t]:[-Et,t-Et]);function i(t,e){return Math.cos(t)*Math.cos(e)>n}function o(t,e,r){var i=[1,0,0],o=ze(Fe(t),Fe(e)),a=Le(o,o),u=o[0],s=a-u*u;if(!s)return!r&&t;var l=n*a/s,c=-n*u/s,h=ze(i,o),f=Re(i,l);De(f,Re(o,c));var p=h,g=Le(f,p),d=Le(p,p),y=g*g-d*(Le(f,f)-1);if(!(y<0)){var m=Math.sqrt(y),x=Re(p,(-g-m)/d);if(De(x,f),x=qe(x),!r)return x;var _,w=t[0],b=e[0],M=t[1],k=e[1];b0^x[1]<(v(x[0]-w)Et^(w<=x[0]&&x[0]<=b)){var A=Re(p,(-g+m)/d);return De(A,f),[x,qe(A)]}}}function a(n,r){var i=e?t:Et-t,o=0;return n<-i?o|=1:n>i&&(o|=2),r<-i?o|=4:r>i&&(o|=8),o}}function er(t,n,e,r){return function(i){var o,a=i.a,u=i.b,s=a.x,l=a.y,c=0,h=1,f=u.x-s,p=u.y-l;if(o=t-s,f||!(o>0)){if(o/=f,f<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=e-s,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o)}else if(f>0){if(o0)){if(o/=p,p<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=r-l,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>c&&(c=o)}else if(p>0){if(o0&&(i.a={x:s+c*f,y:l+c*p}),h<1&&(i.b={x:s+h*f,y:l+h*p}),i}}}}}}function rr(n,e,r,i){return function(s){var l,c,h,f,p,g,d,y,v,m,x,_=s,w=Je(),b=er(n,e,r,i),M={point:S,lineStart:function(){M.point=A,c&&c.push(h=[]),m=!0,v=!1,d=y=NaN},lineEnd:function(){l&&(A(f,p),g&&v&&w.rejoin(),l.push(w.buffer())),M.point=S,v&&s.lineEnd()},polygonStart:function(){s=w,l=[],c=[],x=!0},polygonEnd:function(){s=_,l=t.merge(l);var e=function(t){for(var n=0,e=c.length,r=t[1],i=0;ir&&Lt(l,o,t)>0&&++n:o[1]<=r&&Lt(l,o,t)<0&&--n,l=o;return 0!==n}([n,i]),r=x&&e,o=l.length;(r||o)&&(s.polygonStart(),r&&(s.lineStart(),k(null,null,1,s),s.lineEnd()),o&&We(l,a,e,k,s),s.polygonEnd()),l=c=h=null}};function k(t,a,s,l){var c=0,h=0;if(null==t||(c=o(t,s))!==(h=o(a,s))||u(t,a)<0^s>0)do{l.point(0===c||3===c?n:r,c>1?i:e)}while((c=(c+s+4)%4)!==h);else l.point(a[0],a[1])}function E(t,o){return n<=t&&t<=r&&e<=o&&o<=i}function S(t,n){E(t,n)&&s.point(t,n)}function A(t,n){var e=E(t=Math.max(-1e9,Math.min(1e9,t)),n=Math.max(-1e9,Math.min(1e9,n)));if(c&&h.push([t,n]),m)f=t,p=n,g=e,m=!1,e&&(s.lineStart(),s.point(t,n));else if(e&&v)s.point(t,n);else{var r={a:{x:d,y:y},b:{x:t,y:n}};b(r)?(v||(s.lineStart(),s.point(r.a.x,r.a.y)),s.point(r.b.x,r.b.y),e||s.lineEnd(),x=!1):e&&(s.lineStart(),s.point(t,n),x=!1)}d=t,y=n,v=e}return M};function o(t,i){return v(t[0]-n)0?0:3:v(t[0]-r)0?2:1:v(t[1]-e)0?1:0:i>0?3:2}function a(t,n){return u(t.x,n.x)}function u(t,n){var e=o(t,1),r=o(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 ir(t){var n=0,e=Et/3,r=Nr(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Et/180,e=t[1]*Et/180):[n/Et*180,e/Et*180]},i}function or(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,Dt((i-(t*t+e*e)*r*r)/(2*r))]},a}t.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(u){return arguments.length?(o=rr(t=+u[0][0],n=+u[0][1],e=+u[1][0],r=+u[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ir(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var n,e,r,i,o=t.geo.albers(),a=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),u=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,e){n=[t,e]}};function l(t){var o=t[0],a=t[1];return n=null,e(o,a),n||(r(o,a),n)||i(o,a),n}return l.invert=function(t){var n=o.scale(),e=o.translate(),r=(t[0]-e[0])/n,i=(t[1]-e[1])/n;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?a:i>=.166&&i<.234&&r>=-.214&&r<-.115?u:o).invert(t)},l.stream=function(t){var n=o.stream(t),e=a.stream(t),r=u.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()}}},l.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),u.precision(t),l):o.precision()},l.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),u.scale(t),l.translate(o.translate())):o.scale()},l.translate=function(t){if(!arguments.length)return o.translate();var n=o.scale(),c=+t[0],h=+t[1];return e=o.translate(t).clipExtent([[c-.455*n,h-.238*n],[c+.455*n,h+.238*n]]).stream(s).point,r=a.translate([c-.307*n,h+.201*n]).clipExtent([[c-.425*n+Mt,h+.12*n+Mt],[c-.214*n-Mt,h+.234*n-Mt]]).stream(s).point,i=u.translate([c-.205*n,h+.212*n]).clipExtent([[c-.214*n+Mt,h+.166*n+Mt],[c-.115*n-Mt,h+.234*n-Mt]]).stream(s).point,l},l.scale(1070)};var ar,ur,sr,lr,cr,hr,fr={point:z,lineStart:z,lineEnd:z,polygonStart:function(){ur=0,fr.lineStart=pr},polygonEnd:function(){fr.lineStart=fr.lineEnd=fr.point=z,ar+=v(ur/2)}};function pr(){var t,n,e,r;function i(t,n){ur+=r*t-e*n,e=t,r=n}fr.point=function(o,a){fr.point=i,t=e=o,n=r=a},fr.lineEnd=function(){i(t,n)}}var gr={point:function(t,n){tcr&&(cr=t),nhr&&(hr=n)},lineStart:z,lineEnd:z,polygonStart:z,polygonEnd:z};function dr(){var t=yr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=u},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=yr(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 u(){n.push("Z")}return e}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var vr,mr={point:xr,lineStart:_r,lineEnd:wr,polygonStart:function(){mr.lineStart=br},polygonEnd:function(){mr.point=xr,mr.lineStart=_r,mr.lineEnd=wr}};function xr(t,n){xe+=t,_e+=n,++we}function _r(){var t,n;function e(e,r){var i=e-t,o=r-n,a=Math.sqrt(i*i+o*o);be+=a*(t+e)/2,Me+=a*(n+r)/2,ke+=a,xr(t=e,n=r)}mr.point=function(r,i){mr.point=e,xr(t=r,n=i)}}function wr(){mr.point=xr}function br(){var t,n,e,r;function i(t,n){var i=t-e,o=n-r,a=Math.sqrt(i*i+o*o);be+=a*(e+t)/2,Me+=a*(r+n)/2,ke+=a,Ee+=(a=r*t-e*n)*(e+t),Se+=a*(r+n),Ae+=3*a,xr(e=t,r=n)}mr.point=function(o,a){mr.point=i,xr(t=e=o,n=r=a)},mr.lineEnd=function(){i(t,n)}}function Mr(t){var n=4.5,e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=u},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:z};function r(e,r){t.moveTo(e+n,r),t.arc(e,r,n,0,St)}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 u(){t.closePath()}return e}function kr(t){var n=.5,e=Math.cos(30*Nt),r=16;function i(t){return(r?a:o)(t)}function o(n){return Ar(n,(function(e,r){e=t(e,r),n.point(e[0],e[1])}))}function a(n){var e,i,o,a,s,l,c,h,f,p,g,d,y={point:v,lineStart:m,lineEnd:_,polygonStart:function(){n.polygonStart(),y.lineStart=w},polygonEnd:function(){n.polygonEnd(),y.lineStart=m}};function v(e,r){e=t(e,r),n.point(e[0],e[1])}function m(){h=NaN,y.point=x,n.lineStart()}function x(e,i){var o=Fe([e,i]),a=t(e,i);u(h,f,c,p,g,d,h=a[0],f=a[1],c=e,p=o[0],g=o[1],d=o[2],r,n),n.point(h,f)}function _(){y.point=v,n.lineEnd()}function w(){m(),y.point=b,y.lineEnd=M}function b(t,n){x(e=t,n),i=h,o=f,a=p,s=g,l=d,y.point=x}function M(){u(h,f,c,p,g,d,i,o,e,a,s,l,r,n),y.lineEnd=_,_()}return y}function u(r,i,o,a,s,l,c,h,f,p,g,d,y,m){var x=c-r,_=h-i,w=x*x+_*_;if(w>4*n&&y--){var b=a+p,M=s+g,k=l+d,E=Math.sqrt(b*b+M*M+k*k),S=Math.asin(k/=E),A=v(v(k)-1)n||v((x*F+_*L)/w-.5)>.3||a*p+s*g+l*d0&&16,i):Math.sqrt(n)},i}function Er(t){var n=kr((function(n,e){return t([n*Tt,e*Tt])}));return function(t){return Tr(n(t))}}function Sr(t){this.stream=t}function Ar(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 Cr(t){return Nr((function(){return t}))()}function Nr(n){var e,r,i,o,a,u,s=kr((function(t,n){return[(t=e(t,n))[0]*l+o,a-t[1]*l]})),l=150,c=480,h=250,f=0,p=0,g=0,d=0,y=0,v=tr,m=N,x=null,_=null;function w(t){return[(t=i(t[0]*Nt,t[1]*Nt))[0]*l+o,a-t[1]*l]}function b(t){return(t=i.invert((t[0]-o)/l,(a-t[1])/l))&&[t[0]*Tt,t[1]*Tt]}function M(){i=$e(r=zr(g,d,y),e);var t=e(f,p);return o=c-t[0]*l,a=h+t[1]*l,k()}function k(){return u&&(u.valid=!1,u=null),w}return w.stream=function(t){return u&&(u.valid=!1),(u=Tr(v(r,s(m(t))))).valid=!0,u},w.clipAngle=function(t){return arguments.length?(v=null==t?(x=t,tr):nr((x=+t)*Nt),k()):x},w.clipExtent=function(t){return arguments.length?(_=t,m=t?rr(t[0][0],t[0][1],t[1][0],t[1][1]):N,k()):_},w.scale=function(t){return arguments.length?(l=+t,M()):l},w.translate=function(t){return arguments.length?(c=+t[0],h=+t[1],M()):[c,h]},w.center=function(t){return arguments.length?(f=t[0]%360*Nt,p=t[1]%360*Nt,M()):[f*Tt,p*Tt]},w.rotate=function(t){return arguments.length?(g=t[0]%360*Nt,d=t[1]%360*Nt,y=t.length>2?t[2]%360*Nt:0,M()):[g*Tt,d*Tt,y*Tt]},t.rebind(w,s,"precision"),function(){return e=n.apply(this,arguments),w.invert=e.invert&&b,M()}}function Tr(t){return Ar(t,(function(n,e){t.point(n*Nt,e*Nt)}))}function Fr(t,n){return[t,n]}function Lr(t,n){return[t>Et?t-St:t<-Et?t+St:t,n]}function zr(t,n,e){return t?n||e?$e(Rr(t),Pr(n,e)):Rr(t):n||e?Pr(n,e):Lr}function Dr(t){return function(n,e){return[(n+=t)>Et?n-St:n<-Et?n+St:n,e]}}function Rr(t){var n=Dr(t);return n.invert=Dr(-t),n}function Pr(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),u=Math.cos(t)*a,s=Math.sin(t)*a,l=Math.sin(n),c=l*e+u*r;return[Math.atan2(s*i-c*o,u*e-l*r),Dt(c*i+s*o)]}return a.invert=function(t,n){var a=Math.cos(n),u=Math.cos(t)*a,s=Math.sin(t)*a,l=Math.sin(n),c=l*i-s*o;return[Math.atan2(s*i+l*o,u*e+c*r),Dt(c*e-u*r)]},a}function qr(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,u){var s=a*n;null!=i?(i=Ur(e,i),o=Ur(e,o),(a>0?io)&&(i+=a*St)):(i=t+a*St,o=t-.5*s);for(var l,c=i;a>0?c>o:c2?t[2]*Nt:0),n.invert=function(n){return(n=t.invert(n[0]*Nt,n[1]*Nt))[0]*=Tt,n[1]*=Tt,n},n},Lr.invert=Fr,t.geo.circle=function(){var t,n,e=[0,0],r=6;function i(){var t="function"==typeof e?e.apply(this,arguments):e,r=zr(-t[0]*Nt,-t[1]*Nt,0).invert,i=[];return n(null,null,1,{point:function(t,n){i.push(t=r(t,n)),t[0]*=Tt,t[1]*=Tt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(e=t,i):e},i.angle=function(e){return arguments.length?(n=qr((t=+e)*Nt,r*Nt),i):t},i.precision=function(e){return arguments.length?(n=qr(t*Nt,(r=+e)*Nt),i):r},i.angle(90)},t.geo.distance=function(t,n){var e,r=(n[0]-t[0])*Nt,i=t[1]*Nt,o=n[1]*Nt,a=Math.sin(r),u=Math.cos(r),s=Math.sin(i),l=Math.cos(i),c=Math.sin(o),h=Math.cos(o);return Math.atan2(Math.sqrt((e=h*a)*e+(e=l*c-s*h*u)*e),s*c+l*h*u)},t.geo.graticule=function(){var n,e,r,i,o,a,u,s,l,c,h,f,p=10,g=p,d=90,y=360,m=2.5;function x(){return{type:"MultiLineString",coordinates:_()}}function _(){return t.range(Math.ceil(i/d)*d,r,d).map(h).concat(t.range(Math.ceil(s/y)*y,u,y).map(f)).concat(t.range(Math.ceil(e/p)*p,n,p).filter((function(t){return v(t%d)>Mt})).map(l)).concat(t.range(Math.ceil(a/g)*g,o,g).filter((function(t){return v(t%y)>Mt})).map(c))}return x.lines=function(){return _().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(f(u).slice(1),h(r).reverse().slice(1),f(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],s=+t[0][1],u=+t[1][1],i>r&&(t=i,i=r,r=t),s>u&&(t=s,s=u,u=t),x.precision(m)):[[i,s],[r,u]]},x.minorExtent=function(t){return arguments.length?(e=+t[0][0],n=+t[1][0],a=+t[0][1],o=+t[1][1],e>n&&(t=e,e=n,n=t),a>o&&(t=a,a=o,o=t),x.precision(m)):[[e,a],[n,o]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],x):[d,y]},x.minorStep=function(t){return arguments.length?(p=+t[0],g=+t[1],x):[p,g]},x.precision=function(t){return arguments.length?(m=+t,l=Or(a,o,90),c=Ir(e,n,m),h=Or(s,u,90),f=Ir(i,r,m),x):m},x.majorExtent([[-180,-90+Mt],[180,90-Mt]]).minorExtent([[-180,-80-Mt],[180,80+Mt]])},t.geo.greatArc=function(){var n,e,r=Hr,i=jr;function o(){return{type:"LineString",coordinates:[n||r.apply(this,arguments),e||i.apply(this,arguments)]}}return o.distance=function(){return t.geo.distance(n||r.apply(this,arguments),e||i.apply(this,arguments))},o.source=function(t){return arguments.length?(r=t,n="function"==typeof t?null:t,o):r},o.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,o):i},o.precision=function(){return arguments.length?o:0},o},t.geo.interpolate=function(t,n){return e=t[0]*Nt,r=t[1]*Nt,i=n[0]*Nt,o=n[1]*Nt,a=Math.cos(r),u=Math.sin(r),s=Math.cos(o),l=Math.sin(o),c=a*Math.cos(e),h=a*Math.sin(e),f=s*Math.cos(i),p=s*Math.sin(i),g=2*Math.asin(Math.sqrt(Pt(o-r)+a*s*Pt(i-e))),d=1/Math.sin(g),(y=g?function(t){var n=Math.sin(t*=g)*d,e=Math.sin(g-t)*d,r=e*c+n*f,i=e*h+n*p,o=e*u+n*l;return[Math.atan2(i,r)*Tt,Math.atan2(o,Math.sqrt(r*r+i*i))*Tt]}:function(){return[e*Tt,r*Tt]}).distance=g,y;var e,r,i,o,a,u,s,l,c,h,f,p,g,d,y},t.geo.length=function(n){return vr=0,t.geo.stream(n,Vr),vr};var Vr={sphere:z,point:z,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=Nt),a=Math.cos(i),u=v((r*=Nt)-t),s=Math.cos(u);vr+=Math.atan2(Math.sqrt((u=a*Math.sin(u))*u+(u=e*o-n*a*s)*u),n*o+e*a*s),t=r,n=o,e=a}Vr.point=function(i,o){t=i*Nt,n=Math.sin(o*=Nt),e=Math.cos(o),Vr.point=r},Vr.lineEnd=function(){Vr.point=Vr.lineEnd=z}},lineEnd:z,polygonStart:z,polygonEnd:z};function Br(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 $r=Br((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(t.geo.azimuthalEqualArea=function(){return Cr($r)}).raw=$r;var Yr=Br((function(t){var n=Math.acos(t);return n&&n/Math.sin(n)}),N);function Wr(t,n){var e=Math.cos(t),r=function(t){return Math.tan(Et/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 Gr;function a(t,n){o>0?n<-Ct+Mt&&(n=-Ct+Mt):n>Ct-Mt&&(n=Ct-Mt);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=Ft(i)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ct]},a}function Zr(t,n){var e=Math.cos(t),r=t===n?Math.sin(t):(e-Math.cos(n))/(n-t),i=e/r+t;if(v(r)1&&Lt(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ii(t,n){return t[0]-n[0]||t[1]-n[1]}(t.geo.stereographic=function(){return Cr(Kr)}).raw=Kr,ti.invert=function(t,n){return[-n,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Qr(ti),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=ti,t.geom={},t.geom.hull=function(t){var n=ni,e=ei;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=gn(n),o=gn(e),a=t.length,u=[],s=[];for(r=0;r=0;--r)p.push(t[u[l[r]][2]]);for(r=+h;rMt)u=u.L;else{if(!((i=o-bi(u,a))>Mt)){r>-Mt?(n=u.P,e=u):i>-Mt?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}var s=vi(t);if(hi.insert(n,s),n||e){if(n===e)return Ai(n),e=vi(n.site),hi.insert(s,e),s.edge=e.edge=Ti(n.site,s.site),Si(n),void Si(e);if(e){Ai(n),Ai(e);var l=n.site,c=l.x,h=l.y,f=t.x-c,p=t.y-h,g=e.site,d=g.x-c,y=g.y-h,v=2*(f*y-p*d),m=f*f+p*p,x=d*d+y*y,_={x:(y*m-p*x)/v+c,y:(f*x-d*m)/v+h};Fi(e.edge,l,g,_),s.edge=Ti(l,t,null,_),e.edge=Ti(t,g,null,_),Si(n),Si(e)}else s.edge=Ti(n.site,s.site)}}function wi(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 u=(e=a.site).x,s=e.y,l=s-n;if(!l)return u;var c=u-r,h=1/o-1/l,f=c/l;return h?(-f+Math.sqrt(f*f-2*h*(c*c/(-2*l)-s+l/2+i-o/2)))/h+r:(r+u)/2}function bi(t,n){var e=t.N;if(e)return wi(e,n);var r=t.site;return r.y===n?r.x:1/0}function Mi(t){this.site=t,this.edges=[]}function ki(t,n){return n.angle-t.angle}function Ei(){Di(this),this.x=this.y=this.arc=this.site=this.cy=null}function Si(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,u=i.y,s=r.x-a,l=r.y-u,c=o.x-a,h=2*(s*(y=o.y-u)-l*c);if(!(h>=-kt)){var f=s*s+l*l,p=c*c+y*y,g=(y*f-l*p)/h,d=(s*p-c*f)/h,y=d+u,v=di.pop()||new Ei;v.arc=t,v.site=i,v.x=g+a,v.y=y+Math.sqrt(g*g+d*d),v.cy=y,t.circle=v;for(var m=null,x=pi._;x;)if(v.y=u)return;if(f>g){if(o){if(o.y>=l)return}else o={x:y,y:s};e={x:y,y:l}}else{if(o){if(o.y1)if(f>g){if(o){if(o.y>=l)return}else o={x:(s-i)/r,y:s};e={x:(l-i)/r,y:l}}else{if(o){if(o.y=u)return}else o={x:a,y:r*a+i};e={x:u,y:r*u+i}}else{if(o){if(o.xMt||v(i-e)>Mt)&&(u.splice(a,0,new Li((m=o.site,x=c,_=v(r-h)Mt?{x:h,y:v(n-h)Mt?{x:v(e-g)Mt?{x:f,y:v(n-f)Mt?{x:v(e-p)=e&&l.x<=i&&l.y>=r&&l.y<=a?[[e,a],[i,a],[i,r],[e,r]]:[]).point=t[u]})),n}function u(t){return t.map((function(t,n){return{x:Math.round(r(t,n)/Mt)*Mt,y:Math.round(i(t,n)/Mt)*Mt,i:n}}))}return a.links=function(t){return Ui(u(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 Ui(u(t)).cells.forEach((function(e,r){for(var i,o,a,u,s=e.site,l=e.edges.sort(ki),c=-1,h=l.length,f=l[h-1].edge,p=f.l===s?f.r:f.l;++co||h>a||f=w)<<1|n>=_,M=b+4;bo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,s.push({i:a,x:Wi(e,r)})),o=Gi.lastIndex;return od&&(d=s.x),s.y>y&&(y=s.y),l.push(s.x),c.push(s.y);else for(h=0;hd&&(d=_),w>y&&(y=w),l.push(_),c.push(w)}var b=d-p,M=y-g;function k(t,n,e,r,i,o,a,u){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var s=t.x,l=t.y;if(null!=s)if(v(s-e)+v(l-r)<.01)E(t,n,e,r,i,o,a,u);else{var c=t.point;t.x=t.y=t.point=null,E(t,c,s,l,i,o,a,u),E(t,n,e,r,i,o,a,u)}else t.x=e,t.y=r,t.point=n}else E(t,n,e,r,i,o,a,u)}function E(t,n,e,r,i,o,a,u){var s=.5*(i+a),l=.5*(o+u),c=e>=s,h=r>=l,f=h<<1|c;t.leaf=!1,c?i=s:a=s,h?o=l:u=l,k(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,u)}b>M?y=g+b:d=p+M;var S={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(S,t,+m(t,++h),+x(t,h),p,g,d,y)},visit:function(t){Vi(t,S,p,g,d,y)},find:function(t){return Bi(S,t[0],t[1],p,g,d,y)}};if(h=-1,null==n){for(;++h=0&&!(r=t.interpolators[i](n,e)););return r}function Ji(t,n){var e,r=[],i=[],o=t.length,a=n.length,u=Math.min(t.length,n.length);for(e=0;e=1?1:t(n)}}function ro(t){return function(n){return 1-t(1-n)}}function io(t){return function(n){return.5*(n<.5?t(2*n):2-t(2-2*n))}}function oo(t){return t*t}function ao(t){return t*t*t}function uo(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 so(t){return 1-Math.cos(t*Ct)}function lo(t){return Math.pow(2,10*(t-1))}function co(t){return 1-Math.sqrt(1-t*t)}function ho(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 fo(t,n){return n-=t,function(e){return Math.round(t+n*e)}}function po(t){var n,e,r,i=[t.a,t.b],o=[t.c,t.d],a=yo(i),u=go(i,o),s=yo(((n=o)[0]+=(r=-u)*(e=i)[0],n[1]+=r*e[1],n))||0;i[0]*o[1]=0?t.slice(0,e):t,i=e>=0?t.slice(e+1):"in";return r=to.get(r)||Ki,eo((i=no.get(i)||N)(r.apply(null,n.call(arguments,1))))},t.interpolateHcl=function(n,e){n=t.hcl(n),e=t.hcl(e);var r=n.h,i=n.c,o=n.l,a=e.h-r,u=e.c-i,s=e.l-o;return isNaN(u)&&(u=0,i=isNaN(i)?e.c:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Wt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateHsl=function(n,e){n=t.hsl(n),e=t.hsl(e);var r=n.h,i=n.s,o=n.l,a=e.h-r,u=e.s-i,s=e.l-o;return isNaN(u)&&(u=0,i=isNaN(i)?e.s:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Bt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateLab=function(n,e){n=t.lab(n),e=t.lab(e);var r=n.l,i=n.a,o=n.b,a=e.l-r,u=e.a-i,s=e.b-o;return function(t){return Qt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateRound=fo,t.transform=function(n){var e=r.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new po(n?n.matrix:vo)})(n)},po.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var vo={a:1,b:0,c:0,d:1,e:0,f:0};function mo(t){return t.length?t.pop()+",":""}function xo(n,e){var r=[],i=[];return n=t.transform(n),e=t.transform(e),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:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else(n[0]||n[1])&&e.push("translate("+n+")")}(n.translate,e.translate,r,i),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:Wi(t,n)})):n&&e.push(mo(e)+"rotate("+n+")")}(n.rotate,e.rotate,r,i),function(t,n,e,r){t!==n?r.push({i:e.push(mo(e)+"skewX(",null,")")-2,x:Wi(t,n)}):n&&e.push(mo(e)+"skewX("+n+")")}(n.skew,e.skew,r,i),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:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else 1===n[0]&&1===n[1]||e.push(mo(e)+"scale("+n+")")}(n.scale,e.scale,r,i),n=e=null,function(t){for(var n,e=-1,o=i.length;++e0?r=t:(n.c=null,n.t=NaN,n=null,s.end({type:"end",alpha:r=0})):t>0&&(s.start({type:"start",alpha:r=t}),n=bn(u.tick)),u):r},u.start=function(){var t,n,e,r=v.length,s=m.length,c=l[0],g=l[1];for(t=0;t=0;)e.push(i[r])}function zo(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(c=l[s]),c.parent=o,c.depth=o.depth+1;e&&(o.value=0),o.children=l}else e&&(o.value=+e.call(r,o,o.depth)||0),delete o.children;return zo(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),u}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&&(Lo(t,(function(t){t.children&&(t.value=0)})),zo(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},t.layout.partition=function(){var n=t.layout.hierarchy(),e=[1,1];function r(t,r){var i=n.call(this,t,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,u,s,l=-1;for(r=n.value?r/n.value:0;++lu&&(u=r),a.push(r)}for(e=0;ei&&(r=e,i=n);return r}function Wo(t){return t.reduce(Zo,0)}function Zo(t,n){return t+n[1]}function Xo(t,n){return Go(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function Go(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 Qo(n){return[t.min(n),t.max(n)]}function Jo(t,n){return t.value-n.value}function Ko(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function ta(t,n){t._pack_next=n,n._pack_prev=t}function na(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 ea(t){if((n=t.children)&&(s=n.length)){var n,e,r,i,o,a,u,s,l=1/0,c=-1/0,h=1/0,f=-1/0;if(n.forEach(ra),(e=n[0]).x=-e.r,e.y=0,x(e),s>1&&((r=n[1]).x=r.r,r.y=0,x(r),s>2))for(oa(e,r,i=n[2]),x(i),Ko(e,i),e._pack_prev=i,Ko(i,r),r=e._pack_next,o=3;o0)for(a=-1;++a=h[0]&&s<=h[1]&&((u=l[t.bisect(f,s,1,g)-1]).y+=d,u.push(o[a]));return l}return o.value=function(t){return arguments.length?(e=t,o):e},o.range=function(t){return arguments.length?(r=gn(t),o):r},o.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return Go(n,t)}:gn(t),o):i},o.frequency=function(t){return arguments.length?(n=!!t,o):n},o},t.layout.pack=function(){var n,e=t.layout.hierarchy().sort(Jo),r=0,i=[1,1];function o(t,o){var a=e.call(this,t,o),u=a[0],s=i[0],l=i[1],c=null==n?Math.sqrt:"function"==typeof n?n:function(){return n};if(u.x=u.y=0,zo(u,(function(t){t.r=+c(t.value)})),zo(u,ea),r){var h=r*(n?1:Math.max(2*u.r/s,2*u.r/l))/2;zo(u,(function(t){t.r+=h})),zo(u,ea),zo(u,(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,u=o.length;++ap.x&&(p=t),t.depth>g.depth&&(g=t)}));var d=e(f,p)/2-f.x,y=r[0]/(p.x+e(p,f)/2+d),v=r[1]/(g.depth||1);Lo(c,(function(t){t.x=(t.x+d)*y,t.y=t.depth*v}))}return l}function a(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n.length){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(t);var o=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+e(t._,i._));t.parent.A=function(t,n,r){if(n){for(var i,o=t,a=t,u=n,s=o.parent.children[0],l=o.m,c=a.m,h=u.m,f=s.m;u=sa(u),o=ua(o),u&&o;)s=ua(s),(a=sa(a)).a=t,(i=u.z+h-o.z-l+e(u._,o._))>0&&(la(ca(u,t,r),t,i),l+=i,c+=i),h+=u.m,l+=o.m,f+=s.m,c+=a.m;u&&!sa(a)&&(a.t=u,a.m+=h-c),o&&!ua(s)&&(s.t=o,s.m+=l-f,r=t)}return r}(t,i,t.parent.A||r[0])}function u(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=r[0],t.y=t.depth*r[1]}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t)?s:null,o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:s,o):i?r:null},Fo(o,n)},t.layout.cluster=function(){var n=t.layout.hierarchy().sort(null).value(null),e=aa,r=[1,1],i=!1;function o(o,a){var u,s=n.call(this,o,a),l=s[0],c=0;zo(l,(function(n){var r=n.children;r&&r.length?(n.x=function(t){return t.reduce((function(t,n){return t+n.x}),0)/t.length}(r),n.y=function(n){return 1+t.max(n,(function(t){return t.y}))}(r)):(n.x=u?c+=e(n,u):0,n.y=0,u=n)}));var h=function t(n){var e=n.children;return e&&e.length?t(e[0]):n}(l),f=function t(n){var e,r=n.children;return r&&(e=r.length)?t(r[e-1]):n}(l),p=h.x-e(h,f)/2,g=f.x+e(f,h)/2;return zo(l,i?function(t){t.x=(t.x-l.x)*r[0],t.y=(l.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(g-p)*r[0],t.y=(1-(l.y?t.y/l.y:1))*r[1]}),s}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t),o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null!=(r=t),o):i?r:null},Fo(o,n)},t.layout.treemap=function(){var n,e=t.layout.hierarchy(),r=Math.round,i=[1,1],o=null,a=ha,u=!1,s="squarify",l=.5*(1+Math.sqrt(5));function c(t,n){for(var e,r,i=-1,o=t.length;++i0;)u.push(e=l[i-1]),u.area+=e.area,"squarify"!==s||(r=p(u,d))<=f?(l.pop(),f=r):(u.area-=u.pop().area,g(u,d,o,!1),d=Math.min(o.dx,o.dy),u.length=u.area=0,f=1/0);u.length&&(g(u,d,o,!0),u.length=u.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(c(i,r.dx*r.dy/t.value),o.area=0;e=i.pop();)o.push(e),o.area+=e.area,null!=e.z&&(g(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,u=t.length;++ai&&(i=e));return n*=n,(r*=r)?Math.max(n*i*l/r,r/(n*o*l)):1/0}function g(t,n,e,i){var o,a=-1,u=t.length,s=e.x,l=e.y,c=n?r(t.area/n):0;if(n==e.dx){for((i||c>e.dy)&&(c=e.dy);++ae.dx)&&(c=e.dx);++a1);return t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=t.random.normal.apply(t,arguments);return function(){return Math.exp(n())}},bates:function(n){var e=t.random.irwinHall(n);return function(){return e()/n}},irwinHall:function(t){return function(){for(var n=0,e=0;e2?xa:da,u=i?wo:_o;return o=t(n,e,u,r),a=t(e,n,u,Qi),s}function s(t){return o(t)}return s.invert=function(t){return a(t)},s.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},s.range=function(t){return arguments.length?(e=t,u()):e},s.rangeRound=function(t){return s.range(t).interpolate(fo)},s.clamp=function(t){return arguments.length?(i=t,u()):i},s.interpolate=function(t){return arguments.length?(r=t,u()):r},s.ticks=function(t){return Ma(n,t)},s.tickFormat=function(t,e){return ka(n,t,e)},s.nice=function(t){return wa(n,t),u()},s.copy=function(){return t(n,e,r,i)},u()}([0,1],[0,1],Qi,!1)};var Ea={s:1,g:1,p:1,r:1,e:1};function Sa(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function n(e,r,i,o){function a(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function u(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function s(t){return e(a(t))}return s.invert=function(t){return u(e.invert(t))},s.domain=function(t){return arguments.length?(i=t[0]>=0,e.domain((o=t.map(Number)).map(a)),s):o},s.base=function(t){return arguments.length?(r=+t,e.domain(o.map(a)),s):r},s.nice=function(){var t=ya(o.map(a),i?Math:Ca);return e.domain(t),o=t.map(u),s},s.ticks=function(){var t=pa(o),n=[],e=t[0],s=t[1],l=Math.floor(a(e)),c=Math.ceil(a(s)),h=r%1?2:r;if(isFinite(c-l)){if(i){for(;l0;f--)n.push(u(l)*f);for(l=0;n[l]s;c--);n=n.slice(l,c)}return n},s.tickFormat=function(n,e){if(!arguments.length)return Aa;arguments.length<2?e=Aa:"function"!=typeof e&&(e=t.format(e));var i=Math.max(1,r*n/s.ticks().length);return function(t){var n=t/u(Math.round(a(t)));return n*r0?i[t-1]:e[0],th?0:1;if(l=At)return s(l,p)+(u?s(u,1-p):"")+"Z";var g,d,y,v,m,x,_,w,b,M,k,E,S=0,A=0,C=[];if((v=(+a.apply(this,arguments)||0)/2)&&(y=r===Ra?Math.sqrt(u*u+l*l):+r.apply(this,arguments),p||(A*=-1),l&&(A=Dt(y/l*Math.sin(v))),u&&(S=Dt(y/u*Math.sin(v)))),l){m=l*Math.cos(c+A),x=l*Math.sin(c+A),_=l*Math.cos(h-A),w=l*Math.sin(h-A);var N=Math.abs(h-c-2*A)<=Et?0:1;if(A&&Ha(m,x,_,w)===p^N){var T=(c+h)/2;m=l*Math.cos(T),x=l*Math.sin(T),_=w=null}}else m=x=0;if(u){b=u*Math.cos(h-S),M=u*Math.sin(h-S),k=u*Math.cos(c+S),E=u*Math.sin(c+S);var F=Math.abs(c-h+2*S)<=Et?0:1;if(S&&Ha(b,M,k,E)===1-p^F){var L=(c+h)/2;b=u*Math.cos(L),M=u*Math.sin(L),k=E=null}}else b=M=0;if(f>Mt&&(g=Math.min(Math.abs(l-u)/2,+e.apply(this,arguments)))>.001){d=u0?0:1}function ja(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],u=(i?r:-r)/Math.sqrt(o*o+a*a),s=u*a,l=-u*o,c=t[0]+s,h=t[1]+l,f=n[0]+s,p=n[1]+l,g=(c+f)/2,d=(h+p)/2,y=f-c,v=p-h,m=y*y+v*v,x=e-r,_=c*p-f*h,w=(v<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-_*_)),b=(_*v-y*w)/m,M=(-_*y-v*w)/m,k=(_*v+y*w)/m,E=(-_*y+v*w)/m,S=b-g,A=M-d,C=k-g,N=E-d;return S*S+A*A>C*C+N*N&&(b=k,M=E),[[b-s,M-l],[b*e/x,M*e/x]]}function Va(t){var n=ni,e=ei,r=Ye,i=$a,o=i.key,a=.7;function u(o){var u,s=[],l=[],c=-1,h=o.length,f=gn(n),p=gn(e);function g(){s.push("M",i(t(l),a))}for(;++c1&&i.push("H",r[0]),i.join("")},"step-before":Wa,"step-after":Za,basis:Qa,"basis-open":function(t){if(t.length<4)return $a(t);for(var n,e=[],r=-1,i=t.length,o=[0],a=[0];++r<3;)n=t[r],o.push(n[0]),a.push(n[1]);for(e.push(Ja(nu,o)+","+Ja(nu,a)),--r;++r9&&(i=3*n/Math.sqrt(i),a[u]=i*e,a[u+1]=i*r);for(u=-1;++u<=s;)i=(t[Math.min(s,u+1)][0]-t[Math.max(0,u-1)][0])/(6*(1+a[u]*a[u])),o.push([i||0,a[u]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function Ya(t){return t.join("L")+"Z"}function Wa(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n1){u=n[1],o=t[s],s++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-u[0])+","+(o[1]-u[1])+","+o[0]+","+o[1];for(var l=2;lEt)+",1 "+n}function s(t,n,e,r){return"Q 0,0 "+r}return o.radius=function(t){return arguments.length?(e=gn(t),o):e},o.source=function(n){return arguments.length?(t=gn(n),o):t},o.target=function(t){return arguments.length?(n=gn(t),o):n},o.startAngle=function(t){return arguments.length?(r=gn(t),o):r},o.endAngle=function(t){return arguments.length?(i=gn(t),o):i},o},t.svg.diagonal=function(){var t=Hr,n=jr,e=uu;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),u=(o.y+a.y)/2,s=[o,{x:o.x,y:u},{x:a.x,y:u},a];return"M"+(s=s.map(e))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return r.source=function(n){return arguments.length?(t=gn(n),r):t},r.target=function(t){return arguments.length?(n=gn(t),r):n},r.projection=function(t){return arguments.length?(e=t,r):e},r},t.svg.diagonal.radial=function(){var n=t.svg.diagonal(),e=uu,r=n.projection;return n.projection=function(t){return arguments.length?r(su(e=t)):e},n},t.svg.symbol=function(){var t=cu,n=lu;function e(e,r){return(fu.get(t.call(this,e,r))||hu)(n.call(this,e,r))}return e.type=function(n){return arguments.length?(t=gn(n),e):t},e.size=function(t){return arguments.length?(n=gn(t),e):n},e};var fu=t.map({circle:hu,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*gu)),e=n*gu;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/pu),e=n*pu/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/pu),e=n*pu/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});t.svg.symbolTypes=fu.keys();var pu=Math.sqrt(3),gu=Math.tan(30*Nt);$.transition=function(t){for(var n,e,r=mu||++wu,i=ku(t),o=[],a=xu||{time:Date.now(),ease:uo,delay:0,duration:250},u=-1,s=this.length;++u0;)l[--f].call(t,a);if(o>=1)return h.event&&h.event.end.call(t,t.__data__,n),--c.count?delete c[r]:delete t[e],1}h||(o=i.time,a=bn((function(t){var n=h.delay;if(a.t=n+o,n<=t)return f(t-n);a.c=f}),0,o),h=c[r]={tween:new _,time:o,timer:a,delay:i.delay,duration:i.duration,ease:i.ease,index:n},i=null,++c.count)}_u.call=$.call,_u.empty=$.empty,_u.node=$.node,_u.size=$.size,t.transition=function(n,e){return n&&n.transition?mu?n.transition(e):n:t.selection().transition(n)},t.transition.prototype=_u,_u.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=Y(t);for(var u=-1,s=this.length;++urect,.s>rect").attr("width",u[1]-u[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 y(){var h,y,v=this,m=t.select(t.event.target),x=r.of(v,arguments),_=t.select(v),w=m.datum(),b=!/^(n|s)$/.test(w)&&i,M=!/^(e|w)$/.test(w)&&a,k=m.classed("extent"),E=xt(v),S=t.mouse(v),A=t.select(o(v)).on("keydown.brush",T).on("keyup.brush",F);if(t.event.changedTouches?A.on("touchmove.brush",L).on("touchend.brush",D):A.on("mousemove.brush",L).on("mouseup.brush",D),_.interrupt().selectAll("*").interrupt(),k)S[0]=u[0]-S[0],S[1]=s[0]-S[1];else if(w){var C=+/w$/.test(w),N=+/^n/.test(w);y=[u[1-C]-S[0],s[1-N]-S[1]],S[0]=u[C],S[1]=s[N]}else t.event.altKey&&(h=S.slice());function T(){32==t.event.keyCode&&(k||(h=null,S[0]-=u[1],S[1]-=s[1],k=2),P())}function F(){32==t.event.keyCode&&2==k&&(S[0]+=u[1],S[1]+=s[1],k=0,P())}function L(){var n=t.mouse(v),e=!1;y&&(n[0]+=y[0],n[1]+=y[1]),k||(t.event.altKey?(h||(h=[(u[0]+u[1])/2,(s[0]+s[1])/2]),S[0]=u[+(n[0]1?{floor:function(n){for(;u(n=t.floor(n));)n=qu(n-1);return n},ceil:function(n){for(;u(n=t.ceil(n));)n=qu(+n+1);return n}}:t))},i.ticks=function(t,n){var e=pa(i.domain()),r=null==t?o(e,10):"number"==typeof t?o(e,t):!t.range&&[{range:t},n];return r&&(t=r[0],n=r[1]),t.range(e[0],qu(+e[1]+1),n<1?1:n)},i.tickFormat=function(){return r},i.copy=function(){return Pu(n.copy(),e,r)},_a(i,n)}function qu(t){return new Date(t)}Lu.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ru:Du,Ru.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Ru.toString=Du.toString,Ln.second=Pn((function(t){return new zn(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),Ln.seconds=Ln.second.range,Ln.seconds.utc=Ln.second.utc.range,Ln.minute=Pn((function(t){return new zn(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),Ln.minutes=Ln.minute.range,Ln.minutes.utc=Ln.minute.utc.range,Ln.hour=Pn((function(t){var n=t.getTimezoneOffset()/60;return new zn(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),Ln.hours=Ln.hour.range,Ln.hours.utc=Ln.hour.utc.range,Ln.month=Pn((function(t){return(t=Ln.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),Ln.months=Ln.month.range,Ln.months.utc=Ln.month.utc.range;var Uu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ou=[[Ln.second,1],[Ln.second,5],[Ln.second,15],[Ln.second,30],[Ln.minute,1],[Ln.minute,5],[Ln.minute,15],[Ln.minute,30],[Ln.hour,1],[Ln.hour,3],[Ln.hour,6],[Ln.hour,12],[Ln.day,1],[Ln.day,2],[Ln.week,1],[Ln.month,1],[Ln.month,3],[Ln.year,1]],Iu=Lu.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",Ye]]),Hu={range:function(n,e,r){return t.range(Math.ceil(n/r)*r,+e,r).map(qu)},floor:N,ceil:N};Ou.year=Ln.year,Ln.scale=function(){return Pu(t.scale.linear(),Ou,Iu)};var ju=Ou.map((function(t){return[t[0].utc,t[1]]})),Vu=zu.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",Ye]]);function Bu(t){return JSON.parse(t.responseText)}function $u(t){var n=r.createRange();return n.selectNode(r.body),n.createContextualFragment(t.responseText)}ju.year=Ln.year.utc,Ln.scale.utc=function(){return Pu(t.scale.linear(),ju,Vu)},t.text=dn((function(t){return t.responseText})),t.json=function(t,n){return yn(t,"application/json",Bu,n)},t.html=function(t,n){return yn(t,"text/html",$u,n)},t.xml=dn((function(t){return t.responseXML})),"function"==typeof define&&define.amd?(this.d3=t,define(t)):"object"==typeof module&&module.exports?module.exports=t:this.d3=t}(),null==window.Epoch&&(window.Epoch={}),null==(c=window.Epoch).Chart&&(c.Chart={}),null==(t=window.Epoch).Time&&(t.Time={}),null==(n=window.Epoch).Util&&(n.Util={}),null==(e=window.Epoch).Formats&&(e.Formats={}),Epoch.warn=function(t){return(console.warn||console.log)("Epoch Warning: "+t)},Epoch.exception=function(t){throw"Epoch Error: "+t},Epoch.TestContext=function(){var t;function n(){var n,e,r;for(this._log=[],n=0,e=t.length;n0},Epoch.Util.copy=function(t){var n,e,r;if(null==t)return null;for(e in n={},t)a.call(t,e)&&(r=t[e],n[e]=r);return n},Epoch.Util.defaults=function(t,n){var e,r,i,o,u;for(i in u=Epoch.Util.copy(t),n)a.call(n,i)&&(n[i],o=t[i],r=n[i],e=Epoch.isObject(o)&&Epoch.isObject(r),null!=o&&null!=r?e&&!Epoch.isArray(o)?u[i]=Epoch.Util.defaults(o,r):u[i]=o:u[i]=null!=o?o:r);return u},Epoch.Util.formatSI=function(t,n,e){var r,i,o,u,s;if(null==n&&(n=1),null==e&&(e=!1),t<1e3)return((0|(u=t))!==u||e)&&(u=u.toFixed(n)),u;for(i in s=["K","M","G","T","P","E","Z","Y"])if(a.call(s,i)&&(o=s[i],t>=(r=Math.pow(10,3*(1+(0|i))))&&t=(r=Math.pow(1024,1+(0|i)))&&t=0;)r.push(this._events[t].splice(e,1));return r}},t.prototype.offAll=function(t){var n,e,r,i,o,u;if(Epoch.isArray(t)){for(o=[],e=0,r=t.length;en;i=1<=n?++t:--t)e.push(arguments[i]);return e}.apply(this,arguments),s=[],o=0,a=(u=this._events[t]).length;o=this.data.length||(i=this.data[e]));return i},r.prototype.showLayer=function(t){var n;if((n=this._findLayer(t))&&!n.visible)return n.visible=!0,this.trigger("layer:shown")},r.prototype.hideLayer=function(t){var n;if((n=this._findLayer(t))&&n.visible)return n.visible=!1,this.trigger("layer:hidden")},r.prototype.toggleLayer=function(t){var n;if(n=this._findLayer(t))return n.visible=!n.visible,n.visible?this.trigger("layer:shown"):this.trigger("layer:hidden")},r.prototype.isLayerVisible=function(t){var n;return(n=this._findLayer(t))?n.visible:null},r.prototype.getVisibleLayers=function(){return this.data.filter((function(t){return t.visible}))},r.prototype.update=function(t,n){if(null==n&&(n=!0),this.setData(t),n)return this.draw()},r.prototype.draw=function(){return this.trigger("draw")},r.prototype._getScaleDomain=function(t){var n,e,r,i;return Array.isArray(t)?t:Epoch.isString(t)&&null!=(n=this.getVisibleLayers().filter((function(n){return n.range===t})).map((function(t){return t.values})))&&n.length?(r=function(t,n){return nt?n:t},[(i=Epoch.Util.flatten(n).map((function(t){return t.y}))).reduce(r,i[0]),i.reduce(e,i[0])]):Array.isArray(this.options.range)?this.options.range:this.options.range&&Array.isArray(this.options.range.left)?this.options.range.left:this.options.range&&Array.isArray(this.options.range.right)?this.options.range.right:this.extent((function(t){return t.y}))},r.prototype.extent=function(t){return[d3.min(this.getVisibleLayers(),(function(n){return d3.min(n.values,t)})),d3.max(this.getVisibleLayers(),(function(n){return d3.max(n.values,t)}))]},r.prototype.dimensionsChanged=function(){return this.width=this.option("width")||this.width,this.height=this.option("height")||this.height,this.el.width(this.width),this.el.height(this.height)},r.prototype.layerChanged=function(){return this.draw()},r}(Epoch.Events),Epoch.Chart.SVG=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.el?this.svg=this.el.append("svg"):this.svg=d3.select(document.createElement("svg")),this.svg.attr({xmlns:"http://www.w3.org/2000/svg",width:this.width,height:this.height})}return s(n,t),n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.svg.attr("width",this.width).attr("height",this.height)},n}(Epoch.Chart.Base),Epoch.Chart.Canvas=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.options.pixelRatio?this.pixelRatio=this.options.pixelRatio:null!=window.devicePixelRatio?this.pixelRatio=window.devicePixelRatio:this.pixelRatio=1,this.canvas=d3.select(document.createElement("CANVAS")),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()}),null!=this.el&&this.el.node().appendChild(this.canvas.node()),this.ctx=Epoch.Util.getContext(this.canvas.node())}return s(n,t),n.prototype.getWidth=function(){return this.width*this.pixelRatio},n.prototype.getHeight=function(){return this.height*this.pixelRatio},n.prototype.clear=function(){return this.ctx.clearRect(0,0,this.getWidth(),this.getHeight())},n.prototype.getStyles=function(t){return Epoch.QueryCSS.getStyles(t,this.el)},n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()})},n.prototype.redraw=function(){return Epoch.QueryCSS.purge(),this.draw()},n}(Epoch.Chart.Base),u=function(){var t,n,e,r,i;function o(){}return n=0,r=function(){return"epoch-container-"+n++},t=/^([^#. ]+)?(#[^. ]+)?(\.[^# ]+)?$/,e=!1,i=function(n){var e,r,i,o,a;return null==(o=n.match(t))?Epoch.error("Query CSS cannot match given selector: "+n):(o[0],a=o[1],i=o[2],e=o[3],a=(null!=a?a:"div").toUpperCase(),r=document.createElement(a),null!=i&&(r.id=i.substr(1)),null!=e&&(r.className=e.substr(1).replace(/\./g," ")),r)},o.log=function(t){return e=t},o.cache={},o.styleList=["fill","stroke","stroke-width"],o.container=null,o.purge=function(){return o.cache={}},o.getContainer=function(){var t;return null!=o.container?o.container:((t=document.createElement("DIV")).id="_canvas_css_reference",document.body.appendChild(t),o.container=d3.select(t))},o.hash=function(t,n){var e;return null==(e=n.attr("data-epoch-container-id"))&&(e=r(),n.attr("data-epoch-container-id",e)),e+"__"+t},o.getStyles=function(t,n){var r,a,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E,S;if(a=o.hash(t,n),null!=(r=o.cache[a]))return r;for(m=[],v=n.node().parentNode;null!=v&&"body"!==v.nodeName.toLowerCase();)m.unshift(v),v=v.parentNode;for(m.push(n.node()),k=[],l=0,f=m.length;l0&&(M+="#"+s.id),null!=s.className&&s.className.length>0&&(M+="."+Epoch.Util.trim(s.className).replace(/\s+/g,".")),k.push(M);for(k.push("svg"),c=0,p=(_=Epoch.Util.trim(t).split(/\s+/)).length;ce)t.label=u[e];else if(o&&r.length>e)t.label=r[e];else if(i){for(a=[];e>=0;)a.push(String.fromCharCode(65+e%26)),e-=26;t.label=a.join("")}return t},Epoch.Data.Format.array=(f={x:function(t,n){return n},y:function(t,n){return t},time:function(t,n,e){return parseInt(e)+parseInt(n)},type:"area",autoLabels:!1,labels:[],startTime:parseInt((new Date).getTime()/1e3)},h=function(t,n,e){var r,i,o;if(i=[],Epoch.isArray(t[0]))for(r in t)a.call(t,r)&&(o=t[r],i.push(l({values:o.map(e)},n,parseInt(r))));else i.push(l({values:t.map(e)},n,0));return i},g=function(t,n){return h(t,n,(function(t,e){return{x:n.x(t,e),y:n.y(t,e)}}))},v=function(t,n){return h(t,n,(function(t,e){return{time:n.time(t,e,n.startTime),y:n.y(t,e)}}))},d=function(t,n){return h(t,n,(function(t,e){return{time:n.time(t,e,n.startTime),histogram:t}}))},y=function(t,n){var e,r,i;for(e in r=[],t)if(a.call(t,e)){if(i=t[e],!Epoch.isNumber(t[0]))return[];r.push(l({value:i},n,e))}return r},(p=function(t,n){var e;return null==t&&(t=[]),null==n&&(n={}),Epoch.isNonEmptyArray(t)?"time.heatmap"===(e=Epoch.Util.defaults(n,f)).type?d(t,e):e.type.match(/^time\./)?v(t,e):"pie"===e.type?y(t,e):g(t,e):[]}).entry=function(t,n){var e,r,i,o,a,u,s,l;if(null==n&&(n={}),"time.gauge"===n.type)return null==t?0:(u=Epoch.Util.defaults(n,f),e=Epoch.isArray(t)?t[0]:t,u.y(e,0));if(null==t)return[];for(null==n.startTime&&(n.startTime=parseInt((new Date).getTime()/1e3)),r=Epoch.isArray(t)?t.map((function(t){return[t]})):[t],l=[],i=0,a=(s=p(r,n)).length;i-1},i.prototype.innerWidth=function(){return this.width-(this.margins.left+this.margins.right)},i.prototype.innerHeight=function(){return this.height-(this.margins.top+this.margins.bottom)},i.prototype.x=function(){var t,n;return t=null!=(n=this.options.domain)?n:this.extent((function(t){return t.x})),d3.scale.linear().domain(t).range([0,this.innerWidth()])},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.bottomAxis=function(){return d3.svg.axis().scale(this.x()).orient("bottom").ticks(this.options.ticks.bottom).tickFormat(this.options.tickFormats.bottom)},i.prototype.topAxis=function(){return d3.svg.axis().scale(this.x()).orient("top").ticks(this.options.ticks.top).tickFormat(this.options.tickFormats.top)},i.prototype.leftAxis=function(){var t;return t=this.options.range?this.options.range.left:null,d3.svg.axis().scale(this.y(t)).orient("left").ticks(this.options.ticks.left).tickFormat(this.options.tickFormats.left)},i.prototype.rightAxis=function(){var t;return t=this.options.range?this.options.range.right:null,d3.svg.axis().scale(this.y(t)).orient("right").ticks(this.options.ticks.right).tickFormat(this.options.tickFormats.right)},i.prototype.draw=function(){return this._axesDrawn?this._redrawAxes():this._drawAxes(),i.__super__.draw.call(this)},i.prototype._redrawAxes=function(){if(this.hasAxis("bottom")&&this.g.selectAll(".x.axis.bottom").transition().duration(500).ease("linear").call(this.bottomAxis()),this.hasAxis("top")&&this.g.selectAll(".x.axis.top").transition().duration(500).ease("linear").call(this.topAxis()),this.hasAxis("left")&&this.g.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.g.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._drawAxes=function(){return this.hasAxis("bottom")&&this.g.append("g").attr("class","x axis bottom").attr("transform","translate(0, "+this.innerHeight()+")").call(this.bottomAxis()),this.hasAxis("top")&&this.g.append("g").attr("class","x axis top").call(this.topAxis()),this.hasAxis("left")&&this.g.append("g").attr("class","y axis left").call(this.leftAxis()),this.hasAxis("right")&&this.g.append("g").attr("class","y axis right").attr("transform","translate("+this.innerWidth()+", 0)").call(this.rightAxis()),this._axesDrawn=!0},i.prototype.dimensionsChanged=function(){return i.__super__.dimensionsChanged.call(this),this.g.selectAll(".axis").remove(),this._axesDrawn=!1,this.draw()},i.prototype.marginsChanged=function(){var t,n,e;if(null!=this.options.margins){for(t in n=this.options.margins)a.call(n,t)&&(e=n[t],this.margins[t]=null==e?6:e);return this.g.transition().duration(750).attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.draw()}},i.prototype.axesChanged=function(){var t,e,r,i;for(t=0,e=(i=["top","right","bottom","left"]).length;t0?tn;e=t+=o)a.push(this.data[0].values[e].x);return a}.call(this))},o.prototype.bottomAxis=function(){var t;return t=d3.svg.axis().scale(this.x()).orient("bottom").ticks(this.options.ticks.bottom).tickFormat(this.options.tickFormats.bottom),this._isVertical()&&null!=this.options.ticks.bottom&&t.tickValues(this._getTickValues(this.options.ticks.bottom)),t},o.prototype.topAxis=function(){var t;return t=d3.svg.axis().scale(this.x()).orient("top").ticks(this.options.ticks.top).tickFormat(this.options.tickFormats.top),this._isVertical()&&null!=this.options.ticks.top&&t.tickValues(this._getTickValues(this.options.ticks.top)),t},o.prototype.leftAxis=function(){var t;return t=d3.svg.axis().scale(this.y()).orient("left").ticks(this.options.ticks.left).tickFormat(this.options.tickFormats.left),this._isHorizontal()&&null!=this.options.ticks.left&&t.tickValues(this._getTickValues(this.options.ticks.left)),t},o.prototype.rightAxis=function(){var t;return t=d3.svg.axis().scale(this.y()).orient("right").ticks(this.options.ticks.right).tickFormat(this.options.tickFormats.right),this._isHorizontal()&&null!=this.options.ticks.right&&t.tickValues(this._getTickValues(this.options.ticks.right)),t},o.prototype.orientationChanged=function(){var t,n,e,r;return r=this.options.tickFormats.top,t=this.options.tickFormats.bottom,n=this.options.tickFormats.left,e=this.options.tickFormats.right,this.options.tickFormats.left=r,this.options.tickFormats.right=t,this.options.tickFormats.top=n,this.options.tickFormats.bottom=e,this.draw()},o.prototype.paddingChanged=function(){return this.draw()},o}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Histogram=function(t){var n,e;function r(t){this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.onAll(e),this.draw()}return s(r,t),n={type:"histogram",domain:[0,100],bucketRange:[0,100],buckets:10,cutOutliers:!1},e={"option:bucketRange":"bucketRangeChanged","option:buckets":"bucketsChanged","option:cutOutliers":"cutOutliersChanged"},r.prototype._prepareData=function(t){var n,e,r,i,o,u,s,l,c,h,f,p,g,d;for(n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,f=[],i=0,l=t.length;in;0<=n?++t:--t)e.push(0);return e}.call(this),u=0,c=(g=s.values).length;u=this.options.buckets)||(r<0?r=0:r>=this.options.buckets&&(r=this.options.buckets-1),e[r]+=parseInt(h.y));for(o in p={values:e.map((function(t,e){return{x:parseInt(e)*n,y:t}}))},s)a.call(s,o)&&(d=s[o],"values"!==o&&(p[o]=d));f.push(p)}return f},r.prototype.resetData=function(){return this.setData(this.rawData),this.draw()},r.prototype.bucketRangeChanged=function(){return this.resetData()},r.prototype.bucketsChanged=function(){return this.resetData()},r.prototype.cutOutliersChanged=function(){return this.resetData()},r}(Epoch.Chart.Bar),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Line=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="line"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype.line=function(t){var n,e,r;return n=[this.x(),this.y(t.range)],e=n[0],r=n[1],d3.svg.line().x((function(t){return e(t.x)})).y((function(t){return r(t.y)}))},n.prototype.draw=function(){var t,e,r;return 0===(this.x(),this.y(),e=this.getVisibleLayers()).length?this.g.selectAll(".layer").remove():((t=this.g.selectAll(".layer").data(e,(function(t){return t.category}))).select(".line").transition().duration(500).attr("d",(r=this,function(t){return r.line(t)(t.values)})),t.enter().append("g").attr("class",(function(t){return t.className})).append("path").attr("class","line").attr("d",function(t){return function(n){return t.line(n)(n.values)}}(this)),t.exit().transition().duration(750).style("opacity","0").remove(),n.__super__.draw.call(this))},n}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Pie=function(t){var n;function e(t){var r;this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.pie=d3.layout.pie().sort(null).value((function(t){return t.value})),this.arc=d3.svg.arc().outerRadius((r=this,function(){return Math.max(r.width,r.height)/2-r.options.margin})).innerRadius(function(t){return function(){return t.options.inner}}(this)),this.g=this.svg.append("g").attr("transform","translate("+this.width/2+", "+this.height/2+")"),this.on("option:margin","marginChanged"),this.on("option:inner","innerChanged"),this.draw()}return s(e,t),n={type:"pie",margin:10,inner:0},e.prototype.draw=function(){var t,n;return this.g.selectAll(".arc").remove(),(t=this.g.selectAll(".arc").data(this.pie(this.getVisibleLayers()),(function(t){return t.data.category}))).enter().append("g").attr("class",(function(t){return"arc pie "+t.data.className})),t.select("path").attr("d",this.arc),t.select("text").attr("transform",(n=this,function(t){return"translate("+n.arc.centroid(t)+")"})).text((function(t){return t.data.label||t.data.category})),t.append("path").attr("d",this.arc).each((function(t){return this._current=t})),t.append("text").attr("transform",function(t){return function(n){return"translate("+t.arc.centroid(n)+")"}}(this)).attr("dy",".35em").style("text-anchor","middle").text((function(t){return t.data.label||t.data.category})),e.__super__.draw.call(this)},e.prototype.marginChanged=function(){return this.draw()},e.prototype.innerChanged=function(){return this.draw()},e}(Epoch.Chart.SVG),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Scatter=function(t){var n;function e(t){this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.on("option:radius","radiusChanged"),this.draw()}return s(e,t),n={type:"scatter",radius:3.5,axes:["top","bottom","left","right"]},e.prototype.draw=function(){var t,n,r,i,o,a,u;return o=[this.x(),this.y(),this.getVisibleLayers()],a=o[0],u=o[1],r=o[2],i=this.options.radius,0===r.length?this.g.selectAll(".layer").remove():((n=this.g.selectAll(".layer").data(r,(function(t){return t.category}))).enter().append("g").attr("class",(function(t){return t.className})),(t=n.selectAll(".dot").data((function(t){return t.values}))).transition().duration(500).attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return u(t.y)})),t.enter().append("circle").attr("class","dot").attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return u(t.y)})),t.exit().transition().duration(750).style("opacity",0).remove(),n.exit().transition().duration(750).style("opacity",0).remove(),e.__super__.draw.call(this))},e.prototype.radiusChanged=function(){return this.draw()},e}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Plot=function(t){var n,e,r;function i(t){var o,a,u,s,l;for(this.options=t,Epoch.Util.copy(this.options.margins),i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this.options.model&&this.options.model.on("data:push",(l=this,function(){return l.pushFromModel()})),this._queue=[],this.margins={},o=0,a=(s=["top","right","bottom","left"]).length;o=0&&n>=0;)this._pushTick(t,r.values[n].time,!1,!0),t-=s,n-=s;break}return u},i.prototype._prepareRangeAxes=function(){if(this.hasAxis("left")&&this.svg.append("g").attr("class","y axis left").attr("transform","translate("+(this.margins.left-1)+", "+this.margins.top+")").call(this.leftAxis()),this.hasAxis("right"))return this.svg.append("g").attr("class","y axis right").attr("transform","translate("+(this.width-this.margins.right)+", "+this.margins.top+")").call(this.rightAxis())},i.prototype.leftAxis=function(){var t,n;return n=this.options.ticks.left,t=d3.svg.axis().scale(this.ySvgLeft()).orient("left").tickFormat(this.options.tickFormats.left),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.rightAxis=function(){var t,n;return this.extent((function(t){return t.y})),n=this.options.ticks.right,t=d3.svg.axis().scale(this.ySvgRight()).orient("right").tickFormat(this.options.tickFormats.right),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.hasAxis=function(t){return this.options.axes.indexOf(t)>-1},i.prototype.innerWidth=function(){return(this.width-(this.margins.left+this.margins.right))*this.pixelRatio},i.prototype.innerHeight=function(){return(this.height-(this.margins.top+this.margins.bottom))*this.pixelRatio},i.prototype._prepareEntry=function(t){return t},i.prototype._prepareLayers=function(t){return t},i.prototype._startTransition=function(){if(!0!==this.animation.active&&0!==this._queue.length)return this.trigger("transition:start"),this._shift(),this.animation.active=!0,this.animation.interval=setInterval(this.animationCallback,1e3/this.options.fps)},i.prototype._stopTransition=function(){var t,n,e,r,i,o,a;if(this.inTransition()){for(n=0,i=(o=this.data).length;nthis.options.windowSize+1&&r.values.shift();return t=(a=[this._ticks[0],this._ticks[this._ticks.length-1]])[0],null!=(e=a[1])&&e.enter&&(e.enter=!1,e.opacity=1),null!=t&&t.exit&&this._shiftTick(),this.animation.frame=0,this.trigger("transition:end"),this._queue.length>0?this._shift():(this.animation.active=!1,clearInterval(this.animation.interval))}},i.prototype.inTransition=function(){return this.animation.active},i.prototype.push=function(t){return t=this._prepareLayers(t),this._queue.length>this.options.queueSize&&this._queue.splice(this.options.queueSize,this._queue.length-this.options.queueSize),this._queue.length!==this.options.queueSize&&(this._queue.push(t.map((n=this,function(t){return n._prepareEntry(t)}))),this.trigger("push"),this.inTransition()?void 0:this._startTransition());var n},i.prototype.pushFromModel=function(){return this.push(this.options.model.getNext(this.options.type,this.options.dataFormat))},i.prototype._shift=function(){var t,n,e;for(n in this.trigger("before:shift"),t=this._queue.shift(),e=this.data)a.call(e,n)&&e[n].values.push(t[n]);return this._updateTicks(t[0].time),this._transitionRangeAxes(),this.trigger("after:shift")},i.prototype._transitionRangeAxes=function(){if(this.hasAxis("left")&&this.svg.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.svg.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._animate=function(){if(this.inTransition())return++this.animation.frame===this.animation.duration&&this._stopTransition(),this.draw(this.animation.frame*this.animation.delta()),this._updateTimeAxes()},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.ySvg=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.ySvgLeft=function(){return null!=this.options.range?this.ySvg(this.options.range.left):this.ySvg()},i.prototype.ySvgRight=function(){return null!=this.options.range?this.ySvg(this.options.range.right):this.ySvg()},i.prototype.w=function(){return this.innerWidth()/this.options.windowSize},i.prototype._updateTicks=function(t){if((this.hasAxis("top")||this.hasAxis("bottom"))&&(++this._tickTimer%this.options.ticks.time||this._pushTick(this.options.windowSize,t,!0),this._ticks.length>0))return this._ticks[0].x-this.w()/this.pixelRatio>=0?void 0:this._ticks[0].exit=!0},i.prototype._pushTick=function(t,n,e,r){var i,o;if(null==e&&(e=!1),null==r&&(r=!1),this.hasAxis("top")||this.hasAxis("bottom"))return o={time:n,x:t*(this.w()/this.pixelRatio)+this._offsetX(),opacity:e?0:1,enter:!!e,exit:!1},this.hasAxis("bottom")&&((i=this.bottomAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",6),i.append("text").attr("text-anchor","middle").attr("dy",19).text(this.options.tickFormats.bottom(o.time)),o.bottomEl=i),this.hasAxis("top")&&((i=this.topAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",-6),i.append("text").attr("text-anchor","middle").attr("dy",-10).text(this.options.tickFormats.top(o.time)),o.topEl=i),r?this._ticks.unshift(o):this._ticks.push(o),o},i.prototype._shiftTick=function(){var t;if(this._ticks.length>0)return null!=(t=this._ticks.shift()).topEl&&t.topEl.remove(),null!=t.bottomEl?t.bottomEl.remove():void 0},i.prototype._updateTimeAxes=function(){var t,n,e,r,i,o,a,u;if(this.hasAxis("top")||this.hasAxis("bottom")){for(n=(i=[this.animation.tickDelta(),1/this.options.fps])[0],t=i[1],a=[],e=0,r=(o=this._ticks).length;e0){for(o=[],t=n=0,i=r[0].values.length;0<=i?ni;t=0<=i?++n:--n)a=0,o.push(function(){var n,i,o;for(o=[],i=0,n=r.length;iu;t=0<=u?++e:--e){for(l=0,n=i=0,s=r.length;0<=s?is;n=0<=s?++i:--i)l+=r[n].values[t].y;l>o&&(o=l)}return[0,o]},n.prototype.layerChanged=function(){var t,e,r,i;for(this._stackLayers(),t=0,r=(i=this._queue).length;t=0;i=h<=0?++u:--u)if(s=l[i]){for(this.setStyles(s),this.ctx.beginPath(),o=(f=[this.options.windowSize,s.values.length,this.inTransition()])[0],a=f[1],g=f[2];--o>=-2&&--a>=0;)n=[(o+1)*d+t,y((r=s.values[a]).y+r.y0)],g&&(n[0]+=d),i===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);e=g?(o+3)*d+t:(o+2)*d+t,this.ctx.lineTo(e,this.innerHeight()),this.ctx.lineTo(this.width*this.pixelRatio+d+t,this.innerHeight()),this.ctx.closePath(),p.push(this.ctx.fill())}return p},n.prototype._drawStrokes=function(t){var n,e,r,i,o,a,u,s,l,c,h,f,p,g;for(null==t&&(t=0),g=(s=[this.y(),this.w(),this.getVisibleLayers()])[0],p=s[1],h=[],r=o=l=(u=s[2]).length-1;l<=0?o<=0:o>=0;r=l<=0?++o:--o)if(a=u[r]){for(this.setStyles(a),this.ctx.beginPath(),r=(c=[this.options.windowSize,a.values.length,this.inTransition()])[0],i=c[1],f=c[2];--r>=-2&&--i>=0;)n=[(r+1)*p+t,g((e=a.values[i]).y+e.y0)],f&&(n[0]+=p),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);h.push(this.ctx.stroke())}return h},n.prototype.draw=function(t){return null==t&&(t=0),this.clear(),this._drawAreas(t),this._drawStrokes(t),n.__super__.draw.call(this)},n}(Epoch.Time.Stack),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Bar=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="time.bar"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},n.prototype.setStyles=function(t){var n;if(n=this.getStyles("rect.bar."+t.replace(/\s/g,".")),this.ctx.fillStyle=n.fill,null==n.stroke||"none"===n.stroke?this.ctx.strokeStyle="transparent":this.ctx.strokeStyle=n.stroke,null!=n["stroke-width"])return this.ctx.lineWidth=n["stroke-width"].replace("px","")},n.prototype.draw=function(t){var e,r,i,o,a,u,s,l,c,h,f,p,g,d,y,v,m;for(null==t&&(t=0),this.clear(),m=(f=[this.y(),this.w()])[0],v=f[1],s=0,h=(p=this.getVisibleLayers()).length;s=u&&--l>=0;)i=(d=[a*v+t,(r=c.values[l]).y,r.y0])[0],y&&(i+=v),e=[i+1,m((o=d[1])+d[2]),v-2,this.innerHeight()-m(o)+.5*this.pixelRatio],this.ctx.fillRect.apply(this.ctx,e),this.ctx.strokeRect.apply(this.ctx,e);return n.__super__.draw.call(this)},n}(Epoch.Time.Stack),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Gauge=function(t){var n,e;function r(t){var i;this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.value=this.options.value||0,this.options.model&&this.options.model.on("data:push",(i=this,function(){return i.pushFromModel()})),"absolute"!==this.el.style("position")&&"relative"!==this.el.style("position")&&this.el.style("position","relative"),this.svg=this.el.insert("svg",":first-child").attr("width",this.width).attr("height",this.height).attr("class","gauge-labels"),this.svg.style({position:"absolute","z-index":"1"}),this.svg.append("g").attr("transform","translate("+this.textX()+", "+this.textY()+")").append("text").attr("class","value").text(this.options.format(this.value)),this.animation={interval:null,active:!1,delta:0,target:0},this._animate=function(t){return function(){return Math.abs(t.animation.target-t.value)=c;o=0<=c?++a:--a)t=p(o),y=(n=(h=[Math.cos(t),Math.sin(t)])[0])*(u-g)+e,m=(f=h[1])*(u-g)+i,v=n*(u-g-d)+e,x=f*(u-g-d)+i,this.ctx.moveTo(y,m),this.ctx.lineTo(v,x);return this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.outer"),this.ctx.beginPath(),this.ctx.arc(e,i,u,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.inner"),this.ctx.beginPath(),this.ctx.arc(e,i,u-10,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.drawNeedle(),r.__super__.draw.call(this)},r.prototype.drawNeedle=function(){var t,n,e,r;return t=(r=[this.centerX(),this.centerY(),this.radius()])[0],n=r[1],e=r[2],this.value,this.options.domain[1],this.setStyles(".epoch .gauge .needle"),this.ctx.beginPath(),this.ctx.save(),this.ctx.translate(t,n),this.ctx.rotate(this.getAngle(this.value)),this.ctx.moveTo(4*this.pixelRatio,0),this.ctx.lineTo(-4*this.pixelRatio,0),this.ctx.lineTo(-1*this.pixelRatio,19-e),this.ctx.lineTo(1,19-e),this.ctx.fill(),this.setStyles(".epoch .gauge .needle-base"),this.ctx.beginPath(),this.ctx.arc(0,0,this.getWidth()/25,0,2*Math.PI),this.ctx.fill(),this.ctx.restore()},r.prototype.domainChanged=function(){return this.draw()},r.prototype.ticksChanged=function(){return this.draw()},r.prototype.tickSizeChanged=function(){return this.draw()},r.prototype.tickOffsetChanged=function(){return this.draw()},r.prototype.formatChanged=function(){return this.svg.select("text.value").text(this.options.format(this.value))},r}(Epoch.Chart.Canvas),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Heatmap=function(t){var n,e,r;function i(t){this.options=null!=t?t:{},i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this._setOpacityFunction(),this._setupPaintCanvas(),this.onAll(r),this.draw()}return s(i,t),e={type:"time.heatmap",buckets:10,bucketRange:[0,100],opacity:"linear",bucketPadding:2,paintZeroValues:!1,cutOutliers:!1},n={root:function(t,n){return Math.pow(t/n,.5)},linear:function(t,n){return t/n},quadratic:function(t,n){return Math.pow(t/n,2)},cubic:function(t,n){return Math.pow(t/n,3)},quartic:function(t,n){return Math.pow(t/n,4)},quintic:function(t,n){return Math.pow(t/n,5)}},r={"option:buckets":"bucketsChanged","option:bucketRange":"bucketRangeChanged","option:opacity":"opacityChanged","option:bucketPadding":"bucketPaddingChanged","option:paintZeroValues":"paintZeroValuesChanged","option:cutOutliers":"cutOutliersChanged"},i.prototype._setOpacityFunction=function(){return Epoch.isString(this.options.opacity)?(this._opacityFn=n[this.options.opacity],null==this._opacityFn?Epoch.exception("Unknown coloring function provided '"+this.options.opacity+"'"):void 0):Epoch.isFunction(this.options.opacity)?this._opacityFn=this.options.opacity:Epoch.exception("Unknown type for provided coloring function.")},i.prototype.setData=function(t){var n,e,r,o,a;for(i.__super__.setData.call(this,t),a=[],n=0,r=(o=this.data).length;nn;r=0<=n?++t:--t)e.push(0);return e}.call(this)},n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,s=t.histogram)a.call(s,c)&&(e=s[c],i=parseInt((c-this.options.bucketRange[0])/n),this.options.cutOutliers&&(i<0||i>=this.options.buckets)||(i<0?i=0:i>=this.options.buckets&&(i=this.options.buckets-1),u.buckets[i]+=parseInt(e)));for(r=o=0,l=u.buckets.length;0<=l?ol;r=0<=l?++o:--o)u.max=Math.max(u.max,u.buckets[r]);return u},i.prototype.y=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight(),0])},i.prototype.ySvg=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.h=function(){return this.innerHeight()/this.options.buckets},i.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},i.prototype._setupPaintCanvas=function(){return this.paintWidth=(this.options.windowSize+1)*this.w(),this.paintHeight=this.height*this.pixelRatio,this.paint=document.createElement("CANVAS"),this.paint.width=this.paintWidth,this.paint.height=this.paintHeight,this.p=Epoch.Util.getContext(this.paint),this.redraw(),this.on("after:shift","_paintEntry"),this.on("transition:end","_shiftPaintCanvas"),this.on("transition:end",(t=this,function(){return t.draw(t.animation.frame*t.animation.delta())}));var t},i.prototype.redraw=function(){var t,n;if(Epoch.isNonEmptyArray(this.data)&&Epoch.isNonEmptyArray(this.data[0].values)){for(n=this.data[0].values.length,t=this.options.windowSize,this.inTransition()&&t++;--n>=0&&--t>=0;)this._paintEntry(n,t);return this.draw(this.animation.frame*this.animation.delta())}},i.prototype._computeColor=function(t,n,e){return Epoch.Util.toRGBA(e,this._opacityFn(t,n))},i.prototype._paintEntry=function(t,n){var e,r,i,o,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E;for(null==t&&(t=null),null==n&&(n=null),k=(m=[this.w(),this.h()])[0],l=m[1],null==t&&(t=this.data[0].values.length-1),null==n&&(n=this.options.windowSize),u=[],r=function(){var t,n,e;for(e=[],t=0,n=this.options.buckets;0<=n?tn;0<=n?++t:--t)e.push(0);return e}.call(this),v=0,h=0,p=(x=this.getVisibleLayers()).length;h0||this.options.paintZeroValues)&&(this.p.fillStyle=this._computeColor(M,y,i),this.p.fillRect(E,(c-1)*l,k-this.options.bucketPadding,l-this.options.bucketPadding)),w.push(c--)}return w},i.prototype._shiftPaintCanvas=function(){var t;return t=this.p.getImageData(this.w(),0,this.paintWidth-this.w(),this.paintHeight),this.p.putImageData(t,0,0)},i.prototype._avgLab=function(t,n){var e,r,i,o,u,s,l,c,h,f,p;for(l=(f=[0,0,0,0])[0],e=f[1],r=f[2],p=f[3],s=0,c=t.length;s=-2&&--o>=0;)e=[(r+1)*h+t,f(a.values[o].y)],c&&(e[0]+=h),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,e):this.ctx.lineTo.apply(this.ctx,e);this.ctx.stroke()}return n.__super__.draw.call(this)},n}(Epoch.Time.Plot),Epoch._typeMap={area:Epoch.Chart.Area,bar:Epoch.Chart.Bar,line:Epoch.Chart.Line,pie:Epoch.Chart.Pie,scatter:Epoch.Chart.Scatter,histogram:Epoch.Chart.Histogram,"time.area":Epoch.Time.Area,"time.bar":Epoch.Time.Bar,"time.line":Epoch.Time.Line,"time.gauge":Epoch.Time.Gauge,"time.heatmap":Epoch.Time.Heatmap},m=function(t){return t.fn.epoch=function(t){var n,e;return t.el=this.get(0),null==(n=this.data("epoch-chart"))&&(null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",n=new e(t))),n}},null!=window.jQuery&&m(jQuery),x=function(){return Element.implement("epoch",(function(t){var n,e,r;return null==(n=(r=$$(this)).retrieve("epoch-chart")[0])&&(t.el=this,null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),r.store("epoch-chart",n=new e(t))),n}))},null!=window.MooTools&&x(),_=function(t){var n,e,r;return e={},n=0,r=function(){return"epoch-chart-"+ ++n},t.extend(t.fn,{epoch:function(t){var n,i,o;return null!=(i=this.data("epoch-chart"))?e[i]:(t.el=this.get(0),null==(o=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",i=r()),n=new o(t),e[i]=n,n)}})},null!=window.Zepto&&_(Zepto); \ No newline at end of file +var t,n,e;(function(){var t,n;t=class extends OS.application.BaseService{constructor(t){super("SysmondService",t),this.text=__("{0}%",(0).toString()),this.iconclass="fa fa-android",this.app=void 0,this.onmenuselect=t=>this.openApp()}setting(){return this.systemsetting.applications.SystemControl}init(){var t;return t=()=>{if(Antunnel.tunnel){if(!this.setting().topic)return;return this.tunnel=Antunnel.tunnel,this.sub=new Antunnel.Subscriber(this.setting().topic),this.sub.onopen=()=>console.log("Subscribed to notification channel"),this.sub.onerror=t=>this.error(__("Error: {0}",new TextDecoder("utf-8").decode(t.data)),t),this.sub.onmessage=t=>{var n;return t.data&&(n=JSON.parse(new TextDecoder("utf-8").decode(t.data))),this.text=__("{0}%",Math.round(n.battery_percent).toString()),this.app&&this.app.feed(n),this.update()},this.sub.onclose=()=>(this.sub=void 0,this.notify(__("Unsubscribed to the notification service")),this.quit()),Antunnel.tunnel.subscribe(this.sub)}return this.error(__("The Antunnel service is not started, please start it first")),this._gui.pushService("Antunnel/AntunnelService").catch(t=>this.error(t.toString(),t)),this.quit()},this.setting().topic?t():(console.log("Open dialog"),this._gui.openDialog("PromptDialog",{title:__("Enter topic name"),label:__("Please enter topic name")}).then(n=>(this.setting().topic=n,t())))}openApp(){if(!this.app)return this._gui.launch("SystemControl",[])}execute(t){}awake(){}cleanup(){if(this.app&&this.app.quit(),this.sub)return this.sub.close()}},this.OS.register("SysmondService",t),(n=class extends this.OS.application.BaseApplication{constructor(t){super("SystemControl",t)}main(){return this.diskchart=$(this.find("disk-area")).epoch({type:"time.gauge",value:0}),this.on("resize",()=>{var t;if(t=this.find("cpu-area"),this.cpu&&($(t).children().hide(),this.cpu.option("width",$(t).width()),this.cpu.option("height",$(t).height()),$(t).children().show()),t=this.find("battery-area"),t=this.find("memory-area"),this.memory&&($(t).children().hide(),this.memory.option("width",$(t).width()),this.memory.option("height",$(t).height()),$(t).children().show()),t=this.find("network-area"),this.network&&($(t).children().hide(),this.network.option("width",$(t).width()),this.network.option("height",$(t).height()),$(t).children().show()),t=this.find("temp-area"),this.temp&&($(t).children().hide(),this.temp.option("width",$(t).width()),this.temp.option("height",$(t).height()),$(t).children().show()),t=this.find("battery-area"),this.battery)return $(t).children().hide(),this.battery.option("width",$(t).width()),this.battery.option("height",$(t).height()),$(t).children().show()}),this._gui.pushService("SystemControl/SysmondService",[]).then(t=>(this.service=t,t.app=this)).catch(t=>this.error(__("Unable to start sysmond service"),t))}streamline(t,n,e,r){var i,o,a,u,s,l,c,h,f;if(o=0,l=$(this.find(t+"-text")),!this[t]){for(f={type:"time.line",axes:["bottom","left","right"]},e&&(f.range=e),i=[],u=0,c=n.length;u").addClass("legend-color").addClass("ref").addClass("category"+(o+1)).appendTo(l),$("
").addClass("legend-label").appendTo(l).text(r?r[o]:`${t}-${o}`),$("
").addClass("legend-value").appendTo(l),o+=1;f.data=i,this[t]=$(this.find(t+"-area")).epoch(f)}for(s=0,h=n.length;sm?v:m],this.streamline("memory",s,l,["RAM (GB)","SWAP (GB)"]),h=0,f=0,i=0,a=(g=t.net).length;in?1:t>=n?0:NaN}function f(t){return null===t?NaN:+t}function p(t){return!isNaN(t)}function g(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}}}t.ascending=h,t.descending=function(t,n){return nt?1:n>=t?0:NaN},t.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},t.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},t.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/(s-1)},t.deviation=function(){var n=t.variance.apply(this,arguments);return n?Math.sqrt(n):n};var d=g(h);function y(t){return t.length}t.bisectLeft=d.left,t.bisect=t.bisectRight=d.right,t.bisector=function(t){return g(1===t.length?function(n,e){return h(t(n),e)}:t)},t.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},t.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},t.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 v=Math.abs;function m(t){for(var n=1;t*n%1;)n*=10;return n}function x(t,n){for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}function _(){this._=Object.create(null)}function w(t){return"__proto__"==(t+="")||"\0"===t[0]?"\0"+t:t}function b(t){return"\0"===(t+="")[0]?t.slice(1):t}function M(t){return w(t)in this._}function k(t){return(t=w(t))in this._&&delete this._[t]}function E(){var t=[];for(var n in this._)t.push(b(n));return t}function S(){var t=0;for(var n in this._)++t;return t}function A(){for(var t in this._)return!1;return!0}function C(){this._=Object.create(null)}function N(t){return t}function T(t,n,e){return function(){var r=e.apply(n,arguments);return r===n?t:r}}function F(t,n){if(n in t)return n;n=n.charAt(0).toUpperCase()+n.slice(1);for(var e=0,r=L.length;en;)i.push(r/o);else for(;(r=t+e*++a)=i.length)return e?e.call(r,o):n?o.sort(n):o;for(var s,l,c,h,f=-1,p=o.length,g=i[u++],d=new _;++f=i.length)return n;var r=[],a=o[e++];return n.forEach((function(n,i){r.push({key:n,values:t(i,e)})})),a?r.sort((function(t,n){return a(t.key,n.key)})):r}(a(t.map,n,0),0)},r.key=function(t){return i.push(t),r},r.sortKeys=function(t){return o[i.length-1]=t,r},r.sortValues=function(t){return n=t,r},r.rollup=function(t){return e=t,r},r},t.set=function(t){var n=new C;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}},t.event=null,t.requote=function(t){return t.replace(O,"\\$&")};var O=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,I={}.__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};function H(t){return I(t,$),t}var j=function(t,n){return n.querySelector(t)},V=function(t,n){return n.querySelectorAll(t)},B=function(t,n){var e=t.matches||t[F(t,"matchesSelector")];return(B=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(j=function(t,n){return Sizzle(t,n)[0]||null},V=Sizzle,B=Sizzle.matchesSelector),t.selection=function(){return t.select(r.documentElement)};var $=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return j(t,this)}}function W(t){return"function"==typeof t?t:function(){return V(t,this)}}$.select=function(t){var n,e,r,i,o=[];t=Y(t);for(var a=-1,u=this.length;++a=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),X.hasOwnProperty(e)?{space:X[e],local:t}:t}},$.attr=function(n,e){if(arguments.length<2){if("string"==typeof n){var r=this.node();return(n=t.ns.qualify(n)).local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}for(e in n)this.each(G(e,n[e]));return this}return this.each(G(n,e))},$.classed=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node(),r=(t=K(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},$.sort=function(t){t=st.apply(this,arguments);for(var n=-1,e=this.length;++n=n&&(n=i+1);!(a=u[n])&&++n0&&(n=n.slice(0,a));var s=gt.get(n);function l(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}return s&&(n=s,u=yt),a?r?function(){var t=u(r,e(arguments));l.call(this),this.addEventListener(n,this[o]=t,t.$=i),t._=r}:l:r?z:function(){var e,r=new RegExp("^__on([^.]+)"+t.requote(n)+"$");for(var i in this)if(e=i.match(r)){var o=this[i];this.removeEventListener(e[1],o,o.$),delete this[i]}}}t.selection.enter=ct,t.selection.enter.prototype=ht,ht.append=$.append,ht.empty=$.empty,ht.node=$.node,ht.call=$.call,ht.size=$.size,ht.select=function(t){for(var n,e,r,i,o,a=[],u=-1,s=this.length;++u0?1:t<0?-1:0}function Lt(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function zt(t){return t>1?0:t<-1?Et:Math.acos(t)}function Dt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function Pt(t){return(t=Math.sin(t/2))*t}var qt=Math.SQRT2;t.interpolateZoom=function(t,n){var e,r,i=t[0],o=t[1],a=t[2],u=n[0],s=n[1],l=n[2],c=u-i,h=s-o,f=c*c+h*h;if(f0&&(n=n.transition().duration(d)),n.call(b.event)}function A(){l&&l.domain(s.range().map((function(t){return(t-f.x)/f.k})).map(s.invert)),h&&h.domain(c.range().map((function(t){return(t-f.y)/f.k})).map(c.invert))}function C(t){y++||t({type:"zoomstart"})}function N(t){A(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function T(t){--y||(t({type:"zoomend"}),e=null)}function F(){var n=this,e=w.of(n,arguments),r=0,i=t.select(o(n)).on(m,s).on(x,l),a=M(t.mouse(n)),u=xt(n);function s(){r=1,E(t.mouse(n),a),N(e)}function l(){i.on(m,null).on(x,null),u(r),T(e)}du.call(n),C(e)}function L(){var n,e=this,r=w.of(e,arguments),i={},o=0,a=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+a,l="touchend"+a,c=[],h=t.select(e),p=xt(e);function g(){var r=t.touches(e);return n=f.k,r.forEach((function(t){t.identifier in i&&(i[t.identifier]=M(t))})),r}function d(){var n=t.event.target;t.select(n).on(s,y).on(l,m),c.push(n);for(var r=t.event.changedTouches,a=0,h=r.length;a1){v=p[0];var x=p[1],_=v[0]-x[0],w=v[1]-x[1];o=_*_+w*w}}function y(){var a,s,l,c,h=t.touches(e);du.call(e);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 en(o(t+120),o(t),o(t-120))}function $t(n,e,r){return this instanceof $t?(this.h=+n,this.c=+e,void(this.l=+r)):arguments.length<2?n instanceof $t?new $t(n.h,n.c,n.l):Jt(n instanceof Zt?n.l:(n=cn((n=t.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new $t(n,e,r)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new jt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new jt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Bt(this.h,this.s,this.l)},t.hcl=$t;var Yt=$t.prototype=new Ht;function Wt(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),new Zt(e,Math.cos(t*=Nt)*n,Math.sin(t)*n)}function Zt(t,n,e){return this instanceof Zt?(this.l=+t,this.a=+n,void(this.b=+e)):arguments.length<2?t instanceof Zt?new Zt(t.l,t.a,t.b):t instanceof $t?Wt(t.h,t.c,t.l):cn((t=en(t)).r,t.g,t.b):new Zt(t,n,e)}Yt.brighter=function(t){return new $t(this.h,this.c,Math.min(100,this.l+Xt*(arguments.length?t:1)))},Yt.darker=function(t){return new $t(this.h,this.c,Math.max(0,this.l-Xt*(arguments.length?t:1)))},Yt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Zt;var Xt=18,Gt=Zt.prototype=new Ht;function Qt(t,n,e){var r=(t+16)/116,i=r+n/500,o=r-e/200;return new en(nn(3.2404542*(i=.95047*Kt(i))-1.5371385*(r=1*Kt(r))-.4985314*(o=1.08883*Kt(o))),nn(-.969266*i+1.8760108*r+.041556*o),nn(.0556434*i-.2040259*r+1.0572252*o))}function Jt(t,n,e){return t>0?new $t(Math.atan2(e,n)*Tt,Math.sqrt(n*n+e*e),t):new $t(NaN,NaN,t)}function Kt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function tn(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function nn(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function en(t,n,e){return this instanceof en?(this.r=~~t,this.g=~~n,void(this.b=~~e)):arguments.length<2?t instanceof en?new en(t.r,t.g,t.b):sn(""+t,en,Bt):new en(t,n,e)}function rn(t){return new en(t>>16,t>>8&255,255&t)}function on(t){return rn(t)+""}Gt.brighter=function(t){return new Zt(Math.min(100,this.l+Xt*(arguments.length?t:1)),this.a,this.b)},Gt.darker=function(t){return new Zt(Math.max(0,this.l-Xt*(arguments.length?t:1)),this.a,this.b)},Gt.rgb=function(){return Qt(this.l,this.a,this.b)},t.rgb=en;var an=en.prototype=new Ht;function un(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function sn(t,n,e){var r,i,o,a=0,u=0,s=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(fn(i[0]),fn(i[1]),fn(i[2]))}return(o=pn.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,u=240&o,u|=u>>4,s=15&o,s|=s<<4):7===t.length&&(a=(16711680&o)>>16,u=(65280&o)>>8,s=255&o)),n(a,u,s))}function ln(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),u=a-o,s=(a+o)/2;return u?(i=s<.5?u/(a+o):u/(2-a-o),r=t==a?(n-e)/u+(n0&&s<1?0:r),new jt(r,i,s)}function cn(t,n,e){var r=tn((.4124564*(t=hn(t))+.3575761*(n=hn(n))+.1804375*(e=hn(e)))/.95047),i=tn((.2126729*t+.7151522*n+.072175*e)/1);return Zt(116*i-16,500*(r-i),200*(i-tn((.0193339*t+.119192*n+.9503041*e)/1.08883)))}function hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function fn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}an.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=i.call(a,l)}catch(t){return void u.error.call(a,t)}u.load.call(a,t)}else u.error.call(a,l)}return this.XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(n)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=h:l.onreadystatechange=function(){l.readyState>3&&h()},l.onprogress=function(n){var e=t.event;t.event=n;try{u.progress.call(a,l)}finally{t.event=e}},a.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==n?delete s[t]:s[t]=n+"",a)},a.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",a):r},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return i=t,a},["get","post"].forEach((function(t){a[t]=function(){return a.send.apply(a,[t].concat(e(arguments)))}})),a.send=function(t,e,i){if(2===arguments.length&&"function"==typeof e&&(i=e,e=null),l.open(t,n,!0),null==r||"accept"in s||(s.accept=r+",*/*"),l.setRequestHeader)for(var o in s)l.setRequestHeader(o,s[o]);return null!=r&&l.overrideMimeType&&l.overrideMimeType(r),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",(function(t){i(null,t)})),u.beforesend.call(a,l),l.send(null==e?null:e),a},a.abort=function(){return l.abort(),a},t.rebind(a,u,"on"),null==o?a:a.get(function(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}(o))}pn.forEach((function(t,n){pn.set(t,rn(n))})),t.functor=gn,t.xhr=dn(N),t.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=yn(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 u(n){return n.map(s).join(t)}function s(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={},u=[],s=t.length,l=0,c=0;function h(){if(l>=s)return a;if(i)return i=!1,o;var n=l;if(34===t.charCodeAt(n)){for(var e=n;e++24?(isFinite(n)&&(clearTimeout(_n),_n=setTimeout(Mn,n)),xn=0):(xn=1,wn(Mn))}function kn(){for(var t=Date.now(),n=vn;n;)t>=n.t&&n.c(t-n.t)&&(n.c=null),n=n.n;return t}function En(){for(var t,n=vn,e=1/0;n;)n.c?(n.t8?function(t){return t/e}:function(t){return t*e},symbol:t}}));function Cn(n){var e=n.decimal,r=n.thousands,i=n.grouping,o=n.currency,a=i&&r?function(t,n){for(var e=t.length,o=[],a=0,u=i[0],s=0;e>0&&u>0&&(s+u+1>n&&(u=Math.max(1,n-s)),o.push(t.substring(e-=u,e+u)),!((s+=u+1)>n));)u=i[a=(a+1)%i.length];return o.reverse().join(r)}:N;return function(n){var r=Nn.exec(n),i=r[1]||" ",u=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],h=+r[6],f=r[7],p=r[8],g=r[9],d=1,y="",v="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(c||"0"===i&&"="===u)&&(c=i="0",u="="),g){case"n":f=!0,g="g";break;case"%":d=100,v="%",g="f";break;case"p":d=100,v="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(y="0"+g.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":d=-1,g="r"}"$"===l&&(y=o[0],v=o[1]),"r"!=g||p||(g="g"),null!=p&&("g"==g?p=Math.max(1,Math.min(21,p)):"e"!=g&&"f"!=g||(p=Math.max(0,Math.min(20,p)))),g=Tn.get(g)||Fn;var _=c&&f;return function(n){var r=v;if(m&&n%1)return"";var o=n<0||0===n&&1/n<0?(n=-n,"-"):"-"===s?"":s;if(d<0){var l=t.formatPrefix(n,p);n=l.scale(n),r=l.symbol+v}else n*=d;var w,b,M=(n=g(n,p)).lastIndexOf(".");if(M<0){var k=x?n.lastIndexOf("e"):-1;k<0?(w=n,b=""):(w=n.substring(0,k),b=n.substring(k))}else w=n.substring(0,M),b=e+n.substring(M+1);!c&&f&&(w=a(w,1/0));var E=y.length+w.length+b.length+(_?0:o.length),S=E"===u?S+o+n:"^"===u?S.substring(0,E>>=1)+o+n+S.substring(E):o+(_?n:S+n))+r}}}t.formatPrefix=function(n,e){var r=0;return(n=+n)&&(n<0&&(n*=-1),e&&(n=t.round(n,Sn(n,e))),r=1+Math.floor(1e-12+Math.log(n)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),An[8+r/3]};var Nn=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Tn=t.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(n,e){return(n=t.round(n,Sn(n,e))).toFixed(Math.max(0,Math.min(20,Sn(n*(1+1e-15),e))))}});function Fn(t){return t+""}var Ln=t.time={},zn=Date;function Dn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Dn.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(){Rn.setUTCDate.apply(this._,arguments)},setDay:function(){Rn.setUTCDay.apply(this._,arguments)},setFullYear:function(){Rn.setUTCFullYear.apply(this._,arguments)},setHours:function(){Rn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Rn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Rn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Rn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Rn.setUTCSeconds.apply(this._,arguments)},setTime:function(){Rn.setTime.apply(this._,arguments)}};var Rn=Date.prototype;function Pn(t,n,e){function r(n){var e=t(n),r=o(e,1);return n-e1)for(;a=l)return-1;if(37===(i=n.charCodeAt(u++))){if(a=n.charAt(u++),!(o=b[a in On?n.charAt(u++):a])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}c.utc=function(t){var n=c(t);function e(t){try{var e=new(zn=Dn);return e._=t,n(e)}finally{zn=Date}}return e.parse=function(t){try{zn=Dn;var e=n.parse(t);return e&&e._}finally{zn=Date}},e.toString=n.toString,e},c.multi=c.utc.multi=ae;var f=t.map(),p=Vn(a),g=Bn(a),d=Vn(u),y=Bn(u),v=Vn(s),m=Bn(s),x=Vn(l),_=Bn(l);o.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return u[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:c(e),d:function(t,n){return jn(t.getDate(),n,2)},e:function(t,n){return jn(t.getDate(),n,2)},H:function(t,n){return jn(t.getHours(),n,2)},I:function(t,n){return jn(t.getHours()%12||12,n,2)},j:function(t,n){return jn(1+Ln.dayOfYear(t),n,3)},L:function(t,n){return jn(t.getMilliseconds(),n,3)},m:function(t,n){return jn(t.getMonth()+1,n,2)},M:function(t,n){return jn(t.getMinutes(),n,2)},p:function(t){return o[+(t.getHours()>=12)]},S:function(t,n){return jn(t.getSeconds(),n,2)},U:function(t,n){return jn(Ln.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return jn(Ln.mondayOfYear(t),n,2)},x:c(r),X:c(i),y:function(t,n){return jn(t.getFullYear()%100,n,2)},Y:function(t,n){return jn(t.getFullYear()%1e4,n,4)},Z:ie,"%":function(){return"%"}},b={a:function(t,n,e){d.lastIndex=0;var r=d.exec(n.slice(e));return r?(t.w=y.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=g.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){x.lastIndex=0;var r=x.exec(n.slice(e));return r?(t.m=_.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=m.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,n,e){return h(t,w.c.toString(),n,e)},d:Jn,e:Jn,H:te,I:te,j:Kn,L:re,m:Qn,M:ne,p:function(t,n,e){var r=f.get(n.slice(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)},S:ee,U:Yn,w:$n,W:Wn,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:Xn,Y:Zn,Z:Gn,"%":oe};return c}Ln.year=Pn((function(t){return(t=Ln.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),Ln.years=Ln.year.range,Ln.years.utc=Ln.year.utc.range,Ln.day=Pn((function(t){var n=new zn(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})),Ln.days=Ln.day.range,Ln.days.utc=Ln.day.utc.range,Ln.dayOfYear=function(t){var n=Ln.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=Ln[t]=Pn((function(t){return(t=Ln.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=Ln.year(t).getDay();return Math.floor((Ln.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));Ln[t+"s"]=e.range,Ln[t+"s"].utc=e.utc.range,Ln[t+"OfYear"]=function(t){var e=Ln.year(t).getDay();return Math.floor((Ln.dayOfYear(t)+(e+n)%7)/7)}})),Ln.week=Ln.sunday,Ln.weeks=Ln.sunday.range,Ln.weeks.utc=Ln.sunday.utc.range,Ln.weekOfYear=Ln.sundayOfYear;var On={"-":"",_:" ",0:"0"},In=/^\s*\d+/,Hn=/^%/;function jn(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 Gn(t,n,e){return/^[+-]\d{4}$/.test(n=n.slice(e,e+5))?(t.Z=-n,e+5):-1}function Qn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function Jn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function Kn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+3));return r?(t.j=+r[0],e+r[0].length):-1}function te(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function ne(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function ee(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function re(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function ie(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=v(n)/60|0,i=v(n)%60;return e+jn(r,"0",2)+jn(i,"0",2)}function oe(t,n,e){Hn.lastIndex=0;var r=Hn.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function ae(t){for(var n=t.length,e=-1;++e=0?1:-1,u=a*o,s=Math.cos(n),l=Math.sin(n),c=i*l,h=r*s+c*Math.cos(u),f=c*a*Math.sin(u);Ce.add(Math.atan2(f,h)),e=t,r=s,i=l}Ne.point=function(a,u){Ne.point=o,e=(t=a)*Nt,r=Math.cos(u=(n=u)*Nt/2+Et/4),i=Math.sin(u)},Ne.lineEnd=function(){o(t,n)}}function Fe(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 Le(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ze(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 De(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Re(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Pe(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 qe(t){return[Math.atan2(t[1],t[0]),Dt(t[2])]}function Ue(t,n){return v(t[0]-n[0])Mt?i=90:l<-Mt&&(e=-90),h[0]=n,h[1]=r}};function p(t,o){c.push(h=[n=t,r=t]),oi&&(i=o)}function g(t,a){var u=Fe([t*Nt,a*Nt]);if(s){var l=ze(s,u),c=ze([l[1],-l[0],0],l);Pe(c),c=qe(c);var h=t-o,f=h>0?1:-1,g=c[0]*Tt*f,d=v(h)>180;if(d^(f*oi&&(i=y);else if(d^(f*o<(g=(g+360)%360-180)&&gi&&(i=a);d?tw(n,r)&&(r=t):w(t,r)>w(n,r)&&(n=t):r>=n?(tr&&(r=t)):t>o?w(n,t)>w(n,r)&&(r=t):w(t,r)>w(n,r)&&(n=t)}else p(t,a);s=u,o=t}function d(){f.point=g}function y(){h[0]=n,h[1]=r,f.point=p,s=null}function m(t,n){if(s){var e=t-o;l+=v(e)>180?e+(e>0?360:-360):e}else a=t,u=n;Ne.point(t,n),g(t,n)}function x(){Ne.lineStart()}function _(){m(a,u),Ne.lineEnd(),v(l)>Mt&&(n=-(r=180)),h[0]=n,h[1]=r,s=null}function w(t,n){return(n-=t)<0?n+360:n}function b(t,n){return t[0]-n[0]}function M(t,n){return n[0]<=n[1]?n[0]<=t&&t<=n[1]:tw(d[0],d[1])&&(d[1]=p[1]),w(p[0],d[1])>w(d[0],d[1])&&(d[0]=p[0])):u.push(d=p);for(var s,l,p,g=-1/0,d=(a=0,u[l=u.length-1]);a<=l;d=p,++a)p=u[a],(s=w(d[1],p[0]))>g&&(g=s,n=p[0],r=d[1])}return c=h=null,n===1/0||e===1/0?[[NaN,NaN],[NaN,NaN]]:[[n,e],[r,i]]}}(),t.geo.centroid=function(n){ve=me=xe=_e=we=be=Me=ke=Ee=Se=Ae=0,t.geo.stream(n,Oe);var e=Ee,r=Se,i=Ae,o=e*e+r*r+i*i;return o=0;--u)i.point((h=c[u])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}c=(p=p.o).z,g=!g}while(!p.v);i.lineEnd()}}}function Ze(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,M=b*w,k=M>Et,E=g*x;if(Ce.add(Math.atan2(E*b*Math.sin(M),d*_+E*Math.cos(M))),o+=k?w+b*St:w,k^f>=e^v>=e){var S=ze(Fe(h),Fe(t));Pe(S);var A=ze(i,S);Pe(A);var C=(k^w>=0?-1:1)*Dt(A[2]);(r>C||r===C&&(S[0]||S[1]))&&(a+=k^w>=0?1:-1)}if(!y++)break;f=v,g=x,d=_,h=t}}return(o<-Mt||o0){for(x||(a.polygonStart(),x=!0),a.lineStart();++o1&&2&n&&e.push(e.pop().concat(e.shift())),u.push(e.filter(Qe))}return c}}function Qe(t){return t.length>1}function Je(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:z,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function Ke(t,n){return((t=t.x)[0]<0?t[1]-Ct-Mt:Ct-t[1])-((n=n.x)[0]<0?n[1]-Ct-Mt:Ct-n[1])}var tr=Ge(Ye,(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?Et:-Et,s=v(o-e);v(s-Et)0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&s>=Et&&(v(e-i)Mt?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(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*Ct,r.point(-Et,i),r.point(0,i),r.point(Et,i),r.point(Et,0),r.point(Et,-i),r.point(0,-i),r.point(-Et,-i),r.point(-Et,0),r.point(-Et,i);else if(v(t[0]-n[0])>Mt){var o=t[0]0,r=v(n)>Mt;return Ge(i,(function(t){var n,u,s,l,c;return{lineStart:function(){l=s=!1,c=1},point:function(h,f){var p,g=[h,f],d=i(h,f),y=e?d?0:a(h,f):d?a(h+(h<0?Et:-Et),f):0;if(!n&&(l=s=d)&&t.lineStart(),d!==s&&(p=o(n,g),(Ue(n,p)||Ue(g,p))&&(g[0]+=Mt,g[1]+=Mt,d=i(g[0],g[1]))),d!==s)c=0,d?(t.lineStart(),p=o(g,n),t.point(p[0],p[1])):(p=o(n,g),t.point(p[0],p[1]),t.lineEnd()),n=p;else if(r&&n&&e^d){var v;y&u||!(v=o(g,n,!0))||(c=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&&Ue(n,g)||t.point(g[0],g[1]),n=g,s=d,u=y},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return c|(l&&s)<<1}}}),qr(t,6*Nt),e?[0,-t]:[-Et,t-Et]);function i(t,e){return Math.cos(t)*Math.cos(e)>n}function o(t,e,r){var i=[1,0,0],o=ze(Fe(t),Fe(e)),a=Le(o,o),u=o[0],s=a-u*u;if(!s)return!r&&t;var l=n*a/s,c=-n*u/s,h=ze(i,o),f=Re(i,l);De(f,Re(o,c));var p=h,g=Le(f,p),d=Le(p,p),y=g*g-d*(Le(f,f)-1);if(!(y<0)){var m=Math.sqrt(y),x=Re(p,(-g-m)/d);if(De(x,f),x=qe(x),!r)return x;var _,w=t[0],b=e[0],M=t[1],k=e[1];b0^x[1]<(v(x[0]-w)Et^(w<=x[0]&&x[0]<=b)){var A=Re(p,(-g+m)/d);return De(A,f),[x,qe(A)]}}}function a(n,r){var i=e?t:Et-t,o=0;return n<-i?o|=1:n>i&&(o|=2),r<-i?o|=4:r>i&&(o|=8),o}}function er(t,n,e,r){return function(i){var o,a=i.a,u=i.b,s=a.x,l=a.y,c=0,h=1,f=u.x-s,p=u.y-l;if(o=t-s,f||!(o>0)){if(o/=f,f<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=e-s,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o)}else if(f>0){if(o0)){if(o/=p,p<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=r-l,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>c&&(c=o)}else if(p>0){if(o0&&(i.a={x:s+c*f,y:l+c*p}),h<1&&(i.b={x:s+h*f,y:l+h*p}),i}}}}}}function rr(n,e,r,i){return function(s){var l,c,h,f,p,g,d,y,v,m,x,_=s,w=Je(),b=er(n,e,r,i),M={point:S,lineStart:function(){M.point=A,c&&c.push(h=[]),m=!0,v=!1,d=y=NaN},lineEnd:function(){l&&(A(f,p),g&&v&&w.rejoin(),l.push(w.buffer())),M.point=S,v&&s.lineEnd()},polygonStart:function(){s=w,l=[],c=[],x=!0},polygonEnd:function(){s=_,l=t.merge(l);var e=function(t){for(var n=0,e=c.length,r=t[1],i=0;ir&&Lt(l,o,t)>0&&++n:o[1]<=r&&Lt(l,o,t)<0&&--n,l=o;return 0!==n}([n,i]),r=x&&e,o=l.length;(r||o)&&(s.polygonStart(),r&&(s.lineStart(),k(null,null,1,s),s.lineEnd()),o&&We(l,a,e,k,s),s.polygonEnd()),l=c=h=null}};function k(t,a,s,l){var c=0,h=0;if(null==t||(c=o(t,s))!==(h=o(a,s))||u(t,a)<0^s>0)do{l.point(0===c||3===c?n:r,c>1?i:e)}while((c=(c+s+4)%4)!==h);else l.point(a[0],a[1])}function E(t,o){return n<=t&&t<=r&&e<=o&&o<=i}function S(t,n){E(t,n)&&s.point(t,n)}function A(t,n){var e=E(t=Math.max(-1e9,Math.min(1e9,t)),n=Math.max(-1e9,Math.min(1e9,n)));if(c&&h.push([t,n]),m)f=t,p=n,g=e,m=!1,e&&(s.lineStart(),s.point(t,n));else if(e&&v)s.point(t,n);else{var r={a:{x:d,y:y},b:{x:t,y:n}};b(r)?(v||(s.lineStart(),s.point(r.a.x,r.a.y)),s.point(r.b.x,r.b.y),e||s.lineEnd(),x=!1):e&&(s.lineStart(),s.point(t,n),x=!1)}d=t,y=n,v=e}return M};function o(t,i){return v(t[0]-n)0?0:3:v(t[0]-r)0?2:1:v(t[1]-e)0?1:0:i>0?3:2}function a(t,n){return u(t.x,n.x)}function u(t,n){var e=o(t,1),r=o(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 ir(t){var n=0,e=Et/3,r=Nr(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Et/180,e=t[1]*Et/180):[n/Et*180,e/Et*180]},i}function or(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,Dt((i-(t*t+e*e)*r*r)/(2*r))]},a}t.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(u){return arguments.length?(o=rr(t=+u[0][0],n=+u[0][1],e=+u[1][0],r=+u[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ir(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var n,e,r,i,o=t.geo.albers(),a=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),u=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,e){n=[t,e]}};function l(t){var o=t[0],a=t[1];return n=null,e(o,a),n||(r(o,a),n)||i(o,a),n}return l.invert=function(t){var n=o.scale(),e=o.translate(),r=(t[0]-e[0])/n,i=(t[1]-e[1])/n;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?a:i>=.166&&i<.234&&r>=-.214&&r<-.115?u:o).invert(t)},l.stream=function(t){var n=o.stream(t),e=a.stream(t),r=u.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()}}},l.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),u.precision(t),l):o.precision()},l.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),u.scale(t),l.translate(o.translate())):o.scale()},l.translate=function(t){if(!arguments.length)return o.translate();var n=o.scale(),c=+t[0],h=+t[1];return e=o.translate(t).clipExtent([[c-.455*n,h-.238*n],[c+.455*n,h+.238*n]]).stream(s).point,r=a.translate([c-.307*n,h+.201*n]).clipExtent([[c-.425*n+Mt,h+.12*n+Mt],[c-.214*n-Mt,h+.234*n-Mt]]).stream(s).point,i=u.translate([c-.205*n,h+.212*n]).clipExtent([[c-.214*n+Mt,h+.166*n+Mt],[c-.115*n-Mt,h+.234*n-Mt]]).stream(s).point,l},l.scale(1070)};var ar,ur,sr,lr,cr,hr,fr={point:z,lineStart:z,lineEnd:z,polygonStart:function(){ur=0,fr.lineStart=pr},polygonEnd:function(){fr.lineStart=fr.lineEnd=fr.point=z,ar+=v(ur/2)}};function pr(){var t,n,e,r;function i(t,n){ur+=r*t-e*n,e=t,r=n}fr.point=function(o,a){fr.point=i,t=e=o,n=r=a},fr.lineEnd=function(){i(t,n)}}var gr={point:function(t,n){tcr&&(cr=t),nhr&&(hr=n)},lineStart:z,lineEnd:z,polygonStart:z,polygonEnd:z};function dr(){var t=yr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=u},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=yr(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 u(){n.push("Z")}return e}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var vr,mr={point:xr,lineStart:_r,lineEnd:wr,polygonStart:function(){mr.lineStart=br},polygonEnd:function(){mr.point=xr,mr.lineStart=_r,mr.lineEnd=wr}};function xr(t,n){xe+=t,_e+=n,++we}function _r(){var t,n;function e(e,r){var i=e-t,o=r-n,a=Math.sqrt(i*i+o*o);be+=a*(t+e)/2,Me+=a*(n+r)/2,ke+=a,xr(t=e,n=r)}mr.point=function(r,i){mr.point=e,xr(t=r,n=i)}}function wr(){mr.point=xr}function br(){var t,n,e,r;function i(t,n){var i=t-e,o=n-r,a=Math.sqrt(i*i+o*o);be+=a*(e+t)/2,Me+=a*(r+n)/2,ke+=a,Ee+=(a=r*t-e*n)*(e+t),Se+=a*(r+n),Ae+=3*a,xr(e=t,r=n)}mr.point=function(o,a){mr.point=i,xr(t=e=o,n=r=a)},mr.lineEnd=function(){i(t,n)}}function Mr(t){var n=4.5,e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=u},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:z};function r(e,r){t.moveTo(e+n,r),t.arc(e,r,n,0,St)}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 u(){t.closePath()}return e}function kr(t){var n=.5,e=Math.cos(30*Nt),r=16;function i(t){return(r?a:o)(t)}function o(n){return Ar(n,(function(e,r){e=t(e,r),n.point(e[0],e[1])}))}function a(n){var e,i,o,a,s,l,c,h,f,p,g,d,y={point:v,lineStart:m,lineEnd:_,polygonStart:function(){n.polygonStart(),y.lineStart=w},polygonEnd:function(){n.polygonEnd(),y.lineStart=m}};function v(e,r){e=t(e,r),n.point(e[0],e[1])}function m(){h=NaN,y.point=x,n.lineStart()}function x(e,i){var o=Fe([e,i]),a=t(e,i);u(h,f,c,p,g,d,h=a[0],f=a[1],c=e,p=o[0],g=o[1],d=o[2],r,n),n.point(h,f)}function _(){y.point=v,n.lineEnd()}function w(){m(),y.point=b,y.lineEnd=M}function b(t,n){x(e=t,n),i=h,o=f,a=p,s=g,l=d,y.point=x}function M(){u(h,f,c,p,g,d,i,o,e,a,s,l,r,n),y.lineEnd=_,_()}return y}function u(r,i,o,a,s,l,c,h,f,p,g,d,y,m){var x=c-r,_=h-i,w=x*x+_*_;if(w>4*n&&y--){var b=a+p,M=s+g,k=l+d,E=Math.sqrt(b*b+M*M+k*k),S=Math.asin(k/=E),A=v(v(k)-1)n||v((x*F+_*L)/w-.5)>.3||a*p+s*g+l*d0&&16,i):Math.sqrt(n)},i}function Er(t){var n=kr((function(n,e){return t([n*Tt,e*Tt])}));return function(t){return Tr(n(t))}}function Sr(t){this.stream=t}function Ar(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 Cr(t){return Nr((function(){return t}))()}function Nr(n){var e,r,i,o,a,u,s=kr((function(t,n){return[(t=e(t,n))[0]*l+o,a-t[1]*l]})),l=150,c=480,h=250,f=0,p=0,g=0,d=0,y=0,v=tr,m=N,x=null,_=null;function w(t){return[(t=i(t[0]*Nt,t[1]*Nt))[0]*l+o,a-t[1]*l]}function b(t){return(t=i.invert((t[0]-o)/l,(a-t[1])/l))&&[t[0]*Tt,t[1]*Tt]}function M(){i=$e(r=zr(g,d,y),e);var t=e(f,p);return o=c-t[0]*l,a=h+t[1]*l,k()}function k(){return u&&(u.valid=!1,u=null),w}return w.stream=function(t){return u&&(u.valid=!1),(u=Tr(v(r,s(m(t))))).valid=!0,u},w.clipAngle=function(t){return arguments.length?(v=null==t?(x=t,tr):nr((x=+t)*Nt),k()):x},w.clipExtent=function(t){return arguments.length?(_=t,m=t?rr(t[0][0],t[0][1],t[1][0],t[1][1]):N,k()):_},w.scale=function(t){return arguments.length?(l=+t,M()):l},w.translate=function(t){return arguments.length?(c=+t[0],h=+t[1],M()):[c,h]},w.center=function(t){return arguments.length?(f=t[0]%360*Nt,p=t[1]%360*Nt,M()):[f*Tt,p*Tt]},w.rotate=function(t){return arguments.length?(g=t[0]%360*Nt,d=t[1]%360*Nt,y=t.length>2?t[2]%360*Nt:0,M()):[g*Tt,d*Tt,y*Tt]},t.rebind(w,s,"precision"),function(){return e=n.apply(this,arguments),w.invert=e.invert&&b,M()}}function Tr(t){return Ar(t,(function(n,e){t.point(n*Nt,e*Nt)}))}function Fr(t,n){return[t,n]}function Lr(t,n){return[t>Et?t-St:t<-Et?t+St:t,n]}function zr(t,n,e){return t?n||e?$e(Rr(t),Pr(n,e)):Rr(t):n||e?Pr(n,e):Lr}function Dr(t){return function(n,e){return[(n+=t)>Et?n-St:n<-Et?n+St:n,e]}}function Rr(t){var n=Dr(t);return n.invert=Dr(-t),n}function Pr(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),u=Math.cos(t)*a,s=Math.sin(t)*a,l=Math.sin(n),c=l*e+u*r;return[Math.atan2(s*i-c*o,u*e-l*r),Dt(c*i+s*o)]}return a.invert=function(t,n){var a=Math.cos(n),u=Math.cos(t)*a,s=Math.sin(t)*a,l=Math.sin(n),c=l*i-s*o;return[Math.atan2(s*i+l*o,u*e+c*r),Dt(c*e-u*r)]},a}function qr(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,u){var s=a*n;null!=i?(i=Ur(e,i),o=Ur(e,o),(a>0?io)&&(i+=a*St)):(i=t+a*St,o=t-.5*s);for(var l,c=i;a>0?c>o:c2?t[2]*Nt:0),n.invert=function(n){return(n=t.invert(n[0]*Nt,n[1]*Nt))[0]*=Tt,n[1]*=Tt,n},n},Lr.invert=Fr,t.geo.circle=function(){var t,n,e=[0,0],r=6;function i(){var t="function"==typeof e?e.apply(this,arguments):e,r=zr(-t[0]*Nt,-t[1]*Nt,0).invert,i=[];return n(null,null,1,{point:function(t,n){i.push(t=r(t,n)),t[0]*=Tt,t[1]*=Tt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(e=t,i):e},i.angle=function(e){return arguments.length?(n=qr((t=+e)*Nt,r*Nt),i):t},i.precision=function(e){return arguments.length?(n=qr(t*Nt,(r=+e)*Nt),i):r},i.angle(90)},t.geo.distance=function(t,n){var e,r=(n[0]-t[0])*Nt,i=t[1]*Nt,o=n[1]*Nt,a=Math.sin(r),u=Math.cos(r),s=Math.sin(i),l=Math.cos(i),c=Math.sin(o),h=Math.cos(o);return Math.atan2(Math.sqrt((e=h*a)*e+(e=l*c-s*h*u)*e),s*c+l*h*u)},t.geo.graticule=function(){var n,e,r,i,o,a,u,s,l,c,h,f,p=10,g=p,d=90,y=360,m=2.5;function x(){return{type:"MultiLineString",coordinates:_()}}function _(){return t.range(Math.ceil(i/d)*d,r,d).map(h).concat(t.range(Math.ceil(s/y)*y,u,y).map(f)).concat(t.range(Math.ceil(e/p)*p,n,p).filter((function(t){return v(t%d)>Mt})).map(l)).concat(t.range(Math.ceil(a/g)*g,o,g).filter((function(t){return v(t%y)>Mt})).map(c))}return x.lines=function(){return _().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(f(u).slice(1),h(r).reverse().slice(1),f(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],s=+t[0][1],u=+t[1][1],i>r&&(t=i,i=r,r=t),s>u&&(t=s,s=u,u=t),x.precision(m)):[[i,s],[r,u]]},x.minorExtent=function(t){return arguments.length?(e=+t[0][0],n=+t[1][0],a=+t[0][1],o=+t[1][1],e>n&&(t=e,e=n,n=t),a>o&&(t=a,a=o,o=t),x.precision(m)):[[e,a],[n,o]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],x):[d,y]},x.minorStep=function(t){return arguments.length?(p=+t[0],g=+t[1],x):[p,g]},x.precision=function(t){return arguments.length?(m=+t,l=Or(a,o,90),c=Ir(e,n,m),h=Or(s,u,90),f=Ir(i,r,m),x):m},x.majorExtent([[-180,-90+Mt],[180,90-Mt]]).minorExtent([[-180,-80-Mt],[180,80+Mt]])},t.geo.greatArc=function(){var n,e,r=Hr,i=jr;function o(){return{type:"LineString",coordinates:[n||r.apply(this,arguments),e||i.apply(this,arguments)]}}return o.distance=function(){return t.geo.distance(n||r.apply(this,arguments),e||i.apply(this,arguments))},o.source=function(t){return arguments.length?(r=t,n="function"==typeof t?null:t,o):r},o.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,o):i},o.precision=function(){return arguments.length?o:0},o},t.geo.interpolate=function(t,n){return e=t[0]*Nt,r=t[1]*Nt,i=n[0]*Nt,o=n[1]*Nt,a=Math.cos(r),u=Math.sin(r),s=Math.cos(o),l=Math.sin(o),c=a*Math.cos(e),h=a*Math.sin(e),f=s*Math.cos(i),p=s*Math.sin(i),g=2*Math.asin(Math.sqrt(Pt(o-r)+a*s*Pt(i-e))),d=1/Math.sin(g),(y=g?function(t){var n=Math.sin(t*=g)*d,e=Math.sin(g-t)*d,r=e*c+n*f,i=e*h+n*p,o=e*u+n*l;return[Math.atan2(i,r)*Tt,Math.atan2(o,Math.sqrt(r*r+i*i))*Tt]}:function(){return[e*Tt,r*Tt]}).distance=g,y;var e,r,i,o,a,u,s,l,c,h,f,p,g,d,y},t.geo.length=function(n){return vr=0,t.geo.stream(n,Vr),vr};var Vr={sphere:z,point:z,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=Nt),a=Math.cos(i),u=v((r*=Nt)-t),s=Math.cos(u);vr+=Math.atan2(Math.sqrt((u=a*Math.sin(u))*u+(u=e*o-n*a*s)*u),n*o+e*a*s),t=r,n=o,e=a}Vr.point=function(i,o){t=i*Nt,n=Math.sin(o*=Nt),e=Math.cos(o),Vr.point=r},Vr.lineEnd=function(){Vr.point=Vr.lineEnd=z}},lineEnd:z,polygonStart:z,polygonEnd:z};function Br(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 $r=Br((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(t.geo.azimuthalEqualArea=function(){return Cr($r)}).raw=$r;var Yr=Br((function(t){var n=Math.acos(t);return n&&n/Math.sin(n)}),N);function Wr(t,n){var e=Math.cos(t),r=function(t){return Math.tan(Et/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 Gr;function a(t,n){o>0?n<-Ct+Mt&&(n=-Ct+Mt):n>Ct-Mt&&(n=Ct-Mt);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=Ft(i)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ct]},a}function Zr(t,n){var e=Math.cos(t),r=t===n?Math.sin(t):(e-Math.cos(n))/(n-t),i=e/r+t;if(v(r)1&&Lt(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ii(t,n){return t[0]-n[0]||t[1]-n[1]}(t.geo.stereographic=function(){return Cr(Kr)}).raw=Kr,ti.invert=function(t,n){return[-n,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Qr(ti),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=ti,t.geom={},t.geom.hull=function(t){var n=ni,e=ei;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=gn(n),o=gn(e),a=t.length,u=[],s=[];for(r=0;r=0;--r)p.push(t[u[l[r]][2]]);for(r=+h;rMt)u=u.L;else{if(!((i=o-bi(u,a))>Mt)){r>-Mt?(n=u.P,e=u):i>-Mt?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}var s=vi(t);if(hi.insert(n,s),n||e){if(n===e)return Ai(n),e=vi(n.site),hi.insert(s,e),s.edge=e.edge=Ti(n.site,s.site),Si(n),void Si(e);if(e){Ai(n),Ai(e);var l=n.site,c=l.x,h=l.y,f=t.x-c,p=t.y-h,g=e.site,d=g.x-c,y=g.y-h,v=2*(f*y-p*d),m=f*f+p*p,x=d*d+y*y,_={x:(y*m-p*x)/v+c,y:(f*x-d*m)/v+h};Fi(e.edge,l,g,_),s.edge=Ti(l,t,null,_),e.edge=Ti(t,g,null,_),Si(n),Si(e)}else s.edge=Ti(n.site,s.site)}}function wi(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 u=(e=a.site).x,s=e.y,l=s-n;if(!l)return u;var c=u-r,h=1/o-1/l,f=c/l;return h?(-f+Math.sqrt(f*f-2*h*(c*c/(-2*l)-s+l/2+i-o/2)))/h+r:(r+u)/2}function bi(t,n){var e=t.N;if(e)return wi(e,n);var r=t.site;return r.y===n?r.x:1/0}function Mi(t){this.site=t,this.edges=[]}function ki(t,n){return n.angle-t.angle}function Ei(){Di(this),this.x=this.y=this.arc=this.site=this.cy=null}function Si(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,u=i.y,s=r.x-a,l=r.y-u,c=o.x-a,h=2*(s*(y=o.y-u)-l*c);if(!(h>=-kt)){var f=s*s+l*l,p=c*c+y*y,g=(y*f-l*p)/h,d=(s*p-c*f)/h,y=d+u,v=di.pop()||new Ei;v.arc=t,v.site=i,v.x=g+a,v.y=y+Math.sqrt(g*g+d*d),v.cy=y,t.circle=v;for(var m=null,x=pi._;x;)if(v.y=u)return;if(f>g){if(o){if(o.y>=l)return}else o={x:y,y:s};e={x:y,y:l}}else{if(o){if(o.y1)if(f>g){if(o){if(o.y>=l)return}else o={x:(s-i)/r,y:s};e={x:(l-i)/r,y:l}}else{if(o){if(o.y=u)return}else o={x:a,y:r*a+i};e={x:u,y:r*u+i}}else{if(o){if(o.xMt||v(i-e)>Mt)&&(u.splice(a,0,new Li((m=o.site,x=c,_=v(r-h)Mt?{x:h,y:v(n-h)Mt?{x:v(e-g)Mt?{x:f,y:v(n-f)Mt?{x:v(e-p)=e&&l.x<=i&&l.y>=r&&l.y<=a?[[e,a],[i,a],[i,r],[e,r]]:[]).point=t[u]})),n}function u(t){return t.map((function(t,n){return{x:Math.round(r(t,n)/Mt)*Mt,y:Math.round(i(t,n)/Mt)*Mt,i:n}}))}return a.links=function(t){return Ui(u(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 Ui(u(t)).cells.forEach((function(e,r){for(var i,o,a,u,s=e.site,l=e.edges.sort(ki),c=-1,h=l.length,f=l[h-1].edge,p=f.l===s?f.r:f.l;++co||h>a||f=w)<<1|n>=_,M=b+4;bo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,s.push({i:a,x:Wi(e,r)})),o=Gi.lastIndex;return od&&(d=s.x),s.y>y&&(y=s.y),l.push(s.x),c.push(s.y);else for(h=0;hd&&(d=_),w>y&&(y=w),l.push(_),c.push(w)}var b=d-p,M=y-g;function k(t,n,e,r,i,o,a,u){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var s=t.x,l=t.y;if(null!=s)if(v(s-e)+v(l-r)<.01)E(t,n,e,r,i,o,a,u);else{var c=t.point;t.x=t.y=t.point=null,E(t,c,s,l,i,o,a,u),E(t,n,e,r,i,o,a,u)}else t.x=e,t.y=r,t.point=n}else E(t,n,e,r,i,o,a,u)}function E(t,n,e,r,i,o,a,u){var s=.5*(i+a),l=.5*(o+u),c=e>=s,h=r>=l,f=h<<1|c;t.leaf=!1,c?i=s:a=s,h?o=l:u=l,k(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,u)}b>M?y=g+b:d=p+M;var S={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(S,t,+m(t,++h),+x(t,h),p,g,d,y)},visit:function(t){Vi(t,S,p,g,d,y)},find:function(t){return Bi(S,t[0],t[1],p,g,d,y)}};if(h=-1,null==n){for(;++h=0&&!(r=t.interpolators[i](n,e)););return r}function Ji(t,n){var e,r=[],i=[],o=t.length,a=n.length,u=Math.min(t.length,n.length);for(e=0;e=1?1:t(n)}}function ro(t){return function(n){return 1-t(1-n)}}function io(t){return function(n){return.5*(n<.5?t(2*n):2-t(2-2*n))}}function oo(t){return t*t}function ao(t){return t*t*t}function uo(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 so(t){return 1-Math.cos(t*Ct)}function lo(t){return Math.pow(2,10*(t-1))}function co(t){return 1-Math.sqrt(1-t*t)}function ho(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 fo(t,n){return n-=t,function(e){return Math.round(t+n*e)}}function po(t){var n,e,r,i=[t.a,t.b],o=[t.c,t.d],a=yo(i),u=go(i,o),s=yo(((n=o)[0]+=(r=-u)*(e=i)[0],n[1]+=r*e[1],n))||0;i[0]*o[1]=0?t.slice(0,e):t,i=e>=0?t.slice(e+1):"in";return r=to.get(r)||Ki,eo((i=no.get(i)||N)(r.apply(null,n.call(arguments,1))))},t.interpolateHcl=function(n,e){n=t.hcl(n),e=t.hcl(e);var r=n.h,i=n.c,o=n.l,a=e.h-r,u=e.c-i,s=e.l-o;return isNaN(u)&&(u=0,i=isNaN(i)?e.c:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Wt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateHsl=function(n,e){n=t.hsl(n),e=t.hsl(e);var r=n.h,i=n.s,o=n.l,a=e.h-r,u=e.s-i,s=e.l-o;return isNaN(u)&&(u=0,i=isNaN(i)?e.s:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Bt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateLab=function(n,e){n=t.lab(n),e=t.lab(e);var r=n.l,i=n.a,o=n.b,a=e.l-r,u=e.a-i,s=e.b-o;return function(t){return Qt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateRound=fo,t.transform=function(n){var e=r.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new po(n?n.matrix:vo)})(n)},po.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var vo={a:1,b:0,c:0,d:1,e:0,f:0};function mo(t){return t.length?t.pop()+",":""}function xo(n,e){var r=[],i=[];return n=t.transform(n),e=t.transform(e),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:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else(n[0]||n[1])&&e.push("translate("+n+")")}(n.translate,e.translate,r,i),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:Wi(t,n)})):n&&e.push(mo(e)+"rotate("+n+")")}(n.rotate,e.rotate,r,i),function(t,n,e,r){t!==n?r.push({i:e.push(mo(e)+"skewX(",null,")")-2,x:Wi(t,n)}):n&&e.push(mo(e)+"skewX("+n+")")}(n.skew,e.skew,r,i),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:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else 1===n[0]&&1===n[1]||e.push(mo(e)+"scale("+n+")")}(n.scale,e.scale,r,i),n=e=null,function(t){for(var n,e=-1,o=i.length;++e0?r=t:(n.c=null,n.t=NaN,n=null,s.end({type:"end",alpha:r=0})):t>0&&(s.start({type:"start",alpha:r=t}),n=bn(u.tick)),u):r},u.start=function(){var t,n,e,r=v.length,s=m.length,c=l[0],g=l[1];for(t=0;t=0;)e.push(i[r])}function zo(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(c=l[s]),c.parent=o,c.depth=o.depth+1;e&&(o.value=0),o.children=l}else e&&(o.value=+e.call(r,o,o.depth)||0),delete o.children;return zo(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),u}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&&(Lo(t,(function(t){t.children&&(t.value=0)})),zo(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},t.layout.partition=function(){var n=t.layout.hierarchy(),e=[1,1];function r(t,r){var i=n.call(this,t,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,u,s,l=-1;for(r=n.value?r/n.value:0;++lu&&(u=r),a.push(r)}for(e=0;ei&&(r=e,i=n);return r}function Wo(t){return t.reduce(Zo,0)}function Zo(t,n){return t+n[1]}function Xo(t,n){return Go(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function Go(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 Qo(n){return[t.min(n),t.max(n)]}function Jo(t,n){return t.value-n.value}function Ko(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function ta(t,n){t._pack_next=n,n._pack_prev=t}function na(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 ea(t){if((n=t.children)&&(s=n.length)){var n,e,r,i,o,a,u,s,l=1/0,c=-1/0,h=1/0,f=-1/0;if(n.forEach(ra),(e=n[0]).x=-e.r,e.y=0,x(e),s>1&&((r=n[1]).x=r.r,r.y=0,x(r),s>2))for(oa(e,r,i=n[2]),x(i),Ko(e,i),e._pack_prev=i,Ko(i,r),r=e._pack_next,o=3;o0)for(a=-1;++a=h[0]&&s<=h[1]&&((u=l[t.bisect(f,s,1,g)-1]).y+=d,u.push(o[a]));return l}return o.value=function(t){return arguments.length?(e=t,o):e},o.range=function(t){return arguments.length?(r=gn(t),o):r},o.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return Go(n,t)}:gn(t),o):i},o.frequency=function(t){return arguments.length?(n=!!t,o):n},o},t.layout.pack=function(){var n,e=t.layout.hierarchy().sort(Jo),r=0,i=[1,1];function o(t,o){var a=e.call(this,t,o),u=a[0],s=i[0],l=i[1],c=null==n?Math.sqrt:"function"==typeof n?n:function(){return n};if(u.x=u.y=0,zo(u,(function(t){t.r=+c(t.value)})),zo(u,ea),r){var h=r*(n?1:Math.max(2*u.r/s,2*u.r/l))/2;zo(u,(function(t){t.r+=h})),zo(u,ea),zo(u,(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,u=o.length;++ap.x&&(p=t),t.depth>g.depth&&(g=t)}));var d=e(f,p)/2-f.x,y=r[0]/(p.x+e(p,f)/2+d),v=r[1]/(g.depth||1);Lo(c,(function(t){t.x=(t.x+d)*y,t.y=t.depth*v}))}return l}function a(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n.length){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(t);var o=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+e(t._,i._));t.parent.A=function(t,n,r){if(n){for(var i,o=t,a=t,u=n,s=o.parent.children[0],l=o.m,c=a.m,h=u.m,f=s.m;u=sa(u),o=ua(o),u&&o;)s=ua(s),(a=sa(a)).a=t,(i=u.z+h-o.z-l+e(u._,o._))>0&&(la(ca(u,t,r),t,i),l+=i,c+=i),h+=u.m,l+=o.m,f+=s.m,c+=a.m;u&&!sa(a)&&(a.t=u,a.m+=h-c),o&&!ua(s)&&(s.t=o,s.m+=l-f,r=t)}return r}(t,i,t.parent.A||r[0])}function u(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=r[0],t.y=t.depth*r[1]}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t)?s:null,o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:s,o):i?r:null},Fo(o,n)},t.layout.cluster=function(){var n=t.layout.hierarchy().sort(null).value(null),e=aa,r=[1,1],i=!1;function o(o,a){var u,s=n.call(this,o,a),l=s[0],c=0;zo(l,(function(n){var r=n.children;r&&r.length?(n.x=function(t){return t.reduce((function(t,n){return t+n.x}),0)/t.length}(r),n.y=function(n){return 1+t.max(n,(function(t){return t.y}))}(r)):(n.x=u?c+=e(n,u):0,n.y=0,u=n)}));var h=function t(n){var e=n.children;return e&&e.length?t(e[0]):n}(l),f=function t(n){var e,r=n.children;return r&&(e=r.length)?t(r[e-1]):n}(l),p=h.x-e(h,f)/2,g=f.x+e(f,h)/2;return zo(l,i?function(t){t.x=(t.x-l.x)*r[0],t.y=(l.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(g-p)*r[0],t.y=(1-(l.y?t.y/l.y:1))*r[1]}),s}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t),o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null!=(r=t),o):i?r:null},Fo(o,n)},t.layout.treemap=function(){var n,e=t.layout.hierarchy(),r=Math.round,i=[1,1],o=null,a=ha,u=!1,s="squarify",l=.5*(1+Math.sqrt(5));function c(t,n){for(var e,r,i=-1,o=t.length;++i0;)u.push(e=l[i-1]),u.area+=e.area,"squarify"!==s||(r=p(u,d))<=f?(l.pop(),f=r):(u.area-=u.pop().area,g(u,d,o,!1),d=Math.min(o.dx,o.dy),u.length=u.area=0,f=1/0);u.length&&(g(u,d,o,!0),u.length=u.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(c(i,r.dx*r.dy/t.value),o.area=0;e=i.pop();)o.push(e),o.area+=e.area,null!=e.z&&(g(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,u=t.length;++ai&&(i=e));return n*=n,(r*=r)?Math.max(n*i*l/r,r/(n*o*l)):1/0}function g(t,n,e,i){var o,a=-1,u=t.length,s=e.x,l=e.y,c=n?r(t.area/n):0;if(n==e.dx){for((i||c>e.dy)&&(c=e.dy);++ae.dx)&&(c=e.dx);++a1);return t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=t.random.normal.apply(t,arguments);return function(){return Math.exp(n())}},bates:function(n){var e=t.random.irwinHall(n);return function(){return e()/n}},irwinHall:function(t){return function(){for(var n=0,e=0;e2?xa:da,u=i?wo:_o;return o=t(n,e,u,r),a=t(e,n,u,Qi),s}function s(t){return o(t)}return s.invert=function(t){return a(t)},s.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},s.range=function(t){return arguments.length?(e=t,u()):e},s.rangeRound=function(t){return s.range(t).interpolate(fo)},s.clamp=function(t){return arguments.length?(i=t,u()):i},s.interpolate=function(t){return arguments.length?(r=t,u()):r},s.ticks=function(t){return Ma(n,t)},s.tickFormat=function(t,e){return ka(n,t,e)},s.nice=function(t){return wa(n,t),u()},s.copy=function(){return t(n,e,r,i)},u()}([0,1],[0,1],Qi,!1)};var Ea={s:1,g:1,p:1,r:1,e:1};function Sa(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function n(e,r,i,o){function a(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function u(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function s(t){return e(a(t))}return s.invert=function(t){return u(e.invert(t))},s.domain=function(t){return arguments.length?(i=t[0]>=0,e.domain((o=t.map(Number)).map(a)),s):o},s.base=function(t){return arguments.length?(r=+t,e.domain(o.map(a)),s):r},s.nice=function(){var t=ya(o.map(a),i?Math:Ca);return e.domain(t),o=t.map(u),s},s.ticks=function(){var t=pa(o),n=[],e=t[0],s=t[1],l=Math.floor(a(e)),c=Math.ceil(a(s)),h=r%1?2:r;if(isFinite(c-l)){if(i){for(;l0;f--)n.push(u(l)*f);for(l=0;n[l]s;c--);n=n.slice(l,c)}return n},s.tickFormat=function(n,e){if(!arguments.length)return Aa;arguments.length<2?e=Aa:"function"!=typeof e&&(e=t.format(e));var i=Math.max(1,r*n/s.ticks().length);return function(t){var n=t/u(Math.round(a(t)));return n*r0?i[t-1]:e[0],th?0:1;if(l=At)return s(l,p)+(u?s(u,1-p):"")+"Z";var g,d,y,v,m,x,_,w,b,M,k,E,S=0,A=0,C=[];if((v=(+a.apply(this,arguments)||0)/2)&&(y=r===Ra?Math.sqrt(u*u+l*l):+r.apply(this,arguments),p||(A*=-1),l&&(A=Dt(y/l*Math.sin(v))),u&&(S=Dt(y/u*Math.sin(v)))),l){m=l*Math.cos(c+A),x=l*Math.sin(c+A),_=l*Math.cos(h-A),w=l*Math.sin(h-A);var N=Math.abs(h-c-2*A)<=Et?0:1;if(A&&Ha(m,x,_,w)===p^N){var T=(c+h)/2;m=l*Math.cos(T),x=l*Math.sin(T),_=w=null}}else m=x=0;if(u){b=u*Math.cos(h-S),M=u*Math.sin(h-S),k=u*Math.cos(c+S),E=u*Math.sin(c+S);var F=Math.abs(c-h+2*S)<=Et?0:1;if(S&&Ha(b,M,k,E)===1-p^F){var L=(c+h)/2;b=u*Math.cos(L),M=u*Math.sin(L),k=E=null}}else b=M=0;if(f>Mt&&(g=Math.min(Math.abs(l-u)/2,+e.apply(this,arguments)))>.001){d=u0?0:1}function ja(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],u=(i?r:-r)/Math.sqrt(o*o+a*a),s=u*a,l=-u*o,c=t[0]+s,h=t[1]+l,f=n[0]+s,p=n[1]+l,g=(c+f)/2,d=(h+p)/2,y=f-c,v=p-h,m=y*y+v*v,x=e-r,_=c*p-f*h,w=(v<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-_*_)),b=(_*v-y*w)/m,M=(-_*y-v*w)/m,k=(_*v+y*w)/m,E=(-_*y+v*w)/m,S=b-g,A=M-d,C=k-g,N=E-d;return S*S+A*A>C*C+N*N&&(b=k,M=E),[[b-s,M-l],[b*e/x,M*e/x]]}function Va(t){var n=ni,e=ei,r=Ye,i=$a,o=i.key,a=.7;function u(o){var u,s=[],l=[],c=-1,h=o.length,f=gn(n),p=gn(e);function g(){s.push("M",i(t(l),a))}for(;++c1&&i.push("H",r[0]),i.join("")},"step-before":Wa,"step-after":Za,basis:Qa,"basis-open":function(t){if(t.length<4)return $a(t);for(var n,e=[],r=-1,i=t.length,o=[0],a=[0];++r<3;)n=t[r],o.push(n[0]),a.push(n[1]);for(e.push(Ja(nu,o)+","+Ja(nu,a)),--r;++r9&&(i=3*n/Math.sqrt(i),a[u]=i*e,a[u+1]=i*r);for(u=-1;++u<=s;)i=(t[Math.min(s,u+1)][0]-t[Math.max(0,u-1)][0])/(6*(1+a[u]*a[u])),o.push([i||0,a[u]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function Ya(t){return t.join("L")+"Z"}function Wa(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n1){u=n[1],o=t[s],s++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-u[0])+","+(o[1]-u[1])+","+o[0]+","+o[1];for(var l=2;lEt)+",1 "+n}function s(t,n,e,r){return"Q 0,0 "+r}return o.radius=function(t){return arguments.length?(e=gn(t),o):e},o.source=function(n){return arguments.length?(t=gn(n),o):t},o.target=function(t){return arguments.length?(n=gn(t),o):n},o.startAngle=function(t){return arguments.length?(r=gn(t),o):r},o.endAngle=function(t){return arguments.length?(i=gn(t),o):i},o},t.svg.diagonal=function(){var t=Hr,n=jr,e=uu;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),u=(o.y+a.y)/2,s=[o,{x:o.x,y:u},{x:a.x,y:u},a];return"M"+(s=s.map(e))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return r.source=function(n){return arguments.length?(t=gn(n),r):t},r.target=function(t){return arguments.length?(n=gn(t),r):n},r.projection=function(t){return arguments.length?(e=t,r):e},r},t.svg.diagonal.radial=function(){var n=t.svg.diagonal(),e=uu,r=n.projection;return n.projection=function(t){return arguments.length?r(su(e=t)):e},n},t.svg.symbol=function(){var t=cu,n=lu;function e(e,r){return(fu.get(t.call(this,e,r))||hu)(n.call(this,e,r))}return e.type=function(n){return arguments.length?(t=gn(n),e):t},e.size=function(t){return arguments.length?(n=gn(t),e):n},e};var fu=t.map({circle:hu,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*gu)),e=n*gu;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/pu),e=n*pu/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/pu),e=n*pu/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});t.svg.symbolTypes=fu.keys();var pu=Math.sqrt(3),gu=Math.tan(30*Nt);$.transition=function(t){for(var n,e,r=mu||++wu,i=ku(t),o=[],a=xu||{time:Date.now(),ease:uo,delay:0,duration:250},u=-1,s=this.length;++u0;)l[--f].call(t,a);if(o>=1)return h.event&&h.event.end.call(t,t.__data__,n),--c.count?delete c[r]:delete t[e],1}h||(o=i.time,a=bn((function(t){var n=h.delay;if(a.t=n+o,n<=t)return f(t-n);a.c=f}),0,o),h=c[r]={tween:new _,time:o,timer:a,delay:i.delay,duration:i.duration,ease:i.ease,index:n},i=null,++c.count)}_u.call=$.call,_u.empty=$.empty,_u.node=$.node,_u.size=$.size,t.transition=function(n,e){return n&&n.transition?mu?n.transition(e):n:t.selection().transition(n)},t.transition.prototype=_u,_u.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=Y(t);for(var u=-1,s=this.length;++urect,.s>rect").attr("width",u[1]-u[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 y(){var h,y,v=this,m=t.select(t.event.target),x=r.of(v,arguments),_=t.select(v),w=m.datum(),b=!/^(n|s)$/.test(w)&&i,M=!/^(e|w)$/.test(w)&&a,k=m.classed("extent"),E=xt(v),S=t.mouse(v),A=t.select(o(v)).on("keydown.brush",T).on("keyup.brush",F);if(t.event.changedTouches?A.on("touchmove.brush",L).on("touchend.brush",D):A.on("mousemove.brush",L).on("mouseup.brush",D),_.interrupt().selectAll("*").interrupt(),k)S[0]=u[0]-S[0],S[1]=s[0]-S[1];else if(w){var C=+/w$/.test(w),N=+/^n/.test(w);y=[u[1-C]-S[0],s[1-N]-S[1]],S[0]=u[C],S[1]=s[N]}else t.event.altKey&&(h=S.slice());function T(){32==t.event.keyCode&&(k||(h=null,S[0]-=u[1],S[1]-=s[1],k=2),P())}function F(){32==t.event.keyCode&&2==k&&(S[0]+=u[1],S[1]+=s[1],k=0,P())}function L(){var n=t.mouse(v),e=!1;y&&(n[0]+=y[0],n[1]+=y[1]),k||(t.event.altKey?(h||(h=[(u[0]+u[1])/2,(s[0]+s[1])/2]),S[0]=u[+(n[0]1?{floor:function(n){for(;u(n=t.floor(n));)n=qu(n-1);return n},ceil:function(n){for(;u(n=t.ceil(n));)n=qu(+n+1);return n}}:t))},i.ticks=function(t,n){var e=pa(i.domain()),r=null==t?o(e,10):"number"==typeof t?o(e,t):!t.range&&[{range:t},n];return r&&(t=r[0],n=r[1]),t.range(e[0],qu(+e[1]+1),n<1?1:n)},i.tickFormat=function(){return r},i.copy=function(){return Pu(n.copy(),e,r)},_a(i,n)}function qu(t){return new Date(t)}Lu.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ru:Du,Ru.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Ru.toString=Du.toString,Ln.second=Pn((function(t){return new zn(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),Ln.seconds=Ln.second.range,Ln.seconds.utc=Ln.second.utc.range,Ln.minute=Pn((function(t){return new zn(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),Ln.minutes=Ln.minute.range,Ln.minutes.utc=Ln.minute.utc.range,Ln.hour=Pn((function(t){var n=t.getTimezoneOffset()/60;return new zn(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),Ln.hours=Ln.hour.range,Ln.hours.utc=Ln.hour.utc.range,Ln.month=Pn((function(t){return(t=Ln.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),Ln.months=Ln.month.range,Ln.months.utc=Ln.month.utc.range;var Uu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ou=[[Ln.second,1],[Ln.second,5],[Ln.second,15],[Ln.second,30],[Ln.minute,1],[Ln.minute,5],[Ln.minute,15],[Ln.minute,30],[Ln.hour,1],[Ln.hour,3],[Ln.hour,6],[Ln.hour,12],[Ln.day,1],[Ln.day,2],[Ln.week,1],[Ln.month,1],[Ln.month,3],[Ln.year,1]],Iu=Lu.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",Ye]]),Hu={range:function(n,e,r){return t.range(Math.ceil(n/r)*r,+e,r).map(qu)},floor:N,ceil:N};Ou.year=Ln.year,Ln.scale=function(){return Pu(t.scale.linear(),Ou,Iu)};var ju=Ou.map((function(t){return[t[0].utc,t[1]]})),Vu=zu.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",Ye]]);function Bu(t){return JSON.parse(t.responseText)}function $u(t){var n=r.createRange();return n.selectNode(r.body),n.createContextualFragment(t.responseText)}ju.year=Ln.year.utc,Ln.scale.utc=function(){return Pu(t.scale.linear(),ju,Vu)},t.text=dn((function(t){return t.responseText})),t.json=function(t,n){return yn(t,"application/json",Bu,n)},t.html=function(t,n){return yn(t,"text/html",$u,n)},t.xml=dn((function(t){return t.responseXML})),"function"==typeof define&&define.amd?(this.d3=t,define(t)):"object"==typeof module&&module.exports?module.exports=t:this.d3=t}(),null==window.Epoch&&(window.Epoch={}),null==(c=window.Epoch).Chart&&(c.Chart={}),null==(t=window.Epoch).Time&&(t.Time={}),null==(n=window.Epoch).Util&&(n.Util={}),null==(e=window.Epoch).Formats&&(e.Formats={}),Epoch.warn=function(t){return(console.warn||console.log)("Epoch Warning: "+t)},Epoch.exception=function(t){throw"Epoch Error: "+t},Epoch.TestContext=function(){var t;function n(){var n,e,r;for(this._log=[],n=0,e=t.length;n0},Epoch.Util.copy=function(t){var n,e,r;if(null==t)return null;for(e in n={},t)a.call(t,e)&&(r=t[e],n[e]=r);return n},Epoch.Util.defaults=function(t,n){var e,r,i,o,u;for(i in u=Epoch.Util.copy(t),n)a.call(n,i)&&(n[i],o=t[i],r=n[i],e=Epoch.isObject(o)&&Epoch.isObject(r),null!=o&&null!=r?e&&!Epoch.isArray(o)?u[i]=Epoch.Util.defaults(o,r):u[i]=o:u[i]=null!=o?o:r);return u},Epoch.Util.formatSI=function(t,n,e){var r,i,o,u,s;if(null==n&&(n=1),null==e&&(e=!1),t<1e3)return((0|(u=t))!==u||e)&&(u=u.toFixed(n)),u;for(i in s=["K","M","G","T","P","E","Z","Y"])if(a.call(s,i)&&(o=s[i],t>=(r=Math.pow(10,3*(1+(0|i))))&&t=(r=Math.pow(1024,1+(0|i)))&&t=0;)r.push(this._events[t].splice(e,1));return r}},t.prototype.offAll=function(t){var n,e,r,i,o,u;if(Epoch.isArray(t)){for(o=[],e=0,r=t.length;en;i=1<=n?++t:--t)e.push(arguments[i]);return e}.apply(this,arguments),s=[],o=0,a=(u=this._events[t]).length;o=this.data.length||(i=this.data[e]));return i},r.prototype.showLayer=function(t){var n;if((n=this._findLayer(t))&&!n.visible)return n.visible=!0,this.trigger("layer:shown")},r.prototype.hideLayer=function(t){var n;if((n=this._findLayer(t))&&n.visible)return n.visible=!1,this.trigger("layer:hidden")},r.prototype.toggleLayer=function(t){var n;if(n=this._findLayer(t))return n.visible=!n.visible,n.visible?this.trigger("layer:shown"):this.trigger("layer:hidden")},r.prototype.isLayerVisible=function(t){var n;return(n=this._findLayer(t))?n.visible:null},r.prototype.getVisibleLayers=function(){return this.data.filter((function(t){return t.visible}))},r.prototype.update=function(t,n){if(null==n&&(n=!0),this.setData(t),n)return this.draw()},r.prototype.draw=function(){return this.trigger("draw")},r.prototype._getScaleDomain=function(t){var n,e,r,i;return Array.isArray(t)?t:Epoch.isString(t)&&null!=(n=this.getVisibleLayers().filter((function(n){return n.range===t})).map((function(t){return t.values})))&&n.length?(r=function(t,n){return nt?n:t},[(i=Epoch.Util.flatten(n).map((function(t){return t.y}))).reduce(r,i[0]),i.reduce(e,i[0])]):Array.isArray(this.options.range)?this.options.range:this.options.range&&Array.isArray(this.options.range.left)?this.options.range.left:this.options.range&&Array.isArray(this.options.range.right)?this.options.range.right:this.extent((function(t){return t.y}))},r.prototype.extent=function(t){return[d3.min(this.getVisibleLayers(),(function(n){return d3.min(n.values,t)})),d3.max(this.getVisibleLayers(),(function(n){return d3.max(n.values,t)}))]},r.prototype.dimensionsChanged=function(){return this.width=this.option("width")||this.width,this.height=this.option("height")||this.height,this.el.width(this.width),this.el.height(this.height)},r.prototype.layerChanged=function(){return this.draw()},r}(Epoch.Events),Epoch.Chart.SVG=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.el?this.svg=this.el.append("svg"):this.svg=d3.select(document.createElement("svg")),this.svg.attr({xmlns:"http://www.w3.org/2000/svg",width:this.width,height:this.height})}return s(n,t),n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.svg.attr("width",this.width).attr("height",this.height)},n}(Epoch.Chart.Base),Epoch.Chart.Canvas=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.options.pixelRatio?this.pixelRatio=this.options.pixelRatio:null!=window.devicePixelRatio?this.pixelRatio=window.devicePixelRatio:this.pixelRatio=1,this.canvas=d3.select(document.createElement("CANVAS")),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()}),null!=this.el&&this.el.node().appendChild(this.canvas.node()),this.ctx=Epoch.Util.getContext(this.canvas.node())}return s(n,t),n.prototype.getWidth=function(){return this.width*this.pixelRatio},n.prototype.getHeight=function(){return this.height*this.pixelRatio},n.prototype.clear=function(){return this.ctx.clearRect(0,0,this.getWidth(),this.getHeight())},n.prototype.getStyles=function(t){return Epoch.QueryCSS.getStyles(t,this.el)},n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()})},n.prototype.redraw=function(){return Epoch.QueryCSS.purge(),this.draw()},n}(Epoch.Chart.Base),u=function(){var t,n,e,r,i;function o(){}return n=0,r=function(){return"epoch-container-"+n++},t=/^([^#. ]+)?(#[^. ]+)?(\.[^# ]+)?$/,e=!1,i=function(n){var e,r,i,o,a;return null==(o=n.match(t))?Epoch.error("Query CSS cannot match given selector: "+n):(o[0],a=o[1],i=o[2],e=o[3],a=(null!=a?a:"div").toUpperCase(),r=document.createElement(a),null!=i&&(r.id=i.substr(1)),null!=e&&(r.className=e.substr(1).replace(/\./g," ")),r)},o.log=function(t){return e=t},o.cache={},o.styleList=["fill","stroke","stroke-width"],o.container=null,o.purge=function(){return o.cache={}},o.getContainer=function(){var t;return null!=o.container?o.container:((t=document.createElement("DIV")).id="_canvas_css_reference",document.body.appendChild(t),o.container=d3.select(t))},o.hash=function(t,n){var e;return null==(e=n.attr("data-epoch-container-id"))&&(e=r(),n.attr("data-epoch-container-id",e)),e+"__"+t},o.getStyles=function(t,n){var r,a,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E,S;if(a=o.hash(t,n),null!=(r=o.cache[a]))return r;for(m=[],v=n.node().parentNode;null!=v&&"body"!==v.nodeName.toLowerCase();)m.unshift(v),v=v.parentNode;for(m.push(n.node()),k=[],l=0,f=m.length;l0&&(M+="#"+s.id),null!=s.className&&s.className.length>0&&(M+="."+Epoch.Util.trim(s.className).replace(/\s+/g,".")),k.push(M);for(k.push("svg"),c=0,p=(_=Epoch.Util.trim(t).split(/\s+/)).length;ce)t.label=u[e];else if(o&&r.length>e)t.label=r[e];else if(i){for(a=[];e>=0;)a.push(String.fromCharCode(65+e%26)),e-=26;t.label=a.join("")}return t},Epoch.Data.Format.array=(f={x:function(t,n){return n},y:function(t,n){return t},time:function(t,n,e){return parseInt(e)+parseInt(n)},type:"area",autoLabels:!1,labels:[],startTime:parseInt((new Date).getTime()/1e3)},h=function(t,n,e){var r,i,o;if(i=[],Epoch.isArray(t[0]))for(r in t)a.call(t,r)&&(o=t[r],i.push(l({values:o.map(e)},n,parseInt(r))));else i.push(l({values:t.map(e)},n,0));return i},g=function(t,n){return h(t,n,(function(t,e){return{x:n.x(t,e),y:n.y(t,e)}}))},v=function(t,n){return h(t,n,(function(t,e){return{time:n.time(t,e,n.startTime),y:n.y(t,e)}}))},d=function(t,n){return h(t,n,(function(t,e){return{time:n.time(t,e,n.startTime),histogram:t}}))},y=function(t,n){var e,r,i;for(e in r=[],t)if(a.call(t,e)){if(i=t[e],!Epoch.isNumber(t[0]))return[];r.push(l({value:i},n,e))}return r},(p=function(t,n){var e;return null==t&&(t=[]),null==n&&(n={}),Epoch.isNonEmptyArray(t)?"time.heatmap"===(e=Epoch.Util.defaults(n,f)).type?d(t,e):e.type.match(/^time\./)?v(t,e):"pie"===e.type?y(t,e):g(t,e):[]}).entry=function(t,n){var e,r,i,o,a,u,s,l;if(null==n&&(n={}),"time.gauge"===n.type)return null==t?0:(u=Epoch.Util.defaults(n,f),e=Epoch.isArray(t)?t[0]:t,u.y(e,0));if(null==t)return[];for(null==n.startTime&&(n.startTime=parseInt((new Date).getTime()/1e3)),r=Epoch.isArray(t)?t.map((function(t){return[t]})):[t],l=[],i=0,a=(s=p(r,n)).length;i-1},i.prototype.innerWidth=function(){return this.width-(this.margins.left+this.margins.right)},i.prototype.innerHeight=function(){return this.height-(this.margins.top+this.margins.bottom)},i.prototype.x=function(){var t,n;return t=null!=(n=this.options.domain)?n:this.extent((function(t){return t.x})),d3.scale.linear().domain(t).range([0,this.innerWidth()])},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.bottomAxis=function(){return d3.svg.axis().scale(this.x()).orient("bottom").ticks(this.options.ticks.bottom).tickFormat(this.options.tickFormats.bottom)},i.prototype.topAxis=function(){return d3.svg.axis().scale(this.x()).orient("top").ticks(this.options.ticks.top).tickFormat(this.options.tickFormats.top)},i.prototype.leftAxis=function(){var t;return t=this.options.range?this.options.range.left:null,d3.svg.axis().scale(this.y(t)).orient("left").ticks(this.options.ticks.left).tickFormat(this.options.tickFormats.left)},i.prototype.rightAxis=function(){var t;return t=this.options.range?this.options.range.right:null,d3.svg.axis().scale(this.y(t)).orient("right").ticks(this.options.ticks.right).tickFormat(this.options.tickFormats.right)},i.prototype.draw=function(){return this._axesDrawn?this._redrawAxes():this._drawAxes(),i.__super__.draw.call(this)},i.prototype._redrawAxes=function(){if(this.hasAxis("bottom")&&this.g.selectAll(".x.axis.bottom").transition().duration(500).ease("linear").call(this.bottomAxis()),this.hasAxis("top")&&this.g.selectAll(".x.axis.top").transition().duration(500).ease("linear").call(this.topAxis()),this.hasAxis("left")&&this.g.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.g.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._drawAxes=function(){return this.hasAxis("bottom")&&this.g.append("g").attr("class","x axis bottom").attr("transform","translate(0, "+this.innerHeight()+")").call(this.bottomAxis()),this.hasAxis("top")&&this.g.append("g").attr("class","x axis top").call(this.topAxis()),this.hasAxis("left")&&this.g.append("g").attr("class","y axis left").call(this.leftAxis()),this.hasAxis("right")&&this.g.append("g").attr("class","y axis right").attr("transform","translate("+this.innerWidth()+", 0)").call(this.rightAxis()),this._axesDrawn=!0},i.prototype.dimensionsChanged=function(){return i.__super__.dimensionsChanged.call(this),this.g.selectAll(".axis").remove(),this._axesDrawn=!1,this.draw()},i.prototype.marginsChanged=function(){var t,n,e;if(null!=this.options.margins){for(t in n=this.options.margins)a.call(n,t)&&(e=n[t],this.margins[t]=null==e?6:e);return this.g.transition().duration(750).attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.draw()}},i.prototype.axesChanged=function(){var t,e,r,i;for(t=0,e=(i=["top","right","bottom","left"]).length;t0?tn;e=t+=o)a.push(this.data[0].values[e].x);return a}.call(this))},o.prototype.bottomAxis=function(){var t;return t=d3.svg.axis().scale(this.x()).orient("bottom").ticks(this.options.ticks.bottom).tickFormat(this.options.tickFormats.bottom),this._isVertical()&&null!=this.options.ticks.bottom&&t.tickValues(this._getTickValues(this.options.ticks.bottom)),t},o.prototype.topAxis=function(){var t;return t=d3.svg.axis().scale(this.x()).orient("top").ticks(this.options.ticks.top).tickFormat(this.options.tickFormats.top),this._isVertical()&&null!=this.options.ticks.top&&t.tickValues(this._getTickValues(this.options.ticks.top)),t},o.prototype.leftAxis=function(){var t;return t=d3.svg.axis().scale(this.y()).orient("left").ticks(this.options.ticks.left).tickFormat(this.options.tickFormats.left),this._isHorizontal()&&null!=this.options.ticks.left&&t.tickValues(this._getTickValues(this.options.ticks.left)),t},o.prototype.rightAxis=function(){var t;return t=d3.svg.axis().scale(this.y()).orient("right").ticks(this.options.ticks.right).tickFormat(this.options.tickFormats.right),this._isHorizontal()&&null!=this.options.ticks.right&&t.tickValues(this._getTickValues(this.options.ticks.right)),t},o.prototype.orientationChanged=function(){var t,n,e,r;return r=this.options.tickFormats.top,t=this.options.tickFormats.bottom,n=this.options.tickFormats.left,e=this.options.tickFormats.right,this.options.tickFormats.left=r,this.options.tickFormats.right=t,this.options.tickFormats.top=n,this.options.tickFormats.bottom=e,this.draw()},o.prototype.paddingChanged=function(){return this.draw()},o}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Histogram=function(t){var n,e;function r(t){this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.onAll(e),this.draw()}return s(r,t),n={type:"histogram",domain:[0,100],bucketRange:[0,100],buckets:10,cutOutliers:!1},e={"option:bucketRange":"bucketRangeChanged","option:buckets":"bucketsChanged","option:cutOutliers":"cutOutliersChanged"},r.prototype._prepareData=function(t){var n,e,r,i,o,u,s,l,c,h,f,p,g,d;for(n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,f=[],i=0,l=t.length;in;0<=n?++t:--t)e.push(0);return e}.call(this),u=0,c=(g=s.values).length;u=this.options.buckets)||(r<0?r=0:r>=this.options.buckets&&(r=this.options.buckets-1),e[r]+=parseInt(h.y));for(o in p={values:e.map((function(t,e){return{x:parseInt(e)*n,y:t}}))},s)a.call(s,o)&&(d=s[o],"values"!==o&&(p[o]=d));f.push(p)}return f},r.prototype.resetData=function(){return this.setData(this.rawData),this.draw()},r.prototype.bucketRangeChanged=function(){return this.resetData()},r.prototype.bucketsChanged=function(){return this.resetData()},r.prototype.cutOutliersChanged=function(){return this.resetData()},r}(Epoch.Chart.Bar),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Line=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="line"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype.line=function(t){var n,e,r;return n=[this.x(),this.y(t.range)],e=n[0],r=n[1],d3.svg.line().x((function(t){return e(t.x)})).y((function(t){return r(t.y)}))},n.prototype.draw=function(){var t,e,r;return 0===(this.x(),this.y(),e=this.getVisibleLayers()).length?this.g.selectAll(".layer").remove():((t=this.g.selectAll(".layer").data(e,(function(t){return t.category}))).select(".line").transition().duration(500).attr("d",(r=this,function(t){return r.line(t)(t.values)})),t.enter().append("g").attr("class",(function(t){return t.className})).append("path").attr("class","line").attr("d",function(t){return function(n){return t.line(n)(n.values)}}(this)),t.exit().transition().duration(750).style("opacity","0").remove(),n.__super__.draw.call(this))},n}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Pie=function(t){var n;function e(t){var r;this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.pie=d3.layout.pie().sort(null).value((function(t){return t.value})),this.arc=d3.svg.arc().outerRadius((r=this,function(){return Math.max(r.width,r.height)/2-r.options.margin})).innerRadius(function(t){return function(){return t.options.inner}}(this)),this.g=this.svg.append("g").attr("transform","translate("+this.width/2+", "+this.height/2+")"),this.on("option:margin","marginChanged"),this.on("option:inner","innerChanged"),this.draw()}return s(e,t),n={type:"pie",margin:10,inner:0},e.prototype.draw=function(){var t,n;return this.g.selectAll(".arc").remove(),(t=this.g.selectAll(".arc").data(this.pie(this.getVisibleLayers()),(function(t){return t.data.category}))).enter().append("g").attr("class",(function(t){return"arc pie "+t.data.className})),t.select("path").attr("d",this.arc),t.select("text").attr("transform",(n=this,function(t){return"translate("+n.arc.centroid(t)+")"})).text((function(t){return t.data.label||t.data.category})),t.append("path").attr("d",this.arc).each((function(t){return this._current=t})),t.append("text").attr("transform",function(t){return function(n){return"translate("+t.arc.centroid(n)+")"}}(this)).attr("dy",".35em").style("text-anchor","middle").text((function(t){return t.data.label||t.data.category})),e.__super__.draw.call(this)},e.prototype.marginChanged=function(){return this.draw()},e.prototype.innerChanged=function(){return this.draw()},e}(Epoch.Chart.SVG),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Scatter=function(t){var n;function e(t){this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.on("option:radius","radiusChanged"),this.draw()}return s(e,t),n={type:"scatter",radius:3.5,axes:["top","bottom","left","right"]},e.prototype.draw=function(){var t,n,r,i,o,a,u;return o=[this.x(),this.y(),this.getVisibleLayers()],a=o[0],u=o[1],r=o[2],i=this.options.radius,0===r.length?this.g.selectAll(".layer").remove():((n=this.g.selectAll(".layer").data(r,(function(t){return t.category}))).enter().append("g").attr("class",(function(t){return t.className})),(t=n.selectAll(".dot").data((function(t){return t.values}))).transition().duration(500).attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return u(t.y)})),t.enter().append("circle").attr("class","dot").attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return u(t.y)})),t.exit().transition().duration(750).style("opacity",0).remove(),n.exit().transition().duration(750).style("opacity",0).remove(),e.__super__.draw.call(this))},e.prototype.radiusChanged=function(){return this.draw()},e}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Plot=function(t){var n,e,r;function i(t){var o,a,u,s,l;for(this.options=t,Epoch.Util.copy(this.options.margins),i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this.options.model&&this.options.model.on("data:push",(l=this,function(){return l.pushFromModel()})),this._queue=[],this.margins={},o=0,a=(s=["top","right","bottom","left"]).length;o=0&&n>=0;)this._pushTick(t,r.values[n].time,!1,!0),t-=s,n-=s;break}return u},i.prototype._prepareRangeAxes=function(){if(this.hasAxis("left")&&this.svg.append("g").attr("class","y axis left").attr("transform","translate("+(this.margins.left-1)+", "+this.margins.top+")").call(this.leftAxis()),this.hasAxis("right"))return this.svg.append("g").attr("class","y axis right").attr("transform","translate("+(this.width-this.margins.right)+", "+this.margins.top+")").call(this.rightAxis())},i.prototype.leftAxis=function(){var t,n;return n=this.options.ticks.left,t=d3.svg.axis().scale(this.ySvgLeft()).orient("left").tickFormat(this.options.tickFormats.left),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.rightAxis=function(){var t,n;return this.extent((function(t){return t.y})),n=this.options.ticks.right,t=d3.svg.axis().scale(this.ySvgRight()).orient("right").tickFormat(this.options.tickFormats.right),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.hasAxis=function(t){return this.options.axes.indexOf(t)>-1},i.prototype.innerWidth=function(){return(this.width-(this.margins.left+this.margins.right))*this.pixelRatio},i.prototype.innerHeight=function(){return(this.height-(this.margins.top+this.margins.bottom))*this.pixelRatio},i.prototype._prepareEntry=function(t){return t},i.prototype._prepareLayers=function(t){return t},i.prototype._startTransition=function(){if(!0!==this.animation.active&&0!==this._queue.length)return this.trigger("transition:start"),this._shift(),this.animation.active=!0,this.animation.interval=setInterval(this.animationCallback,1e3/this.options.fps)},i.prototype._stopTransition=function(){var t,n,e,r,i,o,a;if(this.inTransition()){for(n=0,i=(o=this.data).length;nthis.options.windowSize+1&&r.values.shift();return t=(a=[this._ticks[0],this._ticks[this._ticks.length-1]])[0],null!=(e=a[1])&&e.enter&&(e.enter=!1,e.opacity=1),null!=t&&t.exit&&this._shiftTick(),this.animation.frame=0,this.trigger("transition:end"),this._queue.length>0?this._shift():(this.animation.active=!1,clearInterval(this.animation.interval))}},i.prototype.inTransition=function(){return this.animation.active},i.prototype.push=function(t){return t=this._prepareLayers(t),this._queue.length>this.options.queueSize&&this._queue.splice(this.options.queueSize,this._queue.length-this.options.queueSize),this._queue.length!==this.options.queueSize&&(this._queue.push(t.map((n=this,function(t){return n._prepareEntry(t)}))),this.trigger("push"),this.inTransition()?void 0:this._startTransition());var n},i.prototype.pushFromModel=function(){return this.push(this.options.model.getNext(this.options.type,this.options.dataFormat))},i.prototype._shift=function(){var t,n,e;for(n in this.trigger("before:shift"),t=this._queue.shift(),e=this.data)a.call(e,n)&&e[n].values.push(t[n]);return this._updateTicks(t[0].time),this._transitionRangeAxes(),this.trigger("after:shift")},i.prototype._transitionRangeAxes=function(){if(this.hasAxis("left")&&this.svg.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.svg.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._animate=function(){if(this.inTransition())return++this.animation.frame===this.animation.duration&&this._stopTransition(),this.draw(this.animation.frame*this.animation.delta()),this._updateTimeAxes()},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.ySvg=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.ySvgLeft=function(){return null!=this.options.range?this.ySvg(this.options.range.left):this.ySvg()},i.prototype.ySvgRight=function(){return null!=this.options.range?this.ySvg(this.options.range.right):this.ySvg()},i.prototype.w=function(){return this.innerWidth()/this.options.windowSize},i.prototype._updateTicks=function(t){if((this.hasAxis("top")||this.hasAxis("bottom"))&&(++this._tickTimer%this.options.ticks.time||this._pushTick(this.options.windowSize,t,!0),this._ticks.length>0))return this._ticks[0].x-this.w()/this.pixelRatio>=0?void 0:this._ticks[0].exit=!0},i.prototype._pushTick=function(t,n,e,r){var i,o;if(null==e&&(e=!1),null==r&&(r=!1),this.hasAxis("top")||this.hasAxis("bottom"))return o={time:n,x:t*(this.w()/this.pixelRatio)+this._offsetX(),opacity:e?0:1,enter:!!e,exit:!1},this.hasAxis("bottom")&&((i=this.bottomAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",6),i.append("text").attr("text-anchor","middle").attr("dy",19).text(this.options.tickFormats.bottom(o.time)),o.bottomEl=i),this.hasAxis("top")&&((i=this.topAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",-6),i.append("text").attr("text-anchor","middle").attr("dy",-10).text(this.options.tickFormats.top(o.time)),o.topEl=i),r?this._ticks.unshift(o):this._ticks.push(o),o},i.prototype._shiftTick=function(){var t;if(this._ticks.length>0)return null!=(t=this._ticks.shift()).topEl&&t.topEl.remove(),null!=t.bottomEl?t.bottomEl.remove():void 0},i.prototype._updateTimeAxes=function(){var t,n,e,r,i,o,a,u;if(this.hasAxis("top")||this.hasAxis("bottom")){for(n=(i=[this.animation.tickDelta(),1/this.options.fps])[0],t=i[1],a=[],e=0,r=(o=this._ticks).length;e0){for(o=[],t=n=0,i=r[0].values.length;0<=i?ni;t=0<=i?++n:--n)a=0,o.push(function(){var n,i,o;for(o=[],i=0,n=r.length;iu;t=0<=u?++e:--e){for(l=0,n=i=0,s=r.length;0<=s?is;n=0<=s?++i:--i)l+=r[n].values[t].y;l>o&&(o=l)}return[0,o]},n.prototype.layerChanged=function(){var t,e,r,i;for(this._stackLayers(),t=0,r=(i=this._queue).length;t=0;i=h<=0?++u:--u)if(s=l[i]){for(this.setStyles(s),this.ctx.beginPath(),o=(f=[this.options.windowSize,s.values.length,this.inTransition()])[0],a=f[1],g=f[2];--o>=-2&&--a>=0;)n=[(o+1)*d+t,y((r=s.values[a]).y+r.y0)],g&&(n[0]+=d),i===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);e=g?(o+3)*d+t:(o+2)*d+t,this.ctx.lineTo(e,this.innerHeight()),this.ctx.lineTo(this.width*this.pixelRatio+d+t,this.innerHeight()),this.ctx.closePath(),p.push(this.ctx.fill())}return p},n.prototype._drawStrokes=function(t){var n,e,r,i,o,a,u,s,l,c,h,f,p,g;for(null==t&&(t=0),g=(s=[this.y(),this.w(),this.getVisibleLayers()])[0],p=s[1],h=[],r=o=l=(u=s[2]).length-1;l<=0?o<=0:o>=0;r=l<=0?++o:--o)if(a=u[r]){for(this.setStyles(a),this.ctx.beginPath(),r=(c=[this.options.windowSize,a.values.length,this.inTransition()])[0],i=c[1],f=c[2];--r>=-2&&--i>=0;)n=[(r+1)*p+t,g((e=a.values[i]).y+e.y0)],f&&(n[0]+=p),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);h.push(this.ctx.stroke())}return h},n.prototype.draw=function(t){return null==t&&(t=0),this.clear(),this._drawAreas(t),this._drawStrokes(t),n.__super__.draw.call(this)},n}(Epoch.Time.Stack),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Bar=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="time.bar"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},n.prototype.setStyles=function(t){var n;if(n=this.getStyles("rect.bar."+t.replace(/\s/g,".")),this.ctx.fillStyle=n.fill,null==n.stroke||"none"===n.stroke?this.ctx.strokeStyle="transparent":this.ctx.strokeStyle=n.stroke,null!=n["stroke-width"])return this.ctx.lineWidth=n["stroke-width"].replace("px","")},n.prototype.draw=function(t){var e,r,i,o,a,u,s,l,c,h,f,p,g,d,y,v,m;for(null==t&&(t=0),this.clear(),m=(f=[this.y(),this.w()])[0],v=f[1],s=0,h=(p=this.getVisibleLayers()).length;s=u&&--l>=0;)i=(d=[a*v+t,(r=c.values[l]).y,r.y0])[0],y&&(i+=v),e=[i+1,m((o=d[1])+d[2]),v-2,this.innerHeight()-m(o)+.5*this.pixelRatio],this.ctx.fillRect.apply(this.ctx,e),this.ctx.strokeRect.apply(this.ctx,e);return n.__super__.draw.call(this)},n}(Epoch.Time.Stack),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Gauge=function(t){var n,e;function r(t){var i;this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.value=this.options.value||0,this.options.model&&this.options.model.on("data:push",(i=this,function(){return i.pushFromModel()})),"absolute"!==this.el.style("position")&&"relative"!==this.el.style("position")&&this.el.style("position","relative"),this.svg=this.el.insert("svg",":first-child").attr("width",this.width).attr("height",this.height).attr("class","gauge-labels"),this.svg.style({position:"absolute","z-index":"1"}),this.svg.append("g").attr("transform","translate("+this.textX()+", "+this.textY()+")").append("text").attr("class","value").text(this.options.format(this.value)),this.animation={interval:null,active:!1,delta:0,target:0},this._animate=function(t){return function(){return Math.abs(t.animation.target-t.value)=c;o=0<=c?++a:--a)t=p(o),y=(n=(h=[Math.cos(t),Math.sin(t)])[0])*(u-g)+e,m=(f=h[1])*(u-g)+i,v=n*(u-g-d)+e,x=f*(u-g-d)+i,this.ctx.moveTo(y,m),this.ctx.lineTo(v,x);return this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.outer"),this.ctx.beginPath(),this.ctx.arc(e,i,u,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.inner"),this.ctx.beginPath(),this.ctx.arc(e,i,u-10,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.drawNeedle(),r.__super__.draw.call(this)},r.prototype.drawNeedle=function(){var t,n,e,r;return t=(r=[this.centerX(),this.centerY(),this.radius()])[0],n=r[1],e=r[2],this.value,this.options.domain[1],this.setStyles(".epoch .gauge .needle"),this.ctx.beginPath(),this.ctx.save(),this.ctx.translate(t,n),this.ctx.rotate(this.getAngle(this.value)),this.ctx.moveTo(4*this.pixelRatio,0),this.ctx.lineTo(-4*this.pixelRatio,0),this.ctx.lineTo(-1*this.pixelRatio,19-e),this.ctx.lineTo(1,19-e),this.ctx.fill(),this.setStyles(".epoch .gauge .needle-base"),this.ctx.beginPath(),this.ctx.arc(0,0,this.getWidth()/25,0,2*Math.PI),this.ctx.fill(),this.ctx.restore()},r.prototype.domainChanged=function(){return this.draw()},r.prototype.ticksChanged=function(){return this.draw()},r.prototype.tickSizeChanged=function(){return this.draw()},r.prototype.tickOffsetChanged=function(){return this.draw()},r.prototype.formatChanged=function(){return this.svg.select("text.value").text(this.options.format(this.value))},r}(Epoch.Chart.Canvas),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Heatmap=function(t){var n,e,r;function i(t){this.options=null!=t?t:{},i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this._setOpacityFunction(),this._setupPaintCanvas(),this.onAll(r),this.draw()}return s(i,t),e={type:"time.heatmap",buckets:10,bucketRange:[0,100],opacity:"linear",bucketPadding:2,paintZeroValues:!1,cutOutliers:!1},n={root:function(t,n){return Math.pow(t/n,.5)},linear:function(t,n){return t/n},quadratic:function(t,n){return Math.pow(t/n,2)},cubic:function(t,n){return Math.pow(t/n,3)},quartic:function(t,n){return Math.pow(t/n,4)},quintic:function(t,n){return Math.pow(t/n,5)}},r={"option:buckets":"bucketsChanged","option:bucketRange":"bucketRangeChanged","option:opacity":"opacityChanged","option:bucketPadding":"bucketPaddingChanged","option:paintZeroValues":"paintZeroValuesChanged","option:cutOutliers":"cutOutliersChanged"},i.prototype._setOpacityFunction=function(){return Epoch.isString(this.options.opacity)?(this._opacityFn=n[this.options.opacity],null==this._opacityFn?Epoch.exception("Unknown coloring function provided '"+this.options.opacity+"'"):void 0):Epoch.isFunction(this.options.opacity)?this._opacityFn=this.options.opacity:Epoch.exception("Unknown type for provided coloring function.")},i.prototype.setData=function(t){var n,e,r,o,a;for(i.__super__.setData.call(this,t),a=[],n=0,r=(o=this.data).length;nn;r=0<=n?++t:--t)e.push(0);return e}.call(this)},n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,s=t.histogram)a.call(s,c)&&(e=s[c],i=parseInt((c-this.options.bucketRange[0])/n),this.options.cutOutliers&&(i<0||i>=this.options.buckets)||(i<0?i=0:i>=this.options.buckets&&(i=this.options.buckets-1),u.buckets[i]+=parseInt(e)));for(r=o=0,l=u.buckets.length;0<=l?ol;r=0<=l?++o:--o)u.max=Math.max(u.max,u.buckets[r]);return u},i.prototype.y=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight(),0])},i.prototype.ySvg=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.h=function(){return this.innerHeight()/this.options.buckets},i.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},i.prototype._setupPaintCanvas=function(){return this.paintWidth=(this.options.windowSize+1)*this.w(),this.paintHeight=this.height*this.pixelRatio,this.paint=document.createElement("CANVAS"),this.paint.width=this.paintWidth,this.paint.height=this.paintHeight,this.p=Epoch.Util.getContext(this.paint),this.redraw(),this.on("after:shift","_paintEntry"),this.on("transition:end","_shiftPaintCanvas"),this.on("transition:end",(t=this,function(){return t.draw(t.animation.frame*t.animation.delta())}));var t},i.prototype.redraw=function(){var t,n;if(Epoch.isNonEmptyArray(this.data)&&Epoch.isNonEmptyArray(this.data[0].values)){for(n=this.data[0].values.length,t=this.options.windowSize,this.inTransition()&&t++;--n>=0&&--t>=0;)this._paintEntry(n,t);return this.draw(this.animation.frame*this.animation.delta())}},i.prototype._computeColor=function(t,n,e){return Epoch.Util.toRGBA(e,this._opacityFn(t,n))},i.prototype._paintEntry=function(t,n){var e,r,i,o,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E;for(null==t&&(t=null),null==n&&(n=null),k=(m=[this.w(),this.h()])[0],l=m[1],null==t&&(t=this.data[0].values.length-1),null==n&&(n=this.options.windowSize),u=[],r=function(){var t,n,e;for(e=[],t=0,n=this.options.buckets;0<=n?tn;0<=n?++t:--t)e.push(0);return e}.call(this),v=0,h=0,p=(x=this.getVisibleLayers()).length;h0||this.options.paintZeroValues)&&(this.p.fillStyle=this._computeColor(M,y,i),this.p.fillRect(E,(c-1)*l,k-this.options.bucketPadding,l-this.options.bucketPadding)),w.push(c--)}return w},i.prototype._shiftPaintCanvas=function(){var t;return t=this.p.getImageData(this.w(),0,this.paintWidth-this.w(),this.paintHeight),this.p.putImageData(t,0,0)},i.prototype._avgLab=function(t,n){var e,r,i,o,u,s,l,c,h,f,p;for(l=(f=[0,0,0,0])[0],e=f[1],r=f[2],p=f[3],s=0,c=t.length;s=-2&&--o>=0;)e=[(r+1)*h+t,f(a.values[o].y)],c&&(e[0]+=h),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,e):this.ctx.lineTo.apply(this.ctx,e);this.ctx.stroke()}return n.__super__.draw.call(this)},n}(Epoch.Time.Plot),Epoch._typeMap={area:Epoch.Chart.Area,bar:Epoch.Chart.Bar,line:Epoch.Chart.Line,pie:Epoch.Chart.Pie,scatter:Epoch.Chart.Scatter,histogram:Epoch.Chart.Histogram,"time.area":Epoch.Time.Area,"time.bar":Epoch.Time.Bar,"time.line":Epoch.Time.Line,"time.gauge":Epoch.Time.Gauge,"time.heatmap":Epoch.Time.Heatmap},m=function(t){return t.fn.epoch=function(t){var n,e;return t.el=this.get(0),null==(n=this.data("epoch-chart"))&&(null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",n=new e(t))),n}},null!=window.jQuery&&m(jQuery),x=function(){return Element.implement("epoch",(function(t){var n,e,r;return null==(n=(r=$$(this)).retrieve("epoch-chart")[0])&&(t.el=this,null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),r.store("epoch-chart",n=new e(t))),n}))},null!=window.MooTools&&x(),_=function(t){var n,e,r;return e={},n=0,r=function(){return"epoch-chart-"+ ++n},t.extend(t.fn,{epoch:function(t){var n,i,o;return null!=(i=this.data("epoch-chart"))?e[i]:(t.el=this.get(0),null==(o=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",i=r()),n=new o(t),e[i]=n,n)}})},null!=window.Zepto&&_(Zepto); \ No newline at end of file diff --git a/SystemControl/build/debug/package.json b/SystemControl/build/debug/package.json index 35460c1..550bed3 100644 --- a/SystemControl/build/debug/package.json +++ b/SystemControl/build/debug/package.json @@ -13,7 +13,7 @@ "dependencies": [ "Antunnel@0.1.8-a" ], - "version":"0.1.6-a", + "version":"0.1.7-a", "category":"Other", "iconclass":"fa fa-android", "mimes":["none"], diff --git a/SystemControl/build/release/SystemControl.zip b/SystemControl/build/release/SystemControl.zip index 18d8d8ee9b2303b3e7bf8805a4e643667ee660d1..1be37135dab290ff3029f0cb7d0df92ced6a8d07 100644 GIT binary patch delta 291 zcmX@`TkzIzLGb`@W)?065Lh%)B-b;mf%nXGa#gDRzCKeQ^sg-187V807dWEH# zB^sJK&DUAmud^}&G1Kxo9OxwS)GOx;D z+A*hnQ6BU5MR_bgn3;CY**>R;rH&26kf~%j%gC`4Xu=U^roinVt60Jr8O^49*02=u zqL@4VL=B6EJV@yJmRChrm>C&Bm;>wp7*R8wzm`QDXzX;2S{51EvLY6S;^d6f+*G}c xlH8mCZ$>5&28fe^N)mxen7&m^uLo*@J7D^}S{5 cleanup: () -> + @app.quit() if @app @sub.close() if @sub diff --git a/SystemControl/package.json b/SystemControl/package.json index 35460c1..550bed3 100644 --- a/SystemControl/package.json +++ b/SystemControl/package.json @@ -13,7 +13,7 @@ "dependencies": [ "Antunnel@0.1.8-a" ], - "version":"0.1.6-a", + "version":"0.1.7-a", "category":"Other", "iconclass":"fa fa-android", "mimes":["none"], diff --git a/packages.json b/packages.json index 24d1fde..0789833 100644 --- a/packages.json +++ b/packages.json @@ -235,8 +235,8 @@ "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/SystemControl/README.md", "category": "Other", "author": "", - "version": "0.1.6-a", - "dependencies": ["Antunnel@0.1.8-a"],"version":"0.1.6-a","category":"Other","iconclass":"fafa-android","mimes":["none"], + "version": "0.1.7-a", + "dependencies": ["Antunnel@0.1.8-a"],"version":"0.1.7-a","category":"Other","iconclass":"fafa-android","mimes":["none"], "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/SystemControl/build/release/SystemControl.zip" }, {