UNPKG

lightweight-charts

Version:

Financial lightweight charts built with HTML5 canvas

7 lines 139 kB
/*! * @license * TradingView Lightweight Charts v3.1.5 * Copyright (c) 2020 TradingView, Inc. * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ !function(){"use strict";var t,i;function n(t,i){var n,h=((n={})[0]=[],n[1]=[t.lineWidth,t.lineWidth],n[2]=[2*t.lineWidth,2*t.lineWidth],n[3]=[6*t.lineWidth,6*t.lineWidth],n[4]=[t.lineWidth,4*t.lineWidth],n)[i];t.setLineDash(h)}function h(t,i,n,h){t.beginPath();var s=t.lineWidth%2?.5:0;t.moveTo(n,i+s),t.lineTo(h,i+s),t.stroke()}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps"}(t||(t={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(i||(i={}));var s=function(t,i){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])})(t,i)};function r(t,i){function n(){this.constructor=t}s(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var e=function(){return(e=Object.assign||function(t){for(var i,n=1,h=arguments.length;n<h;n++)for(var s in i=arguments[n])Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s]);return t}).apply(this,arguments)};function u(){for(var t=0,i=0,n=arguments.length;i<n;i++)t+=arguments[i].length;var h=Array(t),s=0;for(i=0;i<n;i++)for(var r=arguments[i],e=0,u=r.length;e<u;e++,s++)h[s]=r[e];return h}function o(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function a(t){if(void 0===t)throw new Error("Value is undefined");return t}function l(t){if(null===t)throw new Error("Value is null");return t}function f(t){return l(a(t))}function c(t){for(var i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];for(var h=0,s=i;h<s.length;h++){var r=s[h];for(var e in r)void 0!==r[e]&&("object"!=typeof r[e]||void 0===t[e]?t[e]=r[e]:c(t[e],r[e]))}return t}function v(t){return"number"==typeof t&&isFinite(t)}function _(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function w(t){return"boolean"==typeof t}function M(t){var i,n,h,s=t;if(!s||"object"!=typeof s)return s;for(n in i=Array.isArray(s)?[]:{},s)s.hasOwnProperty(n)&&(h=s[n],i[n]=h&&"object"==typeof h?M(h):h);return i}function b(t){return null!==t}function m(t){return null===t?void 0:t}var g=function(){function t(){this.t=[]}return t.prototype.i=function(t){this.t=t},t.prototype.h=function(t,i,n,h){this.t.forEach((function(s){t.save(),s.h(t,i,n,h),t.restore()}))},t}(),p=function(){function t(){}return t.prototype.h=function(t,i,n,h){t.save(),t.scale(i,i),this.s(t,n,h),t.restore()},t.prototype.u=function(t,i,n,h){t.save(),t.scale(i,i),this.o(t,n,h),t.restore()},t.prototype.o=function(t,i,n){},t}(),y=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.l=null,i}return r(i,t),i.prototype.v=function(t){this.l=t},i.prototype.s=function(t){if(null!==this.l&&null!==this.l._){var i=this.l._,n=this.l,h=function(h){t.beginPath();for(var s=i.to-1;s>=i.from;--s){var r=n.M[s];t.moveTo(r.m,r.g),t.arc(r.m,r.g,h,0,2*Math.PI)}t.fill()};t.fillStyle=n.p,h(n.k+2),t.fillStyle=n.N,h(n.k)}},i}(p);var k,x,N,S={from:0,to:1},D=function(){function t(t,i){this.S=new g,this.D=[],this.C=[],this.T=!0,this.A=t,this.L=i,this.S.i(this.D)}return t.prototype.B=function(t){var i=this,n=this.A.F();n.length!==this.D.length&&(this.C=n.map((function(){return{M:[{m:0,g:0,V:0,O:0}],N:"",p:i.A.P().layout.backgroundColor,k:0,_:null}})),this.D=this.C.map((function(t){var i=new y;return i.v(t),i})),this.S.i(this.D)),this.T=!0},t.prototype.I=function(t,i,n){return this.T&&(this.W(),this.T=!1),this.S},t.prototype.W=function(){var t=this,i=this.A.F(),n=this.L.R(),h=this.A.j();i.forEach((function(i,s){var r=t.C[s],e=i.U(n);if(null!==e){var u=l(i.q());r.N=i.K().Y(n).H,r.p=t.A.P().layout.backgroundColor,r.k=e.k,r.M[0].O=e.O,r.M[0].g=i.X().$(e.O,u.Z),r.M[0].V=n,r.M[0].m=h.J(n),r._=S}else r._=null}))},t}(),C=function(){function t(t){this.G=t}return t.prototype.h=function(t,i,s,r){if(null!==this.G){var e=this.G.it.tt,u=this.G.nt.tt;if(e||u){t.save();var o=Math.round(this.G.m*i),a=Math.round(this.G.g*i),l=Math.ceil(this.G.ht*i),f=Math.ceil(this.G.st*i);t.lineCap="butt",e&&o>=0&&(t.lineWidth=Math.floor(this.G.it.rt*i),t.strokeStyle=this.G.it.et,t.fillStyle=this.G.it.et,n(t,this.G.it.ut),function(t,i,n,h){t.beginPath();var s=t.lineWidth%2?.5:0;t.moveTo(i+s,n),t.lineTo(i+s,h),t.stroke()}(t,o,0,f)),u&&a>=0&&(t.lineWidth=Math.floor(this.G.nt.rt*i),t.strokeStyle=this.G.nt.et,t.fillStyle=this.G.nt.et,n(t,this.G.nt.ut),h(t,a,0,l)),t.restore()}}},t}(),T=function(){function t(t){this.T=!0,this.ot={it:{rt:1,ut:0,et:"",tt:!1},nt:{rt:1,ut:0,et:"",tt:!1},ht:0,st:0,m:0,g:0},this.at=new C(this.ot),this.lt=t}return t.prototype.B=function(){this.T=!0},t.prototype.I=function(t,i){return this.T&&(this.W(),this.T=!1),this.at},t.prototype.W=function(){var t=this.lt.tt(),i=l(this.lt.ft()),n=i.ct().P().crosshair,h=this.ot;h.nt.tt=t&&this.lt.vt(i),h.it.tt=t&&this.lt._t(),h.nt.rt=n.horzLine.width,h.nt.ut=n.horzLine.style,h.nt.et=n.horzLine.color,h.it.rt=n.vertLine.width,h.it.ut=n.vertLine.style,h.it.et=n.vertLine.color,h.ht=i.dt(),h.st=i.wt(),h.m=this.lt.Mt(),h.g=this.lt.bt()},t}(),A={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",feldspar:"#d19275",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslateblue:"#8470ff",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",violetred:"#d02090",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function E(t){return function(t,i,n){return(h=i)<=0||h>0?i<t?t:i>n?n:Math.round(i):t;var h}(0,t,255)}function L(t){if("transparent"===(t=t.toLowerCase()))return[0,0,0];t in A&&(t=A[t]);var i=function(t){var i=N.rgbaRe.exec(t)||N.rgbRe.exec(t);return null!==i?N.parse(i):null}(t);if(null!==i)return i;var n,h,s=(n=t,null!==(h=x.re.exec(n))?x.parse(h):null);if(null!==s)return s;var r=function(t){var i=k.re.exec(t);return null!==i?k.parse(i):null}(t);if(null!==r)return r;throw new Error("Cannot parse color: "+t)}function B(t){var i,n=L(t);return{gt:"rgb("+n[0]+", "+n[1]+", "+n[2]+")",pt:(i=n,.199*i[0]+.687*i[1]+.114*i[2]>160?"black":"white")}}function F(t,i,n,h,s,r){t.fillRect(i,n,r,s),t.fillRect(i+r,n,h-2*r,r),t.fillRect(i+r,n+s-r,h-2*r,r),t.fillRect(i+h-r,n,r,s)}function V(t,i,n){t.save(),t.scale(i,i),n(),t.restore()}function z(t,i,n,h,s,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,n,h,s),t.restore()}!function(t){t.re=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/,t.parse=function(t){return[E(parseInt(t[1]+t[1],16)),E(parseInt(t[2]+t[2],16)),E(parseInt(t[3]+t[3],16))]}}(k||(k={})),function(t){t.re=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/,t.parse=function(t){return[E(parseInt(t[1],16)),E(parseInt(t[2],16)),E(parseInt(t[3],16))]}}(x||(x={})),function(t){t.rgbRe=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,t.rgbaRe=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/,t.parse=function(t){return[E(parseInt(t[1],10)),E(parseInt(t[2],10)),E(parseInt(t[3],10))]}}(N||(N={}));var O,P=function(){function t(t,i){this.v(t,i)}return t.prototype.v=function(t,i){this.G=t,this.yt=i},t.prototype.h=function(t,i,n,h,s,r){if(this.G.tt){t.font=i.kt;var e=this.G.xt||!this.G.Nt?i.St:0,u=i.Dt,o=i.Ct,a=i.Tt,l=i.At,f=i.Et,c=this.G.Lt,v=Math.ceil(n.Bt(t,c)),_=i.Ft,d=i.Vt+o+a,w=Math.ceil(.5*d),M=u+v+l+f+e,b=this.yt.zt;this.yt.Ot&&(b=this.yt.Ot);var m,g,p=(b=Math.round(b))-w,y=p+d,k="right"===s,x=k?h:0,N=Math.ceil(h*r),S=x;if(t.fillStyle=this.yt.gt,t.lineWidth=1,t.lineCap="butt",c){k?(m=x-e,g=(S=x-M)+f):(S=x+M,m=x+e,g=x+u+e+l);var D=Math.max(1,Math.floor(r)),C=Math.max(1,Math.floor(u*r)),T=k?N:0,A=Math.round(p*r),E=Math.round(S*r),L=Math.round(b*r)-Math.floor(.5*r),B=L+D+(L-A),F=Math.round(m*r);t.save(),t.beginPath(),t.moveTo(T,A),t.lineTo(E,A),t.lineTo(E,B),t.lineTo(T,B),t.fill(),t.fillStyle=this.G.Pt,t.fillRect(k?N-C:0,A,C,B-A),this.G.xt&&(t.fillStyle=this.yt.et,t.fillRect(T,L,F-T,D)),t.textAlign="left",t.fillStyle=this.yt.et,V(t,r,(function(){t.fillText(c,g,y-a-_)})),t.restore()}}},t.prototype.wt=function(t,i){return this.G.tt?t.Vt+t.Ct+t.Tt:0},t}(),I=function(){function t(t){this.It={zt:0,et:"#FFF",gt:"#000"},this.Wt={Lt:"",tt:!1,xt:!0,Nt:!1,Pt:""},this.Rt={Lt:"",tt:!1,xt:!1,Nt:!0,Pt:""},this.T=!0,this.jt=new(t||P)(this.Wt,this.It),this.Ut=new(t||P)(this.Rt,this.It)}return t.prototype.Lt=function(){return this.Wt.Lt},t.prototype.zt=function(){return this.qt(),this.It.zt},t.prototype.B=function(){this.T=!0},t.prototype.wt=function(t,i){return void 0===i&&(i=!1),Math.max(this.jt.wt(t,i),this.Ut.wt(t,i))},t.prototype.Ht=function(){return this.It.Ot||0},t.prototype.Yt=function(t){this.It.Ot=t},t.prototype.Kt=function(){return this.qt(),this.Wt.tt||this.Rt.tt},t.prototype.$t=function(){return this.qt(),this.Wt.tt},t.prototype.I=function(t){return this.qt(),this.Wt.xt=this.Wt.xt&&t.P().drawTicks,this.Rt.xt=this.Rt.xt&&t.P().drawTicks,this.jt.v(this.Wt,this.It),this.Ut.v(this.Rt,this.It),this.jt},t.prototype.Xt=function(){return this.qt(),this.jt.v(this.Wt,this.It),this.Ut.v(this.Rt,this.It),this.Ut},t.prototype.qt=function(){this.T&&(this.Wt.xt=!0,this.Rt.xt=!1,this.Zt(this.Wt,this.Rt,this.It))},t}(),W=function(t){function i(i,n,h){var s=t.call(this)||this;return s.lt=i,s.Jt=n,s.Gt=h,s}return r(i,t),i.prototype.Zt=function(t,i,n){t.tt=!1;var h=this.lt.P().horzLine;if(h.labelVisible){var s=this.Jt.q();if(this.lt.tt()&&!this.Jt.Qt()&&null!==s){var r=B(h.labelBackgroundColor);n.gt=r.gt,n.et=r.pt;var e=this.Gt(this.Jt);n.zt=e.zt,t.Lt=this.Jt.ti(e.O,s),t.tt=!0}}},i}(I),R=/[1-9]/g,j=function(){function t(){this.G=null}return t.prototype.v=function(t){this.G=t},t.prototype.h=function(t,i,n){var h=this;if(null!==this.G&&!1!==this.G.tt&&0!==this.G.Lt.length){t.font=i.kt;var s=Math.round(i.ii.Bt(t,this.G.Lt,R));if(!(s<=0)){t.save();var r=i.ni,e=s+2*r,u=e/2,o=this.G.dt,a=this.G.zt,f=Math.floor(a-u)+.5;f<0?(a+=Math.abs(0-f),f=Math.floor(a-u)+.5):f+e>o&&(a-=Math.abs(o-(f+e)),f=Math.floor(a-u)+.5);var c=f+e,v=0+i.Dt+i.Ct+i.Vt+i.Tt;t.fillStyle=this.G.gt;var _=Math.round(f*n),d=Math.round(0*n),w=Math.round(c*n),M=Math.round(v*n);t.fillRect(_,d,w-_,M-d);var b=Math.round(this.G.zt*n),m=d,g=Math.round((m+i.Dt+i.St)*n);t.fillStyle=this.G.et;var p=Math.max(1,Math.floor(n)),y=Math.floor(.5*n);t.fillRect(b-y,m,p,g-m);var k=v-i.Ft-i.Tt;t.textAlign="left",t.fillStyle=this.G.et,V(t,n,(function(){t.fillText(l(h.G).Lt,f+r,k)})),t.restore()}}},t}(),U=function(){function t(t,i,n){this.T=!0,this.at=new j,this.ot={tt:!1,gt:"#4c525e",et:"white",Lt:"",dt:0,zt:NaN},this.L=t,this.hi=i,this.Gt=n}return t.prototype.B=function(){this.T=!0},t.prototype.I=function(){return this.T&&(this.W(),this.T=!1),this.at.v(this.ot),this.at},t.prototype.W=function(){var t=this.ot;t.tt=!1;var i=this.L.P().vertLine;if(i.labelVisible){var n=this.hi.j();if(!n.Qt()){var h=n.si(this.L.R());t.dt=n.dt();var s=this.Gt();if(s.V){t.zt=s.zt,t.Lt=n.ri(l(h)),t.tt=!0;var r=B(i.labelBackgroundColor);t.gt=r.gt,t.et=r.pt}}}},t}(),q=function(){function t(){this.ei=null,this.ui=0}return t.prototype.oi=function(){return this.ui},t.prototype.ai=function(t){this.ui=t},t.prototype.X=function(){return this.ei},t.prototype.li=function(t){this.ei=t},t.prototype.fi=function(t,i){return[]},t.prototype.ci=function(t){return[]},t.prototype.vi=function(){return[]},t}();!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet"}(O||(O={}));var H=function(t){function i(i,n){var h=t.call(this)||this;h._i=null,h.di=NaN,h.wi=0,h.Mi=!0,h.bi=new Map,h.mi=!1,h.gi=NaN,h.pi=NaN,h.yi=NaN,h.ki=NaN,h.hi=i,h.xi=n,h.Ni=new D(i,h);var s,r;h.Si=(s=function(){return h.di},r=function(){return h.pi},function(t){var i=r(),n=s();if(t===l(h._i).Di())return{O:n,zt:i};var e=l(t.q());return{O:t.Ci(i,e),zt:i}});var e=function(t,i){return function(){return{V:h.hi.j().si(t()),zt:i()}}}((function(){return h.wi}),(function(){return h.Mt()}));return h.Ti=new U(h,i,e),h.Ai=new T(h),h}return r(i,t),i.prototype.P=function(){return this.xi},i.prototype.Ei=function(t,i){this.yi=t,this.ki=i},i.prototype.Li=function(){this.yi=NaN,this.ki=NaN},i.prototype.Bi=function(){return this.yi},i.prototype.Fi=function(){return this.ki},i.prototype.Vi=function(t,i,n){this.mi||(this.mi=!0),this.Mi=!0,this.zi(t,i,n)},i.prototype.R=function(){return this.wi},i.prototype.Mt=function(){return this.gi},i.prototype.bt=function(){return this.pi},i.prototype.tt=function(){return this.Mi},i.prototype.Oi=function(){this.Mi=!1,this.Pi(),this.di=NaN,this.gi=NaN,this.pi=NaN,this._i=null,this.Li()},i.prototype.ci=function(t){return null!==this._i?[this.Ai,this.Ni]:[]},i.prototype.vt=function(t){return t===this._i&&this.xi.horzLine.visible},i.prototype._t=function(){return this.xi.vertLine.visible},i.prototype.fi=function(t,i){this.Mi&&this._i===t||this.bi.clear();var n=[];return this._i===t&&n.push(this.Ii(this.bi,i,this.Si)),n},i.prototype.vi=function(){return this.Mi?[this.Ti]:[]},i.prototype.ft=function(){return this._i},i.prototype.Wi=function(){this.Ai.B(),this.bi.forEach((function(t){return t.B()})),this.Ti.B(),this.Ni.B()},i.prototype.Ri=function(t){return t&&!t.Di().Qt()?t.Di():null},i.prototype.zi=function(t,i,n){this.ji(t,i,n)&&this.Wi()},i.prototype.ji=function(t,i,n){var h=this.gi,s=this.pi,r=this.di,e=this.wi,u=this._i,o=this.Ri(n);this.wi=t,this.gi=isNaN(t)?NaN:this.hi.j().J(t),this._i=n;var a=null!==o?o.q():null;return null!==o&&null!==a?(this.di=i,this.pi=o.$(i,a)):(this.di=NaN,this.pi=NaN),h!==this.gi||s!==this.pi||e!==this.wi||r!==this.di||u!==this._i},i.prototype.Pi=function(){var t=this.hi.F().map((function(t){return t.qi().Ui()})).filter(b),i=0===t.length?null:Math.max.apply(Math,t);this.wi=null!==i?i:NaN},i.prototype.Ii=function(t,i,n){var h=t.get(i);return void 0===h&&(h=new W(this,i,n),t.set(i,h)),h},i}(q),Y=".",K="'";function $(t,i){if(!v(t))return"n/a";if(!_(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}var X=function(){function t(t,i,n,h){if(i||(i=1),v(t)&&_(t)||(t=100),t<0)throw new TypeError("invalid base");this.Jt=t,this.Hi=i,this.Yi=h,n&&void 0!==h&&h>0&&2!==h&&4!==h&&8!==h||(this.Ki=n,this.$i())}return t.prototype.Xi=function(t){var i=t<0?"−":"";return t=Math.abs(t),this.Ki?i+this.Zi(t):i+this.Ji(t)},t.prototype.$i=function(){if(this.Gi=0,this.Jt>0&&this.Hi>0){var t=this.Jt;for(this.Ki&&this.Yi&&(t/=this.Yi);t>1;)t/=10,this.Gi++}},t.prototype.Ji=function(t){var i;i=this.Ki?Math.pow(10,this.Gi||0):this.Jt/this.Hi;var n=Math.floor(t),h="",s=void 0!==this.Gi?this.Gi:NaN;if(i>1){var r=+(Math.round(t*i)-n*i).toFixed(this.Gi);r>=i&&(r-=i,n+=1),h=Y+$(+r.toFixed(this.Gi)*this.Hi,s)}else n=Math.round(n*i)/i,s>0&&(h=Y+$(0,s));return n.toFixed(0)+h},t.prototype.Zi=function(t){var i=this.Jt/this.Hi,n=Math.floor(t),h=Math.round(t*i)-n*i;if(h===i&&(h=0,n+=1),!this.Gi)throw new Error("_fractionalLength is not calculated");var s="";if(this.Yi){var r=h%this.Yi,e=$(h=(h-r)/this.Yi,this.Gi),u=2===this.Yi?["0","5"][r]:8===this.Yi?["0","1","2","3","4","5","6","7"][r]:["0","2","5","7"][r];s=e+K+u}else s=$(h*this.Hi,this.Gi);return n.toString()+K+s},t}(),Z=function(t){function i(i){return void 0===i&&(i=100),t.call(this,i)||this}return r(i,t),i.prototype.Xi=function(i){return t.prototype.Xi.call(this,i)+"%"},i}(X),J=function(){function t(){this.Qi=[]}return t.prototype.tn=function(t,i,n){var h={in:t,nn:i,hn:!0===n};this.Qi.push(h)},t.prototype.sn=function(t){var i=this.Qi.findIndex((function(i){return t===i.in}));i>-1&&this.Qi.splice(i,1)},t.prototype.rn=function(t){this.Qi=this.Qi.filter((function(i){return i.nn===t}))},t.prototype.en=function(t,i){var n=u(this.Qi);this.Qi=this.Qi.filter((function(t){return!t.hn})),n.forEach((function(n){return n.in(t,i)}))},t.prototype.un=function(){return this.Qi.length>0},t.prototype.on=function(){this.Qi=[]},t}(),G=function(){function t(t,i){this.an=t,this.ln=i}return t.prototype.fn=function(t){return null!==t&&(this.an===t.an&&this.ln===t.ln)},t.prototype.cn=function(){return new t(this.an,this.ln)},t.prototype.vn=function(){return this.an},t.prototype._n=function(){return this.ln},t.prototype.dn=function(){return this.ln-this.an},t.prototype.Qt=function(){return this.ln===this.an||Number.isNaN(this.ln)||Number.isNaN(this.an)},t.prototype.wn=function(i){return null===i?this:new t(Math.min(this.vn(),i.vn()),Math.max(this._n(),i._n()))},t.prototype.Mn=function(t){if(v(t)&&0!==this.ln-this.an){var i=.5*(this.ln+this.an),n=this.ln-i,h=this.an-i;n*=t,h*=t,this.ln=i+n,this.an=i+h}},t.prototype.bn=function(t){v(t)&&(this.ln+=t,this.an+=t)},t.prototype.mn=function(){return{minValue:this.an,maxValue:this.ln}},t.gn=function(i){return null===i?null:new t(i.minValue,i.maxValue)},t}();function Q(t,i,n){return Math.min(Math.max(t,i),n)}function tt(t,i,n){return i-t<=n}function it(t){return t<=0?NaN:Math.log(t)/Math.log(10)}function nt(t){var i=Math.ceil(t);return i%2!=0?i-1:i}function ht(t){var i=Math.ceil(t);return i%2==0?i-1:i}function st(t,i){var n=100*(t-i)/i;return i<0?-n:n}function rt(t,i){var n=st(t.vn(),i),h=st(t._n(),i);return new G(n,h)}function et(t,i){var n=100*(t-i)/i+100;return i<0?-n:n}function ut(t,i){var n=et(t.vn(),i),h=et(t._n(),i);return new G(n,h)}function ot(t){var i=Math.abs(t);if(i<1e-8)return 0;var n=it(i+1e-4)+4;return t<0?-n:n}function at(t){var i=Math.abs(t);if(i<1e-8)return 0;var n=Math.pow(10,i-4)-1e-4;return t<0?-n:n}function lt(t){if(null===t)return null;var i=ot(t.vn()),n=ot(t._n());return new G(i,n)}var ft,ct=function(){function t(t,i){if(this.pn=t,this.yn=i,function(t){if(t<0)return!1;for(var i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.pn))this.kn=[2,2.5,2];else{this.kn=[];for(var n=this.pn;1!==n;){if(n%2==0)this.kn.push(2),n/=2;else{if(n%5!=0)throw new Error("unexpected base");this.kn.push(2),this.kn.push(2.5),n/=5}if(this.kn.length>100)throw new Error("something wrong with base")}}}return t.prototype.xn=function(t,i,n){for(var h,s,r,e=0===this.pn?0:1/this.pn,u=Math.pow(10,Math.max(0,Math.ceil(it(t-i)))),o=0,a=this.yn[0];;){var l=tt(u,e,1e-9)&&u>e+1e-9,f=tt(u,n*a,1e-9),c=tt(u,1,1e-9);if(!(l&&f&&c))break;u/=a,a=this.yn[++o%this.yn.length]}if(u<=e+1e-9&&(u=e),u=Math.max(1,u),this.kn.length>0&&(h=u,s=1,r=1e-9,Math.abs(h-s)<r))for(o=0,a=this.kn[0];tt(u,n*a,1e-9)&&u>e+1e-9;)u/=a,a=this.kn[++o%this.kn.length];return u},t}(),vt=function(){function t(t,i,n,h){this.Nn=[],this.Jt=t,this.pn=i,this.Sn=n,this.Dn=h}return t.prototype.xn=function(t,i){if(t<i)throw new Error("high < low");var n=this.Jt.wt(),h=(t-i)*this.Cn()/n,s=new ct(this.pn,[2,2.5,2]),r=new ct(this.pn,[2,2,2.5]),e=new ct(this.pn,[2.5,2,2]),u=[];return u.push(s.xn(t,i,h)),u.push(r.xn(t,i,h)),u.push(e.xn(t,i,h)),function(t){if(t.length<1)throw Error("array is empty");for(var i=t[0],n=1;n<t.length;++n)t[n]<i&&(i=t[n]);return i}(u)},t.prototype.Tn=function(){var t=this.Jt,i=t.q();if(null!==i){var n=t.wt(),h=this.Sn(n-1,i),s=this.Sn(0,i),r=this.Jt.P().entireTextOnly?this.An()/2:0,e=r,u=n-1-r,o=Math.max(h,s),a=Math.min(h,s);if(o!==a){for(var l=this.xn(o,a),f=o%l,c=o>=a?1:-1,v=null,_=0,d=o-(f+=f<0?l:0);d>a;d-=l){var w=this.Dn(d,i,!0);null!==v&&Math.abs(w-v)<this.Cn()||(w<e||w>u||(_<this.Nn.length?(this.Nn[_].En=w,this.Nn[_].Ln=t.Bn(d)):this.Nn.push({En:w,Ln:t.Bn(d)}),_++,v=w,t.Fn()&&(l=this.xn(d*c,a))))}this.Nn.length=_}else this.Nn=[]}else this.Nn=[]},t.prototype.Vn=function(){return this.Nn},t.prototype.An=function(){return this.Jt.Vt()},t.prototype.Cn=function(){return Math.ceil(2.5*this.An())},t}();function _t(t){return t.slice().sort((function(t,i){return l(t.oi())-l(i.oi())}))}!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(ft||(ft={}));var dt,wt=new Z,Mt=new X(100,1),bt=function(){function t(t,i,n,h){this.zn=0,this.On=null,this.Pn=null,this.In=null,this.Wn={Rn:!1,jn:null},this.Un=0,this.qn=0,this.Hn=new J,this.Yn=new J,this.Kn=[],this.$n=null,this.Xn=null,this.Zn=null,this.Jn=null,this.Gn=Mt,this.Qn=t,this.xi=i,this.th=n,this.ih=h,this.nh=new vt(this,100,this.hh.bind(this),this.sh.bind(this))}return t.prototype.rh=function(){return this.Qn},t.prototype.P=function(){return this.xi},t.prototype.eh=function(t){if(c(this.xi,t),this.uh(),void 0!==t.mode&&this.oh({ah:t.mode}),void 0!==t.scaleMargins){var i=a(t.scaleMargins.top),n=a(t.scaleMargins.bottom);if(i<0||i>1)throw new Error("Invalid top margin - expect value between 0 and 1, given="+i);if(n<0||n>1||i+n>1)throw new Error("Invalid bottom margin - expect value between 0 and 1, given="+n);if(i+n>1)throw new Error("Invalid margins - sum of margins must be less than 1, given="+(i+n));this.lh(),this.Xn=null}},t.prototype.fh=function(){return this.xi.autoScale},t.prototype.Fn=function(){return 1===this.xi.mode},t.prototype.vh=function(){return 2===this.xi.mode},t.prototype._h=function(){return 3===this.xi.mode},t.prototype.ah=function(){return{dh:this.xi.autoScale,wh:this.xi.invertScale,ah:this.xi.mode}},t.prototype.oh=function(t){var i=this.ah(),n=null;void 0!==t.dh&&(this.xi.autoScale=t.dh),void 0!==t.ah&&(this.xi.mode=t.ah,2!==t.ah&&3!==t.ah||(this.xi.autoScale=!0),this.Wn.Rn=!1),1===i.ah&&t.ah!==i.ah&&(!function(t){if(null===t)return!1;var i=at(t.vn()),n=at(t._n());return isFinite(i)&&isFinite(n)}(this.Pn)?this.xi.autoScale=!0:null!==(n=function(t){if(null===t)return null;var i=at(t.vn()),n=at(t._n());return new G(i,n)}(this.Pn))&&this.Mh(n)),1===t.ah&&t.ah!==i.ah&&null!==(n=lt(this.Pn))&&this.Mh(n);var h=i.ah!==this.xi.mode;h&&(2===i.ah||this.vh())&&this.uh(),h&&(3===i.ah||this._h())&&this.uh(),void 0!==t.wh&&i.wh!==t.wh&&(this.xi.invertScale=t.wh,this.bh()),this.Yn.en(i,this.ah())},t.prototype.mh=function(){return this.Yn},t.prototype.Vt=function(){return this.th.fontSize},t.prototype.wt=function(){return this.zn},t.prototype.gh=function(t){this.zn!==t&&(this.zn=t,this.lh(),this.Xn=null)},t.prototype.ph=function(){if(this.On)return this.On;var t=this.wt()-this.yh()-this.kh();return this.On=t,t},t.prototype.xh=function(){return this.Nh(),this.Pn},t.prototype.Mh=function(t,i){var n=this.Pn;(i||null===n&&null!==t||null!==n&&!n.fn(t))&&(this.Xn=null,this.Pn=t)},t.prototype.Qt=function(){return this.Nh(),0===this.zn||!this.Pn||this.Pn.Qt()},t.prototype.Sh=function(t){return this.wh()?t:this.wt()-1-t},t.prototype.$=function(t,i){return this.vh()?t=st(t,i):this._h()&&(t=et(t,i)),this.sh(t,i)},t.prototype.Dh=function(t,i,n){this.Nh();for(var h=this.kh(),s=l(this.xh()),r=s.vn(),e=s._n(),u=this.ph()-1,o=this.wh(),a=u/(e-r),f=void 0===n?0:n.from,c=void 0===n?t.length:n.to,v=this.Ch(),_=f;_<c;_++){var d=t[_],w=d.O;if(!isNaN(w)){var M=w;null!==v&&(M=v(d.O,i));var b=h+a*(M-r),m=o?b:this.zn-1-b;d.g=m}}},t.prototype.Th=function(t,i,n){this.Nh();for(var h=this.kh(),s=l(this.xh()),r=s.vn(),e=s._n(),u=this.ph()-1,o=this.wh(),a=u/(e-r),f=void 0===n?0:n.from,c=void 0===n?t.length:n.to,v=this.Ch(),_=f;_<c;_++){var d=t[_],w=d.open,M=d.high,b=d.low,m=d.close;null!==v&&(w=v(d.open,i),M=v(d.high,i),b=v(d.low,i),m=v(d.close,i));var g=h+a*(w-r),p=o?g:this.zn-1-g;d.Ah=p,g=h+a*(M-r),p=o?g:this.zn-1-g,d.Eh=p,g=h+a*(b-r),p=o?g:this.zn-1-g,d.Lh=p,g=h+a*(m-r),p=o?g:this.zn-1-g,d.Bh=p}},t.prototype.Ci=function(t,i){var n=this.hh(t,i);return this.Fh(n,i)},t.prototype.Fh=function(t,i){var n=t;return this.vh()?n=function(t,i){return i<0&&(t=-t),t/100*i+i}(n,i):this._h()&&(n=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(n,i)),n},t.prototype.Vh=function(){return this.Kn},t.prototype.zh=function(){if(this.$n)return this.$n;for(var t=[],i=0;i<this.Kn.length;i++){var n=this.Kn[i];null===n.oi()&&n.ai(i+1),t.push(n)}return t=_t(t),this.$n=t,this.$n},t.prototype.Oh=function(t){-1===this.Kn.indexOf(t)&&(this.Kn.push(t),this.uh(),this.Ph())},t.prototype.Ih=function(t){var i=this.Kn.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.Kn.splice(i,1),this.Qt()&&this.oh({dh:!0}),this.uh(),this.Ph()},t.prototype.q=function(){for(var t=null,i=0,n=this.Kn;i<n.length;i++){var h=n[i].q();null!==h&&((null===t||h.Wh<t.Wh)&&(t=h))}return null===t?null:t.Z},t.prototype.wh=function(){return this.xi.invertScale},t.prototype.Vn=function(){return this.Xn||(this.nh.Tn(),this.Xn=this.nh.Vn(),this.Hn.en()),this.Xn},t.prototype.Rh=function(){return this.Hn},t.prototype.jh=function(t){this.vh()||this._h()||null===this.Zn&&null===this.In&&(this.Qt()||(this.Zn=this.zn-t,this.In=l(this.xh()).cn()))},t.prototype.Uh=function(t){if(!this.vh()&&!this._h()&&null!==this.Zn){this.oh({dh:!1}),(t=this.zn-t)<0&&(t=0);var i=(this.Zn+.2*(this.zn-1))/(t+.2*(this.zn-1)),n=l(this.In).cn();i=Math.max(i,.1),n.Mn(i),this.Mh(n)}},t.prototype.qh=function(){this.vh()||this._h()||(this.Zn=null,this.In=null)},t.prototype.Hh=function(t){this.fh()||null===this.Jn&&null===this.In&&(this.Qt()||(this.Jn=t,this.In=l(this.xh()).cn()))},t.prototype.Yh=function(t){if(!this.fh()&&null!==this.Jn){var i=l(this.xh()).dn()/(this.ph()-1),n=t-this.Jn;this.wh()&&(n*=-1);var h=n*i,s=l(this.In).cn();s.bn(h),this.Mh(s,!0),this.Xn=null}},t.prototype.Kh=function(){this.fh()||null!==this.Jn&&(this.Jn=null,this.In=null)},t.prototype.$h=function(){return this.Gn||this.uh(),this.Gn},t.prototype.ti=function(t,i){switch(this.xi.mode){case 2:return this.$h().Xi(st(t,i));case 3:return this.$h().Xi(et(t,i));default:return this.Xh(t)}},t.prototype.Bn=function(t){switch(this.xi.mode){case 2:case 3:return this.$h().Xi(t);default:return this.Xh(t)}},t.prototype.Zh=function(t){return this.Xh(t,l(this.Jh()).$h())},t.prototype.Gh=function(t,i){return t=st(t,i),wt.Xi(t)},t.prototype.Qh=function(){return this.Kn},t.prototype.ts=function(t){this.Wn={jn:t,Rn:!1}},t.prototype.Wi=function(){this.Kn.forEach((function(t){return t.Wi()}))},t.prototype.uh=function(){this.Xn=null;var t=this.Jh(),i=100;null!==t&&(i=Math.round(1/t.ns())),this.Gn=Mt,this.vh()?(this.Gn=wt,i=100):this._h()?(this.Gn=new X(100,1),i=100):null!==t&&(this.Gn=t.$h()),this.nh=new vt(this,i,this.hh.bind(this),this.sh.bind(this)),this.nh.Tn()},t.prototype.Ph=function(){this.$n=null},t.prototype.Jh=function(){return this.Kn[0]||null},t.prototype.yh=function(){return this.wh()?this.xi.scaleMargins.bottom*this.wt()+this.qn:this.xi.scaleMargins.top*this.wt()+this.Un},t.prototype.kh=function(){return this.wh()?this.xi.scaleMargins.top*this.wt()+this.Un:this.xi.scaleMargins.bottom*this.wt()+this.qn},t.prototype.Nh=function(){this.Wn.Rn||(this.Wn.Rn=!0,this.hs())},t.prototype.lh=function(){this.On=null},t.prototype.sh=function(t,i){if(this.Nh(),this.Qt())return 0;t=this.Fn()&&t?ot(t):t;var n=l(this.xh()),h=this.kh()+(this.ph()-1)*(t-n.vn())/n.dn();return this.Sh(h)},t.prototype.hh=function(t,i){if(this.Nh(),this.Qt())return 0;var n=this.Sh(t),h=l(this.xh()),s=h.vn()+h.dn()*((n-this.kh())/(this.ph()-1));return this.Fn()?at(s):s},t.prototype.bh=function(){this.Xn=null,this.nh.Tn()},t.prototype.hs=function(){var t=this.Wn.jn;if(null!==t){for(var i=null,n=0,h=0,s=0,r=this.Qh();s<r.length;s++){var e=r[s],u=e.q();if(null!==u){var o=e.ss(t.rs(),t.es()),a=o&&o.xh();if(null!==a){switch(this.xi.mode){case 1:a=lt(a);break;case 2:a=rt(a,u.Z);break;case 3:a=ut(a,u.Z)}if(i=null===i?a:i.wn(l(a)),null!==o){var f=o.us();null!==f&&(n=Math.max(n,f.above),h=Math.max(n,f.below))}}}}if(n===this.Un&&h===this.qn||(this.Un=n,this.qn=h,this.Xn=null,this.lh()),null!==i){if(i.vn()===i._n()){var c=this.Jh(),v=5*(null===c||this.vh()||this._h()?1:c.ns());i=new G(i.vn()-v,i._n()+v)}this.Mh(i)}else null===this.Pn&&this.Mh(new G(-.5,.5));this.Wn.Rn=!0}},t.prototype.Ch=function(){return this.vh()?st:this._h()?et:this.Fn()?ot:null},t.prototype.Xh=function(t,i){return void 0===this.ih.priceFormatter?(void 0===i&&(i=this.$h()),i.Xi(t)):this.ih.priceFormatter(t)},t}();function mt(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}!function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(dt||(dt={}));var gt=function(t){return t.getUTCFullYear()};function pt(t,i,n){return i.replace(/yyyy/g,function(t){return $(gt(t),4)}(t)).replace(/yy/g,function(t){return $(gt(t)%100,2)}(t)).replace(/MMMM/g,function(t,i){return new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"})}(t,n)).replace(/MMM/g,function(t,i){return new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"})}(t,n)).replace(/MM/g,function(t){return $(function(t){return t.getUTCMonth()+1}(t),2)}(t)).replace(/dd/g,function(t){return $(function(t){return t.getUTCDate()}(t),2)}(t))}var yt=function(){function t(t,i){void 0===t&&(t="yyyy-MM-dd"),void 0===i&&(i="default"),this.os=t,this.as=i}return t.prototype.Xi=function(t){return pt(t,this.os,this.as)},t}(),kt=function(){function t(t){this.ls=t||"%h:%m:%s"}return t.prototype.Xi=function(t){return this.ls.replace("%h",$(t.getUTCHours(),2)).replace("%m",$(t.getUTCMinutes(),2)).replace("%s",$(t.getUTCSeconds(),2))},t}(),xt={fs:"yyyy-MM-dd",cs:"%h:%m:%s",vs:" ",_s:"default"},Nt=function(){function t(t){void 0===t&&(t={});var i=e(e({},xt),t);this.ds=new yt(i.fs,i._s),this.ws=new kt(i.cs),this.Ms=i.vs}return t.prototype.Xi=function(t){return""+this.ds.Xi(t)+this.Ms+this.ws.Xi(t)},t}();var St=function(){function t(t,i){void 0===i&&(i=50),this.bs=0,this.ms=1,this.gs=1,this.ps=new Map,this.ys=new Map,this.ks=t,this.xs=i}return t.prototype.Xi=function(t){var i=void 0===t.Ns?new Date(1e3*t.Ss).getTime():new Date(Date.UTC(t.Ns.year,t.Ns.month-1,t.Ns.day)).getTime(),n=this.ps.get(i);if(void 0!==n)return n.Ds;if(this.bs===this.xs){var h=this.ys.get(this.gs);this.ys.delete(this.gs),this.ps.delete(a(h)),this.gs++,this.bs--}var s=this.ks(t);return this.ps.set(i,{Ds:s,Cs:this.ms}),this.ys.set(this.ms,i),this.bs++,this.ms++,s},t}(),Dt=function(){function t(t,i){o(t<=i,"right should be >= left"),this.Ts=t,this.As=i}return t.prototype.rs=function(){return this.Ts},t.prototype.es=function(){return this.As},t.prototype.Es=function(){return this.As-this.Ts+1},t.prototype.Ls=function(t){return this.Ts<=t&&t<=this.As},t.prototype.fn=function(t){return this.Ts===t.rs()&&this.As===t.es()},t}();function Ct(t,i){return null===t||null===i?t===i:t.fn(i)}var Tt,At=function(){function t(){this.Bs=new Map,this.ps=null}return t.prototype.Fs=function(t){var i=this;this.ps=null,this.Bs.clear(),t.forEach((function(t,n){var h=i.Bs.get(t.Vs);void 0===h&&(h=[],i.Bs.set(t.Vs,h)),h.push({zs:n,V:t.V,Os:t.Vs})}))},t.prototype.Ps=function(t,i){var n=Math.ceil(i/t);return null!==this.ps&&this.ps.Is===n||(this.ps={Vn:this.Ws(n),Is:n}),this.ps.Vn},t.prototype.Ws=function(t){for(var i=[],n=0,h=Array.from(this.Bs.keys()).sort((function(t,i){return i-t}));n<h.length;n++){var s=h[n];if(this.Bs.get(s)){var r=i;i=[];for(var e=r.length,u=0,o=a(this.Bs.get(s)),l=o.length,f=1/0,c=-1/0,v=0;v<l;v++){for(var _=o[v],d=_.zs;u<e;){var w=r[u],M=w.zs;if(!(M<d)){f=M;break}u++,i.push(w),c=M,f=1/0}f-d>=t&&d-c>=t&&(i.push(_),c=d)}for(;u<e;u++)i.push(r[u])}}return i},t}(),Et=function(){function t(t){this.Rs=t}return t.prototype.js=function(){return null===this.Rs?null:new Dt(Math.floor(this.Rs.rs()),Math.ceil(this.Rs.es()))},t.prototype.Us=function(){return this.Rs},t.qs=function(){return new t(null)},t}();!function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Tt||(Tt={}));var Lt=function(){function t(t,i,n){this.Hs=0,this.Ys=null,this.Ks=[],this.Jn=null,this.Zn=null,this.$s=new At,this.Xs=new Map,this.Zs=Et.qs(),this.Js=!0,this.Gs=new J,this.Qs=new J,this.tr=new J,this.ir=null,this.nr=null,this.hr=[],this.xi=i,this.ih=n,this.sr=i.rightOffset,this.rr=i.barSpacing,this.hi=t,this.er()}return t.prototype.P=function(){return this.xi},t.prototype.ur=function(t){c(this.ih,t),this.or(),this.er()},t.prototype.eh=function(t,i){c(this.xi,t),this.xi.fixLeftEdge&&this.ar(),void 0!==t.barSpacing&&this.lr(t.barSpacing),void 0!==t.rightOffset&&this.cr(t.rightOffset),this.or(),this.er(),this.tr.en()},t.prototype.si=function(t){var i;return(null===(i=this.Ks[t])||void 0===i?void 0:i.V)||null},t.prototype.vr=function(t,i){if(this.Ks.length<1)return null;if(t.Ss>this.Ks[this.Ks.length-1].V.Ss)return i?this.Ks.length-1:null;for(var n=0;n<this.Ks.length;++n){if(t.Ss===this.Ks[n].V.Ss)return n;if(t.Ss<this.Ks[n].V.Ss)return i?n:null}return null},t.prototype.Qt=function(){return 0===this.Hs||0===this.Ks.length},t.prototype._r=function(){return this.dr(),this.Zs.js()},t.prototype.wr=function(){return this.dr(),this.Zs.Us()},t.prototype.Mr=function(){var t=this._r();if(null===t)return null;var i={from:t.rs(),to:t.es()};return this.br(i)},t.prototype.br=function(t){var i=Math.round(t.from),n=Math.round(t.to),h=l(this.mr()),s=l(this.gr());return{from:l(this.si(Math.max(h,i))),to:l(this.si(Math.min(s,n)))}},t.prototype.pr=function(t){var i=this.hi.j();return{from:l(i.vr(t.from,!0)),to:l(i.vr(t.to,!0))}},t.prototype.yr=function(){return this.$s},t.prototype.dt=function(){return this.Hs},t.prototype.kr=function(t){if(isFinite(t)&&!(t<=0)&&this.Hs!==t){if(this.xi.lockVisibleTimeRangeOnResize&&this.Hs){var i=this.rr*t/this.Hs;this.xr(i)}if(this.xi.fixLeftEdge){var n=this._r();if(null!==n)if(n.rs()<=0){var h=this.Hs-t;this.sr-=Math.round(h/this.rr)+1}}this.Hs=t,this.Js=!0,this.Nr(),this.Sr()}},t.prototype.J=function(t){if(this.Qt()||!_(t))return 0;var i=this.Dr()+this.sr-t;return this.Hs-(i+.5)*this.rr},t.prototype.Cr=function(t,i){for(var n=this.Dr(),h=void 0===i?0:i.from,s=void 0===i?t.length:i.to,r=h;r<s;r++){var e=t[r].V,u=n+this.sr-e,o=this.Hs-(u+.5)*this.rr;t[r].m=o}},t.prototype.Tr=function(t){return Math.ceil(this.Ar(t))},t.prototype.cr=function(t){this.Js=!0,this.sr=t,this.Sr(),this.hi.Er(),this.hi.Lr()},t.prototype.Br=function(){return this.rr},t.prototype.lr=function(t){this.xr(t),this.Sr(),this.hi.Er(),this.hi.Lr()},t.prototype.Fr=function(){return this.sr},t.prototype.Vn=function(){if(this.Qt())return null;if(null!==this.nr)return this.nr;for(var t=this.rr,i=5*(this.hi.P().layout.fontSize+4),n=Math.round(i/t),h=l(this._r()),s=Math.max(h.rs(),h.rs()-n),r=Math.max(h.es(),h.es()-n),e=0,u=0,o=this.$s.Ps(t,i);u<o.length;u++){var a=o[u];if(s<=a.zs&&a.zs<=r){var f=this.si(a.zs);if(null!==f){if(e<this.hr.length){var c=this.hr[e];c.En=this.J(a.zs),c.Ln=this.Vr(f,a.Os),c.Os=a.Os}else this.hr.push({En:this.J(a.zs),Ln:this.Vr(f,a.Os),Os:a.Os});e++}}}return this.hr.length=e,this.nr=this.hr,this.hr},t.prototype.zr=function(){this.Js=!0,this.lr(this.xi.barSpacing),this.cr(this.xi.rightOffset)},t.prototype.Or=function(t){this.Js=!0,this.Ys=t,this.Sr(),this.ar()},t.prototype.Pr=function(t,i){var n=this.Ar(t),h=this.Br(),s=h+i*(h/10);this.lr(s),this.xi.rightBarStaysOnScroll||this.cr(this.Fr()+(n-this.Ar(t)))},t.prototype.jh=function(t){this.Jn&&this.Kh(),null===this.Zn&&null===this.ir&&(this.Qt()||(this.Zn=t,this.Ir()))},t.prototype.Uh=function(t){if(null!==this.ir){var i=Q(this.Hs-t,0,this.Hs),n=Q(this.Hs-l(this.Zn),0,this.Hs);0!==i&&0!==n&&this.lr(this.ir.Br*i/n)}},t.prototype.qh=function(){null!==this.Zn&&(this.Zn=null,this.Wr())},t.prototype.Hh=function(t){null===this.Jn&&null===this.ir&&(this.Qt()||(this.Jn=t,this.Ir()))},t.prototype.Yh=function(t){if(null!==this.Jn){var i=(this.Jn-t)/this.Br();this.sr=l(this.ir).Fr+i,this.Js=!0,this.Sr()}},t.prototype.Kh=function(){null!==this.Jn&&(this.Jn=null,this.Wr())},t.prototype.Rr=function(){this.jr(this.xi.rightOffset)},t.prototype.jr=function(t,i){var n=this;if(void 0===i&&(i=400),!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");var h=this.sr,s=(new Date).getTime(),r=function(){var e=((new Date).getTime()-s)/i,u=e>=1,o=u?t:h+(t-h)*e;n.cr(o),u||setTimeout(r,20)};r()},t.prototype.B=function(t){this.Js=!0,this.Ks=t,this.$s.Fs(t),this.Sr()},t.prototype.Ur=function(){return this.Gs},t.prototype.qr=function(){return this.Qs},t.prototype.Hr=function(){return this.tr},t.prototype.Dr=function(){return this.Ys||0},t.prototype.Yr=function(t){var i=t.Es();this.xr(this.Hs/i),this.sr=t.es()-this.Dr(),this.Sr(),this.Js=!0,this.hi.Er(),this.hi.Lr()},t.prototype.Kr=function(){var t=this.mr(),i=this.gr();null!==t&&null!==i&&this.Yr(new Dt(t,i+this.xi.rightOffset))},t.prototype.$r=function(t){var i=new Dt(t.from,t.to);this.Yr(i)},t.prototype.ri=function(t){return void 0!==this.ih.timeFormatter?this.ih.timeFormatter(t.Ns||t.Ss):this.Xr.Xi(new Date(1e3*t.Ss))},t.prototype.mr=function(){return 0===this.Ks.length?null:0},t.prototype.gr=function(){return 0===this.Ks.length?null:this.Ks.length-1},t.prototype.Zr=function(t){return(this.Hs+1-t)/this.rr},t.prototype.Ar=function(t){var i=this.Zr(t),n=this.Dr()+this.sr-i;return Math.round(1e6*n)/1e6},t.prototype.xr=function(t){var i=this.rr;this.rr=t,this.Nr(),i!==this.rr&&(this.Js=!0,this.Jr())},t.prototype.dr=function(){if(this.Js)if(this.Js=!1,this.Qt())this.Gr(Et.qs());else{var t=this.Dr(),i=this.Hs/this.rr,n=this.sr+t,h=new Dt(n-i+1,n);this.Gr(new Et(h))}},t.prototype.Nr=function(){if(this.rr<.5&&(this.rr=.5,this.Js=!0),0!==this.Hs){var t=.5*this.Hs;this.rr>t&&(this.rr=t,this.Js=!0)}},t.prototype.Sr=function(){var t=this.Qr();this.sr>t&&(this.sr=t,this.Js=!0);var i=this.te();null!==i&&this.sr<i&&(this.sr=i,this.Js=!0)},t.prototype.te=function(){var t=this.mr(),i=this.Ys;return null===t||null===i?null:t-i-1+(this.xi.fixLeftEdge?this.Hs/this.rr:Math.min(2,this.Ks.length))},t.prototype.Qr=function(){return this.Hs/this.rr-Math.min(2,this.Ks.length)},t.prototype.Ir=function(){this.ir={Br:this.Br(),Fr:this.Fr()}},t.prototype.Wr=function(){this.ir=null},t.prototype.Vr=function(t,i){var n=this,h=this.Xs.get(i);return void 0===h&&(h=new St((function(t){return n.ie(t,i)})),this.Xs.set(i,h)),h.Xi(t)},t.prototype.ie=function(t,i){var n,h,s=this.xi.timeVisible;return h=i<20&&s?this.xi.secondsVisible?4:3:i<40&&s?3:i<50||i<60?2:i<70?1:0,void 0!==this.xi.tickMarkFormatter?this.xi.tickMarkFormatter(null!==(n=t.Ns)&&void 0!==n?n:t.Ss,h,this.ih.locale):function(t,i,n){var h={};switch(i){case 0:h.year="numeric";break;case 1:h.month="short";break;case 2:h.day="numeric";break;case 3:h.hour12=!1,h.hour="2-digit",h.minute="2-digit";break;case 4:h.hour12=!1,h.hour="2-digit",h.minute="2-digit",h.second="2-digit"}var s=void 0===t.Ns?new Date(1e3*t.Ss):new Date(Date.UTC(t.Ns.year,t.Ns.month-1,t.Ns.day));return new Date(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()).toLocaleString(n,h)}(t,h,this.ih.locale)},t.prototype.Gr=function(t){var i=this.Zs;this.Zs=t,Ct(i.js(),this.Zs.js())||this.Gs.en(),Ct(i.Us(),this.Zs.Us())||this.Qs.en(),this.Jr()},t.prototype.Jr=function(){this.nr=null},t.prototype.or=function(){this.Jr(),this.Xs.clear()},t.prototype.er=function(){var t=this.ih.dateFormat;this.xi.timeVisible?this.Xr=new Nt({fs:t,cs:this.xi.secondsVisible?"%h:%m:%s":"%h:%m",vs:" ",_s:this.ih.locale}):this.Xr=new yt(t,this.ih.locale)},t.prototype.ar=function(){if(this.xi.fixLeftEdge){var t=this.mr();if(null!==t){var i=l(this._r()).rs()-t;if(i<0){var n=this.sr-i-1;this.cr(n)}}}},t}();function Bt(t){return!v(t)&&!d(t)}function Ft(t){return v(t)}var Vt="'Trebuchet MS', Roboto, Ubuntu, sans-serif";function zt(t,i,n){return void 0!==n?n+=" ":n="",void 0===i&&(i=Vt),""+n+t+"px "+i}var Ot=function(){function t(t){this.ne={Dt:1,St:4,Vt:NaN,kt:"",he:"",et:"",Tt:0,At:0,Et:0,Ct:0,Ft:0},this.A=t}return t.prototype.P=function(){var t=this.ne,i=this.se(),n=this.ee();return t.Vt===i&&t.he===n||(t.Vt=i,t.he=n,t.kt=zt(i,n),t.Ct=Math.floor(i/3.5),t.Tt=t.Ct,t.At=Math.max(Math.ceil(i/2-t.St/2),0),t.Et=Math.ceil(i/2+t.St/2),t.Ft=Math.round(i/10)),t.et=this.ue(),this.ne},t.prototype.ue=function(){return this.A.P().layout.textColor},t.prototype.se=function(){return this.A.P().layout.fontSize},t.prototype.ee=function(){return this.A.P().layout.fontFamily},t}();function Pt(t){return"left"===t||"right"===t}var It=function(){function t(){this.G=null}return t.prototype.v=function(t){this.G=t},t.prototype.h=function(t,i,h,s){var r=this;if(null!==this.G){var e=Math.floor(i);t.lineWidth=e;var u=Math.ceil(this.G.st*i),o=Math.ceil(this.G.ht*i);!function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(function(){var h=l(r.G);if(h.oe){t.strokeStyle=h.ae,n(t,h.le),t.beginPath();for(var s=0,a=h.fe;s<a.length;s++){var f=a[s],c=Math.round(f.En*i);t.moveTo(c,-e),t.lineTo(c,u+e)}t.stroke()}if(h.ce){t.strokeStyle=h.ve,n(t,h._e),t.beginPath();for(var v=0,_=h.de;v<_.length;v++){var d=_[v],w=Math.round(d.En*i);t.moveTo(-e,w),t.lineTo(o+e,w)}t.stroke()}}))}},t}(),Wt=function(){function t(t){this.at=new It,this.T=!0,this._i=t}return t.prototype.B=function(){this.T=!0},t.prototype.I=function(t,i){if(this.T){var n=this._i.ct().P().grid,h={st:t,ht:i,ce:n.horzLines.visible,oe:n.vertLines.visible,ve:n.horzLines.color,ae:n.vertLines.color,_e:n.horzLines.style,le:n.vertLines.style,de:this._i.Di().Vn(),fe:this._i.ct().j().Vn()||[]};this.at.v(h),this.T=!1}return this.at},t}(),Rt=function(){function t(){this.we=new WeakMap,this.T=!0}return t.prototype.ci=function(t){var i=this.we.get(t);return void 0===i&&(i=[new Wt(t)],this.we.set(t,i)),this.T&&(i.forEach((function(t){return t.B()})),this.T=!1),i},t.prototype.Me=function(){this.T=!0},t}();var jt=function(){function t(t){this.be=new Map,this.me=!1,this.ge=!1,this.Rs=null,this.pe=t}return t.prototype.ye=function(t,i){var n=function(t,i){return void 0===t?i:{ke:Math.max(t.ke,i.ke),dh:t.dh||i.dh}}(this.be.get(t),i);this.be.set(t,n)},t.prototype.xe=function(){return this.pe},t.prototype.Ne=function(t){var i=this.be.get(t);return void 0===i?{ke:this.pe}:{ke:Math.max(this.pe,i.ke),dh:i.dh}},t.prototype.Se=function(){this.ge=!0,this.Rs=null},t.prototype.De=function(){return this.ge},t.prototype.$r=function(t){this.Rs=t,this.ge=!1},t.prototype.Ce=function(){return this.Rs},t.prototype.wn=function(t){var i=this;this.me=this.me||t.me,t.ge&&this.Se(),t.Rs&&this.$r(t.Rs),this.pe=Math.max(this.pe,t.pe),t.be.forEach((function(t,n){i.ye(n,t)}))},t}(),Ut=function(){function t(t){this.Te=t}return t.prototype.Xi=function(t){var i="";return t<0&&(i="-",t=-t),t<995?i+this.Ae(t):t<999995?i+this.Ae(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Ae(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Ae(t/1e9)+"B")},t.prototype.Ae=function(t){var i=Math.pow(10,this.Te);return((t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this.Te).replace(/\.?0+$/,""):String(t)).replace(/(\.[1-9]*)0+$/,(function(t,i){return i}))},t}();function qt(t,i,n,h){if(0!==i.length){var s=i[h.from].m,r=i[h.from].g;t.moveTo(s,r);for(var e=h.from+1;e<h.to;++e){var u=i[e];if(1===n){var o=i[e-1].g,a=u.m;t.lineTo(a,o)}t.lineTo(u.m,u.g)}}}var Ht=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.l=null,i}return r(i,t),i.prototype.v=function(t){this.l=t},i.prototype.s=function(t){if(null!==this.l&&0!==this.l.M.length&&null!==this.l._){t.lineCap="butt",t.strokeStyle=this.l.N,t.lineWidth=this.l.rt,n(t,this.l.ut),t.lineWidth=1,t.beginPath(),t.moveTo(this.l.M[this.l._.from].m,this.l.Ee),t.lineTo(this.l.M[this.l._.from].m,this.l.M[this.l._.from].g),qt(t,this.l.M,this.l.Le,this.l._),this.l._.to>this.l._.from&&(t.lineTo(this.l.M[this.l._.to-1].m,this.l.Ee),t.lineTo(this.l.M[this.l._.from].m,this.l.Ee)),t.closePath();var i=t.createLinearGradient(0,0,0,this.l.Ee);i.addColorStop(0,this.l.Be),i.addColorStop(1,this.l.Fe),t.fillStyle=i,t.fill()}},i}(p),Yt=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.l=null,i}return r(i,t),i.prototype.v=function(t){this.l=t},i.prototype.s=function(t){null!==this.l&&0!==this.l.M.length&&null!==this.l._&&(t.lineCap="square",t.lineWidth=this.l.rt,n(t,this.l.ut),t.strokeStyle=this.l.N,t.lineJoin="miter",t.beginPath(),qt(t,this.l.M,this.l.Le,this.l._),t.stroke())},i}(p);function Kt(t,i,n,h,s){void 0===h&&(h=0),void 0===s&&(s=t.length);for(var r=s-h;0<r;){var e=r>>1,u=h+e;n(t[u],i)?(h=u+1,r-=e+1):r=e}return h}function $t(t,i,n,h,s){void 0===h&&(h=0),void 0===s&&(s=t.length);for(var r=s-h;0<r;){var e=r>>1,u=h+e;n(i,t[u])?r=e:(h=u+1,r-=e+1)}return h}function Xt(t,i){return t.V<i}function Zt(t,i){return t<i.V}function Jt(t,i,n){var h=i.rs(),s=i.es(),r=Kt(t,h,Xt),e=$t(t,s,Zt);if(!n)return{from:r,to:e};var u=r,o=e;return r>0&&r<t.length&&t[r].V>=h&&(u=r-1),e>0&&e<t.length&&t[e-1].V<=s&&(o=e+1),{from:u,to:o}}var Gt=function(){function t(t,i,n){this.Ve=!0,this.ze=!0,this.Oe=[],this.Pe=null,this.Ie=t,this.We=i,this.Re=n}return t.prototype.B=function(t){this.Ve=!0,"data"===t&&(this.ze=!0)},t.prototype.je=function(){this.ze&&(this.Ue(),this.ze=!1),this.Ve&&(this.qe(),this.Ve=!1)},t.prototype.He=function(){this.Pe=null},t.prototype.qe=function(){var t=this.Ie.X(),i=this.We.j();if(this.He(),!i.Qt()&&!t.Qt()){var n=i._r();if(null!==n&&0!==this.Ie.qi().Ye()){var h=this.Ie.q();null!==h&&(this.Pe=Jt(this.Oe,n,this.Re),this.Ke(t,i,h.Z))}}},t}(),Qt=function(t){function i(i,n){return t.call(this,i,n,!0)||this}return r(i,t),i.prototype.Ke=function(t,i,n){i.Cr(this.Oe,m(this.Pe)),t.Dh(this.Oe,n,m(this.Pe))},i.prototype.$e=function(t,i){return{V:t,O:i,m:NaN,g:NaN}},i.prototype.Ue=function(){var t=this,i=this.Ie.K();this.Oe=this.Ie.qi().Xe().map((function(n){var h=n.Z[3];return t.Ze(n.zs,h,i)}))},i}(Gt),ti=function(t){function i(i,n){var h=t.call(this,i,n)||this;return h.at=new g,h.Je=new Ht,h.Ge=new Yt,h.at.i([h.Je,h.Ge]),h}return r(i,t),i.prototype.I=function(t,i){this.je();var n=this.Ie.P(),h={Le:n.lineType,M:this.Oe,N:n.lineColor,ut:n.lineStyle,rt:n.lineWidth,Be:n.topColor,Fe:n.bottomColor,Ee:t,_:this.Pe};return this.Je.v(h),this.Ge.v(h),this.at},i.prototype.Ze=function(t,i){return this.$e(t,i)},i}(Qt);var ii=function(){function t(){this.G=null,this.Qe=0,this.tu=0}return t.prototype.v=function(t){this.G=t},t.prototype.h=function(t,i,n,h){if(null!==this.G&&0!==this.G.qi.length&&null!==this.G._){if(this.Qe=Math.max(1,Math.floor(function(t,i){return Math.floor(.3*t*i)}(this.G.Br,i))),this.Qe>=2)Math.floor(i)%2!=this.Qe%2&&this.Qe--;this.tu=this.G.iu?Math.min(this.Qe,Math.floor(i)):this.Qe;for(var s=null,r=this.G._.from;r<this.G._.to;++r){var e=this.G.qi[r];s!==e.et&&(t.fillStyle=e.et,s=e.et);var u=Math.floor(.5*this.tu),o=Math.round(e.m*i),a=o-u,l=this.tu,f=a+l-1,c=Math.round(e.Eh*i)-u,v=Math.round(e.Lh*i)+u,_=Math.max(v-c,this.tu);t.fillRect(a,c,l,_);var d=Math.ceil(1.5*this.Qe);if(this.tu<=this.Qe){if(this.G.nu){var w=o-d,M=Math.max(c,Math.round(e.Ah*i)-u),b=M+l-1;b>c+_-1&&(M=(b=c+_-1)-l+1),t.fillRect(w,M,a-w,b-M+1)}var m=o+d,g=Math.max(c,Math.round(e.Bh*i)-u),p=g+l-1;p>c+_-1&&(g=(p=c+_-1)-l+1),t.fillRect(f+1,g,m-f,p-g+1)}}}},t}(),ni=function(t){function i(i,n){return t.call(this,i,n,!1)||this}return r(i,t),i.prototype.Ke=function(t,i,n){i.Cr(this.Oe,m(this.Pe)),t.Th(this.Oe,n,m(this.Pe))},i.prototype.hu=function(t,i,n){return{V:t,open:i.Z[0],high:i.Z[1],low:i.Z[2],close:i.Z[3],m:NaN,Ah:NaN,Eh:NaN,Lh:NaN,Bh:NaN}},i.prototype.Ue=function(){var t=this,i=this.Ie.K();this.Oe=this.Ie.qi().Xe().map((function(n){return t.Ze(n.zs,n,i)}))},i}(Gt),hi=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.at=new ii,i}return r(i,t),i.prototype.I=function(t,i){this.je();var n=this.Ie.P(),h={qi:this.Oe,Br:this.We.j().Br(),nu:n.openVisible,iu:n.thinBars,_:this.Pe};return this.at.v(h),this.at},i.prototype.Ze=function(