UNPKG

@dickyindra/klinecharts

Version:

Lightweight k-line chart built with html5 canvas

15 lines 178 kB
/** * @license * KLineChart v8.3.6-7 * Copyright (c) 2019 lihu. * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).klinecharts={})}(this,(function(t){"use strict";var e={technicalIndicatorExtensions:{},shapeExtensions:{},addTechnicalIndicatorTemplate:function(t){var e=this;t&&[].concat(t).forEach((function(t){t.name&&(e.technicalIndicatorExtensions[t.name]=t)}))},addShapeTemplate:function(t){var e=this;t&&[].concat(t).forEach((function(t){t.name&&(e.shapeExtensions[t.name]=t)}))}};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t){return a="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},a(t)}function o(t,e){if(l(t)&&l(e))for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&i in t){var n=t[i],r=e[i];l(r)&&l(n)&&!c(r)&&!c(n)?o(n,r):f(e[i])&&(t[i]=e[i])}}function s(t){if(!l(t))return t;var e;for(var i in e=c(t)?[]:{},t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=t[i];e[i]=l(n)?s(n):n}return e}function c(t){return"[object Array]"===Object.prototype.toString.call(t)}function h(t){return t&&"function"==typeof t}function l(t){return!!t&&"object"===a(t)}function u(t){return"number"==typeof t&&!isNaN(t)}function f(t){return null!=t}function d(t){return"boolean"==typeof t}function v(t){return"string"==typeof t}var _="stroke",p="fill",y="dash",m="solid",g="left",x="right",S="normal",b="percentage",k="log",w="candle_solid",E="candle_stroke",P="candle_up_stroke",C="candle_down_stroke",A="ohlc",T="area",I="always",O="follow_cross",M="rect",D="standard",L="circle",R="rect",B="triangle",F="diamond",z="custom",j="point",H="top",V="bottom",N={grid:{show:!0,horizontal:{show:!0,size:1,color:"#EDEDED",style:y,dashValue:[2,2]},vertical:{show:!0,size:1,color:"#EDEDED",style:y,dashValue:[2,2]}},candle:{margin:{top:.2,bottom:.1},type:w,bar:{upColor:"#26A69A",downColor:"#EF5350",noChangeColor:"#999999"},area:{lineSize:2,lineColor:"#2196F3",value:"close",backgroundColor:[{offset:0,color:"rgba(33, 150, 243, 0.01)"},{offset:1,color:"rgba(33, 150, 243, 0.2)"}]},priceMark:{show:!0,high:{show:!0,color:"#76808F",textMargin:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},low:{show:!0,color:"#76808F",textMargin:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},last:{show:!0,upColor:"#26A69A",downColor:"#EF5350",noChangeColor:"#888888",line:{show:!0,style:y,dashValue:[4,4],size:1},text:{show:!0,size:12,paddingLeft:2,paddingTop:2,paddingRight:2,paddingBottom:2,color:"#FFFFFF",family:"Helvetica Neue",weight:"normal",borderRadius:2}}},tooltip:{showRule:I,showType:D,labels:["时间: ","开: ","收: ","高: ","低: ","成交量: "],values:null,defaultValue:"n/a",rect:{paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:6,offsetLeft:8,offsetTop:8,offsetRight:8,borderRadius:4,borderSize:1,borderColor:"#F2F3F5",backgroundColor:"#FEFEFE"},text:{size:12,family:"Helvetica Neue",weight:"normal",color:"#76808F",marginLeft:8,marginTop:6,marginRight:8,marginBottom:0}}},technicalIndicator:{margin:{top:.2,bottom:.1},bar:{upColor:"rgba(38, 166, 154, .65)",downColor:"rgba(239, 83, 80, .65)",noChangeColor:"#888888"},line:{size:1,colors:["#FF9600","#9D65C9","#2196F3","#E11D74","#01C5C4"]},circle:{upColor:"rgba(38, 166, 154, .65)",downColor:"rgba(239, 83, 80, .65)",noChangeColor:"#888888"},lastValueMark:{show:!1,text:{show:!1,color:"#FFFFFF",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:3,paddingTop:2,paddingRight:3,paddingBottom:2,borderRadius:2}},tooltip:{showRule:I,showType:D,showName:!0,showParams:!0,defaultValue:"n/a",text:{size:12,family:"Helvetica Neue",weight:"normal",color:"#76808F",marginTop:6,marginRight:8,marginBottom:0,marginLeft:8}}},xAxis:{show:!0,height:null,axisLine:{show:!0,color:"#DDDDDD",size:1},tickText:{show:!0,color:"#76808F",size:12,family:"Helvetica Neue",weight:"normal",paddingTop:3,paddingBottom:6},tickLine:{show:!0,size:1,length:3,color:"#DDDDDD"}},yAxis:{show:!0,width:null,type:S,position:x,inside:!1,axisLine:{show:!0,color:"#DDDDDD",size:1},tickText:{show:!0,color:"#76808F",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:3,paddingRight:6},tickLine:{show:!0,size:1,length:3,color:"#DDDDDD"}},separator:{size:1,color:"#DDDDDD",fill:!0,activeBackgroundColor:"rgba(33, 150, 243, 0.08)"},crosshair:{show:!0,horizontal:{show:!0,line:{show:!0,style:y,dashValue:[4,2],size:1,color:"#76808F"},text:{show:!0,color:"#FFFFFF",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:2,paddingRight:2,paddingTop:2,paddingBottom:2,borderSize:1,borderColor:"#686D76",borderRadius:2,backgroundColor:"#686D76"}},vertical:{show:!0,line:{show:!0,style:y,dashValue:[4,2],size:1,color:"#76808F"},text:{show:!0,color:"#FFFFFF",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:2,paddingRight:2,paddingTop:2,paddingBottom:2,borderSize:1,borderRadius:2,borderColor:"#686D76",backgroundColor:"#686D76"}}},shape:{point:{backgroundColor:"#2196F3",borderColor:"rgba(33, 150, 243, 0.35)",borderSize:1,radius:5,activeBackgroundColor:"#2196F3",activeBorderColor:"rgba(33, 150, 243, 0.35)",activeBorderSize:3,activeRadius:5},line:{style:m,color:"#2196F3",size:1,dashValue:[2,2]},polygon:{style:_,stroke:{style:m,size:1,color:"#2196F3",dashValue:[2,2]},fill:{color:"#2196F3"}},arc:{style:_,stroke:{style:m,size:1,color:"#2196F3",dashValue:[2,2]},fill:{color:"#2196F3"}},text:{style:p,color:"#2196F3",size:12,family:"Helvetica Neue",weight:"normal",offset:[0,0]}},annotation:{position:H,offset:[20,0],symbol:{type:F,size:8,color:"#2196F3",activeSize:10,activeColor:"#FF9600"}},tag:{position:j,offset:0,line:{show:!0,style:y,dashValue:[4,2],size:1,color:"#2196F3"},text:{color:"#FFFFFF",backgroundColor:"#2196F3",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:2,paddingRight:2,paddingTop:2,paddingBottom:2,borderRadius:2,borderSize:1,borderColor:"#2196F3"},mark:{offset:0,color:"#FFFFFF",backgroundColor:"#2196F3",size:12,family:"Helvetica Neue",weight:"normal",paddingLeft:2,paddingRight:2,paddingTop:2,paddingBottom:2,borderRadius:2,borderSize:1,borderColor:"#2196F3"}}},Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},W={exports:{}}; /*! @preserve * numeral.js * version : 2.0.6 * author : Adam Draper * license : MIT * http://adamwdraper.github.com/Numeral-js/ */ !function(t){!function(e,i){t.exports?t.exports=i():e.numeral=i()}(Y,(function(){var t,e,i,n,r,a={},o={},s={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},c={currentLocale:s.currentLocale,zeroFormat:s.zeroFormat,nullFormat:s.nullFormat,defaultFormat:s.defaultFormat,scalePercentBy100:s.scalePercentBy100};function h(t,e){this._input=t,this._value=e}return(t=function(i){var n,r,o,s;if(t.isNumeral(i))n=i.value();else if(0===i||void 0===i)n=0;else if(null===i||e.isNaN(i))n=null;else if("string"==typeof i)if(c.zeroFormat&&i===c.zeroFormat)n=0;else if(c.nullFormat&&i===c.nullFormat||!i.replace(/[^0-9]+/g,"").length)n=null;else{for(r in a)if((s="function"==typeof a[r].regexps.unformat?a[r].regexps.unformat():a[r].regexps.unformat)&&i.match(s)){o=a[r].unformat;break}n=(o=o||t._.stringToNumber)(i)}else n=Number(i)||null;return new h(i,n)}).version="2.0.6",t.isNumeral=function(t){return t instanceof h},t._=e={numberToFormat:function(e,i,n){var r,a,s,c,h,l,u,f,d=o[t.options.currentLocale],v=!1,_=!1,p="",y=1e12,m=1e9,g=1e6,x="",S=!1;if(s=Math.abs(e=e||0),t._.includes(i,"(")?(v=!0,i=i.replace(/[\(|\)]/g,"")):(t._.includes(i,"+")||t._.includes(i,"-"))&&(l=t._.includes(i,"+")?i.indexOf("+"):0>e?i.indexOf("-"):-1,i=i.replace(/[\+|\-]/g,"")),t._.includes(i,"a")&&(a=!!(a=i.match(/a(k|m|b|t)?/))&&a[1],t._.includes(i," a")&&(p=" "),i=i.replace(RegExp(p+"a[kmbt]?"),""),s>=y&&!a||"t"===a?(p+=d.abbreviations.trillion,e/=y):y>s&&s>=m&&!a||"b"===a?(p+=d.abbreviations.billion,e/=m):m>s&&s>=g&&!a||"m"===a?(p+=d.abbreviations.million,e/=g):(g>s&&s>=1e3&&!a||"k"===a)&&(p+=d.abbreviations.thousand,e/=1e3)),t._.includes(i,"[.]")&&(_=!0,i=i.replace("[.]",".")),c=(""+e).split(".")[0],h=i.split(".")[1],u=i.indexOf(","),r=(i.split(".")[0].split(",")[0].match(/0/g)||[]).length,h?(t._.includes(h,"[")?(h=(h=h.replace("]","")).split("["),x=t._.toFixed(e,h[0].length+h[1].length,n,h[1].length)):x=t._.toFixed(e,h.length,n),c=x.split(".")[0],x=t._.includes(x,".")?d.delimiters.decimal+x.split(".")[1]:"",_&&0===Number(x.slice(1))&&(x="")):c=t._.toFixed(e,0,n),p&&!a&&Number(c)>=1e3&&p!==d.abbreviations.trillion)switch(c=Number(c)/1e3+"",p){case d.abbreviations.thousand:p=d.abbreviations.million;break;case d.abbreviations.million:p=d.abbreviations.billion;break;case d.abbreviations.billion:p=d.abbreviations.trillion}if(t._.includes(c,"-")&&(c=c.slice(1),S=!0),r>c.length)for(var b=r-c.length;b>0;b--)c="0"+c;return u>-1&&(c=(""+c).replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+d.delimiters.thousands)),0===i.indexOf(".")&&(c=""),f=c+x+(p||""),v?f=(v&&S?"(":"")+f+(v&&S?")":""):0>l?S&&(f="-"+f):f=0===l?(S?"-":"+")+f:f+(S?"-":"+"),f},stringToNumber:function(t){var e,i,n,r=o[c.currentLocale],a=t,s={thousand:3,million:6,billion:9,trillion:12};if(c.zeroFormat&&t===c.zeroFormat)i=0;else if(c.nullFormat&&t===c.nullFormat||!t.replace(/[^0-9]+/g,"").length)i=null;else{for(e in i=1,"."!==r.delimiters.decimal&&(t=t.replace(/\./g,"").replace(r.delimiters.decimal,".")),s)if(n=RegExp("[^a-zA-Z]"+r.abbreviations[e]+"(?:\\)|(\\"+r.currency.symbol+")?(?:\\))?)?$"),a.match(n)){i*=Math.pow(10,s[e]);break}i*=(t.split("-").length+Math.min(t.split("(").length-1,t.split(")").length-1))%2?1:-1,t=t.replace(/[^0-9\.]+/g,""),i*=Number(t)}return i},isNaN:function(t){return"number"==typeof t&&isNaN(t)},includes:function(t,e){return-1!==t.indexOf(e)},insert:function(t,e,i){return t.slice(0,i)+e+t.slice(i)},reduce:function(t,e){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof e)throw new TypeError(e+" is not a function");var i,n=Object(t),r=n.length>>>0,a=0;if(3===arguments.length)i=arguments[2];else{for(;r>a&&!(a in n);)a++;if(a>=r)throw new TypeError("Reduce of empty array with no initial value");i=n[a++]}for(;r>a;a++)a in n&&(i=e(i,n[a],a,n));return i},multiplier:function(t){var e=(""+t).split(".");return 2>e.length?1:Math.pow(10,e[1].length)},correctionFactor:function(){var t=Array.prototype.slice.call(arguments);return t.reduce((function(t,i){var n=e.multiplier(i);return t>n?t:n}),1)},toFixed:function(t,e,i,n){var r,a,o,s,c=(""+t).split("."),h=e-(n||0);return o=Math.pow(10,r=2===c.length?Math.min(Math.max(c[1].length,h),e):h),s=(i(t+"e+"+r)/o).toFixed(r),n>e-r&&(a=RegExp("\\.?0{1,"+(n-(e-r))+"}$"),s=s.replace(a,"")),s}},t.options=c,t.formats=a,t.locales=o,t.locale=function(t){return t&&(c.currentLocale=t.toLowerCase()),c.currentLocale},t.localeData=function(t){if(!t)return o[c.currentLocale];if(t=t.toLowerCase(),!o[t])throw Error("Unknown locale : "+t);return o[t]},t.reset=function(){for(var t in s)c[t]=s[t]},t.zeroFormat=function(t){c.zeroFormat="string"==typeof t?t:null},t.nullFormat=function(t){c.nullFormat="string"==typeof t?t:null},t.defaultFormat=function(t){c.defaultFormat="string"==typeof t?t:"0.0"},t.register=function(t,e,i){if(e=e.toLowerCase(),this[t+"s"][e])throw new TypeError(e+" "+t+" already registered.");return this[t+"s"][e]=i,i},t.validate=function(e,i){var n,r,a,o,s,c,h,l;if("string"!=typeof e&&(e+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",e)),(e=e.trim()).match(/^\d+$/))return!0;if(""===e)return!1;try{h=t.localeData(i)}catch(e){h=t.localeData(t.locale())}return a=h.currency.symbol,s=h.abbreviations,n=h.delimiters.decimal,r="."===h.delimiters.thousands?"\\.":h.delimiters.thousands,(null===(l=e.match(/^[^\d]+/))||(e=e.substr(1),l[0]===a))&&((null===(l=e.match(/[^\d]+$/))||(e=e.slice(0,-1),l[0]===s.thousand||l[0]===s.million||l[0]===s.billion||l[0]===s.trillion))&&(c=RegExp(r+"{2}"),!e.match(/[^\d.,]/g)&&(2>=(o=e.split(n)).length&&(2>o.length?!!o[0].match(/^\d+.*\d$/)&&!o[0].match(c):1===o[0].length?!!o[0].match(/^\d+$/)&&!o[0].match(c)&&!!o[1].match(/^\d+$/):!!o[0].match(/^\d+.*\d$/)&&!o[0].match(c)&&!!o[1].match(/^\d+$/)))))},t.fn=h.prototype={clone:function(){return t(this)},format:function(e,i){var n,r,o,s=this._value,h=e||c.defaultFormat;if(i=i||Math.round,0===s&&null!==c.zeroFormat)r=c.zeroFormat;else if(null===s&&null!==c.nullFormat)r=c.nullFormat;else{for(n in a)if(h.match(a[n].regexps.format)){o=a[n].format;break}r=(o=o||t._.numberToFormat)(s,h,i)}return r},value:function(){return this._value},input:function(){return this._input},set:function(t){return this._value=Number(t),this},add:function(t){var i=e.correctionFactor.call(null,this._value,t);return this._value=e.reduce([this._value,t],(function(t,e,n,r){return t+Math.round(i*e)}),0)/i,this},subtract:function(t){var i=e.correctionFactor.call(null,this._value,t);return this._value=e.reduce([t],(function(t,e,n,r){return t-Math.round(i*e)}),Math.round(this._value*i))/i,this},multiply:function(t){return this._value=e.reduce([this._value,t],(function(t,i,n,r){var a=e.correctionFactor(t,i);return Math.round(t*a)*Math.round(i*a)/Math.round(a*a)}),1),this},divide:function(t){return this._value=e.reduce([this._value,t],(function(t,i,n,r){var a=e.correctionFactor(t,i);return Math.round(t*a)/Math.round(i*a)})),this},difference:function(e){return Math.abs(t(this._value).subtract(e).value())}},t.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(t){var e=t%10;return 1==~~(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th"},currency:{symbol:"$"}}),t.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(e,i,n){var r,a=t._.includes(i," BPS")?" ":"";return e*=1e4,i=i.replace(/\s?BPS/,""),r=t._.numberToFormat(e,i,n),t._.includes(r,")")?((r=r.split("")).splice(-1,0,a+"BPS"),r=r.join("")):r=r+a+"BPS",r},unformat:function(e){return+(1e-4*t._.stringToNumber(e)).toFixed(15)}}),r="("+(r=(i={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}).suffixes.concat((n={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]}).suffixes.filter((function(t){return 0>i.suffixes.indexOf(t)}))).join("|")).replace("B","B(?!PS)")+")",t.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:RegExp(r)},format:function(e,r,a){var o,s,c=t._.includes(r,"ib")?n:i,h=t._.includes(r," b")||t._.includes(r," ib")?" ":"";for(r=r.replace(/\s?i?b/,""),o=0;c.suffixes.length>=o;o++)if(s=Math.pow(c.base,o),null===e||0===e||e>=s&&Math.pow(c.base,o+1)>e){h+=c.suffixes[o],s>0&&(e/=s);break}return t._.numberToFormat(e,r,a)+h},unformat:function(e){var r,a,o=t._.stringToNumber(e);if(o){for(r=i.suffixes.length-1;r>=0;r--){if(t._.includes(e,i.suffixes[r])){a=Math.pow(i.base,r);break}if(t._.includes(e,n.suffixes[r])){a=Math.pow(n.base,r);break}}o*=a||1}return o}}),t.register("format","currency",{regexps:{format:/(\$)/},format:function(e,i,n){var r,a,o=t.locales[t.options.currentLocale],s={before:i.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:i.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(i=i.replace(/\s?\$\s?/,""),r=t._.numberToFormat(e,i,n),0>e?e>=0||t._.includes(s.before,"-")||t._.includes(s.before,"(")||(s.before="-"+s.before):(s.before=s.before.replace(/[\-\(]/,""),s.after=s.after.replace(/[\-\)]/,"")),a=0;s.before.length>a;a++)switch(s.before[a]){case"$":r=t._.insert(r,o.currency.symbol,a);break;case" ":r=t._.insert(r," ",a+o.currency.symbol.length-1)}for(a=s.after.length-1;a>=0;a--)switch(s.after[a]){case"$":r=a===s.after.length-1?r+o.currency.symbol:t._.insert(r,o.currency.symbol,-(s.after.length-(1+a)));break;case" ":r=a===s.after.length-1?r+" ":t._.insert(r," ",-(s.after.length-(1+a)+o.currency.symbol.length-1))}return r}}),t.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(e,i,n){var r=("number"!=typeof e||t._.isNaN(e)?"0e+0":e.toExponential()).split("e");return i=i.replace(/e[\+|\-]{1}0/,""),t._.numberToFormat(Number(r[0]),i,n)+"e"+r[1]},unformat:function(e){var i=t._.includes(e,"e+")?e.split("e+"):e.split("e-"),n=Number(i[0]),r=Number(i[1]);return r=t._.includes(e,"e-")?r*=-1:r,t._.reduce([n,Math.pow(10,r)],(function(e,i,n,r){var a=t._.correctionFactor(e,i);return e*a*(i*a)/(a*a)}),1)}}),t.register("format","ordinal",{regexps:{format:/(o)/},format:function(e,i,n){var r=t.locales[t.options.currentLocale],a=t._.includes(i," o")?" ":"";return i=i.replace(/\s?o/,""),a+=r.ordinal(e),t._.numberToFormat(e,i,n)+a}}),t.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(e,i,n){var r,a=t._.includes(i," %")?" ":"";return t.options.scalePercentBy100&&(e*=100),i=i.replace(/\s?\%/,""),r=t._.numberToFormat(e,i,n),t._.includes(r,")")?((r=r.split("")).splice(-1,0,a+"%"),r=r.join("")):r=r+a+"%",r},unformat:function(e){var i=t._.stringToNumber(e);return t.options.scalePercentBy100?.01*i:i}}),t.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(t,e,i){var n=Math.floor(t/60/60),r=Math.floor((t-60*n*60)/60),a=Math.round(t-60*n*60-60*r);return n+":"+(10>r?"0"+r:r)+":"+(10>a?"0"+a:a)},unformat:function(t){var e=t.split(":"),i=0;return 3===e.length?(i+=60*Number(e[0])*60,i+=60*Number(e[1]),i+=Number(e[2])):2===e.length&&(i+=60*Number(e[0]),i+=Number(e[1])),Number(i)}}),t}))}(W);var X=W.exports;function G(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"--";if(l(t)){var n=t[e];if(f(n))return n}return i}function U(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"DD-MM hh:mm";if(u(e)){var n=t.format(new Date(e)),r=n.split(", "),a=r[0].split("/"),o={YYYY:a[2],MM:a[0],DD:a[1],"hh:mm":"24"===r[1].match(/^[\d]{2}/)[0]?r[1].replace(/^[\d]{2}/,"00"):r[1]};return i.replace(/YYYY|MM|DD|(hh:mm)/g,(function(t){return o[t]}))}return"--"}function Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,i=+t;return u(i)?Number(i).toLocaleString("id",{minimumFractionDigits:e,maximumFractionDigits:e}):"".concat(i)}function $(t){var e=t;return v(t)&&(e=Number(e.replaceAll(".","").replaceAll(",","."))),u(e)?X(e).format("0.[00]a"):"".concat(e)}function K(t,e){return null==e&&(e=10),+(t=(+t).toFixed(e=Math.min(Math.max(0,e),20)))}function q(t){return Math.log(t)/Math.log(10)}function J(t){return Math.pow(10,t)}X.register("locale","id",{delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"K",million:"M",billion:"B",trillion:"T"},currency:{symbol:"Rp"}}),X.locale("id");var Q={ZOOM:"zoom",SCROLL:"scroll",CROSSHAIR:"crosshair",TOOLTIP:"tooltip",PANE_DRAG:"pane_drag"};function tt(t){return Object.values(Q).indexOf(t)>-1}var et=function(){function t(e){i(this,t),this._chartStore=e,this._dateTimeFormat=new Intl.DateTimeFormat("en",{hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),this._zoomEnabled=!0,this._scrollEnabled=!0,this._loading=!0,this._loadMoreCallback=null,this._more=!0,this._totalDataSpace=0,this._dataSpace=6,this._barSpace=this._calcBarSpace(),this._offsetRightSpace=50,this._offsetRightBarCount=this._offsetRightSpace/this._dataSpace,this._leftMinVisibleBarCount=2,this._rightMinVisibleBarCount=2,this._leftEmptyBarCount=null,this._rightEmptyBarCount=null,this._from=0,this._to=0,this._preOffsetRightBarCount=0}return r(t,[{key:"_calcBarSpace",value:function(){return Math.max(1,Math.min(Math.floor(.82*this._dataSpace),Math.floor(this._dataSpace)-1))}},{key:"adjustFromTo",value:function(){var t=this._chartStore.dataList().length,e=this._totalDataSpace/this._dataSpace,i=null!==this._leftEmptyBarCount?e-(e-this._leftEmptyBarCount):e-Math.min(this._leftMinVisibleBarCount,t);this._offsetRightBarCount>i&&(this._offsetRightBarCount=i);var n=null!==this._rightEmptyBarCount?e-this._rightEmptyBarCount-t:-t+Math.min(this._rightMinVisibleBarCount,t);n>this._offsetRightBarCount&&(this._offsetRightBarCount=n),this._to=Math.round(this._offsetRightBarCount+t+.5),this._from=Math.round(this._to-e)-1,this._to>t&&(this._to=t),0>this._from&&(this._from=0),this._chartStore.adjustVisibleDataList(),0===this._from&&this._more&&!this._loading&&h(this._loadMoreCallback)&&(this._loading=!0,this._loadMoreCallback(G(this._chartStore.dataList()[0],"timestamp")))}},{key:"setMore",value:function(t){this._more=t}},{key:"setLoading",value:function(t){this._loading=t}},{key:"dateTimeFormat",value:function(){return this._dateTimeFormat}},{key:"setTimezone",value:function(t){var e;try{e=new Intl.DateTimeFormat("en",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}catch(t){}e&&(this._dateTimeFormat=e)}},{key:"timezone",value:function(){return this._dateTimeFormat.resolvedOptions().timeZone}},{key:"dataSpace",value:function(){return this._dataSpace}},{key:"barSpace",value:function(){return this._barSpace}},{key:"halfBarSpace",value:function(){return this._barSpace/2}},{key:"setDataSpace",value:function(t,e){1>t||t>50||this._dataSpace===t||(this._dataSpace=t,this._barSpace=this._calcBarSpace(),e&&e(),this.adjustFromTo(),this._chartStore.crosshairStore().recalculate(!0),this._chartStore.invalidate())}},{key:"setTotalDataSpace",value:function(t){this._totalDataSpace!==t&&(this._totalDataSpace=t,this.adjustFromTo(),this._chartStore.crosshairStore().recalculate(!0))}},{key:"setOffsetRightSpace",value:function(t,e){this._offsetRightSpace=t,this._offsetRightBarCount=t/this._dataSpace,e&&(this.adjustFromTo(),this._chartStore.crosshairStore().recalculate(!0),this._chartStore.invalidate())}},{key:"resetOffsetRightSpace",value:function(){this.setOffsetRightSpace(this._offsetRightSpace)}},{key:"offsetRightSpace",value:function(){return this._offsetRightSpace}},{key:"offsetRightBarCount",value:function(){return this._offsetRightBarCount}},{key:"setOffsetRightBarCount",value:function(t){this._offsetRightBarCount=t}},{key:"setLeftMinVisibleBarCount",value:function(t){this._leftMinVisibleBarCount=t}},{key:"setRightMinVisibleBarCount",value:function(t){this._rightMinVisibleBarCount=t}},{key:"setLeftEmptyBarCount",value:function(t){this._leftEmptyBarCount=t}},{key:"setRightEmptyBarCount",value:function(t){this._rightEmptyBarCount=t}},{key:"from",value:function(){return this._from}},{key:"to",value:function(){return this._to}},{key:"startScroll",value:function(){this._preOffsetRightBarCount=this._offsetRightBarCount}},{key:"scroll",value:function(t,e){if(this._scrollEnabled){var i=t/this._dataSpace;this._chartStore.actionStore().execute(Q.SCROLL,{barCount:i,distance:t}),this._offsetRightBarCount=this._preOffsetRightBarCount-i,this.adjustFromTo();var n=e||this._chartStore.crosshairStore().get();this._chartStore.crosshairStore().set(n,!0),this._chartStore.invalidate()}}},{key:"getDataByDataIndex",value:function(t){return this._chartStore.dataList()[t]}},{key:"coordinateToFloatIndex",value:function(t){var e=this._chartStore.dataList().length;return Math.round(1e6*(e+this._offsetRightBarCount-(this._totalDataSpace-t)/this._dataSpace))/1e6}},{key:"dataIndexToTimestamp",value:function(t){var e=this.getDataByDataIndex(t);if(e)return e.timestamp}},{key:"timestampToDataIndex",value:function(t){return 0===this._chartStore.dataList().length?0:function(t,e,i){var n=0,r=0;for(r=t.length-1;n!==r;){var a=Math.floor((r+n)/2),o=r-n,s=t[a][e];if(i===t[n][e])return n;if(i===t[r][e])return r;if(i===s)return a;if(i>s?n=a:r=a,2>=o)break}return n}(this._chartStore.dataList(),"timestamp",t)}},{key:"dataIndexToCoordinate",value:function(t){var e=this._chartStore.dataList().length;return this._totalDataSpace-(e+this._offsetRightBarCount-t-.5)*this._dataSpace}},{key:"coordinateToDataIndex",value:function(t){return Math.ceil(this.coordinateToFloatIndex(t))-1}},{key:"zoom",value:function(t,e){var i=this;if(this._zoomEnabled){if(!e||!f(e.x)){var n=this._chartStore.crosshairStore().get();e={x:f(n.x)?n.x:this._totalDataSpace/2}}this._chartStore.actionStore().execute(Q.ZOOM,{coordinate:e,scale:t});var r=this.coordinateToFloatIndex(e.x);this.setDataSpace(this._dataSpace+t*(this._dataSpace/10),(function(){i._offsetRightBarCount+=r-i.coordinateToFloatIndex(e.x)}))}}},{key:"setZoomEnabled",value:function(t){this._zoomEnabled=t}},{key:"zoomEnabled",value:function(){return this._zoomEnabled}},{key:"setScrollEnabled",value:function(t){this._scrollEnabled=t}},{key:"scrollEnabled",value:function(){return this._scrollEnabled}},{key:"setLoadMoreCallback",value:function(t){this._loadMoreCallback=t}},{key:"clear",value:function(){this._more=!0,this._loading=!0,this._from=0,this._to=0}}]),t}();function it(t,e){return it=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},it(t,e)}function nt(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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&it(t,e)}function rt(t,e){if(e&&("object"===a(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function at(t){return at=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},at(t)}function ot(t,e,i,n,r,a,o){try{var s=t[a](o),c=s.value}catch(t){return void i(t)}s.done?e(c):Promise.resolve(c).then(n,r)}var st={exports:{}};!function(t){var e=function(t){var e,i=Object.prototype,n=i.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function c(t,e,i){return Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,i){return t[e]=i}}function h(t,e,i,n){var r=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new A(n||[]);return r._invoke=function(t,e,i){var n=u;return function(r,a){if(n===d)throw Error("Generator is already running");if(n===v){if("throw"===r)throw a;return I()}for(i.method=r,i.arg=a;;){var o=i.delegate;if(o){var s=E(o,i);if(s){if(s===_)continue;return s}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===u)throw n=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=d;var c=l(t,e,i);if("normal"===c.type){if(n=i.done?v:f,c.arg===_)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(n=v,i.method="throw",i.arg=c.arg)}}}(t,i,a),r}function l(t,e,i){try{return{type:"normal",arg:t.call(e,i)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var u="suspendedStart",f="suspendedYield",d="executing",v="completed",_={};function p(){}function y(){}function m(){}var g={};c(g,a,(function(){return this}));var x=Object.getPrototypeOf,S=x&&x(x(T([])));S&&S!==i&&n.call(S,a)&&(g=S);var b=m.prototype=p.prototype=Object.create(g);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function i(r,a,o,s){var c=l(t[r],t,a);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==typeof u&&n.call(u,"__await")?e.resolve(u.__await).then((function(t){i("next",t,o,s)}),(function(t){i("throw",t,o,s)})):e.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,s)}))}s(c.arg)}var r;this._invoke=function(t,n){function a(){return new e((function(e,r){i(t,n,e,r)}))}return r=r?r.then(a,a):a()}}function E(t,i){var n=t.iterator[i.method];if(n===e){if(i.delegate=null,"throw"===i.method){if(t.iterator.return&&(i.method="return",i.arg=e,E(t,i),"throw"===i.method))return _;i.method="throw",i.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var r=l(n,t.iterator,i.arg);if("throw"===r.type)return i.method="throw",i.arg=r.arg,i.delegate=null,_;var a=r.arg;return a?a.done?(i[t.resultName]=a.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,_):a:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,_)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function T(t){if(t){var i=t[a];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function i(){for(;++r<t.length;)if(n.call(t,r))return i.value=t[r],i.done=!1,i;return i.value=e,i.done=!0,i};return o.next=o}}return{next:I}}function I(){return{value:e,done:!0}}return y.prototype=m,c(b,"constructor",m),c(m,"constructor",y),y.displayName=c(m,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,c(t,s,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},k(w.prototype),c(w.prototype,o,(function(){return this})),t.AsyncIterator=w,t.async=function(e,i,n,r,a){void 0===a&&(a=Promise);var o=new w(h(e,i,n,r),a);return t.isGeneratorFunction(i)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},k(b),c(b,s,"Generator"),c(b,a,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var i in t)e.push(i);return e.reverse(),function i(){for(;e.length;){var n=e.pop();if(n in t)return i.value=n,i.done=!1,i}return i.done=!0,i}},t.values=T,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function r(n,r){return s.type="throw",s.arg=t,i.next=n,r&&(i.method="next",i.arg=e),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return r("end");if(this.prev>=o.tryLoc){var c=n.call(o,"catchLoc"),h=n.call(o,"finallyLoc");if(c&&h){if(o.catchLoc>this.prev)return r(o.catchLoc,!0);if(o.finallyLoc>this.prev)return r(o.finallyLoc)}else if(c){if(o.catchLoc>this.prev)return r(o.catchLoc,!0)}else{if(!h)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(this.prev>=r.tryLoc&&n.call(r,"finallyLoc")&&r.finallyLoc>this.prev){var a=r;break}}!a||"break"!==t&&"continue"!==t||a.tryLoc>e||e>a.finallyLoc||(a=null);var o=a?a.completion:{};return o.type=t,o.arg=e,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),_},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.finallyLoc===t)return this.complete(i.completion,i.afterLoc),C(i),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc===t){var n=i.completion;if("throw"===n.type){var r=n.arg;C(i)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,i,n){return this.delegate={iterator:T(t),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=e),_}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(st);var ct=st.exports,ht="line",lt="bar",ut="circle",ft={PRICE:"price",VOLUME:"volume",NORMAL:"normal"};function dt(t,e,i,n,r,a){var o=a.color,s=a.isStroke,c={prev:{kLineData:t[i-1],technicalIndicatorData:e[i-1]},current:{kLineData:t[i],technicalIndicatorData:e[i]},next:{kLineData:t[i+1],technicalIndicatorData:e[i+1]}};return f(n.color)&&(o=h(n.color)?n.color(c,r)||a.color:n.color||a.color),f(n.isStroke)&&(s=h(n.isStroke)?n.isStroke(c):n.isStroke),{color:o,isStroke:s}}var vt=function(){function t(e){var n=e.name,r=e.shortName,a=e.series,o=e.calcParams,s=e.plots,h=e.precision,l=e.shouldCheckParamCount,v=e.shouldOhlc,_=e.shouldFormatBigNumber,p=e.minValue,y=e.maxValue,m=e.styles;i(this,t),this.name=n||"",this.shortName=f(r)?r:n,this.series=-1!==Object.values(ft).indexOf(a)?a:ft.NORMAL,this.precision=u(h)&&h>=0?h:4,this._precisionFlag=!1,this.calcParams=c(o)?o:[],this.plots=c(s)?s:[],this.shouldCheckParamCount=!d(l)||l,this.shouldOhlc=!!d(v)&&v,this.shouldFormatBigNumber=!!d(_)&&_,this.minValue=p,this.maxValue=y,this.styles=m,this.result=[]}var e,n;return r(t,[{key:"_createParams",value:function(t){return t.map((function(t){return l(t)?t.value:t}))}},{key:"setShortName",value:function(t){return!(!f(t)||this.shortName===t)&&(this.shortName=t,!0)}},{key:"setPrecision",value:function(t,e){return!(!u(t)||0>t||e&&(!e||this._precisionFlag))&&(this.precision=parseInt(t,10),e||(this._precisionFlag=!0),!0)}},{key:"setCalcParams",value:function(t){if(!c(t))return!1;if(this.shouldCheckParamCount&&t.length!==this.calcParams.length)return!1;for(var e=[],i=0;t.length>i;i++){var n=t[i],r=void 0,a=void 0;l(n)?(r=n.value,a=n.allowDecimal):(r=n,a=!1);var o=this.calcParams[i];if(l(o)&&d(o.allowDecimal)&&(a=o.allowDecimal),!u(r)||!a&&parseInt(r,10)!==r)return!1;e.push({allowDecimal:a,value:r})}this.calcParams=e;var s=this.regeneratePlots(this._createParams(e));return s&&c(s)&&(this.plots=s),!0}},{key:"setShouldOhlc",value:function(t){return!(!d(t)||this.shouldOhlc===t)&&(this.shouldOhlc=t,!0)}},{key:"setShouldFormatBigNumber",value:function(t){return!(!d(t)||this.shouldFormatBigNumber===t)&&(this.shouldFormatBigNumber=t,!0)}},{key:"setStyles",value:function(t,e){return!!l(t)&&(this.styles||(this.styles={margin:s(e.margin),bar:s(e.bar),line:s(e.line),circle:s(e.circle)}),o(this.styles,t),!0)}},{key:"calc",value:(e=ct.mark((function t(e){return ct.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.calcTechnicalIndicator(e,{params:this._createParams(this.calcParams),plots:this.plots});case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:this.result=t.t0;case 6:case"end":return t.stop()}}),t,this)})),n=function(){var t=this,i=arguments;return new Promise((function(n,r){var a=e.apply(t,i);function o(t){ot(a,n,r,o,s,"next",t)}function s(t){ot(a,n,r,o,s,"throw",t)}o(void 0)}))},function(t){return n.apply(this,arguments)})},{key:"calcTechnicalIndicator",value:function(t,e){}},{key:"regeneratePlots",value:function(t){}}]),t}();function _t(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(!t)return;if("string"==typeof t)return pt(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return pt(t,e)}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return t.length>n?{done:!1,value:t[n++]}:{done:!0}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function pt(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);e>i;i++)n[i]=t[i];return n}function yt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=at(t);if(e){var r=at(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return rt(this,i)}}var mt=function(){function t(e){i(this,t),this._chartStore=e,this._templates=this._createTemplates(),this._instances=new Map}return r(t,[{key:"_createTechInfo",value:function(t){return{name:t.name,shortName:t.shortName,series:t.series,calcParams:t.calcParams,shouldCheckParamCount:t.shouldCheckParamCount,shouldOhlc:t.shouldOhlc,shouldFormatBigNumber:t.shouldFormatBigNumber,precision:t.precision,styles:t.styles,plots:t.plots,result:t.result||[]}}},{key:"_createTemplates",value:function(){var t={},i=e.technicalIndicatorExtensions;for(var n in i){var r=this._createTemplateInstance(i[n]);r&&(t[n]=r)}return t}},{key:"_createTemplateInstance",value:function(t){var e=t.name,n=t.shortName,a=t.series,o=t.calcParams,s=t.plots,c=t.precision,l=t.shouldCheckParamCount,u=t.shouldOhlc,f=t.shouldFormatBigNumber,d=t.minValue,v=t.maxValue,_=t.styles,p=t.calcTechnicalIndicator,y=t.regeneratePlots,m=t.createToolTipDataSource,g=t.render;if(!e||!h(p))return null;var x=function(t){nt(p,t);var h=yt(p);function p(){return i(this,p),h.call(this,{name:e,shortName:n,series:a,calcParams:o,plots:s,precision:c,shouldCheckParamCount:l,shouldOhlc:u,shouldFormatBigNumber:f,minValue:d,maxValue:v,styles:_})}return r(p)}(vt);return x.prototype.calcTechnicalIndicator=p,h(y)&&(x.prototype.regeneratePlots=y),h(m)&&(x.prototype.createToolTipDataSource=m),h(g)&&(x.prototype.render=g),new x}},{key:"addTemplate",value:function(t){var e=this;t.forEach((function(t){var i=e._createTemplateInstance(t||{});i&&(e._templates[i.name]=i)}))}},{key:"hasTemplate",value:function(t){return!!this._templates[t]}},{key:"getTemplateInfo",value:function(t){if(!f(t)){var e={};for(var i in this._templates){e[i]=this._createTechInfo(this._templates[i])}return e}var n=this._templates[t];return n?this._createTechInfo(n):{}}},{key:"addInstance",value:function(t,e,i){var n=e.name,r=e.calcParams,a=e.precision,o=e.shouldOhlc,s=e.shouldFormatBigNumber,c=e.styles,h=this._instances.get(t);if(!h||!h.has(n)){h||(h=new Map,this._instances.set(t,h));var l=this._templates[n],u=Object.create(Object.getPrototypeOf(l));for(var f in l)Object.prototype.hasOwnProperty.call(l,f)&&(u[f]=l[f]);return u.setCalcParams(r),u.setPrecision(a),u.setShouldOhlc(o),u.setShouldFormatBigNumber(s),u.setStyles(c,this._chartStore.styleOptions().technicalIndicator),i||h.clear(),h.set(n,u),u.calc(this._chartStore.dataList())}}},{key:"instances",value:function(t){return this._instances.get(t)||new Map}},{key:"removeInstance",value:function(t,e){var i=!1;if(this._instances.has(t)){var n=this._instances.get(t);f(e)?n.has(e)&&(n.delete(e),i=!0):(n.clear(),i=!0),0===n.size&&this._instances.delete(t)}return i}},{key:"hasInstance",value:function(t){return this._instances.has(t)}},{key:"calcInstance",value:function(t,e){var i=this,n=[];if(f(t))if(f(e)){var r=this._instances.get(e);r&&r.has(t)&&n.push(r.get(t).calc(this._chartStore.dataList()))}else this._instances.forEach((function(e){e.has(t)&&n.push(e.get(t).calc(i._chartStore.dataList()))}));else this._instances.forEach((function(t){t.forEach((function(t){n.push(t.calc(i._chartStore.dataList()))}))}));return Promise.all(n)}},{key:"getInstanceInfo",value:function(t,e){var i=this,n=function(t){var n,r=[],a=_t(t);try{for(a.s();!(n=a.n()).done;){var o=n.value[1];if(o){var s=i._createTechInfo(o);if(o.name===e)return s;r.push(s)}}}catch(t){a.e(t)}finally{a.f()}return r};if(!f(t)){var r={};return this._instances.forEach((function(t,e){r[e]=n(t)})),r}return this._instances.has(t)?n(this._instances.get(t)):{}}},{key:"setSeriesPrecision",value:function(t,e){var i=function(i){i.series===ft.PRICE&&i.setPrecision(t,!0),i.series===ft.VOLUME&&i.setPrecision(e,!0)};for(var n in this._templates)i(this._templates[n]);this._instances.forEach((function(t){t.forEach((function(t){i(t)}))}))}},{key:"override",value:function(t,e){var i=this,n=t.name,r=t.shortName,a=t.calcParams,o=t.precision,s=t.shouldOhlc,c=t.shouldFormatBigNumber,h=t.styles,l=this._chartStore.styleOptions().technicalIndicator,u=new Map;if(f(e))this._instances.has(e)&&u.set(e,this._instances.get(e));else{u=this._instances;var d=this._templates[n];d&&(d.setCalcParams(a),d.setShortName(r),d.setPrecision(o),d.setShouldOhlc(s),d.setShouldFormatBigNumber(c),d.setStyles(h,l))}var v=!1,_=[];if(u.forEach((function(t){if(t.has(n)){var e=t.get(n),u=e.setShortName(r),f=e.setCalcParams(a),d=e.setPrecision(o),p=e.setShouldOhlc(s),y=e.setShouldFormatBigNumber(c),m=e.setStyles(h,l);(u||f||d||p||y||m)&&(v=!0),f&&_.push(e.calc(i._chartStore.dataList()))}})),v)return Promise.all(_)}}]),t}();function gt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function xt(t,e){e.forEach((function(e){var i=e.key,n=e.fn;h(n)&&(t[i]=n)}))}var St=function(){function t(e){var n=e.id,r=e.chartStore,a=e.xAxis,o=e.yAxis;i(this,t),this._id=n,this._chartStore=r,this._xAxis=a,this._yAxis=o,this._styles=null}return r(t,[{key:"draw",value:function(t){}},{key:"setStyles",value:function(t,e){return!!l(t)&&(this._styles||(this._styles=s(e)),o(this._styles,t),!0)}},{key:"id",value:function(){return this._id}},{key:"styles",value:function(){return this._styles}},{key:"setYAxis",value:function(t){t&&(this._yAxis=t)}},{key:"checkEventCoordinateOn",value:function(t){}},{key:"onClick",value:function(t){}},{key:"onRightClick",value:function(t){}},{key:"onMouseEnter",value:function(t){}},{key:"onMouseLeave",value:function(t){}}]),t}();function bt(t,e,i,n){t.fillStyle=e,t.beginPath(),t.arc(i.x,i.y,n,0,2*Math.PI),t.closePath(),t.fill()}function kt(t,e,i){var n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y),a=Math.abs(i.x-t.x);return Math.abs(n*Math.abs(i.y-t.y)-a*r)/2}function wt(t,e,i){if(!i)return!1;var n=i.x-t.x,r=i.y-t.y;return!(n*n+r*r>e*e)}function Et(t,e,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),t.beginPath();var n=!0;e.forEach((function(e){e&&(n?(t.moveTo(e.x,e.y),n=!1):t.lineTo(e.x,e.y))})),i(),t.restore()}function Pt(t,e){Et(t,e,(function(){t.closePath(),t.stroke()}))}function Ct(t,e){Et(t,e,(function(){t.closePath(),t.fill()}))}function At(t,e,i,n){t.beginPath();var r=t.lineWidth%2?.5:0;t.moveTo(i,e+r),t.lineTo(n,e+r),t.stroke(),t.closePath()}function Tt(t,e,i,n){t.beginPath();var r=t.lineWidth%2?.5:0;t.moveTo(e+r,i),t.lineTo(e+r,n),t.stroke(),t.closePath()}function It(t,e){Et(t,e,(function(){t.stroke(),t.closePath()}))}function Ot(t){return t.ownerDocument&&t.ownerDocument.defaultView&&t.ownerDocument.defaultView.devicePixelRatio||2}function Mt(t,e){return Math.round(t.measureText(e).width)}function Dt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"normal",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Helvetica Neue";return"".concat(e," ").concat(t,"px ").concat(i)}function Lt(t,e,i){t.font=Dt(i.size,i.weight,i.family);var n=Mt(t,e);return i.paddingLeft+i.paddingRight+n+2*(i.borderSize||0)}function Rt(t){return t.paddingTop+t.paddingBottom+t.size+2*(t.borderSize||0)}function Bt(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(!t)return;if("string"==typeof t)return Ft(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Ft(t,e)}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return t.length>n?{done:!1,value:t[n++]}:{done:!0}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);e>i;i++)n[i]=t[i];return n}function zt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=at(t);if(e){var r=at(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return rt(this,i)}}var jt="other",Ht="point",Vt="none",Nt="line",Yt="text",Wt="continuous_line",Xt="polygon",Gt="arc",Ut=0,Zt=1,$t=2,Kt={NORMAL:"normal",WEAK_MAGNET:"weak_magnet",STRONG_MAGNET:"strong_magnet"};var qt=function(t){nt(n,t);var e=zt(n);function n(t){var r,a=t.id,o=t.name,s=t.totalStep,c=t.chartStore,h=t.xAxis,l=t.yAxis,u=t.points,f=t.styles,d=t.lock,v=t.mode,_=t.data;return i(this,n),(r=e.call(this,{id:a,chartStore:c,xAxis:h,yAxis:l}))._name=o,r._totalStep=s,r._lock=d,r._mode=Kt.NORMAL,r.setMode(v),r._data=_,r._drawStep=1,r._points=[],r.setPoints(u),r.setStyles(f,c.styleOptions().shape),r._prevPressPoint=null,r._prevPoints=null,r._coordinates=[],r}return r(n,[{key:"setPoints",value:function(t){if(c(t)&&t.length>0){var e;this._totalStep-1>t.length?(this._drawStep=t.length+1,this._points=s(t),e=t.length):(this._drawStep=-1,this._points=t.slice(0,this._totalStep-1),e=this._totalStep-1);for(var i=0;e>i;i++)this.performEventMoveForDrawing({step:i+2,mode:this._mode,points:this._points,movePoint:this._points[i],xAxis:this._xAxis,yAxis:this._yAxis});-1===this._drawStep&&this.performEventPressedMove({mode:this._mode,points:this._points,pressPointIndex:this._points.length-1,pressPoint:this._points[this._points.length-1],xAxis:this._xAxis,yAxis:this._yAxis})}}},{key:"_timestampOrDataIndexToCoordinateX",value:function(t){var e=t.timestamp,i=t.dataIndex;return e&&(i=this._chartStore.timeScaleStore().timestampToDataIndex(e)),this._xAxis.convertToPixel(i)}},{key:"_drawLines",value:function(t,e,i,n){t.save(),t.strokeStyle=i.color||n.color,t.lineWidth=i.size||n.size,i.style===y&&t.setLineDash(i.dashValue||n.dashValue),e.forEach((function(e){var i,n;if(e.length>1)switch((i=e[0]).x===(n=e[1]).x?$t:i.y===n.y?Zt:Ut){case Ut:It(t,e);break;case Zt:At(t,e[0].y,e[0].x,e[1].x);break;case $t:Tt(t,e[0].x,e[0].y,e[1].y)}})),t.restore()}},{key:"_drawContinuousLines",value:function(t,e,i,n){t.save(),t.strokeStyle=i.color||n.color,t.lineWidth=i.size||n.size,i.style===y&&t.setLineDash(i.dashValue||n.dashValue),e.forEach((function(e){e.length>0&&It(t,e)})),t.restore()}},{key:"_drawPolygons",value:function(t,e,i,n){var r;if(t.save(),i.style===p)t.fillStyle=(i.fill||n.fill).color,r=Ct;else{var a=i.stroke||n.stroke;a.style===y&&t.setLineDash(a.dashValue),t.lineWidth=a.size,t.strokeStyle=a.color,r=Pt}e.forEach((function(e){e.length>0&&r(t,e)})),t.restore()}},{key:"_drawArcs",value:function(t,e,i,n){if(t.save(),i.style===p)t.fillStyle=(i.fill||n.fill).color;else{var r=i.stroke||n.stroke;r.style===y&&t.setLineDash(r.dashValue),t.lineWidth=r.size,t.strokeStyle=r.color}e.forEach((function(e){var n=e.x,r=e.y,a=e.radius,o=e.startAngle,s=e.endAngle;t.beginPath(),t.arc(n,r,a,o,s),i.style===p?(t.closePath(),t.fill()):(t.stroke(),t.closePath())})),t.restore()}},{key:"_drawText",value:function(t,e,i,n){var r;t.save(),i.style===_?(t.strokeStyle=i.color||n.color,r=t.strokeText):(t.fillStyle=i.color||n.color,r=t.fillText),t.font=Dt(i.size||n.size,i.family||n.family,i.weight||n.weight);var a=i.offset||n.offset||[0,0];e.forEach((function(e){r.call(t,e.text,e.x+a[1],e.y+a[0])})),t.restore()}},{key:"draw",value:function(t){var e=this;this._coordinates=this._points.map((function(t){var i=t.value;return{x:e._timestampOrDataIndexToCoordinateX({timestamp:t.timestamp,dataIndex:t.dataIndex}),y:e._yAxis.convertToPixel(i)}}));var i=this._styles||this._chartStore.styleOptions().shape;if(1!==this._drawStep&&this._coordinates.length>0){var n={width:this._xAxis.width(),height:this._yAxis.height()},r={price:this._chartStore.pricePrecision(),volume:this._chartStore.volumePrecision()};this._shapeDataSources=this.createShapeDataSource({step:this._drawStep,mode:this._mode,points:this._points,coordinates:this._coordinates,viewport:{width:this._xAxis.width(),height:this._yAxis.height()},precision:{price:this._chartStore.pricePrecision(),volume:this._chartStore.volumePrecision()},styles:i,xAxis:this._xAxis,yAxis:this._yAxis,data:this._data})||[],this._shapeDataSources.forEach((function(n){var r=n.styles,a=n.dataSource,o=void 0===a?[]:a;if(n.isDraw)switch(n.type){case Nt:e._drawLines(t,o,r||i.line,i.line);break;case Wt:e._drawContinuousLines(t,o,r||i.line,i.line);break;case Xt:e._drawPolygons(t,o,r||i.polygon,i.polygon);break;case Gt:e._drawArcs(t,o,r||i.arc,i.arc);break;case Yt:e._drawText(t,o,r||i.text,i.text)}})),this.drawExtend&&(t.save(),this.drawExtend({ctx:t,dataSource:this._shapeDataSources,styles:i,viewport:n,precision:r,mode:this._mode,xAxis:this._xAxis,yAxis:this._yAxis,data:this