You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
187 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var a in i)("object"==typeof exports?exports:t)[a]=i[a]}}(window,(function(){return i={},t.m=e=[function(t,e,i){"use strict";function a(t,e){for(var i=0;i<e.length;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)}}i.r(e);var n=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,i){i&&a(t,i)}(t,0,[{key:"getScreenResolution",value:function(e){if(!t.resolution){var i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;t.resolution=(window.devicePixelRatio||1)/i}return t.resolution}},{key:"creatCanvas",value:function(e,i,a){var n=document.createElement("canvas"),r=n.getContext("2d"),s=t.getScreenResolution(r);return n.style.position="absolute",n.style.width=i+"px",n.style.height=a+"px",n.width=i*s,n.height=a*s,r.scale(s,s),e.append(n),{can:n,ctx:r}}},{key:"loadingShow",value:function(e){t.loading?t.loading.style.zIndex=99999:(e.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 38 38" fill="none" stroke="#5874CB"\n class="loading"\n style="position: absolute; top: 50%; left: 50%; width: 66px; height: 66px;margin:-33px 0 0 -33px;z-index: 99999">\n <g transform="translate(1 1)" stroke-width="2">\n <path d="M36 18c0-9.94-8.06-18-18-18" transform="rotate(207.698 18 18)">\n <animateTransform\n attributeName="transform"\n type="rotate"\n from="0 18 18"\n to="360 18 18"\n dur="1s"\n repeatCount="indefinite"/>\n </path>\n </g>\n </svg>',t.loading=e.children[0])}},{key:"loadingHide",value:function(){t.loading.style.zIndex=-1}},{key:"clean",value:function(e){t.loading=!1,e.innerHTML=""}}]),t}();function r(t,e){for(var i=0;i<e.length;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)}}var s=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._axisWidth=66,this._axisHeight=22,this.kline=e}return function(t,e,i){e&&r(t.prototype,e)}(t,[{key:"getAxisWidth",value:function(){return this._axisWidth}},{key:"setAxisWidth",value:function(t,e){e&&(this._axisWidth=66),this._axisWidth=Math.max(t,this._axisWidth),this.kline.zoom.updateItemCount()}},{key:"getAxisHeight",value:function(){return this._axisHeight}}]),t}();function o(t,e){for(var i=0;i<e.length;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)}}var l=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._index=6,this._itemCount=-1,this._itemFirst=-1,this._post=!0,this.kline=e,this.init()}return function(t,e,i){e&&o(t.prototype,e)}(t,[{key:"getItemFirst",value:function(){var t=this.kline.getDataLen();return this._itemFirst>=t?t:this._itemFirst}},{key:"setItemFirst",value:function(t){var e=this.kline.getDataLen()+this._itemCount-5;t<5?t=5:e<t&&(t=e),this._itemFirst=t}},{key:"addItemFirst",value:function(t){t?this._itemFirst+=t:this._itemFirst===this.kline.getDataLen()-1&&this._itemFirst++}},{key:"getItemLast",value:function(){var t=this._itemFirst-this._itemCount;return t<0?0:t}},{key:"calcItemCount",value:function(){this._itemCount=Math.floor((this.kline.getWidth()-this.kline.layout.getAxisWidth())/this.getWidthAndSpace())}},{key:"getItemWidth",value:function(){return t.ITEM_WIDTH[this._index]}},{key:"getItemHalfWidth",value:function(){return t.ITEM_WIDTH[this._index]/2}},{key:"getWidthAndSpace",value:function(){return t.ITEM_WIDTH[this._index]+t.SPACE_WIDTH[this._index]}},{key:"setPost",value:function(t){this._post=t}},{key:"getX",value:function(t){return this.kline.getWidth()-this.kline.layout.getAxisWidth()-Math.floor(this.getWidthAndSpace()*(this._itemFirst-t))}},{key:"xCoordsToIndex",value:function(t){return this._itemFirst-Math.ceil((this.kline.getWidth()-this.kline.layout.getAxisWidth()-t)/this.getWidthAndSpace())}},{key:"indexToDate",value:function(t){var e=this.kline,i=e.getDataLen()-1;if(t<0){var a=e.getDataAt(0).date;return a+(1<i?e.getDataAt(1).date-a:3e5)*t}if(i<t){var n=e.getDataAt(i).date;return n+(1<i?n-e.getDataAt(i-1).date:3e5)*(t-i)}return e.getDataAt(t).date}},{key:"dateToIndex",value:function(t){var e=this.kline,i=e.getDataLen()-1;if(t<e.getDataAt(0).date){var a=e.getDataAt(0).date;return(t-a)/(1<i?e.getDataAt(1).date-a:3e5)}if(t>e.getDataAt(i).date){var n=e.getDataAt(i).date;return i+(t-n)/(1<i?n-e.getDataAt(i-1).date:3e5)}for(var r=0;r<e.getDataLen();r++){var s=e.getDataAt(r),o=e.getDataAt(r+1);if(t===s.date||o&&t>s.date&&t<o.date)return r}}},{key:"init",value:function(){var t=this.kline.getDataLen();this.calcItemCount(),this._itemFirst=t>=this._itemCount?t:this._itemCount}},{key:"addMore",value:function(){this._post&&this._itemFirst+1<=this._itemCount&&(this._post=!1,this.kline._on.moreCallBack())}},{key:"update",value:function(){var t=this._itemCount;this.calcItemCount();var e=this.kline.getDataLen();t<e&&this._itemFirst>e?this.setItemFirst(e+Math.round((this._itemFirst-e)/t*this._itemCount)):e<t&&(this._itemFirst===t?this.setItemFirst(this._itemCount):this._itemFirst>t?this.setItemFirst(this._itemCount+this._itemFirst-t):this._itemFirst<t&&this.setItemFirst(e+Math.round((this._itemFirst-e)/t*this._itemCount)))}},{key:"updateItemCount",value:function(){this._itemFirst===this._itemCount&&this.kline.getDataLen()<this._itemCount?(this.calcItemCount(),this._itemFirst=this._itemCount):this.calcItemCount()}},{key:"translation",value:function(t,e){var i=Math.floor((e-t)/this.getWidthAndSpace());return 0!==i&&(this.setItemFirst(this._itemFirst-i),this.addMore(),this.kline.manage.updateMaxAndMin()),t+i*this.getWidthAndSpace()}},{key:"scale",value:function(e){return(e<0&&1<=this._index||0<e&&this._index<t.ITEM_WIDTH.length-1)&&(this._index+=e,this.update(),this.addMore(),this.kline.manage.updateMaxAndMin(),this.kline.timeline.calcCount(),!0)}}]),t}();function c(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var i=[],a=!0,n=!1,r=void 0;try{for(var s,o=t[Symbol.iterator]();!(a=(s=o.next()).done)&&(i.push(s.value),!e||i.length!==e);a=!0);}catch(t){n=!0,r=t}finally{try{a||null==o.return||o.return()}finally{if(n)throw r}}return i}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function u(t,e){for(var i=0;i<e.length;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)}}l.created=!1,l.instance=null,l.ITEM_WIDTH=[1,3,3,5,5,7,7,9,9,11,11,13,13,15,15,17,17,19,21,23,25,27,29,29],l.SPACE_WIDTH=[1,1,2,2,3,2,3,3,4,4,5,4,5,4,5,5,6,5,5,5,7,7,7,9];var g=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,i){i&&u(t,i)}(t,0,[{key:"BrowserType",value:function(){var t=navigator.userAgent,e=-1<t.indexOf("Opera"),i=-1<t.indexOf("compatible")&&-1<t.indexOf("MSIE")&&!e,a=-1<t.indexOf("Windows NT 6.1; Trident/7.0;")&&!i,n=-1<t.indexOf("Firefox"),r=-1<t.indexOf("Safari")&&-1==t.indexOf("Chrome"),s=-1<t.indexOf("Chrome")&&-1<t.indexOf("Safari");if(i){new RegExp("MSIE (\\d+\\.\\d+);").test(t);var o=parseFloat(RegExp.$1);return 7==o?"IE7":8==o?"IE8":9==o?"IE9":10==o?"IE10":11==o?"IE11":"IE"}return n?"FF":e?"Opera":r?"Safari":s?"Chrome":a?"Edge":void 0}},{key:"toNumber",value:function(t){return"string"==typeof t?Number(t):"number"!=typeof t?0:t}},{key:"numberToReplenish",value:function(t,e){return t<10&&!e?"0"+t:t}},{key:"numberToRate",value:function(e,i,a){return 0===(e=t.toNumber(e))?0:(0<e&&!a?"+":"")+(i?e:100*e).toFixed(2)+"%"}},{key:"isIntGreaterThanOne",value:function(e,i,a,n){return 1<t.getFullNum(e-i)?"USDT"===a?4:"BTC"===a?6:"ETH"===a?6:4:"USDT"===a?"FEG"===n?11:6:"BTC"===a?8:"ETH"===a?8:6}},{key:"calcPairNamePlaces",value:function(e,i,a){if(!a)return t.calcPlaces(e,i);var n=-1<a.indexOf("-")?a.split("-"):a.split("/"),r=n[0],s=n[1];return["BTC","WBTC","RENBTC","BTCB","YFI","ETH","LTC","MKR","BCH","BSV"].some((function(t){return t===r}))?"USDT"===s?2:"BTC"===s?6:"ETH"===s?6:t.isIntGreaterThanOne(e,i,s,r):t.isIntGreaterThanOne(e,i,s,r)}},{key:"calcPairBigBuy",value:function(t){if(t){var e=(-1<t.indexOf("-")?t.split("-"):t.split("/"))[0];return["BTC","ETH"].some((function(t){return e==t}))?15e4:3e4}}},{key:"getJsMaxValue",value:function(){return 179e306}},{key:"orderCount",value:function(t){var e=(t="number"==typeof t?t.toFixed(5).split("."):parseFloat(t).toFixed(5).split("."))[0],i=t[1];if(e<999999){var a=i.substring(0,5-e.length),n=5===e.length?"":".";t="".concat(e).concat(e.length<6?n+a:"")}else t=(e/1e6).toFixed(5).substring(0,5)+"m";return t}},{key:"toNonExponential",value:function(t){if(!t)return 0;if(t===1/0||t===-1/0)return t;try{var e=t.toExponential().match(/\d(?:\.(\d*))?e([+-]\d+)/);return t.toFixed(Math.max(0,(e[1]||"").length-e[2]))}catch(t){}}},{key:"noRoundToFixed",value:function(t,e){return parseFloat(t).toFixed(e+1).slice(0,-1)+""}},{key:"formatSignificantDigit",value:function(t,e,i,a,n,r){var s=1<arguments.length&&void 0!==e?e:2,o=2<arguments.length&&void 0!==i?i:10,h=3<arguments.length&&void 0!==a?a:6,l=4<arguments.length&&void 0!==n&&n;if(""+t==""+-this.getJsMaxValue())return t;if(""+t==""+this.getJsMaxValue())return t;var c=this.toNonExponential(t);if(!c)return"0";var u=this.magnitude(Math.abs(c)),g=Math.max(s,Math.min(o,h-u-1));return l?"+".concat(this.noRoundToFixed(c,g)):"".concat(this.noRoundToFixed(c,g))}},{key:"magnitude",value:function(t){return 0==t||-0==t?-1:parseInt(Math.floor(Math.log10(Math.abs(t))))}},{key:"deBounce",value:function(t,e){var i=null;return function(){for(var a=arguments.length,n=new Array(a),r=0;r<a;r++)n[r]=arguments[r];clearTimeout(i),i=setTimeout((function(){t.apply(void 0,n)}),e)}}},{key:"numberSeparator",value:function(t){if(!t)return this.toNumber(t);"number"==typeof t&&(t=String(t));var e=t.indexOf("-"),i="";0<=e&&(i="-",t=t.slice(e+1));var a="";0<=(e=t.indexOf("."))&&(a=t.slice(e),t=t.slice(0,e));for(var n=[],r=t.length;0<r;r-=3)n.unshift(t.slice(r<3?0:r-3,r));return i+n.join(",")+a}},{key:"numberUnit",value:function(t,e,i){var a=this.toNumber(t),n="";switch(e){case 3:a=(t/1e3).toFixed(i||1),n="K";break;case 6:a=(t/1e7).toFixed(i||1),n="M";break;case 9:a=(t/1e8).toFixed(i||1),n="G";break;case 12:a=(t/1e12).toFixed(i||1),n="T"}return{num:a,unit:n}}},{key:"numberRang",value:function(e,i,a){return e?(n=1e12<=e||e<=-1e12?t.numberUnit(e,12,i):1e9<=e||e<=-1e9?t.numberUnit(e,9,i):1e6<=e||e<=-1e6?t.numberUnit(e,6,i):1e3<=e||e<=-1e3?t.numberUnit(e,3,i):{num:t.numberPrice(e),unit:""},(a?t.numberSeparator(n.num):n.num)+n.unit):t.toNumber(e);var n}},{key:"numberPrice",value:function(e,i){return(e=t.toNumber(e))?i?e.toFixed(i):e=1<=e||e<=-1?e.toFixed(2):1e-4<=e||e<=-1e-4?e.toFixed(4):e.toFixed(8):0}},{key:"calcPeriodsDiff",value:function(t,e){}},{key:"transformRateData",value:function(t,e){return t.map((function(t){return t.open=t.open*e,t.high=t.high*e,t.low=t.low*e,t.close=t.close*e,t}))}},{key:"dateToJSON",value:function(e,i){var a=e,n=a.getFullYear(),r=a.getDay();return{year:n,month:t.numberToReplenish(a.getMonth()+1,i),day:t.numberToReplenish(a.getDate(),i),hour:t.numberToReplenish(a.getHours(),i),minute:t.numberToReplenish(a.getMinutes(),i),second:t.numberToReplenish(a.getSeconds(),i),week:r}}},{key:"dateFormat",value:function(e,i,a){if(!e)return"";var n=t.dateToJSON(new Date(e),a),r=n.year,s=n.month,o=n.day,h=n.hour,l=n.minute,c=n.second,u=n.week;return i?i.replace(/(yyyy)/gi,r).replace(/(mm)/gi,s).replace(/(dd)/gi,o).replace(/(hh)/gi,h).replace(/(mn)/gi,l).replace(/(ss)/gi,c).replace(/(ww)/gi,u):"".concat(r,"-").concat(s,"-").concat(o)}},{key:"getTimeInterval",value:function(t,e){var i=[0,0,0,0],a="",n=t<e?parseInt((e-t)/1e3):0;return i[0]=86400<n?parseInt(n/86400):0,n-=86400*i[0],i[1]=3600<n?parseInt(n/3600):0,n-=3600*i[1],i[2]=60<n?parseInt(n/60):0,i[3]=n-60*i[2],a=0<i[0]?i[0]+"天":"",(a+=i[0]<=0&&i[1]<=0?"":i[1]+"小时")+(i[0]<=0&&i[1]<=0&&i[2]<=0?"":i[2]+"分钟")}},{key:"getCountTime",value:function(e,i){var a=[0,0,0,0],n="",r=e<i?parseInt((i-e)/1e3):0;return a[0]=86400<r?parseInt(r/86400):0,r-=86400*a[0],a[1]=3600<r?parseInt(r/3600):0,r-=3600*a[1],a[2]=60<r?parseInt(r/60):0,a[3]=r-60*a[2],1<a[0]?(n=0<a[0]?a[0]+"d ":"",n+=a[0]<=0&&a[1]<=0?"":a[1]+"h"):(n=a[0]<=0&&a[1]<=0?"00:":"".concat(t.numberToReplenish(a[1],!1),":"),n+=a[0]<=0&&a[1]<=0&&a[2]<=0?"00:":"".concat(t.numberToReplenish(a[2],!1),":"),n+=a[0]<=0&&a[1]<=0&&a[2]<=0&&a[3]<=0?"00":"".concat(t.numberToReplenish(a[3],!1)))}},{key:"dateToStr",value:function(t){var e=2592e6;return t<36e5?t/6e4+"分":t<864e5?t/36e5+"时":t<e?t/864e5+"天":t<31104e6?t/e+"月":t/31104e6+"年"}},{key:"getFullNum",value:function(t){try{var e=String(t);if(isNaN(t)||e.indexOf("e")<0)return t;var i=(e=Math.abs(Number(e.split("e")[1])))+1;return 100<=e+1?i=100:e+1<0&&(i=0),t.toFixed(i)}catch(t){console.log(t)}}},{key:"calcPlaces",value:function(e,i){var a=t.getFullNum(e-i);if(1<a)return 2;a=(a=String(a)).substring(a.indexOf(".")+1);for(var n=0;n<a.length;n++)if("0"!==a[n])return n+2}},{key:"toHeight",value:function(t,e){return t==1/0||0==e?1.5:Math.floor(t*e+1.5)}},{key:"calcInterval",value:function(t,e,i){for(var a=(e-i)/t*40,n=[],r=[1,2,5],s=0,o=0,h=0;s<r.length;s++)o=r[s],h=Math.ceil(Math.log(a/o)/Math.log(10)),h=Math.pow(10,h),h*=o,n.push(h);return Math.min.apply(Math,n)}},{key:"calcTextWidth",value:function(t,e,i,a,n){return n=n||0,t.font="".concat(i||"12","px ").concat(a||"PingFangSC-Regular ,Microsoft YaHei"),Math.ceil(t.measureText(e).width+n)}},{key:"calcSlope",value:function(t,e,i,a){var n=(a-e)/(i-t);return{k:n,b:e-t*n}}},{key:"drawLine",value:function(t,e,i,a,n,r,s){t.save(),t.beginPath(),t.strokeStyle=e,t.lineWidth=s||1,t.moveTo(i,a),t.lineTo(n,r),t.closePath(),t.stroke(),t.restore()}},{key:"drawStyleLine",value:function(e,i,a,n,r,s,o,h){var l=7<arguments.length&&void 0!==h?h:0;0===l?t.drawLine(e,i,a,n,r,s,o):1===l?t.drawDotted(e,i,a,n,r,s,2,2,o):2===l&&t.drawDotted(e,i,a,n,r,s,4,4,o)}},{key:"drawDotted",value:function(t,e,i,a,n,r,s,o,h){var l,c=6<arguments.length&&void 0!==s?s:2,u=7<arguments.length&&void 0!==o?o:1,g=8<arguments.length?h:void 0;if(t.save(),t.lineWidth=g||1,i===n)for(l=a;l<=r;l+=c)t.beginPath(),t.strokeStyle=e,t.moveTo(i,l),l+=u,t.lineTo(i,l),t.stroke();else if(a===r)for(l=i;l<=n;l+=c)t.beginPath(),t.strokeStyle=e,t.moveTo(l,a),l+=u,t.lineTo(l,a),t.stroke();else t.beginPath(),t.strokeStyle=e,t.moveTo(i,a),t.dashedLineTo(n,r,u),t.stroke();t.restore()}},{key:"drawBrokenLine",value:function(e,i,a,n,r){try{if(1===r&&2===a.length){var s=a[0].x,o=a[0].y,h=a[1].x,l=a[1].y;t.drawDotted(e,i,s,o,h,l,2,2,n)}else if(2===r&&2===a.length){var c=a[0].x,u=a[0].y,g=a[1].x,d=a[1].y;t.drawDotted(e,i,c,u,g,d,4,4,n)}else{e.save(),e.beginPath(),e.lineWidth=n||1,e.strokeStyle=i;for(var v=0;v<a.length;v++)e.lineTo(a[v].x,a[v].y);e.stroke(),e.restore()}}catch(e){console.log(e)}}},{key:"drawPolygon",value:function(t,e,i,a){if(!(i&&i.length<2)){t.save(),t.beginPath(),t.moveTo(i[0].x,i[0].y);for(var n=1;n<i.length;n++)t.lineTo(i[n].x,i[n].y);t.strokeStyle=e,t.fillStyle=a,t.closePath(),t.fill(),t.stroke(),t.restore()}}},{key:"drawEllipse",value:function(t,e,i,a,n,r,s,o,h,l,c){var u=10<arguments.length&&void 0!==c?c:0;t.save();var g=n<a?1/a:1/n;t.beginPath(),t.moveTo(e+a,i),t.lineWidth=l||1,t.strokeStyle=h||"rgba(0,0,0,0)",t.fillStyle=o,1===u?t.setLineDash([2,2]):2===u&&t.setLineDash([4,4]);for(var d=r;d<s;d+=g)t.lineTo(e+a*Math.cos(d),i+n*Math.sin(d));t.closePath(),t.stroke(),t.fill(),t.restore()}},{key:"drawRadian",value:function(t,e,i,a,n,r,s,o,h,l){t.save();var c=n<a?1/a:1/n;if(t.beginPath(),t.moveTo(e+a,i),t.lineWidth=h||1,t.strokeStyle=o||"rgba(0,0,0,0)",1===l?t.setLineDash([2,2]):2===l&&t.setLineDash([4,4]),r<s)for(var u=r;u<s;u+=c)t.lineTo(e+a*Math.cos(u),i+n*Math.sin(u));else for(u=r;s<u;u-=c)t.lineTo(e+a*Math.cos(u),i+n*Math.sin(u));t.stroke(),t.restore()}},{key:"drawRect",value:function(t,e,i,a,n,r){t.save(),t.fillStyle=e,t.fillRect(i,a,n,r),t.restore()}},{key:"drawBorderRect",value:function(e,i,a,n,r,s,o,h,l){e.save(),e.lineWidth=h||1,e.strokeStyle=0===l?o:"rgba(0,0,0,0)",e.fillStyle=i,e.fillRect(a,n,r,s),e.strokeRect(a,n,r,s),1===l?t.drawDashRect(e,a,n,r,s,o,h,2):2===l&&t.drawDashRect(e,a,n,r,s,o,h,4),e.restore()}},{key:"drawDashRect",value:function(e,i,a,n,r,s,o,h){var l=7<arguments.length&&void 0!==h?h:5;t.drawDashLine(e,[i,a],[i+n,a],s,o,l),e.stroke(),t.drawDashLine(e,[i+n,a],[i+n,a+r],s,o,l),e.stroke(),t.drawDashLine(e,[i+n,a+r],[i,a+r],s,o,l),e.stroke(),t.drawDashLine(e,[i,a+r],[i,a],s,o,l),e.stroke()}},{key:"drawDashLine",value:function(t,e,i,a,n,r){var s=c(e,2),o=s[0],h=s[1],l=c(i,2),u=l[0],g=l[1],d=5<arguments.length&&void 0!==r?r:5,v=u-o,f=g-h,y=Math.floor(Math.sqrt(v*v+f*f)/d),p=v/y,m=f/y;t.lineWidth=n||1,t.strokeStyle=a,t.beginPath();for(var _=0;_<y;_++)_%2==0?t.moveTo(o,h):t.lineTo(o,h),o+=p,h+=m;t.lineTo(u,g)}},{key:"drawRectFrame",value:function(t,e,i,a,n,r){t.save(),t.beginPath(),t.strokeStyle=e,t.moveTo(i,a-.5),t.lineTo(i+n,a-.5),t.moveTo(i+n-.5,a),t.lineTo(i+n-.5,a+r),t.moveTo(i+n,a+r-.5),t.lineTo(i,a+r-.5),t.moveTo(i+.5,a+r),t.lineTo(i+.5,a),t.stroke(),t.restore()}},{key:"drawArc",value:function(t,e,i,a,n,r,s){s=s||1,t.save(),t.beginPath(),t.strokeStyle=e,t.lineWidth=s,t.arc(a,n,r,0,2*Math.PI),t.stroke(),i&&(t.beginPath(),t.fillStyle=i,t.arc(a,n,r-s/2,0,2*Math.PI),t.fill()),t.restore()}},{key:"drawArrow",value:function(e,i,a,n,r){var s=4<arguments.length&&void 0!==r?r:1,o=a[0].x,h=a[0].y,l=a[1].x,c=a[1].y,u=t.calcSlope(o,h,l,c).k,g=o<l?-10:10,d=h<c?-10:10,v=Math.abs(Math.cos(Math.atan(u)))*g*s,f=Math.abs(Math.sin(Math.atan(u)))*d*s;e.save(),e.strokeStyle=i,e.lineWidth=n||1,e.translate(l,c),e.rotate(35*Math.PI/180),e.translate(-l,-c),e.beginPath(),e.moveTo(l,c),e.lineTo(l+v,c+f),e.stroke(),e.restore(),e.save(),e.strokeStyle=i,e.lineWidth=n||1,e.translate(l,c),e.rotate(-35*Math.PI/180),e.translate(-l,-c),e.beginPath(),e.moveTo(l,c),e.lineTo(l+v,c+f),e.stroke(),e.restore()}},{key:"drawText",value:function(t,e,i,a,n,r,s,o,h){t.save(),t.font="".concat(r||12,"px ").concat(s||"PingFangSC-Regular ,Microsoft YaHei"),t.textAlign=o||"center",t.textBaseline=h||"hanging",t.fillStyle=i,t.fillText(e,a,n),t.restore()}},{key:"drawImage",value:function(t,e,i,a,n,r){t.save();var s=new Image;s.src=e,t.drawImage(s,i,a,n,r),t.restore()}},{key:"drawMaxAndMinPrice",value:function(e,i,a,n,r,s,o){var h=0<n-t.calcTextWidth(e,i,s,o,12)?-1:1;e.save(),e.strokeStyle=a,e.beginPath(),e.lineWidth=1,e.moveTo(n+2*h,r),e.lineTo(n+10*h,r),e.moveTo(n+2*h,r),e.lineTo(n+6*h,r-2),e.moveTo(n+2*h,r),e.lineTo(n+6*h,r+2),e.stroke(),e.restore(),t.drawText(e,i,a,n+12*h,r-4,s,o,0<h?"left":"right")}},{key:"drawPoint",value:function(t,e,i,a){t.save(),t.fillStyle=e,t.fillRect(i-.5,a,1,1),t.strokeStyle=e,t.lineWidth=1,t.beginPath(),t.moveTo(i-7.5,a+.5),t.lineTo(i-2.5,a+.5),t.moveTo(i+7.5,a+.5),t.lineTo(i+2.5,a+.5),t.moveTo(i,a-7),t.lineTo(i,a-2),t.moveTo(i,a+3),t.lineTo(i,a+8),t.stroke(),t.restore()}},{key:"drawWatermark",value:function(e,i,a,n,r,s){var o=new Image;o.setAttribute("crossOrigin","Anonymous"),o.src=i,o.onload=function(){var i=o.width,h=o.height,l=a/2-i/2,c=n/2-h/2;e.clearRect(0,0,a,n),e.save(),t.drawRect(e,r,0,0,a,n),e.drawImage(o,l,c,i,h),e.restore(),s&&s()},o.onerror=function(){s&&s()}}},{key:"segmentsIntr",value:function(t,e,i,a){var n=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),r=(t.x-a.x)*(e.y-a.y)-(t.y-a.y)*(e.x-a.x);if(0<=n*r)return!1;var s=(i.x-t.x)*(a.y-t.y)-(i.y-t.y)*(a.x-t.x);if(0<=s*(s+n-r))return!1;var o=s/(r-n),h=o*(e.x-t.x),l=o*(e.y-t.y);return{x:t.x+h,y:t.y+l}}},{key:"unique",value:function(t){return Array.from(new Set(t))}},{key:"isEmpty",value:function(t,e){return!t||JSON.stringify(t)===e}}]),t}();function d(t,e){for(var i=0;i<e.length;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 v(t,e,i){return e&&d(t.prototype,e),i&&d(t,i),t}g.Dot=function(t){this.x=0,this.y=0;var e=arguments.length;return 1===e?{x:t.x,y:t.y}:2===e?{x:t,y:arguments[1]}:void 0},g.smoothLineRender=function(t,e){var i=function(t){var e=[];e.push({start:t[0],end:t[1],dot1:t[0],dot2:null});for(var i=1;i<t.length-1;i++){var a=t[i],n=t[i+1],r=t[i-1],s=g.Dot(a.x-1/3*Math.abs(a.x-r.x),a.y),o=g.Dot(a.x+1/3*Math.abs(a.x-n.x),a.y);e[i-1].dot2=s,e.push({start:a,end:n,dot1:o,dot2:null})}return e[e.length-1].dot2=t[t.length-1],e}(e);t.beginPath();for(var a=0;a<i.length;a++)t.moveTo(i[a].start.x,i[a].start.y),t.bezierCurveTo(i[a].dot1.x,i[a].dot1.y,i[a].dot2.x,i[a].dot2.y,i[a].end.x,i[a].end.y);t.stroke()};var f=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._period=null,this._lastIndex="",this.kline=e,this.log={posiL:0,posiR:0,posiT:0,posiB:0},this.calc()}return v(t,null,[{key:"periodRule",value:function(t,e){for(var i=0;i<e.length;i++)if(t<=e[i])return e[i]}}]),v(t,[{key:"resetLastIndex",value:function(){this._lastIndex=""}},{key:"calc",value:function(){this.calcPeriod(),this.calcCount()}},{key:"calcPeriod",value:function(){var t,e,i=this.kline,a=i.getDataLen(),n=Math.floor(a/2),r={},s=1,o=a;for(100<n&&(s=n-100,o=n+100);s<o;s++){var h=i.getDataAt(s).date-i.getDataAt(s-1).date;r[h]?r[h]++:r[h]=1}for(var l in r)(!e||r[l]>e)&&(e=r[t=l]);this._timePeriod=t}},{key:"calcCount",value:function(){this._count=Math.ceil(t.AXIS_SPACE/this.kline.zoom.getItemWidth());var e=this._timePeriod*this._count;e<t.DATE_HOUR?(this._type=0,this._period=t.periodRule(Math.ceil(e/t.DATE_MINUTE),[5,10,15,30,60])):e<t.DATE_DAY?(this._type=1,this._period=t.periodRule(Math.ceil(e/t.DATE_HOUR),[1,2,3,4,6,8,12,24])):e<t.DATE_MONTH?(this._type=2,this._period=e<7*t.DATE_DAY?t.periodRule(Math.ceil(e/t.DATE_DAY),[1,2,3]):null):e<t.DATE_YEAR?(this._type=3,this._period=t.periodRule(Math.ceil(e/t.DATE_MONTH),[1,2,3,4,6,12])):(this._type=4,this._period=Math.ceil(e/t.DATE_YEAR))}},{key:"fillGrid",value:function(t,e,i){var a=Math.floor((e-this._lastIndex)/2);""===this._lastIndex||a<this._count||i&&i(t,e-a)}},{key:"fillDayAxis",value:function(t,e){var i=Math.floor((e-this._lastIndex)/2);if(!(""===this._lastIndex||i<this._count)){var a=this.kline.getHeight()-this.kline.layout.getAxisHeight();this.drawXAxis(t,g.dateFormat(this.kline.getDataAt(e-i).date,"dd",!0),a,e-i)}}},{key:"dateText",value:function(t,e){if(0===t||""!==this._lastIndex&&this._lastIndex+this._count>t)return!1;var i=this.kline.getData(),a="",n=0<t&&g.dateToJSON(new Date(i[t-1].date),!0),r=0<=t-this._count&&g.dateToJSON(new Date(i[t-this._count].date),!0),s=t+this._count-1<this.kline.getDataLen()&&g.dateToJSON(new Date(i[t+this._count-1].date),!0),o=g.dateToJSON(new Date(i[t].date),!0);return(4===this._type&&o.year%this._period==0||this._type<4)&&n.year!==o.year?a="".concat(o.year):(3===this._type&&(o.month-1)%this._period==0||this._type<3)&&n.month!==o.month?(a="".concat(o.month,"月"),e&&e()):!(2!==this._type||(this._period||1!==o.week)&&(!this._period||o.day%this._period!=0||n&&n.day===o.day)||s&&s.month!==o.month||r&&r.month!==o.month)||this._type<2&&n.day!==o.day?(a="".concat(o.day),e&&e()):(1!==this._type||o.hour%this._period!=0||s&&s.day!==o.day||n.hour===o.hour)&&(0!==this._type||o.minute%this._period!=0||s&&s.day!==o.day)||(a=g.dateFormat(i[t].date,"hh:mn")),a&&(this._lastIndex=t),a}},{key:"drawXAxis",value:function(t,e,i,a){if(e){var n=this.kline,r=n.getTheme(),s=r.getColors("Frame"),o=r.getColors("RangText"),h=n.zoom.getX(a)+n.zoom.getItemHalfWidth();g.drawLine(t,s,h,i,h,i+4),g.drawText(t,e,o,h,i+7,11)}}},{key:"drawMain",value:function(t){var e=this.kline,i=e.zoom.getItemFirst(),a=e.zoom.getItemLast(),n=e.layout.getAxisHeight(),r=e.getHeight()-n,s=e.getTheme();this.resetLastIndex();for(var o=a;o<i;o++)this.drawXAxis(t,this.dateText(o,this.fillDayAxis.bind(this,t,o)),r,o);var h=Math.ceil(t.measureText("对数").width),l=e.getWidth()-40,c=5+r,u=s.getColors("RangText");e._log&&(u=s.getColors("Selected")),g.drawText(t,"对数",u,l,c),this.log={posiL:l,posiR:l+h,posiT:c,posiB:15+c}}},{key:"drawLog",value:function(t){}},{key:"logInPath",value:function(t,e){var i=e.x,a=e.y,n=this.log;return n.posiL-10<=i&&i<n.posiR-10&&n.posiT<=a&&a<n.posiB&&(this.kline._el.style.cursor="pointer",!0)}},{key:"clickEvent",value:function(t,e){if(this.logInPath(t,e)){var i=this.kline,a=!i._log;i._on&&i._on.log&&i._on.log?i._on&&i._on.log&&i._on.log(a):i.log(a)}}},{key:"drawOverlay",value:function(t){var e=this.kline,i=e.manage.getHover();if(!(i<0)){var a=e.getDataAt(i),n=e.getWidth()-e.layout.getAxisWidth(),r=e.layout.getAxisHeight(),s=e.zoom.getX(i)+e.zoom.getItemHalfWidth(),o=e.getHeight()-r,h=e.getTheme(),l=g.dateFormat(a.date,"yyyy-mm-dd hh:mn"),c=2*Math.ceil(g.calcTextWidth(t,l,!1,!1,20)/2);s-c/2<0?s=c/2-.5:n<s+c/2&&(s=n-c/2-.5),g.drawRect(t,h.getColors("SelectionBg"),s-c/2+.5,o,c,20),g.drawText(t,l,h.getColors("SelectionText"),s,4+o)}}}]),t}();f.DATE_MINUTE=6e4,f.DATE_HOUR=60*f.DATE_MINUTE,f.DATE_DAY=24*f.DATE_HOUR,f.DATE_MONTH=30*f.DATE_DAY,f.DATE_YEAR=12*f.DATE_MONTH,f.AXIS_SPACE=80;var p="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAARVBMVEUAAAD////////////////////////X19fT09PQ0NClpaejpqiWlpmTlZeSlJaSk5WQkZSMjZGLjZCLi46Jio2Jio2Jio1B4GIsAAAAFnRSTlMABBUcHR8gLS4xYGGWmqKqs9nk8/n6904QsAAAAKpJREFUOMu1k+sOwyAIRlFrW2tv9sL7P+rM0k3ATZNl5afnROSLACht7JcyWgGoxhaqUaBtsTSYsmDAVuqPQtvR4z4T2iW4xP0+SKELmAx/4Ji1cMmIfPrwyLfBOJ3iMjhnYz4NwXkO0dhOzkVQbkOcS0n6E5HmIYXYfw7CAM4nmocUrvcLAySXBmRcGC+h38n80VizG4aR5rG6G77c70J1caqrV13e2vo/AGfRGNsBtVgYAAAAAElFTkSuQmCC",m="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAilBMVEUAAAD////////////////////////r6+vf3+bc3NzGxsbHx8fCwsK4vLy1tbWprKyioqScnqCbnZ+cnJ6WmJqYmJyUlpiWlpqUlJeSlJeTk5aTk5aRkpWRk5WRkZSQkZSPj5OOkJKOjpKMjZGLjI+LjI+Ki4+LjI+Ki46Jio2Ki46Jio2Ki46Jio0n5V/OAAAALXRSTlMABBUcHR8gJigsNjc7QUhWaHZ4eYuLkpKbpKWnq66wtb2+x9Xi6ezv9ff6/f5jDCqOAAAA4klEQVQ4y53T13LCMBCFYdnmp4neQ8BgwPTz/q+XmwwWNrCZnOtvRqstzkVxwpskceRcVONDapGL+ZjYJZ9B4jBSgOYwSPMFmCnIrAo6l/vq+zer+6VTARuti4fX2pRBX+d2Adpn9Z9Bfa9pWPtU+/oTGOvQCEHjoHEIWkcNAHya56kHGOjYCsBCOwB/kqSTB9hpUYDu9dYDSJV5nykF6N2u3QfI9AVALg9eOQBLZQ+w1fIV2P79CbNI+5uMqo0alVs9CcGk3GpzWPa47YVhHq7c/D9L+27tzcMxT888Xuv8fwDoTSyMFWMKAwAAAABJRU5ErkJggg==",_="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAIVBMVEUAAAD////////////////////Q0NDMzNGanJ6MjZGJio2TCl/NAAAACnRSTlMABBUcHR8xMnzZ9GxjNwAAAHVJREFUKM9jYFQORQJGAgwioSjAkUEVVSCIwRRVIJghFA3QUaANws6ACUSsTAUxw2a1QgXCZk0DCWSCxRngTKgwQyhMCUQB1BYgB6oAKgDkQRXA3JG5EqoAJhA2C6oA7tLKaWhOD0+lbwBhRBRGVGJENnpyAADryq78/8xAhgAAAABJRU5ErkJggg==",k="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAQlBMVEUAAADY6+vg4Off4ube4Ofe4Ofe4OfY2uLW2uDV2d/Ex9DGx9G5vMW3u8O1ucK1uMG0tsCtsbussLmrrrirrbeprLa92m1bAAAAFXRSTlMADUtoa3N0e3x+nJy9wMXKz+fu9/sxZ6HSAAAAp0lEQVQ4y7WT7Q6DIAxFC4iK3+h4/1eVGDfaywbJsvUn56TQG0qktLEfymhFpBpbqEaRtsXSZMqCIVupHwptx4/7TGhX7xIfjwGFzodkjI8wZVe4ZEQ+v3nkyxCcT3EbkosxLwO4zCEaO3AIyu0hLKUkY//A80Ah8sWDQZLPPA8U7veDQcjRoIyD8RT6g80fjS3rMEw8j8394ct9L1QXp7p61eWtrf8JKc8YvQFjoWQAAAAASUVORK5CYII=",A="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAilBMVEUAAADY6+vg4Off4ube4Ofe4Ofe4Ofb3ePZ2+HY3ODU193U1NzT1drO0trO0NfIzNPDxMzAw8y/wMm/wsm6vca7vMa5vcW5vMa5usW2uMK2ucG1uMG2t8G1t8GztsCzt8CytL2ytb+wsr2usbusr7qrr7msrrmsrrirrriqrbiprLeprLaqrbeprLbHPbvfAAAALXRSTlMADUtoa3N0d3l7gYKEiIyVoamrq7a3urvAxsfIyszO0NbW3OXt8fP1+Pr8/f58eqy8AAAA4UlEQVQ4y53T13LCMBCFYdnmp4neQ8CYYvp5/9fLTQYLG9hMzvU3o9UW56I44U2SOHIuqvEhtcjFfEzsks8gcRgpQHMYpPkCzBVkXgWdy331/ZvV/dKpgI3WxcNrbcqgr3O7AO2z+s+gvtckrH2iff0JjHVohKBx0DgEraMGAD7N89QDDHRsBWChHYA/SdLJA+y0KED3eusBpMq8z5QC9G7X7gNk+gIglwevHIClsgfYavkKbP/+hFmk/U1G1UaNyq2ehmBabrU5LHvc9sIwC1du9p+lfbf25uGYp2cer3X+P+HbLIiM5uv2AAAAAElFTkSuQmCC",C="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAIVBMVEUAAADY6+vg4Off4ube4Ofe4OfV2d/V19++wcitsbuprLbJr9lkAAAACnRSTlMADUtoa3N+f63nY4oLPQAAAHVJREFUKM9jYFQORQJGAgwioSjAkUEVVSCIwRRVIJghFA3QUaANws6ACUSsTAUxw2a1QgXCZk0DCWSCxRngTKgwQyhMCUQB1BYgB6oAKgDkQRXA3JG5EqoAJhA2C6oA7tLKaWhOD0+lbwBhRBRGVGJENnpyAADryq78/8xAhgAAAABJRU5ErkJggg==";function b(t){return(b="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 T(t,e){return!e||"object"!==b(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function M(t){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function D(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&&function(t,e){(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function I(t,e){for(var i=0;i<e.length;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 L(t,e,i){return e&&I(t.prototype,e),i&&I(t,i),t}var R=function(){function t(e,i,a){P(this,t),this.kline=e,this._image=new Image,this._indicator=i,this._action=a,this._isActive=!1,this._posix=-1,this._posiy=-1,this._width=0,this._height=0,this._hover=!1}return L(t,[{key:"setParams",value:function(t){this._posix=t.x,this._posiy=t.y,this._width=t.width,this._height=t.height}},{key:"inPath",value:function(t,e){var i=e.x,a=e.y;return i>=this._posix&&i<=this._posix+this._width&&a>=this._posiy&&a<=this._posiy+this._height?(this.kline._el.style.cursor="pointer",this._isActive=!0,this):this._isActive=!1}},{key:"mouseEvent",value:function(t,e){return this._hover=this.inPath(t,e),this._hover}},{key:"clickEvent",value:function(t,e){var i=this.inPath(t,e),a=this.kline;return!!i&&("hide"===this._action&&a.indicatorTextVisible(!this.kline._showIndicatorText),a._on&&a._on.iconCallBack&&a._on.iconCallBack(this._action,this._indicator),!0)}}]),t}(),S=function(){function t(e,i){var a;return P(this,t),(a=T(this,M(t).call(this,e,i,"set")))._image.src=e._theme?m:A,a}return D(t,R),L(t,[{key:"draw",value:function(t){this._isActive?this._image.src=this.kline._theme?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAilBMVEUAAABgn99ZmvlZmfJamPNZl/NYmPRal/hamPVZlfVZlPNZl/ZZmPZam/RZlvVZmfRYl/NXl/JXmPJYl/JWl/JYmfRYlvFZmPJYmPJXmPJYl/JYmPJXl/NYmPNYl/BYl/JXmPJYmPRXl/JXmPFXl/FYl/JWmPJXl/FXl/JXmPFXl/JYl/JXmPJXl/HweVw3AAAALXRSTlMACCs8PkJDR0pNVlZZXmRwgIyNjp2do6OrsrO0uLq9wMjI0Nzn7O/x9vn7/f6TKw2BAAAA4klEQVQ4y53T13LCMBCFYdnmp4neQ8BgwPTz/q+XmwwWNrCZnOtvRqstzkVxwpskceRcVONDapGL+ZjYJZ9B4jBSgOYwSPMFmCvIvAo6l/vq+zer+6VTARuti4fX2pRBX+d2Adpn9Z9Bfa9JWPtE+/oTGOvQCEHjoHEIWkcNAHya56kHGOjYCsBCOwB/kqSTB9hpUYDu9dYDSJV5nykF6N2u3QfI9AVALg9eOQBLZQ+w1fIV2P79CbNI+5uMqo0alVs9DcG03GpzWPa47YVhFq7c7D9L+27tzcMxT888Xuv8fwDqXSyMbP2FKAAAAABJRU5ErkJggg==":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAilBMVEUAAACAv/9VlfRVk/BalvBVlfFTkfFJkvNEk/RFivo4hvY3iPc1hvc0hfgsg/grgPkjgPoifP0hfP0hff0fe/0fev0cfP0be/0ce/8aef0aev0aev0bef4aev8aev4ZeP8Yef4Yef4Xef8YeP8WeP8WeP8WeP8Vd/8Wd/8Wd/8Vd/8VeP8Vd/8Vd/9abGtKAAAALXRSTlMABBghIiQlKi0wOzw/RUxabHl7fI2OlJWdpqepra+ytr/AyNbj6ezv9fj6/f4dJ2ngAAAA4klEQVQ4y53T13LCMBCFYdnmp4neQ8BgwPTz/q+XmwwWNrCZnOtvRqstzkVxwpskceRcVONDapGL+ZjYJZ9B4jBSgOYwSPMFmCvIvAo6l/vq+zer+6VTARuti4fX2pRBX+d2Adpn9Z9Bfa9JWPtE+/oTGOvQCEHjoHEIWkcNAHya56kHGOjYCsBCOwB/kqSTB9hpUYDu9dYDSJV5nykF6N2u3QfI9AVALg9eOQBLZQ+w1fIV2P79CbNI+5uMqo0alVs9DcG03GpzWPa47YVhFq7c7D9L+27tzcMxT888Xuv8fwDqXSyMbP2FKAAAAABJRU5ErkJggg==":this._image.src=this.kline._theme?m:A,t.save(),t.drawImage(this._image,this._posix,this._posiy,this._width,this._height),t.restore()}}]),t}(),N=function(){function t(e,i){var a;return P(this,t),(a=T(this,M(t).call(this,e,i,"close")))._image.src=e._theme?p:k,a}return D(t,R),L(t,[{key:"draw",value:function(t){this._isActive?this._image.src=this.kline._theme?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAARVBMVEUAAABgn99ZmvlZmfJamPNZl/NYmPRZmPhamPVbl/JZmPJYmfJYmPNZmPNYl/JYmPJXmPJXl/FXmPJXl/FXl/JXmPJXl/FZ6QGwAAAAFnRSTlMACCs8PkJDTU9ReXqmqrG3v9/o9fr6lJGRogAAAKpJREFUOMu1k+sOwyAIRlFrW2tv9sL7P+rM0k3ATZNl5afnROSLACht7JcyWgGoxhaqUaBtsTSYsmDAVuqPQtvR4z4T2iW4xP0+SKELmAx/4Ji1cMmIfPrwyLfBOJ3iMjhnYz4NwXkO0dhOzkVQbkOcS0n6E5HmIYXYfw7CAM4nmocUrvcLAySXBmRcGC+h38n80VizG4aR5rG6G77c70J1caqrV13e2vo/AGfRGNsBtVgYAAAAAElFTkSuQmCC":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAARVBMVEUAAACAv/9VlfRVk/BalvBVlfFTkfFEjfVBjPU9ifYmffwmfvodev0cev0aef0bev4Zef4Xd/4Xd/4VeP8WeP8Vd/8Vd/+22k4uAAAAFnRSTlMABBghIiQlMTM2ZGWYnaWstdrl8/n6FMJCPwAAAKpJREFUOMu1k+sOwyAIRlFrW2tv9sL7P+rM0k3ATZNl5afnROSLACht7JcyWgGoxhaqUaBtsTSYsmDAVuqPQtvR4z4T2iW4xP0+SKELmAx/4Ji1cMmIfPrwyLfBOJ3iMjhnYz4NwXkO0dhOzkVQbkOcS0n6E5HmIYXYfw7CAM4nmocUrvcLAySXBmRcGC+h38n80VizG4aR5rG6G77c70J1caqrV13e2vo/AGfRGNsBtVgYAAAAAElFTkSuQmCC":this._image.src=this.kline._theme?p:k,t.save(),t.drawImage(this._image,this._posix,this._posiy,this._width,this._height),t.restore()}}]),t}(),O=function(){function t(e,i){var a;return P(this,t),(a=T(this,M(t).call(this,e,i,"hide")))._image.src=e._theme?_:C,a}return D(t,R),L(t,[{key:"draw",value:function(t){this.kline._showIndicatorText?this._isActive?this._image.src=this.kline._theme?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAIVBMVEUAAABgn99ZmvlZmfJamPNZl/Nbl/JamPNZl/NXl/FXl/FxIKrUAAAACnRSTlMACCs8PkJRUpDfZECx5AAAAHVJREFUKM9jYFQORQJGAgwioSjAkUEVVSCIwRRVIJghFA3QUaANws6ACUSsTAUxw2a1QgXCZk0DCWSCxRngTKgwQyhMCUQB1BYgB6oAKgDkQRXA3JG5EqoAJhA2C6oA7tLKaWhOD0+lbwBhRBRGVGJENnpyAADryq78/8xAhgAAAABJRU5ErkJggg==":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAIVBMVEUAAACAv/9VlfRVk/BalvBVlfE5jvo9ifYgfPsXd/4Vd/8h6Ma8AAAACnRSTlMABBghIiQ2Nn/arfochwAAAHVJREFUKM9jYFQORQJGAgwioSjAkUEVVSCIwRRVIJghFA3QUaAdwq6ACUSsLAUxw2e1QgXCZ00HCVSCxRngTKgwQyhMCUQB1BYgB6oAKgDkQRXA3FG5EqoAJhA+C6oA7tLM6WhODyulbwBhRBRGVGJENnpyAADvGK/qe3eqMAAAAABJRU5ErkJggg==":this._image.src=this.kline._theme?_:C:this._isActive?this._image.src=this.kline._theme?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAHlBMVEUAAABgn99ZmvlZmfJamPNZl/Nbl/JZl/NXl/FXl/EZicCeAAAACXRSTlMACCs8PkJRkN873L0tAAAAa0lEQVQoz2NgVA5FAkYCDCKhKMCRQRVVIIjBFFUgmCEUDRAtUIYmED4jFVUgrLMNTUsGXAlUAKEEZgtcCUwArgTuDpgSuABMCW4BdC0YhqJbi+EwdKdjeA7D+xgBRFogY0QURlRiRDZ6cgAAJ+KtURSett4AAAAASUVORK5CYII=":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAHlBMVEUAAACAv/9VlfRVk/BalvBVlfE9ifYgfPsXd/4Vd/8XKNrLAAAACXRSTlMABBghIiQ2f9oV+RK9AAAAa0lEQVQoz2NgVA5FAkYCDCKhKMCRQRVVIIjBFFUgmCEUDRAtUIYmED4jFVUgrLMNTUsGXAlUAKEEZgtcCUwArgTuDpgSuABMCW4BdC0YhqJbi+EwdKdjeA7D+xgBRFogY0QURlRiRDZ6cgAAJ+KtURSett4AAAAASUVORK5CYII=":this._image.src=this.kline._theme?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAHlBMVEUAAAD////////////////////Q0NCanJ6MjZGJio3p2B0DAAAACXRSTlMABBUcHR8xfNl/+iMFAAAAa0lEQVQoz2NgVA5FAkYCDCKhKMCRQRVVIIjBFFUgmCEUDRAtUIYmED4jFVUgrLMNTUsGXAlUAKEEZgtcCUwArgTuDpgSuABMCW4BdC0YhqJbi+EwdKdjeA7D+xgBRFogY0QURlRiRDZ6cgAAJ+KtURSett4AAAAASUVORK5CYII=":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAHlBMVEUAAADY6+vg4Off4ube4Ofe4OfV2d++wcitsbuprLYkacCaAAAACXRSTlMADUtoa3N+reemCpvPAAAAa0lEQVQoz2NgVA5FAkYCDCKhKMCRQRVVIIjBFFUgmCEUDRAtUIYmED4jFVUgrLMNTUsGXAlUAKEEZgtcCUwArgTuDpgSuABMCW4BdC0YhqJbi+EwdKdjeA7D+xgBRFogY0QURlRiRDZ6cgAAJ+KtURSett4AAAAASUVORK5CYII=",t.save(),t.drawImage(this._image,this._posix,this._posiy,this._width,this._height),t.restore()}}]),t}();function V(t){return(V="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 W(t,e,i){return(W="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=Y(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 B(t,e){return!e||"object"!==V(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function Y(t){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function E(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&&function(t,e){(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function F(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function X(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function H(t,e){for(var i=0;i<e.length;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 U(t,e,i){return e&&H(t.prototype,e),i&&H(t,i),t}var J=function(){function t(e,i,a){X(this,t),this._minValue=i||1,this._maxValue=a||1e3,this._value=this._defaultValue=e}return U(t,[{key:"getValue",value:function(){return this._value}},{key:"setValue",value:function(t){this._value=t}}]),t}(),z=function(){function t(e,i){X(this,t),this._params=[],this._outputs=[],this.kline=e,this.chart=i,this.defaultParameter(),this.calc()}return U(t,[{key:"addParameter",value:function(t){this._params.push(t)}},{key:"getParameter",value:function(t){return this._params[t]}},{key:"defaultParameter",value:function(){this._params=[];for(var e=this.getName(),i=this.kline.getTheme(),a=this.kline.getIndicatorConfig(e),n=this.params(a?a.input:t.IndicatorConfig(i)[e].input),r=0;r<n.length;r++)this.addParameter(new J(n[r].value))}},{key:"updateParameter",value:function(t){for(var e=0;e<this._params.length;e++)this._params[e].setValue(t[e]);this.calc()}},{key:"defaultInputOutput",value:function(t){for(var e=0;e<this._params.length;e++)this._params[e].setValue(t.input[e]);this.calc()}},{key:"addOutput",value:function(e){var i=this.kline,a=this.getName(),n=i.getTheme(),r=i._indicatorParams?i._indicatorParams[a].output:t.IndicatorConfig(n)[a].output,s=r.findIndex((function(t){return t.index===e.index}));return this._outputs.push(Object.assign(e,r[s])),this}},{key:"getOutput",value:function(){return this._outputs}},{key:"getOutputAt",value:function(t,e){return 0===e||e?this._outputs[t].data[e]:this._outputs[t]}},{key:"updateOutputAt",value:function(t,e,i){e>this._outputs[t].data.length-1?this._outputs[t].data.push(i):this._outputs[t].data[e]=i}},{key:"modifyIndicatorOutput",value:function(t,e){var i=this._outputs.findIndex((function(t){return t.index===e.index}));-1<i&&(this._outputs[i]=Object.assign(this._outputs[i],e))}},{key:"clearOutput",value:function(){this._outputs=[]}},{key:"calcMaxMinVal",value:function(){for(var t=this.kline,e=t.zoom.getItemFirst(),i=t.zoom.getItemLast(),a=-g.getJsMaxValue(),n=g.getJsMaxValue(),r=0;r<this._outputs.length;r++)for(var s=this._outputs[r].data,o=i;o<e;o++)isNaN(s[o])||(a=Math.max(a,s[o]),n=Math.min(n,s[o]));return[a,n]}},{key:"drawIndicatorRang",value:function(){}},{key:"draw",value:function(t,e){for(var i=this.kline,a=(i.getTheme(),i.zoom.getItemFirst()),n=[],r=i.zoom.getItemLast();r<a;r++)for(var s=0;s<this._outputs.length;s++){n[s]||n.push({data:[],lineColor:"",lineWidth:""});var o=this._outputs[s].data[r];isNaN(o)||(n[s].data.push({x:i.zoom.getX(r)+i.zoom.getItemHalfWidth(),y:e.getY(o)-.5}),n[s].lineColor=this._outputs[s].lineColor,n[s].lineWidth=this._outputs[s].lineWidth,n[s].lineVisible=this._outputs[s].lineVisible)}for(var h=0;h<n.length;h++)n[h].lineVisible&&g.drawBrokenLine(t,n[h].lineColor,n[h].data,n[h].lineWidth)}},{key:"drawOverlay",value:function(t,e){e._posi.textY+=8;var i=this.kline,a=i.manage.getHover();a<0&&(a=i.getDataLen()-1);for(var n=i.getTheme(),r=[],s=[],o=0;o<this._params.length;o++){var h=this.getParameter(o).getValue();h&&s.push(h)}r.push({val:"".concat(this.getName(),"(").concat(s.join(","),")")}),"VOLUME"===this.getName()&&r.push({val:"VOLUME:".concat(g.numberSeparator(e.valToFixed(this.kline.getDataAt(a).volume)))});for(var l=0;l<this._outputs.length;l++){var c=this._outputs[l];!isNaN(c.data[a])&&c.lineVisible&&r.push({val:"".concat(c.name,":").concat("VOLUME"===this.getName()?g.numberSeparator(e.valToFixed(c.data[a])):e.valToFixed(c.data[a])),color:c.lineColor||n.getColors("Indicator",l)})}i._showIndicatorText&&(this.drawText(t,27,e._posi.textY,r,e,27),e._posi.textY=e._posi.textY+10)}},{key:"drawText",value:function(t,e,i,a,n,r){for(var s=this.kline,o=s.manage,h=this.getIcons(),l="Consolas",c=this.kline.getTheme(),u=o.getViewWidth(),d=0;d<a.length;d++){var v=a[d].color||c.getColors("IndicatorName"),f=a[d].val,y=g.calcTextWidth(t,f,!1,l,8);if(u-e-y<0&&(e=r,i+=n._lineH,n._posi.textY+=n._lineH),i+n._lineH>=n.getMinusBarY2())return;g.drawText(t,f,v,e,i,!1,l,"left"),e+=y,0===d&&0===s._viewType&&(h[0].setParams({x:e,y:i-2,width:16,height:16}),h[0].draw(t),h[1].setParams({x:e+22,y:i-2,width:16,height:16}),h[1].draw(t),e+=44)}}}],[{key:"IndicatorConfig",value:function(t){var e;return F(e={MA:{input:[7,30,0,0,0,0,0,0,0,0],output:new Array(10).fill(0).map((function(e,i){return{index:i,label:"MA"+(i+1),lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}}))},EMA:{input:[7,30,0,0,0,0,0,0,0,0],output:new Array(10).fill(0).map((function(e,i){return{index:i,label:"EMA"+(i+1),lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}}))},BOLL:{input:[20,2],output:[{index:0,label:"MID",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"UPPER",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1},{index:2,label:"UPPER",lineWidth:1,lineColor:t.getColors("Indicator",2),lineVisible:1}]},SAR:{input:[4,2,20],output:[]},DEPTH:{input:[],output:[]},VOLUME:{input:[5,10,0,0,0,0],output:new Array(6).fill(0).map((function(e,i){return{label:"MA"+(i+1),index:i,lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}}))},MACD:{input:[12,26,9],output:[{index:0,label:"DIF",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"DEA",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1},{index:2,label:"MACD"}]},KDJ:{input:[9,3,3],output:[{index:0,label:"K",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"D",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:2,label:"J",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1}]},OBV:{input:[30],output:[{index:0,label:"OBV",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"MAOBV",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1}]},RSI:{input:[6,12,24],output:new Array(10).fill(0).map((function(e,i){return{index:i,label:"RSI"+(i+1),lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}})).concat([{index:3,label:"上限",lineWidth:1,lineColor:t.getColors("LimitLine"),lineVisible:1},{index:4,label:"下限",lineWidth:1,lineColor:t.getColors("LimitLine"),lineVisible:1},{index:5,label:"背景",lineColor:t.getColors("BetweenBg"),lineVisible:1}]),maxLimit:70,minLimit:30},TRIX:{input:[12,9],output:[{index:0,label:"TRIX",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"MATRIX",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1}]},WR:{input:[10,6],output:new Array(10).fill(0).map((function(e,i){return{index:i,label:"WR"+(i+1),lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}}))},CCI:{input:[20],output:[{index:0,label:"CCI",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1}]},ROC:{input:[12,6],output:[{index:0,label:"ROC",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"MAROC",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1}]},ATR:{input:[14],output:[{index:0,label:"ATR",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1}]},DMI:{input:[14,6],output:[{index:0,label:"PDI",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"MDI",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1},{index:2,label:"ADX",lineWidth:1,lineColor:t.getColors("Indicator",2),lineVisible:1},{index:3,label:"ADXR",lineWidth:1,lineColor:t.getColors("Indicator",3),lineVisible:1}]},VR:{input:[26,2],output:[{index:0,label:"VR",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"MAVR",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1}]},PSY:{input:[12,6],output:[{index:0,label:"PSY",lineWidth:1,lineColor:t.getColors("Indicator",0),lineVisible:1},{index:1,label:"MAPSY",lineWidth:1,lineColor:t.getColors("Indicator",1),lineVisible:1}]},BIAS:{input:[6,12,24],output:new Array(10).fill(0).map((function(e,i){return{index:i,label:"RSI"+(i+1),lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}}))},BRAR:[26],Yang:[7,14]},"DEPTH",{input:[6,12,24],output:new Array(10).fill(0).map((function(e,i){return{index:i,label:"RSI"+(i+1),lineWidth:1,lineColor:t.getColors("Indicator",i),lineVisible:1}}))}),F(e,"ORDER",[20]),e}},{key:"calcMA",value:function(t,e){for(var i=0,a=e.length-1;a>=e.length-t;a--)i+=e[a];return i/t}},{key:"calcEMA",value:function(t,e,i){return(e*(t-1)+2*i)/(t+1)}},{key:"calcTR",value:function(t,e,i){return Math.max(t-e,Math.max(Math.abs(t-i),Math.abs(e-i)))}},{key:"calcDX",value:function(t,e,i){var a=Math.abs(e[t]-i[t])/(e[t]+i[t])*100;return isNaN(a)?0:a}},{key:"calcDM",value:function(t,e){if(t<1)return[0,0];var i=e[t-1],a=e[t],n=[a.high-i.high,i.low-a.low];return(n[0]<0||n[0]<=n[1])&&(n[0]=0),(n[1]<0||n[1]<=n[0])&&(n[1]=0),n}},{key:"calc3Volume",value:function(t,e){var i=e[t].close-e[t-1].close,a=e[t].volume;return 0<i?[a,0,0]:i<0?[0,a,0]:[0,0,a]}}]),t}(),j=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"MAVOL"+(i+1),value:t[i]});return e}},{key:"calc",value:function(){this.clearOutput();for(var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=0;a<this._params.length;a++){var n=this.getParameter(a).getValue();if(!(0===n||i<n)){for(var r=[],s=0,o=[];s<i;s++)s<n-1?(o.push(e[s].close),r.push(NaN)):(o.push(e[s].close),r.push(z.calcMA(n,o)));this.addOutput({index:a,name:this.getName()+n,data:r})}}}},{key:"update",value:function(){for(var t=Init.instance.getData(),e=t.length,i=0,a=0;i<this._params.length;i++){var n=this.getParameter(i).getValue();if(!(0===n||e<n)){for(var r=e-n,s=[];r<e;r++)s.push(t[r].close);this.updateOutputAt(a,e-1,z.calcMA(n,s)),a++}}}},{key:"getName",value:function(){return"MA"}}]),t}(),G=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"EMA"+(i+1),value:t[i]});return e}},{key:"calc",value:function(){this.clearOutput();for(var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=0;a<this._params.length;a++){var n=this.getParameter(a).getValue();if(!(n<=0||i<n)){var r=[],s=[];r.push(e[0].close),s.push(NaN);for(var o=1;o<e.length;o++){var h=z.calcEMA(n,r[o-1],e[o].close);r.push(h),o<n-1?s.push(NaN):s.push(h)}this.addOutput({index:a,name:this.getName()+n,data:s})}}}},{key:"update",value:function(){for(var t=Kline.instance.data,e=t.length,i=0,a=0;i<this._params.length;i++){var n=this.getParameter(i)._value;if(!(0===n||e<n)){var r=this.getOutputAt(i).data.length;r===e&&r--;var s=z.calcEMA(n,this.getOutputAt(i,r-1),t[e-1].close);this.updateOutputAt(a,e-1,s),a++}}}},{key:"getName",value:function(){return"EMA"}}]),t}(),K=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"MID",value:t[0]},{type:"带宽",value:t[1]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue();if(!(0===a||i<a)){for(var r=[],s=[],o=[],h=0,l=[];h<i;h++)if(h<a-1)l.push(e[h].close),r.push(NaN),s.push(NaN),o.push(NaN);else{l.push(e[h].close),r.push(z.calcMA(a,l));for(var c=0,u=h-a+1;u<=h;u++)c+=Math.pow(e[u].close-r[h],2);c=Math.sqrt(c/a),s.push(r[h]+c*n),o.push(r[h]-c*n)}this.addOutput({index:0,name:"MID",data:r}),this.addOutput({index:1,name:"UPPER",data:s}),this.addOutput({index:2,name:"UPPER",data:o})}}},{key:"update",value:function(){var t=Kline.instance.data,e=t.length,i=this.getParameter(0)._value,a=this.getParameter(1)._value;if(!(0===i||e<i)){for(var n=e-i,r=[];n<e;n++)r.push(t[n].close);var s=z.calcMA(i,r),o=0;for(n=e-i;n<e;n++)o+=Math.pow(t[n].close-s,2);o=Math.sqrt(o/i);var h=g.priceRule(s+o*a),l=g.priceRule(s-o*a);this.updateOutputAt(0,e-1,s),this.updateOutputAt(1,e-1,h),this.updateOutputAt(2,e-1,l)}}},{key:"getName",value:function(){return"BOLL"}}]),t}(),Q=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"天数",value:t[0]},{type:"加速因子",value:t[1]},{type:"加速极限",value:t[2]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue()/100,r=this.getParameter(2).getValue()/100;if(!(0===a||i<a)){for(var s=[],o=0;o<a;o++)s.push(NaN);var h=e[a-1];if(1===a){if(1===i)return;h=e[1]}for(var l=h.close>e[0].close,c=n,u=l?h.high:h.low,d=l?g.getJsMaxValue():-g.getJsMaxValue(),v=0;v<a;v++)d=l?Math.min(d,e[v].low):Math.max(d,e[v].high);for(var f=Math.max(2,a);f<i;f++){if(h=e[f],l)if(d>h.low){l=!1,c=n,u=h.low,d=-g.getJsMaxValue();for(var y=0;y<a;y++)d=Math.max(d,e[f-y].high)}else h.close>e[f-1].close&&(c=Math.min(c+n,r)),d=Math.min(h.low,d+c*(u-d)),u=h.high;else if(d<h.high){l=!0,c=n,u=h.high,d=g.getJsMaxValue();for(var p=0;p<a;p++)d=Math.min(d,e[f-p].low)}else h.close<e[f-1].close&&(c=Math.min(c+n,r)),d=Math.max(h.high,d+c*(u-d)),u=h.low;s.push(d)}this.addOutput({name:this.getName(),data:s})}}},{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=i.zoom.getItemLast();r<n;r++)for(var s=0;s<this._outputs.length;s++){var o=this._outputs[s].data[r];if(!isNaN(o)){var h=i.zoom.getX(r)+i.zoom.getItemHalfWidth(),l=e.getY(o)-.5,c=Math.floor(i.zoom.getItemWidth()/2);4<c?c=4:c<.5&&(c=.5),g.drawArc(t,a.getColors("SAR"),!1,h,l,c)}}}},{key:"getName",value:function(){return"SAR"}}]),t}(),q=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"MA"+(i+1),value:t[i]});return e}},{key:"calc",value:function(){this.clearOutput();for(var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=0;a<this._params.length;a++){var n=this.getParameter(a).getValue();if(!(0===n||i<n)){for(var r=[],s=0,o=[];s<i;s++)s<n-1?(o.push(e[s].volume),r.push(NaN)):(o.push(e[s].volume),r.push(z.calcMA(n,o)));this.addOutput({index:a,name:"MAVOL"+n,data:r})}}}},{key:"calcMaxMinVal",value:function(){for(var t=this.kline,e=t.zoom.getItemFirst(),i=t.zoom.getItemLast(),a=-g.getJsMaxValue(),n=0;n<this._outputs.length;n++)for(var r=this._outputs[n].data,s=i;s<e;s++)a=Math.max(a,t.getDataAt(s).volume),isNaN(r[s])||(a=Math.max(a,r[s]));return[a,0]}},{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=[],s=i.zoom.getItemLast();s<n;s++){var o=i.getDataAt(s),h=i.zoom.getX(s),l=e.getY(o.volume),c=e.getY(0)-l,u=i.zoom.getItemWidth(),d=o.close>o.open?a.getColors("Positive"):a.getColors("Negative");g.drawRect(t,d,h,l,u,c);for(var v=0;v<this._outputs.length;v++){r[v]||r.push({data:[],lineColor:"",lineWidth:""});var f=this._outputs[v].data[s];isNaN(f)||(r[v].data.push({x:i.zoom.getX(s)+i.zoom.getItemHalfWidth(),y:e.getY(f)-.5}),r[v].lineColor=this._outputs[v].lineColor,r[v].lineWidth=this._outputs[v].lineWidth,r[v].lineVisible=this._outputs[v].lineVisible)}}for(var y=0;y<r.length;y++)r[y].lineVisible&&g.drawBrokenLine(t,r[y].lineColor,r[y].data,r[y].lineWidth)}},{key:"update",value:function(){for(var t=Kline.instance.data,e=t.length,i=0,a=0;i<this._params.length;i++){var n=this.getParameter(i).getValue();if(!(0===n||e<n)){for(var r=e-n,s=[];r<e;r++)s.push(t[r].volume);this.updateOutputAt(a,e-1,z.calcMA(n,s)),a++}}}},{key:"drawIndicatorRang",value:function(t,e){var i=this.kline,a=i.getLastData(),n=i.getTheme(),r=e.getViewWidth(),s=i.layout.getAxisWidth(),o=e.getY(a.volume);g.drawRect(t,"rgba(0,109,135, 0.75)",r,o-10,s,19),g.drawLine(t,n.getColors("IndexText"),r,o-.5,r+5,o-.5),g.drawText(t,g.numberRang(a.volume),n.getColors("IndexText"),r+10,o-6,!1,!1,"left")}},{key:"getName",value:function(){return"VOLUME"}}]),t}(),Z=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"短周期",value:t[0]},{type:"长周期",value:t[1]},{type:"移动平均周期",value:t[2]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue(),r=this.getParameter(2).getValue();if(!(0===a||i<a||0===n||i<n||0===r||i<r)){for(var s=e[0].close,o=e[0].close,h=0,l=0,c=0,u=[NaN],g=[NaN],d=[NaN],v=1;v<e.length;v++)c=2*((h=(s=z.calcEMA(a,s,e[v].close))-(o=z.calcEMA(n,o,e[v].close)))-(l=(l*(r-1)+2*h)/(r+1))),v<n-1?(u.push(NaN),g.push(NaN),d.push(NaN)):v<n+r-1?(u.push(h),g.push(NaN),d.push(NaN)):(u.push(h),g.push(l),d.push(c));this.addOutput({index:0,name:"DIF",data:u}),this.addOutput({index:1,name:"DEA",data:g}),this.addOutput({name:"MACD",data:d})}}},{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=[],s=i.zoom.getItemLast();s<n;s++)for(var o=i.zoom.getX(s),h=0;h<this._outputs.length;h++){r[h]||r.push({data:[],lineColor:"",lineWidth:""});var l=parseFloat(this._outputs[h].data[s]),c=0===s?l:parseFloat(this._outputs[h].data[s-1]);if(!isNaN(l)){var u=e.getY(l);if(2===h){var d=i.zoom.getItemWidth(),v=e.getY(0)-u,f=0<l?a.getColors("Positive"):a.getColors("Negative");0===v&&(v=0<l?-1:1),c<l?g.drawRectFrame(t,f,o,u,d,v):(u-=0<l?0:1,g.drawRect(t,f,o,u,d,v))}else r[h].data.push({x:o+i.zoom.getItemHalfWidth(),y:u-.5}),r[h].lineColor=this._outputs[h].lineColor,r[h].lineWidth=this._outputs[h].lineWidth,r[h].lineVisible=this._outputs[h].lineVisible}}for(var y=0;y<r.length;y++)r[y].lineVisible&&g.drawBrokenLine(t,r[y].lineColor,r[y].data,r[y].lineWidth)}},{key:"getName",value:function(){return"MACD"}}]),t}(),$=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"计算周期",value:t[0]},{type:"移动平均周期1",value:t[1]},{type:"移动平均周期2",value:t[2]}]}},{key:"drawIndicatorRang",value:function(t,e){for(var i=this.kline.getTheme(),a=e.getViewWidth(),n=[20,50,80],r=0;r<n.length;r++){var s=e.getY(n[r]);g.drawDotted(t,i.getColors("IndicatorRangLine"),0,s-.5,a-1,s-.5,3,6)}}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue(),r=this.getParameter(2).getValue();if(!(0===a||i<a||0===n||i<n||0===r||i<r)){for(var s,o,h,l=[],c=[],u=[],d=0;d<i;d++){for(var v=-g.getJsMaxValue(),f=g.getJsMaxValue(),y=0;d<a-1&&y<=d||a-1<=d&&y<a;y++)v=Math.max(v,e[d-y].high),f=Math.min(f,e[d-y].low);var p=v===f?0:(e[d].close-f)/(v-f)*100;h=3*(s=((s=s||p)*(n-1)+p)/n)-2*(o=((o=o||p)*(r-1)+s)/r),d<a-1?(l.push(NaN),c.push(NaN),u.push(NaN)):(l.push(s),c.push(o),u.push(h))}this.addOutput({index:0,name:"K",data:l}),this.addOutput({index:1,name:"D",data:c}),this.addOutput({index:2,name:"J",data:u})}}},{key:"getName",value:function(){return"KDJ"}}]),t}(),tt=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"MAOBV",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=this.getParameter(0).getValue();if(!(0===a||i<a)){for(var n=[e[0].volume],r=[NaN],s=1;s<i;s++)e[s].close>e[s-1].close?n.push(n[s-1]+e[s].volume):e[s].close<e[s-1].close?n.push(n[s-1]-e[s].volume):n.push(n[s-1]),s<a-1?r.push(NaN):r.push(z.calcMA(a,n));this.addOutput({index:0,name:this.getName(),data:n}),this.addOutput({index:1,name:"MA"+this.getName(),data:r})}}},{key:"getName",value:function(){return"OBV"}}]),t}(),et=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"RES"+(i+1),value:t[i]});return e}},{key:"drawIndicatorRang",value:function(t,e){var i,a=this.kline,n=a.getTheme(),r=e.getViewWidth(),s=this.getName(),o=a._indicatorParams&&a._indicatorParams.RSI.maxLimit||z.IndicatorConfig(n)[s].maxLimit;a._indicatorParams&&(i=void 0!==a._indicatorParams.RSI.minLimit?a._indicatorParams.RSI.minLimit:z.IndicatorConfig(n)[s].minLimit);var h=e.getY(o),l=e.getY(i),c=a._indicatorParams?a._indicatorParams[s].output:z.IndicatorConfig(n)[s].output;if(c[3].lineVisible&&(g.drawDotted(t,c[3].lineColor,0,h-.5,r-1,h-.5,3,6,c[3].lineWidth),g.drawLine(t,n.getColors("Frame"),r,h-.5,r+5,h-.5),g.drawText(t,o.toFixed(2),n.getColors("RangText"),r+10,h-6,!1,!1,"left")),c[4].lineVisible&&(g.drawDotted(t,c[4].lineColor,0,l-.5,r-1,l-.5,3,6,c[4].lineWidth),g.drawLine(t,n.getColors("Frame"),r,l-.5,r+5,l-.5),g.drawText(t,i.toFixed(2),n.getColors("RangText"),r+10,l-6,!1,!1,"left")),c[5].lineVisible){var u=r-1,d=l-h-1;g.drawRect(t,c[5].lineColor,0,h,u,d)}}},{key:"calc",value:function(){this.clearOutput();for(var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=0;a<this._params.length;a++){var n=this.getParameter(a).getValue();if(!(0===n||i<n)){for(var r=[NaN],s=0,o=0,h=1;h<e.length;h++){var l=e[h].close-e[h-1].close;h<n?(0<l?s+=l:l<0&&(o-=l),r.push(NaN)):(h===n?0<l?s+=l:l<0&&(o-=l):0<l?(s=s*(n-1)+l,o*=n-1):l<0&&(s*=n-1,o=o*(n-1)-l),s/=n,o/=n,r.push(s/(s+o)*100))}this.addOutput({index:a,name:this.getName()+(a+1),data:r})}}}},{key:"getName",value:function(){return"RSI"}}]),t}(),it=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"TRIX",value:t[0]},{type:"MATRIX",value:t[1]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=(t.getTheme(),t.getData()),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue();if(!(a<=0||i<a)){for(var r=[NaN],s=[NaN],o=[e[0].close],h=[e[0].close],l=[e[0].close],c=1;c<e.length;c++)o.push(z.calcEMA(a,o[c-1],e[c].close)),h.push(z.calcEMA(a,h[c-1],o[c])),l.push(z.calcEMA(a,l[c-1],h[c])),r.push((l[c]-l[c-1])/l[c-1]*100),c<n?s.push(NaN):s.push(z.calcMA(n,r));this.addOutput({index:0,name:this.getName(),data:r}),this.addOutput({index:1,name:"MA"+this.getName(),data:s})}}},{key:"getName",value:function(){return"TRIX"}}]),t}(),at=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"WR"+(i+1),value:t[i]});return e}},{key:"calc",value:function(){this.clearOutput();for(var t=this.kline,e=t.getData(),i=t.getDataLen(),a=0;a<this._params.length;a++){var n=this.getParameter(a).getValue();if(!(0===n||i<n)){for(var r=[],s=0;s<i;s++)if(n<=s){for(var o=-g.getJsMaxValue(),h=g.getJsMaxValue(),l=0;l<n;l++)o=Math.max(o,e[s-l].high),h=Math.min(h,e[s-l].low);r.push((o-e[s].close)/(o-h)*100)}else r.push(NaN);this.addOutput({index:a,name:this.getName()+(a+1),data:r})}}}},{key:"getName",value:function(){return"WR"}}]),t}(),nt=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"CCI",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue();if(!(0===a||i<a)){for(var n=[],r=0,s=[];r<i;r++)if(s.push((e[r].high+e[r].low+e[r].close)/3),r<a-1)n.push(NaN);else{for(var o=z.calcMA(a,s),h=0,l=0;l<a;l++)h+=Math.abs(s[r-l]-o);n.push((s[r]-o)/(h/a)/.015)}this.addOutput({index:0,name:this.getName(),data:n})}}},{key:"getName",value:function(){return"CCI"}}]),t}(),rt=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"ROC",value:t[0]},{type:"MAROC",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue();if(!(0===a||i<a)){for(var r=[],s=[],o=0;o<i;o++)o<a?(r.push(NaN),s.push(NaN)):(r.push((e[o].close-e[o-a].close)/e[o-a].close*100),a+n-1<o?s.push(z.calcMA(n,r)):s.push(NaN));this.addOutput({index:0,name:this.getName(),data:r}),this.addOutput({index:1,name:"MA"+this.getName(),data:s})}}},{key:"getName",value:function(){return"ROC"}}]),t}(),st=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"ATR",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue();if(!(0===a||i<a)){for(var n=[e[0].high-e[0].low],r=[NaN],s=1;s<i;s++)n.push(z.calcTR(e[s].high,e[s].low,e[s-1].close)),s<a-1?r.push(NaN):r.push(z.calcMA(a,n));this.addOutput({index:0,name:this.getName(),data:r})}}},{key:"getName",value:function(){return"ATR"}}]),t}(),ot=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"DI",value:t[0]},{type:"ADX",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue();if(!(0===a||i<a)){for(var r=[e[0].high-e[0].low],s=[NaN],o=[NaN],h=[NaN],l=[NaN],c=0,u=0,g=0,d=r[0],v=1;v<i;v++){r.push(z.calcTR(e[v].high,e[v].low,e[v-1].close));var f=z.calcDM(v,e);if(c+=f[0],u+=f[1],d+=r[v],a<=v){var y=z.calcDM(v-a,e);c-=y[0],u-=y[1],d-=r[v-a]}0===d?(s.push(NaN),o.push(NaN)):(s.push(c/d*100),o.push(u/d*100)),g+=z.calcDX(v,s,o),n<=v?(g-=z.calcDX(v-n,s,o),h.push(g/n)):h.push(NaN),2*n<=v?l.push((h[v]+h[v-n])/2):l.push(NaN)}this.addOutput({index:0,name:"PDI",data:s}),this.addOutput({index:1,name:"MDI",data:o}),this.addOutput({index:2,name:"ADX",data:h}),this.addOutput({index:3,name:"ADXR",data:l})}}},{key:"getName",value:function(){return"DMI"}}]),t}(),ht=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"VR",value:t[0]},{type:"MAVR",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var t=this.kline,e=t.getData(),i=t.getDataLen(),a=this.getParameter(0).getValue(),n=this.getParameter(1).getValue();if(!(0===a||i<a)){for(var r=e[0].volume,s=e[0].volume,o=e[0].volume,h=[NaN],l=[NaN],c=1;c<i;c++){var u=z.calc3Volume(c,e);r+=u[0],s+=u[1],o+=u[2],a<c&&(r-=(u=z.calc3Volume(c-a,e))[0],s-=u[1],o-=u[2]),0===s&&0===o?h.push(NaN):h.push((r+.5*o)/(s+.5*o)*100),c<=n+1?l.push(NaN):l.push(z.calcMA(n,h))}this.addOutput({index:0,name:this.getName(),data:h}),this.addOutput({index:1,name:"MA"+this.getName(),data:l})}}},{key:"getName",value:function(){return"VR"}}]),t}(),lt=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,null,[{key:"isUp",value:function(t,e){return e[t].close>e[t-1].close}}]),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"PSY",value:t[0]},{type:"MAPSY",value:t[0]}]}},{key:"calc",value:function(){this.clearOutput();var e=this.kline,i=e.getData(),a=e.getDataLen(),n=this.getParameter(0).getValue(),r=this.getParameter(1).getValue();if(!(0===n||a<n)){for(var s=0,o=[NaN],h=[NaN],l=1;l<a;l++)t.isUp(l,i)&&s++,n<l&&t.isUp(l-n,i)&&s--,o.push(s/n*100),r<=l?h.push(z.calcMA(r,o)):h.push(NaN);this.addOutput({index:0,name:this.getName(),data:o}),this.addOutput({index:1,name:"MA"+this.getName(),data:h})}}},{key:"getName",value:function(){return"PSY"}}]),t}(),ct=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"BIAS"+(i+1),value:t[i]});return e}},{key:"calc",value:function(){this.clearOutput();for(var t=this.kline,e=t.getData(),i=t.getDataLen(),a=0;a<this._params.length;a++){var n=this.getParameter(a).getValue();if(!(0===n||i<n)){for(var r=0,s=[],o=[],h=0;r<i;r++)o.push(e[r].close),h=z.calcMA(n,o),n-1<=r?s.push((o[r]-h)/h*100):s.push(NaN);this.addOutput({index:a,name:this.getName()+(a+1),data:s})}}}},{key:"getName",value:function(){return"BIAS"}}]),t}(),ut=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.creatIcons(),a}return E(t,z),U(t,[{key:"creatIcons",value:function(){var t=[];t.push(new S(this.kline,this)),t.push(new N(this.kline,this)),this._icons=t}},{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){for(var e=[],i=0;i<t.length;i++)e.push({type:"Yang"+(i+1),value:t[i]});return e}},{key:"calc",value:function(){this.clearOutput();for(var e=this.kline,i=e.getData(),a=e.getDataLen(),n=0;n<this._params.length;n++){var r=this.getParameter(n).getValue();if(!(0===r||a<r)){for(var s=[],o=0,h=[];o<a;o++)o<r-1?(h.push(i[o].high),s.push(NaN)):(h.push(i[o].high),s.push(t.caleYang(r,h,o)));this.addOutput({index:n,name:this.getName()+r,data:s})}}}},{key:"draw",value:function(e,i){W(Y(t.prototype),"draw",this).call(this,e,i);for(var a=this.kline,n=a.zoom.getItemFirst(),r=a.zoom.getItemLast(),s=a.getTheme(),o=r;o<n;o++){var h=a.getDataAt(o),l=a.zoom.getX(o),c=i.getY(h.close),u=i.getY(i.getMin())-c,d=a.zoom.getItemWidth(),v=h.close>h.open?s.getColors("Positive"):s.getColors("Negative");g.drawRect(e,v,l,c,d,u)}}},{key:"calcMaxMinVal",value:function(){for(var t=this.kline,e=t.zoom.getItemFirst(),i=t.zoom.getItemLast(),a=-g.getJsMaxValue(),n=g.getJsMaxValue(),r=0;r<this._outputs.length;r++)for(var s=this._outputs[r].data,o=i;o<e;o++)a=Math.max(a,t.getDataAt(o).close),n=Math.min(n,t.getDataAt(o).close),isNaN(s[o])||(a=Math.max(a,s[o]),n=Math.min(n,s[o]));return[a,n]}},{key:"getName",value:function(){return"Yang"}}],[{key:"caleYang",value:function(t,e,i){if(0<=i+1-t){for(var a=i,n=0,r=i-t;r<=a;r++)n+=e[r];return n/t}return NaN}}]),t}(),gt=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.kline=e,a.chart=i,a._width=i.getViewHeight(),a._height=e.layout.getAxisWidth()-10,a._axisHeight=0,a._pad=[0,0,0,0],a._point=[],a._radius=3,a._colors={asks:{color:"rgba(237, 101, 95, .39)",bg:[{step:1,color:"rgba(237, 101, 95, .39)"}]},bids:{color:"rgba(76, 184, 113, .39)",bg:[{step:1,color:"rgba(76, 184, 113, .39)"}]},text:"#9B9B9B"},a._asks=!0,a._bids=!0,a}return E(t,z),U(t,[{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"DEPTH",value:""}]}},{key:"close",value:function(t,e){"asks"===t&&(this._asks=e),"bids"===t&&(this._bids=e),this.draw()}},{key:"getX",value:function(t){return this.chart.getY(t)+Math.floor((this._width-this._pad[1]-this._pad[3])/(this._maxPrice-this._minPrice)*(t-this._minPrice)+this._pad[3])}},{key:"getY",value:function(t){return this.chart.getViewWidth()+Math.floor((this._height-this._axisHeight-this._pad[0]-this._pad[2])/this._maxCount*(this._maxCount-t)+this._pad[0])}},{key:"draw",value:function(t,e){this.drawMain(t,e)}},{key:"drawOverlay",value:function(t,e){this.kline.getTheme();var i="Consolas",a=this._hover;if(this._hover&&a){var n="价格: "+e.valToFixed(a.price),r="数量: "+g.orderCount(a.count),s=g.calcTextWidth(t,n,!1,i,0),o=g.calcTextWidth(t,r,!1,i,0),h=Math.max(s,o)+20,l=a.posiL-h,c=a.posiT;g.drawRect(t,"#000",l,c,h,40),g.drawText(t,n,"#fff",10+l,c+6,!1,"Consolas","left"),g.drawText(t,r,"#fff",10+l,c+20,!1,"Consolas","left")}}},{key:"calc",value:function(){}},{key:"drawMain",value:function(t,e){var i=this,a=this.kline;function n(n){if("asks"===n&&!i._asks||"bids"===n&&!i._bids)return"continue";var s=i._data[n];if(!s.length)return"continue";e._maxAndMinVal;var d=e.getMinusBarY2();s=s.filter((function(t){return e.getY(t[0])<d}));for(var v=g.getJsMaxValue(),f=-g.getJsMaxValue(),y=0;y<s.length;y++){var p=parseFloat(s[y][0]);f=Math.max(f,p),v=Math.min(v,p)}var m=a.getLastData().close,_=m,k=[],A=3e-4*m;if("asks"===n)for(;_<f;_+=A)k.push({type:n,floor:[_,_+A],order:[],count:0});else if("bids"===n)for(;v<_;_-=A)k.push({type:n,floor:[_-A,_],order:[],count:0});for(var x=0,w=0;w<s.length;w++)for(var C=0;C<k.length;C++)k[C].floor[0]<parseFloat(s[w][0])&&parseFloat(s[w][0])<=k[C].floor[1]&&(k[C].order.push(s[w]),k[C].count+=parseFloat(s[w][1]),x=Math.max(x,k[C].count));var b=void 0;"asks"===n&&(b=i._colors.asks.color,i._colors.asks.bg),"bids"===n&&(b=i._colors.bids.color,i._colors.bids.bg);for(var T=[],M=0;M<k.length;M++)T.push(k[M].count);var D=e.getY(k[k.length-1].floor[1])-e.getY(k[0].floor[0]),P=i._height,I=T;r.save(),h=I[o=0],I.forEach((function(t,e){o<t&&(o=t),t<h&&(h=t)})),l=P/(o-h),c=D/I.length,r.beginPath(),r.translate(e.getViewWidth()+i._height,e.getY(m)),r.rotate(Math.PI/2),r.lineTo(0,P),k.forEach((function(t,e){var i=c*(e-1),a=Math.floor(P-l*(I[e-1]-h)),n=c*(e-2),s=Math.floor(P-l*(I[e-2]-h)),o=c*e,u=Math.abs(Math.floor(P-l*(I[e]-h))),g=c*(e+1),d=Math.floor(P-l*(I[e+1]-h)),v=i+.1*(o-n),f=Math.abs(a+.1*(u-s)),y=o-.1*(g-i),p=Math.abs(u-.1*(d-a));0!==e?(1===e?(v=i+.1*(o-0),f=Math.abs(a+.1*(u-P))):e===I.length-1&&(y=o-.1*(o-i),p=Math.abs(u-.1*(u-a))),k[e].posi={price:parseFloat(k[e].floor[1]),count:I[e],cAx:v,cAy:f,cBx:y,cBy:p,nowX:o,nowY:u},u=Math.min(f,p,u),r.bezierCurveTo(v,f+.5,y,p+.5,o,u+.5)):r.lineTo(o,u)}));try{(u=r.createLinearGradient(0,0,0,D)).addColorStop(0,b),u.addColorStop(1,b),r.lineTo(D,P),r.lineTo(0,P),r.strokeStyle="rgba(0, 0, 0, 0)",r.stroke(),r.fillStyle=u,r.fill();for(var L=[],R=x.toFixed(6),S=(a.getPairName(),0);S<k.length;S++){var N=k[S].count.toFixed(6);k[S].posi&&k[S].posi.price,N===R&&L.push(S)}for(var O=0;O<L.length;O++){var V=L[O],W=V+1===k.length,B=W?V:V+1,Y=k[B].posi,E=W?Y.nowX:Y.cAx,F=W?Y.nowY:Y.cAy,X=e.getY(m)+E,H=e.getY(m)+E,U=e.getViewWidth()+P+F,J=e.getViewWidth()+P+F;i._point.push({price:k[B].posi.price,count:k[B].count,posiT:X,posiB:H,posiL:U,posiR:J}),E="bids"===n?E-i._radius:E+i._radius,F-=1*i._radius,g.drawArc(r,"red","red",E,F,i._radius,3)}}catch(n){console.log("error"),console.log(n)}t.restore()}this._data=this.kline._DEPTH,this._point=[];var r=t;for(var s in this._data){var o,h,l,c,u;n(s)}}},{key:"inPath",value:function(t,e){var i=e.x,a=e.y,n=this.chart.getPosiY1(),r=this.chart.getPosiY2();if(n<=a&&a<r)for(var s=this._point,o=0;o<s.length;o++)if(Math.abs(i-s[o].posiL)<10&&Math.abs(a-s[o].posiT)<10)return s[o];return!1}},{key:"mouseEvent",value:function(t,e){var i=this.inPath(t,e);return this._hover=i&&i,this._hover}},{key:"getName",value:function(){return"DEPTH"}}],[{key:"calcInterval",value:function(t){for(var e=[],i=[1,2,5],a=0,n=0,r=0;a<i.length;a++)n=i[a],r=Math.ceil(Math.log(t/n)/Math.log(10)),r=Math.pow(10,r),r*=n,e.push(r);return e}}]),t}(),dt=function(){function t(e,i){var a;return X(this,t),(a=B(this,Y(t).call(this,e,i)))._icons=[],a.kline=e,a.chart=i,a._pad=[0,0,0,0],a._count=20,a._h=0,a._maxWidth=0,a._maxAndMinVal=[],a._maxOrder=0,a._curOrder=0,a._data=[],a.calc(),a}return E(t,z),U(t,[{key:"getIcons",value:function(){return this._icons}},{key:"params",value:function(t){return[{type:"ORDER",value:""}]}},{key:"draw",value:function(t,e){this._maxWidth=.3*e.getViewWidth();var i=this.kline,a=(i.zoom.getItemFirst(),i.zoom.getItemLast(),g.getJsMaxValue()),n=-g.getJsMaxValue();this._maxAndMinVal=[n,a],this._h=[n-a]/this._count}},{key:"drawOverlay",value:function(){var t=x+.5-w/2,e=y+.5-h-10;t<0?t=0:t+w>this._width&&(t=this._width-w),e<0&&(e=y+.5+10),Draws.drawFillReact(ctx,"#fff",.8,t,e,w,h),Draws.drawStrokeReact(ctx,color,t,e,w,h),Draws.drawText(ctx,Canvas.getFont(),"#333",price,t+pad,e+pad,"left"),Draws.drawText(ctx,Canvas.getFont(),"#333",text,t+pad,e+pad+18,"left")}},{key:"calc",value:function(){for(var t=this.kline,e=t.zoom.getItemFirst(),i=t.zoom.getItemLast(),a=g.getJsMaxValue(),n=-g.getJsMaxValue(),r=i;r<e;r++){var s=t.getDataAt(r).close;n=Math.max(n,s),a=Math.min(a,s)}this._maxAndMinVal=[n,a],this._h=[n-a]/20;for(var o=[],h=this._h,l=a,c=0;c<20;c++)o.push({floor:[l,l+h],asks:[],bids:[],asksCount:0,bidsCount:0}),l+=h;for(var u=i;u<e;u++){for(var d=t.getDataAt(u).asks,v=t.getDataAt(u).bids,f=0;f<d.length;f++)for(var y=0;y<o.length;y++)o[y].floor[0]<d[f][0]&&d[f][0]<=o[y].floor[1]&&(o[y].asks.push(d[f]),o[y].asksCount+=d[f][1]);for(var p=0;p<v.length;p++)for(var m=0;m<o.length;m++)o[m].floor[0]<v[p][0]&&v[p][0]<=o[m].floor[1]&&(o[m].bids.push(d[p]),o[m].bidsCount+=d[p][1]);n=Math.max(n,close),a=Math.min(a,close)}}},{key:"getName",value:function(){return"ORDER"}}]),t}();function vt(t){return(vt="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 ft(t,e){return!e||"object"!==vt(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function yt(t){return(yt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function pt(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&&function(t,e){(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function mt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _t(t,e){for(var i=0;i<e.length;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 kt(t,e,i){return e&&_t(t.prototype,e),i&&_t(t,i),t}var At=function(){function t(e){mt(this,t),this._MA=[],this.kline=e,this._priceLine={line:!0,label:!0,count:!0},this.calc()}return kt(t,[{key:"changePriceLine",value:function(t){this._priceLine=t}},{key:"calc",value:function(){this._MA=[];for(var t=this.kline,e=t.getDataLen(),i=0,a=[];i<e;i++){var n=t.getDataAt(i).close;i<59?(a.push(n),this._MA.push(NaN)):(a.push(n),this._MA.push(z.calcMA(60,a)))}}},{key:"calcMaxMinVal",value:function(){for(var t=this.kline,e=t.zoom.getItemFirst(),i=t.zoom.getItemLast(),a=g.getJsMaxValue(),n=-g.getJsMaxValue(),r=i;r<e;r++){var s=t.getDataAt(r).close,o=this._MA[r];isNaN(o)||(n=Math.max(n,o),a=Math.min(a,o)),n=Math.max(n,s),a=Math.min(a,s)}return this._maxAndMinVal=[n,a],this._maxAndMinVal}},{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=[],s=[],o=i.zoom.getItemLast();o<n;o++){var h=i.zoom.getX(o)+i.zoom.getItemHalfWidth();r.push({x:h,y:e.getY(i.getDataAt(o).close)-.5}),isNaN(this._MA[o])||s.push({x:h,y:e.getY(this._MA[o])-.5})}g.drawBrokenLine(t,a.getColors("CloseLine"),r),g.drawBrokenLine(t,a.getColors("MaLine"),s)}},{key:"drawOverlay",value:function(t,e){var i=this.kline,a="cn"===i.getLang(),n=i.manage.getHover();n<0&&(n=i.getDataLen()-1);var r=i.getDataAt(n),s=0===n?r:i.getDataAt(n-1),o=i.getTheme(),h=[],l=(r.close-s.close)/s.close;h.push({val:"".concat(a?"时间":"Date",":").concat(g.dateFormat(r.date,"yyyy-mm-dd hh:mn"))}),h.push([{val:"".concat(a?"开":"O",":")},{val:"".concat(e.valToFixed(r.open)),color:0<=l?o.getColors("Positive"):o.getColors("Negative")}]),h.push([{val:"".concat(a?"高":"H",":")},{val:"".concat(e.valToFixed(r.high)),color:0<=l?o.getColors("Positive"):o.getColors("Negative")}]),h.push([{val:"".concat(a?"低":"L",":")},{val:"".concat(e.valToFixed(r.low)),color:0<=l?o.getColors("Positive"):o.getColors("Negative")}]),h.push([{val:"".concat(a?"收":"C",":")},{val:"".concat(e.valToFixed(r.close)),color:0<=l?o.getColors("Positive"):o.getColors("Negative")}]),h.push([{val:"".concat(a?"涨幅":"Change",":")},{val:g.numberToRate(l,!1,!0),color:0<=l?o.getColors("Positive"):o.getColors("Negative")}]);var c=(r.high-r.low)/r.low;h.push([{val:"".concat(a?"振幅":"Ampl",":")},{val:"".concat(g.numberToRate(c,!1,!0)),color:0<=l?o.getColors("Positive"):o.getColors("Negative")}]);var u=0===i._viewType?5:2;this.drawText(t,5,e._posi.textY+u,h,e),e._posi.textY+=e._lineH,this.drawNewPrice(t,e,i.getLastData())}},{key:"drawNewPrice",value:function(t,e,i){if(!(i.close<e.getMin()||i.close>e.getMax())){var a=this.kline,n=a.layout.getAxisWidth(),r=e.getViewWidth(),s=e.getY(i.close),o=a.getTheme(),h=o.getColors("CloseLine"),l=h+"ed";if(this._priceLine.line&&g.drawDotted(t,h,0,s-.5,r-1,s-.5),this._priceLine.label&&(g.drawRect(t,l,r,s-10,n,19),g.drawLine(t,o.getColors("IndexText"),r,s-.5,r+5,s-.5),g.drawText(t,e.valToFixed(i.close),o.getColors("IndexText"),r+10,s-6,!1,!1,"left")),this._priceLine.count){var c=this._priceLine.label?s-10+20:s-10,u=this._priceLine.label?s-10+23:s-6;a._countDownTime&&(g.drawRect(t,l,r,c,n,19),g.drawText(t,g.getCountTime(0,a._countDownTime),o.getColors("IndexText"),r+10,u,!1,!1,"left"))}}}},{key:"drawText",value:function(t,e,i,a,n){for(var r=this.kline.manage,s="Consolas",o=this.kline.getTheme(),h=r.getViewWidth(),l=0;l<a.length;l++)if(a[l]instanceof Array)for(var c=0;c<a[l].length;c++){var u=a[l][c].color||o.getColors("Text"),d=a[l][c].val,v=g.calcTextWidth(t,d,!1,s,c===a[l].length-1?8:0);if(h-e-v<0&&(e=5,i+=n._lineH,n._posi.textY+=n._lineH),i+n._lineH>=n.getMinusBarY2())return;g.drawText(t,d,u,e,i,!1,s,"left"),e+=v}else{var f=a[l].color||o.getColors("Text"),y=a[l].val;g.drawText(t,y,f,e,i,!1,s,"left"),e+=g.calcTextWidth(t,y,!1,s,8)}}},{key:"getName",value:function(){return"TimeShare"}}]),t}(),xt=function(){function t(e){mt(this,t),this.kline=e,this._priceLine={line:!0,label:!0,count:!0}}return kt(t,[{key:"changePriceLine",value:function(t){this._priceLine=t}},{key:"calcMaxMinVal",value:function(){for(var t=this.kline,e=t.getData(),i=t.zoom.getItemFirst(),a=t.zoom.getItemLast(),n=g.getJsMaxValue(),r=-g.getJsMaxValue(),s=a;s<i;s++)r=Math.max(r,e[s].high),n=Math.min(n,e[s].low);return this._maxAndMinVal=[r,n],this._maxAndMinVal}},{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=i.zoom.getItemLast(),s=!0,o=!0,h=i._mainChartStyle,l=r;l<n;l++){var c,u=i.getDataAt(l),d=u.open,v=u.high,f=u.low,y=u.close,p=e.getY(v),m=e.getY(f),_=e.getY(d),k=e.getY(y),A=i.zoom.getX(l),x=i.zoom.getItemWidth(),w=k-_,C=void 0,b=i._theme?"dark":"light";c=d<y?(C=a.getColors("Positive"),"yang"):(C=a.getColors("Negative"),"ying");var T=h[b]["candle.".concat(c,".hollow")],M=A+i.zoom.getItemHalfWidth();p===m&&m++,0<=w&&w<1?w=1:w<0&&-1<w&&(w=-1),T?g.drawRectFrame(t,C,A,_,x,w):g.drawRect(t,C,A,_,x,w);var D=p+Math.min(Math.abs(_-p),Math.abs(k-p),Math.abs(k-p)),P=m-Math.min(Math.abs(_-m),Math.abs(k-m),Math.abs(p-m));p<Math.min(_,k)&&g.drawLine(t,C,M,p,M,D),m>Math.max(_,k)&&g.drawLine(t,C,M,P,M,m),s&&this._maxAndMinVal[0]===v&&(s=!1,g.drawMaxAndMinPrice(t,e.valToFixed(v),a.getColors("Text"),M+.5,p+.5,!1,"Consolas")),o&&this._maxAndMinVal[1]===f&&(o=!1,g.drawMaxAndMinPrice(t,e.valToFixed(f),a.getColors("Text"),M+.5,m-.5,!1,"Consolas"))}}},{key:"drawOverlay",value:function(t,e){var i=this.kline,a=i.getTitle(),n="cn"===i.getLang(),r=i.manage.getHover();r<0&&(r=i.getDataLen()-1);var s=i.getDataAt(r),o=0===r?s:i.getDataAt(r-1),h=i.getTheme(),l=[],c=(s.close-o.close)/o.close;a&&l.push({val:a,color:h.getColors("Title")}),l.push({val:"".concat(n?"时间":"Date",":").concat(g.dateFormat(s.date,"yyyy-mm-dd hh:mn"))}),l.push([{val:"".concat(n?"开":"O",":")},{val:"".concat(e.valToFixed(s.open)),color:0<=c?h.getColors("Positive"):h.getColors("Negative")}]),l.push([{val:"".concat(n?"高":"H",":")},{val:"".concat(e.valToFixed(s.high)),color:0<=c?h.getColors("Positive"):h.getColors("Negative")}]),l.push([{val:"".concat(n?"低":"L",":")},{val:"".concat(e.valToFixed(s.low)),color:0<=c?h.getColors("Positive"):h.getColors("Negative")}]),l.push([{val:"".concat(n?"收":"C",":")},{val:"".concat(e.valToFixed(s.close)),color:0<=c?h.getColors("Positive"):h.getColors("Negative")}]),l.push([{val:"".concat(n?"涨幅":"Change",":")},{val:g.numberToRate(c,!1,!0),color:0<=c?h.getColors("Positive"):h.getColors("Negative")}]);var u=(s.high-s.low)/s.low;l.push([{val:"".concat(n?"振幅":"Ampl",":")},{val:"".concat(g.numberToRate(u,!1,!0)),color:0<=c?h.getColors("Positive"):h.getColors("Negative")}]);var d=0===i._viewType?5:2;this.drawText(t,5,e._posi.textY+d,l,e),e._posi.textY+=e._lineH,this.drawNewPrice(t,e,i.getLastData())}},{key:"drawNewPrice",value:function(t,e,i){var a=this.kline.getLog()?Math.log(i.close)/Math.log(10):i.close;if(!(a<e.getMin()||a>e.getMax())){var n=this.kline,r=n.layout.getAxisWidth(),s=e.getViewWidth(),o=e.getY(i.close),h=n.getTheme(),l=i.close>i.open?h.getColors("Positive"):h.getColors("Negative"),c=l+"ed";if(this._priceLine.line&&g.drawDotted(t,l,0,o-.5,s-1,o-.5),this._priceLine.label&&(g.drawRect(t,c,s,o-10,r,19),g.drawLine(t,h.getColors("IndexText"),s,o-.5,s+5,o-.5),g.drawText(t,e.valToFixed(i.close),h.getColors("IndexText"),s+10,o-6,!1,!1,"left")),this._priceLine.count){var u=this._priceLine.label?o-10+20:o-10,d=this._priceLine.label?o-10+23:o-6;n._countDownTime&&(g.drawRect(t,c,s,u,r,19),g.drawText(t,g.getCountTime(0,n._countDownTime),h.getColors("IndexText"),s+10,d,!1,!1,"left"))}}}},{key:"drawText",value:function(t,e,i,a,n){for(var r=this.kline.manage,s="Consolas",o=this.kline.getTheme(),h=r.getViewWidth(),l=0;l<a.length;l++)if(a[l]instanceof Array)for(var c=0;c<a[l].length;c++){var u=a[l][c].color||o.getColors("Text"),d=a[l][c].val,v=g.calcTextWidth(t,d,!1,s,c===a[l].length-1?8:0);if(h-e-v<0&&(e=5,i+=n._lineH,n._posi.textY+=n._lineH),i+n._lineH>=n.getMinusBarY2())return;g.drawText(t,d,u,e,i,!1,s,"left",!1),e+=v}else{var f=a[l].color||o.getColors("Text"),y=a[l].val;g.drawText(t,y,f,e,i,!1,s,"left"),e+=g.calcTextWidth(t,y,!1,s,8)}}},{key:"getName",value:function(){return"CandleStick"}}]),t}(),wt=function(){function t(e){return mt(this,t),ft(this,yt(t).call(this,e))}return pt(t,xt),kt(t,[{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=i.zoom.getItemLast(),s=!0,o=!0,h=i._mainChartStyle,l=r;l<n;l++){var c,u=i.getDataAt(l),d=i.zoom.getX(l),v=i.zoom.getItemWidth(),f=void 0,y=void 0,p=void 0,m=0===l?u.open:i.getDataAt(l-1).close,_=u.high,k=u.low,A=u.close,x=e.getY(_),w=e.getY(k),C=e.getY(m),b=e.getY(A);c=m<A?(y=C-(f=b),p=a.getColors("Positive"),"yang"):(y=b-(f=C),p=a.getColors("Negative"),"ying"),x===w&&(w=x+1),C===b&&(y=1);var T=d+i.zoom.getItemHalfWidth();h[i._theme?"dark":"light"]["candle.".concat(c,".hollow")]?g.drawRectFrame(t,p,d,f,v,y):g.drawRect(t,p,d,f,v,y);var M=x+Math.min(Math.abs(C-x),Math.abs(b-x),Math.abs(b-x)),D=w-Math.min(Math.abs(C-w),Math.abs(b-w),Math.abs(x-w));x<Math.min(C,b)&&g.drawLine(t,p,T,x,T,M),w>Math.max(C,b)&&g.drawLine(t,p,T,D,T,w),s&&this._maxAndMinVal[0]===_&&(s=!1,g.drawMaxAndMinPrice(t,e.valToFixed(_),a.getColors("Text"),T+.5,x+.5,!1,"Consolas")),o&&this._maxAndMinVal[1]===k&&(o=!1,g.drawMaxAndMinPrice(t,e.valToFixed(k),a.getColors("Text"),T+.5,w-.5,!1,"Consolas"))}}},{key:"getName",value:function(){return"CandleStickHLC"}}]),t}(),Ct=function(){function t(e){return mt(this,t),ft(this,yt(t).call(this,e))}return pt(t,xt),kt(t,[{key:"draw",value:function(t,e){for(var i=this.kline,a=i.getTheme(),n=i.zoom.getItemFirst(),r=!0,s=!0,o=i.zoom.getItemLast();o<n;o++){var h=i.getDataAt(o),l=h.open,c=h.high,u=h.low,d=h.close,v=i.zoom.getX(o),f=l<d?a.getColors("Positive"):a.getColors("Negative"),y=e.getY(c),p=e.getY(u),m=e.getY(l)-.5,_=e.getY(d)-.5,k=i.zoom.getItemHalfWidth(),A=v+k;g.drawLine(t,f,A,y,A,p),g.drawLine(t,f,A,m,A-k,m),g.drawLine(t,f,A,_,A+k,_),r&&this._maxAndMinVal[0]===c&&(r=!1,g.drawMaxAndMinPrice(t,e.valToFixed(c),a.getColors("Text"),A+.5,y+.5,!1,"Consolas")),s&&this._maxAndMinVal[1]===u&&(s=!1,g.drawMaxAndMinPrice(t,e.valToFixed(u),a.getColors("Text"),A+.5,p-.5,!1,"Consolas"))}}},{key:"getName",value:function(){return"OHLCLine"}}]),t}();function bt(t){return(bt="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 Tt(t,e){return!e||"object"!==bt(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function Mt(t){return(Mt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Dt(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&&function(t,e){(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function Pt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function It(t,e){for(var i=0;i<e.length;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 Lt(t,e,i){return e&&It(t.prototype,e),i&&It(t,i),t}var Rt=function(){function t(e,i,a){Pt(this,t),this.kline=e,this._chart=i,this._indicators=a,this._hover=!1,this.bound=[]}return Lt(t,[{key:"inPath",value:function(t,e){var i=e.x,a=e.y,n=this._chart.getMinusBarY2(),r=this._chart.getPosiY2();if(n<=a&&a<r)for(var s=this._indicators,o=0;o<s.length;o++)if(s[o].posiL<=i&&i<s[o].posiR)return s[o].dis||(this.kline._el.style.cursor="pointer"),{name:s[o].name,index:o,dis:s[o].dis||!1};return!1}},{key:"mouseEvent",value:function(t,e,i){var a=this.inPath(t,e);return this._hover=a&&a.name,this._hover}},{key:"getMainText",value:function(){return"cn"===this.kline.getLang()?"主指标":"Main Indicators"}},{key:"getSubText",value:function(){return"cn"===this.kline.getLang()?"副指标":"Sub Indicators"}},{key:"calc",value:function(t){var e=5,i=this._indicators,a=this.kline,n=a.getMainContext(),r=[];if(a.getLang(),0===a._viewType){var s="Main"===t?this.getMainText():this.getSubText();i.unshift(s)}for(var o=0;o<i.length;o++){var h=Math.ceil(n.measureText(i[o]).width);r.push({width:h,name:i[o],posiW:h,posiL:e,posiR:e+h,posiH:0,paddingR:12}),e=e+h+12}this._indicators=r.concat([])}}]),t}(),St=function(){function t(e,i){var a;Pt(this,t),a=Tt(this,Mt(t).call(this,e,i,["MA","EMA","BOLL","SAR","DEPTH"]));for(var n=[],r=i._indicators,s=1;s<r.length;s++)n.push(r[s].getName());return a._selected=n,a._clickName=null,a.calc("Main"),a}return Dt(t,Rt),Lt(t,[{key:"updateSelected",value:function(t){this._selected=t}},{key:"clickEvent",value:function(t,e){var i=this.inPath(t,e),a=this.kline;if(i&&!i.dis){if(i.name!==this.getMainText()){var n=this._selected.indexOf(i.name);return-1<n?this._selected.splice(n,1):this._selected.push(i.name),this._clickName=i.name,this.repaintChart(),this._selected}a._on.iconCallBack&&a._on.iconCallBack("set",null)}}},{key:"repaintChart",value:function(){var t=this.kline;t.mainIndicator(this._selected),t._on.indicatorBarCallBack&&t._on.indicatorBarCallBack("main",this._selected,this._clickName)}},{key:"draw",value:function(t){this.bound=[];for(var e=this.kline.manage,i=this._chart.getPosiY2(),a=this.kline.getTheme(),n=this._indicators,r=this._selected,s=e.getViewWidth(),o=0;o<n.length;o++){if(this.bound.length)return;n[o].posiH=i-17;var h=a.getColors("IndicatorBarName");this._hover===n[o].name&&(h=a.getColors("IndicatorHover"));for(var l=0;l<r.length;l++)r[l]===n[o].name&&(h=a.getColors("IndicatorSelected"));if(n[o].name===this.getMainText()&&(h=a.getColors("IndicatorBarName")),s>n[o].width+n[o].paddingR){var c=n[o].name;"DEPTH"===c&&(c="全量深度"),g.drawText(t,c,h,n[o].posiL,n[o].posiH,!1,!1,"left"),s-=n[o].width+n[o].paddingR}else this.bound=[0,e.getViewWidth()-s]}}}]),t}(),Nt=function(){function t(e,i){var a;return Pt(this,t),(a=Tt(this,Mt(t).call(this,e,i,["VOLUME","MACD","KDJ","OBV","RSI","TRIX","WR","CCI","ROC","ATR","DMI","VR","PSY","BIAS"])))._lastSelected=null,a._selected=i._indicators[0].getName(),a.calc("Deputy"),a}return Dt(t,Rt),Lt(t,[{key:"clickEvent",value:function(t,e){var i=this.inPath(t,e),a=this.kline;if(i&&!i.dis){if(i.name!==this.getSubText())return this._lastSelected=this._selected,this._selected=i.name,this.repaintChart(),this._selected;a._on.iconCallBack&&a._on.iconCallBack("set",this._chart._indicators[0])}}},{key:"repaintChart",value:function(){var t=this.kline;t.replaceIndicator({name:this._selected,last:this._lastSelected}),t._on.indicatorBarCallBack&&t._on.indicatorBarCallBack("deputy",this._selected,this._lastSelected)}},{key:"draw",value:function(t){this.bound=[];for(var e=this.kline,i=e.manage,a=e.getTheme(),n=this._indicators,r=this.kline._indicators,s=this._chart.getPosiY2(),o=i.getViewWidth(),h=0;h<n.length;h++){if(this.bound.length)return;n[h].posiH=s-17,n[h].dis=!1;var l=a.getColors("IndicatorBarName");this._hover===n[h].name&&(l=a.getColors("IndicatorHover")),this._selected===n[h].name&&(l=a.getColors("IndicatorSelected")),-1<r.indexOf(n[h].name)&&this._selected!==n[h].name&&(n[h].dis=!0,l=a.getColors("IndicatorDis")),n[h].name===this.getSubText()&&(l=a.getColors("IndicatorBarName"));var c=n[h].name;o>n[h].width+n[h].paddingR?(g.drawText(t,c,l,n[h].posiL,n[h].posiH,!1,!1,"left"),o-=n[h].width+n[h].paddingR):this.bound=[0,i.getViewWidth()-o]}this._indicators=n}}]),t}();function Ot(t){return(Ot="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 Vt(t,e,i){return(Vt="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=Bt(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 Wt(t,e){return!e||"object"!==Ot(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function Bt(t){return(Bt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Yt(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&&function(t,e){(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function Et(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ft(t,e){for(var i=0;i<e.length;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 Xt(t,e,i){return e&&Ft(t.prototype,e),i&&Ft(t,i),t}var Ht=function(){function t(e){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:2,a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};Et(this,t),this._now=a.type?i:0,this._count=i,this._data=a.data||[],this._hover="none",this._focus=!1,this._selected=!a.type,this._radius=6,this._lineWidth=a.lineWidth||1,this._lineStyle=a.lineStyle||0,this._lineWidthHover=2,this.kline=e,this._color=a.color||this.kline.getTheme().getColors("Line"),this._bgColor=a.bgColor||this.kline.getTheme().getColors("ToolBg"),this._isLock=a.isLock||!1,this.setDefaultParams({lineWidth:1,lineStyle:0,color:this.kline.getTheme().getColors("Line"),bgColor:this.kline.getTheme().getColors("ToolBg"),isLock:!1})}return Xt(t,[{key:"setDefaultParams",value:function(t){this._defaultParams=t}},{key:"addData",value:function(){if(this._now++,this._now===this._count){var t=this.kline.manage,e=t.getMainChart()._tools.length;this.kline._on&&this.kline._on.toolCompleted&&this.kline._on.toolCompleted(this,e-1),this.kline.manage.setTools(!1),t.getMainChart().saveTools()}}},{key:"isOVer",value:function(){return this._now===this._count}},{key:"setData",value:function(t){this._data[this._now]=t}},{key:"getData",value:function(){return this._data}},{key:"lock",value:function(t){this._isLock=!t}},{key:"recover",value:function(){var t=this._defaultParams;for(var e in t)this["_".concat(e)]=t[e]}},{key:"setParams",value:function(t){void 0!==t.color&&(this._color=t.color),void 0!==t.lineWidth&&(this._lineWidth=t.lineWidth),void 0!==t.lineStyle&&(this._lineStyle=t.lineStyle)}},{key:"getParams",value:function(){return{type:this.getName(),lineWidth:this._lineWidth,lineStyle:this._lineStyle,color:this._color,bgColor:this._bgColor,isLock:this._isLock,data:this._data}}},{key:"updateData",value:function(t){if("none"!==this._hover)if(this._hover===this.getDataLen())for(var e=this.kline.zoom,i=0;i<this.getDataLen();i++){var a=JSON.parse(JSON.stringify(this.getDataAt(i)));a.date=e.indexToDate(e.dateToIndex(a.date)+t.ind),a.price=Number(a.price)+Number(t.price),this.setDataAt(i,a)}else this.setDataAt(this._hover,t)}},{key:"getDataAt",value:function(t){return this._data[t]}},{key:"setDataAt",value:function(t,e){this._data[t]=e}},{key:"getDataLen",value:function(){return this._data.length}},{key:"isMovePoint",value:function(){return this._hover!==this.getDataLen()}},{key:"getX",value:function(t){var e=this.kline.zoom,i=e.dateToIndex(t);return e.getX(i)+e.getItemHalfWidth()}},{key:"getY",value:function(t){return this.kline.manage.getMainChart().getY(t)}},{key:"getPrice",value:function(t,e){var i=this.kline,a=i.manage.getMainChart();if(t>=i.getDataLen()||t<0)return a.yCoordsToPrice(e);var n=i.getDataAt(t),r=a.getY(n.open),s=a.getY(n.close),o=a.getY(n.high),h=a.getY(n.low);return o<e&&e-o<10?a.valToFixed(n.high):r<e&&e-r<10?a.valToFixed(n.open):s<e&&e-s<10?a.valToFixed(n.close):h<e&&e-h<10?a.valToFixed(n.low):a.yCoordsToPrice(e)}},{key:"getHorzPoint",value:function(){return{x1:0,x2:this.kline.manage.getMainChart().getViewWidth()}}},{key:"getVertPoint",value:function(){var t=this.kline.manage.getMainChart();return{y1:t.getPosiY1(),y2:t.getPosiY2()}}},{key:"calcLineTo",value:function(t,e,i,a){var n,r,s,o,h=this.kline.manage.getMainChart(),l=h.getViewWidth(),c=h.getPosiY2();if(t===i)n=r=t,s=0,o=c;else if(e===a)n=0,r=l,s=o=e;else{var u=g.calcSlope(t,e,i,a),d=u.k,v=u.b;d<0?(r=-(s=v)/d,o=n=0):(n=0,r=((o=c)-(s=v))/d),c<s&&(n=((s=c)-v)/d),l<r&&(o=d*(r=l)+v)}return{x1:n,y1:s,x2:r,y2:o}}},{key:"calcFib",value:function(t,e,i){var a,n=2<arguments.length&&void 0!==i?i:"price",r=this.kline.manage.getMainChart();switch(e){case"FibRetracement":a=[0,.236,.382,.5,.618,.786,1,1.382,1.618,2.618,3.618,4.236];break;case"FibFans":a=[.382,.5,.618];break;case"FibCycle":a=[0,1,2,3,5,8,13,21,34]}for(var s=0;s<a.length;s++)if("price"===n){var o=Number(t[1].price)+a[s]*Number(t[0].price-t[1].price);a[s]={y:this.getY(o),price:o,text:parseFloat((100*a[s]).toFixed(3))+"%"+r.valToFixed(o)+""}}else if("time"===n){var h=Number(t[1].date)+a[s]*Number(t[0].date-t[1].date);a[s]={x:this.getX(h),text:parseFloat(a[s].toFixed(3))}}else if("cycle"===n){var l=Number(t[1].date)+a[s]*Number(t[0].date-t[1].date);a[s]={x:this.getX(l),text:parseFloat(a[s].toFixed(3))}}return a}},{key:"mouseEvent",value:function(t,e){this.isOVer()&&(this._hover=this.inPath(t,e),"none"!==this._hover&&(this.kline._el.style.cursor="pointer"))}},{key:"clickEvent",value:function(t,e){if(this.isOVer())return this._selected="none"!==this.inPath(t,e),this._selected&&this}},{key:"isSelected",value:function(t,e){var i=!1;for(var a in this.points)if(this.points[a].isSelected(t,e)){i=!0;break}return!0===i&&(this.select(),!0)}},{key:"select",value:function(){for(var t in this.points)this.points[t].getState()===CPoint.state.Hide&&this.points[t].setState(CPoint.state.Show)}},{key:"unselect",value:function(){for(var t in this.points)this.points[t].getState()!==CPoint.state.Hide&&this.points[t].setState(CPoint.state.Hide)}},{key:"calcDistance",value:function(t,e,i){var a=t.x,n=t.y,r=e.x,s=e.y,o=i.x,h=i.y,l=a-o,c=n-h,u=r-o,g=s-h;return Math.abs(l*g-c*u)/Math.sqrt(Math.pow(r-a,2)+Math.pow(s-n,2))}},{key:"calcGap",value:function(t,e,i){var a=t.sx,n=t.sy,r=t.ex,s=t.ey,o=a-e,h=n-i,l=r-e,c=s-i;return Math.abs(o*c-h*l)/Math.sqrt(Math.pow(r-a,2)+Math.pow(s-n,2))}},{key:"isWithRect",value:function(t,e,i){var a=t.x,n=t.y,r=e.x,s=e.y,o=i.x,h=i.y;return r<a?(a+=4,r-=4):(a-=4,r+=4),s<n?(n+=4,s-=4):(n-=4,s+=4),a<=o&&o<=r&&n<=h&&h<=s||o<=a&&r<=o&&n<=h&&h<=s||a<=o&&o<=r&&h<=n&&s<=h||o<=a&&r<=o&&h<=n&&s<=h}},{key:"getRectCrossPt",value:function(t,e,i){var a={x:-1,y:-1},n={x:-1,y:-1},r=i.x-e.x,s=i.y-e.y;if(Math.abs(r)<2)return[a={x:e.x,y:t.top},n={x:i.x,y:t.bottom}];var o=s/r;return n.x=t.right,n.y=e.y+(t.right-e.x)*o,a.x=t.left,a.y=e.y+(t.left-e.x)*o,[a,n]}},{key:"inPath",value:function(t,e){if(!e)return"none";for(var i=this.getDataLen(),a=[],n=0;n<i;n++){var r=this.getDataAt(n),s=this.getX(r.date),o=this.getY(r.price);if(t.save(),t.beginPath(),t.lineWidth=this._lineWidth,t.arc(s,o,this._radius,0,2*Math.PI),t.restore(),t.isPointInPath(e.x,e.y))return n;a.push({x:s,y:o})}t.save(),t.beginPath(),t.lineWidth=5;for(var h=0;h<a.length;h++)t.lineTo(a[h].x,a[h].y);return t.restore(),t.isPointInStroke(e.x,e.y)?i:"none"}},{key:"drawPoint",value:function(t,e,i,a){var n=this.kline.getTheme().getColors("Line");g.drawPoint(t,n,e,i),g.drawText(t,a,n,e+10,i-10,!1,"Consolas","left")}},{key:"drawSegLine",value:function(t,e){var i=this.kline.getTheme();e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,e[1].y=this._lineWidth%2==0?e[1].y:e[1].y-.5,g.drawStyleLine(t,this._color,e[0].x,e[0].y,e[1].x,e[1].y,this._lineWidth,this._lineStyle);for(var a=0;(this._selected||"none"!==this._hover)&&a<e.length;a++){var n=this._lineWidth;!this._selected&&this._hover!==a||(n=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[a].x,e[a].y,this._radius,n)}}},{key:"drawStraightLine",value:function(t,e){var i=this.kline.getTheme(),a=this.calcLineTo(e[0].x,e[0].y,e[1].x,e[1].y);a.y1=this._lineWidth%2==0?a.y1:a.y1-.5,a.y2=this._lineWidth%2==0?a.y2:a.y2-.5,g.drawStyleLine(t,this._color,a.x1,a.y1,a.x2,a.y2,this._lineWidth,this._lineStyle);for(var n=0;(this._selected||"none"!==this._hover)&&n<e.length;n++){var r=this._lineWidth;!this._selected&&this._hover!==n||(r=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[n].x,e[n].y,this._radius,r)}}},{key:"drawRayLine",value:function(t,e){var i,a,n=this.kline.manage.getMainChart(),r=this.kline.getTheme(),s=this.calcLineTo(e[0].x,e[0].y,e[1].x,e[1].y);a=e[0].x>e[1].x?(i=s.x1,s.y1):e[0].x<e[1].x?(i=s.x2,s.y2):(i=e[0].x,e[0].y>e[1].y?0:n.getPosiY2()),e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,a=this._lineWidth%2==0?a:a-.5,g.drawStyleLine(t,this._color,e[0].x,e[0].y,i,a,this._lineWidth,this._lineStyle);for(var o=0;(this._selected||"none"!==this._hover)&&o<e.length;o++){var h=this._lineWidth;!this._selected&&this._hover!==o||(h=this._lineWidthHover),g.drawArc(t,r.getColors("Point"),r.getColors("Background"),e[o].x,e[o].y,this._radius,h)}}}]),t}(),Ut=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,1,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"HorzLine"}},{key:"inPath",value:function(t,e){var i=this.getY(this.getDataAt(0).price);return e.y>i+4||e.y<i-4?"none":this.getDataLen()}},{key:"draw",value:function(t){if(0!==this.getDataLen()){var e=this.getDataAt(0);this.drawHorzLine(t,this.getX(e.date),this.getY(e.price))}}},{key:"drawHorzLine",value:function(t,e,i){var a=this.getHorzPoint(),n=this.kline.getTheme();if(i=this._lineWidth%2==0?i:i-.5,g.drawStyleLine(t,this._color,a.x1,i,a.x2,i,this._lineWidth,this._lineStyle),this._selected||"none"!==this._hover){var r=this._lineWidth;!this._selected&&0!==this._hover||(r=this._lineWidthHover),g.drawArc(t,n.getColors("Point"),n.getColors("Background"),e,i,this._radius,r)}}}]),t}(),Jt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,1,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"VertLine"}},{key:"inPath",value:function(t,e){var i=this.getX(this.getDataAt(0).date);return e.x>i+4||e.x<i-4?"none":this.getDataLen()}},{key:"draw",value:function(t){if(0!==this.getDataLen()){var e=this.getDataAt(0);this.drawVertLine(t,this.getX(e.date),this.getY(e.price))}}},{key:"drawVertLine",value:function(t,e,i){var a=this.getVertPoint(),n=this.kline.getTheme();if(e=this._lineWidth%2==0?e+.5:e,g.drawStyleLine(t,this._color,e,a.y1,e,a.y2,this._lineWidth,this._lineStyle),this._selected||"none"!==this._hover){var r=this._lineWidth;!this._selected&&0!==this._hover||(r=this._lineWidthHover),g.drawArc(t,n.getColors("Point"),n.getColors("Background"),e,i,this._radius,r)}}}]),t}(),zt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,1,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"CrossLine"}},{key:"inPath",value:function(t,e){if(!e)return"none";for(var i=e.x,a=e.y,n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i-this.getX(r.date))<10&&Math.abs(a-this.getY(r.price))<10)return 0}var s=this.getX(this.getDataAt(0).date),o=this.getY(this.getDataAt(0).price);return e.y<o+4&&e.y>o-4?1:e.x<s+4&&e.x>s-4?1:"none"}},{key:"draw",value:function(t){if(0!==this.getDataLen()){var e=this.getDataAt(0);this.drawCrossLine(t,this.getX(e.date),this.getY(e.price))}}},{key:"drawCrossLine",value:function(t,e,i){var a=this.getHorzPoint(),n=this.getVertPoint(),r=this.kline.getTheme();if(i=this._lineWidth%2==0?i:i-.5,e=this._lineWidth%2==0?e+.5:e,g.drawStyleLine(t,this._color,a.x1,i,a.x2,i,this._lineWidth,this._lineStyle),g.drawStyleLine(t,this._color,e,n.y1,e,n.y2,this._lineWidth,this._lineStyle),this._selected||"none"!==this._hover){var s=this._lineWidth;!this._selected&&0!==this._hover||(s=this._lineWidthHover),g.drawArc(t,r.getColors("Point"),r.getColors("Background"),e,i,this._radius,s)}}}]),t}(),jt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"SegLine"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawSegLine(t,a)}}},{key:"inPath",value:function(t,e){for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}return!1===this.isWithRect(a[0],a[1],i)?"none":this.calcDistance(a[0],a[1],i)<4?this.getDataLen():"none"}}]),t}(),Gt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"HoriSegLine"}},{key:"inPath",value:function(t,e){for(var i=e.x,a=e.y,n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);if(Math.abs(i-this.getX(s.date))<10&&Math.abs(a-this.getY(s.price))<10)return r;n.push({x:this.getX(s.date),y:this.getY(s.price)})}var o=this.getY(this.getDataAt(0).price),h=this.getX(this.getDataAt(0).date),l=this.getX(this.getDataAt(1).date);return e.y>o+4||e.y<o-4?"none":l<h&&(e.x>h+4||e.x<l-4)?"none":h<l&&(e.x<h-4||e.x>l+4)?"none":this.getDataLen()}},{key:"updateData",value:function(t){if(this._hover===this.getDataLen())for(var e=this.kline.zoom,i=0;i<this.getDataLen();i++){var a=JSON.parse(JSON.stringify(this.getDataAt(i)));a.date=e.indexToDate(e.dateToIndex(a.date)+t.ind),a.price=Number(a.price)+Number(t.price),this.setDataAt(i,a)}else this.setDataAt(this._hover,t),this._data[0===this._hover?1:0].price=t.price}},{key:"setData",value:function(t){0===this._now||(this._data[0].price=t.price),this._data[this._now]=t}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawSegLine(t,a)}}}]),t}(),Kt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"StraightLine"}},{key:"inPath",value:function(t,e){for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}return this.calcDistance(a[0],a[1],i)<4?this.getDataLen():"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawStraightLine(t,a)}}},{key:"drawStraightLine",value:function(t,e){var i=this.kline.getTheme(),a=this.calcLineTo(e[0].x,e[0].y,e[1].x,e[1].y);a.y1=this._lineWidth%2==0?a.y1:a.y1-.5,a.y2=this._lineWidth%2==0?a.y2:a.y2-.5,g.drawStyleLine(t,this._color,a.x1,a.y1,a.x2,a.y2,this._lineWidth,this._lineStyle);for(var n=0;(this._selected||"none"!==this._hover)&&n<e.length;n++){var r=this._lineWidth;!this._selected&&this._hover!==n||(r=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[n].x,e[n].y,this._radius,r)}}}]),t}(),Qt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"ArrowLine"}},{key:"inPath",value:function(t,e){for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}return!1===this.isWithRect(a[0],a[1],i)?"none":this.calcDistance(a[0],a[1],i)<4?this.getDataLen():"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawArrowLine(t,a)}}},{key:"drawArrowLine",value:function(t,e){var i=this.kline.getTheme();g.drawBrokenLine(t,this._color,e,this._lineWidth,this._lineStyle),g.drawArrow(t,this._color,e,this._lineWidth);for(var a=0;(this._selected||"none"!==this._hover)&&a<e.length;a++){var n=this._lineWidth;!this._selected&&this._hover!==a||(n=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[a].x,e[a].y,this._radius,n)}}}]),t}(),qt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"RayLine"}},{key:"inPath",value:function(t,e){if(!e)return"none";for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}var s=this.getX(this.getDataAt(0).date),o=this.getX(this.getDataAt(1).date);return s<o&&e.x<s-4?"none":o<s&&e.x>s+4?"none":this.calcDistance(a[0],a[1],i)<4?this.getDataLen():"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawRayLine(t,a)}}}]),t}(),Zt=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,3,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"ParallelLine"}},{key:"inPath",value:function(t,e){if(!e)return"none";for(var i=e.x,a=e.y,n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i-this.getX(r.date))<10&&Math.abs(a-this.getY(r.price))<10)return n}var s=this.getX(this.getDataAt(0).date),o=this.getY(this.getDataAt(0).price),h=this.getX(this.getDataAt(2).date),l=this.getY(this.getDataAt(2).price),c=this.getX(this.getDataAt(1).date),u=this.getY(this.getDataAt(1).price),g={sx:s,sy:o,ex:c,ey:u},d={sx:h,sy:l,ex:s-(s-h+(s-c)),ey:o-(o-l+(o-u))};return 4<this.calcGap(g,e.x,e.y)&&4<this.calcGap(d,e.x,e.y)?"none":this.getDataLen()}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawStraightLine(t,a)}else if(3===e){for(var s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);s.push({x:this.getX(h.date),y:this.getY(h.price)})}this.drawParallelLine(t,s,3)}}},{key:"getParaPt",value:function(){var t=[];t[0]=this.endPoint.x-this.startPoint.x,t[1]=this.endPoint.y-this.startPoint.y;var e=[];e[0]=this.paraStartPoint.x-this.startPoint.x,e[1]=this.paraStartPoint.y-this.startPoint.y,this.paraEndPoint={x:-1,y:-1},this.paraEndPoint.x=t[0]+e[0]+this.startPoint.x,this.paraEndPoint.y=t[1]+e[1]+this.startPoint.y}},{key:"drawParallelLine",value:function(t,e,i){var a=this.kline,n=this.kline.getTheme(),r={left:0,top:0,right:a._width,bottom:a.manage.getMainChart().getViewHeight()};this.startPoint=e[0],this.paraStartPoint=e[2],this.endPoint=e[1],this.getParaPt(),this.crossPt0=this.getRectCrossPt(r,this.startPoint,this.endPoint),this.crossPt0[0].y=this._lineWidth%2==0?this.crossPt0[0].y:this.crossPt0[0].y-.5,this.crossPt0[1].y=this._lineWidth%2==0?this.crossPt0[1].y:this.crossPt0[1].y-.5,g.drawStyleLine(t,this._color,this.crossPt0[0].x,this.crossPt0[0].y,this.crossPt0[1].x,this.crossPt0[1].y,this._lineWidth,this._lineStyle),this.crossPt1=this.getRectCrossPt(r,this.paraStartPoint,this.paraEndPoint),this.crossPt1[0].y=this._lineWidth%2==0?this.crossPt1[0].y:this.crossPt1[0].y-.5,this.crossPt1[1].y=this._lineWidth%2==0?this.crossPt1[1].y:this.crossPt1[1].y-.5,g.drawStyleLine(t,this._color,this.crossPt1[0].x,this.crossPt1[0].y,this.crossPt1[1].x,this.crossPt1[1].y,this._lineWidth,this._lineStyle);for(var s=0;(this._selected||"none"!==this._hover)&&s<e.length;s++){var o=this._lineWidth;!this._selected&&this._hover!==s||(o=this._lineWidthHover),g.drawArc(t,n.getColors("Point"),n.getColors("Background"),e[s].x,e[s].y,this._radius,o)}}}]),t}(),$t=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,3,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"ParallelRayLine"}},{key:"inPath",value:function(t,e){if(!e)return"none";for(var i=e.x,a=e.y,n=e.x,r=e.y,s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);if(Math.abs(n-this.getX(h.date))<10&&Math.abs(r-this.getY(h.price))<10)return o;s.push({x:this.getX(h.date),y:this.getY(h.price)})}var l=this.getX(this.getDataAt(0).date),c=this.getY(this.getDataAt(0).price),u=this.getX(this.getDataAt(2).date),g=this.getY(this.getDataAt(2).price),d=this.getX(this.getDataAt(1).date),v=this.getY(this.getDataAt(1).price),f=l-(l-u+(l-d)),y=c-(c-g+(c-v)),p={sx:l,sy:c,ex:d,ey:v},m={sx:u,sy:g,ex:f,ey:y},_=u-l,k=g-c,A=f-d,x=y-v,w={sx:Math.abs(_-l),sy:Math.abs(k-c),ex:Math.abs(A-d),ey:Math.abs(x-v)};return 4<this.calcGap(p,i,a)&&4<this.calcGap(m,i,a)&&4<this.calcGap(w,i,a)?"none":this.getDataLen()}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawRayLine(t,a)}else if(3===e){for(var s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);s.push({x:this.getX(h.date),y:this.getY(h.price)})}this.drawParallelRayLine(t,s)}}},{key:"drawParallelRayLine",value:function(t,e){var i,a,n=this.kline.manage.getMainChart(),r=this.kline.getTheme(),s=this.calcLineTo(e[0].x,e[0].y,e[1].x,e[1].y),o=e[2].x-e[1].x,h=e[2].y-e[1].y;a=e[0].x>e[1].x?(i=s.x1,s.y1):e[0].x<e[1].x?(i=s.x2,s.y2):(i=e[0].x,e[0].y>e[1].y?0:n.getPosiY2()),e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,a=this._lineWidth%2==0?a:a-.5,g.drawStyleLine(t,this._color,e[0].x,e[0].y,i,a,this._lineWidth,this._lineStyle),s=this.calcLineTo(e[2].x,e[2].y,i+o,a+h),a=e[0].x>e[1].x?(i=s.x1,s.y1):e[0].x<e[1].x?(i=s.x2,s.y2):(i=e[2].x,e[0].y>e[1].y?0:n.getPosiY2()),e[2].y=this._lineWidth%2==0?e[2].y:e[2].y-.5,a=this._lineWidth%2==0?a:a-.5,g.drawStyleLine(t,this._color,e[2].x,e[2].y,i,a,this._lineWidth,this._lineStyle);for(var l=0;(this._selected||"none"!==this._hover)&&l<e.length;l++){var c=this._lineWidth;!this._selected&&this._hover!==l||(c=this._lineWidthHover),g.drawArc(t,r.getColors("Point"),r.getColors("Background"),e[l].x,e[l].y,this._radius,c)}}}]),t}(),te=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,1,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"PriceLine"}},{key:"inPath",value:function(t,e){for(var i=e.x,a=e.y,n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);if(Math.abs(i-this.getX(s.date))<10&&Math.abs(a-this.getY(s.price))<10)return r;n.push({x:this.getX(s.date),y:this.getY(s.price)})}var o=this.getX(this.getDataAt(0).date),h=this.getY(this.getDataAt(0).price);return i<o-4?"none":h+4<=a||a<=h-4?"none":this.getDataLen()}},{key:"draw",value:function(t){if(0!==this.getDataLen()){var e=this.getDataAt(0);this.drawPriceLine(t,this.getX(e.date),this.getY(e.price),e.price)}}},{key:"drawPriceLine",value:function(t,e,i,a){var n=this.kline.manage.getMainChart(),r=this.getHorzPoint(),s=this.kline.getTheme();if(i=this._lineWidth%2==0?i:i-.5,g.drawStyleLine(t,this._color,e,i,r.x2,i,this._lineWidth,this._lineStyle),g.drawText(t,n.valToFixed(a),this._color,e+5,i-15,!1,"Consolas","left"),this._selected||"none"!==this._hover){var o=this._lineWidth;!this._selected&&0!==this._hover||(o=this._lineWidthHover),g.drawArc(t,s.getColors("Point"),s.getColors("Background"),e,i,this._radius,o)}}}]),t}(),ee=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"FibRetracement"}},{key:"inPath",value:function(t,e){e.x;for(var i=e.y,a=e.x,n=e.y,r=[],s=0;s<this.getDataLen();s++){var o=this.getDataAt(s);if(Math.abs(a-this.getX(o.date))<10&&Math.abs(n-this.getY(o.price))<10)return s;r.push({x:this.getX(o.date),y:this.getY(o.price)})}this.getX(this.getDataAt(0).date);for(var h=this.getY(this.getDataAt(0).price),l=(this.getX(this.getDataAt(1).date),this.getY(this.getDataAt(1).price)),c=[0,.236,.382,.5,.618,.786,1,1.382,1.618,2.618,3.618,4.236].reverse(),u=0;u<c.length;u++){var g=h+(100-100*c[u])/100*(l-h);if(g<i+4&&i-4<g)return this.getDataLen()}return"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawFibRetracement(t,a,this.calcFib(this.getData(),"FibRetracement"))}}},{key:"drawFibRetracement",value:function(t,e,i){for(var a=this.getHorzPoint(),n=this.kline.getTheme(),r=0;r<i.length;r++){var s=i[r].y;s=this._lineWidth%2==0?s:s-.5,g.drawStyleLine(t,this._color,a.x1,s,a.x2,s,this._lineWidth,this._lineStyle),g.drawText(t,i[r].text,this._color,5,s-14,!1,"Consolas","left")}for(var o=0;(this._selected||"none"!==this._hover)&&o<e.length;o++){var h=this._lineWidth;!this._selected&&this._hover!==o||(h=this._lineWidthHover),g.drawArc(t,n.getColors("Point"),n.getColors("Background"),e[o].x,e[o].y,this._radius,h)}}}]),t}(),ie=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"FibSegLine"}},{key:"inPath",value:function(t,e){for(var i=e.x,a=e.y,n=e.x,r=e.y,s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);if(Math.abs(n-this.getX(h.date))<10&&Math.abs(r-this.getY(h.price))<10)return o;s.push({x:this.getX(h.date),y:this.getY(h.price)})}for(var l=this.getX(this.getDataAt(0).date),c=this.getY(this.getDataAt(0).price),u=this.getX(this.getDataAt(1).date),g=this.getY(this.getDataAt(1).price),d=[0,.236,.382,.5,.618,.786,1,1.382,1.618,2.618,3.618,4.236].reverse(),v=l<=u?l:u,f=l<=u?u:l,y=0;y<d.length;y++){var p=c+(100-100*d[y])/100*(g-c);if(p<a+4&&a-4<p&&v<i&&i<=f)return this.getDataLen()}return"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawFibRetracement(t,a,this.calcFib(this.getData(),"FibRetracement"))}}},{key:"drawFibRetracement",value:function(t,e,i){for(var a=this.kline.getTheme(),n=e[0].x,r=e[1].x,s=Math.min(e[0].x,e[1].x),o=0;o<i.length;o++){var h=i[o].y;h=this._lineWidth%2==0?h:h-.5,g.drawStyleLine(t,this._color,n,h,r,h,this._lineWidth,this._lineStyle);var l=g.calcTextWidth(t,i[o].text,12,null,2);g.drawRect(t,a.getColors("TextMask"),s-l-2,h-7,l-2,14),g.drawText(t,i[o].text,this._color,s-l,h-6,!1,"Consolas","left")}for(var c=0;(this._selected||"none"!==this._hover)&&c<e.length;c++){var u=this._lineWidth;!this._selected&&this._hover!==c||(u=this._lineWidthHover),g.drawArc(t,a.getColors("Point"),a.getColors("Background"),e[c].x,e[c].y,this._radius,u)}}}]),t}(),ae=function(){function t(e,i){Et(this,t);var a=e.getTheme(),n={bgColor:a.getColors("ToolFibExtendBg"),color:a.getColors("ToolFibExtendColor")};return Wt(this,Bt(t).call(this,e,3,Object.assign(n,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"FibExtend"}},{key:"drawSegLine",value:function(t,e){var i=this.kline.getTheme();e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,e[1].y=this._lineWidth%2==0?e[1].y:e[1].y-.5,g.drawStyleLine(t,this._color,e[0].x,e[0].y,e[1].x,e[1].y,this._lineWidth,1);for(var a=0;(this._selected||"none"!==this._hover)&&a<e.length;a++){var n=this._lineWidth;!this._selected&&this._hover!==a||(n=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),this._bgColor,e[a].x,e[a].y,this._radius,n)}}},{key:"inPath",value:function(t,e){for(var i=e.x,a=e.y,n={x:e.x,y:e.y},r=[],s=0;s<this.getDataLen();s++){var o=this.getDataAt(s);if(Math.abs(n.x-this.getX(o.date))<10&&Math.abs(n.y-this.getY(o.price))<10)return s;r.push({x:this.getX(o.date),y:this.getY(o.price)})}for(var h=r.length-1,l=0;l<h;l++)if(!1!==this.isWithRect(r[l],r[l+1],n)&&this.calcDistance(r[l],r[l+1],n)<4)return this.getDataLen();var c,u,g=r[2].y-this._fib[0].y,d=this.getY(this.getDataAt(1).price),v=this.getY(this.getDataAt(0).price);u=r[2].x>=r[1].x?(c=this.getX(this.getDataAt(1).date),this.getX(this.getDataAt(2).date)):(c=this.getX(this.getDataAt(2).date),this.getX(this.getDataAt(1).date));for(var f=[0,.236,.382,.5,.618,.786,1,1.382,1.618,2.618,3.618,4.236].reverse(),y=0;y<f.length;y++){var p=d+g+(100-100*f[y])/100*(v-d);if(p<a+4&&a-4<p&&c<i&&i<=u)return this.getDataLen()}return"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawSegLine(t,a)}else if(3===e){for(var s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);s.push({x:this.getX(h.date),y:this.getY(h.price)})}var l=this.kline.manage.getMainChart(),c=[this.getDataAt(1),this.getDataAt(0)],u=this.calcFib(c,"FibRetracement"),g=s[2].y-u[0].y,d=[0,.236,.382,.5,.618,.786,1,1.382,1.618,2.618,3.618,4.236];u=u.map((function(t,e){t.exty=t.y+g-.5;var i=l.valToFixed(l.yCoordsToPrice(t.exty)-l.yCoordsToPrice(t.y)),a=Number(t.price)+Number(i);return t.text=parseFloat((100*d[e]).toFixed(3))+"%"+l.valToFixed(a)+"",t})),this.drawFibRetracement(t,s,u)}}},{key:"drawFibRetracement",value:function(t,e,i){this._fib=i,this.drawSegLine(t,[e[0],e[1]]),this.drawSegLine(t,[e[1],e[2]]);var a=this.kline.getTheme(),n=e[1].x,r=e[2].x,s=e[2].y-i[0].y,o=i.length-1;i[0].calcY=i[0].y+s,i[o].calcY=i[o].y+s;var h=Math.abs(i[i.length-1].calcY-i[0].calcY),l=e[1].y>=e[0].y?i[0].calcY:i[0].calcY-h;l=this._lineWidth%2==0?l:l-.5;var c=e[2].x>=e[1].x?e[1].x:e[2].x;g.drawRect(t,this._bgColor,c,l,Math.abs(r-n),h);for(var u=0;u<i.length;u++){var d=i[u].y+s;g.drawStyleLine(t,this._color,n,d,r,d,this._lineWidth,this._lineStyle);var v=g.calcTextWidth(t,i[u].text,12,null,2);g.drawRect(t,a.getColors("TextMask"),c-v-2,d-7,v-2,14),g.drawText(t,i[u].text,this._color,c-v,d-6,!1,"Consolas","left")}for(var f=0;(this._selected||"none"!==this._hover)&&f<e.length;f++){var y=this._lineWidth;!this._selected&&this._hover!==f||(y=this._lineWidthHover),g.drawArc(t,a.getColors("Point"),a.getColors("Background"),e[f].x,e[f].y,this._radius,y)}}}]),t}(),ne=function(){function t(e,i){Et(this,t);var a=e.getTheme(),n={bgColor:a.getColors("ToolFibTimeBg"),color:a.getColors("ToolFibTimeColor")};return Wt(this,Bt(t).call(this,e,3,n,Object.assign(n,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"FibTime"}},{key:"drawSegLine",value:function(t,e){var i=this.kline.getTheme();e[0].x=this._lineWidth%2==0?e[0].x+.5:e[0].x,e[1].x=this._lineWidth%2==0?e[1].x+.5:e[1].x,g.drawStyleLine(t,this._color,e[0].x,e[0].y,e[1].x,e[1].y,this._lineWidth,0);for(var a=0;(this._selected||"none"!==this._hover)&&a<e.length;a++){var n=this._lineWidth;!this._selected&&this._hover!==a||(n=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[a].x,e[a].y,this._radius,n)}}},{key:"inPath",value:function(t,e){for(var i=e.x,a=(e.y,{x:e.x,y:e.y}),n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);if(Math.abs(a.x-this.getX(s.date))<10&&Math.abs(a.y-this.getY(s.price))<10)return r;n.push({x:this.getX(s.date),y:this.getY(s.price)})}for(var o=n.length-1,h=0;h<o;h++)if(!1!==this.isWithRect(n[h],n[h+1],a)&&this.calcDistance(n[h],n[h+1],a)<4)return this.getDataLen();for(var l=n[2].x-n[0].x,c=this.getX(this.getDataAt(1).date),u=(this.getY(this.getDataAt(1).price),this.getX(this.getDataAt(0).date)),g=(this.getY(this.getDataAt(0).price),[0,.236,.382,.5,.618,.786,1,1.382,1.618,2.618,3.618,4.236].reverse()),d=0;d<g.length;d++){var v=c+l+(100-100*g[d])/100*(u-c);if(v<i+4&&i-4<v)return this.getDataLen()}return"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawSegLine(t,a)}else if(3===e){for(var s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);s.push({x:this.getX(h.date),y:this.getY(h.price)})}this.drawFibRetracement(t,s,this.calcFib([this.getDataAt(1),this.getDataAt(0)],"FibRetracement","time"))}}},{key:"drawFibRetracement",value:function(t,e,i){this.drawSegLine(t,[e[0],e[1]]),this.drawSegLine(t,[e[1],e[2]]);var a=this.kline.getTheme(),n=this.getVertPoint(),r=e[2].x-e[0].x,s=i.length-1;i[0].calcX=i[0].x+r,i[s].calcX=i[s].x+r;var o=Math.abs(i[s].calcX-i[0].calcX),h=n.y2-n.y1,l=e[1].x>=e[0].x?e[2].x:e[2].x-o;g.drawRect(t,this._bgColor,l,n.y1,o,h);for(var c=0;c<i.length;c++){var u=i[c].x+r;u=this._lineWidth%2!=0?u:u-.5,g.drawStyleLine(t,this._color,u,n.y1,u,n.y2,this._lineWidth,this._lineStyle),g.drawText(t,i[c].text,this._color,u,n.y1+40,!1,"Consolas","left")}for(var d=0;(this._selected||"none"!==this._hover)&&d<e.length;d++){var v=this._lineWidth;!this._selected&&this._hover!==d||(v=this._lineWidthHover),g.drawArc(t,a.getColors("Point"),a.getColors("Background"),e[d].x,e[d].y,this._radius,v)}}}]),t}(),re=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,2,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"FibFans"}},{key:"inPath",value:function(t,e){for(var i=e.x,a=(e.y,{x:e.x,y:e.y}),n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);if(Math.abs(a.x-this.getX(s.date))<10&&Math.abs(a.y-this.getY(s.price))<10)return r;n.push({x:this.getX(s.date),y:this.getY(s.price)})}for(var o=this.getX(this.getDataAt(0).date),h=this.getY(this.getDataAt(0).price),l=this.getX(this.getDataAt(1).date),c=this.getY(this.getDataAt(1).price),u=this.kline,g={left:0,top:0,right:u._width,bottom:u.manage.getMainChart().getViewHeight()},d=[0,38.2,50,61.8],v=0;v<d.length;v++){var f={x:o,y:h},y={x:l,y:h+(100-d[v])/100*(c-h)},p=this.getRectCrossPt(g,f,y),m=Math.pow(p[0].x-o,2)+Math.pow(p[0].y-h,2),_=Math.pow(p[0].x-l,2)+Math.pow(p[0].y-c,2)<m?{x:p[0].x,y:p[0].y}:{x:p[1].x,y:p[1].y};if(!(o<_.x&&i<o||_.x<o&&o<i||4<this.calcDistance({x:o,y:h},{x:_.x,y:_.y},a)))return this.getDataLen()}return"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawFibFans(t,a,this.calcFib(this.getData(),"FibFans"))}}},{key:"drawFibFans",value:function(t,e,i){for(var a=this.kline.manage.getMainChart(),n=this.kline.getTheme(),r=-1;r<i.length;r++){var s,o=void 0,h=void 0;s=r<0?this.calcLineTo(e[0].x,e[0].y,e[1].x,e[1].y):this.calcLineTo(e[0].x,e[0].y,e[1].x,i[r].y),h=e[0].x>e[1].x?(o=s.x1,s.y1):e[0].x<e[1].x?(o=s.x2,s.y2):(o=e[0].x,e[0].y>e[1].y?0:a.getPosiY2()),e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,h=this._lineWidth%2==0?h:h-.5,g.drawStyleLine(t,this._color,e[0].x,e[0].y,o,h,this._lineWidth,this._lineStyle)}for(var l=0;(this._selected||"none"!==this._hover)&&l<e.length;l++){var c=this._lineWidth;!this._selected&&this._hover!==l||(c=this._lineWidthHover),g.drawArc(t,n.getColors("Point"),n.getColors("Background"),e[l].x,e[l].y,this._radius,c)}}}]),t}(),se=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,3,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"YangTool"}},{key:"inPath",value:function(e,i){var a=Vt(Bt(t.prototype),"inPath",this).call(this,e,i),n=[];if("none"!==a)return a;e.save(),e.beginPath();for(var r=0;r<this.getDataLen();r++){var s=this.getDataAt(r),o={x:this.getX(s.date),y:this.getY(s.price)};n.push(o),0===r?e.moveTo(o.x,o.y):1===r?e.lineTo(o.x,o.y):(e.lineTo(o.x,o.y),e.closePath())}return e.restore(),e.isPointInPath(i.x,i.y)?this.getDataLen():"none"}},{key:"draw",value:function(t){var e=this.getDataLen(),i=[],a=this.kline.getTheme();if(this._color,1===e){var n=this.getDataAt(0);this.drawPoint(t,this.getX(n.date),this.getY(n.price),n.price)}else if(2===e){for(var r=[],s=0;s<this.getDataLen();s++){var o=this.getDataAt(s);r.push({x:this.getX(o.date),y:this.getY(o.price)})}this.drawSegLine(t,r)}else if(3===e){t.save(),t.beginPath();for(var h=0;h<this.getDataLen();h++){var l=this.getDataAt(h),c={x:this.getX(l.date),y:this.getY(l.price)};i.push(c),0===h?t.moveTo(c.x,c.y):1===h?t.lineTo(c.x,c.y):(t.lineTo(c.x,c.y),t.closePath())}t.fillStyle="rgba(255,255,255,0.5)",t.fill(),t.restore()}for(var u=0;(this._selected||"none"!==this._hover)&&u<i.length;u++){var d=this._lineWidth;!this._selected&&this._hover!==u||(d=this._lineWidthHover),g.drawArc(t,a.getColors("Point"),a.getColors("Background"),i[u].x,i[u].y,this._radius,d)}}}]),t}(),oe=function(){function t(e,i){var a;return Et(this,t),(a=Wt(this,Bt(t).call(this,e,2,i))).tipsRectW=127,a.tipsRectH=60,a}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"TimeRuler"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}var s=this.calc(this.getDataAt(0),this.getDataAt(1));this.drawRect(t,a),this.drawTips(t,s,a),this.drawArrowLine(t,a,s)}}},{key:"inPath",value:function(t,e){for(var i,a,n,r,s={x:e.x,y:e.y},o=[],h=0;h<this.getDataLen();h++){var l=this.getDataAt(h);if(Math.abs(s.x-this.getX(l.date))<10&&Math.abs(s.y-this.getY(l.price))<10)return h;o.push({x:this.getX(l.date),y:this.getY(l.price)})}return!1===this.isWithRect(o[0],o[1],s)?"none":(a=o[0].x<=o[1].x?(i=o[0].x,o[1].x):(i=o[1].x,o[0].x),r=o[0].y<=o[1].y?(n=o[0].y,o[1].y):(n=o[1].y,o[0].y),i<s.x&&s.x<=a&&n<s.y&&s.y<=r?"none":this.getDataLen())}},{key:"drawRect",value:function(t,e){this.kline;var i=this.kline.getTheme(),a=e[1].x-e[0].x,n=e[1].y-e[0].y;e[0].x=this._lineWidth%2==0?e[0].x+.5:e[0].x,e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,g.drawBorderRect(t,i.getColors("ToolBg"),e[0].x,e[0].y,a,n,this._color,this._lineWidth,this._lineStyle);for(var r=0;(this._selected||"none"!==this._hover)&&r<e.length;r++){var s=this._lineWidth;!this._selected&&this._hover!==r||(s=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[r].x,e[r].y,this._radius,s)}}},{key:"drawArrowLine",value:function(t,e,i){var a=this.kline,n=[],r=[];e[1].y<e[0].y?(n.push({x:e[0].x,y:e[1].y+(e[0].y-e[1].y)/2}),n.push({x:e[1].x,y:e[1].y+(e[0].y-e[1].y)/2}),r.push({x:e[0].x+(e[1].x-e[0].x)/2,y:e[0].y}),r.push({x:e[0].x+(e[1].x-e[0].x)/2,y:e[1].y})):e[1].y>=e[0].y&&(n.push({x:e[0].x,y:e[0].y+(e[1].y-e[0].y)/2}),n.push({x:e[1].x,y:e[0].y+(e[1].y-e[0].y)/2}),r.push({x:e[0].x+(e[1].x-e[0].x)/2,y:e[0].y}),r.push({x:e[0].x+(e[1].x-e[0].x)/2,y:e[1].y}));var s=a._theme?"#5B6060":"#637575";i.num<0?g.drawDotted(t,s,n[1].x,n[1].y,n[0].x,n[0].y):g.drawDotted(t,s,n[0].x,n[0].y,n[1].x,n[1].y),g.drawArrow(t,s,n,1,.5),e[1].y<e[0].y?g.drawDotted(t,s,r[1].x,r[1].y,r[0].x,r[0].y):e[1].y>e[0].y&&g.drawDotted(t,s,r[0].x,r[0].y,r[1].x,r[1].y),g.drawArrow(t,s,r,1,.5)}},{key:"drawTips",value:function(t,e,i){var a=this.kline,n=0,r=this.kline.manage.getMainChart();i[1].y<i[0].y?n=i[1].y-11-this.tipsRectH:i[1].y>i[0].y&&(n=i[1].y+11),n+this.tipsRectH>=r.getPosiY2()&&(n=r.getPosiY2()-this.tipsRectH-10),n<=r.getPosiY1()&&(n=10);var s=g.calcTextWidth(t,"".concat(e.price," (").concat(e.increase,")"),13),o=g.calcTextWidth(t,"".concat(e.num,"柱 ").concat(e.time),13),h=Math.max(s,o),l=(i[1].x-i[0].x)/2+i[0].x-.5*h;n=this._lineWidth%2==0?n:n-.5,g.drawRect(t,a._theme?"rgba(0, 73, 79, 0.9)":"rgba(32, 179, 190, 0.9)",l,n,h+18,this.tipsRectH),g.drawText(t,"".concat(e.price," (").concat(e.increase,")"),"#fff",9+l+.5*h,n+11,13),g.drawText(t,"".concat(e.num,"柱 ").concat(e.time),"#fff",9+l+.5*h,n+11+23,13)}},{key:"calc",value:function(t,e){var i=t,a=e,n=this.kline.zoom,r={time:0,price:0,num:0,increase:0};return a.price<i.price?(r.price=g.numberPrice(a.price-i.price,2),r.increase=g.numberToRate((a.price-i.price)/i.price,!1)):a.price>i.price&&(r.price=g.numberPrice(a.price-i.price,2),r.increase=g.numberToRate((a.price-i.price)/i.price,!1)),this.getX(i.date),this.getX(a.date),r.num=n.dateToIndex(a.date)-n.dateToIndex(i.date),r.num<0?r.time="-"+g.getTimeInterval(a.date,i.date):r.time=g.getTimeInterval(i.date,a.date),r}}]),t}(),he=function(){function t(e,i){return Et(this,t),Wt(this,Bt(t).call(this,e,3,i))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"ParallelSegLine"}},{key:"inPath",value:function(t,e){if(!e)return"none";for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}return a.push(this.paraEndPoint),!1===this.isWithRect(a[0],a[1],i)&&!1===this.isWithRect(a[2],a[3],i)?"none":this.calcDistance(a[0],a[1],i)<4||this.calcDistance(a[2],a[3],i)<4?this.getDataLen():"none"}},{key:"inBound",value:function(t,e){var i=t.x,a=t.y;return e.minX<i&&i<e.maxX&&e.minY<a&&a<e.maxY}},{key:"calc",value:function(){for(var t=[],e=[],i=[this.startPoint,this.endPoint,this.paraStartPoint,this.paraEndPoint],a=0;a<i.length;a++)t.push(i[a].x),e.push(i[a].y);return{minX:Math.min.apply(Math,t),maxX:Math.max.apply(Math,t),minY:Math.min.apply(Math,e),maxY:Math.max.apply(Math,e)}}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawSegLine(t,a)}else if(3===e){for(var s=[],o=0;o<this.getDataLen();o++){var h=this.getDataAt(o);s.push({x:this.getX(h.date),y:this.getY(h.price)})}this.drawParallelLine(t,s,3)}}},{key:"getParaPt",value:function(){var t=[];t[0]=this.endPoint.x-this.startPoint.x,t[1]=this.endPoint.y-this.startPoint.y;var e=[];e[0]=this.paraStartPoint.x-this.startPoint.x,e[1]=this.paraStartPoint.y-this.startPoint.y,this.paraEndPoint={x:-1,y:-1},this.paraEndPoint.x=t[0]+e[0]+this.startPoint.x,this.paraEndPoint.y=t[1]+e[1]+this.startPoint.y}},{key:"drawParallelLine",value:function(t,e,i){var a=this.kline,n=this.kline.getTheme();a._width,a.manage.getMainChart().getViewHeight(),this.startPoint=e[0],this.paraStartPoint=e[2],this.endPoint=e[1],this.getParaPt(),this.crossPt0=[{x:this.startPoint.x,y:this.startPoint.y},{x:this.endPoint.x,y:this.endPoint.y}],this.crossPt0[0].y=this._lineWidth%2==0?this.crossPt0[0].y:this.crossPt0[0].y-.5,this.crossPt0[1].y=this._lineWidth%2==0?this.crossPt0[1].y:this.crossPt0[1].y-.5,g.drawStyleLine(t,this._color,this.crossPt0[0].x,this.crossPt0[0].y,this.crossPt0[1].x,this.crossPt0[1].y,this._lineWidth,this._lineStyle),this.crossPt1=[{x:this.paraStartPoint.x,y:this.paraStartPoint.y},{x:this.paraEndPoint.x,y:this.paraEndPoint.y}],this.crossPt1[0].y=this._lineWidth%2==0?this.crossPt1[0].y:this.crossPt1[0].y-.5,this.crossPt1[1].y=this._lineWidth%2==0?this.crossPt1[1].y:this.crossPt1[1].y-.5,g.drawStyleLine(t,this._color,this.crossPt1[0].x,this.crossPt1[0].y,this.crossPt1[1].x,this.crossPt1[1].y,this._lineWidth,this._lineStyle);for(var r=0;(this._selected||"none"!==this._hover)&&r<e.length;r++){var s=this._lineWidth;!this._selected&&this._hover!==r||(s=this._lineWidthHover),g.drawArc(t,n.getColors("Point"),n.getColors("Background"),e[r].x,e[r].y,this._radius,s)}}}]),t}(),le=function(){function t(e,i){Et(this,t);var a=e.getTheme(),n={bgColor:a.getColors("ToolRectBg"),color:a.getColors("ToolRectColor")};return Wt(this,Bt(t).call(this,e,2,n,Object.assign(n,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"Rect"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawRect(t,a)}}},{key:"inPath",value:function(t,e){for(var i,a,n,r,s={x:e.x,y:e.y},o=[],h=0;h<this.getDataLen();h++){var l=this.getDataAt(h);if(Math.abs(s.x-this.getX(l.date))<10&&Math.abs(s.y-this.getY(l.price))<10)return h;o.push({x:this.getX(l.date),y:this.getY(l.price)})}return!1===this.isWithRect(o[0],o[1],s)?"none":(a=o[0].x<=o[1].x?(i=o[0].x,o[1].x):(i=o[1].x,o[0].x),r=o[0].y<=o[1].y?(n=o[0].y,o[1].y):(n=o[1].y,o[0].y),i<s.x&&s.x<=a&&n<s.y&&s.y<=r?"none":this.getDataLen())}},{key:"drawRect",value:function(t,e){this.kline;var i=this.kline.getTheme(),a=e[1].x-e[0].x,n=e[1].y-e[0].y;e[0].x=this._lineWidth%2==0?e[0].x+.5:e[0].x,e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5,g.drawBorderRect(t,this._bgColor,e[0].x,e[0].y,a,n,this._color,this._lineWidth,this._lineStyle);for(var r=0;(this._selected||"none"!==this._hover)&&r<e.length;r++){var s=this._lineWidth;!this._selected&&this._hover!==r||(s=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[r].x,e[r].y,this._radius,s)}}}]),t}(),ce=function(){function t(e,i){Et(this,t);var a={color:e.getTheme().getColors("ToolMHeadWBaseColor")};return Wt(this,Bt(t).call(this,e,5,a,Object.assign(a,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"MHeadWBase"}},{key:"draw",value:function(t){if(1===this.getDataLen()){var e=this.getDataAt(0),i=this.getX(e.date),a=this.getY(e.price);this.drawPoint(t,i,a,e.price),this.drawPointText(t,[{x:i,y:a}])}else{for(var n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);n.push({x:this.getX(s.date),y:this.getY(s.price)})}this.drawSeriesLine(t,n),this.drawPointText(t,n)}}},{key:"drawPointText",value:function(t,e){for(var i=0;i<e.length;i++){var a=i%2==0?e[i].y+14:e[i].y-20;g.drawText(t,"(".concat(i,")"),this._color,e[i].x-6,a,!1,"Consolas","left")}}},{key:"inPath",value:function(t,e){for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}for(var s=a.length-1,o=0;o<s;o++)if(!1!==this.isWithRect(a[o],a[o+1],i)&&this.calcDistance(a[o],a[o+1],i)<4)return this.getDataLen();return"none"}},{key:"drawSeriesLine",value:function(t,e){for(var i=e.length-1,a=this.kline.getTheme(),n=0;n<i;n++)this.drawSegLine(t,[e[n],e[n+1]]);for(var r=0;(this._selected||"none"!==this._hover)&&r<e.length;r++){var s=this._lineWidth;!this._selected&&this._hover!==r||(s=this._lineWidthHover),g.drawArc(t,a.getColors("Point"),a.getColors("Background"),e[r].x,e[r].y,this._radius,s)}}}]),t}(),ue=function(){function t(e,i){Et(this,t);var a=e.getTheme(),n={bgColor:a.getColors("ToolHeadShoulderBg"),color:a.getColors("ToolHeadShoulderColor")};return Wt(this,Bt(t).call(this,e,7,Object.assign(n,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"HeadShoulder"}},{key:"draw",value:function(t){if(1===this.getDataLen()){var e=this.getDataAt(0),i=this.getX(e.date),a=this.getY(e.price);this.drawPoint(t,i,a,e.price)}else{for(var n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);n.push({x:this.getX(s.date),y:this.getY(s.price),text:this.getPointText(r)})}this.drawSeriesLine(t,n),this.drawPointText(t,n)}}},{key:"getPointText",value:function(t){return 1===t?"左肩":3===t?"头部":5===t?"右肩":""}},{key:"drawPointText",value:function(t,e){for(var i=0;i<e.length;i++)if(e[i].text){var a=e[i].y-20,n=e[i].x-6,r=g.calcTextWidth(t,e[i].text,12,null,2);g.drawRect(t,this._color,n-1,a-1,r,14),g.drawText(t,"".concat(e[i].text),"#fff",n,a,!1,"Consolas","left")}}},{key:"inPath",value:function(t,e){for(var i={x:e.x,y:e.y},a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);if(Math.abs(i.x-this.getX(r.date))<10&&Math.abs(i.y-this.getY(r.price))<10)return n;a.push({x:this.getX(r.date),y:this.getY(r.price)})}for(var s=a.length-1,o=0;o<s;o++)if(!1!==this.isWithRect(a[o],a[o+1],i)&&this.calcDistance(a[o],a[o+1],i)<4)return this.getDataLen();var h={x:this._cx1,y:this._cy1},l={x:this._cx2,y:this._cy2};return this.calcDistance(h,l,i)<4?this.getDataLen():"none"}},{key:"drawSeriesLine",value:function(t,e){for(var i,a,n=e.length-1,r=this.kline.getTheme(),s=0;s<n;s++)this.drawSegLine(t,[e[s],e[s+1]]);if(e[4]){var o=this.calcLineTo(e[2].x,e[2].y,e[4].x,e[4].y);g.drawPolygon(t,this._bgColor,[e[2],e[3],e[4]],this._bgColor),(i=g.segmentsIntr(e[0],e[1],{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}))&&g.drawPolygon(t,this._bgColor,[i,e[1],e[2]],this._bgColor),e[6]&&(a=g.segmentsIntr(e[5],e[6],{x:o.x1,y:o.y1},{x:o.x2,y:o.y2}))&&g.drawPolygon(t,this._bgColor,[a,e[4],e[5]],this._bgColor),this._cx1=i?i.x:o.x1,this._cy1=i?i.y:o.y1,this._cx2=a?a.x:o.x2,this._cy2=a?a.y:o.y2,this._cy1=this._lineWidth%2==0?this._cy1:this._cy1-.5,this._cy2=this._lineWidth%2==0?this._cy2:this._cy2-.5,g.drawStyleLine(t,this._color,this._cx1,this._cy1,this._cx2,this._cy2,this._lineWidth,this._lineStyle)}for(var h=0;(this._selected||"none"!==this._hover)&&h<e.length;h++){var l=this._lineWidth;!this._selected&&this._hover!==h||(l=this._lineWidthHover),g.drawArc(t,r.getColors("Point"),r.getColors("Background"),e[h].x,e[h].y,this._radius,l)}}}]),t}(),ge=function(){function t(e,i){Et(this,t);var a=e.getTheme(),n={bgColor:a.getColors("ToolEllipseBg"),color:a.getColors("ToolEllipseColor")};return Wt(this,Bt(t).call(this,e,2,Object.assign(n,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"Ellipse"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawEllipse(t,a)}}},{key:"inPath",value:function(t,e){for(var i=e.x,a=e.y,n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);if(Math.abs(i-this.getX(s.date))<10&&Math.abs(a-this.getY(s.price))<10)return r;n.push({x:this.getX(s.date),y:this.getY(s.price)})}var o=Math.abs(this._f1.x-i),h=Math.abs(this._f1.y-a),l=Math.abs(this._f2.x-i),c=Math.abs(this._f2.y-a),u=Math.sqrt(Math.pow(o,2)+Math.pow(h,2)),g=Math.sqrt(Math.pow(l,2)+Math.pow(c,2)),d=this._absA>=this._absB?2*this._absA:2*this._absB;return Math.abs(d-u-g)<10?this.getDataLen():"none"}},{key:"drawEllipse",value:function(t,e){var i=this.kline.getTheme();e[0].x=this._lineWidth%2==0?e[0].x+.5:e[0].x,e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5;var a=(e[1].x-e[0].x)/2,n=(e[1].y-e[0].y)/2,r=e[0].x+a,s=e[0].y+n;this._absA=Math.abs(a),this._absB=Math.abs(n),g.drawEllipse(t,r,s,this._absA,this._absB,0,2*Math.PI,this._bgColor,this._color,this._lineWidth,this._lineStyle),this._absA>=this._absB?(this._c=Math.sqrt(Math.pow(a,2)-Math.pow(n,2)),this._f1={x:r-this._c,y:s},this._f2={x:r+this._c,y:s}):(this._c=Math.sqrt(Math.pow(n,2)-Math.pow(a,2)),this._f1={x:r,y:s-this._c},this._f2={x:r,y:s+this._c});for(var o=0;(this._selected||"none"!==this._hover)&&o<e.length;o++){var h=this._lineWidth;!this._selected&&this._hover!==o||(h=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[o].x,e[o].y,this._radius,h)}}}]),t}(),de=function(){function t(e,i){Et(this,t);var a={color:e.getTheme().getColors("ToolArcColor")};return Wt(this,Bt(t).call(this,e,2,Object.assign(a,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"Arc"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawEllipse(t,a)}}},{key:"inPath",value:function(t,e){for(var i=e.x,a=e.y,n=[],r=0;r<this.getDataLen();r++){var s=this.getDataAt(r);if(Math.abs(i-this.getX(s.date))<10&&Math.abs(a-this.getY(s.price))<10)return r;n.push({x:this.getX(s.date),y:this.getY(s.price)})}var o=Math.abs(this._f1.x-i),h=Math.abs(this._f1.y-a),l=Math.abs(this._f2.x-i),c=Math.abs(this._f2.y-a),u=Math.sqrt(Math.pow(o,2)+Math.pow(h,2)),g=Math.sqrt(Math.pow(l,2)+Math.pow(c,2)),d=this._absA>=this._absB?2*this._absA:2*this._absB;return Math.abs(d-u-g)<10?this.getDataLen():"none"}},{key:"drawEllipse",value:function(t,e){var i=this.kline.getTheme();e[0].x=this._lineWidth%2==0?e[0].x+.5:e[0].x,e[0].y=this._lineWidth%2==0?e[0].y:e[0].y-.5;var a,n,r=e[1].y-e[0].y,s=e[1].x-e[0].x,o=e[1].x,h=e[0].y;this._absA=Math.abs(r),this._absB=Math.abs(s),n=e[1].y>=e[0].y?(a=0,Math.PI):(a=0,-Math.PI),g.drawRadian(t,o,h,this._absB,this._absA,a,n,this._color,this._lineWidth,this._lineStyle),this._absA>=this._absB?(this._c=Math.sqrt(Math.pow(r,2)-Math.pow(s,2)),this._f1={x:o,y:h+this._c},this._f2={x:o,y:h-this._c}):(this._c=Math.sqrt(Math.pow(s,2)-Math.pow(r,2)),this._f1={x:o+this._c,y:h},this._f2={x:o-this._c,y:h});for(var l=0;(this._selected||"none"!==this._hover)&&l<e.length;l++){var c=this._lineWidth;!this._selected&&this._hover!==l||(c=this._lineWidthHover),g.drawArc(t,i.getColors("Point"),i.getColors("Background"),e[l].x,e[l].y,this._radius,c)}}}]),t}(),ve=function(){function t(e,i){Et(this,t);var a={color:e.getTheme().getColors("ToolFibCycleColor")};return Wt(this,Bt(t).call(this,e,2,Object.assign(a,i)))}return Yt(t,Ht),Xt(t,[{key:"getName",value:function(){return"FibCycle"}},{key:"inPath",value:function(t,e){for(var i=e.x,a=(e.y,e.x),n=e.y,r=[],s=0;s<this.getDataLen();s++){var o=this.getDataAt(s);if(Math.abs(a-this.getX(o.date))<10&&Math.abs(n-this.getY(o.price))<10)return s;r.push({x:this.getX(o.date),y:this.getY(o.price)})}for(var h=this.getX(this.getDataAt(1).date),l=(this.getY(this.getDataAt(1).price),this.getX(this.getDataAt(0).date)),c=(this.getY(this.getDataAt(0).price),[0,1,2,3,5,8,13,21,34].reverse()),u=0;u<c.length;u++){var g=h+(100-100*c[u])/100*(l-h);if(g<i+4&&i-4<g)return this.getDataLen()}return"none"}},{key:"draw",value:function(t){var e=this.getDataLen();if(1===e){var i=this.getDataAt(0);this.drawPoint(t,this.getX(i.date),this.getY(i.price),i.price)}else if(2===e){for(var a=[],n=0;n<this.getDataLen();n++){var r=this.getDataAt(n);a.push({x:this.getX(r.date),y:this.getY(r.price)})}this.drawFibRetracement(t,a,this.calcFib([this.getDataAt(1),this.getDataAt(0)],"FibCycle","cycle"))}}},{key:"drawFibRetracement",value:function(t,e,i){for(var a=this.kline.getTheme(),n=this.getVertPoint(),r=0;r<i.length;r++){var s=i[r].x;s=this._lineWidth%2!=0?s:s-.5,g.drawStyleLine(t,this._color,s,n.y1,s,n.y2,this._lineWidth,this._lineStyle),g.drawText(t,i[r].text,this._color,s+2,n.y1+40,!1,"Consolas","left")}for(var o=0;(this._selected||"none"!==this._hover)&&o<e.length;o++){var h=this._lineWidth;!this._selected&&this._hover!==o||(h=this._lineWidthHover),g.drawArc(t,a.getColors("Point"),a.getColors("Background"),e[o].x,e[o].y,this._radius,h)}}}]),t}();function fe(t){return(fe="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 ye(t,e){return!e||"object"!==fe(e)&&"function"!=typeof e?me(t):e}function pe(t){return(pe=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function me(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _e(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&&function(t,e){(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}function ke(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ae(t,e){for(var i=0;i<e.length;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 xe(t,e,i){return e&&Ae(t.prototype,e),i&&Ae(t,i),t}var we=function(){function t(e,i,a,n){ke(this,t),this._posi=i.posi,this._isClean=!1,this._indicators=[],this._oldIndicators=[],this._tools=[],this._name=a,this.kline=e,this._indicatorPaddingTop=24,this._icons=[],this._barHeight=22;for(var r=0;r<i.indicators.length;r++)this.setIndicators(this.creatIndicators(i.indicators[r]));this._lineH=18,this.calcMaxMinVal(),this.creatIcons()}return xe(t,[{key:"creatIcons",value:function(){var t=[];t.push(new O(this.kline,this)),this._icons=t}},{key:"creatIndicators",value:function(t){var e;switch(t){case"TimeShare":e=new At(this.kline);break;case"CandleStick":e=new xt(this.kline);break;case"CandleStickHLC":e=new wt(this.kline);break;case"OHLC":e=new Ct(this.kline);break;case"MA":e=new j(this.kline,this);break;case"EMA":e=new G(this.kline,this);break;case"BOLL":e=new K(this.kline,this);break;case"SAR":e=new Q(this.kline,this);break;case"VOLUME":e=new q(this.kline,this);break;case"MACD":e=new Z(this.kline,this);break;case"KDJ":e=new $(this.kline,this);break;case"OBV":e=new tt(this.kline,this);break;case"RSI":e=new et(this.kline,this);break;case"TRIX":e=new it(this.kline,this);break;case"WR":e=new at(this.kline,this);break;case"CCI":e=new nt(this.kline,this);break;case"ROC":e=new rt(this.kline,this);break;case"ATR":e=new st(this.kline,this);break;case"DMI":e=new ot(this.kline,this);break;case"VR":e=new ht(this.kline,this);break;case"PSY":e=new lt(this.kline,this);break;case"BIAS":e=new ct(this.kline,this);break;case"Yang":e=new ut(this.kline,this);break;case"DEPTH":e=new gt(this.kline,this);break;case"ORDER":e=new dt(this.kline,this)}return e}},{key:"setIndicators",value:function(t){t&&this._indicators.push(t)}},{key:"getName",value:function(){return this._name}},{key:"getPosi",value:function(){return this._posi}},{key:"getIndex",value:function(){var t=this,e=this.kline.manage.getCharts();return e.length?e.findIndex((function(e){return e.getName()===t.getName()})):-1}},{key:"getPosiY1",value:function(){return this._posi.y}},{key:"getPosiY2",value:function(){return this._posi.y+this._posi.h}},{key:"getMinusBarY2",value:function(){return this.getPosiY2()-(this.getBarVisible()?this._barHeight:0)}},{key:"getViewWidth",value:function(){return this._posi.w-this.kline.layout.getAxisWidth()}},{key:"changeTools",value:function(t){this._tools=t}},{key:"getViewHeight",value:function(){return this._posi.h-this._posi.pad[0]-this._posi.pad[2]-(this.getBarVisible()?this._barHeight:0)}},{key:"getMax",value:function(){return this._maxAndMinVal[0]}},{key:"getMin",value:function(){return this._maxAndMinVal[1]}},{key:"getBarVisible",value:function(){return this.kline.getIndicatorsBar()}},{key:"getY",value:function(t){var e=this._maxAndMinVal[0],i=this._maxAndMinVal[1];if("main"===this._name&&this.kline.getLog()&&(t=Math.log(t)/Math.log(10)),"main"===this._name)return this._posi.y+this._posi.pad[0]+Math.floor(this.getViewHeight()/(e-i)*(e-t));var a=this.getViewHeight()-this._indicatorPaddingTop;return this._posi.y+this._indicatorPaddingTop+Math.floor(a/(e-i)*(e-t))}},{key:"update",value:function(){for(var t=0;t<this._indicators.length;t++)this._indicators[t].calc&&this._indicators[t].calc();this.calcMaxMinVal()}},{key:"resize",value:function(t){this._posi=t,this.calcMaxMinVal()}},{key:"defaultInputOutput",value:function(t,e){for(var i=0;i<this._indicators.length;i++)this._indicators[i].getName()===t&&this._indicators[i].defaultInputOutput(e)}},{key:"modifyIndicatorParams",value:function(t,e){for(var i=0;i<this._indicators.length;i++)this._indicators[i].getName()===t&&this._indicators[i].updateParameter(e)}},{key:"modifyIndicatorOutput",value:function(t,e,i){for(var a=0;a<this._indicators.length;a++)this._indicators[a].getName()===t&&this._indicators[a].modifyIndicatorOutput(e,i)}},{key:"defaultIndicatorParams",value:function(t){for(var e=0;e<this._indicators.length;e++)this._indicators[e].getName()===t&&this._indicators[e].defaultParameter()}},{key:"calcMaxMinVal",value:function(){for(var t,e=this.kline,i=-g.getJsMaxValue(),a=g.getJsMaxValue(),n=e.getTheme(),r=0;r<this._indicators.length;r++){var s=this._indicators[r].calcMaxMinVal();i=Math.max(i,s[0]),a=Math.min(a,s[1])}this._places=g.calcPairNamePlaces(i,a,e.getPairName()),t="VOLUME"===this._name?g.numberRang(i):this.valToFixed(i),"main"===this._name&&this.kline.getLog()&&(i=Math.log(i)/Math.log(10),a=Math.log(a)/Math.log(10)),this._rang=g.calcInterval(this._posi.h,i,a),a="main"===this._name&&this.kline.getLog()?(i+=this._rang,0===a?a:a-this._rang):"main"===this._name?(i=this.valToFixed(i+this._rang),this.valToFixed(0===a?a:a-this._rang)):(i=this.valToFixed(i),this.valToFixed(a));var o=g.calcTextWidth(e._mainContext,t,!1,!1,20);if(e.layout.setAxisWidth(o,this._isClean),"main"!==this._name){var h,l=this._name,c=e._indicatorParams&&e._indicatorParams[l].maxLimit||z.IndicatorConfig(n)[l].maxLimit;e._indicatorParams&&(h=void 0!==e._indicatorParams[l].minLimit?e._indicatorParams[l].minLimit:z.IndicatorConfig(n)[l].minLimit),c&&(i=Math.max(i,c)),void 0!==h&&(a=(a=Math.min(a,h))<=0?0:a)}this._maxAndMinVal=[parseFloat(i),parseFloat(a)]}},{key:"yCoordsToPrice",value:function(t){var e,i=this._maxAndMinVal[0],a=this._maxAndMinVal[1];return e="main"!==this._name?i-(i-a)/(this.getViewHeight()-this._indicatorPaddingTop)*(t-this._indicatorPaddingTop-this._posi.y-this._posi.pad[0]):i-(i-a)/this.getViewHeight()*(t-this._posi.y-this._posi.pad[0]),"main"===this._name&&this.kline.getLog()&&(e=Math.pow(10,e)),"VOLUME"===this._name?g.numberRang(e):this.valToFixed(e)}},{key:"valToFixed",value:function(t){return"string"==typeof t&&(t=Number(t)),g.formatSignificantDigit(t)}},{key:"drawGrid",value:function(t,e){var i=this.kline,a=i.getTheme(),n=i.zoom.getX(e)+i.zoom.getItemHalfWidth();g.drawLine(t,a.getColors("Grid"),n,this.getPosiY1(),n,this.getBarVisible()?this.getMinusBarY2()-1:this.getPosiY2()-1)}},{key:"drawRang",value:function(t){var e=this.kline,i=e.zoom.getItemFirst(),a=e.zoom.getItemLast(),n=e.getTheme(),r=this.getViewWidth(),s=this.getMinusBarY2();g.drawLine(t,n.getColors("Frame"),r+.5,this.getPosiY1(),r+.5,this.getPosiY2());for(var o="main"===this._name?this._maxAndMinVal[0]-this._rang:this._maxAndMinVal[0];o>this._maxAndMinVal[1];o-=this._rang){var h="",l=Math.floor(o/this._rang)*this._rang,c=this.getY(l);if("main"===this._name&&e.getLog()?(h=this.valToFixed(Math.pow(10,l)),c=this.getY(h)):h="VOLUME"===this._name?g.numberRang(l):"RSI"===this._name?l.toFixed(2):this.valToFixed(l),s-10<c)break;g.drawLine(t,n.getColors("Grid"),0,c-.5,r-1,c-.5),g.drawLine(t,n.getColors("Frame"),r,c-.5,r+5,c-.5),g.drawText(t,h,n.getColors("RangText"),r+10,c-6,!1,!1,"left")}e.timeline.resetLastIndex();for(var u=a;u<i;u++)e.timeline.dateText(u,e.timeline.fillGrid.bind(e.timeline,t,u,this.drawGrid.bind(this)))&&this.drawGrid(t,u)}},{key:"getIcons",value:function(){return this._icons}},{key:"drawIndicators",value:function(t){for(var e=0;e<this._indicators.length;e++)this._indicators[e].drawIndicatorRang&&this._indicators[e].drawIndicatorRang(t,this),this._indicators[e].draw(t,this)}},{key:"drawMain",value:function(t){var e=this.kline.getTheme();g.drawLine(t,e.getColors("Frame"),this._posi.x,this.getPosiY2()-.5,this._posi.w,this.getPosiY2()-.5),this.drawRang(t),this.drawIndicators(t);var i=this.getViewWidth(),a=this.getMinusBarY2();g.drawLine(t,e.getColors("Frame"),0,a-.5,i,a-.5)}},{key:"drawOverlay",value:function(t){if(this._posi.textY=this._posi.y,0<this._tools.length){if(!this.kline.getToolsVisible())for(var e=0;e<this._tools.length;e++)this._tools[e].draw(t);t.clearRect(this.getViewWidth(),0,this.kline.layout.getAxisWidth(),this._posi.h),t.clearRect(0,this._posi.h,this._posi.w,this.kline.getHeight()-this._posi.h)}for(var i=0;i<this._indicators.length;i++){var a=this.getIcons();"main"===this._name&&0===i?(this._indicators[i].drawOverlay(t,this),a[0].setParams({x:5,y:this._posi.textY+6,width:16,height:16}),a[0].draw(t)):("main"===this._name&&0!==i||(a[0].setParams({x:5,y:this._posi.textY+6,width:16,height:16}),a[0].draw(t)),this._indicators[i].drawOverlay(t,this))}this.getBarVisible()&&this.bar&&this.bar.draw(t);var n=this.kline,r=n.getTheme(),s=n.manage.getHover(),o=n.zoom.getX(s)+n.zoom.getItemHalfWidth(),h=n.manage.getHoverY();if(this._posi.y<h&&this.getPosiY2()>h){var l=n.layout.getAxisWidth(),c=this.getViewWidth();0<=s&&g.drawDotted(t,r.getColors("SelectionBg"),0,h-.5,c-1,h-.5,5,5),g.drawRect(t,r.getColors("SelectionBg"),c,h-10,l,19),g.drawLine(t,r.getColors("SelectionText"),c,h-.5,c+5,h-.5),g.drawText(t,this.yCoordsToPrice(h),r.getColors("SelectionText"),c+10,h-6,!1,!1,"left")}0<=s&&g.drawDotted(t,r.getColors("SelectionBg"),o,0,o,this.getPosiY2(),5,5)}}]),t}(),Ce=function(){function t(e,i,a){var n;ke(this,t),(n=ye(this,pe(t).call(this,e,i,a)))._isClean=!0,n._tools=[];for(var r=i.tools,s=0;s<r.length;s++)n.creatTools(r[s].type,r[s]);return n.bar=new St(e,me(n)),n}return _e(t,we),xe(t,[{key:"creatTools",value:function(t,e){var i,a=1<arguments.length&&void 0!==e?e:{};switch(t){case"HorzLine":i=new Ut(this.kline,a);break;case"VertLine":i=new Jt(this.kline,a);break;case"CrossLine":i=new zt(this.kline,a);break;case"SegLine":i=new jt(this.kline,a);break;case"HoriSegLine":i=new Gt(this.kline,a);break;case"StraightLine":i=new Kt(this.kline,a);break;case"ArrowLine":i=new Qt(this.kline,a);break;case"RayLine":i=new qt(this.kline,a);break;case"PriceLine":i=new te(this.kline,a);break;case"ParallelLine":i=new Zt(this.kline,a);break;case"ParallelRayLine":i=new $t(this.kline,a);break;case"FibRetracement":i=new ee(this.kline,a);break;case"FibSegLine":i=new ie(this.kline,a);break;case"FibExtend":i=new ae(this.kline,a);break;case"FibTime":i=new ne(this.kline,a);break;case"FibFans":i=new re(this.kline,a);break;case"YangTool":i=new se(this.kline,a);break;case"TimeRuler":i=new oe(this.kline,a);break;case"ParallelSegLine":i=new he(this.kline,a);break;case"Rect":i=new le(this.kline,a);break;case"MHeadWBase":i=new ce(this.kline,a);break;case"HeadShoulder":i=new ue(this.kline,a);break;case"Ellipse":i=new ge(this.kline,a);break;case"Arc":i=new de(this.kline,a);break;case"FibCycle":i=new ve(this.kline,a);break;default:return}this.setTools(i,a.type)}},{key:"setTools",value:function(t,e){1<arguments.length&&void 0!==e&&e||this.kline._on&&this.kline._on.setToolBack&&this.kline._on.setToolBack(t,this._tools.length),this._tools.push(t)}},{key:"clearNoOverTools",value:function(){for(var t=this._tools.length-1;0<=t;t--)this._tools[t].isOVer()||this._tools.splice(t,1)}},{key:"getTools",value:function(){return this._tools}},{key:"getTool",value:function(){return this._tools[this._tools.length-1]}},{key:"cleanTools",value:function(){this._tools=[]}},{key:"saveTools",value:function(){var t=this._tools.map((function(t){return t.getParams()}));this.kline._on&&this.kline._on.toolSave&&this.kline._on.toolSave(t)}},{key:"modifyIndicators",value:function(t,e){var i=[];if(Array.isArray(t))for(var a=0;a<t.length;a++)this._indicators.indexOf(-1===t[a])&&i.push(this.creatIndicators(t[a]));else i=this.creatIndicators(t);i&&("TimeShare"===this._indicators[0].getName()?0==e?this._oldIndicators[e]=i:this._oldIndicators=[this._oldIndicators[0]].concat(i):0==e?this._indicators[e]=i:this._indicators=[this._indicators[0]].concat(i))}},{key:"timeShare",value:function(t){if(t){var e=this.creatIndicators("TimeShare");"TimeShare"!==this._indicators[0].getName()&&(this._oldIndicators=this._indicators.slice(0)),this._indicators=[e]}else 0<this._oldIndicators.length&&(this._indicators=this._oldIndicators.slice(0))}}]),t}(),be=function(){function t(e,i,a){var n;return ke(this,t),(n=ye(this,pe(t).call(this,e,i,a))).bar=new Nt(e,me(n)),n}return _e(t,we),xe(t,[{key:"replaceIndicator",value:function(t){this._name=t,this._indicators.pop(),this.setIndicators(this.creatIndicators(t)),this.calcMaxMinVal()}}]),t}();function Te(t,e){for(var i=0;i<e.length;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)}}var Me=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._chart=[],this._hover=-1,this._hoverY=0,this._tools=!1,this.kline=e,this.init()}return function(t,e,i){e&&Te(t.prototype,e)}(t,[{key:"creatChart",value:function(t,e,i){var a;switch(t){case"main":a=new Ce(this.kline,e,i);break;case"deputy":a=new be(this.kline,e,i)}return a}},{key:"creatMainChart",value:function(t,e){var i={posi:{w:0,h:0,x:0,y:0,pad:[0,0,5,0]},indicators:t,tools:this.kline._tools};return new Ce(this.kline,i,e)}},{key:"creatDeputyChart",value:function(t){var e={posi:{w:0,h:0,x:0,y:0,pad:[0,0,5,0]},indicators:[t]};return new be(this.kline,e,t)}},{key:"setChart",value:function(t){this._chart.push(t)}},{key:"removeChart",value:function(t){for(var e=0;e<this._chart.length;e++)if(this._chart[e].getName()===t){this._chart.splice(e,1),this.resize();break}}},{key:"replaceChart",value:function(t,e){for(var i=0;i<this._chart.length;i++)if(this._chart[i].getName()===e){this._chart[i].replaceIndicator(t);break}}},{key:"getChartLen",value:function(){return this._chart.length}},{key:"getCharts",value:function(){return this._chart}},{key:"getMainChart",value:function(){return this._chart[0]}},{key:"getViewWidth",value:function(){return this.kline.getWidth()-this.kline.layout.getAxisWidth()}},{key:"getViewHeight",value:function(){return this.kline.getHeight()-this.kline.layout.getAxisHeight()}},{key:"getHover",value:function(){return this._hover}},{key:"setHover",value:function(t){t>=this.kline.zoom.getItemLast()&&t<this.kline.zoom.getItemFirst()?this._hover=t:this._hover=-1}},{key:"getHoverY",value:function(){return this._hoverY}},{key:"setHoverY",value:function(t){this._hoverY=t}},{key:"clearHover",value:function(){this._hover=-1,this._hoverY=0}},{key:"getTools",value:function(){return this._tools}},{key:"setTools",value:function(t,e){(this._tools=t)||e||this.kline._on&&this.kline._on.toolCallBack()}},{key:"init",value:function(){this.setChart(this.creatMainChart(this.kline.getMainIndicators(),"main"));for(var t=this.kline.getIndicators(),e=0;e<t.length;e++)this.setChart(this.creatDeputyChart(t[e]));this.resize()}},{key:"update",value:function(){for(var t=0;t<this._chart.length;t++)this._chart[t].update()}},{key:"updateMaxAndMin",value:function(){for(var t=0;t<this._chart.length;t++)this._chart[t].calcMaxMinVal()}},{key:"getDeputyChartFactor",value:function(){var t=this._chart.length-1;return 1==t?.26:2==t?.2:3==t?.18:.15}},{key:"resize",value:function(){for(var t=this._chart.length,e=this.getViewHeight(),i=0;i<t;i++){var a={w:this.kline.getWidth(),x:0};0===i?(a.h=e-Math.floor(e*this.getDeputyChartFactor())*(t-1),a.y=0,a.pad=[0,0,0,0]):(a.h=Math.floor(e*this.getDeputyChartFactor()),a.y=e-a.h*(t-i),a.pad=[0,0,5,0]),this._chart[i].resize(a)}}},{key:"defaultInputOutput",value:function(t,e){for(var i=0;i<this._chart.length;i++)this._chart[i].defaultInputOutput(t,e)}},{key:"modifyIndicatorParams",value:function(t,e){for(var i=0;i<this._chart.length;i++)this._chart[i].modifyIndicatorParams(t,e)}},{key:"modifyIndicatorOutput",value:function(t,e,i){for(var a=0;a<this._chart.length;a++)this._chart[a].modifyIndicatorOutput(t,e,i)}},{key:"defaultIndicatorParams",value:function(t){for(var e=0;e<this._chart.length;e++)this._chart[e].defaultIndicatorParams(t)}},{key:"drawMain",value:function(t){for(var e=0;e<this._chart.length;e++)this._chart[e].drawMain(t)}},{key:"drawOverlay",value:function(t){for(var e=0;e<this._chart.length;e++)this._chart[e].drawOverlay(t)}}]),t}();function De(t,e){for(var i=0;i<e.length;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)}}var Pe=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._mouseMove=null,this._mouseDown=null,this._selectedTools=!1,this._selectedToolsIndex=-1,this.kline=e,this._mouseDownButton=-1,this._chartIsMove=null,this.bindMouseEvent()}return function(t,e,i){e&&De(t.prototype,e)}(t,[{key:"setChartIsMove",value:function(t){var e=this.kline.getEl();t&&t.index!==this.kline.getCharts().length-1?(this._chartIsMove=t,e.style.cursor="s-resize"):(this._chartIsMove=null,"default"!==e.style.cursor&&(e.style.cursor="default"))}},{key:"inChartBottomEdge",value:function(t,e){for(var i=1<arguments.length&&void 0!==e?e:5,a=this.kline.getCharts(),n=0;n<a.length;n++){var r=a[n],s=r.getPosiY2();if(s-i<t&&t<s+i)return{chart:r,index:n}}}},{key:"iconsHoverEvent",value:function(t,e){for(var i=!1,a=this.kline.getCharts(),n=0;n<a.length;n++){var r=a[n];if(r._icons)for(var s=0;s<r._icons.length;s++)r._icons[s].mouseEvent(t,e)&&(i=!0);for(var o=0;o<r._indicators.length;o++){var h=r._indicators[o];if(h._icons)for(var l=0;l<h._icons.length;l++)h._icons[l].mouseEvent(t,e)&&(i=!0)}}return i}},{key:"iconsClickEvent",value:function(t,e){for(var i=this.kline.manage.getCharts(),a=0;a<i.length;a++){var n=i[a];if(n._icons)for(var r=0;r<n._icons.length&&!n._icons[r].clickEvent(t,e);r++);for(var s=0;s<n._indicators.length;s++){var o=n._indicators[s];if(o._icons)for(var h=0;h<o._icons.length&&!o._icons[h].clickEvent(t,e);h++);}}}},{key:"toolsClickEvent",value:function(t,e){for(var i=this.kline.manage.getMainChart(),a=i.getTools(),n=0;n<a.length;n++)a[n].clickEvent(t,e);this._selectedTools=!1;for(var r=0;r<a.length;r++)if(this._selectedTools=a[r].clickEvent(t,e),this._selectedTools){var s=a.splice(r,1);a=a.concat(s),i.changeTools(a),this._selectedToolsIndex=a.length-1;break}}},{key:"chartBarClickEvent",value:function(t,e){for(var i=this.kline.manage.getCharts(),a=0;a<i.length&&!i[a].bar.clickEvent(t,e);a++);}},{key:"chartBarHoverEvent",value:function(t,e,i){for(var a=this.kline.manage.getCharts(),n=0;n<a.length;n++){var r=a[n].bar.mouseEvent(t,e,i);if(r)return r}return!1}},{key:"indicatorsHoverEvent",value:function(t,e){for(var i=this.kline.manage.getMainChart()._indicators,a=0;a<i.length;a++)if(i[a].mouseEvent){var n=i[a].mouseEvent(t,e);if(n)return this.kline._el.style.cursor="pointer",n}return!1}},{key:"timelineHoveEvent",value:function(t,e){var i=this.kline.timeline;i.logInPath&&i.logInPath(t,e)}},{key:"isInChartBar",value:function(t){for(var e=t.offsetY,i=this.kline.manage.getCharts(),a=0;a<i.length;a++){var n=i[a].getMinusBarY2(),r=i[a].getPosiY2();if(n<=e&&e<r)return!0}return!1}},{key:"bindMouseEvent",value:function(){var t=this,e=this.kline,i=e.manage,a=e.zoom,n=e.getMainContext();function r(n){if(t._mouseMove){n.preventDefault();var r=n.wheelDelta||n.detail;a.scale(0<r?1:-1)&&(i.setHover(a.xCoordsToIndex(t._mouseMove.x)),e.draw())}}e._el.onmousemove=function(r){var s=e._el.getAttribute("id"),o=r.offsetX,h=r.offsetY;t._mouseMove={x:o,y:h};var l=i.getMainChart(),c=a.xCoordsToIndex(o);if(i.getTools()){if(h>l.getPosiY1()&&h<=l.getMinusBarY2()-10){var u=l.getTool();u.setData({date:a.indexToDate(c),price:u.getPrice(c,h)}),e.draw("Overlay")}}else if(t._mouseDown){if(2===t._mouseDownButton)return;i.clearHover();var g=t._selectedTools;if(g){if(g._isLock)return;t.kline._el.style.cursor="grabbing",h>l.getPosiY1()&&h<=l.getMinusBarY2()-10&&(g.isMovePoint()?g.updateData({date:a.indexToDate(c),price:g.getPrice(c,h)}):g.updateData({ind:c-a.xCoordsToIndex(t._mouseDown.x),price:l.valToFixed(l.yCoordsToPrice(h)-l.yCoordsToPrice(t._mouseDown.y))}),t._mouseDown={x:o,y:h},e.draw("Overlay"))}else if(t._chartIsMove){var d=parseInt(h-t._mouseDown.y),v=t._chartIsMove.chart,f=t.kline.getCharts()[t._chartIsMove.index+1];if(0===d)return;if(!f)return;var y=JSON.parse(JSON.stringify(v.getPosi())),p=JSON.parse(JSON.stringify(f.getPosi())),m=e.getChartMinH();if(y.h+=d,p.y+=d,p.h-=d,y.h<m||p.h<m)return;v.resize(y),f.resize(p),t._mouseDown={x:o,y:h},e.draw()}else t._mouseDown.x=a.translation(t._mouseDown.x,t._mouseMove.x),e.draw("All"),e._el.style.cursor="grabbing"}else{var _=t.inChartBottomEdge(h);if(t.setChartIsMove(_),_)return i.clearHover(),void e.draw("Overlay");0<o&&o<e._width-e.layout.getAxisWidth()&&0<h&&h<e._height-e.layout.getAxisHeight()&&"crossCursor"===e.getMoveCursorType()&&!t.isInChartBar({offsetX:o,offsetY:h})&&!t.iconsHoverEvent(n,t._mouseMove)?(i.setHover(c),i.setHoverY(h)):i.clearHover(),t.chartBarHoverEvent(n,t._mouseMove,s),t.indicatorsHoverEvent(n,t._mouseMove),t.timelineHoveEvent(n,t._mouseMove);for(var k=i.getMainChart().getTools(),A=0;A<k.length;A++)k[A].mouseEvent(n,t._mouseMove);e.draw("Overlay")}},e._el.onmouseleave=function(){t._mouseMove=null,t._mouseDown=null,i.clearHover(),e.draw("Overlay")},e._el.oncontextmenu=function(t){t.preventDefault()},e._el.dblclick=function(t){t.preventDefault()},e._el.onmousedown=function(e){if(e.preventDefault(),t._mouseMove){var a=t.kline,r=e.offsetX,s=e.offsetY;if(t._mouseDown={x:r,y:s},0==e.button){if(t._mouseDownButton=0,i.getTools()){var o=i.getMainChart().getTool();return 0===o._now||o._data[o._now]?o.addData():(o._now=1,o._data=[],t.kline.clearNoOverTools(),a._on&&a._on.contextmenu&&a._on.contextmenu(!1,-1,t._mouseDown,e.button)),void a.draw("Overlay")}t.iconsClickEvent(n,t._mouseDown),t.chartBarClickEvent(n,t._mouseDown),t.toolsClickEvent(n,t._mouseDown),a.timeline.clickEvent(n,t._mouseDown),a.draw("Overlay"),a._on&&a._on.contextmenu&&a._on.contextmenu(t._selectedTools,t._selectedToolsIndex,t._mouseDown,e.button)}else if(2===e.button){if(i.getTools())return t.kline.clearNoOverTools(),void(a._on&&a._on.contextmenu&&a._on.contextmenu(!1,-1,t._mouseDown,e.button));t.chartBarClickEvent(n,t._mouseDown),t._mouseDownButton=2,t.toolsClickEvent(n,t._mouseDown),a.draw("Overlay"),a._on&&a._on.contextmenu&&a._on.contextmenu(t._selectedTools,t._selectedToolsIndex,t._mouseDown,e.button)}}},e._el.onmouseup=function(){t._selectedTools&&i.getMainChart().saveTools(),t._mouseDown=null},document.attachEvent?(console.log("IE"),document.attachEvent("onmousewheel",r)):"FF"===g.BrowserType()?(console.log("FF"),document.addEventListener("DOMMouseScroll",r,!1)):e._el.onmousewheel=r}}]),t}();function Ie(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Le(t,e){for(var i=0;i<e.length;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 Re(t,e,i){return e&&Le(t.prototype,e),i&&Le(t,i),t}var Se=function(){function t(e){Ie(this,t),this.colors={},this.Positive="#50BA85",this.Negative="#EB4959",this.colors.Background="#0e121f",this.colors.Positive=this.Positive,this.colors.Negative=this.Negative,this.colors.CloseLine="#2196F3",this.colors.MaLine="#F8E71C",this.colors.Frame="#262626",this.colors.Grid="#1C1C1C",this.colors.RangText="#B7B8BC",this.colors.IndexText="#fff",this.colors.SelectionText="#0E1117",this.colors.SelectionBg="#B7B8BC",this.colors.Title="#f8cb00",this.colors.Text="#9EA0A5",this.colors.IndicatorName="#D7D9DE",this.colors.IndicatorBarName="#8A8A8A",this.colors.IndicatorRangLine="#474747",this.colors.IndicatorHover="#CCCCCC",this.colors.IndicatorSelected="#5797F1",this.colors.IndicatorDis="#4D4D4D",this.colors.Indicator=["#D7D9DE","#DFD645","#DE45BF","#46C2DE","#44DE9C","#DE4544","#4580DE","#DE9144","#9645DE","#DE4578"],this.colors.SAR="#5396CE",this.colors.Line="rgba(21,194,193,1)",this.colors.Point="#FFF",this.colors.Selected="#5797F1",this.colors.LimitLine="#525252",this.colors.BetweenBg="rgba(111,0,128, 0.25)",this.colors.NoCotent="#5C5C5C",this.colors.ToolBg="rgba(5, 112, 121, 0.4)",this.colors.ToolRectBg="rgba(144,19,254, 0.25)",this.colors.ToolRectColor="rgba(144,19,254,1)",this.colors.ToolFibExtendBg="rgba(25,144,255,0.3)",this.colors.ToolFibExtendColor="rgba(25,144,255,1)",this.colors.ToolFibTimeBg="rgba(25,144,255,0.3)",this.colors.ToolFibTimeColor="rgba(25,144,255,1)",this.colors.ToolMHeadWBaseColor="rgba(25,144,255,1)",this.colors.ToolHeadShoulderColor="rgba(55,158,15,1)",this.colors.ToolHeadShoulderBg="rgba(55,158,15,0.3)",this.colors.ToolEllipseColor="rgba(144,19,254,1)",this.colors.ToolEllipseBg="rgba(144,19,254,0.3)",this.colors.ToolArcColor="rgba(21,194,193,1)",this.colors.ToolFibCycleColor="rgba(25,144,255,1)",this.colors.TextMask="#0e121f",Object.assign(this.colors,e)}return Re(t,[{key:"getColors",value:function(t,e){return"Indicator"===t?this.colors[t][e||0]:this.colors[t]}},{key:"changeRiseFallColor",value:function(t){t?(this.colors.Positive=this.Negative,this.colors.Negative=this.Positive):(this.colors.Positive=this.Positive,this.colors.Negative=this.Negative)}}]),t}(),Ne=function(){function t(e){Ie(this,t),this.colors={},this.Positive="#12b36e",this.Negative="#de2f5c",this.colors.Background="#fff",this.colors.Positive=this.Positive,this.colors.Negative=this.Negative,this.colors.CloseLine="#2196F3",this.colors.MaLine="#F8E71C",this.colors.Frame="#A0A2A8",this.colors.Grid="#F7F7F7",this.colors.RangText="#44474D",this.colors.IndexText="#fff",this.colors.SelectionText="#FFFFFF",this.colors.SelectionBg="#555961",this.colors.Title="#003AC8",this.colors.Text="#36383D",this.colors.IndicatorName="#36383D",this.colors.IndicatorBarName="#797979",this.colors.IndicatorRangLine="#CCCCCC",this.colors.IndicatorHover="#333333",this.colors.IndicatorSelected="#1577FF",this.colors.IndicatorDis="#C2C2C2",this.colors.Indicator=["#2ECCAC","#D0AB2F","#C935CC","#2E9FCC","#2ECC3F","#CC3D2D","#2C6ACC","#CC742D","#722DCC","#CB3165"],this.colors.SAR="#5396CE",this.colors.Line="rgba(21,194,193,1)",this.colors.Point="#393C40",this.colors.Selected="#1577FF",this.colors.LimitLine="#C2C2C2",this.colors.BetweenBg="rgba(111,0,128, 0.1)",this.colors.NoCotent="#A1A1A1",this.colors.ToolBg="rgba(32, 179, 190, 0.4)",this.colors.ToolRectBg="rgba(144,19,254,0.25)",this.colors.ToolRectColor="rgba(144,19,254,1)",this.colors.ToolFibExtendBg="rgba(25,144,255,0.3)",this.colors.ToolFibExtendColor="rgba(25,144,255,1)",this.colors.ToolFibTimeBg="rgba(25,144,255,0.3)",this.colors.ToolFibTimeColor="rgba(25,144,255,1)",this.colors.ToolMHeadWBaseColor="rgba(25,144,255,1)",this.colors.ToolHeadShoulderColor="rgba(55,158,15,1)",this.colors.ToolHeadShoulderBg="rgba(55,158,15,0.3)",this.colors.ToolEllipseColor="rgba(144,19,254,1)",this.colors.ToolEllipseBg="rgba(144,19,254,0.3)",this.colors.ToolArcColor="rgba(21,194,193,1)",this.colors.ToolFibCycleColor="rgba(25,144,255,1)",this.colors.TextMask="#fff",Object.assign(this.colors,e)}return Re(t,[{key:"getColors",value:function(t,e){return"Indicator"===t?this.colors[t][e||0]:this.colors[t]}},{key:"changeRiseFallColor",value:function(t){t?(this.colors.Positive=this.Negative,this.colors.Negative=this.Positive):(this.colors.Positive=this.Positive,this.colors.Negative=this.Negative)}}]),t}();function Oe(t,e){for(var i=0;i<e.length;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)}}var Ve=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.tasks=[],this.kline=e}return function(t,e,i){e&&Oe(t.prototype,e)}(t,[{key:"addTask",value:function(t){this.tasks.push(t)}},{key:"draw",value:function(){var t=this;window.setTimeout((function(){var e=t.tasks;if(e.length){Date.now();for(var i=e.length,a=0;a<i;a++)e.shift()();Date.now()}window.setTimeout((function(){Date.now();try{t.kline.draw()}catch(t){console.log(t)}Date.now(),t.draw.call(t)}),0)}),0)}}]),t}();function We(t,e){for(var i=0;i<e.length;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)}}var Be=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._el=e.el||document.getElementsByClassName("LXKline")[0],this._viewType=e.viewType||0,this._data=e.data,this._pairName=e.pairName,this._pairId=e.pairId,this._title=e.title,this._log=e.log,this._lang=e.lang||"cn",this._theme=e.theme||!1,this._indicatorParams=e.indicatorParams,this._mainIndicators=e.mainIndicators||["CandleStick","MA"],this._indicators=e.indicators?JSON.parse(JSON.stringify(e.indicators)):["VOLUME"],this._showIndicatorText=!0,this._mainChartStyle=e.mainChartStyle||{dark:{"candle.yang.hollow":!0,"candle.ying.hollow":!1},light:{"candle.yang.hollow":!1,"candle.ying.hollow":!1}},this._showIndicatorsBar=e.showIndicatorsBar||!1,this._tools=e.tools||[],this._hideTools=e.hideTools||!1,this._width=e.width||e.el.offsetWidth,this._height=e.height||e.el.offsetHeight,this._chartMinH=e.chartMinH||80,this._watermark=e.watermark,this._rate=e.rate||1,this._periods=e.periods||0,this._worker=null,this._timer=null,this._on=e.on,this.task=null,this.darkTheme=new Se(e.dark||{}),this.lightTheme=new Ne(e.light||{}),this._moveCursorType=e.moveCursorType||"crossCursor",this._isRedRiseGreenFall=e.isRedRiseGreenFall||!1,this._DEPTH=e.depth||{asks:[],bids:[]},this.extend(),this.init(),this.draw(),this._countDownTime=null,this.startCountDown()}return function(t,e,i){e&&We(t.prototype,e)}(t,[{key:"extend",value:function(){var t=CanvasRenderingContext2D.prototype.moveTo;CanvasRenderingContext2D.prototype.moveToLocation={},CanvasRenderingContext2D.prototype.moveTo=function(e,i){this.moveToLocation.x=e,this.moveToLocation.y=i,t.apply(this,[e,i])},CanvasRenderingContext2D.prototype.dashedLineTo=function(t,e,i){i=void 0===i?5:i;for(var a=this.moveToLocation.x,n=this.moveToLocation.y,r=t-a,s=e-n,o=Math.floor(Math.sqrt(r*r+s*s)/i),h=0;h<o;h++)this[h%2==0?"moveTo":"lineTo"](a+r/o*h,n+s/o*h);this.moveTo(t,e)}}},{key:"init",value:function(){this.template(),this.layout=new s(this),this.zoom=new l(this),this.timeline=new f(this),this.manage=new Me(this),this.mouseEvent=new Pe(this),this.darkTheme.changeRiseFallColor(this._isRedRiseGreenFall),this.lightTheme.changeRiseFallColor(this._isRedRiseGreenFall)}},{key:"template",value:function(){n.clean(this._el),this.bindCanvas("Main",n.creatCanvas(this._el,this._width,this._height)),this.bindCanvas("Overlay",n.creatCanvas(this._el,this._width,this._height))}},{key:"bindCanvas",value:function(t,e){var i=e.can,a=e.ctx;"Main"===t?(this._mainCanvas=i,this._mainContext=a):"Overlay"===t&&(this._overlayCanvas=i,this._overlayContext=a)}},{key:"draw",value:function(t){0!==this.getDataLen()&&(void 0===t&&(t="All"),"All"!==t&&"Main"!==t||this.drawMain(),"All"!==t&&"Overlay"!==t||this.drawOverlay())}},{key:"drawMain",value:function(){var t=this,e=this._mainContext,i=this._watermark,a=this.getTheme().getColors("Background");i?g.drawWatermark(e,i,this._width,this._height,a,(function(){t.timeline.drawMain(e),t.manage.drawMain(e)})):(e.clearRect(0,0,this._width,this._height),g.drawRect(e,a,0,0,this._width,this._height),this.timeline.drawMain(e),this.manage.drawMain(e))}},{key:"drawOverlay",value:function(){var t=this._overlayContext;t.clearRect(0,0,this._width,this._height),this.manage.drawOverlay(t),this.timeline.drawOverlay(t)}},{key:"getEl",value:function(){return this._el}},{key:"getChartMinH",value:function(){return this._chartMinH}},{key:"getCharts",value:function(){return this.manage.getCharts()}},{key:"getData",value:function(){return this._data}},{key:"getDataAt",value:function(t){return this._data[t]}},{key:"getLastData",value:function(){return this._data[this.getDataLen()-1]}},{key:"getDataLen",value:function(){return this._data.length}},{key:"getWidth",value:function(){return this._width}},{key:"getHeight",value:function(){return this._height}},{key:"getMainContext",value:function(){return this._mainContext}},{key:"getLog",value:function(){return this._log}},{key:"getTitle",value:function(){return this._title}},{key:"getLang",value:function(){return this._lang}},{key:"getPairName",value:function(){return this._pairName}},{key:"getPairId",value:function(){return this._pairId}},{key:"getTheme",value:function(){return this._theme?this.darkTheme:this.lightTheme}},{key:"getIndicatorConfig",value:function(t){return this._indicatorParams&&this._indicatorParams[t]}},{key:"getMainIndicators",value:function(){return this._mainIndicators}},{key:"getIndicators",value:function(){return this._indicators}},{key:"getMoveCursorType",value:function(){return this._moveCursorType}},{key:"setMoveCursorType",value:function(t){this.clearNoOverTools(),this._moveCursorType=t}},{key:"indicatorTextVisible",value:function(t){this._showIndicatorText=t,this.draw()}},{key:"startCountDown",value:function(){var t=this._data.length,e=this._periods;if(t&&e){var i=(new Date).getTime();this._countDownTime=this._data[t-1].date+e-i,this.priceLineCountDown()}}},{key:"priceLineCountDown",value:function(){if(this._worker)this._worker.postMessage(this._countDownTime);else{this._worker=new Worker("/static/js/countdown.js"),this._worker.postMessage(this._countDownTime);var t=this;this._worker.onmessage=function(e){t._countDownTime=e.data,t.drawOverlay()}}}},{key:"updateTask",value:function(t,e){if(t&&0!==t.length){var i=this.zoom,a=this.getLastData(),n=!1;if(0===e)this._data=t,i.setPost(!0),i.init(),this.timeline.calc(),n=!0;else if(1===e)this._data=t.concat(this._data),i.setPost(!0),i.addItemFirst(t.length);else if(2===e)for(var r=0;r<t.length;r++)(a=this.getLastData()).date===t[r].date?(a.close=t[r].close,a.high=Math.max(a.high,t[r].close),a.low=Math.min(a.low,t[r].close),a.volume+=t[r].volume):a.date<t[r].date&&(t[r].open=t[r].close,t[r].high=t[r].close,t[r].low=t[r].close,this._data.push(t[r]),i.addItemFirst(),this.manage.update(),this.startCountDown());this.manage.update(),n&&this.startCountDown()}}},{key:"update",value:function(t,e,i,a){this.task||(this.task=new Ve(this),this.task.draw()),this._periods=i,a&&a.asks&&(this._DEPTH=a),this.updateTask.bind(this,t,e),this.task.addTask(this.updateTask.bind(this,t,e),this)}},{key:"resize",value:function(t,e){this._width=t||this._el.offsetWidth,this._height=e||this._el.offsetHeight,this.zoom.calcItemCount(),this.manage.resize(),this.template(),this.draw()}},{key:"theme",value:function(t,e){this._theme=t,e&&(this._indicatorParams=e),this.getTheme().changeRiseFallColor(this._isRedRiseGreenFall),this.draw()}},{key:"indicatorsBar",value:function(t){this._showIndicatorsBar=t,this.draw()}},{key:"getIndicatorsBar",value:function(){return this._showIndicatorsBar}},{key:"log",value:function(t){this._log=t,this.manage.update(),this.draw()}},{key:"tools",value:function(t){this.clearNoOverTools(),this.getMainContext();var e=this.mouseEvent,i=this.manage.getMainChart().getTools();e._mouseDown=null;for(var a=0;a<i.length;a++)i[a]._hover="none",i[a]._focus=!1,i[a]._selected=!1;this.manage.setTools(t),this.manage.getMainChart().creatTools(t)}},{key:"updateTools",value:function(t){this.manage.getMainChart().getTools()}},{key:"deleteTools",value:function(t){var e=this.manage.getMainChart();e.getTools().splice(t,1),e.saveTools()}},{key:"lockTools",value:function(t,e){var i=this.manage.getMainChart(),a=i.getTools();-1<t&&(a[t].lock(e),this.draw(),i.saveTools())}},{key:"recoverTools",value:function(t){var e=this.manage.getMainChart(),i=e.getTools();-1<t&&(i[t].recover(),this.draw(),e.saveTools())}},{key:"changeToolsStyle",value:function(t,e){var i=this.manage.getMainChart().getTools();-1<t&&(i[t].setParams(e),this.draw())}},{key:"changeIndicatorsStyle",value:function(t,e){this.manage.modifyIndicatorParams(t,e),this.draw()}},{key:"setPriceLine",value:function(t){this.manage.getMainChart()._indicators[0].changePriceLine(t),this.drawOverlay()}},{key:"changeMainChartStyle",value:function(t){this._mainChartStyle=t,this.draw()}},{key:"setRiseFallColor",value:function(t){this._isRedRiseGreenFall=t,this.getTheme().changeRiseFallColor(this._isRedRiseGreenFall),this.draw()}},{key:"clearNoOverTools",value:function(){this.manage.setTools(null,!0),this.manage.getMainChart().clearNoOverTools(),this.drawOverlay()}},{key:"cleanTools",value:function(){this.manage.getMainChart().cleanTools(),this.draw(),this._on&&this._on.cleanToolsCb&&this._on.cleanToolsCb()}},{key:"changeToolsVisible",value:function(t){this._hideTools=t,this.draw()}},{key:"getToolsVisible",value:function(){return this._hideTools}},{key:"loadingShow",value:function(){this._mainContext.clearRect(0,0,this._width,this._height),this._overlayContext.clearRect(0,0,this._width,this._height),n.loadingShow()}},{key:"loadingHide",value:function(){n.loadingHide()}},{key:"timeShare",value:function(t){this.manage.getMainChart().timeShare(t),this.manage.update(),this.draw()}},{key:"mainStyle",value:function(t){this.manage.getMainChart().modifyIndicators(t,0),this.manage.update(),this.draw()}},{key:"mainIndicator",value:function(t){console.log("name的值",t);for(var e=this.manage.getMainChart(),i=e._indicators.slice(1),a=[],n=0;n<i.length;n++)a.push(i[n].getName());console.log("list的值",a);for(var r=a.filter((function(e){return-1===t.indexOf(e)})),s=t.filter((function(t){return-1===a.indexOf(t)})),o=function(t){var e=a.findIndex((function(e){return e===r[t]}));-1<e&&a.splice(e,1)},h=0;h<r.length;h++)o(h);var l={};a.concat(s).map((function(t){"MA"===t?l.MA={num:0}:"EMA"===t?l.EMA={num:1}:"BOLL"===t?l.BOLL={num:2}:"SAR"===t?l.SAR={num:3}:"DEPTH"===t&&(l.DEPTH={num:4})}));var c=Object.keys(l).sort((function(t,e){return l[t].num-l[e].num}));console.log("sort的值",c),e.bar.updateSelected(c),e.modifyIndicators(c,1),e.calcMaxMinVal(),this.draw()}},{key:"addIndicator",value:function(t){if(!(-1<this._indicators.indexOf(t))){var e=this.manage;5<e.getChartLen()?console.error("最多设置5个指标"):(this._indicators.push(t),e.setChart(e.creatChart("deputy",{posi:{w:0,h:0,x:0,y:0,pad:[0,0,5,0]},indicators:[t]},t)),e.resize(),this.draw())}}},{key:"removeIndicator",value:function(t){if(-1!==this._indicators.indexOf(t)){var e=this._indicators.indexOf(t);this._indicators.splice(e,1),this.manage.removeChart(t),this.draw()}}},{key:"replaceIndicator",value:function(t){var e=t.name,i=t.last,a=this._indicators.indexOf(i),n=this._indicators.indexOf(e);-1<a&&-1===n&&(this._indicators.splice(a,1,e),this.manage.replaceChart(e,i)),this.draw()}},{key:"changeIndicatorsParams",value:function(t){var e=t.name,i=t.key,a=t.value;this._indicatorParams[e][i]=a,this.draw()}},{key:"defaultInputOutput",value:function(t){var e=t.key,i=t.value;this._indicatorParams[e]=i,this.manage.defaultInputOutput(e,i),this.draw()}},{key:"modifyIndicatorOutput",value:function(t){var e=t.key,i=t.i,a=t.value;this.manage.modifyIndicatorOutput(e,i,a),this._indicatorParams[e].output[i]=a,this.draw()}},{key:"modifyIndicatorInput",value:function(t){var e=t.key,i=t.value;this.manage.modifyIndicatorParams(e,i),this._indicatorParams[e].input=i,this.draw()}},{key:"defaultIndicatorParams",value:function(t){this.manage.defaultIndicatorParams(t),this.draw()}}]),t}();window.Chainfor=Be}],t.c=i,t.d=function(e,i,a){t.o(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:a})},t.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t.t=function(e,i){if(1&i&&(e=t(e)),8&i)return e;if(4&i&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&i&&"string"!=typeof e)for(var n in e)t.d(a,n,function(t){return e[t]}.bind(null,n));return a},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t.p="",t(t.s=0);function t(a){if(i[a])return i[a].exports;var n=i[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var e,i}));