-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreboard.min.js
8 lines (8 loc) · 194 KB
/
reboard.min.js
1
2
3
4
5
6
7
8
/*! reboard 2016-10-17 */
(function(){var a;a=window.da={name:"DataCollab",version:"0.2.0",author:"VISUP srl"}}).call(this),function(){function a(){function a(a,b,c){for(var d,e,f,g=([{x:0,y:0},{x:m[0],y:m[1]}],b.x),h=b.y,j=Math.sqrt(m[0]*m[0]+m[1]*m[1]),l=w(m),n=Math.random()<.5?1:-1,o=-n;(d=l(o+=n))&&(e=~~d[0],f=~~d[1],!(Math.min(e,f)>j));)if(b.x=g+e,b.y=h+f,!(b.x+b.x0<0||b.y+b.y0<0||b.x+b.x1>m[0]||b.y+b.y1>m[1])&&(!c||!i(b,a,m[0]))&&(!c||k(b,c))){for(var p,q=b.sprite,r=b.width>>5,s=m[0]>>5,t=b.x-(r<<4),u=127&t,v=32-u,x=b.y1-b.y0,y=(b.y+b.y0)*s+(t>>5),z=0;x>z;z++){p=0;for(var A=0;r>=A;A++)a[y+A]|=p<<v|(r>A?(p=q[z*r+A])>>>u:0);y+=s}return delete b.sprite,!0}return!1}var m=[256,256],o=b,p=c,q=e,r=d,s=d,t=f,v=g,w=l,x=[],y=1/0,z=d3.dispatch("word","end"),A=null,B={};return B.start=function(){function b(){for(var b,k=+new Date;+new Date-k<y&&++f<e&&A;)b=i[f],b.x=m[0]*(Math.random()+.5)>>1,b.y=m[1]*(Math.random()+.5)>>1,h(b,i,f),b.hasText&&a(c,b,d)&&(g.push(b),z.word(b),d?j(d,b):d=[{x:b.x+b.x0,y:b.y+b.y0},{x:b.x+b.x1,y:b.y+b.y1}],b.x-=m[0]>>1,b.y-=m[1]>>1);f>=e&&(B.stop(),z.end(g,d))}var c=n((m[0]>>5)*m[1]),d=null,e=x.length,f=-1,g=[],i=x.map(function(a,b){return a.text=o.call(this,a,b),a.font=p.call(this,a,b),a.style=r.call(this,a,b),a.weight=s.call(this,a,b),a.rotate=t.call(this,a,b),a.size=~~q.call(this,a,b),a.padding=v.call(this,a,b),a}).sort(function(a,b){return b.size-a.size});return A&&clearInterval(A),A=setInterval(b,0),b(),B},B.stop=function(){return A&&(clearInterval(A),A=null),B},B.timeInterval=function(a){return arguments.length?(y=null==a?1/0:a,B):y},B.words=function(a){return arguments.length?(x=a,B):x},B.size=function(a){return arguments.length?(m=[+a[0],+a[1]],B):m},B.font=function(a){return arguments.length?(p=d3.functor(a),B):p},B.fontStyle=function(a){return arguments.length?(r=d3.functor(a),B):r},B.fontWeight=function(a){return arguments.length?(s=d3.functor(a),B):s},B.rotate=function(a){return arguments.length?(t=d3.functor(a),B):t},B.text=function(a){return arguments.length?(o=d3.functor(a),B):o},B.spiral=function(a){return arguments.length?(w=u[a+""]||a,B):w},B.fontSize=function(a){return arguments.length?(q=d3.functor(a),B):q},B.padding=function(a){return arguments.length?(v=d3.functor(a),B):v},d3.rebind(B,z,"on")}function b(a){return a.text}function c(){return"serif"}function d(){return"normal"}function e(a){return Math.sqrt(a.value)}function f(){return 30*(~~(6*Math.random())-3)}function g(){return 1}function h(a,b,c){if(!a.sprite){t.clearRect(0,0,(q<<5)/s,r/s);var d=0,e=0,f=0,g=b.length;for(--c;++c<g;){a=b[c],t.save(),t.font=a.style+" "+a.weight+" "+~~((a.size+1)/s)+"px "+a.font;var h=t.measureText(a.text+"m").width*s,i=a.size<<1;if(a.rotate){var j=Math.sin(a.rotate*p),k=Math.cos(a.rotate*p),l=h*k,m=h*j,n=i*k,o=i*j;h=Math.max(Math.abs(l+o),Math.abs(l-o))+31>>5<<5,i=~~Math.max(Math.abs(m+n),Math.abs(m-n))}else h=h+31>>5<<5;if(i>f&&(f=i),d+h>=q<<5&&(d=0,e+=f,f=0),e+i>=r)break;t.translate((d+(h>>1))/s,(e+(i>>1))/s),a.rotate&&t.rotate(a.rotate*p),t.fillText(a.text,0,0),a.padding&&(t.lineWidth=2*a.padding,t.strokeText(a.text,0,0)),t.restore(),a.width=h,a.height=i,a.xoff=d,a.yoff=e,a.x1=h>>1,a.y1=i>>1,a.x0=-a.x1,a.y0=-a.y1,a.hasText=!0,d+=h}for(var u=t.getImageData(0,0,(q<<5)/s,r/s).data,v=[];--c>=0;)if(a=b[c],a.hasText){for(var h=a.width,w=h>>5,i=a.y1-a.y0,x=0;i*w>x;x++)v[x]=0;if(d=a.xoff,null==d)return;e=a.yoff;for(var y=0,z=-1,A=0;i>A;A++){for(var x=0;h>x;x++){var B=w*A+(x>>5),C=u[(e+A)*(q<<5)+(d+x)<<2]?1<<31-x%32:0;v[B]|=C,y|=C}y?z=A:(a.y0++,i--,A--,e++)}a.y1=a.y0+z,a.sprite=v.slice(0,(a.y1-a.y0)*w)}}}function i(a,b,c){c>>=5;for(var d,e=a.sprite,f=a.width>>5,g=a.x-(f<<4),h=127&g,i=32-h,j=a.y1-a.y0,k=(a.y+a.y0)*c+(g>>5),l=0;j>l;l++){d=0;for(var m=0;f>=m;m++)if((d<<i|(f>m?(d=e[l*f+m])>>>h:0))&b[k+m])return!0;k+=c}return!1}function j(a,b){var c=a[0],d=a[1];b.x+b.x0<c.x&&(c.x=b.x+b.x0),b.y+b.y0<c.y&&(c.y=b.y+b.y0),b.x+b.x1>d.x&&(d.x=b.x+b.x1),b.y+b.y1>d.y&&(d.y=b.y+b.y1)}function k(a,b){return a.x+a.x1>b[0].x&&a.x+a.x0<b[1].x&&a.y+a.y1>b[0].y&&a.y+a.y0<b[1].y}function l(a){var b=a[0]/a[1];return function(a){return[b*(a*=.1)*Math.cos(a),a*Math.sin(a)]}}function m(a){var b=4,c=b*a[0]/a[1],d=0,e=0;return function(a){var f=0>a?-1:1;switch(Math.sqrt(1+4*f*a)-f&3){case 0:d+=c;break;case 1:e+=b;break;case 2:d-=c;break;default:e-=b}return[d,e]}}function n(a){for(var b=[],c=-1;++c<a;)b[c]=0;return b}var o,p=Math.PI/180,q=64,r=2048,s=1;"undefined"!=typeof document?(o=document.createElement("canvas"),o.width=1,o.height=1,s=Math.sqrt(o.getContext("2d").getImageData(0,0,1,1).data.length>>2),o.width=(q<<5)/s,o.height=r/s):o=new Canvas(q<<5,r);var t=o.getContext("2d"),u={archimedean:l,rectangular:m};t.fillStyle=t.strokeStyle="red",t.textAlign="center","object"==typeof module&&module.exports?module.exports=a:(d3.layout||(d3.layout={})).cloud=a}(),window.Modernizr=function(a,b,c){function d(a){o.cssText=a}function e(a,b){return typeof a===b}var f,g,h,i="2.8.3",j={},k=!0,l=b.documentElement,m="modernizr",n=b.createElement(m),o=n.style,p=({}.toString," -webkit- -moz- -o- -ms- ".split(" ")),q={},r=[],s=r.slice,t=function(a,c,d,e){var f,g,h,i,j=b.createElement("div"),k=b.body,n=k||b.createElement("body");if(parseInt(d,10))for(;d--;)h=b.createElement("div"),h.id=e?e[d]:m+(d+1),j.appendChild(h);return f=["­",'<style id="s',m,'">',a,"</style>"].join(""),j.id=m,(k?j:n).innerHTML+=f,n.appendChild(j),k||(n.style.background="",n.style.overflow="hidden",i=l.style.overflow,l.style.overflow="hidden",l.appendChild(n)),g=c(j,a),k?j.parentNode.removeChild(j):(n.parentNode.removeChild(n),l.style.overflow=i),!!g},u={}.hasOwnProperty;h=e(u,"undefined")||e(u.call,"undefined")?function(a,b){return b in a&&e(a.constructor.prototype[b],"undefined")}:function(a,b){return u.call(a,b)},Function.prototype.bind||(Function.prototype.bind=function(a){var b=this;if("function"!=typeof b)throw new TypeError;var c=s.call(arguments,1),d=function(){if(this instanceof d){var e=function(){};e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(s.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(s.call(arguments)))};return d}),q.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:t(["@media (",p.join("touch-enabled),("),m,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=9===a.offsetTop}),c};for(var v in q)h(q,v)&&(g=v.toLowerCase(),j[g]=q[v](),r.push((j[g]?"":"no-")+g));return j.addTest=function(a,b){if("object"==typeof a)for(var d in a)h(a,d)&&j.addTest(d,a[d]);else{if(a=a.toLowerCase(),j[a]!==c)return j;b="function"==typeof b?b():b,"undefined"!=typeof k&&k&&(l.className+=" "+(b?"":"no-")+a),j[a]=b}return j},d(""),n=f=null,function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=s.elements;return"string"==typeof a?a.split(" "):a}function e(a){var b=r[a[p]];return b||(b={},q++,a[p]=q,r[q]=b),b}function f(a,c,d){if(c||(c=b),k)return c.createElement(a);d||(d=e(c));var f;return f=d.cache[a]?d.cache[a].cloneNode():o.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!f.canHaveChildren||n.test(a)||f.tagUrn?f:d.frag.appendChild(f)}function g(a,c){if(a||(a=b),k)return a.createDocumentFragment();c=c||e(a);for(var f=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)f.createElement(h[g]);return f}function h(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return s.shivMethods?f(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(s,b.frag)}function i(a){a||(a=b);var d=e(a);return s.shivCSS&&!j&&!d.hasCSS&&(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),k||h(a,d),a}var j,k,l="3.7.0",m=a.html5||{},n=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,o=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,p="_html5shiv",q=0,r={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",j="hidden"in a,k=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){j=!0,k=!0}}();var s={elements:m.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:l,shivCSS:m.shivCSS!==!1,supportsUnknownElements:k,shivMethods:m.shivMethods!==!1,type:"default",shivDocument:i,createElement:f,createDocumentFragment:g};a.html5=s,i(b)}(this,b),j._version=i,j._prefixes=p,j.testStyles=t,l.className=l.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(k?" js "+r.join(" "):""),j}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==q.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=r.shift();s=1,a?a.t?o(function(){("c"==a.t?m.injectCss:m.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):s=0}function i(a,c,d,e,f,i,j){function k(b){if(!n&&g(l.readyState)&&(t.r=n=1,!s&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&o(function(){v.removeChild(l)},50);for(var d in A[c])A[c].hasOwnProperty(d)&&A[c][d].onload()}}var j=j||m.errorTimeout,l=b.createElement(a),n=0,q=0,t={t:d,s:c,e:f,a:i,x:j};1===A[c]&&(q=1,A[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,q)},r.splice(e,0,t),"img"!=a&&(q||2===A[c]?(v.insertBefore(l,u?null:p),o(k,j)):A[c].push(l))}function j(a,b,c,d,f){return s=0,b=b||"j",e(a)?i("c"==b?x:w,a,b,this.i++,c,d,f):(r.splice(this.i++,0,a),1==r.length&&h()),this}function k(){var a=m;return a.loader={load:j,i:0},a}var l,m,n=b.documentElement,o=a.setTimeout,p=b.getElementsByTagName("script")[0],q={}.toString,r=[],s=0,t="MozAppearance"in n.style,u=t&&!!b.createRange().compareNode,v=u?n:p.parentNode,n=a.opera&&"[object Opera]"==q.call(a.opera),n=!!b.attachEvent&&!n,w=t?"object":n?"script":"img",x=n?"script":w,y=Array.isArray||function(a){return"[object Array]"==q.call(a)},z=[],A={},B={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}};m=function(a){function b(a){var b,c,d,a=a.split("!"),e=z.length,f=a.pop(),g=a.length,f={url:f,origUrl:f,prefixes:a};for(c=0;g>c;c++)d=a[c].split("="),(b=B[d.shift()])&&(f=b(f,d));for(c=0;e>c;c++)f=z[c](f);return f}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(A[i.url]?i.noexec=!0:A[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),A[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(l=function(){var a=[].slice.call(arguments);m.apply(this,a),n()}),g(a,l,b,0,j);else if(Object(a)===a)for(i in h=function(){var b,c=0;for(b in a)a.hasOwnProperty(b)&&c++;return c}(),a)a.hasOwnProperty(i)&&(!c&&!--h&&(d(l)?l=function(){var a=[].slice.call(arguments);m.apply(this,a),n()}:l[i]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),n()}}(m[i])),g(a[i],l,b,i,j))}else!c&&n()}var h,i,j=!!a.test,k=a.load||a.both,l=a.callback||f,m=l,n=a.complete||f;c(j?a.yep:a.nope,!!k),k&&c(k)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(y(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):y(j)?m(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},m.addPrefix=function(a,b){B[a]=b},m.addFilter=function(a){z.push(a)},m.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",l=function(){b.removeEventListener("DOMContentLoaded",l,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k,l,n=b.createElement("script"),e=e||m.errorTimeout;n.src=a;for(l in d)n.setAttribute(l,d[l]);c=j?h:c||f,n.onreadystatechange=n.onload=function(){!k&&g(n.readyState)&&(k=1,c(),n.onload=n.onreadystatechange=null)},o(function(){k||(k=1,c(1))},e),i?n.onload():p.parentNode.insertBefore(n,p)},a.yepnope.injectCss=function(a,c,d,e,g,i){var j,e=b.createElement("link"),c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(p.parentNode.insertBefore(e,p),o(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))},function(){function a(a,b){if(null!=b){var c=b.className;void 0!=c&&(a.className=c),c=b.backgroundColor,void 0!=c&&(a.style.backgroundColor=c),c=b.opacity,void 0!=c&&(a.style.opacity=c),0==c&&(a.style.background=0),c=b.zIndex,void 0!=c&&(a.style.zIndex=c),c=b.width,void 0!=c&&(a.style.width=isNaN(c)?c:c+"px"),c=b.height,void 0!=c&&(a.style.height=isNaN(c)?c:c+"px"),c=b.padding,void 0!=c&&(a.style.padding=isNaN(c)?c:c+"px"),c=b.margin,void 0!=c&&(a.style.margin=isNaN(c)?c:c+"px"),c=b.border,void 0!=c&&(a.style.border=isNaN(c)?c:c+"px"),c=b.selectable,void 0!=c&&(a.style.selectable=c?"auto":"none"),c=b.touchEnabled,void 0!=c&&(a.style.touchEnabled=c?"auto":"none"),c=b.overflow,void 0!=c&&(a.style.overflow=c?"auto":"none"),c=b.display,void 0!=c&&(a.style[ea.userSelect]=isNaN(c)?c:c?"visible":"hidden"),c=b.transform3D,1==c&&ga&&fa(a,0,0,1,0)}}function b(a,b){var c={};c.point=_,c.scale=1,c.rotation=0,ia[a]={transform:c}}function c(a,b){return a?a[b]:null}function d(a,b,c){return a.addEventListener(b,c,!1)}function e(a,b,c){return a.removeEventListener(b,c,!1)}function f(a,b,c){return a.attachEvent("on"+b,c)}function g(a,b,c){return a.detachEvent("on"+b,c)}function h(a){var b=null;void 0==a.target._uid?(a.target._uid=++Aa,b=j(a.target)):b=za[a.target._uid],null==b.type[a.type]?b.count=b.count||1:b.count++,b.type[a.type]=a}function i(a){var b=za[a.target._uid];return b?(delete b.type[a.type],0==--b.count&&k(a),!0):!1}function j(a){if(!za[a._uid]){var b=za[a._uid]={type:{},target:a,event:{},pointCount:0,clicks:[]};return Fa(b),b}}function k(a){return null!=a?(Ga(a),delete za[a.target._uid],delete a.target._uid,a):void 0}function l(a){var b=function(b){R.env.isIE&&1!=b.button||!R.env.isIE&&0!=b.button||(Ba=a,p(b))};Da(a.target,sa,a._starter=b);var c=function(b){Ba=a,r(b)};Da(a.target,ta,a._move=c);var d="mousewheel";R.env.isFF&&R.env.isFF>=17?d="wheel":R.env.isFF&&R.env.isFF<17&&(d="DOMMouseScroll");var e=function(b){Ba=a,q(b)};Da(a.target,d,a._starterWheel=e)}function m(a){Ea(a.target,sa,a._starter),Ea(a.target,ta,a._move),Ea(document,ta,p),Ea(document,ua,p)}function n(a){var b=function(b){Ba=a,s(b)};if(Da(a.target,va,a._starter=b),R.env.isIE>=10){var c="wheel",d=function(b){Ba=a,q(b)};Da(a.target,c,a._starterWheel=d)}Da(a.target,"contextmenu",function(a){a.preventDefault()})}function o(a){Ea(a.target,va,a._starter),Ea(window,wa,s),Ea(window,xa,s)}function p(a){var b=D(a),c=Ba;switch(b.kind="mouse",b.target=c.target,b.points=M(c,a),a.type){case sa:b.phase="start",c.isFirst=!0,c.firstEvent=b,c.history=[],c.maxPointCount=1,c.pointCount=1,Da(document,ta,p),Da(document,ua,p);break;case ta:b.phase="change";break;case ua:b.phase="end",c.pointCount=0,Ea(document,ta,p),Ea(document,ua,p)}c.history.push(b),E(b,c),t(b,c),c.lastEvent=b}function q(a){var b=D(a),c=Ba;b.kind="mouse",b.target=c.target,b.points=M(c,a);var d=0;d="onwheel"in document?-a.deltaY*(a.deltaMode?120:1):"onmousewheel"in document?a.wheelDelta:-a.detail,b.phase="change",b.force=d,"scroll"!=c.gesture&&v(),c.recognized&&B(c,b),Ha.reduce(function(){c.gesture="scroll",C(c.gesture,c,b),c.lastEvent=b},10)}function r(a){if(!Ba.recognized&&!Ba.pointCount){var b=D(a),c=Ba;b.kind="mouse",b.target=c.target,b.points=M(c,a),b.phase="change",Ia.reduce(function(){C("move",c,b)},100)}}function s(a){var b=D(a),c=Ba;switch(b.kind="touch",b.target=c.target,R.env.isIE>=10?b.points=O(c,a,c._tmap||(c._tmap={})):b.points=N(c,a),a.type){case va:if(c.pointCount==b.points.length)return;0==c.pointCount?(c.isFirst=!0,Da(window,wa,s),Da(window,xa,s)):c.isFirst=!1,b.phase="start",c.firstEvent=b,c.history=[b],c.maxPointCount=Math.max(c.maxPointCount,b.points.length),c.pointCount=b.points.length;break;case wa:b.phase="change",c.pointCount=b.points.length,c.history.push(b);break;case xa:case ya:0==b.points.length?(Ea(window,wa,s),Ea(window,xa,s),b.phase="end",c.pointCount=0,delete c._tmap):(b.phase="end",c.firstEvent=b,c.history=[],c.pointCount=b.points.length)}E(b,c),t(b,c),c.lastEvent=b}function t(a,b){b.pointCount;"start"==a.phase?(b.recognized||Ja.runs()||!b.isFirst||(b.recognizing=!0,b.clicks=[],b.maxPointCount=b.pointCount,Ja.delay(function(){if(!b.recognized){var a=b.lastEvent;z(b,a)&&(C("tap",b,a),v())}},oa),Ka.delay(function(){if(!b.recognized){var a=b.lastEvent;A(b,a)&&(C("longpress",b,a),v())}},LONGPRESS_MIN_TIME)),b.recognized&&B(b,a),w(b)):"change"==a.phase?(b.recognized||x(b,a)||y(b,a),b.recognized&&C(b.gesture,b,a)):(0==b.pointCount&&b.clicks.push(b.lastEvent),b.recognized&&B(b,a),w(b))}function u(a,b){b.gesture=a,b.recognized=!0,b.recognizing=!1,v()}function v(a,b){Ja.kill(),Ka.kill(),Ia.kill()}function w(a){a.gesture=null,a.recognized=!1,a.recognizing=!1}function x(a,b){if(1!=a.pointCount)return!1;var c=P([a.firstEvent.getCGPoint(),b.getCGPoint()]);return c>pa?(b.phase="start",u("drag",a),!0):!1}function y(a,b){return a.pointCount<2?!1:(b.phase="start",u("pinch",a),!0)}function z(a,b){var c=a.clicks;if(c.length>1){var d=P([c[0].getCGPoint(),c[1].getCGPoint()]);if(d>qa)return!1}return c.length>0?(delete b.phase,b.tapCount=Math.min(2,c.length),b.touchNum=a.maxPointCount,b.points=c[0].points,!0):!1}function A(a,b){var c=P([a.firstEvent.getCGPoint(),b.getCGPoint()]);return c>ra?!1:0==a.clicks.length?(delete b.phase,!0):!1}function B(a,b){b.points=a.lastEvent.points,b.phase="end",C(a.gesture,a,b),a.gesture=null,a.recognized=!1}function C(a,b,c){var d=za[b.target._uid];d&&d.type[a]&&(c.type=a,d.type[a].listener&&d.type[a].listener.call(null,c))}function D(a){a||(a=window.event);var b={time:(new Date).getTime(),nativeEvent:a,altKey:a.altKey,ctrlKey:a.ctrlKey,charCode:a.charCode?a.charCode:void 0,keyCode:a.keyCode?a.keyCode:void 0};return a.preventDefault?(a.preventDefault(),a.stopPropagation()):(a.returnValue=!1,a.cancelBubble=!0),b}function E(a,b){a.getCGPoint=function(){return F(b,a)},a.getScale=function(){return G(b,a)},a.getRotation=function(){return H(b,a)},a.getSpeed=function(){return I(b,a)},a.getScaleSpeed=function(){return J(b,a)}}function F(a,b){for(var c=0,d=0,e=b.points,f=0;f<e.length;f++)c+=e[f].x,d+=e[f].y;return{x:Math.round(c/e.length),y:Math.round(d/e.length)}}function G(a,b){if(b.nativeEvent.scale)return b.nativeEvent.scale;var c=a.firstEvent.points;if(null==c||c==b.points)return 1;if(b.points.length<2||c.length<2)return 1;var d=P(c),e=P(b.points);return d&&e?e/d:1}function H(a,b){if(Ca&&void 0!=b.nativeEvent.rotation)return b.nativeEvent.rotation;var c=a.firstEvent.points;if(null==c||c==b.points)return 0;if(b.points.length<2||c.length<2)return 0;var d=Q(c),e=Q(b.points),f=-(d-e);return f=(f+360)%360,f>180?f-360:f}function I(a,b){var c=a.history.length;if(0==c)return{x:0,y:0};for(var d=5,e=c>d?c-1-d:0,f=[],g=e;c>g;)f.push({t:a.history[g].time,p:a.history[g].getCGPoint()}),g++;return K(f,10)}function J(a,b){var c=a.history.length;if(0==c)return 0;for(var d=5,e=c>d?c-1-d:0,f=[],g=e;c>g;)f.push({t:a.history[g].time,s:a.history[g].getScale()}),g++;return L(f,5)}function K(a,b){var c,d=a.length,e=d-1;if(3>d)return{x:0,y:0};c=d>b?e-b:e-d+1;var f=a[c].p,g=a[e].p,h=a[c].t,i=a[e].t,j=i-h;return 0>=j&&(j=100),{x:1e3*(g.x-f.x)/j,y:1e3*(g.y-f.y)/j}}function L(a,b){var c,d=a.length,e=d-1;if(3>d)return 0;c=d>b?e-b:e-d+1;var f=a[c].s,g=a[e].s,h=a[c].t,i=a[e].t,j=i-h;return 0>=j&&(j=100),1e3*(g-f)/j}function M(a,b){var c=R.display.getOffset(a.target);return[{x:b.clientX-c.x,y:b.clientY-c.y}]}function N(a,b){for(var c=R.display.getOffset(a.target),d=b.touches,e=[],f=0;f<d.length;f++)e.push({id:d[f].identifier,x:d[f].clientX-c.x,y:d[f].clientY-c.y});return e.sort(function(a,b){return a.id-b.id}),e}function O(a,b,c){var d=b.pointerId;switch(c[d]=b,b.type){case va:case wa:c[d]={id:d,x:b.offsetX,y:b.offsetY};break;case xa:case ya:delete c[d]}var e=[];for(var f in c)e.push(c[f]);return e.sort(function(a,b){return a.id-b.id}),e}function P(a){var b=a[0],c=a[1];return b&&c?Math.sqrt((c.x-b.x)*(c.x-b.x)+(c.y-b.y)*(c.y-b.y)):0}function Q(a){var b=a[0],c=a[1],d=c.x-b.x,e=c.y-b.y,f=180*Math.atan2(e,d)/Math.PI;return f}var R={},S=R;if(S.version="0.2.4 modified",S=R.globals={},S.disableCSS3D=!1,S=R.env={isBrowser:!1,isMobile:!1,isFF:void 0,isIE:void 0,isWebKit:void 0,isChrome:void 0,isOpera:void 0,isMac:!1},"undefined"!=typeof window){S.isBrowser=!0;var T=navigator,U=T.userAgent,V=T.appVersion,W=parseFloat(V);S.isWebKit=parseFloat(U.split("WebKit/")[1])||void 0,S.isOpera=parseFloat(U.split("Opera/")[1])||void 0,S.isChrome=parseFloat(U.split("Chrome/")[1])||void 0,S.isMac=V.indexOf("Macintosh")>=0,S.isUnix=V.indexOf("Unix")>=0,S.isAndroid=V.indexOf("Android")>=0;var X=Math.max(V.indexOf("WebKit"),V.indexOf("Safari"),0);if(X&&!S.isChrome&&(S.isSafari=parseFloat(V.split("Version/")[1]),(!S.isSafari||parseFloat(V.substr(X+7))<=419.3)&&(S.isSafari=2)),U.indexOf("Gecko")>=0&&!S.isKhtml&&!S.isWebKit&&(S.isMozilla=S.isMoz=W),S.isMoz&&(S.isFF=parseFloat(U.split("Firefox/")[1]||U.split("Minefield/")[1])||void 0),document.all&&!S.isOpera){S.isIE=parseFloat(V.split("MSIE ")[1])||void 0;var Y=document.documentMode;Y&&5!=Y&&Math.floor(S.isIE)!=Y&&(S.isIE=Y)}if(S.isSafari||S.isChrome||S.isOpera)switch(!0){case-1!=U.indexOf("iPhone"):case-1!=U.indexOf("iPod"):case-1!=U.indexOf("iPad"):case-1!=U.indexOf("Android"):S.isMobile=!0}}var Z;!function(){Z=function(a,b,c){function d(a){r.cssText=a}function e(a,b){return typeof a===b}function f(a,b){return!!~(""+a).indexOf(b)}function g(a,b){for(var d in a){var e=a[d];if(!f(e,"-")&&r[e]!==c)return"pfx"==b?e:!0}return!1}function h(a,b,d){for(var f in a){var g=b[a[f]];if(g!==c)return d===!1?a[f]:e(g,"function")?g.bind(d||b):g}return!1}function i(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),f=(a+" "+u.join(d+" ")+d).split(" ");return e(b,"string")||e(b,"undefined")?g(f,b):(f=(a+" "+v.join(d+" ")+d).split(" "),h(f,b,c))}var j,k,l,m="2.6.2",n={},o=b.documentElement,p="modernizr",q=b.createElement(p),r=q.style,s=({}.toString," -webkit- -moz- -o- -ms- ".split(" ")),t="Webkit Moz O ms",u=t.split(" "),v=t.toLowerCase().split(" "),w={},x=[],y=x.slice,z=function(a,c,d,e){var f,g,h,i,j=b.createElement("div"),k=b.body,l=k||b.createElement("body");if(parseInt(d,10))for(;d--;)h=b.createElement("div"),h.id=e?e[d]:p+(d+1),j.appendChild(h);return f=["­",'<style id="s',p,'">',a,"</style>"].join(""),j.id=p,(k?j:l).innerHTML+=f,l.appendChild(j),k||(l.style.background="",l.style.overflow="hidden",i=o.style.overflow,o.style.overflow="hidden",o.appendChild(l)),g=c(j,a),k?j.parentNode.removeChild(j):(l.parentNode.removeChild(l),o.style.overflow=i),!!g},A={}.hasOwnProperty;l=e(A,"undefined")||e(A.call,"undefined")?function(a,b){return b in a&&e(a.constructor.prototype[b],"undefined")}:function(a,b){return A.call(a,b)},Function.prototype.bind||(Function.prototype.bind=function(a){var b=this;if("function"!=typeof b)throw new TypeError;var c=y.call(arguments,1),d=function(){if(this instanceof d){var e=function(){};e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(y.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(y.call(arguments)))};return d}),w.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:z(["@media (",s.join("touch-enabled),("),p,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=9===a.offsetTop}),c},w.csstransforms=function(){return!!i("transform")},w.csstransforms3d=function(){var a=!!i("perspective");return a&&"webkitPerspective"in o.style&&z("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=9===b.offsetLeft&&3===b.offsetHeight}),a};for(var B in w)l(w,B)&&(k=B,n[k]=w[B](),x.push((n[k]?"":"no-")+k));return n.addTest=function(a,b){if("object"==typeof a)for(var d in a)l(a,d)&&n.addTest(d,a[d]);else{if(a=a.toLowerCase(),n[a]!==c)return n;b="function"==typeof b?b():b,"undefined"!=typeof enableClasses&&enableClasses&&(o.className+=" "+(b?"":"no-")+a),n[a]=b}return n},d(""),q=j=null,n._version=m,n._prefixes=s,n._domPrefixes=v,n._cssomPrefixes=u,n.testProp=function(a){return g([a])},n.testAllProps=i,n.testStyles=z,n}(this,this.document)}(),S=R.capabilities={},S.hasTransform3D=function(){return Z.csstransforms3d},S.hasTransform2D=function(){return Z.csstransforms},S.hasTouch=function(){return window.navigator&&window.navigator.msMaxTouchPoints&&window.navigator.msMaxTouchPoints>1?!0:Z.touch},S.getSystemInfo=function(){var a={};return a.supportsTouches=!0,a.supportsRotation=!0,a.supportsInteraction=!0,a.supportsAcceleration3d=!0,a.performanceRating=5,a.memoryRating=5,a},R.timer=function(){function a(){clearInterval(d),d=null}function b(a,b){d=setInterval(a,b)}var c={},d=null;return c.runs=function(){return null!=d},c.delay=function(d,e){return a(),b(function(){a(),d()},e),c},c.schedule=function(d,e){return a(),b(d,e),c},c.reduce=function(e,f){return null==d?(runs=!0,b(function(){a(),e()},f),c):void 0},c.kill=function(){return a(),c},c},S=R.display={};var _={x:0,y:0},aa={userSelect:"webkitUserSelect",transform2D:"webkitTransform",transform3D:"webkitTransform",transformOrigin2D:"webkitTransformOrigin"},ba={userSelect:"MozUserSelect",transform2D:"MozTransform",transform3D:"MozTransform",transformOrigin2D:"MozTransformOrigin"},ca={userSelect:"OUserSelect",transform2D:"OTransform",transform3D:"OTransform",transformOrigin2D:"OTransformOrigin"},da={userSelect:"MsUserSelect",transform2D:"msTransform",transform3D:"msTransform",transformOrigin2D:"msTransformOrigin"},ea={userSelect:"userSelect",transform2D:"transform",transform3D:"transform",transformOrigin2D:"transformOrigin"},fa=null,ga=R.capabilities.hasTransform3D(),ha=R.capabilities.hasTransform2D();R.env.isChrome>36&&(R.env.isAndroid||R.env.isUnix)&&(ga=!1,ha=!0);var ia={},ja=function(a,b,c,d,e,f){a.style[ea.transform2D]="translate("+b+"px,"+c+"px) scale("+d+","+(void 0!=f?f:d)+") rotate("+e+"deg)"},ka=function(a,b,c,d,e,f){a.style[ea.transform3D]="translate3d("+b+"px,"+c+"px,0px) scale3d("+d+","+(void 0!=f?f:d)+",1) rotate3d(0, 0, 1, "+e+"deg)"},la=function(a,b,c){a.style[ea.transformOrigin2D]=b+"px "+c+"px"},ma=function(a,b,c,d,e){a.style.zoom=d,a.style.top=c+"px",a.style.left=b+"px"};fa=ga?ka:ha?ja:ma,R.env.isWebKit>-1?ea=aa:R.env.isFF>-1?ea=ba:R.env.isIE>-1?ea=da:R.env.isOpera>-1&&(ea=ca),S.getCurrent=function(){return document.body},S.createLayer=function(c,d){var e=document.createElement("div");return e.id=c,e.style.position="absolute",la(e,0,0),e.style.top=e.style.left="0px",a(e,d),b(c),e};var na=0;S.wrapLayer=function(c,d){var e=c;return void 0==e.id&&(e.id="wrap_"+na++),a(e,d),b(e.id,d),e},S.createImage=function(c,d){var e=document.createElement("img");return e.id=c,e.style.position="absolute",e.style.width=e.style.height="auto",e.style.top=e.style.left="0px",e.style[ea.userSelect]="none",a(e,d),b(c,d),e},S.createText=function(c,d){var e=document.createElement("div");return e.id=c,e.style.position="absolute",e.style.width=e.style.height="auto",e.style.top=e.style.left="0px",e.style.whiteSpace="nowrap",e.style[ea.userSelect]="none",a(e,d),b(c,d),e},S.getId=function(a){return a.id},S.retrieve=function(a,b,c){var d=ia[a.id]||{};return null==d[b]&&c&&(d[b]=c()),ia[a.id]=d},S.addChild=function(a,b){return a.appendChild(b),a},S.removeChild=function(a,b){return a.removeChild(b),a},S.addClass=function(a,b){return $(a).addClass(b),a},S.removeClass=function(a,b){return $(a).removeClass(b),a},S.getParent=function(a){return a.parentNode},S.unparent=function(a){return a.parentNode&&a.parentNode.removeChild(a),a},S.getChildrenNum=function(a){return a.childNodes.length},S.getVisible=function(a){return"none"!=a.style.display},S.setVisible=function(a,b){return a.style.display=b?"":"none",a},S.setOpacity=function(a,b){return a.style.opacity=b,a},S.getOpacity=function(a,b){return a.style.opacity||1},S.getPosition=function(a){var b=$(a).position(),c={x:b.left,y:b.top};return c},S.setPosition=function(a,b){return a.style.left=b.x+"px",a.style.top=b.y+"px",b},S.getOffset=function(a){var b={x:a.offsetLeft-a.scrollLeft,y:a.offsetTop-a.scrollTop};do null!=a&&(b.x+=a.offsetLeft-a.scrollLeft,b.y+=a.offsetTop-a.scrollTop);while(window.document.body!=(a=a.offsetParent));return b},S.getSize=function(a){return{width:a.clientWidth,height:a.clientHeight}},S.setSize=function(a,b){return a.style.width=b.width+"px",a.style.height=b.height+"px",a},S.setCanvasSize=function(a,b){return a.width=b.width+"px",a.height=b.height+"px",a},S.setTransform=function(a,b){return R.globals.disableCSS3D?ja(a,b.point.x||0,b.point.y||0,b.scale||1,b.rotation||0,b.scaleY):fa(a,b.point.x||0,b.point.y||0,b.scale||1,b.rotation||0,b.scaleY),ia[a.id].transform=b,a},S.getTransform=function(a){return ia[a.id].transform},S.setTransformOrigin=function(a,b){return la(a,b.x||0,b.y||0),a},S.setZIndex=function(a,b){return a.style.zIndex=b,b},S.getZIndex=function(a){return a.style.zIndex},S.loadImage=function(a,b,d){return window.addEventListener?(a.onload=c(d,"onload"),a.onerror=c(d,"onerror")):(a.attachEvent("onload",c(d,"onload")),a.attachEvent("onerror",c(d,"onerror"))),a.src=b,a},S.unloadImage=function(a){return a.src="",a},S.getImageUrl=function(a){return a.src},S.getTextString=function(a){return null==a?null:a.innerHTML},S.setTextString=function(a,b){return null!=a?(a.innerHTML=b,a):void 0},S.getHtmlString=function(a){return null==a?null:a.innerHTML},S.setHtmlString=function(a,b){return null!=a?(a.innerHTML=b,a):void 0},S=R.network={},S.createHTTPRequest=function(a){var b={};return a=a||{},b.url=a.url,b.method=a.method||"GET",b.handleResponse=a.onResponse,b.handleError=a.onError,b.request=null,b.response=null,b.timeout=a.timeout||3e4,b.timeoutTimer=null,window.XMLHttpRequest?b.request=new XMLHttpRequest:window.ActiveXObject&&(b.request=new ActiveXObject("Msxml2.XMLHTTP"),b.request||(b.request=new ActiveXObject("Microsoft.XMLHTTP"))),b.convertResponseTextToResponseXml=function(a){var b;if(window.ActiveXObject)b=new ActiveXObject("Microsoft.XMLDOM"),b.async=!0,b.loadXML(a);else if(document.implementation.createDocument){var c=new DOMParser;b=c.parseFromString(a,"text/xml")}return null!=b?b:void alert("XML Doc Load Failed")},b},S.send=function(a,b){a.timeoutTimer&&clearTimeout(a.timeoutTimer),a.timeoutTimer=setTimeout(function(){a.request.abort(),clearTimeout(a.timeoutTimer)},a.timeout),a.request.open(a.method,a.url,!0),a.request.onreadystatechange=function(){4==a.request.readyState&&(clearTimeout(a.timeoutTimer),a.request.status>=200&&a.request.status<300||304===a.request.status?(a.response=a.request.responseText,a.handleResponse&&a.handleResponse({target:a,statusCode:a.request.status})):(a.response=null,a.handleError&&a.handleError({target:a,statusCode:a.request.status})))},a.request.send(b)},S.getResponse=function(a){return a.response},S.getJSONResponse=function(a){return JSON.parse(a.response)},S.getXMLResponse=function(a){return a.convertResponseTextToResponseXml(a.response)},S.abort=function(a){return a.request.abort()},S.onResponse=function(a,b){return a.handleResponse=b},S.onError=function(a,b){return a.handleError=b},S=R.gestures={};var oa=400,pa=15,qa=50,ra=5;
LONGPRESS_MIN_TIME=800;var sa="mousedown",ta="mousemove",ua="mouseup",va="touchstart",wa="touchmove",xa="touchend",ya="touchend",za={},Aa=0,Ba=null,Ca=!0,Da=null,Ea=null;R.env.isIE>=10&&(sa="MSPointerDown",ta="MSPointerMove",ua="MSPointerUp",va="MSPointerDown",wa="MSPointerMove",xa="MSPointerUp",Ca=!1),R.env.isIE&&R.env.isIE<10?(Da=f,Ea=g):(Da=d,Ea=e);var Fa=null,Ga=null,Ha=R.timer(),Ia=R.timer(),Ja=R.timer(),Ka=R.timer();R.capabilities.hasTouch()?(Fa=n,Ga=o):(Fa=l,Ga=m),S.addEventListener=function(a,b,c){var d={};return d.target=a,d.type=b,d.listener=c,h(d),d},S.removeEventListener=function(a){return i(a)},window.cross_js=R}(),window.noise=function(){for(var a=256,b=a-1,c=1,d=1,e=[],f=0;a>f;++f)e.push(Math.random());var g=function(a){var f=a*d,g=Math.floor(f),i=f-g,j=i*i*(3-2*i),k=g&b,l=k+1&b,m=h(e[k],e[l],j);return m*c},h=function(a,b,c){return a*(1-c)+b*c};return{getVal:g,setAmplitude:function(a){c=a},setScale:function(a){d=a}}},function(a,b,c,d){"use strict";function e(a,b,c){return setTimeout(k(a,c),b)}function f(a,b,c){return Array.isArray(a)?(g(a,c[b],c),!0):!1}function g(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e<a.length;)b.call(c,a[e],e,a),e++;else for(e in a)a.hasOwnProperty(e)&&b.call(c,a[e],e,a)}function h(a,b,c){for(var e=Object.keys(b),f=0;f<e.length;)(!c||c&&a[e[f]]===d)&&(a[e[f]]=b[e[f]]),f++;return a}function i(a,b){return h(a,b,!0)}function j(a,b,c){var d,e=b.prototype;d=a.prototype=Object.create(e),d.constructor=a,d._super=e,c&&h(d,c)}function k(a,b){return function(){return a.apply(b,arguments)}}function l(a,b){return typeof a==ka?a.apply(b?b[0]||d:d,b):a}function m(a,b){return a===d?b:a}function n(a,b,c){g(r(b),function(b){a.addEventListener(b,c,!1)})}function o(a,b,c){g(r(b),function(b){a.removeEventListener(b,c,!1)})}function p(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function q(a,b){return a.indexOf(b)>-1}function r(a){return a.trim().split(/\s+/g)}function s(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;d<a.length;){if(c&&a[d][c]==b||!c&&a[d]===b)return d;d++}return-1}function t(a){return Array.prototype.slice.call(a,0)}function u(a,b,c){for(var d=[],e=[],f=0;f<a.length;){var g=b?a[f][b]:a[f];s(e,g)<0&&d.push(a[f]),e[f]=g,f++}return c&&(d=b?d.sort(function(a,c){return a[b]>c[b]}):d.sort()),d}function v(a,b){for(var c,e,f=b[0].toUpperCase()+b.slice(1),g=0;g<ia.length;){if(c=ia[g],e=c?c+f:b,e in a)return e;g++}return d}function w(){return oa++}function x(a){var b=a.ownerDocument;return b.defaultView||b.parentWindow}function y(a,b){var c=this;this.manager=a,this.callback=b,this.element=a.element,this.target=a.options.inputTarget,this.domHandler=function(b){l(a.options.enable,[a])&&c.handler(b)},this.init()}function z(a){var b,c=a.options.inputClass;return new(b=c?c:ra?N:sa?Q:qa?S:M)(a,A)}function A(a,b,c){var d=c.pointers.length,e=c.changedPointers.length,f=b&ya&&d-e===0,g=b&(Aa|Ba)&&d-e===0;c.isFirst=!!f,c.isFinal=!!g,f&&(a.session={}),c.eventType=b,B(a,c),a.emit("hammer.input",c),a.recognize(c),a.session.prevInput=c}function B(a,b){var c=a.session,d=b.pointers,e=d.length;c.firstInput||(c.firstInput=E(b)),e>1&&!c.firstMultiple?c.firstMultiple=E(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=F(d);b.timeStamp=na(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=J(h,i),b.distance=I(h,i),C(c,b),b.offsetDirection=H(b.deltaX,b.deltaY),b.scale=g?L(g.pointers,d):1,b.rotation=g?K(g.pointers,d):0,D(c,b);var j=a.element;p(b.srcEvent.target,j)&&(j=b.srcEvent.target),b.target=j}function C(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(b.eventType===ya||f.eventType===Aa)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function D(a,b){var c,e,f,g,h=a.lastInterval||b,i=b.timeStamp-h.timeStamp;if(b.eventType!=Ba&&(i>xa||h.velocity===d)){var j=h.deltaX-b.deltaX,k=h.deltaY-b.deltaY,l=G(i,j,k);e=l.x,f=l.y,c=ma(l.x)>ma(l.y)?l.x:l.y,g=H(j,k),a.lastInterval=b}else c=h.velocity,e=h.velocityX,f=h.velocityY,g=h.direction;b.velocity=c,b.velocityX=e,b.velocityY=f,b.direction=g}function E(a){for(var b=[],c=0;c<a.pointers.length;)b[c]={clientX:la(a.pointers[c].clientX),clientY:la(a.pointers[c].clientY)},c++;return{timeStamp:na(),pointers:b,center:F(b),deltaX:a.deltaX,deltaY:a.deltaY}}function F(a){var b=a.length;if(1===b)return{x:la(a[0].clientX),y:la(a[0].clientY)};for(var c=0,d=0,e=0;b>e;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:la(c/b),y:la(d/b)}}function G(a,b,c){return{x:b/a||0,y:c/a||0}}function H(a,b){return a===b?Ca:ma(a)>=ma(b)?a>0?Da:Ea:b>0?Fa:Ga}function I(a,b,c){c||(c=Ka);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function J(a,b,c){c||(c=Ka);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function K(a,b){return J(b[1],b[0],La)-J(a[1],a[0],La)}function L(a,b){return I(b[0],b[1],La)/I(a[0],a[1],La)}function M(){this.evEl=Na,this.evWin=Oa,this.allow=!0,this.pressed=!1,y.apply(this,arguments)}function N(){this.evEl=Ra,this.evWin=Sa,y.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function O(){this.evTarget=Ua,this.evWin=Va,this.started=!1,y.apply(this,arguments)}function P(a,b){var c=t(a.touches),d=t(a.changedTouches);return b&(Aa|Ba)&&(c=u(c.concat(d),"identifier",!0)),[c,d]}function Q(){this.evTarget=Xa,this.targetIds={},y.apply(this,arguments)}function R(a,b){var c=t(a.touches),d=this.targetIds;if(b&(ya|za)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=t(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return p(a.target,i)}),b===ya)for(e=0;e<f.length;)d[f[e].identifier]=!0,e++;for(e=0;e<g.length;)d[g[e].identifier]&&h.push(g[e]),b&(Aa|Ba)&&delete d[g[e].identifier],e++;return h.length?[u(f.concat(h),"identifier",!0),h]:void 0}function S(){y.apply(this,arguments);var a=k(this.handler,this);this.touch=new Q(this.manager,a),this.mouse=new M(this.manager,a)}function T(a,b){this.manager=a,this.set(b)}function U(a){if(q(a,bb))return bb;var b=q(a,cb),c=q(a,db);return b&&c?cb+" "+db:b||c?b?cb:db:q(a,ab)?ab:_a}function V(a){this.id=w(),this.manager=null,this.options=i(a||{},this.defaults),this.options.enable=m(this.options.enable,!0),this.state=eb,this.simultaneous={},this.requireFail=[]}function W(a){return a&jb?"cancel":a&hb?"end":a&gb?"move":a&fb?"start":""}function X(a){return a==Ga?"down":a==Fa?"up":a==Da?"left":a==Ea?"right":""}function Y(a,b){var c=b.manager;return c?c.get(a):a}function Z(){V.apply(this,arguments)}function $(){Z.apply(this,arguments),this.pX=null,this.pY=null}function _(){Z.apply(this,arguments)}function aa(){V.apply(this,arguments),this._timer=null,this._input=null}function ba(){Z.apply(this,arguments)}function ca(){Z.apply(this,arguments)}function da(){V.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function ea(a,b){return b=b||{},b.recognizers=m(b.recognizers,ea.defaults.preset),new fa(a,b)}function fa(a,b){b=b||{},this.options=i(b,ea.defaults),this.options.inputTarget=this.options.inputTarget||a,this.handlers={},this.session={},this.recognizers=[],this.element=a,this.input=z(this),this.touchAction=new T(this,this.options.touchAction),ga(this,!0),g(b.recognizers,function(a){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[3])},this)}function ga(a,b){var c=a.element;g(a.options.cssProps,function(a,d){c.style[v(c.style,d)]=b?a:""})}function ha(a,c){var d=b.createEvent("Event");d.initEvent(a,!0,!0),d.gesture=c,c.target.dispatchEvent(d)}var ia=["","webkit","moz","MS","ms","o"],ja=b.createElement("div"),ka="function",la=Math.round,ma=Math.abs,na=Date.now,oa=1,pa=/mobile|tablet|ip(ad|hone|od)|android/i,qa="ontouchstart"in a,ra=v(a,"PointerEvent")!==d,sa=qa&&pa.test(navigator.userAgent),ta="touch",ua="pen",va="mouse",wa="kinect",xa=25,ya=1,za=2,Aa=4,Ba=8,Ca=1,Da=2,Ea=4,Fa=8,Ga=16,Ha=Da|Ea,Ia=Fa|Ga,Ja=Ha|Ia,Ka=["x","y"],La=["clientX","clientY"];y.prototype={handler:function(){},init:function(){this.evEl&&n(this.element,this.evEl,this.domHandler),this.evTarget&&n(this.target,this.evTarget,this.domHandler),this.evWin&&n(x(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&o(this.element,this.evEl,this.domHandler),this.evTarget&&o(this.target,this.evTarget,this.domHandler),this.evWin&&o(x(this.element),this.evWin,this.domHandler)}};var Ma={mousedown:ya,mousemove:za,mouseup:Aa},Na="mousedown",Oa="mousemove mouseup";j(M,y,{handler:function(a){var b=Ma[a.type];b&ya&&0===a.button&&(this.pressed=!0),b&za&&1!==a.which&&(b=Aa),this.pressed&&this.allow&&(b&Aa&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:va,srcEvent:a}))}});var Pa={pointerdown:ya,pointermove:za,pointerup:Aa,pointercancel:Ba,pointerout:Ba},Qa={2:ta,3:ua,4:va,5:wa},Ra="pointerdown",Sa="pointermove pointerup pointercancel";a.MSPointerEvent&&(Ra="MSPointerDown",Sa="MSPointerMove MSPointerUp MSPointerCancel"),j(N,y,{handler:function(a){var b=this.store,c=!1,d=a.type.toLowerCase().replace("ms",""),e=Pa[d],f=Qa[a.pointerType]||a.pointerType,g=f==ta,h=s(b,a.pointerId,"pointerId");e&ya&&(0===a.button||g)?0>h&&(b.push(a),h=b.length-1):e&(Aa|Ba)&&(c=!0),0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Ta={touchstart:ya,touchmove:za,touchend:Aa,touchcancel:Ba},Ua="touchstart",Va="touchstart touchmove touchend touchcancel";j(O,y,{handler:function(a){var b=Ta[a.type];if(b===ya&&(this.started=!0),this.started){var c=P.call(this,a,b);b&(Aa|Ba)&&c[0].length-c[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:ta,srcEvent:a})}}});var Wa={touchstart:ya,touchmove:za,touchend:Aa,touchcancel:Ba},Xa="touchstart touchmove touchend touchcancel";j(Q,y,{handler:function(a){var b=Wa[a.type],c=R.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:ta,srcEvent:a})}}),j(S,y,{handler:function(a,b,c){var d=c.pointerType==ta,e=c.pointerType==va;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(Aa|Ba)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Ya=v(ja.style,"touchAction"),Za=Ya!==d,$a="compute",_a="auto",ab="manipulation",bb="none",cb="pan-x",db="pan-y";T.prototype={set:function(a){a==$a&&(a=this.compute()),Za&&(this.manager.element.style[Ya]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return g(this.manager.recognizers,function(b){l(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),U(a.join(" "))},preventDefaults:function(a){if(!Za){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=q(d,bb),f=q(d,db),g=q(d,cb);return e||f&&c&Ha||g&&c&Ia?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var eb=1,fb=2,gb=4,hb=8,ib=hb,jb=16,kb=32;V.prototype={defaults:{},set:function(a){return h(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(f(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=Y(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return f(a,"dropRecognizeWith",this)?this:(a=Y(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(f(a,"requireFailure",this))return this;var b=this.requireFail;return a=Y(a,this),-1===s(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(f(a,"dropRequireFailure",this))return this;a=Y(a,this);var b=s(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function b(b){c.manager.emit(c.options.event+(b?W(d):""),a)}var c=this,d=this.state;hb>d&&b(!0),b(),d>=hb&&b(!0)},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=kb)},canEmit:function(){for(var a=0;a<this.requireFail.length;){if(!(this.requireFail[a].state&(kb|eb)))return!1;a++}return!0},recognize:function(a){var b=h({},a);return l(this.options.enable,[this,b])?(this.state&(ib|jb|kb)&&(this.state=eb),this.state=this.process(b),void(this.state&(fb|gb|hb|jb)&&this.tryEmit(b))):(this.reset(),void(this.state=kb))},process:function(a){},getTouchAction:function(){},reset:function(){}},j(Z,V,{defaults:{pointers:1},attrTest:function(a){var b=this.options.pointers;return 0===b||a.pointers.length===b},process:function(a){var b=this.state,c=a.eventType,d=b&(fb|gb),e=this.attrTest(a);return d&&(c&Ba||!e)?b|jb:d||e?c&Aa?b|hb:b&fb?b|gb:fb:kb}}),j($,Z,{defaults:{event:"pan",threshold:10,pointers:1,direction:Ja},getTouchAction:function(){var a=this.options.direction,b=[];return a&Ha&&b.push(db),a&Ia&&b.push(cb),b},directionTest:function(a){var b=this.options,c=!0,d=a.distance,e=a.direction,f=a.deltaX,g=a.deltaY;return e&b.direction||(b.direction&Ha?(e=0===f?Ca:0>f?Da:Ea,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?Ca:0>g?Fa:Ga,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return Z.prototype.attrTest.call(this,a)&&(this.state&fb||!(this.state&fb)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this._super.emit.call(this,a)}}),j(_,Z,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[bb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&fb)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),j(aa,V,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[_a]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,f=a.deltaTime>b.time;if(this._input=a,!d||!c||a.eventType&(Aa|Ba)&&!f)this.reset();else if(a.eventType&ya)this.reset(),this._timer=e(function(){this.state=ib,this.tryEmit()},b.time,this);else if(a.eventType&Aa)return ib;return kb},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===ib&&(a&&a.eventType&Aa?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=na(),this.manager.emit(this.options.event,this._input)))}}),j(ba,Z,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[bb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&fb)}}),j(ca,Z,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Ha|Ia,pointers:1},getTouchAction:function(){return $.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Ha|Ia)?b=a.velocity:c&Ha?b=a.velocityX:c&Ia&&(b=a.velocityY),this._super.attrTest.call(this,a)&&c&a.direction&&a.distance>this.options.threshold&&ma(b)>this.options.velocity&&a.eventType&Aa},emit:function(a){var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),j(da,V,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[ab]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,f=a.deltaTime<b.time;if(this.reset(),a.eventType&ya&&0===this.count)return this.failTimeout();if(d&&f&&c){if(a.eventType!=Aa)return this.failTimeout();var g=this.pTime?a.timeStamp-this.pTime<b.interval:!0,h=!this.pCenter||I(this.pCenter,a.center)<b.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,h&&g?this.count+=1:this.count=1,this._input=a;var i=this.count%b.taps;if(0===i)return this.hasRequireFailures()?(this._timer=e(function(){this.state=ib,this.tryEmit()},b.interval,this),fb):ib}return kb},failTimeout:function(){return this._timer=e(function(){this.state=kb},this.options.interval,this),kb},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==ib&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),ea.VERSION="2.0.4",ea.defaults={domEvents:!1,touchAction:$a,enable:!0,inputTarget:null,inputClass:null,preset:[[ba,{enable:!1}],[_,{enable:!1},["rotate"]],[ca,{direction:Ha}],[$,{direction:Ha},["swipe"]],[da],[da,{event:"doubletap",taps:2},["tap"]],[aa]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var lb=1,mb=2;fa.prototype={set:function(a){return h(this.options,a),a.touchAction&&this.touchAction.update(),a.inputTarget&&(this.input.destroy(),this.input.target=a.inputTarget,this.input.init()),this},stop:function(a){this.session.stopped=a?mb:lb},recognize:function(a){var b=this.session;if(!b.stopped){this.touchAction.preventDefaults(a);var c,d=this.recognizers,e=b.curRecognizer;(!e||e&&e.state&ib)&&(e=b.curRecognizer=null);for(var f=0;f<d.length;)c=d[f],b.stopped===mb||e&&c!=e&&!c.canRecognizeWith(e)?c.reset():c.recognize(a),!e&&c.state&(fb|gb|hb)&&(e=b.curRecognizer=c),f++}},get:function(a){if(a instanceof V)return a;for(var b=this.recognizers,c=0;c<b.length;c++)if(b[c].options.event==a)return b[c];return null},add:function(a){if(f(a,"add",this))return this;var b=this.get(a.options.event);return b&&this.remove(b),this.recognizers.push(a),a.manager=this,this.touchAction.update(),a},remove:function(a){if(f(a,"remove",this))return this;var b=this.recognizers;return a=this.get(a),b.splice(s(b,a),1),this.touchAction.update(),this},on:function(a,b){var c=this.handlers;return g(r(a),function(a){c[a]=c[a]||[],c[a].push(b)}),this},off:function(a,b){var c=this.handlers;return g(r(a),function(a){b?c[a].splice(s(c[a],b),1):delete c[a]}),this},emit:function(a,b){this.options.domEvents&&ha(a,b);var c=this.handlers[a]&&this.handlers[a].slice();if(c&&c.length){b.type=a,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var d=0;d<c.length;)c[d](b),d++}},destroy:function(){this.element&&ga(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},h(ea,{INPUT_START:ya,INPUT_MOVE:za,INPUT_END:Aa,INPUT_CANCEL:Ba,STATE_POSSIBLE:eb,STATE_BEGAN:fb,STATE_CHANGED:gb,STATE_ENDED:hb,STATE_RECOGNIZED:ib,STATE_CANCELLED:jb,STATE_FAILED:kb,DIRECTION_NONE:Ca,DIRECTION_LEFT:Da,DIRECTION_RIGHT:Ea,DIRECTION_UP:Fa,DIRECTION_DOWN:Ga,DIRECTION_HORIZONTAL:Ha,DIRECTION_VERTICAL:Ia,DIRECTION_ALL:Ja,Manager:fa,Input:y,TouchAction:T,TouchInput:Q,MouseInput:M,PointerEventInput:N,TouchMouseInput:S,SingleTouchInput:O,Recognizer:V,AttrRecognizer:Z,Tap:da,Pan:$,Swipe:ca,Pinch:_,Rotate:ba,Press:aa,on:n,off:o,each:g,merge:i,extend:h,inherit:j,bindFn:k,prefixed:v}),typeof define==ka&&define.amd?define(function(){return ea}):"undefined"!=typeof module&&module.exports?module.exports=ea:a[c]=ea}(window,document,"Hammer"),function(){da.utils={},da.utils.locales={it_Tb:{d3:{decimal:",",thousands:".",grouping:[3],currency:["€",""],dateTime:"%A %e %B %Y, %X",date:"%d/%m/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"],shortDays:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],months:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],shortMonths:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"]},numeral:{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"K",million:"M",billion:"G",trillion:"T"},ordinal:function(a){return"º"},currency:{symbol:"€"}}}},da.utils.multi={"default":[[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%a %d",function(a){return a.getDay()&&1!==a.getDate()}],["%b %d",function(a){return 1!==a.getDate()}],["%B",function(a){return a.getMonth()}],["%Y",function(a){return!0}]],"default-utc":[[".%L",function(a){return a.getUTCMilliseconds()}],[":%S",function(a){return a.getUTCSeconds()}],["%I:%M",function(a){return a.getUTCMinutes()}],["%I %p",function(a){return a.getUTCHours()}],["%a %d",function(a){return a.getUTCDay()&&1!==a.getUTCDate()}],["%b %d",function(a){return 1!==a.getUTCDate()}],["%B",function(a){return a.getUTCMonth()}],["%Y",function(a){return!0}]],quarters:[[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%a %d",function(a){return a.getDay()&&1!==a.getDate()}],["%b %d",function(a){return 1!==a.getDate()}],["%B",function(a){return a.getMonth()}],["%Y",function(){return!0}]],"quarters-utc":[[".%L",function(a){return a.getUTCMilliseconds()}],[":%S",function(a){return a.getUTCSeconds()}],["%I:%M",function(a){return a.getUTCMinutes()}],["%I %p",function(a){return a.getUTCHours()}],["%a %d",function(a){return a.getUTCDay()&&1!==a.getUTCDate()}],["%b %d",function(a){return 1!==a.getUTCDate()}],["%B",function(a){return a.getUTCMonth()}],["%Y",function(){return!0}]]},da.utils.template=function(a,b,c){var d;return _.assign(b,da.utils.templateHelpers),null!=c&&_.assign(b,{localeId:c}),Number(_.VERSION.split(".")[0])>2?(d=_.template(a,{interpolate:/\{(.+?)\}/g}))(b):_.template(a,b,{interpolate:/\{(.+?)\}/g})},da.utils.templateHelpers={N:function(a,b,c){var d;if(null!=a)return null!=(d=c||this.localeId)&&(numeral.language(d,da.utils.locales[d].numeral),numeral.language(d)),numeral(a).format(b||"0.[00]a")},I:function(a,b,c){var d;if(null!=a)return null!=(d=c||this.localeId)&&(numeral.language(d,da.utils.locales[d].numeral),numeral.language(d)),1e6>a?numeral(a).format(null!=b?b.replace("a",""):"0.[00]"):numeral(a).format(b||"0.[00]a")},T:function(a,b,c,d){var e,f,g;return null==d&&(d=!1),null!=a?(null!=(f=c||this.localeId)?(g=d3.locale(da.utils.locales[f].d3),e=d?g.timeFormat.utc(b||"%x"):g.timeFormat(b||"%x")):e=d?d3.time.format.utc(b||"%x"):d3.time.format(b||"%x"),e(a)):void 0},M:function(a,b,c,d){var e,f,g,h;return null==d&&(d=!1),null!=a?(f=b||"default",null!=(g=c||this.localeId)?(h=d3.locale(da.utils.locales[g].d3),e=d?h.timeFormat.utc.multi(_.cloneDeep(da.utils.multi[f+"-utc"])):h.timeFormat.multi(_.cloneDeep(da.utils.multi[f]))):e=d?d3.time.format.utc.multi(_.cloneDeep(da.utils.multi[f+"-utc"])):d3.time.format.multi(_.cloneDeep(da.utils.multi[f])),e(a)):void 0}},da.utils.svgNum=function(a){return"number"!=typeof a||0>a||!isFinite(a)?0:Math.round(10*a)/10},da.utils.isSvgNum=function(a){return!("number"!=typeof a||0>a||!isFinite(a))},da.utils.realNum=function(a){return"number"==typeof a&&isFinite(a)?a:0},da.utils.realPosNum=function(a){return"number"!=typeof a||0>a||!isFinite(a)?0:a},da.utils.isRealNum=function(a){return!("number"!=typeof a||!isFinite(a))},da.utils.moreColor=function(a,b,c){var d,e;return e=b.indexOf(a),d=b.length-1>0?e*((b.length-1)/(b.length+1))*(c.length-1)/(b.length-1):0,d+=b.length>0?(c.length-1)/(b.length+1):0},da.utils.setAxisTicks=function(a,b,c,d,e){var f;switch(d.tickExtension){case"default":case null:return e.tickPadding(3).tickSize(4,0);case"axis":return e.tickPadding(-a[d.position]+5).tickSize(a[d.position],0);case"chart":return e.tickPadding(5).tickSize("left"===(f=d.position)||"right"===f?-b:-c,0);default:return e.tickPadding(3).tickSize(6,0)}},da.utils.setAxisValues=function(a,b,c){var d,e,f,g,h;if(null!=c.ticks)switch(a.tickValues){case"domain":return h=b.ticks()[0],g=c.ticks(h),e=c.domain().slice(),d=e[0],f=e[e.length-1],Math.abs(c(g[0])-c(d<a.tickPadding))&&g.shift(),g.unshift(c.domain()[0]),Math.abs(c(g[0])-c(f<a.tickPadding))&&g.pop(),g.push(c.domain()[1]),_.uniq(g),b.tickValues(g)}},da.utils.scaleDomain=function(a,b,c,d){var e,f,g,h,i;for(e=[],h=a[b].domain,f=0,g=h.length;g>f;f++)i=h[f],e.push(function(){switch(i){case"min":return d3.min(d,function(a){return a[c[b]]});case"max":return d3.max(d,function(a){return a[c[b]]});case null:break;default:return i}}());return e},da.utils.scaleColorDomain=function(a,b,c,d){if("linear"===a[b].type)return d3.range(a[b].range.length);switch(a[b].domain){case null:return _.uniq(_.map(d,function(a){return a[c[b]]}));default:return da.utils.scaleDomain(a,b,c,d)}},da.utils.scaleRange=function(a,b,c,d){var e,f,g,h,i;for(g=[],h=a[b].range,e=0,f=h.length;f>e;e++)i=h[e],g.push(function(){switch(i){case"width":return c;case"height":return d;default:return i}}());return g},da.utils.relayoutLegend=function(a,b,c,d){switch(b.select("div.td-legend-title").text(function(){return a.title}),b.selectAll("div.td-legend-item-text").text(function(b,c){var d;return null!=a.labels?null!=a.labels[c]?a.labels[c]:"N.D.":null!=a.labelFormat?isNaN(d3.select(this.parentNode).datum())?da.utils.template(a.labelFormat,{value:d3.select(this.parentNode).datum()}):(d=d3.format(a.labelFormat))(d3.select(this.parentNode).datum()):_.isUndefined(d3.select(this.parentNode).datum())?"N.D.":d3.select(this.parentNode).datum()}),a.position){case"top":return c.style("float","left").style("display","inline-block"),b.style("top",0).style("left",function(){return $(d.node()).innerWidth()/2-$(this).outerWidth()/2+"px"});case"top-left":return c.style("float","left").style("display","inline-block"),b.style("top",0).style("left",0);case"top-right":return c.style("float","left").style("display","inline-block"),b.style("top",0).style("right",0);case"left":return c.style("float","none"),b.style("left",0).style("top",function(){return $(d.node()).innerHeight()/2-$(this).outerHeight()/2+"px"});case"left-top":return c.style("float","none"),b.style("top",0).style("left",0);case"left-bottom":return c.style("float","none"),b.style("bottom",0).style("left",0);case"right":return c.style("float","none"),b.style("right",0).style("top",function(){return $(d.node()).innerHeight()/2-$(this).outerHeight()/2+"px"});case"right-top":return c.style("float","none"),b.style("top",0).style("right",0);case"right-bottom":return c.style("float","none"),b.style("bottom",0).style("right",0);case"bottom":return c.style("float","left").style("display","inline-block"),b.style("bottom",0).style("left",function(){return $(d.node()).innerWidth()/2-$(this).outerWidth()/2+"px"});case"bottom-left":return c.style("float","left").style("display","inline-block"),b.style("bottom",0).style("left",0);case"bottom-right":return c.style("float","left").style("display","inline-block"),b.style("bottom",0).style("right",0)}},da.utils.numStr=function(a,b){var c,d,e;return _.isNaN(a)||_.isUndefined(a)?"n.d.":(c=a,e=b,a>=1e9?(c=a/1e9,e="B"):a>=1e6?(c=a/1e6,e="M"):a>=1e3&&(c=a/1e3,e="K"),d="",d=c>=100?c.toFixed(1):c.toFixed(2),d.split(".").join(".")+e)},da.utils.wrap=function(a,b){return a.each(function(){var c,d,e,f,g,h,i,j,k,l;if(a=d3.select(this),a.node().getComputedTextLength()>b){for(j=a.text().split(/\s+/).reverse(),i=void 0,d=[],f=0,e=1,l=a.attr("y"),k=a.attr("x")||0,c=parseFloat(a.attr("dy")),h=a.text(null).append("tspan").attr("x",k).attr("y",l).attr("dy",c+"em"),g=[];i=j.pop();){if(d.push(i),h.text(d.join(" ")),h.node().getComputedTextLength()>b&&d.length>1&&(d.pop(),h.text(d.join(" ")),d=[i],h=a.append("tspan").attr("x",k).attr("y",l).attr("dy",++f*e+c+"em").text(i)),h.node().getComputedTextLength()>b){h.text(i.slice(0,3).concat("..."));break}g.push(void 0)}return g}})},da.utils.timeInterval=function(a){var b,c,d;return b=[d3.time.second,d3.time.minute,d3.time.hour,d3.time.day,d3.time.week,d3.time.month,d3.time.year],c=[1,60,3600,86400,604800,2629743.83,31556926],d=1e3,{interval:d3.time.second,step:Math.floor(a/d)}}}.call(this),function(){da.bars=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,aa,ba;return o=d3.select(a),l={padding:{top:0,right:0,bottom:0,left:0},scales:{x:{field:"d.x",type:"ordinal",domain:"all",range:[0,"width"],format:null},y:{field:"d.y",type:"linear",domain:["min","max"],range:["height",0],nice:!0},color:{field:"d.color",type:"linear",domain:null,range:["#444","#ccc"]}},axes:{x:{position:"bottom",tickPadding:100,tickFormat:"{x}",tickExtension:"default",tickValues:null,visible:!0},y:{position:"left",tickPadding:25,tickFormat:'{N(y,"0.[00]a")}',tickExtension:"axis",visible:!0}},legends:{color:{title:null,labelFormat:null,labels:null,position:"bottom",visible:!0}},tooltip:{textFormat:"{N($y)}",visible:!0},transition:{enter:!1,update:!0,exit:!1},custom:{grouped:!1,normalized:!1,rangePadding:.1,outerPadding:0,selectable:!0,horizontal:!1,wrapTicks:!0,localeId:null,showTotals:!1,totalHeight:30,totalFormat:'{I(t,"0,0.[00]")}',thresholds:null}},q=i=j=k=null,D=[],B=null,J=null,H=f=b=z=N=null,I=null,W=Z=e=null,X=d3.svg.axis(),aa=d3.svg.axis(),F=null,m=d3.dispatch("click","select","over","bind","ready"),C=!1,g=_.cloneDeep(l),V=y=null,(S=function(){var b,c;return c=$(a).width(),b=$(a).height(),V=c-da.utils.svgNum(g.padding.right)-da.utils.svgNum(g.padding.left),y=b-da.utils.svgNum(g.padding.top)-da.utils.svgNum(g.padding.bottom)})(),E=o.append("svg").attr("width","100%").attr("height","100%"),Modernizr.touch?F=cross_js.gestures.addEventListener(E.node(),"drag",function(a){switch(a.phase){case"start":case"change":return s(a);case"end":return t()}}):null!=F&&cross_js.gestures.removeEventListener(F),E.on("mousemove",Modernizr.touch?null:function(){return v.call(this)}).on("mouseleave",Modernizr.touch?null:function(){return t.call(this)}),h=E.append("g").attr("class","td-chart-container"),Y=h.append("g").attr("class","td-x-axis"),ba=h.append("g").attr("class","td-y-axis"),c=h.append("g").attr("class","td-bars-main-container"),G=h.append("g").attr("class","td-threshold-container"),M=o.append("div").attr("class","td-total-container"),A=o.append("div").attr("class","td-legend-container").style("position","absolute"),A.append("div").attr("class","td-legend-title"),L=o.append("div").attr("class","td-tooltip-container").style("position","absolute"),K=L.append("div").attr("class","td-tooltip td-hidden"),(P=function(){var a;return W=function(){switch(g.scales.x.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"time":return d3.time.scale();case"utc":return d3.time.scale.utc()}}(),Z=function(){switch(g.scales.y.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),e=function(){switch(g.scales.color.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}(),H=G.selectAll("line.td-threshold").data(null!=g.custom.thresholds?g.custom.thresholds:[]),H.enter().append("line").style("opacity",0).attr("class","td-threshold"),H.exit().remove(),null!=g.custom.localeId&&(a=d3.locale(da.utils.locales[g.custom.localeId].d3)),I=null!=g.scales.x.format?null!=g.custom.localeId&&null!=a?a.timeFormat(g.scales.x.format):d3.time.format(g.scales.x.format):void 0})(),d=function(){return d},d.data=function(a){return 0===arguments.length?i:(i=a,Q(),R(),O(),U(),d)},d.options=function(a){return 0===arguments.length?g:(g=_.merge(g,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),P(),S(),Q(),R(),U(),d)},d.resize=function(){return S(),R(),U(),d},d.destroy=function(){return o.selectAll("*").remove(),d},d.on=function(a,b){return m.on(a,b),d},d.select=function(a){return 0===arguments.length?D:(T(a),U(),d)},Q=function(){var b,c,d,f,h,l,n,o,p,r,s,t,u,v,w,x,y;if(null!==i){switch(v=!1,q={},q.x=g.scales.x.field.slice(2),q.y=[],_.isArray(g.scales.y.field)){case!0:v=!0,g.scales.y.field.forEach(function(a){return q.y.push(a.slice(2))});break;case!1:q.y.push(g.scales.y.field.slice(2))}switch(q.color=[],g.scales.color.field){case"keys":q.color=_.cloneDeep(q.y);break;default:q.color.push(g.scales.color.field.slice(2));
}for(q.keys=v?q.y:_.uniq(i.map(function(a){return a[q.color]})),null!=g.scales.x.format&&i.forEach(function(a){return a[q.x]=function(){switch(g.scales.x.format){case"date":return new Date(a[q.x]);case"timestamp":return new Date(1e3*a[q.x]);default:return I.parse(String(a[q.x]))}}()}),v||(r=_.cloneDeep(i),r=d3.nest().key(function(a){return a[q.x]}).key(function(a){return a[q.color]}).entries(r).map(function(a){var b,c,d,e,f;for(e={items:{}},e[q.x]=a.values[0].values[0][q.x],f=a.values,c=0,d=f.length;d>c;c++)b=f[c],e.items[b.key]=b.values[0],e[b.key]=b.values[0][q.y];return e})),j=v?_.cloneDeep(i):r,c=0,h=j.length;h>c;c++){for(b=j[c],b._val=[],b._totPos=0,b._totNeg=0,s=q.keys,f=0,l=s.length;l>f;f++)d=s[f],da.utils.isRealNum(b[d])&&(g.custom.grouped?b[d]>b._totPos?b._totPos=b[d]:b[d]<b._totNeg&&(b._totNeg=b[d]):b[d]>=0?b._totPos+=b[d]:b._totNeg+=b[d]);for(g.custom.normalized&&(b._totNorm=b._totPos+Math.abs(b._totNeg),b._totPos=b._totPos/b._totNorm,b._totNeg=b._totNeg/b._totNorm),y=0,x=0,t=q.keys,o=0,n=t.length;n>o;o++)d=t[o],null!=b[d]&&(b._val.push({_y1:g.custom.normalized?b[d]/b._totNorm:b[d],_y0:b[d]>=0?g.custom.normalized?y/b._totNorm:y:g.custom.normalized?x/b._totNorm:x,x:b[q.x],y:b[d],color:d,item:v?b:b.items[d]}),da.utils.isRealNum(b[d])&&(b[d]>=0?y+=b[d]:x+=b[d]))}if(k=q.keys,"ordinal"!==g.scales.x.type){if(w=_.filter(_.uniq(_.sortBy(_.pluck(i,q.x)),!0),function(a){return null!=a}),_.some(w,isNaN))throw"non linear domain";p=d3.min(w,function(a,b){return b<w.length-1?Math.abs(w[b+1]-a):void 0}),"time"===g.scales.x.type?W.rangeBand=da.utils.timeInterval(p):W.rangeBand=p}return W.domain(function(){var b,c,d,e,f,h,j;if(b=[],_.isArray(g.scales.x.domain))for(h=g.scales.x.domain,f=0,e=h.length;e>f;f++)j=h[f],b.push(function(){switch(j){case"min":return d3.min(i,function(a){return"ordinal"===g.scales.x.type?a[q.x]:"time"===g.scales.x.type?W.rangeBand.interval.offset(a[q.x],-W.rangeBand.step*g.custom.outerPadding):a[q.x]-W.rangeBand*g.custom.outerPadding});case"max":return d3.max(i,function(a){return"ordinal"===g.scales.x.type?a[q.x]:"time"===g.scales.x.type?W.rangeBand.interval.offset(a[q.x],W.rangeBand.step*(1+g.custom.outerPadding-g.custom.rangePadding)):a[q.x]+W.rangeBand*(1+g.custom.outerPadding-g.custom.rangePadding)});case null:break;default:return j}}());else switch(g.scales.x.domain){case"all":i.forEach(function(a){return null!==a[q.x]?b.push(a[q.x]):void 0}),b=_.uniq(b)}try{if(_.isArray(b)&&("ordinal"===g.scales.x.type||b.length>=2))return b;throw"Inconsistent domain at:"}catch(d){return c=d,console.error(c,a),[1,0]}}()),Z.domain(function(){var a,b,c,d,e;if(a=[],_.isArray(g.scales.y.domain))for(d=g.scales.y.domain,c=0,b=d.length;b>c;c++)e=d[c],a.push(function(){switch(e){case"min":return d3.min(j,function(a){return a._totNeg});case"max":return d3.max(j,function(a){return a._totPos});case null:break;default:return e}}());return _.isArray(a)&&a.length>=2?a:void 0}()),null!=g.custom.thresholds&&(u=d3.extent(g.custom.thresholds),Z.domain(d3.extent(Z.domain().concat(u)))),e.domain("linear"===g.scales.color.type?d3.range(g.scales.color.range.length):k),m.bind()}},R=function(){var a;if(null!==i)return function(){var a,b,c,d,e,f,h;if(d=[],_.isArray(g.scales.x.range))for(e=g.scales.x.range,a=0,b=e.length;b>a;a++)h=e[a],d.push(function(){switch(h){case"width":return V;case"height":return y;case null:break;default:return h}}());return"ordinal"===g.scales.x.type?W.rangeBands(d,g.custom.rangePadding,g.custom.outerPadding):(W.range(d),"time"===g.scales.x.type?(null!=W.rangeBand.interval&&(J=W.rangeBand.interval.offset(W.domain()[0],W.rangeBand.step)),f=W(J)-W(W.domain()[0])):f=W(W.rangeBand)-W(0),c=f-f*g.custom.rangePadding,W.rangeBand=function(){return c})}(),Z.range(function(){var a,b,c,d,e;if(c=[],_.isArray(g.scales.y.range))for(d=g.scales.y.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return V;case"height":return y;case null:break;default:return g.custom.showTotals?e+g.custom.totalHeight:e}}());return c}()),e.range(function(){var a,b,c,d,e;if(c=[],_.isArray(g.scales.y.range))for(d=g.scales.color.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return V;case"height":return y;default:return e}}());return c}()),a=null,a=_.isFunction(g.axes.y.tickFormat)?g.axes.y.tickFormat:d3.format(g.axes.y.tickFormat),X.scale(W).orient(g.axes.x.position).ticks(function(){var a,b;return a=("left"===(b=g.axes.x.position)||"right"===b?y:V)/g.axes.x.tickPadding,a>3?a:3}()).tickFormat(function(a){return da.utils.template(g.axes.x.tickFormat,{x:a},g.custom.localeId)}),da.utils.setAxisValues(g.axes.x,X,W),da.utils.setAxisTicks(g.padding,V,y,g.axes.x,X),aa.scale(Z).orient(g.axes.y.position).ticks(function(){var a,b;return a=("left"===(b=g.axes.y.position)||"right"===b?y:V)/g.axes.y.tickPadding,a>3?a:3}()).tickFormat(function(a){return da.utils.template(g.axes.y.tickFormat,{y:a},g.custom.localeId)}),da.utils.setAxisTicks(g.padding,V,y,g.axes.y,aa)},O=function(){var a,d;if(null!==o&&null!==i)return f=c.selectAll("g.td-column").data(j),f.enter().append("g").attr("class","td-column"),b=f.selectAll("rect.td-bar").data(function(a){return a._val}),a=b.enter().append("rect").attr("class","td-bar").style("opacity",0).on("click",Modernizr.touch?null:r).each(function(a){var b,c;return Modernizr.touch?(c=this,b=new Hammer.Manager(c),b.add(new Hammer.Tap),b.on("tap",function(){return r.call(c,a)})):void 0}),g.transition.enter&&a.attr(g.custom.horizontal?"y":"x",function(a,b){var c,d,e;return g.custom.grouped===!1?d=W(d3.select(this.parentNode).datum()[q.x]):(c=W(d3.select(this.parentNode).datum()[q.x]),e=W.rangeBand()/d3.select(this.parentNode).datum()._val.length,d=da.utils.realNum(c+e*(b%d3.select(this.parentNode).datum()._val.length))),a.bbox={},a.bbox[g.custom.horizontal?"y":"x"]=d}).attr(g.custom.horizontal?"x":"y",da.utils.realNum(g.custom.horizontal?V:Z(0))).attr(g.custom.horizontal?"width":"height",0),g.transition.exit?(f.exit().selectAll(".td-bar").transition().duration(1e3).style("opacity",0).attr(g.custom.horizontal?"x":"y",da.utils.realNum(g.custom.horizontal?V:Z(0))).attr(g.custom.horizontal?"width":"height",0).remove(),f.exit().transition().duration(1e3).remove()):(f.exit().remove(),b.exit().remove()),N=M.selectAll(".td-total").data(j),N.enter().append("div").attr("class","td-total").style("opacity",0),N.exit().remove(),z=A.selectAll("div.td-legend-item").data(k),d=z.enter().append("div").attr("class","td-legend-item"),d.append("i").attr("class","td-legend-item-icon"),d.append("div").attr("class","td-legend-item-text"),z.exit().remove()},U=function(){return null!==o&&null!==i?(h.attr("transform","translate("+da.utils.svgNum(g.padding.left)+","+da.utils.svgNum(g.padding.top)+")"),g.axes.x.visible&&(Y.attr("transform",function(){switch(g.axes.x.position){case"right":return"translate("+V+",0)";case"bottom":return"translate(0,"+y+")";default:return null}}()).transition().duration(1e3).call(X).select(".domain").attr("transform",function(){switch(g.axes.x.position){case"top":case"bottom":return"translate(0,"+(da.utils.realNum(Z(0))-y)+")";case"left":case"right":return"translate("+da.utils.realNum(Z(0))+",0)"}}()),g.custom.wrapTicks&&Y.selectAll(".tick text").call(da.utils.wrap,g.custom.horizontal?g.padding.left-X.tickPadding()-X.tickSize():W.rangeBand()/(1-g.custom.rangePadding))),g.axes.y.visible&&ba.attr("transform",function(){switch(g.axes.y.position){case"right":return"translate("+V+",0)";case"bottom":return"translate(0,"+y+")";default:return null}}()).transition().duration(1e3).call(aa),null!=g.custom.thresholds?H.classed("visup-hidden",!1).transition().duration(1e3).style("opacity",1).attr("x1",function(a){return g.custom.horizontal?da.utils.svgNum(Z(a)):0}).attr("x2",function(a){return g.custom.horizontal?da.utils.svgNum(Z(a)):V}).attr("y1",function(a){return g.custom.horizontal?0:da.utils.svgNum(Z(a))}).attr("y2",function(a){return g.custom.horizontal?y:da.utils.svgNum(Z(a))}).style("stroke","lightgrey"):H.classed("visup-hidden",!0),b.transition().duration(1e3).style("opacity",1).attr(g.custom.horizontal?"y":"x",function(a,b){var c,d,e;return g.custom.grouped===!1?d=W(d3.select(this.parentNode).datum()[q.x]):(c=W(d3.select(this.parentNode).datum()[q.x]),e=W.rangeBand()/d3.select(this.parentNode).datum()._val.length,d=da.utils.realNum(c+e*(b%d3.select(this.parentNode).datum()._val.length))),a.bbox={},a.bbox[g.custom.horizontal?"y":"x"]=d}).attr(g.custom.horizontal?"width":"height",function(a){var b;return null!=a._y1&&(b=da.utils.svgNum(Math.abs(Z(a._y1)-Z(0)))),a.bbox[g.custom.horizontal?"width":"height"]=b}).attr(g.custom.horizontal?"x":"y",function(a){var b;return null!=a._y1?(b=g.custom.grouped?da.utils.realNum(d3.min([Z(0),Z(a._y1)])):da.utils.realNum(d3.min([Z(a._y0),Z(a._y1+a._y0)])),a.bbox[g.custom.horizontal?"x":"y"]=b):void 0}).attr(g.custom.horizontal?"height":"width",function(a){var b;return b=g.custom.grouped===!1?da.utils.svgNum(W.rangeBand()):da.utils.svgNum(W.rangeBand()/d3.select(this.parentNode).datum()._val.length),a.bbox[g.custom.horizontal?"height":"width"]=b}).style("fill",function(a){return e("linear"===g.scales.color.type?da.utils.moreColor(a.color,k,g.scales.color.range):a.color)}).tween("",function(a){return function(b){return 1>b?void 0:a.centroid=[a.bbox.x+a.bbox.width/2,a.bbox.y+a.bbox.height/2]}}).each("end",function(a,c){return c===b[0].length-1?(C=!0,m.ready()):void 0}),g.custom.showTotals?N.classed("td-hidden",!1).style("position","absolute").style("width",function(){return da.utils.svgNum(W.rangeBand())+"px"}).transition().duration(1e3).style("opacity",1).style("bottom",function(a){return y+g.padding.bottom-da.utils.realNum(Z(a._totPos))+"px"}).style("left",function(a,b){return g.padding.left+da.utils.realNum(W(a[q.x]))+"px"}).text(function(a){return da.utils.template(g.custom.totalFormat,{t:a._totPos+a._totNeg},g.custom.localeId)}):N.classed("td-hidden",!0),g.legends.color.visible&&(A.selectAll("i.td-legend-item-icon").attr("class","td-legend-item-icon fa fa-square").style("color",function(){return e("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum(),k,g.scales.color.range):d3.select(this.parentNode).datum())}),da.utils.relayoutLegend(g.legends.color,A,z,o)),K.classed("td-hidden",!0)):void 0},p=function(a){var b;return b=_.cloneDeep(a.item),b.$x=a.x,b.$y=a.y,b.$color=a.color,b.$colorString=e("linear"===g.scales.color.type?da.utils.moreColor(a.color,k,g.scales.color.range):a.color),b},n=function(a,b){var c;if(c=null!=a?p(a):null,null!=d3.event&&(b=d3.event.type),null!=b)switch(b){case"click":return m.click(c);case"mouseover":case"mousemove":return m.over(c);case"mouseleave":return m.over(null)}},w=function(a){return d3.select(this).classed("td-over",!0),d3.select(B.parentNode).classed("td-over",!0),null!=B.parentNode&&d3.select(B.parentNode.parentNode).classed("td-over",!0),null!=B.parentNode&&null!=B.parentNode.parentNode&&d3.select(B.parentNode.parentNode.parentNode).classed("td-over",!0),g.tooltip.visible&&K.classed("td-hidden",!1).html(function(){return da.utils.template(g.tooltip.textFormat,p(a),g.custom.localeId)}),null!=d3.event?n(a):n(a,"mousemove")},u=function(a){return d3.select(this).classed("td-over",!1),d3.select(B.parentNode).classed("td-over",!1),null!=B.parentNode&&d3.select(B.parentNode.parentNode).classed("td-over",!1),null!=B.parentNode&&null!=B.parentNode.parentNode&&d3.select(B.parentNode.parentNode.parentNode).classed("td-over",!1),g.tooltip.visible&&K.classed("td-hidden",!0),null!=d3.event?n(a):n(a,"mouseleave")},r=function(a){return g.custom.selectable?(b.classed("td-selected",!1),_.isEqual(a,D)?(D=null,null!=d3.event?n(null):n(null,"click")):(d3.select(this).classed("td-selected",!0),D=a,null!=d3.event?n(a):n(a,"click"))):void 0},t=function(){return C?(u.call(B,d3.select(B).datum()),B=null):void 0},x=function(a){var c,d,e,f;if(C)return null!=B&&(d3.select(B).classed("td-over",!1),d3.select(B.parentNode).classed("td-over",!1),null!=B.parentNode&&d3.select(B.parentNode.parentNode).classed("td-over",!1),null!=B.parentNode&&null!=B.parentNode.parentNode&&d3.select(B.parentNode.parentNode.parentNode).classed("td-over",!1)),a.x-=g.padding.left,a.y-=g.padding.top,e=1/0,f=1/0,B=c=null,b.each(function(b){var d,h;return(null==b.centroid||_.isEqual(b.centroid,[0,0]))&&(b.centroid=[b.bbox.x+b.bbox.width/2,b.bbox.y+b.bbox.height/2]),d=Math.abs(b.centroid[0]-a.x),h=Math.abs(b.centroid[1]-a.y),!g.custom.horizontal&&(e>d||e>=d&&f>h)||g.custom.horizontal&&(f>h||f>=h&&e>d)?(e=d,f=h,B=this,c=b):void 0}),d=$(K.node()).width(),L.style("top","auto").style("left",function(){var a,b;return b=g.padding.left+c.centroid[0],0>b-d/2?d/2+"px":b+d/2>(a=g.padding.left+V)?a-d/2+"px":b+"px"}).style("bottom",g.padding.bottom+y-(c.bbox.y<=a.y||g.custom.horizontal||!Modernizr.touch?c.bbox.y:a.y)+"px"),w.call(B,c)},v=function(){return x({x:d3.mouse(this)[0],y:d3.mouse(this)[1]})},s=function(a){return x(a.getCGPoint())},T=function(a){return g.custom.selectable&&null!==o&&null!==i?(b.classed("td-selected",!1),null===a?D=null:b.each(function(b){return null!=b.item.id&&b.item.id.toString()===a||null!=b.item[q.color]&&b.item[q.color].toString()===a?(d3.select(this).classed("td-selected",!0),D=b):void 0})):void 0},d}}.call(this),function(){da.bullet=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A;return i=d3.select(a),g={padding:{top:0,right:0,bottom:0,left:0},scales:{x:{field:"d.x",type:"linear",domain:["min","max"],range:[0,"width"]},color:{range:["#444","#ccc"]}},axes:{x:{position:"bottom",tickPadding:100,tickFormat:"{x}",visible:!0}},transition:{enter:!1,update:!0,exit:!1},custom:{ranges:[],target:null,projected:null,localeId:null}},f=j=null,p=n=l=null,y=null,c=d3.scale.linear(),z=d3.svg.axis(),h=d3.dispatch("click","select","over"),d=_.cloneDeep(g),x=k=null,(v=function(){var b,c;return c=$(a).width(),b=$(a).height(),x=c-da.utils.svgNum(d.padding.right)-da.utils.svgNum(d.padding.left),k=b-da.utils.svgNum(d.padding.top)-da.utils.svgNum(d.padding.bottom)})(),e=i.append("svg").attr("width","100%").attr("height","100%").append("g").attr("class","td-chart-container"),A=e.append("g").attr("class","td-x-axis"),q=e.append("g").attr("class","td-ranges-cont"),r=e.append("line").attr("class","td-target").style("opacity",0),o=e.append("rect").attr("class","td-projected").style("opacity",0),m=e.append("rect").attr("class","td-measure").style("opacity",0),(s=function(){var a;return y=function(){switch(d.scales.x.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),p=q.selectAll("rect.td-range").data(null!=d.custom.ranges?d.custom.ranges:[]),a=p.enter().append("rect").style("opacity",0).attr("class","td-range"),d.transition.enter&&(a.attr("x",0).attr("width",0),r.attr("x1",0).attr("x2",0),o.attr("width",0),m.attr("width",0)),d.transition.exit?p.exit().transition().duration(1e3).attr("x",x).attr("width",0):p.exit().remove(),r.datum(null!=d.custom.target?d.custom.target:null),o.datum(null!=d.custom.projected?d.custom.projected:null)})(),b=function(){return b},b.data=function(a){return 0===arguments.length?f:(f=a,t(),u(),w(),b)},b.options=function(a){return 0===arguments.length?d:(d=_.merge(d,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),s(),v(),t(),u(),w(),b)},b.resize=function(){return v(),u(),w(),b},b.destroy=function(){return i.selectAll("*").remove(),b},b.on=function(a,c){return h.on(a,c),b},b.select=function(a){return 0===arguments.length?selected:(updateSelection(a),w(),b)},t=function(){var a;if(null!==f)return j={},j.x=d.scales.x.field.slice(2),m.datum(f[j.x]),null!=d.custom.ranges&&(a=[d3.min(d.custom.ranges,function(a){return a[0]}),d3.max(d.custom.ranges,function(a){return a[1]})]),y.domain(d3.extent(_.union(a,[d.custom.target,d.custom.projected,f[j.x],0]))),c.domain(d3.range(d.scales.color.range.length))},u=function(){return y.range(function(){var a,b,c,e,f;for(c=[],e=d.scales.x.range,a=0,b=e.length;b>a;a++)f=e[a],c.push(function(){switch(f){case"width":return x;case"height":return k;default:return f}}());return c}()),c.range(d.scales.color.range),z.scale(y).orient(d.axes.x.position).ticks(Math.ceil(x/d.axes.x.tickPadding)>3?Math.ceil(x/d.axes.x.tickPadding):3).tickFormat(function(a){return da.utils.template(d.axes.x.tickFormat,{x:a},d.custom.localeId)})},w=function(){var a;if(null!==i&&null!==f)return a=k/6,e.attr("transform","translate("+da.utils.svgNum(d.padding.left)+","+da.utils.svgNum(d.padding.top)+")"),d.axes.x.visible&&A.attr("transform",function(){switch(d.axes.x.position){case"right":return"translate("+x+",0)";case"bottom":return"translate(0,"+k+")";default:return null}}()).transition().duration(1e3).call(z),null!=d.custom.ranges?p.classed("visup-hidden",!1).transition().duration(1e3).style("opacity",1).attr("x",function(a){return y(a[0])}).attr("y",0).attr("width",function(a){return da.utils.svgNum(y(a[1])-y(a[0]))}).attr("height",k).style("fill",function(a,b){return null!=a.color?a.color:c(da.utils.moreColor(b,d3.range(d.custom.ranges.length),d.scales.color.range))}):p.classed("visup-hidden",!0),null!=d.custom.target?r.classed("visup-hidden",!1).transition().duration(1e3).style("opacity",1).attr("x1",function(a){return y(a)}).attr("x2",function(a){return y(a)}).attr("y1",function(b){return 1*a}).attr("y2",function(b){return 5*a}):r.classed("visup-hidden",!0),null!=d.custom.projected?o.classed("visup-hidden",!1).transition().duration(1e3).style("opacity",1).attr("x",function(a){return y(Math.min(0,a))}).attr("y",2*a).attr("width",function(a){return da.utils.svgNum(Math.abs(y(a)-y(0)))}).attr("height",2*a):r.classed("visup-hidden",!0),null!=f[j.x]?m.classed("visup-hidden",!1).transition().duration(1e3).style("opacity",1).attr("x",function(a){return y(Math.min(0,a))}).attr("y",2*a).attr("width",function(a){return da.utils.svgNum(Math.abs(y(a)-y(0)))}).attr("height",2*a):m.classed("visup-hidden",!0)},b}}.call(this),function(){da.funnel=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E;return m=d3.select(a),j={padding:{top:0,right:0,bottom:0,left:0},scales:{x:{field:"d.x"},color:{field:"d.color",type:"linear",domain:["min","max"],range:["#444","#ccc"]}},custom:{valueFormat:null,labelFormat:null,fieldDescription:"d.description",selectable:!0}},o=g=h=i=null,w=[],b=t=null,d=null,v=d3.svg.line(),k=d3.dispatch("click","select","over"),e=_.cloneDeep(j),(y=function(){return d=function(){switch(e.scales.color.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}()})(),E=s=x=null,(B=function(){var b,c;return c=$(a).width(),b=$(a).height(),E=(c-da.utils.svgNum(e.padding.right)-da.utils.svgNum(e.padding.left))/2,s=b-da.utils.svgNum(e.padding.top)-da.utils.svgNum(e.padding.bottom)})(),f=m.append("svg").attr("width","100%").attr("height","100%").append("g").attr("class","td-chart-container"),u=m.append("div").attr("class","td-items-container"),c=function(){return c},c.data=function(a){return 0===arguments.length?g:(g=a,z(),A(),D(),c)},c.options=function(a){return 0===arguments.length?e:(e=_.merge(e,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),y(),B(),z(),A(),D(),c)},c.resize=function(){return B(),A(),D(),c},c.destroy=function(){return m.selectAll("*").remove(),c},c.on=function(a,b){return k.on(a,b),c},c.select=function(a){return 0===arguments.length?_.forEach(_.cloneDeep(w),function(a){return n(a)}):(C(a),D(),c)},z=function(){var a,c,j,k,l,m;if(null!==g){for(o={},o.x=e.scales.x.field.slice(2),o.color=e.scales.color.field.slice(2),o.description=e.custom.fieldDescription.slice(2),h=_.cloneDeep(g),m=d3.max(h,function(a){return Math.abs(a[o.x])}),c=k=0,l=h.length;l>k;c=++k)a=h[c],da.utils.isSvgNum(a[o.x])&&(a._xNorm=Math.abs(a[o.x]/m),a._path=[[0,c],[a._xNorm,c],[a._xNorm,c+1],[0,c+1]]);return"linear"===e.scales.color.type&&(i=function(){var b,c,d;for(a=[],b=0,c=g.length;c>b;b++)d=g[b],a.push(d[o.color]);return _.uniq(a)}()),b=f.selectAll(".td-bar").data(h),b.enter().append("path").attr("class","td-bar").on("mouseover",r).on("mouseleave",q).on("click",Modernizr.touch?null:p).each(function(a){var b,c;return Modernizr.touch?(c=this,b=new Hammer.Manager(c),b.add(new Hammer.Tap),b.on("tap",function(){return p.call(c,a)})):void 0}),b.exit().remove(),t=u.selectAll(".td-item").data(h),j=t.enter().append("div").attr("class","td-item"),j.append("div").attr("class","td-item-label"),j.append("div").attr("class","td-item-description"),t.exit().remove(),d.domain(function(){var a,b,c,d,f;if("linear"===e.scales.color.type)return a=d3.range(e.scales.color.range.length);if(a=[],_.isArray(e.scales.color.domain))for(d=e.scales.color.domain,b=0,c=d.length;c>b;b++)f=d[b],a.push(function(){switch(f){case"min":return d3.min(g,function(a){return a[o.color]});case"max":return d3.max(g,function(a){return a[o.color]});case null:break;default:return f}}());else switch(e.scales.color.domain){case"all":g.forEach(function(b){return null!=b[o.color]?a.push(b[o.color]):void 0}),a=_.uniq(a)}return a}())}},A=function(){return null!==m&&null!==g?(d.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.color.range,a=0,b=d.length;b>a;a++)f=d[a],c.push(function(){switch(f){case"width":return E;case"height":return s;case null:break;default:return f}}());return c}()),x=s/g.length,v.x(function(a){return da.utils.svgNum(E-a[0]*E)}).y(function(a){return x*a[1]})):void 0},D=function(){return null!==m&&null!==g?(f.attr("transform","translate("+da.utils.svgNum(e.padding.left)+","+da.utils.svgNum(e.padding.top)+")"),f.selectAll("path.td-bar").transition().duration(1e3).attr("d",function(a){return null!=a._path?v(a._path):void 0}).style("fill",function(a){return d("linear"===e.scales.color.type?da.utils.moreColor(a[o.color],i,e.scales.color.range):a[o.color])}),u.selectAll("div.td-item").style("height",x+"px"),u.selectAll("div.td-item-label").text(function(){return d3.select(this.parentNode).datum()[o.color]}),u.selectAll("div.td-item-description").text(function(){return d3.select(this.parentNode).datum()[o.description]})):void 0},n=function(a){var b;return b=_.cloneDeep(a),b.$x=a[o.x],b.$color=a[o.color],b},l=function(a){var b,c;if(b=null!=a?n(a):null,null!=d3.event&&(c=d3.event.type),null!=c)switch(c){case"click":return k.click(b);case"mouseover":case"mousemove":return k.over(b);case"mouseleave":return k.over(null)}},r=function(a){return d3.select(this).classed("td-over",!0),l(a)},q=function(a){return d3.select(this).classed("td-over",!1),l(a)},p=function(a){return e.custom.selectable?(b.classed("td-selected",!1),_.isEqual(a,w)?(w=null,l(null)):(d3.select(this).classed("td-selected",!0),w=a,l(a))):void 0},C=function(a){return e.custom.selectable&&null!==m&&null!==g?(b.classed("td-selected",!1),null===a?w=null:b.each(function(b){return null!=b.id&&b.id.toString()===a||null!=b[o.color]&&b[o.color].toString()===a?(d3.select(this).classed("td-selected",!0),w=b):void 0})):void 0},c}}.call(this),function(){da.graph=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,aa,ba,ca,ea,fa,ga,ha,ia,ja,ka;return w=d3.select(a),p={padding:{top:0,right:0,bottom:0,left:0},scales:{nodeRadius:{field:"d.radius",type:"linear",domain:["min","max"],range:[5,10]},nodeColor:{field:"d.color",type:"linear",domain:["min","max"],range:["#444","#ccc"]},edgeWidth:{field:"d.width",type:"linear",domain:["min","max"],range:[1,5]},edgeColor:{field:"d.color",type:"linear",domain:["min","max"],range:["#444","#ccc"]}},tooltip:{textFormat:"{$radius}",visible:!0},custom:{layout:{type:"force",fieldCircular:"d.circular",fieldRanked:"d.ranked"},force:{gravity:.05,charge:-3e3,chargeDistance:1/0,linkDistance:20,linkStrength:7,friction:.9,theta:.8},showNodes:!0,showEdges:!0,showLabels:!1,labels:{labelsSize:14,fieldLabel:"d.label",fieldRankLabel:"d.rankLabel",rankLabels:!1},collide:!1,draggable:!0,circlePadding:5,zoomExtent:[0,1/0]}},x=m=o=n=S=null,O=v=I=V=null,N=L=u=s=null,l=null,q=d3.dispatch("click","select","forceStop","forceStart","zoom","drag"),J=Q=null,y=d3.layout.force().on("end",function(){return q.forceStop()}).on("start",function(){return q.forceStart()}),ia=d3.behavior.zoom().on("zoom",function(){return h.custom.collide&&(O.each(d(1)),aa()),ga(),q.zoom()}),r=y.drag().on("dragstart",function(a){return d3.event.sourceEvent.stopPropagation()}).on("drag",function(a){return d3.select(this).classed("visup-graph-fixed",a.fixed=!0),ga(),("circular"===h.custom.layout.type||"ranked"===h.custom.layout.type)&&(y.stop(),a.x=d3.event.x,a.y=d3.event.y,aa()),q.drag()}),h=_.cloneDeep(p),(Y=function(){return N=function(){switch(h.scales.nodeRadius.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"pow":return d3.scale.pow().exponent(10);case"sqrt":return d3.scale.sqrt()}}(),L=function(){switch(h.scales.nodeColor.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal()}}(),u=function(){switch(h.scales.edgeWidth.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"pow":return d3.scale.pow().exponent(10)}}(),s=function(){switch(h.scales.edgeColor.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal()}}(),ia.scaleExtent(h.custom.zoomExtent)})(),ha=G=null,(ea=function(){var b,c;return c=$(a).width(),b=$(a).height(),ha=c-da.utils.svgNum(h.padding.right)-da.utils.svgNum(h.padding.left),G=b-da.utils.svgNum(h.padding.top)-da.utils.svgNum(h.padding.bottom)})(),W=w.append("svg").attr("width","100%").attr("height","100%").call(ia),b=W.append("rect").attr("class","visup-chart-background").on("click",function(){return d3.event.defaultPrevented?void 0:(fa(null),ga())}),i=W.append("g").attr("class","visup-chart-container").append("g").attr("class","visup-chart-zoom-container"),t=i.append("g").attr("class","visup-edge-container"),M=i.append("g").attr("class","visup-node-container"),H=i.append("g").attr("class","visup-label-container"),X=w.append("div").attr("class","tooltip-container").style("position","absolute").append("div").attr("class","tooltip"),c=function(){return c},c.version="0.1.0",c.data=function(a,b){return 0===arguments.length?m:(m=a,Z(b),ba(),ga(),ca(b),c)},c.options=function(a){return 0===arguments.length?h:(h=_.merge(h,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),Y(),ea(),Z(!0),ba(),ga(),ca(),c)},c.resize=function(){return ea(),ba(),ga(),ca(),c},c.destroy=function(){return w.selectAll("*").remove(),c},c.on=function(a,b){return q.on(a,b),c},c.select=function(a){return 0===arguments.length?S:(fa(a),ga(),c)},c.reset=function(){return S=null,O.each(function(a){return a.fixed=!1}).classed("visup-graph-selected",!1).classed("visup-graph-fixed",!1).classed("visup-graph-masked",!1),v.classed("visup-graph-masked",!1),ca(),ga(),"force"!==h.custom.layout.type&&aa(!0),c},c.stop=function(){return y.stop(),c},c.start=function(){return h.custom.layout.type="force",y.start(),c},c.force=function(a){return 0===arguments.length?y:c},c.zoom=function(a){return ja(a)},c.center=function(a){return ka(a)},f=function(a,b){return null!=a.source.x?(a.target.x=a.target.px=a.source.x+Math.random(),a.target.y=a.target.py=a.source.y+Math.random()):null!=a.target.x?(a.source.x=a.source.px=a.target.x+Math.random(),a.source.y=a.source.py=a.target.y+Math.random()):(a.source.x=(0+Math.random()*b)/ia.scale()-ia.translate()[0]*ia.scale(),a.source.y=(0+Math.random()*b)/ia.scale()-ia.translate()[1]*ia.scale(),a.target.x=(0+Math.random()*b)/ia.scale()-ia.translate()[0]*ia.scale(),a.target.y=(0+Math.random()*b)/ia.scale()-ia.translate()[1]*ia.scale())},Z=function(a){var b,c,d;if(null!==m)return a||(S=null,M.selectAll(".visup-graph-node").classed("visup-graph-selected",!1)),x={},x.nodeRadius=h.scales.nodeRadius.field.slice(2),x.nodeColor=h.scales.nodeColor.field.slice(2),x.edgeWidth=h.scales.edgeWidth.field.slice(2),x.edgeColor=h.scales.edgeColor.field.slice(2),x.label=h.custom.labels.fieldLabel.slice(2),x.rankLabel=h.custom.labels.fieldRankLabel.slice(2),x.ranked=h.custom.layout.fieldRanked.slice(2),x.circular=h.custom.layout.fieldCircular.slice(2),b=j(m),o=b.nodes,n=b.edges,null!==M.selectAll(".visup-graph-node").data()&&o.forEach(function(a){return M.selectAll(".visup-graph-node").each(function(b){return a.id===b.id?(a.x=b.x,a.y=b.y,a.px=b.px,a.py=b.py,a.fixed=b.fixed):void 0})}),O=M.selectAll(".visup-graph-node").data(o,function(a){return a.id}),O.enter().append("circle").attr("class","visup-graph-node").on("click",function(a){return"force"===h.custom.layout.type&&l>0&&T(),d3.event.defaultPrevented?void 0:F(a)}).on("mouseover",E).on("mouseleave",D),O.exit().remove(),h.custom.draggable&&O.call(r).on("mousedown",function(a){return R()}).on("mouseup",function(){}),v=t.selectAll("line.visup-graph-edge").data(n,function(a){return a.id}),v.enter().append("line").attr("class","visup-graph-edge").each(f),v.exit().remove(),I=H.selectAll("text.visup-graph-label").data(o,function(a){return a.id}),I.enter().append("text").attr("class","visup-graph-label"),I.exit().remove(),y.nodes(o).links(n),N.domain(function(){var a,b,c,d,e;for(a=[],d=h.scales.nodeRadius.domain,c=0,b=d.length;b>c;c++)e=d[c],a.push(function(){switch(e){case"min":return d3.min(o,function(a){return a[x.nodeRadius]});case"max":return d3.max(o,function(a){return a[x.nodeRadius]});default:return e}}());return a}()),L.domain(function(){var a,b,c,d,e;if("linear"===h.scales.nodeColor.type)return d3.range(h.scales.nodeColor.range.length);switch(h.scales.nodeColor.domain){case null:return _.uniq(_.map(o,function(a){return a[x.nodeColor]}));default:for(a=[],d=h.scales.nodeColor.domain,c=0,b=d.length;b>c;c++)e=d[c],a.push(function(){switch(e){case"min":return d3.min(o,function(a){return a[x.nodeColor]});case"max":return d3.max(o,function(a){return a[x.nodeColor]});default:return e}}());return a}}()),"source"!==(c=h.scales.edgeWidth.field)&&"target"!==c?u.domain(function(){var a,b,c,d,e;for(a=[],d=h.scales.edgeWidth.domain,c=0,b=d.length;b>c;c++)e=d[c],a.push(function(){switch(e){case"min":return d3.min(n,function(a){return a[x.edgeWidth]});case"max":return d3.max(n,function(a){return a[x.edgeWidth]});default:return e}}());return a}()):u.domain(N.domain()),"source"!==(d=h.scales.edgeColor.field)&&"target"!==d?s.domain(function(){var a,b,c,d,e;if("linear"===h.scales.edgeColor.type)return d3.range(h.scales.edgeColor.range.length);switch(h.scales.edgeColor.domain){case null:return _.uniq(_.map(n,function(a){return a[x.edgeColor]}));default:for(a=[],d=h.scales.edgeColor.domain,c=0,b=d.length;b>c;c++)e=d[c],a.push(function(){switch(e){case"min":return d3.min(n,function(a){return a[x.edgeColor]});case"max":return d3.max(n,function(a){return a[x.edgeColor]});default:return e}}());return a}}()):s.domain(L.domain())},ba=function(){return null!==w&&null!==m&&null!==N?(N.range(function(){var a,b,c,d,e;for(c=[],d=h.scales.nodeRadius.range,b=0,a=d.length;a>b;b++)e=d[b],c.push(e);return c}()),L.range(function(){var a,b,c,d,e;for(c=[],d=h.scales.nodeColor.range,b=0,a=d.length;a>b;b++)e=d[b],c.push(e);return c}()),u.range(function(){var a,b,c,d,e;for(c=[],d=h.scales.edgeWidth.range,b=0,a=d.length;a>b;b++)e=d[b],c.push(e);return c}()),s.range(function(){var a,b,c,d,e;for(c=[],d=h.scales.edgeColor.range,b=0,a=d.length;a>b;b++)e=d[b],c.push(e);return c}()),y.size([ha,G]).gravity(h.custom.force.gravity).charge(h.custom.force.charge).linkDistance(h.custom.force.linkDistance).linkStrength(h.custom.force.linkStrength).friction(h.custom.force.friction)):void 0},ga=function(){return null!==w&&null!==m?(b.attr("x",0).attr("y",0).attr("width",h.padding.left+ha+h.padding.right).attr("height",h.padding.top+G+h.padding.bottom),w.select(".visup-chart-container").attr("transform","translate("+da.utils.svgNum(h.padding.left)+","+da.utils.svgNum(h.padding.top)+")"),w.select(".visup-chart-zoom-container").attr("transform","translate("+ia.translate()+")scale("+ia.scale()+")"),h.custom.showNodes?O.classed("visup-hidden",!1).attr("r",function(a){
return null!=a[x.nodeRadius]?N(a[x.nodeRadius])/ia.scale():void 0}).style("fill",function(a){return d3.select(this).classed("visup-graph-selected")?"#333":L("linear"===h.scales.nodeColor.type?da.utils.moreColor(a[x.nodeColor],_.sortBy(_.uniq(_.map(o,function(a){return a[x.nodeColor]}))),h.scales.nodeColor.range):a[x.nodeColor])}).style("stroke",function(a){return d3.select(this).classed("visup-graph-selected")&&null!=a[x.nodeColor]?L("linear"===h.scales.nodeColor.type?da.utils.moreColor(a[x.nodeColor],_.sortBy(_.uniq(_.map(o,function(a){return a[x.nodeColor]}))),h.scales.nodeColor.range):a[x.nodeColor]):d3.select(this).classed("visup-graph-fixed")?"white":"none"}).style("stroke-width",function(){return 4/ia.scale()}).style("stroke-dasharray",function(){return d3.select(this).classed("visup-graph-fixed")?[2/ia.scale(),2/ia.scale()]:"none"}):O.classed("visup-hidden",!0),h.custom.showEdges?v.classed("visup-hidden",!1).attr("stroke-width",function(a){switch(h.scales.edgeWidth.field){case"source":if(null!=a.source[x.nodeRadius])return u(a.source[x.nodeRadius])/ia.scale();break;case"target":if(null!=a.target[x.nodeRadius])return u(a.target[x.nodeRadius])/ia.scale();break;default:if(null!=a[x.edgeWidth])return u(a[x.edgeWidth])/ia.scale()}}).attr("stroke",function(a){switch(h.scales.edgeColor.field){case"source":if("linear"===h.scales.nodeColor.type)return L(da.utils.moreColor(a.source[x.nodeColor],_.sortBy(_.uniq(_.map(o,function(a){return a[x.nodeColor]}))),h.scales.nodeColor.range));if(null!=a.source[x.nodeColor])return L(a.source[x.nodeColor]);break;case"target":if("linear"===h.scales.nodeColor.type)return L(da.utils.moreColor(a.target[x.nodeColor],_.sortBy(_.uniq(_.map(o,function(a){return a[x.nodeColor]}))),h.scales.nodeColor.range));if(null!=a.target[x.nodeColor])return L(a.target[x.nodeColor]);break;default:if("linear"===h.scales.edgeColor.type)return s(da.utils.moreColor(a[x.edgeColor],_.sortBy(_.uniq(_.map(n,function(a){return a[x.edgeColor]}))),h.scales.nodeColor.range));if(null!=a[x.edgeColor])return s(a[x.edgeColor])}}):v.classed("visup-hidden",!0),h.custom.showLabels?(I.classed("visup-hidden",!1).text(function(a){return a.bbox=null,a[x.label]}).style("font-size",h.custom.labels.labelsSize/ia.scale()).attr("y",function(a){return a.yPad=10/ia.scale()+N(a[x.nodeRadius])/ia.scale()-h.custom.labels.labelsSize/ia.scale()/3,null!=a.y?a.ly=a.y-a.yPad:void 0}),h.custom.labels.rankLabels?(U(),P()):I.classed("visup-collide",!1)):I.classed("visup-hidden",!0)):void 0},ca=function(a){if(null!==w&&null!==m)switch(h.custom.layout.type){case"force":return y.alpha()>0&&R(),y.start(),a?l>0?T():y.resume():y.on("tick",function(){return h.custom.collide&&O.each(d(y.alpha())),aa()});case"circular":return y.start(),y.stop(),e(),aa(!0);case"ranked":return y.start(),y.stop(),g(),aa(!0)}},aa=function(a){var b,c,d;if(h.custom.showNodes&&(d=O,a&&(d=O.transition()),d.attr("cx",function(a){return a.x}).attr("cy",function(a){return a.y})),h.custom.showEdges&&(b=v,a&&(b=v.transition()),b.attr("x1",function(a){return a.source.x}).attr("y1",function(a){return a.source.y}).attr("x2",function(a){return a.target.x}).attr("y2",function(a){return a.target.y})),h.custom.showLabels){if(c=I,a&&(c=I.transition()),c.attr("x",function(a){return a.lx=a.x}).attr("y",function(a){return a.ly=a.y-a.yPad}),!h.custom.labels.rankLabels)return clearTimeout(Q);if(clearTimeout(Q),P(),a)return Q=setTimeout(function(){return P()},500)}},e=function(){var a,b,c;return a={x:ha/2,y:G/2},c=G>ha?ha/3:G/3,b=_.clone(o),b.sort(function(a,b){return b[x.circular]-a[x.circular]}),b.forEach(function(b,d){var e;return b.fixed?void 0:(e=2*d*Math.PI/o.length,b.x=a.x+Math.cos(e)*c,b.y=a.y+Math.sin(e)*c)})},g=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(a=o,a=d3.nest().key(function(a){return a[x.ranked]}).entries(a),a.sort(function(a,b){return b.key-a.key}),g=a.length,b=0,d=0,c=a.length;c>d;d++)h=a[d],h.values.length>b&&(b=h.values.length);return j=50,l=50,f=j*(b-1),e=l*(g-1),i=(ha-f)/2,k=(G-e)/2,a.forEach(function(a,b){var c,d;return c=i+(f-(a.values.length-1)*j)/2,d=k+l*b,a.values.forEach(function(a,b){return a.fixed?void 0:(a.x=c+b*j,a.y=d)})})},F=function(a){return fa(a.id),ga()},fa=function(a){var b;return M.selectAll(".visup-graph-node").classed("visup-graph-selected",!1),null===a?S=null:(b=_.find(o,function(b){return b.id===a}),S===b?(S=null,O.each(function(b){return b.id===a&&(d3.select(this).classed("visup-graph-fixed",b.fixed=!1)&&b.fixed,"force"!==h.custom.layout.type)?ca():void 0})):(O.each(function(b){return b.id===a?d3.select(this).classed("visup-graph-selected",!0):void 0}),S=b)),ga(),q.select(S)},E=function(a){var b;return b=a.id,O.classed("visup-graph-masked",!0),d3.select(this).classed("visup-graph-masked",!1),v.each(function(a,c){return a.source.id!==b&&a.target.id!==b?d3.select(this).classed("visup-graph-masked",!0):O.each(function(b,c){return b.id===a.source.id||b.id===a.target.id?d3.select(this).classed("visup-graph-masked",!1):void 0})}),h.tooltip.visible?X.classed("hidden",!1).text(function(){return da.utils.template(h.tooltip.textFormat,function(){var b;return b=_.cloneDeep(a),b.$radius=a[x.nodeRadius],b.$color=a[x.nodeColor],b}())}):void 0},D=function(a){return O.classed("visup-graph-masked",!1),v.classed("visup-graph-masked",!1),h.tooltip.visible?X.classed("hidden",!0):void 0},j=function(a){var b;return O=a.nodes,v=a.edges,b=k(O,v),{nodes:O,edges:b}},k=function(a,b){var c,d,e,f,g,h,i,j,k,l,m;for(i=[],c=0,h=0,g=b.length;g>h;h++){if(d=b[h],!_.isObject(d.source)){try{if(k=d.source,j=_.find(a,function(a){return a.id===k}),void 0===j)throw"source undefined. edge id: "+d.id+", source id: "+k}catch(e){d=e,c++;continue}d.source=j}if(!_.isObject(d.target)){try{if(m=d.target,l=_.find(a,function(a){return a.id===m}),void 0===l)throw"target undefined. edgeid: "+d.id+", target id: "+m}catch(f){d=f,c++;continue}d.target=l}i.push(d)}return i},K=function(a){return N(a[x.nodeRadius])/ia.scale()},d=function(a){var b,c,d;return b=1*a,d=d3.geom.quadtree(o),c=h.custom.circlePadding,function(a){var e,f,g,h,i;return e=K(a)+c,f=a.x-e,g=a.x+e,h=a.y-e,i=a.y+e,d.visit(function(d,j,k,l,m){var n,o,p;return d.point&&d.point!==a&&(n=a.x-d.point.x,o=a.y-d.point.y,p=Math.sqrt(n*n+o*o),e=K(a)+c+K(d.point),e>p&&(p=(p-e)/p*b,a.x-=n*=p,a.y-=o*=p,d.point.x+=n,d.point.y+=o)),j>g||f>l||k>i||h>m})}},U=function(){return V=_.clone(H.selectAll(".visup-graph-label")[0]),V.sort(function(a,b){return d3.select(b).datum()[x.rankLabel]-d3.select(a).datum()[x.rankLabel]})},P=function(){var a,b,c,d,e,f,g,i,j,k;for(k=[],f=0,d=V.length;d>f;f++){for(j=V[f],b=d3.select(j).datum(),null==b.bbox&&(b.bbox=j.getBBox()),a=[b.x-b.bbox.width/2,b.x+b.bbox.width/2,b.ly],c=!1,g=0,e=k.length;e>g;g++)if(i=k[g],!(i[0]>a[1]||i[1]<a[0]||Math.abs(a[2]-i[2])>h.custom.labels.labelsSize/ia.scale())){c=!0;break}c||k.push(a),d3.select(j).classed("visup-collide",c)}},R=function(){return l=y.alpha()},T=function(){return y.alpha(l)},ja=function(a){var b,c,d,e,f,g;f=ia.scale(),d=ia.scaleExtent(),e=f*a,c=1e3,d[0]<=e&&e<=d[1]&&(g=ia.translate(),b=[ha/2,G/2],ia.scale(e).translate([b[0]+(g[0]-b[0])/f*e,b[1]+(g[1]-b[1])/f*e]).event(W.transition().duration(c)))},ka=function(a){var b,c,d,e,f,g,h,j;return c=1e3,a=a?a:.9,b=i.node().getBBox(),d=b.width,e=b.height,h=b.x+b.width/2,j=b.y+b.height/2,f=a/Math.max(d/ha,e/G),g=[ha/2-f*h,G/2-f*j],ia.scale(f).translate(g).event(W.transition().duration(c))},A=function(a){var b,c;return b=ia.scale(),c=ia.translate(),[(a[0]-c[0])/b,(a[1]-c[1])/b]},B=function(){var a,b,c,d,e;for(e=[[0,0],[ha,0],[ha,G],[0,G]],a=c=0,b=e.length;b>c;a=++c)d=e[a],e[a]=A(d);return e},C=function(){var a,b,c,d,e;for(e=[[0-h.padding.left,0-h.padding.top],[ha+h.padding.right,0-h.padding.top],[ha+h.padding.right,G+h.padding.bottom],[0-h.padding.left,G+h.padding.bottom]],a=c=0,b=e.length;b>c;a=++c)d=e[a],e[a]=A(d);return e},z=function(){var a,b;return b=i.node().getBBox(),a=[[b.x,b.y],[b.x+b.width,b.y],[b.x+b.width,b.y+b.height],[b.x,b.y+b.height]]},c}}.call(this),function(){da.lines=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,aa,ba,ca,ea,fa,ga,ha,ia,ja,ka,la,ma;return p=d3.select(a),l={padding:{top:0,right:0,bottom:0,left:0},scales:{x:{field:"d.x",type:"linear",domain:["min","max"],range:[0,"width"],format:null},y:{field:"d.y",type:"linear",domain:["min","max"],domainExtend:null,range:["height",0],nice:!0},color:{field:"d.color",type:"linear",domain:"all",range:["#444","#ccc"]}},axes:{x:{position:"bottom",tickPadding:100,tickFormat:'{N(x,"0.[00]a")}',tickExtension:"default",tickValues:null,visible:!0},y:{position:"left",tickPadding:25,tickFormat:'{N(y,"0.[00]a")}',tickExtension:"axis",visible:!0}},legends:{color:{title:null,labelFormat:null,labels:null,position:"bottom",visible:!0}},tooltip:{textFormat:"{N($y)}",visible:!0},transition:{enter:!1,update:!0,exit:!1},custom:{interpolate:"linear",strokeWidth:1,stacked:!1,normalized:!1,showAreas:!0,showLines:!0,showPoints:!0,showMarker:!0,showLabels:!1,labelFormat:'{N(y,"0.[00]a")}',pointRadius:10,selectable:!0,showBrush:!1,eventBrush:!1,brushExtent:null,locale:null,outerPadding:0,forecastX:null,dashLength:8}},r=i=k=j=J=null,N=[],K=null,O=C=null,F=null,S=null,ha=ka=f=null,ia=d3.svg.axis(),la=d3.svg.axis(),b=d3.svg.area(),E=d3.svg.line(),c=d3.svg.brush(),R=null,m=d3.dispatch("click","select","over","brush","bind","ready"),L=!1,g=_.cloneDeep(l),(X=function(){var a;return ha=function(){switch(g.scales.x.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"time":return d3.time.scale();case"utc":return d3.time.scale.utc()}}(),ka=function(){switch(g.scales.y.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),f=function(){switch(g.scales.color.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}(),null!=g.custom.localeId&&(F=d3.locale(da.utils.locales[g.custom.localeId].d3)),S=null!=g.scales.x.format?null!=g.custom.localeId&&null!=F?F.timeFormat(g.scales.x.format):d3.time.format(g.scales.x.format):void 0,null!=g.custom.tooltipFormat&&(a=d3.format(g.custom.tooltipFormat)),c.on("brush",function(){return g.custom.eventBrush?s():null})})(),ga=B=null,(ba=function(){var b,c;return c=$(a).width(),b=$(a).height(),ga=c-da.utils.svgNum(g.padding.right)-da.utils.svgNum(g.padding.left),B=b-da.utils.svgNum(g.padding.top)-da.utils.svgNum(g.padding.bottom)})(),Q=p.append("svg").attr("width","100%").attr("height","100%"),Modernizr.touch?R=cross_js.gestures.addEventListener(Q.node(),"drag",function(a){switch(a.phase){case"start":return v();case"change":return u(a);case"end":return w()}}):null!=R&&cross_js.gestures.removeEventListener(R),Q.on("mouseenter",Modernizr.touch?null:function(){return v.call(this)}).on("mousemove",Modernizr.touch?null:function(){return y.call(this)}).on("mouseleave",Modernizr.touch?null:function(){return w.call(this)}),h=Q.append("g").attr("class","td-chart-container"),ja=h.append("g").attr("class","td-x-axis"),ma=h.append("g").attr("class","td-y-axis"),H=h.append("line").attr("class","td-marker-line x"),I=h.append("line").attr("class","td-marker-line y"),P=h.append("g").attr("class","td-series-main-cont"),D=p.append("div").attr("class","td-legend-container").style("position","absolute"),D.append("div").attr("class","td-legend-title"),U=p.append("div").attr("class","td-tooltip-container").style("position","absolute"),T=U.append("div").attr("class","td-tooltip td-hidden"),G=h.append("circle").attr("class","td-marker"),d=h.append("g").attr("class","td-brush"),e=function(){return e},e.data=function(a){return 0===arguments.length?i:(i=a,Y(),aa(),V(),ea(),e)},e.options=function(a){return 0===arguments.length?g:(g=_.merge(g,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),X(),ba(),Y(),aa(),ea(),e)},e.resize=function(){return ba(),aa(),ea(),e},e.destroy=function(){return p.selectAll("*").remove(),e},e.on=function(a,b){return m.on(a,b),e},e.select=function(a){return 0===arguments.length?_.forEach(_.cloneDeep(N),function(a){return q(a)}):(ca(a),ea(),e)},e.extent=function(a){return 0===arguments.length?ha.domain():(Z(a),aa(),ea(),e)},e.brush=function(a){return 0===arguments.length?c.extent():(g.custom.brushExtent=a,W(),ea(),e)},M=null,Y=function(){var a,b,c,d,e,h,l,n,o,p,q,s,t;if(null!==i){switch(q=!1,r={},r.x=g.scales.x.field.slice(2),r.y=[],_.isArray(g.scales.y.field)){case!0:q=!0,g.scales.y.field.forEach(function(a){return r.y.push(a.slice(2))});break;case!1:r.y.push(g.scales.y.field.slice(2))}switch(r.color=[],g.scales.color.field){case"keys":r.color=_.cloneDeep(r.y);break;default:r.color.push(g.scales.color.field.slice(2))}for(r.keys=q?r.y:_.uniq(i.map(function(a){return a[r.color]})),null!=g.scales.x.format&&i.forEach(function(a){return _.isDate(a[r.x])?void 0:a[r.x]=function(){switch(g.scales.x.format){case"date":return new Date(a[r.x]);case"timestamp":return new Date(1e3*a[r.x]);default:return S.parse(String(a[r.x]))}}()}),J={},o=r.keys,b=0,h=o.length;h>b;b++)d=o[b],J[d]={color:d,series:[]};for(q||(n=_.cloneDeep(i),n=d3.nest().key(function(a){return a[r.x]}).key(function(a){return a[r.color]}).entries(n).map(function(a){var b,c,d,e,f;for(e={items:{}},e[r.x]=a.values[0].values[0][r.x],f=a.values,c=0,d=f.length;d>c;c++)b=f[c],e.items[b.key]=b.values[0],e[b.key]=b.values[0][r.y];return e})),p=q?i:n,e=0,l=p.length;l>e;e++){a=p[e],t=0,s=0;for(c in J)J[c].series.push([a[r.x],a[c],a[c]>=0?t:s,c,q?a:a.items[c]]),da.utils.isRealNum(a[c])&&(a[c]>=0?t+=a[c]:s+=a[c])}return k=_.forEach(_.values(J),function(a){return a.series=_.sortBy(a.series,function(b){return null!=a.series&&"time"===g.scales.x.type?b[0]:void 0})}),j=r.keys,(M=function(){return ha.domain(function(){var a,b,c,d,e;if(a=[],_.isArray(g.scales.x.domain))for(d=g.scales.x.domain,c=0,b=d.length;b>c;c++)e=d[c],a.push(function(){switch(e){case"min":return d3.min(i,function(a){return a[r.x]});case"max":return d3.max(i,function(a){return a[r.x]});case null:break;default:return e}}());else switch(g.scales.x.domain){case"all":i.forEach(function(b){return null!==b[r.x]?a.push(b[r.x]):void 0}),a=_.uniq(a)}return _.isArray(a)&&a.length>=2?a:void 0}())})(),ka.domain(function(){var a,b,e,f,h,j,k;if(h=g.custom.normalized?1/0:0,f=g.custom.normalized?-(1/0):0,i.forEach(function(a){var b,e,i,j,k,l;for(i=r.y,j=[],e=0,b=i.length;b>e;e++)c=i[e],g.custom.stacked?j.push(function(){var a,b,c,e;for(c=r.keys,e=[],b=0,a=c.length;a>b;b++)d=c[b],l=d3.min(J[d].series,function(a){return a[2]+a[1]}),k=d3.max(J[d].series,function(a){return a[2]+a[1]}),h>l&&(h=l),k>f?e.push(f=k):e.push(void 0);return e}()):(null!=a[c]&&a[c]<h&&(h=a[c]),null!=a[c]&&a[c]>f?j.push(f=a[c]):j.push(void 0));return j}),a=[],_.isArray(g.scales.y.domain))for(j=g.scales.y.domain,e=0,b=j.length;b>e;e++)k=j[e],a.push(function(){switch(k){case"min":return h;case"max":return f;case null:break;default:return k}}());return _.isArray(a)&&a.length>=2?a:void 0}()),null!=g.scales.y.domainExtend&&ka.domain(function(){var a,b;return a=ka.domain(),b=Math.abs(a[0]-a[a.length-1]),a[0]-=b*g.scales.y.domainExtend,a[a.length-1]+=b*g.scales.y.domainExtend,a}()),f.domain("linear"===g.scales.color.type?d3.range(g.scales.color.range.length):j),m.bind()}},aa=function(){return function(){var a,b,c,d,e;for(c=[],d=g.scales.x.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return ga;case"height":return B;default:return e}}());return"ordinal"===g.scales.x.type?ha.rangePoints(c,g.custom.outerPadding):ha.range(c)}(),ka.range(function(){var a,b,c,d,e;for(c=[],d=g.scales.y.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return ga;case"height":return B;default:return e}}());return c}()),f.range(function(){var a,b,c,d,e;for(c=[],d=g.scales.color.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return ga;case"height":return B;default:return e}}());return c}()),ia.scale(ha).orient(g.axes.x.position).ticks(Math.ceil(ga/g.axes.x.tickPadding)>3?Math.ceil(ga/g.axes.x.tickPadding):3).tickFormat(function(a){return da.utils.template(g.axes.x.tickFormat,{x:a},g.custom.localeId)}),da.utils.setAxisValues(g.axes.x,ia,ha),da.utils.setAxisTicks(g.padding,ga,B,g.axes.x,ia),la.scale(ka).orient(g.axes.y.position).ticks(Math.ceil(B/g.axes.y.tickPadding)>3?Math.ceil(B/g.axes.y.tickPadding):3).tickFormat(function(a){return da.utils.template(g.axes.y.tickFormat,{y:a},g.custom.localeId)}),da.utils.setAxisTicks(g.padding,ga,B,g.axes.y,la),b.x(function(a){return ha(a[0])}).y0(function(a){return g.custom.normalized?ka(0)<ka.range()[1]?ka.range()[0]:ka(0)<=ka.range()[0]?ka(0):ka.range()[0]:ka(g.custom.stacked?a[2]:0)}).y1(function(a){return ka(g.custom.stacked?a[1]+a[2]:a[1])}).defined(function(a){return da.utils.isRealNum(a[1])&&da.utils.isRealNum(a[2])}),E.x(function(a){return ha(a[0])}).y(function(a){return ka(g.custom.stacked?a[1]+a[2]:a[1])}).defined(function(a){return da.utils.isRealNum(a[1])&&da.utils.isRealNum(a[2])}),c.x(ha),null!=g.custom.brushExtent?c.extent(fa(g.custom.brushExtent)):void 0},V=function(){var a,b,c,d,e,f,h;if(null!==p&&null!==i)return h=ka(0),0>h&&(h=0),h>B&&(h=B),O=P.selectAll("g.td-series-container").data(k),f=O.enter().append("g").attr("class","td-series-container"),a=f.append("path").attr("class","td-series-area").style("opacity",0).on("click",Modernizr.touch?null:t).each(function(a){var b,c;return Modernizr.touch?(c=this,b=new Hammer.Manager(c),b.add(new Hammer.Tap),b.on("tap",function(){return t.call(c,a)})):void 0}),d=f.append("path").attr("class","td-series-line").style("opacity",0),g.transition.enter&&(a.attr("d",function(a){var b,c;return b=a.series.length,2>b&&(b=2),c=d3.range(b).map(function(a){return[ga/b*a,h]}),d3.svg.area().y0(h)(c)}),d.attr("d",function(a){var b,c;return b=a.series.length,2>b&&(b=2),c=d3.range(b).map(function(a){return[ga/b*a,h]}),d3.svg.line()(c)})),g.transition.exit?(O.exit().selectAll(".td-series-area").transition().duration(1e3).attr("opacity",0).attr("d",function(a){var b,c;return b=a.series.length,2>b&&(b=2),c=d3.range(b).map(function(a){return[ga/b*a,h]}),d3.svg.area().y0(h)(c)}).remove(),O.exit().selectAll(".td-series-line").transition().duration(1e3).attr("opacity",0).attr("d",function(a){var b,c;return b=a.series.length,2>b&&(b=2),c=d3.range(b).map(function(a){return[ga/b*a,h]}),d3.svg.line()(c)}).remove(),O.exit().transition().duration(1e3).remove()):O.exit().remove(),e=O.selectAll(".td-series-point").data(function(a){return a.series}),e.enter().append("circle").attr("class","td-series-point").style("opacity",0),e.exit().remove(),c=O.selectAll(".td-series-label").data(function(a){return a.series}),c.enter().append("text").attr("class","td-series-label").style("opacity",0),c.exit().remove(),C=D.selectAll("div.td-legend-item").data(j),b=C.enter().append("div").attr("class","td-legend-item"),b.append("i").attr("class","td-legend-item-icon"),b.append("div").attr("class","td-legend-item-text"),C.exit().remove()},ea=function(){return null!==p&&null!==i?(h.attr("transform","translate("+da.utils.svgNum(g.padding.left)+","+da.utils.svgNum(g.padding.top)+")"),g.axes.x.visible&&ja.attr("transform",function(){switch(g.axes.x.position){case"right":return"translate("+ga+",0)";case"bottom":return"translate(0,"+B+")";default:return null}}()).transition().duration(1e3).call(ia).select(".domain").attr("transform",function(){switch(g.axes.x.position){case"top":case"bottom":return"translate(0,"+(da.utils.realNum(ka(0))-B)+")";case"left":case"right":return"translate("+da.utils.realNum(ka(0))+",0)"}}()),g.axes.y.visible&&ma.attr("transform",function(){switch(g.axes.y.position){case"right":return"translate("+ga+",0)";case"bottom":return"translate(0,"+B+")";default:return null}}()).transition().duration(1e3).call(la),g.custom.showLines?(g.custom.transition&&O.selectAll("path.td-series-line").attr("d",function(){var a;return a=ka(0),0>a&&(a=0),a>B&&(a=B),d3.svg.line()([[0,a],[ga,a]])}()),O.selectAll("path.td-series-line").classed("td-hidden",!1).style("opacity",1).style("stroke-width",g.custom.strokeWidth).style("fill","none").style("stroke",function(){return f("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,j,g.scales.color.range):d3.select(this.parentNode).datum().color)}).transition().duration(1e3).attr("d",function(a,b){return E.interpolate(_.isArray(g.custom.interpolate)?null!=g.custom.interpolate[b]?g.custom.interpolate[b]:null:g.custom.interpolate)(d3.select(this.parentNode).datum().series)}).each("end",function(){var a,b,c,d,e,f,h,i,j,k,l,m;if(null!=(e=g.custom.forecastX)){for(e=ha("time"===g.scales.x.type?new Date(1e3*e):e)+g.padding.left,h=this,i=h.getTotalLength(),l=e,d=i,m=void 0;;){if(m=Math.floor((l+d)/2),j=h.getPointAtLength(m),(m===d||m===l)&&j.x!==e)break;if(j.x>e)d=m;else{if(!(j.x<e))break;l=m}}if(m>0&&i>m){for(a=i-m,c=Math.ceil(a/g.custom.dashLength),b="",f=0,k=c;k>=0?k>=f:f>=k;k>=0?f++:f--)b=b.concat(g.custom.dashLength+" ");return d3.select(this).attr("stroke-dasharray",m+" "+b)}}})):O.selectAll("path.td-series-line").classed("td-hidden",!0),g.custom.showAreas?(g.custom.transition&&O.selectAll("path.td-series-area").attr("d",function(){var a;return a=ka(0),0>a&&(a=0),a>B&&(a=B),d3.svg.area().y0(a)([[0,a],[ga,a]])}()),O.selectAll("path.td-series-area").classed("td-hidden",!1).transition().duration(1e3).style("opacity",1).attr("d",function(a,c){return b.interpolate(_.isArray(g.custom.interpolate)?null!=g.custom.interpolate[c]?g.custom.interpolate[c]:null:g.custom.interpolate)(d3.select(this.parentNode).datum().series)}).style("fill",function(){return f("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,j,g.scales.color.range):d3.select(this.parentNode).datum().color)})):O.selectAll("path.td-series-area").classed("td-hidden",!0),g.custom.showPoints?h.selectAll("circle.td-series-point").classed("td-hidden",!1).transition().duration(1e3).style("opacity",1).attr("cx",function(a){return a[5]=da.utils.realNum(ha(a[0]))}).attr("cy",function(a){return g.custom.stacked?a[6]=da.utils.realNum(ka(a[1]+a[2])):a[6]=da.utils.realNum(ka(a[1]))}).attr("r",function(a){return da.utils.isRealNum(a[1])&&da.utils.isRealNum(a[2])?g.custom.pointRadius:null}).style("stroke",function(){return f("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,j,g.scales.color.range):d3.select(this.parentNode).datum().color)}).style("fill",function(){return f("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,j,g.scales.color.range):d3.select(this.parentNode).datum().color)}).each("end",function(a,b){return b===h.selectAll("circle.td-series-point")[0].length-1?(L=!0,m.ready()):void 0}):h.selectAll("circle.td-series-point").classed("td-hidden",!0),g.custom.showLabels?h.selectAll("text.td-series-label").classed("td-hidden",!1).style("text-anchor","middle").html(function(a){return da.utils.isRealNum(a[1])&&da.utils.isRealNum(a[2])?da.utils.template(g.custom.labelFormat,{y:a[1]},g.custom.localeId):null}).transition().duration(1e3).style("opacity",1).attr("x",function(a){return a[5]=da.utils.realNum(ha(a[0]))}).attr("y",function(a){return g.custom.stacked?a[6]=da.utils.realNum(ka(a[1]+a[2])):a[6]=da.utils.realNum(ka(a[1]))}).style("fill",function(){return f("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,j,g.scales.color.range):d3.select(this.parentNode).datum().color)}):h.selectAll("text.td-series-label").classed("td-hidden",!0),g.legends.color.visible&&(D.selectAll("i.td-legend-item-icon").attr("class","td-legend-item-icon fa fa-square").style("color",function(){return f("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum(),j,g.scales.color.range):d3.select(this.parentNode).datum())}),da.utils.relayoutLegend(g.legends.color,D,C,p)),T.classed("td-hidden",!0),g.custom.showBrush?d.classed("td-hidden",!1).transition().duration(1e3).call(c).style("pointer-events",g.custom.eventBrush?"all":"none").selectAll("rect").attr("height",B).style("opacity",.4):d.classed("td-hidden",!0)):void 0},q=function(a){var b;return null!=a.series?(b=_.cloneDeep(a),b.$x=a.series[0][0],b.$y=null,b.$color=a.color,b.$colorString=f("linear"===g.scales.color.type?da.utils.moreColor(a.color,j,g.scales.color.range):a.color)):(b=_.cloneDeep(a[4]),b.$x=a[0],b.$y=a[1],b.$color=a[3],b.$colorString=f("linear"===g.scales.color.type?da.utils.moreColor(a[3],j,g.scales.color.range):a[3])),b},o=function(a,b){var c;if(c=null!=a?q(a):null,null!=d3.event&&(b=d3.event.type),null!=b)switch(b){case"click":return m.click(c);case"mouseover":case"mousemove":return m.over(c);case"mouseleave":return m.over(null)}},n=function(a){switch(d3.event.type){case"brush":return m.brush(a)}},z=function(a){return d3.select(this).classed("td-over",!0),d3.select(this.parentNode).classed("td-over",!0),null!=K.parentNode&&d3.select(K.parentNode.parentNode).classed("td-over",!0),g.tooltip.visible&&T.classed("td-hidden",!1).html(function(){return da.utils.template(g.tooltip.textFormat,q(a),g.custom.localeId)}),g.custom.showMarker&&G.classed("td-hidden",!1).attr("r",g.custom.pointRadius).attr("cx",da.utils.realNum(ha(a[0]))).attr("cy",g.custom.stacked?da.utils.realNum(ka(a[1]+a[2])):da.utils.realNum(ka(a[1]))),null!=d3.event?o(a):o(a,"mousemove")},x=function(a){return d3.select(this).classed("td-over",!1),d3.select(this.parentNode).classed("td-over",!1),null!=K.parentNode&&d3.select(K.parentNode.parentNode).classed("td-over",!1),g.tooltip.visible&&T.classed("td-hidden",!0),g.custom.showMarker&&G.classed("td-hidden",!0),null!=d3.event?o(a):o(a,"mouseleave")},t=function(a){return g.custom.selectable?(O.classed("td-selected",!1),_.isEqual(a,N)?(N=null,null!=d3.event?o(null):o(null,"click")):(d3.select(this.parentNode).classed("td-selected",!0),N=d3.select(this.parentNode).datum(),null!=d3.event?o(d3.select(this.parentNode).datum()):o(d3.select(this.parentNode).datum(),"click"))):void 0},s=function(){return g.custom.showBrush?n(c.empty()?null:c.extent()):void 0},v=function(){return L?(H.classed("td-hidden",!1),I.classed("td-hidden",!1)):void 0},w=function(){return L?(x.call(K,d3.select(K).datum()),K=null,H.classed("td-hidden",!0),I.classed("td-hidden",!0)):void 0},A=function(a){var b,c,d,e;if(L)return null!=K&&(d3.select(K).classed("td-over",!1),d3.select(K.parentNode).classed("td-over",!1),null!=K.parentNode&&d3.select(K.parentNode.parentNode).classed("td-over",!1)),a.x-=g.padding.left,a.y-=g.padding.top,d=1/0,e=1/0,K=b=null,h.selectAll(".td-series-point").each(function(c){var f,g;return null!=c[1]&&(f=Math.abs(c[5]-a.x),g=Math.abs(c[6]-a.y),d>f||d>=f&&e>g)?(d=f,e=g,K=this,b=c):void 0}),null!=b&&(H.datum(b).attr("x1",function(a){return a[5]}).attr("x2",function(a){return a[5]}).attr("y1",0).attr("y2",B).style("stroke","lightgrey"),I.datum(b).attr("x1",0).attr("x2",ga).attr("y1",function(a){return a[6]}).attr("y2",function(a){return a[6]}).style("stroke","lightgrey")),c=$(T.node()).width(),U.style("top","auto").style("left",function(){var a,d;return d=g.padding.left+b[5],0>d-c/2?c/2+"px":d+c/2>(a=g.padding.left+ga)?a-c/2+"px":d+"px"}).style("bottom",g.padding.bottom+B-(b[6]<=a.y||!Modernizr.touch?b[6]:a.y)+"px"),z.call(K,b)},y=function(){return A({x:d3.mouse(this)[0],y:d3.mouse(this)[1]})},u=function(a){return A(a.getCGPoint())},ca=function(a){return g.custom.selectable&&null!==p&&null!==i?(O.classed("td-selected",!1),null===a?N=null:O.each(function(b){return null!=b.id&&b.id.toString()===a||null!=b[r.color]&&b[r.color].toString()===a?(d3.select(this.parentNode).classed("td-selected",!0),N=d3.select(this.parentNode).datum()):void 0})):void 0},d3.interpolators.push(function(a,b){var c,d,e,f,g,h,i,j,k,l,m;return i=function(a,b){return d3.range(b).map(function(){return a})},h=function(a){return a.substr(1,a.length-(k?2:1)).split("L")},m=function(a){return"M"+a.join("L")+(k?"Z":"")},g=function(a,b){var c;return c=b.length-a.length,k?i(a[0],c/2).concat(a,i(a[a.length-1],c/2)):i(a[0],c).concat(a)},l=/M-?\d*\.?\d*,-?\d*\.?\d*(L-?\d*\.?\d*,-?\d*\.?\d*)*Z?/,l.test(a)&&l.test(b)?(k="Z"===a[a.length-1],c=h(a),e=h(b),d=c.length,f=e.length,d>f&&(e=g(e,c)),f>d&&(c=g(c,e)),j=d3.interpolateString(f>d?m(c):a,d>f?m(e):b),f>d?j:function(a){return 1===a?b:j(a)}):void 0}),fa=function(a){return null!=g.scales.x.format&&(a=a.map(function(a){switch(g.scales.x.format){case"date":return new Date(a);case"timestamp":return new Date(1e3*a);default:return S.parse(String(a))}})),"time"===g.scales.x.type&&(a=a.map(function(a){return new Date(a)})),a},Z=function(a){return null===a?M():ha.domain(fa(a))},W=function(){return null===g.custom.brushExtent?c.clear():c.extent(fa(g.custom.brushExtent))},e}}.call(this),function(){da.map=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,aa,ba;return r=d3.select(a),o={padding:{top:0,right:0,bottom:0,left:0},scales:{symbolRadius:{field:"d.radius",type:"linear",domain:["min","max"],range:[5,10]},symbolColor:{field:"d.color",type:"linear",domain:["min","max"],range:["#444","#ccc"]},shapeColor:{field:"d.color",type:"linear",domain:["min","max"],range:["#444","#ccc"]}},tooltip:{textFormat:"{N($color)}",visible:!1},custom:{projection:{type:"mercator",center:[-1,48],rotate:[347,0],scale:3e3},source:null,selectable:!0,responsive:!1,localeId:null,strokeWidth:1,bboxExtent:[1,1],selectByColor:!0,useQuadtree:!1}},t=n=K=k=l=m=null,j={features:null,symbols:null},H=[],D=null,i=null,J=b=d=null,O=N=I=null,F=d3.geo.mercator(),E=d3.geo.path(),M=null,p=d3.dispatch("click","select","over","bind","ready"),G=!1,aa={scale:1,translate:[0,0]},e=_.cloneDeep(o),Z=C=null,(U=function(){var b,c;return c=$(a).width(),b=$(a).height(),Z=c-da.utils.svgNum(e.padding.right)-da.utils.svgNum(e.padding.left),C=b-da.utils.svgNum(e.padding.top)-da.utils.svgNum(e.padding.bottom)})(),L=r.append("svg").attr("width","100%").attr("height","100%"),Modernizr.touch?M=cross_js.gestures.addEventListener(L.node(),"drag",function(a){switch(a.phase){case"start":case"change":return v(a);case"end":return w()}}):null!=M&&cross_js.gestures.removeEventListener(M),L.on("mousemove",Modernizr.touch||!e.custom.useQuadtree?null:function(){return y.call(this)}).on("mouseleave",Modernizr.touch||!e.custom.useQuadtree?null:function(){return w.call(this)}),f=L.append("g").attr("class","td-chart-container"),ba=f.append("g").attr("class","td-zoom-container"),h=ba.append("g").attr("class","td-countries-border"),g=ba.append("g").attr("class","td-countries"),Q=r.append("div").attr("class","td-tooltip-container").style("position","absolute"),P=Q.append("div").attr("class","td-tooltip td-hidden"),(R=function(a){return O=function(){switch(e.scales.symbolRadius.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold();case"quantize":return d3.scale.quantize();case"sqrt":return d3.scale.sqrt()}}(),N=function(){switch(e.scales.symbolColor.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold();case"quantize":return d3.scale.quantize()}}(),I=function(){switch(e.scales.shapeColor.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold();case"quantize":return d3.scale.quantize()}}(),F=function(){switch(e.custom.projection.type){case"mercator":return d3.geo.mercator();case"equirectangular":return d3.geo.equirectangular();case"orthographic":return d3.geo.orthographic();case"stereographic":return d3.geo.stereographic()}}(),null!==e.custom.source&&e.custom.source!==i?(i=e.custom.source,d3.json(e.custom.source,function(c,d){return null==c?(n=topojson.feature(d,d.objects.items).features,k=null!=d.objects.borders?topojson.feature(d,d.objects.borders).features:[],K=_.map(n,function(a){return{label:a.properties.label,id:a.id
}}),b=h.selectAll("path.td-border").data(k),b.enter().append("path").attr("class","td-border").style("opacity",0),b.exit().remove(),J=g.selectAll("path.td-shape").data(n),J.enter().append("path").attr("class","td-shape").style("opacity",0).on("click",Modernizr.touch?null:u).each(function(){var a,b;return Modernizr.touch?(b=this,a=new Hammer.Manager(b),a.add(new Hammer.Tap),a.on("tap",function(){return u.call(b,d3.select(b).datum())})):void 0}).on("mouseover",Modernizr.touch||e.custom.useQuadtree?null:B).on("mouseleave",Modernizr.touch||e.custom.useQuadtree?null:w),J.exit().remove(),_.isFunction(a)?a():void 0):void 0})):_.isFunction(a)?a():void 0})(null),c=function(){return c},c.data=function(a){return 0===arguments.length?j:(j=_.merge(j,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),S(),T(),X(),c)},c.options=function(a){return 0===arguments.length?_.cloneDeep(e):(e=_.merge(e,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),R(V),c)},c.resize=function(){return U(),T(),X(),c},c.destroy=function(){return r.selectAll("*").remove(),c},c.on=function(a,b){return p.on(a,b),c},c.select=function(a){return W(a),c},c.zoom=function(a,b,d){return 0===arguments.length?_.cloneDeep(aa):(Y(a,b,d),X(),c)},S=function(){return null!==j&&null!==J?(null===j.features&&(j.features=[]),null===j.symbols&&(j.symbols=[]),t={},t.shapeColor=e.scales.shapeColor.field.slice(2),t.symbolRadius=e.scales.symbolRadius.field.slice(2),t.symbolColor=e.scales.symbolColor.field.slice(2),l=function(){var a,b,c,d,e;for(a=[],d=j.features,b=0,c=d.length;c>b;b++)e=d[b],a.push(e[t.shapeColor]);return _.sortBy(_.uniq(a))}(),J.each(function(a){var b,c,d,e,f;for(delete a[t.shapeColor],e=j.features,f=[],c=0,d=e.length;d>c;c++){if(b=e[c],a.id===b.id){_.merge(a,b,{});break}f.push(void 0)}return f}),m=function(){var a,b,c,d,e;for(a=[],d=j.symbols,b=0,c=d.length;c>b;b++)e=d[b],a.push(e[t.symbolColor]);return _.sortBy(_.uniq(a))}(),d=ba.selectAll("circle.td-dot").data(j.symbols),d.enter().append("circle").attr("class","td-dot").style("opacity",0).on("click",Modernizr.touch?null:u).each(function(){var a,b;return Modernizr.touch?(b=this,a=new Hammer.Manager(b),a.add(new Hammer.Tap),a.on("tap",function(){return u.call(b,d3.select(b).datum())})):void 0}),d.exit().remove(),O.domain(function(){var a,b,c,d,f;for(a=[],d=e.scales.symbolRadius.domain,b=0,c=d.length;c>b;b++)f=d[b],a.push(function(){switch(f){case"min":return d3.min(j.symbols,function(a){return a[t.symbolRadius]});case"max":return d3.max(j.symbols,function(a){return a[t.symbolRadius]});case null:break;default:return f}}());return a}()),N.domain(function(){var a,b,c,d,f,g,h,i;if("linear"===e.scales.symbolColor.type)return d3.range(e.scales.symbolColor.range.length);switch(e.scales.symbolColor.domain){case null:for(a=[],g=j.symbols,b=0,c=g.length;c>b;b++)i=g[b],null!=i[t.symbolColor]&&a.push(i[t.symbolColor]);a=_.uniq(a);break;default:for(a=[],h=e.scales.symbolColor.domain,f=0,d=h.length;d>f;f++)i=h[f],a.push(function(){switch(i){case"min":return d3.min(j.symbols,function(a){return a[t.symbolColor]});case"max":return d3.max(j.symbols,function(a){return a[t.symbolColor]});default:return i}}())}return a}()),I.domain(function(){var a,b,c,d,f,g,h,i;if("linear"===e.scales.shapeColor.type)return d3.range(e.scales.shapeColor.range.length);switch(e.scales.shapeColor.domain){case null:for(a=[],g=j.features,b=0,c=g.length;c>b;b++)i=g[b],null!=i[t.shapeColor]&&a.push(i[t.shapeColor]);a=_.uniq(a);break;default:for(a=[],h=e.scales.shapeColor.domain,f=0,d=h.length;d>f;f++)i=h[f],a.push(function(){switch(i){case"min":return d3.min(j.features,function(a){return a[t.shapeColor]});case"max":return d3.max(j.features,function(a){return a[t.shapeColor]});default:return i}}())}return a}()),p.bind()):void 0},T=function(){var a,b,c,d;if(null!==j&&null!==J)return O.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.symbolRadius.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),N.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.symbolColor.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),I.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.shapeColor.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),F.center(e.custom.projection.center).rotate(e.custom.projection.rotate).translate([Z/2,C/2]),E.projection(F),e.custom.responsive?(F.scale(1),a=[[],[]],J.data().map(function(b){var c;return c=E.bounds(b),a[0].push(c[0][0],c[1][0]),a[1].push(c[0][1],c[1][1])}),b=[d3.extent(a[0]),d3.extent(a[1])],c=1,d=c/Math.max(e.custom.bboxExtent[0]*(b[0][1]-b[0][0])/Z,e.custom.bboxExtent[1]*(b[1][1]-b[1][0])/C),F.scale(d)):F.scale(e.custom.projection.scale)},X=function(){return null!==r&&null!==j&&null!==J?(f.attr("transform","translate("+da.utils.svgNum(e.padding.left)+","+da.utils.svgNum(e.padding.top)+")"),ba.transition().duration(1e3).attr("transform","translate( "+aa.translate+" )scale( "+aa.scale+" )"),J.attr("d",function(a){return E(a)}).classed("td-no-data",function(a){return!da.utils.isRealNum(a[t.shapeColor])}).transition().duration(1e3).style("opacity",1).style("stroke-width",e.custom.strokeWidth/aa.scale).attr("fill",function(a){return da.utils.isRealNum(a[t.shapeColor])?I("linear"===e.scales.shapeColor.type?da.utils.moreColor(a[t.shapeColor],l,e.scales.shapeColor.range):a[t.shapeColor]):void 0}).each(function(a){return a.centroid=E.centroid(a)}).each("end",function(a,b){return b===J[0].length-1?(G=!0,p.ready()):void 0}),b.attr("d",function(a){return E(a)}).transition().duration(1e3).style("opacity",1).style("stroke-width",e.custom.strokeWidth/aa.scale),d.transition().duration(1e3).style("opacity",1).attr("cx",function(a){return null!=a.id&&null==a.lon&&null==a.lat?da.utils.realNum(F(d3.geo.centroid(_.find(n,function(b){return b.id===a.id})))[0]):da.utils.realNum(F([a.lon,a.lat])[0])}).attr("cy",function(a){return null!=a.id&&null==a.lon&&null==a.lat?da.utils.realNum(F(d3.geo.centroid(_.find(n,function(b){return b.id===a.id})))[1]):da.utils.realNum(F([a.lon,a.lat])[1])}).attr("r",function(a){return null!=a.id&&null!=_.find(n,function(b){return b.id===a.id})&&null!=a[t.symbolRadius]&&da.utils.isSvgNum(O(a[t.symbolRadius]))?a._r=O(a[t.symbolRadius])/aa.scale:da.utils.isRealNum(a.lon)&&da.utils.isRealNum(a.lat)&&null!=a[t.symbolRadius]&&da.utils.isSvgNum(O(a[t.symbolRadius]))?a._r=O(a[t.symbolRadius])/aa.scale:a._r=0}).attr("fill",function(a){return N("linear"===e.scales.symbolColor.type?da.utils.moreColor(a[t.symbolColor],m,e.scales.symbolColor.range):a[t.symbolColor])}),P.classed("td-hidden",!0)):void 0},s=function(a){var b,c,d,e;c=_.cloneDeep(a),c.$id=a.id,c.$color=a[t.shapeColor],d=a.properties;for(b in d)e=d[b],c["$"+b]=e;return c},q=function(a,b){var c;if(c=null!=a?s(a):null,null!=d3.event&&(b=d3.event.type),null!=b)switch(b){case"click":return p.click(c);case"mouseover":case"mousemove":return p.over(c);case"mouseleave":return p.over(null)}},u=function(a){return null!=a[t.shapeColor]&&e.custom.selectable?(d.classed("td-selected",!1),J.classed("td-selected",!1),_.isEqual(a,H)?(H=null,null!=d3.event?q(null):q(null,"click")):(d3.select(this).classed("td-selected",!0),H=a,null!=d3.event?q(a):q(a,"click"))):void 0},z=function(a){return d3.select(this).classed("td-over",!0),d3.select(this.parentNode).classed("td-over",!0),null!=D.parentNode&&d3.select(this.parentNode.parentNode).classed("td-over",!0),e.tooltip.visible&&(null!=a[t.shapeColor]?P.classed("td-hidden",!1).html(function(){return da.utils.template(e.tooltip.textFormat,s(a),e.custom.localeId)}):P.classed("td-hidden",!0)),null!=d3.event?q(a):q(a,"mousemove")},x=function(a){return d3.select(this).classed("td-over",!1),d3.select(this.parentNode).classed("td-over",!1),null!=D.parentNode&&d3.select(this.parentNode.parentNode).classed("td-over",!1),e.tooltip.visible&&P.classed("td-hidden",!0),null!=d3.event?q(a):q(a,"mouseleave")},w=function(){return G?(x.call(D,d3.select(D).datum()),D=null):void 0},A=function(a){var b,c;if(G)return null!=D&&(d3.select(D).classed("td-over",!1),d3.select(D.parentNode).classed("td-over",!1),null!=D.parentNode&&d3.select(D.parentNode.parentNode).classed("td-over",!1)),a.x-=e.padding.left,a.y-=e.padding.top,b=1/0,D=c=null,J.each(function(d){var e,f,g;return e=Math.abs(d.centroid[0]-a.x),f=Math.abs(d.centroid[1]-a.y),g=Math.sqrt(e*e+f*f),b>g?(b=g,D=this,c=d):void 0}),B.call(D,c,a)},B=function(a,b){var c;return D=this,a=a,c=$(P.node()).width(),Q.style("top","auto").style("left",function(){var b,d;return d=e.padding.left+(a.centroid[0]*aa.scale+aa.translate[0]),0>d-c/2?c/2+"px":d+c/2>(b=e.padding.left+Z)?b-c/2+"px":d+"px"}).style("bottom",e.padding.bottom+C-(e.custom.useQuadtree?a.centroid[1]<=b.y||!Modernizr.touch?a.centroid[1]:b.y:a.centroid[1])*aa.scale-aa.translate[1]+"px"),z.call(D,a)},y=function(){return A({x:(d3.mouse(this)[0]-aa.translate[0])/aa.scale,y:(d3.mouse(this)[1]-aa.translate[1])/aa.scale})},v=function(a){var b;return b=a.getCGPoint(),A({x:(b.x-aa.translate[0])/aa.scale,y:(b.y-aa.translate[1])/aa.scale})},W=function(a){return null==J&&null==d||!e.custom.selectable?void 0:(_.isNumber(a)&&(a=String(a)),d.classed("td-selected",!1),J.classed("td-selected",!1),null===a?H=null:(null!=d&&d.each(function(b){return null!=b.id&&b.id.toString()===a||e.custom.selectByColor&&null!=b[t.symbolColor]&&b[t.symbolColor].toString()===a?(d3.select(this).classed("td-selected",!0),H=b):void 0}),null!=J?J.each(function(b){return null!=b.id&&b.id.toString()===a||e.custom.selectByColor&&null!=b[t.symbolColor]&&b[t.symbolColor].toString()===a?(d3.select(this).classed("td-selected",!0),H=b):void 0}):void 0))},Y=function(a,c,d){var e,f,g,h,i,j;if(c&&null!=b||null!=J){if(b.classed("zoomed",!1),J.classed("zoomed",!1),null!=a){if(_.isNumber(a)&&(a=String(a)),d=null!=d?d:.9,j=(c?b:J).filter(function(b){return null!=b.id&&b.id.toString()===a}),j.empty())return;return j.classed("zoomed",!0),e=E.bounds(j.datum()),f=e[1][0]-e[0][0],g=e[1][1]-e[0][1],h=(e[0][0]+e[1][0])/2,i=(e[0][1]+e[1][1])/2,aa.scale=d/Math.max(f/Z,g/C),aa.translate=[Z/2-aa.scale*h,C/2-aa.scale*i]}return aa.translate=[0,0],aa.scale=1}},V=function(){return U(),S(),T(),X()},c}}.call(this),function(){da.pie=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U;return p=d3.select(a),m={padding:{top:0,right:0,bottom:0,left:0},scales:{angle:{field:"d.angle",type:"linear",domain:["min","max"],range:[0,1]},r:{field:"d.r",type:"linear",domain:[0,"max"],range:["innerRadius","outerRadius"]},color:{field:"d.color",type:"linear",domain:"all",range:["#444","#ccc"]}},legends:{color:{title:null,labelFormat:null,labels:null,position:"bottom",visible:!0}},tooltip:{textFormat:"{N($angle)}",visible:!0},transition:{enter:!1,update:!0,exit:!1},custom:{polar:!1,innerRadius:0,outerRadius:null,startAngle:0,endAngle:360,sortByValue:!1,selectable:!0,localeId:null}},r=j=k=l=null,G=null,D=null,e=A=null,L=null,b=null,E=null,g=null,B=d3.layout.pie(),c=d3.svg.arc().startAngle(function(a){return isNaN(a.startAngle)?0:a.startAngle}).endAngle(function(a){return isNaN(a.endAngle)?0:a.endAngle}),I=null,n=d3.dispatch("click","select","over","bind","ready"),F=!1,h=_.cloneDeep(m),(N=function(){return b=function(){switch(h.scales.angle.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),E=function(){switch(h.scales.r.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal();case"sqrt":return d3.scale.sqrt()}}(),g=function(){switch(h.scales.color.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}(),null!=h.custom.tooltipFormat?L=d3.format(h.custom.tooltipFormat):void 0})(),U=z=null,(R=function(){var b,c;return c=$(a).width(),b=$(a).height(),U=c-da.utils.svgNum(h.padding.right)-da.utils.svgNum(h.padding.left),z=b-da.utils.svgNum(h.padding.top)-da.utils.svgNum(h.padding.bottom)})(),H=p.append("svg").attr("width","100%").attr("height","100%"),Modernizr.touch?I=cross_js.gestures.addEventListener(H.node(),"drag",function(a){switch(a.phase){case"start":case"change":return t(a);case"end":return u()}}):null!=I&&cross_js.gestures.removeEventListener(I),H.on("mousemove",Modernizr.touch?null:function(){return w.call(this)}).on("mouseleave",Modernizr.touch?null:function(){return u.call(this)}),i=H.append("g").attr("class","td-chart-container"),C=p.append("div").attr("class","td-legend-container").style("position","absolute"),C.append("div").attr("class","td-legend-title"),K=p.append("div").attr("class","td-tooltip-container").style("position","absolute"),J=K.append("div").attr("class","td-tooltip td-hidden"),f=function(){return f},f.data=function(a){return 0===arguments.length?j:(j=a,O(),P(),M(),T(),f)},f.options=function(a){return 0===arguments.length?h:(h=_.merge(h,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),N(),R(),O(),P(),T(),f)},f.resize=function(){return R(),P(),T(),f},f.destroy=function(){return p.selectAll("*").remove(),f},f.on=function(a,b){return n.on(a,b),f},f.select=function(a){return 0===arguments.length?_.forEach(_.cloneDeep(G),function(a){return q(a)}):(S(a),T(),f)},f.over=function(a){return Q(a),f},O=function(){return null!==j?(r={},r.angle=h.scales.angle.field.slice(2),r.r=h.scales.r.field.slice(2),r.color=h.scales.color.field.slice(2),B.value(function(a){return da.utils.realPosNum(a[r.angle])}).startAngle(h.custom.startAngle/180*Math.PI).endAngle(h.custom.endAngle/180*Math.PI),h.custom.sortByValue||B.sort(function(a){return a}),k=B(j),l=function(){var a,b,c,d;for(a=[],b=0,c=j.length;c>b;b++)d=j[b],a.push(d[r.color]);return _.uniq(a)}(),b.domain(function(){var a,b,c,d,e;for(a=[],d=h.scales.angle.domain,b=0,c=d.length;c>b;b++)e=d[b],a.push(function(){switch(e){case"min":return d3.min(j,function(a){return a[r.angle]});case"max":return d3.max(j,function(a){return a[r.angle]});case null:break;default:return e}}());return a}()),E.domain(function(){var a,b,c,d,e;for(a=[],d=h.scales.r.domain,b=0,c=d.length;c>b;b++)e=d[b],a.push(function(){switch(e){case"min":return d3.min(j,function(a){return a[r.r]});case"max":return d3.max(j,function(a){return a[r.r]});case null:break;default:return e}}());return a}()),g.domain(function(){var a,b,c,d,e;if("linear"===h.scales.color.type)return a=d3.range(h.scales.color.range.length);if(a=[],_.isArray(h.scales.color.domain))for(d=h.scales.color.domain,b=0,c=d.length;c>b;b++)e=d[b],a.push(function(){switch(e){case"min":return d3.min(j,function(a){return a[r.color]});case"max":return d3.max(j,function(a){return a[r.color]});case null:break;default:return e}}());else switch(h.scales.color.domain){case"all":j.forEach(function(b){return null!=b[r.color]?a.push(b[r.color]):void 0}),a=_.uniq(a)}return a}()),n.bind()):void 0},P=function(){var a;if(null!==p&&null!==j)return b.range(function(){var a,b,c,d,e;for(c=[],d=h.scales.angle.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return U;case"height":return z;case null:break;default:return e}}());return c}()),E.range(function(){var a,b,c,d,e;for(c=[],d=h.scales.r.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){var a;switch(e){case"innerRadius":return 0<(a=h.custom.innerRadius)&&1>a?d3.min([U,z])/2*h.custom.innerRadius:h.custom.innerRadius;case"outerRadius":return null===h.custom.outerRadius?d3.min([U,z])/2:h.custom.outerRadius;case null:break;default:return e}}());return c}()),g.range(h.scales.color.range),c.innerRadius(0<(a=h.custom.innerRadius)&&1>a?d3.min([U,z])/2*h.custom.innerRadius:h.custom.innerRadius),c.outerRadius(function(a){return h.custom.polar?da.utils.svgNum(E(a.data[r.r])):null===h.custom.outerRadius?d3.min([U,z])/2:h.custom.outerRadius})},M=function(){var a,b;if(null!==p&&null!==j)return e=i.selectAll("path.td-arc").data(k),a=e.enter().append("path").attr("class","td-arc").style("opacity",0).each(function(a){return this._current=a}).on("click",Modernizr.touch?null:s).each(function(a){var b,c;return Modernizr.touch?(c=this,b=new Hammer.Manager(c),b.add(new Hammer.Tap),b.on("tap",function(){return s.call(c,a)})):void 0}),h.transition.enter&&a.style("fill",function(a,b){return g("linear"===h.scales.color.type?da.utils.moreColor(a.data[r.color],l,h.scales.color.range):a.data[r.color])}),h.transition.exit?e.exit().datum(function(a){var b;return b=(a.startAngle+a.endAngle)/2,a.startAngle=b,a.endAngle=b,a}).transition().duration(1e3).style("opacity",0).attrTween("d",d).remove():e.exit().remove(),A=C.selectAll("div.td-legend-item").data(l),b=A.enter().append("div").attr("class","td-legend-item"),b.append("i").attr("class","td-legend-item-icon"),b.append("div").attr("class","td-legend-item-text"),A.exit().remove()},T=function(){return null!==p&&null!==j?(i.attr("transform","translate("+(U/2+da.utils.svgNum(h.padding.left))+","+(z/2+da.utils.svgNum(h.padding.top))+")"),e.transition().duration(1e3).style("opacity",1).style("fill",function(a,b){return g("linear"===h.scales.color.type?da.utils.moreColor(a.data[r.color],l,h.scales.color.range):a.data[r.color])}).attrTween("d",d).each(function(a){return a.centroid=c.centroid(a)}).each("end",function(a,b){return b===e[0].length-1?(F=!0,n.ready()):void 0}),h.legends.color.visible&&(C.selectAll("i.td-legend-item-icon").attr("class","td-legend-item-icon fa fa-square").style("color",function(){return g("linear"===h.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum(),l,h.scales.color.range):d3.select(this.parentNode).datum())}),da.utils.relayoutLegend(h.legends.color,C,A,p)),J.classed("td-hidden",!0)):void 0},q=function(a){var b;return b=_.cloneDeep(a.data),b.$angle=a.data[r.angle],b.$r=a.data[r.r],b.$color=a.data[r.color],b},o=function(a,b){var c;if(c=null!=a?q(a):null,null!=d3.event&&(b=d3.event.type),null!=b)switch(b){case"click":return n.click(c);case"mouseover":case"mousemove":return n.over(c);case"mouseleave":return n.over(null)}},x=function(a){return d3.select(this).classed("td-over",!0),d3.select(D.parentNode).classed("td-over",!0),h.tooltip.visible&&J.classed("td-hidden",!1).html(function(){return da.utils.template(h.tooltip.textFormat,q(a),h.custom.localeId)}),null!=d3.event?o(a):o(a,"mousemove")},v=function(a){return d3.select(this).classed("td-over",!1),d3.select(D.parentNode).classed("td-over",!1),h.tooltip.visible&&J.classed("td-hidden",!0),null!=d3.event?o(a):o(a,"mouseleave")},s=function(a){return h.custom.selectable?(e.classed("td-selected",!1),_.isEqual(a,G)?(G=null,null!=d3.event?o(null):o(null,"click")):(d3.select(this).classed("td-selected",!0),G=a,null!=d3.event?o(a):o(a,"click"))):void 0},u=function(){return F?(null!=D&&v.call(D,d3.select(D).datum()),D=null):void 0},y=function(a){var b,c,d;if(F)return null!=D&&(d3.select(D).classed("td-over",!1),d3.select(D.parentNode).classed("td-over",!1)),a.x-=U/2+h.padding.left,a.y-=z/2+h.padding.top,b=1/0,D=c=null,e.each(function(d){var e,f,g,h;return e=Math.abs(d.centroid[0]-a.x),f=Math.abs(d.centroid[1]-a.y),g=Math.sqrt(e*e+f*f),b>g?(b=g,h=e,D=this,c=d):void 0}),d=$(J.node()).width(),K.style("top","auto").style("left",function(){var a,b;return b=U/2+h.padding.left+c.centroid[0],0>b-d/2?d/2+"px":b+d/2>(a=h.padding.left+U)?a-d/2+"px":b+"px"}).style("bottom",h.padding.bottom+z/2-(c.centroid[1]<=a.y||!Modernizr.touch?c.centroid[1]:a.y)+"px"),x.call(D,c)},w=function(){return y({x:d3.mouse(this)[0],y:d3.mouse(this)[1]})},t=function(a){return y(a.getCGPoint())},S=function(a){return h.custom.selectable&&null!==p&&null!==j?(e.classed("td-selected",!1),null===a?G=null:e.each(function(b){return null!=b.data.id&&b.data.id.toString()===a||null!=b.data[r.color]&&b.data[r.color].toString()===a?(d3.select(this).classed("td-selected",!0),G=b):void 0})):void 0},Q=function(a){return null!==p&&null!==j?(u(),e.each(function(b){return null!=b.data.id&&b.data.id.toString()===a||null!=b.data[r.color]&&b.data[r.color].toString()===a?(D=this,x.call(D,d3.select(D).datum())):void 0})):void 0},d=function(a){var b;return b=d3.interpolate(this._current,a),this._current=b(0),function(a){var d;return d=a,c(b(a))}},f}}.call(this),function(){da.scatter=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T;return l=d3.select(a),i={padding:{top:0,right:0,bottom:0,left:0},scales:{x:{field:"d.x",type:"linear",domain:["min","max"],range:[0,"width"],nice:!0,format:null},y:{field:"d.y",type:"linear",domain:["min","max"],range:["height",0],nice:!0},r:{field:"d.r",type:"linear",domain:["min","max"],range:[5,10],nice:!0},color:{field:"d.color",type:"linear",domain:null,range:["#444","#ccc"]}},axes:{x:{position:"bottom",tickPadding:100,tickFormat:'{N(x,"0.[00]a")}',tickExtension:"chart",visible:!0},y:{position:"left",tickPadding:25,tickFormat:'{N(y,"0.[00]a")}',tickExtension:"chart",visible:!0}},legends:{color:{title:null,labelFormat:null,labels:null,position:"bottom",visible:!0}},tooltip:{textFormat:"{N($r)}",visible:!0},transition:{enter:!1,update:!0,exit:!1},custom:{localeId:null,selectable:!0}},n=g=h=null,B=[],y=null,c=w=null,E=null,O=R=z=d=null,P=d3.svg.axis(),S=d3.svg.axis(),D=null,j=d3.dispatch("click","select","over","bind","ready"),A=!1,e=_.cloneDeep(i),(H=function(){return O=function(){switch(e.scales.x.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"time":return d3.time.scale();case"utc":return d3.time.scale.utc()}}(),R=function(){switch(e.scales.y.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),z=function(){switch(e.scales.r.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal();case"sqrt":return d3.scale.sqrt()}}(),d=function(){switch(e.scales.color.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}(),null!=e.scales.x.format?E=d3.time.format(e.scales.x.format):void 0})(),N=v=null,(K=function(){var b,c;return c=$(a).width(),b=$(a).height(),N=c-da.utils.svgNum(e.padding.right)-da.utils.svgNum(e.padding.left),v=b-da.utils.svgNum(e.padding.top)-da.utils.svgNum(e.padding.bottom)})(),C=l.append("svg").attr("width","100%").attr("height","100%"),Modernizr.touch?D=cross_js.gestures.addEventListener(C.node(),"drag",function(a){switch(a.phase){case"start":case"change":return p(a);case"end":return q()}}):null!=D&&cross_js.gestures.removeEventListener(D),C.on("mousemove",Modernizr.touch?null:function(){return s.call(this)}).on("mouseleave",Modernizr.touch?null:function(){return q.call(this)}),f=C.append("g").attr("class","td-chart-container"),Q=f.append("g").attr("class","td-x-axis"),T=f.append("g").attr("class","td-y-axis"),x=l.append("div").attr("class","td-legend-container").style("position","absolute"),x.append("div").attr("class","td-legend-title"),G=l.append("div").attr("class","td-tooltip-container").style("position","absolute"),F=G.append("div").attr("class","td-tooltip td-hidden"),b=function(){return b},b.data=function(a){return 0===arguments.length?g:(g=a,I(),J(),M(),b)},b.options=function(a){return 0===arguments.length?e:(e=_.merge(e,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),H(),K(),I(),J(),M(),b)},b.resize=function(){return K(),J(),M(),b},b.destroy=function(){return l.selectAll("*").remove(),b},b.on=function(a,c){return j.on(a,c),b},b.select=function(a){return 0===arguments.length?B:(L(a),M(),b)},I=function(){var a,b,i;if(null!==g)return n={},n.x=e.scales.x.field.slice(2),n.y=e.scales.y.field.slice(2),n.r=e.scales.r.field.slice(2),n.color=e.scales.color.field.slice(2),null!=e.scales.x.format&&g.forEach(function(a){return a[n.x]=function(){switch(e.scales.x.format){case"date":return new Date(a[n.x]);case"timestamp":return new Date(1e3*a[n.x]);default:return E.parse(String(a[n.x]))}}()}),h=function(){var a,b,c,d;for(a=[],b=0,c=g.length;c>b;b++)d=g[b],a.push(d[n.color]);return _.uniq(a)}(),c=f.selectAll("circle.td-dot").data(g),a=c.enter().append("circle").attr("class","td-dot").style("opacity",0).on("click",Modernizr.touch?null:o).each(function(a){var b,c;return Modernizr.touch?(c=this,b=new Hammer.Manager(c),b.add(new Hammer.Tap),b.on("tap",function(){return o.call(c,a)})):void 0}),e.transition.enter&&a.attr("r",0),b=c.exit(),e.transition.exit&&(b=b.transition().duration(1e3).attr("r",0)),b.remove(),w=x.selectAll("div.td-legend-item").data(h),i=w.enter().append("div").attr("class","td-legend-item"),i.append("i").attr("class","td-legend-item-icon"),i.append("div").attr("class","td-legend-item-text"),w.exit().remove(),O.domain(function(){var a,b,c,d,f;for(a=[],d=e.scales.x.domain,b=0,c=d.length;c>b;b++)f=d[b],a.push(function(){switch(f){case"min":return d3.min(g,function(a){return a[n.x]});case"max":return d3.max(g,function(a){return a[n.x]});case null:break;default:return f}}());return a}()),R.domain(function(){var a,b,c,d,f;for(a=[],d=e.scales.y.domain,b=0,c=d.length;c>b;b++)f=d[b],a.push(function(){switch(f){case"min":return d3.min(g,function(a){return a[n.y]});case"max":return d3.max(g,function(a){return a[n.y]});case null:break;default:return f}}());return a}()),z.domain(function(){var a,b,c,d,f;for(a=[],d=e.scales.r.domain,b=0,c=d.length;c>b;b++)f=d[b],a.push(function(){switch(f){case"min":return d3.min(g,function(a){return a[n.r]});case"max":return d3.max(g,function(a){return a[n.r]});case null:break;default:return f}}());return a}()),d.domain(function(){var a,b,c,d,f,h,i;if("linear"===e.scales.color.type)return d3.range(e.scales.color.range.length);switch(e.scales.color.domain){case null:for(a=[],b=0,d=g.length;d>b;b++)i=g[b],a.push(i[n.color]);a=_.uniq(a);break;default:for(a=[],h=e.scales.color.domain,c=0,f=h.length;f>c;c++)i=h[c],a.push(function(){switch(i){case"min":return d3.min(g,function(a){return a[n.color]});case"max":return d3.max(g,function(a){return a[n.color]});default:return i}}())}return a}()),j.bind()},J=function(){return O.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.x.range,a=0,b=d.length;b>a;a++)f=d[a],c.push(function(){switch(f){case"width":return N;case"height":return v;case null:break;default:return f}}());return c}()),R.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.y.range,a=0,b=d.length;b>a;a++)f=d[a],c.push(function(){switch(f){case"width":return N;case"height":return v;case null:break;default:return f}}());return c}()),z.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.r.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),d.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.color.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),e.scales.x.nice&&!function(){var a;return a=O.range(),a[0]+=d3.max(z.range()),a[a.length-1]-=d3.max(z.range()),O.range(a)}(),e.scales.y.nice&&!function(){var a;return a=R.range(),a[0]-=d3.max(z.range()),a[a.length-1]+=d3.max(z.range()),R.range(a)}(),P.scale(O).orient(e.axes.x.position).ticks(Math.ceil(N/e.axes.x.tickPadding)>3?Math.ceil(N/e.axes.x.tickPadding):3).tickFormat(function(a){return da.utils.template(e.axes.x.tickFormat,{x:a},e.custom.localeId)}),da.utils.setAxisTicks(e.padding,N,v,e.axes.x,P),S.scale(R).orient(e.axes.y.position).ticks(Math.ceil(v/e.axes.y.tickPadding)>3?Math.ceil(v/e.axes.y.tickPadding):3).tickFormat(function(a){return da.utils.template(e.axes.y.tickFormat,{y:a},e.custom.localeId)}),da.utils.setAxisTicks(e.padding,N,v,e.axes.y,S)},M=function(){return null!==l&&null!==g?(f.attr("transform","translate("+da.utils.svgNum(e.padding.left)+","+da.utils.svgNum(e.padding.top)+")"),e.axes.x.visible&&Q.attr("transform",function(){switch(e.axes.x.position){case"right":return"translate("+N+",0)";case"bottom":return"translate(0,"+v+")";default:return null}}()).transition().duration(1e3).call(P).select(".domain").attr("transform",function(){switch(e.axes.x.position){case"top":case"bottom":return"translate(0,"+(da.utils.realNum(R(0))-v)+")";case"left":case"right":return"translate("+da.utils.realNum(R(0))+",0)"}}()),e.axes.y.visible&&T.attr("transform",function(){switch(e.axes.y.position){case"right":return"translate("+N+",0)";case"bottom":return"translate(0,"+v+")";default:return null}}()).transition().duration(1e3).call(S),(e.transition.update?c.transition().duration(1e3):(A=!0,c)).style("opacity",1).attr("cx",function(a){return a.cx=da.utils.realNum(O(a[n.x]))}).attr("cy",function(a){return a.cy=da.utils.realNum(R(a[n.y]))}).attr("r",function(a){return da.utils.isRealNum(O(a[n.x]))&&da.utils.isRealNum(R(a[n.y]))&&da.utils.isSvgNum(z(a[n.r]))?z(a[n.r]):0}).attr("fill",function(a){return d("linear"===e.scales.color.type?da.utils.moreColor(a[n.color],h,e.scales.color.range):a[n.color])}).each("end",function(a,b){return b===c[0].length-1?(A=!0,j.ready()):void 0}),e.legends.color.visible&&(x.selectAll("i.td-legend-item-icon").attr("class","td-legend-item-icon fa fa-square").style("color",function(){return d("linear"===e.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum(),h,e.scales.color.range):d3.select(this.parentNode).datum())}),da.utils.relayoutLegend(e.legends.color,x,w,l)),F.classed("td-hidden",!0)):void 0},m=function(a){var b;return b=_.cloneDeep(a),b.$x=a[n.x],b.$y=a[n.y],b.$r=a[n.r],b.$color=a[n.color],b},k=function(a,b){var c;if(c=null!=a?m(a):null,null!=d3.event&&(b=d3.event.type),null!=b)switch(b){case"click":return j.click(c);case"mouseover":case"mousemove":return j.over(c);case"mouseleave":return j.over(null)}},t=function(a){return d3.select(this).classed("td-over",!0),d3.select(y.parentNode).classed("td-over",!0),e.tooltip.visible&&F.classed("td-hidden",!1).html(function(){return da.utils.template(e.tooltip.textFormat,m(a),e.custom.localeId)}),null!=d3.event?k(a):k(a,"mousemove")},r=function(a){return d3.select(this).classed("td-over",!1),d3.select(y.parentNode).classed("td-over",!1),e.tooltip.visible&&F.classed("td-hidden",!0),null!=d3.event?k(a):k(a,"mouseleave")},o=function(a){return e.custom.selectable?(c.classed("td-selected",!1),_.isEqual(a,B)?(B=null,null!=d3.event?k(null):k(null,"click")):(d3.select(this).classed("td-selected",!0),B=a,null!=d3.event?k(a):k(a,"click"))):void 0},q=function(){return A?(r.call(y,d3.select(y).datum()),y=null):void 0},u=function(a){var b,d,f;if(A)return null!=y&&(d3.select(y).classed("td-over",!1),d3.select(y.parentNode).classed("td-over",!1)),a.x-=e.padding.left,a.y-=e.padding.top,b=1/0,y=d=null,c.each(function(c){var e,f,g;return e=Math.abs(c.cx-a.x),f=Math.abs(c.cy-a.y),g=Math.sqrt(e*e+f*f),b>g?(b=g,y=this,d=c):void 0}),f=$(F.node()).width(),G.style("top","auto").style("left",function(){var a,b;return b=e.padding.left+d.cx,0>b-f/2?f/2+"px":b+f/2>(a=e.padding.left+N)?a-f/2+"px":b+"px"}).style("bottom",e.padding.bottom+v-(d.cy<=a.y||!Modernizr.touch?d.cy:a.y)+"px"),t.call(y,d)},s=function(){return u({x:d3.mouse(this)[0],y:d3.mouse(this)[1]})},p=function(a){return u(a.getCGPoint())},L=function(a){return e.custom.selectable&&null!==l&&null!==g?(c.classed("td-selected",!1),null===a?B=null:c.each(function(b){return null!=b.id&&b.id.toString()===a||null!=b[n.color]&&b[n.color].toString()===a?(d3.select(this).classed("td-selected",!0),B=b):void 0})):void 0},b}}.call(this),function(){da.words=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G;return m=d3.select(a),j={padding:{top:0,right:0,bottom:0,left:0},scales:{size:{field:"d.size",type:"pow",domain:["min","max"],range:[10,50],format:null},color:{field:"d.color",type:"linear",domain:null,range:["#444","#ccc"]}},tooltip:{textFormat:"{$size}",visible:!0},custom:{fontFamily:"sans-serif",fontWeight:"normal",fontStyle:"normal",textField:"d.text",rectPadding:0}},o=g=i=h=null,t=[],F=null,u=d=null,c=d3.layout.cloud(),k=d3.dispatch("click","select","over"),e=_.cloneDeep(j),(w=function(){return u=function(){switch(e.scales.size.type){case"linear":return d3.scale.linear();case"sqrt":return d3.scale.sqrt();case"ordinal":return d3.scale.ordinal();case"pow":return d3.scale.pow().exponent(10)}}(),d=function(){switch(e.scales.color.type){
case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}()})(),E=s=null,(A=function(){var b,c;return c=$(a).width(),b=$(a).height(),E=c-da.utils.svgNum(e.padding.right)-da.utils.svgNum(e.padding.left),s=b-da.utils.svgNum(e.padding.top)-da.utils.svgNum(e.padding.bottom)})(),f=m.append("svg").attr("width","100%").attr("height","100%").append("g").attr("class","td-chart-container"),G=f.append("g").attr("class","td-words-container"),v=m.append("div").attr("class","tooltip-container").style("position","absolute").append("div").attr("class","tooltip"),b=function(){return b},b.data=function(a){return 0===arguments.length?g:(g=a,x(),y(),D(),z(),b)},b.options=function(a){return 0===arguments.length?e:(e=_.merge(e,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),w(),A(),x(),y(),D(),z(),b)},b.resize=function(){return A(),y(),D(),b},b.destroy=function(){return m.selectAll("*").remove(),b},b.on=function(a,c){return k.on(a,c),b},b.select=function(a){return 0===arguments.length?t:(updateSelection(a),D(),b)},x=function(){var a;if(null!==g)return console.log(g),a=!1,o={},o.size=e.scales.size.field.slice(2),o.color=e.scales.color.field.slice(2),o.text=e.custom.textField.slice(2),h=_.uniq(_.map(g,function(a){return a[o.color]})),i=_.cloneDeep(g).map(function(a){return{_datum:a,text:a[o.text]}}),F=G.selectAll("text.td-word").data(i),F.enter().append("text").attr("class","td-word").on("mouseover",r).on("mouseleave",q).on("click",p),F.exit().remove(),c.words(i),u.domain(function(){var a,b,c,d,f;for(a=[],d=e.scales.size.domain,b=0,c=d.length;c>b;b++)f=d[b],a.push(function(){switch(f){case"min":return d3.min(g,function(a){return a[o.size]});case"max":return d3.max(g,function(a){return a[o.size]});case null:break;default:return f}}());return a}()),d.domain(function(){var a,b,c,d,f,h,i;if("linear"===e.scales.color.type)return d3.range(e.scales.color.range.length);switch(e.scales.color.domain){case null:for(a=[],b=0,d=g.length;d>b;b++)i=g[b],a.push(i[o.color]);a=_.uniq(a);break;default:for(a=[],h=e.scales.color.domain,c=0,f=h.length;f>c;c++)i=h[c],a.push(function(){switch(i){case"min":return d3.min(g,function(a){return a[o.color]});case"max":return d3.max(g,function(a){return a[o.color]});default:return i}}())}return a}())},y=function(){return u.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.size.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),d.range(function(){var a,b,c,d,f;for(c=[],d=e.scales.color.range,a=0,b=d.length;b>a;a++)f=d[a],null!=f&&c.push(f);return c}()),console.log(E,s),c.size([E,s]).padding(e.custom.rectPadding).rotate(0).fontSize(function(a){return u(da.utils.realNum(a._datum[o.size]))}).font(e.custom.fontFamily).fontWeight(e.custom.fontWeight).fontStyle(e.custom.fontStyle)},D=function(){return null!==m&&null!==g?(f.attr("transform","translate("+da.utils.svgNum(e.padding.left)+","+da.utils.svgNum(e.padding.top)+")"),G.attr("transform","translate("+E/2+","+s/2+")"),F.text(function(a){return a._datum[o.text]}).attr("fill",function(a){return d("linear"===e.scales.color.type?da.utils.moreColor(a._datum[o.color],h,e.scales.color.range):a[o.color])}).style("font-size",function(a){return u(da.utils.realNum(a._datum[o.size]))}).style("font-family",e.custom.fontFamily).style("font-weight",e.custom.fontWeight).style("font-style",e.custom.fontStyle),v.classed("td-hidden",!0)):void 0},B=function(){return F.attr("transform",function(a){return"translate("+[a.x,a.y]+")rotate("+a.rotate+")"})},z=function(){return c.on("end",B).start()},n=function(a){var b;return b=_.cloneDeep(a._datum),b.$size=a._datum[o.size],b.$color=a._datum[o.color],b},l=function(a){var b;switch(b=n(a),d3.event.type){case"click":return k.click(b);case"mouseover":return k.over(b);case"mouseleave":return k.over(null)}},r=function(a){return d3.select(this).classed("td-over",!0),e.tooltip.visible&&v.classed("td-hidden",!1).text(function(){return da.utils.template(e.tooltip.textFormat,n(a))}),l(a)},q=function(a){return d3.select(this).classed("td-over",!1),e.tooltip.visible&&v.classed("td-hidden",!0),l(a)},p=function(a){return d3.select(this).classed("td-selected",!0),_.contains(t,this)||t.push(this),l(a)},C=function(a){return null===a?(t=[],F.classed("td-selected",!1)):F.each(function(b){return b._datum[o.text]===a?(_.contains(t,b)||t.push(b),d3.select(this).classed("td-selected",!0)):void 0})},b}}.call(this),function(){da.barsLines=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,aa,ba,ca,ea;return o=d3.select(a),l={padding:{top:0,right:0,bottom:0,left:0},scales:{x:{field:"d.x",type:"ordinal",domain:"all",range:[0,"width"],format:null},y:{field:"d.y",type:"linear",domain:["min","max"],range:["height",0],nice:!0},y2:{field:"d.y",type:"linear",domain:["min","max"],range:["height",0],nice:!0},color:{field:"d.color",type:"linear",domain:null,range:["#444","#ccc"]}},axes:{x:{position:"bottom",tickPadding:100,tickFormat:"{x}",tickExtension:"default",visible:!0},y:{position:"left",tickPadding:25,tickFormat:'{N(y,"0.[00]a")}',tickExtension:"axis",visible:!0},y2:{position:"right",tickPadding:25,tickFormat:'{N(y2,"0.[00]a")}',tickExtension:"axis",visible:!0}},legends:{color:{title:null,labelFormat:null,labels:null,position:"bottom",visible:!0}},tooltip:{textFormat:"{N($y)}",visible:!0},custom:{grouped:!1,normalized:!1,rangePadding:.1,outerPadding:0,selectable:!0,horizontal:!1,wrapTicks:!0,localeId:null,showTotals:!1,totalHeight:30,totalFormat:'{I(t,"0,0.[00]")}',showLines:!0,showPoints:!0,interpolate:"linear"}},q=i=j=k=null,E=[],C=null,f=b=z=N=null,J=null,V=Y=Z=e=null,W=d3.svg.axis(),ca=d3.svg.axis(),aa=d3.svg.axis(),G=d3.layout.stack(),B=d3.svg.line(),I=null,m=d3.dispatch("click","select","over","bind","ready"),D=!1,g=_.cloneDeep(l),(O=function(){return V=function(){switch(g.scales.x.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"time":return d3.time.scale()}}(),Y=function(){switch(g.scales.y.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),Z=function(){switch(g.scales.y2.type){case"linear":return d3.scale.linear();case"pow":return d3.scale.pow();case"ordinal":return d3.scale.ordinal()}}(),e=function(){switch(g.scales.color.type){case"linear":return d3.scale.linear();case"ordinal":return d3.scale.ordinal();case"threshold":return d3.scale.threshold()}}(),null!=g.scales.x.format?J=d3.time.format(g.scales.x.format):void 0})(),U=y=null,(R=function(){var b,c;return c=$(a).width(),b=$(a).height(),U=c-da.utils.svgNum(g.padding.right)-da.utils.svgNum(g.padding.left),y=b-da.utils.svgNum(g.padding.top)-da.utils.svgNum(g.padding.bottom)})(),H=o.append("svg").attr("width","100%").attr("height","100%"),Modernizr.touch?I=cross_js.gestures.addEventListener(H.node(),"drag",function(a){switch(a.phase){case"start":case"change":return s(a);case"end":return t()}}):null!=I&&cross_js.gestures.removeEventListener(I),H.on("mousemove",Modernizr.touch?null:function(){return v.call(this)}).on("mouseleave",Modernizr.touch?null:function(){return t.call(this)}),h=H.append("g").attr("class","td-chart-container"),X=h.append("g").attr("class","td-x-axis"),ea=h.append("g").attr("class","td-y-axis"),ba=h.append("g").attr("class","td-y2-axis"),c=h.append("g").attr("class","td-bars-main-cont"),F=h.append("g").attr("class","td-series-main-cont"),M=o.append("div").attr("class","td-total-container"),A=o.append("div").attr("class","td-legend-container").style("position","absolute"),A.append("div").attr("class","td-legend-title"),L=o.append("div").attr("class","td-tooltip-container").style("position","absolute"),K=L.append("div").attr("class","td-tooltip td-hidden"),d=function(){return d},d.data=function(a){return 0===arguments.length?i:(i=a,P(),Q(),T(),d)},d.options=function(a){return 0===arguments.length?g:(g=_.merge(g,a,function(a,b){return _.isArray(a)||_.isArray(b)?b:void 0}),O(),R(),P(),Q(),T(),d)},d.resize=function(){return R(),Q(),T(),d},d.destroy=function(){return o.selectAll("*").remove(),d},d.on=function(a,b){return m.on(a,b),d},d.select=function(a){return 0===arguments.length?E:(S(a),T(),d)},P=function(){var a,d,h,j,l,n,o,p,s;if(null!==i){switch(s=!1,q={},q.x=g.scales.x.field.slice(2),q.y=[],q.y2=[],_.isArray(g.scales.y.field)){case!0:s=!0,g.scales.y.field.forEach(function(a){return q.y.push(a.slice(2))});break;case!1:q.y.push(g.scales.y.field.slice(2))}switch(_.isArray(g.scales.y2.field)){case!0:s=!0,g.scales.y2.field.forEach(function(a){return q.y2.push(a.slice(2))});break;case!1:q.y2.push(g.scales.y2.field.slice(2))}switch(q.color=[],g.scales.color.field){case"keys":q.color=_.cloneDeep(q.y);break;default:q.color.push(g.scales.color.field.slice(2))}return q.keys=s?q.y:_.uniq(i.map(function(a){return a[q.color]})),null!=g.scales.x.format&&i.forEach(function(a){return _.isDate(a[q.x])?void 0:a[q.x]=function(){switch(g.scales.x.format){case"date":return new Date(a[q.x]);case"timestamp":return new Date(1e3*a[q.x]);default:return J.parse(String(a[q.x]))}}()}),s||(l=_.cloneDeep(i),l=d3.nest().key(function(a){return a[q.color]}).entries(l)),h=s?_.cloneDeep(i):l,h=_.pluck(l,"values"),d=[_.first(h)],a=G(_.rest(h)),console.log(d,a),k=q.keys,f=c.selectAll("g.td-column").data(a),f.enter().append("g").attr("class","td-column"),f.exit().remove(),b=f.selectAll("rect.td-bar").data(function(a){return a}),b.enter().append("rect").attr("class","td-bar").style("opacity",0).on("click",r),b.exit().remove(),o=F.selectAll("g.td-series-container").data(d),p=o.enter().append("g").attr("class","td-series-container"),p.append("path").attr("class","td-series-line").style("opacity",0),o.exit().remove(),n=o.selectAll(".td-series-point").data(function(a){return a}),n.enter().append("circle").attr("class","td-series-point").style("opacity",0),n.exit().remove(),z=A.selectAll("div.td-legend-item").data(k),j=z.enter().append("div").attr("class","td-legend-item"),j.append("i").attr("class","td-legend-item-icon"),j.append("div").attr("class","td-legend-item-text"),z.exit().remove(),function(){var a,b,c,d,e;if(a=[],_.isArray(g.scales.x.domain))for(d=g.scales.x.domain,b=0,c=d.length;c>b;b++)e=d[b],a.push(function(){switch(e){case"min":return d3.min(i,function(a){return a[q.x]});case"max":return d3.max(i,function(a){return a[q.x]});case null:break;default:return e}}());else switch(g.scales.x.domain){case"all":i.forEach(function(b){return null!==b[q.x]?a.push(b[q.x]):void 0}),a=_.uniq(a)}return _.isArray(a)&&a.length>=2?V.domain(a):void 0}(),function(){var b,c,d,e,f;if(b=[],_.isArray(g.scales.y.domain))for(e=g.scales.y.domain,c=0,d=e.length;d>c;c++)f=e[c],b.push(function(){switch(f){case"min":return d3.min(_.flatten(a),function(a){return a.y0});case"max":return d3.max(_.flatten(a),function(a){return a.y0+a.y});case null:break;default:return f}}());return _.isArray(b)&&b.length>=2?Y.domain(b):void 0}(),function(){var a,b,c,e,f;if(a=[],_.isArray(g.scales.y2.domain))for(e=g.scales.y2.domain,b=0,c=e.length;c>b;b++)f=e[b],a.push(function(){switch(f){case"min":return d3.min(_.flatten(d),function(a){return a.y});case"max":return d3.max(_.flatten(d),function(a){return a.y});case null:break;default:return f}}());return _.isArray(a)&&a.length>=2?Z.domain(a):void 0}(),e.domain("linear"===g.scales.color.type?d3.range(g.scales.color.range.length):k),m.bind()}},Q=function(){return V.rangeBands(function(){var a,b,c,d,e;if(c=[],_.isArray(g.scales.x.range))for(d=g.scales.x.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return U;case"height":return y;case null:break;default:return e}}());return c}(),g.custom.rangePadding,g.custom.outerPadding),Y.range(function(){var a,b,c,d,e;if(c=[],_.isArray(g.scales.y.range))for(d=g.scales.y.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return U;case"height":return y;case null:break;default:return g.custom.showTotals?e+g.custom.totalHeight:e}}());return c}()),Z.range(function(){var a,b,c,d,e;if(c=[],_.isArray(g.scales.y2.range))for(d=g.scales.y2.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return U;case"height":return y;case null:break;default:return g.custom.showTotals?e+g.custom.totalHeight:e}}());return c}()),e.range(function(){var a,b,c,d,e;if(c=[],_.isArray(g.scales.y.range))for(d=g.scales.color.range,a=0,b=d.length;b>a;a++)e=d[a],c.push(function(){switch(e){case"width":return U;case"height":return y;default:return e}}());return c}()),W.scale(V).orient(g.axes.x.position).ticks(function(){var a,b;return a=("left"===(b=g.axes.x.position)||"right"===b?y:U)/g.axes.x.tickPadding,a>3?a:3}()).tickFormat(function(a){return da.utils.template(g.axes.x.tickFormat,{x:a},g.custom.localeId)}),da.utils.setAxisTicks(g.padding,U,y,g.axes.x,W),ca.scale(Y).orient(g.axes.y.position).ticks(function(){var a,b;return a=("left"===(b=g.axes.y.position)||"right"===b?y:U)/g.axes.y.tickPadding,a>3?a:3}()).tickFormat(function(a){return da.utils.template(g.axes.y.tickFormat,{y:a},g.custom.localeId)}),da.utils.setAxisTicks(g.padding,U,y,g.axes.y,ca),aa.scale(Z).orient(g.axes.y2.position).ticks(function(){var a,b;return a=("left"===(b=g.axes.y2.position)||"right"===b?y:U)/g.axes.y2.tickPadding,a>3?a:3}()).tickFormat(function(a){return da.utils.template(g.axes.y2.tickFormat,{y2:a},g.custom.localeId)}),da.utils.setAxisTicks(g.padding,U,y,g.axes.y2,aa),B.x(function(a){return V.rangeBand()/2+V(a[q.x])}).y(function(a){return Z(a[q.y])})},T=function(){return null!==o&&null!==i?(h.attr("transform","translate("+da.utils.svgNum(g.padding.left)+","+da.utils.svgNum(g.padding.top)+")"),g.axes.x.visible&&(X.attr("transform",function(){switch(g.axes.x.position){case"right":return"translate("+U+",0)";case"bottom":return"translate(0,"+y+")";default:return null}}()).transition().duration(1e3).call(W),X.select(".domain").attr("transform",function(){switch(g.axes.x.position){case"top":case"bottom":return"translate(0,"+(da.utils.realNum(Y(0))-y)+")";case"left":case"right":return"translate("+da.utils.realNum(Y(0))+",0)"}}()),g.custom.wrapTicks&&X.selectAll(".tick text").call(da.utils.wrap,g.custom.horizontal?g.padding.left-W.tickPadding()-W.tickSize():V.rangeBand()/(1-g.custom.rangePadding))),g.axes.y.visible&&ea.attr("transform",function(){switch(g.axes.y.position){case"right":return"translate("+U+",0)";case"bottom":return"translate(0,"+y+")";default:return null}}()).transition().duration(1e3).call(ca),g.axes.y2.visible&&ba.attr("transform",function(){switch(g.axes.y2.position){case"right":return"translate("+U+",0)";case"bottom":return"translate(0,"+y+")";default:return null}}()).transition().duration(1e3).call(aa),h.selectAll("rect.td-bar").transition().duration(1e3).style("opacity",1).attr(g.custom.horizontal?"y":"x",function(a,b){var c;return c=V(a[q.x]),a.bbox={},a.bbox[g.custom.horizontal?"y":"x"]=c}).attr(g.custom.horizontal?"width":"height",function(a){var b;return b=da.utils.svgNum(Math.abs(Y(a[q.y])-Y(0))),a.bbox[g.custom.horizontal?"width":"height"]=b}).attr(g.custom.horizontal?"x":"y",function(a){var b;return b=da.utils.realNum(d3.min([Y(a.y0),Y(a[q.y]+a.y0)])),a.bbox[g.custom.horizontal?"x":"y"]=b}).attr(g.custom.horizontal?"height":"width",function(a){var b;return b=g.custom.grouped===!1?da.utils.svgNum(V.rangeBand()):da.utils.svgNum(V.rangeBand()/d3.select(this.parentNode).datum()._val.length),a.bbox[g.custom.horizontal?"height":"width"]=b}).style("fill",function(a){return e("linear"===g.scales.color.type?da.utils.moreColor(a.color,k,g.scales.color.range):a.color)}).tween("",function(a){return function(b){return 1>b?void 0:a.centroid=[a.bbox.x+a.bbox.width/2,a.bbox.y+a.bbox.height/2]}}).each("end",function(a,b){return b===h.selectAll("rect.td-bar")[0].length-1?(D=!0,m.ready()):void 0}),g.custom.showLines?h.selectAll("path.td-series-line").classed("td-hidden",!1).style("opacity",1).style("stroke-width",g.custom.strokeWidth).style("fill","none").style("stroke",function(){return e("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,k,g.scales.color.range):d3.select(this.parentNode).datum().color)}).transition().duration(1e3).attr("d",function(a,b){return B.interpolate(_.isArray(g.custom.interpolate)?null!=g.custom.interpolate[b]?g.custom.interpolate[b]:null:g.custom.interpolate)(d3.select(this.parentNode).datum())}):h.selectAll("path.td-series-line").classed("td-hidden",!0),g.custom.showPoints?h.selectAll("circle.td-series-point").classed("td-hidden",!1).transition().duration(1e3).style("opacity",1).attr("cx",function(a){return a[5]=da.utils.realNum(V(a[0]))}).attr("cy",function(a){return g.custom.stacked?a[6]=da.utils.realNum(Y(a[1]+a[2])):a[6]=da.utils.realNum(Y(a[1]))}).attr("r",function(a){return da.utils.isRealNum(a[1])&&da.utils.isRealNum(a[2])?g.custom.pointRadius:null}).style("stroke",function(){return e("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,k,g.scales.color.range):d3.select(this.parentNode).datum().color)}).style("fill",function(){return e("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum().color,k,g.scales.color.range):d3.select(this.parentNode).datum().color)}).each("end",function(a,b){return b===h.selectAll("circle.td-series-point")[0].length-1?(D=!0,m.ready()):void 0}):h.selectAll("circle.td-series-point").classed("td-hidden",!0),g.legends.color.visible&&(A.selectAll("i.td-legend-item-icon").attr("class","td-legend-item-icon fa fa-square").style("color",function(){return e("linear"===g.scales.color.type?da.utils.moreColor(d3.select(this.parentNode).datum(),k,g.scales.color.range):d3.select(this.parentNode).datum())}),da.utils.relayoutLegend(g.legends.color,A,z,o)),K.classed("td-hidden",!0)):void 0},p=function(a){var b;return b=_.cloneDeep(a),b.$x=a.x,b.$y=a.y,b.$color=a.color,b.$colorString=e("linear"===g.scales.color.type?da.utils.moreColor(a.color,k,g.scales.color.range):a.color),b},n=function(a,b){var c;if(c=null!=a?p(a):null,null!=d3.event&&(b=d3.event.type),null!=b)switch(b){case"click":return m.click(c);case"mouseover":case"mousemove":return m.over(c);case"mouseleave":return m.over(null)}},w=function(a){return d3.select(this).classed("td-over",!0),d3.select(C.parentNode).classed("td-over",!0),null!=C.parentNode&&d3.select(C.parentNode.parentNode).classed("td-over",!0),g.tooltip.visible&&K.classed("td-hidden",!1).html(function(){return da.utils.template(g.tooltip.textFormat,p(a),g.custom.localeId)}),null!=d3.event?n(a):n(a,"mousemove")},u=function(a){return d3.select(this).classed("td-over",!1),d3.select(C.parentNode).classed("td-over",!1),null!=C.parentNode&&d3.select(C.parentNode.parentNode).classed("td-over",!1),g.tooltip.visible&&K.classed("td-hidden",!0),null!=d3.event?n(a):n(a,"mouseleave")},r=function(a){return g.custom.selectable?(b.classed("td-selected",!1),_.isEqual(a,E)?(E=null,null!=d3.event?n(null):n(null,"click")):(d3.select(this).classed("td-selected",!0),E=a,null!=d3.event?n(a):n(a,"click"))):void 0},t=function(){return D?(u.call(C,d3.select(C).datum()),C=null):void 0},x=function(a){var b,c,d,e;if(D)return null!=C&&(d3.select(C).classed("td-over",!1),d3.select(C.parentNode).classed("td-over",!1),null!=C.parentNode&&d3.select(C.parentNode.parentNode).classed("td-over",!1)),a.x-=g.padding.left,a.y-=g.padding.top,d=1/0,e=1/0,C=b=null,h.selectAll("rect.td-bar").each(function(c){var f,h;return(null==c.centroid||_.isEqual(c.centroid,[0,0]))&&(c.centroid=[c.bbox.x+c.bbox.width/2,c.bbox.y+c.bbox.height/2]),f=Math.abs(c.centroid[0]-a.x),h=Math.abs(c.centroid[1]-a.y),!g.custom.horizontal&&(d>f||d>=f&&e>h)||g.custom.horizontal&&(e>h||e>=h&&d>f)?(d=f,e=h,C=this,b=c):void 0}),c=$(K.node()).width(),L.style("top","auto").style("left",function(){var a,d;return d=g.padding.left+b.centroid[0],0>d-c/2?c/2+"px":d+c/2>(a=g.padding.left+U)?a-c/2+"px":d+"px"}).style("bottom",g.padding.bottom+y-(b.centroid[1]<=a.y||g.custom.horizontal?b.centroid[1]:a.y)+"px"),w.call(C,b)},v=function(){return x({x:d3.mouse(this)[0],y:d3.mouse(this)[1]})},s=function(a){return x(a.getCGPoint())},S=function(a){return g.custom.selectable&&null!==o&&null!==i?(b.classed("td-selected",!1),null===a?E=null:b.each(function(b){return null!=b.item.id&&b.item.id.toString()===a||null!=b.item[q.color]&&b.item[q.color].toString()===a?(d3.select(this).classed("td-selected",!0),E=b):void 0})):void 0},d}}.call(this),function(){da.choropleth=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;return m={top:50,right:0,bottom:50,left:0},u=d3.select(a),y=b.width-m.left-m.right,i=b.height-m.top-m.bottom,h=u.append("svg").attr("width",y).attr("height",i).style("top",m.top+"px").style("left",m.left+"px"),o=d3.geo.mercator().center([-1,48]).rotate([347,0]).scale(2e3).translate([y/2,i/2]),n=d3.geo.path().projection(o),p=d3.scale.quantize().range(d3.range(4).map(function(a){return"q"+a+"-4"})),d=d3.dispatch("select","inspect"),t=[],j=!1,q=null,x=null,e=function(a){if(a=_.clone(_.find(t,{id:a.id})))switch(x[a.id]&&(a.value=x[a.id][0].value),d3.event.type){case"click":return d.select(a);case"mouseover":return d.inspect(a);case"mouseout":return d.inspect(null)}},l=function(a,b){return d3.json(a,function(a,c){var d;return d=topojson.feature(c,c.objects.items).features,t=_.map(d,function(a){return{label:a.properties.label,id:a.id}}),h.selectAll("g").remove(),h.append("g").attr("class","counties").selectAll("path").data(d).enter().append("path").attr("d",n).on("click",e).on("mouseover",e).on("mouseout",e),j=!0,w(),b(a)})},g=function(){return _.clone(t)},c=function(a){return a?p(a[0].value):"no-data"},k=function(a,b){return d.on(a,b)},s=function(a){return q=a,w()},f=function(){return q},r=function(a){return a.center&&o.center(a.center),a.rotate&&o.rotate(a.rotate),a.scale&&o.scale(a.scale),w()},v=function(a){return p.domain(d3.extent(a,function(a){return a.value})),x=_.groupBy(a,"id"),w()},w=function(){return null!=j?h.selectAll("path").attr("class",function(a){return a.id===q?"selected":c(x?x[a.id]:null)}):void 0},{load:l,data:v,shapes:g,projection:r,update:w,selected:function(a){return arguments.length?s(a):f()},on:k}}}.call(this),function(){da.singletimeline=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa;return S={top:30,right:200,bottom:90,left:0},W=d3.select(a),N=Modernizr.touch,ia=_.parseInt(W.style("width"))-S.left-S.right,M=_.parseInt(W.style("height"))-S.top-S.bottom,y=null!=N?N:{0:44},ja=d3.time.scale().range([0,ia]),na=d3.scale.linear().range([M-y,0]),ka=d3.time.scale().range([50,ia]),oa=d3.scale.linear().range([S.bottom,0]),u=[],ha=[],s=d3.time.format("%d/%m/%Y"),Y=d3.time.format("%e/%m h%H.%M"),H=d3.time.format("%d %B"),I=d3.time.format("h%H"),da="weeks",ca=d3.time.monday,ba=H,la=d3.svg.axis().scale(ja).orient("bottom").ticks(d3.time.weeks).tickSize(M).tickPadding(-M-10),pa=d3.svg.axis().scale(na).orient("right").ticks(2).tickSize(-ia).tickPadding(10),ma=d3.svg.axis().scale(ka).orient("bottom").ticks(d3.time.months).tickSize(S.bottom).tickPadding(-S.bottom+10).tickFormat(s),U=[],V=W.append("svg").attr("width",ia+S.left+S.right).attr("height",M+S.top+S.bottom),V.append("defs").append("clipPath").attr("id","clip").append("rect").attr("width",ia).attr("height",M+S.top),k=V.append("defs").append("clipPath").attr("id","clip-sel").append("rect").attr("x",500).attr("width",340).attr("height",M-y),l=V.append("defs").append("clipPath").attr("id","clip-sel-cxt").append("rect").attr("x",500).attr("width",140).attr("height",M+S.top+S.bottom),L=ia+S.left+S.right,K=V.append("rect").attr("class","head").attr("width",L).attr("height",S.top),V.append("rect").attr("class","bottom-bg").attr("y",M+S.top).attr("width","100%").attr("height",S.bottom),B=V.append("g").attr("transform","translate("+S.left+","+S.top+")"),C=B.append("path").attr("class","focus-area").attr("clip-path","url(#clip-sel)"),F=B.append("path").attr("class","focus-line"),aa=B.append("g").attr("class","blocks").attr("transform","translate(0,0)"),D=B.append("g").attr("class","x axis").attr("transform","translate(0,0)"),B.append("rect").attr("class","left-box").attr("x",ia+S.left).attr("y",-S.top).attr("width",S.right).attr("height",M+S.top),E=B.append("g").attr("class","y axis").attr("transform","translate("+ia+",0)"),G=B.append("rect").attr("class","pane").attr("width",ia).attr("height",M),N?(v=B.append("g").attr("class","cursor").attr("transform","translate(0,"+(M-y)+")"),v.append("rect").attr("width",ia).attr("height",y)):W.select(".drag-label").classed("hidden",!0),X=B.append("g").attr("class","tooltip").classed("hidden",!0),X.append("rect").attr("width",50).attr("height",20).attr("x",-25).attr("y",-10),X.append("text"),n=V.append("g").attr("transform","translate("+S.left+","+(S.top+M)+")"),o=n.append("path").attr("class","context-area").attr("clip-path","url(#clip-sel-cxt)"),t=n.append("path").attr("class","context-line"),p=n.append("g").attr("class","x axis context").attr("transform","translate(0,0)"),r=n.append("g").attr("class","x view").attr("transform","translate(0,4)"),q=n.append("g").attr("class","x brush"),V.append("line").attr("class","head-line").attr("x2",L-S.right).attr("y1",S.top).attr("y2",S.top),V.append("line").attr("class","middle-line").attr("x2",L-S.right).attr("y1",M+S.top).attr("y2",M+S.top),V.append("line").attr("class","left-line").attr("y2",M+S.top).attr("x1",ia+S.left).attr("x2",ia+S.left),z=d3.dispatch("select"),b=864e5,d=7*b,c=30*b,qa=d3.behavior.zoom().x(ja).scaleExtent([.5,20]).on("zoom",function(){var a,c,d;switch(d=d3.event.scale,c=ja.domain(),a=c[1].getTime()-c[0].getTime(),!1){case!(.5*b>a):da="hours",ca=d3.time.hour,ba=I;break;case!(8*b>a):da="days",ca=d3.time.day,ba=H;break;case!(50*b>a):da="weeks",ca=d3.time.monday,ba=H;break;default:da="months",ca=d3.time.month,ba=H}return i.extent(ja.domain()),r.call(i),T()}),G.call(qa),h=d3.svg.brush().x(ka).on("brush",function(){return d3.event.sourceEvent?j(h.extent()):void 0}).on("brushend",function(){!d3.event.sourceEvent}),q.call(h),q.selectAll("rect").attr("height",S.bottom),i=d3.svg.brush().x(ka).on("brush",function(){return d3.event.sourceEvent?(ja.domain(i.extent()),qa.x(ja),T()):void 0}).on("brushend",function(){!d3.event.sourceEvent}),r.call(i),r.selectAll("rect").attr("height",S.bottom-7),r.selectAll(".resize").style("pointer-events","none"),r.selectAll(".background").style("pointer-events","none"),$=function(a){var b;return a?(X.classed("hidden",!1).select("text").text(a[1]),a!==b?(X.transition().duration(250).attr("transform","translate("+ja(a[0])+","+(na(a[1])-15)+")"),b=a):void 0):(X.classed("hidden",!0),void(b=null))},Z=function(){var a;return a=null},O=null,x=_.debounce($,100),w=d3.svg.brush().x(ja).extent([0,0]).on("brush",function(){var a;return a=h.extent()[0],d3.event.sourceEvent&&(a=ja.invert(d3.mouse(this)[0]),w.extent([a,a])),a=_.find(u,function(b){return b[0]>a}),x(a)}).on("brushend",function(){return x(null)}),v?v&&v.call(w):(G.on("mousemove",function(){var a;return a=ja.invert(d3.mouse(this)[0]),a=_.find(u,function(b){return b[0]>a}),x(a)}),G.on("mouseout",function(){return x(null)})),f=d3.svg.area().interpolate("monotone").x(function(a){return ja(a[0])}).y0(M).y1(function(a){return na(a[1])}),P=d3.svg.line().interpolate("monotone").x(function(a){return ja(a[0])}).y(function(a){return na(a[1])}),g=d3.svg.area().interpolate("monotone").x(function(a){return ka(a[0])}).y0(M).y1(function(a){return oa(a[1])}),Q=d3.svg.line().interpolate("monotone").x(function(a){return ka(a[0])}).y(function(a){return oa(a[1])}),j=function(a){return U=a,fa(),z.select(U)},A=!0,ea=function(a){return _.forEach(a,function(a){return a[0]=new Date(Date.parse(a[0]))}),ha=d3.extent(a.map(function(a){return a[0]})),A&&ja.domain(ha),na.domain([0,d3.max(a.map(function(a){return a[1]}))]).nice(),ka.domain(ha),oa.domain(na.domain()),qa.x(ja),F.datum(a),C.datum(a),t.datum(a),o.datum(a),u=a,T(!0),A=!1},ga=function(a){var b;return b=ja(d3.select(a[0][1]).datum())-ja(d3.select(a[0][0]).datum()),a.each(function(a,c){var d;return d=d3.select(this).attr("transform",function(a){return"translate("+ja(a)+", -"+S.top+")"}),d.select("rect").attr("width",b).attr("height",M+S.top),d.select("text").attr("x",10).attr("y",20).style("text-anchor","start").text(function(a){return ba(a)})})},m=function(a,b){return a(b[1])-a(b[0])},fa=function(a){return k.attr("x",ja(U[0])).attr("width",m(ja,U)),l.attr("x",ka(U[0])).attr("width",m(ka,U)),h.extent(U),q.call(h),i.extent(ja.domain()),r.call(i),null!=v&&v.call(w),a?q.call(h.event):void 0},R=function(a,b){return z.on(a,b)},e=null,J=function(a,b){return e||(e={},e.n=0,e.delay=_.delay(function(){var b;return b=null,b=e.n>1?[ha[0],ca.offset(a,1)]:[a,ca.offset(a,1)],j(b),e=null},300)),e.n+=1},T=function(a){var b,c,d,e;switch(E.transition().duration(1e3).call(pa),E.selectAll("line").attr("x1",S.left),a?(F.transition().duration(1e3).attr("d",P),C.transition().duration(1e3).attr("d",f)):(F.attr("d",P),C.attr("d",f)),p.transition().duration(1e3).call(ma).selectAll("text").attr("x",10).style("text-anchor","start"),t.transition().duration(1e3).attr("d",Q),o.transition().duration(1e3).attr("d",g),fa(!0),d=ja.domain(),da){case"hours":e=d3.time.hours(d3.time.hour.offset(d[0],-1),d3.time.hour.offset(d[1],1));break;case"days":e=d3.time.days(d3.time.day.offset(d[0],-1),d3.time.day.offset(d[1],1));break;case"months":e=d3.time.months(d3.time.month.offset(d[0],-1),d3.time.month.offset(d[1],1));break;case"weeks":e=d3.time.mondays(d3.time.monday.offset(d[0],-1),d3.time.monday.offset(d[1],1))}return b=aa.selectAll("g").data(e),c=b.enter().append("g"),c.append("rect").attr("class","box").on("click",J),c.append("line").attr("class","box-line").attr("x1",0).attr("x2",0).attr("y2",M+S.top),c.append("text").attr("class","no-selection"),b.transition().duration(1e3).call(ga),b.exit().remove()},{data:ea,selection:j,on:R}}}.call(this),function(){da.timeline=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,Aa,Ba,Ca,Da,Ea,Fa,Ga;return U={top:30,right:200,bottom:90,left:0},V=5,ha=d3.select(a),O=Modernizr.touch,O=!1,wa=_.parseInt(ha.style("width"))-U.left-U.right,N=_.parseInt(ha.style("height"))-U.top-U.bottom,y=O?44:0,K=30,xa=d3.time.scale().range([0,wa]),Ba=d3.scale.linear().range([N-y,0]),ya=d3.time.scale().range([K,wa-K]),Ca=d3.scale.linear().range([U.bottom,0]),Y=null,v=null,W=[],X=null,Z=[],t=d3.time.format("%d/%m/%Y"),ia=d3.time.format("%e/%m h%H.%M"),H=d3.time.format("%d %B"),I=d3.time.format("h%H"),oa="weeks",na=d3.time.monday,ma=H,za=d3.svg.axis().scale(xa).orient("bottom").ticks(d3.time.weeks).tickSize(N).tickPadding(-N-10),Da=d3.svg.axis().scale(Ba).orient("right").ticks(2).tickSize(-wa).tickPadding(10),Aa=d3.svg.axis().scale(ya).orient("bottom").ticks(d3.time.months).tickSize(U.bottom).tickPadding(-U.bottom+10).tickFormat(t),aa=[],$=[],k=null,ea=[],ga=ha.append("svg").attr("width",wa+U.left+U.right).attr("height",N+U.top+U.bottom),n=ga.append("rect").attr("class","time-sel").attr("height",N+U.top),o=ga.append("rect").attr("class","time-sel").attr("height",U.bottom).attr("y",N+U.top),M=wa+U.left+U.right,L=ga.append("rect").attr("class","head").attr("width",M).attr("height",U.top),B=ga.append("g").attr("transform","translate("+U.left+","+U.top+")"),E=B.append("g"),la=B.append("g").attr("class","blocks").attr("transform","translate(0,0)"),G=B.append("rect").attr("class","pane").attr("width",wa).attr("height",N),F=B.append("g"),B.append("rect").attr("class","right-box").attr("x",wa+U.left).attr("y",-U.top).attr("width",U.right).attr("height",N+U.top+U.bottom),C=B.append("g").attr("class","x axis").attr("transform","translate(0,0)"),D=B.append("g").attr("class","y axis").attr("transform","translate("+wa+",0)"),O?(w=B.append("g").attr("class","cursor").attr("transform","translate(0,"+(N-y)+")"),
w.append("rect").attr("width",wa).attr("height",y)):ha.select(".drag-label").classed("hidden",!0),q=ga.append("g").attr("transform","translate("+U.left+","+(U.top+N)+")"),u=q.append("g"),r=q.append("g").attr("class","x axis context").attr("transform","translate(0,0)"),s=q.append("g").attr("class","x view").attr("transform","translate(0,3)"),ga.append("line").attr("class","head-line").attr("x2",M-U.right).attr("y1",U.top).attr("y2",U.top),ga.append("line").attr("class","middle-line").attr("x2",M-U.right).attr("y1",N+U.top).attr("y2",N+U.top),ga.append("line").attr("class","left-line").attr("y2",N+U.top+U.bottom).attr("x1",wa+U.left).attr("x2",wa+U.left),z=d3.dispatch("select","tooltip","note"),b=864e5,d=7*b,c=30*b,Fa=!1,Ga=null,Ea=d3.behavior.zoom().x(xa).scaleExtent([1,1/0]).on("zoomstart",function(){return Fa=!0,x()}).on("zoomend",function(){return Fa=!1,x()}).on("zoom",Ga=function(){return fa(xa.domain())}),G.call(Ea),fa=function(a){var b,c,d;return d=ta(a),b=d[1]-d[0],c=Z[1]-Z[0],xa.domain(d),Ea.translate([xa(Z[0]),0]),Ea.scale(c/b),G.call(Ea),f.extent(d),s.call(f),ba()},f=d3.svg.brush().x(ya).on("brush",function(){return d3.event.sourceEvent?fa(f.extent()):void 0}).on("brushend",function(){!d3.event.sourceEvent}),s.call(f),s.selectAll("rect").attr("height",U.bottom-6),da=s.selectAll("g.resize.w"),da.append("rect").attr("class","handler").attr("width",K-1).attr("height",U.bottom-6).attr("x",-K+1),da.append("path").attr("d","M0 0 L-0 15 M5 0 L5 15 M10 0 L10 15 ").attr("transform","translate(-19,36)"),ca=s.selectAll("g.resize.e"),ca.append("rect").attr("class","handler").attr("width",K-1).attr("height",U.bottom-6).attr("x",0),ca.append("path").attr("d","M0 0 L-0 15 M5 0 L5 15 M10 0 L10 15 ").attr("transform","translate(10,36)"),s.selectAll(".resize"),s.selectAll(".background"),ta=function(a){var b;return b=_.clone(a),a[0]<Z[0]&&(b[0]=Z[0]),a[1]>Z[1]&&(b[1]=Z[1]),b},ua=function(){var a,b,c,d,e;return a=wa/((xa.domain()[1]-xa.domain()[0])*Ea.scale()),c=-((xa.domain()[0]-xa.domain()[1])*Ea.scale()+(Z[1]-(Z[1]-wa/a))),b=-(xa.domain()[0]-xa.domain()[1]+(Z[1]-Z[0]))*a*Ea.scale(),d=xa.domain()[0]<Z[0]?c:xa.domain()[1]>Z[1]?b:Ea.translate()[0],e=Ea.translate()[1],[d,e]},va=function(){var a,c;switch(c=xa.domain(),a=c[1].getTime()-c[0].getTime(),!1){case!(.5*b>a):return oa="hours",na=d3.time.hour,ma=I;case!(8*b>a):return oa="days",na=d3.time.day,ma=H;case!(50*b>a):return oa="weeks",na=d3.time.monday,ma=H;default:return oa="months",na=d3.time.month,ma=H}},ra=function(){return n.attr("x",xa(ea[0])).attr("width",p(xa,ea)),o.attr("x",ya(ea[0])).attr("width",p(ya,ea))},ka=function(a){var b;return!a||Fa?(k&&k.classed("hidden",!0),b||z.tooltip(null),void(b=null)):(k.classed("hidden",!1),k.attr("cx",xa(a[0])),k.attr("cy",function(b,c){return Ba(a[1][c])}),z.tooltip(a),l(),b=a)},ja=function(){var a;return a=null},Q=null,x=_.debounce(ka,10),w?w.call(cursorBrush):(G.on("mousemove",function(){var a;if(!A)return a=xa.invert(d3.mouse(this)[0]),a=_.find(Y,function(b){return b.timestamp>a}),null!=a?x([a.timestamp,a.value]):void 0}),G.on("mouseout",function(){return x(null)})),R=d3.svg.line().interpolate("monotone").x(function(a){return xa(a[0])}).y(function(a){return Ba(a[1])}),S=d3.svg.line().interpolate("monotone").x(function(a){return ya(a[0])}).y(function(a){return Ca(a[1])}),i=function(a){return ea=a,A?void 0:ba()},g=function(a){return W=a,A?void 0:ba()},h=function(a){return X=a,A?void 0:ba()},j=function(a){return A?void 0:fa(a)},A=!0,pa=function(a){var c,d;if(a.length)return Z=d3.extent(a.map(function(a){return a.timestamp})),d=(Z[1]-Z[0])/b/V,A&&(xa.domain(Z),ya.domain(Z),Ea.scaleExtent([1,d]),Ea.x(xa),f.extent(xa.domain()),s.call(f)),Ba.domain([0,d3.max(a.map(function(a){return d3.max(a.value)}))]).nice(),Ca.domain(Ba.domain()),c=d3.range(a[0].value.length).map(function(b,c){return a.map(function(a){return[a.timestamp,a.value[c]]})}),aa=E.selectAll("path").data(c),aa.enter().append("path").attr("class","focus-line"),aa.exit().remove(),$=u.selectAll("path").data(c),$.enter().append("path").attr("class","context-line"),$.exit().remove(),k=E.selectAll("circle").data(c),k.enter().append("circle").attr("class","tooltip-circle").attr("r",5),k.exit().remove(),v=c,Y=a,ba(!0),A=!1},P=null,m=function(a,b){return P===b?l():(z.note(a.value),P=b)},l=function(){return z.note(null),P=null},qa=function(){var a;return a=F.selectAll("path").data(W),a.enter().append("path").attr("class","note-item").attr("d",d3.svg.symbol().type("triangle-up").size(50)).attr("fill",function(a){return a.color}).on("click",m).append("title").text(function(a){return a.value}),a.attr("transform",function(a){return"translate("+xa(a.timestamp)+","+(Ba(0)-5)+")"}),a.exit().remove()},sa=function(a){var b;return b=xa(d3.select(a[0][1]).datum())-xa(d3.select(a[0][0]).datum()),a.each(function(a,c){var d;return d=d3.select(this).attr("transform",function(a){return"translate("+xa(a)+", -"+U.top+")"}),d.select("rect").attr("width",b).attr("height",N+U.top),d.select("text").attr("x",10).attr("y",20).style("text-anchor","start").text(function(a){return ma(a)})})},p=function(a,b){return a(b[1])-a(b[0])},T=function(a,b){return z.on(a,b)},e=null,J=function(a,b){return e||(e={},e.n=0,e.delay=_.delay(function(){var b;return b=null,b=e.n>1?[Z[0],na.offset(a,1)]:[a,na.offset(a,1)],i(b),z.select(b),e=null},300)),e.n+=1},ba=function(a){var b,c,d,e;switch(D.transition().duration(1e3).call(Da),D.selectAll("line").attr("x1",U.left),a?(aa.transition().duration(1e3).attr("d",R),$.transition().duration(1e3).attr("d",S)):(aa.attr("d",R),$.attr("d",S)),X.categories&&(aa.style("display",function(a,b){return X.categories[b].disabled?"none":""}).style("stroke",function(a,b){return X.categories[b].color}),$.style("display",function(a,b){return X.categories[b].disabled?"none":""}).style("stroke",function(a,b){return X.categories[b].color}),k.style("display",function(a,b){return X.categories[b].disabled?"none":""}).style("fill",function(a,b){return X.categories[b].color})),r.transition().duration(1e3).call(Aa).selectAll("text").attr("x",10).style("text-anchor","start"),va(),ra(),qa(),d=xa.domain(),oa){case"hours":e=d3.time.hours(d3.time.hour.offset(d[0],-1),d3.time.hour.offset(d[1],1));break;case"days":e=d3.time.days(d3.time.day.offset(d[0],-1),d3.time.day.offset(d[1],1));break;case"months":e=d3.time.months(d3.time.month.offset(d[0],-1),d3.time.month.offset(d[1],1));break;case"weeks":e=d3.time.mondays(d3.time.monday.offset(d[0],-1),d3.time.monday.offset(d[1],1))}return b=la.selectAll("g").data(e),c=b.enter().append("g"),c.append("rect").attr("class","box").on("click",J),c.append("line").attr("class","box-line").attr("x1",0).attr("x2",0).attr("y2",N+U.top),c.append("text").attr("class","no-selection"),b.transition().duration(1e3).call(sa),b.exit().remove(),x(Q)},{data:pa,notes:g,options:h,selection:i,visibleRange:j,on:T}}}.call(this),function(){}.call(this);