var base1,base2,base3;(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=t[0].app,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.app.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.max_net_range=2048,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",[{path:this.meta().path,type:"app",app:this}]).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,s,u,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=[],s=0,c=n.length;s").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(u=0,h=n.length;um?v:m],this.streamline("memory",u,l,["RAM (GB)","SWAP (GB)"]),h=0,f=0,i=0,a=(g=t.net).length;ithis.max_net_range&&(this.max_net_range=c[0].y),c[1].y>this.max_net_range&&(this.max_net_range=c[1].y),this.streamline("network",c,[0,this.max_net_range],["RX (Kb/s)","TX (Kb/s)"]),y=[{time:p,y:(t.cpu_temp/1e3).toFixed(2)},{time:p,y:(t.gpu_temp/1e3).toFixed(2)}],this.streamline("temp",y,[0,100],["CPU temp (C)","GPU temp (C)"]),n=[(t.battery_min_voltage/1e3).toFixed(2),(t.battery_max_voltage/1e3).toFixed(2)],this.streamline("battery",[{time:p,y:(t.battery/1e3).toFixed(2)}],n,["Baterry (v)"])}cleanup(){if(this.service)return this.service.app=void 0,this.service=void 0}}).singleton=!0,n.dependencies=["pkg://Antunnel/main.js"],this.OS.register("SystemControl",n)}).call(this),function(){var t={version:"3.5.17"},n=[].slice,e=function(t){return n.call(t)},r=this.document;function i(t){return t&&(t.ownerDocument||t.document||t).documentElement}function o(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(r)try{e(r.documentElement.childNodes)[0].nodeType}catch(t){e=function(t){for(var n=t.length,e=new Array(n);n--;)e[n]=t[n];return e}}if(Date.now||(Date.now=function(){return+new Date}),r)try{r.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var a=this.Element.prototype,s=a.setAttribute,u=a.setAttributeNS,l=this.CSSStyleDeclaration.prototype,c=l.setProperty;a.setAttribute=function(t,n){s.call(this,t,n+"")},a.setAttributeNS=function(t,n,e){u.call(this,t,n,e+"")},l.setProperty=function(t,n,e){c.call(this,t,n+"",e)}}function h(t,n){return tn?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/(u-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 P(t,n){if(n in t)return n;n=n.charAt(0).toUpperCase()+n.slice(1);for(var e=0,r=F.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 u,l,c,h,f=-1,p=o.length,g=i[s++],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 j(t){return I(t,$),t}var H=function(t,n){return n.querySelector(t)},V=function(t,n){return n.querySelectorAll(t)},B=function(t,n){var e=t.matches||t[P(t,"matchesSelector")];return(B=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(H=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 H(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,s=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=ut.apply(this,arguments);for(var n=-1,e=this.length;++n=n&&(n=i+1);!(a=s[n])&&++n0&&(n=n.slice(0,a));var u=gt.get(n);function l(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}return u&&(n=u,s=yt),a?r?function(){var t=s(r,e(arguments));l.call(this),this.addEventListener(n,this[o]=t,t.$=i),t._=r}:l:r?L: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=[],s=-1,u=this.length;++s0?1:t<0?-1:0}function Ft(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function Lt(t){return t>1?0:t<-1?Et:Math.acos(t)}function zt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Dt(t){return((t=Math.exp(t))+1/t)/2}function Rt(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],s=n[0],u=n[1],l=n[2],c=s-i,h=u-o,f=c*c+h*h;if(f0&&(n=n.transition().duration(d)),n.call(b.event)}function A(){l&&l.domain(u.range().map((function(t){return(t-f.x)/f.k})).map(u.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 P(){var n=this,e=w.of(n,arguments),r=0,i=t.select(o(n)).on(m,u).on(x,l),a=M(t.mouse(n)),s=xt(n);function u(){r=1,E(t.mouse(n),a),N(e)}function l(){i.on(m,null).on(x,null),s(r),T(e)}ds.call(n),C(e)}function F(){var n,e=this,r=w.of(e,arguments),i={},o=0,a=".zoom-"+t.event.changedTouches[0].identifier,u="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(u,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,u,l,c,h=t.touches(e);ds.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 Ht(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ht(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 jt;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 jt;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):un(""+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 jt;function sn(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function un(t,n,e){var r,i,o,a=0,s=0,u=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return n(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,s=240&o,s|=s>>4,u=15&o,u|=u<<4):7===t.length&&(a=(16711680&o)>>16,s=(65280&o)>>8,u=255&o)),n(a,s,u))}function ln(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),s=a-o,u=(a+o)/2;return s?(i=u<.5?s/(a+o):s/(2-a-o),r=t==a?(n-e)/s+(n0&&u<1?0:r),new Ht(r,i,u)}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 s.error.call(a,t)}s.load.call(a,t)}else s.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{s.progress.call(a,l)}finally{t.event=e}},a.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?u[t]:(null==n?delete u[t]:u[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 u||(u.accept=r+",*/*"),l.setRequestHeader)for(var o in u)l.setRequestHeader(o,u[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)})),s.beforesend.call(a,l),l.send(null==e?null:e),a},a.abort=function(){return l.abort(),a},t.rebind(a,s,"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 s(n){return n.map(u).join(t)}function u(t){return e.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,n){var e;return i.parseRows(t,(function(t,r){if(e)return e(t,r-1);var i=new Function("d","return {"+t.map((function(t,n){return JSON.stringify(t)+": d["+n+"]"})).join(",")+"}");e=n?function(t,e){return n(i(t),e)}:i}))},i.parseRows=function(t,n){var e,i,o={},a={},s=[],u=t.length,l=0,c=0;function h(){if(l>=u)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,s=i[0],u=0;e>0&&s>0&&(u+s+1>n&&(s=Math.max(1,n-u)),o.push(t.substring(e-=s,e+s)),!((u+=s+1)>n));)s=i[a=(a+1)%i.length];return o.reverse().join(r)}:N;return function(n){var r=Nn.exec(n),i=r[1]||" ",s=r[2]||">",u=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&&"="===s)&&(c=i="0",s="="),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)||Pn;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,"-"):"-"===u?"":u;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"===s?S+o+n:"^"===s?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 Pn(t){return t+""}var Fn=t.time={},Ln=Date;function zn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}zn.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(){Dn.setUTCDate.apply(this._,arguments)},setDay:function(){Dn.setUTCDay.apply(this._,arguments)},setFullYear:function(){Dn.setUTCFullYear.apply(this._,arguments)},setHours:function(){Dn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Dn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Dn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Dn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Dn.setUTCSeconds.apply(this._,arguments)},setTime:function(){Dn.setTime.apply(this._,arguments)}};var Dn=Date.prototype;function Rn(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(s++))){if(a=n.charAt(s++),!(o=b[a in On?n.charAt(s++):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(Ln=zn);return e._=t,n(e)}finally{Ln=Date}}return e.parse=function(t){try{Ln=zn;var e=n.parse(t);return e&&e._}finally{Ln=Date}},e.toString=n.toString,e},c.multi=c.utc.multi=ae;var f=t.map(),p=Vn(a),g=Bn(a),d=Vn(s),y=Bn(s),v=Vn(u),m=Bn(u),x=Vn(l),_=Bn(l);o.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return s[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:c(e),d:function(t,n){return Hn(t.getDate(),n,2)},e:function(t,n){return Hn(t.getDate(),n,2)},H:function(t,n){return Hn(t.getHours(),n,2)},I:function(t,n){return Hn(t.getHours()%12||12,n,2)},j:function(t,n){return Hn(1+Fn.dayOfYear(t),n,3)},L:function(t,n){return Hn(t.getMilliseconds(),n,3)},m:function(t,n){return Hn(t.getMonth()+1,n,2)},M:function(t,n){return Hn(t.getMinutes(),n,2)},p:function(t){return o[+(t.getHours()>=12)]},S:function(t,n){return Hn(t.getSeconds(),n,2)},U:function(t,n){return Hn(Fn.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return Hn(Fn.mondayOfYear(t),n,2)},x:c(r),X:c(i),y:function(t,n){return Hn(t.getFullYear()%100,n,2)},Y:function(t,n){return Hn(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}Fn.year=Rn((function(t){return(t=Fn.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),Fn.years=Fn.year.range,Fn.years.utc=Fn.year.utc.range,Fn.day=Rn((function(t){var n=new Ln(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})),Fn.days=Fn.day.range,Fn.days.utc=Fn.day.utc.range,Fn.dayOfYear=function(t){var n=Fn.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=Fn[t]=Rn((function(t){return(t=Fn.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=Fn.year(t).getDay();return Math.floor((Fn.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));Fn[t+"s"]=e.range,Fn[t+"s"].utc=e.utc.range,Fn[t+"OfYear"]=function(t){var e=Fn.year(t).getDay();return Math.floor((Fn.dayOfYear(t)+(e+n)%7)/7)}})),Fn.week=Fn.sunday,Fn.weeks=Fn.sunday.range,Fn.weeks.utc=Fn.sunday.utc.range,Fn.weekOfYear=Fn.sundayOfYear;var On={"-":"",_:" ",0:"0"},In=/^\s*\d+/,jn=/^%/;function Hn(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+Hn(r,"0",2)+Hn(i,"0",2)}function oe(t,n,e){jn.lastIndex=0;var r=jn.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,s=a*o,u=Math.cos(n),l=Math.sin(n),c=i*l,h=r*u+c*Math.cos(s),f=c*a*Math.sin(s);Ce.add(Math.atan2(f,h)),e=t,r=u,i=l}Ne.point=function(a,s){Ne.point=o,e=(t=a)*Nt,r=Math.cos(s=(n=s)*Nt/2+Et/4),i=Math.sin(s)},Ne.lineEnd=function(){o(t,n)}}function Pe(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 Fe(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Le(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 ze(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function De(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Re(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]),zt(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 s=Pe([t*Nt,a*Nt]);if(u){var l=Le(u,s),c=Le([l[1],-l[0],0],l);Re(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);u=s,o=t}function d(){f.point=g}function y(){h[0]=n,h[1]=r,f.point=p,u=null}function m(t,n){if(u){var e=t-o;l+=v(e)>180?e+(e>0?360:-360):e}else a=t,s=n;Ne.point(t,n),g(t,n)}function x(){Ne.lineStart()}function _(){m(a,s),Ne.lineEnd(),v(l)>Mt&&(n=-(r=180)),h[0]=n,h[1]=r,u=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])):s.push(d=p);for(var u,l,p,g=-1/0,d=(a=0,s[l=s.length-1]);a<=l;d=p,++a)p=s[a],(u=w(d[1],p[0]))>g&&(g=u,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;--s)i.point((h=c[s])[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=Le(Pe(h),Pe(t));Re(S);var A=Le(i,S);Re(A);var C=(k^w>=0?-1:1)*zt(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())),s.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:L,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 s=o>0?Et:-Et,u=v(o-e);v(u-Et)0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),n=0):i!==s&&u>=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(s,r),n=0),t.point(e=o,r=a),i=s},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*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,s,u,l,c;return{lineStart:function(){l=u=!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=u=d)&&t.lineStart(),d!==u&&(p=o(n,g),(Ue(n,p)||Ue(g,p))&&(g[0]+=Mt,g[1]+=Mt,d=i(g[0],g[1]))),d!==u)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&s||!(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,u=d,s=y},lineEnd:function(){u&&t.lineEnd(),n=null},clean:function(){return c|(l&&u)<<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=Le(Pe(t),Pe(e)),a=Fe(o,o),s=o[0],u=a-s*s;if(!u)return!r&&t;var l=n*a/u,c=-n*s/u,h=Le(i,o),f=De(i,l);ze(f,De(o,c));var p=h,g=Fe(f,p),d=Fe(p,p),y=g*g-d*(Fe(f,f)-1);if(!(y<0)){var m=Math.sqrt(y),x=De(p,(-g-m)/d);if(ze(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=De(p,(-g+m)/d);return ze(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,s=i.b,u=a.x,l=a.y,c=0,h=1,f=s.x-u,p=s.y-l;if(o=t-u,f||!(o>0)){if(o/=f,f<0){if(o0){if(o>h)return;o>c&&(c=o)}if(o=e-u,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:u+c*f,y:l+c*p}),h<1&&(i.b={x:u+h*f,y:l+h*p}),i}}}}}}function rr(n,e,r,i){return function(u){var l,c,h,f,p,g,d,y,v,m,x,_=u,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&&u.lineEnd()},polygonStart:function(){u=w,l=[],c=[],x=!0},polygonEnd:function(){u=_,l=t.merge(l);var e=function(t){for(var n=0,e=c.length,r=t[1],i=0;ir&&Ft(l,o,t)>0&&++n:o[1]<=r&&Ft(l,o,t)<0&&--n,l=o;return 0!==n}([n,i]),r=x&&e,o=l.length;(r||o)&&(u.polygonStart(),r&&(u.lineStart(),k(null,null,1,u),u.lineEnd()),o&&We(l,a,e,k,u),u.polygonEnd()),l=c=h=null}};function k(t,a,u,l){var c=0,h=0;if(null==t||(c=o(t,u))!==(h=o(a,u))||s(t,a)<0^u>0)do{l.point(0===c||3===c?n:r,c>1?i:e)}while((c=(c+u+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)&&u.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&&(u.lineStart(),u.point(t,n));else if(e&&v)u.point(t,n);else{var r={a:{x:d,y:y},b:{x:t,y:n}};b(r)?(v||(u.lineStart(),u.point(r.a.x,r.a.y)),u.point(r.b.x,r.b.y),e||u.lineEnd(),x=!1):e&&(u.lineStart(),u.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 s(t.x,n.x)}function s(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,zt((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(s){return arguments.length?(o=rr(t=+s[0][0],n=+s[0][1],e=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(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]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),u={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?s:o).invert(t)},l.stream=function(t){var n=o.stream(t),e=a.stream(t),r=s.stream(t);return{point:function(t,i){n.point(t,i),e.point(t,i),r.point(t,i)},sphere:function(){n.sphere(),e.sphere(),r.sphere()},lineStart:function(){n.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){n.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){n.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){n.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},l.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),s.precision(t),l):o.precision()},l.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),s.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(u).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(u).point,i=s.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(u).point,l},l.scale(1070)};var ar,sr,ur,lr,cr,hr,fr={point:L,lineStart:L,lineEnd:L,polygonStart:function(){sr=0,fr.lineStart=pr},polygonEnd:function(){fr.lineStart=fr.lineEnd=fr.point=L,ar+=v(sr/2)}};function pr(){var t,n,e,r;function i(t,n){sr+=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:L,lineEnd:L,polygonStart:L,polygonEnd:L};function dr(){var t=yr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=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 s(){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=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:L};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 s(){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,u,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=Pe([e,i]),a=t(e,i);s(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,u=g,l=d,y.point=x}function M(){s(h,f,c,p,g,d,i,o,e,a,u,l,r,n),y.lineEnd=_,_()}return y}function s(r,i,o,a,u,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=u+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*P+_*F)/w-.5)>.3||a*p+u*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,s,u=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=Lr(g,d,y),e);var t=e(f,p);return o=c-t[0]*l,a=h+t[1]*l,k()}function k(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Tr(v(r,u(m(t))))).valid=!0,s},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,u,"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 Pr(t,n){return[t,n]}function Fr(t,n){return[t>Et?t-St:t<-Et?t+St:t,n]}function Lr(t,n,e){return t?n||e?$e(Dr(t),Rr(n,e)):Dr(t):n||e?Rr(n,e):Fr}function zr(t){return function(n,e){return[(n+=t)>Et?n-St:n<-Et?n+St:n,e]}}function Dr(t){var n=zr(t);return n.invert=zr(-t),n}function Rr(t,n){var e=Math.cos(t),r=Math.sin(t),i=Math.cos(n),o=Math.sin(n);function a(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,l=Math.sin(n),c=l*e+s*r;return[Math.atan2(u*i-c*o,s*e-l*r),zt(c*i+u*o)]}return a.invert=function(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,l=Math.sin(n),c=l*i-u*o;return[Math.atan2(u*i+l*o,s*e+c*r),zt(c*e-s*r)]},a}function qr(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,s){var u=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*u);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},Fr.invert=Pr,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=Lr(-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),s=Math.cos(r),u=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-u*h*s)*e),u*c+l*h*s)},t.geo.graticule=function(){var n,e,r,i,o,a,s,u,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(u/y)*y,s,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(s).slice(1),h(r).reverse().slice(1),f(u).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],u=+t[0][1],s=+t[1][1],i>r&&(t=i,i=r,r=t),u>s&&(t=u,u=s,s=t),x.precision(m)):[[i,u],[r,s]]},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(u,s,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=jr,i=Hr;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),s=Math.sin(r),u=Math.cos(o),l=Math.sin(o),c=a*Math.cos(e),h=a*Math.sin(e),f=u*Math.cos(i),p=u*Math.sin(i),g=2*Math.asin(Math.sqrt(Rt(o-r)+a*u*Rt(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*s+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,s,u,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:L,point:L,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=Nt),a=Math.cos(i),s=v((r*=Nt)-t),u=Math.cos(s);vr+=Math.atan2(Math.sqrt((s=a*Math.sin(s))*s+(s=e*o-n*a*u)*s),n*o+e*a*u),t=r,n=o,e=a}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=L}},lineEnd:L,polygonStart:L,polygonEnd:L};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=Pt(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&&Ft(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,s=[],u=[];for(r=0;r=0;--r)p.push(t[s[l[r]][2]]);for(r=+h;rMt)s=s.L;else{if(!((i=o-bi(s,a))>Mt)){r>-Mt?(n=s.P,e=s):i>-Mt?(n=s,e=s.N):n=e=s;break}if(!s.R){n=s;break}s=s.R}var u=vi(t);if(hi.insert(n,u),n||e){if(n===e)return Ai(n),e=vi(n.site),hi.insert(u,e),u.edge=e.edge=Ti(n.site,u.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};Pi(e.edge,l,g,_),u.edge=Ti(l,t,null,_),e.edge=Ti(t,g,null,_),Si(n),Si(e)}else u.edge=Ti(n.site,u.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 s=(e=a.site).x,u=e.y,l=u-n;if(!l)return s;var c=s-r,h=1/o-1/l,f=c/l;return h?(-f+Math.sqrt(f*f-2*h*(c*c/(-2*l)-u+l/2+i-o/2)))/h+r:(r+s)/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(){zi(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,s=i.y,u=r.x-a,l=r.y-s,c=o.x-a,h=2*(u*(y=o.y-s)-l*c);if(!(h>=-kt)){var f=u*u+l*l,p=c*c+y*y,g=(y*f-l*p)/h,d=(u*p-c*f)/h,y=d+s,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=s)return;if(f>g){if(o){if(o.y>=l)return}else o={x:y,y:u};e={x:y,y:l}}else{if(o){if(o.y1)if(f>g){if(o){if(o.y>=l)return}else o={x:(u-i)/r,y:u};e={x:(l-i)/r,y:l}}else{if(o){if(o.y=s)return}else o={x:a,y:r*a+i};e={x:s,y:r*s+i}}else{if(o){if(o.xMt||v(i-e)>Mt)&&(s.splice(a,0,new Fi((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[s]})),n}function s(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(s(t)).edges.filter((function(t){return t.l&&t.r})).map((function(n){return{source:t[n.l.i],target:t[n.r.i]}}))},a.triangles=function(t){var n=[];return Ui(s(t)).cells.forEach((function(e,r){for(var i,o,a,s,u=e.site,l=e.edges.sort(ki),c=-1,h=l.length,f=l[h-1].edge,p=f.l===u?f.r:f.l;++co||h>a||f=w)<<1|n>=_,M=b+4;bo&&(i=n.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(e=e[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Wi(e,r)})),o=Gi.lastIndex;return od&&(d=u.x),u.y>y&&(y=u.y),l.push(u.x),c.push(u.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,s){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var u=t.x,l=t.y;if(null!=u)if(v(u-e)+v(l-r)<.01)E(t,n,e,r,i,o,a,s);else{var c=t.point;t.x=t.y=t.point=null,E(t,c,u,l,i,o,a,s),E(t,n,e,r,i,o,a,s)}else t.x=e,t.y=r,t.point=n}else E(t,n,e,r,i,o,a,s)}function E(t,n,e,r,i,o,a,s){var u=.5*(i+a),l=.5*(o+s),c=e>=u,h=r>=l,f=h<<1|c;t.leaf=!1,c?i=u:a=u,h?o=l:s=l,k(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,s)}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,s=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 so(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 uo(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),s=go(i,o),u=yo(((n=o)[0]+=(r=-s)*(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,s=e.c-i,u=e.l-o;return isNaN(s)&&(s=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+s*t,o+u*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,s=e.s-i,u=e.l-o;return isNaN(s)&&(s=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+s*t,o+u*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,s=e.a-i,u=e.b-o;return function(t){return Qt(r+a*t,i+s*t,o+u*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,u.end({type:"end",alpha:r=0})):t>0&&(u.start({type:"start",alpha:r=t}),n=bn(s.tick)),s):r},s.start=function(){var t,n,e,r=v.length,u=m.length,c=l[0],g=l[1];for(t=0;t=0;)e.push(i[r])}function Lo(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[u]),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 Lo(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),s}return r.sort=function(n){return arguments.length?(t=n,r):t},r.children=function(t){return arguments.length?(n=t,r):n},r.value=function(t){return arguments.length?(e=t,r):e},r.revalue=function(t){return e&&(Fo(t,(function(t){t.children&&(t.value=0)})),Lo(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,s,u,l=-1;for(r=n.value?r/n.value:0;++ls&&(s=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)&&(u=n.length)){var n,e,r,i,o,a,s,u,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),u>1&&((r=n[1]).x=r.r,r.y=0,x(r),u>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]&&u<=h[1]&&((s=l[t.bisect(f,u,1,g)-1]).y+=d,s.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),s=a[0],u=i[0],l=i[1],c=null==n?Math.sqrt:"function"==typeof n?n:function(){return n};if(s.x=s.y=0,Lo(s,(function(t){t.r=+c(t.value)})),Lo(s,ea),r){var h=r*(n?1:Math.max(2*s.r/u,2*s.r/l))/2;Lo(s,(function(t){t.r+=h})),Lo(s,ea),Lo(s,(function(t){t.r-=h}))}return function t(n,e,r,i){var o=n.children;if(n.x=e+=i*n.x,n.y=r+=i*n.y,n.r*=i,o)for(var a=-1,s=o.length;++ap.x&&(p=t),t.depth>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);Fo(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,s=n,u=o.parent.children[0],l=o.m,c=a.m,h=s.m,f=u.m;s=ua(s),o=sa(o),s&&o;)u=sa(u),(a=ua(a)).a=t,(i=s.z+h-o.z-l+e(s._,o._))>0&&(la(ca(s,t,r),t,i),l+=i,c+=i),h+=s.m,l+=o.m,f+=u.m,c+=a.m;s&&!ua(a)&&(a.t=s,a.m+=h-c),o&&!sa(u)&&(u.t=o,u.m+=l-f,r=t)}return r}(t,i,t.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=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)?u:null,o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:u,o):i?r:null},Po(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 s,u=n.call(this,o,a),l=u[0],c=0;Lo(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=s?c+=e(n,s):0,n.y=0,s=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 Lo(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]}),u}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},Po(o,n)},t.layout.treemap=function(){var n,e=t.layout.hierarchy(),r=Math.round,i=[1,1],o=null,a=ha,s=!1,u="squarify",l=.5*(1+Math.sqrt(5));function c(t,n){for(var e,r,i=-1,o=t.length;++i0;)s.push(e=l[i-1]),s.area+=e.area,"squarify"!==u||(r=p(s,d))<=f?(l.pop(),f=r):(s.area-=s.pop().area,g(s,d,o,!1),d=Math.min(o.dx,o.dy),s.length=s.area=0,f=1/0);s.length&&(g(s,d,o,!0),s.length=s.area=0),n.forEach(h)}}function f(t){var n=t.children;if(n&&n.length){var e,r=a(t),i=n.slice(),o=[];for(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,s=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,s=t.length,u=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,s=i?wo:_o;return o=t(n,e,s,r),a=t(e,n,s,Qi),u}function u(t){return o(t)}return u.invert=function(t){return a(t)},u.domain=function(t){return arguments.length?(n=t.map(Number),s()):n},u.range=function(t){return arguments.length?(e=t,s()):e},u.rangeRound=function(t){return u.range(t).interpolate(fo)},u.clamp=function(t){return arguments.length?(i=t,s()):i},u.interpolate=function(t){return arguments.length?(r=t,s()):r},u.ticks=function(t){return Ma(n,t)},u.tickFormat=function(t,e){return ka(n,t,e)},u.nice=function(t){return wa(n,t),s()},u.copy=function(){return t(n,e,r,i)},s()}([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 s(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function u(t){return e(a(t))}return u.invert=function(t){return s(e.invert(t))},u.domain=function(t){return arguments.length?(i=t[0]>=0,e.domain((o=t.map(Number)).map(a)),u):o},u.base=function(t){return arguments.length?(r=+t,e.domain(o.map(a)),u):r},u.nice=function(){var t=ya(o.map(a),i?Math:Ca);return e.domain(t),o=t.map(s),u},u.ticks=function(){var t=pa(o),n=[],e=t[0],u=t[1],l=Math.floor(a(e)),c=Math.ceil(a(u)),h=r%1?2:r;if(isFinite(c-l)){if(i){for(;l0;f--)n.push(s(l)*f);for(l=0;n[l]u;c--);n=n.slice(l,c)}return n},u.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/u.ticks().length);return function(t){var n=t/s(Math.round(a(t)));return n*r0?i[t-1]:e[0],th?0:1;if(l=At)return u(l,p)+(s?u(s,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===Da?Math.sqrt(s*s+l*l):+r.apply(this,arguments),p||(A*=-1),l&&(A=zt(y/l*Math.sin(v))),s&&(S=zt(y/s*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&&ja(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(s){b=s*Math.cos(h-S),M=s*Math.sin(h-S),k=s*Math.cos(c+S),E=s*Math.sin(c+S);var P=Math.abs(c-h+2*S)<=Et?0:1;if(S&&ja(b,M,k,E)===1-p^P){var F=(c+h)/2;b=s*Math.cos(F),M=s*Math.sin(F),k=E=null}}else b=M=0;if(f>Mt&&(g=Math.min(Math.abs(l-s)/2,+e.apply(this,arguments)))>.001){d=s0?0:1}function Ha(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],s=(i?r:-r)/Math.sqrt(o*o+a*a),u=s*a,l=-s*o,c=t[0]+u,h=t[1]+l,f=n[0]+u,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-u,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 s(o){var s,u=[],l=[],c=-1,h=o.length,f=gn(n),p=gn(e);function g(){u.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(ns,o)+","+Ja(ns,a)),--r;++r9&&(i=3*n/Math.sqrt(i),a[s]=i*e,a[s+1]=i*r);for(s=-1;++s<=u;)i=(t[Math.min(u,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+a[s]*a[s])),o.push([i||0,a[s]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function 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){s=n[1],o=t[u],u++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-s[0])+","+(o[1]-s[1])+","+o[0]+","+o[1];for(var l=2;lEt)+",1 "+n}function u(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=jr,n=Hr,e=ss;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),s=(o.y+a.y)/2,u=[o,{x:o.x,y:s},{x:a.x,y:s},a];return"M"+(u=u.map(e))[0]+"C"+u[1]+" "+u[2]+" "+u[3]}return r.source=function(n){return arguments.length?(t=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=ss,r=n.projection;return n.projection=function(t){return arguments.length?r(us(e=t)):e},n},t.svg.symbol=function(){var t=cs,n=ls;function e(e,r){return(fs.get(t.call(this,e,r))||hs)(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 fs=t.map({circle:hs,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*gs)),e=n*gs;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/ps),e=n*ps/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/ps),e=n*ps/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});t.svg.symbolTypes=fs.keys();var ps=Math.sqrt(3),gs=Math.tan(30*Nt);$.transition=function(t){for(var n,e,r=ms||++ws,i=ks(t),o=[],a=xs||{time:Date.now(),ease:so,delay:0,duration:250},s=-1,u=this.length;++s0;)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)}_s.call=$.call,_s.empty=$.empty,_s.node=$.node,_s.size=$.size,t.transition=function(n,e){return n&&n.transition?ms?n.transition(e):n:t.selection().transition(n)},t.transition.prototype=_s,_s.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=Y(t);for(var s=-1,u=this.length;++srect,.s>rect").attr("width",s[1]-s[0])}function d(t){t.select(".extent").attr("y",u[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",u[1]-u[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",P);if(t.event.changedTouches?A.on("touchmove.brush",F).on("touchend.brush",z):A.on("mousemove.brush",F).on("mouseup.brush",z),_.interrupt().selectAll("*").interrupt(),k)S[0]=s[0]-S[0],S[1]=u[0]-S[1];else if(w){var C=+/w$/.test(w),N=+/^n/.test(w);y=[s[1-C]-S[0],u[1-N]-S[1]],S[0]=s[C],S[1]=u[N]}else t.event.altKey&&(h=S.slice());function T(){32==t.event.keyCode&&(k||(h=null,S[0]-=s[1],S[1]-=u[1],k=2),R())}function P(){32==t.event.keyCode&&2==k&&(S[0]+=s[1],S[1]+=u[1],k=0,R())}function F(){var n=t.mouse(v),e=!1;y&&(n[0]+=y[0],n[1]+=y[1]),k||(t.event.altKey?(h||(h=[(s[0]+s[1])/2,(u[0]+u[1])/2]),S[0]=s[+(n[0]1?{floor:function(n){for(;s(n=t.floor(n));)n=qs(n-1);return n},ceil:function(n){for(;s(n=t.ceil(n));)n=qs(+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],qs(+e[1]+1),n<1?1:n)},i.tickFormat=function(){return r},i.copy=function(){return Rs(n.copy(),e,r)},_a(i,n)}function qs(t){return new Date(t)}Fs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ds:zs,Ds.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Ds.toString=zs.toString,Fn.second=Rn((function(t){return new Ln(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),Fn.seconds=Fn.second.range,Fn.seconds.utc=Fn.second.utc.range,Fn.minute=Rn((function(t){return new Ln(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),Fn.minutes=Fn.minute.range,Fn.minutes.utc=Fn.minute.utc.range,Fn.hour=Rn((function(t){var n=t.getTimezoneOffset()/60;return new Ln(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),Fn.hours=Fn.hour.range,Fn.hours.utc=Fn.hour.utc.range,Fn.month=Rn((function(t){return(t=Fn.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),Fn.months=Fn.month.range,Fn.months.utc=Fn.month.utc.range;var Us=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Os=[[Fn.second,1],[Fn.second,5],[Fn.second,15],[Fn.second,30],[Fn.minute,1],[Fn.minute,5],[Fn.minute,15],[Fn.minute,30],[Fn.hour,1],[Fn.hour,3],[Fn.hour,6],[Fn.hour,12],[Fn.day,1],[Fn.day,2],[Fn.week,1],[Fn.month,1],[Fn.month,3],[Fn.year,1]],Is=Fs.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]]),js={range:function(n,e,r){return t.range(Math.ceil(n/r)*r,+e,r).map(qs)},floor:N,ceil:N};Os.year=Fn.year,Fn.scale=function(){return Rs(t.scale.linear(),Os,Is)};var Hs=Os.map((function(t){return[t[0].utc,t[1]]})),Vs=Ls.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 Bs(t){return JSON.parse(t.responseText)}function $s(t){var n=r.createRange();return n.selectNode(r.body),n.createContextualFragment(t.responseText)}Hs.year=Fn.year.utc,Fn.scale.utc=function(){return Rs(t.scale.linear(),Hs,Vs)},t.text=dn((function(t){return t.responseText})),t.json=function(t,n){return yn(t,"application/json",Bs,n)},t.html=function(t,n){return yn(t,"text/html",$s,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==(base=window.Epoch).Chart&&(base.Chart={}),null==(base1=window.Epoch).Time&&(base1.Time={}),null==(base2=window.Epoch).Util&&(base2.Util={}),null==(base3=window.Epoch).Formats&&(base3.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)hasProp.call(t,e)&&(r=t[e],n[e]=r);return n},Epoch.Util.defaults=function(t,n){var e,r,i,o,a;for(i in a=Epoch.Util.copy(t),n)hasProp.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)?a[i]=Epoch.Util.defaults(o,r):a[i]=o:a[i]=null!=o?o:r);return a},Epoch.Util.formatSI=function(t,n,e){var r,i,o,a,s;if(null==n&&(n=1),null==e&&(e=!1),t<1e3)return((0|(a=t))!==a||e)&&(a=a.toFixed(n)),a;for(i in s=["K","M","G","T","P","E","Z","Y"])if(hasProp.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,a;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),u=[],o=0,a=(s=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 extend(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 extend(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),QueryCSS=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,s,u,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+="#"+u.id),null!=u.className&&u.className.length>0&&(M+="."+Epoch.Util.trim(u.className).replace(/\s+/g,".")),k.push(M);for(k.push("svg"),c=0,p=(_=Epoch.Util.trim(t).split(/\s+/)).length;ce)t.label=s[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=function(){var t,n,e,r,i,o,a;return n={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)},t=function(t,n,e){var r,i,o;if(i=[],Epoch.isArray(t[0]))for(r in t)hasProp.call(t,r)&&(o=t[r],i.push(applyLayerLabel({values:o.map(e)},n,parseInt(r))));else i.push(applyLayerLabel({values:t.map(e)},n,0));return i},r=function(n,e){return t(n,e,(function(t,n){return{x:e.x(t,n),y:e.y(t,n)}}))},a=function(n,e){return t(n,e,(function(t,n){return{time:e.time(t,n,e.startTime),y:e.y(t,n)}}))},i=function(n,e){return t(n,e,(function(t,n){return{time:e.time(t,n,e.startTime),histogram:t}}))},o=function(t,n){var e,r,i;for(e in r=[],t)if(hasProp.call(t,e)){if(i=t[e],!Epoch.isNumber(t[0]))return[];r.push(applyLayerLabel({value:i},n,e))}return r},(e=function(t,e){var s;return null==t&&(t=[]),null==e&&(e={}),Epoch.isNonEmptyArray(t)?"time.heatmap"===(s=Epoch.Util.defaults(e,n)).type?i(t,s):s.type.match(/^time\./)?a(t,s):"pie"===s.type?o(t,s):r(t,s):[]}).entry=function(t,r){var i,o,a,s,u,l,c,h;if(null==r&&(r={}),"time.gauge"===r.type)return null==t?0:(l=Epoch.Util.defaults(r,n),i=Epoch.isArray(t)?t[0]:t,l.y(i,0));if(null==t)return[];for(null==r.startTime&&(r.startTime=parseInt((new Date).getTime()/1e3)),o=Epoch.isArray(t)?t.map((function(t){return[t]})):[t],h=[],a=0,u=(c=e(o,r)).length;a-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)hasProp.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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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 extend(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,a,s,u,l,c,h,f,p,g;for(n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,h=[],i=0,u=t.length;in;0<=n?++t:--t)e.push(0);return e}.call(this),a=0,l=(p=s.values).length;a=this.options.buckets)||(r<0?r=0:r>=this.options.buckets&&(r=this.options.buckets-1),e[r]+=parseInt(c.y));for(o in f={values:e.map((function(t,e){return{x:parseInt(e)*n,y:t}}))},s)hasProp.call(s,o)&&(g=s[o],"values"!==o&&(f[o]=g));h.push(f)}return h},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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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 extend(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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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 extend(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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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 extend(e,t),n={type:"scatter",radius:3.5,axes:["top","bottom","left","right"]},e.prototype.draw=function(){var t,n,r,i,o,a,s;return o=[this.x(),this.y(),this.getVisibleLayers()],a=o[0],s=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 s(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 s(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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.hasOwnProperty,Epoch.Time.Plot=function(t){var n,e,r;function i(t){var o,a,s,u,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=(u=["top","right","bottom","left"]).length;o=0&&n>=0;)this._pushTick(t,r.values[n].time,!1,!0),t-=u,n-=u;break}return s},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)hasProp.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,s;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;is;t=0<=s?++e:--e){for(l=0,n=i=0,u=r.length;0<=u?iu;n=0<=u?++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?++s:--s)if(u=l[i]){for(this.setStyles(u),this.ctx.beginPath(),o=(f=[this.options.windowSize,u.values.length,this.inTransition()])[0],a=f[1],g=f[2];--o>=-2&&--a>=0;)n=[(o+1)*d+t,y((r=u.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,s,u,l,c,h,f,p,g;for(null==t&&(t=0),g=(u=[this.y(),this.w(),this.getVisibleLayers()])[0],p=u[1],h=[],r=o=l=(s=u[2]).length-1;l<=0?o<=0:o>=0;r=l<=0?++o:--o)if(a=s[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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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 extend(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,s,u,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],u=0,h=(p=this.getVisibleLayers()).length;u=s&&--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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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])*(s-g)+e,m=(f=h[1])*(s-g)+i,v=n*(s-g-d)+e,x=f*(s-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,s,-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,s-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),extend=function(t,n){for(var e in n)hasProp.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},hasProp={}.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 extend(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)hasProp.call(s,l)&&(e=s[l],i=parseInt((l-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),a.buckets[i]+=parseInt(e)));for(r=o=0,u=a.buckets.length;0<=u?ou;r=0<=u?++o:--o)a.max=Math.max(a.max,a.buckets[r]);return a},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,a,s,u,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k;for(null==t&&(t=null),null==n&&(n=null),M=(v=[this.w(),this.h()])[0],u=v[1],null==t&&(t=this.data[0].values.length-1),null==n&&(n=this.options.windowSize),a=[],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),y=0,c=0,f=(m=this.getVisibleLayers()).length;c0||this.options.paintZeroValues)&&(this.p.fillStyle=this._computeColor(b,d,i),this.p.fillRect(k,(l-1)*u,M-this.options.bucketPadding,u-this.options.bucketPadding)),_.push(l--)}return _},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,a,s,u,l,c,h,f;for(u=(h=[0,0,0,0])[0],e=h[1],r=h[2],f=h[3],s=0,l=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},jQueryModule=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&&jQueryModule(jQuery),MooToolsModule=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&&MooToolsModule(),zeptoModule=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&&zeptoModule(Zepto);