mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-08 14:38:28 +01:00
1 line
221 KiB
JavaScript
1 line
221 KiB
JavaScript
var base1,base2,base3;(function(){var t,n;t=class extends OS.application.BaseService{constructor(t){super("SysmondService",t),this.text=__("{0}%",(0).toString()),this.iconclass="fa fa-android",this.app=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,s,u,l,c,h,f;if(o=0,l=$(this.find(t+"-text")),!this[t]){for(f={type:"time.line",axes:["bottom","left","right"]},e&&(f.range=e),i=[],s=0,c=n.length;s<c;s++)a=n[s],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(u=0,h=n.length;u<h;u++)a=n[u],$(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,s,u,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,u=[{time:p,y:x.toFixed(3)},{time:p,y:_.toFixed(3)}],l=[0,v>m?v:m],this.streamline("memory",u,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,s=(d=t.net).length;o<s;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,s=a.setAttribute,u=a.setAttributeNS,l=this.CSSStyleDeclaration.prototype,c=l.setProperty;a.setAttribute=function(t,n){s.call(this,t,n+"")},a.setAttributeNS=function(t,n,e){u.call(this,t,n,e+"")},l.setProperty=function(t,n,e){c.call(this,t,n+"",e)}}function h(t,n){return 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,s=-1,u=0;if(1===arguments.length)for(;++s<i;)p(e=f(t[s]))&&(a+=(r=e-o)*(e-(o+=r/++u)));else for(;++s<i;)p(e=f(n.call(t,t[s],s)))&&(a+=(r=e-o)*(e-(o+=r/++u)));if(u>1)return a/(u-1)},t.deviation=function(){var n=t.variance.apply(this,arguments);return n?Math.sqrt(n):n};var d=g(h);function y(t){return t.length}t.bisectLeft=d.left,t.bisect=t.bisectRight=d.right,t.bisector=function(t){return g(1===t.length?function(n,e){return h(t(n),e)}:t)},t.shuffle=function(t,n,e){(o=arguments.length)<3&&(e=t.length,o<2&&(n=0));for(var r,i,o=e-n;o;)i=Math.random()*o--|0,r=t[o+n],t[o+n]=t[i+n],t[i+n]=r;return t},t.permute=function(t,n){for(var e=n.length,r=new Array(e);e--;)r[e]=t[n[e]];return r},t.pairs=function(t){for(var n=0,e=t.length-1,r=t[0],i=new Array(e<0?0:e);n<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,s=i[e]=new Array(o);++a<o;)s[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 P(t,n){if(n in t)return n;n=n.charAt(0).toUpperCase()+n.slice(1);for(var e=0,r=F.length;e<r;++e){var i=F[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,s){if(s>=i.length)return e?e.call(r,o):n?o.sort(n):o;for(var u,l,c,h,f=-1,p=o.length,g=i[s++],d=new _;++f<p;)(h=d.get(u=g(l=o[f])))?h.push(l):d.set(u,[l]);return t?(l=t(),c=function(n,e){l.set(n,a(t,e,s))}):(l={},c=function(n,e){l[n]=a(t,e,s)}),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 F=["webkit","ms","moz","Moz","o","O"];function L(){}function z(){}function D(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 R(){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 z,r=0,i=arguments.length;++r<i;)e[arguments[r]]=D(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 z,n=-1,e=arguments.length;++n<e;)t[arguments[n]]=D(t);return t},z.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 j(t){return I(t,$),t}var H=function(t,n){return n.querySelector(t)},V=function(t,n){return n.querySelectorAll(t)},B=function(t,n){var e=t.matches||t[P(t,"matchesSelector")];return(B=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(H=function(t,n){return Sizzle(t,n)[0]||null},V=Sizzle,B=Sizzle.matchesSelector),t.selection=function(){return t.select(r.documentElement)};var $=t.selection.prototype=[];function Y(t){return"function"==typeof t?t:function(){return H(t,this)}}function W(t){return"function"==typeof t?t:function(){return V(t,this)}}$.select=function(t){var n,e,r,i,o=[];t=Y(t);for(var a=-1,s=this.length;++a<s;){o.push(n=[]),n.parentNode=(r=this[a]).parentNode;for(var u=-1,l=r.length;++u<l;)(i=r[u])?(n.push(e=t.call(i,i.__data__,u,a)),e&&"__data__"in i&&(e.__data__=i.__data__)):n.push(null)}return j(o)},$.selectAll=function(t){var n,r,i=[];t=W(t);for(var o=-1,a=this.length;++o<a;)for(var s=this[o],u=-1,l=s.length;++u<l;)(r=s[u])&&(i.push(n=e(t.call(r,r.__data__,u,o))),n.parentNode=r);return j(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 st(t){return function(){return B(this,t)}}function ut(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,s=o.length;a<s;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,s.push(p),u.push(f),l.push(g)}var s=ct([]),u=j([]),l=j([]);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 u.enter=function(){return s},u.exit=function(){return l},u},$.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=st(t));for(var o=0,a=this.length;o<a;o++){i.push(n=[]),n.parentNode=(e=this[o]).parentNode;for(var s=0,u=e.length;s<u;s++)(r=e[s])&&t.call(r,r.__data__,s,o)&&n.push(r)}return j(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=ut.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,s=t[o].update,u=s.length;for(o!=e&&(e=o,n=0),i>=n&&(n=i+1);!(a=s[n])&&++n<u;);return a}}function pt(n,r,i){var o="__on"+n,a=n.indexOf("."),s=dt;a>0&&(n=n.slice(0,a));var u=gt.get(n);function l(){var t=this[o];t&&(this.removeEventListener(n,t,t.$),delete this[o])}return u&&(n=u,s=yt),a?r?function(){var t=s(r,e(arguments));l.call(this),this.addEventListener(n,this[o]=t,t.$=i),t._=r}:l:r?L:function(){var e,r=new RegExp("^__on([^.]+)"+t.requote(n)+"$");for(var i in this)if(e=i.match(r)){var o=this[i];this.removeEventListener(e[1],o,o.$),delete this[i]}}}t.selection.enter=ct,t.selection.enter.prototype=ht,ht.append=$.append,ht.empty=$.empty,ht.node=$.node,ht.call=$.call,ht.size=$.size,ht.select=function(t){for(var n,e,r,i,o,a=[],s=-1,u=this.length;++s<u;){r=(i=this[s]).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,s)),e.__data__=o.__data__):n.push(null)}return j(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=[H(t,r)]).parentNode=r.documentElement:(n=[t]).parentNode=i(t),j([n])},t.selectAll=function(t){var n;return"string"==typeof t?(n=e(V(t,r))).parentNode=r.documentElement:(n=e(t)).parentNode=null,j([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,R).on("dragstart"+e,R).on("selectstart"+e,R);if(null==vt&&(vt=!("onselectstart"in n)&&P(n.style,"userSelect")),vt){var s=i(n).style,u=s[vt];s[vt]="none"}return function(t){if(a.on(e,null),vt&&(s[vt]=u),t){var n=function(){a.on(r,null)};a.on(r,(function(){R(),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 s=(r=t.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important"))[0][0].getScreenCTM();_t=!(s.f||s.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 u=n.getBoundingClientRect();return[e.clientX-u.left-n.clientLeft,e.clientY-u.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=s(L,t.mouse,o,"mousemove","mouseup"),i=s(bt,t.touch,N,"touchmove","touchend");function a(){this.on("mousedown.drag",r).on("touchstart.drag",i)}function s(r,i,o,a,s){return function(){var u,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(s+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]+u[0],y:e[1]+u[1],dx:t,dy:n}))}function _(){i(h,g)&&(y.on(a+d,null).on(s+d,null),v(p),f({type:"dragend"}))}u=e?[(u=e.apply(l,arguments)).x-m[0],u.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 Pt(t){return t>0?1:t<0?-1:0}function Ft(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function Lt(t){return t>1?0:t<-1?Et:Math.acos(t)}function zt(t){return t>1?Ct:t<-1?-Ct:Math.asin(t)}function Dt(t){return((t=Math.exp(t))+1/t)/2}function Rt(t){return(t=Math.sin(t/2))*t}var qt=Math.SQRT2;t.interpolateZoom=function(t,n){var e,r,i=t[0],o=t[1],a=t[2],s=n[0],u=n[1],l=n[2],c=s-i,h=u-o,f=c*c+h*h;if(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,s=Dt(y),u=a/(2*p)*(s*(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+u*c,o+u*h,a*s/Dt(qt*e+y)]}}return e.duration=1e3*r,e},t.behavior.zoom=function(){var n,e,i,a,s,u,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,P).on(Ot+".zoom",L).on("dblclick.zoom",z).on(_,F)}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(u.range().map((function(t){return(t-f.x)/f.k})).map(u.invert)),h&&h.domain(c.range().map((function(t){return(t-f.y)/f.k})).map(c.invert))}function C(t){y++||t({type:"zoomstart"})}function N(t){A(),t({type:"zoom",scale:f.k,translate:[f.x,f.y]})}function T(t){--y||(t({type:"zoomend"}),e=null)}function P(){var n=this,e=w.of(n,arguments),r=0,i=t.select(o(n)).on(m,u).on(x,l),a=M(t.mouse(n)),s=xt(n);function u(){r=1,E(t.mouse(n),a),N(e)}function l(){i.on(m,null).on(x,null),s(r),T(e)}ds.call(n),C(e)}function F(){var n,e=this,r=w.of(e,arguments),i={},o=0,a=".zoom-"+t.event.changedTouches[0].identifier,u="touchmove"+a,l="touchend"+a,c=[],h=t.select(e),p=xt(e);function g(){var r=t.touches(e);return n=f.k,r.forEach((function(t){t.identifier in i&&(i[t.identifier]=M(t))})),r}function d(){var n=t.event.target;t.select(n).on(u,y).on(l,m),c.push(n);for(var r=t.event.changedTouches,a=0,h=r.length;a<h;++a)i[r[a].identifier]=null;var p=g(),d=Date.now();if(1===p.length){if(d-s<500){var v=p[0];S(e,v,i[v.identifier],Math.floor(Math.log(f.k)/Math.LN2)+1),R()}s=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,u,l,c,h=t.touches(e);ds.call(e);for(var f=0,p=h.length;f<p;++f,c=null)if(l=h[f],c=i[l.identifier]){if(u)break;a=l,u=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],u=[(u[0]+c[0])/2,(u[1]+c[1])/2],k(d*n)}s=null,E(a,u),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 s in i)return void g()}t.selectAll(c).on(a,null),h.on(v,P).on(_,F),p(),T(r)}d(),C(r),h.on(v,null).on(_,d)}function L(){var r=w.of(this,arguments);a?clearTimeout(a):(ds.call(this),n=M(e=i||t.mouse(this)),C(r)),a=setTimeout((function(){a=null,T(r)}),50),R(),k(Math.pow(2,.002*Ut())*f.k),E(e,n),N(r)}function z(){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;ms?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,s=e?e[1]:o/2,u=t.interpolateZoom([(a-f.x)/f.k,(s-f.y)/f.k,i/f.k],[(a-r.x)/r.k,(s-r.y)/r.k,i/r.k]);return function(t){var e=u(t),r=i/e[2];this.__chart__=f={x:a-e[0]*r,y:s-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,u=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 jt(){}function Ht(t,n,e){return this instanceof Ht?(this.h=+t,this.s=+n,void(this.l=+e)):arguments.length<2?t instanceof Ht?new Ht(t.h,t.s,t.l):un(""+t,ln,Ht):new Ht(t,n,e)}t.color=jt,jt.prototype.toString=function(){return this.rgb()+""},t.hsl=Ht;var Vt=Ht.prototype=new jt;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 Ht(this.h,this.s,this.l/t)},Vt.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new Ht(this.h,this.s,t*this.l)},Vt.rgb=function(){return Bt(this.h,this.s,this.l)},t.hcl=$t;var Yt=$t.prototype=new jt;function Wt(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),new Zt(e,Math.cos(t*=Nt)*n,Math.sin(t)*n)}function Zt(t,n,e){return this instanceof Zt?(this.l=+t,this.a=+n,void(this.b=+e)):arguments.length<2?t instanceof Zt?new Zt(t.l,t.a,t.b):t instanceof $t?Wt(t.h,t.c,t.l):cn((t=en(t)).r,t.g,t.b):new Zt(t,n,e)}Yt.brighter=function(t){return new $t(this.h,this.c,Math.min(100,this.l+Xt*(arguments.length?t:1)))},Yt.darker=function(t){return new $t(this.h,this.c,Math.max(0,this.l-Xt*(arguments.length?t:1)))},Yt.rgb=function(){return Wt(this.h,this.c,this.l).rgb()},t.lab=Zt;var Xt=18,Gt=Zt.prototype=new jt;function Qt(t,n,e){var r=(t+16)/116,i=r+n/500,o=r-e/200;return new en(nn(3.2404542*(i=.95047*Kt(i))-1.5371385*(r=1*Kt(r))-.4985314*(o=1.08883*Kt(o))),nn(-.969266*i+1.8760108*r+.041556*o),nn(.0556434*i-.2040259*r+1.0572252*o))}function Jt(t,n,e){return t>0?new $t(Math.atan2(e,n)*Tt,Math.sqrt(n*n+e*e),t):new $t(NaN,NaN,t)}function Kt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function tn(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function nn(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function en(t,n,e){return this instanceof en?(this.r=~~t,this.g=~~n,void(this.b=~~e)):arguments.length<2?t instanceof en?new en(t.r,t.g,t.b):un(""+t,en,Bt):new en(t,n,e)}function rn(t){return new en(t>>16,t>>8&255,255&t)}function on(t){return rn(t)+""}Gt.brighter=function(t){return new Zt(Math.min(100,this.l+Xt*(arguments.length?t:1)),this.a,this.b)},Gt.darker=function(t){return new Zt(Math.max(0,this.l-Xt*(arguments.length?t:1)),this.a,this.b)},Gt.rgb=function(){return Qt(this.l,this.a,this.b)},t.rgb=en;var an=en.prototype=new jt;function sn(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function un(t,n,e){var r,i,o,a=0,s=0,u=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return n(fn(i[0]),fn(i[1]),fn(i[2]))}return(o=pn.get(t))?n(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(a=(3840&o)>>4,a|=a>>4,s=240&o,s|=s>>4,u=15&o,u|=u<<4):7===t.length&&(a=(16711680&o)>>16,s=(65280&o)>>8,u=255&o)),n(a,s,u))}function ln(t,n,e){var r,i,o=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),s=a-o,u=(a+o)/2;return s?(i=u<.5?s/(a+o):s/(2-a-o),r=t==a?(n-e)/s+(n<e?6:0):n==a?(e-t)/s+2:(t-n)/s+4,r*=60):(r=NaN,i=u>0&&u<1?0:r),new Ht(r,i,u)}function cn(t,n,e){var r=tn((.4124564*(t=hn(t))+.3575761*(n=hn(n))+.1804375*(e=hn(e)))/.95047),i=tn((.2126729*t+.7151522*n+.072175*e)/1);return Zt(116*i-16,500*(r-i),200*(i-tn((.0193339*t+.119192*n+.9503041*e)/1.08883)))}function hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function fn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}an.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&n<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"#"+sn(this.r)+sn(this.g)+sn(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={},s=t.dispatch("beforesend","progress","load","error"),u={},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 s.error.call(a,t)}s.load.call(a,t)}else s.error.call(a,l)}return this.XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(n)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=h:l.onreadystatechange=function(){l.readyState>3&&h()},l.onprogress=function(n){var e=t.event;t.event=n;try{s.progress.call(a,l)}finally{t.event=e}},a.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?u[t]:(null==n?delete u[t]:u[t]=n+"",a)},a.mimeType=function(t){return arguments.length?(r=null==t?null:t+"",a):r},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return i=t,a},["get","post"].forEach((function(t){a[t]=function(){return a.send.apply(a,[t].concat(e(arguments)))}})),a.send=function(t,e,i){if(2===arguments.length&&"function"==typeof e&&(i=e,e=null),l.open(t,n,!0),null==r||"accept"in u||(u.accept=r+",*/*"),l.setRequestHeader)for(var o in u)l.setRequestHeader(o,u[o]);return null!=r&&l.overrideMimeType&&l.overrideMimeType(r),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",(function(t){i(null,t)})),s.beforesend.call(a,l),l.send(null==e?null:e),a},a.abort=function(){return l.abort(),a},t.rebind(a,s,"on"),null==o?a:a.get(function(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}(o))}pn.forEach((function(t,n){pn.set(t,rn(n))})),t.functor=gn,t.xhr=dn(N),t.dsv=function(t,n){var e=new RegExp('["'+t+"\n]"),r=t.charCodeAt(0);function i(t,e,r){arguments.length<3&&(r=e,e=null);var i=yn(t,n,null==e?o:a(e),r);return i.row=function(t){return arguments.length?i.response(null==(e=t)?o:a(t)):e},i}function o(t){return i.parse(t.responseText)}function a(t){return function(n){return i.parse(n.responseText,t)}}function s(n){return n.map(u).join(t)}function u(t){return e.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}return i.parse=function(t,n){var e;return i.parseRows(t,(function(t,r){if(e)return e(t,r-1);var i=new Function("d","return {"+t.map((function(t,n){return JSON.stringify(t)+": d["+n+"]"})).join(",")+"}");e=n?function(t,e){return n(i(t),e)}:i}))},i.parseRows=function(t,n){var e,i,o={},a={},s=[],u=t.length,l=0,c=0;function h(){if(l>=u)return a;if(i)return i=!1,o;var n=l;if(34===t.charCodeAt(n)){for(var e=n;e++<u;)if(34===t.charCodeAt(e)){if(34!==t.charCodeAt(e+1))break;++e}return l=e+2,13===(s=t.charCodeAt(e+1))?(i=!0,10===t.charCodeAt(e+2)&&++l):10===s&&(i=!0),t.slice(n+1,e).replace(/""/g,'"')}for(;l<u;){var s,c=1;if(10===(s=t.charCodeAt(l++)))i=!0;else if(13===s)i=!0,10===t.charCodeAt(l)&&(++l,++c);else if(s!==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++))||s.push(f)}return s},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(u).join(t)].concat(n.map((function(n){return r.map((function(t){return u(n[t])})).join(t)}))).join("\n")},i.formatRows=function(t){return t.map(s).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[P(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,s=i[0],u=0;e>0&&s>0&&(u+s+1>n&&(s=Math.max(1,n-u)),o.push(t.substring(e-=s,e+s)),!((u+=s+1)>n));)s=i[a=(a+1)%i.length];return o.reverse().join(r)}:N;return function(n){var r=Nn.exec(n),i=r[1]||" ",s=r[2]||">",u=r[3]||"-",l=r[4]||"",c=r[5],h=+r[6],f=r[7],p=r[8],g=r[9],d=1,y="",v="",m=!1,x=!0;switch(p&&(p=+p.substring(1)),(c||"0"===i&&"="===s)&&(c=i="0",s="="),g){case"n":f=!0,g="g";break;case"%":d=100,v="%",g="f";break;case"p":d=100,v="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(y="0"+g.toLowerCase());case"c":x=!1;case"d":m=!0,p=0;break;case"s":d=-1,g="r"}"$"===l&&(y=o[0],v=o[1]),"r"!=g||p||(g="g"),null!=p&&("g"==g?p=Math.max(1,Math.min(21,p)):"e"!=g&&"f"!=g||(p=Math.max(0,Math.min(20,p)))),g=Tn.get(g)||Pn;var _=c&&f;return function(n){var r=v;if(m&&n%1)return"";var o=n<0||0===n&&1/n<0?(n=-n,"-"):"-"===u?"":u;if(d<0){var l=t.formatPrefix(n,p);n=l.scale(n),r=l.symbol+v}else n*=d;var w,b,M=(n=g(n,p)).lastIndexOf(".");if(M<0){var k=x?n.lastIndexOf("e"):-1;k<0?(w=n,b=""):(w=n.substring(0,k),b=n.substring(k))}else w=n.substring(0,M),b=e+n.substring(M+1);!c&&f&&(w=a(w,1/0));var E=y.length+w.length+b.length+(_?0:o.length),S=E<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,("<"===s?o+n+S:">"===s?S+o+n:"^"===s?S.substring(0,E>>=1)+o+n+S.substring(E):o+(_?n:S+n))+r}}}t.formatPrefix=function(n,e){var r=0;return(n=+n)&&(n<0&&(n*=-1),e&&(n=t.round(n,Sn(n,e))),r=1+Math.floor(1e-12+Math.log(n)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),An[8+r/3]};var Nn=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Tn=t.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(n,e){return(n=t.round(n,Sn(n,e))).toFixed(Math.max(0,Math.min(20,Sn(n*(1+1e-15),e))))}});function Pn(t){return t+""}var Fn=t.time={},Ln=Date;function zn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}zn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Dn.setUTCDate.apply(this._,arguments)},setDay:function(){Dn.setUTCDay.apply(this._,arguments)},setFullYear:function(){Dn.setUTCFullYear.apply(this._,arguments)},setHours:function(){Dn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Dn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Dn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Dn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Dn.setUTCSeconds.apply(this._,arguments)},setTime:function(){Dn.setTime.apply(this._,arguments)}};var Dn=Date.prototype;function Rn(t,n,e){function r(n){var e=t(n),r=o(e,1);return n-e<r-n?e:r}function i(e){return n(e=t(new Ln(e-1)),1),e}function o(t,e){return n(t=new Ln(+t),e),t}function a(t,r,o){var a=i(t),s=[];if(o>1)for(;a<r;)e(a)%o||s.push(new Date(+a)),n(a,1);else for(;a<r;)s.push(new Date(+a)),n(a,1);return s}t.floor=t,t.round=r,t.ceil=i,t.offset=o,t.range=a;var s=t.utc=qn(t);return s.floor=s,s.round=qn(r),s.ceil=qn(i),s.offset=qn(o),s.range=function(t,n,e){try{Ln=zn;var r=new zn;return r._=t,a(r,n,e)}finally{Ln=Date}},t}function qn(t){return function(n,e){try{Ln=zn;var r=new zn;return r._=n,t(r,e)._}finally{Ln=Date}}}function Un(n){var e=n.dateTime,r=n.date,i=n.time,o=n.periods,a=n.days,s=n.shortDays,u=n.months,l=n.shortMonths;function c(t){var n=t.length;function e(e){for(var r,i,o,a=[],s=-1,u=0;++s<n;)37===t.charCodeAt(s)&&(a.push(t.slice(u,s)),null!=(i=On[r=t.charAt(++s)])&&(r=t.charAt(++s)),(o=w[r])&&(r=o(e,null==i?"e"===r?" ":"0":i)),a.push(r),u=s+1);return a.push(t.slice(u,s)),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&&Ln!==zn,i=new(r?zn:Ln);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,s=0,u=n.length,l=e.length;s<u;){if(r>=l)return-1;if(37===(i=n.charCodeAt(s++))){if(a=n.charAt(s++),!(o=b[a in On?n.charAt(s++):a])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}c.utc=function(t){var n=c(t);function e(t){try{var e=new(Ln=zn);return e._=t,n(e)}finally{Ln=Date}}return e.parse=function(t){try{Ln=zn;var e=n.parse(t);return e&&e._}finally{Ln=Date}},e.toString=n.toString,e},c.multi=c.utc.multi=ae;var f=t.map(),p=Vn(a),g=Bn(a),d=Vn(s),y=Bn(s),v=Vn(u),m=Bn(u),x=Vn(l),_=Bn(l);o.forEach((function(t,n){f.set(t.toLowerCase(),n)}));var w={a:function(t){return s[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:c(e),d:function(t,n){return Hn(t.getDate(),n,2)},e:function(t,n){return Hn(t.getDate(),n,2)},H:function(t,n){return Hn(t.getHours(),n,2)},I:function(t,n){return Hn(t.getHours()%12||12,n,2)},j:function(t,n){return Hn(1+Fn.dayOfYear(t),n,3)},L:function(t,n){return Hn(t.getMilliseconds(),n,3)},m:function(t,n){return Hn(t.getMonth()+1,n,2)},M:function(t,n){return Hn(t.getMinutes(),n,2)},p:function(t){return o[+(t.getHours()>=12)]},S:function(t,n){return Hn(t.getSeconds(),n,2)},U:function(t,n){return Hn(Fn.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return Hn(Fn.mondayOfYear(t),n,2)},x:c(r),X:c(i),y:function(t,n){return Hn(t.getFullYear()%100,n,2)},Y:function(t,n){return Hn(t.getFullYear()%1e4,n,4)},Z:ie,"%":function(){return"%"}},b={a:function(t,n,e){d.lastIndex=0;var r=d.exec(n.slice(e));return r?(t.w=y.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(t,n,e){p.lastIndex=0;var r=p.exec(n.slice(e));return r?(t.w=g.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){x.lastIndex=0;var r=x.exec(n.slice(e));return r?(t.m=_.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(t,n,e){v.lastIndex=0;var r=v.exec(n.slice(e));return r?(t.m=m.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,n,e){return h(t,w.c.toString(),n,e)},d:Jn,e:Jn,H:te,I:te,j:Kn,L:re,m:Qn,M:ne,p:function(t,n,e){var r=f.get(n.slice(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)},S:ee,U:Yn,w:$n,W:Wn,x:function(t,n,e){return h(t,w.x.toString(),n,e)},X:function(t,n,e){return h(t,w.X.toString(),n,e)},y:Xn,Y:Zn,Z:Gn,"%":oe};return c}Fn.year=Rn((function(t){return(t=Fn.day(t)).setMonth(0,1),t}),(function(t,n){t.setFullYear(t.getFullYear()+n)}),(function(t){return t.getFullYear()})),Fn.years=Fn.year.range,Fn.years.utc=Fn.year.utc.range,Fn.day=Rn((function(t){var n=new Ln(2e3,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n}),(function(t,n){t.setDate(t.getDate()+n)}),(function(t){return t.getDate()-1})),Fn.days=Fn.day.range,Fn.days.utc=Fn.day.utc.range,Fn.dayOfYear=function(t){var n=Fn.year(t);return Math.floor((t-n-6e4*(t.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach((function(t,n){n=7-n;var e=Fn[t]=Rn((function(t){return(t=Fn.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t}),(function(t,n){t.setDate(t.getDate()+7*Math.floor(n))}),(function(t){var e=Fn.year(t).getDay();return Math.floor((Fn.dayOfYear(t)+(e+n)%7)/7)-(e!==n)}));Fn[t+"s"]=e.range,Fn[t+"s"].utc=e.utc.range,Fn[t+"OfYear"]=function(t){var e=Fn.year(t).getDay();return Math.floor((Fn.dayOfYear(t)+(e+n)%7)/7)}})),Fn.week=Fn.sunday,Fn.weeks=Fn.sunday.range,Fn.weeks.utc=Fn.sunday.utc.range,Fn.weekOfYear=Fn.sundayOfYear;var On={"-":"",_:" ",0:"0"},In=/^\s*\d+/,jn=/^%/;function Hn(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(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+Hn(r,"0",2)+Hn(i,"0",2)}function oe(t,n,e){jn.lastIndex=0;var r=jn.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function ae(t){for(var n=t.length,e=-1;++e<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 se=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 ue(){}t.format=se.numberFormat,t.geo={},ue.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 ue;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 ue,Ne={sphere:function(){ye+=4*Et},point:L,lineStart:L,lineEnd:L,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=L}};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,s=a*o,u=Math.cos(n),l=Math.sin(n),c=i*l,h=r*u+c*Math.cos(s),f=c*a*Math.sin(s);Ce.add(Math.atan2(f,h)),e=t,r=u,i=l}Ne.point=function(a,s){Ne.point=o,e=(t=a)*Nt,r=Math.cos(s=(n=s)*Nt/2+Et/4),i=Math.sin(s)},Ne.lineEnd=function(){o(t,n)}}function Pe(t){var n=t[0],e=t[1],r=Math.cos(e);return[r*Math.cos(n),r*Math.sin(n),Math.sin(e)]}function Fe(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Le(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function ze(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function De(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Re(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function qe(t){return[Math.atan2(t[1],t[0]),zt(t[2])]}function Ue(t,n){return v(t[0]-n[0])<Mt&&v(t[1]-n[1])<Mt}t.geo.bounds=function(){var n,e,r,i,o,a,s,u,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 s=Pe([t*Nt,a*Nt]);if(u){var l=Le(u,s),c=Le([l[1],-l[0],0],l);Re(c),c=qe(c);var h=t-o,f=h>0?1:-1,g=c[0]*Tt*f,d=v(h)>180;if(d^(f*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);u=s,o=t}function d(){f.point=g}function y(){h[0]=n,h[1]=r,f.point=p,u=null}function m(t,n){if(u){var e=t-o;l+=v(e)>180?e+(e>0?360:-360):e}else a=t,s=n;Ne.point(t,n),g(t,n)}function x(){Ne.lineStart()}function _(){m(a,s),Ne.lineEnd(),v(l)>Mt&&(n=-(r=180)),h[0]=n,h[1]=r,u=null}function w(t,n){return(n-=t)<0?n+360:n}function b(t,n){return t[0]-n[0]}function M(t,n){return n[0]<=n[1]?n[0]<=t&&t<=n[1]: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,s=[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])):s.push(d=p);for(var u,l,p,g=-1/0,d=(a=0,s[l=s.length-1]);a<=l;d=p,++a)p=s[a],(u=w(d[1],p[0]))>g&&(g=u,n=p[0],r=d[1])}return c=h=null,n===1/0||e===1/0?[[NaN,NaN],[NaN,NaN]]:[[n,e],[r,i]]}}(),t.geo.centroid=function(n){ve=me=xe=_e=we=be=Me=ke=Ee=Se=Ae=0,t.geo.stream(n,Oe);var e=Ee,r=Se,i=Ae,o=e*e+r*r+i*i;return o<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,zt(i/Math.sqrt(o))*Tt]};var Oe={sphere:L,point:Ie,lineStart:He,lineEnd:Ve,polygonStart:function(){Oe.lineStart=Be},polygonEnd:function(){Oe.lineStart=He}};function Ie(t,n){t*=Nt;var e=Math.cos(n*=Nt);je(e*Math.cos(t),e*Math.sin(t),Math.sin(n))}function je(t,n,e){++ve,xe+=(t-xe)/ve,_e+=(n-_e)/ve,we+=(e-we)/ve}function He(){var t,n,e;function r(r,i){r*=Nt;var o=Math.cos(i*=Nt),a=o*Math.cos(r),s=o*Math.sin(r),u=Math.sin(i),l=Math.atan2(Math.sqrt((l=n*u-e*s)*l+(l=e*a-t*u)*l+(l=t*s-n*a)*l),t*a+n*s+e*u);me+=l,be+=l*(t+(t=a)),Me+=l*(n+(n=s)),ke+=l*(e+(e=u)),je(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,je(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),s=o*Math.sin(t),u=Math.sin(n),l=r*u-i*s,c=i*a-e*u,h=e*s-r*a,f=Math.sqrt(l*l+c*c+h*h),p=e*a+r*s+i*u,g=f&&-Lt(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=s)),ke+=d*(i+(i=u)),je(e,r,i)}Oe.point=function(a,s){t=a,n=s,Oe.point=o,a*=Nt;var u=Math.cos(s*=Nt);e=u*Math.cos(a),r=u*Math.sin(a),i=Math.sin(s),je(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 s=0;s<n;++s)i.point((e=t[s])[0],e[1]);i.lineEnd()}else{var u=new Xe(e,t,null,!0),l=new Xe(e,null,u,!1);u.o=l,o.push(u),a.push(l),u=new Xe(r,t,null,!1),l=new Xe(r,null,u,!0),u.o=l,o.push(u),a.push(l)}}})),a.sort(n),Ze(o),Ze(a),o.length){for(var s=0,u=e,l=a.length;s<l;++s)a[s].e=u=!u;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(s=0,l=c.length;s<l;++s)i.point((h=c[s])[0],h[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(g)for(s=(c=p.p.z).length-1;s>=0;--s)i.point((h=c[s])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}c=(p=p.o).z,g=!g}while(!p.v);i.lineEnd()}}}function Ze(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r<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 s,u=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,s=[],d=[]},polygonEnd:function(){c.point=h,c.lineStart=p,c.lineEnd=g,s=t.merge(s);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 s=0,u=n.length;s<u;++s){var l=n[s],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=Le(Pe(h),Pe(t));Re(S);var A=Le(i,S);Re(A);var C=(k^w>=0?-1:1)*zt(A[2]);(r>C||r===C&&(S[0]||S[1]))&&(a+=k^w>=0?1:-1)}if(!y++)break;f=v,g=x,d=_,h=t}}return(o<-Mt||o<Mt&&Ce<-Mt)^1&a}(l,d);s.length?(x||(a.polygonStart(),x=!0),We(s,Ke,n,r,a)):n&&(x||(a.polygonStart(),x=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),x&&(a.polygonEnd(),x=!1),s=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);u.point(e[0],e[1])}function p(){c.point=f,u.lineStart()}function g(){c.point=h,u.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())),s.push(e.filter(Qe))}return c}}function Qe(t){return t.length>1}function Je(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:L,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function Ke(t,n){return((t=t.x)[0]<0?t[1]-Ct-Mt:Ct-t[1])-((n=n.x)[0]<0?n[1]-Ct-Mt:Ct-n[1])}var tr=Ge(Ye,(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var s=o>0?Et:-Et,u=v(o-e);v(u-Et)<Mt?(t.point(e,r=(r+a)/2>0?Ct:-Ct),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),n=0):i!==s&&u>=Et&&(v(e-i)<Mt&&(e-=i*Mt),v(o-s)<Mt&&(o-=s*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(s,r),n=0),t.point(e=o,r=a),i=s},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*Ct,r.point(-Et,i),r.point(0,i),r.point(Et,i),r.point(Et,0),r.point(Et,-i),r.point(0,-i),r.point(-Et,-i),r.point(-Et,0),r.point(-Et,i);else if(v(t[0]-n[0])>Mt){var o=t[0]<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,s,u,l,c;return{lineStart:function(){l=u=!1,c=1},point:function(h,f){var p,g=[h,f],d=i(h,f),y=e?d?0:a(h,f):d?a(h+(h<0?Et:-Et),f):0;if(!n&&(l=u=d)&&t.lineStart(),d!==u&&(p=o(n,g),(Ue(n,p)||Ue(g,p))&&(g[0]+=Mt,g[1]+=Mt,d=i(g[0],g[1]))),d!==u)c=0,d?(t.lineStart(),p=o(g,n),t.point(p[0],p[1])):(p=o(n,g),t.point(p[0],p[1]),t.lineEnd()),n=p;else if(r&&n&&e^d){var v;y&s||!(v=o(g,n,!0))||(c=0,e?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!d||n&&Ue(n,g)||t.point(g[0],g[1]),n=g,u=d,s=y},lineEnd:function(){u&&t.lineEnd(),n=null},clean:function(){return c|(l&&u)<<1}}}),qr(t,6*Nt),e?[0,-t]:[-Et,t-Et]);function i(t,e){return Math.cos(t)*Math.cos(e)>n}function o(t,e,r){var i=[1,0,0],o=Le(Pe(t),Pe(e)),a=Fe(o,o),s=o[0],u=a-s*s;if(!u)return!r&&t;var l=n*a/u,c=-n*s/u,h=Le(i,o),f=De(i,l);ze(f,De(o,c));var p=h,g=Fe(f,p),d=Fe(p,p),y=g*g-d*(Fe(f,f)-1);if(!(y<0)){var m=Math.sqrt(y),x=De(p,(-g-m)/d);if(ze(x,f),x=qe(x),!r)return x;var _,w=t[0],b=e[0],M=t[1],k=e[1];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=De(p,(-g+m)/d);return ze(A,f),[x,qe(A)]}}}function a(n,r){var i=e?t:Et-t,o=0;return n<-i?o|=1:n>i&&(o|=2),r<-i?o|=4:r>i&&(o|=8),o}}function er(t,n,e,r){return function(i){var o,a=i.a,s=i.b,u=a.x,l=a.y,c=0,h=1,f=s.x-u,p=s.y-l;if(o=t-u,f||!(o>0)){if(o/=f,f<0){if(o<c)return;o<h&&(h=o)}else if(f>0){if(o>h)return;o>c&&(c=o)}if(o=e-u,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o)}else if(f>0){if(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:u+c*f,y:l+c*p}),h<1&&(i.b={x:u+h*f,y:l+h*p}),i}}}}}}function rr(n,e,r,i){return function(u){var l,c,h,f,p,g,d,y,v,m,x,_=u,w=Je(),b=er(n,e,r,i),M={point:S,lineStart:function(){M.point=A,c&&c.push(h=[]),m=!0,v=!1,d=y=NaN},lineEnd:function(){l&&(A(f,p),g&&v&&w.rejoin(),l.push(w.buffer())),M.point=S,v&&u.lineEnd()},polygonStart:function(){u=w,l=[],c=[],x=!0},polygonEnd:function(){u=_,l=t.merge(l);var e=function(t){for(var n=0,e=c.length,r=t[1],i=0;i<e;++i)for(var o,a=1,s=c[i],u=s.length,l=s[0];a<u;++a)o=s[a],l[1]<=r?o[1]>r&&Ft(l,o,t)>0&&++n:o[1]<=r&&Ft(l,o,t)<0&&--n,l=o;return 0!==n}([n,i]),r=x&&e,o=l.length;(r||o)&&(u.polygonStart(),r&&(u.lineStart(),k(null,null,1,u),u.lineEnd()),o&&We(l,a,e,k,u),u.polygonEnd()),l=c=h=null}};function k(t,a,u,l){var c=0,h=0;if(null==t||(c=o(t,u))!==(h=o(a,u))||s(t,a)<0^u>0)do{l.point(0===c||3===c?n:r,c>1?i:e)}while((c=(c+u+4)%4)!==h);else l.point(a[0],a[1])}function E(t,o){return n<=t&&t<=r&&e<=o&&o<=i}function S(t,n){E(t,n)&&u.point(t,n)}function A(t,n){var e=E(t=Math.max(-1e9,Math.min(1e9,t)),n=Math.max(-1e9,Math.min(1e9,n)));if(c&&h.push([t,n]),m)f=t,p=n,g=e,m=!1,e&&(u.lineStart(),u.point(t,n));else if(e&&v)u.point(t,n);else{var r={a:{x:d,y:y},b:{x:t,y:n}};b(r)?(v||(u.lineStart(),u.point(r.a.x,r.a.y)),u.point(r.b.x,r.b.y),e||u.lineEnd(),x=!1):e&&(u.lineStart(),u.point(t,n),x=!1)}d=t,y=n,v=e}return M};function o(t,i){return v(t[0]-n)<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 s(t.x,n.x)}function s(t,n){var e=o(t,1),r=o(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}}function ir(t){var n=0,e=Et/3,r=Nr(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Et/180,e=t[1]*Et/180):[n/Et*180,e/Et*180]},i}function or(t,n){var e=Math.sin(t),r=(e+Math.sin(n))/2,i=1+e*(2*r-e),o=Math.sqrt(i)/r;function a(t,n){var e=Math.sqrt(i-2*r*Math.sin(n))/r;return[e*Math.sin(t*=r),o-e*Math.cos(t)]}return a.invert=function(t,n){var e=o-n;return[Math.atan2(t,e)/r,zt((i-(t*t+e*e)*r*r)/(2*r))]},a}t.geo.clipExtent=function(){var t,n,e,r,i,o,a={stream:function(t){return i&&(i.valid=!1),(i=o(t)).valid=!0,i},extent:function(s){return arguments.length?(o=rr(t=+s[0][0],n=+s[0][1],e=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),a):[[t,n],[e,r]]}};return a.extent([[0,0],[960,500]])},(t.geo.conicEqualArea=function(){return ir(or)}).raw=or,t.geo.albers=function(){return t.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},t.geo.albersUsa=function(){var n,e,r,i,o=t.geo.albers(),a=t.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=t.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),u={point:function(t,e){n=[t,e]}};function l(t){var o=t[0],a=t[1];return n=null,e(o,a),n||(r(o,a),n)||i(o,a),n}return l.invert=function(t){var n=o.scale(),e=o.translate(),r=(t[0]-e[0])/n,i=(t[1]-e[1])/n;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?a:i>=.166&&i<.234&&r>=-.214&&r<-.115?s:o).invert(t)},l.stream=function(t){var n=o.stream(t),e=a.stream(t),r=s.stream(t);return{point:function(t,i){n.point(t,i),e.point(t,i),r.point(t,i)},sphere:function(){n.sphere(),e.sphere(),r.sphere()},lineStart:function(){n.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){n.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){n.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){n.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},l.precision=function(t){return arguments.length?(o.precision(t),a.precision(t),s.precision(t),l):o.precision()},l.scale=function(t){return arguments.length?(o.scale(t),a.scale(.35*t),s.scale(t),l.translate(o.translate())):o.scale()},l.translate=function(t){if(!arguments.length)return o.translate();var n=o.scale(),c=+t[0],h=+t[1];return e=o.translate(t).clipExtent([[c-.455*n,h-.238*n],[c+.455*n,h+.238*n]]).stream(u).point,r=a.translate([c-.307*n,h+.201*n]).clipExtent([[c-.425*n+Mt,h+.12*n+Mt],[c-.214*n-Mt,h+.234*n-Mt]]).stream(u).point,i=s.translate([c-.205*n,h+.212*n]).clipExtent([[c-.214*n+Mt,h+.166*n+Mt],[c-.115*n-Mt,h+.234*n-Mt]]).stream(u).point,l},l.scale(1070)};var ar,sr,ur,lr,cr,hr,fr={point:L,lineStart:L,lineEnd:L,polygonStart:function(){sr=0,fr.lineStart=pr},polygonEnd:function(){fr.lineStart=fr.lineEnd=fr.point=L,ar+=v(sr/2)}};function pr(){var t,n,e,r;function i(t,n){sr+=r*t-e*n,e=t,r=n}fr.point=function(o,a){fr.point=i,t=e=o,n=r=a},fr.lineEnd=function(){i(t,n)}}var gr={point:function(t,n){t<ur&&(ur=t),t>cr&&(cr=t),n<lr&&(lr=n),n>hr&&(hr=n)},lineStart:L,lineEnd:L,polygonStart:L,polygonEnd:L};function dr(){var t=yr(4.5),n=[],e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(n){return t=yr(n),e},result:function(){if(n.length){var t=n.join("");return n=[],t}}};function r(e,r){n.push("M",e,",",r,t)}function i(t,r){n.push("M",t,",",r),e.point=o}function o(t,e){n.push("L",t,",",e)}function a(){e.point=r}function s(){n.push("Z")}return e}function yr(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var vr,mr={point:xr,lineStart:_r,lineEnd:wr,polygonStart:function(){mr.lineStart=br},polygonEnd:function(){mr.point=xr,mr.lineStart=_r,mr.lineEnd=wr}};function xr(t,n){xe+=t,_e+=n,++we}function _r(){var t,n;function e(e,r){var i=e-t,o=r-n,a=Math.sqrt(i*i+o*o);be+=a*(t+e)/2,Me+=a*(n+r)/2,ke+=a,xr(t=e,n=r)}mr.point=function(r,i){mr.point=e,xr(t=r,n=i)}}function wr(){mr.point=xr}function br(){var t,n,e,r;function i(t,n){var i=t-e,o=n-r,a=Math.sqrt(i*i+o*o);be+=a*(e+t)/2,Me+=a*(r+n)/2,ke+=a,Ee+=(a=r*t-e*n)*(e+t),Se+=a*(r+n),Ae+=3*a,xr(e=t,r=n)}mr.point=function(o,a){mr.point=i,xr(t=e=o,n=r=a)},mr.lineEnd=function(){i(t,n)}}function Mr(t){var n=4.5,e={point:r,lineStart:function(){e.point=i},lineEnd:a,polygonStart:function(){e.lineEnd=s},polygonEnd:function(){e.lineEnd=a,e.point=r},pointRadius:function(t){return n=t,e},result:L};function r(e,r){t.moveTo(e+n,r),t.arc(e,r,n,0,St)}function i(n,r){t.moveTo(n,r),e.point=o}function o(n,e){t.lineTo(n,e)}function a(){e.point=r}function s(){t.closePath()}return e}function kr(t){var n=.5,e=Math.cos(30*Nt),r=16;function i(t){return(r?a:o)(t)}function o(n){return Ar(n,(function(e,r){e=t(e,r),n.point(e[0],e[1])}))}function a(n){var e,i,o,a,u,l,c,h,f,p,g,d,y={point:v,lineStart:m,lineEnd:_,polygonStart:function(){n.polygonStart(),y.lineStart=w},polygonEnd:function(){n.polygonEnd(),y.lineStart=m}};function v(e,r){e=t(e,r),n.point(e[0],e[1])}function m(){h=NaN,y.point=x,n.lineStart()}function x(e,i){var o=Pe([e,i]),a=t(e,i);s(h,f,c,p,g,d,h=a[0],f=a[1],c=e,p=o[0],g=o[1],d=o[2],r,n),n.point(h,f)}function _(){y.point=v,n.lineEnd()}function w(){m(),y.point=b,y.lineEnd=M}function b(t,n){x(e=t,n),i=h,o=f,a=p,u=g,l=d,y.point=x}function M(){s(h,f,c,p,g,d,i,o,e,a,u,l,r,n),y.lineEnd=_,_()}return y}function s(r,i,o,a,u,l,c,h,f,p,g,d,y,m){var x=c-r,_=h-i,w=x*x+_*_;if(w>4*n&&y--){var b=a+p,M=u+g,k=l+d,E=Math.sqrt(b*b+M*M+k*k),S=Math.asin(k/=E),A=v(v(k)-1)<Mt||v(o-f)<Mt?(o+f)/2:Math.atan2(M,b),C=t(A,S),N=C[0],T=C[1],P=N-r,F=T-i,L=_*P-x*F;(L*L/w>n||v((x*P+_*F)/w-.5)>.3||a*p+u*g+l*d<e)&&(s(r,i,o,a,u,l,N,T,A,b/=E,M/=E,k,y,m),m.point(N,T),s(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,s,u=kr((function(t,n){return[(t=e(t,n))[0]*l+o,a-t[1]*l]})),l=150,c=480,h=250,f=0,p=0,g=0,d=0,y=0,v=tr,m=N,x=null,_=null;function w(t){return[(t=i(t[0]*Nt,t[1]*Nt))[0]*l+o,a-t[1]*l]}function b(t){return(t=i.invert((t[0]-o)/l,(a-t[1])/l))&&[t[0]*Tt,t[1]*Tt]}function M(){i=$e(r=Lr(g,d,y),e);var t=e(f,p);return o=c-t[0]*l,a=h+t[1]*l,k()}function k(){return s&&(s.valid=!1,s=null),w}return w.stream=function(t){return s&&(s.valid=!1),(s=Tr(v(r,u(m(t))))).valid=!0,s},w.clipAngle=function(t){return arguments.length?(v=null==t?(x=t,tr):nr((x=+t)*Nt),k()):x},w.clipExtent=function(t){return arguments.length?(_=t,m=t?rr(t[0][0],t[0][1],t[1][0],t[1][1]):N,k()):_},w.scale=function(t){return arguments.length?(l=+t,M()):l},w.translate=function(t){return arguments.length?(c=+t[0],h=+t[1],M()):[c,h]},w.center=function(t){return arguments.length?(f=t[0]%360*Nt,p=t[1]%360*Nt,M()):[f*Tt,p*Tt]},w.rotate=function(t){return arguments.length?(g=t[0]%360*Nt,d=t[1]%360*Nt,y=t.length>2?t[2]%360*Nt:0,M()):[g*Tt,d*Tt,y*Tt]},t.rebind(w,u,"precision"),function(){return e=n.apply(this,arguments),w.invert=e.invert&&b,M()}}function Tr(t){return Ar(t,(function(n,e){t.point(n*Nt,e*Nt)}))}function Pr(t,n){return[t,n]}function Fr(t,n){return[t>Et?t-St:t<-Et?t+St:t,n]}function Lr(t,n,e){return t?n||e?$e(Dr(t),Rr(n,e)):Dr(t):n||e?Rr(n,e):Fr}function zr(t){return function(n,e){return[(n+=t)>Et?n-St:n<-Et?n+St:n,e]}}function Dr(t){var n=zr(t);return n.invert=zr(-t),n}function Rr(t,n){var e=Math.cos(t),r=Math.sin(t),i=Math.cos(n),o=Math.sin(n);function a(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,l=Math.sin(n),c=l*e+s*r;return[Math.atan2(u*i-c*o,s*e-l*r),zt(c*i+u*o)]}return a.invert=function(t,n){var a=Math.cos(n),s=Math.cos(t)*a,u=Math.sin(t)*a,l=Math.sin(n),c=l*i-u*o;return[Math.atan2(u*i+l*o,s*e+c*r),zt(c*e-s*r)]},a}function qr(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,o,a,s){var u=a*n;null!=i?(i=Ur(e,i),o=Ur(e,o),(a>0?i<o:i>o)&&(i+=a*St)):(i=t+a*St,o=t-.5*u);for(var l,c=i;a>0?c>o:c<o;c-=u)s.point((l=qe([e,-r*Math.cos(c),-r*Math.sin(c)]))[0],l[1])}}function Ur(t,n){var e=Pe(n);e[0]-=t,Re(e);var r=Lt(-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 jr(t){return t.source}function Hr(t){return t.target}t.geo.path=function(){var n,e,r,i,o,a=4.5;function s(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 u(){return o=null,s}return s.area=function(n){return ar=0,t.geo.stream(n,r(fr)),ar},s.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]},s.bounds=function(n){return cr=hr=-(ur=lr=1/0),t.geo.stream(n,r(gr)),[[ur,lr],[cr,hr]]},s.projection=function(t){return arguments.length?(r=(n=t)?t.stream||Er(t):N,u()):n},s.context=function(t){return arguments.length?(i=null==(e=t)?new dr:new Mr(t),"function"!=typeof a&&i.pointRadius(a),u()):e},s.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),s):a},s.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(Pr)}).raw=Pr.invert=Pr,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=Lr(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},Fr.invert=Pr,t.geo.circle=function(){var t,n,e=[0,0],r=6;function i(){var t="function"==typeof e?e.apply(this,arguments):e,r=Lr(-t[0]*Nt,-t[1]*Nt,0).invert,i=[];return n(null,null,1,{point:function(t,n){i.push(t=r(t,n)),t[0]*=Tt,t[1]*=Tt}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(t){return arguments.length?(e=t,i):e},i.angle=function(e){return arguments.length?(n=qr((t=+e)*Nt,r*Nt),i):t},i.precision=function(e){return arguments.length?(n=qr(t*Nt,(r=+e)*Nt),i):r},i.angle(90)},t.geo.distance=function(t,n){var e,r=(n[0]-t[0])*Nt,i=t[1]*Nt,o=n[1]*Nt,a=Math.sin(r),s=Math.cos(r),u=Math.sin(i),l=Math.cos(i),c=Math.sin(o),h=Math.cos(o);return Math.atan2(Math.sqrt((e=h*a)*e+(e=l*c-u*h*s)*e),u*c+l*h*s)},t.geo.graticule=function(){var n,e,r,i,o,a,s,u,l,c,h,f,p=10,g=p,d=90,y=360,m=2.5;function x(){return{type:"MultiLineString",coordinates:_()}}function _(){return t.range(Math.ceil(i/d)*d,r,d).map(h).concat(t.range(Math.ceil(u/y)*y,s,y).map(f)).concat(t.range(Math.ceil(e/p)*p,n,p).filter((function(t){return v(t%d)>Mt})).map(l)).concat(t.range(Math.ceil(a/g)*g,o,g).filter((function(t){return v(t%y)>Mt})).map(c))}return x.lines=function(){return _().map((function(t){return{type:"LineString",coordinates:t}}))},x.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(f(s).slice(1),h(r).reverse().slice(1),f(u).reverse().slice(1))]}},x.extent=function(t){return arguments.length?x.majorExtent(t).minorExtent(t):x.minorExtent()},x.majorExtent=function(t){return arguments.length?(i=+t[0][0],r=+t[1][0],u=+t[0][1],s=+t[1][1],i>r&&(t=i,i=r,r=t),u>s&&(t=u,u=s,s=t),x.precision(m)):[[i,u],[r,s]]},x.minorExtent=function(t){return arguments.length?(e=+t[0][0],n=+t[1][0],a=+t[0][1],o=+t[1][1],e>n&&(t=e,e=n,n=t),a>o&&(t=a,a=o,o=t),x.precision(m)):[[e,a],[n,o]]},x.step=function(t){return arguments.length?x.majorStep(t).minorStep(t):x.minorStep()},x.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],x):[d,y]},x.minorStep=function(t){return arguments.length?(p=+t[0],g=+t[1],x):[p,g]},x.precision=function(t){return arguments.length?(m=+t,l=Or(a,o,90),c=Ir(e,n,m),h=Or(u,s,90),f=Ir(i,r,m),x):m},x.majorExtent([[-180,-90+Mt],[180,90-Mt]]).minorExtent([[-180,-80-Mt],[180,80+Mt]])},t.geo.greatArc=function(){var n,e,r=jr,i=Hr;function o(){return{type:"LineString",coordinates:[n||r.apply(this,arguments),e||i.apply(this,arguments)]}}return o.distance=function(){return t.geo.distance(n||r.apply(this,arguments),e||i.apply(this,arguments))},o.source=function(t){return arguments.length?(r=t,n="function"==typeof t?null:t,o):r},o.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,o):i},o.precision=function(){return arguments.length?o:0},o},t.geo.interpolate=function(t,n){return e=t[0]*Nt,r=t[1]*Nt,i=n[0]*Nt,o=n[1]*Nt,a=Math.cos(r),s=Math.sin(r),u=Math.cos(o),l=Math.sin(o),c=a*Math.cos(e),h=a*Math.sin(e),f=u*Math.cos(i),p=u*Math.sin(i),g=2*Math.asin(Math.sqrt(Rt(o-r)+a*u*Rt(i-e))),d=1/Math.sin(g),(y=g?function(t){var n=Math.sin(t*=g)*d,e=Math.sin(g-t)*d,r=e*c+n*f,i=e*h+n*p,o=e*s+n*l;return[Math.atan2(i,r)*Tt,Math.atan2(o,Math.sqrt(r*r+i*i))*Tt]}:function(){return[e*Tt,r*Tt]}).distance=g,y;var e,r,i,o,a,s,u,l,c,h,f,p,g,d,y},t.geo.length=function(n){return vr=0,t.geo.stream(n,Vr),vr};var Vr={sphere:L,point:L,lineStart:function(){var t,n,e;function r(r,i){var o=Math.sin(i*=Nt),a=Math.cos(i),s=v((r*=Nt)-t),u=Math.cos(s);vr+=Math.atan2(Math.sqrt((s=a*Math.sin(s))*s+(s=e*o-n*a*u)*s),n*o+e*a*u),t=r,n=o,e=a}Vr.point=function(i,o){t=i*Nt,n=Math.sin(o*=Nt),e=Math.cos(o),Vr.point=r},Vr.lineEnd=function(){Vr.point=Vr.lineEnd=L}},lineEnd:L,polygonStart:L,polygonEnd:L};function Br(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),o=t(r*i);return[o*i*Math.sin(n),o*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),o=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*o,r*a),Math.asin(r&&e*o/r)]},e}var $r=Br((function(t){return Math.sqrt(2/(1+t))}),(function(t){return 2*Math.asin(t/2)}));(t.geo.azimuthalEqualArea=function(){return Cr($r)}).raw=$r;var Yr=Br((function(t){var n=Math.acos(t);return n&&n/Math.sin(n)}),N);function Wr(t,n){var e=Math.cos(t),r=function(t){return Math.tan(Et/4+t/2)},i=t===n?Math.sin(t):Math.log(e/Math.cos(n))/Math.log(r(n)/r(t)),o=e*Math.pow(r(t),i)/i;if(!i)return Gr;function a(t,n){o>0?n<-Ct+Mt&&(n=-Ct+Mt):n>Ct-Mt&&(n=Ct-Mt);var e=o/Math.pow(r(n),i);return[e*Math.sin(i*t),o-e*Math.cos(i*t)]}return a.invert=function(t,n){var e=o-n,r=Pt(i)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/i,2*Math.atan(Math.pow(o/r,1/i))-Ct]},a}function Zr(t,n){var e=Math.cos(t),r=t===n?Math.sin(t):(e-Math.cos(n))/(n-t),i=e/r+t;if(v(r)<Mt)return Pr;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-Pt(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 s=Et*r(),u=i();o([[u[0]-s,u[1]-s],[u[0]+s,u[1]+s]])}}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&&Ft(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ii(t,n){return t[0]-n[0]||t[1]-n[1]}(t.geo.stereographic=function(){return Cr(Kr)}).raw=Kr,ti.invert=function(t,n){return[-n,2*Math.atan(Math.exp(t))-Ct]},(t.geo.transverseMercator=function(){var t=Qr(ti),n=t.center,e=t.rotate;return t.center=function(t){return t?n([-t[1],t[0]]):[(t=n())[1],-t[0]]},t.rotate=function(t){return t?e([t[0],t[1],t.length>2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90])}).raw=ti,t.geom={},t.geom.hull=function(t){var n=ni,e=ei;if(arguments.length)return r(t);function r(t){if(t.length<3)return[];var r,i=gn(n),o=gn(e),a=t.length,s=[],u=[];for(r=0;r<a;r++)s.push([+i.call(this,t[r],r),+o.call(this,t[r],r),r]);for(s.sort(ii),r=0;r<a;r++)u.push([s[r][0],-s[r][1]]);var l=ri(s),c=ri(u),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[s[l[r]][2]]);for(r=+h;r<c.length-f;++r)p.push(t[s[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 si(t,n,e,r){var i=t[0],o=e[0],a=n[0]-i,s=r[0]-o,u=t[1],l=e[1],c=n[1]-u,h=r[1]-l,f=(s*(u-l)-h*(i-o))/(h*a-s*c);return[i+f*a,u+f*c]}function ui(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,s=this[i-1];for(arguments.length||(t=-1/(6*this.area()));++r<i;)n=s,s=this[r],e=n[0]*s[1]-s[0]*n[1],o+=(n[0]+s[0])*e,a+=(n[1]+s[1])*e;return[o*t,a*t]},oi.clip=function(t){for(var n,e,r,i,o,a,s=ui(t),u=-1,l=this.length-ui(this),c=this[l-1];++u<l;){for(n=t.slice(),t.length=0,i=this[u],o=n[(r=n.length-s)-1],e=-1;++e<r;)ai(a=n[e],c,i)?(ai(o,c,i)||t.push(si(o,a,c,i)),t.push(a)):ai(o,c,i)&&t.push(si(o,a,c,i)),o=a;s&&t.push(t[0]),c=i}return t};var li,ci,hi,fi,pi,gi=[],di=[];function yi(){zi(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),zi(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,s=[t];mi(t);for(var u=o;u.circle&&v(e-u.circle.x)<Mt&&v(r-u.circle.cy)<Mt;)o=u.P,s.unshift(u),mi(u),u=o;s.unshift(u),Ai(u);for(var l=a;l.circle&&v(e-l.circle.x)<Mt&&v(r-l.circle.cy)<Mt;)a=l.N,s.push(l),mi(l),l=a;s.push(l),Ai(l);var c,h=s.length;for(c=1;c<h;++c)l=s[c],u=s[c-1],Pi(l.edge,u.site,l.site,i);u=s[0],(l=s[h-1]).edge=Ti(u.site,l.site,null,i),Si(u),Si(l)}function _i(t){for(var n,e,r,i,o=t.x,a=t.y,s=hi._;s;)if((r=wi(s,a)-o)>Mt)s=s.L;else{if(!((i=o-bi(s,a))>Mt)){r>-Mt?(n=s.P,e=s):i>-Mt?(n=s,e=s.N):n=e=s;break}if(!s.R){n=s;break}s=s.R}var u=vi(t);if(hi.insert(n,u),n||e){if(n===e)return Ai(n),e=vi(n.site),hi.insert(u,e),u.edge=e.edge=Ti(n.site,u.site),Si(n),void Si(e);if(e){Ai(n),Ai(e);var l=n.site,c=l.x,h=l.y,f=t.x-c,p=t.y-h,g=e.site,d=g.x-c,y=g.y-h,v=2*(f*y-p*d),m=f*f+p*p,x=d*d+y*y,_={x:(y*m-p*x)/v+c,y:(f*x-d*m)/v+h};Pi(e.edge,l,g,_),u.edge=Ti(l,t,null,_),e.edge=Ti(t,g,null,_),Si(n),Si(e)}else u.edge=Ti(n.site,u.site)}}function wi(t,n){var e=t.site,r=e.x,i=e.y,o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var s=(e=a.site).x,u=e.y,l=u-n;if(!l)return s;var c=s-r,h=1/o-1/l,f=c/l;return h?(-f+Math.sqrt(f*f-2*h*(c*c/(-2*l)-u+l/2+i-o/2)))/h+r:(r+s)/2}function bi(t,n){var e=t.N;if(e)return wi(e,n);var r=t.site;return r.y===n?r.x:1/0}function Mi(t){this.site=t,this.edges=[]}function ki(t,n){return n.angle-t.angle}function Ei(){zi(this),this.x=this.y=this.arc=this.site=this.cy=null}function Si(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i.x,s=i.y,u=r.x-a,l=r.y-s,c=o.x-a,h=2*(u*(y=o.y-s)-l*c);if(!(h>=-kt)){var f=u*u+l*l,p=c*c+y*y,g=(y*f-l*p)/h,d=(u*p-c*f)/h,y=d+s,v=di.pop()||new Ei;v.arc=t,v.site=i,v.x=g+a,v.y=y+Math.sqrt(g*g+d*d),v.cy=y,t.circle=v;for(var m=null,x=pi._;x;)if(v.y<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),zi(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],s=n[1][0],u=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>=s)return;if(f>g){if(o){if(o.y>=l)return}else o={x:y,y:u};e={x:y,y:l}}else{if(o){if(o.y<u)return}else o={x:y,y:l};e={x:y,y:u}}}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:(u-i)/r,y:u};e={x:(l-i)/r,y:l}}else{if(o){if(o.y<u)return}else o={x:(l-i)/r,y:l};e={x:(u-i)/r,y:u}}else if(p<d){if(o){if(o.x>=s)return}else o={x:a,y:r*a+i};e={x:s,y:r*s+i}}else{if(o){if(o.x<a)return}else o={x:s,y:r*s+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&&Pi(i,t,n,e),r&&Pi(i,n,t,r),ci[t.i].edges.push(new Fi(i,t,n)),ci[n.i].edges.push(new Fi(i,n,t)),i}function Pi(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 Fi(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 Li(){this._=null}function zi(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function Di(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 Ri(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 Li,pi=new Li;;)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,s,u,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(u=(s=o.edges).length,a=0;a<u;)r=(c=s[a].end()).x,i=c.y,n=(l=s[++a%u].start()).x,e=l.y,(v(r-n)>Mt||v(i-e)>Mt)&&(s.splice(a,0,new Fi((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)),++u);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},Fi.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}},Li.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&&(Di(this,e),e=(t=e).U),e.C=!1,r.C=!0,Ri(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(Ri(this,e),e=(t=e).U),e.C=!1,r.C=!0,Di(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,Di(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,Ri(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,Di(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,Ri(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,Di(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,Ri(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(s(t),o).cells.forEach((function(o,s){var u=o.edges,l=o.site;(n[s]=u.length?u.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[s]})),n}function s(t){return t.map((function(t,n){return{x:Math.round(r(t,n)/Mt)*Mt,y:Math.round(i(t,n)/Mt)*Mt,i:n}}))}return a.links=function(t){return Ui(s(t)).edges.filter((function(t){return t.l&&t.r})).map((function(n){return{source:t[n.l.i],target:t[n.r.i]}}))},a.triangles=function(t){var n=[];return Ui(s(t)).cells.forEach((function(e,r){for(var i,o,a,s,u=e.site,l=e.edges.sort(ki),c=-1,h=l.length,f=l[h-1].edge,p=f.l===u?f.r:f.l;++c<h;)i=p,p=(f=l[c].edge).l===u?f.r:f.l,r<i.i&&r<p.i&&(a=i,s=p,((o=u).x-s.x)*(a.y-o.y)-(o.x-a.x)*(s.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 ji(t){return t.x}function Hi(t){return t.y}function Vi(t,n,e,r,i,o){if(!t(n,e,r,i,o)){var a=.5*(e+i),s=.5*(r+o),u=n.nodes;u[0]&&Vi(t,u[0],e,r,a,s),u[1]&&Vi(t,u[1],a,r,i,s),u[2]&&Vi(t,u[2],e,s,a,o),u[3]&&Vi(t,u[3],a,s,i,o)}}function Bi(t,n,e,r,i,o,a){var s,u=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<u){var m=Math.sqrt(u=v);r=n-m,i=e-m,o=n+m,a=e+m,s=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),s}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,s=e.g-i,u=e.b-o;return function(t){return"#"+sn(Math.round(r+a*t))+sn(Math.round(i+s*t))+sn(Math.round(o+u*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,s=[],u=[];for(t+="",n+="";(e=Xi.exec(t))&&(r=Gi.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(e=e[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Wi(e,r)})),o=Gi.lastIndex;return o<n.length&&(i=n.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?u[0]?(n=u[0].x,function(t){return n(t)+""}):function(){return n}:(n=u.length,function(t){for(var e,r=0;r<n;++r)s[(e=u[r]).i]=e.x(t);return s.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,s=ei;if(o=arguments.length)return a=ji,s=Hi,3===o&&(i=e,r=n,e=n=0),u(t);function u(t){var u,l,c,h,f,p,g,d,y,m=gn(a),x=gn(s);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)(u=t[h]).x<p&&(p=u.x),u.y<g&&(g=u.y),u.x>d&&(d=u.x),u.y>y&&(y=u.y),l.push(u.x),c.push(u.y);else for(h=0;h<f;++h){var _=+m(u=t[h],h),w=+x(u,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,s){if(!isNaN(e)&&!isNaN(r))if(t.leaf){var u=t.x,l=t.y;if(null!=u)if(v(u-e)+v(l-r)<.01)E(t,n,e,r,i,o,a,s);else{var c=t.point;t.x=t.y=t.point=null,E(t,c,u,l,i,o,a,s),E(t,n,e,r,i,o,a,s)}else t.x=e,t.y=r,t.point=n}else E(t,n,e,r,i,o,a,s)}function E(t,n,e,r,i,o,a,s){var u=.5*(i+a),l=.5*(o+s),c=e>=u,h=r>=l,f=h<<1|c;t.leaf=!1,c?i=u:a=u,h?o=l:s=l,k(t=t.nodes[f]||(t.nodes[f]={leaf:!0,nodes:[],point:null,x:null,y:null}),n,e,r,i,o,a,s)}b>M?y=g+b:d=p+M;var S={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(t){k(S,t,+m(t,++h),+x(t,h),p,g,d,y)},visit:function(t){Vi(t,S,p,g,d,y)},find:function(t){return Bi(S,t[0],t[1],p,g,d,y)}};if(h=-1,null==n){for(;++h<f;)k(S,t[h],l[h],c[h],p,g,d,y);--h}else t.forEach(S.add);return l=c=t=u=null,S}return u.x=function(t){return arguments.length?(a=t,u):a},u.y=function(t){return arguments.length?(s=t,u):s},u.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]),u):null==n?null:[[n,e],[r,i]]},u.size=function(t){return arguments.length?(null==t?n=e=r=i=null:(n=e=0,r=+t[0],i=+t[1]),u):null==n?null:[r-n,i-e]},u},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,s=Math.min(t.length,n.length);for(e=0;e<s;++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<s;++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 jt?$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 uo},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 so(t){if(t<=0)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(t<.5?e:3*(t-n)+e-.75)}function uo(t){return 1-Math.cos(t*Ct)}function lo(t){return Math.pow(2,10*(t-1))}function co(t){return 1-Math.sqrt(1-t*t)}function ho(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function fo(t,n){return n-=t,function(e){return Math.round(t+n*e)}}function po(t){var n,e,r,i=[t.a,t.b],o=[t.c,t.d],a=yo(i),s=go(i,o),u=yo(((n=o)[0]+=(r=-s)*(e=i)[0],n[1]+=r*e[1],n))||0;i[0]*o[1]<o[0]*i[1]&&(i[0]*=-1,i[1]*=-1,a*=-1,s*=-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,u],this.skew=u?Math.atan2(s,u)*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,s=e.c-i,u=e.l-o;return isNaN(s)&&(s=0,i=isNaN(i)?e.c:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Wt(r+a*t,i+s*t,o+u*t)+""}},t.interpolateHsl=function(n,e){n=t.hsl(n),e=t.hsl(e);var r=n.h,i=n.s,o=n.l,a=e.h-r,s=e.s-i,u=e.l-o;return isNaN(s)&&(s=0,i=isNaN(i)?e.s:i),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return Bt(r+a*t,i+s*t,o+u*t)+""}},t.interpolateLab=function(n,e){n=t.lab(n),e=t.lab(e);var r=n.l,i=n.a,o=n.b,a=e.l-r,s=e.a-i,u=e.b-o;return function(t){return Qt(r+a*t,i+s*t,o+u*t)+""}},t.interpolateRound=fo,t.transform=function(n){var e=r.createElementNS(t.ns.prefix.svg,"g");return(t.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new po(n?n.matrix:vo)})(n)},po.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var vo={a:1,b:0,c:0,d:1,e:0,f:0};function mo(t){return t.length?t.pop()+",":""}function xo(n,e){var r=[],i=[];return n=t.transform(n),e=t.transform(e),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push("translate(",null,",",null,")");r.push({i:i-4,x:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else(n[0]||n[1])&&e.push("translate("+n+")")}(n.translate,e.translate,r,i),function(t,n,e,r){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),r.push({i:e.push(mo(e)+"rotate(",null,")")-2,x:Wi(t,n)})):n&&e.push(mo(e)+"rotate("+n+")")}(n.rotate,e.rotate,r,i),function(t,n,e,r){t!==n?r.push({i:e.push(mo(e)+"skewX(",null,")")-2,x:Wi(t,n)}):n&&e.push(mo(e)+"skewX("+n+")")}(n.skew,e.skew,r,i),function(t,n,e,r){if(t[0]!==n[0]||t[1]!==n[1]){var i=e.push(mo(e)+"scale(",null,",",null,")");r.push({i:i-4,x:Wi(t[0],n[0])},{i:i-2,x:Wi(t[1],n[1])})}else 1===n[0]&&1===n[1]||e.push(mo(e)+"scale("+n+")")}(n.scale,e.scale,r,i),n=e=null,function(t){for(var n,e=-1,o=i.length;++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,s,u={},l=0;function c(){var u,c,f,p,g,d={},y=[],v=t.range(i),m=[];for(n=[],e=[],u=0,p=-1;++p<i;){for(c=0,g=-1;++g<i;)c+=r[p][g];y.push(c),m.push(t.range(i)),u+=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])}))})),u=(St-l*i)/u,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*u;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})}s&&h()}function h(){n.sort((function(t,n){return s((t.source.value+t.target.value)/2,(n.source.value+n.target.value)/2)}))}return u.matrix=function(t){return arguments.length?(i=(r=t)&&r.length,n=e=null,u):r},u.padding=function(t){return arguments.length?(l=t,n=e=null,u):l},u.sortGroups=function(t){return arguments.length?(o=t,n=e=null,u):o},u.sortSubgroups=function(t){return arguments.length?(a=t,n=null,u):a},u.sortChords=function(t){return arguments.length?(s=t,n&&h(),u):s},u.chords=function(){return n||c(),n},u.groups=function(){return e||c(),e},u},t.layout.force=function(){var n,e,r,i,o,a,s={},u=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,s=i-e,u=o*o+a*a;if(s*s/y<u){if(u<g){var l=n.charge/u;t.px-=o*l,t.py-=a*l}return!0}n.point&&u&&u<g&&(l=n.pointCharge/u,t.px-=o*l,t.py-=a*l)}return!n.charge}}function _(n){n.px=t.event.x,n.py=t.event.y,s.resume()}return s.tick=function(){if((r*=.99)<.005)return n=null,u.end({type:"end",alpha:r=0}),!0;var e,s,h,f,g,y,_,w,b,M=v.length,k=m.length;for(s=0;s<k;++s)f=(h=m[s]).source,(y=(w=(g=h.target).x-f.x)*w+(b=g.y-f.y)*b)&&(w*=y=r*o[s]*((y=Math.sqrt(y))-i[s])/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,s=-1,_))for(;++s<M;)(h=v[s]).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,s=n.nodes,u=s.length,l=-1;++l<u;)null!=(a=s[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),s=-1;++s<M;)(h=v[s]).fixed||e.visit(x(h));for(s=-1;++s<M;)(h=v[s]).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);u.tick({type:"tick",alpha:r})},s.nodes=function(t){return arguments.length?(v=t,s):v},s.links=function(t){return arguments.length?(m=t,s):m},s.size=function(t){return arguments.length?(l=t,s):l},s.linkDistance=function(t){return arguments.length?(h="function"==typeof t?t:+t,s):h},s.distance=s.linkDistance,s.linkStrength=function(t){return arguments.length?(f="function"==typeof t?t:+t,s):f},s.friction=function(t){return arguments.length?(c=+t,s):c},s.charge=function(t){return arguments.length?(p="function"==typeof t?t:+t,s):p},s.chargeDistance=function(t){return arguments.length?(g=t*t,s):Math.sqrt(g)},s.gravity=function(t){return arguments.length?(d=+t,s):d},s.theta=function(t){return arguments.length?(y=t*t,s):Math.sqrt(y)},s.alpha=function(t){return arguments.length?(t=+t,r?t>0?r=t:(n.c=null,n.t=NaN,n=null,u.end({type:"end",alpha:r=0})):t>0&&(u.start({type:"start",alpha:r=t}),n=bn(s.tick)),s):r},s.start=function(){var t,n,e,r=v.length,u=m.length,c=l[0],g=l[1];for(t=0;t<r;++t)(e=v[t]).index=t,e.weight=0;for(t=0;t<u;++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<u;++t)i[t]=+h.call(this,m[t],t);else for(t=0;t<u;++t)i[t]=h;if(o=[],"function"==typeof f)for(t=0;t<u;++t)o[t]=+f.call(this,m[t],t);else for(t=0;t<u;++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<u;++l){var o=m[l];n[o.source.index].push(o.target),n[o.target.index].push(o.source)}}for(var a,s=n[t],l=-1,c=s.length;++l<c;)if(!isNaN(a=s[l][e]))return a;return Math.random()*i}return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.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(s,u,"on")};var Co=20,No=1,To=1/0;function Po(n,e){return t.rebind(n,e,"sort","children","value"),n.nodes=n,n.links=qo,n}function Fo(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 Lo(t,n){for(var e=[t],r=[];null!=(t=e.pop());)if(r.push(t),(o=t.children)&&(i=o.length))for(var i,o,a=-1;++a<i;)e.push(o[a]);for(;null!=(t=r.pop());)n(t)}function zo(t){return t.children}function Do(t){return t.value}function Ro(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=Ro,n=zo,e=Do;function r(i){var o,a=[i],s=[];for(i.depth=0;null!=(o=a.pop());)if(s.push(o),(l=n.call(r,o,o.depth))&&(u=l.length)){for(var u,l,c;--u>=0;)a.push(c=l[u]),c.parent=o,c.depth=o.depth+1;e&&(o.value=0),o.children=l}else e&&(o.value=+e.call(r,o,o.depth)||0),delete o.children;return Lo(i,(function(n){var r,i;t&&(r=n.children)&&r.sort(t),e&&(i=n.parent)&&(i.value+=n.value)})),s}return r.sort=function(n){return arguments.length?(t=n,r):t},r.children=function(t){return arguments.length?(n=t,r):n},r.value=function(t){return arguments.length?(e=t,r):e},r.revalue=function(t){return e&&(Fo(t,(function(t){t.children&&(t.value=0)})),Lo(t,(function(t){var n;t.children||(t.value=+e.call(r,t,t.depth)||0),(n=t.parent)&&(n.value+=t.value)}))),t},r},t.layout.partition=function(){var n=t.layout.hierarchy(),e=[1,1];function r(t,r){var i=n.call(this,t,r);return function t(n,e,r,i){var o=n.children;if(n.x=e,n.y=n.depth*i,n.dx=r,n.dy=i,o&&(a=o.length)){var a,s,u,l=-1;for(r=n.value?r/n.value:0;++l<a;)t(s=o[l],e,u=s.value*r,i),e+=u}}(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},Po(r,n)},t.layout.pie=function(){var n=Number,e=Uo,r=0,i=St,o=0;function a(s){var u,l=s.length,c=s.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(s[t],s[n])}),v.forEach((function(t){m[t]={data:s[t],value:u=c[t],startAngle:h,endAngle:h+=u*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 jo(t,n,e){t.y0=n,t.y=e}t.layout.stack=function(){var n=N,e=Bo,r=$o,i=jo,o=Oo,a=Io;function s(u,l){if(!(p=u.length))return u;var c=u.map((function(t,e){return n.call(s,t,e)})),h=c.map((function(t){return t.map((function(t,n){return[o.call(s,t,n),a.call(s,t,n)]}))})),f=e.call(s,h,l);c=t.permute(c,f),h=t.permute(h,f);var p,g,d,y,v=r.call(s,h,l),m=c[0].length;for(d=0;d<m;++d)for(i.call(s,c[0][d],y=v[d],h[0][d][1]),g=1;g<p;++g)i.call(s,c[g][d],y+=h[g-1][d][1],h[g][d][1]);return u}return s.values=function(t){return arguments.length?(n=t,s):n},s.order=function(t){return arguments.length?(e="function"==typeof t?t:Ho.get(t)||Bo,s):e},s.offset=function(t){return arguments.length?(r="function"==typeof t?t:Vo.get(t)||$o,s):r},s.x=function(t){return arguments.length?(o=t,s):o},s.y=function(t){return arguments.length?(a=t,s):a},s.out=function(t){return arguments.length?(i=t,s):i},s};var Ho=t.map({"inside-out":function(n){var e,r,i=n.length,o=n.map(Yo),a=n.map(Wo),s=t.range(i).sort((function(t,n){return o[t]-o[n]})),u=0,l=0,c=[],h=[];for(e=0;e<i;++e)r=s[e],u<l?(u+=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=[],s=0,u=[];for(e=0;e<o;++e){for(n=0,r=0;n<i;n++)r+=t[n][e][1];r>s&&(s=r),a.push(r)}for(e=0;e<o;++e)u[e]=(s-a[e])/2;return u},wiggle:function(t){var n,e,r,i,o,a,s,u,l,c=t.length,h=t[0],f=h.length,p=[];for(p[0]=u=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,s=h[e][0]-h[e-1][0];n<c;++n){for(r=0,a=(t[n][e][1]-t[n][e-1][1])/(2*s);r<n;++r)a+=(t[r][e][1]-t[r][e-1][1])/s;o+=a*t[n][e][1]}p[e]=u-=i?o/i*s:0,u<l&&(l=u)}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,s=[];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)s[e]=0;return s},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)&&(u=n.length)){var n,e,r,i,o,a,s,u,l=1/0,c=-1/0,h=1/0,f=-1/0;if(n.forEach(ra),(e=n[0]).x=-e.r,e.y=0,x(e),u>1&&((r=n[1]).x=r.r,r.y=0,x(r),u>2))for(oa(e,r,i=n[2]),x(i),Ko(e,i),e._pack_prev=i,Ko(i,r),r=e._pack_next,o=3;o<u;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(s=e._pack_prev;s!==a._pack_prev&&!na(s,i);s=s._pack_prev,d++);p?(g<d||g==d&&r.r<e.r?ta(e,r=a):ta(e=s,r),o--):(Ko(e,i),r=i,x(i))}var y=(l+c)/2,v=(h+f)/2,m=0;for(o=0;o<u;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,s=i*i+o*o,u=.5+((r*=r)-(a*=a))/(2*s),l=Math.sqrt(Math.max(0,2*a*(r+s)-(r-=s)*r-a*a))/(2*s);e.x=t.x+u*i+l*o,e.y=t.y+u*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 sa(t){var n=t.children;return n.length?n[0]:t.t}function ua(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 s,u,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;)(s=l[a]=[]).dx=f[a+1]-(s.x=f[a]),s.y=0;if(g>0)for(a=-1;++a<p;)(u=c[a])>=h[0]&&u<=h[1]&&((s=l[t.bisect(f,u,1,g)-1]).y+=d,s.push(o[a]));return l}return o.value=function(t){return arguments.length?(e=t,o):e},o.range=function(t){return arguments.length?(r=gn(t),o):r},o.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return Go(n,t)}:gn(t),o):i},o.frequency=function(t){return arguments.length?(n=!!t,o):n},o},t.layout.pack=function(){var n,e=t.layout.hierarchy().sort(Jo),r=0,i=[1,1];function o(t,o){var a=e.call(this,t,o),s=a[0],u=i[0],l=i[1],c=null==n?Math.sqrt:"function"==typeof n?n:function(){return n};if(s.x=s.y=0,Lo(s,(function(t){t.r=+c(t.value)})),Lo(s,ea),r){var h=r*(n?1:Math.max(2*s.r/u,2*s.r/l))/2;Lo(s,(function(t){t.r+=h})),Lo(s,ea),Lo(s,(function(t){t.r-=h}))}return function t(n,e,r,i){var o=n.children;if(n.x=e+=i*n.x,n.y=r+=i*n.y,n.r*=i,o)for(var a=-1,s=o.length;++a<s;)t(o[a],e,r,i)}(s,u/2,l/2,n?1:1/Math.max(2*s.r/u,2*s.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},Po(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,s=o.length;a<s;++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(Lo(h,a),h.parent.m=-h.z,Fo(h,s),i)Fo(c,u);else{var f=c,p=c,g=c;Fo(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);Fo(c,(function(t){t.x=(t.x+d)*y,t.y=t.depth*v}))}return l}function a(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n.length){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(t);var o=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-o):t.z=o}else i&&(t.z=i.z+e(t._,i._));t.parent.A=function(t,n,r){if(n){for(var i,o=t,a=t,s=n,u=o.parent.children[0],l=o.m,c=a.m,h=s.m,f=u.m;s=ua(s),o=sa(o),s&&o;)u=sa(u),(a=ua(a)).a=t,(i=s.z+h-o.z-l+e(s._,o._))>0&&(la(ca(s,t,r),t,i),l+=i,c+=i),h+=s.m,l+=o.m,f+=u.m,c+=a.m;s&&!ua(a)&&(a.t=s,a.m+=h-c),o&&!sa(u)&&(u.t=o,u.m+=l-f,r=t)}return r}(t,i,t.parent.A||r[0])}function s(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=r[0],t.y=t.depth*r[1]}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t)?u:null,o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null==(r=t)?null:u,o):i?r:null},Po(o,n)},t.layout.cluster=function(){var n=t.layout.hierarchy().sort(null).value(null),e=aa,r=[1,1],i=!1;function o(o,a){var s,u=n.call(this,o,a),l=u[0],c=0;Lo(l,(function(n){var r=n.children;r&&r.length?(n.x=function(t){return t.reduce((function(t,n){return t+n.x}),0)/t.length}(r),n.y=function(n){return 1+t.max(n,(function(t){return t.y}))}(r)):(n.x=s?c+=e(n,s):0,n.y=0,s=n)}));var h=function t(n){var e=n.children;return e&&e.length?t(e[0]):n}(l),f=function t(n){var e,r=n.children;return r&&(e=r.length)?t(r[e-1]):n}(l),p=h.x-e(h,f)/2,g=f.x+e(f,h)/2;return Lo(l,i?function(t){t.x=(t.x-l.x)*r[0],t.y=(l.y-t.y)*r[1]}:function(t){t.x=(t.x-p)/(g-p)*r[0],t.y=(1-(l.y?t.y/l.y:1))*r[1]}),u}return o.separation=function(t){return arguments.length?(e=t,o):e},o.size=function(t){return arguments.length?(i=null==(r=t),o):i?null:r},o.nodeSize=function(t){return arguments.length?(i=null!=(r=t),o):i?r:null},Po(o,n)},t.layout.treemap=function(){var n,e=t.layout.hierarchy(),r=Math.round,i=[1,1],o=null,a=ha,s=!1,u="squarify",l=.5*(1+Math.sqrt(5));function c(t,n){for(var e,r,i=-1,o=t.length;++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),s=[],l=n.slice(),f=1/0,d="slice"===u?o.dx:"dice"===u?o.dy:"slice-dice"===u?1&t.depth?o.dy:o.dx:Math.min(o.dx,o.dy);for(c(l,o.dx*o.dy/t.value),s.area=0;(i=l.length)>0;)s.push(e=l[i-1]),s.area+=e.area,"squarify"!==u||(r=p(s,d))<=f?(l.pop(),f=r):(s.area-=s.pop().area,g(s,d,o,!1),d=Math.min(o.dx,o.dy),s.length=s.area=0,f=1/0);s.length&&(g(s,d,o,!0),s.length=s.area=0),n.forEach(h)}}function f(t){var n=t.children;if(n&&n.length){var e,r=a(t),i=n.slice(),o=[];for(c(i,r.dx*r.dy/t.value),o.area=0;e=i.pop();)o.push(e),o.area+=e.area,null!=e.z&&(g(o,e.z?r.dx:r.dy,r,!i.length),o.length=o.area=0);n.forEach(f)}}function p(t,n){for(var e,r=t.area,i=0,o=1/0,a=-1,s=t.length;++a<s;)(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,s=t.length,u=e.x,l=e.y,c=n?r(t.area/n):0;if(n==e.dx){for((i||c>e.dy)&&(c=e.dy);++a<s;)(o=t[a]).x=u,o.y=l,o.dy=c,u+=o.dx=Math.min(e.x+e.dx-u,c?r(o.area/c):0);o.z=!0,o.dx+=e.x+e.dx-u,e.y+=c,e.dy-=c}else{for((i||c>e.dx)&&(c=e.dx);++a<s;)(o=t[a]).x=u,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),s&&(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?(s=t,n=null,d):s},d.ratio=function(t){return arguments.length?(l=t,d):l},d.mode=function(t){return arguments.length?(u=t+"",d):u},Po(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=[],s=0,u=Math.min(n.length,e.length)-1;for(n[u]<n[0]&&(n=n.slice().reverse(),e=e.slice().reverse());++s<=u;)o.push(r(n[s-1],n[s])),a.push(i(e[s-1],e[s]));return function(e){var r=t.bisect(n,e,1,u)-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 s(){var t=Math.min(n.length,e.length)>2?xa:da,s=i?wo:_o;return o=t(n,e,s,r),a=t(e,n,s,Qi),u}function u(t){return o(t)}return u.invert=function(t){return a(t)},u.domain=function(t){return arguments.length?(n=t.map(Number),s()):n},u.range=function(t){return arguments.length?(e=t,s()):e},u.rangeRound=function(t){return u.range(t).interpolate(fo)},u.clamp=function(t){return arguments.length?(i=t,s()):i},u.interpolate=function(t){return arguments.length?(r=t,s()):r},u.ticks=function(t){return Ma(n,t)},u.tickFormat=function(t,e){return ka(n,t,e)},u.nice=function(t){return wa(n,t),s()},u.copy=function(){return t(n,e,r,i)},s()}([0,1],[0,1],Qi,!1)};var Ea={s:1,g:1,p:1,r:1,e:1};function Sa(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}t.scale.log=function(){return function n(e,r,i,o){function a(t){return(i?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(r)}function s(t){return i?Math.pow(r,t):-Math.pow(r,-t)}function u(t){return e(a(t))}return u.invert=function(t){return s(e.invert(t))},u.domain=function(t){return arguments.length?(i=t[0]>=0,e.domain((o=t.map(Number)).map(a)),u):o},u.base=function(t){return arguments.length?(r=+t,e.domain(o.map(a)),u):r},u.nice=function(){var t=ya(o.map(a),i?Math:Ca);return e.domain(t),o=t.map(s),u},u.ticks=function(){var t=pa(o),n=[],e=t[0],u=t[1],l=Math.floor(a(e)),c=Math.ceil(a(u)),h=r%1?2:r;if(isFinite(c-l)){if(i){for(;l<c;l++)for(var f=1;f<h;f++)n.push(s(l)*f);n.push(s(l))}else for(n.push(s(l));l++<c;)for(f=h-1;f>0;f--)n.push(s(l)*f);for(l=0;n[l]<e;l++);for(c=n.length;n[c-1]>u;c--);n=n.slice(l,c)}return n},u.tickFormat=function(n,e){if(!arguments.length)return Aa;arguments.length<2?e=Aa:"function"!=typeof e&&(e=t.format(e));var i=Math.max(1,r*n/u.ticks().length);return function(t){var n=t/s(Math.round(a(t)));return n*r<r-.5&&(n*=r),n<=i?e(t):""}},u.copy=function(){return n(e.copy(),r,i,o)},_a(u,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 s(t){return o[((i.get(t)||("range"===r.t?i.set(t,e.push(t)):NaN))-1)%o.length]}function u(n,r){return t.range(e.length).map((function(t){return n+r*t}))}return s.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 s[r.t].apply(s,r.a)},s.range=function(t){return arguments.length?(o=t,a=0,r={t:"range",a:arguments},s):o},s.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=u(i+c*n/2,c),a=0,r={t:"rangePoints",a:arguments},s},s.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=u(i+Math.round(c*n/2+(l-i-(e.length-1+n)*c)/2),c),a=0,r={t:"rangeRoundPoints",a:arguments},s},s.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=u(c+f*i,f),l&&o.reverse(),a=f*(1-n),r={t:"rangeBands",a:arguments},s},s.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=u(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},s},s.rangeBand=function(){return a},s.rangeExtent=function(){return pa(r.a[0])},s.copy=function(){return n(e,r)},s.domain(e)}([],{t:"range",a:[[]]})},t.scale.category10=function(){return t.scale.ordinal().range(Ta)},t.scale.category20=function(){return t.scale.ordinal().range(Pa)},t.scale.category20b=function(){return t.scale.ordinal().range(Fa)},t.scale.category20c=function(){return t.scale.ordinal().range(La)};var Ta=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(on),Pa=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(on),Fa=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(on),La=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(on);function za(){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 s(){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],s()):[n,e]},a.range=function(t){return arguments.length?(r=t,s()):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)},s()}(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=Ra,n=qa,e=za,r=Da,i=Ua,o=Oa,a=Ia;function s(){var s=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<s&&(g=l,l=s,s=g),f>=At)return u(l,p)+(s?u(s,1-p):"")+"Z";var g,d,y,v,m,x,_,w,b,M,k,E,S=0,A=0,C=[];if((v=(+a.apply(this,arguments)||0)/2)&&(y=r===Da?Math.sqrt(s*s+l*l):+r.apply(this,arguments),p||(A*=-1),l&&(A=zt(y/l*Math.sin(v))),s&&(S=zt(y/s*Math.sin(v)))),l){m=l*Math.cos(c+A),x=l*Math.sin(c+A),_=l*Math.cos(h-A),w=l*Math.sin(h-A);var N=Math.abs(h-c-2*A)<=Et?0:1;if(A&&ja(m,x,_,w)===p^N){var T=(c+h)/2;m=l*Math.cos(T),x=l*Math.sin(T),_=w=null}}else m=x=0;if(s){b=s*Math.cos(h-S),M=s*Math.sin(h-S),k=s*Math.cos(c+S),E=s*Math.sin(c+S);var P=Math.abs(c-h+2*S)<=Et?0:1;if(S&&ja(b,M,k,E)===1-p^P){var F=(c+h)/2;b=s*Math.cos(F),M=s*Math.sin(F),k=E=null}}else b=M=0;if(f>Mt&&(g=Math.min(Math.abs(l-s)/2,+e.apply(this,arguments)))>.001){d=s<l^p?0:1;var L=g,z=g;if(f<Et){var D=null==k?[b,M]:null==_?[m,x]:si([m,x],[k,E],[_,w],[b,M]),R=m-D[0],q=x-D[1],U=_-D[0],O=w-D[1],I=1/Math.sin(Math.acos((R*U+q*O)/(Math.sqrt(R*R+q*q)*Math.sqrt(U*U+O*O)))/2),j=Math.sqrt(D[0]*D[0]+D[1]*D[1]);z=Math.min(g,(s-j)/(I-1)),L=Math.min(g,(l-j)/(I+1))}if(null!=_){var H=Ha(null==k?[b,M]:[k,E],[m,x],l,L,p),V=Ha([_,w],[b,M],l,L,p);g===L?C.push("M",H[0],"A",L,",",L," 0 0,",d," ",H[1],"A",l,",",l," 0 ",1-p^ja(H[1][0],H[1][1],V[1][0],V[1][1]),",",p," ",V[1],"A",L,",",L," 0 0,",d," ",V[0]):C.push("M",H[0],"A",L,",",L," 0 1,",d," ",V[0])}else C.push("M",m,",",x);if(null!=k){var B=Ha([m,x],[k,E],s,-z,p),$=Ha([b,M],null==_?[m,x]:[_,w],s,-z,p);g===z?C.push("L",$[0],"A",z,",",z," 0 0,",d," ",$[1],"A",s,",",s," 0 ",p^ja($[1][0],$[1][1],B[1][0],B[1][1]),",",1-p," ",B[1],"A",z,",",z," 0 0,",d," ",B[0]):C.push("L",$[0],"A",z,",",z," 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",s,",",s," 0 ",P,",",1-p," ",k,",",E);return C.push("Z"),C.join("")}function u(t,n){return"M0,"+t+"A"+t+","+t+" 0 1,"+n+" 0,"+-t+"A"+t+","+t+" 0 1,"+n+" 0,"+t}return s.innerRadius=function(n){return arguments.length?(t=gn(n),s):t},s.outerRadius=function(t){return arguments.length?(n=gn(t),s):n},s.cornerRadius=function(t){return arguments.length?(e=gn(t),s):e},s.padRadius=function(t){return arguments.length?(r=t==Da?Da:gn(t),s):r},s.startAngle=function(t){return arguments.length?(i=gn(t),s):i},s.endAngle=function(t){return arguments.length?(o=gn(t),s):o},s.padAngle=function(t){return arguments.length?(a=gn(t),s):a},s.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]},s};var Da="auto";function Ra(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 ja(t,n,e,r){return(t-e)*n-(n-r)*t>0?0:1}function Ha(t,n,e,r,i){var o=t[0]-n[0],a=t[1]-n[1],s=(i?r:-r)/Math.sqrt(o*o+a*a),u=s*a,l=-s*o,c=t[0]+u,h=t[1]+l,f=n[0]+u,p=n[1]+l,g=(c+f)/2,d=(h+p)/2,y=f-c,v=p-h,m=y*y+v*v,x=e-r,_=c*p-f*h,w=(v<0?-1:1)*Math.sqrt(Math.max(0,x*x*m-_*_)),b=(_*v-y*w)/m,M=(-_*y-v*w)/m,k=(_*v+y*w)/m,E=(-_*y+v*w)/m,S=b-g,A=M-d,C=k-g,N=E-d;return S*S+A*A>C*C+N*N&&(b=k,M=E),[[b-u,M-l],[b*e/x,M*e/x]]}function Va(t){var n=ni,e=ei,r=Ye,i=$a,o=i.key,a=.7;function s(o){var s,u=[],l=[],c=-1,h=o.length,f=gn(n),p=gn(e);function g(){u.push("M",i(t(l),a))}for(;++c<h;)r.call(this,s=o[c],c)?l.push([+f.call(this,s,c),+p.call(this,s,c)]):l.length&&(g(),l=[]);return l.length&&g(),u.length?u.join(""):null}return s.x=function(t){return arguments.length?(n=t,s):n},s.y=function(t){return arguments.length?(e=t,s):e},s.defined=function(t){return arguments.length?(r=t,s):r},s.interpolate=function(t){return arguments.length?(o="function"==typeof t?i=t:(i=Ba.get(t)||$a).key,s):o},s.tension=function(t){return arguments.length?(a=t,s):a},s}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(ns,o)+","+Ja(ns,a)),--r;++r<i;)n=t[r],o.shift(),o.push(n[0]),a.shift(),a.push(n[1]),es(e,o,a);return e.join("")},"basis-closed":function(t){for(var n,e,r=-1,i=t.length,o=i+4,a=[],s=[];++r<4;)e=t[r%i],a.push(e[0]),s.push(e[1]);for(n=[Ja(ns,a),",",Ja(ns,s)],--r;++r<o;)e=t[r%i],a.shift(),a.push(e[0]),s.shift(),s.push(e[1]),es(n,a,s);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],s=t[e][0]-o,u=t[e][1]-a,l=-1;++l<=e;)i=l/e,(r=t[l])[0]=n*r[0]+(1-n)*(o+i*s),r[1]=n*r[1]+(1-n)*(a+i*u);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]=rs(i,o);++n<e;)r[n]=(a+(a=rs(i=o,o=t[n+1])))/2;return r[n]=a,r}(t),s=-1,u=t.length-1;++s<u;)n=rs(t[s],t[s+1]),v(n)<Mt?a[s]=a[s+1]=0:(i=(e=a[s]/n)*e+(r=a[s+1]/n)*r)>9&&(i=3*n/Math.sqrt(i),a[s]=i*e,a[s+1]=i*r);for(s=-1;++s<=u;)i=(t[Math.min(u,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+a[s]*a[s])),o.push([i||0,a[s]*i||0]);return o}(t))}});function $a(t){return t.length>1?t.join("L"):t+"Z"}function Ya(t){return t.join("L")+"Z"}function Wa(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];++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],s=a,u=1;if(e&&(r+="Q"+(o[0]-2*a[0]/3)+","+(o[1]-2*a[1]/3)+","+o[0]+","+o[1],i=t[1],u=2),n.length>1){s=n[1],o=t[u],u++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(o[0]-s[0])+","+(o[1]-s[1])+","+o[0]+","+o[1];for(var l=2;l<n.length;l++,u++)o=t[u],s=n[l],r+="S"+(o[0]-s[0])+","+(o[1]-s[1])+","+o[0]+","+o[1]}if(e){var c=t[u];r+="Q"+(o[0]+2*s[0]/3)+","+(o[1]+2*s[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],s=1,u=t.length;++s<u;)e=o,o=a,a=t[s],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]],s=[o,o,o,r[1]],u=[i,",",o,"L",Ja(ns,a),",",Ja(ns,s)];for(t.push(t[e-1]);++n<=e;)r=t[n],a.shift(),a.push(r[0]),s.shift(),s.push(r[1]),es(u,a,s);return t.pop(),u.push("L",r),u.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],ts=[0,1/3,2/3,0],ns=[0,1/6,2/3,1/6];function es(t,n,e){t.push("C",Ja(Ka,n),",",Ja(Ka,e),",",Ja(ts,n),",",Ja(ts,e),",",Ja(ns,n),",",Ja(ns,e))}function rs(t,n){return(n[1]-t[1])/(n[0]-t[0])}function is(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 os(t){var n=ni,e=ni,r=0,i=ei,o=Ye,a=$a,s=a.key,u=a,l="L",c=.7;function h(s){var h,f,p,g=[],d=[],y=[],v=-1,m=s.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,u(t(d.reverse()),c),"Z")}for(;++v<m;)o.call(this,h=s[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?(s="function"==typeof t?a=t:(a=Ba.get(t)||$a).key,u=a.reverse||a,l=a.closed?"M":"L",h):s},h.tension=function(t){return arguments.length?(c=t,h):c},h}function as(t){return t.radius}function ss(t){return[t.x,t.y]}function us(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 ls(){return 64}function cs(){return"circle"}function hs(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(is);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 os(N)},t.svg.area.radial=function(){var t=os(is);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=jr,n=Hr,e=as,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+s(l.r,l.p1,l.a1-l.a0)+(o=c,((i=l).a0==o.a0&&i.a1==o.a1?u(l.r,l.p1,l.r,l.p0):u(l.r,l.p1,c.r,c.p0)+s(c.r,c.p1,c.a1-c.a0)+u(c.r,c.p1,l.r,l.p0))+"Z")}function a(t,n,o,a){var s=n.call(t,o,a),u=e.call(t,s,a),l=r.call(t,s,a)-Ct,c=i.call(t,s,a)-Ct;return{r:u,a0:l,a1:c,p0:[u*Math.cos(l),u*Math.sin(l)],p1:[u*Math.cos(c),u*Math.sin(c)]}}function s(t,n,e){return"A"+t+","+t+" 0 "+ +(e>Et)+",1 "+n}function u(t,n,e,r){return"Q 0,0 "+r}return o.radius=function(t){return arguments.length?(e=gn(t),o):e},o.source=function(n){return arguments.length?(t=gn(n),o):t},o.target=function(t){return arguments.length?(n=gn(t),o):n},o.startAngle=function(t){return arguments.length?(r=gn(t),o):r},o.endAngle=function(t){return arguments.length?(i=gn(t),o):i},o},t.svg.diagonal=function(){var t=jr,n=Hr,e=ss;function r(r,i){var o=t.call(this,r,i),a=n.call(this,r,i),s=(o.y+a.y)/2,u=[o,{x:o.x,y:s},{x:a.x,y:s},a];return"M"+(u=u.map(e))[0]+"C"+u[1]+" "+u[2]+" "+u[3]}return r.source=function(n){return arguments.length?(t=gn(n),r):t},r.target=function(t){return arguments.length?(n=gn(t),r):n},r.projection=function(t){return arguments.length?(e=t,r):e},r},t.svg.diagonal.radial=function(){var n=t.svg.diagonal(),e=ss,r=n.projection;return n.projection=function(t){return arguments.length?r(us(e=t)):e},n},t.svg.symbol=function(){var t=cs,n=ls;function e(e,r){return(fs.get(t.call(this,e,r))||hs)(n.call(this,e,r))}return e.type=function(n){return arguments.length?(t=gn(n),e):t},e.size=function(t){return arguments.length?(n=gn(t),e):n},e};var fs=t.map({circle:hs,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*gs)),e=n*gs;return"M0,"+-n+"L"+e+",0 0,"+n+" "+-e+",0Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/ps),e=n*ps/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/ps),e=n*ps/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});t.svg.symbolTypes=fs.keys();var ps=Math.sqrt(3),gs=Math.tan(30*Nt);$.transition=function(t){for(var n,e,r=ms||++ws,i=ks(t),o=[],a=xs||{time:Date.now(),ease:so,delay:0,duration:250},s=-1,u=this.length;++s<u;){o.push(n=[]);for(var l=this[s],c=-1,h=l.length;++c<h;)(e=l[c])&&Es(e,c,i,r,a),n.push(e)}return vs(o,i,r)},$.interrupt=function(t){return this.each(null==t?ds:ys(ks(t)))};var ds=ys(ks());function ys(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 vs(t,n,e){return I(t,_s),t.namespace=n,t.id=e,t}var ms,xs,_s=[],ws=0;function bs(t,n,e,r){var i=t.id,o=t.namespace;return lt(t,"function"==typeof e?function(t,a,s){t[o][i].tween.set(n,r(e.call(t,t.__data__,a,s)))}:(e=r(e),function(t){t[o][i].tween.set(n,e)}))}function Ms(t){return null==t&&(t=""),function(){this.textContent=t}}function ks(t){return null==t?"__transition__":"__transition_"+t+"__"}function Es(t,n,e,r,i){var o,a,s,u,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)})),u=h.ease,s=h.duration}function p(i){for(var o=i/s,a=u(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)}_s.call=$.call,_s.empty=$.empty,_s.node=$.node,_s.size=$.size,t.transition=function(n,e){return n&&n.transition?ms?n.transition(e):n:t.selection().transition(n)},t.transition.prototype=_s,_s.select=function(t){var n,e,r,i=this.id,o=this.namespace,a=[];t=Y(t);for(var s=-1,u=this.length;++s<u;){a.push(n=[]);for(var l=this[s],c=-1,h=l.length;++c<h;)(r=l[c])&&(e=t.call(r,r.__data__,c,s))?("__data__"in r&&(e.__data__=r.__data__),Es(e,c,o,i,r[o][i]),n.push(e)):n.push(null)}return vs(a,o,i)},_s.selectAll=function(t){var n,e,r,i,o,a=this.id,s=this.namespace,u=[];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[s][a],e=t.call(r,r.__data__,f,l),u.push(n=[]);for(var g=-1,d=e.length;++g<d;)(i=e[g])&&Es(i,g,s,a,o),n.push(i)}return vs(u,s,a)},_s.filter=function(t){var n,e,r=[];"function"!=typeof t&&(t=st(t));for(var i=0,o=this.length;i<o;i++){r.push(n=[]);for(var a,s=0,u=(a=this[i]).length;s<u;s++)(e=a[s])&&t.call(e,e.__data__,s,i)&&n.push(e)}return vs(r,this.namespace,this.id)},_s.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)})},_s.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 s(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 u(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 bs(this,"attr."+n,e,i.local?u:s)},_s.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))}})},_s.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 bs(this,"style."+t,n,a)},_s.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)},_s.text=function(t){return bs(this,"text",t,Ms)},_s.remove=function(){var t=this.namespace;return this.each("end.transition",(function(){var n;this[t].count<2&&(n=this.parentNode)&&n.removeChild(this)}))},_s.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})))},_s.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}))},_s.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}))},_s.each=function(n,e){var r=this.id,i=this.namespace;if(arguments.length<2){var o=xs,a=ms;try{ms=r,lt(this,(function(t,e,o){xs=t[i][r],n.call(t,t.__data__,e,o)}))}finally{xs=o,ms=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},_s.transition=function(){for(var t,n,e,r=this.id,i=++ws,o=this.namespace,a=[],s=0,u=this.length;s<u;s++){a.push(t=[]);for(var l,c=0,h=(l=this[s]).length;c<h;c++)(n=l[c])&&Es(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 vs(a,o,i)},t.svg.axis=function(){var n,r=t.scale.linear(),i=Ss,o=6,a=6,s=3,u=[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,u):f.domain():l,g=null==n?f.tickFormat?f.tickFormat.apply(f,u):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)+s,_=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),P=y.select("text"),F=m.select("text"),L="top"===i||"left"===i?-1:1;if("bottom"===i||"top"===i?(e=Cs,M="x",E="y",k="x2",S="y2",T.attr("dy",L<0?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+_[0]+","+L*a+"V0H"+_[1]+"V"+L*a)):(e=Ns,M="y",E="x",k="y2",S="x2",T.attr("dy",".32em").style("text-anchor",L<0?"end":"start"),b.attr("d","M"+L*a+","+_[0]+"H0V"+_[1]+"H"+L*a)),A.attr(S,L*o),P.attr(E,L*x),C.attr(k,0).attr(S,L*o),F.attr(M,0).attr(E,L*x),f.rangeBand){var z=f,D=z.rangeBand()/2;h=f=function(t){return z(t)+D}}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 As?t+"":Ss,c):i},c.ticks=function(){return arguments.length?(u=e(arguments),c):u},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?(s=+t,c):s},c.tickSubdivide=function(){return arguments.length&&c},c};var Ss="bottom",As={top:1,right:1,bottom:1,left:1};function Cs(t,n,e){t.attr("transform",(function(t){var r=n(t);return"translate("+(isFinite(r)?r:e(t))+",0)"}))}function Ns(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,s=[0,0],u=[0,0],l=!0,c=!0,h=Ps[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 Ts[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,s=t.transition(n),u=t.transition(e);i&&(o=ga(i),u.attr("x",o[0]).attr("width",o[1]-o[0]),g(s)),a&&(o=ga(a),u.attr("y",o[0]).attr("height",o[1]-o[0]),d(s)),p(s)}))}function p(t){t.selectAll(".resize").attr("transform",(function(t){return"translate("+s[+/e$/.test(t)]+","+u[+/^s/.test(t)]+")"}))}function g(t){t.select(".extent").attr("x",s[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function d(t){t.select(".extent").attr("y",u[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",u[1]-u[0])}function y(){var h,y,v=this,m=t.select(t.event.target),x=r.of(v,arguments),_=t.select(v),w=m.datum(),b=!/^(n|s)$/.test(w)&&i,M=!/^(e|w)$/.test(w)&&a,k=m.classed("extent"),E=xt(v),S=t.mouse(v),A=t.select(o(v)).on("keydown.brush",T).on("keyup.brush",P);if(t.event.changedTouches?A.on("touchmove.brush",F).on("touchend.brush",z):A.on("mousemove.brush",F).on("mouseup.brush",z),_.interrupt().selectAll("*").interrupt(),k)S[0]=s[0]-S[0],S[1]=u[0]-S[1];else if(w){var C=+/w$/.test(w),N=+/^n/.test(w);y=[s[1-C]-S[0],u[1-N]-S[1]],S[0]=s[C],S[1]=u[N]}else t.event.altKey&&(h=S.slice());function T(){32==t.event.keyCode&&(k||(h=null,S[0]-=s[1],S[1]-=u[1],k=2),R())}function P(){32==t.event.keyCode&&2==k&&(S[0]+=s[1],S[1]+=u[1],k=0,R())}function F(){var n=t.mouse(v),e=!1;y&&(n[0]+=y[0],n[1]+=y[1]),k||(t.event.altKey?(h||(h=[(s[0]+s[1])/2,(u[0]+u[1])/2]),S[0]=s[+(n[0]<h[0])],S[1]=u[+(n[1]<h[1])]):h=null),b&&L(n,i,0)&&(g(_),e=!0),M&&L(n,a,1)&&(d(_),e=!0),e&&(p(_),x({type:"brush",mode:k?"move":"resize"}))}function L(t,r,i){var o,a,f=ga(r),p=f[0],g=f[1],d=S[i],y=i?u:s,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 z(){F(),_.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"}),F()}return f.event=function(i){i.each((function(){var i=r.of(this,arguments),o={x:s,y:u,i:n,j:e},a=this.__chart__||o;this.__chart__=o,ms?t.select(this).transition().each("start.brush",(function(){n=a.i,e=a.j,s=a.x,u=a.y,i({type:"brushstart"})})).tween("brush:brush",(function(){var t=Ji(s,o.x),r=Ji(u,o.y);return n=e=null,function(n){s=o.x=t(n),u=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=Ps[!(i=t)<<1|!a],f):i},f.y=function(t){return arguments.length?(h=Ps[!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==s[0]&&o==s[1]||(s=[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==u[0]&&c==u[1]||(u=[l,c])),f):(i&&(n?(r=n[0],o=n[1]):(r=s[0],o=s[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=u[0],c=u[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()||(s=[0,0],u=[0,0],n=e=null),f},f.empty=function(){return!!i&&s[0]==s[1]||!!a&&u[0]==u[1]},t.rebind(f,r,"on")};var Ts={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ps=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Fs=Fn.format=se.timeFormat,Ls=Fs.utc,zs=Ls("%Y-%m-%dT%H:%M:%S.%LZ");function Ds(t){return t.toISOString()}function Rs(n,e,r){function i(t){return n(t)}function o(n,r){var i=(n[1]-n[0])/r,o=t.bisect(Us,i);return o==Us.length?[e.year,ba(n.map((function(t){return t/31536e6})),r)[2]]:o?e[i/Us[o-1]<Us[o]/i?o-1:o]:[js,ba(n,r)[2]]}return i.invert=function(t){return qs(n.invert(t))},i.domain=function(t){return arguments.length?(n.domain(t),i):n.domain().map(qs)},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 s(e){return!isNaN(e)&&!t.range(e,qs(+e+1),n).length}return a&&(t=a[0],n=a[1]),i.domain(ya(e,n>1?{floor:function(n){for(;s(n=t.floor(n));)n=qs(n-1);return n},ceil:function(n){for(;s(n=t.ceil(n));)n=qs(+n+1);return n}}:t))},i.ticks=function(t,n){var e=pa(i.domain()),r=null==t?o(e,10):"number"==typeof t?o(e,t):!t.range&&[{range:t},n];return r&&(t=r[0],n=r[1]),t.range(e[0],qs(+e[1]+1),n<1?1:n)},i.tickFormat=function(){return r},i.copy=function(){return Rs(n.copy(),e,r)},_a(i,n)}function qs(t){return new Date(t)}Fs.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ds:zs,Ds.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},Ds.toString=zs.toString,Fn.second=Rn((function(t){return new Ln(1e3*Math.floor(t/1e3))}),(function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))}),(function(t){return t.getSeconds()})),Fn.seconds=Fn.second.range,Fn.seconds.utc=Fn.second.utc.range,Fn.minute=Rn((function(t){return new Ln(6e4*Math.floor(t/6e4))}),(function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))}),(function(t){return t.getMinutes()})),Fn.minutes=Fn.minute.range,Fn.minutes.utc=Fn.minute.utc.range,Fn.hour=Rn((function(t){var n=t.getTimezoneOffset()/60;return new Ln(36e5*(Math.floor(t/36e5-n)+n))}),(function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))}),(function(t){return t.getHours()})),Fn.hours=Fn.hour.range,Fn.hours.utc=Fn.hour.utc.range,Fn.month=Rn((function(t){return(t=Fn.day(t)).setDate(1),t}),(function(t,n){t.setMonth(t.getMonth()+n)}),(function(t){return t.getMonth()})),Fn.months=Fn.month.range,Fn.months.utc=Fn.month.utc.range;var Us=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Os=[[Fn.second,1],[Fn.second,5],[Fn.second,15],[Fn.second,30],[Fn.minute,1],[Fn.minute,5],[Fn.minute,15],[Fn.minute,30],[Fn.hour,1],[Fn.hour,3],[Fn.hour,6],[Fn.hour,12],[Fn.day,1],[Fn.day,2],[Fn.week,1],[Fn.month,1],[Fn.month,3],[Fn.year,1]],Is=Fs.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Ye]]),js={range:function(n,e,r){return t.range(Math.ceil(n/r)*r,+e,r).map(qs)},floor:N,ceil:N};Os.year=Fn.year,Fn.scale=function(){return Rs(t.scale.linear(),Os,Is)};var Hs=Os.map((function(t){return[t[0].utc,t[1]]})),Vs=Ls.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Ye]]);function Bs(t){return JSON.parse(t.responseText)}function $s(t){var n=r.createRange();return n.selectNode(r.body),n.createContextualFragment(t.responseText)}Hs.year=Fn.year.utc,Fn.scale.utc=function(){return Rs(t.scale.linear(),Hs,Vs)},t.text=dn((function(t){return t.responseText})),t.json=function(t,n){return yn(t,"application/json",Bs,n)},t.html=function(t,n){return yn(t,"text/html",$s,n)},t.xml=dn((function(t){return t.responseXML})),"function"==typeof define&&define.amd?(this.d3=t,define(t)):"object"==typeof module&&module.exports?module.exports=t:this.d3=t}(),null==window.Epoch&&(window.Epoch={}),null==(base=window.Epoch).Chart&&(base.Chart={}),null==(base1=window.Epoch).Time&&(base1.Time={}),null==(base2=window.Epoch).Util&&(base2.Util={}),null==(base3=window.Epoch).Formats&&(base3.Formats={}),Epoch.warn=function(t){return(console.warn||console.log)("Epoch Warning: "+t)},Epoch.exception=function(t){throw"Epoch Error: "+t},Epoch.TestContext=function(){var t;function n(){var n,e,r;for(this._log=[],n=0,e=t.length;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 ref,typeFunction,d3Seconds,hasProp={}.hasOwnProperty;typeFunction=function(t){return function(n){return Object.prototype.toString.call(n)==="[object "+t+"]"}},Epoch.isArray=null!=(ref=Array.isArray)?ref:typeFunction("Array"),Epoch.isObject=typeFunction("Object"),Epoch.isString=typeFunction("String"),Epoch.isFunction=typeFunction("Function"),Epoch.isNumber=typeFunction("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)hasProp.call(t,e)&&(r=t[e],n[e]=r);return n},Epoch.Util.defaults=function(t,n){var e,r,i,o,a;for(i in a=Epoch.Util.copy(t),n)hasProp.call(n,i)&&(n[i],o=t[i],r=n[i],e=Epoch.isObject(o)&&Epoch.isObject(r),null!=o&&null!=r?e&&!Epoch.isArray(o)?a[i]=Epoch.Util.defaults(o,r):a[i]=o:a[i]=null!=o?o:r);return a},Epoch.Util.formatSI=function(t,n,e){var r,i,o,a,s;if(null==n&&(n=1),null==e&&(e=!1),t<1e3)return((0|(a=t))!==a||e)&&(a=a.toFixed(n)),a;for(i in s=["K","M","G","T","P","E","Z","Y"])if(hasProp.call(s,i)&&(o=s[i],t>=(r=Math.pow(10,3*(1+(0|i))))&&t<Math.pow(10,3*(2+(0|i)))))return((a=t/r)%1!=0||e)&&(a=a.toFixed(n)),a+" "+o},Epoch.Util.formatBytes=function(t,n,e){var r,i,o,a,s;if(null==n&&(n=1),null==e&&(e=!1),t<1024)return((a=t)%1!=0||e)&&(a=a.toFixed(n)),a+" B";for(i in s=["KB","MB","GB","TB","PB","EB","ZB","YB"])if(hasProp.call(s,i)&&(o=s[i],t>=(r=Math.pow(1024,1+(0|i)))&&t<Math.pow(1024,2+(0|i))))return((a=t/r)%1!=0||e)&&(a=a.toFixed(n)),a+" "+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,s,u,l;for(null==n&&(n="x"),l={},e=[],i=0,a=t.length;i<a;i++)for(o=0,s=(u=t[i].values).length;o<s;o++)null==l[(r=u[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)hasProp.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,a;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 a=[],t)hasProp.call(t,i)&&(n=t[i],a.push(this.off(i,n)));return a}},t.prototype.trigger=function(t){var n,e,r,i,o,a,s,u;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),u=[],o=0,a=(s=this._events[t]).length;o<a;o++)e=s[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."),u.push(r.apply(this,n));return u}},t}(),Epoch.Util.flatten=function(t){var n,e,r,i,o,a,s;if(!Array.isArray(t))throw new Error("Epoch.Util.flatten only accepts arrays");for(s=[],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],s.push(e);else s.push(n);return s},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 d3Seconds(new Date(1e3*t))},d3Seconds=d3.time.format("%I:%M:%S %p"),Epoch.Formats.bytes=function(t){return Epoch.Util.formatBytes(t)};var QueryCSS,extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t};hasProp={}.hasOwnProperty,Epoch.Chart.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 extend(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)hasProp.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 extend(n,t),n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.svg.attr("width",this.width).attr("height",this.height)},n}(Epoch.Chart.Base),Epoch.Chart.Canvas=function(t){function n(t){this.options=null!=t?t:{},n.__super__.constructor.call(this,this.options),null!=this.options.pixelRatio?this.pixelRatio=this.options.pixelRatio:null!=window.devicePixelRatio?this.pixelRatio=window.devicePixelRatio:this.pixelRatio=1,this.canvas=d3.select(document.createElement("CANVAS")),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()}),null!=this.el&&this.el.node().appendChild(this.canvas.node()),this.ctx=Epoch.Util.getContext(this.canvas.node())}return extend(n,t),n.prototype.getWidth=function(){return this.width*this.pixelRatio},n.prototype.getHeight=function(){return this.height*this.pixelRatio},n.prototype.clear=function(){return this.ctx.clearRect(0,0,this.getWidth(),this.getHeight())},n.prototype.getStyles=function(t){return Epoch.QueryCSS.getStyles(t,this.el)},n.prototype.dimensionsChanged=function(){return n.__super__.dimensionsChanged.call(this),this.canvas.style({width:this.width+"px",height:this.height+"px"}),this.canvas.attr({width:this.getWidth(),height:this.getHeight()})},n.prototype.redraw=function(){return Epoch.QueryCSS.purge(),this.draw()},n}(Epoch.Chart.Base),QueryCSS=function(){var t,n,e,r,i;function o(){}return n=0,r=function(){return"epoch-container-"+n++},t=/^([^#. ]+)?(#[^. ]+)?(\.[^# ]+)?$/,e=!1,i=function(n){var e,r,i,o,a;return null==(o=n.match(t))?Epoch.error("Query CSS cannot match given selector: "+n):(o[0],a=o[1],i=o[2],e=o[3],a=(null!=a?a:"div").toUpperCase(),r=document.createElement(a),null!=i&&(r.id=i.substr(1)),null!=e&&(r.className=e.substr(1).replace(/\./g," ")),r)},o.log=function(t){return e=t},o.cache={},o.styleList=["fill","stroke","stroke-width"],o.container=null,o.purge=function(){return o.cache={}},o.getContainer=function(){var t;return null!=o.container?o.container:((t=document.createElement("DIV")).id="_canvas_css_reference",document.body.appendChild(t),o.container=d3.select(t))},o.hash=function(t,n){var e;return null==(e=n.attr("data-epoch-container-id"))&&(e=r(),n.attr("data-epoch-container-id",e)),e+"__"+t},o.getStyles=function(t,n){var r,a,s,u,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k,E,S;if(a=o.hash(t,n),null!=(r=o.cache[a]))return r;for(m=[],v=n.node().parentNode;null!=v&&"body"!==v.nodeName.toLowerCase();)m.unshift(v),v=v.parentNode;for(m.push(n.node()),k=[],l=0,f=m.length;l<f;l++)M=(u=m[l]).nodeName.toLowerCase(),null!=u.id&&u.id.length>0&&(M+="#"+u.id),null!=u.className&&u.className.length>0&&(M+="."+Epoch.Util.trim(u.className).replace(/\s+/g,".")),k.push(M);for(k.push("svg"),c=0,p=(_=Epoch.Util.trim(t).split(/\s+/)).length;c<p;c++)S=_[c],k.push(S);for(e&&console.log(k),y=b=i(k.shift());k.length;)s=i(k.shift()),y.appendChild(s),y=s;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=QueryCSS,hasProp={}.hasOwnProperty;var applyLayerLabel,base,jQueryModule,MooToolsModule,zeptoModule,slice=[].slice;null==Epoch.Data&&(Epoch.Data={}),null==(base=Epoch.Data).Format&&(base.Format={}),applyLayerLabel=function(t,n,e,r){var i,o,a,s,u;if(null==r&&(r=[]),i=(u=[n.labels,n.autoLabels,n.keyLabels])[1],o=u[2],null!=(s=u[0])&&Epoch.isArray(s)&&s.length>e)t.label=s[e];else if(o&&r.length>e)t.label=r[e];else if(i){for(a=[];e>=0;)a.push(String.fromCharCode(65+e%26)),e-=26;t.label=a.join("")}return t},Epoch.Data.Format.array=function(){var t,n,e,r,i,o,a;return n={x:function(t,n){return n},y:function(t,n){return t},time:function(t,n,e){return parseInt(e)+parseInt(n)},type:"area",autoLabels:!1,labels:[],startTime:parseInt((new Date).getTime()/1e3)},t=function(t,n,e){var r,i,o;if(i=[],Epoch.isArray(t[0]))for(r in t)hasProp.call(t,r)&&(o=t[r],i.push(applyLayerLabel({values:o.map(e)},n,parseInt(r))));else i.push(applyLayerLabel({values:t.map(e)},n,0));return i},r=function(n,e){return t(n,e,(function(t,n){return{x:e.x(t,n),y:e.y(t,n)}}))},a=function(n,e){return t(n,e,(function(t,n){return{time:e.time(t,n,e.startTime),y:e.y(t,n)}}))},i=function(n,e){return t(n,e,(function(t,n){return{time:e.time(t,n,e.startTime),histogram:t}}))},o=function(t,n){var e,r,i;for(e in r=[],t)if(hasProp.call(t,e)){if(i=t[e],!Epoch.isNumber(t[0]))return[];r.push(applyLayerLabel({value:i},n,e))}return r},(e=function(t,e){var s;return null==t&&(t=[]),null==e&&(e={}),Epoch.isNonEmptyArray(t)?"time.heatmap"===(s=Epoch.Util.defaults(e,n)).type?i(t,s):s.type.match(/^time\./)?a(t,s):"pie"===s.type?o(t,s):r(t,s):[]}).entry=function(t,r){var i,o,a,s,u,l,c,h;if(null==r&&(r={}),"time.gauge"===r.type)return null==t?0:(l=Epoch.Util.defaults(r,n),i=Epoch.isArray(t)?t[0]:t,l.y(i,0));if(null==t)return[];for(null==r.startTime&&(r.startTime=parseInt((new Date).getTime()/1e3)),o=Epoch.isArray(t)?t.map((function(t){return[t]})):[t],h=[],a=0,u=(c=e(o,r)).length;a<u;a++)s=c[a],h.push(s.values[0]);return h},e}(),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)hasProp.call(t,r)&&(o=t[r],i.push(applyLayerLabel({values:o.map(e)},n,parseInt(r))));else i.push(applyLayerLabel({values:t.map(e)},n,0));return i},(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,s,u;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],u=[],i=0,a=(s=e(r,n)).length;i<a;i++)o=s[i],u.push(o.values[0]);return u},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,a,s,u,l;for(a in u=[],n)if(hasProp.call(n,a)){for(o in s=n[a],l=[],t)hasProp.call(t,o)&&(i=t[o],l.push(r(i,s,parseInt(o))));u.push(applyLayerLabel({values:l},e,parseInt(a),n))}return u},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,s,u;if(null==n&&(n=[]),null==r&&(r={}),null==t||!Epoch.isNonEmptyArray(n))return[];for(null==r.startTime&&(r.startTime=parseInt((new Date).getTime()/1e3)),u=[],i=0,a=(s=e([t],n,r)).length;i<a;i++)o=s[i],u.push(o.values[0]);return u},e}(),Epoch.data=function(){var t,n,e;return e=arguments[0],t=2<=arguments.length?slice.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,s,u;if(null==t&&(t=[]),!Epoch.isNonEmptyArray(t))return t;if(Epoch.isString(e))return s={type:n},Epoch.data(e,t,s);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=(u=e.arguments).length;o<a;o++)r=u[o],i.push(r);return null!=e.options?(s=e.options,null!=n&&null==s.type&&(s.type=n),i.push(s)):null!=n&&i.push({type:n}),Epoch.data.apply(Epoch.data,i)},Epoch.Data.formatEntry=function(t,n,e){var r,i,o,a,s,u,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(s=0,u=(c=o.arguments).length;s<u;s++)r=c[s],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)},extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.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 extend(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),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.Plot=function(t){var n,e,r;function i(t){var o,a,s,u;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=(u=["top","right","bottom","left"]).length;o<a;o++)s=u[o],this.margins[s]=null!=this.options.margins&&null!=this.options.margins[s]?this.options.margins[s]:this.hasAxis(s)?n[s]:6;this.g=this.svg.append("g").attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.onAll(r)}return extend(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)hasProp.call(n,t)&&(e=n[t],this.margins[t]=null==e?6:e);return this.g.transition().duration(750).attr("transform","translate("+this.margins.left+", "+this.margins.top+")"),this.draw()}},i.prototype.axesChanged=function(){var t,e,r,i;for(t=0,e=(i=["top","right","bottom","left"]).length;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),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.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 extend(n,t),n.prototype.y=function(){var t,n,e,r,i,o,a,s;for(t=[],n=0,r=(i=this.getVisibleLayers()).length;n<r;n++)for(e in o=i[n].values)hasProp.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!=(a=this.options.range)?a:[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),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.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 extend(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,a,s,u,l,c,h,f,p;for(u={},e=0,a=(c=this.getVisibleLayers()).length;e<a;e++)for(t="bar "+(o=c[e]).className.replace(/\s*layer\s*/,""),i=0,s=(h=o.values).length;i<s;i++)null==u[l=(n=h[i]).x]&&(u[l]=[]),u[n.x].push({label:o.category,y:n.y,className:t});for(r in f=[],u)hasProp.call(u,r)&&(p=u[r],f.push({group:r,values:p}));return f},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,s;return i=[this.x(),this.y()],o=i[0],s=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 s(t.y)})).attr("width",a.rangeBand()).attr("height",(function(t){return n-s(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 s(t.y)})).attr("width",a.rangeBand()).attr("height",(function(t){return n-s(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),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.Histogram=function(t){var n,e;function r(t){this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.onAll(e),this.draw()}return extend(r,t),n={type:"histogram",domain:[0,100],bucketRange:[0,100],buckets:10,cutOutliers:!1},e={"option:bucketRange":"bucketRangeChanged","option:buckets":"bucketsChanged","option:cutOutliers":"cutOutliersChanged"},r.prototype._prepareData=function(t){var n,e,r,i,o,a,s,u,l,c,h,f,p,g;for(n=(this.options.bucketRange[1]-this.options.bucketRange[0])/this.options.buckets,h=[],i=0,u=t.length;i<u;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),a=0,l=(p=s.values).length;a<l;a++)c=p[a],r=parseInt((c.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(c.y));for(o in f={values:e.map((function(t,e){return{x:parseInt(e)*n,y:t}}))},s)hasProp.call(s,o)&&(g=s[o],"values"!==o&&(f[o]=g));h.push(f)}return h},r.prototype.resetData=function(){return this.setData(this.rawData),this.draw()},r.prototype.bucketRangeChanged=function(){return this.resetData()},r.prototype.bucketsChanged=function(){return this.resetData()},r.prototype.cutOutliersChanged=function(){return this.resetData()},r}(Epoch.Chart.Bar),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.Line=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="line"),n.__super__.constructor.call(this,this.options),this.draw()}return extend(n,t),n.prototype.line=function(t){var n,e,r;return n=[this.x(),this.y(t.range)],e=n[0],r=n[1],d3.svg.line().x((function(t){return e(t.x)})).y((function(t){return r(t.y)}))},n.prototype.draw=function(){var t,e,r;return 0===(this.x(),this.y(),e=this.getVisibleLayers()).length?this.g.selectAll(".layer").remove():((t=this.g.selectAll(".layer").data(e,(function(t){return t.category}))).select(".line").transition().duration(500).attr("d",(r=this,function(t){return r.line(t)(t.values)})),t.enter().append("g").attr("class",(function(t){return t.className})).append("path").attr("class","line").attr("d",function(t){return function(n){return t.line(n)(n.values)}}(this)),t.exit().transition().duration(750).style("opacity","0").remove(),n.__super__.draw.call(this))},n}(Epoch.Chart.Plot),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.Pie=function(t){var n;function e(t){var r;this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.pie=d3.layout.pie().sort(null).value((function(t){return t.value})),this.arc=d3.svg.arc().outerRadius((r=this,function(){return Math.max(r.width,r.height)/2-r.options.margin})).innerRadius(function(t){return function(){return t.options.inner}}(this)),this.g=this.svg.append("g").attr("transform","translate("+this.width/2+", "+this.height/2+")"),this.on("option:margin","marginChanged"),this.on("option:inner","innerChanged"),this.draw()}return extend(e,t),n={type:"pie",margin:10,inner:0},e.prototype.draw=function(){var t,n;return this.g.selectAll(".arc").remove(),(t=this.g.selectAll(".arc").data(this.pie(this.getVisibleLayers()),(function(t){return t.data.category}))).enter().append("g").attr("class",(function(t){return"arc pie "+t.data.className})),t.select("path").attr("d",this.arc),t.select("text").attr("transform",(n=this,function(t){return"translate("+n.arc.centroid(t)+")"})).text((function(t){return t.data.label||t.data.category})),t.append("path").attr("d",this.arc).each((function(t){return this._current=t})),t.append("text").attr("transform",function(t){return function(n){return"translate("+t.arc.centroid(n)+")"}}(this)).attr("dy",".35em").style("text-anchor","middle").text((function(t){return t.data.label||t.data.category})),e.__super__.draw.call(this)},e.prototype.marginChanged=function(){return this.draw()},e.prototype.innerChanged=function(){return this.draw()},e}(Epoch.Chart.SVG),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Chart.Scatter=function(t){var n;function e(t){this.options=null!=t?t:{},e.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.on("option:radius","radiusChanged"),this.draw()}return extend(e,t),n={type:"scatter",radius:3.5,axes:["top","bottom","left","right"]},e.prototype.draw=function(){var t,n,r,i,o,a,s;return o=[this.x(),this.y(),this.getVisibleLayers()],a=o[0],s=o[1],r=o[2],i=this.options.radius,0===r.length?this.g.selectAll(".layer").remove():((n=this.g.selectAll(".layer").data(r,(function(t){return t.category}))).enter().append("g").attr("class",(function(t){return t.className})),(t=n.selectAll(".dot").data((function(t){return t.values}))).transition().duration(500).attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return s(t.y)})),t.enter().append("circle").attr("class","dot").attr("r",(function(t){var n;return null!=(n=t.r)?n:i})).attr("cx",(function(t){return a(t.x)})).attr("cy",(function(t){return s(t.y)})),t.exit().transition().duration(750).style("opacity",0).remove(),n.exit().transition().duration(750).style("opacity",0).remove(),e.__super__.draw.call(this))},e.prototype.radiusChanged=function(){return this.draw()},e}(Epoch.Chart.Plot),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Time.Plot=function(t){var n,e,r;function i(t){var o,a,s,u,l;for(this.options=t,Epoch.Util.copy(this.options.margins),i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this.options.model&&this.options.model.on("data:push",(l=this,function(){return l.pushFromModel()})),this._queue=[],this.margins={},o=0,a=(u=["top","right","bottom","left"]).length;o<a;o++)s=u[o],this.margins[s]=null!=this.options.margins&&null!=this.options.margins[s]?this.options.margins[s]:this.hasAxis(s)?n[s]: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 extend(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,a;for(i in r=[],t)hasProp.call(t,i)&&(o=t[i],e=Epoch.Util.copy(o),a=Math.max(0,o.values.length-this.options.historySize),e.values=o.values.slice(a),(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,s,u;for(u=this.options.ticks.time,this._ticks=[],this._tickTimer=u,null!=this.bottomAxis&&this.bottomAxis.selectAll(".tick").remove(),null!=this.topAxis&&this.topAxis.selectAll(".tick").remove(),s=[],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-=u,n-=u;break}return s},i.prototype._prepareRangeAxes=function(){if(this.hasAxis("left")&&this.svg.append("g").attr("class","y axis left").attr("transform","translate("+(this.margins.left-1)+", "+this.margins.top+")").call(this.leftAxis()),this.hasAxis("right"))return this.svg.append("g").attr("class","y axis right").attr("transform","translate("+(this.width-this.margins.right)+", "+this.margins.top+")").call(this.rightAxis())},i.prototype.leftAxis=function(){var t,n;return n=this.options.ticks.left,t=d3.svg.axis().scale(this.ySvgLeft()).orient("left").tickFormat(this.options.tickFormats.left),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.rightAxis=function(){var t,n;return this.extent((function(t){return t.y})),n=this.options.ticks.right,t=d3.svg.axis().scale(this.ySvgRight()).orient("right").tickFormat(this.options.tickFormats.right),2===n?t.tickValues(this.extent((function(t){return t.y}))):t.ticks(n)},i.prototype.hasAxis=function(t){return this.options.axes.indexOf(t)>-1},i.prototype.innerWidth=function(){return(this.width-(this.margins.left+this.margins.right))*this.pixelRatio},i.prototype.innerHeight=function(){return(this.height-(this.margins.top+this.margins.bottom))*this.pixelRatio},i.prototype._prepareEntry=function(t){return t},i.prototype._prepareLayers=function(t){return t},i.prototype._startTransition=function(){if(!0!==this.animation.active&&0!==this._queue.length)return this.trigger("transition:start"),this._shift(),this.animation.active=!0,this.animation.interval=setInterval(this.animationCallback,1e3/this.options.fps)},i.prototype._stopTransition=function(){var t,n,e,r,i,o,a;if(this.inTransition()){for(n=0,i=(o=this.data).length;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)hasProp.call(e,n)&&e[n].values.push(t[n]);return this._updateTicks(t[0].time),this._transitionRangeAxes(),this.trigger("after:shift")},i.prototype._transitionRangeAxes=function(){if(this.hasAxis("left")&&this.svg.selectAll(".y.axis.left").transition().duration(500).ease("linear").call(this.leftAxis()),this.hasAxis("right"))return this.svg.selectAll(".y.axis.right").transition().duration(500).ease("linear").call(this.rightAxis())},i.prototype._animate=function(){if(this.inTransition())return++this.animation.frame===this.animation.duration&&this._stopTransition(),this.draw(this.animation.frame*this.animation.delta()),this._updateTimeAxes()},i.prototype.y=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight(),0])},i.prototype.ySvg=function(t){return d3.scale.linear().domain(this._getScaleDomain(t)).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.ySvgLeft=function(){return null!=this.options.range?this.ySvg(this.options.range.left):this.ySvg()},i.prototype.ySvgRight=function(){return null!=this.options.range?this.ySvg(this.options.range.right):this.ySvg()},i.prototype.w=function(){return this.innerWidth()/this.options.windowSize},i.prototype._updateTicks=function(t){if((this.hasAxis("top")||this.hasAxis("bottom"))&&(++this._tickTimer%this.options.ticks.time||this._pushTick(this.options.windowSize,t,!0),this._ticks.length>0))return this._ticks[0].x-this.w()/this.pixelRatio>=0?void 0:this._ticks[0].exit=!0},i.prototype._pushTick=function(t,n,e,r){var i,o;if(null==e&&(e=!1),null==r&&(r=!1),this.hasAxis("top")||this.hasAxis("bottom"))return o={time:n,x:t*(this.w()/this.pixelRatio)+this._offsetX(),opacity:e?0:1,enter:!!e,exit:!1},this.hasAxis("bottom")&&((i=this.bottomAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",6),i.append("text").attr("text-anchor","middle").attr("dy",19).text(this.options.tickFormats.bottom(o.time)),o.bottomEl=i),this.hasAxis("top")&&((i=this.topAxis.append("g").attr("class","tick major").attr("transform","translate("+(o.x+1)+",0)").style("opacity",o.opacity)).append("line").attr("y2",-6),i.append("text").attr("text-anchor","middle").attr("dy",-10).text(this.options.tickFormats.top(o.time)),o.topEl=i),r?this._ticks.unshift(o):this._ticks.push(o),o},i.prototype._shiftTick=function(){var t;if(this._ticks.length>0)return null!=(t=this._ticks.shift()).topEl&&t.topEl.remove(),null!=t.bottomEl?t.bottomEl.remove():void 0},i.prototype._updateTimeAxes=function(){var t,n,e,r,i,o,a,s;if(this.hasAxis("top")||this.hasAxis("bottom")){for(n=(i=[this.animation.tickDelta(),1/this.options.fps])[0],t=i[1],a=[],e=0,r=(o=this._ticks).length;e<r;e++)(s=o[e]).x+=n,this.hasAxis("bottom")&&s.bottomEl.attr("transform","translate("+(s.x+1)+",0)"),this.hasAxis("top")&&s.topEl.attr("transform","translate("+(s.x+1)+",0)"),s.enter?s.opacity+=t:s.exit&&(s.opacity-=t),s.enter||s.exit?(this.hasAxis("bottom")&&s.bottomEl.style("opacity",s.opacity),this.hasAxis("top")?a.push(s.topEl.style("opacity",s.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)hasProp.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 extend(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)hasProp.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,s,u,l;if(o=(a=[0,this.getVisibleLayers()])[0],!(r=a[1]).length)return[0,0];for(t=e=0,s=r[0].values.length;0<=s?e<s:e>s;t=0<=s?++e:--e){for(l=0,n=i=0,u=r.length;0<=u?i<u:i>u;n=0<=u?++i:--i)l+=r[n].values[t].y;l>o&&(o=l)}return[0,o]},n.prototype.layerChanged=function(){var t,e,r,i;for(this._stackLayers(),t=0,r=(i=this._queue).length;t<r;t++)e=i[t],this._prepareLayers(e);return n.__super__.layerChanged.call(this)},n}(Epoch.Time.Plot),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Time.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 extend(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,s,u,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=s=h=(l=c[2]).length-1;h<=0?s<=0:s>=0;i=h<=0?++s:--s)if(u=l[i]){for(this.setStyles(u),this.ctx.beginPath(),o=(f=[this.options.windowSize,u.values.length,this.inTransition()])[0],a=f[1],g=f[2];--o>=-2&&--a>=0;)n=[(o+1)*d+t,y((r=u.values[a]).y+r.y0)],g&&(n[0]+=d),i===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);e=g?(o+3)*d+t:(o+2)*d+t,this.ctx.lineTo(e,this.innerHeight()),this.ctx.lineTo(this.width*this.pixelRatio+d+t,this.innerHeight()),this.ctx.closePath(),p.push(this.ctx.fill())}return p},n.prototype._drawStrokes=function(t){var n,e,r,i,o,a,s,u,l,c,h,f,p,g;for(null==t&&(t=0),g=(u=[this.y(),this.w(),this.getVisibleLayers()])[0],p=u[1],h=[],r=o=l=(s=u[2]).length-1;l<=0?o<=0:o>=0;r=l<=0?++o:--o)if(a=s[r]){for(this.setStyles(a),this.ctx.beginPath(),r=(c=[this.options.windowSize,a.values.length,this.inTransition()])[0],i=c[1],f=c[2];--r>=-2&&--i>=0;)n=[(r+1)*p+t,g((e=a.values[i]).y+e.y0)],f&&(n[0]+=p),r===this.options.windowSize-1?this.ctx.moveTo.apply(this.ctx,n):this.ctx.lineTo.apply(this.ctx,n);h.push(this.ctx.stroke())}return h},n.prototype.draw=function(t){return null==t&&(t=0),this.clear(),this._drawAreas(t),this._drawStrokes(t),n.__super__.draw.call(this)},n}(Epoch.Time.Stack),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Time.Bar=function(t){function n(t){var e;this.options=null!=t?t:{},null==(e=this.options).type&&(e.type="time.bar"),n.__super__.constructor.call(this,this.options),this.draw()}return extend(n,t),n.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},n.prototype.setStyles=function(t){var n;if(n=this.getStyles("rect.bar."+t.replace(/\s/g,".")),this.ctx.fillStyle=n.fill,null==n.stroke||"none"===n.stroke?this.ctx.strokeStyle="transparent":this.ctx.strokeStyle=n.stroke,null!=n["stroke-width"])return this.ctx.lineWidth=n["stroke-width"].replace("px","")},n.prototype.draw=function(t){var e,r,i,o,a,s,u,l,c,h,f,p,g,d,y,v,m;for(null==t&&(t=0),this.clear(),m=(f=[this.y(),this.w()])[0],v=f[1],u=0,h=(p=this.getVisibleLayers()).length;u<h;u++)if(c=p[u],Epoch.isNonEmptyArray(c.values))for(this.setStyles(c.className),a=(g=[this.options.windowSize,c.values.length,this.inTransition()])[0],l=g[1],s=(y=g[2])?-1:0;--a>=s&&--l>=0;)i=(d=[a*v+t,(r=c.values[l]).y,r.y0])[0],y&&(i+=v),e=[i+1,m((o=d[1])+d[2]),v-2,this.innerHeight()-m(o)+.5*this.pixelRatio],this.ctx.fillRect.apply(this.ctx,e),this.ctx.strokeRect.apply(this.ctx,e);return n.__super__.draw.call(this)},n}(Epoch.Time.Stack),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Time.Gauge=function(t){var n,e;function r(t){var i;this.options=null!=t?t:{},r.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,n)),this.value=this.options.value||0,this.options.model&&this.options.model.on("data:push",(i=this,function(){return i.pushFromModel()})),"absolute"!==this.el.style("position")&&"relative"!==this.el.style("position")&&this.el.style("position","relative"),this.svg=this.el.insert("svg",":first-child").attr("width",this.width).attr("height",this.height).attr("class","gauge-labels"),this.svg.style({position:"absolute","z-index":"1"}),this.svg.append("g").attr("transform","translate("+this.textX()+", "+this.textY()+")").append("text").attr("class","value").text(this.options.format(this.value)),this.animation={interval:null,active:!1,delta:0,target:0},this._animate=function(t){return function(){return Math.abs(t.animation.target-t.value)<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 extend(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,s,u,l,c,h,f,p,g,d,y,v,m,x;for(e=(u=[this.centerX(),this.centerY(),this.radius()])[0],i=u[1],s=u[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])*(s-g)+e,m=(f=h[1])*(s-g)+i,v=n*(s-g-d)+e,x=f*(s-g-d)+i,this.ctx.moveTo(y,m),this.ctx.lineTo(v,x);return this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.outer"),this.ctx.beginPath(),this.ctx.arc(e,i,s,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.setStyles(".epoch .gauge .arc.inner"),this.ctx.beginPath(),this.ctx.arc(e,i,s-10,-9/8*Math.PI,1/8*Math.PI,!1),this.ctx.stroke(),this.drawNeedle(),r.__super__.draw.call(this)},r.prototype.drawNeedle=function(){var t,n,e,r;return t=(r=[this.centerX(),this.centerY(),this.radius()])[0],n=r[1],e=r[2],this.value,this.options.domain[1],this.setStyles(".epoch .gauge .needle"),this.ctx.beginPath(),this.ctx.save(),this.ctx.translate(t,n),this.ctx.rotate(this.getAngle(this.value)),this.ctx.moveTo(4*this.pixelRatio,0),this.ctx.lineTo(-4*this.pixelRatio,0),this.ctx.lineTo(-1*this.pixelRatio,19-e),this.ctx.lineTo(1,19-e),this.ctx.fill(),this.setStyles(".epoch .gauge .needle-base"),this.ctx.beginPath(),this.ctx.arc(0,0,this.getWidth()/25,0,2*Math.PI),this.ctx.fill(),this.ctx.restore()},r.prototype.domainChanged=function(){return this.draw()},r.prototype.ticksChanged=function(){return this.draw()},r.prototype.tickSizeChanged=function(){return this.draw()},r.prototype.tickOffsetChanged=function(){return this.draw()},r.prototype.formatChanged=function(){return this.svg.select("text.value").text(this.options.format(this.value))},r}(Epoch.Chart.Canvas),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Time.Heatmap=function(t){var n,e,r;function i(t){this.options=null!=t?t:{},i.__super__.constructor.call(this,this.options=Epoch.Util.defaults(this.options,e)),this._setOpacityFunction(),this._setupPaintCanvas(),this.onAll(r),this.draw()}return extend(i,t),e={type:"time.heatmap",buckets:10,bucketRange:[0,100],opacity:"linear",bucketPadding:2,paintZeroValues:!1,cutOutliers:!1},n={root:function(t,n){return Math.pow(t/n,.5)},linear:function(t,n){return t/n},quadratic:function(t,n){return Math.pow(t/n,2)},cubic:function(t,n){return Math.pow(t/n,3)},quartic:function(t,n){return Math.pow(t/n,4)},quintic:function(t,n){return Math.pow(t/n,5)}},r={"option:buckets":"bucketsChanged","option:bucketRange":"bucketRangeChanged","option:opacity":"opacityChanged","option:bucketPadding":"bucketPaddingChanged","option:paintZeroValues":"paintZeroValuesChanged","option:cutOutliers":"cutOutliersChanged"},i.prototype._setOpacityFunction=function(){return Epoch.isString(this.options.opacity)?(this._opacityFn=n[this.options.opacity],null==this._opacityFn?Epoch.exception("Unknown coloring function provided '"+this.options.opacity+"'"):void 0):Epoch.isFunction(this.options.opacity)?this._opacityFn=this.options.opacity:Epoch.exception("Unknown type for provided coloring function.")},i.prototype.setData=function(t){var n,e,r,o,a;for(i.__super__.setData.call(this,t),a=[],n=0,r=(o=this.data).length;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,a,s,u,l;for(l in a={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)hasProp.call(s,l)&&(e=s[l],i=parseInt((l-this.options.bucketRange[0])/n),this.options.cutOutliers&&(i<0||i>=this.options.buckets)||(i<0?i=0:i>=this.options.buckets&&(i=this.options.buckets-1),a.buckets[i]+=parseInt(e)));for(r=o=0,u=a.buckets.length;0<=u?o<u:o>u;r=0<=u?++o:--o)a.max=Math.max(a.max,a.buckets[r]);return a},i.prototype.y=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight(),0])},i.prototype.ySvg=function(){return d3.scale.linear().domain(this.options.bucketRange).range([this.innerHeight()/this.pixelRatio,0])},i.prototype.h=function(){return this.innerHeight()/this.options.buckets},i.prototype._offsetX=function(){return.5*this.w()/this.pixelRatio},i.prototype._setupPaintCanvas=function(){return this.paintWidth=(this.options.windowSize+1)*this.w(),this.paintHeight=this.height*this.pixelRatio,this.paint=document.createElement("CANVAS"),this.paint.width=this.paintWidth,this.paint.height=this.paintHeight,this.p=Epoch.Util.getContext(this.paint),this.redraw(),this.on("after:shift","_paintEntry"),this.on("transition:end","_shiftPaintCanvas"),this.on("transition:end",(t=this,function(){return t.draw(t.animation.frame*t.animation.delta())}));var t},i.prototype.redraw=function(){var t,n;if(Epoch.isNonEmptyArray(this.data)&&Epoch.isNonEmptyArray(this.data[0].values)){for(n=this.data[0].values.length,t=this.options.windowSize,this.inTransition()&&t++;--n>=0&&--t>=0;)this._paintEntry(n,t);return this.draw(this.animation.frame*this.animation.delta())}},i.prototype._computeColor=function(t,n,e){return Epoch.Util.toRGBA(e,this._opacityFn(t,n))},i.prototype._paintEntry=function(t,n){var e,r,i,o,a,s,u,l,c,h,f,p,g,d,y,v,m,x,_,w,b,M,k;for(null==t&&(t=null),null==n&&(n=null),M=(v=[this.w(),this.h()])[0],u=v[1],null==t&&(t=this.data[0].values.length-1),null==n&&(n=this.options.windowSize),a=[],r=function(){var t,n,e;for(e=[],t=0,n=this.options.buckets;0<=n?t<n:t>n;0<=n?++t:--t)e.push(0);return e}.call(this),y=0,c=0,f=(m=this.getVisibleLayers()).length;c<f;c++){for(e in h=m[c],x=(s=this._getBuckets(h.values[t])).buckets)hasProp.call(x,e)&&(o=x[e],r[e]+=o);y+=s.max,w=this.getStyles("."+h.className.split(" ").join(".")+" rect.bucket"),s.color=w.fill,a.push(s)}for(e in k=n*M,this.p.clearRect(k,0,M,this.paintHeight),l=this.options.buckets,_=[],r)if(hasProp.call(r,e)){for(b=r[e],i=this._avgLab(a,e),d=0,g=0,p=a.length;g<p;g++)d+=(s=a[g]).buckets[e]/b*y;(b>0||this.options.paintZeroValues)&&(this.p.fillStyle=this._computeColor(b,d,i),this.p.fillRect(k,(l-1)*u,M-this.options.bucketPadding,u-this.options.bucketPadding)),_.push(l--)}return _},i.prototype._shiftPaintCanvas=function(){var t;return t=this.p.getImageData(this.w(),0,this.paintWidth-this.w(),this.paintHeight),this.p.putImageData(t,0,0)},i.prototype._avgLab=function(t,n){var e,r,i,o,a,s,u,l,c,h,f;for(u=(h=[0,0,0,0])[0],e=h[1],r=h[2],f=h[3],s=0,l=t.length;s<l;s++)null!=(o=t[s]).buckets[n]&&(f+=o.buckets[n]);for(a in t)hasProp.call(t,a)&&(u+=(c=(null!=(o=t[a]).buckets[n]?0|o.buckets[n]:0)/f)*(i=d3.lab(o.color)).l,e+=c*i.a,r+=c*i.b);return d3.lab(u,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),extend=function(t,n){for(var e in n)hasProp.call(n,e)&&(t[e]=n[e]);function r(){this.constructor=t}return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},hasProp={}.hasOwnProperty,Epoch.Time.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 extend(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,s,u,l,c,h,f;for(null==t&&(t=0),this.clear(),h=this.w(),i=0,s=(u=this.getVisibleLayers()).length;i<s;i++)if(a=u[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},jQueryModule=function(t){return t.fn.epoch=function(t){var n,e;return t.el=this.get(0),null==(n=this.data("epoch-chart"))&&(null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",n=new e(t))),n}},null!=window.jQuery&&jQueryModule(jQuery),MooToolsModule=function(){return Element.implement("epoch",(function(t){var n,e,r;return null==(n=(r=$$(this)).retrieve("epoch-chart")[0])&&(t.el=this,null==(e=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),r.store("epoch-chart",n=new e(t))),n}))},null!=window.MooTools&&MooToolsModule(),zeptoModule=function(t){var n,e,r;return e={},n=0,r=function(){return"epoch-chart-"+ ++n},t.extend(t.fn,{epoch:function(t){var n,i,o;return null!=(i=this.data("epoch-chart"))?e[i]:(t.el=this.get(0),null==(o=Epoch._typeMap[t.type])&&Epoch.exception("Unknown chart type '"+t.type+"'"),this.data("epoch-chart",i=r()),n=new o(t),e[i]=n,n)}})},null!=window.Zepto&&zeptoModule(Zepto); |