mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-18 03:08:24 +01:00
1 line
220 KiB
JavaScript
1 line
220 KiB
JavaScript
var t,n,e;(function(){var t,n;t=class extends OS.application.BaseService{constructor(t){super("SysmondService",t),this.text=__("{0}%",(0).toString()),this.iconclass="fa fa-android",this.app=void 0,this.onmenuselect=t=>this.openApp()}setting(){return this.systemsetting.applications.SystemControl}init(){var t;return t=()=>{if(Antunnel.tunnel){if(!this.setting().topic)return;return this.tunnel=Antunnel.tunnel,this.sub=new Antunnel.Subscriber(this.setting().topic),this.sub.onopen=()=>console.log("Subscribed to notification channel"),this.sub.onerror=t=>this.error(__("Error: {0}",new TextDecoder("utf-8").decode(t.data)),t),this.sub.onmessage=t=>{var n;return t.data&&(n=JSON.parse(new TextDecoder("utf-8").decode(t.data))),this.text=__("{0}%",Math.round(n.battery_percent).toString()),this.app&&this.app.feed(n),this.update()},this.sub.onclose=()=>(this.sub=void 0,this.notify(__("Unsubscribed to the notification service")),this.quit()),Antunnel.tunnel.subscribe(this.sub)}return this.error(__("The Antunnel service is not started, please start it first")),this._gui.pushService("Antunnel/AntunnelService").catch(t=>this.error(t.toString(),t)),this.quit()},this.setting().topic?t():(console.log("Open dialog"),this._gui.openDialog("PromptDialog",{title:__("Enter topic name"),label:__("Please enter topic name")}).then(n=>(this.setting().topic=n,t())))}openApp(){if(!this.app)return this._gui.launch("SystemControl",[])}execute(t){}awake(){}cleanup(){if(this.app&&this.app.quit(),this.sub)return this.sub.close()}},this.OS.register("SysmondService",t),(n=class extends this.OS.application.BaseApplication{constructor(t){super("SystemControl",t)}main(){return this.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",[]).then(t=>(this.service=t,t.app=this)).catch(t=>this.error(__("Unable to start sysmond service"),t))}streamline(t,n,e,r){var i,o,a,u,s,l,c,h,f;if(o=0,l=$(this.find(t+"-text")),!this[t]){for(f={type:"time.line",axes:["bottom","left","right"]},e&&(f.range=e),i=[],u=0,c=n.length;u<c;u++)a=n[u],i.push({label:"label-"+o,values:[]}),$("<div>").addClass("legend-color").addClass("ref").addClass("category"+(o+1)).appendTo(l),$("<div>").addClass("legend-label").appendTo(l).text(r?r[o]:`${t}-${o}`),$("<div>").addClass("legend-value").appendTo(l),o+=1;f.data=i,this[t]=$(this.find(t+"-area")).epoch(f)}for(s=0,h=n.length;s<h;s++)a=n[s],$(l.children()[3*o+2]).text(a.y.toString()),o+=1;return this[t].push(n)}feed(t){var n,e,r,i,o,a,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w;for(r=t.disk_total-t.disk_free,this.diskchart.push(r/t.disk_total),this.find("disk-text").text="Disk: "+Math.round(r/1024/1024/1024)+"/"+Math.round(t.disk_total/1024/1024/1024)+" GB",p=t.stamp_sec,t.cpu_usages.shift(),e=function(){var n,e,r,i;for(i=[],n=0,e=(r=t.cpu_usages).length;n<e;n++)w=r[n],i.push({time:p,y:w.toFixed(2)});return i}(),this.streamline("cpu",e,[0,100]),v=t.mem_total/1024/1024,x=t.mem_used/1024/1024,m=t.mem_swap_total/1024/1024,_=(t.mem_swap_total-t.mem_swap_free)/1024/1024,s=[{time:p,y:x.toFixed(3)},{time:p,y:_.toFixed(3)}],l=[0,v>m?v:m],this.streamline("memory",s,l,["RAM (GB)","SWAP (GB)"]),h=0,f=0,i=0,a=(g=t.net).length;i<a;i++)h+=(w=g[i]).rx_rate;for(o=0,u=(d=t.net).length;o<u;o++)f+=(w=d[o]).tx_rate;return(c=[{time:p,y:(h/1024).toFixed(3)},{time:p,y:(f/1024).toFixed(3)}])[0].y>this.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,u=a.setAttribute,s=a.setAttributeNS,l=this.CSSStyleDeclaration.prototype,c=l.setProperty;a.setAttribute=function(t,n){u.call(this,t,n+"")},a.setAttributeNS=function(t,n,e){s.call(this,t,n,e+"")},l.setProperty=function(t,n,e){c.call(this,t,n+"",e)}}function h(t,n){return t<n?-1:t>n?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<i;){var o=r+i>>>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<i;){var o=r+i>>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}t.ascending=h,t.descending=function(t,n){return n<t?-1:n>t?1:n>=t?0:NaN},t.min=function(t,n){var e,r,i=-1,o=t.length;if(1===arguments.length){for(;++i<o;)if(null!=(r=t[i])&&r>=r){e=r;break}for(;++i<o;)null!=(r=t[i])&&e>r&&(e=r)}else{for(;++i<o;)if(null!=(r=n.call(t,t[i],i))&&r>=r){e=r;break}for(;++i<o;)null!=(r=n.call(t,t[i],i))&&e>r&&(e=r)}return e},t.max=function(t,n){var e,r,i=-1,o=t.length;if(1===arguments.length){for(;++i<o;)if(null!=(r=t[i])&&r>=r){e=r;break}for(;++i<o;)null!=(r=t[i])&&r>e&&(e=r)}else{for(;++i<o;)if(null!=(r=n.call(t,t[i],i))&&r>=r){e=r;break}for(;++i<o;)null!=(r=n.call(t,t[i],i))&&r>e&&(e=r)}return e},t.extent=function(t,n){var e,r,i,o=-1,a=t.length;if(1===arguments.length){for(;++o<a;)if(null!=(r=t[o])&&r>=r){e=i=r;break}for(;++o<a;)null!=(r=t[o])&&(e>r&&(e=r),i<r&&(i=r))}else{for(;++o<a;)if(null!=(r=n.call(t,t[o],o))&&r>=r){e=i=r;break}for(;++o<a;)null!=(r=n.call(t,t[o],o))&&(e>r&&(e=r),i<r&&(i=r))}return[e,i]},t.sum=function(t,n){var e,r=0,i=t.length,o=-1;if(1===arguments.length)for(;++o<i;)p(e=+t[o])&&(r+=e);else for(;++o<i;)p(e=+n.call(t,t[o],o))&&(r+=e);return r},t.mean=function(t,n){var e,r=0,i=t.length,o=-1,a=i;if(1===arguments.length)for(;++o<i;)p(e=f(t[o]))?r+=e:--a;else for(;++o<i;)p(e=f(n.call(t,t[o],o)))?r+=e:--a;if(a)return r/a},t.quantile=function(t,n){var e=(t.length-1)*n+1,r=Math.floor(e),i=+t[r-1],o=e-r;return o?i+o*(t[r]-i):i},t.median=function(n,e){var r,i=[],o=n.length,a=-1;if(1===arguments.length)for(;++a<o;)p(r=f(n[a]))&&i.push(r);else for(;++a<o;)p(r=f(e.call(n,n[a],a)))&&i.push(r);if(i.length)return t.quantile(i.sort(h),.5)},t.variance=function(t,n){var e,r,i=t.length,o=0,a=0,u=-1,s=0;if(1===arguments.length)for(;++u<i;)p(e=f(t[u]))&&(a+=(r=e-o)*(e-(o+=r/++s)));else for(;++u<i;)p(e=f(n.call(t,t[u],u)))&&(a+=(r=e-o)*(e-(o+=r/++s)));if(s>1)return a/(s-1)},t.deviation=function(){var n=t.variance.apply(this,arguments);return n?Math.sqrt(n):n};var d=g(h);function y(t){return t.length}t.bisectLeft=d.left,t.bisect=t.bisectRight=d.right,t.bisector=function(t){return g(1===t.length?function(n,e){return h(t(n),e)}:t)},t.shuffle=function(t,n,e){(o=arguments.length)<3&&(e=t.length,o<2&&(n=0));for(var r,i,o=e-n;o;)i=Math.random()*o--|0,r=t[o+n],t[o+n]=t[i+n],t[i+n]=r;return t},t.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},t.pairs=function(t){for(var n=0,e=t.length-1,r=t[0],i=new Array(e<0?0:e);n<e;)i[n]=[r,r=t[++n]];return i},t.transpose=function(n){if(!(o=n.length))return[];for(var e=-1,r=t.min(n,y),i=new Array(r);++e<r;)for(var o,a=-1,u=i[e]=new Array(o);++a<o;)u[a]=n[a][e];return i},t.zip=function(){return t.transpose(arguments)},t.keys=function(t){var n=[];for(var e in t)n.push(e);return n},t.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},t.entries=function(t){var n=[];for(var e in t)n.push({key:e,value:t[e]});return n},t.merge=function(t){for(var n,e,r,i=t.length,o=-1,a=0;++o<i;)a+=t[o].length;for(e=new Array(a);--i>=0;)for(n=(r=t[i]).length;--n>=0;)e[--a]=r[n];return e};var v=Math.abs;function m(t){for(var n=1;t*n%1;)n*=10;return n}function x(t,n){for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}function _(){this._=Object.create(null)}function w(t){return"__proto__"==(t+="")||"\0"===t[0]?"\0"+t:t}function b(t){return"\0"===(t+="")[0]?t.slice(1):t}function M(t){return w(t)in this._}function k(t){return(t=w(t))in this._&&delete this._[t]}function E(){var t=[];for(var n in this._)t.push(b(n));return t}function S(){var t=0;for(var n in this._)++t;return t}function A(){for(var t in this._)return!1;return!0}function C(){this._=Object.create(null)}function N(t){return t}function T(t,n,e){return function(){var r=e.apply(n,arguments);return r===n?t:r}}function F(t,n){if(n in t)return n;n=n.charAt(0).toUpperCase()+n.slice(1);for(var e=0,r=L.length;e<r;++e){var i=L[e]+n;if(i in t)return i}}t.range=function(t,n,e){if(arguments.length<3&&(e=1,arguments.length<2&&(n=t,t=0)),(n-t)/e==1/0)throw new Error("infinite range");var r,i=[],o=m(v(e)),a=-1;if(t*=o,n*=o,(e*=o)<0)for(;(r=t+e*++a)>n;)i.push(r/o);else for(;(r=t+e*++a)<n;)i.push(r/o);return i},t.map=function(t,n){var e=new _;if(t instanceof _)t.forEach((function(t,n){e.set(t,n)}));else if(Array.isArray(t)){var r,i=-1,o=t.length;if(1===arguments.length)for(;++i<o;)e.set(i,t[i]);else for(;++i<o;)e.set(n.call(t,r=t[i],i),r)}else for(var a in t)e.set(a,t[a]);return e},x(_,{has:M,get:function(t){return this._[w(t)]},set:function(t,n){return this._[w(t)]=n},remove:k,keys:E,values:function(){var t=[];for(var n in this._)t.push(this._[n]);return t},entries:function(){var t=[];for(var n in this._)t.push({key:b(n),value:this._[n]});return t},size:S,empty:A,forEach:function(t){for(var n in this._)t.call(this,b(n),this._[n])}}),t.nest=function(){var n,e,r={},i=[],o=[];function a(t,o,u){if(u>=i.length)return e?e.call(r,o):n?o.sort(n):o;for(var s,l,c,h,f=-1,p=o.length,g=i[u++],d=new _;++f<p;)(h=d.get(s=g(l=o[f])))?h.push(l):d.set(s,[l]);return t?(l=t(),c=function(n,e){l.set(n,a(t,e,u))}):(l={},c=function(n,e){l[n]=a(t,e,u)}),d.forEach(c),l}return r.map=function(t,n){return a(n,t,0)},r.entries=function(n){return function t(n,e){if(e>=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<r;++e)n.add(t[e]);return n},x(C,{has:M,add:function(t){return this._[w(t+="")]=!0,t},remove:k,values:E,size:S,empty:A,forEach:function(t){for(var n in this._)t.call(this,b(n))}}),t.behavior={},t.rebind=function(t,n){for(var e,r=1,i=arguments.length;++r<i;)t[e=arguments[r]]=T(t,n,n[e]);return t};var L=["webkit","ms","moz","Moz","o","O"];function z(){}function D(){}function R(t){var n=[],e=new _;function r(){for(var e,r=n,i=-1,o=r.length;++i<o;)(e=r[i].on)&&e.apply(this,arguments);return t}return r.on=function(r,i){var o,a=e.get(r);return arguments.length<2?a&&a.on:(a&&(a.on=null,n=n.slice(0,o=n.indexOf(a)).concat(n.slice(o+1)),e.remove(r)),i&&n.push(e.set(r,{on:i})),t)},r}function P(){t.event.preventDefault()}function q(){for(var n,e=t.event;n=e.sourceEvent;)e=n;return e}function U(n){for(var e=new D,r=0,i=arguments.length;++r<i;)e[arguments[r]]=R(e);return e.of=function(r,i){return function(o){try{var a=o.sourceEvent=t.event;o.target=n,t.event=o,e[o.type].apply(r,i)}finally{t.event=a}}},e}t.dispatch=function(){for(var t=new D,n=-1,e=arguments.length;++n<e;)t[arguments[n]]=R(t);return t},D.prototype.on=function(t,n){var e=t.indexOf("."),r="";if(e>=0&&(r=t.slice(e+1),t=t.slice(0,e)),t)return arguments.length<2?this[t].on(r):this[t].on(r,n);if(2===arguments.length){if(null==n)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},t.event=null,t.requote=function(t){return t.replace(O,"\\$&")};var O=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,I={}.__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};function H(t){return I(t,$),t}var j=function(t,n){return n.querySelector(t)},V=function(t,n){return n.querySelectorAll(t)},B=function(t,n){var e=t.matches||t[F(t,"matchesSelector")];return(B=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(j=function(t,n){return Sizzle(t,n)[0]||null},V=Sizzle,B=Sizzle.matchesSelector),t.selection=function(){return t.select(r.documentElement)};var $=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return j(t,this)}}function W(t){return"function"==typeof t?t:function(){return V(t,this)}}$.select=function(t){var n,e,r,i,o=[];t=Y(t);for(var a=-1,u=this.length;++a<u;){o.push(n=[]),n.parentNode=(r=this[a]).parentNode;for(var s=-1,l=r.length;++s<l;)(i=r[s])?(n.push(e=t.call(i,i.__data__,s,a)),e&&"__data__"in i&&(e.__data__=i.__data__)):n.push(null)}return H(o)},$.selectAll=function(t){var n,r,i=[];t=W(t);for(var o=-1,a=this.length;++o<a;)for(var u=this[o],s=-1,l=u.length;++s<l;)(r=u[s])&&(i.push(n=e(t.call(r,r.__data__,s,o))),n.parentNode=r);return H(i)};var Z="http://www.w3.org/1999/xhtml",X={svg:"http://www.w3.org/2000/svg",xhtml:Z,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function G(n,e){return n=t.ns.qualify(n),null==e?n.local?function(){this.removeAttributeNS(n.space,n.local)}:function(){this.removeAttribute(n)}:"function"==typeof e?n.local?function(){var t=e.apply(this,arguments);null==t?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,t)}:function(){var t=e.apply(this,arguments);null==t?this.removeAttribute(n):this.setAttribute(n,t)}:n.local?function(){this.setAttributeNS(n.space,n.local,e)}:function(){this.setAttribute(n,e)}}function Q(t){return t.trim().replace(/\s+/g," ")}function J(n){return new RegExp("(?:^|\\s+)"+t.requote(n)+"(?:\\s+|$)","g")}function K(t){return(t+"").trim().split(/^|\s+/)}function tt(t,n){var e=(t=K(t).map(nt)).length;return"function"==typeof n?function(){for(var r=-1,i=n.apply(this,arguments);++r<e;)t[r](this,i)}:function(){for(var r=-1;++r<e;)t[r](this,n)}}function nt(t){var n=J(t);return function(e,r){if(i=e.classList)return r?i.add(t):i.remove(t);var i=e.getAttribute("class")||"";r?(n.lastIndex=0,n.test(i)||e.setAttribute("class",Q(i+" "+t))):e.setAttribute("class",Q(i.replace(n," ")))}}function et(t,n,e){return null==n?function(){this.style.removeProperty(t)}:"function"==typeof n?function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}:function(){this.style.setProperty(t,n,e)}}function rt(t,n){return null==n?function(){delete this[t]}:"function"==typeof n?function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}:function(){this[t]=n}}function it(n){return"function"==typeof n?n:(n=t.ns.qualify(n)).local?function(){return this.ownerDocument.createElementNS(n.space,n.local)}:function(){var t=this.ownerDocument,e=this.namespaceURI;return e===Z&&t.documentElement.namespaceURI===Z?t.createElement(n):t.createElementNS(e,n)}}function ot(){var t=this.parentNode;t&&t.removeChild(this)}function at(t){return{__data__:t}}function ut(t){return function(){return B(this,t)}}function st(t){return arguments.length||(t=h),function(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}}function lt(t,n){for(var e=0,r=t.length;e<r;e++)for(var i,o=t[e],a=0,u=o.length;a<u;a++)(i=o[a])&&n(i,a,e);return t}function ct(t){return I(t,ht),t}t.ns={prefix:X,qualify:function(t){var n=t.indexOf(":"),e=t;return n>=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<r;)if(!n.contains(t[i]))return!1}else for(n=e.getAttribute("class");++i<r;)if(!J(t[i]).test(n))return!1;return!0}for(n in t)this.each(tt(n,t[n]));return this}return this.each(tt(t,n))},$.style=function(t,n,e){var r=arguments.length;if(r<3){if("string"!=typeof t){for(e in r<2&&(n=""),t)this.each(et(e,t[e],n));return this}if(r<2){var i=this.node();return o(i).getComputedStyle(i,null).getPropertyValue(t)}e=""}return this.each(et(t,n,e))},$.property=function(t,n){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(n in t)this.each(rt(n,t[n]));return this}return this.each(rt(t,n))},$.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},$.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},$.append=function(t){return t=it(t),this.select((function(){return this.appendChild(t.apply(this,arguments))}))},$.insert=function(t,n){return t=it(t),n=Y(n),this.select((function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)}))},$.remove=function(){return this.each(ot)},$.data=function(t,n){var e,r,i=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(e=this[0]).length);++i<o;)(r=e[i])&&(t[i]=r.__data__);return t}function a(t,e){var r,i,o,a=t.length,c=e.length,h=Math.min(a,c),f=new Array(c),p=new Array(c),g=new Array(a);if(n){var d,y=new _,v=new Array(a);for(r=-1;++r<a;)(i=t[r])&&(y.has(d=n.call(i,i.__data__,r))?g[r]=i:y.set(d,i),v[r]=d);for(r=-1;++r<c;)(i=y.get(d=n.call(e,o=e[r],r)))?!0!==i&&(f[r]=i,i.__data__=o):p[r]=at(o),y.set(d,!0);for(r=-1;++r<a;)r in v&&!0!==y.get(v[r])&&(g[r]=t[r])}else{for(r=-1;++r<h;)i=t[r],o=e[r],i?(i.__data__=o,f[r]=i):p[r]=at(o);for(;r<c;++r)p[r]=at(e[r]);for(;r<a;++r)g[r]=t[r]}p.update=f,p.parentNode=f.parentNode=g.parentNode=t.parentNode,u.push(p),s.push(f),l.push(g)}var u=ct([]),s=H([]),l=H([]);if("function"==typeof t)for(;++i<o;)a(e=this[i],t.call(e,e.parentNode.__data__,i));else for(;++i<o;)a(e=this[i],t);return s.enter=function(){return u},s.exit=function(){return l},s},$.datum=function(t){return arguments.length?this.property("__data__",t):this.property("__data__")},$.filter=function(t){var n,e,r,i=[];"function"!=typeof t&&(t=ut(t));for(var o=0,a=this.length;o<a;o++){i.push(n=[]),n.parentNode=(e=this[o]).parentNode;for(var u=0,s=e.length;u<s;u++)(r=e[u])&&t.call(r,r.__data__,u,o)&&n.push(r)}return H(i)},$.order=function(){for(var t=-1,n=this.length;++t<n;)for(var e,r=this[t],i=r.length-1,o=r[i];--i>=0;)(e=r[i])&&(o&&o!==e.nextSibling&&o.parentNode.insertBefore(e,o),o=e);return this},$.sort=function(t){t=st.apply(this,arguments);for(var n=-1,e=this.length;++n<e;)this[n].sort(t);return this.order()},$.each=function(t){return lt(this,(function(n,e,r){t.call(n,n.__data__,e,r)}))},$.call=function(t){var n=e(arguments);return t.apply(n[0]=this,n),this},$.empty=function(){return!this.node()},$.node=function(){for(var t=0,n=this.length;t<n;t++)for(var e=this[t],r=0,i=e.length;r<i;r++){var o=e[r];if(o)return o}return null},$.size=function(){var t=0;return lt(this,(function(){++t})),t};var ht=[];function ft(t){var n,e;return function(r,i,o){var a,u=t[o].update,s=u.length;for(o!=e&&(e=o,n=0),i>=n&&(n=i+1);!(a=u[n])&&++n<s;);return a}}function pt(n,r,i){var o="__on"+n,a=n.indexOf("."),u=dt;a>0&&(n=n.slice(0,a));var s=gt.get(n);function l(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}return s&&(n=s,u=yt),a?r?function(){var t=u(r,e(arguments));l.call(this),this.addEventListener(n,this[o]=t,t.$=i),t._=r}:l:r?z:function(){var e,r=new RegExp("^__on([^.]+)"+t.requote(n)+"$");for(var i in this)if(e=i.match(r)){var o=this[i];this.removeEventListener(e[1],o,o.$),delete this[i]}}}t.selection.enter=ct,t.selection.enter.prototype=ht,ht.append=$.append,ht.empty=$.empty,ht.node=$.node,ht.call=$.call,ht.size=$.size,ht.select=function(t){for(var n,e,r,i,o,a=[],u=-1,s=this.length;++u<s;){r=(i=this[u]).update,a.push(n=[]),n.parentNode=i.parentNode;for(var l=-1,c=i.length;++l<c;)(o=i[l])?(n.push(r[l]=e=t.call(i.parentNode,o.__data__,l,u)),e.__data__=o.__data__):n.push(null)}return H(a)},ht.insert=function(t,n){return arguments.length<2&&(n=ft(this)),$.insert.call(this,t,n)},t.select=function(t){var n;return"string"==typeof t?(n=[j(t,r)]).parentNode=r.documentElement:(n=[t]).parentNode=i(t),H([n])},t.selectAll=function(t){var n;return"string"==typeof t?(n=e(V(t,r))).parentNode=r.documentElement:(n=e(t)).parentNode=null,H([n])},$.on=function(t,n,e){var r=arguments.length;if(r<3){if("string"!=typeof t){for(e in r<2&&(n=!1),t)this.each(pt(e,t[e],n));return this}if(r<2)return(r=this.node()["__on"+t])&&r._;e=!1}return this.each(pt(t,n,e))};var gt=t.map({mouseenter:"mouseover",mouseleave:"mouseout"});function dt(n,e){return function(r){var i=t.event;t.event=r,e[0]=this.__data__;try{n.apply(this,e)}finally{t.event=i}}}function yt(t,n){var e=dt(t,n);return function(t){var n=t.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||e.call(this,t)}}r&>.forEach((function(t){"on"+t in r&>.remove(t)}));var vt,mt=0;function xt(n){var e=".dragsuppress-"+ ++mt,r="click"+e,a=t.select(o(n)).on("touchmove"+e,P).on("dragstart"+e,P).on("selectstart"+e,P);if(null==vt&&(vt=!("onselectstart"in n)&&F(n.style,"userSelect")),vt){var u=i(n).style,s=u[vt];u[vt]="none"}return function(t){if(a.on(e,null),vt&&(u[vt]=s),t){var n=function(){a.on(r,null)};a.on(r,(function(){P(),n()}),!0),setTimeout(n,0)}}}t.mouse=function(t){return wt(t,q())};var _t=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;function wt(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();if(_t<0){var a=o(n);if(a.scrollX||a.scrollY){var u=(r=t.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important"))[0][0].getScreenCTM();_t=!(u.f||u.e),r.remove()}}return _t?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),[(i=i.matrixTransform(n.getScreenCTM().inverse())).x,i.y]}var s=n.getBoundingClientRect();return[e.clientX-s.left-n.clientLeft,e.clientY-s.top-n.clientTop]}function bt(){return t.event.changedTouches[0].identifier}t.touch=function(t,n,e){if(arguments.length<3&&(e=n,n=q().changedTouches),n)for(var r,i=0,o=n.length;i<o;++i)if((r=n[i]).identifier===e)return wt(t,r)},t.behavior.drag=function(){var n=U(a,"drag","dragstart","dragend"),e=null,r=u(z,t.mouse,o,"mousemove","mouseup"),i=u(bt,t.touch,N,"touchmove","touchend");function a(){this.on("mousedown.drag",r).on("touchstart.drag",i)}function u(r,i,o,a,u){return function(){var s,l=this,c=t.event.target.correspondingElement||t.event.target,h=l.parentNode,f=n.of(l,arguments),p=0,g=r(),d=".drag"+(null==g?"":"-"+g),y=t.select(o(c)).on(a+d,x).on(u+d,_),v=xt(c),m=i(h,g);function x(){var t,n,e=i(h,g);e&&(t=e[0]-m[0],n=e[1]-m[1],p|=t|n,m=e,f({type:"drag",x:e[0]+s[0],y:e[1]+s[1],dx:t,dy:n}))}function _(){i(h,g)&&(y.on(a+d,null).on(u+d,null),v(p),f({type:"dragend"}))}s=e?[(s=e.apply(l,arguments)).x-m[0],s.y-m[1]]:[0,0],f({type:"dragstart"})}}return a.origin=function(t){return arguments.length?(e=t,a):e},t.rebind(a,n,"on")},t.touches=function(t,n){return arguments.length<2&&(n=q().touches),n?e(n).map((function(n){var e=wt(t,n);return e.identifier=n.identifier,e})):[]};var Mt=1e-6,kt=1e-12,Et=Math.PI,St=2*Et,At=St-Mt,Ct=Et/2,Nt=Et/180,Tt=180/Et;function Ft(t){return t>0?1:t<0?-1:0}function Lt(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function zt(t){return t>1?0:t<-1?Et:Math.acos(t)}function Dt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Rt(t){return((t=Math.exp(t))+1/t)/2}function Pt(t){return(t=Math.sin(t/2))*t}var qt=Math.SQRT2;t.interpolateZoom=function(t,n){var e,r,i=t[0],o=t[1],a=t[2],u=n[0],s=n[1],l=n[2],c=u-i,h=s-o,f=c*c+h*h;if(f<kt)r=Math.log(l/a)/qt,e=function(t){return[i+t*c,o+t*h,a*Math.exp(qt*t*r)]};else{var p=Math.sqrt(f),g=(l*l-a*a+4*f)/(2*a*2*p),d=(l*l-a*a-4*f)/(2*l*2*p),y=Math.log(Math.sqrt(g*g+1)-g),v=Math.log(Math.sqrt(d*d+1)-d);r=(v-y)/qt,e=function(t){var n,e=t*r,u=Rt(y),s=a/(2*p)*(u*(n=qt*e+y,((n=Math.exp(2*n))-1)/(n+1))-function(t){return((t=Math.exp(t))-1/t)/2}(y));return[i+s*c,o+s*h,a*u/Rt(qt*e+y)]}}return e.duration=1e3*r,e},t.behavior.zoom=function(){var n,e,i,a,u,s,l,c,h,f={x:0,y:0,k:1},p=[960,500],g=It,d=250,y=0,v="mousedown.zoom",m="mousemove.zoom",x="mouseup.zoom",_="touchstart.zoom",w=U(b,"zoomstart","zoom","zoomend");function b(t){t.on(v,F).on(Ot+".zoom",z).on("dblclick.zoom",D).on(_,L)}function M(t){return[(t[0]-f.x)/f.k,(t[1]-f.y)/f.k]}function k(t){f.k=Math.max(g[0],Math.min(g[1],t))}function E(t,n){n=function(t){return[t[0]*f.k+f.x,t[1]*f.k+f.y]}(n),f.x+=t[0]-n[0],f.y+=t[1]-n[1]}function S(n,r,i,o){n.__chart__={x:f.x,y:f.y,k:f.k},k(Math.pow(2,o)),E(e=r,i),n=t.select(n),d>0&&(n=n.transition().duration(d)),n.call(b.event)}function A(){l&&l.domain(s.range().map((function(t){return(t-f.x)/f.k})).map(s.invert)),h&&h.domain(c.range().map((function(t){return(t-f.y)/f.k})).map(c.invert))}function C(t){y++||t({type:"zoomstart"})}function N(t){A(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function T(t){--y||(t({type:"zoomend"}),e=null)}function F(){var n=this,e=w.of(n,arguments),r=0,i=t.select(o(n)).on(m,s).on(x,l),a=M(t.mouse(n)),u=xt(n);function s(){r=1,E(t.mouse(n),a),N(e)}function l(){i.on(m,null).on(x,null),u(r),T(e)}du.call(n),C(e)}function L(){var n,e=this,r=w.of(e,arguments),i={},o=0,a=".zoom-"+t.event.changedTouches[0].identifier,s="touchmove"+a,l="touchend"+a,c=[],h=t.select(e),p=xt(e);function g(){var r=t.touches(e);return n=f.k,r.forEach((function(t){t.identifier in i&&(i[t.identifier]=M(t))})),r}function d(){var n=t.event.target;t.select(n).on(s,y).on(l,m),c.push(n);for(var r=t.event.changedTouches,a=0,h=r.length;a<h;++a)i[r[a].identifier]=null;var p=g(),d=Date.now();if(1===p.length){if(d-u<500){var v=p[0];S(e,v,i[v.identifier],Math.floor(Math.log(f.k)/Math.LN2)+1),P()}u=d}else if(p.length>1){v=p[0];var x=p[1],_=v[0]-x[0],w=v[1]-x[1];o=_*_+w*w}}function y(){var a,s,l,c,h=t.touches(e);du.call(e);for(var f=0,p=h.length;f<p;++f,c=null)if(l=h[f],c=i[l.identifier]){if(s)break;a=l,s=c}if(c){var g=(g=l[0]-a[0])*g+(g=l[1]-a[1])*g,d=o&&Math.sqrt(g/o);a=[(a[0]+l[0])/2,(a[1]+l[1])/2],s=[(s[0]+c[0])/2,(s[1]+c[1])/2],k(d*n)}u=null,E(a,s),N(r)}function m(){if(t.event.touches.length){for(var n=t.event.changedTouches,e=0,o=n.length;e<o;++e)delete i[n[e].identifier];for(var u in i)return void g()}t.selectAll(c).on(a,null),h.on(v,F).on(_,L),p(),T(r)}d(),C(r),h.on(v,null).on(_,d)}function z(){var r=w.of(this,arguments);a?clearTimeout(a):(du.call(this),n=M(e=i||t.mouse(this)),C(r)),a=setTimeout((function(){a=null,T(r)}),50),P(),k(Math.pow(2,.002*Ut())*f.k),E(e,n),N(r)}function D(){var n=t.mouse(this),e=Math.log(f.k)/Math.LN2;S(this,n,M(n),t.event.shiftKey?Math.ceil(e)-1:Math.floor(e)+1)}return Ot||(Ot="onwheel"in r?(Ut=function(){return-t.event.deltaY*(t.event.deltaMode?120:1)},"wheel"):"onmousewheel"in r?(Ut=function(){return t.event.wheelDelta},"mousewheel"):(Ut=function(){return-t.event.detail},"MozMousePixelScroll")),b.event=function(n){n.each((function(){var n=w.of(this,arguments),r=f;mu?t.select(this).transition().each("start.zoom",(function(){f=this.__chart__||{x:0,y:0,k:1},C(n)})).tween("zoom:zoom",(function(){var i=p[0],o=p[1],a=e?e[0]:i/2,u=e?e[1]:o/2,s=t.interpolateZoom([(a-f.x)/f.k,(u-f.y)/f.k,i/f.k],[(a-r.x)/r.k,(u-r.y)/r.k,i/r.k]);return function(t){var e=s(t),r=i/e[2];this.__chart__=f={x:a-e[0]*r,y:u-e[1]*r,k:r},N(n)}})).each("interrupt.zoom",(function(){T(n)})).each("end.zoom",(function(){T(n)})):(this.__chart__=f,C(n),N(n),T(n))}))},b.translate=function(t){return arguments.length?(f={x:+t[0],y:+t[1],k:f.k},A(),b):[f.x,f.y]},b.scale=function(t){return arguments.length?(f={x:f.x,y:f.y,k:null},k(+t),A(),b):f.k},b.scaleExtent=function(t){return arguments.length?(g=null==t?It:[+t[0],+t[1]],b):g},b.center=function(t){return arguments.length?(i=t&&[+t[0],+t[1]],b):i},b.size=function(t){return arguments.length?(p=t&&[+t[0],+t[1]],b):p},b.duration=function(t){return arguments.length?(d=+t,b):d},b.x=function(t){return arguments.length?(l=t,s=t.copy(),f={x:0,y:0,k:1},b):l},b.y=function(t){return arguments.length?(h=t,c=t.copy(),f={x:0,y:0,k:1},b):h},t.rebind(b,w,"on")};var Ut,Ot,It=[0,1/0];function Ht(){}function jt(t,n,e){return this instanceof jt?(this.h=+t,this.s=+n,void(this.l=+e)):arguments.length<2?t instanceof jt?new jt(t.h,t.s,t.l):sn(""+t,ln,jt):new jt(t,n,e)}t.color=Ht,Ht.prototype.toString=function(){return this.rgb()+""},t.hsl=jt;var Vt=jt.prototype=new Ht;function Bt(t,n,e){var r,i;function o(t){return Math.round(255*function(t){return t>360?t-=360:t<0&&(t+=360),t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r}(t))}return t=isNaN(t)?0:(t%=360)<0?t+360:t,n=isNaN(n)||n<0?0:n>1?1:n,r=2*(e=e<0?0:e>1?1:e)-(i=e<=.5?e*(1+n):e+n-e*n),new en(o(t+120),o(t),o(t-120))}function $t(n,e,r){return this instanceof $t?(this.h=+n,this.c=+e,void(this.l=+r)):arguments.length<2?n instanceof $t?new $t(n.h,n.c,n.l):Jt(n instanceof Zt?n.l:(n=cn((n=t.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new $t(n,e,r)}Vt.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new jt(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new jt(this.h,this.s,t*this.l)},Vt.rgb=function(){return Bt(this.h,this.s,this.l)},t.hcl=$t;var Yt=$t.prototype=new Ht;function Wt(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),new Zt(e,Math.cos(t*=Nt)*n,Math.sin(t)*n)}function Zt(t,n,e){return this instanceof Zt?(this.l=+t,this.a=+n,void(this.b=+e)):arguments.length<2?t instanceof Zt?new Zt(t.l,t.a,t.b):t instanceof $t?Wt(t.h,t.c,t.l):cn((t=en(t)).r,t.g,t.b):new Zt(t,n,e)}Yt.brighter=function(t){return new $t(this.h,this.c,Math.min(100,this.l+Xt*(arguments.length?t:1)))},Yt.darker=function(t){return new $t(this.h,this.c,Math.max(0,this.l-Xt*(arguments.length?t:1)))},Yt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Zt;var Xt=18,Gt=Zt.prototype=new Ht;function Qt(t,n,e){var r=(t+16)/116,i=r+n/500,o=r-e/200;return new en(nn(3.2404542*(i=.95047*Kt(i))-1.5371385*(r=1*Kt(r))-.4985314*(o=1.08883*Kt(o))),nn(-.969266*i+1.8760108*r+.041556*o),nn(.0556434*i-.2040259*r+1.0572252*o))}function Jt(t,n,e){return t>0?new $t(Math.atan2(e,n)*Tt,Math.sqrt(n*n+e*e),t):new $t(NaN,NaN,t)}function Kt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function tn(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function nn(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function en(t,n,e){return this instanceof en?(this.r=~~t,this.g=~~n,void(this.b=~~e)):arguments.length<2?t instanceof en?new en(t.r,t.g,t.b):sn(""+t,en,Bt):new en(t,n,e)}function rn(t){return new en(t>>16,t>>8&255,255&t)}function on(t){return rn(t)+""}Gt.brighter=function(t){return new Zt(Math.min(100,this.l+Xt*(arguments.length?t:1)),this.a,this.b)},Gt.darker=function(t){return new Zt(Math.max(0,this.l-Xt*(arguments.length?t:1)),this.a,this.b)},Gt.rgb=function(){return Qt(this.l,this.a,this.b)},t.rgb=en;var an=en.prototype=new Ht;function un(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function sn(t,n,e){var r,i,o,a=0,u=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return n(fn(i[0]),fn(i[1]),fn(i[2]))}return(o=pn.get(t))?n(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(a=(3840&o)>>4,a|=a>>4,u=240&o,u|=u>>4,s=15&o,s|=s<<4):7===t.length&&(a=(16711680&o)>>16,u=(65280&o)>>8,s=255&o)),n(a,u,s))}function ln(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),u=a-o,s=(a+o)/2;return u?(i=s<.5?u/(a+o):u/(2-a-o),r=t==a?(n-e)/u+(n<e?6:0):n==a?(e-t)/u+2:(t-n)/u+4,r*=60):(r=NaN,i=s>0&&s<1?0:r),new jt(r,i,s)}function cn(t,n,e){var r=tn((.4124564*(t=hn(t))+.3575761*(n=hn(n))+.1804375*(e=hn(e)))/.95047),i=tn((.2126729*t+.7151522*n+.072175*e)/1);return Zt(116*i-16,500*(r-i),200*(i-tn((.0193339*t+.119192*n+.9503041*e)/1.08883)))}function hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function fn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}an.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&n<i&&(n=i),e&&e<i&&(e=i),r&&r<i&&(r=i),new en(Math.min(255,n/t),Math.min(255,e/t),Math.min(255,r/t))):new en(i,i,i)},an.darker=function(t){return new en((t=Math.pow(.7,arguments.length?t:1))*this.r,t*this.g,t*this.b)},an.hsl=function(){return ln(this.r,this.g,this.b)},an.toString=function(){return"#"+un(this.r)+un(this.g)+un(this.b)};var pn=t.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});function gn(t){return"function"==typeof t?t:function(){return t}}function dn(t){return function(n,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),yn(n,e,t,r)}}function yn(n,r,i,o){var a={},u=t.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;function h(){var t,n=l.status;if(!n&&function(t){var n=t.responseType;return n&&"text"!==n?t.response:t.responseText}(l)||n>=200&&n<300||304===n){try{t=i.call(a,l)}catch(t){return void u.error.call(a,t)}u.load.call(a,t)}else u.error.call(a,l)}return this.XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(n)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=h:l.onreadystatechange=function(){l.readyState>3&&h()},l.onprogress=function(n){var e=t.event;t.event=n;try{u.progress.call(a,l)}finally{t.event=e}},a.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==n?delete s[t]:s[t]=n+"",a)},a.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",a):r},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return i=t,a},["get","post"].forEach((function(t){a[t]=function(){return a.send.apply(a,[t].concat(e(arguments)))}})),a.send=function(t,e,i){if(2===arguments.length&&"function"==typeof e&&(i=e,e=null),l.open(t,n,!0),null==r||"accept"in s||(s.accept=r+",*/*"),l.setRequestHeader)for(var o in s)l.setRequestHeader(o,s[o]);return null!=r&&l.overrideMimeType&&l.overrideMimeType(r),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",(function(t){i(null,t)})),u.beforesend.call(a,l),l.send(null==e?null:e),a},a.abort=function(){return l.abort(),a},t.rebind(a,u,"on"),null==o?a:a.get(function(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}(o))}pn.forEach((function(t,n){pn.set(t,rn(n))})),t.functor=gn,t.xhr=dn(N),t.dsv=function(t,n){var e=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function i(t,e,r){arguments.length<3&&(r=e,e=null);var i=yn(t,n,null==e?o:a(e),r);return i.row=function(t){return arguments.length?i.response(null==(e=t)?o:a(t)):e},i}function o(t){return i.parse(t.responseText)}function a(t){return function(n){return i.parse(n.responseText,t)}}function u(n){return n.map(s).join(t)}function s(t){return e.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,n){var e;return i.parseRows(t,(function(t,r){if(e)return e(t,r-1);var i=new Function("d","return {"+t.map((function(t,n){return JSON.stringify(t)+": d["+n+"]"})).join(",")+"}");e=n?function(t,e){return n(i(t),e)}:i}))},i.parseRows=function(t,n){var e,i,o={},a={},u=[],s=t.length,l=0,c=0;function h(){if(l>=s)return a;if(i)return i=!1,o;var n=l;if(34===t.charCodeAt(n)){for(var e=n;e++<s;)if(34===t.charCodeAt(e)){if(34!==t.charCodeAt(e+1))break;++e}return l=e+2,13===(u=t.charCodeAt(e+1))?(i=!0,10===t.charCodeAt(e+2)&&++l):10===u&&(i=!0),t.slice(n+1,e).replace(/""/g,'"')}for(;l<s;){var u,c=1;if(10===(u=t.charCodeAt(l++)))i=!0;else if(13===u)i=!0,10===t.charCodeAt(l)&&(++l,++c);else if(u!==r)continue;return t.slice(n,l-c)}return t.slice(n)}for(;(e=h())!==a;){for(var f=[];e!==o&&e!==a;)f.push(e),e=h();n&&null==(f=n(f,c++))||u.push(f)}return u},i.format=function(n){if(Array.isArray(n[0]))return i.formatRows(n);var e=new C,r=[];return n.forEach((function(t){for(var n in t)e.has(n)||r.push(e.add(n))})),[r.map(s).join(t)].concat(n.map((function(n){return r.map((function(t){return s(n[t])})).join(t)}))).join("\n")},i.formatRows=function(t){return t.map(u).join("\n")},i},t.csv=t.dsv(",","text/csv"),t.tsv=t.dsv("\t","text/tab-separated-values");var vn,mn,xn,_n,wn=this[F(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};function bn(t,n,e){var r=arguments.length;r<2&&(n=0),r<3&&(e=Date.now());var i=e+n,o={c:t,t:i,n:null};return mn?mn.n=o:vn=o,mn=o,xn||(_n=clearTimeout(_n),xn=1,wn(Mn)),o}function Mn(){var t=kn(),n=En()-t;n>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.t<e&&(e=n.t),n=(t=n).n):n=t?t.n=n.n:vn=n.n;return mn=t,e}function Sn(t,n){return n-(t?Math.ceil(Math.log(t)/Math.LN10):1)}t.timer=function(){bn.apply(this,arguments)},t.timer.flush=function(){kn(),En()},t.round=function(t,n){return n?Math.round(t*(n=Math.pow(10,n)))/n:Math.round(t)};var An=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map((function(t,n){var e=Math.pow(10,3*v(8-n));return{scale:n>8?function(t){return t/e}:function(t){return t*e},symbol:t}}));function Cn(n){var e=n.decimal,r=n.thousands,i=n.grouping,o=n.currency,a=i&&r?function(t,n){for(var e=t.length,o=[],a=0,u=i[0],s=0;e>0&&u>0&&(s+u+1>n&&(u=Math.max(1,n-s)),o.push(t.substring(e-=u,e+u)),!((s+=u+1)>n));)u=i[a=(a+1)%i.length];return o.reverse().join(r)}:N;return function(n){var r=Nn.exec(n),i=r[1]||" ",u=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],h=+r[6],f=r[7],p=r[8],g=r[9],d=1,y="",v="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(c||"0"===i&&"="===u)&&(c=i="0",u="="),g){case"n":f=!0,g="g";break;case"%":d=100,v="%",g="f";break;case"p":d=100,v="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(y="0"+g.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":d=-1,g="r"}"$"===l&&(y=o[0],v=o[1]),"r"!=g||p||(g="g"),null!=p&&("g"==g?p=Math.max(1,Math.min(21,p)):"e"!=g&&"f"!=g||(p=Math.max(0,Math.min(20,p)))),g=Tn.get(g)||Fn;var _=c&&f;return function(n){var r=v;if(m&&n%1)return"";var o=n<0||0===n&&1/n<0?(n=-n,"-"):"-"===s?"":s;if(d<0){var l=t.formatPrefix(n,p);n=l.scale(n),r=l.symbol+v}else n*=d;var w,b,M=(n=g(n,p)).lastIndexOf(".");if(M<0){var k=x?n.lastIndexOf("e"):-1;k<0?(w=n,b=""):(w=n.substring(0,k),b=n.substring(k))}else w=n.substring(0,M),b=e+n.substring(M+1);!c&&f&&(w=a(w,1/0));var E=y.length+w.length+b.length+(_?0:o.length),S=E<h?new Array(E=h-E+1).join(i):"";return _&&(w=a(S+w,S.length?h-b.length:1/0)),o+=y,n=w+b,("<"===u?o+n+S:">"===u?S+o+n:"^"===u?S.substring(0,E>>=1)+o+n+S.substring(E):o+(_?n:S+n))+r}}}t.formatPrefix=function(n,e){var r=0;return(n=+n)&&(n<0&&(n*=-1),e&&(n=t.round(n,Sn(n,e))),r=1+Math.floor(1e-12+Math.log(n)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),An[8+r/3]};var Nn=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Tn=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(n,e){return(n=t.round(n,Sn(n,e))).toFixed(Math.max(0,Math.min(20,Sn(n*(1+1e-15),e))))}});function Fn(t){return t+""}var Ln=t.time={},zn=Date;function Dn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Dn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Rn.setUTCDate.apply(this._,arguments)},setDay:function(){Rn.setUTCDay.apply(this._,arguments)},setFullYear:function(){Rn.setUTCFullYear.apply(this._,arguments)},setHours:function(){Rn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Rn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Rn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Rn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Rn.setUTCSeconds.apply(this._,arguments)},setTime:function(){Rn.setTime.apply(this._,arguments)}};var Rn=Date.prototype;function Pn(t,n,e){function r(n){var e=t(n),r=o(e,1);return n-e<r-n?e:r}function i(e){return n(e=t(new zn(e-1)),1),e}function o(t,e){return n(t=new zn(+t),e),t}function a(t,r,o){var a=i(t),u=[];if(o>1)for(;a<r;)e(a)%o||u.push(new Date(+a)),n(a,1);else for(;a<r;)u.push(new Date(+a)),n(a,1);return u}t.floor=t,t.round=r,t.ceil=i,t.offset=o,t.range=a;var u=t.utc=qn(t);return u.floor=u,u.round=qn(r),u.ceil=qn(i),u.offset=qn(o),u.range=function(t,n,e){try{zn=Dn;var r=new Dn;return r._=t,a(r,n,e)}finally{zn=Date}},t}function qn(t){return function(n,e){try{zn=Dn;var r=new Dn;return r._=n,t(r,e)._}finally{zn=Date}}}function Un(n){var e=n.dateTime,r=n.date,i=n.time,o=n.periods,a=n.days,u=n.shortDays,s=n.months,l=n.shortMonths;function c(t){var n=t.length;function e(e){for(var r,i,o,a=[],u=-1,s=0;++u<n;)37===t.charCodeAt(u)&&(a.push(t.slice(s,u)),null!=(i=On[r=t.charAt(++u)])&&(r=t.charAt(++u)),(o=w[r])&&(r=o(e,null==i?"e"===r?" ":"0":i)),a.push(r),s=u+1);return a.push(t.slice(s,u)),a.join("")}return e.parse=function(n){var e={y:1900,m:0,d:1,H:0,M:0,S:0,L:0,Z:null};if(h(e,t,n,0)!=n.length)return null;"p"in e&&(e.H=e.H%12+12*e.p);var r=null!=e.Z&&zn!==Dn,i=new(r?Dn:zn);return"j"in e?i.setFullYear(e.y,0,e.j):"W"in e||"U"in e?("w"in e||(e.w="W"in e?1:0),i.setFullYear(e.y,0,1),i.setFullYear(e.y,0,"W"in e?(e.w+6)%7+7*e.W-(i.getDay()+5)%7:e.w+7*e.U-(i.getDay()+6)%7)):i.setFullYear(e.y,e.m,e.d),i.setHours(e.H+(e.Z/100|0),e.M+e.Z%100,e.S,e.L),r?i._:i},e.toString=function(){return t},e}function h(t,n,e,r){for(var i,o,a,u=0,s=n.length,l=e.length;u<s;){if(r>=l)return-1;if(37===(i=n.charCodeAt(u++))){if(a=n.charAt(u++),!(o=b[a in On?n.charAt(u++):a])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}c.utc=function(t){var n=c(t);function e(t){try{var e=new(zn=Dn);return e._=t,n(e)}finally{zn=Date}}return e.parse=function(t){try{zn=Dn;var e=n.parse(t);return e&&e._}finally{zn=Date}},e.toString=n.toString,e},c.multi=c.utc.multi=ae;var f=t.map(),p=Vn(a),g=Bn(a),d=Vn(u),y=Bn(u),v=Vn(s),m=Bn(s),x=Vn(l),_=Bn(l);o.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return u[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:c(e),d:function(t,n){return jn(t.getDate(),n,2)},e:function(t,n){return jn(t.getDate(),n,2)},H:function(t,n){return jn(t.getHours(),n,2)},I:function(t,n){return jn(t.getHours()%12||12,n,2)},j:function(t,n){return jn(1+Ln.dayOfYear(t),n,3)},L:function(t,n){return jn(t.getMilliseconds(),n,3)},m:function(t,n){return jn(t.getMonth()+1,n,2)},M:function(t,n){return jn(t.getMinutes(),n,2)},p:function(t){return o[+(t.getHours()>=12)]},S:function(t,n){return jn(t.getSeconds(),n,2)},U:function(t,n){return jn(Ln.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return jn(Ln.mondayOfYear(t),n,2)},x:c(r),X:c(i),y:function(t,n){return jn(t.getFullYear()%100,n,2)},Y:function(t,n){return jn(t.getFullYear()%1e4,n,4)},Z:ie,"%":function(){return"%"}},b={a:function(t,n,e){d.lastIndex=0;var r=d.exec(n.slice(e));return r?(t.w=y.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(t,n,e){p.lastIndex=0;var r=p.exec(n.slice(e));return r?(t.w=g.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){x.lastIndex=0;var r=x.exec(n.slice(e));return r?(t.m=_.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(t,n,e){v.lastIndex=0;var r=v.exec(n.slice(e));return r?(t.m=m.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,n,e){return h(t,w.c.toString(),n,e)},d:Jn,e:Jn,H:te,I:te,j:Kn,L:re,m:Qn,M:ne,p:function(t,n,e){var r=f.get(n.slice(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)},S:ee,U:Yn,w:$n,W:Wn,x:function(t,n,e){return h(t,w.x.toString(),n,e)},X:function(t,n,e){return h(t,w.X.toString(),n,e)},y:Xn,Y:Zn,Z:Gn,"%":oe};return c}Ln.year=Pn((function(t){return(t=Ln.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),Ln.years=Ln.year.range,Ln.years.utc=Ln.year.utc.range,Ln.day=Pn((function(t){var n=new zn(2e3,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n}),(function(t,n){t.setDate(t.getDate()+n)}),(function(t){return t.getDate()-1})),Ln.days=Ln.day.range,Ln.days.utc=Ln.day.utc.range,Ln.dayOfYear=function(t){var n=Ln.year(t);return Math.floor((t-n-6e4*(t.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(t,n){n=7-n;var e=Ln[t]=Pn((function(t){return(t=Ln.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t}),(function(t,n){t.setDate(t.getDate()+7*Math.floor(n))}),(function(t){var e=Ln.year(t).getDay();return Math.floor((Ln.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));Ln[t+"s"]=e.range,Ln[t+"s"].utc=e.utc.range,Ln[t+"OfYear"]=function(t){var e=Ln.year(t).getDay();return Math.floor((Ln.dayOfYear(t)+(e+n)%7)/7)}})),Ln.week=Ln.sunday,Ln.weeks=Ln.sunday.range,Ln.weeks.utc=Ln.sunday.utc.range,Ln.weekOfYear=Ln.sundayOfYear;var On={"-":"",_:" ",0:"0"},In=/^\s*\d+/,Hn=/^%/;function jn(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<e?new Array(e-o+1).join(n)+i:i)}function Vn(n){return new RegExp("^(?:"+n.map(t.requote).join("|")+")","i")}function Bn(t){for(var n=new _,e=-1,r=t.length;++e<r;)n.set(t[e].toLowerCase(),e);return n}function $n(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+1));return r?(t.w=+r[0],e+r[0].length):-1}function Yn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e));return r?(t.U=+r[0],e+r[0].length):-1}function Wn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e));return r?(t.W=+r[0],e+r[0].length):-1}function Zn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+4));return r?(t.y=+r[0],e+r[0].length):-1}function Xn(t,n,e){In.lastIndex=0;var r,i=In.exec(n.slice(e,e+2));return i?(t.y=(r=+i[0])+(r>68?1900:2e3),e+i[0].length):-1}function Gn(t,n,e){return/^[+-]\d{4}$/.test(n=n.slice(e,e+5))?(t.Z=-n,e+5):-1}function Qn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function Jn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function Kn(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+3));return r?(t.j=+r[0],e+r[0].length):-1}function te(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function ne(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function ee(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function re(t,n,e){In.lastIndex=0;var r=In.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function ie(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=v(n)/60|0,i=v(n)%60;return e+jn(r,"0",2)+jn(i,"0",2)}function oe(t,n,e){Hn.lastIndex=0;var r=Hn.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function ae(t){for(var n=t.length,e=-1;++e<n;)t[e][0]=this(t[e][0]);return function(n){for(var e=0,r=t[e];!r[1](n);)r=t[++e];return r[0](n)}}t.locale=function(t){return{numberFormat:Cn(t),timeFormat:Un(t)}};var ue=t.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function se(){}t.format=ue.numberFormat,t.geo={},se.prototype={s:0,t:0,add:function(t){ce(t,this.t,le),ce(le.s,this.s,this),this.s?this.t+=le.t:this.s=le.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var le=new se;function ce(t,n,e){var r=e.s=t+n,i=r-t,o=r-i;e.t=t-o+(n-i)}function he(t,n){t&&pe.hasOwnProperty(t.type)&&pe[t.type](t,n)}t.geo.stream=function(t,n){t&&fe.hasOwnProperty(t.type)?fe[t.type](t,n):he(t,n)};var fe={Feature:function(t,n){he(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)he(e[r].geometry,n)}},pe={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){ge(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)ge(e[r],n,0)},Polygon:function(t,n){de(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)de(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)he(e[r],n)}};function ge(t,n,e){var r,i=-1,o=t.length-e;for(n.lineStart();++i<o;)r=t[i],n.point(r[0],r[1],r[2]);n.lineEnd()}function de(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)ge(t[e],n,1);n.polygonEnd()}t.geo.area=function(n){return ye=0,t.geo.stream(n,Ne),ye};var ye,ve,me,xe,_e,we,be,Me,ke,Ee,Se,Ae,Ce=new se,Ne={sphere:function(){ye+=4*Et},point:z,lineStart:z,lineEnd:z,polygonStart:function(){Ce.reset(),Ne.lineStart=Te},polygonEnd:function(){var t=2*Ce;ye+=t<0?4*Et+t:t,Ne.lineStart=Ne.lineEnd=Ne.point=z}};function Te(){var t,n,e,r,i;function o(t,n){n=n*Nt/2+Et/4;var o=(t*=Nt)-e,a=o>=0?1:-1,u=a*o,s=Math.cos(n),l=Math.sin(n),c=i*l,h=r*s+c*Math.cos(u),f=c*a*Math.sin(u);Ce.add(Math.atan2(f,h)),e=t,r=s,i=l}Ne.point=function(a,u){Ne.point=o,e=(t=a)*Nt,r=Math.cos(u=(n=u)*Nt/2+Et/4),i=Math.sin(u)},Ne.lineEnd=function(){o(t,n)}}function Fe(t){var n=t[0],e=t[1],r=Math.cos(e);return[r*Math.cos(n),r*Math.sin(n),Math.sin(e)]}function Le(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ze(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function De(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Re(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Pe(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function qe(t){return[Math.atan2(t[1],t[0]),Dt(t[2])]}function Ue(t,n){return v(t[0]-n[0])<Mt&&v(t[1]-n[1])<Mt}t.geo.bounds=function(){var n,e,r,i,o,a,u,s,l,c,h,f={point:p,lineStart:d,lineEnd:y,polygonStart:function(){f.point=m,f.lineStart=x,f.lineEnd=_,l=0,Ne.polygonStart()},polygonEnd:function(){Ne.polygonEnd(),f.point=p,f.lineStart=d,f.lineEnd=y,Ce<0?(n=-(r=180),e=-(i=90)):l>Mt?i=90:l<-Mt&&(e=-90),h[0]=n,h[1]=r}};function p(t,o){c.push(h=[n=t,r=t]),o<e&&(e=o),o>i&&(i=o)}function g(t,a){var u=Fe([t*Nt,a*Nt]);if(s){var l=ze(s,u),c=ze([l[1],-l[0],0],l);Pe(c),c=qe(c);var h=t-o,f=h>0?1:-1,g=c[0]*Tt*f,d=v(h)>180;if(d^(f*o<g&&g<f*t))(y=c[1]*Tt)>i&&(i=y);else if(d^(f*o<(g=(g+360)%360-180)&&g<f*t)){var y;(y=-c[1]*Tt)<e&&(e=y)}else a<e&&(e=a),a>i&&(i=a);d?t<o?w(n,t)>w(n,r)&&(r=t):w(t,r)>w(n,r)&&(n=t):r>=n?(t<n&&(n=t),t>r&&(r=t)):t>o?w(n,t)>w(n,r)&&(r=t):w(t,r)>w(n,r)&&(n=t)}else p(t,a);s=u,o=t}function d(){f.point=g}function y(){h[0]=n,h[1]=r,f.point=p,s=null}function m(t,n){if(s){var e=t-o;l+=v(e)>180?e+(e>0?360:-360):e}else a=t,u=n;Ne.point(t,n),g(t,n)}function x(){Ne.lineStart()}function _(){m(a,u),Ne.lineEnd(),v(l)>Mt&&(n=-(r=180)),h[0]=n,h[1]=r,s=null}function w(t,n){return(n-=t)<0?n+360:n}function b(t,n){return t[0]-n[0]}function M(t,n){return n[0]<=n[1]?n[0]<=t&&t<=n[1]:t<n[0]||n[1]<t}return function(o){if(i=r=-(n=e=1/0),c=[],t.geo.stream(o,f),l=c.length){c.sort(b);for(var a=1,u=[d=c[0]];a<l;++a)M((p=c[a])[0],d)||M(p[1],d)?(w(d[0],p[1])>w(d[0],d[1])&&(d[1]=p[1]),w(p[0],d[1])>w(d[0],d[1])&&(d[0]=p[0])):u.push(d=p);for(var s,l,p,g=-1/0,d=(a=0,u[l=u.length-1]);a<=l;d=p,++a)p=u[a],(s=w(d[1],p[0]))>g&&(g=s,n=p[0],r=d[1])}return c=h=null,n===1/0||e===1/0?[[NaN,NaN],[NaN,NaN]]:[[n,e],[r,i]]}}(),t.geo.centroid=function(n){ve=me=xe=_e=we=be=Me=ke=Ee=Se=Ae=0,t.geo.stream(n,Oe);var e=Ee,r=Se,i=Ae,o=e*e+r*r+i*i;return o<kt&&(e=be,r=Me,i=ke,me<Mt&&(e=xe,r=_e,i=we),(o=e*e+r*r+i*i)<kt)?[NaN,NaN]:[Math.atan2(r,e)*Tt,Dt(i/Math.sqrt(o))*Tt]};var Oe={sphere:z,point:Ie,lineStart:je,lineEnd:Ve,polygonStart:function(){Oe.lineStart=Be},polygonEnd:function(){Oe.lineStart=je}};function Ie(t,n){t*=Nt;var e=Math.cos(n*=Nt);He(e*Math.cos(t),e*Math.sin(t),Math.sin(n))}function He(t,n,e){++ve,xe+=(t-xe)/ve,_e+=(n-_e)/ve,we+=(e-we)/ve}function je(){var t,n,e;function r(r,i){r*=Nt;var o=Math.cos(i*=Nt),a=o*Math.cos(r),u=o*Math.sin(r),s=Math.sin(i),l=Math.atan2(Math.sqrt((l=n*s-e*u)*l+(l=e*a-t*s)*l+(l=t*u-n*a)*l),t*a+n*u+e*s);me+=l,be+=l*(t+(t=a)),Me+=l*(n+(n=u)),ke+=l*(e+(e=s)),He(t,n,e)}Oe.point=function(i,o){i*=Nt;var a=Math.cos(o*=Nt);t=a*Math.cos(i),n=a*Math.sin(i),e=Math.sin(o),Oe.point=r,He(t,n,e)}}function Ve(){Oe.point=Ie}function Be(){var t,n,e,r,i;function o(t,n){t*=Nt;var o=Math.cos(n*=Nt),a=o*Math.cos(t),u=o*Math.sin(t),s=Math.sin(n),l=r*s-i*u,c=i*a-e*s,h=e*u-r*a,f=Math.sqrt(l*l+c*c+h*h),p=e*a+r*u+i*s,g=f&&-zt(p)/f,d=Math.atan2(f,p);Ee+=g*l,Se+=g*c,Ae+=g*h,me+=d,be+=d*(e+(e=a)),Me+=d*(r+(r=u)),ke+=d*(i+(i=s)),He(e,r,i)}Oe.point=function(a,u){t=a,n=u,Oe.point=o,a*=Nt;var s=Math.cos(u*=Nt);e=s*Math.cos(a),r=s*Math.sin(a),i=Math.sin(u),He(e,r,i)},Oe.lineEnd=function(){o(t,n),Oe.lineEnd=Ve,Oe.point=Ie}}function $e(t,n){function e(e,r){return e=t(e,r),n(e[0],e[1])}return t.invert&&n.invert&&(e.invert=function(e,r){return(e=n.invert(e,r))&&t.invert(e[0],e[1])}),e}function Ye(){return!0}function We(t,n,e,r,i){var o=[],a=[];if(t.forEach((function(t){if(!((n=t.length-1)<=0)){var n,e=t[0],r=t[n];if(Ue(e,r)){i.lineStart();for(var u=0;u<n;++u)i.point((e=t[u])[0],e[1]);i.lineEnd()}else{var s=new Xe(e,t,null,!0),l=new Xe(e,null,s,!1);s.o=l,o.push(s),a.push(l),s=new Xe(r,t,null,!1),l=new Xe(r,null,s,!0),s.o=l,o.push(s),a.push(l)}}})),a.sort(n),Ze(o),Ze(a),o.length){for(var u=0,s=e,l=a.length;u<l;++u)a[u].e=s=!s;for(var c,h,f=o[0];;){for(var p=f,g=!0;p.v;)if((p=p.n)===f)return;c=p.z,i.lineStart();do{if(p.v=p.o.v=!0,p.e){if(g)for(u=0,l=c.length;u<l;++u)i.point((h=c[u])[0],h[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(g)for(u=(c=p.p.z).length-1;u>=0;--u)i.point((h=c[u])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}c=(p=p.o).z,g=!g}while(!p.v);i.lineEnd()}}}function Ze(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r<n;)i.n=e=t[r],e.p=i,i=e;i.n=e=t[0],e.p=i}}function Xe(t,n,e,r){this.x=t,this.z=n,this.o=e,this.e=r,this.v=!1,this.n=this.p=null}function Ge(n,e,r,i){return function(o,a){var u,s=e(a),l=o.invert(i[0],i[1]),c={point:h,lineStart:p,lineEnd:g,polygonStart:function(){c.point=_,c.lineStart=w,c.lineEnd=b,u=[],d=[]},polygonEnd:function(){c.point=h,c.lineStart=p,c.lineEnd=g,u=t.merge(u);var n=function(t,n){var e=t[0],r=t[1],i=[Math.sin(e),-Math.cos(e),0],o=0,a=0;Ce.reset();for(var u=0,s=n.length;u<s;++u){var l=n[u],c=l.length;if(c)for(var h=l[0],f=h[0],p=h[1]/2+Et/4,g=Math.sin(p),d=Math.cos(p),y=1;;){y===c&&(y=0);var v=(t=l[y])[0],m=t[1]/2+Et/4,x=Math.sin(m),_=Math.cos(m),w=v-f,b=w>=0?1:-1,M=b*w,k=M>Et,E=g*x;if(Ce.add(Math.atan2(E*b*Math.sin(M),d*_+E*Math.cos(M))),o+=k?w+b*St:w,k^f>=e^v>=e){var S=ze(Fe(h),Fe(t));Pe(S);var A=ze(i,S);Pe(A);var C=(k^w>=0?-1:1)*Dt(A[2]);(r>C||r===C&&(S[0]||S[1]))&&(a+=k^w>=0?1:-1)}if(!y++)break;f=v,g=x,d=_,h=t}}return(o<-Mt||o<Mt&&Ce<-Mt)^1&a}(l,d);u.length?(x||(a.polygonStart(),x=!0),We(u,Ke,n,r,a)):n&&(x||(a.polygonStart(),x=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),x&&(a.polygonEnd(),x=!1),u=d=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}};function h(t,e){var r=o(t,e);n(t=r[0],e=r[1])&&a.point(t,e)}function f(t,n){var e=o(t,n);s.point(e[0],e[1])}function p(){c.point=f,s.lineStart()}function g(){c.point=h,s.lineEnd()}var d,y,v=Je(),m=e(v),x=!1;function _(t,n){y.push([t,n]);var e=o(t,n);m.point(e[0],e[1])}function w(){m.lineStart(),y=[]}function b(){_(y[0][0],y[0][1]),m.lineEnd();var t,n=m.clean(),e=v.buffer(),r=e.length;if(y.pop(),d.push(y),y=null,r)if(1&n){var i,o=-1;if((r=(t=e[0]).length-1)>0){for(x||(a.polygonStart(),x=!0),a.lineStart();++o<r;)a.point((i=t[o])[0],i[1]);a.lineEnd()}}else r>1&&2&n&&e.push(e.pop().concat(e.shift())),u.push(e.filter(Qe))}return c}}function Qe(t){return t.length>1}function Je(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:z,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function Ke(t,n){return((t=t.x)[0]<0?t[1]-Ct-Mt:Ct-t[1])-((n=n.x)[0]<0?n[1]-Ct-Mt:Ct-n[1])}var tr=Ge(Ye,(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?Et:-Et,s=v(o-e);v(s-Et)<Mt?(t.point(e,r=(r+a)/2>0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&s>=Et&&(v(e-i)<Mt&&(e-=i*Mt),v(o-u)<Mt&&(o-=u*Mt),r=function(t,n,e,r){var i,o,a=Math.sin(t-e);return v(a)>Mt?Math.atan((Math.sin(n)*(o=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(n))*Math.sin(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*Ct,r.point(-Et,i),r.point(0,i),r.point(Et,i),r.point(Et,0),r.point(Et,-i),r.point(0,-i),r.point(-Et,-i),r.point(-Et,0),r.point(-Et,i);else if(v(t[0]-n[0])>Mt){var o=t[0]<n[0]?Et:-Et;i=e*o/2,r.point(-o,i),r.point(0,i),r.point(o,i)}else r.point(n[0],n[1])}),[-Et,-Et/2]);function nr(t){var n=Math.cos(t),e=n>0,r=v(n)>Mt;return Ge(i,(function(t){var n,u,s,l,c;return{lineStart:function(){l=s=!1,c=1},point:function(h,f){var p,g=[h,f],d=i(h,f),y=e?d?0:a(h,f):d?a(h+(h<0?Et:-Et),f):0;if(!n&&(l=s=d)&&t.lineStart(),d!==s&&(p=o(n,g),(Ue(n,p)||Ue(g,p))&&(g[0]+=Mt,g[1]+=Mt,d=i(g[0],g[1]))),d!==s)c=0,d?(t.lineStart(),p=o(g,n),t.point(p[0],p[1])):(p=o(n,g),t.point(p[0],p[1]),t.lineEnd()),n=p;else if(r&&n&&e^d){var v;y&u||!(v=o(g,n,!0))||(c=0,e?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!d||n&&Ue(n,g)||t.point(g[0],g[1]),n=g,s=d,u=y},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return c|(l&&s)<<1}}}),qr(t,6*Nt),e?[0,-t]:[-Et,t-Et]);function i(t,e){return Math.cos(t)*Math.cos(e)>n}function o(t,e,r){var i=[1,0,0],o=ze(Fe(t),Fe(e)),a=Le(o,o),u=o[0],s=a-u*u;if(!s)return!r&&t;var l=n*a/s,c=-n*u/s,h=ze(i,o),f=Re(i,l);De(f,Re(o,c));var p=h,g=Le(f,p),d=Le(p,p),y=g*g-d*(Le(f,f)-1);if(!(y<0)){var m=Math.sqrt(y),x=Re(p,(-g-m)/d);if(De(x,f),x=qe(x),!r)return x;var _,w=t[0],b=e[0],M=t[1],k=e[1];b<w&&(_=w,w=b,b=_);var E=b-w,S=v(E-Et)<Mt;if(!S&&k<M&&(_=M,M=k,k=_),S||E<Mt?S?M+k>0^x[1]<(v(x[0]-w)<Mt?M:k):M<=x[1]&&x[1]<=k:E>Et^(w<=x[0]&&x[0]<=b)){var A=Re(p,(-g+m)/d);return De(A,f),[x,qe(A)]}}}function a(n,r){var i=e?t:Et-t,o=0;return n<-i?o|=1:n>i&&(o|=2),r<-i?o|=4:r>i&&(o|=8),o}}function er(t,n,e,r){return function(i){var o,a=i.a,u=i.b,s=a.x,l=a.y,c=0,h=1,f=u.x-s,p=u.y-l;if(o=t-s,f||!(o>0)){if(o/=f,f<0){if(o<c)return;o<h&&(h=o)}else if(f>0){if(o>h)return;o>c&&(c=o)}if(o=e-s,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o)}else if(f>0){if(o<c)return;o<h&&(h=o)}if(o=n-l,p||!(o>0)){if(o/=p,p<0){if(o<c)return;o<h&&(h=o)}else if(p>0){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(o<c)return;o<h&&(h=o)}return c>0&&(i.a={x:s+c*f,y:l+c*p}),h<1&&(i.b={x:s+h*f,y:l+h*p}),i}}}}}}function rr(n,e,r,i){return function(s){var l,c,h,f,p,g,d,y,v,m,x,_=s,w=Je(),b=er(n,e,r,i),M={point:S,lineStart:function(){M.point=A,c&&c.push(h=[]),m=!0,v=!1,d=y=NaN},lineEnd:function(){l&&(A(f,p),g&&v&&w.rejoin(),l.push(w.buffer())),M.point=S,v&&s.lineEnd()},polygonStart:function(){s=w,l=[],c=[],x=!0},polygonEnd:function(){s=_,l=t.merge(l);var e=function(t){for(var n=0,e=c.length,r=t[1],i=0;i<e;++i)for(var o,a=1,u=c[i],s=u.length,l=u[0];a<s;++a)o=u[a],l[1]<=r?o[1]>r&&Lt(l,o,t)>0&&++n:o[1]<=r&&Lt(l,o,t)<0&&--n,l=o;return 0!==n}([n,i]),r=x&&e,o=l.length;(r||o)&&(s.polygonStart(),r&&(s.lineStart(),k(null,null,1,s),s.lineEnd()),o&&We(l,a,e,k,s),s.polygonEnd()),l=c=h=null}};function k(t,a,s,l){var c=0,h=0;if(null==t||(c=o(t,s))!==(h=o(a,s))||u(t,a)<0^s>0)do{l.point(0===c||3===c?n:r,c>1?i:e)}while((c=(c+s+4)%4)!==h);else l.point(a[0],a[1])}function E(t,o){return n<=t&&t<=r&&e<=o&&o<=i}function S(t,n){E(t,n)&&s.point(t,n)}function A(t,n){var e=E(t=Math.max(-1e9,Math.min(1e9,t)),n=Math.max(-1e9,Math.min(1e9,n)));if(c&&h.push([t,n]),m)f=t,p=n,g=e,m=!1,e&&(s.lineStart(),s.point(t,n));else if(e&&v)s.point(t,n);else{var r={a:{x:d,y:y},b:{x:t,y:n}};b(r)?(v||(s.lineStart(),s.point(r.a.x,r.a.y)),s.point(r.b.x,r.b.y),e||s.lineEnd(),x=!1):e&&(s.lineStart(),s.point(t,n),x=!1)}d=t,y=n,v=e}return M};function o(t,i){return v(t[0]-n)<Mt?i>0?0:3:v(t[0]-r)<Mt?i>0?2:1:v(t[1]-e)<Mt?i>0?1:0:i>0?3:2}function a(t,n){return u(t.x,n.x)}function u(t,n){var e=o(t,1),r=o(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}}function ir(t){var n=0,e=Et/3,r=Nr(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Et/180,e=t[1]*Et/180):[n/Et*180,e/Et*180]},i}function or(t,n){var e=Math.sin(t),r=(e+Math.sin(n))/2,i=1+e*(2*r-e),o=Math.sqrt(i)/r;function a(t,n){var e=Math.sqrt(i-2*r*Math.sin(n))/r;return[e*Math.sin(t*=r),o-e*Math.cos(t)]}return a.invert=function(t,n){var e=o-n;return[Math.atan2(t,e)/r,Dt((i-(t*t+e*e)*r*r)/(2*r))]},a}t.geo.clipExtent=function(){var t,n,e,r,i,o,a={stream:function(t){return i&&(i.valid=!1),(i=o(t)).valid=!0,i},extent:function(u){return arguments.length?(o=rr(t=+u[0][0],n=+u[0][1],e=+u[1][0],r=+u[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ir(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var n,e,r,i,o=t.geo.albers(),a=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),u=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,e){n=[t,e]}};function l(t){var o=t[0],a=t[1];return n=null,e(o,a),n||(r(o,a),n)||i(o,a),n}return l.invert=function(t){var n=o.scale(),e=o.translate(),r=(t[0]-e[0])/n,i=(t[1]-e[1])/n;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?a:i>=.166&&i<.234&&r>=-.214&&r<-.115?u:o).invert(t)},l.stream=function(t){var n=o.stream(t),e=a.stream(t),r=u.stream(t);return{point:function(t,i){n.point(t,i),e.point(t,i),r.point(t,i)},sphere:function(){n.sphere(),e.sphere(),r.sphere()},lineStart:function(){n.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){n.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){n.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){n.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},l.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),u.precision(t),l):o.precision()},l.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),u.scale(t),l.translate(o.translate())):o.scale()},l.translate=function(t){if(!arguments.length)return o.translate();var n=o.scale(),c=+t[0],h=+t[1];return e=o.translate(t).clipExtent([[c-.455*n,h-.238*n],[c+.455*n,h+.238*n]]).stream(s).point,r=a.translate([c-.307*n,h+.201*n]).clipExtent([[c-.425*n+Mt,h+.12*n+Mt],[c-.214*n-Mt,h+.234*n-Mt]]).stream(s).point,i=u.translate([c-.205*n,h+.212*n]).clipExtent([[c-.214*n+Mt,h+.166*n+Mt],[c-.115*n-Mt,h+.234*n-Mt]]).stream(s).point,l},l.scale(1070)};var ar,ur,sr,lr,cr,hr,fr={point:z,lineStart:z,lineEnd:z,polygonStart:function(){ur=0,fr.lineStart=pr},polygonEnd:function(){fr.lineStart=fr.lineEnd=fr.point=z,ar+=v(ur/2)}};function pr(){var t,n,e,r;function i(t,n){ur+=r*t-e*n,e=t,r=n}fr.point=function(o,a){fr.point=i,t=e=o,n=r=a},fr.lineEnd=function(){i(t,n)}}var gr={point:function(t,n){t<sr&&(sr=t),t>cr&&(cr=t),n<lr&&(lr=n),n>hr&&(hr=n)},lineStart:z,lineEnd:z,polygonStart:z,polygonEnd:z};function dr(){var t=yr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=u},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=yr(n),e},result:function(){if(n.length){var t=n.join("");return n=[],t}}};function r(e,r){n.push("M",e,",",r,t)}function i(t,r){n.push("M",t,",",r),e.point=o}function o(t,e){n.push("L",t,",",e)}function a(){e.point=r}function u(){n.push("Z")}return e}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var vr,mr={point:xr,lineStart:_r,lineEnd:wr,polygonStart:function(){mr.lineStart=br},polygonEnd:function(){mr.point=xr,mr.lineStart=_r,mr.lineEnd=wr}};function xr(t,n){xe+=t,_e+=n,++we}function _r(){var t,n;function e(e,r){var i=e-t,o=r-n,a=Math.sqrt(i*i+o*o);be+=a*(t+e)/2,Me+=a*(n+r)/2,ke+=a,xr(t=e,n=r)}mr.point=function(r,i){mr.point=e,xr(t=r,n=i)}}function wr(){mr.point=xr}function br(){var t,n,e,r;function i(t,n){var i=t-e,o=n-r,a=Math.sqrt(i*i+o*o);be+=a*(e+t)/2,Me+=a*(r+n)/2,ke+=a,Ee+=(a=r*t-e*n)*(e+t),Se+=a*(r+n),Ae+=3*a,xr(e=t,r=n)}mr.point=function(o,a){mr.point=i,xr(t=e=o,n=r=a)},mr.lineEnd=function(){i(t,n)}}function Mr(t){var n=4.5,e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=u},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:z};function r(e,r){t.moveTo(e+n,r),t.arc(e,r,n,0,St)}function i(n,r){t.moveTo(n,r),e.point=o}function o(n,e){t.lineTo(n,e)}function a(){e.point=r}function u(){t.closePath()}return e}function kr(t){var n=.5,e=Math.cos(30*Nt),r=16;function i(t){return(r?a:o)(t)}function o(n){return Ar(n,(function(e,r){e=t(e,r),n.point(e[0],e[1])}))}function a(n){var e,i,o,a,s,l,c,h,f,p,g,d,y={point:v,lineStart:m,lineEnd:_,polygonStart:function(){n.polygonStart(),y.lineStart=w},polygonEnd:function(){n.polygonEnd(),y.lineStart=m}};function v(e,r){e=t(e,r),n.point(e[0],e[1])}function m(){h=NaN,y.point=x,n.lineStart()}function x(e,i){var o=Fe([e,i]),a=t(e,i);u(h,f,c,p,g,d,h=a[0],f=a[1],c=e,p=o[0],g=o[1],d=o[2],r,n),n.point(h,f)}function _(){y.point=v,n.lineEnd()}function w(){m(),y.point=b,y.lineEnd=M}function b(t,n){x(e=t,n),i=h,o=f,a=p,s=g,l=d,y.point=x}function M(){u(h,f,c,p,g,d,i,o,e,a,s,l,r,n),y.lineEnd=_,_()}return y}function u(r,i,o,a,s,l,c,h,f,p,g,d,y,m){var x=c-r,_=h-i,w=x*x+_*_;if(w>4*n&&y--){var b=a+p,M=s+g,k=l+d,E=Math.sqrt(b*b+M*M+k*k),S=Math.asin(k/=E),A=v(v(k)-1)<Mt||v(o-f)<Mt?(o+f)/2:Math.atan2(M,b),C=t(A,S),N=C[0],T=C[1],F=N-r,L=T-i,z=_*F-x*L;(z*z/w>n||v((x*F+_*L)/w-.5)>.3||a*p+s*g+l*d<e)&&(u(r,i,o,a,s,l,N,T,A,b/=E,M/=E,k,y,m),m.point(N,T),u(N,T,A,b,M,k,c,h,f,p,g,d,y,m))}}return i.precision=function(t){return arguments.length?(r=(n=t*t)>0&&16,i):Math.sqrt(n)},i}function Er(t){var n=kr((function(n,e){return t([n*Tt,e*Tt])}));return function(t){return Tr(n(t))}}function Sr(t){this.stream=t}function Ar(t,n){return{point:n,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function Cr(t){return Nr((function(){return t}))()}function Nr(n){var e,r,i,o,a,u,s=kr((function(t,n){return[(t=e(t,n))[0]*l+o,a-t[1]*l]})),l=150,c=480,h=250,f=0,p=0,g=0,d=0,y=0,v=tr,m=N,x=null,_=null;function w(t){return[(t=i(t[0]*Nt,t[1]*Nt))[0]*l+o,a-t[1]*l]}function b(t){return(t=i.invert((t[0]-o)/l,(a-t[1])/l))&&[t[0]*Tt,t[1]*Tt]}function M(){i=$e(r=zr(g,d,y),e);var t=e(f,p);return o=c-t[0]*l,a=h+t[1]*l,k()}function k(){return u&&(u.valid=!1,u=null),w}return w.stream=function(t){return u&&(u.valid=!1),(u=Tr(v(r,s(m(t))))).valid=!0,u},w.clipAngle=function(t){return arguments.length?(v=null==t?(x=t,tr):nr((x=+t)*Nt),k()):x},w.clipExtent=function(t){return arguments.length?(_=t,m=t?rr(t[0][0],t[0][1],t[1][0],t[1][1]):N,k()):_},w.scale=function(t){return arguments.length?(l=+t,M()):l},w.translate=function(t){return arguments.length?(c=+t[0],h=+t[1],M()):[c,h]},w.center=function(t){return arguments.length?(f=t[0]%360*Nt,p=t[1]%360*Nt,M()):[f*Tt,p*Tt]},w.rotate=function(t){return arguments.length?(g=t[0]%360*Nt,d=t[1]%360*Nt,y=t.length>2?t[2]%360*Nt:0,M()):[g*Tt,d*Tt,y*Tt]},t.rebind(w,s,"precision"),function(){return e=n.apply(this,arguments),w.invert=e.invert&&b,M()}}function Tr(t){return Ar(t,(function(n,e){t.point(n*Nt,e*Nt)}))}function Fr(t,n){return[t,n]}function Lr(t,n){return[t>Et?t-St:t<-Et?t+St:t,n]}function zr(t,n,e){return t?n||e?$e(Rr(t),Pr(n,e)):Rr(t):n||e?Pr(n,e):Lr}function Dr(t){return function(n,e){return[(n+=t)>Et?n-St:n<-Et?n+St:n,e]}}function Rr(t){var n=Dr(t);return n.invert=Dr(-t),n}function Pr(t,n){var e=Math.cos(t),r=Math.sin(t),i=Math.cos(n),o=Math.sin(n);function a(t,n){var a=Math.cos(n),u=Math.cos(t)*a,s=Math.sin(t)*a,l=Math.sin(n),c=l*e+u*r;return[Math.atan2(s*i-c*o,u*e-l*r),Dt(c*i+s*o)]}return a.invert=function(t,n){var a=Math.cos(n),u=Math.cos(t)*a,s=Math.sin(t)*a,l=Math.sin(n),c=l*i-s*o;return[Math.atan2(s*i+l*o,u*e+c*r),Dt(c*e-u*r)]},a}function qr(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,u){var s=a*n;null!=i?(i=Ur(e,i),o=Ur(e,o),(a>0?i<o:i>o)&&(i+=a*St)):(i=t+a*St,o=t-.5*s);for(var l,c=i;a>0?c>o:c<o;c-=s)u.point((l=qe([e,-r*Math.cos(c),-r*Math.sin(c)]))[0],l[1])}}function Ur(t,n){var e=Fe(n);e[0]-=t,Pe(e);var r=zt(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Mt)%(2*Math.PI)}function Or(n,e,r){var i=t.range(n,e-Mt,r).concat(e);return function(t){return i.map((function(n){return[t,n]}))}}function Ir(n,e,r){var i=t.range(n,e-Mt,r).concat(e);return function(t){return i.map((function(n){return[n,t]}))}}function Hr(t){return t.source}function jr(t){return t.target}t.geo.path=function(){var n,e,r,i,o,a=4.5;function u(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=r(i)),t.geo.stream(n,o)),i.result()}function s(){return o=null,u}return u.area=function(n){return ar=0,t.geo.stream(n,r(fr)),ar},u.centroid=function(n){return xe=_e=we=be=Me=ke=Ee=Se=Ae=0,t.geo.stream(n,r(mr)),Ae?[Ee/Ae,Se/Ae]:ke?[be/ke,Me/ke]:we?[xe/we,_e/we]:[NaN,NaN]},u.bounds=function(n){return cr=hr=-(sr=lr=1/0),t.geo.stream(n,r(gr)),[[sr,lr],[cr,hr]]},u.projection=function(t){return arguments.length?(r=(n=t)?t.stream||Er(t):N,s()):n},u.context=function(t){return arguments.length?(i=null==(e=t)?new dr:new Mr(t),"function"!=typeof a&&i.pointRadius(a),s()):e},u.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),u):a},u.projection(t.geo.albersUsa()).context(null)},t.geo.transform=function(t){return{stream:function(n){var e=new Sr(n);for(var r in t)e[r]=t[r];return e}}},Sr.prototype={point:function(t,n){this.stream.point(t,n)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},t.geo.projection=Cr,t.geo.projectionMutator=Nr,(t.geo.equirectangular=function(){return Cr(Fr)}).raw=Fr.invert=Fr,t.geo.rotation=function(t){function n(n){return(n=t(n[0]*Nt,n[1]*Nt))[0]*=Tt,n[1]*=Tt,n}return t=zr(t[0]%360*Nt,t[1]*Nt,t.length>2?t[2]*Nt:0),n.invert=function(n){return(n=t.invert(n[0]*Nt,n[1]*Nt))[0]*=Tt,n[1]*=Tt,n},n},Lr.invert=Fr,t.geo.circle=function(){var t,n,e=[0,0],r=6;function i(){var t="function"==typeof e?e.apply(this,arguments):e,r=zr(-t[0]*Nt,-t[1]*Nt,0).invert,i=[];return n(null,null,1,{point:function(t,n){i.push(t=r(t,n)),t[0]*=Tt,t[1]*=Tt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(e=t,i):e},i.angle=function(e){return arguments.length?(n=qr((t=+e)*Nt,r*Nt),i):t},i.precision=function(e){return arguments.length?(n=qr(t*Nt,(r=+e)*Nt),i):r},i.angle(90)},t.geo.distance=function(t,n){var e,r=(n[0]-t[0])*Nt,i=t[1]*Nt,o=n[1]*Nt,a=Math.sin(r),u=Math.cos(r),s=Math.sin(i),l=Math.cos(i),c=Math.sin(o),h=Math.cos(o);return Math.atan2(Math.sqrt((e=h*a)*e+(e=l*c-s*h*u)*e),s*c+l*h*u)},t.geo.graticule=function(){var n,e,r,i,o,a,u,s,l,c,h,f,p=10,g=p,d=90,y=360,m=2.5;function x(){return{type:"MultiLineString",coordinates:_()}}function _(){return t.range(Math.ceil(i/d)*d,r,d).map(h).concat(t.range(Math.ceil(s/y)*y,u,y).map(f)).concat(t.range(Math.ceil(e/p)*p,n,p).filter((function(t){return v(t%d)>Mt})).map(l)).concat(t.range(Math.ceil(a/g)*g,o,g).filter((function(t){return v(t%y)>Mt})).map(c))}return x.lines=function(){return _().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(f(u).slice(1),h(r).reverse().slice(1),f(s).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],s=+t[0][1],u=+t[1][1],i>r&&(t=i,i=r,r=t),s>u&&(t=s,s=u,u=t),x.precision(m)):[[i,s],[r,u]]},x.minorExtent=function(t){return arguments.length?(e=+t[0][0],n=+t[1][0],a=+t[0][1],o=+t[1][1],e>n&&(t=e,e=n,n=t),a>o&&(t=a,a=o,o=t),x.precision(m)):[[e,a],[n,o]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],x):[d,y]},x.minorStep=function(t){return arguments.length?(p=+t[0],g=+t[1],x):[p,g]},x.precision=function(t){return arguments.length?(m=+t,l=Or(a,o,90),c=Ir(e,n,m),h=Or(s,u,90),f=Ir(i,r,m),x):m},x.majorExtent([[-180,-90+Mt],[180,90-Mt]]).minorExtent([[-180,-80-Mt],[180,80+Mt]])},t.geo.greatArc=function(){var n,e,r=Hr,i=jr;function o(){return{type:"LineString",coordinates:[n||r.apply(this,arguments),e||i.apply(this,arguments)]}}return o.distance=function(){return t.geo.distance(n||r.apply(this,arguments),e||i.apply(this,arguments))},o.source=function(t){return arguments.length?(r=t,n="function"==typeof t?null:t,o):r},o.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,o):i},o.precision=function(){return arguments.length?o:0},o},t.geo.interpolate=function(t,n){return e=t[0]*Nt,r=t[1]*Nt,i=n[0]*Nt,o=n[1]*Nt,a=Math.cos(r),u=Math.sin(r),s=Math.cos(o),l=Math.sin(o),c=a*Math.cos(e),h=a*Math.sin(e),f=s*Math.cos(i),p=s*Math.sin(i),g=2*Math.asin(Math.sqrt(Pt(o-r)+a*s*Pt(i-e))),d=1/Math.sin(g),(y=g?function(t){var n=Math.sin(t*=g)*d,e=Math.sin(g-t)*d,r=e*c+n*f,i=e*h+n*p,o=e*u+n*l;return[Math.atan2(i,r)*Tt,Math.atan2(o,Math.sqrt(r*r+i*i))*Tt]}:function(){return[e*Tt,r*Tt]}).distance=g,y;var e,r,i,o,a,u,s,l,c,h,f,p,g,d,y},t.geo.length=function(n){return vr=0,t.geo.stream(n,Vr),vr};var Vr={sphere:z,point:z,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=Nt),a=Math.cos(i),u=v((r*=Nt)-t),s=Math.cos(u);vr+=Math.atan2(Math.sqrt((u=a*Math.sin(u))*u+(u=e*o-n*a*s)*u),n*o+e*a*s),t=r,n=o,e=a}Vr.point=function(i,o){t=i*Nt,n=Math.sin(o*=Nt),e=Math.cos(o),Vr.point=r},Vr.lineEnd=function(){Vr.point=Vr.lineEnd=z}},lineEnd:z,polygonStart:z,polygonEnd:z};function Br(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),o=t(r*i);return[o*i*Math.sin(n),o*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),o=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*o,r*a),Math.asin(r&&e*o/r)]},e}var $r=Br((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(t.geo.azimuthalEqualArea=function(){return Cr($r)}).raw=$r;var Yr=Br((function(t){var n=Math.acos(t);return n&&n/Math.sin(n)}),N);function Wr(t,n){var e=Math.cos(t),r=function(t){return Math.tan(Et/4+t/2)},i=t===n?Math.sin(t):Math.log(e/Math.cos(n))/Math.log(r(n)/r(t)),o=e*Math.pow(r(t),i)/i;if(!i)return Gr;function a(t,n){o>0?n<-Ct+Mt&&(n=-Ct+Mt):n>Ct-Mt&&(n=Ct-Mt);var e=o/Math.pow(r(n),i);return[e*Math.sin(i*t),o-e*Math.cos(i*t)]}return a.invert=function(t,n){var e=o-n,r=Ft(i)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ct]},a}function Zr(t,n){var e=Math.cos(t),r=t===n?Math.sin(t):(e-Math.cos(n))/(n-t),i=e/r+t;if(v(r)<Mt)return Fr;function o(t,n){var e=i-n;return[e*Math.sin(r*t),i-e*Math.cos(r*t)]}return o.invert=function(t,n){var e=i-n;return[Math.atan2(t,e)/r,i-Ft(r)*Math.sqrt(t*t+e*e)]},o}(t.geo.azimuthalEquidistant=function(){return Cr(Yr)}).raw=Yr,(t.geo.conicConformal=function(){return ir(Wr)}).raw=Wr,(t.geo.conicEquidistant=function(){return ir(Zr)}).raw=Zr;var Xr=Br((function(t){return 1/t}),Math.atan);function Gr(t,n){return[t,Math.log(Math.tan(Et/4+n/2))]}function Qr(t){var n,e=Cr(t),r=e.scale,i=e.translate,o=e.clipExtent;return e.scale=function(){var t=r.apply(e,arguments);return t===e?n?e.clipExtent(null):e:t},e.translate=function(){var t=i.apply(e,arguments);return t===e?n?e.clipExtent(null):e:t},e.clipExtent=function(t){var a=o.apply(e,arguments);if(a===e){if(n=null==t){var u=Et*r(),s=i();o([[s[0]-u,s[1]-u],[s[0]+u,s[1]+u]])}}else n&&(a=null);return a},e.clipExtent(null)}(t.geo.gnomonic=function(){return Cr(Xr)}).raw=Xr,Gr.invert=function(t,n){return[t,2*Math.atan(Math.exp(n))-Ct]},(t.geo.mercator=function(){return Qr(Gr)}).raw=Gr;var Jr=Br((function(){return 1}),Math.asin);(t.geo.orthographic=function(){return Cr(Jr)}).raw=Jr;var Kr=Br((function(t){return 1/(1+t)}),(function(t){return 2*Math.atan(t)}));function ti(t,n){return[Math.log(Math.tan(Et/4+n/2)),-t]}function ni(t){return t[0]}function ei(t){return t[1]}function ri(t){for(var n=t.length,e=[0,1],r=2,i=2;i<n;i++){for(;r>1&&Lt(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ii(t,n){return t[0]-n[0]||t[1]-n[1]}(t.geo.stereographic=function(){return Cr(Kr)}).raw=Kr,ti.invert=function(t,n){return[-n,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Qr(ti),n=t.center,e=t.rotate;return t.center=function(t){return t?n([-t[1],t[0]]):[(t=n())[1],-t[0]]},t.rotate=function(t){return t?e([t[0],t[1],t.length>2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var n=ni,e=ei;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=gn(n),o=gn(e),a=t.length,u=[],s=[];for(r=0;r<a;r++)u.push([+i.call(this,t[r],r),+o.call(this,t[r],r),r]);for(u.sort(ii),r=0;r<a;r++)s.push([u[r][0],-u[r][1]]);var l=ri(u),c=ri(s),h=c[0]===l[0],f=c[c.length-1]===l[l.length-1],p=[];for(r=l.length-1;r>=0;--r)p.push(t[u[l[r]][2]]);for(r=+h;r<c.length-f;++r)p.push(t[u[c[r]][2]]);return p}return r.x=function(t){return arguments.length?(n=t,r):n},r.y=function(t){return arguments.length?(e=t,r):e},r},t.geom.polygon=function(t){return I(t,oi),t};var oi=t.geom.polygon.prototype=[];function ai(t,n,e){return(e[0]-n[0])*(t[1]-n[1])<(e[1]-n[1])*(t[0]-n[0])}function ui(t,n,e,r){var i=t[0],o=e[0],a=n[0]-i,u=r[0]-o,s=t[1],l=e[1],c=n[1]-s,h=r[1]-l,f=(u*(s-l)-h*(i-o))/(h*a-u*c);return[i+f*a,s+f*c]}function si(t){var n=t[0],e=t[t.length-1];return!(n[0]-e[0]||n[1]-e[1])}oi.area=function(){for(var t,n=-1,e=this.length,r=this[e-1],i=0;++n<e;)t=r,r=this[n],i+=t[1]*r[0]-t[0]*r[1];return.5*i},oi.centroid=function(t){var n,e,r=-1,i=this.length,o=0,a=0,u=this[i-1];for(arguments.length||(t=-1/(6*this.area()));++r<i;)n=u,u=this[r],e=n[0]*u[1]-u[0]*n[1],o+=(n[0]+u[0])*e,a+=(n[1]+u[1])*e;return[o*t,a*t]},oi.clip=function(t){for(var n,e,r,i,o,a,u=si(t),s=-1,l=this.length-si(this),c=this[l-1];++s<l;){for(n=t.slice(),t.length=0,i=this[s],o=n[(r=n.length-u)-1],e=-1;++e<r;)ai(a=n[e],c,i)?(ai(o,c,i)||t.push(ui(o,a,c,i)),t.push(a)):ai(o,c,i)&&t.push(ui(o,a,c,i)),o=a;u&&t.push(t[0]),c=i}return t};var li,ci,hi,fi,pi,gi=[],di=[];function yi(){Di(this),this.edge=this.site=this.circle=null}function vi(t){var n=gi.pop()||new yi;return n.site=t,n}function mi(t){Ai(t),hi.remove(t),gi.push(t),Di(t)}function xi(t){var n=t.circle,e=n.x,r=n.cy,i={x:e,y:r},o=t.P,a=t.N,u=[t];mi(t);for(var s=o;s.circle&&v(e-s.circle.x)<Mt&&v(r-s.circle.cy)<Mt;)o=s.P,u.unshift(s),mi(s),s=o;u.unshift(s),Ai(s);for(var l=a;l.circle&&v(e-l.circle.x)<Mt&&v(r-l.circle.cy)<Mt;)a=l.N,u.push(l),mi(l),l=a;u.push(l),Ai(l);var c,h=u.length;for(c=1;c<h;++c)l=u[c],s=u[c-1],Fi(l.edge,s.site,l.site,i);s=u[0],(l=u[h-1]).edge=Ti(s.site,l.site,null,i),Si(s),Si(l)}function _i(t){for(var n,e,r,i,o=t.x,a=t.y,u=hi._;u;)if((r=wi(u,a)-o)>Mt)u=u.L;else{if(!((i=o-bi(u,a))>Mt)){r>-Mt?(n=u.P,e=u):i>-Mt?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}var s=vi(t);if(hi.insert(n,s),n||e){if(n===e)return Ai(n),e=vi(n.site),hi.insert(s,e),s.edge=e.edge=Ti(n.site,s.site),Si(n),void Si(e);if(e){Ai(n),Ai(e);var l=n.site,c=l.x,h=l.y,f=t.x-c,p=t.y-h,g=e.site,d=g.x-c,y=g.y-h,v=2*(f*y-p*d),m=f*f+p*p,x=d*d+y*y,_={x:(y*m-p*x)/v+c,y:(f*x-d*m)/v+h};Fi(e.edge,l,g,_),s.edge=Ti(l,t,null,_),e.edge=Ti(t,g,null,_),Si(n),Si(e)}else s.edge=Ti(n.site,s.site)}}function wi(t,n){var e=t.site,r=e.x,i=e.y,o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var u=(e=a.site).x,s=e.y,l=s-n;if(!l)return u;var c=u-r,h=1/o-1/l,f=c/l;return h?(-f+Math.sqrt(f*f-2*h*(c*c/(-2*l)-s+l/2+i-o/2)))/h+r:(r+u)/2}function bi(t,n){var e=t.N;if(e)return wi(e,n);var r=t.site;return r.y===n?r.x:1/0}function Mi(t){this.site=t,this.edges=[]}function ki(t,n){return n.angle-t.angle}function Ei(){Di(this),this.x=this.y=this.arc=this.site=this.cy=null}function Si(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i.x,u=i.y,s=r.x-a,l=r.y-u,c=o.x-a,h=2*(s*(y=o.y-u)-l*c);if(!(h>=-kt)){var f=s*s+l*l,p=c*c+y*y,g=(y*f-l*p)/h,d=(s*p-c*f)/h,y=d+u,v=di.pop()||new Ei;v.arc=t,v.site=i,v.x=g+a,v.y=y+Math.sqrt(g*g+d*d),v.cy=y,t.circle=v;for(var m=null,x=pi._;x;)if(v.y<x.y||v.y===x.y&&v.x<=x.x){if(!x.L){m=x.P;break}x=x.L}else{if(!x.R){m=x;break}x=x.R}pi.insert(m,v),m||(fi=v)}}}}function Ai(t){var n=t.circle;n&&(n.P||(fi=n.N),pi.remove(n),di.push(n),Di(n),t.circle=null)}function Ci(t,n){var e=t.b;if(e)return!0;var r,i,o=t.a,a=n[0][0],u=n[1][0],s=n[0][1],l=n[1][1],c=t.l,h=t.r,f=c.x,p=c.y,g=h.x,d=h.y,y=(f+g)/2,v=(p+d)/2;if(d===p){if(y<a||y>=u)return;if(f>g){if(o){if(o.y>=l)return}else o={x:y,y:s};e={x:y,y:l}}else{if(o){if(o.y<s)return}else o={x:y,y:l};e={x:y,y:s}}}else if(i=v-(r=(f-g)/(d-p))*y,r<-1||r>1)if(f>g){if(o){if(o.y>=l)return}else o={x:(s-i)/r,y:s};e={x:(l-i)/r,y:l}}else{if(o){if(o.y<s)return}else o={x:(l-i)/r,y:l};e={x:(s-i)/r,y:s}}else if(p<d){if(o){if(o.x>=u)return}else o={x:a,y:r*a+i};e={x:u,y:r*u+i}}else{if(o){if(o.x<a)return}else o={x:u,y:r*u+i};e={x:a,y:r*a+i}}return t.a=o,t.b=e,!0}function Ni(t,n){this.l=t,this.r=n,this.a=this.b=null}function Ti(t,n,e,r){var i=new Ni(t,n);return li.push(i),e&&Fi(i,t,n,e),r&&Fi(i,n,t,r),ci[t.i].edges.push(new Li(i,t,n)),ci[n.i].edges.push(new Li(i,n,t)),i}function Fi(t,n,e,r){t.a||t.b?t.l===e?t.b=r:t.a=r:(t.a=r,t.l=n,t.r=e)}function Li(t,n,e){var r=t.a,i=t.b;this.edge=t,this.site=n,this.angle=e?Math.atan2(e.y-n.y,e.x-n.x):t.l===n?Math.atan2(i.x-r.x,r.y-i.y):Math.atan2(r.x-i.x,i.y-r.y)}function zi(){this._=null}function Di(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function Ri(t,n){var e=n,r=n.R,i=e.U;i?i.L===e?i.L=r:i.R=r:t._=r,r.U=i,e.U=r,e.R=r.L,e.R&&(e.R.U=e),r.L=e}function Pi(t,n){var e=n,r=n.L,i=e.U;i?i.L===e?i.L=r:i.R=r:t._=r,r.U=i,e.U=r,e.L=r.R,e.L&&(e.L.U=e),r.R=e}function qi(t){for(;t.L;)t=t.L;return t}function Ui(t,n){var e,r,i,o=t.sort(Oi).pop();for(li=[],ci=new Array(t.length),hi=new zi,pi=new zi;;)if(i=fi,o&&(!i||o.y<i.y||o.y===i.y&&o.x<i.x))o.x===e&&o.y===r||(ci[o.i]=new Mi(o),_i(o),e=o.x,r=o.y),o=t.pop();else{if(!i)break;xi(i.arc)}n&&(function(t){for(var n,e=li,r=er(t[0][0],t[0][1],t[1][0],t[1][1]),i=e.length;i--;)(!Ci(n=e[i],t)||!r(n)||v(n.a.x-n.b.x)<Mt&&v(n.a.y-n.b.y)<Mt)&&(n.a=n.b=null,e.splice(i,1))}(n),function(t){for(var n,e,r,i,o,a,u,s,l,c,h=t[0][0],f=t[1][0],p=t[0][1],g=t[1][1],d=ci,y=d.length;y--;)if((o=d[y])&&o.prepare())for(s=(u=o.edges).length,a=0;a<s;)r=(c=u[a].end()).x,i=c.y,n=(l=u[++a%s].start()).x,e=l.y,(v(r-n)>Mt||v(i-e)>Mt)&&(u.splice(a,0,new Li((m=o.site,x=c,_=v(r-h)<Mt&&g-i>Mt?{x:h,y:v(n-h)<Mt?e:g}:v(i-g)<Mt&&f-r>Mt?{x:v(e-g)<Mt?n:f,y:g}:v(r-f)<Mt&&i-p>Mt?{x:f,y:v(n-f)<Mt?e:p}:v(i-p)<Mt&&r-h>Mt?{x:v(e-p)<Mt?n:h,y:p}:null,w=void 0,(w=new Ni(m,null)).a=x,w.b=_,li.push(w),w),o.site,null)),++s);var m,x,_,w}(n));var a={cells:ci,edges:li};return hi=pi=li=ci=null,a}function Oi(t,n){return n.y-t.y||n.x-t.x}Mi.prototype.prepare=function(){for(var t,n=this.edges,e=n.length;e--;)(t=n[e].edge).b&&t.a||n.splice(e,1);return n.sort(ki),n.length},Li.prototype={start:function(){return this.edge.l===this.site?this.edge.a:this.edge.b},end:function(){return this.edge.l===this.site?this.edge.b:this.edge.a}},zi.prototype={insert:function(t,n){var e,r,i;if(t){if(n.P=t,n.N=t.N,t.N&&(t.N.P=n),t.N=n,t.R){for(t=t.R;t.L;)t=t.L;t.L=n}else t.R=n;e=t}else this._?(t=qi(this._),n.P=null,n.N=t,t.P=t.L=n,e=t):(n.P=n.N=null,this._=n,e=null);for(n.L=n.R=null,n.U=e,n.C=!0,t=n;e&&e.C;)e===(r=e.U).L?(i=r.R)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.R&&(Ri(this,e),e=(t=e).U),e.C=!1,r.C=!0,Pi(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(Pi(this,e),e=(t=e).U),e.C=!1,r.C=!0,Ri(this,r)),e=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var n,e,r,i=t.U,o=t.L,a=t.R;if(e=o?a?qi(a):o:a,i?i.L===t?i.L=e:i.R=e:this._=e,o&&a?(r=e.C,e.C=t.C,e.L=o,o.U=e,e!==a?(i=e.U,e.U=t.U,t=e.R,i.L=t,e.R=a,a.U=e):(e.U=i,i=e,t=e.R)):(r=t.C,t=e),t&&(t.U=i),!r)if(t&&t.C)t.C=!1;else{do{if(t===this._)break;if(t===i.L){if((n=i.R).C&&(n.C=!1,i.C=!0,Ri(this,i),n=i.R),n.L&&n.L.C||n.R&&n.R.C){n.R&&n.R.C||(n.L.C=!1,n.C=!0,Pi(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,Ri(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,Pi(this,i),n=i.L),n.L&&n.L.C||n.R&&n.R.C){n.L&&n.L.C||(n.R.C=!1,n.C=!0,Ri(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,Pi(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}},t.geom.voronoi=function(t){var n=ni,e=ei,r=n,i=e,o=Ii;if(t)return a(t);function a(t){var n=new Array(t.length),e=o[0][0],r=o[0][1],i=o[1][0],a=o[1][1];return Ui(u(t),o).cells.forEach((function(o,u){var s=o.edges,l=o.site;(n[u]=s.length?s.map((function(t){var n=t.start();return[n.x,n.y]})):l.x>=e&&l.x<=i&&l.y>=r&&l.y<=a?[[e,a],[i,a],[i,r],[e,r]]:[]).point=t[u]})),n}function u(t){return t.map((function(t,n){return{x:Math.round(r(t,n)/Mt)*Mt,y:Math.round(i(t,n)/Mt)*Mt,i:n}}))}return a.links=function(t){return Ui(u(t)).edges.filter((function(t){return t.l&&t.r})).map((function(n){return{source:t[n.l.i],target:t[n.r.i]}}))},a.triangles=function(t){var n=[];return Ui(u(t)).cells.forEach((function(e,r){for(var i,o,a,u,s=e.site,l=e.edges.sort(ki),c=-1,h=l.length,f=l[h-1].edge,p=f.l===s?f.r:f.l;++c<h;)i=p,p=(f=l[c].edge).l===s?f.r:f.l,r<i.i&&r<p.i&&(a=i,u=p,((o=s).x-u.x)*(a.y-o.y)-(o.x-a.x)*(u.y-o.y)<0)&&n.push([t[r],t[i.i],t[p.i]])})),n},a.x=function(t){return arguments.length?(r=gn(n=t),a):n},a.y=function(t){return arguments.length?(i=gn(e=t),a):e},a.clipExtent=function(t){return arguments.length?(o=null==t?Ii:t,a):o===Ii?null:o},a.size=function(t){return arguments.length?a.clipExtent(t&&[[0,0],t]):o===Ii?null:o&&o[1]},a};var Ii=[[-1e6,-1e6],[1e6,1e6]];function Hi(t){return t.x}function ji(t){return t.y}function Vi(t,n,e,r,i,o){if(!t(n,e,r,i,o)){var a=.5*(e+i),u=.5*(r+o),s=n.nodes;s[0]&&Vi(t,s[0],e,r,a,u),s[1]&&Vi(t,s[1],a,r,i,u),s[2]&&Vi(t,s[2],e,u,a,o),s[3]&&Vi(t,s[3],a,u,i,o)}}function Bi(t,n,e,r,i,o,a){var u,s=1/0;return function t(l,c,h,f,p){if(!(c>o||h>a||f<r||p<i)){if(g=l.point){var g,d=n-l.x,y=e-l.y,v=d*d+y*y;if(v<s){var m=Math.sqrt(s=v);r=n-m,i=e-m,o=n+m,a=e+m,u=g}}for(var x=l.nodes,_=.5*(c+f),w=.5*(h+p),b=(e>=w)<<1|n>=_,M=b+4;b<M;++b)if(l=x[3&b])switch(3&b){case 0:t(l,c,h,_,w);break;case 1:t(l,_,h,f,w);break;case 2:t(l,c,w,_,p);break;case 3:t(l,_,w,f,p)}}}(t,r,i,o,a),u}function $i(n,e){n=t.rgb(n),e=t.rgb(e);var r=n.r,i=n.g,o=n.b,a=e.r-r,u=e.g-i,s=e.b-o;return function(t){return"#"+un(Math.round(r+a*t))+un(Math.round(i+u*t))+un(Math.round(o+s*t))}}function Yi(t,n){var e,r={},i={};for(e in t)e in n?r[e]=Qi(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}}function Wi(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}function Zi(t,n){var e,r,i,o=Xi.lastIndex=Gi.lastIndex=0,a=-1,u=[],s=[];for(t+="",n+="";(e=Xi.exec(t))&&(r=Gi.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,s.push({i:a,x:Wi(e,r)})),o=Gi.lastIndex;return o<n.length&&(i=n.slice(o),u[a]?u[a]+=i:u[++a]=i),u.length<2?s[0]?(n=s[0].x,function(t){return n(t)+""}):function(){return n}:(n=s.length,function(t){for(var e,r=0;r<n;++r)u[(e=s[r]).i]=e.x(t);return u.join("")})}t.geom.delaunay=function(n){return t.geom.voronoi().triangles(n)},t.geom.quadtree=function(t,n,e,r,i){var o,a=ni,u=ei;if(o=arguments.length)return a=Hi,u=ji,3===o&&(i=e,r=n,e=n=0),s(t);function s(t){var s,l,c,h,f,p,g,d,y,m=gn(a),x=gn(u);if(null!=n)p=n,g=e,d=r,y=i;else if(d=y=-(p=g=1/0),l=[],c=[],f=t.length,o)for(h=0;h<f;++h)(s=t[h]).x<p&&(p=s.x),s.y<g&&(g=s.y),s.x>d&&(d=s.x),s.y>y&&(y=s.y),l.push(s.x),c.push(s.y);else for(h=0;h<f;++h){var _=+m(s=t[h],h),w=+x(s,h);_<p&&(p=_),w<g&&(g=w),_>d&&(d=_),w>y&&(y=w),l.push(_),c.push(w)}var b=d-p,M=y-g;function k(t,n,e,r,i,o,a,u){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var s=t.x,l=t.y;if(null!=s)if(v(s-e)+v(l-r)<.01)E(t,n,e,r,i,o,a,u);else{var c=t.point;t.x=t.y=t.point=null,E(t,c,s,l,i,o,a,u),E(t,n,e,r,i,o,a,u)}else t.x=e,t.y=r,t.point=n}else E(t,n,e,r,i,o,a,u)}function E(t,n,e,r,i,o,a,u){var s=.5*(i+a),l=.5*(o+u),c=e>=s,h=r>=l,f=h<<1|c;t.leaf=!1,c?i=s:a=s,h?o=l:u=l,k(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,u)}b>M?y=g+b:d=p+M;var S={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(S,t,+m(t,++h),+x(t,h),p,g,d,y)},visit:function(t){Vi(t,S,p,g,d,y)},find:function(t){return Bi(S,t[0],t[1],p,g,d,y)}};if(h=-1,null==n){for(;++h<f;)k(S,t[h],l[h],c[h],p,g,d,y);--h}else t.forEach(S.add);return l=c=t=s=null,S}return s.x=function(t){return arguments.length?(a=t,s):a},s.y=function(t){return arguments.length?(u=t,s):u},s.extent=function(t){return arguments.length?(null==t?n=e=r=i=null:(n=+t[0][0],e=+t[0][1],r=+t[1][0],i=+t[1][1]),s):null==n?null:[[n,e],[r,i]]},s.size=function(t){return arguments.length?(null==t?n=e=r=i=null:(n=e=0,r=+t[0],i=+t[1]),s):null==n?null:[r-n,i-e]},s},t.interpolateRgb=$i,t.interpolateObject=Yi,t.interpolateNumber=Wi,t.interpolateString=Zi;var Xi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Gi=new RegExp(Xi.source,"g");function Qi(n,e){for(var r,i=t.interpolators.length;--i>=0&&!(r=t.interpolators[i](n,e)););return r}function Ji(t,n){var e,r=[],i=[],o=t.length,a=n.length,u=Math.min(t.length,n.length);for(e=0;e<u;++e)r.push(Qi(t[e],n[e]));for(;e<o;++e)i[e]=t[e];for(;e<a;++e)i[e]=n[e];return function(t){for(e=0;e<u;++e)i[e]=r[e](t);return i}}t.interpolate=Qi,t.interpolators=[function(t,n){var e=typeof n;return("string"===e?pn.has(n.toLowerCase())||/^(#|rgb\(|hsl\()/i.test(n)?$i:Zi:n instanceof Ht?$i:Array.isArray(n)?Ji:"object"===e&&isNaN(n)?Yi:Wi)(t,n)}],t.interpolateArray=Ji;var Ki=function(){return N},to=t.map({linear:Ki,poly:function(t){return function(n){return Math.pow(n,t)}},quad:function(){return oo},cubic:function(){return ao},sin:function(){return so},exp:function(){return lo},circle:function(){return co},elastic:function(t,n){var e;return arguments.length<2&&(n=.45),arguments.length?e=n/St*Math.asin(1/t):(t=1,e=n/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-e)*St/n)}},back:function(t){return t||(t=1.70158),function(n){return n*n*((t+1)*n-t)}},bounce:function(){return ho}}),no=t.map({in:N,out:ro,"in-out":io,"out-in":function(t){return io(ro(t))}});function eo(t){return function(n){return n<=0?0:n>=1?1:t(n)}}function ro(t){return function(n){return 1-t(1-n)}}function io(t){return function(n){return.5*(n<.5?t(2*n):2-t(2-2*n))}}function oo(t){return t*t}function ao(t){return t*t*t}function uo(t){if(t<=0)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(t<.5?e:3*(t-n)+e-.75)}function so(t){return 1-Math.cos(t*Ct)}function lo(t){return Math.pow(2,10*(t-1))}function co(t){return 1-Math.sqrt(1-t*t)}function ho(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function fo(t,n){return n-=t,function(e){return Math.round(t+n*e)}}function po(t){var n,e,r,i=[t.a,t.b],o=[t.c,t.d],a=yo(i),u=go(i,o),s=yo(((n=o)[0]+=(r=-u)*(e=i)[0],n[1]+=r*e[1],n))||0;i[0]*o[1]<o[0]*i[1]&&(i[0]*=-1,i[1]*=-1,a*=-1,u*=-1),this.rotate=(a?Math.atan2(i[1],i[0]):Math.atan2(-o[0],o[1]))*Tt,this.translate=[t.e,t.f],this.scale=[a,s],this.skew=s?Math.atan2(u,s)*Tt:0}function go(t,n){return t[0]*n[0]+t[1]*n[1]}function yo(t){var n=Math.sqrt(go(t,t));return n&&(t[0]/=n,t[1]/=n),n}t.ease=function(t){var e=t.indexOf("-"),r=e>=0?t.slice(0,e):t,i=e>=0?t.slice(e+1):"in";return r=to.get(r)||Ki,eo((i=no.get(i)||N)(r.apply(null,n.call(arguments,1))))},t.interpolateHcl=function(n,e){n=t.hcl(n),e=t.hcl(e);var r=n.h,i=n.c,o=n.l,a=e.h-r,u=e.c-i,s=e.l-o;return isNaN(u)&&(u=0,i=isNaN(i)?e.c:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Wt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateHsl=function(n,e){n=t.hsl(n),e=t.hsl(e);var r=n.h,i=n.s,o=n.l,a=e.h-r,u=e.s-i,s=e.l-o;return isNaN(u)&&(u=0,i=isNaN(i)?e.s:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Bt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateLab=function(n,e){n=t.lab(n),e=t.lab(e);var r=n.l,i=n.a,o=n.b,a=e.l-r,u=e.a-i,s=e.b-o;return function(t){return Qt(r+a*t,i+u*t,o+s*t)+""}},t.interpolateRound=fo,t.transform=function(n){var e=r.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new po(n?n.matrix:vo)})(n)},po.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var vo={a:1,b:0,c:0,d:1,e:0,f:0};function mo(t){return t.length?t.pop()+",":""}function xo(n,e){var r=[],i=[];return n=t.transform(n),e=t.transform(e),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push("translate(",null,",",null,")");r.push({i:i-4,x:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else(n[0]||n[1])&&e.push("translate("+n+")")}(n.translate,e.translate,r,i),function(t,n,e,r){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),r.push({i:e.push(mo(e)+"rotate(",null,")")-2,x:Wi(t,n)})):n&&e.push(mo(e)+"rotate("+n+")")}(n.rotate,e.rotate,r,i),function(t,n,e,r){t!==n?r.push({i:e.push(mo(e)+"skewX(",null,")")-2,x:Wi(t,n)}):n&&e.push(mo(e)+"skewX("+n+")")}(n.skew,e.skew,r,i),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push(mo(e)+"scale(",null,",",null,")");r.push({i:i-4,x:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else 1===n[0]&&1===n[1]||e.push(mo(e)+"scale("+n+")")}(n.scale,e.scale,r,i),n=e=null,function(t){for(var n,e=-1,o=i.length;++e<o;)r[(n=i[e]).i]=n.x(t);return r.join("")}}function _o(t,n){return n=(n-=t=+t)||1/n,function(e){return(e-t)/n}}function wo(t,n){return n=(n-=t=+t)||1/n,function(e){return Math.max(0,Math.min(1,(e-t)/n))}}function bo(t){for(var n=t.source,e=t.target,r=function(t,n){if(t===n)return t;for(var e=Mo(t),r=Mo(n),i=e.pop(),o=r.pop(),a=null;i===o;)a=i,i=e.pop(),o=r.pop();return a}(n,e),i=[n];n!==r;)n=n.parent,i.push(n);for(var o=i.length;e!==r;)i.splice(o,0,e),e=e.parent;return i}function Mo(t){for(var n=[],e=t.parent;null!=e;)n.push(t),t=e,e=e.parent;return n.push(t),n}function ko(t){t.fixed|=2}function Eo(t){t.fixed&=-7}function So(t){t.fixed|=4,t.px=t.x,t.py=t.y}function Ao(t){t.fixed&=-5}t.interpolateTransform=xo,t.layout={},t.layout.bundle=function(){return function(t){for(var n=[],e=-1,r=t.length;++e<r;)n.push(bo(t[e]));return n}},t.layout.chord=function(){var n,e,r,i,o,a,u,s={},l=0;function c(){var s,c,f,p,g,d={},y=[],v=t.range(i),m=[];for(n=[],e=[],s=0,p=-1;++p<i;){for(c=0,g=-1;++g<i;)c+=r[p][g];y.push(c),m.push(t.range(i)),s+=c}for(o&&v.sort((function(t,n){return o(y[t],y[n])})),a&&m.forEach((function(t,n){t.sort((function(t,e){return a(r[n][t],r[n][e])}))})),s=(St-l*i)/s,c=0,p=-1;++p<i;){for(f=c,g=-1;++g<i;){var x=v[p],_=m[x][g],w=r[x][_],b=c,M=c+=w*s;d[x+"-"+_]={index:x,subindex:_,startAngle:b,endAngle:M,value:w}}e[x]={index:x,startAngle:f,endAngle:c,value:y[x]},c+=l}for(p=-1;++p<i;)for(g=p-1;++g<i;){var k=d[p+"-"+g],E=d[g+"-"+p];(k.value||E.value)&&n.push(k.value<E.value?{source:E,target:k}:{source:k,target:E})}u&&h()}function h(){n.sort((function(t,n){return u((t.source.value+t.target.value)/2,(n.source.value+n.target.value)/2)}))}return s.matrix=function(t){return arguments.length?(i=(r=t)&&r.length,n=e=null,s):r},s.padding=function(t){return arguments.length?(l=t,n=e=null,s):l},s.sortGroups=function(t){return arguments.length?(o=t,n=e=null,s):o},s.sortSubgroups=function(t){return arguments.length?(a=t,n=null,s):a},s.sortChords=function(t){return arguments.length?(u=t,n&&h(),s):u},s.chords=function(){return n||c(),n},s.groups=function(){return e||c(),e},s},t.layout.force=function(){var n,e,r,i,o,a,u={},s=t.dispatch("start","tick","end"),l=[1,1],c=.9,h=Co,f=No,p=-30,g=To,d=.1,y=.64,v=[],m=[];function x(t){return function(n,e,r,i){if(n.point!==t){var o=n.cx-t.x,a=n.cy-t.y,u=i-e,s=o*o+a*a;if(u*u/y<s){if(s<g){var l=n.charge/s;t.px-=o*l,t.py-=a*l}return!0}n.point&&s&&s<g&&(l=n.pointCharge/s,t.px-=o*l,t.py-=a*l)}return!n.charge}}function _(n){n.px=t.event.x,n.py=t.event.y,u.resume()}return u.tick=function(){if((r*=.99)<.005)return n=null,s.end({type:"end",alpha:r=0}),!0;var e,u,h,f,g,y,_,w,b,M=v.length,k=m.length;for(u=0;u<k;++u)f=(h=m[u]).source,(y=(w=(g=h.target).x-f.x)*w+(b=g.y-f.y)*b)&&(w*=y=r*o[u]*((y=Math.sqrt(y))-i[u])/y,b*=y,g.x-=w*(_=f.weight+g.weight?f.weight/(f.weight+g.weight):.5),g.y-=b*_,f.x+=w*(_=1-_),f.y+=b*_);if((_=r*d)&&(w=l[0]/2,b=l[1]/2,u=-1,_))for(;++u<M;)(h=v[u]).x+=(w-h.x)*_,h.y+=(b-h.y)*_;if(p)for(function t(n,e,r){var i=0,o=0;if(n.charge=0,!n.leaf)for(var a,u=n.nodes,s=u.length,l=-1;++l<s;)null!=(a=u[l])&&(t(a,e,r),n.charge+=a.charge,i+=a.charge*a.cx,o+=a.charge*a.cy);if(n.point){n.leaf||(n.point.x+=Math.random()-.5,n.point.y+=Math.random()-.5);var c=e*r[n.point.index];n.charge+=n.pointCharge=c,i+=c*n.point.x,o+=c*n.point.y}n.cx=i/n.charge,n.cy=o/n.charge}(e=t.geom.quadtree(v),r,a),u=-1;++u<M;)(h=v[u]).fixed||e.visit(x(h));for(u=-1;++u<M;)(h=v[u]).fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*c,h.y-=(h.py-(h.py=h.y))*c);s.tick({type:"tick",alpha:r})},u.nodes=function(t){return arguments.length?(v=t,u):v},u.links=function(t){return arguments.length?(m=t,u):m},u.size=function(t){return arguments.length?(l=t,u):l},u.linkDistance=function(t){return arguments.length?(h="function"==typeof t?t:+t,u):h},u.distance=u.linkDistance,u.linkStrength=function(t){return arguments.length?(f="function"==typeof t?t:+t,u):f},u.friction=function(t){return arguments.length?(c=+t,u):c},u.charge=function(t){return arguments.length?(p="function"==typeof t?t:+t,u):p},u.chargeDistance=function(t){return arguments.length?(g=t*t,u):Math.sqrt(g)},u.gravity=function(t){return arguments.length?(d=+t,u):d},u.theta=function(t){return arguments.length?(y=t*t,u):Math.sqrt(y)},u.alpha=function(t){return arguments.length?(t=+t,r?t>0?r=t:(n.c=null,n.t=NaN,n=null,s.end({type:"end",alpha:r=0})):t>0&&(s.start({type:"start",alpha:r=t}),n=bn(u.tick)),u):r},u.start=function(){var t,n,e,r=v.length,s=m.length,c=l[0],g=l[1];for(t=0;t<r;++t)(e=v[t]).index=t,e.weight=0;for(t=0;t<s;++t)"number"==typeof(e=m[t]).source&&(e.source=v[e.source]),"number"==typeof e.target&&(e.target=v[e.target]),++e.source.weight,++e.target.weight;for(t=0;t<r;++t)e=v[t],isNaN(e.x)&&(e.x=d("x",c)),isNaN(e.y)&&(e.y=d("y",g)),isNaN(e.px)&&(e.px=e.x),isNaN(e.py)&&(e.py=e.y);if(i=[],"function"==typeof h)for(t=0;t<s;++t)i[t]=+h.call(this,m[t],t);else for(t=0;t<s;++t)i[t]=h;if(o=[],"function"==typeof f)for(t=0;t<s;++t)o[t]=+f.call(this,m[t],t);else for(t=0;t<s;++t)o[t]=f;if(a=[],"function"==typeof p)for(t=0;t<r;++t)a[t]=+p.call(this,v[t],t);else for(t=0;t<r;++t)a[t]=p;function d(e,i){if(!n){for(n=new Array(r),l=0;l<r;++l)n[l]=[];for(l=0;l<s;++l){var o=m[l];n[o.source.index].push(o.target),n[o.target.index].push(o.source)}}for(var a,u=n[t],l=-1,c=u.length;++l<c;)if(!isNaN(a=u[l][e]))return a;return Math.random()*i}return u.resume()},u.resume=function(){return u.alpha(.1)},u.stop=function(){return u.alpha(0)},u.drag=function(){if(e||(e=t.behavior.drag().origin(N).on("dragstart.force",ko).on("drag.force",_).on("dragend.force",Eo)),!arguments.length)return e;this.on("mouseover.force",So).on("mouseout.force",Ao).call(e)},t.rebind(u,s,"on")};var Co=20,No=1,To=1/0;function Fo(n,e){return t.rebind(n,e,"sort","children","value"),n.nodes=n,n.links=qo,n}function Lo(t,n){for(var e=[t];null!=(t=e.pop());)if(n(t),(i=t.children)&&(r=i.length))for(var r,i;--r>=0;)e.push(i[r])}function zo(t,n){for(var e=[t],r=[];null!=(t=e.pop());)if(r.push(t),(o=t.children)&&(i=o.length))for(var i,o,a=-1;++a<i;)e.push(o[a]);for(;null!=(t=r.pop());)n(t)}function Do(t){return t.children}function Ro(t){return t.value}function Po(t,n){return n.value-t.value}function qo(n){return t.merge(n.map((function(t){return(t.children||[]).map((function(n){return{source:t,target:n}}))})))}t.layout.hierarchy=function(){var t=Po,n=Do,e=Ro;function r(i){var o,a=[i],u=[];for(i.depth=0;null!=(o=a.pop());)if(u.push(o),(l=n.call(r,o,o.depth))&&(s=l.length)){for(var s,l,c;--s>=0;)a.push(c=l[s]),c.parent=o,c.depth=o.depth+1;e&&(o.value=0),o.children=l}else e&&(o.value=+e.call(r,o,o.depth)||0),delete o.children;return zo(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),u}return r.sort=function(n){return arguments.length?(t=n,r):t},r.children=function(t){return arguments.length?(n=t,r):n},r.value=function(t){return arguments.length?(e=t,r):e},r.revalue=function(t){return e&&(Lo(t,(function(t){t.children&&(t.value=0)})),zo(t,(function(t){var n;t.children||(t.value=+e.call(r,t,t.depth)||0),(n=t.parent)&&(n.value+=t.value)}))),t},r},t.layout.partition=function(){var n=t.layout.hierarchy(),e=[1,1];function r(t,r){var i=n.call(this,t,r);return function t(n,e,r,i){var o=n.children;if(n.x=e,n.y=n.depth*i,n.dx=r,n.dy=i,o&&(a=o.length)){var a,u,s,l=-1;for(r=n.value?r/n.value:0;++l<a;)t(u=o[l],e,s=u.value*r,i),e+=s}}(i[0],0,e[0],e[1]/function t(n){var e=n.children,r=0;if(e&&(i=e.length))for(var i,o=-1;++o<i;)r=Math.max(r,t(e[o]));return 1+r}(i[0])),i}return r.size=function(t){return arguments.length?(e=t,r):e},Fo(r,n)},t.layout.pie=function(){var n=Number,e=Uo,r=0,i=St,o=0;function a(u){var s,l=u.length,c=u.map((function(t,e){return+n.call(a,t,e)})),h=+("function"==typeof r?r.apply(this,arguments):r),f=("function"==typeof i?i.apply(this,arguments):i)-h,p=Math.min(Math.abs(f)/l,+("function"==typeof o?o.apply(this,arguments):o)),g=p*(f<0?-1:1),d=t.sum(c),y=d?(f-l*g)/d:0,v=t.range(l),m=[];return null!=e&&v.sort(e===Uo?function(t,n){return c[n]-c[t]}:function(t,n){return e(u[t],u[n])}),v.forEach((function(t){m[t]={data:u[t],value:s=c[t],startAngle:h,endAngle:h+=s*y+g,padAngle:p}})),m}return a.value=function(t){return arguments.length?(n=t,a):n},a.sort=function(t){return arguments.length?(e=t,a):e},a.startAngle=function(t){return arguments.length?(r=t,a):r},a.endAngle=function(t){return arguments.length?(i=t,a):i},a.padAngle=function(t){return arguments.length?(o=t,a):o},a};var Uo={};function Oo(t){return t.x}function Io(t){return t.y}function Ho(t,n,e){t.y0=n,t.y=e}t.layout.stack=function(){var n=N,e=Bo,r=$o,i=Ho,o=Oo,a=Io;function u(s,l){if(!(p=s.length))return s;var c=s.map((function(t,e){return n.call(u,t,e)})),h=c.map((function(t){return t.map((function(t,n){return[o.call(u,t,n),a.call(u,t,n)]}))})),f=e.call(u,h,l);c=t.permute(c,f),h=t.permute(h,f);var p,g,d,y,v=r.call(u,h,l),m=c[0].length;for(d=0;d<m;++d)for(i.call(u,c[0][d],y=v[d],h[0][d][1]),g=1;g<p;++g)i.call(u,c[g][d],y+=h[g-1][d][1],h[g][d][1]);return s}return u.values=function(t){return arguments.length?(n=t,u):n},u.order=function(t){return arguments.length?(e="function"==typeof t?t:jo.get(t)||Bo,u):e},u.offset=function(t){return arguments.length?(r="function"==typeof t?t:Vo.get(t)||$o,u):r},u.x=function(t){return arguments.length?(o=t,u):o},u.y=function(t){return arguments.length?(a=t,u):a},u.out=function(t){return arguments.length?(i=t,u):i},u};var jo=t.map({"inside-out":function(n){var e,r,i=n.length,o=n.map(Yo),a=n.map(Wo),u=t.range(i).sort((function(t,n){return o[t]-o[n]})),s=0,l=0,c=[],h=[];for(e=0;e<i;++e)r=u[e],s<l?(s+=a[r],c.push(r)):(l+=a[r],h.push(r));return h.reverse().concat(c)},reverse:function(n){return t.range(n.length).reverse()},default:Bo}),Vo=t.map({silhouette:function(t){var n,e,r,i=t.length,o=t[0].length,a=[],u=0,s=[];for(e=0;e<o;++e){for(n=0,r=0;n<i;n++)r+=t[n][e][1];r>u&&(u=r),a.push(r)}for(e=0;e<o;++e)s[e]=(u-a[e])/2;return s},wiggle:function(t){var n,e,r,i,o,a,u,s,l,c=t.length,h=t[0],f=h.length,p=[];for(p[0]=s=l=0,e=1;e<f;++e){for(n=0,i=0;n<c;++n)i+=t[n][e][1];for(n=0,o=0,u=h[e][0]-h[e-1][0];n<c;++n){for(r=0,a=(t[n][e][1]-t[n][e-1][1])/(2*u);r<n;++r)a+=(t[r][e][1]-t[r][e-1][1])/u;o+=a*t[n][e][1]}p[e]=s-=i?o/i*u:0,s<l&&(l=s)}for(e=0;e<f;++e)p[e]-=l;return p},expand:function(t){var n,e,r,i=t.length,o=t[0].length,a=1/i,u=[];for(e=0;e<o;++e){for(n=0,r=0;n<i;n++)r+=t[n][e][1];if(r)for(n=0;n<i;n++)t[n][e][1]/=r;else for(n=0;n<i;n++)t[n][e][1]=a}for(e=0;e<o;++e)u[e]=0;return u},zero:$o});function Bo(n){return t.range(n.length)}function $o(t){for(var n=-1,e=t[0].length,r=[];++n<e;)r[n]=0;return r}function Yo(t){for(var n,e=1,r=0,i=t[0][1],o=t.length;e<o;++e)(n=t[e][1])>i&&(r=e,i=n);return r}function Wo(t){return t.reduce(Zo,0)}function Zo(t,n){return t+n[1]}function Xo(t,n){return Go(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function Go(t,n){for(var e=-1,r=+t[0],i=(t[1]-r)/n,o=[];++e<=n;)o[e]=i*e+r;return o}function Qo(n){return[t.min(n),t.max(n)]}function Jo(t,n){return t.value-n.value}function Ko(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function ta(t,n){t._pack_next=n,n._pack_prev=t}function na(t,n){var e=n.x-t.x,r=n.y-t.y,i=t.r+n.r;return.999*i*i>e*e+r*r}function ea(t){if((n=t.children)&&(s=n.length)){var n,e,r,i,o,a,u,s,l=1/0,c=-1/0,h=1/0,f=-1/0;if(n.forEach(ra),(e=n[0]).x=-e.r,e.y=0,x(e),s>1&&((r=n[1]).x=r.r,r.y=0,x(r),s>2))for(oa(e,r,i=n[2]),x(i),Ko(e,i),e._pack_prev=i,Ko(i,r),r=e._pack_next,o=3;o<s;o++){oa(e,r,i=n[o]);var p=0,g=1,d=1;for(a=r._pack_next;a!==r;a=a._pack_next,g++)if(na(a,i)){p=1;break}if(1==p)for(u=e._pack_prev;u!==a._pack_prev&&!na(u,i);u=u._pack_prev,d++);p?(g<d||g==d&&r.r<e.r?ta(e,r=a):ta(e=u,r),o--):(Ko(e,i),r=i,x(i))}var y=(l+c)/2,v=(h+f)/2,m=0;for(o=0;o<s;o++)(i=n[o]).x-=y,i.y-=v,m=Math.max(m,i.r+Math.sqrt(i.x*i.x+i.y*i.y));t.r=m,n.forEach(ia)}function x(t){l=Math.min(t.x-t.r,l),c=Math.max(t.x+t.r,c),h=Math.min(t.y-t.r,h),f=Math.max(t.y+t.r,f)}}function ra(t){t._pack_next=t._pack_prev=t}function ia(t){delete t._pack_next,delete t._pack_prev}function oa(t,n,e){var r=t.r+e.r,i=n.x-t.x,o=n.y-t.y;if(r&&(i||o)){var a=n.r+e.r,u=i*i+o*o,s=.5+((r*=r)-(a*=a))/(2*u),l=Math.sqrt(Math.max(0,2*a*(r+u)-(r-=u)*r-a*a))/(2*u);e.x=t.x+s*i+l*o,e.y=t.y+s*o-l*i}else e.x=t.x+r,e.y=t.y}function aa(t,n){return t.parent==n.parent?1:2}function ua(t){var n=t.children;return n.length?n[0]:t.t}function sa(t){var n,e=t.children;return(n=e.length)?e[n-1]:t.t}function la(t,n,e){var r=e/(n.i-t.i);n.c-=r,n.s+=e,t.c+=r,n.z+=e,n.m+=e}function ca(t,n,e){return t.a.parent===n.parent?t.a:e}function ha(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function fa(t,n){var e=t.x+n[3],r=t.y+n[0],i=t.dx-n[1]-n[3],o=t.dy-n[0]-n[2];return i<0&&(e+=i/2,i=0),o<0&&(r+=o/2,o=0),{x:e,y:r,dx:i,dy:o}}function pa(t){var n=t[0],e=t[t.length-1];return n<e?[n,e]:[e,n]}function ga(t){return t.rangeExtent?t.rangeExtent():pa(t.range())}function da(t,n,e,r){var i=e(t[0],t[1]),o=r(n[0],n[1]);return function(t){return o(i(t))}}function ya(t,n){var e,r=0,i=t.length-1,o=t[r],a=t[i];return a<o&&(e=r,r=i,i=e,e=o,o=a,a=e),t[r]=n.floor(o),t[i]=n.ceil(a),t}function va(t){return t?{floor:function(n){return Math.floor(n/t)*t},ceil:function(n){return Math.ceil(n/t)*t}}:ma}t.layout.histogram=function(){var n=!0,e=Number,r=Qo,i=Xo;function o(o,a){for(var u,s,l=[],c=o.map(e,this),h=r.call(this,c,a),f=i.call(this,h,c,a),p=(a=-1,c.length),g=f.length-1,d=n?1:1/p;++a<g;)(u=l[a]=[]).dx=f[a+1]-(u.x=f[a]),u.y=0;if(g>0)for(a=-1;++a<p;)(s=c[a])>=h[0]&&s<=h[1]&&((u=l[t.bisect(f,s,1,g)-1]).y+=d,u.push(o[a]));return l}return o.value=function(t){return arguments.length?(e=t,o):e},o.range=function(t){return arguments.length?(r=gn(t),o):r},o.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return Go(n,t)}:gn(t),o):i},o.frequency=function(t){return arguments.length?(n=!!t,o):n},o},t.layout.pack=function(){var n,e=t.layout.hierarchy().sort(Jo),r=0,i=[1,1];function o(t,o){var a=e.call(this,t,o),u=a[0],s=i[0],l=i[1],c=null==n?Math.sqrt:"function"==typeof n?n:function(){return n};if(u.x=u.y=0,zo(u,(function(t){t.r=+c(t.value)})),zo(u,ea),r){var h=r*(n?1:Math.max(2*u.r/s,2*u.r/l))/2;zo(u,(function(t){t.r+=h})),zo(u,ea),zo(u,(function(t){t.r-=h}))}return function t(n,e,r,i){var o=n.children;if(n.x=e+=i*n.x,n.y=r+=i*n.y,n.r*=i,o)for(var a=-1,u=o.length;++a<u;)t(o[a],e,r,i)}(u,s/2,l/2,n?1:1/Math.max(2*u.r/s,2*u.r/l)),a}return o.size=function(t){return arguments.length?(i=t,o):i},o.radius=function(t){return arguments.length?(n=null==t||"function"==typeof t?t:+t,o):n},o.padding=function(t){return arguments.length?(r=+t,o):r},Fo(o,e)},t.layout.tree=function(){var n=t.layout.hierarchy().sort(null).value(null),e=aa,r=[1,1],i=null;function o(t,o){var l=n.call(this,t,o),c=l[0],h=function(t){for(var n,e={A:null,children:[t]},r=[e];null!=(n=r.pop());)for(var i,o=n.children,a=0,u=o.length;a<u;++a)r.push((o[a]=i={_:o[a],parent:n,children:(i=o[a].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:a}).a=i);return e.children[0]}(c);if(zo(h,a),h.parent.m=-h.z,Lo(h,u),i)Lo(c,s);else{var f=c,p=c,g=c;Lo(c,(function(t){t.x<f.x&&(f=t),t.x>p.x&&(p=t),t.depth>g.depth&&(g=t)}));var d=e(f,p)/2-f.x,y=r[0]/(p.x+e(p,f)/2+d),v=r[1]/(g.depth||1);Lo(c,(function(t){t.x=(t.x+d)*y,t.y=t.depth*v}))}return l}function a(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n.length){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(t);var o=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+e(t._,i._));t.parent.A=function(t,n,r){if(n){for(var i,o=t,a=t,u=n,s=o.parent.children[0],l=o.m,c=a.m,h=u.m,f=s.m;u=sa(u),o=ua(o),u&&o;)s=ua(s),(a=sa(a)).a=t,(i=u.z+h-o.z-l+e(u._,o._))>0&&(la(ca(u,t,r),t,i),l+=i,c+=i),h+=u.m,l+=o.m,f+=s.m,c+=a.m;u&&!sa(a)&&(a.t=u,a.m+=h-c),o&&!ua(s)&&(s.t=o,s.m+=l-f,r=t)}return r}(t,i,t.parent.A||r[0])}function u(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function s(t){t.x*=r[0],t.y=t.depth*r[1]}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t)?s:null,o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:s,o):i?r:null},Fo(o,n)},t.layout.cluster=function(){var n=t.layout.hierarchy().sort(null).value(null),e=aa,r=[1,1],i=!1;function o(o,a){var u,s=n.call(this,o,a),l=s[0],c=0;zo(l,(function(n){var r=n.children;r&&r.length?(n.x=function(t){return t.reduce((function(t,n){return t+n.x}),0)/t.length}(r),n.y=function(n){return 1+t.max(n,(function(t){return t.y}))}(r)):(n.x=u?c+=e(n,u):0,n.y=0,u=n)}));var h=function t(n){var e=n.children;return e&&e.length?t(e[0]):n}(l),f=function t(n){var e,r=n.children;return r&&(e=r.length)?t(r[e-1]):n}(l),p=h.x-e(h,f)/2,g=f.x+e(f,h)/2;return zo(l,i?function(t){t.x=(t.x-l.x)*r[0],t.y=(l.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(g-p)*r[0],t.y=(1-(l.y?t.y/l.y:1))*r[1]}),s}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t),o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null!=(r=t),o):i?r:null},Fo(o,n)},t.layout.treemap=function(){var n,e=t.layout.hierarchy(),r=Math.round,i=[1,1],o=null,a=ha,u=!1,s="squarify",l=.5*(1+Math.sqrt(5));function c(t,n){for(var e,r,i=-1,o=t.length;++i<o;)r=(e=t[i]).value*(n<0?0:n),e.area=isNaN(r)||r<=0?0:r}function h(t){var n=t.children;if(n&&n.length){var e,r,i,o=a(t),u=[],l=n.slice(),f=1/0,d="slice"===s?o.dx:"dice"===s?o.dy:"slice-dice"===s?1&t.depth?o.dy:o.dx:Math.min(o.dx,o.dy);for(c(l,o.dx*o.dy/t.value),u.area=0;(i=l.length)>0;)u.push(e=l[i-1]),u.area+=e.area,"squarify"!==s||(r=p(u,d))<=f?(l.pop(),f=r):(u.area-=u.pop().area,g(u,d,o,!1),d=Math.min(o.dx,o.dy),u.length=u.area=0,f=1/0);u.length&&(g(u,d,o,!0),u.length=u.area=0),n.forEach(h)}}function f(t){var n=t.children;if(n&&n.length){var e,r=a(t),i=n.slice(),o=[];for(c(i,r.dx*r.dy/t.value),o.area=0;e=i.pop();)o.push(e),o.area+=e.area,null!=e.z&&(g(o,e.z?r.dx:r.dy,r,!i.length),o.length=o.area=0);n.forEach(f)}}function p(t,n){for(var e,r=t.area,i=0,o=1/0,a=-1,u=t.length;++a<u;)(e=t[a].area)&&(e<o&&(o=e),e>i&&(i=e));return n*=n,(r*=r)?Math.max(n*i*l/r,r/(n*o*l)):1/0}function g(t,n,e,i){var o,a=-1,u=t.length,s=e.x,l=e.y,c=n?r(t.area/n):0;if(n==e.dx){for((i||c>e.dy)&&(c=e.dy);++a<u;)(o=t[a]).x=s,o.y=l,o.dy=c,s+=o.dx=Math.min(e.x+e.dx-s,c?r(o.area/c):0);o.z=!0,o.dx+=e.x+e.dx-s,e.y+=c,e.dy-=c}else{for((i||c>e.dx)&&(c=e.dx);++a<u;)(o=t[a]).x=s,o.y=l,o.dx=c,l+=o.dy=Math.min(e.y+e.dy-l,c?r(o.area/c):0);o.z=!1,o.dy+=e.y+e.dy-l,e.x+=c,e.dx-=c}}function d(t){var r=n||e(t),o=r[0];return o.x=o.y=0,o.value?(o.dx=i[0],o.dy=i[1]):o.dx=o.dy=0,n&&e.revalue(o),c([o],o.dx*o.dy/o.value),(n?f:h)(o),u&&(n=r),r}return d.size=function(t){return arguments.length?(i=t,d):i},d.padding=function(t){if(!arguments.length)return o;function n(n){var e=t.call(d,n,n.depth);return null==e?ha(n):fa(n,"number"==typeof e?[e,e,e,e]:e)}function e(n){return fa(n,t)}var r;return a=null==(o=t)?ha:"function"==(r=typeof t)?n:"number"===r?(t=[t,t,t,t],e):e,d},d.round=function(t){return arguments.length?(r=t?Math.round:Number,d):r!=Number},d.sticky=function(t){return arguments.length?(u=t,n=null,d):u},d.ratio=function(t){return arguments.length?(l=t,d):l},d.mode=function(t){return arguments.length?(s=t+"",d):s},Fo(d,e)},t.random={normal:function(t,n){var e=arguments.length;return e<2&&(n=1),e<1&&(t=0),function(){var e,r,i;do{i=(e=2*Math.random()-1)*e+(r=2*Math.random()-1)*r}while(!i||i>1);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;e<t;e++)n+=Math.random();return n}}},t.scale={};var ma={floor:N,ceil:N};function xa(n,e,r,i){var o=[],a=[],u=0,s=Math.min(n.length,e.length)-1;for(n[s]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++u<=s;)o.push(r(n[u-1],n[u])),a.push(i(e[u-1],e[u]));return function(e){var r=t.bisect(n,e,1,s)-1;return a[r](o[r](e))}}function _a(n,e){return t.rebind(n,e,"range","rangeRound","interpolate","clamp")}function wa(t,n){return ya(t,va(ba(t,n)[2])),ya(t,va(ba(t,n)[2])),t}function ba(t,n){null==n&&(n=10);var e=pa(t),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/n)/Math.LN10)),o=n/r*i;return o<=.15?i*=10:o<=.35?i*=5:o<=.75&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Ma(n,e){return t.range.apply(t,ba(n,e))}function ka(n,e,r){var i=ba(n,e);if(r){var o=Nn.exec(r);if(o.shift(),"s"===o[8]){var a=t.formatPrefix(Math.max(v(i[0]),v(i[1])));return o[7]||(o[7]="."+Sa(a.scale(i[2]))),o[8]="f",r=t.format(o.join("")),function(t){return r(a.scale(t))+a.symbol}}o[7]||(o[7]="."+function(t,n){var e=Sa(n[2]);return t in Ea?Math.abs(e-Sa(Math.max(v(n[0]),v(n[1]))))+ +("e"!==t):e-2*("%"===t)}(o[8],i)),r=o.join("")}else r=",."+Sa(i[2])+"f";return t.format(r)}t.scale.linear=function(){return function t(n,e,r,i){var o,a;function u(){var t=Math.min(n.length,e.length)>2?xa:da,u=i?wo:_o;return o=t(n,e,u,r),a=t(e,n,u,Qi),s}function s(t){return o(t)}return s.invert=function(t){return a(t)},s.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},s.range=function(t){return arguments.length?(e=t,u()):e},s.rangeRound=function(t){return s.range(t).interpolate(fo)},s.clamp=function(t){return arguments.length?(i=t,u()):i},s.interpolate=function(t){return arguments.length?(r=t,u()):r},s.ticks=function(t){return Ma(n,t)},s.tickFormat=function(t,e){return ka(n,t,e)},s.nice=function(t){return wa(n,t),u()},s.copy=function(){return t(n,e,r,i)},u()}([0,1],[0,1],Qi,!1)};var Ea={s:1,g:1,p:1,r:1,e:1};function Sa(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function n(e,r,i,o){function a(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function u(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function s(t){return e(a(t))}return s.invert=function(t){return u(e.invert(t))},s.domain=function(t){return arguments.length?(i=t[0]>=0,e.domain((o=t.map(Number)).map(a)),s):o},s.base=function(t){return arguments.length?(r=+t,e.domain(o.map(a)),s):r},s.nice=function(){var t=ya(o.map(a),i?Math:Ca);return e.domain(t),o=t.map(u),s},s.ticks=function(){var t=pa(o),n=[],e=t[0],s=t[1],l=Math.floor(a(e)),c=Math.ceil(a(s)),h=r%1?2:r;if(isFinite(c-l)){if(i){for(;l<c;l++)for(var f=1;f<h;f++)n.push(u(l)*f);n.push(u(l))}else for(n.push(u(l));l++<c;)for(f=h-1;f>0;f--)n.push(u(l)*f);for(l=0;n[l]<e;l++);for(c=n.length;n[c-1]>s;c--);n=n.slice(l,c)}return n},s.tickFormat=function(n,e){if(!arguments.length)return Aa;arguments.length<2?e=Aa:"function"!=typeof e&&(e=t.format(e));var i=Math.max(1,r*n/s.ticks().length);return function(t){var n=t/u(Math.round(a(t)));return n*r<r-.5&&(n*=r),n<=i?e(t):""}},s.copy=function(){return n(e.copy(),r,i,o)},_a(s,e)}(t.scale.linear().domain([0,1]),10,!0,[1,10])};var Aa=t.format(".0e"),Ca={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};function Na(t){return function(n){return n<0?-Math.pow(-n,t):Math.pow(n,t)}}t.scale.pow=function(){return function t(n,e,r){var i=Na(e),o=Na(1/e);function a(t){return n(i(t))}return a.invert=function(t){return o(n.invert(t))},a.domain=function(t){return arguments.length?(n.domain((r=t.map(Number)).map(i)),a):r},a.ticks=function(t){return Ma(r,t)},a.tickFormat=function(t,n){return ka(r,t,n)},a.nice=function(t){return a.domain(wa(r,t))},a.exponent=function(t){return arguments.length?(i=Na(e=t),o=Na(1/e),n.domain(r.map(i)),a):e},a.copy=function(){return t(n.copy(),e,r)},_a(a,n)}(t.scale.linear(),1,[0,1])},t.scale.sqrt=function(){return t.scale.pow().exponent(.5)},t.scale.ordinal=function(){return function n(e,r){var i,o,a;function u(t){return o[((i.get(t)||("range"===r.t?i.set(t,e.push(t)):NaN))-1)%o.length]}function s(n,r){return t.range(e.length).map((function(t){return n+r*t}))}return u.domain=function(t){if(!arguments.length)return e;e=[],i=new _;for(var n,o=-1,a=t.length;++o<a;)i.has(n=t[o])||i.set(n,e.push(n));return u[r.t].apply(u,r.a)},u.range=function(t){return arguments.length?(o=t,a=0,r={t:"range",a:arguments},u):o},u.rangePoints=function(t,n){arguments.length<2&&(n=0);var i=t[0],l=t[1],c=e.length<2?(i=(i+l)/2,0):(l-i)/(e.length-1+n);return o=s(i+c*n/2,c),a=0,r={t:"rangePoints",a:arguments},u},u.rangeRoundPoints=function(t,n){arguments.length<2&&(n=0);var i=t[0],l=t[1],c=e.length<2?(i=l=Math.round((i+l)/2),0):(l-i)/(e.length-1+n)|0;return o=s(i+Math.round(c*n/2+(l-i-(e.length-1+n)*c)/2),c),a=0,r={t:"rangeRoundPoints",a:arguments},u},u.rangeBands=function(t,n,i){arguments.length<2&&(n=0),arguments.length<3&&(i=n);var l=t[1]<t[0],c=t[l-0],h=t[1-l],f=(h-c)/(e.length-n+2*i);return o=s(c+f*i,f),l&&o.reverse(),a=f*(1-n),r={t:"rangeBands",a:arguments},u},u.rangeRoundBands=function(t,n,i){arguments.length<2&&(n=0),arguments.length<3&&(i=n);var l=t[1]<t[0],c=t[l-0],h=t[1-l],f=Math.floor((h-c)/(e.length-n+2*i));return o=s(c+Math.round((h-c-(e.length-n)*f)/2),f),l&&o.reverse(),a=Math.round(f*(1-n)),r={t:"rangeRoundBands",a:arguments},u},u.rangeBand=function(){return a},u.rangeExtent=function(){return pa(r.a[0])},u.copy=function(){return n(e,r)},u.domain(e)}([],{t:"range",a:[[]]})},t.scale.category10=function(){return t.scale.ordinal().range(Ta)},t.scale.category20=function(){return t.scale.ordinal().range(Fa)},t.scale.category20b=function(){return t.scale.ordinal().range(La)},t.scale.category20c=function(){return t.scale.ordinal().range(za)};var Ta=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(on),Fa=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(on),La=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(on),za=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(on);function Da(){return 0}t.scale.quantile=function(){return function n(e,r){var i;function o(){var n=0,o=r.length;for(i=[];++n<o;)i[n-1]=t.quantile(e,n/o);return a}function a(n){if(!isNaN(n=+n))return r[t.bisect(i,n)]}return a.domain=function(t){return arguments.length?(e=t.map(f).filter(p).sort(h),o()):e},a.range=function(t){return arguments.length?(r=t,o()):r},a.quantiles=function(){return i},a.invertExtent=function(t){return(t=r.indexOf(t))<0?[NaN,NaN]:[t>0?i[t-1]:e[0],t<i.length?i[t]:e[e.length-1]]},a.copy=function(){return n(e,r)},o()}([],[])},t.scale.quantize=function(){return function t(n,e,r){var i,o;function a(t){return r[Math.max(0,Math.min(o,Math.floor(i*(t-n))))]}function u(){return i=r.length/(e-n),o=r.length-1,a}return a.domain=function(t){return arguments.length?(n=+t[0],e=+t[t.length-1],u()):[n,e]},a.range=function(t){return arguments.length?(r=t,u()):r},a.invertExtent=function(t){return[t=(t=r.indexOf(t))<0?NaN:t/i+n,t+1/i]},a.copy=function(){return t(n,e,r)},u()}(0,1,[0,1])},t.scale.threshold=function(){return function n(e,r){function i(n){if(n<=n)return r[t.bisect(e,n)]}return i.domain=function(t){return arguments.length?(e=t,i):e},i.range=function(t){return arguments.length?(r=t,i):r},i.invertExtent=function(t){return t=r.indexOf(t),[e[t-1],e[t]]},i.copy=function(){return n(e,r)},i}([.5],[0,1])},t.scale.identity=function(){return function t(n){function e(t){return+t}return e.invert=e,e.domain=e.range=function(t){return arguments.length?(n=t.map(e),e):n},e.ticks=function(t){return Ma(n,t)},e.tickFormat=function(t,e){return ka(n,t,e)},e.copy=function(){return t(n)},e}([0,1])},t.svg={},t.svg.arc=function(){var t=Pa,n=qa,e=Da,r=Ra,i=Ua,o=Oa,a=Ia;function u(){var u=Math.max(0,+t.apply(this,arguments)),l=Math.max(0,+n.apply(this,arguments)),c=i.apply(this,arguments)-Ct,h=o.apply(this,arguments)-Ct,f=Math.abs(h-c),p=c>h?0:1;if(l<u&&(g=l,l=u,u=g),f>=At)return s(l,p)+(u?s(u,1-p):"")+"Z";var g,d,y,v,m,x,_,w,b,M,k,E,S=0,A=0,C=[];if((v=(+a.apply(this,arguments)||0)/2)&&(y=r===Ra?Math.sqrt(u*u+l*l):+r.apply(this,arguments),p||(A*=-1),l&&(A=Dt(y/l*Math.sin(v))),u&&(S=Dt(y/u*Math.sin(v)))),l){m=l*Math.cos(c+A),x=l*Math.sin(c+A),_=l*Math.cos(h-A),w=l*Math.sin(h-A);var N=Math.abs(h-c-2*A)<=Et?0:1;if(A&&Ha(m,x,_,w)===p^N){var T=(c+h)/2;m=l*Math.cos(T),x=l*Math.sin(T),_=w=null}}else m=x=0;if(u){b=u*Math.cos(h-S),M=u*Math.sin(h-S),k=u*Math.cos(c+S),E=u*Math.sin(c+S);var F=Math.abs(c-h+2*S)<=Et?0:1;if(S&&Ha(b,M,k,E)===1-p^F){var L=(c+h)/2;b=u*Math.cos(L),M=u*Math.sin(L),k=E=null}}else b=M=0;if(f>Mt&&(g=Math.min(Math.abs(l-u)/2,+e.apply(this,arguments)))>.001){d=u<l^p?0:1;var z=g,D=g;if(f<Et){var R=null==k?[b,M]:null==_?[m,x]:ui([m,x],[k,E],[_,w],[b,M]),P=m-R[0],q=x-R[1],U=_-R[0],O=w-R[1],I=1/Math.sin(Math.acos((P*U+q*O)/(Math.sqrt(P*P+q*q)*Math.sqrt(U*U+O*O)))/2),H=Math.sqrt(R[0]*R[0]+R[1]*R[1]);D=Math.min(g,(u-H)/(I-1)),z=Math.min(g,(l-H)/(I+1))}if(null!=_){var j=ja(null==k?[b,M]:[k,E],[m,x],l,z,p),V=ja([_,w],[b,M],l,z,p);g===z?C.push("M",j[0],"A",z,",",z," 0 0,",d," ",j[1],"A",l,",",l," 0 ",1-p^Ha(j[1][0],j[1][1],V[1][0],V[1][1]),",",p," ",V[1],"A",z,",",z," 0 0,",d," ",V[0]):C.push("M",j[0],"A",z,",",z," 0 1,",d," ",V[0])}else C.push("M",m,",",x);if(null!=k){var B=ja([m,x],[k,E],u,-D,p),$=ja([b,M],null==_?[m,x]:[_,w],u,-D,p);g===D?C.push("L",$[0],"A",D,",",D," 0 0,",d," ",$[1],"A",u,",",u," 0 ",p^Ha($[1][0],$[1][1],B[1][0],B[1][1]),",",1-p," ",B[1],"A",D,",",D," 0 0,",d," ",B[0]):C.push("L",$[0],"A",D,",",D," 0 0,",d," ",B[0])}else C.push("L",b,",",M)}else C.push("M",m,",",x),null!=_&&C.push("A",l,",",l," 0 ",N,",",p," ",_,",",w),C.push("L",b,",",M),null!=k&&C.push("A",u,",",u," 0 ",F,",",1-p," ",k,",",E);return C.push("Z"),C.join("")}function s(t,n){return"M0,"+t+"A"+t+","+t+" 0 1,"+n+" 0,"+-t+"A"+t+","+t+" 0 1,"+n+" 0,"+t}return u.innerRadius=function(n){return arguments.length?(t=gn(n),u):t},u.outerRadius=function(t){return arguments.length?(n=gn(t),u):n},u.cornerRadius=function(t){return arguments.length?(e=gn(t),u):e},u.padRadius=function(t){return arguments.length?(r=t==Ra?Ra:gn(t),u):r},u.startAngle=function(t){return arguments.length?(i=gn(t),u):i},u.endAngle=function(t){return arguments.length?(o=gn(t),u):o},u.padAngle=function(t){return arguments.length?(a=gn(t),u):a},u.centroid=function(){var e=(+t.apply(this,arguments)+ +n.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +o.apply(this,arguments))/2-Ct;return[Math.cos(r)*e,Math.sin(r)*e]},u};var Ra="auto";function Pa(t){return t.innerRadius}function qa(t){return t.outerRadius}function Ua(t){return t.startAngle}function Oa(t){return t.endAngle}function Ia(t){return t&&t.padAngle}function Ha(t,n,e,r){return(t-e)*n-(n-r)*t>0?0:1}function ja(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],u=(i?r:-r)/Math.sqrt(o*o+a*a),s=u*a,l=-u*o,c=t[0]+s,h=t[1]+l,f=n[0]+s,p=n[1]+l,g=(c+f)/2,d=(h+p)/2,y=f-c,v=p-h,m=y*y+v*v,x=e-r,_=c*p-f*h,w=(v<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-_*_)),b=(_*v-y*w)/m,M=(-_*y-v*w)/m,k=(_*v+y*w)/m,E=(-_*y+v*w)/m,S=b-g,A=M-d,C=k-g,N=E-d;return S*S+A*A>C*C+N*N&&(b=k,M=E),[[b-s,M-l],[b*e/x,M*e/x]]}function Va(t){var n=ni,e=ei,r=Ye,i=$a,o=i.key,a=.7;function u(o){var u,s=[],l=[],c=-1,h=o.length,f=gn(n),p=gn(e);function g(){s.push("M",i(t(l),a))}for(;++c<h;)r.call(this,u=o[c],c)?l.push([+f.call(this,u,c),+p.call(this,u,c)]):l.length&&(g(),l=[]);return l.length&&g(),s.length?s.join(""):null}return u.x=function(t){return arguments.length?(n=t,u):n},u.y=function(t){return arguments.length?(e=t,u):e},u.defined=function(t){return arguments.length?(r=t,u):r},u.interpolate=function(t){return arguments.length?(o="function"==typeof t?i=t:(i=Ba.get(t)||$a).key,u):o},u.tension=function(t){return arguments.length?(a=t,u):a},u}t.svg.line=function(){return Va(N)};var Ba=t.map({linear:$a,"linear-closed":Ya,step:function(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n<e;)i.push("H",(r[0]+(r=t[n])[0])/2,"V",r[1]);return e>1&&i.push("H",r[0]),i.join("")},"step-before":Wa,"step-after":Za,basis:Qa,"basis-open":function(t){if(t.length<4)return $a(t);for(var n,e=[],r=-1,i=t.length,o=[0],a=[0];++r<3;)n=t[r],o.push(n[0]),a.push(n[1]);for(e.push(Ja(nu,o)+","+Ja(nu,a)),--r;++r<i;)n=t[r],o.shift(),o.push(n[0]),a.shift(),a.push(n[1]),eu(e,o,a);return e.join("")},"basis-closed":function(t){for(var n,e,r=-1,i=t.length,o=i+4,a=[],u=[];++r<4;)e=t[r%i],a.push(e[0]),u.push(e[1]);for(n=[Ja(nu,a),",",Ja(nu,u)],--r;++r<o;)e=t[r%i],a.shift(),a.push(e[0]),u.shift(),u.push(e[1]),eu(n,a,u);return n.join("")},bundle:function(t,n){var e=t.length-1;if(e)for(var r,i,o=t[0][0],a=t[0][1],u=t[e][0]-o,s=t[e][1]-a,l=-1;++l<=e;)i=l/e,(r=t[l])[0]=n*r[0]+(1-n)*(o+i*u),r[1]=n*r[1]+(1-n)*(a+i*s);return Qa(t)},cardinal:function(t,n){return t.length<3?$a(t):t[0]+Xa(t,Ga(t,n))},"cardinal-open":function(t,n){return t.length<4?$a(t):t[1]+Xa(t.slice(1,-1),Ga(t,n))},"cardinal-closed":function(t,n){return t.length<3?Ya(t):t[0]+Xa((t.push(t[0]),t),Ga([t[t.length-2]].concat(t,[t[1]]),n))},monotone:function(t){return t.length<3?$a(t):t[0]+Xa(t,function(t){for(var n,e,r,i,o=[],a=function(t){for(var n=0,e=t.length-1,r=[],i=t[0],o=t[1],a=r[0]=ru(i,o);++n<e;)r[n]=(a+(a=ru(i=o,o=t[n+1])))/2;return r[n]=a,r}(t),u=-1,s=t.length-1;++u<s;)n=ru(t[u],t[u+1]),v(n)<Mt?a[u]=a[u+1]=0:(i=(e=a[u]/n)*e+(r=a[u+1]/n)*r)>9&&(i=3*n/Math.sqrt(i),a[u]=i*e,a[u+1]=i*r);for(u=-1;++u<=s;)i=(t[Math.min(s,u+1)][0]-t[Math.max(0,u-1)][0])/(6*(1+a[u]*a[u])),o.push([i||0,a[u]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function Ya(t){return t.join("L")+"Z"}function Wa(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n<e;)i.push("V",(r=t[n])[1],"H",r[0]);return i.join("")}function Za(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++n<e;)i.push("H",(r=t[n])[0],"V",r[1]);return i.join("")}function Xa(t,n){if(n.length<1||t.length!=n.length&&t.length!=n.length+2)return $a(t);var e=t.length!=n.length,r="",i=t[0],o=t[1],a=n[0],u=a,s=1;if(e&&(r+="Q"+(o[0]-2*a[0]/3)+","+(o[1]-2*a[1]/3)+","+o[0]+","+o[1],i=t[1],s=2),n.length>1){u=n[1],o=t[s],s++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-u[0])+","+(o[1]-u[1])+","+o[0]+","+o[1];for(var l=2;l<n.length;l++,s++)o=t[s],u=n[l],r+="S"+(o[0]-u[0])+","+(o[1]-u[1])+","+o[0]+","+o[1]}if(e){var c=t[s];r+="Q"+(o[0]+2*u[0]/3)+","+(o[1]+2*u[1]/3)+","+c[0]+","+c[1]}return r}function Ga(t,n){for(var e,r=[],i=(1-n)/2,o=t[0],a=t[1],u=1,s=t.length;++u<s;)e=o,o=a,a=t[u],r.push([i*(a[0]-e[0]),i*(a[1]-e[1])]);return r}function Qa(t){if(t.length<3)return $a(t);var n=1,e=t.length,r=t[0],i=r[0],o=r[1],a=[i,i,i,(r=t[1])[0]],u=[o,o,o,r[1]],s=[i,",",o,"L",Ja(nu,a),",",Ja(nu,u)];for(t.push(t[e-1]);++n<=e;)r=t[n],a.shift(),a.push(r[0]),u.shift(),u.push(r[1]),eu(s,a,u);return t.pop(),s.push("L",r),s.join("")}function Ja(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]*n[3]}Ba.forEach((function(t,n){n.key=t,n.closed=/-closed$/.test(t)}));var Ka=[0,2/3,1/3,0],tu=[0,1/3,2/3,0],nu=[0,1/6,2/3,1/6];function eu(t,n,e){t.push("C",Ja(Ka,n),",",Ja(Ka,e),",",Ja(tu,n),",",Ja(tu,e),",",Ja(nu,n),",",Ja(nu,e))}function ru(t,n){return(n[1]-t[1])/(n[0]-t[0])}function iu(t){for(var n,e,r,i=-1,o=t.length;++i<o;)e=(n=t[i])[0],r=n[1]-Ct,n[0]=e*Math.cos(r),n[1]=e*Math.sin(r);return t}function ou(t){var n=ni,e=ni,r=0,i=ei,o=Ye,a=$a,u=a.key,s=a,l="L",c=.7;function h(u){var h,f,p,g=[],d=[],y=[],v=-1,m=u.length,x=gn(n),_=gn(r),w=n===e?function(){return f}:gn(e),b=r===i?function(){return p}:gn(i);function M(){g.push("M",a(t(y),c),l,s(t(d.reverse()),c),"Z")}for(;++v<m;)o.call(this,h=u[v],v)?(d.push([f=+x.call(this,h,v),p=+_.call(this,h,v)]),y.push([+w.call(this,h,v),+b.call(this,h,v)])):d.length&&(M(),d=[],y=[]);return d.length&&M(),g.length?g.join(""):null}return h.x=function(t){return arguments.length?(n=e=t,h):e},h.x0=function(t){return arguments.length?(n=t,h):n},h.x1=function(t){return arguments.length?(e=t,h):e},h.y=function(t){return arguments.length?(r=i=t,h):i},h.y0=function(t){return arguments.length?(r=t,h):r},h.y1=function(t){return arguments.length?(i=t,h):i},h.defined=function(t){return arguments.length?(o=t,h):o},h.interpolate=function(t){return arguments.length?(u="function"==typeof t?a=t:(a=Ba.get(t)||$a).key,s=a.reverse||a,l=a.closed?"M":"L",h):u},h.tension=function(t){return arguments.length?(c=t,h):c},h}function au(t){return t.radius}function uu(t){return[t.x,t.y]}function su(t){return function(){var n=t.apply(this,arguments),e=n[0],r=n[1]-Ct;return[e*Math.cos(r),e*Math.sin(r)]}}function lu(){return 64}function cu(){return"circle"}function hu(t){var n=Math.sqrt(t/Et);return"M0,"+n+"A"+n+","+n+" 0 1,1 0,"+-n+"A"+n+","+n+" 0 1,1 0,"+n+"Z"}t.svg.line.radial=function(){var t=Va(iu);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Wa.reverse=Za,Za.reverse=Wa,t.svg.area=function(){return ou(N)},t.svg.area.radial=function(){var t=ou(iu);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},t.svg.chord=function(){var t=Hr,n=jr,e=au,r=Ua,i=Oa;function o(e,r){var i,o,l=a(this,t,e,r),c=a(this,n,e,r);return"M"+l.p0+u(l.r,l.p1,l.a1-l.a0)+(o=c,((i=l).a0==o.a0&&i.a1==o.a1?s(l.r,l.p1,l.r,l.p0):s(l.r,l.p1,c.r,c.p0)+u(c.r,c.p1,c.a1-c.a0)+s(c.r,c.p1,l.r,l.p0))+"Z")}function a(t,n,o,a){var u=n.call(t,o,a),s=e.call(t,u,a),l=r.call(t,u,a)-Ct,c=i.call(t,u,a)-Ct;return{r:s,a0:l,a1:c,p0:[s*Math.cos(l),s*Math.sin(l)],p1:[s*Math.cos(c),s*Math.sin(c)]}}function u(t,n,e){return"A"+t+","+t+" 0 "+ +(e>Et)+",1 "+n}function s(t,n,e,r){return"Q 0,0 "+r}return o.radius=function(t){return arguments.length?(e=gn(t),o):e},o.source=function(n){return arguments.length?(t=gn(n),o):t},o.target=function(t){return arguments.length?(n=gn(t),o):n},o.startAngle=function(t){return arguments.length?(r=gn(t),o):r},o.endAngle=function(t){return arguments.length?(i=gn(t),o):i},o},t.svg.diagonal=function(){var t=Hr,n=jr,e=uu;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),u=(o.y+a.y)/2,s=[o,{x:o.x,y:u},{x:a.x,y:u},a];return"M"+(s=s.map(e))[0]+"C"+s[1]+" "+s[2]+" "+s[3]}return r.source=function(n){return arguments.length?(t=gn(n),r):t},r.target=function(t){return arguments.length?(n=gn(t),r):n},r.projection=function(t){return arguments.length?(e=t,r):e},r},t.svg.diagonal.radial=function(){var n=t.svg.diagonal(),e=uu,r=n.projection;return n.projection=function(t){return arguments.length?r(su(e=t)):e},n},t.svg.symbol=function(){var t=cu,n=lu;function e(e,r){return(fu.get(t.call(this,e,r))||hu)(n.call(this,e,r))}return e.type=function(n){return arguments.length?(t=gn(n),e):t},e.size=function(t){return arguments.length?(n=gn(t),e):n},e};var fu=t.map({circle:hu,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*gu)),e=n*gu;return"M0,"+-n+"L"+e+",0 0,"+n+" "+-e+",0Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/pu),e=n*pu/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/pu),e=n*pu/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});t.svg.symbolTypes=fu.keys();var pu=Math.sqrt(3),gu=Math.tan(30*Nt);$.transition=function(t){for(var n,e,r=mu||++wu,i=ku(t),o=[],a=xu||{time:Date.now(),ease:uo,delay:0,duration:250},u=-1,s=this.length;++u<s;){o.push(n=[]);for(var l=this[u],c=-1,h=l.length;++c<h;)(e=l[c])&&Eu(e,c,i,r,a),n.push(e)}return vu(o,i,r)},$.interrupt=function(t){return this.each(null==t?du:yu(ku(t)))};var du=yu(ku());function yu(t){return function(){var n,e,r;(n=this[t])&&(r=n[e=n.active])&&(r.timer.c=null,r.timer.t=NaN,--n.count?delete n[e]:delete this[t],n.active+=.5,r.event&&r.event.interrupt.call(this,this.__data__,r.index))}}function vu(t,n,e){return I(t,_u),t.namespace=n,t.id=e,t}var mu,xu,_u=[],wu=0;function bu(t,n,e,r){var i=t.id,o=t.namespace;return lt(t,"function"==typeof e?function(t,a,u){t[o][i].tween.set(n,r(e.call(t,t.__data__,a,u)))}:(e=r(e),function(t){t[o][i].tween.set(n,e)}))}function Mu(t){return null==t&&(t=""),function(){this.textContent=t}}function ku(t){return null==t?"__transition__":"__transition_"+t+"__"}function Eu(t,n,e,r,i){var o,a,u,s,l,c=t[e]||(t[e]={active:0,count:0}),h=c[r];function f(e){var i=c.active,f=c[i];for(var g in f&&(f.timer.c=null,f.timer.t=NaN,--c.count,delete c[i],f.event&&f.event.interrupt.call(t,t.__data__,f.index)),c)if(+g<r){var d=c[g];d.timer.c=null,d.timer.t=NaN,--c.count,delete c[g]}a.c=p,bn((function(){return a.c&&p(e||1)&&(a.c=null,a.t=NaN),1}),0,o),c.active=r,h.event&&h.event.start.call(t,t.__data__,n),l=[],h.tween.forEach((function(e,r){(r=r.call(t,t.__data__,n))&&l.push(r)})),s=h.ease,u=h.duration}function p(i){for(var o=i/u,a=s(o),f=l.length;f>0;)l[--f].call(t,a);if(o>=1)return h.event&&h.event.end.call(t,t.__data__,n),--c.count?delete c[r]:delete t[e],1}h||(o=i.time,a=bn((function(t){var n=h.delay;if(a.t=n+o,n<=t)return f(t-n);a.c=f}),0,o),h=c[r]={tween:new _,time:o,timer:a,delay:i.delay,duration:i.duration,ease:i.ease,index:n},i=null,++c.count)}_u.call=$.call,_u.empty=$.empty,_u.node=$.node,_u.size=$.size,t.transition=function(n,e){return n&&n.transition?mu?n.transition(e):n:t.selection().transition(n)},t.transition.prototype=_u,_u.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=Y(t);for(var u=-1,s=this.length;++u<s;){a.push(n=[]);for(var l=this[u],c=-1,h=l.length;++c<h;)(r=l[c])&&(e=t.call(r,r.__data__,c,u))?("__data__"in r&&(e.__data__=r.__data__),Eu(e,c,o,i,r[o][i]),n.push(e)):n.push(null)}return vu(a,o,i)},_u.selectAll=function(t){var n,e,r,i,o,a=this.id,u=this.namespace,s=[];t=W(t);for(var l=-1,c=this.length;++l<c;)for(var h=this[l],f=-1,p=h.length;++f<p;)if(r=h[f]){o=r[u][a],e=t.call(r,r.__data__,f,l),s.push(n=[]);for(var g=-1,d=e.length;++g<d;)(i=e[g])&&Eu(i,g,u,a,o),n.push(i)}return vu(s,u,a)},_u.filter=function(t){var n,e,r=[];"function"!=typeof t&&(t=ut(t));for(var i=0,o=this.length;i<o;i++){r.push(n=[]);for(var a,u=0,s=(a=this[i]).length;u<s;u++)(e=a[u])&&t.call(e,e.__data__,u,i)&&n.push(e)}return vu(r,this.namespace,this.id)},_u.tween=function(t,n){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(t):lt(this,null==n?function(n){n[r][e].tween.remove(t)}:function(i){i[r][e].tween.set(t,n)})},_u.attr=function(n,e){if(arguments.length<2){for(e in n)this.attr(e,n[e]);return this}var r="transform"==n?xo:Qi,i=t.ns.qualify(n);function o(){this.removeAttribute(i)}function a(){this.removeAttributeNS(i.space,i.local)}function u(t){return null==t?o:(t+="",function(){var n,e=this.getAttribute(i);return e!==t&&(n=r(e,t),function(t){this.setAttribute(i,n(t))})})}function s(t){return null==t?a:(t+="",function(){var n,e=this.getAttributeNS(i.space,i.local);return e!==t&&(n=r(e,t),function(t){this.setAttributeNS(i.space,i.local,n(t))})})}return bu(this,"attr."+n,e,i.local?s:u)},_u.attrTween=function(n,e){var r=t.ns.qualify(n);return this.tween("attr."+n,r.local?function(t,n){var i=e.call(this,t,n,this.getAttributeNS(r.space,r.local));return i&&function(t){this.setAttributeNS(r.space,r.local,i(t))}}:function(t,n){var i=e.call(this,t,n,this.getAttribute(r));return i&&function(t){this.setAttribute(r,i(t))}})},_u.style=function(t,n,e){var r=arguments.length;if(r<3){if("string"!=typeof t){for(e in r<2&&(n=""),t)this.style(e,t[e],n);return this}e=""}function i(){this.style.removeProperty(t)}function a(n){return null==n?i:(n+="",function(){var r,i=o(this).getComputedStyle(this,null).getPropertyValue(t);return i!==n&&(r=Qi(i,n),function(n){this.style.setProperty(t,r(n),e)})})}return bu(this,"style."+t,n,a)},_u.styleTween=function(t,n,e){function r(r,i){var a=n.call(this,r,i,o(this).getComputedStyle(this,null).getPropertyValue(t));return a&&function(n){this.style.setProperty(t,a(n),e)}}return arguments.length<3&&(e=""),this.tween("style."+t,r)},_u.text=function(t){return bu(this,"text",t,Mu)},_u.remove=function(){var t=this.namespace;return this.each("end.transition",(function(){var n;this[t].count<2&&(n=this.parentNode)&&n.removeChild(this)}))},_u.ease=function(n){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof n&&(n=t.ease.apply(t,arguments)),lt(this,(function(t){t[r][e].ease=n})))},_u.delay=function(t){var n=this.id,e=this.namespace;return arguments.length<1?this.node()[e][n].delay:lt(this,"function"==typeof t?function(r,i,o){r[e][n].delay=+t.call(r,r.__data__,i,o)}:(t=+t,function(r){r[e][n].delay=t}))},_u.duration=function(t){var n=this.id,e=this.namespace;return arguments.length<1?this.node()[e][n].duration:lt(this,"function"==typeof t?function(r,i,o){r[e][n].duration=Math.max(1,t.call(r,r.__data__,i,o))}:(t=Math.max(1,t),function(r){r[e][n].duration=t}))},_u.each=function(n,e){var r=this.id,i=this.namespace;if(arguments.length<2){var o=xu,a=mu;try{mu=r,lt(this,(function(t,e,o){xu=t[i][r],n.call(t,t.__data__,e,o)}))}finally{xu=o,mu=a}}else lt(this,(function(o){var a=o[i][r];(a.event||(a.event=t.dispatch("start","end","interrupt"))).on(n,e)}));return this},_u.transition=function(){for(var t,n,e,r=this.id,i=++wu,o=this.namespace,a=[],u=0,s=this.length;u<s;u++){a.push(t=[]);for(var l,c=0,h=(l=this[u]).length;c<h;c++)(n=l[c])&&Eu(n,c,o,i,{time:(e=n[o][r]).time,ease:e.ease,delay:e.delay+e.duration,duration:e.duration}),t.push(n)}return vu(a,o,i)},t.svg.axis=function(){var n,r=t.scale.linear(),i=Su,o=6,a=6,u=3,s=[10],l=null;function c(e){e.each((function(){var e,c=t.select(this),h=this.__chart__||r,f=this.__chart__=r.copy(),p=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,g=null==n?f.tickFormat?f.tickFormat.apply(f,s):N:n,d=c.selectAll(".tick").data(p,f),y=d.enter().insert("g",".domain").attr("class","tick").style("opacity",Mt),v=t.transition(d.exit()).style("opacity",Mt).remove(),m=t.transition(d.order()).style("opacity",1),x=Math.max(o,0)+u,_=ga(f),w=c.selectAll(".domain").data([0]),b=(w.enter().append("path").attr("class","domain"),t.transition(w));y.append("line"),y.append("text");var M,k,E,S,A=y.select("line"),C=m.select("line"),T=d.select("text").text(g),F=y.select("text"),L=m.select("text"),z="top"===i||"left"===i?-1:1;if("bottom"===i||"top"===i?(e=Cu,M="x",E="y",k="x2",S="y2",T.attr("dy",z<0?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+_[0]+","+z*a+"V0H"+_[1]+"V"+z*a)):(e=Nu,M="y",E="x",k="y2",S="x2",T.attr("dy",".32em").style("text-anchor",z<0?"end":"start"),b.attr("d","M"+z*a+","+_[0]+"H0V"+_[1]+"H"+z*a)),A.attr(S,z*o),F.attr(E,z*x),C.attr(k,0).attr(S,z*o),L.attr(M,0).attr(E,z*x),f.rangeBand){var D=f,R=D.rangeBand()/2;h=f=function(t){return D(t)+R}}else h.rangeBand?h=f:v.call(e,f,h);y.call(e,h,f),m.call(e,f,f)}))}return c.scale=function(t){return arguments.length?(r=t,c):r},c.orient=function(t){return arguments.length?(i=t in Au?t+"":Su,c):i},c.ticks=function(){return arguments.length?(s=e(arguments),c):s},c.tickValues=function(t){return arguments.length?(l=t,c):l},c.tickFormat=function(t){return arguments.length?(n=t,c):n},c.tickSize=function(t){var n=arguments.length;return n?(o=+t,a=+arguments[n-1],c):o},c.innerTickSize=function(t){return arguments.length?(o=+t,c):o},c.outerTickSize=function(t){return arguments.length?(a=+t,c):a},c.tickPadding=function(t){return arguments.length?(u=+t,c):u},c.tickSubdivide=function(){return arguments.length&&c},c};var Su="bottom",Au={top:1,right:1,bottom:1,left:1};function Cu(t,n,e){t.attr("transform",(function(t){var r=n(t);return"translate("+(isFinite(r)?r:e(t))+",0)"}))}function Nu(t,n,e){t.attr("transform",(function(t){var r=n(t);return"translate(0,"+(isFinite(r)?r:e(t))+")"}))}t.svg.brush=function(){var n,e,r=U(f,"brushstart","brush","brushend"),i=null,a=null,u=[0,0],s=[0,0],l=!0,c=!0,h=Fu[0];function f(n){n.each((function(){var n=t.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",y).on("touchstart.brush",y),e=n.selectAll(".background").data([0]);e.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var r=n.selectAll(".resize").data(h,N);r.exit().remove(),r.enter().append("g").attr("class",(function(t){return"resize "+t})).style("cursor",(function(t){return Tu[t]})).append("rect").attr("x",(function(t){return/[ew]$/.test(t)?-3:null})).attr("y",(function(t){return/^[ns]/.test(t)?-3:null})).attr("width",6).attr("height",6).style("visibility","hidden"),r.style("display",f.empty()?"none":null);var o,u=t.transition(n),s=t.transition(e);i&&(o=ga(i),s.attr("x",o[0]).attr("width",o[1]-o[0]),g(u)),a&&(o=ga(a),s.attr("y",o[0]).attr("height",o[1]-o[0]),d(u)),p(u)}))}function p(t){t.selectAll(".resize").attr("transform",(function(t){return"translate("+u[+/e$/.test(t)]+","+s[+/^s/.test(t)]+")"}))}function g(t){t.select(".extent").attr("x",u[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",u[1]-u[0])}function d(t){t.select(".extent").attr("y",s[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1]-s[0])}function y(){var h,y,v=this,m=t.select(t.event.target),x=r.of(v,arguments),_=t.select(v),w=m.datum(),b=!/^(n|s)$/.test(w)&&i,M=!/^(e|w)$/.test(w)&&a,k=m.classed("extent"),E=xt(v),S=t.mouse(v),A=t.select(o(v)).on("keydown.brush",T).on("keyup.brush",F);if(t.event.changedTouches?A.on("touchmove.brush",L).on("touchend.brush",D):A.on("mousemove.brush",L).on("mouseup.brush",D),_.interrupt().selectAll("*").interrupt(),k)S[0]=u[0]-S[0],S[1]=s[0]-S[1];else if(w){var C=+/w$/.test(w),N=+/^n/.test(w);y=[u[1-C]-S[0],s[1-N]-S[1]],S[0]=u[C],S[1]=s[N]}else t.event.altKey&&(h=S.slice());function T(){32==t.event.keyCode&&(k||(h=null,S[0]-=u[1],S[1]-=s[1],k=2),P())}function F(){32==t.event.keyCode&&2==k&&(S[0]+=u[1],S[1]+=s[1],k=0,P())}function L(){var n=t.mouse(v),e=!1;y&&(n[0]+=y[0],n[1]+=y[1]),k||(t.event.altKey?(h||(h=[(u[0]+u[1])/2,(s[0]+s[1])/2]),S[0]=u[+(n[0]<h[0])],S[1]=s[+(n[1]<h[1])]):h=null),b&&z(n,i,0)&&(g(_),e=!0),M&&z(n,a,1)&&(d(_),e=!0),e&&(p(_),x({type:"brush",mode:k?"move":"resize"}))}function z(t,r,i){var o,a,f=ga(r),p=f[0],g=f[1],d=S[i],y=i?s:u,v=y[1]-y[0];if(k&&(p-=d,g-=v+d),o=(i?c:l)?Math.max(p,Math.min(g,t[i])):t[i],k?a=(o+=d)+v:(h&&(d=Math.max(p,Math.min(g,2*h[i]-o))),d<o?(a=o,o=d):a=d),y[0]!=o||y[1]!=a)return i?e=null:n=null,y[0]=o,y[1]=a,!0}function D(){L(),_.style("pointer-events","all").selectAll(".resize").style("display",f.empty()?"none":null),t.select("body").style("cursor",null),A.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),E(),x({type:"brushend"})}_.style("pointer-events","none").selectAll(".resize").style("display",null),t.select("body").style("cursor",m.style("cursor")),x({type:"brushstart"}),L()}return f.event=function(i){i.each((function(){var i=r.of(this,arguments),o={x:u,y:s,i:n,j:e},a=this.__chart__||o;this.__chart__=o,mu?t.select(this).transition().each("start.brush",(function(){n=a.i,e=a.j,u=a.x,s=a.y,i({type:"brushstart"})})).tween("brush:brush",(function(){var t=Ji(u,o.x),r=Ji(s,o.y);return n=e=null,function(n){u=o.x=t(n),s=o.y=r(n),i({type:"brush",mode:"resize"})}})).each("end.brush",(function(){n=o.i,e=o.j,i({type:"brush",mode:"resize"}),i({type:"brushend"})})):(i({type:"brushstart"}),i({type:"brush",mode:"resize"}),i({type:"brushend"}))}))},f.x=function(t){return arguments.length?(h=Fu[!(i=t)<<1|!a],f):i},f.y=function(t){return arguments.length?(h=Fu[!i<<1|!(a=t)],f):a},f.clamp=function(t){return arguments.length?(i&&a?(l=!!t[0],c=!!t[1]):i?l=!!t:a&&(c=!!t),f):i&&a?[l,c]:i?l:a?c:null},f.extent=function(t){var r,o,l,c,h;return arguments.length?(i&&(r=t[0],o=t[1],a&&(r=r[0],o=o[0]),n=[r,o],i.invert&&(r=i(r),o=i(o)),o<r&&(h=r,r=o,o=h),r==u[0]&&o==u[1]||(u=[r,o])),a&&(l=t[0],c=t[1],i&&(l=l[1],c=c[1]),e=[l,c],a.invert&&(l=a(l),c=a(c)),c<l&&(h=l,l=c,c=h),l==s[0]&&c==s[1]||(s=[l,c])),f):(i&&(n?(r=n[0],o=n[1]):(r=u[0],o=u[1],i.invert&&(r=i.invert(r),o=i.invert(o)),o<r&&(h=r,r=o,o=h))),a&&(e?(l=e[0],c=e[1]):(l=s[0],c=s[1],a.invert&&(l=a.invert(l),c=a.invert(c)),c<l&&(h=l,l=c,c=h))),i&&a?[[r,l],[o,c]]:i?[r,o]:a&&[l,c])},f.clear=function(){return f.empty()||(u=[0,0],s=[0,0],n=e=null),f},f.empty=function(){return!!i&&u[0]==u[1]||!!a&&s[0]==s[1]},t.rebind(f,r,"on")};var Tu={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Fu=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Lu=Ln.format=ue.timeFormat,zu=Lu.utc,Du=zu("%Y-%m-%dT%H:%M:%S.%LZ");function Ru(t){return t.toISOString()}function Pu(n,e,r){function i(t){return n(t)}function o(n,r){var i=(n[1]-n[0])/r,o=t.bisect(Uu,i);return o==Uu.length?[e.year,ba(n.map((function(t){return t/31536e6})),r)[2]]:o?e[i/Uu[o-1]<Uu[o]/i?o-1:o]:[Hu,ba(n,r)[2]]}return i.invert=function(t){return qu(n.invert(t))},i.domain=function(t){return arguments.length?(n.domain(t),i):n.domain().map(qu)},i.nice=function(t,n){var e=i.domain(),r=pa(e),a=null==t?o(r,10):"number"==typeof t&&o(r,t);function u(e){return!isNaN(e)&&!t.range(e,qu(+e+1),n).length}return a&&(t=a[0],n=a[1]),i.domain(ya(e,n>1?{floor:function(n){for(;u(n=t.floor(n));)n=qu(n-1);return n},ceil:function(n){for(;u(n=t.ceil(n));)n=qu(+n+1);return n}}:t))},i.ticks=function(t,n){var e=pa(i.domain()),r=null==t?o(e,10):"number"==typeof t?o(e,t):!t.range&&[{range:t},n];return r&&(t=r[0],n=r[1]),t.range(e[0],qu(+e[1]+1),n<1?1:n)},i.tickFormat=function(){return r},i.copy=function(){return Pu(n.copy(),e,r)},_a(i,n)}function qu(t){return new Date(t)}Lu.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ru:Du,Ru.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Ru.toString=Du.toString,Ln.second=Pn((function(t){return new zn(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),Ln.seconds=Ln.second.range,Ln.seconds.utc=Ln.second.utc.range,Ln.minute=Pn((function(t){return new zn(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),Ln.minutes=Ln.minute.range,Ln.minutes.utc=Ln.minute.utc.range,Ln.hour=Pn((function(t){var n=t.getTimezoneOffset()/60;return new zn(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),Ln.hours=Ln.hour.range,Ln.hours.utc=Ln.hour.utc.range,Ln.month=Pn((function(t){return(t=Ln.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),Ln.months=Ln.month.range,Ln.months.utc=Ln.month.utc.range;var Uu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ou=[[Ln.second,1],[Ln.second,5],[Ln.second,15],[Ln.second,30],[Ln.minute,1],[Ln.minute,5],[Ln.minute,15],[Ln.minute,30],[Ln.hour,1],[Ln.hour,3],[Ln.hour,6],[Ln.hour,12],[Ln.day,1],[Ln.day,2],[Ln.week,1],[Ln.month,1],[Ln.month,3],[Ln.year,1]],Iu=Lu.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Ye]]),Hu={range:function(n,e,r){return t.range(Math.ceil(n/r)*r,+e,r).map(qu)},floor:N,ceil:N};Ou.year=Ln.year,Ln.scale=function(){return Pu(t.scale.linear(),Ou,Iu)};var ju=Ou.map((function(t){return[t[0].utc,t[1]]})),Vu=zu.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Ye]]);function Bu(t){return JSON.parse(t.responseText)}function $u(t){var n=r.createRange();return n.selectNode(r.body),n.createContextualFragment(t.responseText)}ju.year=Ln.year.utc,Ln.scale.utc=function(){return Pu(t.scale.linear(),ju,Vu)},t.text=dn((function(t){return t.responseText})),t.json=function(t,n){return yn(t,"application/json",Bu,n)},t.html=function(t,n){return yn(t,"text/html",$u,n)},t.xml=dn((function(t){return t.responseXML})),"function"==typeof define&&define.amd?(this.d3=t,define(t)):"object"==typeof module&&module.exports?module.exports=t:this.d3=t}(),null==window.Epoch&&(window.Epoch={}),null==(c=window.Epoch).Chart&&(c.Chart={}),null==(t=window.Epoch).Time&&(t.Time={}),null==(n=window.Epoch).Util&&(n.Util={}),null==(e=window.Epoch).Formats&&(e.Formats={}),Epoch.warn=function(t){return(console.warn||console.log)("Epoch Warning: "+t)},Epoch.exception=function(t){throw"Epoch Error: "+t},Epoch.TestContext=function(){var t;function n(){var n,e,r;for(this._log=[],n=0,e=t.length;n<e;n++)r=t[n],this._makeFauxMethod(r)}return t=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","drawImage","fill","fillRect","fillText","moveTo","quadraticCurveTo","rect","restore","rotate","save","scale","scrollPathIntoView","setLineDash","setTransform","stroke","strokeRect","strokeText","transform","translate","lineTo"],n.prototype._makeFauxMethod=function(t){return this[t]=function(){var n;return this._log.push(t+"("+function(){var t,e,r;for(r=[],t=0,e=arguments.length;t<e;t++)n=arguments[t],r.push(n.toString());return r}.apply(this,arguments).join(",")+")")}},n.prototype.getImageData=function(){var t;return this._log.push("getImageData("+function(){var n,e,r;for(r=[],n=0,e=arguments.length;n<e;n++)t=arguments[n],r.push(t.toString());return r}.apply(this,arguments).join(",")+")"),{width:0,height:0,resolution:1,data:[]}},n}();var r,i,o,a={}.hasOwnProperty;i=function(t){return function(n){return Object.prototype.toString.call(n)==="[object "+t+"]"}},Epoch.isArray=null!=(r=Array.isArray)?r:i("Array"),Epoch.isObject=i("Object"),Epoch.isString=i("String"),Epoch.isFunction=i("Function"),Epoch.isNumber=i("Number"),Epoch.isElement=function(t){return"undefined"!=typeof HTMLElement&&null!==HTMLElement?t instanceof HTMLElement:null!=t&&Epoch.isObject(t)&&1===t.nodeType&&Epoch.isString(t.nodeName)},Epoch.isNonEmptyArray=function(t){return Epoch.isArray(t)&&t.length>0},Epoch.Util.copy=function(t){var n,e,r;if(null==t)return null;for(e in n={},t)a.call(t,e)&&(r=t[e],n[e]=r);return n},Epoch.Util.defaults=function(t,n){var e,r,i,o,u;for(i in u=Epoch.Util.copy(t),n)a.call(n,i)&&(n[i],o=t[i],r=n[i],e=Epoch.isObject(o)&&Epoch.isObject(r),null!=o&&null!=r?e&&!Epoch.isArray(o)?u[i]=Epoch.Util.defaults(o,r):u[i]=o:u[i]=null!=o?o:r);return u},Epoch.Util.formatSI=function(t,n,e){var r,i,o,u,s;if(null==n&&(n=1),null==e&&(e=!1),t<1e3)return((0|(u=t))!==u||e)&&(u=u.toFixed(n)),u;for(i in s=["K","M","G","T","P","E","Z","Y"])if(a.call(s,i)&&(o=s[i],t>=(r=Math.pow(10,3*(1+(0|i))))&&t<Math.pow(10,3*(2+(0|i)))))return((u=t/r)%1!=0||e)&&(u=u.toFixed(n)),u+" "+o},Epoch.Util.formatBytes=function(t,n,e){var r,i,o,u,s;if(null==n&&(n=1),null==e&&(e=!1),t<1024)return((u=t)%1!=0||e)&&(u=u.toFixed(n)),u+" B";for(i in s=["KB","MB","GB","TB","PB","EB","ZB","YB"])if(a.call(s,i)&&(o=s[i],t>=(r=Math.pow(1024,1+(0|i)))&&t<Math.pow(1024,2+(0|i))))return((u=t/r)%1!=0||e)&&(u=u.toFixed(n)),u+" "+o},Epoch.Util.dasherize=function(t){return Epoch.Util.trim(t).replace("\n","").replace(/\s+/g,"-").toLowerCase()},Epoch.Util.domain=function(t,n){var e,r,i,o,a,u,s,l;for(null==n&&(n="x"),l={},e=[],i=0,a=t.length;i<a;i++)for(o=0,u=(s=t[i].values).length;o<u;o++)null==l[(r=s[o])[n]]&&(e.push(r[n]),l[r[n]]=!0);return e},Epoch.Util.trim=function(t){return Epoch.isString(t)?t.replace(/^\s+/g,"").replace(/\s+$/g,""):null},Epoch.Util.getComputedStyle=function(t,n){return Epoch.isFunction(window.getComputedStyle)?window.getComputedStyle(t,n):null!=t.currentStyle?t.currentStyle:void 0},Epoch.Util.toRGBA=function(t,n){var e,r,i;return(e=t.match(/^rgba\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*[0-9\.]+\)/))?(e[0],r="rgba("+e[1]+","+e[2]+","+e[3]+","+n+")"):(i=d3.rgb(t))&&(r="rgba("+i.r+","+i.g+","+i.b+","+n+")"),r},Epoch.Util.getContext=function(t,n){return null==n&&(n="2d"),t.getContext(n)},Epoch.Events=function(){function t(){this._events={}}return t.prototype.on=function(t,n){var e;if(null!=n)return null==(e=this._events)[t]&&(e[t]=[]),this._events[t].push(n)},t.prototype.onAll=function(t){var n,e,r;if(Epoch.isObject(t)){for(e in r=[],t)a.call(t,e)&&(n=t[e],r.push(this.on(e,n)));return r}},t.prototype.off=function(t,n){var e,r;if(Epoch.isArray(this._events[t])){if(null==n)return delete this._events[t];for(r=[];(e=this._events[t].indexOf(n))>=0;)r.push(this._events[t].splice(e,1));return r}},t.prototype.offAll=function(t){var n,e,r,i,o,u;if(Epoch.isArray(t)){for(o=[],e=0,r=t.length;e<r;e++)i=t[e],o.push(this.off(i));return o}if(Epoch.isObject(t)){for(i in u=[],t)a.call(t,i)&&(n=t[i],u.push(this.off(i,n)));return u}},t.prototype.trigger=function(t){var n,e,r,i,o,a,u,s;if(null!=this._events[t]){for(n=function(){var t,n,e;for(e=[],i=t=1,n=arguments.length;1<=n?t<n:t>n;i=1<=n?++t:--t)e.push(arguments[i]);return e}.apply(this,arguments),s=[],o=0,a=(u=this._events[t]).length;o<a;o++)e=u[o],r=null,Epoch.isString(e)?r=this[e]:Epoch.isFunction(e)&&(r=e),null==r&&Epoch.exception("Callback for event '"+t+"' is not a function or reference to a method."),s.push(r.apply(this,n));return s}},t}(),Epoch.Util.flatten=function(t){var n,e,r,i,o,a,u;if(!Array.isArray(t))throw new Error("Epoch.Util.flatten only accepts arrays");for(u=[],r=0,o=t.length;r<o;r++)if(n=t[r],Array.isArray(n))for(i=0,a=n.length;i<a;i++)e=n[i],u.push(e);else u.push(n);return u},d3.selection.prototype.width=function(t){return null!=t&&Epoch.isString(t)?this.style("width",t):null!=t&&Epoch.isNumber(t)?this.style("width",t+"px"):+Epoch.Util.getComputedStyle(this.node(),null).width.replace("px","")},d3.selection.prototype.height=function(t){return null!=t&&Epoch.isString(t)?this.style("height",t):null!=t&&Epoch.isNumber(t)?this.style("height",t+"px"):+Epoch.Util.getComputedStyle(this.node(),null).height.replace("px","")},Epoch.Formats.regular=function(t){return t},Epoch.Formats.si=function(t){return Epoch.Util.formatSI(t)},Epoch.Formats.percent=function(t){return(100*t).toFixed(1)+"%"},Epoch.Formats.seconds=function(t){return o(new Date(1e3*t))},o=d3.time.format("%I:%M:%S %p"),Epoch.Formats.bytes=function(t){return Epoch.Util.formatBytes(t)};var u,s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t};a={}.hasOwnProperty,Epoch.Chart.Base=function(t){var n,e;function r(t){var i;this.options=null!=t?t:{},r.__super__.constructor.call(this),this.options.model?(null!=this.options.model.hasData()?this.setData(this.options.model.getData(this.options.type,this.options.dataFormat)):this.setData(this.options.data||[]),this.options.model.on("data:updated",(i=this,function(){return i.setDataFromModel()}))):this.setData(this.options.data||[]),null!=this.options.el&&(this.el=d3.select(this.options.el)),this.width=this.options.width,this.height=this.options.height,null!=this.el?(null==this.width&&(this.width=this.el.width()),null==this.height&&(this.height=this.el.height())):(null==this.width&&(this.width=n.width),null==this.height&&(this.height=n.height),this.el=d3.select(document.createElement("DIV")).attr("width",this.width).attr("height",this.height)),this.onAll(e)}return s(r,t),n={width:320,height:240,dataFormat:null},e={"option:width":"dimensionsChanged","option:height":"dimensionsChanged","layer:shown":"layerChanged","layer:hidden":"layerChanged"},r.prototype._getAllOptions=function(){return Epoch.Util.defaults({},this.options)},r.prototype._getOption=function(t){var n,e;for(n=t.split("."),e=this.options;n.length&&null!=e;)e=e[n.shift()];return e},r.prototype._setOption=function(t,n){var e,r,i;for(e=t.split("."),r=this.options;e.length;){if(i=e.shift(),0===e.length)return r[i]=arguments[1],void this.trigger("option:"+arguments[0]);null==r[i]&&(r[i]={}),r=r[i]}},r.prototype._setManyOptions=function(t,n){var e,r,i;for(e in null==n&&(n=""),r=[],t)a.call(t,e)&&(i=t[e],Epoch.isObject(i)?r.push(this._setManyOptions(i,n+e+".")):r.push(this._setOption(n+e,i)));return r},r.prototype.option=function(){return 0===arguments.length?this._getAllOptions():1===arguments.length&&Epoch.isString(arguments[0])?this._getOption(arguments[0]):2===arguments.length&&Epoch.isString(arguments[0])?this._setOption(arguments[0],arguments[1]):1===arguments.length&&Epoch.isObject(arguments[0])?this._setManyOptions(arguments[0]):void 0},r.prototype.setDataFromModel=function(){var t;return t=this._prepareData(this.options.model.getData(this.options.type,this.options.dataFormat)),this.data=this._annotateLayers(t),this.draw()},r.prototype.setData=function(t,n){var e;return null==n&&(n={}),e=this._prepareData(this.rawData=this._formatData(t)),this.data=this._annotateLayers(e)},r.prototype._prepareData=function(t){return t},r.prototype._formatData=function(t){return Epoch.Data.formatData(t,this.options.type,this.options.dataFormat)},r.prototype._annotateLayers=function(t){var n,e,r,i,o;for(n=1,r=0,o=t.length;r<o;r++)i=t[r],(e=["layer"]).push("category"+n),i.category=n,i.visible=!0,null!=i.label&&e.push(Epoch.Util.dasherize(i.label)),i.className=e.join(" "),n++;return t},r.prototype._findLayer=function(t){var n,e,r,i,o,a;if(i=null,Epoch.isString(t)){for(n=0,o=(a=this.data).length;n<o;n++)if((r=a[n]).label===t){i=r;break}}else Epoch.isNumber(t)&&((e=parseInt(t))<0||e>=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 n<t?n:t},e=function(t,n){return n>t?n:t},[(i=Epoch.Util.flatten(n).map((function(t){return t.y}))).reduce(r,i[0]),i.reduce(e,i[0])]):Array.isArray(this.options.range)?this.options.range:this.options.range&&Array.isArray(this.options.range.left)?this.options.range.left:this.options.range&&Array.isArray(this.options.range.right)?this.options.range.right:this.extent((function(t){return t.y}))},r.prototype.extent=function(t){return[d3.min(this.getVisibleLayers(),(function(n){return d3.min(n.values,t)})),d3.max(this.getVisibleLayers(),(function(n){return d3.max(n.values,t)}))]},r.prototype.dimensionsChanged=function(){return this.width=this.option("width")||this.width,this.height=this.option("height")||this.height,this.el.width(this.width),this.el.height(this.height)},r.prototype.layerChanged=function(){return this.draw()},r}(Epoch.Events),Epoch.Chart.SVG=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.el?this.svg=this.el.append("svg"):this.svg=d3.select(document.createElement("svg")),this.svg.attr({xmlns:"http://www.w3.org/2000/svg",width:this.width,height:this.height})}return s(n,t),n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.svg.attr("width",this.width).attr("height",this.height)},n}(Epoch.Chart.Base),Epoch.Chart.Canvas=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.options.pixelRatio?this.pixelRatio=this.options.pixelRatio:null!=window.devicePixelRatio?this.pixelRatio=window.devicePixelRatio:this.pixelRatio=1,this.canvas=d3.select(document.createElement("CANVAS")),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()}),null!=this.el&&this.el.node().appendChild(this.canvas.node()),this.ctx=Epoch.Util.getContext(this.canvas.node())}return s(n,t),n.prototype.getWidth=function(){return this.width*this.pixelRatio},n.prototype.getHeight=function(){return this.height*this.pixelRatio},n.prototype.clear=function(){return this.ctx.clearRect(0,0,this.getWidth(),this.getHeight())},n.prototype.getStyles=function(t){return Epoch.QueryCSS.getStyles(t,this.el)},n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()})},n.prototype.redraw=function(){return Epoch.QueryCSS.purge(),this.draw()},n}(Epoch.Chart.Base),u=function(){var t,n,e,r,i;function o(){}return n=0,r=function(){return"epoch-container-"+n++},t=/^([^#. ]+)?(#[^. ]+)?(\.[^# ]+)?$/,e=!1,i=function(n){var e,r,i,o,a;return null==(o=n.match(t))?Epoch.error("Query CSS cannot match given selector: "+n):(o[0],a=o[1],i=o[2],e=o[3],a=(null!=a?a:"div").toUpperCase(),r=document.createElement(a),null!=i&&(r.id=i.substr(1)),null!=e&&(r.className=e.substr(1).replace(/\./g," ")),r)},o.log=function(t){return e=t},o.cache={},o.styleList=["fill","stroke","stroke-width"],o.container=null,o.purge=function(){return o.cache={}},o.getContainer=function(){var t;return null!=o.container?o.container:((t=document.createElement("DIV")).id="_canvas_css_reference",document.body.appendChild(t),o.container=d3.select(t))},o.hash=function(t,n){var e;return null==(e=n.attr("data-epoch-container-id"))&&(e=r(),n.attr("data-epoch-container-id",e)),e+"__"+t},o.getStyles=function(t,n){var r,a,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E,S;if(a=o.hash(t,n),null!=(r=o.cache[a]))return r;for(m=[],v=n.node().parentNode;null!=v&&"body"!==v.nodeName.toLowerCase();)m.unshift(v),v=v.parentNode;for(m.push(n.node()),k=[],l=0,f=m.length;l<f;l++)M=(s=m[l]).nodeName.toLowerCase(),null!=s.id&&s.id.length>0&&(M+="#"+s.id),null!=s.className&&s.className.length>0&&(M+="."+Epoch.Util.trim(s.className).replace(/\s+/g,".")),k.push(M);for(k.push("svg"),c=0,p=(_=Epoch.Util.trim(t).split(/\s+/)).length;c<p;c++)S=_[c],k.push(S);for(e&&console.log(k),y=b=i(k.shift());k.length;)u=i(k.shift()),y.appendChild(u),y=u;for(e&&console.log(b),o.getContainer().node().appendChild(b),x=d3.select("#_canvas_css_reference "+t),E={},h=0,g=(w=o.styleList).length;h<g;h++)E[d=w[h]]=x.style(d);return o.cache[a]=E,o.getContainer().html(""),E},o}(),Epoch.QueryCSS=u,a={}.hasOwnProperty;var l,c,h,f,p,g,d,y,v,m,x,_,w=[].slice;null==Epoch.Data&&(Epoch.Data={}),null==(c=Epoch.Data).Format&&(c.Format={}),l=function(t,n,e,r){var i,o,a,u,s;if(null==r&&(r=[]),i=(s=[n.labels,n.autoLabels,n.keyLabels])[1],o=s[2],null!=(u=s[0])&&Epoch.isArray(u)&&u.length>e)t.label=u[e];else if(o&&r.length>e)t.label=r[e];else if(i){for(a=[];e>=0;)a.push(String.fromCharCode(65+e%26)),e-=26;t.label=a.join("")}return t},Epoch.Data.Format.array=(f={x:function(t,n){return n},y:function(t,n){return t},time:function(t,n,e){return parseInt(e)+parseInt(n)},type:"area",autoLabels:!1,labels:[],startTime:parseInt((new Date).getTime()/1e3)},h=function(t,n,e){var r,i,o;if(i=[],Epoch.isArray(t[0]))for(r in t)a.call(t,r)&&(o=t[r],i.push(l({values:o.map(e)},n,parseInt(r))));else i.push(l({values:t.map(e)},n,0));return i},g=function(t,n){return h(t,n,(function(t,e){return{x:n.x(t,e),y:n.y(t,e)}}))},v=function(t,n){return h(t,n,(function(t,e){return{time:n.time(t,e,n.startTime),y:n.y(t,e)}}))},d=function(t,n){return h(t,n,(function(t,e){return{time:n.time(t,e,n.startTime),histogram:t}}))},y=function(t,n){var e,r,i;for(e in r=[],t)if(a.call(t,e)){if(i=t[e],!Epoch.isNumber(t[0]))return[];r.push(l({value:i},n,e))}return r},(p=function(t,n){var e;return null==t&&(t=[]),null==n&&(n={}),Epoch.isNonEmptyArray(t)?"time.heatmap"===(e=Epoch.Util.defaults(n,f)).type?d(t,e):e.type.match(/^time\./)?v(t,e):"pie"===e.type?y(t,e):g(t,e):[]}).entry=function(t,n){var e,r,i,o,a,u,s,l;if(null==n&&(n={}),"time.gauge"===n.type)return null==t?0:(u=Epoch.Util.defaults(n,f),e=Epoch.isArray(t)?t[0]:t,u.y(e,0));if(null==t)return[];for(null==n.startTime&&(n.startTime=parseInt((new Date).getTime()/1e3)),r=Epoch.isArray(t)?t.map((function(t){return[t]})):[t],l=[],i=0,a=(s=p(r,n)).length;i<a;i++)o=s[i],l.push(o.values[0]);return l},p),Epoch.Data.Format.tuple=function(){var t,n,e;return n={x:function(t,n){return t},y:function(t,n){return t},time:function(t,n){return t},type:"area",autoLabels:!1,labels:[]},t=function(t,n,e){var r,i,o;if(!Epoch.isArray(t[0]))return[];if(i=[],Epoch.isArray(t[0][0]))for(r in t)a.call(t,r)&&(o=t[r],i.push(l({values:o.map(e)},n,parseInt(r))));else i.push(l({values:t.map(e)},n,0));return i},(e=function(e,r){var i;return null==e&&(e=[]),null==r&&(r={}),Epoch.isNonEmptyArray(e)?"pie"===(i=Epoch.Util.defaults(r,n)).type||"time.heatmap"===i.type||"time.gauge"===i.type?[]:i.type.match(/^time\./)?t(e,i,(function(t,n){return{time:i.time(t[0],parseInt(n)),y:i.y(t[1],parseInt(n))}})):t(e,i,(function(t,n){return{x:i.x(t[0],parseInt(n)),y:i.y(t[1],parseInt(n))}})):[]}).entry=function(t,n){var r,i,o,a,u,s;if(null==n&&(n={}),null==t)return[];for(null==n.startTime&&(n.startTime=parseInt((new Date).getTime()/1e3)),r=Epoch.isArray(t)&&Epoch.isArray(t[0])?t.map((function(t){return[t]})):[t],s=[],i=0,a=(u=e(r,n)).length;i<a;i++)o=u[i],s.push(o.values[0]);return s},e}(),Epoch.Data.Format.keyvalue=function(){var t,n,e,r,i;return n={type:"area",x:function(t,n){return parseInt(n)},y:function(t,n){return t},time:function(t,n,e){return parseInt(e)+parseInt(n)},labels:[],autoLabels:!1,keyLabels:!0,startTime:parseInt((new Date).getTime()/1e3)},t=function(t,n,e,r){var i,o,u,s,c,h;for(u in c=[],n)if(a.call(n,u)){for(o in s=n[u],h=[],t)a.call(t,o)&&(i=t[o],h.push(r(i,s,parseInt(o))));c.push(l({values:h},e,parseInt(u),n))}return c},r=function(n,e,r){return t(n,e,r,(function(t,n,e){return{x:Epoch.isString(r.x)?t[r.x]:r.x(t,parseInt(e)),y:r.y(t[n],parseInt(e))}}))},i=function(n,e,r,i){return null==i&&(i="y"),t(n,e,r,(function(t,n,e){var o;return(o=Epoch.isString(r.time)?{time:t[r.time]}:{time:r.time(t,parseInt(e),r.startTime)})[i]=r.y(t[n],parseInt(e)),o}))},(e=function(t,e,o){var a;return null==t&&(t=[]),null==e&&(e=[]),null==o&&(o={}),Epoch.isNonEmptyArray(t)&&Epoch.isNonEmptyArray(e)?"pie"===(a=Epoch.Util.defaults(o,n)).type||"time.gauge"===a.type?[]:"time.heatmap"===a.type?i(t,e,a,"histogram"):a.type.match(/^time\./)?i(t,e,a):r(t,e,a):[]}).entry=function(t,n,r){var i,o,a,u,s;if(null==n&&(n=[]),null==r&&(r={}),null==t||!Epoch.isNonEmptyArray(n))return[];for(null==r.startTime&&(r.startTime=parseInt((new Date).getTime()/1e3)),s=[],i=0,a=(u=e([t],n,r)).length;i<a;i++)o=u[i],s.push(o.values[0]);return s},e}(),Epoch.data=function(){var t,n,e;return e=arguments[0],t=2<=arguments.length?w.call(arguments,1):[],null==(n=Epoch.Data.Format[e])?[]:n.apply(n,t)},Epoch.Data.formatData=function(t,n,e){var r,i,o,a,u,s;if(null==t&&(t=[]),!Epoch.isNonEmptyArray(t))return t;if(Epoch.isString(e))return u={type:n},Epoch.data(e,t,u);if(!Epoch.isObject(e))return t;if(null==e.name||!Epoch.isString(e.name))return t;if(null==Epoch.Data.Format[e.name])return t;if(i=[e.name,t],null!=e.arguments&&Epoch.isArray(e.arguments))for(o=0,a=(s=e.arguments).length;o<a;o++)r=s[o],i.push(r);return null!=e.options?(u=e.options,null!=n&&null==u.type&&(u.type=n),i.push(u)):null!=n&&i.push({type:n}),Epoch.data.apply(Epoch.data,i)},Epoch.Data.formatEntry=function(t,n,e){var r,i,o,a,u,s,l,c;if(null==e)return t;if(Epoch.isString(e))return l={type:n},Epoch.Data.Format[e].entry(t,l);if(!Epoch.isObject(e))return t;if(null==e.name||!Epoch.isString(e.name))return t;if(null==Epoch.Data.Format[e.name])return t;if(i=[t],null!=(o=Epoch.Util.defaults(e,{})).arguments&&Epoch.isArray(o.arguments))for(u=0,s=(c=o.arguments).length;u<s;u++)r=c[u],i.push(r);return null!=o.options?((l=o.options).type=n,i.push(l)):null!=n&&i.push({type:n}),(a=Epoch.Data.Format[o.name].entry).apply(a,i)},s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Model=function(t){var n;function e(t){null==t&&(t={}),e.__super__.constructor.call(this),t=Epoch.Util.defaults(t,n),this.dataFormat=t.dataFormat,this.data=t.data,this.loading=!1}return s(e,t),n={dataFormat:null},e.prototype.setData=function(t){return this.data=t,this.trigger("data:updated")},e.prototype.push=function(t){return this.entry=t,this.trigger("data:push")},e.prototype.hasData=function(){return null!=this.data},e.prototype.getData=function(t,n){return null==n&&(n=this.dataFormat),Epoch.Data.formatData(this.data,t,n)},e.prototype.getNext=function(t,n){return null==n&&(n=this.dataFormat),Epoch.Data.formatEntry(this.entry,t,n)},e}(Epoch.Events),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Plot=function(t){var n,e,r;function i(t){var o,a,u,s;for(this.options=null!=t?t:{},Epoch.Util.copy(this.options.margins),i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this.margins={},o=0,a=(s=["top","right","bottom","left"]).length;o<a;o++)u=s[o],this.margins[u]=null!=this.options.margins&&null!=this.options.margins[u]?this.options.margins[u]:this.hasAxis(u)?n[u]:6;this.g=this.svg.append("g").attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.onAll(r)}return s(i,t),e={domain:null,range:null,axes:["left","bottom"],ticks:{top:14,bottom:14,left:5,right:5},tickFormats:{top:Epoch.Formats.regular,bottom:Epoch.Formats.regular,left:Epoch.Formats.si,right:Epoch.Formats.si}},n={top:25,right:50,bottom:25,left:50},r={"option:margins.top":"marginsChanged","option:margins.right":"marginsChanged","option:margins.bottom":"marginsChanged","option:margins.left":"marginsChanged","option:axes":"axesChanged","option:ticks.top":"ticksChanged","option:ticks.right":"ticksChanged","option:ticks.bottom":"ticksChanged","option:ticks.left":"ticksChanged","option:tickFormats.top":"tickFormatsChanged","option:tickFormats.right":"tickFormatsChanged","option:tickFormats.bottom":"tickFormatsChanged","option:tickFormats.left":"tickFormatsChanged","option:domain":"domainChanged","option:range":"rangeChanged"},i.prototype.setTickFormat=function(t,n){return this.options.tickFormats[t]=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)},i.prototype.innerHeight=function(){return this.height-(this.margins.top+this.margins.bottom)},i.prototype.x=function(){var t,n;return t=null!=(n=this.options.domain)?n:this.extent((function(t){return t.x})),d3.scale.linear().domain(t).range([0,this.innerWidth()])},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.bottomAxis=function(){return d3.svg.axis().scale(this.x()).orient("bottom").ticks(this.options.ticks.bottom).tickFormat(this.options.tickFormats.bottom)},i.prototype.topAxis=function(){return d3.svg.axis().scale(this.x()).orient("top").ticks(this.options.ticks.top).tickFormat(this.options.tickFormats.top)},i.prototype.leftAxis=function(){var t;return t=this.options.range?this.options.range.left:null,d3.svg.axis().scale(this.y(t)).orient("left").ticks(this.options.ticks.left).tickFormat(this.options.tickFormats.left)},i.prototype.rightAxis=function(){var t;return t=this.options.range?this.options.range.right:null,d3.svg.axis().scale(this.y(t)).orient("right").ticks(this.options.ticks.right).tickFormat(this.options.tickFormats.right)},i.prototype.draw=function(){return this._axesDrawn?this._redrawAxes():this._drawAxes(),i.__super__.draw.call(this)},i.prototype._redrawAxes=function(){if(this.hasAxis("bottom")&&this.g.selectAll(".x.axis.bottom").transition().duration(500).ease("linear").call(this.bottomAxis()),this.hasAxis("top")&&this.g.selectAll(".x.axis.top").transition().duration(500).ease("linear").call(this.topAxis()),this.hasAxis("left")&&this.g.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.g.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._drawAxes=function(){return this.hasAxis("bottom")&&this.g.append("g").attr("class","x axis bottom").attr("transform","translate(0, "+this.innerHeight()+")").call(this.bottomAxis()),this.hasAxis("top")&&this.g.append("g").attr("class","x axis top").call(this.topAxis()),this.hasAxis("left")&&this.g.append("g").attr("class","y axis left").call(this.leftAxis()),this.hasAxis("right")&&this.g.append("g").attr("class","y axis right").attr("transform","translate("+this.innerWidth()+", 0)").call(this.rightAxis()),this._axesDrawn=!0},i.prototype.dimensionsChanged=function(){return i.__super__.dimensionsChanged.call(this),this.g.selectAll(".axis").remove(),this._axesDrawn=!1,this.draw()},i.prototype.marginsChanged=function(){var t,n,e;if(null!=this.options.margins){for(t in n=this.options.margins)a.call(n,t)&&(e=n[t],this.margins[t]=null==e?6:e);return this.g.transition().duration(750).attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.draw()}},i.prototype.axesChanged=function(){var t,e,r,i;for(t=0,e=(i=["top","right","bottom","left"]).length;t<e;t++)r=i[t],null!=this.options.margins&&null!=this.options.margins[r]||(this.hasAxis(r)?this.margins[r]=n[r]:this.margins[r]=6);return this.g.transition().duration(750).attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.g.selectAll(".axis").remove(),this._axesDrawn=!1,this.draw()},i.prototype.ticksChanged=function(){return this.draw()},i.prototype.tickFormatsChanged=function(){return this.draw()},i.prototype.domainChanged=function(){return this.draw()},i.prototype.rangeChanged=function(){return this.draw()},i}(Epoch.Chart.SVG),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Area=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="area"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype.y=function(){var t,n,e,r,i,o,u,s;for(t=[],n=0,r=(i=this.getVisibleLayers()).length;n<r;n++)for(e in o=i[n].values)a.call(o,e)&&(s=o[e],null!=t[e]&&(t[e]+=s.y),null==t[e]&&(t[e]=s.y));return d3.scale.linear().domain(null!=(u=this.options.range)?u:[0,d3.max(t)]).range([this.height-this.margins.top-this.margins.bottom,0])},n.prototype.draw=function(){var t,e,r,i,o,a;if(i=[this.x(),this.y(),this.getVisibleLayers()],o=i[0],a=i[1],r=i[2],this.g.selectAll(".layer").remove(),0!==r.length)return t=d3.svg.area().x((function(t){return o(t.x)})).y0((function(t){return a(t.y0)})).y1((function(t){return a(t.y0+t.y)})),d3.layout.stack().values((function(t){return t.values}))(r),(e=this.g.selectAll(".layer").data(r,(function(t){return t.category}))).select(".area").attr("d",(function(n){return t(n.values)})),e.enter().append("g").attr("class",(function(t){return t.className})),e.append("path").attr("class","area").attr("d",(function(n){return t(n.values)})),n.__super__.draw.call(this)},n}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Bar=function(t){var n,e,r,i;function o(t){this.options=null!=t?t:{},this._isHorizontal()?this.options=Epoch.Util.defaults(this.options,e):this.options=Epoch.Util.defaults(this.options,n),o.__super__.constructor.call(this,this.options),this.onAll(i),this.draw()}return s(o,t),n={type:"bar",style:"grouped",orientation:"vertical",padding:{bar:.08,group:.1},outerPadding:{bar:.08,group:.1}},r={tickFormats:{top:Epoch.Formats.si,bottom:Epoch.Formats.si,left:Epoch.Formats.regular,right:Epoch.Formats.regular}},e=Epoch.Util.defaults(r,n),i={"option:orientation":"orientationChanged","option:padding":"paddingChanged","option:outerPadding":"paddingChanged","option:padding:bar":"paddingChanged","option:padding:group":"paddingChanged","option:outerPadding:bar":"paddingChanged","option:outerPadding:group":"paddingChanged"},o.prototype._isVertical=function(){return"vertical"===this.options.orientation},o.prototype._isHorizontal=function(){return"horizontal"===this.options.orientation},o.prototype.x=function(){var t;return this._isVertical()?d3.scale.ordinal().domain(Epoch.Util.domain(this.getVisibleLayers())).rangeRoundBands([0,this.innerWidth()],this.options.padding.group,this.options.outerPadding.group):((t=this.extent((function(t){return t.y})))[0]=Math.min(0,t[0]),d3.scale.linear().domain(t).range([0,this.width-this.margins.left-this.margins.right]))},o.prototype.x1=function(t){var n;return d3.scale.ordinal().domain(function(){var t,e,r,i;for(i=[],t=0,e=(r=this.getVisibleLayers()).length;t<e;t++)n=r[t],i.push(n.category);return i}.call(this)).rangeRoundBands([0,t.rangeBand()],this.options.padding.bar,this.options.outerPadding.bar)},o.prototype.y=function(){var t;return this._isVertical()?((t=this.extent((function(t){return t.y})))[0]=Math.min(0,t[0]),d3.scale.linear().domain(t).range([this.height-this.margins.top-this.margins.bottom,0])):d3.scale.ordinal().domain(Epoch.Util.domain(this.getVisibleLayers())).rangeRoundBands([0,this.innerHeight()],this.options.padding.group,this.options.outerPadding.group)},o.prototype.y1=function(t){var n;return d3.scale.ordinal().domain(function(){var t,e,r,i;for(i=[],t=0,e=(r=this.getVisibleLayers()).length;t<e;t++)n=r[t],i.push(n.category);return i}.call(this)).rangeRoundBands([0,t.rangeBand()],this.options.padding.bar,this.options.outerPadding.bar)},o.prototype._remapData=function(){var t,n,e,r,i,o,u,s,l,c,h,f,p,g;for(l={},e=0,u=(h=this.getVisibleLayers()).length;e<u;e++)for(t="bar "+(o=h[e]).className.replace(/\s*layer\s*/,""),i=0,s=(f=o.values).length;i<s;i++)null==l[c=(n=f[i]).x]&&(l[c]=[]),l[n.x].push({label:o.category,y:n.y,className:t});for(r in p=[],l)a.call(l,r)&&(g=l[r],p.push({group:r,values:g}));return p},o.prototype.draw=function(){return this._isVertical()?this._drawVertical():this._drawHorizontal(),o.__super__.draw.call(this)},o.prototype._drawVertical=function(){var t,n,e,r,i,o,a,u;return i=[this.x(),this.y()],o=i[0],u=i[1],a=this.x1(o),n=this.height-this.margins.top-this.margins.bottom,t=this._remapData(),(e=this.g.selectAll(".layer").data(t,(function(t){return t.group}))).transition().duration(750).attr("transform",(function(t){return"translate("+o(t.group)+", 0)"})),e.enter().append("g").attr("class","layer").attr("transform",(function(t){return"translate("+o(t.group)+", 0)"})),(r=e.selectAll("rect").data((function(t){return t.values}))).attr("class",(function(t){return t.className})),r.transition().duration(600).attr("x",(function(t){return a(t.label)})).attr("y",(function(t){return u(t.y)})).attr("width",a.rangeBand()).attr("height",(function(t){return n-u(t.y)})),r.enter().append("rect").attr("class",(function(t){return t.className})).attr("x",(function(t){return a(t.label)})).attr("y",(function(t){return u(t.y)})).attr("width",a.rangeBand()).attr("height",(function(t){return n-u(t.y)})),r.exit().transition().duration(150).style("opacity","0").remove(),e.exit().transition().duration(750).style("opacity","0").remove()},o.prototype._drawHorizontal=function(){var t,n,e,r,i,o,a;return r=[this.x(),this.y()],i=r[0],o=r[1],a=this.y1(o),this.width,this.margins.left,this.margins.right,t=this._remapData(),(n=this.g.selectAll(".layer").data(t,(function(t){return t.group}))).transition().duration(750).attr("transform",(function(t){return"translate(0, "+o(t.group)+")"})),n.enter().append("g").attr("class","layer").attr("transform",(function(t){return"translate(0, "+o(t.group)+")"})),(e=n.selectAll("rect").data((function(t){return t.values}))).attr("class",(function(t){return t.className})),e.transition().duration(600).attr("x",(function(t){return 0})).attr("y",(function(t){return a(t.label)})).attr("height",a.rangeBand()).attr("width",(function(t){return i(t.y)})),e.enter().append("rect").attr("class",(function(t){return t.className})).attr("x",(function(t){return 0})).attr("y",(function(t){return a(t.label)})).attr("height",a.rangeBand()).attr("width",(function(t){return i(t.y)})),e.exit().transition().duration(150).style("opacity","0").remove(),n.exit().transition().duration(750).style("opacity","0").remove()},o.prototype._getTickValues=function(t,n){var e,r,i;return null==n&&(n="x"),null==this.data[0]?[]:(i=this.data[0].values.length,r=0|Math.ceil(i/t),function(){var t,n,o,a;for(a=[],e=t=0,n=i,o=r;o>0?t<n:t>n;e=t+=o)a.push(this.data[0].values[e].x);return a}.call(this))},o.prototype.bottomAxis=function(){var t;return t=d3.svg.axis().scale(this.x()).orient("bottom").ticks(this.options.ticks.bottom).tickFormat(this.options.tickFormats.bottom),this._isVertical()&&null!=this.options.ticks.bottom&&t.tickValues(this._getTickValues(this.options.ticks.bottom)),t},o.prototype.topAxis=function(){var t;return t=d3.svg.axis().scale(this.x()).orient("top").ticks(this.options.ticks.top).tickFormat(this.options.tickFormats.top),this._isVertical()&&null!=this.options.ticks.top&&t.tickValues(this._getTickValues(this.options.ticks.top)),t},o.prototype.leftAxis=function(){var t;return t=d3.svg.axis().scale(this.y()).orient("left").ticks(this.options.ticks.left).tickFormat(this.options.tickFormats.left),this._isHorizontal()&&null!=this.options.ticks.left&&t.tickValues(this._getTickValues(this.options.ticks.left)),t},o.prototype.rightAxis=function(){var t;return t=d3.svg.axis().scale(this.y()).orient("right").ticks(this.options.ticks.right).tickFormat(this.options.tickFormats.right),this._isHorizontal()&&null!=this.options.ticks.right&&t.tickValues(this._getTickValues(this.options.ticks.right)),t},o.prototype.orientationChanged=function(){var t,n,e,r;return r=this.options.tickFormats.top,t=this.options.tickFormats.bottom,n=this.options.tickFormats.left,e=this.options.tickFormats.right,this.options.tickFormats.left=r,this.options.tickFormats.right=t,this.options.tickFormats.top=n,this.options.tickFormats.bottom=e,this.draw()},o.prototype.paddingChanged=function(){return this.draw()},o}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Histogram=function(t){var n,e;function r(t){this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.onAll(e),this.draw()}return s(r,t),n={type:"histogram",domain:[0,100],bucketRange:[0,100],buckets:10,cutOutliers:!1},e={"option:bucketRange":"bucketRangeChanged","option:buckets":"bucketsChanged","option:cutOutliers":"cutOutliersChanged"},r.prototype._prepareData=function(t){var n,e,r,i,o,u,s,l,c,h,f,p,g,d;for(n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,f=[],i=0,l=t.length;i<l;i++){for(s=t[i],e=function(){var t,n,e;for(e=[],t=0,n=this.options.buckets;0<=n?t<n:t>n;0<=n?++t:--t)e.push(0);return e}.call(this),u=0,c=(g=s.values).length;u<c;u++)h=g[u],r=parseInt((h.x-this.options.bucketRange[0])/n),this.options.cutOutliers&&(r<0||r>=this.options.buckets)||(r<0?r=0:r>=this.options.buckets&&(r=this.options.buckets-1),e[r]+=parseInt(h.y));for(o in p={values:e.map((function(t,e){return{x:parseInt(e)*n,y:t}}))},s)a.call(s,o)&&(d=s[o],"values"!==o&&(p[o]=d));f.push(p)}return f},r.prototype.resetData=function(){return this.setData(this.rawData),this.draw()},r.prototype.bucketRangeChanged=function(){return this.resetData()},r.prototype.bucketsChanged=function(){return this.resetData()},r.prototype.cutOutliersChanged=function(){return this.resetData()},r}(Epoch.Chart.Bar),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Line=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="line"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype.line=function(t){var n,e,r;return n=[this.x(),this.y(t.range)],e=n[0],r=n[1],d3.svg.line().x((function(t){return e(t.x)})).y((function(t){return r(t.y)}))},n.prototype.draw=function(){var t,e,r;return 0===(this.x(),this.y(),e=this.getVisibleLayers()).length?this.g.selectAll(".layer").remove():((t=this.g.selectAll(".layer").data(e,(function(t){return t.category}))).select(".line").transition().duration(500).attr("d",(r=this,function(t){return r.line(t)(t.values)})),t.enter().append("g").attr("class",(function(t){return t.className})).append("path").attr("class","line").attr("d",function(t){return function(n){return t.line(n)(n.values)}}(this)),t.exit().transition().duration(750).style("opacity","0").remove(),n.__super__.draw.call(this))},n}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Pie=function(t){var n;function e(t){var r;this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.pie=d3.layout.pie().sort(null).value((function(t){return t.value})),this.arc=d3.svg.arc().outerRadius((r=this,function(){return Math.max(r.width,r.height)/2-r.options.margin})).innerRadius(function(t){return function(){return t.options.inner}}(this)),this.g=this.svg.append("g").attr("transform","translate("+this.width/2+", "+this.height/2+")"),this.on("option:margin","marginChanged"),this.on("option:inner","innerChanged"),this.draw()}return s(e,t),n={type:"pie",margin:10,inner:0},e.prototype.draw=function(){var t,n;return this.g.selectAll(".arc").remove(),(t=this.g.selectAll(".arc").data(this.pie(this.getVisibleLayers()),(function(t){return t.data.category}))).enter().append("g").attr("class",(function(t){return"arc pie "+t.data.className})),t.select("path").attr("d",this.arc),t.select("text").attr("transform",(n=this,function(t){return"translate("+n.arc.centroid(t)+")"})).text((function(t){return t.data.label||t.data.category})),t.append("path").attr("d",this.arc).each((function(t){return this._current=t})),t.append("text").attr("transform",function(t){return function(n){return"translate("+t.arc.centroid(n)+")"}}(this)).attr("dy",".35em").style("text-anchor","middle").text((function(t){return t.data.label||t.data.category})),e.__super__.draw.call(this)},e.prototype.marginChanged=function(){return this.draw()},e.prototype.innerChanged=function(){return this.draw()},e}(Epoch.Chart.SVG),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Chart.Scatter=function(t){var n;function e(t){this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.on("option:radius","radiusChanged"),this.draw()}return s(e,t),n={type:"scatter",radius:3.5,axes:["top","bottom","left","right"]},e.prototype.draw=function(){var t,n,r,i,o,a,u;return o=[this.x(),this.y(),this.getVisibleLayers()],a=o[0],u=o[1],r=o[2],i=this.options.radius,0===r.length?this.g.selectAll(".layer").remove():((n=this.g.selectAll(".layer").data(r,(function(t){return t.category}))).enter().append("g").attr("class",(function(t){return t.className})),(t=n.selectAll(".dot").data((function(t){return t.values}))).transition().duration(500).attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return u(t.y)})),t.enter().append("circle").attr("class","dot").attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return u(t.y)})),t.exit().transition().duration(750).style("opacity",0).remove(),n.exit().transition().duration(750).style("opacity",0).remove(),e.__super__.draw.call(this))},e.prototype.radiusChanged=function(){return this.draw()},e}(Epoch.Chart.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Plot=function(t){var n,e,r;function i(t){var o,a,u,s,l;for(this.options=t,Epoch.Util.copy(this.options.margins),i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this.options.model&&this.options.model.on("data:push",(l=this,function(){return l.pushFromModel()})),this._queue=[],this.margins={},o=0,a=(s=["top","right","bottom","left"]).length;o<a;o++)u=s[o],this.margins[u]=null!=this.options.margins&&null!=this.options.margins[u]?this.options.margins[u]:this.hasAxis(u)?n[u]:6;this.svg=this.el.insert("svg",":first-child").attr("width",this.width).attr("height",this.height).style("z-index","1000"),"absolute"!==this.el.style("position")&&"relative"!==this.el.style("position")&&this.el.style("position","relative"),this.canvas.style({position:"absolute","z-index":"999"}),this._sizeCanvas(),this.animation={interval:null,active:!1,delta:function(t){return function(){return-t.w()/t.options.fps}}(this),tickDelta:function(t){return function(){return-t.w()/t.pixelRatio/t.options.fps}}(this),frame:0,duration:this.options.fps},this._buildAxes(),this.animationCallback=function(t){return function(){return t._animate()}}(this),this.onAll(r)}return s(i,t),e={range:null,fps:24,historySize:120,windowSize:40,queueSize:10,axes:["bottom"],ticks:{time:15,left:5,right:5},tickFormats:{top:Epoch.Formats.seconds,bottom:Epoch.Formats.seconds,left:Epoch.Formats.si,right:Epoch.Formats.si}},n={top:25,right:50,bottom:25,left:50},r={"option:margins":"marginsChanged","option:margins.top":"marginsChanged","option:margins.right":"marginsChanged","option:margins.bottom":"marginsChanged","option:margins.left":"marginsChanged","option:axes":"axesChanged","option:ticks":"ticksChanged","option:ticks.top":"ticksChanged","option:ticks.right":"ticksChanged","option:ticks.bottom":"ticksChanged","option:ticks.left":"ticksChanged","option:tickFormats":"tickFormatsChanged","option:tickFormats.top":"tickFormatsChanged","option:tickFormats.right":"tickFormatsChanged","option:tickFormats.bottom":"tickFormatsChanged","option:tickFormats.left":"tickFormatsChanged"},i.prototype._sizeCanvas=function(){return this.canvas.attr({width:this.innerWidth(),height:this.innerHeight()}),this.canvas.style({width:this.innerWidth()/this.pixelRatio+"px",height:this.innerHeight()/this.pixelRatio+"px",top:this.margins.top+"px",left:this.margins.left+"px"})},i.prototype._buildAxes=function(){return this.svg.selectAll(".axis").remove(),this._prepareTimeAxes(),this._prepareRangeAxes()},i.prototype._annotateLayers=function(t){var n,e,r,i,o,u;for(i in r=[],t)a.call(t,i)&&(o=t[i],e=Epoch.Util.copy(o),u=Math.max(0,o.values.length-this.options.historySize),e.values=o.values.slice(u),(n=["layer"]).push("category"+(1+(0|i))),null!=o.label&&n.push(Epoch.Util.dasherize(o.label)),e.className=n.join(" "),e.visible=!0,r.push(e));return r},i.prototype._offsetX=function(){return 0},i.prototype._prepareTimeAxes=function(){return this.hasAxis("bottom")&&(this.bottomAxis=this.svg.append("g").attr("class","x axis bottom canvas").attr("transform","translate("+(this.margins.left-1)+", "+(this.innerHeight()/this.pixelRatio+this.margins.top)+")")).append("path").attr("class","domain").attr("d","M0,0H"+(this.innerWidth()/this.pixelRatio+1)),this.hasAxis("top")&&(this.topAxis=this.svg.append("g").attr("class","x axis top canvas").attr("transform","translate("+(this.margins.left-1)+", "+this.margins.top+")")).append("path").attr("class","domain").attr("d","M0,0H"+(this.innerWidth()/this.pixelRatio+1)),this._resetInitialTimeTicks()},i.prototype._resetInitialTimeTicks=function(){var t,n,e,r,i,o,a,u,s;for(s=this.options.ticks.time,this._ticks=[],this._tickTimer=s,null!=this.bottomAxis&&this.bottomAxis.selectAll(".tick").remove(),null!=this.topAxis&&this.topAxis.selectAll(".tick").remove(),u=[],e=0,i=(o=this.data).length;e<i;e++)if(r=o[e],Epoch.isNonEmptyArray(r.values)){for(t=(a=[this.options.windowSize-1,r.values.length-1])[0],n=a[1];t>=0&&n>=0;)this._pushTick(t,r.values[n].time,!1,!0),t-=s,n-=s;break}return u},i.prototype._prepareRangeAxes=function(){if(this.hasAxis("left")&&this.svg.append("g").attr("class","y axis left").attr("transform","translate("+(this.margins.left-1)+", "+this.margins.top+")").call(this.leftAxis()),this.hasAxis("right"))return this.svg.append("g").attr("class","y axis right").attr("transform","translate("+(this.width-this.margins.right)+", "+this.margins.top+")").call(this.rightAxis())},i.prototype.leftAxis=function(){var t,n;return n=this.options.ticks.left,t=d3.svg.axis().scale(this.ySvgLeft()).orient("left").tickFormat(this.options.tickFormats.left),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.rightAxis=function(){var t,n;return this.extent((function(t){return t.y})),n=this.options.ticks.right,t=d3.svg.axis().scale(this.ySvgRight()).orient("right").tickFormat(this.options.tickFormats.right),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.hasAxis=function(t){return this.options.axes.indexOf(t)>-1},i.prototype.innerWidth=function(){return(this.width-(this.margins.left+this.margins.right))*this.pixelRatio},i.prototype.innerHeight=function(){return(this.height-(this.margins.top+this.margins.bottom))*this.pixelRatio},i.prototype._prepareEntry=function(t){return t},i.prototype._prepareLayers=function(t){return t},i.prototype._startTransition=function(){if(!0!==this.animation.active&&0!==this._queue.length)return this.trigger("transition:start"),this._shift(),this.animation.active=!0,this.animation.interval=setInterval(this.animationCallback,1e3/this.options.fps)},i.prototype._stopTransition=function(){var t,n,e,r,i,o,a;if(this.inTransition()){for(n=0,i=(o=this.data).length;n<i;n++)(r=o[n]).values.length>this.options.windowSize+1&&r.values.shift();return t=(a=[this._ticks[0],this._ticks[this._ticks.length-1]])[0],null!=(e=a[1])&&e.enter&&(e.enter=!1,e.opacity=1),null!=t&&t.exit&&this._shiftTick(),this.animation.frame=0,this.trigger("transition:end"),this._queue.length>0?this._shift():(this.animation.active=!1,clearInterval(this.animation.interval))}},i.prototype.inTransition=function(){return this.animation.active},i.prototype.push=function(t){return t=this._prepareLayers(t),this._queue.length>this.options.queueSize&&this._queue.splice(this.options.queueSize,this._queue.length-this.options.queueSize),this._queue.length!==this.options.queueSize&&(this._queue.push(t.map((n=this,function(t){return n._prepareEntry(t)}))),this.trigger("push"),this.inTransition()?void 0:this._startTransition());var n},i.prototype.pushFromModel=function(){return this.push(this.options.model.getNext(this.options.type,this.options.dataFormat))},i.prototype._shift=function(){var t,n,e;for(n in this.trigger("before:shift"),t=this._queue.shift(),e=this.data)a.call(e,n)&&e[n].values.push(t[n]);return this._updateTicks(t[0].time),this._transitionRangeAxes(),this.trigger("after:shift")},i.prototype._transitionRangeAxes=function(){if(this.hasAxis("left")&&this.svg.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.svg.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._animate=function(){if(this.inTransition())return++this.animation.frame===this.animation.duration&&this._stopTransition(),this.draw(this.animation.frame*this.animation.delta()),this._updateTimeAxes()},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.ySvg=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.ySvgLeft=function(){return null!=this.options.range?this.ySvg(this.options.range.left):this.ySvg()},i.prototype.ySvgRight=function(){return null!=this.options.range?this.ySvg(this.options.range.right):this.ySvg()},i.prototype.w=function(){return this.innerWidth()/this.options.windowSize},i.prototype._updateTicks=function(t){if((this.hasAxis("top")||this.hasAxis("bottom"))&&(++this._tickTimer%this.options.ticks.time||this._pushTick(this.options.windowSize,t,!0),this._ticks.length>0))return this._ticks[0].x-this.w()/this.pixelRatio>=0?void 0:this._ticks[0].exit=!0},i.prototype._pushTick=function(t,n,e,r){var i,o;if(null==e&&(e=!1),null==r&&(r=!1),this.hasAxis("top")||this.hasAxis("bottom"))return o={time:n,x:t*(this.w()/this.pixelRatio)+this._offsetX(),opacity:e?0:1,enter:!!e,exit:!1},this.hasAxis("bottom")&&((i=this.bottomAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",6),i.append("text").attr("text-anchor","middle").attr("dy",19).text(this.options.tickFormats.bottom(o.time)),o.bottomEl=i),this.hasAxis("top")&&((i=this.topAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",-6),i.append("text").attr("text-anchor","middle").attr("dy",-10).text(this.options.tickFormats.top(o.time)),o.topEl=i),r?this._ticks.unshift(o):this._ticks.push(o),o},i.prototype._shiftTick=function(){var t;if(this._ticks.length>0)return null!=(t=this._ticks.shift()).topEl&&t.topEl.remove(),null!=t.bottomEl?t.bottomEl.remove():void 0},i.prototype._updateTimeAxes=function(){var t,n,e,r,i,o,a,u;if(this.hasAxis("top")||this.hasAxis("bottom")){for(n=(i=[this.animation.tickDelta(),1/this.options.fps])[0],t=i[1],a=[],e=0,r=(o=this._ticks).length;e<r;e++)(u=o[e]).x+=n,this.hasAxis("bottom")&&u.bottomEl.attr("transform","translate("+(u.x+1)+",0)"),this.hasAxis("top")&&u.topEl.attr("transform","translate("+(u.x+1)+",0)"),u.enter?u.opacity+=t:u.exit&&(u.opacity-=t),u.enter||u.exit?(this.hasAxis("bottom")&&u.bottomEl.style("opacity",u.opacity),this.hasAxis("top")?a.push(u.topEl.style("opacity",u.opacity)):a.push(void 0)):a.push(void 0);return a}},i.prototype.draw=function(t){return null==t&&(t=0),i.__super__.draw.call(this)},i.prototype.dimensionsChanged=function(){return i.__super__.dimensionsChanged.call(this),this.svg.attr("width",this.width).attr("height",this.height),this._sizeCanvas(),this._buildAxes(),this.draw(this.animation.frame*this.animation.delta())},i.prototype.axesChanged=function(){var t,e,r,i;for(t=0,e=(i=["top","right","bottom","left"]).length;t<e;t++)r=i[t],null!=this.options.margins&&null!=this.options.margins[r]||(this.hasAxis(r)?this.margins[r]=n[r]:this.margins[r]=6);return this._sizeCanvas(),this._buildAxes(),this.draw(this.animation.frame*this.animation.delta())},i.prototype.ticksChanged=function(){return this._resetInitialTimeTicks(),this._transitionRangeAxes(),this.draw(this.animation.frame*this.animation.delta())},i.prototype.tickFormatsChanged=function(){return this._resetInitialTimeTicks(),this._transitionRangeAxes(),this.draw(this.animation.frame*this.animation.delta())},i.prototype.marginsChanged=function(){var t,n,e;if(null!=this.options.margins){for(t in n=this.options.margins)a.call(n,t)&&(e=n[t],this.margins[t]=null==e?6:e);return this._sizeCanvas(),this.draw(this.animation.frame*this.animation.delta())}},i.prototype.layerChanged=function(){return this._transitionRangeAxes(),i.__super__.layerChanged.call(this)},i}(Epoch.Chart.Canvas),Epoch.Time.Stack=function(t){function n(){return n.__super__.constructor.apply(this,arguments)}return s(n,t),n.prototype._stackLayers=function(){var t,n,e,r,i,o,a;if((r=this.getVisibleLayers()).length>0){for(o=[],t=n=0,i=r[0].values.length;0<=i?n<i:n>i;t=0<=i?++n:--n)a=0,o.push(function(){var n,i,o;for(o=[],i=0,n=r.length;i<n;i++)(e=r[i]).values[t].y0=a,o.push(a+=e.values[t].y);return o}());return o}},n.prototype._prepareLayers=function(t){var n,e,r;for(e in r=0,t)a.call(t,e)&&(n=t[e],this.data[e].visible&&(n.y0=r,r+=n.y));return t},n.prototype.setData=function(t){return n.__super__.setData.call(this,t),this._stackLayers()},n.prototype.extent=function(){var t,n,e,r,i,o,a,u,s,l;if(o=(a=[0,this.getVisibleLayers()])[0],!(r=a[1]).length)return[0,0];for(t=e=0,u=r[0].values.length;0<=u?e<u:e>u;t=0<=u?++e:--e){for(l=0,n=i=0,s=r.length;0<=s?i<s:i>s;n=0<=s?++i:--i)l+=r[n].values[t].y;l>o&&(o=l)}return[0,o]},n.prototype.layerChanged=function(){var t,e,r,i;for(this._stackLayers(),t=0,r=(i=this._queue).length;t<r;t++)e=i[t],this._prepareLayers(e);return n.__super__.layerChanged.call(this)},n}(Epoch.Time.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Area=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="time.area"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype.setStyles=function(t){var n;if(n=null!=t&&null!=t.className?this.getStyles("g."+t.className.replace(/\s/g,".")+" path.area"):this.getStyles("g path.area"),this.ctx.fillStyle=n.fill,null!=n.stroke&&(this.ctx.strokeStyle=n.stroke),null!=n["stroke-width"])return this.ctx.lineWidth=n["stroke-width"].replace("px","")},n.prototype._drawAreas=function(t){var n,e,r,i,o,a,u,s,l,c,h,f,p,g,d,y;for(null==t&&(t=0),y=(c=[this.y(),this.w(),this.getVisibleLayers()])[0],d=c[1],p=[],i=u=h=(l=c[2]).length-1;h<=0?u<=0:u>=0;i=h<=0?++u:--u)if(s=l[i]){for(this.setStyles(s),this.ctx.beginPath(),o=(f=[this.options.windowSize,s.values.length,this.inTransition()])[0],a=f[1],g=f[2];--o>=-2&&--a>=0;)n=[(o+1)*d+t,y((r=s.values[a]).y+r.y0)],g&&(n[0]+=d),i===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);e=g?(o+3)*d+t:(o+2)*d+t,this.ctx.lineTo(e,this.innerHeight()),this.ctx.lineTo(this.width*this.pixelRatio+d+t,this.innerHeight()),this.ctx.closePath(),p.push(this.ctx.fill())}return p},n.prototype._drawStrokes=function(t){var n,e,r,i,o,a,u,s,l,c,h,f,p,g;for(null==t&&(t=0),g=(s=[this.y(),this.w(),this.getVisibleLayers()])[0],p=s[1],h=[],r=o=l=(u=s[2]).length-1;l<=0?o<=0:o>=0;r=l<=0?++o:--o)if(a=u[r]){for(this.setStyles(a),this.ctx.beginPath(),r=(c=[this.options.windowSize,a.values.length,this.inTransition()])[0],i=c[1],f=c[2];--r>=-2&&--i>=0;)n=[(r+1)*p+t,g((e=a.values[i]).y+e.y0)],f&&(n[0]+=p),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);h.push(this.ctx.stroke())}return h},n.prototype.draw=function(t){return null==t&&(t=0),this.clear(),this._drawAreas(t),this._drawStrokes(t),n.__super__.draw.call(this)},n}(Epoch.Time.Stack),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Bar=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="time.bar"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},n.prototype.setStyles=function(t){var n;if(n=this.getStyles("rect.bar."+t.replace(/\s/g,".")),this.ctx.fillStyle=n.fill,null==n.stroke||"none"===n.stroke?this.ctx.strokeStyle="transparent":this.ctx.strokeStyle=n.stroke,null!=n["stroke-width"])return this.ctx.lineWidth=n["stroke-width"].replace("px","")},n.prototype.draw=function(t){var e,r,i,o,a,u,s,l,c,h,f,p,g,d,y,v,m;for(null==t&&(t=0),this.clear(),m=(f=[this.y(),this.w()])[0],v=f[1],s=0,h=(p=this.getVisibleLayers()).length;s<h;s++)if(c=p[s],Epoch.isNonEmptyArray(c.values))for(this.setStyles(c.className),a=(g=[this.options.windowSize,c.values.length,this.inTransition()])[0],l=g[1],u=(y=g[2])?-1:0;--a>=u&&--l>=0;)i=(d=[a*v+t,(r=c.values[l]).y,r.y0])[0],y&&(i+=v),e=[i+1,m((o=d[1])+d[2]),v-2,this.innerHeight()-m(o)+.5*this.pixelRatio],this.ctx.fillRect.apply(this.ctx,e),this.ctx.strokeRect.apply(this.ctx,e);return n.__super__.draw.call(this)},n}(Epoch.Time.Stack),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Gauge=function(t){var n,e;function r(t){var i;this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.value=this.options.value||0,this.options.model&&this.options.model.on("data:push",(i=this,function(){return i.pushFromModel()})),"absolute"!==this.el.style("position")&&"relative"!==this.el.style("position")&&this.el.style("position","relative"),this.svg=this.el.insert("svg",":first-child").attr("width",this.width).attr("height",this.height).attr("class","gauge-labels"),this.svg.style({position:"absolute","z-index":"1"}),this.svg.append("g").attr("transform","translate("+this.textX()+", "+this.textY()+")").append("text").attr("class","value").text(this.options.format(this.value)),this.animation={interval:null,active:!1,delta:0,target:0},this._animate=function(t){return function(){return Math.abs(t.animation.target-t.value)<Math.abs(t.animation.delta)?(t.value=t.animation.target,clearInterval(t.animation.interval),t.animation.active=!1):t.value+=t.animation.delta,t.svg.select("text.value").text(t.options.format(t.value)),t.draw()}}(this),this.onAll(e),this.draw()}return s(r,t),n={type:"time.gauge",domain:[0,1],ticks:10,tickSize:5,tickOffset:5,fps:34,format:Epoch.Formats.percent},e={"option:domain":"domainChanged","option:ticks":"ticksChanged","option:tickSize":"tickSizeChanged","option:tickOffset":"tickOffsetChanged","option:format":"formatChanged"},r.prototype.update=function(t){if(this.animation.target=t,this.animation.delta=(t-this.value)/this.options.fps,!this.animation.active)return this.animation.interval=setInterval(this._animate,1e3/this.options.fps),this.animation.active=!0},r.prototype.push=function(t){return this.update(t)},r.prototype.pushFromModel=function(){var t;return t=this.options.model.getNext(this.options.type,this.options.dataFormat),this.update(t)},r.prototype.radius=function(){return this.getHeight()/1.58},r.prototype.centerX=function(){return this.getWidth()/2},r.prototype.centerY=function(){return.68*this.getHeight()},r.prototype.textX=function(){return this.width/2},r.prototype.textY=function(){return.48*this.height},r.prototype.getAngle=function(t){var n,e;return(t-(n=(e=this.options.domain)[0]))/(e[1]-n)*(Math.PI+2*Math.PI/8)-Math.PI/2-Math.PI/8},r.prototype.setStyles=function(t){var n;if(n=this.getStyles(t),this.ctx.fillStyle=n.fill,this.ctx.strokeStyle=n.stroke,null!=n["stroke-width"])return this.ctx.lineWidth=n["stroke-width"].replace("px","")},r.prototype.draw=function(){var t,n,e,i,o,a,u,s,l,c,h,f,p,g,d,y,v,m,x;for(e=(s=[this.centerX(),this.centerY(),this.radius()])[0],i=s[1],u=s[2],g=(l=[this.options.tickOffset,this.options.tickSize])[0],d=l[1],this.clear(),p=d3.scale.linear().domain([0,this.options.ticks]).range([-9/8*Math.PI,Math.PI/8]),this.setStyles(".epoch .gauge .tick"),this.ctx.beginPath(),o=a=0,c=this.options.ticks;0<=c?a<=c:a>=c;o=0<=c?++a:--a)t=p(o),y=(n=(h=[Math.cos(t),Math.sin(t)])[0])*(u-g)+e,m=(f=h[1])*(u-g)+i,v=n*(u-g-d)+e,x=f*(u-g-d)+i,this.ctx.moveTo(y,m),this.ctx.lineTo(v,x);return this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.outer"),this.ctx.beginPath(),this.ctx.arc(e,i,u,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.inner"),this.ctx.beginPath(),this.ctx.arc(e,i,u-10,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.drawNeedle(),r.__super__.draw.call(this)},r.prototype.drawNeedle=function(){var t,n,e,r;return t=(r=[this.centerX(),this.centerY(),this.radius()])[0],n=r[1],e=r[2],this.value,this.options.domain[1],this.setStyles(".epoch .gauge .needle"),this.ctx.beginPath(),this.ctx.save(),this.ctx.translate(t,n),this.ctx.rotate(this.getAngle(this.value)),this.ctx.moveTo(4*this.pixelRatio,0),this.ctx.lineTo(-4*this.pixelRatio,0),this.ctx.lineTo(-1*this.pixelRatio,19-e),this.ctx.lineTo(1,19-e),this.ctx.fill(),this.setStyles(".epoch .gauge .needle-base"),this.ctx.beginPath(),this.ctx.arc(0,0,this.getWidth()/25,0,2*Math.PI),this.ctx.fill(),this.ctx.restore()},r.prototype.domainChanged=function(){return this.draw()},r.prototype.ticksChanged=function(){return this.draw()},r.prototype.tickSizeChanged=function(){return this.draw()},r.prototype.tickOffsetChanged=function(){return this.draw()},r.prototype.formatChanged=function(){return this.svg.select("text.value").text(this.options.format(this.value))},r}(Epoch.Chart.Canvas),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Heatmap=function(t){var n,e,r;function i(t){this.options=null!=t?t:{},i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this._setOpacityFunction(),this._setupPaintCanvas(),this.onAll(r),this.draw()}return s(i,t),e={type:"time.heatmap",buckets:10,bucketRange:[0,100],opacity:"linear",bucketPadding:2,paintZeroValues:!1,cutOutliers:!1},n={root:function(t,n){return Math.pow(t/n,.5)},linear:function(t,n){return t/n},quadratic:function(t,n){return Math.pow(t/n,2)},cubic:function(t,n){return Math.pow(t/n,3)},quartic:function(t,n){return Math.pow(t/n,4)},quintic:function(t,n){return Math.pow(t/n,5)}},r={"option:buckets":"bucketsChanged","option:bucketRange":"bucketRangeChanged","option:opacity":"opacityChanged","option:bucketPadding":"bucketPaddingChanged","option:paintZeroValues":"paintZeroValuesChanged","option:cutOutliers":"cutOutliersChanged"},i.prototype._setOpacityFunction=function(){return Epoch.isString(this.options.opacity)?(this._opacityFn=n[this.options.opacity],null==this._opacityFn?Epoch.exception("Unknown coloring function provided '"+this.options.opacity+"'"):void 0):Epoch.isFunction(this.options.opacity)?this._opacityFn=this.options.opacity:Epoch.exception("Unknown type for provided coloring function.")},i.prototype.setData=function(t){var n,e,r,o,a;for(i.__super__.setData.call(this,t),a=[],n=0,r=(o=this.data).length;n<r;n++)e=o[n],a.push(e.values=e.values.map(function(t){return function(n){return t._prepareEntry(n)}}(this)));return a},i.prototype._getBuckets=function(t){var n,e,r,i,o,u,s,l,c;for(c in u={time:t.time,max:0,buckets:function(){var t,n,e;for(e=[],r=t=0,n=this.options.buckets;0<=n?t<n:t>n;r=0<=n?++t:--t)e.push(0);return e}.call(this)},n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,s=t.histogram)a.call(s,c)&&(e=s[c],i=parseInt((c-this.options.bucketRange[0])/n),this.options.cutOutliers&&(i<0||i>=this.options.buckets)||(i<0?i=0:i>=this.options.buckets&&(i=this.options.buckets-1),u.buckets[i]+=parseInt(e)));for(r=o=0,l=u.buckets.length;0<=l?o<l:o>l;r=0<=l?++o:--o)u.max=Math.max(u.max,u.buckets[r]);return u},i.prototype.y=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight(),0])},i.prototype.ySvg=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.h=function(){return this.innerHeight()/this.options.buckets},i.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},i.prototype._setupPaintCanvas=function(){return this.paintWidth=(this.options.windowSize+1)*this.w(),this.paintHeight=this.height*this.pixelRatio,this.paint=document.createElement("CANVAS"),this.paint.width=this.paintWidth,this.paint.height=this.paintHeight,this.p=Epoch.Util.getContext(this.paint),this.redraw(),this.on("after:shift","_paintEntry"),this.on("transition:end","_shiftPaintCanvas"),this.on("transition:end",(t=this,function(){return t.draw(t.animation.frame*t.animation.delta())}));var t},i.prototype.redraw=function(){var t,n;if(Epoch.isNonEmptyArray(this.data)&&Epoch.isNonEmptyArray(this.data[0].values)){for(n=this.data[0].values.length,t=this.options.windowSize,this.inTransition()&&t++;--n>=0&&--t>=0;)this._paintEntry(n,t);return this.draw(this.animation.frame*this.animation.delta())}},i.prototype._computeColor=function(t,n,e){return Epoch.Util.toRGBA(e,this._opacityFn(t,n))},i.prototype._paintEntry=function(t,n){var e,r,i,o,u,s,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E;for(null==t&&(t=null),null==n&&(n=null),k=(m=[this.w(),this.h()])[0],l=m[1],null==t&&(t=this.data[0].values.length-1),null==n&&(n=this.options.windowSize),u=[],r=function(){var t,n,e;for(e=[],t=0,n=this.options.buckets;0<=n?t<n:t>n;0<=n?++t:--t)e.push(0);return e}.call(this),v=0,h=0,p=(x=this.getVisibleLayers()).length;h<p;h++){for(e in f=x[h],_=(s=this._getBuckets(f.values[t])).buckets)a.call(_,e)&&(o=_[e],r[e]+=o);v+=s.max,b=this.getStyles("."+f.className.split(" ").join(".")+" rect.bucket"),s.color=b.fill,u.push(s)}for(e in E=n*k,this.p.clearRect(E,0,k,this.paintHeight),c=this.options.buckets,w=[],r)if(a.call(r,e)){for(M=r[e],i=this._avgLab(u,e),y=0,d=0,g=u.length;d<g;d++)y+=(s=u[d]).buckets[e]/M*v;(M>0||this.options.paintZeroValues)&&(this.p.fillStyle=this._computeColor(M,y,i),this.p.fillRect(E,(c-1)*l,k-this.options.bucketPadding,l-this.options.bucketPadding)),w.push(c--)}return w},i.prototype._shiftPaintCanvas=function(){var t;return t=this.p.getImageData(this.w(),0,this.paintWidth-this.w(),this.paintHeight),this.p.putImageData(t,0,0)},i.prototype._avgLab=function(t,n){var e,r,i,o,u,s,l,c,h,f,p;for(l=(f=[0,0,0,0])[0],e=f[1],r=f[2],p=f[3],s=0,c=t.length;s<c;s++)null!=(o=t[s]).buckets[n]&&(p+=o.buckets[n]);for(u in t)a.call(t,u)&&(l+=(h=(null!=(o=t[u]).buckets[n]?0|o.buckets[n]:0)/p)*(i=d3.lab(o.color)).l,e+=h*i.a,r+=h*i.b);return d3.lab(l,e,r).toString()},i.prototype.draw=function(t){return null==t&&(t=0),this.clear(),this.ctx.drawImage(this.paint,t,0),i.__super__.draw.call(this)},i.prototype.bucketsChanged=function(){return this.redraw()},i.prototype.bucketRangeChanged=function(){return this._transitionRangeAxes(),this.redraw()},i.prototype.opacityChanged=function(){return this._setOpacityFunction(),this.redraw()},i.prototype.bucketPaddingChanged=function(){return this.redraw()},i.prototype.paintZeroValuesChanged=function(){return this.redraw()},i.prototype.cutOutliersChanged=function(){return this.redraw()},i.prototype.layerChanged=function(){return this.redraw()},i}(Epoch.Time.Plot),s=function(t,n){for(var e in n)a.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},a={}.hasOwnProperty,Epoch.Time.Line=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="time.line"),n.__super__.constructor.call(this,this.options),this.draw()}return s(n,t),n.prototype.setStyles=function(t){var n;return n=this.getStyles("g."+t.replace(/\s/g,".")+" path.line"),this.ctx.fillStyle=n.fill,this.ctx.strokeStyle=n.stroke,this.ctx.lineWidth=this.pixelRatio*n["stroke-width"].replace("px","")},n.prototype.draw=function(t){var e,r,i,o,a,u,s,l,c,h,f;for(null==t&&(t=0),this.clear(),h=this.w(),i=0,u=(s=this.getVisibleLayers()).length;i<u;i++)if(a=s[i],Epoch.isNonEmptyArray(a.values)){for(this.setStyles(a.className),this.ctx.beginPath(),f=this.y(a.range),r=(l=[this.options.windowSize,a.values.length,this.inTransition()])[0],o=l[1],c=l[2];--r>=-2&&--o>=0;)e=[(r+1)*h+t,f(a.values[o].y)],c&&(e[0]+=h),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,e):this.ctx.lineTo.apply(this.ctx,e);this.ctx.stroke()}return n.__super__.draw.call(this)},n}(Epoch.Time.Plot),Epoch._typeMap={area:Epoch.Chart.Area,bar:Epoch.Chart.Bar,line:Epoch.Chart.Line,pie:Epoch.Chart.Pie,scatter:Epoch.Chart.Scatter,histogram:Epoch.Chart.Histogram,"time.area":Epoch.Time.Area,"time.bar":Epoch.Time.Bar,"time.line":Epoch.Time.Line,"time.gauge":Epoch.Time.Gauge,"time.heatmap":Epoch.Time.Heatmap},m=function(t){return t.fn.epoch=function(t){var n,e;return t.el=this.get(0),null==(n=this.data("epoch-chart"))&&(null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",n=new e(t))),n}},null!=window.jQuery&&m(jQuery),x=function(){return Element.implement("epoch",(function(t){var n,e,r;return null==(n=(r=$$(this)).retrieve("epoch-chart")[0])&&(t.el=this,null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),r.store("epoch-chart",n=new e(t))),n}))},null!=window.MooTools&&x(),_=function(t){var n,e,r;return e={},n=0,r=function(){return"epoch-chart-"+ ++n},t.extend(t.fn,{epoch:function(t){var n,i,o;return null!=(i=this.data("epoch-chart"))?e[i]:(t.el=this.get(0),null==(o=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",i=r()),n=new o(t),e[i]=n,n)}})},null!=window.Zepto&&_(Zepto); |