text: /**
   * @license
   * KLineChart v5.6.0
   * Copyright (c) 2019 lihu.
   * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
   */
  !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).klinecharts={})}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var i=0;e.length>i;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function n(t,e,i){return e&&a(t.prototype,e),i&&a(t,i),t}function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function o(t){for(var e=1;arguments.length>e;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?s(Object(i),!0).forEach((function(e){r(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function _(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,a=h(t);if(e){var n=h(this).constructor;i=Reflect.construct(a,arguments,n)}else i=a.apply(this,arguments);return u(this,i)}}function d(t,e,i){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var a=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(a){var n=Object.getOwnPropertyDescriptor(a,e);return n.get?n.get.call(i):n.value}})(t,e,i||t)}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=Array(e);e>i;i++)a[i]=t[i];return a}function f(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=function(t,e){if(t){if("string"==typeof t)return v(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?v(t,e):void 0}}(t))){var e=0,i=function(){};return{s:i,n:function(){return t.length>e?{done:!1,value:t[e++]}:{done:!0}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,n,r=!0,s=!1;return{s:function(){a=t[Symbol.iterator]()},n:function(){var t=a.next();return r=t.done,t},e:function(t){s=!0,n=t},f:function(){try{r||null==a.return||a.return()}finally{if(s)throw n}}}}function y(t,e){if(g(t)&&g(e))for(var i in e)if(t.hasOwnProperty(i)){var a=t[i],n=e[i];g(n)&&g(a)&&!x(n)&&!x(a)?y(a,n):(e[i]||0===e[i]||!1===e[i])&&(t[i]=e[i])}}function p(t){if(!t||!g(t))return t;var e,i,a;for(i in e=x(t)?[]:{},t)t.hasOwnProperty(i)&&(e[i]=(a=t[i])&&g(a)?p(a):a);return e}function x(t){return"[object Array]"===Object.prototype.toString.call(t)}function m(t){return"function"==typeof t}function g(t){return!!t&&"object"===e(t)}function k(t){return"number"==typeof t&&!isNaN(t)}function w(t){return null!=t}function D(t){return"boolean"==typeof t}var P="dash",M="left",b="right",T="percentage",C="real_time",S="candle_stick",L="solid",E="stroke",A="up_stroke",I="down_stroke",z="ohlc",H="always",V="follow_cross",R="standard",O={grid:{display:!0,horizontal:{display:!0,size:1,color:"#393939",style:P,dashValue:[2,2]},vertical:{display:!1,size:1,color:"#393939",style:P,dashValue:[2,2]}},candleStick:{bar:{style:L,upColor:"#26A69A",downColor:"#EF5350",noChangeColor:"#888888"},priceMark:{display:!0,high:{display:!0,color:"#D9D9D9",textMargin:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},low:{display:!0,color:"#D9D9D9",textMargin:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},last:{display:!0,upColor:"#26A69A",downColor:"#EF5350",noChangeColor:"#888888",line:{display:!0,style:P,dashValue:[4,4],size:1},text:{display:!0,size:12,paddingLeft:2,paddingTop:2,paddingRight:2,paddingBottom:2,color:"#FFFFFF",family:"Helvetica Neue",weight:"normal"}}}},realTime:{timeLine:{color:"#2196F3",size:1,areaFillColor:"rgba(33, 150, 243, 0.08)"},averageLine:{display:!0,color:"#FF9600",size:1}},technicalIndicator:{bar:{upColor:"#26A69A",downColor:"#EF5350",noChangeColor:"#888888"},line:{size:1,colors:["#D9D9D9","#FF9600","#F632FF","#2196F3","#9157DB"]},circle:{upColor:"#26A69A",downColor:"#EF5350",noChangeColor:"#888888"},lastValueMark:{display:!1,textColor:"#ffffff",textSize:12,textFamily:"Helvetica Neue",textWeight:"normal",textPaddingLeft:3,textPaddingTop:2,textPaddingRight:3,textPaddingBottom:2}},xAxis:{display:!0,height:null,axisLine:{display:!0,color:"#888888",size:1},tickText:{display:!0,color:"#D9D9D9",size:12,family:"Helvetica Neue",weight:"normal",paddingTop:3,paddingBottom:6},tickLine:{display:!0,size:1,length:3,color:"#888888"}},yAxis:{display:!0,width:null,type:"normal",position:b,inside:!1,axisLine:{display:!0,color:"#888888",size:1},tickText:{display:!0,color:"#D9D9D9",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:3,paddingRight:6},tickLine:{display:!0,size:1,length:3,color:"#888888"}},separator:{size:1,color:"#888888",fill:!0},floatLayer:{crossHair:{display:!0,horizontal:{display:!0,line:{display:!0,style:P,dashValue:[4,2],size:1,color:"#888888"},text:{display:!0,color:"#D9D9D9",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:2,paddingRight:2,paddingTop:2,paddingBottom:2,borderSize:1,borderColor:"#505050",backgroundColor:"#505050"}},vertical:{display:!0,line:{display:!0,style:P,dashValue:[4,2],size:1,color:"#888888"},text:{display:!0,color:"#D9D9D9",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:2,paddingRight:2,paddingTop:2,paddingBottom:2,borderSize:1,borderColor:"#505050",backgroundColor:"#505050"}}},prompt:{displayRule:H,candleStick:{showType:R,labels:["时间","开","收","高","低","成交量"],values:null,rect:{paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:6,left:8,top:8,right:8,borderRadius:4,borderSize:1,borderColor:"#3f4254",fillColor:"rgba(17, 17, 17, .3)"},text:{size:12,family:"Helvetica Neue",weight:"normal",color:"#D9D9D9",marginLeft:8,marginTop:6,marginRight:8,marginBottom:0}},technicalIndicator:{text:{size:12,family:"Helvetica Neue",weight:"normal",color:"#D9D9D9",marginTop:6,marginRight:8,marginBottom:0,marginLeft:8}}}},graphicMark:{line:{color:"#2196F3",size:1},point:{backgroundColor:"#2196F3",borderColor:"#2196F3",borderSize:1,radius:4,activeBackgroundColor:"#2196F3",activeBorderColor:"#2196F3",activeBorderSize:1,activeRadius:6},text:{color:"#1e88e5",size:12,family:"Helvetica Neue",weight:"normal",marginLeft:2,marginRight:2,marginTop:2,marginBottom:6}}};function B(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"--";if(t&&g(t)){var a=t[e];if(a||0===a||!1===a)return a}return i}function F(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"MM-DD hh:mm";if(e&&k(e)){var a=t.format(new Date(e)),n=a.split(", "),r=n[0].split("/"),s={YYYY:r[2],MM:r[0],DD:r[1],"hh:mm":"24"===n[1].match(/^[\d]{2}/)[0]?n[1].replace(/^[\d]{2}/,"00"):n[1]};return i.replace(/YYYY|MM|DD|(hh:mm)/g,(function(t){return s[t]}))}return"--"}function W(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,i=+t;return(i||0===i)&&k(i)?i.toFixed(e):"".concat(i)}function Y(t){return k(+t)?t>1e9?"".concat(+(t/1e9).toFixed(3),"B"):t>1e6?"".concat(+(t/1e6).toFixed(3),"M"):t>1e3?"".concat(+(t/1e3).toFixed(3),"K"):t:"--"}var G="price",X="volume",j=function(){function t(e){var a=e.name,n=e.series,r=e.calcParams,s=e.plots,o=e.precision,c=e.shouldCheckParamCount,h=e.shouldOhlc,l=e.shouldFormatBigNumber,u=e.baseValue,_=e.minValue,d=e.maxValue;i(this,t),this.name=a||"",this.series=n||"normal",this.precision=w(o)&&k(o)&&o>=0?o:4,this.calcParams=x(r)?r:[],this.plots=x(s)?s:[],this.shouldCheckParamCount=!D(c)||c,this.shouldOhlc=h,this.shouldFormatBigNumber=l,this.baseValue=k(u)?u:null,this.minValue=_,this.maxValue=d,this.result=[]}return n(t,[{key:"setPrecision",value:function(t){t>=0&&k(t)&&(this.precision=parseInt(t,10))}},{key:"setCalcParams",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!this.shouldCheckParamCount||t.length===this.calcParams.length){this.calcParams=p(t);var e=this.regeneratePlots(t);e&&x(e)&&(this.plots=e)}}},{key:"calcTechnicalIndicator",value:function(t,e){}},{key:"regeneratePlots",value:function(t){}}]),t}(),N=function(t){c(a,t);var e=_(a);function a(){var t;return i(this,a),(t=e.call(this,{name:"MA",series:G,precision:2,shouldCheckParamCount:!1,shouldOhlc:!0})).setCalcParams([5,10,30,60]),t}return n(a,[{key:"regeneratePlots",value:function(t){return t.map((function(t){return{key:"ma".concat(t),type:"line"}}))}},{key:"calcTechnicalIndicator",value:function(t,e,i){var a=[],n=[];return t.forEach((function(r,s){var o={},c=r.close;e.forEach((function(e,n){a[n]=(a[n]||0)+c,e-1>s||(o[i[n].key]=a[n]/e,a[n]-=t[s-(e-1)].close)})),n.push(o)})),n}}]),a}(j),K=function(t){c(a,t);var e=_(a);function a(){var t;return i(this,a),(t=e.call(this,{name:"EMA",series:G,precision:2,shouldCheckParamCount:!1,shouldOhlc:!0})).setCalcParams([6,12,20]),t}return n(a,[{key:"regeneratePlots",value:function(t){return t.map((function(t){return{key:"ema".concat(t),type:"line"}}))}},{key:"calcTechnicalIndicator",value:function(t,e,i){var a=[],n=[];return t.forEach((function(t,r){var s={},o=t.close;e.forEach((function(t,e){var n;s[i[e].key]=n=0===r?o:(2*o+(t-1)*a[e])/(t+1),a[e]=n})),n.push(s)})),n}}]),a}(j),U=function(t){c(a,t);var e=_(a);function a(){var t;return i(this,a),(t=e.call(this,{name:"VOL",series:X,shouldCheckParamCount:!1,shouldFormatBigNumber:!0,precision:0,baseValue:0,minValue:0})).setCalcParams([5,10,20]),t}return n(a,[{key:"regeneratePlots",value:function(t){var e=t.map((function(t){return{key:"ma".concat(t),type:"line"}}));return e.push({key:"volume",type:"bar",referenceValue:0,color:function(t,e){var i=t.currentData.kLineData||{};return i.close>i.open?e.bar.upColor:i.open>i.close?e.bar.downColor:e.bar.noChangeColor}}),e}},{key:"calcTechnicalIndicator",value:function(t,e,i){var a=[],n=[];return t.forEach((function(r,s){var o=r.volume||0,c={volume:o};e.forEach((function(e,n){a[n]=(a[n]||0)+o,e-1>s||(c[i[n].key]=a[n]/e,a[n]-=t[s-(e-1)].volume)})),n.push(c)})),n}}]),a}(j),Z=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"MACD",calcParams:[12,26,9],baseValue:0,plots:[{key:"diff",type:"line"},{key:"dea",type:"line"},{key:"macd",type:"bar",color:function(t,e){var i=(t.currentData.technicalIndicatorData||{}).macd;return i>0?e.bar.upColor:0>i?e.bar.downColor:e.bar.noChangeColor},isStroke:function(t){return(t.currentData.technicalIndicatorData||{}).macd>(t.preData.technicalIndicatorData||{}).macd}}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i,a,n=0,r=0,s=0,o=0,c=[];return t.forEach((function(t,h){var l=t.close;0===h?(i=l,a=l):(i=(2*l+(e[0]-1)*n)/(e[0]+1),a=(2*l+(e[1]-1)*r)/(e[1]+1));var u=i-a;n=i,r=a,o=s=(2*u+o*(e[2]-1))/(e[2]+1),c.push({diff:u,dea:s,macd:2*(u-s)})})),c}}]),a}(j),q=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"BOLL",series:G,calcParams:[20],precision:2,shouldOhlc:!0,plots:[{key:"up",type:"line"},{key:"mid",type:"line"},{key:"dn",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=this,a=e[0]-1,n=0,r=[];return t.forEach((function(s,o){var c={};if(n+=s.close,o>=a){c.mid=n/e[0];var h=i._getBollMd(t.slice(o-a,o+1),c.mid);c.up=c.mid+2*h,c.dn=c.mid-2*h,n-=t[o-a].close}r.push(c)})),r}},{key:"_getBollMd",value:function(t,e){var i=t.length,a=0;t.forEach((function(t){var i=t.close-e;a+=i*i}));var n=a>0,r=Math.sqrt((a=Math.abs(a))/i);return n?r:-1*r}}]),a}(j);function $(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=-1/0,i=1/0;return t.forEach((function(t){e=Math.max(t.high,e),i=Math.min(t.low,i)})),{hn:e,ln:i}}var J=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"KDJ",calcParams:[9,3,3],plots:[{key:"k",type:"line"},{key:"d",type:"line"},{key:"j",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=[];return t.forEach((function(a,n){var r={},s=a.close;if(n>=e[0]-1){var o=$(t.slice(n-(e[0]-1),n+1)),c=o.ln,h=o.hn-c;r.k=((e[1]-1)*(i[n-1].k||50)+(s-c)/(0===h?1:h)*100)/e[1],r.d=((e[2]-1)*(i[n-1].d||50)+r.k)/e[2],r.j=3*r.k-2*r.d}i.push(r)})),i}}]),a}(j),Q=function(t){c(a,t);var e=_(a);function a(){var t;return i(this,a),(t=e.call(this,{name:"RSI",shouldCheckParamCount:!1})).setCalcParams([6,12,24]),t}return n(a,[{key:"regeneratePlots",value:function(t){return t.map((function(t){return{key:"rsi".concat(t),type:"line"}}))}},{key:"calcTechnicalIndicator",value:function(t,e,i){var a=[],n=[],r=[];return t.forEach((function(s,o){var c={},h=s.open;e.forEach((function(e,r){var l=(s.close-h)/h;if(a[r]=a[r]||0,n[r]=n[r]||0,l>0?a[r]=a[r]+l:n[r]=n[r]+Math.abs(l),o>=e-1){var u=(a[r]+n[r])/e;c[i[r].key]=0===u?0:a[r]/e/u*100;var _=t[o-(e-1)],d=_.open,v=(_.close-d)/d;v>0?a[r]-=v:n[r]-=Math.abs(v)}})),r.push(c)})),r}}]),a}(j),tt=function(t){c(a,t);var e=_(a);function a(){var t;return i(this,a),(t=e.call(this,{name:"BIAS",shouldCheckParamCount:!1})).setCalcParams([6,12,24]),t}return n(a,[{key:"regeneratePlots",value:function(t){return t.map((function(t){return{key:"bias".concat(t),type:"line"}}))}},{key:"calcTechnicalIndicator",value:function(t,e,i){var a=[],n=[];return t.forEach((function(r,s){var o={},c=r.close;e.forEach((function(n,r){if(a[r]=(a[r]||0)+c,s>=n-1){var h=a[r]/e[r];o[i[r].key]=(c-h)/h*100,a[r]-=t[s-(n-1)].close}})),n.push(o)})),n}}]),a}(j),et=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"BRAR",calcParams:[26],plots:[{key:"br",type:"line"},{key:"ar",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=0,n=0,r=0,s=[];return t.forEach((function(o,c){var h={};if(c>0){var l=o.high,u=o.low,_=o.open,d=t[c-1].close;if(n+=l-_,r+=_-u,i+=l-d,a+=d-u,c>=e[0]){h.ar=0!==r?n/r*100:0,h.br=0!==a?i/a*100:0;var v=t[c-(e[0]-1)].high,f=t[c-(e[0]-1)].low,y=t[c-(e[0]-1)].open,p=t[c-e[0]].close;i-=v-p,a-=p-f,n-=v-y,r-=y-f}}s.push(h)})),s}}]),a}(j),it=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"CCI",calcParams:[13],plots:[{key:"cci",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i,a=e[0]-1,n=0,r=0,s=[],o=[];return t.forEach((function(c,h){var l,u={},_=c.close;if(n+=_,s.push(l=a>h?n/(h+1):n/e[0]),r+=Math.abs(l-_),h>=a){u.cci=0!==(i=r/e[0])?((c.high+c.low+_)/3-l)/i/.015:0;var d=t[h-a].close;n-=d,r-=Math.abs(s[h-a]-d)}o.push(u)})),o}}]),a}(j),at=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"DMI",calcParams:[14,6],plots:[{key:"pdi",type:"line"},{key:"mdi",type:"line"},{key:"adx",type:"line"},{key:"adxr",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=[],n=0,r=[],s=0,o=[],c=0,h=[],l=[];return t.forEach((function(u,_){var d={};if(_>0){var v=t[_-1].close,f=u.high,y=u.low,p=f-y,x=Math.abs(f-v),m=Math.abs(y-v),g=f-t[_-1].high,k=t[_-1].low-y,w=Math.max(Math.max(p,x),m);i+=w,a.push(w);var D=g>0&&g>k?g:0;n+=D,r.push(D);var P=k>0&&k>g?k:0;if(s+=P,o.push(P),_>=e[0]){var M,b,T;if(0===i?(M=0,b=0):(M=100*n/i,b=100*s/i),c+=T=b+M===0?0:Math.abs(b-M)/(b+M)*100,h.push(T),d.pdi=M,d.mdi=b,_>=e[0]+e[1]-1){var C=c/e[1];d.adx=C,e[0]+2*e[1]-2>_||(d.adxr=(C+l[_-(e[1]-1)].adx)/2),c-=h[_-(e[0]+e[1]-1)]}i-=a[_-e[0]],n-=r[_-e[0]],s-=o[_-e[0]]}}l.push(d)})),l}}]),a}(j),nt=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"CR",calcParams:[26,10,20,40,60],plots:[{key:"cr",type:"line"},{key:"ma1",type:"line"},{key:"ma2",type:"line"},{key:"ma3",type:"line"},{key:"ma4",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=Math.ceil(e[1]/2.5+1),a=Math.ceil(e[2]/2.5+1),n=Math.ceil(e[3]/2.5+1),r=Math.ceil(e[4]/2.5+1),s=0,o=[],c=0,h=[],l=0,u=[],_=0,d=[],v=[];return t.forEach((function(f,y){var p={};if(y>0){var x=t[y-1],m=(x.high+x.close+x.low+x.open)/4,g=Math.max(0,f.high-m),k=Math.max(0,m-f.low);if(y>=e[0]){p.cr=0!==k?g/k*100:0;s+=p.cr,c+=p.cr,l+=p.cr,_+=p.cr,e[0]+e[1]-1>y||(o.push(s/e[1]),e[0]+e[1]+i-2>y||(p.ma1=o[o.length-1-i]),s-=v[y-(e[1]-1)].cr),e[0]+e[2]-1>y||(h.push(c/e[2]),e[0]+e[2]+a-2>y||(p.ma2=h[h.length-1-a]),c-=v[y-(e[2]-1)].cr),e[0]+e[3]-1>y||(u.push(l/e[3]),e[0]+e[3]+n-2>y||(p.ma3=u[u.length-1-n]),l-=v[y-(e[3]-1)].cr),e[0]+e[4]-1>y||(d.push(_/e[4]),e[0]+e[4]+r-2>y||(p.ma4=d[d.length-1-r]),_-=v[y-(e[4]-1)].cr)}}v.push(p)})),v}}]),a}(j),rt=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"PSY",calcParams:[12,6],plots:[{key:"psy",type:"line"},{key:"maPsy",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=0,n=[],r=[];return t.forEach((function(t,s){var o={},c=t.close-t.open>0?1:0;n.push(c),i+=c,e[0]-1>s||(o.psy=i/e[0]*100,a+=o.psy,e[0]+e[1]-2>s||(o.maPsy=a/e[1],a-=r[s-(e[1]-1)].psy),i-=n[s-(e[0]-1)]),r.push(o)})),r}}]),a}(j),st=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"DMA",calcParams:[10,50,10],plots:[{key:"dma",type:"line"},{key:"ama",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=Math.max(e[0],e[1]),a=0,n=0,r=0,s=[];return t.forEach((function(o,c){var h,l,u={},_=o.close;if(a+=_,n+=_,e[0]-1>c||(h=a/e[0],a-=t[c-(e[0]-1)].close),e[1]-1>c||(l=n/e[1],n-=t[c-(e[1]-1)].close),c>=i-1){var d=h-l;u.dma=d,r+=d,i+e[2]-2>c||(u.ama=r/e[2],r-=s[c-(e[2]-1)].dma)}s.push(u)})),s}}]),a}(j),ot=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"TRIX",calcParams:[12,20],plots:[{key:"trix",type:"line"},{key:"maTrix",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i,a,n,r,s,o,c=0,h=[];return t.forEach((function(t,l){var u={},_=t.close;0===l?(i=_,a=_,n=_):(n=(2*(a=(2*(i=(2*_+(e[0]-1)*r)/(e[0]+1))+(e[0]-1)*s)/(e[0]+1))+(e[0]-1)*o)/(e[0]+1),u.trix=0===o?0:(n-o)/o*100,c+=u.trix,e[1]-1>l||(u.maTrix=c/e[1],c-=h[l-(e[1]-1)].trix||0)),r=i,s=a,o=n,h.push(u)})),h}}]),a}(j),ct=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"OBV",calcParams:[30],plots:[{key:"obv",type:"line"},{key:"maObv",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=[];return t.forEach((function(t,n){var r={},s=t.close,o=t.high-s;r.obv=0===o?0:(s-t.low-o)/o*t.volume,i+=r.obv,e[0]-1>n||(r.maObv=i/e[0],i-=a[n-(e[0]-1)].obv),a.push(r)})),a}}]),a}(j),ht=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"VR",calcParams:[24,30],plots:[{key:"vr",type:"line"},{key:"maVr",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=0,n=0,r=0,s=[];return t.forEach((function(o,c){var h={},l=o.close,u=o.open,_=o.volume;if(l>u?i+=_:u>l?a+=_:n+=_,c>=e[0]-1){var d=n/2;h.vr=a+d===0?0:(i+d)/(a+d),r+=h.vr,e[0]+e[1]-2>c||(h.maVr=r/e[1],r-=s[c-(e[1]-1)].vr);var v=t[c-(e[0]-1)],f=v.open,y=v.close,p=v.volume;y>f?i-=p:f>y?a-=p:n-=p}s.push(h)})),s}}]),a}(j),lt=function(t){c(a,t);var e=_(a);function a(){var t;return i(this,a),(t=e.call(this,{name:"WR",shouldCheckParamCount:!1})).setCalcParams([6,10,14]),t}return n(a,[{key:"regeneratePlots",value:function(t){return t.map((function(t,e){return{key:"wr".concat(e+1),type:"line"}}))}},{key:"calcTechnicalIndicator",value:function(t,e,i){var a=[];return t.forEach((function(n,r){var s={},o=n.close;e.forEach((function(e,a){var n=e-1;if(r>=n){var c=$(t.slice(r-n,r+1)),h=c.hn,l=h-c.ln;s[i[a].key]=0===l?0:(h-o)/l*100}})),a.push(s)})),a}}]),a}(j),ut=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"MTM",calcParams:[6,10],plots:[{key:"mtm",type:"line"},{key:"maMtm",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=[];return t.forEach((function(n,r){var s={};r<e[0]-1||(s.mtm=n.close-t[r-(e[0]-1)].close,i+=s.mtm,e[0]+e[1]-2>r||(s.maMtm=i/e[1],i-=a[r-(e[1]-1)].mtm));a.push(s)})),a}}]),a}(j),_t=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"SAR",series:G,calcParams:[2,2,20],precision:2,shouldOhlc:!0,plots:[{key:"sar",type:"circle",color:function(t,e){var i=t.currentData,a=i.kLineData||{};return(a.high+a.low)/2>(i.technicalIndicatorData||{}).sar?e.circle.upColor:e.circle.downColor}}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=e[0]/100,a=e[1]/100,n=e[2]/100,r=i,s=-100,o=!1,c=0,h=[];return t.forEach((function(e,l){var u=c,_=e.high,d=e.low;if(o){(-100===s||_>s)&&(s=_,r=Math.min(r+a,n)),c=u+r*(s-u);var v=Math.min(t[Math.max(1,l)-1].low,d);c>e.low?(c=s,r=i,s=-100,o=!o):c>v&&(c=v)}else{(-100===s||s>d)&&(s=d,r=Math.min(r+a,n)),c=u+r*(s-u);var f=Math.max(t[Math.max(1,l)-1].high,_);e.high>c?(c=s,r=0,s=-100,o=!o):f>c&&(c=f)}h.push({sar:c})})),h}}]),a}(j),dt=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"EMV",calcParams:[14,9],plots:[{key:"emv",type:"line"},{key:"maEmv",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=0,n=[],r=[];return t.forEach((function(s,o){var c={};if(o>0){var h=s.high,l=s.low,u=((h+l)/2-(t[o-1].high+t[o-1].low)/2)*(h-l)-(s.turnover||0);n.push(u),i+=u,e[0]>o||(c.emv=i/e[0],a+=c.emv,e[0]+e[1]-1>o||(c.maEmv=a/e[1],a-=r[o-(e[1]-1)].emv),i-=n[o-e[0]])}r.push(c)})),r}}]),a}(j);function vt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0,a=e.calcParams,n=e.plots,r=e.precision,s=e.shouldFormatBigNumber,o=[],c=[],h="";return n.length>0&&(h=e.name),a.length>0&&(h="".concat(h,"(").concat(a.join(","),")")),n.forEach((function(e){o.push(e.key.toUpperCase());var a,n=t[e.key];w(n)&&(a=i.convertToPixel(n),n=W(n,r),s&&(n=Y(n))),c.push({value:n,y:a})})),{labels:o,values:c,name:h}}var ft=function(){function t(){i(this,t),this._observers=[]}return n(t,[{key:"subscribe",value:function(t){0>this._observers.indexOf(t)&&this._observers.push(t)}},{key:"unsubscribe",value:function(t){var e=this._observers.indexOf(t);e>-1&&this._observers.splice(e,1)}},{key:"execute",value:function(t){this._observers.forEach((function(e){e(t)}))}},{key:"hasObservers",value:function(){return this._observers.length>0}}]),t}(),yt=1,pt=2,xt=3,mt=4,gt="none",kt="horizontalStraightLine",wt="verticalStraightLine",Dt="straightLine",Pt="horizontalRayLine",Mt="verticalRayLine",bt="rayLine",Tt="horizontalSegmentLine",Ct="verticalSegmentLine",St="segmentLine",Lt="priceLine",Et="priceChannelLine",At="parallelStraightLine",It="fibonacciLine",zt="drawCandle",Ht="drawTechnicalIndicator",Vt=function(){function t(e,a){var n,s;i(this,t),this._invalidateHandler=a,this._styleOptions=p(O),y(this._styleOptions,e),this._technicalIndicators=(r(s={},"MA",new N),r(s,"EMA",new K),r(s,"VOL",new U),r(s,"MACD",new Z),r(s,"BOLL",new q),r(s,"KDJ",new J),r(s,"RSI",new Q),r(s,"BIAS",new tt),r(s,"BRAR",new et),r(s,"CCI",new it),r(s,"DMI",new at),r(s,"CR",new nt),r(s,"PSY",new rt),r(s,"DMA",new st),r(s,"TRIX",new ot),r(s,"OBV",new ct),r(s,"VR",new ht),r(s,"WR",new lt),r(s,"MTM",new ut),r(s,"EMV",new dt),r(s,"SAR",new _t),s),this._pricePrecision=2,this._volumePrecision=0,this._dateTimeFormat=new Intl.DateTimeFormat("en",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),this._dataList=[],this._loading=!0,this._loadMoreCallback=null,this._more=!0,this._totalDataSpace=0,this._dataSpace=6,this._barSpace=this._calcBarSpace(),this._offsetRightSpace=50,this._offsetRightBarCount=this._offsetRightSpace/this._dataSpace,this._leftMinVisibleBarCount=2,this._rightMinVisibleBarCount=2,this._from=0,this._to=0,this._crossHair={},this._preOffsetRightBarCount=0,this._graphicMarkType=gt,this._graphicMarkPoint=null,this._dragGraphicMarkFlag=!1,this._graphicMarkDatas={horizontalStraightLine:[],verticalStraightLine:[],straightLine:[],horizontalRayLine:[],verticalRayLine:[],rayLine:[],horizontalSegmentLine:[],verticalSegmentLine:[],segmentLine:[],priceLine:[],parallelStraightLine:[],priceChannelLine:[],fibonacciLine:[]},this._drawActionDelegate=(r(n={},zt,new ft),r(n,Ht,new ft),n)}return n(t,[{key:"_loadMoreHandler",value:function(){this._more&&!this._loading&&this._loadMoreCallback&&m(this._loadMoreCallback)&&(this._loading=!0,this._loadMoreCallback(B(this._dataList[0],"timestamp")))}},{key:"_calcBarSpace",value:function(){return Math.max(1,Math.min(Math.floor(.8*this._dataSpace),Math.floor(this._dataSpace)-1))}},{key:"_innerSetDataSpace",value:function(t){return!(!t||3>t||t>50||this._dataSpace===t)&&(this._dataSpace=t,this._barSpace=this._calcBarSpace(),!0)}},{key:"styleOptions",value:function(){return this._styleOptions}},{key:"applyStyleOptions",value:function(t){y(this._styleOptions,t)}},{key:"technicalIndicatorCalcParams",value:function(t){var e=this.technicalIndicator(t);if(e)return p(e.calcParams);var i={};for(var a in this._technicalIndicators)i[a]=p(this._technicalIndicators[a].calcParams);return i}},{key:"technicalIndicator",value:function(t){return this._technicalIndicators[t]}},{key:"pricePrecision",value:function(){return this._pricePrecision}},{key:"volumePrecision",value:function(){return this._volumePrecision}},{key:"dateTimeFormat",value:function(){return this._dateTimeFormat}},{key:"setTimezone",value:function(t){var e;try{e=new Intl.DateTimeFormat("en",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}catch(t){}e&&(this._dateTimeFormat=e)}},{key:"timezone",value:function(){return this._dateTimeFormat.resolvedOptions().timeZone}},{key:"applyPrecision",value:function(t,e){var i=w(t)&&k(t)&&t>=0,a=w(e)&&k(e)&&e>=0;if(i&&(this._pricePrecision=t),a&&(this._volumePrecision=e),i||a)for(var n in this._technicalIndicators){switch(this._technicalIndicators[n].series){case G:this._technicalIndicators[n].setPrecision(t);break;case X:this._technicalIndicators[n].setPrecision(e)}}}},{key:"applyTechnicalIndicatorPrecision",value:function(t,e){var i=this.technicalIndicator(e);if(i)i.setPrecision(t);else for(var a in this._technicalIndicators)this._technicalIndicators[a].setPrecision(t)}},{key:"dataList",value:function(){return this._dataList}},{key:"clearDataList",value:function(){this._more=!0,this._loading=!0,this._dataList=[],this._from=0,this._to=0}},{key:"addData",value:function(t,e,i){if(g(t))if(x(t)){this._loading=!1,this._more=!D(i)||i;var a=0===this._dataList.length;this._dataList=t.concat(this._dataList),a?this.setOffsetRightSpace(this._offsetRightSpace):this.adjustOffsetBarCount()}else{this._dataList.length>e?this._dataList[e]=t:(this._dataList.push(t),0>this._offsetRightBarCount&&(this._offsetRightBarCount-=1),this.adjustOffsetBarCount())}}},{key:"dataSpace",value:function(){return this._dataSpace}},{key:"barSpace",value:function(){return this._barSpace}},{key:"offsetRightBarCount",value:function(){return this._offsetRightBarCount}},{key:"setDataSpace",value:function(t){this._innerSetDataSpace(t)&&(this.adjustOffsetBarCount(),this._invalidateHandler())}},{key:"setTotalDataSpace",value:function(t){this._totalDataSpace!==t&&(this._totalDataSpace=t,this.adjustOffsetBarCount())}},{key:"setOffsetRightSpace",value:function(t){this._offsetRightSpace=t,this._offsetRightBarCount=t/this._dataSpace,this.adjustOffsetBarCount()}},{key:"setLeftMinVisibleBarCount",value:function(t){k(t)&&t>0&&(this._leftMinVisibleBarCount=Math.ceil(t))}},{key:"setRightMinVisibleBarCount",value:function(t){k(t)&&t>0&&(this._rightMinVisibleBarCount=Math.ceil(t))}},{key:"from",value:function(){return this._from}},{key:"to",value:function(){return this._to}},{key:"crossHair",value:function(){return this._crossHair}},{key:"setCrossHairPointPaneTag",value:function(t,e){var i={};t&&(i.x=t.x,i.y=t.y,i.paneTag=this._crossHair.paneTag),void 0!==e&&(i.paneTag=e,this._crossHair=i,this._invalidateHandler(pt))}},{key:"startScroll",value:function(){this._preOffsetRightBarCount=this._offsetRightBarCount}},{key:"scroll",value:function(t){this._offsetRightBarCount=this._preOffsetRightBarCount-t/this._dataSpace,this.adjustOffsetBarCount(),this._invalidateHandler()}},{key:"coordinateToFloatIndex",value:function(t){return Math.round(1e6*(this._dataList.length+this._offsetRightBarCount-(this._totalDataSpace-t)/this._dataSpace))/1e6}},{key:"zoom",value:function(t,e){e&&!w(e.x)||(e={x:w(this._crossHair.x)?this._crossHair.x:this._totalDataSpace/2});var i=this.coordinateToFloatIndex(e.x);this._innerSetDataSpace(this._dataSpace+t*(this._dataSpace/10))&&(this._offsetRightBarCount+=i-this.coordinateToFloatIndex(e.x),this.adjustOffsetBarCount(),this._invalidateHandler())}},{key:"adjustOffsetBarCount",value:function(){var t=this._dataList.length,e=this._totalDataSpace/this._dataSpace,i=1-this._barSpace/2/this._dataSpace,a=e-Math.min(this._leftMinVisibleBarCount,t)+i;this._offsetRightBarCount>a&&(this._offsetRightBarCount=a);var n=1-t+Math.min(this._rightMinVisibleBarCount,t)-i;n>this._offsetRightBarCount&&(this._offsetRightBarCount=n),this._to=Math.round(this._offsetRightBarCount+t),this._from=Math.floor(this._to-e)-1,this._to>t&&(this._to=t),0>this._from&&(this._from=0),0===this._from&&this._loadMoreHandler()}},{key:"graphicMarkType",value:function(){return this._graphicMarkType}},{key:"setGraphicMarkType",value:function(t){this._graphicMarkType=t}},{key:"dragGraphicMarkFlag",value:function(){return this._dragGraphicMarkFlag}},{key:"setDragGraphicMarkFlag",value:function(t){this._dragGraphicMarkFlag=t}},{key:"graphicMarkPoint",value:function(){return this._graphicMarkPoint}},{key:"setGraphicMarkPoint",value:function(t){this._graphicMarkPoint=t}},{key:"graphicMarkData",value:function(){return p(this._graphicMarkDatas)}},{key:"setGraphicMarkData",value:function(t){var e=this.shouldInvalidateGraphicMark();this._graphicMarkDatas=p(t),(e||this.shouldInvalidateGraphicMark())&&this._invalidateHandler(yt)}},{key:"loadMore",value:function(t){this._loadMoreCallback=t}},{key:"shouldInvalidateGraphicMark",value:function(){if(this._graphicMarkType!==gt)return!0;for(var t in this._graphicMarkDatas)if(this._graphicMarkDatas[t].length>0)return!0;return!1}},{key:"addCustomTechnicalIndicator",value:function(t){var e=function(t){var e=t.name,a=t.series,n=t.calcParams,r=t.plots,s=t.precision,o=t.shouldCheckParamCount,h=t.shouldOhlc,l=t.shouldFormatBigNumber,u=t.baseValue,d=t.minValue,v=t.maxValue,f=t.calcTechnicalIndicator,y=t.regeneratePlots,p=t.render;if(!e||!m(f))return null;var x=function(t){c(y,t);var f=_(y);function y(){return i(this,y),f.call(this,{name:e,series:a,calcParams:n,plots:r,precision:s,shouldCheckParamCount:o,shouldOhlc:h,shouldFormatBigNumber:l,baseValue:u,minValue:d,maxValue:v})}return y}(j);return x.prototype.calcTechnicalIndicator=f,y&&m(y)&&(x.prototype.regeneratePlots=y),p&&m(p)&&(x.prototype.render=p),new x}(t||{});e&&(this._technicalIndicators[t.name]=e)}},{key:"drawActionDelegate",value:function(t){return this._drawActionDelegate[t]}}]),t}();function Rt(t){return t.ownerDocument&&t.ownerDocument.defaultView&&t.ownerDocument.defaultView.devicePixelRatio||1}function Ot(t,e){return Math.round(t.measureText(e).width)}function Bt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Helvetica Neue";return"".concat(e," ").concat(t,"px ").concat(i)}function Ft(t,e,i,a){t.beginPath();var n=t.lineWidth%2?.5:0;t.moveTo(i,e+n),t.lineTo(a,e+n),t.stroke(),t.closePath()}function Wt(t,e,i,a){t.beginPath();var n=t.lineWidth%2?.5:0;t.moveTo(e+n,i),t.lineTo(e+n,a),t.stroke(),t.closePath()}function Yt(t,e){t.save(),t.lineWidth%2&&t.translate(.5,.5),e(),t.restore()}var Gt=function(){function t(e){i(this,t),this._height=-1,this._container=e.container,this._chartData=e.chartData,this._initBefore(e),this._initElement(),this._mainWidget=this._createMainWidget(this._element,e),this._yAxisWidget=this._createYAxisWidget(this._element,e)}return n(t,[{key:"_initBefore",value:function(t){}},{key:"_initElement",value:function(){this._element=document.createElement("div"),this._element.style.margin="0",this._element.style.padding="0",this._element.style.position="relative",this._element.style.overflow="hidden",this._element.style.width="100%";var t=this._container.lastChild;t?this._container.insertBefore(this._element,t):this._container.appendChild(this._element)}},{key:"_createMainWidget",value:function(t,e){}},{key:"_createYAxisWidget",value:function(t,e){}},{key:"computeAxis",value:function(){}},{key:"width",value:function(){return this._element.offsetWidth}},{key:"setWidth",value:function(t,e){this._mainWidget.setWidth(t),this._yAxisWidget&&this._yAxisWidget.setWidth(e)}},{key:"height",value:function(){return this._height}},{key:"setHeight",value:function(t){this._height=t,this._mainWidget.setHeight(t),this._yAxisWidget&&this._yAxisWidget.setHeight(t)}},{key:"setOffsetLeft",value:function(t,e){this._mainWidget.setOffsetLeft(t),this._yAxisWidget&&this._yAxisWidget.setOffsetLeft(e)}},{key:"layout",value:function(){this._element.offsetHeight!==this._height&&(this._element.style.height="".concat(this._height,"px")),this._mainWidget.layout(),this._yAxisWidget&&this._yAxisWidget.layout()}},{key:"invalidate",value:function(t){this._yAxisWidget&&this._yAxisWidget.invalidate(t),this._mainWidget.invalidate(t)}},{key:"getImage",value:function(t,e){var i=document.createElement("canvas"),a=i.getContext("2d"),n=Rt(i),r=this._element.offsetWidth,s=this._element.offsetHeight;i.style.width="".concat(r,"px"),i.style.height="".concat(s,"px"),i.width=r*n,i.height=s*n,a.scale(n,n);var o=this._mainWidget.getElement(),c=o.offsetWidth,h=o.offsetHeight,l=parseInt(o.style.left,10);if(a.drawImage(this._mainWidget.getImage(t,e),l,0,c,h),this._yAxisWidget){var u=this._yAxisWidget.getElement(),_=u.offsetWidth,d=u.offsetHeight,v=parseInt(u.style.left,10);a.drawImage(this._yAxisWidget.getImage(t),v,0,_,d)}return i}},{key:"destroy",value:function(){this._container.removeChild(this._element)}}]),t}(),Xt=function(){function t(e){i(this,t),this._width=0,this._height=0,this._initElement(e.container),this._mainView=this._createMainView(this._element,e),this._expandView=this._createExpandView(this._element,e),this._floatLayerView=this._createFloatLayerView(this._element,e)}return n(t,[{key:"_initElement",value:function(t){this._element=document.createElement("div"),this._element.style.top="0",this._element.style.margin="0",this._element.style.padding="0",this._element.style.position="absolute",this._element.style.overflow="hidden",t.appendChild(this._element)}},{key:"_createMainView",value:function(t,e){}},{key:"_createExpandView",value:function(t,e){}},{key:"_createFloatLayerView",value:function(t,e){}},{key:"getElement",value:function(){return this._element}},{key:"setWidth",value:function(t){this._width=t,this._mainView.setWidth(t),this._floatLayerView.setWidth(t),this._expandView&&this._expandView.setWidth(t)}},{key:"setHeight",value:function(t){this._height=t,this._mainView.setHeight(t),this._floatLayerView.setHeight(t),this._expandView&&this._expandView.setHeight(t)}},{key:"setOffsetLeft",value:function(t){this._element.style.left="".concat(t,"px")}},{key:"layout",value:function(){this._element.offsetWidth!==this._width&&(this._element.style.width="".concat(this._width,"px")),this._element.offsetHeight!==this._height&&(this._element.style.height="".concat(this._height,"px")),this._mainView.layout(),this._floatLayerView.layout(),this._expandView&&this._expandView.layout()}},{key:"invalidate",value:function(t){switch(t){case yt:this._expandView&&this._expandView.flush();break;case pt:this._floatLayerView.flush();break;case xt:case mt:this._mainView.flush(),this._floatLayerView.flush(),this._expandView&&this._expandView.flush()}}},{key:"getImage",value:function(t,e){var i=document.createElement("canvas"),a=i.getContext("2d"),n=Rt(i);return i.style.width="".concat(this._width,"px"),i.style.height="".concat(this._height,"px"),i.width=this._width*n,i.height=this._height*n,a.scale(n,n),a.drawImage(this._mainView.getImage(),0,0,this._width,this._height),e&&this._expandView&&a.drawImage(this._expandView.getImage(),0,0,this._width,this._height),t&&a.drawImage(this._floatLayerView.getImage(),0,0,this._width,this._height),i}}]),t}();var jt="line",Nt="bar",Kt="circle",Ut=function(){function t(e,a){i(this,t),this._chartData=a,this._initCanvas(e)}return n(t,[{key:"_initCanvas",value:function(t){this._canvas=document.createElement("canvas"),this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0",this._canvas.style.zIndex="2",this._ctx=this._canvas.getContext("2d"),t.appendChild(this._canvas)}},{key:"_redraw",value:function(t){this._ctx.clearRect(0,0,this._canvas.offsetWidth,this._canvas.offsetHeight),t&&t(),this._draw()}},{key:"_draw",value:function(){}},{key:"setWidth",value:function(t){this._width=t}},{key:"setHeight",value:function(t){this._height=t}},{key:"layout",value:function(){var t=this;this._height!==this._canvas.offsetHeight||this._width!==this._canvas.offsetWidth?this._redraw((function(){var e=Rt(t._canvas);t._canvas.style.width="".concat(t._width,"px"),t._canvas.style.height="".concat(t._height,"px"),t._canvas.width=t._width*e,t._canvas.height=t._height*e,t._ctx.scale(e,e)})):this.flush()}},{key:"flush",value:function(){var t,e,i=this;this.requestAnimationId&&(t=this.requestAnimationId,window.cancelAnimationFrame||clearTimeout(t),window.cancelAnimationFrame(t)),this.requestAnimationId=(e=function(){i._redraw()},window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout((function(){e()}),1e3/60))}},{key:"getImage",value:function(){return this._canvas}}]),t}(),Zt=function(t){c(a,t);var e=_(a);function a(t,n,r,s,o){var c;return i(this,a),(c=e.call(this,t,n))._xAxis=r,c._yAxis=s,c._additionalDataProvider=o,c}return n(a,[{key:"_draw",value:function(){this._drawGrid(),this._drawTechnicalIndicator()}},{key:"_drawGrid",value:function(){var t=this,e=this._chartData.styleOptions().grid;if(e.display){var i=e.horizontal;this._ctx.save(),i.display&&(this._ctx.strokeStyle=i.color,this._ctx.lineWidth=i.size,i.style===P&&this._ctx.setLineDash(i.dashValue),this._yAxis.ticks().forEach((function(e){Ft(t._ctx,e.y,0,t._width)})));var a=e.vertical;a.display&&(this._ctx.strokeStyle=a.color,this._ctx.lineWidth=a.size,this._ctx.setLineDash(a.style===P?a.dashValue:[]),this._xAxis.ticks().forEach((function(e){Wt(t._ctx,e.x,0,t._height)}))),this._ctx.restore()}}},{key:"_drawTechnicalIndicator",value:function(){var t=this,e=this._additionalDataProvider.technicalIndicator(),i=e.plots,a=[],n=this._chartData.styleOptions().technicalIndicator,r=this._chartData.dataList(),s=e.result;e.render&&(this._ctx.save(),e.render(this._ctx,{from:this._chartData.from(),to:this._chartData.to(),kLineDataList:this._chartData.dataList(),technicalIndicatorDataList:s},{width:this._width,height:this._height,dataSpace:this._chartData.dataSpace(),barSpace:this._chartData.barSpace()},this._chartData.styleOptions(),this._xAxis,this._yAxis,this._yAxis.isCandleStickYAxis()),this._ctx.restore());var c=e.baseValue;w(c)||(c=this._yAxis.min());var h=this._yAxis.convertToPixel(c),l=this._yAxis.isCandleStickYAxis();this._ctx.lineWidth=1,this._drawGraphics((function(c,u,_,d,v){var f=s[u]||{},y=0;e.shouldOhlc&&!l&&t._drawCandleStickBar(c,d,v,u,_,n.bar,z);var p={};i.forEach((function(i){var x=f[i.key],m=t._yAxis.convertToPixel(x);switch(p[i.key]=m,i.type){case Kt:if(w(x)){var g={preData:{kLineData:r[u-1],technicalIndicatorData:s[u-1]},currentData:{kLineData:_,technicalIndicatorData:f}},k={x:c,y:m,radius:d,color:i.color&&i.color(g,n)||n.circle.noChangeColor,isStroke:!i.isStroke||i.isStroke(g)};t._drawCircle(k)}break;case Nt:if(w(x)){var D={preData:{kLineData:r[u-1],technicalIndicatorData:s[u-1]},currentData:{kLineData:_,technicalIndicatorData:f}},P=Math.abs(h-m),M={x:c-d,width:2*d,height:Math.max(1,P)};M.y=m>h?h:1>P?h+1:m,M.color=i.color&&i.color(D,n)||n.bar.noChangeColor,M.isStroke=!!i.isStroke&&i.isStroke(D),t._drawBar(M)}break;case jt:if(w(x)){var b={x:c,y:m};a[y]?a[y].push(b):a[y]=[b]}else a[y]?a[y].push(null):a[y]=[null];y++}t._drawActionExecute(Ht,{ctx:t._ctx,kLineData:_,technicalIndicatorData:f,technicalIndicatorType:e.name,coordinate:o({x:c},p),viewport:{width:t._width,height:t._height},barSpace:v,halfBarSpace:d,isCandleStick:l})}))}),(function(){t._drawLines(a,n)}))}},{key:"_drawLines",value:function(t,e){var i=this,a=e.line.colors,n=(a||[]).length;this._ctx.lineWidth=e.line.size,Yt(this._ctx,(function(){t.forEach((function(t,e){i._ctx.strokeStyle=a[e%n],i._ctx.beginPath();var r=!0;t.forEach((function(t){w(t)&&(r?(i._ctx.moveTo(t.x,t.y),r=!1):i._ctx.lineTo(t.x,t.y))})),i._ctx.stroke(),i._ctx.closePath()}))}))}},{key:"_drawBar",value:function(t){t.isStroke?(this._ctx.strokeStyle=t.color,this._ctx.strokeRect(t.x+.5,t.y,t.width-1,t.height)):(this._ctx.fillStyle=t.color,this._ctx.fillRect(t.x,t.y,t.width,t.height))}},{key:"_drawCircle",value:function(t){this._ctx.strokeStyle=t.color,this._ctx.fillStyle=t.color,this._ctx.beginPath(),this._ctx.arc(t.x,t.y,t.radius,2*Math.PI,0,!0),t.isStroke?this._ctx.stroke():this._ctx.fill(),this._ctx.closePath()}},{key:"_drawGraphics",value:function(t,e){for(var i=this._chartData.dataList(),a=i.length,n=this._chartData.barSpace(),r=this._chartData.dataSpace(),s=n/2,o=this._chartData.offsetRightBarCount(),c=this._chartData.to(),h=this._chartData.from();c>h;h++){t(this._width-(a+o-h-.5)*r+s,h,i[h],s,n)}e&&e()}},{key:"_drawCandleStickBar",value:function(t,e,i,a,n,r,s){var o=n.open,c=n.close,h=n.high,l=n.low;c>o?(this._ctx.strokeStyle=r.upColor,this._ctx.fillStyle=r.upColor):o>c?(this._ctx.strokeStyle=r.downColor,this._ctx.fillStyle=r.downColor):(this._ctx.strokeStyle=r.noChangeColor,this._ctx.fillStyle=r.noChangeColor);var u=this._yAxis.convertToPixel(o),_=this._yAxis.convertToPixel(c),d=this._yAxis.convertToPixel(h),v=this._yAxis.convertToPixel(l),f=Math.min(u,_),y=Math.max(u,_);this._ctx.fillRect(t-.5,d,1,f-d),this._ctx.fillRect(t-.5,y,1,v-y);var p=Math.max(1,y-f);switch(s){case L:this._ctx.fillRect(t-e,f,i,p);break;case E:this._ctx.strokeRect(t-e+.5,f,i-1,p);break;case A:c>o?this._ctx.strokeRect(t-e+.5,f,i-1,p):this._ctx.fillRect(t-e,f,i,p);break;case I:c>o?this._ctx.fillRect(t-e,f,i,p):this._ctx.strokeRect(t-e+.5,f,i-1,p);break;default:this._ctx.fillRect(t-.5,d,1,v-d),this._ctx.fillRect(t-e,u-.5,e,1),this._ctx.fillRect(t,_-.5,e,1)}this._drawActionExecute(zt,{ctx:this._ctx,dataIndex:a,kLineData:n,coordinate:{x:t,open:u,close:_,high:d,low:v},viewport:{width:this._width,height:this._height},barSpace:i,halfBarSpace:e,isCandleStick:this._yAxis.isCandleStickYAxis()})}},{key:"_drawActionExecute",value:function(t,e){var i=this._chartData.drawActionDelegate(t);i.hasObservers()&&(this._ctx.save(),i.execute(e),this._ctx.restore())}}]),a}(Ut),qt=function(t){c(a,t);var e=_(a);function a(t,n,r,s,o){var c;return i(this,a),(c=e.call(this,t,n))._xAxis=r,c._yAxis=s,c._additionalDataProvider=o,c}return n(a,[{key:"_draw",value:function(){var t,e=this._chartData.crossHair(),i=this._chartData.dataList(),a=this._additionalDataProvider.technicalIndicator(),n=a.result,r=t=w(e.x)?this._xAxis.convertFromPixel(e.x):i.length-1;0>r?r=0:r>i.length-1&&(r=i.length-1);var s=i[r],o=n[r];if(s){var c=this._xAxis.convertToPixel(t);this._drawCrossHairHorizontalLine(e),this._drawCrossHairVerticalLine(e,c);var h=this._chartData.styleOptions().floatLayer.prompt.displayRule;(h===H||h===V&&e.paneTag)&&this._drawPrompt(s,o,t,c,a,t>=0&&i.length-1>=t&&e.paneTag)}}},{key:"_drawPrompt",value:function(t,e,i,a,n){this._drawTechnicalIndicatorPromptText(e,i,n)}},{key:"_drawCrossHairHorizontalLine",value:function(t){if(t.paneTag===this._additionalDataProvider.tag()){var e=this._chartData.styleOptions().floatLayer.crossHair,i=e.horizontal,a=i.line;e.display&&i.display&&a.display&&(this._ctx.save(),this._ctx.lineWidth=a.size,this._ctx.strokeStyle=a.color,a.style===P&&this._ctx.setLineDash(a.dashValue),Ft(this._ctx,t.y,0,this._width),this._ctx.restore())}}},{key:"_drawCrossHairVerticalLine",value:function(t,e){if(t.paneTag){var i=this._chartData.styleOptions().floatLayer.crossHair,a=i.vertical,n=a.line;i.display&&a.display&&n.display&&(this._ctx.save(),this._ctx.lineWidth=n.size,this._ctx.strokeStyle=n.color,n.style===P&&this._ctx.setLineDash(n.dashValue),Wt(this._ctx,e,0,this._height),this._ctx.restore())}}},{key:"_drawTechnicalIndicatorPromptText",value:function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=this._chartData.styleOptions().technicalIndicator,r=vt(t,i,this._yAxis),s=n.line.colors,o=this._chartData.dataList(),c={preData:{kLineData:o[e-1],technicalIndicatorData:i.result[e-1]},currentData:{kLineData:o[e],technicalIndicatorData:i.result[e]}},h=i.plots,l=this._chartData.styleOptions().floatLayer.prompt.technicalIndicator.text,u=r.name,_=r.labels,d=r.values,v=l.marginLeft,f=l.marginRight,y=v,p=l.marginTop+a,x=l.size,m=l.color,g=s.length;this._ctx.textBaseline="top",this._ctx.font=Bt(x,l.weight,l.family);var k=Ot(this._ctx,u);this._ctx.fillStyle=m,this._ctx.fillText(u,y,p),y+=v+k;for(var w=0,D=0;_.length>D;D++){switch(h[D].type){case Kt:this._ctx.fillStyle=h[D].color&&h[D].color(c,n)||n.circle.noChangeColor;break;case Nt:this._ctx.fillStyle=h[D].color&&h[D].color(c,n)||n.bar.noChangeColor;break;case jt:this._ctx.fillStyle=s[w%g]||m,w++}var P="".concat(_[D],": ").concat(d[D].value||"n/a"),M=Ot(this._ctx,P);this._ctx.fillText(P,y,p),y+=v+f+M}}}]),a}(Ut),$t=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_createMainView",value:function(t,e){return new Zt(t,e.chartData,e.xAxis,e.yAxis,e.additionalDataProvider)}},{key:"_createFloatLayerView",value:function(t,e){return new qt(t,e.chartData,e.xAxis,e.yAxis,e.additionalDataProvider)}}]),a}(Xt),Jt=function(t){c(a,t);var e=_(a);function a(t,n,r,s){var o;return i(this,a),(o=e.call(this,t,n))._yAxis=r,o._additionalDataProvider=s,o}return n(a,[{key:"_draw",value:function(){var t=this._chartData.styleOptions().yAxis;t.display&&(this._drawAxisLine(t),this._drawTickLines(t),this._drawTickLabels(t),this._drawTechnicalIndicatorLastValue(t),this._drawLastPriceLabel(t))}},{key:"_drawAxisLine",value:function(t){var e,i=t.axisLine;i.display&&(this._ctx.strokeStyle=i.color,this._ctx.lineWidth=i.size,e=this._isDrawFromStart(t)?0:this._width-1,Wt(this._ctx,e,0,this._height))}},{key:"_drawTickLines",value:function(t){var e=this,i=t.tickLine;if(i.display){this._ctx.lineWidth=i.size,this._ctx.strokeStyle=i.color;var a,n,r=i.length;this._isDrawFromStart(t)?(a=0,t.axisLine.display&&(a+=t.axisLine.size),n=a+r):(a=this._width,t.axisLine.display&&(a-=t.axisLine.size),n=a-r),this._yAxis.ticks().forEach((function(t){Ft(e._ctx,t.y,a,n)}))}}},{key:"_drawTickLabels",value:function(t){var e=this,i=t.tickText;if(i.display){var a,n=t.tickLine,r=n.display,s=n.length;this._isDrawFromStart(t)?(a=i.paddingLeft,t.axisLine.display&&(a+=t.axisLine.size),r&&(a+=s),this._ctx.textAlign="left"):(a=this._width-i.paddingRight,t.axisLine.display&&(a-=t.axisLine.size),r&&(a-=s),this._ctx.textAlign="right"),this._ctx.textBaseline="middle",this._ctx.font=Bt(i.size,i.weight,i.family),this._ctx.fillStyle=i.color,this._yAxis.ticks().forEach((function(t){e._ctx.fillText(t.v,a,t.y)})),this._ctx.textAlign="left"}}},{key:"_drawTechnicalIndicatorLastValue",value:function(t){var e=this,i=this._chartData.styleOptions().technicalIndicator,a=i.lastValueMark,n=this._additionalDataProvider.technicalIndicator(),r=n.result,s=r.length,o=r[s-1];if(a.display&&o){var c=this._chartData.dataList(),h={preData:{kLineData:c[s-2],technicalIndicatorData:r[s-2]},currentData:{kLineData:c[s-1],technicalIndicatorData:o}},l=n.precision,u=i.line.colors||[],_=u.length,d=0;n.plots.forEach((function(n){var r,s=o[n.key];switch(n.type){case Kt:r=n.color&&n.color(h,i)||i.circle.noChangeColor;break;case Nt:r=n.color&&n.color(h,i)||i.bar.noChangeColor;break;default:r=u[d%_],d++}w(s)&&e._drawMarkLabel(t,s,l,a.textSize,a.textWeight,a.textFamily,a.textColor,r,a.textPaddingLeft,a.textPaddingTop,a.textPaddingRight,a.textPaddingBottom)}))}}},{key:"_drawLastPriceLabel",value:function(t){if(this._yAxis.isCandleStickYAxis()){var e=this._chartData.styleOptions().candleStick.priceMark,i=e.last,a=this._chartData.dataList(),n=a.length;if(e.display&&i.display&&i.text.display&&0!==n){var r,s=a[n-1],o=s.close,c=s.open;r=o>c?i.upColor:c>o?i.downColor:i.noChangeColor;var h=i.text;this._drawMarkLabel(t,o,this._chartData.pricePrecision(),h.size,h.weight,h.family,h.color,r,h.paddingLeft,h.paddingTop,h.paddingRight,h.paddingBottom)}}}},{key:"_drawMarkLabel",value:function(t,e,i,a,n,r,s,o,c,h,l,u){var _,d=this._yAxis.convertToPixel(e);if(d=+Math.max(.05*this._height,Math.min(d,.98*this._height)).toFixed(0),this._yAxis.isPercentageYAxis()){var v=this._chartData.dataList()[this._chartData.from()].close;_="".concat(((e-v)/v*100).toFixed(2),"%")}else _=W(e,i),this._additionalDataProvider.technicalIndicator().shouldFormatBigNumber&&(_=Y(_));this._ctx.font=Bt(a,n,r);var f,y=Ot(this._ctx,_)+c+l,p=h+a+u;f=this._isDrawFromStart(t)?0:this._width-y,this._ctx.fillStyle=o,this._ctx.fillRect(f,d-h-a/2,y,p),this._ctx.fillStyle=s,this._ctx.textBaseline="middle",this._ctx.fillText(_,f+c,d)}},{key:"_isDrawFromStart",value:function(t){return t.position===M&&t.inside||t.position===b&&!t.inside}}]),a}(Ut),Qt=function(t){c(a,t);var e=_(a);function a(t,n,r,s){var o;return i(this,a),(o=e.call(this,t,n))._yAxis=r,o._additionalDataProvider=s,o}return n(a,[{key:"_draw",value:function(){this._drawCrossHairLabel()}},{key:"_drawCrossHairLabel",value:function(){var t=this._chartData.crossHair();if(t.paneTag===this._additionalDataProvider.tag()&&0!==this._chartData.dataList().length){var e=this._chartData.styleOptions().floatLayer.crossHair,i=e.horizontal,a=i.text;if(e.display&&i.display&&a.display){var n,r=this._yAxis.convertFromPixel(t.y);if(this._yAxis.isPercentageYAxis()){var s=this._chartData.dataList()[this._chartData.from()].close;n="".concat(((r-s)/s*100).toFixed(2),"%")}else{var o=this._additionalDataProvider.technicalIndicator();n=W(r,this._yAxis.isCandleStickYAxis()?this._chartData.pricePrecision():o.precision),o.shouldFormatBigNumber&&(n=Y(n))}var c=a.size;this._ctx.font=Bt(c,a.weight,a.family);var h,l=Ot(this._ctx,n),u=a.paddingLeft,_=a.paddingTop,d=a.borderSize,v=l+2*d+u+a.paddingRight,f=c+2*d+_+a.paddingBottom,y=this._chartData.styleOptions().yAxis;h=y.position===M&&y.inside||y.position===b&&!y.inside?0:this._width-v;var p=t.y-d-_-c/2;this._ctx.fillStyle=a.backgroundColor,this._ctx.fillRect(h,p,v,f),this._ctx.lineWidth=d,this._ctx.strokeStyle=a.borderColor,this._ctx.strokeRect(h,p,v,f),this._ctx.textBaseline="middle",this._ctx.fillStyle=a.color,this._ctx.fillText(n,h+d+u,t.y)}}}}]),a}(Ut),te=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_createMainView",value:function(t,e){return new Jt(t,e.chartData,e.yAxis,e.additionalDataProvider)}},{key:"_createFloatLayerView",value:function(t,e){return new Qt(t,e.chartData,e.yAxis,e.additionalDataProvider)}}]),a}(Xt),ee=function(){function t(e){i(this,t),this._chartData=e,this._width=0,this._height=0,this._cacheMinValue=0,this._cacheMaxValue=0,this._minValue=0,this._maxValue=0,this._range=0,this._ticks=[],this._initMeasureCanvas()}return n(t,[{key:"_initMeasureCanvas",value:function(){var t=document.createElement("canvas"),e=Rt(t);this._measureCtx=t.getContext("2d"),this._measureCtx.scale(e,e)}},{key:"min",value:function(){return this._minValue}},{key:"max",value:function(){return this._maxValue}},{key:"setWidth",value:function(t){this._width=t}},{key:"setHeight",value:function(t){this._height=t}},{key:"ticks",value:function(){return this._ticks}},{key:"computeAxis",value:function(t){var e=this._computeMinMaxValue(),i=e.min,a=e.max,n=e.range;return this._minValue=i,this._maxValue=a,!(this._cacheMinValue===i&&this._cacheMaxValue===a&&!t)&&(this._cacheMinValue=i,this._cacheMaxValue=a,this._range=n,this._ticks=this._computeOptimalTicks(this._computeTicks()),!0)}},{key:"_computeMinMaxValue",value:function(){}},{key:"_computeOptimalTicks",value:function(t){}},{key:"_computeTicks",value:function(){var t=[];if(this._range>=0){var e=+this._nice(this._range/8),i=this._getIntervalPrecision(e),a=+this._round(Math.ceil(this._minValue/e)*e,i),n=+this._round(Math.floor(this._maxValue/e)*e,i),r=0,s=a;if(0!==e)for(;n>=s;)t[r]={v:s.toFixed(i)},++r,s+=e}return t}},{key:"_nice",value:function(t){var e=Math.floor(Math.log(t)/Math.LN10),i=Math.pow(10,e),a=t/i;return t=(1.5>a?1:2.5>a?2:3.5>a?3:4.5>a?4:5.5>a?5:6.5>a?6:8)*i,-20>e?t:+t.toFixed(0>e?-e:0)}},{key:"_getIntervalPrecision",value:function(t){var e=""+t,i=e.indexOf("e");if(i>0){var a=+e.slice(i+1);return 0>a?-a:0}var n=e.indexOf(".");return 0>n?0:e.length-1-n}},{key:"_round",value:function(t,e){return null==e&&(e=10),t=(+t).toFixed(e=Math.min(Math.max(0,e),20))}}]),t}(),ie=function(t){c(a,t);var e=_(a);function a(t,n,r){var s;return i(this,a),(s=e.call(this,t))._isCandleStickYAxis=n,s._additionalDataProvider=r,s}return n(a,[{key:"_computeMinMaxValue",value:function(){var t=this._minValue,e=this._maxValue,i=Math.abs(e-t);return{min:t-=i/100*10,max:e+=i/100*20,range:i=Math.abs(e-t)}}},{key:"_computeOptimalTicks",value:function(t){var e=[],i=t.length;if(i>0){var a=this._chartData.styleOptions().xAxis.tickText.size,n=this._innerConvertToPixel(+t[0].v),r=1;if(i>1){var s=this._innerConvertToPixel(+t[1].v),o=Math.abs(s-n);2*a>o&&(r=Math.ceil(2*a/o))}for(var c=this._additionalDataProvider.technicalIndicator(),h=this.isPercentageYAxis(),l=this._isCandleStickYAxis?this._chartData.pricePrecision():c.precision,u=c.shouldFormatBigNumber,_=0;i>_;_+=r){var d=t[_].v,v=this._innerConvertToPixel(+(d=0==+d?"0":d)),f="";h?f="".concat(W(d,2),"%"):(f=W(d,l),u&&(f=Y(f))),v>a&&this._height-a>v&&e.push({v:f,y:v})}}return e}},{key:"calcMinMaxValue",value:function(){var t=this,e=this._additionalDataProvider.technicalIndicator(),i=this._additionalDataProvider.isTimeLine(),a=this._chartData.dataList(),n=e.result,r=this._chartData.from(),s=this._chartData.to(),o=this._chartData.styleOptions().realTime.averageLine.display,c=[1/0,-1/0];if(i)for(var h=r;s>h;h++){var l=a[h],u=n[h]||{};c[0]=Math.min(l.close,c[0]),c[1]=Math.max(l.close,c[1]),o&&w(u.average)&&(c[0]=Math.min(u.average,c[0]),c[1]=Math.max(u.average,c[1]))}else for(var _=e.plots||[],d=function(i){var r=a[i],s=n[i]||{};_.forEach((function(t){var e=s[t.key];w(e)&&(c[0]=Math.min(c[0],e),c[1]=Math.max(c[1],e))})),(t._isCandleStickYAxis||e.shouldOhlc)&&(c[0]=Math.min(c[0],r.low),c[1]=Math.max(c[1],r.high))},v=r;s>v;v++)d(v);if(w(e.minValue)&&k(e.minValue)&&(c[0]=e.minValue),w(e.maxValue)&&k(e.maxValue)&&(c[1]=e.maxValue),c[0]!==1/0&&c[1]!==-1/0)if(this.isPercentageYAxis()){var f=a[r].close;this._minValue=(c[0]-f)/f*100,this._maxValue=(c[1]-f)/f*100,(this._minValue===this._maxValue||.01>Math.abs(this._minValue-this._maxValue))&&(this._minValue-=10,this._maxValue+=10)}else if(this._minValue=c[0],this._maxValue=c[1],this._minValue===this._maxValue||1e-12>Math.abs(this._minValue-this._maxValue)){var y=0!==this._minValue?Math.abs(.2*this._minValue):10;this._minValue=0!==this._minValue?this._minValue-y:this._minValue,this._maxValue+=y}}},{key:"_innerConvertToPixel",value:function(t){return Math.round((1-(t-this._minValue)/this._range)*this._height)}},{key:"isCandleStickYAxis",value:function(){return this._isCandleStickYAxis}},{key:"isPercentageYAxis",value:function(){return this._isCandleStickYAxis&&this._chartData.styleOptions().yAxis.type===T}},{key:"getSelfWidth",value:function(){var t=this,e=this._chartData.styleOptions(),i=e.yAxis,a=i.width;if(w(a)&&k(+a))return+a;var n=0;if(i.display&&(i.axisLine.display&&(n+=i.axisLine.size),i.tickLine.display&&(n+=i.tickLine.length),i.tickText.display)){var r=0;this._measureCtx.font=Bt(i.tickText.size,i.tickText.weight,i.tickText.family),this._ticks.forEach((function(e){r=Math.max(r,Ot(t._measureCtx,e.v))})),n+=i.tickText.paddingLeft+i.tickText.paddingRight+r}var s=e.floatLayer.crossHair,o=0;if(s.display&&s.horizontal.display&&s.horizontal.text.display){var c=this._additionalDataProvider.technicalIndicator();this._measureCtx.font=Bt(s.horizontal.text.size,s.horizontal.text.weight,s.horizontal.text.family);var h=2;if(!this.isPercentageYAxis())if(this._isCandleStickYAxis){var l=this._chartData.pricePrecision();h=e.technicalIndicator.lastValueMark.display?Math.max(c.precision,l):l}else h=c.precision;var u=W(this._maxValue,h);c.shouldFormatBigNumber&&(u=Y(u)),o+=s.horizontal.text.paddingLeft+s.horizontal.text.paddingRight+2*s.horizontal.text.borderSize+Ot(this._measureCtx,u)}return Math.max(n,o)}},{key:"convertFromPixel",value:function(t){var e=(1-t/this._height)*this._range+this._minValue;if(this.isPercentageYAxis()){var i=this._chartData.dataList()[this._chartData.from()].close;return i*e/100+i}return e}},{key:"convertToPixel",value:function(t){var e=t;if(this.isPercentageYAxis()){var i=(this._chartData.dataList()[this._chartData.from()]||{}).close;w(i)&&(e=(t-i)/i*100)}return this._innerConvertToPixel(e)}}]),a}(ee),ae=function(t){c(a,t);var e=_(a);function a(t){var n;return i(this,a),(n=e.call(this,t))._technicalIndicator=new j({}),"height"in t&&n.setHeight(t.height),n.setTechnicalIndicatorType(t.technicalIndicatorType),n}return n(a,[{key:"_initBefore",value:function(t){this._tag=t.tag,this._yAxis=this._createYAxis(t)}},{key:"_createYAxis",value:function(t){return new ie(t.chartData,!1,{technicalIndicator:this.technicalIndicator.bind(this),isTimeLine:this._isRealTime.bind(this)})}},{key:"_createMainWidget",value:function(t,e){return new $t({container:t,chartData:e.chartData,xAxis:e.xAxis,yAxis:this._yAxis,additionalDataProvider:{technicalIndicator:this.technicalIndicator.bind(this),tag:this.tag.bind(this)}})}},{key:"_createYAxisWidget",value:function(t,e){return new te({container:t,chartData:e.chartData,yAxis:this._yAxis,additionalDataProvider:{technicalIndicator:this.technicalIndicator.bind(this),tag:this.tag.bind(this)}})}},{key:"_isRealTime",value:function(){return!1}},{key:"setHeight",value:function(t){d(h(a.prototype),"setHeight",this).call(this,t),this._yAxis.setHeight(t)}},{key:"setWidth",value:function(t,e){d(h(a.prototype),"setWidth",this).call(this,t,e),this._yAxis.setWidth(e)}},{key:"computeAxis",value:function(t){return this._yAxis.calcMinMaxValue(),this._yAxis.computeAxis(t)}},{key:"getSelfAxisWidth",value:function(){return this._yAxis.getSelfWidth(this._technicalIndicator)}},{key:"tag",value:function(){return this._tag}},{key:"yAxis",value:function(){return this._yAxis}},{key:"technicalIndicator",value:function(){return this._technicalIndicator}},{key:"setTechnicalIndicatorType",value:function(t){var e=this._chartData.technicalIndicator(t);return(!this._technicalIndicator||this._technicalIndicator.name!==t)&&(this._technicalIndicator=e?Object.create(e):new j({}),this.calcTechnicalIndicator())}},{key:"calcTechnicalIndicator",value:function(){var t=this.technicalIndicator(),e=this._chartData.technicalIndicator[t.name];return e&&(t.setPrecision(e.precision),t.setCalcParams(e.calcParams)),t.result=t.calcTechnicalIndicator(this._chartData.dataList(),t.calcParams,t.plots)||[],this.computeAxis()}}]),a}(Gt),ne=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_draw",value:function(){this._drawGrid(),this._additionalDataProvider.chartType()===C?this._drawRealTime():(this._drawCandleStick(),this._drawTechnicalIndicator(),this._drawHighestPriceMark(),this._drawLowestPriceMark()),this._drawLastPriceLine()}},{key:"_drawRealTime",value:function(){var t=this,e=[],i=[],a=[],n=this._chartData.from(),r=this._additionalDataProvider.technicalIndicator().result;this._drawGraphics((function(s,o,c,h){var l=(r[o]||{}).average||0,u=t._yAxis.convertToPixel(c.close),_=t._yAxis.convertToPixel(l);if(a.push({x:s,y:_}),o===n){var d=s-h;i.push({x:d,y:t._height}),i.push({x:d,y:u}),e.push({x:d,y:u})}e.push({x:s,y:u}),i.push({x:s,y:u})}),(function(){var n=i.length;if(n>0){var r=i[n-1],s=t._chartData.barSpace()/2,o=r.x+s;e.push({x:o,y:r.y}),i.push({x:o,y:r.y}),i.push({x:o,y:t._height})}var c=t._chartData.styleOptions().realTime,h=c.timeLine;if(e.length>0&&(t._ctx.lineWidth=h.size,t._ctx.strokeStyle=h.color,Yt(t._ctx,(function(){t._ctx.beginPath(),t._ctx.moveTo(e[0].x,e[0].y);for(var i=1;e.length>i;i++)t._ctx.lineTo(e[i].x,e[i].y);t._ctx.stroke(),t._ctx.closePath()}))),i.length>0){t._ctx.fillStyle=h.areaFillColor,t._ctx.beginPath(),t._ctx.moveTo(i[0].x,i[0].y);for(var l=1;i.length>l;l++)t._ctx.lineTo(i[l].x,i[l].y);t._ctx.closePath(),t._ctx.fill()}var u=c.averageLine;u.display&&a.length>0&&(t._ctx.lineWidth=u.size,t._ctx.strokeStyle=u.color,Yt(t._ctx,(function(){t._ctx.beginPath(),t._ctx.moveTo(a[0].x,a[0].y);for(var e=1;a.length>e;e++)t._ctx.lineTo(a[e].x,a[e].y);t._ctx.stroke(),t._ctx.closePath()})))}))}},{key:"_drawCandleStick",value:function(){var t=this,e=this._chartData.styleOptions().candleStick;this._drawGraphics((function(i,a,n,r,s){t._drawCandleStickBar(i,r,s,a,n,e.bar,e.bar.style)}))}},{key:"_drawHighestPriceMark",value:function(){var t=this._chartData.styleOptions().candleStick.priceMark,e=t.high;if(t.display&&e.display){for(var i=this._chartData.dataList(),a=this._chartData.to(),n=-1/0,r=-1,s=this._chartData.from();a>s;s++){var o=B(i[s],"high",-1/0);o>n&&(n=o,r=s)}n!==-1/0&&this._drawLowestHighestPriceMark(e,r,n,!0)}}},{key:"_drawLowestPriceMark",value:function(){var t=this._chartData.styleOptions().candleStick.priceMark,e=t.low;if(t.display&&e.display){for(var i=this._chartData.dataList(),a=this._chartData.to(),n=1/0,r=-1,s=this._chartData.from();a>s;s++){var o=B(i[s],"low",1/0);n>o&&(n=o,r=s)}n!==1/0&&this._drawLowestHighestPriceMark(e,r,n)}}},{key:"_drawLowestHighestPriceMark",value:function(t,e,i,a){var n=this,r=this._chartData.pricePrecision(),s=this._yAxis.convertToPixel(i),o=this._xAxis.convertToPixel(e),c=s+(a?-2:2);this._ctx.textAlign="left",this._ctx.lineWidth=1,this._ctx.strokeStyle=t.color,this._ctx.fillStyle=t.color,Yt(this._ctx,(function(){n._ctx.beginPath(),n._ctx.moveTo(o,c),n._ctx.lineTo(o-2,c+(a?-2:2)),n._ctx.stroke(),n._ctx.closePath(),n._ctx.beginPath(),n._ctx.moveTo(o,c),n._ctx.lineTo(o+2,c+(a?-2:2)),n._ctx.stroke(),n._ctx.closePath()}));var h=c+(a?-5:5);Wt(this._ctx,o,c,h),Ft(this._ctx,h,o,o+5),this._ctx.font=Bt(t.textSize,t.textWeight,t.textFamily);var l=W(i,r);this._ctx.textBaseline="middle",this._ctx.fillText(l,o+5+t.textMargin,h)}},{key:"_drawLastPriceLine",value:function(){var t=this._chartData.dataList(),e=t.length,i=this._chartData.styleOptions().candleStick.priceMark,a=i.last;if(i.display&&a.display&&a.line.display&&0!==e){var n,r=t[e-1],s=r.close,o=r.open,c=this._yAxis.convertToPixel(s);c=+Math.max(.05*this._height,Math.min(c,.98*this._height)).toFixed(0),n=s>o?a.upColor:o>s?a.downColor:a.noChangeColor;var h=a.line;this._ctx.save(),this._ctx.strokeStyle=n,this._ctx.lineWidth=h.size,h.style===P&&this._ctx.setLineDash(h.dashValue),Ft(this._ctx,c,0,this._width),this._ctx.restore()}}}]),a}(Zt),re=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_drawPrompt",value:function(t,e,i,a,n){var r=this._chartData.styleOptions(),s=r.floatLayer.prompt.candleStick,o=this._getCandleStickPromptData(t,r.candleStick,s);if(s.showType===R)this._drawCandleStickStandardPromptText(s,o),this._additionalDataProvider.chartType()===S&&this._drawTechnicalIndicatorPromptText(e,i,n,s.text.size+s.text.marginTop);else{var c=vt(e,n,this._yAxis);this._drawCandleStickRectPromptText(a,s,o,c)}}},{key:"_drawCandleStickStandardPromptText",value:function(t,e){var i=this,a=e,n=t.text.marginLeft,r=t.text.marginRight,s=t.text.size,o=t.text.color,c=t.labels;this._ctx.textBaseline="top",this._ctx.font=Bt(s,t.text.weight,t.text.family);var h=n,l=t.text.marginTop;c.forEach((function(t,e){var s=t?"".concat(t,": "):"",c=Ot(i._ctx,s);i._ctx.fillStyle=o,i._ctx.fillText(s,h,l),h+=c;var u,_=a[e]||"n/a";g(_)?(u=_.value||"n/a",i._ctx.fillStyle=_.color||o):(i._ctx.fillStyle=o,u=_);var d=Ot(i._ctx,u);i._ctx.fillText(u,h,l),h+=d+n+r}))}},{key:"_drawCandleStickRectPromptText",value:function(t,e,i,a){var n=this,r=e.labels,s=i,o=e.text.marginLeft,c=e.text.marginRight,h=e.text.marginTop,l=e.text.marginBottom,u=e.text.size,_=e.text.color;this._ctx.save(),this._ctx.textBaseline="top",this._ctx.font=Bt(u,e.text.weight,e.text.family);var d=0;r.forEach((function(t,e){var i=s[e]||"n/a",a=i;g(i)&&(a=i.value||"n/a");var r="".concat(t,": ").concat(a),h=Ot(n._ctx,r)+o+c;d=Math.max(d,h)}));var v=e.rect,f=v.borderSize,y=v.paddingLeft,p=v.paddingRight,x=v.paddingTop,m=v.left,k=v.right,w=2*f+x+v.paddingBottom+(l+h+u)*r.length,D=this._chartData.styleOptions().floatLayer.prompt.technicalIndicator,P=D.text.marginLeft,M=D.text.marginRight,b=D.text.marginTop,T=D.text.marginBottom,C=D.text.size,L=this._additionalDataProvider.chartType()===S,E=a.labels||[],A=a.values||[];L&&(this._ctx.font=Bt(C,D.text.weight,D.text.family),E.forEach((function(t,e){var i=A[e].value||"n/a",a="".concat(t,": ").concat(i),r=Ot(n._ctx,a)+P+M;d=Math.max(d,r)})),w+=(b+T+C)*E.length);var I,z=2*f+d+y+p;I=this._width/2>t?this._width-k-z:m;var H=v.top,V=v.borderRadius;this._ctx.lineWidth=f,this._ctx.strokeStyle=v.borderColor,this._ctx.fillStyle=v.fillColor,this._drawRoundRect(I,H,z,w,V),this._ctx.stroke(),this._drawRoundRect(I,H,z,w,V),this._ctx.fill();var R=I+f+y+o,O=H+f+x;if(this._ctx.font=Bt(u,e.text.weight,e.text.family),r.forEach((function(t,e){O+=h,n._ctx.textAlign="left",n._ctx.fillStyle=_,n._ctx.fillText("".concat(t,": "),R,O);var i,a=s[e]||"n/a";n._ctx.fillStyle=a.color||_,i=g(a)?a.value||"n/a":a,n._ctx.textAlign="right",n._ctx.fillText(i,I+z-f-c-p,O),O+=u+l})),L){var B=this._chartData.styleOptions().technicalIndicator,F=B.line.colors,W=I+f+y+P,Y=F.length;this._ctx.font=Bt(C,D.text.weight,D.text.family),E.forEach((function(t,e){O+=b,n._ctx.textAlign="left",n._ctx.fillStyle=F[e%Y]||B.text.color,n._ctx.fillText("".concat(t.toUpperCase(),": "),W,O),n._ctx.textAlign="right",n._ctx.fillText(A[e].value||"n/a",I+z-f-M-p,O),O+=C+T}))}this._ctx.restore()}},{key:"_drawRoundRect",value:function(t,e,i,a,n){this._ctx.beginPath(),this._ctx.moveTo(t+n,e),this._ctx.arcTo(t+i,e,t+i,e+a,n),this._ctx.arcTo(t+i,e+a,t,e+a,n),this._ctx.arcTo(t,e+a,t,e,n),this._ctx.arcTo(t,e,t+i,e,n),this._ctx.closePath()}},{key:"_getCandleStickPromptData",value:function(t,e,i){var a=this,n=i.values,r=[];if(n)m(n)?r=n(t,e,i)||[]:x(n)&&(r=n);else{var s=this._chartData.pricePrecision(),o=this._chartData.volumePrecision();(r=[B(t,"timestamp"),B(t,"open"),B(t,"close"),B(t,"high"),B(t,"low"),B(t,"volume")]).forEach((function(t,e){switch(e){case 0:r[e]=F(a._chartData.dateTimeFormat(),t,"YYYY-MM-DD hh:mm");break;case r.length-1:r[e]=Y(W(t,o));break;default:r[e]=W(t,s)}}))}return r}}]),a}(qt);function se(t,e,i){var a=[];if(t&&e&&i.length>0){var n=t.x-e.x;if(0===n)i.forEach((function(t){a.push(t.y)}));else{var r=(t.y-e.y)/n,s=t.y-r*t.x;i.forEach((function(t){a.push(t.x*r+s)}))}}return a}function oe(t,e,i){return!!(i&&t&&e)&&(t.x===e.x?1>Math.abs(i.x-t.x):t.y===e.y?1>Math.abs(i.y-t.y):1>Math.abs(i.y-se(t,e,[i])[0]))}function ce(t,e,i){return!!(i&&t&&e)&&(!!oe(t,e,i)&&(t.x===e.x?e.y>t.y?i.y>t.y-2:t.y+2>i.y:e.x>t.x?i.x>t.x-2:t.x+2>i.x))}function he(t,e,i){return!!(i&&t&&e)&&(!!oe(t,e,i)&&2>Math.abs(Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2))+Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))-Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))))}function le(t,e,i){if(!i)return!1;var a=i.x-t.x,n=i.y-t.y;return!(a*a+n*n>e*e)}function ue(t,e,i){var a=[];if(t.length>1)if(t[0].x===t[1].x){var n=e.height;if(a.push([{x:t[0].x,y:0},{x:t[0].x,y:n}]),t.length>2&&(a.push([{x:t[2].x,y:0},{x:t[2].x,y:n}]),i)){var r=t[0].x-t[2].x;a.push([{x:t[0].x+r,y:0},{x:t[0].x+r,y:n}])}}else{var s=e.width;if(t[0].y===t[1].y){if(a.push([{x:0,y:t[0].y},{x:s,y:t[0].y}]),t.length>2&&(a.push([{x:0,y:t[2].y},{x:s,y:t[2].y}]),i)){var o=t[0].y-t[2].y;a.push([{x:0,y:t[0].y+o},{x:s,y:t[0].y+o}])}}else{var c=(t[0].y-t[1].y)/(t[0].x-t[1].x),h=t[0].y-c*t[0].x;if(a.push([{x:0,y:0*c+h},{x:s,y:s*c+h}]),t.length>2){var l=t[2].y-c*t[2].x;if(a.push([{x:0,y:0*c+l},{x:s,y:s*c+l}]),i){var u=h+(h-l);a.push([{x:0,y:0*c+u},{x:s,y:s*c+u}])}}}}return a}function _e(t,e){var i=[];if(t.length>0){var a=e.width;if(i.push([{x:0,y:t[0].y},{x:a,y:t[0].y}]),t.length>1){var n=t[0].y-t[1].y;i.push([{x:0,y:t[1].y+.786*n},{x:a,y:t[1].y+.786*n}]),i.push([{x:0,y:t[1].y+.618*n},{x:a,y:t[1].y+.618*n}]),i.push([{x:0,y:t[1].y+.5*n},{x:a,y:t[1].y+.5*n}]),i.push([{x:0,y:t[1].y+.382*n},{x:a,y:t[1].y+.382*n}]),i.push([{x:0,y:t[1].y+.236*n},{x:a,y:t[1].y+.236*n}]),i.push([{x:0,y:t[1].y},{x:a,y:t[1].y}])}}return i}var de=0,ve=2;function fe(t){return t.getBoundingClientRect()||{left:0,top:0}}function ye(t){return!!t.touches}function pe(t){t.cancelable&&t.preventDefault()}var xe=!!navigator.maxTouchPoints||!!navigator.msMaxTouchPoints||"ontouchstart"in window||!!(window.DocumentTouch&&document instanceof window.DocumentTouch),me="onorientationchange"in window&&xe;function ge(t,e){var i=t.clientX-e.clientX,a=t.clientY-e.clientY;return Math.sqrt(i*i+a*a)}var ke="mouse",we="touch",De=function(){function t(e,a,n){i(this,t),this._target=e,this._handler=a,this._options=n,this._clickCount=0,this._clickTimeoutId=null,this._longTapTimeoutId=null,this._longTapActive=!1,this._mouseMoveStartPosition=null,this._moveExceededManhattanDistance=!1,this._cancelClick=!1,this._unsubscribeOutsideEvents=null,this._unsubscribeMousemove=null,this._unsubscribeRoot=null,this._startPinchMiddlePoint=null,this._startPinchDistance=0,this._pinchPrevented=!1,this._preventDragProcess=!1,this._mousePressed=!1,this._init()}return n(t,[{key:"destroy",value:function(){null!==this._unsubscribeOutsideEvents&&(this._unsubscribeOutsideEvents(),this._unsubscribeOutsideEvents=null),null!==this._unsubscribeMousemove&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),null!==this._unsubscribeRoot&&(this._unsubscribeRoot(),this._unsubscribeRoot=null),this._clearLongTapTimeout(),this._resetClickTimeout()}},{key:"_mouseEnterHandler",value:function(t){var e=this;this._unsubscribeMousemove&&this._unsubscribeMousemove();var i=this._mouseMoveHandler.bind(this),a=this._mouseWheelHandler.bind(this);this._unsubscribeMousemove=function(){e._target.removeEventListener("mousemove",i),e._target.removeEventListener("wheel",a)},this._target.addEventListener("mousemove",i),this._target.addEventListener("wheel",a,{passive:!1}),ye(t)&&this._mouseMoveHandler(t);var n=this._makeCompatEvent(t);this._processEvent(n,this._handler.mouseEnterEvent)}},{key:"_resetClickTimeout",value:function(){null!==this._clickTimeoutId&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null}},{key:"_mouseMoveHandler",value:function(t){if(!this._mousePressed||ye(t)){var e=this._makeCompatEvent(t);this._processEvent(e,this._handler.mouseMoveEvent)}}},{key:"_mouseWheelHandler",value:function(t){var e=this._makeCompatEvent(t);t.localX=e.localX,t.localY=e.localY,this._processEvent(t,this._handler.mouseWheelEvent)}},{key:"_mouseMoveWithDownHandler",value:function(t){if((!("button"in t)||t.button===de)&&null===this._startPinchMiddlePoint){var e=ye(t);if(!this._preventDragProcess||!e){this._pinchPrevented=!0;var i=this._makeCompatEvent(t),a=this._mouseMoveStartPosition,n=Math.abs(a.x-i.pageX),r=Math.abs(a.y-i.pageY),s=n+r>5;if(s||!e){if(s&&!this._moveExceededManhattanDistance&&e){var o=.5*n;r>=o&&!this._options.treatVertTouchDragAsPageScroll||o>r&&!this._options.treatHorzTouchDragAsPageScroll||(this._preventDragProcess=!0)}s&&(this._moveExceededManhattanDistance=!0,this._cancelClick=!0,e&&this._clearLongTapTimeout()),this._preventDragProcess||(this._processEvent(i,this._handler.pressedMouseMoveEvent),e&&pe(t))}}}}},{key:"_mouseUpHandler",value:function(t){if(!("button"in t)||t.button===de){var e=this._makeCompatEvent(t);this._clearLongTapTimeout(),this._mouseMoveStartPosition=null,this._mousePressed=!1,this._unsubscribeRoot&&(this._unsubscribeRoot(),this._unsubscribeRoot=null),ye(t)&&this._mouseLeaveHandler(t),this._processEvent(e,this._handler.mouseUpEvent),++this._clickCount,this._clickTimeoutId&&this._clickCount>1?(this._processEvent(e,this._handler.mouseDoubleClickEvent),this._resetClickTimeout()):this._cancelClick||this._processEvent(e,this._handler.mouseClickEvent),ye(t)&&(pe(t),this._mouseLeaveHandler(t),0===t.touches.length&&(this._longTapActive=!1))}}},{key:"_clearLongTapTimeout",value:function(){null!==this._longTapTimeoutId&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null)}},{key:"_mouseDownHandler",value:function(t){if(!("button"in t)||t.button===de||t.button===ve){var e=this._makeCompatEvent(t);if("button"in t&&t.button===ve)this._processEvent(e,this._handler.mouseRightDownEvent);else{this._cancelClick=!1,this._moveExceededManhattanDistance=!1,this._preventDragProcess=!1,ye(t)&&this._mouseEnterHandler(t),this._mouseMoveStartPosition={x:e.pageX,y:e.pageY},this._unsubscribeRoot&&(this._unsubscribeRoot(),this._unsubscribeRoot=null);var i=this._mouseMoveWithDownHandler.bind(this),a=this._mouseUpHandler.bind(this),n=this._target.ownerDocument.documentElement;this._unsubscribeRoot=function(){n.removeEventListener("touchmove",i),n.removeEventListener("touchend",a),n.removeEventListener("mousemove",i),n.removeEventListener("mouseup",a)},n.addEventListener("touchmove",i,{passive:!1}),n.addEventListener("touchend",a,{passive:!1}),this._clearLongTapTimeout(),ye(t)&&1===t.touches.length?this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,t),600):(n.addEventListener("mousemove",i),n.addEventListener("mouseup",a)),this._mousePressed=!0,this._processEvent(e,this._handler.mouseDownEvent),this._clickTimeoutId||(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),500))}}}},{key:"_init",value:function(){var t=this;this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),this._target.addEventListener("touchcancel",this._clearLongTapTimeout.bind(this));var e=this._target.ownerDocument,i=function(e){t._handler.mouseDownOutsideEvent&&(e.target&&t._target.contains(e.target)||t._handler.mouseDownOutsideEvent())};this._unsubscribeOutsideEvents=function(){e.removeEventListener("mousedown",i),e.removeEventListener("touchstart",i)},e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!0}),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("touchstart",this._mouseDownHandler.bind(this),{passive:!0}),me||this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",(function(){}),{passive:!1})}},{key:"_initPinch",value:function(){var t=this;void 0===this._handler.pinchStartEvent&&void 0===this._handler.pinchEvent&&void 0===this._handler.pinchEndEvent||(this._target.addEventListener("touchstart",(function(e){return t._checkPinchState(e.touches)}),{passive:!0}),this._target.addEventListener("touchmove",(function(e){if(2===e.touches.length&&null!==t._startPinchMiddlePoint&&void 0!==t._handler.pinchEvent){var i=ge(e.touches[0],e.touches[1]);t._handler.pinchEvent(t._startPinchMiddlePoint,i/t._startPinchDistance),pe(e)}}),{passive:!1}),this._target.addEventListener("touchend",(function(e){t._checkPinchState(e.touches)})))}},{key:"_checkPinchState",value:function(t){1===t.length&&(this._pinchPrevented=!1),2!==t.length||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(t)}},{key:"_startPinch",value:function(t){var e=fe(this._target);this._startPinchMiddlePoint={x:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,y:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this._startPinchDistance=ge(t[0],t[1]),void 0!==this._handler.pinchStartEvent&&this._handler.pinchStartEvent(),this._clearLongTapTimeout()}},{key:"_stopPinch",value:function(){null!==this._startPinchMiddlePoint&&(this._startPinchMiddlePoint=null,void 0!==this._handler.pinchEndEvent&&this._handler.pinchEndEvent())}},{key:"_mouseLeaveHandler",value:function(t){this._unsubscribeMousemove&&this._unsubscribeMousemove();var e=this._makeCompatEvent(t);this._processEvent(e,this._handler.mouseLeaveEvent)}},{key:"_longTapHandler",value:function(t){var e=this._makeCompatEvent(t);this._processEvent(e,this._handler.longTapEvent),this._cancelClick=!0,this._longTapActive=!0}},{key:"_processEvent",value:function(t,e){e&&e.call(this._handler,t)}},{key:"_makeCompatEvent",value:function(t){var e;e="touches"in t&&t.touches.length?t.touches[0]:"changedTouches"in t&&t.changedTouches.length?t.changedTouches[0]:t;var i=fe(this._target);return{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY,localX:e.clientX-i.left,localY:e.clientY-i.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,type:t.type.startsWith("mouse")?ke:we,target:e.target,view:t.view}}}]),t}();function Pe(t){return t.type===we}function Me(t){return t.type===ke}var be=function(){function t(e){i(this,t),this._chartData=e,this._chartContentSize={},this._paneContentSize={}}return n(t,[{key:"_checkEventPointX",value:function(t){return t>0&&this._chartContentSize.contentRight-this._chartContentSize.contentLeft>t}},{key:"setChartContentSize",value:function(t){this._chartContentSize=t}},{key:"setPaneContentSize",value:function(t){this._paneContentSize=t}}]),t}(),Te="step_1",Ce="step_2",Se="step_3",Le="step_done",Ee=function(t){c(r,t);var a=_(r);function r(t,e,n){var s;return i(this,r),(s=a.call(this,t))._xAxis=e,s._yAxis=n,s._noneGraphicMarkMouseDownFlag=!1,s._noneGraphicMarkMouseDownActiveData={markKey:null,dataIndex:-1,onLine:!1,onCircle:!1,pointIndex:-1},s}return n(r,[{key:"mouseUpEvent",value:function(t){this._chartData.setDragGraphicMarkFlag(!1),this._noneGraphicMarkMouseDownFlag=!1,this._noneGraphicMarkMouseDownActiveData={markKey:null,dataIndex:-1,onLine:!1,onCircle:!1,pointIndex:-1}}},{key:"mouseDownEvent",value:function(t){if(this._checkEventPointX(t.localX)&&this._checkEventPointY(t.localY)){this._chartData.setGraphicMarkPoint({x:t.localX,y:t.localY});var e=this._chartData.graphicMarkType();switch(e){case kt:case wt:case Dt:case Pt:case Mt:case bt:case Tt:case Ct:case St:case Lt:case It:this._twoStepGraphicMarkMouseDown(t,e);break;case Et:case At:this._threeStepGraphicMarkMouseDown(t,e);break;case gt:this._noneGraphicMarkMouseLeftDown(t)}}}},{key:"mouseRightDownEvent",value:function(t){if(this._chartData.graphicMarkType()===gt){this._findNoneGraphicMarkMouseDownActiveData(t);var e=this._noneGraphicMarkMouseDownActiveData.markKey,i=this._noneGraphicMarkMouseDownActiveData.dataIndex;if(e&&-1!==i){var a=this._chartData.graphicMarkData(),n=a[e];n.splice(i,1),a[e]=n,this._chartData.setGraphicMarkData(a),this.mouseUpEvent(t)}}}},{key:"_twoStepGraphicMarkMouseDown",value:function(t,e){var i=this;this._graphicMarkMouseDown(t,e,(function(t){switch(t.drawStep){case Te:t.drawStep=Ce;break;case Ce:t.drawStep=Le,i._chartData.setGraphicMarkType(gt)}}))}},{key:"_threeStepGraphicMarkMouseDown",value:function(t,e){var i=this;this._graphicMarkMouseDown(t,e,(function(t){switch(t.drawStep){case Te:t.drawStep=Ce;break;case Ce:t.drawStep=Se;break;case Se:t.drawStep=Le,i._chartData.setGraphicMarkType(gt)}}))}},{key:"_graphicMarkMouseDown",value:function(t,e,i){var a=this._chartData.graphicMarkData(),n=a[e];if(2===t.button)n.splice(n.length-1,1),this._chartData.setGraphicMarkType(gt);else{var r=n[n.length-1];i(r),n[n.length-1]=r}a[e]=n,this._chartData.setGraphicMarkData(a)}},{key:"_noneGraphicMarkMouseLeftDown",value:function(t){this._findNoneGraphicMarkMouseDownActiveData(t),this._noneGraphicMarkMouseDownActiveData.markKey&&-1!==this._noneGraphicMarkMouseDownActiveData.dataIndex&&this._noneGraphicMarkMouseDownActiveData.onCircle&&(this._noneGraphicMarkMouseDownFlag=!0,this._chartData.setDragGraphicMarkFlag(!0))}},{key:"_findNoneGraphicMarkMouseDownActiveData",value:function(t){for(var i=this,a={x:t.localX,y:t.localY},n=Object.keys(this._chartData.graphicMarkData()),r=function(t){var e=n[t];switch(e){case kt:case Lt:if(i._realFindNoneGraphicMarkMouseDownActiveData(e,a,(function(t){return oe(t[0],{x:i._chartContentSize.contentRight,y:t[0].y},a)})))return{v:void 0};break;case wt:if(i._realFindNoneGraphicMarkMouseDownActiveData(e,a,(function(t){return oe(t[0],{x:t[0].x,y:i._paneContentSize[Qe].contentBottom},a)})))return{v:void 0};break;case Dt:if(i._realFindNoneGraphicMarkMouseDownActiveData(e,a,(function(t){return oe(t[0],t[1],a)})))return{v:void 0};break;case Pt:case Mt:case bt:if(i._realFindNoneGraphicMarkMouseDownActiveData(e,a,(function(t){return ce(t[0],t[1],a)})))return{v:void 0};break;case Tt:case Ct:case St:if(i._realFindNoneGraphicMarkMouseDownActiveData(e,a,(function(t){return he(t[0],t[1],a)})))return{v:void 0};break;case Et:case At:case It:if(i._realFindNoneGraphicMarkMouseDownActiveData(e,a,(function(t){var n,r={width:i._chartContentSize.contentRight,height:i._paneContentSize[Qe].contentBottom-i._paneContentSize[Qe].contentTop};switch(e){case Et:n=ue(t,r,!0);break;case At:n=ue(t,r);break;case It:n=_e(t,r)}var s=!1;if(n)for(var o=0;n.length>o;o++){var c=n[o];if(s=oe(c[0],c[1],a))return s}return s})))return{v:void 0}}},s=0;n.length>s;s++){var o=r(s);if("object"===e(o))return o.v}}},{key:"_realFindNoneGraphicMarkMouseDownActiveData",value:function(t,e,i){var a=this,n=this._chartData.graphicMarkData()[t],r=this._chartData.styleOptions().graphicMark;return n.forEach((function(n,s){var o=[],c=!1,h=-1;n.points.forEach((function(t,i){var n=a._xAxis.convertToPixel(t.xPos),s=a._yAxis.convertToPixel(t.price);o.push({x:n,y:s});var l=le({x:n,y:s},r.point.radius,e);l&&(h=i),c||(c=l)}));var l=i(o,e);if(l||c)return a._noneGraphicMarkMouseDownActiveData={markKey:t,dataIndex:s,onLine:l,onCircle:c,pointIndex:h},!0})),!1}},{key:"mouseMoveEvent",value:function(t){if(this._checkEventPointX(t.localX)&&this._checkEventPointY(t.localY)){var e={x:t.localX,y:t.localY};if(this._chartData.setGraphicMarkPoint(e),!this._waitingForMouseMoveAnimationFrame){this._waitingForMouseMoveAnimationFrame=!0;var i=this._chartData.graphicMarkType();switch(i){case kt:case wt:case Lt:this._onePointGraphicMarkMouseMove(e,i);break;case Dt:case bt:case St:case It:this._twoPointGraphicMarkMouseMove(e,i);break;case Pt:case Tt:this._twoPointGraphicMarkMouseMove(e,i,(function(t,e){t.points[0].price=e.price}));break;case Mt:case Ct:this._twoPointGraphicMarkMouseMove(e,i,(function(t,e){t.points[0].xPos=e.xPos}));break;case Et:case At:this._threePointGraphicMarkMouseMove(e,i);break;case gt:this._chartData.setGraphicMarkData(this._chartData.graphicMarkData())}this._waitingForMouseMoveAnimationFrame=!1}}}},{key:"pressedMouseMoveEvent",value:function(t){var e=this._noneGraphicMarkMouseDownActiveData.markKey,i=this._noneGraphicMarkMouseDownActiveData.dataIndex;if(e&&-1!==i){var a=this._chartData.graphicMarkData(),n=a[e],r={x:t.localX,y:t.localY};switch(e){case kt:case wt:case Lt:case Dt:case bt:case St:case Et:case At:case It:var s=this._noneGraphicMarkMouseDownActiveData.pointIndex;-1!==s&&(n[i].points[s].xPos=this._xAxis.convertFromPixel(r.x),n[i].points[s].price=this._yAxis.convertFromPixel(r.y));break;case Pt:case Tt:var o=this._noneGraphicMarkMouseDownActiveData.pointIndex;if(-1!==o){var c=this._yAxis.convertFromPixel(r.y);n[i].points[o].xPos=this._xAxis.convertFromPixel(r.x),n[i].points[0].price=c,n[i].points[1].price=c}break;case Mt:case Ct:var h=this._noneGraphicMarkMouseDownActiveData.pointIndex;if(-1!==h){var l=this._xAxis.convertFromPixel(r.x);n[i].points[0].xPos=l,n[i].points[1].xPos=l,n[i].points[h].price=this._yAxis.convertFromPixel(r.y)}}a[e]=n,this._chartData.setGraphicMarkPoint({x:t.localX,y:t.localY}),this._chartData.setGraphicMarkData(a)}}},{key:"_onePointGraphicMarkMouseMove",value:function(t,e){var i=this;this._graphicMarkMouseMove(t,e,(function(e,a){var n=i._xAxis.convertFromPixel(t.x),r=i._yAxis.convertFromPixel(t.y);switch(a.drawStep){case Le:e.push({points:[{xPos:n,price:r}],drawStep:Te});break;case Te:case Ce:a.points[0].xPos=n,a.points[0].price=r,e[e.length-1]=a}}))}},{key:"_twoPointGraphicMarkMouseMove",value:function(t,e,i){var a=this;this._graphicMarkMouseMove(t,e,(function(e,n){var r=a._xAxis.convertFromPixel(t.x),s=a._yAxis.convertFromPixel(t.y);switch(n.drawStep){case Le:e.push({points:[{xPos:r,price:s},{xPos:r,price:s}],drawStep:Te});break;case Te:n.points[0]={xPos:r,price:s},n.points[1]={xPos:r,price:s},e[e.length-1]=n;break;case Ce:n.points[1]={xPos:r,price:s},m(i)&&i(n,{xPos:r,price:s}),e[e.length-1]=n}}))}},{key:"_threePointGraphicMarkMouseMove",value:function(t,e,i){var a=this;this._graphicMarkMouseMove(t,e,(function(e,n){var r=a._xAxis.convertFromPixel(t.x),s=a._yAxis.convertFromPixel(t.y);switch(n.drawStep){case Le:e.push({points:[{xPos:r,price:s},{xPos:r,price:s}],drawStep:Te});break;case Te:n.points[0]={xPos:r,price:s},n.points[1]={xPos:r,price:s},e[e.length-1]=n;break;case Ce:m(i)&&i(n,{xPos:r,price:s}),n.points[1]={xPos:r,price:s},e[e.length-1]=n;break;case Se:n.points[2]={xPos:r,price:s},e[e.length-1]=n}}))}},{key:"_graphicMarkMouseMove",value:function(t,e,i){var a=this._chartData.graphicMarkData(),n=a[e];i(n,n[n.length-1]||{drawStep:Le}),a[e]=n,this._chartData.setGraphicMarkData(a)}},{key:"_checkEventPointY",value:function(t){var e=this._paneContentSize[Qe];return t>e.contentTop&&e.contentBottom>t}}]),r}(be),Ae=0,Ie=1,ze=2,He=function(t){c(a,t);var e=_(a);function a(t,n,r,s){var o;return i(this,a),(o=e.call(this,t,n))._xAxis=r,o._yAxis=s,o}return n(a,[{key:"_draw",value:function(){var t=this._chartData.styleOptions().graphicMark,e=this._chartData.pricePrecision();this._drawHorizontalStraightLine(t),this._drawVerticalStraightLine(t),this._drawStraightLine(t),this._drawHorizontalRayLine(t),this._drawVerticalRayLine(t),this._drawRayLine(t),this._drawSegmentLine(t),this._drawPriceLine(t,e),this._drawPriceChannelLine(t),this._drawParallelStraightLine(t),this._drawFibonacciLine(t,e)}},{key:"_drawHorizontalStraightLine",value:function(t){var e=this;this._drawPointGraphicMark(kt,t,oe,(function(t){return[[{x:0,y:t[0].y},{x:e._width,y:t[0].y}]]}))}},{key:"_drawVerticalStraightLine",value:function(t){var e=this;this._drawPointGraphicMark(wt,t,oe,(function(t){return[[{x:t[0].x,y:0},{x:t[0].x,y:e._height}]]}))}},{key:"_drawStraightLine",value:function(t){var e=this;this._drawPointGraphicMark(Dt,t,oe,(function(t){if(t[0].x===t[1].x)return[[{x:t[0].x,y:0},{x:t[0].x,y:e._height}]];var i=se(t[0],t[1],[{x:0,y:t[0].y},{x:e._width,y:t[0].y}]);return[[{x:0,y:i[0]},{x:e._width,y:i[1]}]]}))}},{key:"_drawHorizontalRayLine",value:function(t){var e=this;this._drawPointGraphicMark(Pt,t,ce,(function(t){var i={x:0,y:t[0].y};return t[1].x>t[0].x&&(i.x=e._width),[[t[0],i]]}))}},{key:"_drawVerticalRayLine",value:function(t){var e=this;this._drawPointGraphicMark(Mt,t,ce,(function(t){var i={x:t[0].x,y:0};return t[1].y>t[0].y&&(i.y=e._height),[[t[0],i]]}))}},{key:"_drawRayLine",value:function(t){var e=this;this._drawPointGraphicMark(bt,t,ce,(function(t){var i;return i=t[0].x===t[1].x&&t[0].y!==t[1].y?t[1].y>t[0].y?{x:t[0].x,y:e._height}:{x:t[0].x,y:0}:t[0].x>t[1].x?{x:0,y:se(t[0],t[1],[{x:0,y:t[0].y}])[0]}:{x:e._width,y:se(t[0],t[1],[{x:e._width,y:t[0].y}])[0]},[[t[0],i]]}))}},{key:"_drawSegmentLine",value:function(t){this._drawPointGraphicMark(Tt,t,he),this._drawPointGraphicMark(Ct,t,he),this._drawPointGraphicMark(St,t,he)}},{key:"_drawPriceLine",value:function(t,e){var i=this;this._drawPointGraphicMark(Lt,t,ce,(function(t){return[[t[0],{x:i._width,y:t[0].y}]]}),!0,e)}},{key:"_drawPriceChannelLine",value:function(t){var e=this;this._drawPointGraphicMark(Et,t,oe,(function(t){return ue(t,{width:e._width,height:e._height},!0)}))}},{key:"_drawParallelStraightLine",value:function(t){var e=this;this._drawPointGraphicMark(At,t,oe,(function(t){return ue(t,{width:e._width,height:e._height})}))}},{key:"_drawFibonacciLine",value:function(t,e){var i=this;this._drawPointGraphicMark(It,t,oe,(function(t){return _e(t,{width:i._width,height:i._height})}),!0,e,["(100.0%)","(78.6%)","(61.8%)","(50.0%)","(38.2%)","(23.6%)","(0.0%)"])}},{key:"_drawPointGraphicMark",value:function(t,e,i,a,n,r,s){var o=this;this._chartData.graphicMarkData()[t].forEach((function(t){var c=t.drawStep,h=[];t.points.forEach((function(t){var e=t.price,i=o._xAxis.convertToPixel(t.xPos),a=o._yAxis.convertToPixel(e);h.push({x:i,y:a})}));var l=a?a(h):[h];o._drawGraphicMark(e,l,h,c,i,n,r,s)}))}},{key:"_drawGraphicMark",value:function(t,e,i,a,n,r,s){var o=this,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:[],h=this._chartData.graphicMarkPoint(),l=!1;e.forEach((function(e,i){if(e.length>1){var u=n(e[0],e[1],h);if(l||(l=u),a!==Te){switch(o._ctx.strokeStyle=t.line.color,o._ctx.lineWidth=t.line.size,o._getLineType(e[0],e[1])){case Ae:Yt(o._ctx,(function(){o._ctx.beginPath(),o._ctx.moveTo(e[0].x,e[0].y),o._ctx.lineTo(e[1].x,e[1].y),o._ctx.stroke(),o._ctx.closePath()}));break;case Ie:Ft(o._ctx,e[0].y,e[0].x,e[1].x);break;case ze:Wt(o._ctx,e[0].x,e[0].y,e[1].y)}if(r){var _=W(o._yAxis.convertFromPixel(e[0].y),s);o._ctx.font=Bt(t.text.size,t.text.weight,t.text.family),o._ctx.fillStyle=t.text.color,o._ctx.fillText("".concat(_," ").concat(c[i]||""),e[0].x+t.text.marginLeft,e[0].y-t.text.marginBottom)}}}}));for(var u=t.point.radius,_=!1,d=0;i.length>d&&!(_=le(i[d],u,h));d++);i.forEach((function(e){var i=le(e,u,h);if(_||l){var a=u,n=t.point.backgroundColor,r=t.point.borderColor,s=t.point.borderSize;i&&(a=t.point.activeRadius,n=t.point.activeBackgroundColor,r=t.point.activeBorderColor,s=t.point.activeBorderSize),o._ctx.fillStyle=n,o._ctx.beginPath(),o._ctx.arc(e.x,e.y,a,0,2*Math.PI),o._ctx.closePath(),o._ctx.fill(),o._ctx.lineWidth=s,o._ctx.strokeStyle=r,o._ctx.beginPath(),o._ctx.arc(e.x,e.y,a,0,2*Math.PI),o._ctx.closePath(),o._ctx.stroke()}}))}},{key:"_getLineType",value:function(t,e){return t.x===e.x?ze:t.y===e.y?Ie:Ae}}]),a}(Ut),Ve=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_createMainView",value:function(t,e){return new ne(t,e.chartData,e.xAxis,e.yAxis,e.additionalDataProvider)}},{key:"_createExpandView",value:function(t,e){return new He(t,e.chartData,e.xAxis,e.yAxis)}},{key:"_createFloatLayerView",value:function(t,e){return new re(t,e.chartData,e.xAxis,e.yAxis,e.additionalDataProvider)}}]),a}($t),Re=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.call(this,{name:"TAP",precision:2,plots:[{key:"average",type:"line"}]})}return n(a,[{key:"calcTechnicalIndicator",value:function(t,e){var i=0,a=0,n=[];return t.forEach((function(t){var e={},r=t.volume||0;i+=t.turnover||0,a+=r,0!==r&&(e.average=i/a),n.push(e)})),n}}]),a}(j),Oe=function(t){c(a,t);var e=_(a);function a(t){var n;return i(this,a),(n=e.call(this,t))._chartType=S,n._realTimeTechnicalIndicator=new Re,n}return n(a,[{key:"_createYAxis",value:function(t){return new ie(t.chartData,!0,{technicalIndicator:this.technicalIndicator.bind(this),isTimeLine:this._isRealTime.bind(this)})}},{key:"_createMainWidget",value:function(t,e){return new Ve({container:t,chartData:e.chartData,xAxis:e.xAxis,yAxis:this._yAxis,additionalDataProvider:{technicalIndicator:this.technicalIndicator.bind(this),chartType:this.chartType.bind(this),tag:this.tag.bind(this)}})}},{key:"_isRealTime",value:function(){return this._chartType===C}},{key:"technicalIndicator",value:function(){return this._isRealTime()?this._realTimeTechnicalIndicator:this._technicalIndicator}},{key:"chartType",value:function(){return this._chartType}},{key:"setChartType",value:function(t){return this._chartType!==t&&(this._chartType=t,this.calcTechnicalIndicator())}}]),a}(ae),Be=function(t){c(a,t);var e=_(a);function a(t,n,r){var s;return i(this,a),(s=e.call(this,t,n))._xAxis=r,s}return n(a,[{key:"_draw",value:function(){var t=this._chartData.styleOptions().xAxis;t.display&&(this._drawAxisLine(t),this._drawTickLines(t),this._drawTickLabels(t))}},{key:"_drawAxisLine",value:function(t){var e=t.axisLine;e.display&&(this._ctx.strokeStyle=e.color,this._ctx.lineWidth=e.size,Ft(this._ctx,0,0,this._width))}},{key:"_drawTickLines",value:function(t){var e=this,i=t.tickLine;if(i.display){this._ctx.lineWidth=i.size,this._ctx.strokeStyle=i.color;var a=t.axisLine.display?t.axisLine.size:0,n=a+i.length;this._xAxis.ticks().forEach((function(t){Wt(e._ctx,t.x,a,n)}))}}},{key:"_drawTickLabels",value:function(t){var e=t.tickText;if(e.display){var i=t.tickLine;this._ctx.textBaseline="top",this._ctx.font=Bt(e.size,e.weight,e.family),this._ctx.textAlign="center",this._ctx.fillStyle=e.color;var a=e.paddingTop;t.axisLine.display&&(a+=t.axisLine.size),i.display&&(a+=i.length);for(var n=this._xAxis.ticks(),r=n.length,s=0;r>s;s++)this._ctx.fillText(n[s].v,n[s].x,a)}}}]),a}(Ut),Fe=function(t){c(a,t);var e=_(a);function a(t,n,r){var s;return i(this,a),(s=e.call(this,t,n))._xAxis=r,s}return n(a,[{key:"_draw",value:function(){this._drawCrossHairLabel()}},{key:"_drawCrossHairLabel",value:function(){var t=this._chartData.crossHair();if(t.paneTag){var e=this._chartData.styleOptions().floatLayer.crossHair,i=e.vertical,a=i.text;if(e.display&&i.display&&a.display){var n,r=this._chartData.dataList(),s=r[n=w(t.x)?this._xAxis.convertFromPixel(t.x):r.length-1];if(s){var o=this._xAxis.convertToPixel(n),c=s.timestamp,h=F(this._chartData.dateTimeFormat(),c,"YYYY-MM-DD hh:mm"),l=a.size;this._ctx.font=Bt(l,a.weight,a.family);var u=Ot(this._ctx,h),_=o-u/2,d=a.paddingLeft,v=a.paddingRight,f=a.paddingTop,y=a.borderSize;d+y>_?_=d+y:_>this._width-u-y-v&&(_=this._width-u-y-v);var p=_-y-d,x=_+u+y+v,m=0+l+2*y+f+a.paddingBottom;this._ctx.fillStyle=a.backgroundColor,this._ctx.fillRect(p,0,x-p,m-0),this._ctx.lineWidth=y,this._ctx.strokeStyle=a.borderColor,this._ctx.strokeRect(p,0,x-p,m-0),this._ctx.textBaseline="top",this._ctx.fillStyle=a.color,this._ctx.fillText(h,_,y+f)}}}}}]),a}(Ut),We=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_createMainView",value:function(t,e){return new Be(t,e.chartData,e.xAxis)}},{key:"_createFloatLayerView",value:function(t,e){return new Fe(t,e.chartData,e.xAxis)}}]),a}(Xt),Ye=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_computeMinMaxValue",value:function(){var t=this._chartData.from(),e=this._chartData.to()-1;return{min:t,max:e,range:e-t+1}}},{key:"_computeOptimalTicks",value:function(t){var e=[],i=t.length,a=this._chartData.dataList();if(i>0){var n=this._chartData.dateTimeFormat(),r=this._chartData.styleOptions().xAxis.tickText;this._measureCtx.font=Bt(r.size,r.weight,r.family);var s=Ot(this._measureCtx,"00-00 00:00"),o=this.convertToPixel(parseInt(t[0].v,10)),c=1;if(i>1){var h=this.convertToPixel(parseInt(t[1].v,10)),l=Math.abs(h-o);s>l&&(c=Math.ceil(s/l))}for(var u=0;i>u;u+=c){var _=parseInt(t[u].v,10),d=a[_].timestamp,v=F(n,d,"hh:mm");if(0!==u)v=this._optimalTickLabel(n,d,a[parseInt(t[u-c].v,10)].timestamp)||v;var f=this.convertToPixel(_);e.push({v:v,x:f,oV:d})}if(1===e.length)e[0].v=F(n,e[0].oV,"YYYY-MM-DD hh:mm");else{var y=e[0].oV,p=e[1].oV;if(e[2]){var x=e[2].v;/^[0-9]{2}-[0-9]{2}$/.test(x)?e[0].v=F(n,y,"MM-DD"):/^[0-9]{4}-[0-9]{2}$/.test(x)?e[0].v=F(n,y,"YYYY-MM"):/^[0-9]{4}$/.test(x)&&(e[0].v=F(n,y,"YYYY"))}else e[0].v=this._optimalTickLabel(n,y,p)||e[0].v}}return e}},{key:"_optimalTickLabel",value:function(t,e,i){var a=F(t,e,"YYYY"),n=F(t,e,"YYYY-MM"),r=F(t,e,"MM-DD");return a!==F(t,i,"YYYY")?a:n!==F(t,i,"YYYY-MM")?n:r!==F(t,i,"MM-DD")?r:null}},{key:"getSelfHeight",value:function(){var t=this._chartData.styleOptions(),e=t.xAxis,i=e.height;if(w(i)&&k(+i))return+i;var a=t.floatLayer.crossHair,n=0;e.display&&(e.axisLine.display&&(n+=e.axisLine.size),e.tickLine.display&&(n+=e.tickLine.length),e.tickText.display&&(n+=e.tickText.paddingTop+e.tickText.paddingBottom+e.tickText.size));var r=0;return a.display&&a.vertical.display&&a.vertical.text.display&&(r+=a.vertical.text.paddingTop+a.vertical.text.paddingBottom+2*a.vertical.text.borderSize+a.vertical.text.size),Math.max(n,r)}},{key:"convertFromPixel",value:function(t){return Math.round(this._chartData.coordinateToFloatIndex(t))-1}},{key:"convertToPixel",value:function(t){var e=this._chartData.dataList().length,i=this._chartData.dataSpace(),a=e+this._chartData.offsetRightBarCount()-t;return this._width-(a-.5)*i+this._chartData.barSpace()/2}}]),a}(ee),Ge=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"_initBefore",value:function(){this._xAxis=new Ye(this._chartData)}},{key:"_createMainWidget",value:function(t,e){return new We({container:t,chartData:e.chartData,xAxis:this._xAxis})}},{key:"computeAxis",value:function(){this._xAxis.computeAxis(!0)}},{key:"getSelfAxisHeight",value:function(){return this._xAxis.getSelfHeight()}},{key:"xAxis",value:function(){return this._xAxis}},{key:"setWidth",value:function(t,e){d(h(a.prototype),"setWidth",this).call(this,t,e),this._xAxis.setWidth(t)}},{key:"setHeight",value:function(t){d(h(a.prototype),"setHeight",this).call(this,t),this._xAxis.setHeight(t)}}]),a}(Gt),Xe=function(){function t(e,a,n,r,s){i(this,t),this._chartData=a,this._paneIndex=n,this._width=0,this._offsetLeft=0,this._dragEventHandler=s,this._initElement(e,r)}return n(t,[{key:"_initElement",value:function(t,e){this._container=t,this._wrapper=this._createElement(),this._wrapper.style.overflow="hidden",this._element=this._createElement(),this._element.style.width="100%",this._element.style.position="absolute",this._element.style.zIndex="20",this._element.style.height="5px",e&&(this._element.style.cursor="ns-resize",this._dragEvent=new De(this._element,{mouseDownEvent:this._mouseDownEvent.bind(this),pressedMouseMoveEvent:this._pressedMouseMoveEvent.bind(this)},{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0})),this._wrapper.appendChild(this._element);var i=t.lastChild;i?t.insertBefore(this._wrapper,i):t.appendChild(this._wrapper)}},{key:"_createElement",value:function(){var t=document.createElement("div");return t.style.margin="0",t.style.padding="0",t}},{key:"_mouseDownEvent",value:function(t){this._startY=t.pageY,this._dragEventHandler.startDrag(this._paneIndex)}},{key:"_pressedMouseMoveEvent",value:function(t){this._dragEventHandler.drag(t.pageY-this._startY,this._paneIndex)}},{key:"height",value:function(){return this._wrapper.offsetHeight}},{key:"setSize",value:function(t,e){this._offsetLeft=t,this._width=e,this.invalidate()}},{key:"updatePaneIndex",value:function(t){this._paneIndex=t}},{key:"invalidate",value:function(){var t=this._chartData.styleOptions().separator;this._wrapper.style.backgroundColor=t.color,this._wrapper.style.height="".concat(t.size,"px"),this._wrapper.style.marginLeft="".concat(t.fill?0:this._offsetLeft,"px"),this._wrapper.style.width=t.fill?"100%":"".concat(this._width,"px")}},{key:"getImage",value:function(){var t=this._chartData.styleOptions().separator,e=document.createElement("canvas"),i=e.getContext("2d"),a=Rt(e),n=this._wrapper.offsetWidth,r=t.size;return e.style.width="".concat(n,"px"),e.style.height="".concat(r,"px"),e.width=n*a,e.height=r*a,i.scale(a,a),i.fillStyle=t.color,i.fillRect(this._offsetLeft,0,n,r),e}},{key:"destroy",value:function(){this._dragEvent&&this._dragEvent.destroy(),this._container.removeChild(this._wrapper)}}]),t}(),je=function(t){c(a,t);var e=_(a);function a(t){var n;return i(this,a),(n=e.call(this,t))._startScrollPoint={},n._touchPoint={},n._touchCancelCrossHair=!1,n._touchZoomed=!1,n._pinchScale=1,n}return n(a,[{key:"pinchStartEvent",value:function(){this._pinchScale=1,this._touchZoomed=!0}},{key:"pinchEvent",value:function(t,e){var i=5*(e-this._pinchScale);this._pinchScale=e,this._chartData.zoom(i,t)}},{key:"mouseLeaveEvent",value:function(t){Me(t)&&this._chartData.setCrossHairPointPaneTag(null,null)}},{key:"mouseMoveEvent",value:function(t){var e=this;Me(t)&&this._performCross(t,!1,(function(i){e._chartData.setCrossHairPointPaneTag({x:t.localX,y:i.y},i.tag)}),(function(){e._chartData.setCrossHairPointPaneTag(null,null)}))}},{key:"mouseWheelEvent",value:function(t){if(this._checkEventPointX(t.localX)){var e=-t.deltaY/100;if(0!==e){switch(t.cancelable&&t.preventDefault(),t.deltaMode){case t.DOM_DELTA_PAGE:e*=120;break;case t.DOM_DELTA_LINE:e*=32}if(0!==e){var i=Math.sign(e)*Math.min(1,Math.abs(e));this._chartData.zoom(i,{x:t.localX,y:t.localY})}}}}},{key:"mouseClickEvent",value:function(t){var e=this;this._performCross(t,!0,(function(i){e._touchPoint||e._touchCancelCrossHair||e._touchZoomed||(e._touchPoint={x:t.localX,y:t.localY},e._chartData.setCrossHairPointPaneTag({x:t.localX,y:i.y},i.tag))}))}},{key:"mouseDownEvent",value:function(t){var e=this;this._startScrollPoint={x:t.localX,y:t.localY},this._chartData.startScroll(),this._performCross(t,!0,(function(i){var a={x:t.localX,y:i.y};if(e._touchZoomed=!1,e._touchPoint){var n=t.localX-e._touchPoint.x,r=t.localY-e._touchPoint.y;10>Math.sqrt(n*n+r*r)?(e._touchPoint={x:t.localX,y:t.localY},e._chartData.setCrossHairPointPaneTag(a,i.tag)):(e._touchCancelCrossHair=!0,e._touchPoint=null,e._chartData.setCrossHairPointPaneTag(null,null))}else e._touchCancelCrossHair=!1}))}},{key:"pressedMouseMoveEvent",value:function(t){var e=this;this._performCross(t,!1,(function(i){var a={x:t.localX,y:i.y};if(Pe(t)&&e._touchPoint)return e._touchPoint={x:t.localX,y:t.localY},void e._chartData.setCrossHairPointPaneTag(a,i.tag);var n=t.localX-e._startScrollPoint.x;e._chartData.setCrossHairPointPaneTag(a,i.tag),e._chartData.scroll(n)}))}},{key:"longTapEvent",value:function(t){var e=this;this._performCross(t,!0,(function(i){e._touchPoint={x:t.localX,y:t.localY},e._chartData.setCrossHairPointPaneTag({x:t.localX,y:i.y},i.tag)}))}},{key:"_performCross",value:function(t,e,i,a){if(!e||Pe(t))if(this._checkEventPointX(t.localX)){var n=!1;for(var r in this._paneContentSize){var s=this._paneContentSize[r];if(t.localY>s.contentTop&&s.contentBottom>t.localY){n=!0,i&&i({tag:r,y:t.localY-s.contentTop});break}}!n&&a&&a()}else a&&a()}}]),a}(be),Ne="ArrowUp",Ke="ArrowDown",Ue="ArrowLeft",Ze="ArrowRight",qe=function(t){c(a,t);var e=_(a);function a(){return i(this,a),e.apply(this,arguments)}return n(a,[{key:"keyBoardDownEvent",value:function(t){if(t.shiftKey)switch(t.code){case Ne:this._chartData.zoom(-.5);break;case Ke:this._chartData.zoom(.5);break;case Ue:this._chartData.startScroll(),this._chartData.scroll(-this._chartData.dataSpace());break;case Ze:this._chartData.startScroll(),this._chartData.scroll(this._chartData.dataSpace())}}}]),a}(be),$e=function(){function t(e,a,n,r){i(this,t),this._target=e,this._chartData=a,this._chartContentSize={},this._event=new De(this._target,{pinchStartEvent:this._pinchStartEvent.bind(this),pinchEvent:this._pinchEvent.bind(this),mouseUpEvent:this._mouseUpEvent.bind(this),mouseClickEvent:this._mouseClickEvent.bind(this),mouseDownEvent:this._mouseDownEvent.bind(this),mouseRightDownEvent:this._mouseRightDownEvent.bind(this),mouseLeaveEvent:this._mouseLeaveEvent.bind(this),mouseMoveEvent:this._mouseMoveEvent.bind(this),mouseWheelEvent:this._mouseWheelEvent.bind(this),pressedMouseMoveEvent:this._pressedMouseMoveEvent.bind(this),longTapEvent:this._longTapEvent.bind(this)},{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!1}),this._boundKeyBoardDownEvent=this._keyBoardDownEvent.bind(this),this._target.addEventListener("keydown",this._boundKeyBoardDownEvent),this._boundContextMenuEvent=function(t){t.preventDefault()},this._target.addEventListener("contextmenu",this._boundContextMenuEvent,!1),this._zoomScrollEventHandler=new je(a),this._graphicMarkEventHandler=new Ee(a,n,r),this._keyBoardEventHandler=new qe(a)}return n(t,[{key:"_keyBoardDownEvent",value:function(t){this._keyBoardEventHandler.keyBoardDownEvent(t)}},{key:"_pinchStartEvent",value:function(){this._zoomScrollEventHandler.pinchStartEvent()}},{key:"_pinchEvent",value:function(t,e){this._zoomScrollEventHandler.pinchEvent(t,e)}},{key:"_mouseUpEvent",value:function(t){this._target.style.cursor="crosshair",t.localX-=this._chartContentSize.contentLeft,this._graphicMarkEventHandler.mouseUpEvent(t)}},{key:"_mouseLeaveEvent",value:function(t){this._checkZoomScroll()&&(t.localX-=this._chartContentSize.contentLeft,this._zoomScrollEventHandler.mouseLeaveEvent(t))}},{key:"_mouseMoveEvent",value:function(t){t.localX-=this._chartContentSize.contentLeft,this._chartData.shouldInvalidateGraphicMark()&&this._graphicMarkEventHandler.mouseMoveEvent(t),this._checkZoomScroll()&&this._zoomScrollEventHandler.mouseMoveEvent(t)}},{key:"_mouseWheelEvent",value:function(t){this._checkZoomScroll()&&this._zoomScrollEventHandler.mouseWheelEvent(t)}},{key:"_mouseClickEvent",value:function(t){this._checkZoomScroll()&&(t.localX-=this._chartContentSize.contentLeft,this._zoomScrollEventHandler.mouseClickEvent(t))}},{key:"_mouseDownEvent",value:function(t){this._target.style.cursor="pointer",t.localX-=this._chartContentSize.contentLeft,this._graphicMarkEventHandler.mouseDownEvent(t),this._checkZoomScroll()&&this._zoomScrollEventHandler.mouseDownEvent(t)}},{key:"_mouseRightDownEvent",value:function(t){t.localX-=this._chartContentSize.contentLeft,this._graphicMarkEventHandler.mouseRightDownEvent(t)}},{key:"_pressedMouseMoveEvent",value:function(t){t.localX-=this._chartContentSize.contentLeft,this._chartData.dragGraphicMarkFlag()&&(this._graphicMarkEventHandler.pressedMouseMoveEvent(t),this._chartData.crossHair().paneTag&&this._chartData.setCrossHairPointPaneTag(null,null)),this._checkZoomScroll()&&this._zoomScrollEventHandler.pressedMouseMoveEvent(t)}},{key:"_longTapEvent",value:function(t){this._checkZoomScroll()&&(t.localX-=this._chartContentSize.contentLeft,this._zoomScrollEventHandler.longTapEvent(t))}},{key:"_checkZoomScroll",value:function(){return!this._chartData.dragGraphicMarkFlag()&&this._chartData.graphicMarkType()===gt}},{key:"setChartContentSize",value:function(t){this._chartContentSize=t,this._zoomScrollEventHandler.setChartContentSize(t),this._graphicMarkEventHandler.setChartContentSize(t)}},{key:"setPaneContentSize",value:function(t){this._zoomScrollEventHandler.setPaneContentSize(t),this._graphicMarkEventHandler.setPaneContentSize(t)}},{key:"destroy",value:function(){this._event.destroy(),this._target.removeEventListener("keydown",this._boundKeyBoardDownEvent),this._target.removeEventListener("contextmenu",this._boundContextMenuEvent)}}]),t}();function Je(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,i=0;return function(){var a=Date.now(),n=this,r=arguments;a-i>e&&(t.apply(n,r),i=a)}}var Qe="candle_stick_pane_tag",ti=function(){function t(e,a){i(this,t),this._initChartContainer(e),this._technicalIndicatorBaseId=0,this._technicalIndicatorPanes=[],this._separatorPanes=[],this._separatorDragStartTechnicalIndicatorHeight=0,this._chartData=new Vt(a,this._updatePane.bind(this)),this._xAxisPane=new Ge({container:this._chartContainer,chartData:this._chartData}),this._candleStickPane=new Oe({container:this._chartContainer,chartData:this._chartData,xAxis:this._xAxisPane.xAxis(),tag:Qe}),this._chartEvent=new $e(this._chartContainer,this._chartData,this._xAxisPane.xAxis(),this._candleStickPane.yAxis()),this._measurePaneHeight(),this._measureWidthAndLayoutPane(!0)}return n(t,[{key:"_initChartContainer",value:function(t){this._container=t,this._chartContainer=document.createElement("div"),this._chartContainer.style.userSelect="none",this._chartContainer.style.webkitUserSelect="none",this._chartContainer.style.msUserSelect="none",this._chartContainer.style.MozUserSelect="none",this._chartContainer.style.webkitTapHighlightColor="transparent",this._chartContainer.style.position="relative",this._chartContainer.style.outline="none",this._chartContainer.style.borderStyle="none",this._chartContainer.style.width="100%",this._chartContainer.style.cursor="crosshair",this._chartContainer.tabIndex=1,t.appendChild(this._chartContainer)}},{key:"_separatorStartDrag",value:function(t){this._separatorDragStartTechnicalIndicatorHeight=this._technicalIndicatorPanes[t].height()}},{key:"_separatorDrag",value:function(t,e){var i=this._separatorDragStartTechnicalIndicatorHeight-t;0>i&&(i=0),this._technicalIndicatorPanes[e].setHeight(i),this.resize()}},{key:"_updatePane",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:mt;if(t===pt){this._xAxisPane.invalidate(t),this._candleStickPane.invalidate(t);var e,i=f(this._technicalIndicatorPanes);try{for(i.s();!(e=i.n()).done;){var a=e.value;a.invalidate(t)}}catch(t){i.e(t)}finally{i.f()}}else{var n=this._candleStickPane.computeAxis();if(t!==yt){var r,s=f(this._technicalIndicatorPanes);try{for(s.s();!(r=s.n()).done;){var o=r.value,c=o.computeAxis();c&&(n=c)}}catch(t){s.e(t)}finally{s.f()}}this._measureWidthAndLayoutPane(n)}}},{key:"_calcAllPaneTechnicalIndicator",value:function(){var t=this;Promise.resolve().then((function(e){var i,a=t._candleStickPane.calcTechnicalIndicator(),n=f(t._technicalIndicatorPanes);try{for(n.s();!(i=n.n()).done;){var r=i.value.calcTechnicalIndicator();r&&(a=r)}}catch(t){n.e(t)}finally{n.f()}t._measureWidthAndLayoutPane(a)}))}},{key:"_measureWidthAndLayoutPane",value:function(t){t&&this._measurePaneWidth(),this._xAxisPane.computeAxis(),this._xAxisPane.layout(),this._candleStickPane.layout();var e,i=f(this._technicalIndicatorPanes);try{for(i.s();!(e=i.n()).done;){e.value.layout()}}catch(t){i.e(t)}finally{i.f()}}},{key:"_measurePaneHeight",value:function(){var t,e=this._chartData.styleOptions(),i=this._container.offsetHeight,a=e.separator.size*this._separatorPanes.length,n=this._xAxisPane.getSelfAxisHeight(),r=i-n-a,s=0,o=f(this._technicalIndicatorPanes);try{for(o.s();!(t=o.n()).done;){var c=t.value,h=c.height();if((s+=h)>r){var l=s-r;s=r,c.setHeight(h-l)}}}catch(t){o.e(t)}finally{o.f()}var u=r-s,_={};_[Qe]={contentTop:0,contentBottom:u};var d=u,v=u;this._candleStickPane.setHeight(u);for(var y=0;this._technicalIndicatorPanes.length>y;y++){var p=this._technicalIndicatorPanes[y],x=p.height();p.setHeight(x),v+=x,_[p.tag()]={contentTop:d,contentBottom:v},d=v}this._xAxisPane.setHeight(n),this._chartEvent.setPaneContentSize(_)}},{key:"_measurePaneWidth",value:function(){var t,e,i,a,n=this._chartData.styleOptions().yAxis,r=n.position===M,s=this._container.offsetWidth;if(!n.inside){e=this._candleStickPane.getSelfAxisWidth();var o,c=f(this._technicalIndicatorPanes);try{for(c.s();!(o=c.n()).done;){e=Math.max(e,o.value.getSelfAxisWidth())}}catch(t){c.e(t)}finally{c.f()}t=s-e,r?(i=0,a=e):(a=0,i=s-e)}else t=s,e=s,i=0,a=0;this._chartData.setTotalDataSpace(t),this._candleStickPane.setWidth(t,e),this._candleStickPane.setOffsetLeft(a,i);for(var h=0;this._technicalIndicatorPanes.length>h;h++){var l=this._technicalIndicatorPanes[h],u=this._separatorPanes[h];l.setWidth(t,e),l.setOffsetLeft(a,i),u.setSize(a,t)}this._xAxisPane.setWidth(t,e),this._xAxisPane.setOffsetLeft(a,i),this._chartEvent.setChartContentSize({contentLeft:a,contentRight:a+t})}},{key:"chartData",value:function(){return this._chartData}},{key:"resize",value:function(){this._measurePaneHeight(),this._candleStickPane.computeAxis(!0);var t,e=f(this._technicalIndicatorPanes);try{for(e.s();!(t=e.n()).done;){t.value.computeAxis(!0)}}catch(t){e.e(t)}finally{e.f()}this._measureWidthAndLayoutPane(!0)}},{key:"applyTechnicalIndicatorParams",value:function(t,e){var i=this,a=this._chartData.technicalIndicator(t);if(a&&x(e)){var n,r=f(e);try{for(r.s();!(n=r.n()).done;){var s=n.value;if(!k(s)||0>=s||parseInt(s,10)!==s)return}}catch(t){r.e(t)}finally{r.f()}a.setCalcParams(p(e)),Promise.resolve().then((function(e){var a=!1;i._candleStickPane.technicalIndicator().name===t&&(a=i._candleStickPane.calcTechnicalIndicator());var n,r=f(i._technicalIndicatorPanes);try{for(r.s();!(n=r.n()).done;){var s=n.value;if(s.technicalIndicator().name===t){var o=s.calcTechnicalIndicator();o&&(a=o)}}}catch(t){r.e(t)}finally{r.f()}i._measureWidthAndLayoutPane(a)}))}}},{key:"_applyDataList",value:function(t,e,i){x(t)&&(m(i)&&i(),this._chartData.addData(t,0,e),this._calcAllPaneTechnicalIndicator())}},{key:"applyNewData",value:function(t,e){var i=this;this._applyDataList(t,e,(function(){i._chartData.clearDataList()}))}},{key:"applyMoreData",value:function(t,e){this._applyDataList(t,e)}},{key:"updateData",value:function(t){if(g(t)&&!x(t)){var e=this._chartData.dataList(),i=e.length,a=i;+B(t,"timestamp",0)===+B(e[i-1],"timestamp",0)&&(a=i-1),this._chartData.addData(t,a),this._calcAllPaneTechnicalIndicator()}}},{key:"setCandleStickChartType",value:function(t){var e=this._candleStickPane.setChartType(t);this._measureWidthAndLayoutPane(e)}},{key:"createTechnicalIndicator",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,i=arguments.length>2?arguments[2]:void 0,a=this._chartData.technicalIndicator(t);if(!a)return null;var n=this._technicalIndicatorPanes.length,r=!D(i)||i;this._separatorPanes.push(new Xe(this._chartContainer,this._chartData,n,r,{startDrag:this._separatorStartDrag.bind(this),drag:Je(this._separatorDrag.bind(this),50)})),this._technicalIndicatorBaseId++;var s="".concat("technical_indicator_").concat(this._technicalIndicatorBaseId),o=new ae({container:this._chartContainer,chartData:this._chartData,xAxis:this._xAxisPane.xAxis(),technicalIndicatorType:t,tag:s,height:e});return this._technicalIndicatorPanes.push(o),this.resize(),s}},{key:"removeTechnicalIndicator",value:function(t){for(var e=-1,i=0;this._technicalIndicatorPanes.length>i;i++){if(this._technicalIndicatorPanes[i].tag()===t){e=i;break}}if(-1!==e){this._technicalIndicatorPanes[e].destroy(),this._separatorPanes[e].destroy(),this._technicalIndicatorPanes.splice(e,1),this._separatorPanes.splice(e,1);for(var a=0;this._separatorPanes.length>a;a++)this._separatorPanes[a].updatePaneIndex(a);this.resize()}}},{key:"setTechnicalIndicatorType",value:function(t,e){if(t===Qe){var i=this._candleStickPane.setTechnicalIndicatorType(e);this._measureWidthAndLayoutPane(i)}else{var a,n,r=f(this._technicalIndicatorPanes);try{for(r.s();!(n=r.n()).done;){var s=n.value;if(s.tag()===t){a=s;break}}}catch(t){r.e(t)}finally{r.f()}if(a)if(this._chartData.technicalIndicator(e)){var o=a.setTechnicalIndicatorType(e);this._measureWidthAndLayoutPane(o)}else this.removeTechnicalIndicator(t)}}},{key:"setTimezone",value:function(t){this._chartData.setTimezone(t),this._xAxisPane.invalidate(mt)}},{key:"getConvertPictureUrl",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"jpeg",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#333333";if("png"===i||"jpeg"===i||"bmp"===i){var n=document.createElement("canvas"),r=n.getContext("2d"),s=Rt(n),o=this._chartContainer.offsetWidth,c=this._chartContainer.offsetHeight;n.style.width="".concat(o,"px"),n.style.height="".concat(c,"px"),n.width=o*s,n.height=c*s,r.scale(s,s),r.fillStyle=a,r.fillRect(0,0,o,c);var h=0,l=this._candleStickPane.height();r.drawImage(this._candleStickPane.getImage(t,e),0,h,o,l),h+=l;for(var u=0;this._separatorPanes.length>u;u++){var _=this._separatorPanes[u],d=_.height(),v=this._technicalIndicatorPanes[u],f=v.height();r.drawImage(_.getImage(),0,h,o,d),h+=d,r.drawImage(v.getImage(t),0,h,o,f),h+=f}return r.drawImage(this._xAxisPane.getImage(t),0,h,o,this._xAxisPane.height()),n.toDataURL("image/".concat(i))}}},{key:"destroy",value:function(){this._candleStickPane.destroy(),this._technicalIndicatorPanes.forEach((function(t){t.destroy()})),this._separatorPanes.forEach((function(t){t.destroy()})),this._xAxisPane.destroy(),this._container.removeChild(this._chartContainer),this._chartEvent.destroy()}}]),t}(),ei=function(){function t(e,a){i(this,t),this._chartPane=new ti(e,a)}return n(t,[{key:"setStyleOptions",value:function(t){t&&(this._chartPane.chartData().applyStyleOptions(t),this._chartPane.resize())}},{key:"getStyleOptions",value:function(){return p(this._chartPane.chartData().styleOptions())}},{key:"setTechnicalIndicatorParams",value:function(t,e){t&&this._chartPane.applyTechnicalIndicatorParams(t,e)}},{key:"getTechnicalIndicatorParams",value:function(t){return this._chartPane.chartData().technicalIndicatorCalcParams(t)}},{key:"setPrecision",value:function(t,e){this._chartPane.chartData().applyPrecision(t,e)}},{key:"setTechnicalIndicatorPrecision",value:function(t,e){this._chartPane.chartData().applyTechnicalIndicatorPrecision(t,e)}},{key:"setTimezone",value:function(t){this._chartPane.setTimezone(t)}},{key:"getTimezone",value:function(){return this._chartPane.chartData().timezone()}},{key:"resize",value:function(){this._chartPane.resize()}},{key:"setOffsetRightSpace",value:function(t){this._chartPane.chartData().setOffsetRightSpace(t)}},{key:"setLeftMinVisibleBarCount",value:function(t){this._chartPane.chartData().setLeftMinVisibleBarCount(t)}},{key:"setRightMinVisibleBarCount",value:function(t){this._chartPane.chartData().setRightMinVisibleBarCount(t)}},{key:"setDataSpace",value:function(t){this._chartPane.chartData().setDataSpace(t)}},{key:"clearData",value:function(){this._chartPane.chartData().clearDataList()}},{key:"getDataList",value:function(){return this._chartPane.chartData().dataList()}},{key:"applyNewData",value:function(t,e){this._chartPane.applyNewData(t,e)}},{key:"applyMoreData",value:function(t,e){this._chartPane.applyMoreData(t,e)}},{key:"updateData",value:function(t){this._chartPane.updateData(t)}},{key:"loadMore",value:function(t){this._chartPane.chartData().loadMore(t)}},{key:"setCandleStickChartType",value:function(t){this._chartPane.setCandleStickChartType(t)}},{key:"setCandleStickTechnicalIndicatorType",value:function(t){t&&this._chartPane.setTechnicalIndicatorType(Qe,t)}},{key:"setTechnicalIndicatorType",value:function(t,e){t&&this._chartPane.setTechnicalIndicatorType(t,e)}},{key:"createTechnicalIndicator",value:function(t,e,i){return this._chartPane.createTechnicalIndicator(t,e,i)}},{key:"addCustomTechnicalIndicator",value:function(t){this._chartPane.chartData().addCustomTechnicalIndicator(t)}},{key:"removeTechnicalIndicator",value:function(t){t&&this._chartPane.removeTechnicalIndicator(t)}},{key:"addGraphicMark",value:function(t){var e=this._chartPane.chartData().graphicMarkType();if(e!==t){var i=this._chartPane.chartData().graphicMarkData(),a=i[e];a&&x(a)&&(a.splice(a.length-1,1),i[e]=a),i.hasOwnProperty(t)||(t=gt),this._chartPane.chartData().setGraphicMarkType(t),this._chartPane.chartData().setGraphicMarkData(i)}}},{key:"removeAllGraphicMark",value:function(){var t=this._chartPane.chartData().graphicMarkData(),e={};Object.keys(t).forEach((function(t){e[t]=[]})),this._chartPane.chartData().setGraphicMarkType(gt),this._chartPane.chartData().setGraphicMarkData(e)}},{key:"subscribeDrawAction",value:function(t,e){var i=this._chartPane.chartData().drawActionDelegate(t);i&&i.subscribe(e)}},{key:"unsubscribeDrawAction",value:function(t,e){var i=this._chartPane.chartData().drawActionDelegate(t);i&&i.unsubscribe(e)}},{key:"getConvertPictureUrl",value:function(t,e,i,a){return this._chartPane.getConvertPictureUrl(t,e,i,a)}},{key:"destroy",value:function(){this._chartPane.destroy()}}]),t}(),ii={},ai=1;t.dispose=function(t){var e;t&&("string"==typeof t&&(e=(t=document.getElementById(t)||document.getElementsByClassName(t)).chartId),e||(e=t.chartId),!e&&t instanceof ei&&(e=t.id),e&&(ii[e].destroy(),delete ii[e]))},t.init=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t;if(!i)return null;if("string"==typeof i&&(i=document.getElementById(t)||document.getElementsByClassName(t)),!i)return null;var a=ii[i.chartId||""];if(a)return a;var n="".concat("k_line_chart_").concat(ai++),r=new ei(i,e);return r.id=n,i.chartId=n,ii[n]=r,r},t.version=function(){return"5.6.0"},Object.defineProperty(t,"__esModule",{value:!0})}));
  