telegram-crawler/data/tsf.telegram.org/js/tchart.min.js
2021-04-24 12:28:52 +00:00

1 line
No EOL
84 KiB
JavaScript

window.Graph={render:function(t,i){var s=document.createElement("div");return s.className="tchart--wrapper",t.appendChild(s),new this.units.TChart({container:s,data:i})},units:{}},function(){var t=function(t,i,s,e){return{linear:function(t,i,s,e){return s*t/e+i},easeInOutQuad:function(t,i,s,e){return(t/=.5*e)<1?.5*s*t*t+i:-s/2*(--t*(t-2)-1)+i}}[e](s,t,i-t,1)},i=function(t){this.composer=t.composer,this.state=t.state,this.queue={},this.queueSize=0,this.step=this.step.bind(this)};i.prototype={add:function(t){for(var i,s,e,a=0,h=+new Date,o=this.queue;a<t.length;){if(!(i=o[(s=t[a]).prop])){if(s.end==s.state[s.prop]){s.cbEnd&&s.cbEnd(s.state),a++;continue}i={lastStart:1},o[s.prop]=i,this.queueSize++}e=h-i.lastStart,s.duration*=this.state.speed,s.delay*=this.state.speed,i.cbEnd=s.cbEnd,i.state=s.state,i.lastStart=h,i.start=s.state[s.prop],i.end=s.end,i.startDt=h+(s.delay||0),i.endDt=i.startDt+(s.duration||0)-(s.fixed?0:Math.max(s.duration-e,0)),i.tween=s.tween||"easeInOutQuad",i.speed=s.speed,i.group=s.group,a++}this.animFrame||(this.animFrame=requestAnimationFrame(this.step))},get:function(t){return this.queue[t]},step:function(){var i,s,e,a,h,o,n,r,d,l=[],p=+new Date,c={top:!1,bottom:!1};for(i in this.queue)e=p,a=(s=this.queue[i]).endDt-s.startDt,o=s.state[i],d=e<s.startDt,e<s.startDt?e=s.startDt:e>s.endDt&&(e=s.endDt),(n=(h=a?(e-s.startDt)/a:d?0:1)<1?"exp"==s.tween?o+(s.end-o)*s.speed:t(s.start,s.end,h,s.tween):s.end)!=o?(s.state[i]=n,c.top=c.top||s.group.top,c.bottom=c.bottom||s.group.bottom):n==s.end&&l.push(i);for(r=0;r<l.length;)this.queue[l[r]].cbEnd&&this.queue[l[r]].cbEnd(this.queue[l[r]].state),delete this.queue[l[r]],r++;this.queueSize-=l.length,this.composer.render(c),this.queueSize?this.animFrame=requestAnimationFrame(this.step):delete this.animFrame}},window.Graph.units.TAnimator=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,t.additional.mini&&(this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!0}))};i.prototype={onResize:function(){if(this.opts.additional.mini){var t=this.opts.settings.dpi,i=this.opts.additional.mini?this.opts.state.dims.mini:this.opts.state.dims.graph;this.$canvas.width=i.w*t,this.$canvas.height=i.h*t,this.cached=""}},setDarkMode:function(t){this.isDarkMode=t},render:function(){var i,s,e,a,h,o,n,r,d,l,p=this.opts,c=p.data.ys,m=p.state,g=p.additional.mini,u=g?m.xg1:m.x1,x=g?m.xg2:m.x2,v=p.settings,f=v["PADD"+(g?"_MINI_AREA":"")][0],y=v["PADD"+(g?"_MINI_AREA":"")][1],M=v["PADD"+(g?"_MINI_AREA":"")][2],T=v["PADD"+(g?"_MINI_AREA":"")][3],b=p.data.x,_=p.settings.dpi,w=g?this.ctx:this.opts.ctx,D=[],S=[],I=g?m.dims.mini:m.dims.graph,$=null==m.zoomMorph?0:m.zoomMorph,L=$,A=(m.zoomMode,c.length);if(g){var E=[I.w,I.h,m.xg1,m.xg2,this.isDarkMode,m.zoomMode,$];for(i=0;i<A;i++)E.push(m["om_"+i]),E.push(m["f_"+i]);if((E=E.join(","))==this.cached)return void this.opts.ctx.drawImage(this.$canvas,I.l*_,I.t*_);this.cached=E}h=(I.w-y-T)/(x-u),d=Math.floor(t.TUtils.getXIndex(b,u-T/h)),l=Math.ceil(t.TUtils.getXIndex(b,x+y/h)),h*=_,n=(T+(g?0:I.l))*_-u*h,hBottom=(I.h-M+(g?0:I.t))*_;var P=[],R=[],k=0,C=0,z=0,F=!1;for(i=0;i<A;i++)a=g?m["om_"+i]:m["o_"+i],F=F||m["f_"+i]<1,a<1&&a>0&&(k=a),a>0&&(P.push(i),R.push(a),1==a&&m["e_"+i]&&(C++,z=P.length-1));var Y=P.length;k=1==C?k:1,g?m.y1m:m.y1,g?m.y2m:m.y2;var X=t.TUtils.simplifyData("line",b,c,h,n,P,d,l,I.w-y-T);d=X.xInd1,l=X.xInd2;var H=X.x,U=X.ys,N=!1;for(s=d;s<=l;s++){for(D[s]=0,S[s]=0,i=0;i<Y;i++)S[s]+=(U[P[i]].y[s]||0)*R[i];0==S[s]&&(N=!0)}if((N||F)&&(w.fillStyle=this.isDarkMode?"#242f3e":"#fff",w.fillRect(0,0,I.w*_,I.h*_)),$>0&&!g){if(1==L&&(this.savedX1=u,this.savedX2=x),L<1){var B=this.opts.animator.get("x1"),G=this.opts.animator.get("x2");x1End=B?B.end:this.opts.state.x1,x2End=G?G.end:this.opts.state.x2;var O=t.TUtils.getXIndex(b,-1==this.opts.state.zoomDir?this.savedX1:x1End,!0),W=t.TUtils.getXIndex(b,-1==this.opts.state.zoomDir?this.savedX2:x2End,!0)}else O=t.TUtils.getXIndex(b,u,!0),W=t.TUtils.getXIndex(b,x,!0);W--;var j=Math.floor(O),V=Math.ceil(O),Z=Math.floor(W),q=Math.ceil(W),J=0,K=[];for(i=0;i<Y;i++){K[i]=0;var Q=c[P[i]].y;for(s=V;s<=Z;s++){var tt=(Q[s]||0)*R[i];K[i]+=tt,J+=tt}tt=(V-O)*(Q[j]||0)*R[i];K[i]+=tt,J+=tt;tt=(W-Z)*(Q[q]||0)*R[i];K[i]+=tt,J+=tt}var it=1==this.opts.state.zoomDir?Math.pow(Math.min(Math.max(L<.85?(L-.65)/.2:1-(L-.9)/.15,0),1),.8):this.prevElastic,st=2*Math.PI-Math.PI/(7-L)-Math.PI/8*it,et=st;1==this.opts.state.zoomDir?(L=Math.min(Math.max((L-.25)/.4,0),1),this.prevElastic=it):L=Math.min(Math.max(2.4*L-1.4,0),1);var at=[],ht=v.PIE_RADIUS*($<1?2.31:1)*_,ot=_*(I.w/2+I.l),nt=_*(I.h/2+I.t+2),rt=2*Math.PI*ht/_;for(i=0;i<Y;i++){var dt=K[i]/J;dt=dt||0;var lt=2*Math.PI*dt,pt=st-lt,ct=Math.round(dt*rt*(1/13));i==Y-1&&(pt=et-2*Math.PI);var mt=2*Math.PI*.1/rt,gt=c[P[i]];at.push({st:st+mt,ed:pt-mt,mid:st-lt/2-mt/2,additionalPoints:Math.max(ct,4),percentage:0==dt?0:Math.max(Math.round(100*dt),1),percentageText:0==dt?"":dt<.01?"<1%":Math.round(100*dt)+"%",ind:P[i],value:K[i],label:gt.label,color:this.isDarkMode?gt.colors_n[2]:gt.colors_d[2]}),st=pt}m.pieAngles=at}o=_*(I.h-f-M+(g?0:-4)),r=(I.h-M+(g?0:I.t))*_;var ut=0;for(i=0;i<A;i++)if((a=g?m["om_"+i]:m["o_"+i])>0){e=U[i].y;var xt=a*o;if(w.fillStyle=this.isDarkMode?c[i].colors_n[0]:c[i].colors_d[0],w.globalAlpha=.9*m["f_"+i]+.1,w.beginPath(),0!=$&&g){var vt=this.opts.data.mainPeriodLen*h;if(w.moveTo(H[l]*h+vt+n,hBottom-D[l]),i>0)for(w.lineTo(H[l]*h+n,hBottom-D[l]),s=l;s>=d+1;s--)w.lineTo(H[s]*h+n,hBottom-(D[s]+L*(D[s-1]-D[s]))+0),w.lineTo(H[s-1]*h+n,hBottom-D[s-1]+0);else w.lineTo(H[d]*h+n,hBottom);if(ut<Y-1)for(s=d;s<=l-1;s++){Tt=r-(e[s]*xt/S[s]||0),bt=hBottom-Tt;s==d&&w.lineTo(H[d]*h+n,hBottom-D[d]-bt);Tt=r-(e[s+1]*xt/S[s+1]||0);var ft=hBottom-Tt,yt=D[s]+bt,Mt=D[s+1]+ft;w.lineTo(H[s+1]*h+n,hBottom-(Mt+L*(yt-Mt))),w.lineTo(H[s+1]*h+n,hBottom-Mt),s==l-1&&w.lineTo(H[l]*h+vt+n,hBottom-D[l]-ft),D[s]+=bt}else w.lineTo(H[d]*h+n<<0,hBottom-o<<0),w.lineTo(H[l]*h+n<<0,hBottom-o<<0);D[l]+=ft}else if(0==$){if(i>0)for(w.moveTo(H[l]*h+n<<0,hBottom-D[l]+0<<0),s=l-1;s>=d;s--)w.lineTo(H[s]*h+n<<0,hBottom-D[s]+0<<0);else w.moveTo(H[l]*h+n<<0,hBottom<<0),w.lineTo(H[d]*h+n<<0,hBottom<<0);if(ut<Y-1||N)for(s=d;s<=l;s++){var Tt=r-(e[s]*xt/S[s]||0),bt=hBottom-Tt;(Gt=D[s]+bt)>o&&(Gt=o),w.lineTo(H[s]*h+n<<0,hBottom-Gt<<0),D[s]+=bt}else w.lineTo(H[d]*h+n<<0,hBottom-o<<0),w.lineTo(H[l]*h+n<<0,hBottom-o<<0)}else{var _t,wt,Dt,St=function(t,i,s,e){var a=0,h=0;At&&C>1&&(a=Math.cos(at[ut].mid)*At*8*_,h=-Math.sin(at[ut].mid)*At*8*_),e>ht&&(e=ht);var o=Math.atan2(nt-i,t-ot);o=o<0?2*Math.PI+o:o;var n=Math.pow((nt-i)*(nt-i)+(t-ot)*(t-ot),.5);Math.abs(s-o)>Math.PI*(1==Y?1.5:1)&&(s-=2*Math.PI),s<2*-Math.PI&&(s-=2*-Math.PI);var r=o+L*(s-o),d=n+L*(e-n);return[ot+Math.cos(r)*d+a,nt-Math.sin(r)*d+h]},It=$<1?4:at[ut].additionalPoints,$t=!1,Lt=!1,At=m["pieInd_"+P[ut]]||0;if(0==at[ut].percentage&&(w.globalAlpha=0),_t=St(H[l]*h+n,hBottom-D[l],at[0].st,ht),w.moveTo(_t[0],_t[1]),ut>0)for(s=l-1;s>=d;s--){if((Dt=H[s]*h+n)==ot&&($t=!0),Dt>=ot)wt=(Dt-ot)/(I.w*_/2),0==L&&(wt=0),_t=St(Dt,hBottom-D[s]+0,at[0].st,ht*wt);else{if(!$t){$t=!0;var Et=(ot-Dt)/(H[s+1]*h+n-Dt),Pt=hBottom-D[s]+0,Rt=hBottom-D[s+1]+0;_t=St(ot,Pt+Et*(Rt-Pt),at[ut].st,0),w.lineTo(_t[0],_t[1])}wt=(ot-Dt)/(I.w*_/2),_t=St(Dt,hBottom-D[s]+0,at[ut].st,ht*wt)}w.lineTo(_t[0],_t[1])}else _t=St(H[d]*h+n,hBottom,at[0].st,ht),w.lineTo(_t[0],_t[1]);if(ut<Y-1){for(s=0;s<=It;s++){var Tt=r-(e[d]*xt/S[d]||0),bt=hBottom-Tt;Pt=hBottom-D[d]+0,Rt=hBottom-D[d]-bt;_t=St(H[d]*h+n,Pt+s/It*(Rt-Pt),at[ut].st+s/It*(at[ut].ed-at[ut].st),ht),w.lineTo(_t[0],_t[1])}for(s=d;s<=l;s++){var Tt=r-(e[s]*xt/S[s]||0);bt=hBottom-Tt;if((Dt=H[s]*h+n)==ot&&(Lt=!0),Dt<=ot){wt=(ot-Dt)/(I.w*_/2);var kt=Dt,Ct=hBottom-D[s]-bt;_t=St(Dt,Ct,at[ut].ed,ht*wt)}else{if(!Lt){Lt=!0;Et=(ot-kt)/(Dt-kt),Pt=Ct,Rt=hBottom-D[s]-bt;_t=St(ot,Pt+Et*(Rt-Pt),at[ut].ed,0),w.lineTo(_t[0],_t[1])}wt=(Dt-ot)/(I.w*_/2),0==L&&(wt=0),_t=St(Dt,hBottom-D[s]-bt,at[0].st,ht*wt)}w.lineTo(_t[0],_t[1]),D[s]+=bt}Dt<ot&&(Lt||(_t=St(ot,Pt,at[ut].ed,0),w.lineTo(_t[0],_t[1])))}else for(s=0;s<=It;s++)_t=St((H[d]+s/It*(H[l]-H[d]))*h+n,0,at[ut].st+s/It*(at[0].st-2*Math.PI-at[ut].st),ht),w.lineTo(_t[0],_t[1])}if(w.closePath(),w.fill(),!g&&$>0&&at[ut].percentageText){var zt=Math.pow(L,1==this.opts.state.zoomDir?4:20)*a*(.9*m["f_"+i]+.1),Ft=Math.max(Math.min(2*at[ut].percentage,26),10),Yt=v.PIE_RADIUS,Xt=2*Yt/3,Ht=Math.cos(at[ut].mid),Ut=Math.sin(at[ut].mid),Nt=at[ut].percentage<p.data.pieLabelsPercentages.outboard,Bt=0,Gt=0;if(At&&C>1&&(Bt=Ht*At*8*_,Gt=-Ut*At*8*_),w.fillStyle="white",w.textAlign="center",w.globalAlpha=zt,at[ut].percentage<p.data.pieLabelsPercentages.hoverOnly&&(w.globalAlpha=At*zt),Nt){Xt=Yt+(Ft=Math.max(Ft,14))/3+13,w.fillStyle=this.isDarkMode?c[i].colors_n[0]:c[i].colors_d[0],w.lineWidth=1,w.strokeStyle=this.isDarkMode?c[i].colors_n[0]:c[i].colors_d[0];var Ot=ot+Bt+Ht*(Yt-1)*_,Wt=nt+Gt-Ut*(Yt-1)*_,jt=ot+Bt+Ht*(Yt+6*(1-At)-1)*_,Vt=nt+Gt-Ut*(Yt+6*(1-At)-1)*_;w.beginPath(),w.moveTo(Ot,Wt),w.lineTo(jt,Vt),w.stroke()}var Zt=Ht*Xt*(z==ut?k:1),qt=ot+Bt+Zt*_+(Nt?Ft/4*at[ut].percentageText.length*Zt/Xt*_:0),Jt=nt+Gt-Ut*Xt*(z==ut?k:1)*_;w.font="bold "+Ft*_+"px "+p.settings.FONTS,w.fillText(at[ut].percentageText,qt,Jt+Ft*_/2.9),w.globalAlpha=1}ut++}w.globalAlpha=1,g&&this.opts.ctx.drawImage(this.$canvas,I.l*_,I.t*_)}},t.TAreas=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.ctx=t.ctx,this.items={},this.setAnimation(!1),this.deleteItem=this.deleteItem.bind(this)};i.prototype={onResize:function(){this.setAnimation(!1)},setDarkMode:function(t){this.isDarkMode=t},setAnimation:function(t){this.noAnimation=!t},hideItem:function(t,i){this.items[t].tp=2,this.opts.animator.add([{prop:"ox_"+t,state:this.items[t].state,end:0,duration:this.noAnimation?0:200*i,tween:"linear",group:{top:!0},cbEnd:this.deleteItem}])},deleteItem:function(t){delete this.items[t.ind]},render:function(i){var s=this.opts,e=s.settings.dpi,a=s.data.x,h=s.state,o=s.settings.PADD[1],n=s.settings.PADD[3],r=s.animator,d=(a.length,this.opts.state.dims.axisX),l=this.opts.state.dims.dates,p=h.zoomMode,c=null==h.zoomMorph?0:h.zoomMorph,m=A=Math.floor(t.TUtils.getXIndex(a,h.x1)),g=E=Math.ceil(t.TUtils.getXIndex(a,h.x2)),u="bar"==s.graphStyle||"step"==s.graphStyle,x=9*(h.zoomMode&&s.data.details?s.data.details.maxXTickLength:s.data.maxXTickLength),v=u?this.opts.data.mainPeriodLen:0,f=u?this.opts.data.detailPeriodLen:0,y=v+(f-v)*c,M=v*(1-c),T=(d.w-o-n)/Math.round((h.x2-h.x1+v)/this.opts.data.mainPeriodLen),b=(d.w-o-n)/Math.round((h.x2-h.x1+f)/this.opts.data.detailPeriodLen),_=T+(b-T)*c,w=Math.pow(2,Math.ceil(Math.log2(x/T))),D=Math.pow(2,Math.ceil(Math.log2(x/b))),S=(d.w-n-o)/(h.x2-h.x1+M);w<1&&(w=1),D<1&&(D=1),this.ctx.font=11*e+"px "+s.settings.FONTS,this.ctx.textAlign="center",this.ctx.fillStyle=this.isDarkMode?this.opts.data.axis_n.x:this.opts.data.axis_d.x;var I=this.prevXStep?this.prevXStep>T?this.prevXStep/T:T/this.prevXStep:1,$=1/Math.pow(I,5);p&&1==c&&($/=2),this.prevXStep=T;var L,A=Math.max(A-Math.ceil((n+.5*x)/_),0),E=Math.min(E+Math.ceil((o+.5*x)/_),a.length-1);if(p){var P=this.opts.animator.get("x1"),R=this.opts.animator.get("x2");m=P?P.end:this.opts.state.x1,g=R?R.end:this.opts.state.x2,m=Math.floor(t.TUtils.getXIndex(a,m)),g=Math.floor(t.TUtils.getXIndex(a,g))}if(p)var k=Math.max(a[this.opts.state.detailInd1],this.opts.state.xMainMin),C=Math.min(a[this.opts.state.detailInd2],this.opts.state.xMainMax),z=Math.round((C-k)/this.opts.data.mainPeriodLen)+(u?0:1);for(var F=A;F<=E;F++){var Y=F%w==0,X="m";p&&(F<this.opts.state.detailInd1?Y=F%w==0&&c<1:F<=this.opts.state.detailInd2?(Y=Math.max(F-this.opts.state.detailInd1,0)%D==0,X="d"):Y=Math.max(F-(this.opts.state.detailInd2-this.opts.state.detailInd1+1-z),0)%w==0&&c<1);var H=a[F]+X,U=this.items[H];if(Y?U?2==U.tp&&(U.tp=1,r.add([{prop:"ox_"+H,state:U.state,end:1,duration:this.noAnimation?0:200*$,tween:"linear",group:{top:!0}}])):((U={tp:1,xi:a[F],i:F,state:{ind:H}}).state["ox_"+H]=0,this.items[H]=U,r.add([{prop:"ox_"+H,state:U.state,end:1,duration:this.noAnimation?0:200*$,tween:"linear",group:{top:!0}}])):U&&1==U.tp&&this.hideItem(H,$),U&&U.state["ox_"+H]>0){var N=(U.xi-h.x1+y/2)*S+n;if(this.ctx.globalAlpha=U.state["ox_"+H]*i,N+x/2>=d.l&&N-x/2<=d.l+d.w){var B=(N+d.l)*e;this.ctx.fillText(s.data.datesShort[F],B,(d.t+9)*e)}}}for(F in this.items){1==(U=this.items[F]).tp&&(U.xi<h.x1-n/S||U.xi>h.x2+o/S)&&this.hideItem(F,$)}this.ctx.globalAlpha=1,p&&1==c&&g--,g<m&&(g=m),L=s.data.datesRange[m]==s.data.datesRange[g]?s.data.datesRange[m]:s.data.datesRange[m]+" – "+s.data.datesRange[g];var G=13;d.w<375&&(G=11),this.ctx.font="bold "+G*e+"px "+s.settings.FONTS,this.ctx.textAlign="right",this.ctx.fillStyle=this.isDarkMode?"#fff":"#000",this.ctx.fillText(L,(l.l+l.w)*e,(l.t+l.h-7)*e)}},t.TAxisX=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.ctx=t.ctx,this.uuid=1,this.items={},this.setAnimation(!1),this.setForceUpdate(!1),this.deleteItem=this.deleteItem.bind(this)};i.prototype={onResize:function(){this.setAnimation(!1),this.setForceUpdate(!1)},setDarkMode:function(t){this.isDarkMode=t},setAnimation:function(t){this.noAnimation=!t},setForceUpdate:function(t){this.forceUpdate=t},deleteItem:function(t){delete this.items[t.id]},render:function(t){var i,s;this.opts.pairY?(i=this.calcAxisData("y1_0","y2_0"),(s=this.calcAxisData("y1_1","y2_1")).needAnimation&&!i.needAnimation||this.opts.state.o_0<1?this.updateAxisState("y1_1","y2_1","numRight",s,i,s):this.updateAxisState("y1_0","y2_0","numLeft",i,i,s)):(i=this.calcAxisData("y1","y2"),this.updateAxisState("y1","y2","numLeft",i,i,i)),this.renderState(t)},calcAxisData:function(t,i){var s=this.opts.state,e=this.opts.settings.PADD[0],a=this.opts.settings.PADD[2],h=(Math.floor(this.opts.settings.Y_AXIS_RANGE),!1),o=this.opts.animator.get(t),n=this.opts.animator.get(i),r=o?o.end:s[t],d=n?n.end:s[i],l=Math.round((d-r)/this.opts.settings.Y_AXIS_RANGE),p=r,c=s[i]-s[t],m=s[t]>r?s[t]/r:r/s[t],g=s[i]>d?s[i]/d:d/s[i],u=d-r,x=(this.opts.state.dims.axisYLines.h-e-a)/c,v=(this.opts.state.dims.axisYLines.h-e-a)/u;return(m>1.05||g>1.05||this.forceUpdate)&&(h=!0),{needAnimation:h=this.items[0]&&h&&!this.noAnimation&&!this.animationInProgress,y1:r,y2:d,yRealStep:l,yRealStart:p,yScaleCur:x,yScaleEnd:v}},updateAxisState:function(i,s,e,a,h,o){var n,r=this.opts,d=(r.settings,r.settings.dpi,r.state),l=(r.settings.PADD[0],r.settings.PADD[2]),p=(r.settings.PADD[3],r.settings.PADD[1],r.animator),c=Math.floor(r.settings.Y_AXIS_RANGE),m=!1,g=this.opts.state.dims.axisYLines;a.needAnimation&&(this.animationInProgress=!0);for(var u=0;u<=c;u++){var x=a.yRealStart+Math.round(a.yRealStep*u),v=h.yRealStart+Math.round(h.yRealStep*u),f=o.yRealStart+Math.round(o.yRealStep*u),y=t.TUtils.getFormatter("yTickFormatter",r.data,d.zoomMorph),M=y(v,h.yRealStep),T=y(Math.max(f,0),h.yRealStep,!0);if(a.needAnimation){var b=g.t+g.h-l-(x-a.y1)*a.yScaleEnd,_=g.t+g.h-l-(this.items[u][e]-a.y1)*a.yScaleEnd,w=g.t+g.h-l-(x-d[i])*a.yScaleCur,D=g.t+g.h-l-(x-a.y1)*a.yScaleEnd;Math.abs(_-D)<1?this.items[u]={numLeft:v,strLeft:M,numRight:f,strRight:T,y:D}:(m=!0,this.uuid++,(n={animated:!0,strLeft:this.items[u].strLeft,strRight:this.items[u].strRight,oProp:"oyt_"+this.uuid,yProp:"yyt_"+this.uuid,state:{id:"t_"+this.uuid}}).state[n.oProp]=1,n.state[n.yProp]=b,this.items[n.state.id]=n,p.add([{prop:n.oProp,state:n.state,end:0,duration:this.noAnimation?0:200,tween:"linear",group:{top:!0}},{prop:n.yProp,state:n.state,end:_,duration:this.noAnimation?0:this.forceUpdate?333:500,fixed:!this.forceUpdate,tween:this.forceUpdate?null:"exp",speed:.18,group:{top:!0},cbEnd:this.deleteItem}]),delete this.items[u],this.uuid++,(n={animated:!0,strLeft:M,strRight:T,oProp:"oy_"+u,yProp:"yy_"+u,state:{id:u,numLeft:v,strLeft:M,numRight:f,strRight:T}}).state[n.oProp]=0,n.state[n.yProp]=w,this.items[n.state.id]=n,p.add([{prop:n.oProp,state:n.state,end:1,duration:this.noAnimation?0:200,tween:"linear",group:{top:!0}},{prop:n.yProp,state:n.state,end:D,duration:this.noAnimation?0:this.forceUpdate?333:500,fixed:!this.forceUpdate,tween:this.forceUpdate?null:"exp",speed:.18,group:{top:!0},cbEnd:function(t){this.items[t.id]={numLeft:t.numLeft,strLeft:t.strLeft,numRight:t.numRight,strRight:t.strRight,y:t["yy_"+t.id]},clearTimeout(this.animationEndTimeout),this.animationEndTimeout=setTimeout(function(){this.animationInProgress=!1}.bind(this),30)}.bind(this)}]))}else this.items[u]&&this.items[u].animated?(this.items[u].numLeft=v,this.items[u].strLeft=M,this.items[u].numRight=f,this.items[u].strRight=T,this.items[u].state.numLeft=v,this.items[u].state.strLeft=M,this.items[u].state.numRight=f,this.items[u].state.strRight=T):this.items[u]={numLeft:v,strLeft:M,numRight:f,strRight:T,y:g.t+g.h-l-(x-a.y1)*a.yScaleEnd}}a.needAnimation&&!m&&(this.animationInProgress=!1),this.forceUpdate=!1},renderState:function(t){var i,s,e,a,h=this.opts.settings.dpi,o=this.opts.state.dims.axisYLeft,n=this.opts.state.dims.axisYRight,r=this.opts.state.dims.axisYLines,d=this.opts.data.ys;for(i in this.ctx.font=11*h+"px "+this.opts.settings.FONTS,this.ctx.strokeStyle=this.isDarkMode?"rgba(255, 255, 255, 0.1)":"rgba(24, 45, 59, 0.1)",this.ctx.lineWidth=1*h,this.ctx.lineCap="square",this.ctx.lineJoin="square",this.items)(a=this.items[i]).animated?(e=a.state[a.yProp],s=a.state[a.oProp]):(e=a.y,s=1),e-6>=0&&e-16<=o.h&&(this.ctx.globalAlpha=s*(this.opts.pairY?this.opts.state.o_0:1)*t,this.ctx.textAlign="left",this.opts.pairY?this.ctx.fillStyle=this.isDarkMode?d[0].colors_n[1]:d[0].colors_d[1]:this.ctx.fillStyle=this.isDarkMode?this.opts.data.axis_n.y:this.opts.data.axis_d.y,this.ctx.fillText(a.strLeft,o.l*h,(e-7)*h),this.opts.pairY&&(this.ctx.globalAlpha=s*this.opts.state.o_1*t,this.ctx.textAlign="right",this.ctx.fillStyle=this.isDarkMode?d[1].colors_n[1]:d[1].colors_d[1],this.ctx.fillText(a.strRight,(n.l+n.w)*h,(e-7)*h))),(e=(e<<0)-.5)>=0&&e<=o.h&&(this.ctx.beginPath(),this.ctx.globalAlpha=s*t,this.ctx.moveTo(r.l*h,e*h),this.ctx.lineTo((r.l+r.w)*h,e*h),this.ctx.stroke());this.ctx.globalAlpha=1}},t.TAxisY=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.filteredX1=[],this.filteredX2=[],this.filteredJ=[],this.prevY=[],this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!1})};i.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.additional.mini?this.opts.state.dims.mini:this.opts.state.dims.graph;this.$canvas.width=i.w*t,this.$canvas.height=i.h*t,this.cached=""},setDarkMode:function(t){this.isDarkMode=t},render:function(){var i,s,e,a,h,o,n,r,d,l,p,c,m,g,u=this.opts,x=u.data.ys,v=u.state,f=u.additional.mini,y=f?v.xg1:v.x1,M=f?v.xg2:v.x2,T=u.settings,b=(this.w,this.h,T["PADD"+(f?"_MINI_BAR":"")][0]),_=T["PADD"+(f?"_MINI_BAR":"")][1],w=T["PADD"+(f?"_MINI_BAR":"")][2],D=T["PADD"+(f?"_MINI_BAR":"")][3],S=u.data.x,I=u.settings.dpi,$=this.ctx,L=f?v.dims.mini:v.dims.graph,A=v.zoomMode,E=v.detailInd1,P=v.detailInd2,R=null==v.zoomMorph?0:v.zoomMorph,k=this.filteredX1,C=this.filteredX2,z=this.filteredJ,F=this.prevY,Y=x.length,X=[L.w,L.h,f?v.xg1:v.x1,f?v.xg2:v.x2,this.isDarkMode,A];for(f||(X.push(v.y1),X.push(v.y2)),i=0;i<Y;i++)X.push(f?v["om_"+i]:v["o_"+i]),X.push(v["f_"+i]);if((X=X.join(","))!=this.cached||(this.opts.ctx.drawImage(this.$canvas,L.l*I,L.t*I),!f)){n=(L.w-_-D)/(M-y+this.opts.data.mainPeriodLen*(1-R)),m=Math.floor(t.TUtils.getXIndex(S,y-D/n)),g=Math.ceil(t.TUtils.getXIndex(S,M+_/n)),A&&1==R&&(m<this.opts.state.xg1Ind&&(m=this.opts.state.xg1Ind),g>this.opts.state.xg2Ind&&(g=this.opts.state.xg2Ind-1)),d=D*I-y*(n*=I),p=(L.h-w)*I;var H=this.opts.data.mainPeriodLen*n,U=this.opts.data.detailPeriodLen*n;if(X!=this.cached){var N;$.fillStyle=this.isDarkMode?"#242f3e":"#fff",$.fillRect(0,0,L.w*I,L.h*I);var B=0;for(s=m;s<=g;s++){N=A&&s>=E&&s<=P?U:H;var G=Math.round(S[s]*n+d),O=Math.round(S[s]*n+d+N);O-G>0&&(k[B]=G,C[B]=O,z[B]=s,F[B]=0,B++)}for(i=0;i<Y;i++)if((a=f?v["om_"+i]:v["o_"+i])>0){e=x[i].y,c=x[i].yFrom,h=f?v.y1m:v.y1,o=f?v.y2m:v.y2,r=I*(L.h-b-w)/(o-h),l=(L.h-w)*I+h*r;var W,j=a*r;if($.fillStyle=this.isDarkMode?x[i].colors_n[0]:x[i].colors_d[0],$.globalAlpha=.9*v["f_"+i]+.1,$.beginPath(),$.moveTo(Math.round(S[g]*n+d+(1==R?U:H)),Math.round(p)),i>0)for(s=B-1;s>=0;s--){var V=p-F[s];$.lineTo(C[s],Math.round(V)),$.lineTo(k[s],Math.round(V))}else $.lineTo(Math.round(S[m]*n+d),Math.round(p));for(s=0;s<B;s++){var Z=z[s],q=p-(V=l-(W=(W=A?Z>=E&&Z<=P?c[Z]+R*(e[Z]-c[Z]):e[Z]+R*(e[E]-e[Z]):e[Z])||0)*j);F[s]+=q,$.lineTo(k[s],Math.round(p-F[s])),$.lineTo(C[s],Math.round(p-F[s]))}$.closePath(),$.fill()}$.globalAlpha=1,this.opts.ctx.drawImage(this.$canvas,L.l*I,L.t*I)}if(v.barInd>-1&&!f){this.opts.ctx.fillStyle=this.isDarkMode?"rgba(36, 47, 62, 0.5)":"rgba(255, 255, 255, 0.5)",this.opts.ctx.globalAlpha=v.barO,this.opts.ctx.fillRect(0,0,L.w*I,L.h*I);var J=0;for(i=0;i<Y;i++)if((a=v["o_"+i])>0){e=x[i].y,c=x[i].yFrom,h=v.y1,o=v.y2,r=I*(L.h-b-w)/(o-h),l=(L.h-w)*I+h*r;j=a*r;this.opts.ctx.fillStyle=this.isDarkMode?x[i].colors_n[0]:x[i].colors_d[0],this.opts.ctx.globalAlpha=.9*v["f_"+i]+.1,A?v.barInd>=E&&v.barInd<=P?(W=c[v.barInd]+R*(e[v.barInd]-c[v.barInd]),N=U):(N=H,W=e[v.barInd]+R*(e[E]-e[v.barInd])):(W=e[v.barInd],N=H);var K=p-(l-(W=W||0)*j)+J;this.opts.ctx.fillRect(Math.round(S[v.barInd]*n+d),Math.round(p-J+L.t*I),Math.max(Math.round(N),1),Math.round(J)-Math.round(K)),J=K}$.globalAlpha=1}this.cached=X}}},t.TBars=i}(),function(){var t=window.Graph.units,s=function(i){this.state={},this.state.masterVisibility=1,this.state.slaveVisibility=0,this.specialZoomTransition=void 0,this.darkMode=!!document.documentElement.classList.contains("dark");var s=(!!window.ActiveXObject&&+/msie\s(\d+)/i.exec(navigator.userAgent)[1]||NaN)<11,e=-1!=navigator.userAgent.indexOf("Trident/")&&(-1!=navigator.userAgent.indexOf("rv:")||-1!=navigator.appName.indexOf("Netscape"));this.settings={isIE:s||e,isEdge:/Edge\/\d./i.test(navigator.userAgent),dpi:Math.min(window.devicePixelRatio||1,2),Y_AXIS_RANGE:5.3,PADD:[20,16,20,16],PADD_MINI:[2,0,2,0],PADD_MINI_BAR:[0,0,0,0],PADD_MINI_AREA:[0,0,0,0],Y_LABELS_WIDTH:50,X_LABELS_HEIGHT:12,DATES_HEIGHT:18,DATES_WIDTH:300,MINI_GRAPH_HEIGHT:40,MINI_GRAPH_TOP:14,MINI_GRAPH_BOTTOM:2,FADE_HEIGHT:16,PIE_RADIUS:130,FONTS:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'},this.data={caption:i.data.title,detailsFunc:i.data.x_on_zoom,hasDetail:!!i.data.x_on_zoom,slave:i.slave,yTickFormatter:i.data.yTickFormatter,yTooltipFormatter:i.data.yTooltipFormatter,xTickFormatter:i.data.xTickFormatter,xTooltipFormatter:i.data.xTooltipFormatter,xRangeFormatter:i.data.xRangeFormatter,strokeWidth:i.data.strokeWidth||"auto",hidden:i.data.hidden||[],tooltipOnHover:!!i.data.tooltipOnHover,sideLegend:i.data.sideLegend||!1,pieZoomRange:i.data.pieZoomRange||6048e5,pieLabelsPercentages:{outboard:i.data.pieLabelsPercentages&&null!=i.data.pieLabelsPercentages.outboard?i.data.pieLabelsPercentages.outboard:5,hoverOnly:i.data.pieLabelsPercentages&&null!=i.data.pieLabelsPercentages.hoverOnly?i.data.pieLabelsPercentages.hoverOnly:2},subchart:{show:!i.data.subchart||null==i.data.subchart.show||i.data.subchart.show,defaultZoom:i.data.subchart&&i.data.subchart.defaultZoom}},i.data.y_scaled&&(this.pairY=!0),this.graphStyle="line";var a=this.settings;i.data.columns.forEach(function(s,e){var a=s.shift(),h=i.data.types[a];if("x"===h){this.data.x=s,this.state.xCount=s.length,this.state.x1=s[.75*s.length<<0],this.state.x2=s[s.length-1],this.state.xg1=s[0],this.state.xg2=s[s.length-1],this.state.xg1Ind=0,this.state.xg2Ind=s.length-1,this.state.xMainMin=s[0],this.state.xMainMax=s[this.state.xg2Ind],this.state.xgMin=s[0],this.state.xgMax=s[this.state.xg2Ind];var o=this.getDefaultZoom({x1:this.state.x1,x2:this.state.x2,xg1:this.state.xg1,xg2:this.state.xg2,default:this.data.subchart.defaultZoom});this.state.x1=o.x1,this.state.x2=o.x2,this.data.mainPeriodLen=this.data.x[1]-this.data.x[0],this.data.detailPeriodLen=this.data.mainPeriodLen,this.data.dates=[],this.data.datesShort=[],this.data.datesRange=[];var n=t.TUtils.getFormatter("xTooltipFormatter",this.data,0),r=t.TUtils.getFormatter("xTickFormatter",this.data,0),d=t.TUtils.getFormatter("xRangeFormatter",this.data,0),l=0;s.forEach(function(t,i){this.data.dates[i]=n(t,!1),this.data.datesShort[i]=r(t,!1),this.data.datesRange[i]=d(t,!1),this.data.datesShort[i].length>l&&(l=this.data.datesShort[i].length)}.bind(this)),this.data.maxXTickLength=l}if("x"!==h){this.data.ys=this.data.ys||[],this.data.yIds=this.data.yIds||{};var p=i.data.colors[a];this.data.ys.push({colors_d:[p,p,p],colors_n:[p,p,p],label:i.data.names[a],y:s,tp:h,id:a}),"line"==h||"step"==h?(this.data.axis_d={x:"#8E8E93",y:"#8E8E93"},this.data.axis_n={x:"rgba(163,177,194,0.6)",y:"rgba(163,177,194,0.6)"}):(this.data.axis_d={x:"rgba(37,37,41,0.5)",y:"rgba(37,37,41,0.5)"},this.data.axis_n={x:"rgba(163,177,194,0.6)",y:"rgba(236,242,248,0.5)"});var c=this.data.ys.length-1,m=-1==this.data.hidden.indexOf(a);this.data.yIds[a]=c,this.state["e_"+c]=m,this.state["o_"+c]=m?1:0,this.state["om_"+c]=m?1:0,this.state["pieInd_"+c]=0,this.state["f_"+c]=1,this.graphStyle=h}}.bind(this)),this.state.activeColumnsCount=this.data.ys.length,this.updateSpeed(),"area"==this.graphStyle&&(a.Y_AXIS_RANGE=4.06,this.data.hasDetail=!0);var h=this.reduceGlobalRange({});h.isReduced&&(this.state.x1=h.x1,this.state.x2=h.x2,this.state.xg1=h.xg1,this.state.xg2=h.xg2,this.state.xg1Ind=h.xg1Ind,this.state.xg2Ind=h.xg2Ind),this.onResize=this.onResize.bind(this),this.onSwitcherChange=this.onSwitcherChange.bind(this),this.onSwitcherEnter=this.onSwitcherEnter.bind(this),this.onSwitcherLeave=this.onSwitcherLeave.bind(this),this.onHandleMove=this.onHandleMove.bind(this),this.toggleZoom=this.toggleZoom.bind(this),this.createDOM(i.container),window.addEventListener("resize",this.onResize),document.addEventListener("darkmode",function(t){this.setDarkMode(!this.darkMode)}.bind(this),!1),document.addEventListener("chart-hide-tips",function(t){t.detail.except!=this&&this.tip.toggle(!1)}.bind(this),!1),this.opts=i,this.onResize(),this.darkMode&&this.setDarkMode(this.darkMode),window.matchMedia("(-webkit-min-device-pixel-ratio: 1), (min-resolution: 96dpi)").addListener(this.onResize),window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi)").addListener(this.onResize),window.matchMedia("(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)").addListener(this.onResize),window.matchMedia("(-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi)").addListener(this.onResize)};s.prototype={reduceGlobalRange:function(s){var e=null==s.x1?this.state.x1:s.x1,a=null==s.x2?this.state.x2:s.x2,h=null==s.xg1?this.state.xg1:s.xg1,o=null==s.xg2?this.state.xg2:s.xg2,n=s.useSaved?this.data.saved.x:this.data.x,r=Math.floor(t.TUtils.getXIndex(n,this.state.xgMin)),d=Math.ceil(t.TUtils.getXIndex(n,this.state.xgMax)),l=d,p=r,c=this.state.zoomMode?"bar"==this.graphStyle||"step"==this.graphStyle?1:2:0;if("area"==this.graphStyle&&(c=0),this.data.ys.forEach(function(t,e){var a=s.useSaved?this.data.saved.y[e]:t.y;if(this.state["e_"+e])for(i=r;i<=d-c;i++)v=a[i],null!=v&&(l=Math.min(l,i),p=Math.max(p,i))}.bind(this)),p+c==d&&(p=d-Math.max(c-1,0)),l>=p)return{isReduced:!1};var m=n[l],g=n[p];return h==m&&o==g?{isReduced:!1}:(a>g?(e=g-(a-e),a=g,e<m&&(e=m)):e<m&&(a=m+(a-e),e=m,a>g&&(a=g)),{isReduced:!0,x1:e,x2:a,xg1:m,xg2:g,xg1Ind:l,xg2Ind:p})},getDefaultZoom:function(t){if(!t.default)return{x1:t.x1,x2:t.x2};var i={};return i.x1=t.default[0],i.x2=t.default[1],i.x1=Math.max(i.x1,t.xg1),i.x2=Math.min(i.x2,t.xg2),i.x1>=i.x2&&(i.x1=t.xg1,i.x2=t.xg2),i},updateSpeed:function(t){var i=this.state.activeColumnsCount*this.state.xCount*Math.pow((this.state.x2-this.state.x1)/(this.state.xMainMax-this.state.xMainMin),.5),s=this.state.deviceSpeed*i/16.66<<0,e=Math.max(1-.25*s,0);return e=Math.pow(e,.85),null==this.state.deviceSpeed&&(t=1),t=1,this.state.speed=null==t?e:t,this.state.speed},getYMinMax:function(i,s,e,a,h){if("area"==this.graphStyle)return{min:0,max:102};var o,n,r,d,l,p,c=this.state.dims?this.state.dims.graph.w:this.getGraphWidth(this.data.sideLegend).width,m=Number.MAX_VALUE,g=-Number.MAX_VALUE,u=(s-i)/c,x=t.TUtils.getXIndex(h?this.data.saved.x:this.data.x,i-u*this.settings.PADD[3]),v=t.TUtils.getXIndex(h?this.data.saved.x:this.data.x,s+u*this.settings.PADD[1]),f=[],y=[],M=this.settings,T=this.state;!h&&this.state.zoomMode?(x=Math.max(x,this.state.detailInd1),v=Math.min(v,this.state.detailInd2)):(x=Math.max(x,0),v=Math.min(v,this.data.x.length-1));var b=Math.floor(x),_=Math.ceil(x),w=Math.floor(v),D=Math.ceil(v);if("line"!=this.graphStyle&&"step"!=this.graphStyle||this.data.ys.forEach(function(t,i){var s=h?this.data.saved.y[i]:t.y,e="step"==this.graphStyle?b:_,a="step"==this.graphStyle?D:w;if(T["e_"+i]||0==i&&this.pairY){for(o=e;o<=a;o++)void 0!==(n=s[o])&&(n<m&&(m=n),n>g&&(g=n));"line"==this.graphStyle&&(void 0!==s[b]&&void 0!==s[_]&&((r=s[b]+(x-b)*(s[_]-s[b]))<m&&(m=r),r>g&&(g=r)),void 0!==s[w]&&void 0!==s[D]&&((d=s[w]+(v-w)*(s[D]-s[w]))<m&&(m=d),d>g&&(g=d)))}if(this.pairY){var l=L(m,g,i,p);f[i]=l.min,y[i]=l.max,m=Number.MAX_VALUE,g=-Number.MAX_VALUE,p=l.range}}.bind(this)),"bar"==this.graphStyle){var S=[];for(l=0;l<this.data.ys.length;l++)T["e_"+l]&&S.push(l);var I=S.length;for(o=b;o<=D;o++){for(yCur=0,l=0;l<I;l++)yCur+=(h?this.data.saved.y[S[l]][o]:this.data.ys[S[l]].y[o])||0;yCur>g&&(g=yCur)}m=0}if(this.pairY)return isNaN(f[0])&&(f[0]=f[1]),isNaN(f[1])&&(f[1]=f[0]),isNaN(y[0])&&(y[0]=y[1]),isNaN(y[1])&&(y[1]=y[0]),{min:f,max:y};var $=L(m,g);return{min:$.min,max:$.max};function L(i,s,h,o){if(i==Number.MAX_VALUE)e?null==h?(i=T.y1m,s=T.y2m):(i=T["y1m_"+h],s=T["y2m_"+h]):null==h?(i=T.y1,s=T.y2):(i=T["y1_"+h],s=T["y2_"+h]);else if("bar"==this.graphStyle&&(i=0),i=Math.floor(i),s=Math.ceil(s),a){var n=t.TUtils.roundRange(i,s,M.Y_AXIS_RANGE,o);i=n.yMin,s=n.yMax}return{min:i,max:s,range:n}}},setDarkMode:function(t){this.darkMode=t,this.graph.setDarkMode(t),this.axisY.setDarkMode(t),this.fade.setDarkMode(t),this.axisX.setDarkMode(t),this.mini.setDarkMode(t),this.handle.setDarkMode(t),this.tip.setDarkMode(t),this.switchers.setDarkMode(t),this.composer.setDarkMode(t)},getGraphWidth:function(t){var i=this.$el.getBoundingClientRect();if(t){var s=this.$switchers.getBoundingClientRect();return i.width-s.width>=500?{hasSpaceForLegend:!0,width:Math.max(i.width-s.width,1)}:{hasSpaceForLegend:!1,width:i.width}}return{width:i.width}},onResize:function(){var t=Math.min(window.devicePixelRatio||1,2);if(this.ww!=window.innerWidth||t!=this.settings.dpi){if(this.settings.dpi=t,this.ww=window.innerWidth,this.data.sideLegend){this.$switchers.classList.remove("tchart--switchers__no-space");var i=this.getGraphWidth(!0);i.hasSpaceForLegend?this.$graph.style.width=i.width+"px":(this.$switchers.classList.add("tchart--switchers__no-space"),this.$graph.style.width=i.width+"px")}var s=this.$graph.getBoundingClientRect(),e=this.settings,a=s.height-e.DATES_HEIGHT-e.MINI_GRAPH_HEIGHT-e.MINI_GRAPH_TOP-e.MINI_GRAPH_BOTTOM;this.state.dims={composer:{w:s.width,h:s.height,l:0,t:0},graph:{w:s.width,h:a,l:0,t:e.DATES_HEIGHT},axisYLeft:{w:e.Y_LABELS_WIDTH,h:a,l:e.PADD[3],t:e.DATES_HEIGHT},axisYRight:{w:e.Y_LABELS_WIDTH,h:a,l:s.width-e.PADD[1]-e.Y_LABELS_WIDTH,t:e.DATES_HEIGHT},axisYLines:{w:s.width-e.PADD[1]-e.PADD[3],h:a,l:e.PADD[3],t:e.DATES_HEIGHT},fadeTop:{w:s.width,h:e.FADE_HEIGHT,l:0,t:e.DATES_HEIGHT},fadeBottom:{w:s.width,h:e.FADE_HEIGHT,l:0,t:e.DATES_HEIGHT+a-e.FADE_HEIGHT},axisX:{w:s.width,h:e.X_LABELS_HEIGHT,l:0,t:e.DATES_HEIGHT+a-e.X_LABELS_HEIGHT},dates:{w:e.DATES_WIDTH,h:e.DATES_HEIGHT,l:s.width-e.DATES_WIDTH-e.PADD[1],t:0},mini:{w:s.width-e.PADD[1]-e.PADD[3],h:e.MINI_GRAPH_HEIGHT,l:e.PADD[3],t:e.DATES_HEIGHT+a+e.MINI_GRAPH_TOP},handle:{w:s.width-e.PADD[1]-e.PADD[3],h:e.MINI_GRAPH_HEIGHT+2,l:e.PADD[3],t:e.DATES_HEIGHT+a+e.MINI_GRAPH_TOP-1},tip:{w:s.width,h:a,l:0,t:e.DATES_HEIGHT}},this.graph.onResize(),this.axisY.onResize(),this.fade.onResize(),this.axisX.onResize(),this.mini.onResize(),this.handle.onResize(),this.tip.onResize(),this.composer.onResize()}},createDOM:function(i){var s,e,a,h=this.settings;this.$el=document.createElement("div"),this.$el.className="tchart",this.data.subchart.show||this.$el.classList.add("tchart__no-subchart"),this.data.slave&&this.$el.classList.add("tchart__slave"),this.$h1=document.createElement("h1"),this.$h1.className="tchart--header",this.$h1.textContent=this.data.caption,this.$el.appendChild(this.$h1),this.$zoom=document.createElement("div"),this.$zoom.className="tchart--zoom",this.$el.appendChild(this.$zoom);var o=document.createElement("div");this.$zoom.appendChild(o);var n=document.createElement("span");if(n.textContent="Zoom Out",this.$zoom.appendChild(n),this.$zoom.addEventListener("click",function(){this.toggleZoom(!1)}.bind(this)),this.$graph=document.createElement("div"),this.$graph.className="tchart--graph",this.$el.appendChild(this.$graph),this.$switchers=document.createElement("div"),this.$switchers.className="tchart--switchers",this.data.sideLegend&&this.$switchers.classList.add("tchart--switchers__side-legend"),this.$el.appendChild(this.$switchers),i.appendChild(this.$el),s=this.getYMinMax(this.state.x1,this.state.x2,!1,!0),e=this.getYMinMax(this.state.xg1,this.state.xg2,!0),this.pairY)for(a=0;a<this.data.ys.length;a++)this.state["y1_"+a]=s.min[a],this.state["y2_"+a]=s.max[a],this.state["y1m_"+a]=e.min[a],this.state["y2m_"+a]=e.max[a];else this.state.y1=s.min,this.state.y2=s.max,this.state.y1m=e.min,this.state.y2m=e.max;this.composer=new t.TComposer({$parent:this.$graph,settings:h,chart:this,state:this.state,data:this.data,graphStyle:this.graphStyle}),this.animator=new t.TAnimator({state:this.state,composer:this.composer});var r={line:"TLines",step:"TLines",bar:"TBars",area:"TAreas"};[["graph",r[this.graphStyle],this.$graph],["axisX","TAxisX",this.$graph],["fade","TFade",this.$graph],["axisY","TAxisY",this.$graph],["tip","TTip",this.$graph,{onClick:this.toggleZoom}],["mini",r[this.graphStyle],this.$graph,{mini:!0}],["handle","THandle",this.$graph,{cb:this.onHandleMove}],["switchers","TSwitchers",this.$switchers,{onClick:this.onSwitcherChange,onLongTap:this.onSwitcherChange,onEnter:this.onSwitcherEnter,onLeave:this.onSwitcherLeave}]].forEach(function(i){this[i[0]]=new t[i[1]]({animator:this.animator,$canvas:this.composer.$canvas,ctx:this.composer.ctx,graphStyle:this.graphStyle,chart:this,pairY:this.pairY,state:this.state,data:this.data,$parent:i[2],settings:h,additional:i[3]||{}}),this[i[0]].id=i[0]}.bind(this))},onHandleMove:function(s,e,a,h){this.state.zoomMode;this.updateSpeed();var o=[],n=this.getYMinMax(s,e,!1,!0);for(this.axisX.setAnimation("both"!=a),this.axisY.setAnimation(!0),this.axisY.setForceUpdate(!1),h&&t.TUtils.triggerEvent("chart-hide-tips",{except:null}),o.push({prop:"x1",state:this.state,end:s,fixed:!0,duration:0,group:{top:!0,bottom:!0}}),o.push({prop:"x2",state:this.state,end:e,fixed:!0,duration:0,group:{top:!0,bottom:!0}}),i=0;i<this.data.ys.length;i++)"line"!=this.graphStyle&&"step"!=this.graphStyle||o.push({prop:this.pairY?"y1_"+i:"y1",state:this.state,end:this.pairY?n.min[i]:n.min,duration:500,fixed:!0,tween:"exp",speed:.25,group:{top:!0}}),"area"!=this.graphStyle&&o.push({prop:this.pairY?"y2_"+i:"y2",state:this.state,end:this.pairY?n.max[i]:n.max,duration:500,fixed:!0,tween:"exp",speed:.25,group:{top:!0}});this.animator.add(o)},onSwitcherEnter:function(t){clearTimeout(this.switcherLeaveTimeout);var s=[];for(i=0;i<this.data.ys.length;i++)s.push({prop:"f_"+i,state:this.state,end:t==i?1:0,duration:300,tween:"exp",speed:.15,group:{top:!0,bottom:!0}}),s.push({prop:"pieInd_"+i,state:this.state,end:t==i?1:0,duration:300,tween:"exp",speed:.15,group:{top:!0,bottom:!0}});this.animator.add(s)},onSwitcherLeave:function(t){clearTimeout(this.switcherLeaveTimeout),this.switcherLeaveTimeout=setTimeout(function(){var t=[];for(i=0;i<this.data.ys.length;i++)t.push({prop:"f_"+i,state:this.state,end:1,duration:300,tween:"exp",speed:.15,group:{top:!0,bottom:!0}}),t.push({prop:"pieInd_"+i,state:this.state,end:0,duration:300,tween:"exp",speed:.15,group:{top:!0,bottom:!0}});this.animator.add(t)}.bind(this),300)},onSwitcherChange:function(i,s){var e,a,h,o,n,r,d=[],l=[],p=[];if(this.updateSpeed(),"boolean"!=typeof i)for(n=!0,s=i,r=!0,h=0;h<this.data.ys.length;h++)r=r&&(h==s?this.state["e_"+h]:!this.state["e_"+h]);var c=0;for(h=0;h<this.data.ys.length;h++)o=h==s,p[h]=this.state["e_"+h],n?this.state["e_"+h]=o:o&&(this.state["e_"+h]=!!i),r&&n&&(this.state["e_"+h]=!0),l[h]=this.state["e_"+h],l[h]&&(c=Math.max(c,this.data.ys[h].y.length));var m=this.reduceGlobalRange({});for(m.isReduced?(d.push({prop:"x1",state:this.state,end:m.x1,duration:333,group:{top:!0,bottom:!0}}),d.push({prop:"x2",state:this.state,end:m.x2,duration:333,group:{top:!0,bottom:!0}}),d.push({prop:"xg1",state:this.state,end:m.xg1,duration:333,group:{top:!0,bottom:!0}}),d.push({prop:"xg2",state:this.state,end:m.xg2,duration:333,group:{top:!0,bottom:!0}}),this.state.xg1Ind=m.xg1Ind,this.state.xg2Ind=m.xg2Ind,e=this.getYMinMax(m.x1,m.x2,!1,!0),a=this.getYMinMax(m.xg1,m.xg2,!0)):(e=this.getYMinMax(this.state.x1,this.state.x2,!1,!0),a=this.getYMinMax(this.state.xg1,this.state.xg2,!0)),t.TUtils.triggerEvent("chart-hide-tips",{except:null}),this.axisY.setForceUpdate(!0),this.axisY.setAnimation(!0),this.state.activeColumnsCount=0,h=0;h<l.length;h++)l[h]&&this.state.activeColumnsCount++,p[h]!=l[h]&&(d.push({prop:"o_"+h,state:this.state,end:l[h]?1:0,duration:300,group:{top:!0}}),d.push({prop:"om_"+h,state:this.state,end:l[h]?1:0,duration:"line"==this.graphStyle||"step"==this.graphStyle?166:300,delay:l[h]&&"line"==this.graphStyle||"step"==this.graphStyle?200:0,tween:"linear",group:{bottom:!0}}));for(h=0;h<(this.pairY?l.length:1);h++)"line"!=this.graphStyle&&"step"!=this.graphStyle||d.push({prop:this.pairY?"y1_"+h:"y1",state:this.state,end:this.pairY?e.min[h]:e.min,duration:this.pairY?0:333,group:{top:!0}}),"area"!=this.graphStyle&&d.push({prop:this.pairY?"y2_"+h:"y2",state:this.state,end:this.pairY?e.max[h]:e.max,duration:this.pairY?0:333,group:{top:!0}}),"line"!=this.graphStyle&&"step"!=this.graphStyle||d.push({prop:this.pairY?"y1m_"+h:"y1m",state:this.state,end:this.pairY?a.min[h]:a.min,duration:this.pairY?0:316,group:{bottom:!0}}),"area"!=this.graphStyle&&d.push({prop:this.pairY?"y2m_"+h:"y2m",state:this.state,end:this.pairY?a.max[h]:a.max,duration:this.pairY?0:316,group:{bottom:!0}});this.state.y1m_hidd=this.state.y1m,this.state.y2m_hidd=this.state.y2m,this.state.y1m_show=a.min,this.state.y2m_show=a.max,this.switchers.render(l),this.animator.add(d)},toggleSlave:function(i,s,e,a){var h=[];if(this.updateSpeed(a),this.state.zoomModeSlave!=i){if(this.state.zoomSpecialOrigin=s,i){this.state.zoomModeSlave=!0,this.switchers.switchers.forEach(function(t,i){t.classList.add("tchart--switcher__visible"),t.getElementsByTagName("span")[0].textContent=e.names[i]}),this.tip.labels.forEach(function(t,i){t.$label.textContent=e.names[i]}),this.data.x=e.x;for(var o=[],n=0;n<e.y.length;n++){this.data.ys[n].y=e.y[n];var r=-1==e.hidden.indexOf(this.data.ys[n].id);this.state["e_"+n]=r,this.state["o_"+n]=r?1:0,this.state["om_"+n]=r?1:0,o[n]=r}this.switchers.render(o);var d=this.data.x[0],l=this.data.x[this.data.x.length-1];this.data.dates=[],this.data.datesShort=[],this.data.datesRange=[];var p=t.TUtils.getFormatter("xTooltipFormatter",this.data,1),c=t.TUtils.getFormatter("xTickFormatter",this.data,1),m=t.TUtils.getFormatter("xRangeFormatter",this.data,1),g=0;for(n=0;n<this.data.x.length;n++)this.data.dates[n]=p(this.data.x[n],!0),this.data.datesShort[n]=c(this.data.x[n],!0),this.data.datesRange[n]=m(this.data.x[n],!0),this.data.datesShort[n].length>g&&(g=this.data.datesShort[n].length);this.data.maxXTickLength=g,this.data.subchart=e.subchart,this.data.hidden=e.hidden;var u=this.getDefaultZoom({x1:d,x2:l,xg1:d,xg2:l,default:this.data.subchart.defaultZoom});this.state.x1=u.x1,this.state.x2=u.x2,this.state.xCount=this.data.x.length,this.state.xg1=d,this.state.xg2=l,this.state.xg1Ind=0,this.state.xg2Ind=this.data.x.length-1,this.state.xMainMin=d,this.state.xMainMax=l,this.state.xgMin=d,this.state.xgMax=l;var x=this.reduceGlobalRange({});x.isReduced&&(this.state.x1=x.x1,this.state.x2=x.x2,this.state.xg1=x.xg1,this.state.xg2=x.xg2,this.state.xg1Ind=x.xg1Ind,this.state.xg2Ind=x.xg2Ind);var v=this.getYMinMax(this.state.x1,this.state.x2,!1,!0),f=this.getYMinMax(d,l,!0);this.state.y1=v.min,this.state.y2=v.max,this.state.y1m=f.min,this.state.y2m=f.max}else this.switchers.switchers.forEach(function(t,i){t.classList.remove("tchart--switcher__visible")});setTimeout(function(){i||(this.state.zoomModeSlave=!1)}.bind(this),470),this.state.slaveVisibility=i?0:1,h.push({prop:"slaveVisibility",state:this.state,end:i?1:0,duration:450,group:{top:!0,bottom:!0}}),this.animator.add(h)}},toggleZoomSpecial:function(t,i,s){var e=[];if(this.state.zoomModeSpecial!=t){var a=this.updateSpeed();if(t){var h=(this.state.x2-this.state.x1)/(this.state.dims.graph.w-this.settings.PADD[3]-this.settings.PADD[1]),o=this.settings.PADD[3]*h,n=this.settings.PADD[1]*h;this.state.zoomSpecialOrigin=(i-this.state.x1+o)/(this.state.x2-this.state.x1+o+n),this.state.zoomModeSpecial=!0,this.$h1.classList.add("tchart--header__hidden"),this.$zoom.classList.add("tchart--zoom__visible"),this.switchers.switchers.forEach(function(t,i){t.classList.remove("tchart--switcher__visible")}),this.slaveChart.toggleSlave(!0,this.state.zoomSpecialOrigin,s,a)}else this.$h1.classList.remove("tchart--header__hidden"),this.$zoom.classList.remove("tchart--zoom__visible"),this.switchers.switchers.forEach(function(t,i){t.classList.add("tchart--switcher__visible")}),this.slaveChart.toggleSlave(!1,this.state.zoomSpecialOrigin,null,a);document.body.style.pointerEvents="none",setTimeout(function(){t||(this.state.zoomModeSpecial=!1),document.body.style.pointerEvents=""}.bind(this),470),this.state.masterVisibility=t?1:0,e.push({prop:"masterVisibility",state:this.state,end:t?0:1,duration:450,group:{top:!0,bottom:!0}}),this.animator.add(e)}},toggleZoom:function(i,s,e){if(e&&null==this.specialZoomTransition&&(e.columns.length!=this.data.ys.length+1&&(this.specialZoomTransition=!0),this.specialZoomTransition||e.columns.forEach(function(t,i){var s=t[0],a=e.types[s],h=e.names[s];if(null!=(i=this.data.yIds[s])){var o=this.data.ys[i].tp,n=this.data.ys[i].label;o==a&&n==h||(this.specialZoomTransition=!0)}else"x"!==s&&(this.specialZoomTransition=!0)}.bind(this)),null==this.specialZoomTransition&&(this.specialZoomTransition=!1)),this.specialZoomTransition&&(this.data.master=!0,this.$el.classList.add("tchart__master"),!this.slaveChart)){var a=JSON.parse(JSON.stringify(e));a.yTickFormatter=e.yTickFormatter,a.yTooltipFormatter=e.yTooltipFormatter,a.xTickFormatter=e.xTickFormatter,a.xTooltipFormatter=e.xTooltipFormatter,a.xRangeFormatter=e.xRangeFormatter,a.sideLegend=this.data.sideLegend,this.slaveChart=new t.TChart({container:this.opts.container,slave:!0,data:a}),this.slaveChart.setDarkMode(this.darkMode)}if(e&&!e.details&&(e.details={y:[],names:[]},e.columns.forEach(function(t,i){var s=t.shift(),a=e.types[s],h=e.names[s];"x"===a?e.details.x=t:this.specialZoomTransition?(e.details.y.push(t),e.details.names.push(h)):e.details.y[this.data.yIds[s]]=t}.bind(this))),e&&(e.subchart={show:!e.subchart||null==e.subchart.show||e.subchart.show,defaultZoom:e.subchart&&e.subchart.defaultZoom},e.details.subchart=e.subchart,e.details.hidden=e.hidden||[]),this.specialZoomTransition)this.toggleZoomSpecial(i,s,e&&e.details);else{var h,o,n,r=e&&e.details,d=[];if(this.state.zoomMode!=i){if(i){if(this.state.zoomMode=!0,this.state.zoomDir=1,this.$h1.classList.add("tchart--header__hidden"),this.$zoom.classList.add("tchart--zoom__visible"),this.zoomEnterSpeed=this.updateSpeed(),e&&(this.data.details={yTickFormatter:e.yTickFormatter,yTooltipFormatter:e.yTooltipFormatter,xTickFormatter:e.xTickFormatter,xTooltipFormatter:e.xTooltipFormatter,xRangeFormatter:e.xRangeFormatter,subchart:e.subchart,hidden:e.hidden||[]}),!this.hasSavedData){for(this.data.saved={},this.data.saved.x=this.data.x.slice(),this.data.saved.dates=this.data.dates.slice(),this.data.saved.datesShort=this.data.datesShort.slice(),this.data.saved.datesRange=this.data.datesRange.slice(),this.data.saved.y=[],j=0;j<this.data.ys.length;j++)this.data.saved.y[j]=this.data.ys[j].y.slice();this.hasSavedData=!0}this.data.details&&this.data.details.subchart&&(this.data.details.subchart.show?this.$el.classList.remove("tchart__no-subchart"):this.$el.classList.add("tchart__no-subchart")),this.state.zoomSaved={x1:this.state.x1,x2:this.state.x2,xg1:this.state.xg1,xg2:this.state.xg2,xgMin:this.state.xgMin,xgMax:this.state.xgMax};var l,p,c=this.data.mainPeriodLen,m=s,g=s+c;if(this.data.details){var u=this.getDefaultZoom({x1:m,x2:g,xg1:r.x[0],xg2:r.x[r.x.length-1],default:this.data.details.subchart.defaultZoom});m=u.x1,g=u.x2}if("area"!=this.graphStyle)this.data.detailPeriodLen=r.x[1]-r.x[0],l=r.x[0],p=r.x[r.x.length-1];else{this.data.detailPeriodLen=c;var x=this.data.pieZoomRange;p=(l=m-(x-c)/2)+x,g=m+Math.round(x/7/c)*c,l<this.data.x[0]?(p=(l=this.data.x[0])+x)>this.data.x[this.data.x.length-1]&&(p=this.data.x[this.data.x.length-1]+c):p>this.data.x[this.data.x.length-1]&&(l=(p=this.data.x[this.data.x.length-1]+c)-x)<this.data.x[0]&&(l=this.data.x[0])}l=Math.round(l/c)*c,p=Math.round(p/c)*c,"area"!=this.graphStyle&&this.insertDetails(l,p,r),this.state.xgMin=l,this.state.xgMax=p}else this.updateSpeed(this.zoomEnterSpeed/("area"==this.graphStyle?2:1)),this.$h1.classList.remove("tchart--header__hidden"),this.$zoom.classList.remove("tchart--zoom__visible"),this.data.details&&(this.data.subchart.show?this.$el.classList.remove("tchart__no-subchart"):this.$el.classList.add("tchart__no-subchart")),this.state.zoomDir=-1,m=this.state.zoomSaved.x1,g=this.state.zoomSaved.x2,l=this.state.zoomSaved.xg1,p=this.state.zoomSaved.xg2,this.state.xgMin=this.state.zoomSaved.xgMin,this.state.xgMax=this.state.zoomSaved.xgMax;this.axisY.setForceUpdate(!0),this.axisY.setAnimation(!0),this.axisX.setAnimation(!0);var v=450,f=0,y=0;"area"==this.graphStyle&&(v=350,i?y=.95*v:f=.95*v);var M=this.reduceGlobalRange({x1:m,x2:g,xg1:l,xg2:p,useSaved:!i});for(M.isReduced&&(m=M.x1,g=M.x2,l=M.xg1,p=M.xg2),this.state.xg1Ind=Math.floor(t.TUtils.getXIndex(i?this.data.x:this.data.saved.x,l)),this.state.xg2Ind=Math.ceil(t.TUtils.getXIndex(i?this.data.x:this.data.saved.x,p)),h=this.getYMinMax(m,g,!1,!0,!i),o=this.getYMinMax(l,p,!0,!1,!i),document.body.style.pointerEvents="none",setTimeout(function(){i||(this.state.zoomMode=!1,"area"!=this.graphStyle&&this.revertDetails()),document.body.style.pointerEvents="",this.composer.render({top:!0,bottom:!0})}.bind(this),v+20+("area"==this.graphStyle?.9*v:0)),this.state.zoomMorph=i?0:1,d.push({prop:"zoomMorph",state:this.state,end:i?1:0,duration:v,delay:y,group:{top:!0,bottom:!0}}),d.push({prop:"x1",state:this.state,end:m,delay:f,duration:v,group:{top:!0,bottom:!0}}),d.push({prop:"x2",state:this.state,end:g,delay:f,duration:v,group:{top:!0,bottom:!0}}),d.push({prop:"xg1",state:this.state,end:l,delay:f,duration:v,group:{top:!0,bottom:!0}}),d.push({prop:"xg2",state:this.state,end:p,delay:f,duration:v,group:{top:!0,bottom:!0}}),n=0;n<(this.pairY?this.data.ys.length:1);n++)"line"!=this.graphStyle&&"step"!=this.graphStyle||d.push({prop:this.pairY?"y1_"+n:"y1",state:this.state,end:this.pairY?h.min[n]:h.min,delay:f,duration:v,group:{top:!0}}),"area"!=this.graphStyle&&d.push({prop:this.pairY?"y2_"+n:"y2",state:this.state,end:this.pairY?h.max[n]:h.max,delay:f,duration:v,group:{top:!0}}),"line"!=this.graphStyle&&"step"!=this.graphStyle||d.push({prop:this.pairY?"y1m_"+n:"y1m",state:this.state,end:this.pairY?o.min[n]:o.min,delay:f,duration:v,group:{bottom:!0}}),"area"!=this.graphStyle&&d.push({prop:this.pairY?"y2m_"+n:"y2m",state:this.state,end:this.pairY?o.max[n]:o.max,delay:f,duration:v,group:{bottom:!0}});this.animator.add(d)}}},insertDetails:function(i,s,e){var a=Math.ceil(t.TUtils.getXIndex(this.data.x,i)),h=Math.ceil(t.TUtils.getXIndex(this.data.x,s)),o=e.x.length-1;s>this.data.x[h]&&h++;var n,r,d,l,p,c,m=a,g=h-("bar"==this.graphStyle||"step"==this.graphStyle?1:0),u=this.data.x.length-1,x=[],v=[],f=[],y=[],M=[],T=[];for(n=0;n<m;n++)x[r=n-0]=this.data.x[n],v[r]=this.data.dates[n],f[r]=this.data.datesShort[n],y[r]=this.data.datesRange[n];for(j=0;j<this.data.ys.length;j++)for(M[j]=M[j]||[],d=M[j],p=this.data.ys[j].y,n=0;n<m;n++)d[n-0]=p[n];var b=[],_=[],w=[],D=t.TUtils.getFormatter("xTooltipFormatter",this.data,1),S=t.TUtils.getFormatter("xTickFormatter",this.data,1),I=t.TUtils.getFormatter("xRangeFormatter",this.data,1),$=0;for(n=0;n<=o;n++){x[r=n-0+m]=e.x[n],v[r]=D(x[r],!0),f[r]=S(x[r],!0),y[r]=I(x[r],!0),f[r].length>$&&($=f[r].length);var L=t.TUtils.getXIndex(this.data.x,x[r]);b[n]=L,_[n]=Math.floor(L),w[n]=Math.ceil(L)}for(this.data.details.maxXTickLength=$,j=0;j<this.data.ys.length;j++)for(M[j]=M[j]||[],d=M[j],p=this.data.ys[j].y,c=e.y[j],T[j]=T[j]||[],l=T[j],n=0;n<=o;n++){if("bar"==this.graphStyle)var A=p[_[n]]||0;else if("step"==this.graphStyle)A=p[_[n]];else A=p[_[n]]+(b[n]-_[n])*(p[w[n]]-p[_[n]]);var E=c[n];"bar"!==this.graphStyle&&isNaN(A)&&!isNaN(E)&&(A=0),d[n-0+m]=E,l[n-0+m]=A}for(n=g+1;n<=u;n++)x[r=n-g+o+m]=this.data.x[n],v[r]=this.data.dates[n],f[r]=this.data.datesShort[n],y[r]=this.data.datesRange[n];for(j=0;j<this.data.ys.length;j++)for(M[j]=M[j]||[],d=M[j],p=this.data.ys[j].y,n=g+1;n<=u;n++)d[n-g+o+m]=p[n];for(this.state.detailInd1=m,this.state.detailInd2=m+o-0,this.data.x=x,this.data.dates=v,this.data.datesShort=f,this.data.datesRange=y,j=0;j<this.data.ys.length;j++)this.data.ys[j].y=M[j],this.data.ys[j].yFrom=T[j]},revertDetails:function(){for(this.data.x=this.data.saved.x,this.data.dates=this.data.saved.dates,this.data.datesShort=this.data.saved.datesShort,this.data.datesRange=this.data.saved.datesRange,i=0;i<this.data.ys.length;i++)this.data.ys[i].y=this.data.saved.y[i]}},t.TChart=s}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.$canvas=document.createElement("canvas"),this.$canvas.className="tchart--graph-canvas",this.ctx=this.$canvas.getContext("2d"),t.$parent.appendChild(this.$canvas),this.deviceSpeed=void 0};i.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.state.dims.composer;this.$canvas.width=i.w*t,this.$canvas.height=i.h*t,this.render({top:!0,bottom:!0})},setDarkMode:function(t){this.isDarkMode=t,this.onResize()},render:function(t){if(null==this.deviceSpeed){var i=performance.now(),s=this.opts.state.x1;this.opts.state.x1=this.opts.state.xMainMin,this.renderInner(t);var e=performance.now();this.opts.state.x1=s}if(this.renderInner(t),null==this.deviceSpeed){var a=(e-i)/("line"==this.opts.graphStyle||"step"==this.opts.graphStyle?1.5:2);this.deviceSpeed=a/(this.opts.data.x.length*this.opts.data.ys.length),this.opts.state.deviceSpeed=this.deviceSpeed}},renderInner:function(i){var s=this.opts.state.dims,e=this.opts.state,a=this.ctx,h=this.opts.settings.dpi,o=this.opts.settings,n=o.PADD,r=null==e.zoomMorph?0:e.zoomMorph,d="area"==this.opts.graphStyle&&e.zoomMode&&r<1,l="area"==this.opts.graphStyle&&e.zoomMode&&1==r;if(this.opts.data.master&&(this.$canvas.style.opacity=e.masterVisibility),this.opts.data.slave&&(this.$canvas.style.opacity=e.slaveVisibility,this.opts.chart.$el.style.visibility=e.slaveVisibility>0?"visible":"hidden"),i.top){if(a.clearRect(s.dates.l*h,s.dates.t*h,s.dates.w*h,s.dates.h*h),("line"==this.opts.graphStyle||"step"==this.opts.graphStyle||"area"==this.opts.graphStyle&&r>0||this.opts.data.slave&&e.slaveVisibility<1||this.opts.data.master&&e.masterVisibility<1)&&(l?a.clearRect(s.graph.l*h,(s.graph.t-18)*h,s.graph.w*h,(s.graph.h+30)*h):a.clearRect(s.graph.l*h,s.graph.t*h,s.graph.w*h,s.graph.h*h)),("area"==this.opts.graphStyle&&0==r||"bar"==this.opts.graphStyle)&&(a.clearRect(s.graph.l*h,s.graph.t*h,s.graph.w*h,(o.PADD[0]+4)*h),a.clearRect(s.graph.l*h,(s.graph.t+n[0])*h,n[3]*h,(s.graph.h-n[0]-n[2])*h),a.clearRect(s.graph.l*h,(s.graph.t+s.graph.h-n[2])*h,s.graph.w*h,n[2]*h),a.clearRect((s.graph.l+s.graph.w-n[1]-1)*h,(s.graph.t+n[0])*h,(n[1]+1)*h,(s.graph.h-n[0]-n[2])*h)),d||l||(a.save(),a.beginPath(),a.rect(s.graph.l*h,s.graph.t*h,s.graph.w*h,s.graph.h*h),a.clip()),this.opts.data.master&&e.masterVisibility<1){a.save();var p=5*(1-e.masterVisibility)+1;a.translate(s.graph.w*e.zoomSpecialOrigin*(1-p),0),a.scale(p,1)}if(this.opts.data.slave&&e.slaveVisibility<1){a.save();p=e.slaveVisibility;a.translate(s.graph.w*e.zoomSpecialOrigin*(1-p),0),a.scale(p,1)}var c=1;if("area"==this.opts.graphStyle&&e.zoomMode&&(c=1-r),d){a.save();var m=o.PIE_RADIUS,g=s.graph.w+r*(2*m-s.graph.w),u=s.graph.h-42+r*(2*m-s.graph.h+42);t.TUtils.drawRoundedRect2(a,h,g,u,(s.graph.w-g)/2+s.graph.l,(s.graph.h-42-u)/2+s.graph.t+23,r*m),a.clip()}this.opts.chart.graph.render(),d&&a.restore(),this.opts.data.master&&e.masterVisibility<1&&a.restore(),this.opts.data.slave&&e.slaveVisibility<1&&a.restore(),this.opts.chart.axisY.render(c),this.opts.chart.fade.render(),d||l||a.restore(),this.opts.chart.axisX.render(c)}if(i.bottom){a.clearRect(s.graph.l*h,(s.handle.t-1)*h,s.graph.w*h,(s.handle.h+2)*h);var x=this.opts.data.subchart.show,v=!this.opts.data.master&&!this.opts.data.slave&&this.opts.data.details&&this.opts.data.subchart.show!=this.opts.data.details.subchart.show;v&&(x=x?r<1:r>0),x&&(a.save(),t.TUtils.drawRoundedRect(a,h,s.mini.w,s.mini.h,s.mini.l,s.mini.t,7),a.clip(),this.opts.chart.mini.render(),a.restore(),this.opts.chart.handle.render()),v&&r>0&&r<1&&(a.fillStyle=this.isDarkMode?"#242f3e":"#fff",a.globalAlpha=this.opts.data.subchart.show?r:1-r,a.fillRect(s.graph.l*h,(s.handle.t-1)*h,s.graph.w*h,(s.handle.h+2)*h),a.globalAlpha=1)}}},t.TComposer=i}(),function(){var t=window.Graph.units,i=function(i){this.opts=i,this.onDragStart=this.onDragStart.bind(this),this.onDragMove=this.onDragMove.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.isTouch=t.TUtils.isTouchDevice(),this.skipMoveEnd=!0;var s=i.useElForMove?i.$el:window;i.$el.addEventListener(this.isTouch?"touchstart":"mousedown",this.onDragStart,{passive:!1}),s.addEventListener(this.isTouch?"touchmove":"mousemove",this.onDragMove,{passive:!1}),s.addEventListener(this.isTouch?"touchend":"mouseup",this.onDragEnd,{passive:!1})};i.prototype={onDragStart:function(t){(this.skipMoveEnd=!0,clearTimeout(this.pointerTimeout),this.isTouch&&t.touches.length>1)||(this.scroll=void 0,this.x=this.isTouch?t.touches[0].pageX:t.pageX,this.y=this.isTouch?t.touches[0].pageY:t.pageY,this.dX=0,this.dY=0,this.pageX=this.x,this.pageY=this.y,delete this.prevDx,delete this.prevDy,this.opts.onDragStart({pageX:this.x,pageY:this.y,isTouch:this.isTouch})||(this.skipMoveEnd=!1))},onDragMove:function(t){if(!this.skipMoveEnd&&"v"!=this.scroll){var i=this.isTouch?t.touches[0].pageX:t.pageX,s=this.isTouch?t.touches[0].pageY:t.pageY;this.dX=i-this.x,this.dY=s-this.y,this.pageX=i,this.pageY=s,this.isTouch&&("h"==this.scroll?!this.opts.noPrevent&&t.preventDefault():(Math.abs(this.dX)>5||Math.abs(this.dY)>5)&&(this.scroll=Math.abs(this.dX)>Math.abs(this.dY)?"h":"v")),this.prevDx==this.dX&&this.prevDy==this.dY||(this.opts.onDragMove&&this.opts.onDragMove({canceled:"v"==this.scroll,d:this.dX,pageX:this.pageX,pageY:this.pageY,isTouch:this.isTouch}),this.prevDx=this.dX,this.prevDy=this.dY)}},onDragEnd:function(t){this.skipMoveEnd||(this.skipMoveEnd=!0,this.opts.onDragEnd&&this.opts.onDragEnd({isTouch:this.isTouch,e:t}))}},t.TDrag=i}(),function(){var t=function(t){this.opts=t,this.ctx=t.ctx,"area"!=this.opts.graphStyle&&(this.$fadeTop=document.createElement("canvas"),this.ctxFadeTop=this.$fadeTop.getContext("2d"),"bar"!=this.opts.graphStyle&&(this.$fadeBottom=document.createElement("canvas"),this.ctxFadeBottom=this.$fadeBottom.getContext("2d")))};t.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.state.dims.fadeTop,s=this.opts.state.dims.fadeBottom;if("area"!=this.opts.graphStyle){var e=this.ctxFadeTop.createLinearGradient(0,0,0,i.h*t);if(this.isDarkMode?(e.addColorStop(0,"rgba(36,47,62,1)"),e.addColorStop(1,"rgba(36,47,62,0)")):(e.addColorStop(0,"rgba(255,255,255,1)"),e.addColorStop(1,"rgba(255,255,255,0)")),this.$fadeTop.width=i.w*t,this.$fadeTop.height=i.h*t,this.ctxFadeTop.fillStyle=e,this.ctxFadeTop.fillRect(0,0,i.w*t,i.h*t),"bar"!=this.opts.graphStyle){var a=this.ctxFadeBottom.createLinearGradient(0,0,0,s.h*t);this.isDarkMode?(a.addColorStop(0,"rgba(36,47,62,0)"),a.addColorStop(1,"rgba(36,47,62,1)")):(a.addColorStop(0,"rgba(255,255,255,0)"),a.addColorStop(1,"rgba(255,255,255,1)")),this.$fadeBottom.width=s.w*t,this.$fadeBottom.height=s.h*t,this.ctxFadeBottom.fillStyle=a,this.ctxFadeBottom.fillRect(0,0,s.w*t,s.h*t)}}},setDarkMode:function(t){this.isDarkMode=t,this.onResize()},render:function(){var t=this.opts.settings.dpi,i=this.opts.state.dims.fadeTop,s=this.opts.state.dims.fadeBottom;this.$fadeTop&&this.ctx.drawImage(this.$fadeTop,i.l*t,i.t*t),this.$fadeBottom&&this.ctx.drawImage(this.$fadeBottom,s.l*t,s.t*t)}},window.Graph.units.TFade=t}(),function(){var t=window.Graph.units,i=function(i){this.opts=i,this.ctx=i.ctx,this.isTouch=t.TUtils.isTouchDevice(),this.$canvas=i.$canvas,this.drag=new t.TDrag({$el:this.$canvas,onDragStart:function(s){this.canvasPos=t.TUtils.getElemPagePos(this.$canvas);var e=s.pageX-this.canvasPos.x,a=s.pageY-this.canvasPos.y;return this._x1=i.state.x1,this._x2=i.state.x2,this.constrainHandleSize(!1),this.tp=this.getTp(e-i.settings.PADD[3],a-(this.opts.state.dims.composer.h-i.settings.MINI_GRAPH_HEIGHT-i.settings.MINI_GRAPH_BOTTOM),s.isTouch),this.firstMove=!0,!this.tp}.bind(this),onDragMove:function(t){this.onDragMove(t.d),this.firstMove=!1}.bind(this),onDragEnd:function(t){}.bind(this)}),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.trackMouse(!0)};i.prototype={getTp:function(t,i,s){var e=this.opts.state.dims.handle,a=this.opts.state,h=this.opts.state.zoomMode;if(i<0||i>e.h)return"";var o=s?.3*e.w:10;s&&o<14&&(o=14),s&&o>30&&(o=30);var n=this.prevX1+(s?a.x1==a.xg1?-5:-15:0),r=n+o,d=this.prevX2+(s?a.x2==a.xg2?5:15:0),l=d-o;return Math.abs(a.x2-a.x1-(h?this.opts.data.mainPeriodLen:this.minRange))<.01&&(a.x2==a.xg2&&(l=d+1),a.x1==a.xg1&&(r=n-1)),t>r&&t<l?"both":t>=n&&t<=r?"start":t>=l&&t<=d?"end":""},trackMouse:function(t){this.isTouch||(this.$canvas.addEventListener("mousemove",this.onMouseMove),this.$canvas.addEventListener("mouseleave",this.onMouseLeave))},onMouseLeave:function(){this.$canvas.classList.remove("tchart--graph-canvas__handle-pointer"),this.$canvas.classList.remove("tchart--graph-canvas__handle-grab"),this.$canvas.classList.remove("tchart--graph-canvas__handle-col-resize"),delete this.canvasPos},onMouseMove:function(i){this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas);var s=i.pageX-this.canvasPos.x,e=i.pageY-this.canvasPos.y,a=this.getTp(s-this.opts.settings.PADD[3],e-(this.opts.state.dims.composer.h-this.opts.settings.MINI_GRAPH_HEIGHT-this.opts.settings.MINI_GRAPH_BOTTOM),!1),h={"":"",both:this.opts.settings.isIE?"pointer":"grab",start:"col-resize",end:"col-resize"};this.onMouseLeave(),h[a]&&this.$canvas.classList.add("tchart--graph-canvas__handle-"+h[a])},onResize:function(t){this.constrainHandleSize(!0)},setDarkMode:function(t){this.isDarkMode=t},constrainHandleSize:function(t){var i=32/(this.opts.state.dims.handle.w/(this.opts.state.xg2-this.opts.state.xg1)),s=this.opts.state.x1,e=this.opts.state.x2,a=(this.opts.state.xg1,this.opts.state.xg2);this.minRange=i,e-s<i&&((e=s+i)>a&&(s=(e=a)-i),t&&this.opts.additional.cb(s,e,"constraint"))},onDragMove:function(t){var i,s,e=this.opts.state.dims.handle,a=this.tp,h=this.opts.state,o=t/e.w*(h.xg2-h.xg1),n=this._x1,r=this._x2;"both"==a&&(s=r+o,(i=n+o)<h.xg1&&(i=h.xg1,s=h.xg1+r-n),s>h.xg2&&(i=h.xg2-(r-n),s=h.xg2)),"start"==a&&(s=h.x2,i=Math.min(Math.max(n+o,h.xg1),s-this.minRange)),"end"==a&&(i=h.x1,s=Math.max(Math.min(r+o,h.xg2),i+this.minRange)),h.x1==i&&h.x2==s||this.opts.additional.cb(i,s,a,this.firstMove)},render:function(){var i=this.opts.state.dims.handle,s=this.opts.settings.dpi,e=this.opts.state,a=1/(e.xg2-e.xg1),h=Math.round((e.x1-e.xg1)*a*i.w),o=Math.round((e.x2-e.xg1)*a*i.w),n=this.ctx;n.fillStyle=this.isDarkMode?"rgba(48, 66, 89, 0.6)":"rgba(226, 238, 249, 0.6)",t.TUtils.drawRoundedRect(n,s,h+4,i.h-2,i.l,i.t+1,[7,0,0,7]),n.fill(),t.TUtils.drawRoundedRect(n,s,i.w-o+4,i.h-2,i.l+o-4,i.t+1,[0,7,7,0]),n.fill(),this.isDarkMode||"line"==this.opts.graphStyle||"step"==this.opts.graphStyle||(n.fillStyle="#fff",t.TUtils.drawRoundedRect(n,s,12,i.h+2,i.l+h-1,i.t-1,[8,0,0,8]),n.fill(),t.TUtils.drawRoundedRect(n,s,12,i.h+2,i.l+o-11,i.t-1,[0,8,8,0]),n.fill()),n.fillStyle=this.isDarkMode?"#56626D":"#C0D1E1",t.TUtils.drawRoundedRect(n,s,10,i.h,i.l+h,i.t,[7,0,0,7]),n.fill(),t.TUtils.drawRoundedRect(n,s,10,i.h,i.l+o-10,i.t,[0,7,7,0]),n.fill(),n.fillRect((i.l+h+10)*s,i.t*s,(o-h-20)*s,s),n.fillRect((i.l+h+10)*s,(i.t+i.h-1)*s,(o-h-20)*s,s),n.strokeStyle="#fff",this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.lineWidth=2*s,n.beginPath(),n.moveTo((i.l+h+5)*s,(i.t+17)*s),n.lineTo((i.l+h+5)*s,(i.t+25)*s),n.moveTo((i.l+o-5)*s,(i.t+17)*s),n.lineTo((i.l+o-5)*s,(i.t+25)*s),n.stroke(),this.prevX1=h,this.prevX2=o}},t.THandle=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!0})};i.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.additional.mini?this.opts.state.dims.mini:this.opts.state.dims.graph;this.$canvas.width=i.w*t,this.$canvas.height=i.h*t,this.cached="",this.ctx.fillStyle=this.isDarkMode?"#242f3e":"#fff",this.ctx.fillRect(0,0,i.w*t,i.h*t)},setDarkMode:function(t){this.isDarkMode=t},render:function(){var i,s,e,a,h,o,n,r,d,l,p,c,m,g,u,x=this.opts,v=x.data.ys,f=x.state,y=x.additional.mini,M=y||x.data.master&&f.masterVisibility<1&&f.masterVisibility>0||x.data.slave&&f.slaveVisibility<1&&f.slaveVisibility>0,T=y?f.xg1:f.x1,b=y?f.xg2:f.x2,_=x.settings,w=_["PADD"+(y?"_MINI":"")][0],D=_["PADD"+(y?"_MINI":"")][1],S=_["PADD"+(y?"_MINI":"")][2],I=_["PADD"+(y?"_MINI":"")][3],$=x.data.x,L=x.settings.dpi,A=M?this.ctx:this.opts.ctx,E=y?f.dims.mini:f.dims.graph,P=f.zoomMode,R=f.detailInd1,k=f.detailInd2,C=null==f.zoomMorph?0:f.zoomMorph,z=v.length,F="step"==x.graphStyle;n=(E.w-D-I)/(b-T+(F?this.opts.data.mainPeriodLen*(1-C):0)),m=Math.floor(t.TUtils.getXIndex($,T-I/n)),g=Math.ceil(t.TUtils.getXIndex($,b+D/n)),n*=L,d=(I+(M?0:E.l))*L-T*n,F&&P&&1==C&&(m<this.opts.state.xg1Ind&&(m=this.opts.state.xg1Ind),g>this.opts.state.xg2Ind&&(g=this.opts.state.xg2Ind-1));var Y=this.opts.data.mainPeriodLen*n,X=this.opts.data.detailPeriodLen*n;if(M){var H=[E.w,E.h,y?f.xg1:f.x1,y?f.xg2:f.x2,this.isDarkMode,P];for(y||(H.push(f.y1),H.push(f.y2)),i=0;i<z;i++)H.push(y?f["om_"+i]:f["o_"+i]),H.push(f["f_"+i]);if((H=H.join(","))==this.cached)return void this.opts.ctx.drawImage(this.$canvas,E.l*L,E.t*L);this.cached=H,A.clearRect(0,0,E.w*L,E.w*L)}var U=(x.additional.mini?1:"auto"==x.data.strokeWidth?z>5?1:2:x.data.strokeWidth)*L,N=U%2==0?0:.5;for(A.lineWidth=U,A.lineCap=x.additional.mini?"square":"round",A.lineJoin=x.additional.mini?"square":"round",i=0;i<z;i++)if(a=y?f["om_"+i]:f["o_"+i],p=f["e_"+i],a>0){var B,G;e=v[i].y,c=v[i].yFrom,x.pairY?(h=y?f["y1m_"+i]:f["y1_"+i],o=y?f["y2m_"+i]:f["y2_"+i]):y?p&&a<1?(h=f.y1m_show,o=f.y2m_show):!p&&a<1?(h=f.y1m_hidd,o=f.y2m_hidd):(h=f.y1m,o=f.y2m):(h=f.y1,o=f.y2),r=L*(E.h-w-S)/(o-h),l=(E.h-S+(M?0:E.t))*L+h*r,A.beginPath(),A.strokeStyle=this.isDarkMode?v[i].colors_n[0]:v[i].colors_d[0],A.globalAlpha=a*(.9*f["f_"+i]+.1);var O,W=Number.MAX_VALUE,j=-Number.MAX_VALUE,V=-Number.MAX_VALUE,Z=!1,q=!0;for(s=m;s<=g;s++)P?s>=R&&s<=k?(B=c[s]+C*(e[s]-c[s]),u=X):(B=e[s]+C*(e[R]-e[s]),u=Y):(B=e[s],u=Y),isNaN(B)?q=!0:(G=$[s]*n+d<<0,yc=l-B*r<<0,G>V||F&&s==k+1?(Z&&(O==W?(A.moveTo(V+N,j-N),A.lineTo(V+N,W-N)):(A.moveTo(V+N,W-N),A.lineTo(V+N,j-N),O!=j&&A.moveTo(V+N,O-N)),Z=!1),q&&(A.moveTo(G+N,yc-N),q=!1),W=yc,j=yc,A.lineTo(G+N,yc-N),F&&A.lineTo(($[s]*n+u+d<<0)+N,yc-N)):(W=Math.min(W,yc),j=Math.max(j,yc),Z=!0),V=G,O=yc);Z&&(A.moveTo(V+N,W-N),A.lineTo(V+N,j-N)),A.stroke()}A.globalAlpha=1,M&&this.opts.ctx.drawImage(this.$canvas,E.l*L,E.t*L)}},t.TLines=i}(),function(){var t=window.Graph.units,i=function(i){var s,e;this.opts=i,this.isTouch=t.TUtils.isTouchDevice(),this.enabled=i.data.ys.length,1==this.enabled&&(i.$parent.style.display="none"),this.switchers=i.data.ys.map(function(a,h){var o=document.createElement("div");o.className="tchart--switcher",i.state["e_"+h]?o.classList.toggle("tchart--switcher__active"):this.enabled--,o.setAttribute("data-label",a.label),i.$parent.appendChild(o);var n,r,d,l=document.createElement("span");return l.textContent=a.label,o.appendChild(l),this.isTouch||(o.addEventListener("mouseenter",function(t){i.state["e_"+h]&&i.additional.onEnter(h)}),o.addEventListener("mouseleave",function(t){i.state["e_"+h]&&i.additional.onLeave(h)})),o.addEventListener("click",function(t){if(e)e=!1;else{var a=o.classList.contains("tchart--switcher__active");if(a&&1==this.enabled)return o.classList.add("tchart--switcher__denied"),clearTimeout(s),void(s=setTimeout(function(){o.classList.remove("tchart--switcher__denied")},500));this.isTouch||(a?i.additional.onLeave(h):i.additional.onEnter(h)),i.additional.onClick(!a,h)}}.bind(this)),this.drag=new t.TDrag({$el:o,noPrevent:!0,useElForMove:!0,onDragStart:function(t){n=t.pageX,r=t.pageY,d=setTimeout(function(){e=!0,this.isTouch||i.additional.onEnter(h),i.additional.onLongTap(h)}.bind(this),500)}.bind(this),onDragMove:function(t){(Math.abs(n-t.pageX)>5||Math.abs(r-t.pageY)>5)&&clearTimeout(d)}.bind(this),onDragEnd:function(t){clearTimeout(d)}.bind(this)}),o}.bind(this)),this.updateColors()};i.prototype={onResize:function(){},updateColors:function(){for(var t=this.opts.data.ys,i=0;i<this.switchers.length;i++)this.switchers[i].style.color=this.isDarkMode?t[i].colors_n[1]:t[i].colors_d[1]},setDarkMode:function(t){this.isDarkMode=t,this.updateColors()},render:function(t){this.enabled=0;for(var i=0;i<this.switchers.length;i++)t[i]?(this.enabled++,this.switchers[i].classList.add("tchart--switcher__active")):this.switchers[i].classList.remove("tchart--switcher__active")}},t.TSwitchers=i}(),function(){var t=window.Graph.units,i=function(i){this.opts=i,this.shown=!1,this.isTouch=t.TUtils.isTouchDevice(),this.$canvas=i.$canvas,this.cache={},this.$tip=document.createElement("div"),this.$tip.className="tchart--tip",i.$parent.appendChild(this.$tip),this.$tipDt=document.createElement("h6"),this.$tip.appendChild(this.$tipDt),this.$tipDtText=document.createTextNode(""),this.$tipDt.appendChild(this.$tipDtText),this.$tipDtText.nodeValue=".",this.$tipArrow=document.createElement("div"),this.$tipArrow.className="tchart--tip-arrow",this.$tip.appendChild(this.$tipArrow),this.$tipLoader=document.createElement("div"),this.$tipLoader.className="tchart--tip-loader",this.$tip.appendChild(this.$tipLoader),this.$tipScrollerWrapper=document.createElement("div"),this.$tipScrollerWrapper.className="tchart--tip-scroller-wrapper",this.$tip.appendChild(this.$tipScrollerWrapper),this.$tipScroller=document.createElement("div"),this.$tipScroller.className="tchart--tip-scroller",this.$tipScrollerWrapper.appendChild(this.$tipScroller),this.updateTipScrollClasses=this.updateTipScrollClasses.bind(this),this.$tipScroller.addEventListener("scroll",this.updateTipScrollClasses),this.labels=[],i.data.ys.forEach(function(t,i){this.labels.push(this.addLabel(t))}.bind(this)),"bar"==i.graphStyle&&i.data.ys.length>1&&(this.allLabel=this.addLabel({label:"All",outside:!0})),"area"==i.graphStyle&&(this.pieLabel=this.addLabel({label:"pie",outside:!0})),this.tooltipOnHover=!this.isTouch&&i.data.tooltipOnHover,"bar"!=i.graphStyle?(this.$line=document.createElement("div"),this.$line.className="tchart--line",i.$parent.appendChild(this.$line),this.$lineFill=document.createElement("div"),this.$line.appendChild(this.$lineFill),"area"!=i.graphStyle&&(this.points=i.data.ys.map(function(t,i){var s=document.createElement("span");return this.$line.appendChild(s),s}.bind(this)))):(i.state.barInd=-1,i.state.barO=0),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onTipClick=this.onTipClick.bind(this),this.tooltipOnHover?(this.$canvas.addEventListener("mousemove",function(i){this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas),this.dx=i.pageX-this.canvasPos.x,this.dy=i.pageY-this.canvasPos.y;var s=this.opts.state.dims.tip;this.tp=this.getTp(this.dx,this.dy-s.t,this.isTouch),this.tp?this.shown?this.render({isMove:!0}):(delete this.prevXInd,this.toggle(!0),this.render({})):this.toggle(!1)}.bind(this)),this.$canvas.addEventListener("mouseleave",function(){delete this.canvasPos,this.toggle(!1)}.bind(this)),this.$canvas.addEventListener("click",function(t){this.shown&&this.onTipClick(t)}.bind(this)),this.$tip.style.pointerEvents="none"):(this.drag=new t.TDrag({$el:this.$canvas,onDragStart:function(i){this.canvasPos=t.TUtils.getElemPagePos(this.$canvas),this.dx=i.pageX-this.canvasPos.x,this.dy=i.pageY-this.canvasPos.y;var s=this.opts.state.dims.tip;return this.tp=this.getTp(this.dx,this.dy-s.t,i.isTouch),delete this.prevXInd,clearTimeout(this.showTimeout),this.showTimeout=setTimeout(function(){this.toggle(!!this.tp),this.tp&&this.render()}.bind(this),this.isTouch?100:30),document.body.removeEventListener("click",this.onBodyClick),!this.tp}.bind(this),onDragMove:function(i){if(i.canceled)return clearTimeout(this.showTimeout),void this.toggle(!1);this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas),this.dx=i.pageX-this.canvasPos.x,this.dy=i.pageY-this.canvasPos.y,this.render({isMove:!0})}.bind(this),onDragEnd:function(t){delete this.canvasPos,this.bodyTimeout=setTimeout(function(){document.body.addEventListener("click",this.onBodyClick)}.bind(this),140)}.bind(this)}),this.$tip.addEventListener("click",this.onTipClick)),this.trackMouse(!0),this.updateColors()};i.prototype={onResize:function(t){var i=this.opts.state.dims.tip;if(this.$line){var s="area"==this.opts.graphStyle?25:16;this.$line.style.top=i.t+"px",this.$line.style.height=i.h+"px",this.$lineFill.style.top=s+"px",this.$lineFill.style.bottom=this.opts.settings.PADD[2]+1+"px"}this.render()},abortDetailCallbacks:function(){this.detailCallbacks&&(this.detailCallbacks.forEach(function(t,i){t.cancelled=!0}),delete this.detailCallbacks)},onTipClick:function(t){if(null!=this.prevXInd&&this.opts.additional.onClick&&this.opts.data.hasDetail&&!this.opts.state.zoomMode&&!this.opts.state.zoomModeSpecial&&(t.stopPropagation(),!this.$tip.classList.contains("tchart--tip__loading"))){var i=this.opts.data.x[this.prevXInd];if(!this.opts.data.detailsFunc)return this.toggle(!1,!0),void this.opts.additional.onClick(!0,i);if(this.$tip.classList.remove("tchart--tip__error"),this.$tip.classList.add("tchart--tip__loading"),this.cache[i])return this.toggle(!1,!0),this.opts.additional.onClick(!0,i,this.cache[i]),void this.$tip.classList.remove("tchart--tip__loading");this.abortDetailCallbacks();var s=this.opts.data.detailsFunc(i),e=this;this.detailCallbacks=this.detailCallbacks||[];var a=function(t){a.cancelled||(e.$tip.classList.remove("tchart--tip__loading"),t&&t.columns?(e.toggle(!1,!0),e.opts.additional.onClick(!0,i,t),e.cache[i]=t):e.$tip.classList.add("tchart--tip__error"))},h=function(t){h.cancelled||(console.log("error:",t),e.$tip.classList.remove("tchart--tip__loading"),e.$tip.classList.add("tchart--tip__error"))};this.detailCallbacks.push(a),this.detailCallbacks.push(h),s.then(a).catch(h)}},updateColors:function(){var t=this.opts.data.ys;this.labels.forEach(function(i,s){this.points&&(this.points[s].style.borderColor=this.isDarkMode?t[s].colors_n[0]:t[s].colors_d[0]),i.$value.style.color=this.isDarkMode?t[s].colors_n[2]:t[s].colors_d[2]}.bind(this)),this.allLabel&&(this.allLabel.$value.style.color=this.isDarkMode?"#fff":"#000"),this.$lineFill&&(this.$lineFill.style.backgroundColor=this.isDarkMode?"rgba(255, 255, 255, 0.1)":"rgba(24, 45, 59, 0.1)")},setDarkMode:function(t){this.isDarkMode=t,this.updateColors()},addLabel:function(t){var i=document.createElement("div");i.className="tchart--tip-row",t.outside?(this.$tip.appendChild(i),i.classList.add("tchart--tip-row__outside")):this.$tipScroller.appendChild(i);var s=document.createElement("span");i.appendChild(s);var e,a=document.createTextNode("");if(a.nodeValue=t.label,s.appendChild(a),"area"==this.opts.graphStyle){var h=document.createElement("p");i.appendChild(h),e=document.createTextNode(""),h.appendChild(e)}var o=document.createElement("div");i.appendChild(o);var n=document.createTextNode("");return o.appendChild(n),{$row:i,$value:o,$valueText:n,$label:s,$labelText:a,$per:h,$perText:e}},getTp:function(t,i,s){if("area"==this.opts.graphStyle&&this.opts.state.zoomMode){var e=(h=this.opts.state.dims.graph).w/2,a=h.h/2;return Math.pow((a-i)*(a-i)+(t-e)*(t-e),.5)<=this.opts.settings.PIE_RADIUS?"graph":""}var h=this.opts.state.dims.tip;return i<0||i>h.h?"":"graph"},trackMouse:function(t,i){this.isTouch||(this.$canvas.addEventListener("mousemove",this.onMouseMove),this.$canvas.addEventListener("mouseleave",this.onMouseLeave))},onMouseLeave:function(){this.$canvas.classList.remove("tchart--graph-canvas__tip-pointer"),delete this.canvasPos},onMouseMove:function(i){this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas);var s=i.pageX-this.canvasPos.x,e=i.pageY-this.canvasPos.y,a=this.opts.state.dims.tip,h=this.getTp(s,e-a.t,!1);this.onMouseLeave(),h&&this.$canvas.classList.add("tchart--graph-canvas__tip-pointer")},toggle:function(i,s){var e=this.opts,a=e.state;if(i&&!this.shown&&(this.$tip.classList.add("tchart--tip__visible"),!this.opts.data.hasDetail||this.opts.state.zoomMode||this.opts.state.zoomModeSpecial?this.$tip.classList.remove("tchart--tip__has-zoom"):this.$tip.classList.add("tchart--tip__has-zoom"),this.$tip.classList.remove("tchart--tip__shiftHide"),this.$line&&this.$line.classList.add("tchart--line__visible"),t.TUtils.triggerEvent("chart-hide-tips",{except:this.opts.chart})),!i&&this.shown){if(delete this.lastCurPieItemInd,"area"==e.graphStyle&&a.zoomMode){for(var h=[],o=0;o<a.pieAngles.length;o++){var n=a.pieAngles[o];h.push({prop:"pieInd_"+n.ind,state:e.state,end:0,duration:350,tween:"exp",speed:.2,group:{top:!0}})}e.animator.add(h)}s&&(this.$tip.classList.add("tchart--tip__shiftHide"),this.lastTipTop-=12,this.lastTipLeft=this.lastTipLeft<this.opts.state.dims.tip.w/2?this.lastTipLeft-12:this.lastTipLeft+12,this.$tip.style.transform="translate("+this.lastTipLeft+"px,"+this.lastTipTop+"px)",this.$tip.style.webkitTransform="translate("+this.lastTipLeft+"px,"+this.lastTipTop+"px)"),this.$tip.classList.remove("tchart--tip__visible"),this.$line&&this.$line.classList.remove("tchart--line__visible"),this.abortDetailCallbacks(),this.$tip.classList.remove("tchart--tip__error"),this.$tip.classList.remove("tchart--tip__loading"),"bar"==this.opts.graphStyle&&this.opts.animator.add([{prop:"barInd",state:this.opts.state,end:-1,duration:0,delay:150,tween:"linear",group:{top:!0}},{prop:"barO",state:this.opts.state,end:0,duration:150,tween:"exp",speed:.3,group:{top:!0}}]),document.body.removeEventListener("click",this.onBodyClick)}this.shown=i},onBodyClick:function(t){t.target!=this.$canvas&&this.toggle(!1)},renderPieTooltip:function(i){var s,e=this.opts,a=e.state,h=this.opts.settings,o=h.PADD[0],n=h.PADD[1],r=h.PADD[2],d=h.PADD[3],l=a.dims.graph,p=a.dims.tip,c=l.w/2,m=l.h/2,g=t.TUtils.getFormatter("yTooltipFormatter",e.data,a.zoomMorph),u=Math.atan2(m-this.dy+l.t,this.dx-c);u=u<0?2*Math.PI+u:u;for(var x=0;x<a.pieAngles.length;x++){u<=(f=a.pieAngles[x]).st&&u>=f.ed&&(s=f),u-2*Math.PI<=f.st&&u-2*Math.PI>=f.ed&&(s=f)}if(this.lastCurPieItemInd!=s.ind){var v=[];for(x=0;x<a.pieAngles.length;x++){var f=a.pieAngles[x];v.push({prop:"pieInd_"+f.ind,state:e.state,end:f==s?1:0,duration:350,tween:"exp",speed:.2,group:{top:!0}})}e.animator.add(v)}this.pieLabel.$row.style.display="block",this.labels.forEach(function(t,i){t.$row.style.display="none"}.bind(this)),this.pieLabel.$labelText.nodeValue=s.label,this.pieLabel.$valueText.nodeValue=isNaN(s.value)?"n/a":g(s.value),this.pieLabel.$value.style.color=s.color,this.$tip.classList.add("tchart--tip__piemode"),this.$line&&this.$line.classList.add("tchart--line__piemode"),this.tipH=this.$tip.offsetHeight,this.tipW=this.$tip.offsetWidth;var y=this.dx-this.tipW/2,M=Math.min(this.dy-20-this.tipH,p.t+p.h-this.tipH-r);M<p.t+o&&(M=p.t+o),y=Math.min(Math.max(y,d/2),p.w-this.tipW-n/2),this.$tip.style.transform="translate("+(y<<0)+"px,"+(M<<0)+"px)",this.$tip.style.webkitTransform="translate("+(y<<0)+"px,"+(M<<0)+"px)",this.lastCurPieItemInd=s.ind,this.updateTipScrollClasses()},render:function(i){if(this.shown){var s,e,a,h=this.opts,o=h.state,n=this.opts.settings,r=n.PADD[0],d=n.PADD[1],l=n.PADD[2],p=n.PADD[3],c=0,m=this.opts.state.dims.tip,g=t.TUtils.getFormatter("yTooltipFormatter",h.data,o.zoomMorph),u=null==o.zoomMorph?0:o.zoomMorph,x=("bar"==h.graphStyle||"step"==h.graphStyle?this.opts.data.mainPeriodLen:0)*(1-u);if(i=i||{},this.abortDetailCallbacks(),this.$tip.classList.remove("tchart--tip__error"),this.$tip.classList.remove("tchart--tip__loading"),"area"==h.graphStyle&&o.zoomMode)this.renderPieTooltip(i);else{this.pieLabel&&(this.pieLabel.$row.style.display="none");var v=Math.max(Math.min(this.dx,m.w-1),0),f=o.x1+(o.x2-o.x1+x)*((v-p)/(m.w-d-p)),y=t.TUtils.getXIndex(h.data.x,f),M="bar"==h.graphStyle||"step"==h.graphStyle?Math.floor(y):Math.round(y);if("bar"!==h.graphStyle&&"step"!==h.graphStyle)(b=(h.data.x[M]-o.x1)/(o.x2-o.x1+x)*(m.w-p-d)+p<<0)<0&&M++,b>m.w-1&&M--;else(this.opts.state.zoomMode||this.opts.state.zoomModeSpecial)&&(M<h.state.detailInd1&&M++,M>h.state.detailInd2&&M--);if("bar"==h.graphStyle&&h.animator.add([{prop:"barInd",state:h.state,end:M,duration:0,tween:"linear",group:{top:!0}},{prop:"barO",state:this.opts.state,end:1,duration:150,tween:"exp",speed:.3,group:{top:!0}}]),this.prevXInd!=M||!i.isMove){this.$tip.classList.remove("tchart--tip__piemode"),this.$line&&this.$line.classList.remove("tchart--line__piemode"),this.labels.forEach(function(t,i){var s=h.state["e_"+i]&&!isNaN(h.data.ys[i].y[M])?"block":"none";t.$row.style.display=s,this.points&&(this.points[i].style.display=s),c+="block"==s?1:0}.bind(this)),this.itemsVisible=c,this.allLabel&&(this.allLabel.$row.style.display=c>1?"block":"none"),this.itemsVisible?(this.$tip.classList.remove("tchart--tip__has_no_items"),this.$line&&this.$line.classList.remove("tchart--line__has_no_items")):(this.$tip.classList.add("tchart--tip__has_no_items"),this.$line&&this.$line.classList.add("tchart--line__has_no_items"));var T=0;"step"==h.graphStyle&&(T=this.opts.state.zoomMode?h.data.detailPeriodLen:h.data.mainPeriodLen);var b=(h.data.x[M]-o.x1+T/2)/(o.x2-o.x1+x)*(m.w-p-d)+p<<0;this.$line&&(this.$line.style.transform="translateX("+b+"px)"),this.$line&&(this.$line.style.webkitTransform="translateX("+b+"px)"),this.$tipDtText.nodeValue=h.data.dates[M];var _=0;if(h.data.ys.forEach(function(t,i){if(h.state["e_"+i]&&!isNaN(t.y[M])&&(this.labels[i].$valueText.nodeValue=g(t.y[M]),_+=t.y[M]||0,this.points)){s=this.points[i],h.pairY?(e=o["y1_"+i],a=o["y2_"+i]):(e=o.y1,a=o.y2);var n=(t.y[M]-e)/(a-e);s.style.transform="translateY("+(m.h-n*(m.h-r-l)-l<<0)+"px)",s.style.webkitTransform="translateY("+(m.h-n*(m.h-r-l)-l<<0)+"px)"}}.bind(this)),this.allLabel&&(this.allLabel.$valueText.nodeValue=g(_)),!i.isMove){this.maxLabelWidth=0,this.maxValueWidth=0,this.maxPercentageWidth=0,this.maxDateWidth=0;var w=window.getComputedStyle(this.$tip);this.rowPaddings=parseInt(w.getPropertyValue("padding-left"),10)+parseInt(w.getPropertyValue("padding-right"),10)}"area"==h.graphStyle&&this.fillPercentages(M,_),this.labels.forEach(function(t,i){if(h.state["e_"+i]&&!isNaN(h.data.ys[i].y[M])){var s=t.$label.offsetWidth;s>this.maxLabelWidth&&(this.maxLabelWidth=s);var e=t.$value.offsetWidth;e>this.maxValueWidth&&(this.maxValueWidth=e)}}.bind(this));var D=this.rowPaddings+this.maxLabelWidth+20+this.maxValueWidth;D+="area"==h.graphStyle?this.maxPercentageWidth:0;var S=this.rowPaddings+this.$tipDt.offsetWidth+20;S>this.maxDateWidth&&(this.maxDateWidth=S),D=Math.max(D,this.maxDateWidth),this.$tip.style.width=D+"px",this.tipH=this.$tip.offsetHeight,this.tipW=this.$tip.offsetWidth}var I=this.itemsVisible<=2?"center":"side";if("center"==I){var $=this.dx-this.tipW/2;(L=Math.min(this.dy-20-this.tipH,m.t+m.h-this.tipH-l))<m.t+r&&(I="side")}if("side"==I){if(this.dx>m.w/2)$=this.dx-this.tipW-20;else $=this.dx+20;var L=Math.min(Math.max(this.dy-this.tipH/2,m.t+r),m.t+m.h-this.tipH-l)}$=Math.min(Math.max($,p/2),m.w-this.tipW-d/2),this.$tip.style.transform="translate("+($<<0)+"px,"+(L<<0)+"px)",this.$tip.style.webkitTransform="translate("+($<<0)+"px,"+(L<<0)+"px)",this.lastTipLeft=$<<0,this.lastTipTop=L<<0,this.prevXInd=M,this.updateTipScrollClasses()}}},updateTipScrollClasses:function(){this.$tipScroller.scrollHeight>this.$tipScroller.offsetHeight?this.$tip.classList.add("tchart--tip__scroll"):this.$tip.classList.remove("tchart--tip__scroll"),this.$tipScroller.scrollTop<=0?this.$tip.classList.remove("tchart--tip__has_less"):this.$tip.classList.add("tchart--tip__has_less"),this.$tipScroller.scrollTop>=this.$tipScroller.scrollHeight-this.$tipScroller.offsetHeight?this.$tip.classList.remove("tchart--tip__has_more"):this.$tip.classList.add("tchart--tip__has_more")},fillPercentages:function(t,i){var s=this.opts,e=[],a=2;s.data.ys.forEach(function(h,o){s.state["e_"+o]&&(e[o]=Math.max(Math.round(100*h.y[t]/i),1),isNaN(h.y[t])&&(e[o]=0),100==e[o]&&(a=3))}.bind(this)),s.data.ys.forEach(function(t,i){if(s.state["e_"+i]){var h=8*a+17;this.labels[i].$label.style.transform="translateX("+h+"px)",this.labels[i].$label.style.webkitTransform="translateX("+h+"px)",this.labels[i].$perText.nodeValue=e[i]+"%",this.labels[i].$per.style.width=h-7+"px",h>this.maxPercentageWidth&&(this.maxPercentageWidth=h)}}.bind(this))}},t.TTip=i}(),function(){Math.log2=Math.log2||function(t){return Math.log(t)*Math.LOG2E},Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E};var t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=["January","February","March","April","May","June","July","August","September","October","November","December"],e={simplifyData:function(t,i,s,e,a,h,o,n,r){var d=(n-o)/r,l=[],p=[];if(d<=1)return{xInd1:o,xInd2:n,x:i,ys:s};for(var c,m=0,g=-999999999,u=h.length,x=o;x<=n;x++){var v=i[x]*e+a<<0,f=v>g;for(f?(l[m]=i[x],m++):c++,j=0;j<u;j++){var y=h[j];p[y]=p[y]||{y:[]};var M=p[y].y[m-1],T=s[y].y[x];null==M?p[y].y[m-1]=T:p[y].y[m-1]+=T,m>1&&(f&&(p[y].y[m-2]/=c),x==n&&(p[y].y[m-1]/=c))}f&&(c=1),g=v}return o=0,n=m-1,{isOptimized:d>1,xInd1:0,xInd2:m-1,x:l,ys:p}},getElemPagePos:function(t){var i=t.getBoundingClientRect();return{x:i.left+(window.pageXOffset||document.documentElement.scrollLeft),y:i.top+(window.pageYOffset||document.documentElement.scrollTop)}},getXIndex:function(t,i,s){var e=0,a=t.length-1;for(s||(i<t[e]?i=t[e]:i>t[a]&&(i=t[a]));Math.abs(e-a)>1;){var h=Math.round((e+a)/2);i>=t[e]&&i<=t[h]?a=h:e=h}return e+(i-t[e])/(t[a]-t[e])},triggerEvent:function(t,i){"function"==typeof window.CustomEvent&&document.dispatchEvent(new CustomEvent(t,{detail:i||null}))},isTouchDevice:function(){var t=" -webkit- -moz- -o- -ms- ".split(" ");return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)||function(t){return window.matchMedia(t).matches}(["(",t.join("touch-enabled),("),"heartz",")"].join(""))},drawRoundedRect:function(t,i,s,e,a,h,o){s*=i,e*=i,a*=i,h*=i,"number"==typeof o&&(o=[o,o,o,o]),o[0]*=i,o[1]*=i,o[2]*=i,o[3]*=i,t.beginPath(),t.moveTo(a+o[0],h),t.lineTo(a+s-o[1],h),t.quadraticCurveTo(a+s,h,a+s,h+o[1]),t.lineTo(a+s,h+e-o[2]),t.quadraticCurveTo(a+s,h+e,a+s-o[2],h+e),t.lineTo(a+o[3],h+e),t.quadraticCurveTo(a,h+e,a,h+e-o[3]),t.lineTo(a,h+o[0]),t.quadraticCurveTo(a,h,a+o[0],h),t.closePath()},drawRoundedRect2:function(t,i,s,e,a,h,o){a*=i,h*=i,(s*=i)<2*(o*=i)&&(o=s/2),(e*=i)<2*o&&(o=e/2),t.beginPath(),t.moveTo(a+o,h),t.arcTo(a+s,h,a+s,h+e,o),t.arcTo(a+s,h+e,a,h+e,o),t.arcTo(a,h+e,a,h,o),t.arcTo(a,h,a+s,h,o),t.closePath()},getFormatter:function(t,i,s){var a;return s>.5&&i.details&&(a=i.details[t]),a||i[t]||e[t]},xTooltipFormatter:function(s,e){var a=new Date(s),h=[a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCDay(),a.getUTCHours(),a.getUTCMinutes()];return e?(h[4]<10?"0":"")+h[4]+":"+(h[5]<10?"0":"")+h[5]:i[h[3]]+", "+h[2]+" "+t[h[1]]+" "+h[0]},xTickFormatter:function(i,s){var e=new Date(i),a=[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCDay(),e.getUTCHours(),e.getUTCMinutes()];return s?(a[4]<10?"0":"")+a[4]+":"+(a[5]<10?"0":"")+a[5]:a[2]+" "+t[a[1]]},xRangeFormatter:function(t,i){var e=new Date(t),a=[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()];return a[2]+" "+s[a[1]]+" "+a[0]},yTickFormatter:function(t,i,s){return 0==t?0:i<1e3?Math.floor(t):i>=1e3&&i<1e6?s?Math.floor(10*t/1e3)/10+"K":Math.round(t/1e3)+"K":s?Math.floor(10*t/1e6)/10+"M":Math.round(t/1e6)+"M"},yTooltipFormatter:function(t){return"number"!=typeof t?"string"==typeof t?t:"?":e.statsFormatKMBT(t)},statsFormatKMBT:function(t,i,s){if(0==t)return"0";null==i&&(i=e.statsChooseNumKMBT(t));var a=e.statsFormatFixedKMBT(t,i);return null==s&&(s=e.statsChoosePrecision(a)),a.toFixed(s)+i},statsFormatFixedKMBT:function(t,i){switch(i){case"K":return t/1e3;case"M":return t/1e6;case"B":return t/1e9;case"T":return t/1e12}return t},statsChoosePrecision:function(t){var i=Math.abs(t);return i>10?0:i>=1?Math.abs(i-Math.floor(i))<.001?0:1:2},statsChooseNumKMBT:function(t){var i=Math.abs(t);return i>=1e12?"T":i>=1e9?"B":i>=1e6?"M":i>=2e3?"K":""},roundRange:function(t,i,s,e){if(Math.abs(i-t)<1&&(t-=t/10,i+=i/10),e){var a=(e.yMinOrig-e.yMin)/(e.yMaxOrig-e.yMinOrig),h=(e.yMax-e.yMaxOrig)/(e.yMaxOrig-e.yMinOrig);return{yMin:t-(i-t)*a,yMax:i+(i-t)*h,yMinOrig:t,yMaxOrig:i}}for(var o,n=function(e){var a=l*e,h=Math.floor(t/a)*a,o=h+s*Math.ceil((i-h)*r/a)*a;return{good:o<=c&&h>=p,yMin:Math.round(h),yMax:Math.round(o),yMinOrig:t,yMaxOrig:i}},r=1/s,d=(i-t)*r,l=Math.max(Math.pow(10,Math.floor(Math.log10(d))),1),p=t-.5*d,c=i+.5*d,m=1;!(o=n(5)).good&&!(o=n(2)).good&&!(o=n(1)).good;)if(l*=.1,++m>10)return{yMinOrig:t,yMaxOrig:i,yMin:t,yMax:i};return o}};window.Graph.units.TUtils=e}();