text: !function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=24)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e,n){var r=n(12),i=n(13),a=n(9),s=n(14);t.exports=function(t){return r(t)||i(t)||a(t)||s()}},function(t,e,n){t.exports=n(18)},function(t,e){function n(t,e,n,r,i,a,s){try{var o=t[a](s),u=o.value}catch(t){return void n(t)}o.done?e(u):Promise.resolve(u).then(r,i)}t.exports=function(t){return function(){var e=this,r=arguments;return new Promise((function(i,a){var s=t.apply(e,r);function o(t){n(s,i,a,o,u,"next",t)}function u(t){n(s,i,a,o,u,"throw",t)}o(void 0)}))}}},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e,n){var r=n(21),i=n(22),a=n(23);function s(t,e){if(!r.isSortableArrayLike(t))throw new Error("Invalid data");if(!e||t.length>0&&!(e in t[0]))throw new Error("Invalid index");this.data=t,this.index=e,this.setBoundaries(),this.compare="number"==typeof this.minv?i.numcmp:i.strcmp,this.search=a.search,this.valpos={},this.cursor=null,this.nextlow=null,this.nexthigh=null}t.exports=s,s.prototype.setCompare=function(t){if("function"!=typeof t)throw new Error("Invalid argument");return this.compare=t,this},s.prototype.setSearch=function(t){if("function"!=typeof t)throw new Error("Invalid argument");return this.search=t,this},s.prototype.sort=function(){var t=this,e=this.index;return this.data.sort((function(n,r){return t.compare(n[e],r[e])})),this.setBoundaries(),this},s.prototype.setBoundaries=function(){var t=this.data,e=this.index;return this.minv=t.length&&t[0][e],this.maxv=t.length&&t[t.length-1][e],this},s.prototype.fetch=function(t){if(0===this.data.length)return this.cursor=null,this.nextlow=null,this.nexthigh=null,this;if(-1===this.compare(t,this.minv))return this.cursor=null,this.nextlow=null,this.nexthigh=0,this;if(1===this.compare(t,this.maxv))return this.cursor=null,this.nextlow=this.data.length-1,this.nexthigh=null,this;var e=this.valpos[t];if(e)return e.found?(this.cursor=e.index,this.nextlow=null,this.nexthigh=null):(this.cursor=null,this.nextlow=e.prev,this.nexthigh=e.next),this;var n=this.search.call(this,t);return this.cursor=n.index,this.nextlow=n.prev,this.nexthigh=n.next,this},s.prototype.get=function(t){t&&this.fetch(t);var e=this.cursor;return null!==e?this.data[e]:null},s.prototype.getRange=function(t,e){if(1===this.compare(t,e))return[];this.fetch(t);var n=this.cursor||this.nexthigh;this.fetch(e);var r=this.cursor||this.nextlow;return null===n||null===r?[]:this.data.slice(n,r+1)}},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e,n){var r=n(8);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e,n){var r=n(15),i=n(16),a=n(9),s=n(17);t.exports=function(t,e){return r(t)||i(t,e)||a(t,e)||s()}},function(t,e,n){var r=n(19),i=n(20);function a(e,n,s){return i()?t.exports=a=Reflect.construct:t.exports=a=function(t,e,n){var i=[null];i.push.apply(i,e);var a=new(Function.bind.apply(t,i));return n&&r(a,n.prototype),a},a.apply(null,arguments)}t.exports=a},function(t,e,n){var r=n(8);t.exports=function(t){if(Array.isArray(t))return r(t)}},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,i=!1,a=void 0;try{for(var s,o=t[Symbol.iterator]();!(r=(s=o.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,a=t}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}return n}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,n){var r=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function o(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{o({},"")}catch(t){o=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var i=e&&e.prototype instanceof f?e:f,a=Object.create(i.prototype),s=new x(r||[]);return a._invoke=function(t,e,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return O()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var o=k(s,n);if(o){if(o===c)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=h(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,s),a}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var c={};function f(){}function l(){}function _(){}var d={};d[i]=function(){return this};var v=Object.getPrototypeOf,p=v&&v(v(M([])));p&&p!==e&&n.call(p,i)&&(d=p);var y=_.prototype=f.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){o(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var r;this._invoke=function(i,a){function s(){return new e((function(r,s){!function r(i,a,s,o){var u=h(t[i],t,a);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,s,o)}),(function(t){r("throw",t,s,o)})):e.resolve(f).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,o)}))}o(u.arg)}(i,a,r,s)}))}return r=r?r.then(s,s):s()}}function k(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=h(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,c;var i=r.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function b(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 w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function M(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return l.prototype=y.constructor=_,_.constructor=l,l.displayName=o(_,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,o(t,s,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},m(g.prototype),g.prototype[a]=function(){return this},t.AsyncIterator=g,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var s=new g(u(e,n,r,i),a);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},m(y),o(y,s,"Generator"),y[i]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=M,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},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 e=this;function r(n,r){return s.type="throw",s.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=t,s.arg=e,a?(this.method="next",this.next=a.finallyLoc,c):this.complete(s)},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),c},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),w(n),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:M(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e){t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}},function(t,e){t.exports.isSortableArrayLike=function(t){return function(t){return!!(t&&"object"==typeof t&&isFinite(t.length)&&t.length>=0&&t.length===Math.floor(t.length)&&t.length<4294967296)}(t)&&function(t){return!(!t||"object"!=typeof t||"function"!=typeof t.sort)}(t)}},function(t,e){t.exports={numcmp:function(t,e){return t-e},strcmp:function(t,e){return t<e?-1:t>e?1:0}}},function(t,e){function n(t,e,r,i,a){var s=r+e>>>1,o=this.compare(t[s][this.index],i);return o?e>=r?a[i]={found:!1,index:null,prev:o<0?r:r-1,next:o<0?r+1:r}:o>0?n.call(this,t,e,s-1,i,a):n.call(this,t,s+1,r,i,a):a[i]={found:!0,index:s,prev:null,next:null}}t.exports.search=function(t){var e=this.data;return n.call(this,e,0,e.length-1,t,this.valpos)}},function(t,e,n){"use strict";n.r(e);var r=n(2),i=n.n(r),a=n(10),s=n.n(a),o=n(3),u=n.n(o),h=n(4),c=n.n(h),f=n(0),l=n.n(f),_=n(1),d=n.n(_),v=n(5),p=n.n(v),y=n(11),m=n.n(y);var g=36e5,k=24*g,b=24192e5,w=365*k,x={SBMIN:60,SBMAX:1/0,TOOLBAR:57,TB_ICON:25,TB_ITEM_M:6,TB_ICON_BRI:1,TB_ICON_HOLD:420,TB_BORDER:1,TB_B_STYLE:"dotted",TOOL_COLL:7,EXPAND:.15,CANDLEW:.6,GRIDX:100,GRIDY:47,BOTBAR:28,PANHEIGHT:22,DEFAULT_LEN:50,MINIMUM_LEN:5,MIN_ZOOM:25,MAX_ZOOM:1e3,VOLSCALE:.15,UX_OPACITY:.9,ZOOM_MODE:"tv",L_BTN_SIZE:21,L_BTN_MARGIN:"-6px 0 -6px 0",SCROLL_WHEEL:"prevent",FONT:"11px -apple-system,BlinkMacSystemFont,\n    Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,\n    Fira Sans,Droid Sans,Helvetica Neue,\n    sans-serif"},M={SECOND:1e3,MINUTE:6e4,MINUTE5:3e5,MINUTE15:9e5,MINUTE30:18e5,HOUR:g,HOUR4:144e5,DAY:k,WEEK:6048e5,MONTH:b,YEAR:w,MONTHMAP:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],TIMESCALES:[10*w,5*w,3*w,2*w,w,6*b,4*b,3*b,2*b,b,15*k,10*k,7*k,5*k,3*k,2*k,k,12*g,6*g,3*g,1.5*g,g,18e5,9e5,6e5,3e5,12e4,6e4],$SCALES:[.05,.1,.2,.25,.5,.8,1,2,5],ChartConfig:x,map_unit:{"1s":1e3,"5s":5e3,"10s":1e4,"20s":2e4,"30s":3e4,"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1H":g,"2H":2*g,"3H":3*g,"4H":144e5,"12H":432e5,"1D":k,"1W":6048e5,"1M":b,"1Y":w},IB_TF_WARN:"When using IB mode you should specify timeframe ('tf' filed in 'chart' object),otherwise you can get an unexpected behaviour"},O=/(function |)([$A-Z_][0-9A-Z_$\.]*)[\s]*?\((.*?)\)/gim,A=/([$A-Z_][0-9A-Z_$\.]*)[\s]*?\[([^"^\[^\]]+?)\]/gim,S=/(\d+)(\w*)/gm,j={};function E(t){O.lastIndex=0;var e=O.exec(t);if(e){e[1].trim(),e[2].trim();return e[3].trim().split(",").map((function(t){return t.trim()}))}return[]}function N(t){return t.slice(t.indexOf("{")+1,t.lastIndexOf("}"))}function I(t,e){void 0===e&&(e=""),A.lastIndex=0;do{var n=A.exec(t);if(n){var r=n[1].trim(),i=n[2].trim();if("0"===i||parseInt(i)<5)continue;switch(r){case"let":case"var":case"return":continue}var a="".concat(r,"[").concat(e,"_i(").concat(i,", ").concat(r,")]");t=t.replace(n[0],a),!0}}while(n);return t}function T(t){if("string"==typeof t)return t;var e=t.toString();return e.slice(e.indexOf("{")+1,e.lastIndexOf("}"))}function L(t,e){var n=1;switch(e){case"s":n=M.SECOND;break;case"m":n=M.MINUTE;break;case"H":n=M.HOUR;break;case"D":n=M.DAY;break;case"W":n=M.WEEK;break;case"M":n=M.MONTH;break;case"Y":n=M.YEAR}return parseInt(t)*n}function D(t){if("number"==typeof t)return t;if(j[t])return j[t];S.lastIndex=0;var e=S.exec(t);return e?(j[t]=L(e[1],e[2]),j[t]):void 0}function C(t,e){return t+"-"+e.split("<-").pop()}function F(t,e){var n={};for(var r in t){for(var i in n[r]={},t[r])"data"!==i&&(n[r][i]=t[r][i]);n[r].data=e(t[r].data)}return n}function U(t,e,n){void 0===n&&(n=0);for(var r=0,i=t.length-1;r<=i;){var a=Math.floor((r+i)/2);if(t[a][n]===e)return a;t[a][n]<e?r=a+1:i=a-1}return e<t[a][n]?a:a+1}function P(t){var e=0;for(var n in t){if(t[n].data&&t[n].data[0])e+=q(t[n].data[0])*t[n].data.length}return e}function q(t){for(var e=[],n=[t],r=0;n.length;){var i=n.pop(),a=p()(i);if("boolean"===a)r+=4;else if("string"===a)r+=2*i.length;else if("number"===a)r+=8;else if("object"===a&&-1===e.indexOf(i))for(var s in e.push(i),i)n.push(i[s])}return r}function R(t,e){var n=t.length-1,r=t[n];!r||e[0]>r[0]?t.push(e):t[n]=e}function B(){return(new Date).getTime()}var H=function(t){var e=["high","low","close","vol"].indexOf(t);return function(n,r){var i=this.__tf__;this.__id__;r=r||_t.t;var a=void 0!==n?n:_t[t][0];switch((!this.__t0__||r>=this.__t0__+i)&&(this.unshift(3!==e?a:0),this.__t0__=r-r%i),e){case 0:a>this[0]&&(this[0]=a);break;case 1:a<this[0]&&(this[0]=a);break;case 2:this[0]=a;break;case 3:this[0]+=a}this.length=this.__len__||5}};function z(t,e,n){return e.__id__=t,e.__len__=n,e}function $(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return G(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var W=["open","high","low","close","vol"],Y=function(){function t(e,n){if(l()(this,t),this.id=n.id,this.tf=D(n.tf),this.format=n.format,this.aggtype=n.aggtype||"ohlcv",this.window=n.window,this.fillgaps=n.fillgaps,this.data=e,this.data_type=0,this.main=!!n.main,this.idx=this.data_idx(),this.tmap={},this.tf=this.tf||_t.tf,this.main&&(this.tf=_t.tf),"ohlcv"===this.aggtype){var r,i=$(W);try{for(i.s();!(r=i.n()).done;){this[o=r.value]=z("".concat(this.id,"_").concat(o),[]),this[o].__fn__=H(o).bind(this[o]),this[o].__tf__=this.tf}}catch(t){i.e(t)}finally{i.f()}}if("copy"===this.aggtype){var a,s=$(W);try{for(s.s();!(a=s.n()).done;){var o;this[o=a.value]=z("".concat(this.id,"_").concat(o),[]),this[o].__tf__=this.tf}}catch(t){s.e(t)}finally{s.f()}for(var u=0;u<this.data.length;u++)this.tmap[this.data[u][0]]=u}if("function"==typeof this.aggtype&&(this.close=z("".concat(this.id,"_close"),[]),this.close.__fn__=this.aggtype,this.close.__tf__=this.tf),this.main){if(!this.tf)throw"Main tf should be defined";_t.custom_main=this;var h=this.data[0][0];_t.t=h-h%this.tf,this.update(null,_t.t),_t.data.ohlcv.data.length=0,_t.data.ohlcv.data.push([_t.t,this.open[0],this.high[0],this.low[0],this.close[0],this.vol[0]])}}return d()(t,[{key:"update",value:function(t,e){return"ohlcv"===this.aggtype?this.update_ohlcv(t,e):"copy"===this.aggtype?this.update_copy(t,e):"function"==typeof this.aggtype?this.update_custom(t,e):void 0}},{key:"update_ohlcv",value:function(t,e){e=e||_t.t;var n=this.idx;switch(this.data_type){case 0:if(e>this.data[this.data.length-1][0])return!1;var r=this.window?e-this.window+this.tf:e;r-=r%this.tf;var i=U(this.data,r);if(i>=this.data.length)return!1;var a=e+_t.tf;e<this.vol.__t0__+this.tf&&(this.vol[0]=0);for(var s=!0,o=i;o<this.data.length;o++){s=!1;var u=this.data[o];if(u[n.time]>=a)break;this.open.__fn__(u[n.open],e),this.high.__fn__(u[n.high],e),this.low.__fn__(u[n.low],e),this.close.__fn__(u[n.close],e),this.vol.__fn__(u[n.vol],e)}if(s){if(!1===this.fillgaps&&!this.main)return!1;var h=this.close[0];this.open.__fn__(h,e),this.high.__fn__(h,e),this.low.__fn__(h,e),this.close.__fn__(h,e),this.vol.__fn__(0,e)}}return!0}},{key:"update_copy",value:function(t,e){e=e||_t.t;var n=this.tmap[e],r=this.data[n],i=this.__t0__;if(!i||e>=i+this.tf){for(var a=0;a<5;a++){this[W[a]].unshift(void 0)}this.__t0__=e-e%this.tf;var s=this.data.length-1;this.__t0__===this.data[s][0]&&(this.tmap[this.__t0__]=s,r=this.data[s])}if(r)for(a=0;a<5;a++){this[W[a]][0]=r[a+1]}else if(this.fillgaps)for(a=0;a<5;a++){this[W[a]][0]=this.close[1]}}},{key:"update_custom",value:function(t,e){e=e||_t.t;var n=this.idx;switch(this.data_type){case 0:if(!this.data.length)return!1;if(e>this.data[this.data.length-1][0])return!1;var r=this.window?e-this.window+this.tf:e;r-=r%this.tf;var i=U(this.data,r);if(i>=this.data.length)return!1;for(var a=e+_t.tf,s=[],o=i;o<this.data.length;o++){var u=this.data[o];if(u[n.time]>=a)break;s.push(u)}if(s.length||!1===this.fillgaps)var h=this.close.__fn__(s);else!1!==this.fillgaps&&(h=this.close[0]);var c=this.close.__t0__;!c||e>=c+this.tf?(this.close.unshift(h),this.close.__t0__=e-e%this.tf):this.close[0]=h}return!0}},{key:"data_idx",value:function(){var t={};switch(this.aggtype){case"ohlcv":if(!this.format){var e=this.data[0];e&&6!==e.length?3===e.length&&(this.format="time:open,high,low,close:vol"):this.format="time:open:high:low:close:vol"}break;default:this.format="time:close"}return this.format.split(":").forEach((function(e,n){e.length&&e.split(",").forEach((function(e){return t[e]=n}))})),t}}]),t}();function Z(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return V(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return V(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function V(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var X=function(){function t(e){l()(this,t),this.env=e,this.se=_t,this.SWMA=[1/6,2/6,2/6,1/6],this.STDEV_EPS=1e-10,this.STDEV_Z=1e-4,this._index_tracking()}return d()(t,[{key:"_index_tracking",value:function(){var t,e=Object.getPrototypeOf(this),n=Z(Object.getOwnPropertyNames(e));try{for(n.s();!(t=n.n()).done;){var r=t.value;switch(r){case"constructor":case"ts":case"tstf":case"_index_tracking":case"_tsid":case"_i":case"_v":case"_add_i":case"chart":case"onchart":case"offchart":case"sym":continue}var i=this._add_i(r,this[r].toString());i&&(this[r]=i)}}catch(t){n.e(t)}finally{n.f()}}},{key:"_add_i",value:function(t,e){var n=E(e),r=I(e=N(e),"this.");return r!==e?m()(Function,i()(n).concat([r])):null}},{key:"_tsid",value:function(t,e){return"".concat(t,"<-").concat(e)}},{key:"_i",value:function(t,e){return null!=e&&e==e&&e.__id__&&(!e.__len__||t>=e.__len__)&&(e.__len__=t+5),t}},{key:"_v",value:function(t,e){return null!=t&&t==t&&t.__id__&&(!t.__len__||e>=t.__len__)&&(t.__len__=e+5),t}},{key:"ts",value:function(t,e,n){if(n)return this.tstf(t,n,e);var r=this.env.tss[e];return r?r[0]=t:(r=this.env.tss[e]=[t],r.__id__=e),r}},{key:"tstf",value:function(t,e,n){var r=this.env.tss[n];return r?r.__fn__(t):((r=this.env.tss[n]=[t]).__id__=n,r.__tf__=D(e),r.__fn__=H("close").bind(r)),r}},{key:"nz",value:function(t,e){return null==t||t!=t?e||0:t}},{key:"na",value:function(t){return null==t||t!=t}},{key:"nf",value:function(t,e){return isFinite(t)?t:void 0!==e?e:NaN}},{key:"add",value:function(t,e,n){var r=this._tsid(n,"add"),i=this.na(t)?NaN:t.__id__?t[0]:t,a=this.na(e)?NaN:e.__id__?e[0]:e;return this.ts(i+a,r,t.__tf__)}},{key:"sub",value:function(t,e,n){var r=this._tsid(n,"sub"),i=this.na(t)?NaN:t.__id__?t[0]:t,a=this.na(e)?NaN:e.__id__?e[0]:e;return this.ts(i-a,r,t.__tf__)}},{key:"mult",value:function(t,e,n){var r=this._tsid(n,"mult"),i=this.na(t)?NaN:t.__id__?t[0]:t,a=this.na(e)?NaN:e.__id__?e[0]:e;return this.ts(i*a,r,t.__tf__)}},{key:"div",value:function(t,e,n){var r=this._tsid(n,"div"),i=this.na(t)?NaN:t.__id__?t[0]:t,a=this.na(e)?NaN:e.__id__?e[0]:e;return this.ts(i/a,r,t.__tf__)}},{key:"neg",value:function(t,e){var n=this._tsid(e,"neg"),r=this.na(t)?NaN:t.__id__?t[0]:t;return this.ts(-r,n,t.__tf__)}},{key:"abs",value:function(t){return Math.abs(t)}},{key:"acos",value:function(t){return Math.acos(t)}},{key:"signal",value:function(t,e){void 0===e&&(e={}),"update"===this.se.shared.event&&this.se.send("script-signal",{type:t,data:e})}},{key:"signalif",value:function(t,e,n){void 0===n&&(n={}),"update"===this.se.shared.event&&(t&&t.__id__&&(t=t[0]),t&&this.se.send("script-signal",{type:e,data:n}))}},{key:"alma",value:function(t,e,n,r,i){for(var a=this._tsid(i,"alma(".concat(e,",").concat(n,",").concat(r,")")),s=Math.floor(n*(e-1)),o=e/r,u=0,h=0,c=0;c<e;c++){var f=Math.exp(-1*Math.pow(c-s,2)/(2*Math.pow(o,2)));u+=f,h+=t[e-c-1]*f}return this.ts(h/u,a,t.__tf__)}},{key:"asin",value:function(t){return Math.asin(t)}},{key:"atan",value:function(t){return Math.atan(t)}},{key:"atr",value:function(t,e,n){var r=n||"",i=this._tsid(e,"atr(".concat(t,")")),a=this.env.shared["high".concat(r)],s=this.env.shared["low".concat(r)],o=this.env.shared["close".concat(r)],u=this.ts(0,i,n);return u[0]=this.na(a[1])?a[0]-s[0]:Math.max(Math.max(a[0]-s[0],Math.abs(a[0]-o[1])),Math.abs(s[0]-o[1])),this.rma(u,t,i)}},{key:"avg",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];e.pop();for(var r=0,i=0;i<e.length;i++)r+=e[i];return r/e.length}},{key:"since",value:function(t,e){var n=this._tsid(e,"since()");t&&t.__id__&&(t=t[0]);var r=this.ts(void 0,n);return r[0]=t?0:r[1]+1,r}},{key:"bb",value:function(t,e,n,r){var i=this._tsid(r,"bb(".concat(e,",").concat(n,")")),a=this.sma(t,e,i),s=this.stdev(t,e,i)[0]*n;return[a,this.ts(a[0]+s,i+"1",t.__tf__),this.ts(a[0]-s,i+"2",t.__tf__)]}},{key:"bbw",value:function(t,e,n,r){var i=this._tsid(r,"bbw(".concat(e,",").concat(n,")")),a=this.sma(t,e,i)[0],s=this.stdev(t,e,i)[0]*n;return this.ts(2*s/a,i,t.__tf__)}},{key:"bool",value:function(t){return!!t}},{key:"cci",value:function(t,e,n){var r=this._tsid(n,"cci(".concat(e,")")),i=this.sma(t,e,r),a=this.dev(t,e,r),s=(t[0]-i[0])/(.015*a[0]);return this.ts(s,r,t.__tf__)}},{key:"ceil",value:function(t){return Math.ceil(t)}},{key:"change",value:function(t,e,n){void 0===e&&(e=1);var r=this._tsid(n,"change(".concat(e,")"));return this.ts(t[0]-t[e],r,t.__tf__)}},{key:"cmo",value:function(t,e,n){var r=this._tsid(n,"cmo(".concat(e,")")),i=this.change(t,1,r),a=this.ts(i[0]>=0?i[0]:0,r+"g",t.__tf__),s=this.ts(i[0]>=0?0:-i[0],r+"l",t.__tf__),o=this.sum(a,e,r+"1")[0],u=this.sum(s,e,r+"2")[0];return this.ts(100*(o-u)/(o+u),r,t.__tf__)}},{key:"cog",value:function(t,e,n){for(var r=this._tsid(n,"cmo(".concat(e,")")),i=this.sum(t,e,r)[0],a=0,s=0;s<e;s++)a+=t[s]*(s+1);return this.ts(-a/i,r,t.__tf__)}},{key:"corr",value:function(){}},{key:"cos",value:function(t){return Math.cos(t)}},{key:"cross",value:function(t,e,n){var r=this._tsid(n,"cross"),i=t[0]>e[0]!=t[1]>e[1];return this.ts(i,r,t.__tf__)}},{key:"crossover",value:function(t,e,n){var r=this._tsid(n,"crossover"),i=t[0]>e[0]&&t[1]<=e[1];return this.ts(i,r,t.__tf__)}},{key:"crossunder",value:function(t,e,n){var r=this._tsid(n,"crossunder"),i=t[0]<e[0]&&t[1]>=e[1];return this.ts(i,r,t.__tf__)}},{key:"cum",value:function(t,e){var n=this._tsid(e,"cum"),r=this.ts(0,n,t.__tf__);return r[0]=this.nz(t[0])+this.nz(r[1]),r}},{key:"dayofmonth",value:function(t){return new Date(t||_t.t).getUTCDate()}},{key:"dayofweek",value:function(t){return new Date(t||_t.t).getUTCDay()+1}},{key:"dev",value:function(t,e,n){for(var r=this._tsid(n,"dev(".concat(e,")")),i=this.sma(t,e,r)[0],a=0,s=0;s<e;s++)a+=Math.abs(t[s]-i);return this.ts(a/e,r,t.__tf__)}},{key:"dmi",value:function(t,e,n,r){var i=this._tsid(n,"dmi(".concat(t,",").concat(e,")")),a=r||"",s=this.env.shared["high".concat(a)],o=this.env.shared["low".concat(a)],u=this.change(s,1,i+"1")[0],h=this.neg(this.change(o,1,i+"2"),i)[0],c=this.ts(100*(this.na(u)?NaN:u>h&&u>0?u:0),i+"3",r),f=this.ts(100*(this.na(h)?NaN:h>u&&h>0?h:0),i+"4",r),l=this.rma(this.tr(!1,i,r),t,i+"5"),_=this.div(this.rma(c,t,i+"6"),l,i+"8"),d=this.div(this.rma(f,t,i+"7"),l,i+"9"),v=this.add(_,d,i+"10")[0];return[this.rma(this.ts(100*Math.abs(_[0]-d[0])/(0===v?1:v),i+"11",r),e,i+"12"),_,d]}},{key:"ema",value:function(t,e,n){var r=this._tsid(n,"ema(".concat(e,")")),i=2/(e+1),a=this.ts(0,r,t.__tf__);return a[0]=this.na(a[1])?this.sma(t,e,r)[0]:i*t[0]+(1-i)*this.nz(a[1]),a}},{key:"exp",value:function(t){return Math.exp(t)}},{key:"falling",value:function(t,e,n){for(var r=this._tsid(n,"falling(".concat(e,")")),i=t[0],a=1;a<e+1;a++)if(i>=t[a])return this.ts(!1,r,t.__tf__);return this.ts(!0,r,t.__tf__)}},{key:"fixnan",value:function(t){if(this.na(t[0]))for(var e=1;e<t.length;e++)if(!this.na(t[e])){t[0]=t[e];break}return t}},{key:"floor",value:function(t){Math.floor(t)}},{key:"highest",value:function(t,e,n){for(var r=this._tsid(n,"highest(".concat(e,")")),i=-1/0,a=0;a<e;a++)t[a]>i&&(i=t[a]);return this.ts(i,r,t.__tf__)}},{key:"highestbars",value:function(t,e,n){for(var r=this._tsid(n,"highestbars(".concat(e,")")),i=-1/0,a=0,s=0;s<e;s++)t[s]>i&&(i=t[s],a=s);return this.ts(-a,r,t.__tf__)}},{key:"hma",value:function(t,e,n){var r=this._tsid(n,"hma(".concat(e,")")),i=Math.floor(e/2),a=Math.round(Math.sqrt(e)),s=this.mult(this.wma(t,i,r+"1"),2,r),o=this.wma(t,e,r+"2"),u=this.sub(s,o,r+"3");return this.wma(u,a,r+"4")}},{key:"hour",value:function(t){return new Date(t||_t.t).getUTCHours()}},{key:"iff",value:function(t,e,n){return t&&t.__id__&&(t=t[0]),t?e:n}},{key:"kc",value:function(t,e,n,r,i,a){void 0===r&&(r=!0);var s=this._tsid(i,"kc(".concat(e,",").concat(n,",").concat(r,")")),o=a||"",u=this.env.shared["high".concat(o)],h=this.env.shared["low".concat(o)],c=this.ema(t,e,s+"1"),f=r?this.tr(!1,s+"2",a):this.ts(u[0]-h[0],s+"3",t.__tf__),l=this.ema(f,e,s+"4");return[c,this.ts(c[0]+l[0]*n,s+"5",t.__tf__),this.ts(c[0]-l[0]*n,s+"6",t.__tf__)]}},{key:"kcw",value:function(t,e,n,r,i,a){void 0===r&&(r=!0);var s=this._tsid(i,"kcw(".concat(e,",").concat(n,",").concat(r,")")),o=this.kc(t,e,n,r,"kcw",a);return this.ts((o[1][0]-o[2][0])/o[0][0],s,t.__tf__)}},{key:"linreg",value:function(t,e,n,r){void 0===n&&(n=0);var i=this._tsid(r,"linreg(".concat(e,")"));t.__len__=Math.max(t.__len__||0,e);var a=function(t,e,n){t=t.slice(0,e).reverse().map((function(t,e){return[e,t]}));var r,i,a=0,s=0,o=0,u=0,h=0,c=0;for(e=t.length;c<e;c++){if(!t[c])return NaN;var f=t[c];a+=f[0],s+=f[1],u+=f[0]*f[0],o+=f[0]*f[1],h++}return i=s/h-(r=(h*o-a*s)/(h*u-a*a))*a/h,r*(t.length-1-n)+i}(t,e,n);return this.ts(a,i,t.__tf__)}},{key:"log",value:function(t){return Math.log(t)}},{key:"log10",value:function(t){return Math.log10(t)}},{key:"lowest",value:function(t,e,n){for(var r=this._tsid(n,"lowest(".concat(e,")")),i=1/0,a=0;a<e;a++)t[a]<i&&(i=t[a]);return this.ts(i,r,t.__tf__)}},{key:"lowestbars",value:function(t,e,n){for(var r=this._tsid(n,"lowestbars(".concat(e,")")),i=1/0,a=0,s=0;s<e;s++)t[s]<i&&(i=t[s],a=s);return this.ts(-a,r,t.__tf__)}},{key:"macd",value:function(t,e,n,r,i){var a=this._tsid(i,"macd(".concat(e).concat(n).concat(r,")")),s=this.ema(t,e,a+"1"),o=this.ema(t,n,a+"2"),u=this.sub(s,o,a+"3"),h=this.ema(u,r,a+"4");return[u,h,this.sub(u,h,a+"5")]}},{key:"max",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.pop(),Math.max.apply(Math,e)}},{key:"modify",value:function(t,e){_t.send("modify-overlay",{uuid:t,fields:e})}},{key:"buffsize",value:function(t,e){t.__len__=e}},{key:"mfi",value:function(t,e,n){var r=this._tsid(n,"mfi(".concat(e,")")),i=this.env.shared.vol,a=this.change(t,1,r+"1")[0],s=this.mult(i,a<=0?0:t[0],r+"2"),o=this.mult(i,a>=0?0:t[0],r+"3"),u=this.sum(s,e,r+"4"),h=this.sum(o,e,r+"5"),c=void 0;return this.na(h)||(c=this.rsi(u,h,r+"6")[0]),this.ts(c,r,t.__tf__)}},{key:"min",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.pop(),Math.min.apply(Math,e)}},{key:"minute",value:function(t){return new Date(t||_t.t).getUTCMinutes()}},{key:"mom",value:function(t,e,n){var r=this._tsid(n,"mom(".concat(e,")"));return this.ts(t[0]-t[e],r,t.__tf__)}},{key:"month",value:function(t){return new Date(t||_t.t).getUTCMonth()}},{key:"chart",value:function(){}},{key:"onchart",value:function(t,e,n,r){void 0===n&&(n={});var a=0;if(e=e||C("Onchart",r),t&&t.__id__&&(a=t.__offset__||0,t=t[0]),Array.isArray(t)&&t[0]&&t[0].__id__&&(a=t[0].__offset__||0,t=t.map((function(t){return t[0]}))),!this.env.onchart[e]){var s=n.type;delete n.type,n.$synth=!0,n.skipNaN=!0;var o=Array.isArray(t)?"s":"";this.env.onchart[e]={name:e,type:s||"Spline"+o,data:[],settings:n,scripts:!1,grid:n.grid||{}}}a*=_t.tf;var u=Array.isArray(t)?[_t.t+a].concat(i()(t)):[_t.t+a,t];R(this.env.onchart[e].data,u)}},{key:"offchart",value:function(t,e,n,r){void 0===n&&(n={}),e=e||C("Offchart",r);var a=0;if(t&&t.__id__&&(a=t.__offset__||0,t=t[0]),Array.isArray(t)&&t[0]&&t[0].__id__&&(a=t[0].__offset__||0,t=t.map((function(t){return t[0]}))),!this.env.offchart[e]){var s=n.type;delete n.type,n.$synth=!0,n.skipNaN=!0;var o=Array.isArray(t)?"s":"";this.env.offchart[e]={name:e,type:s||"Spline"+o,data:[],settings:n,scripts:!1,grid:n.grid||{}}}a*=_t.tf;var u=Array.isArray(t)?[_t.t+a].concat(i()(t)):[_t.t+a,t];R(this.env.offchart[e].data,u)}},{key:"onclose",value:function(t){return!!this.env.shared.onclose&&(t||(t=_t.tf),(_t.t+_t.tf)%D(t)==0)}},{key:"settings",value:function(t){this.env.send_modify({settings:t}),Object.assign(this.env.src.sett,t)}},{key:"offset",value:function(t,e,n){if(t.__id__)return t.__offset__=e,t;var r=this._tsid(n,"offset(".concat(e,")")),i=ts(t,r);return i.__offset__=e,i}},{key:"linearint",value:function(){}},{key:"nearestrank",value:function(){}},{key:"now",value:function(){return(new Date).getTime()}},{key:"percentrank",value:function(){}},{key:"pivothigh",value:function(t,e,n,r){for(var i=this._tsid(r,"pivothigh(".concat(e,",").concat(n,")")),a=e+n+1,s=t[n],o=0;o<a;o++)if(s<=t[o]&&o!==n)return this.ts(NaN,i,t.__tf__);return this.ts(s,i,t.__tf__)}},{key:"pivotlow",value:function(t,e,n,r){for(var i=this._tsid(r,"pivotlow(".concat(e,",").concat(n,")")),a=e+n+1,s=t[n],o=0;o<a;o++)if(s>=t[o]&&o!==n)return this.ts(NaN,i,t.__tf__);return this.ts(s,i,t.__tf__)}},{key:"pow",value:function(t){return Math.pow(t)}},{key:"rising",value:function(t,e,n){for(var r=this._tsid(n,"rising(".concat(e,")")),i=t[0],a=1;a<e+1;a++)if(i<=t[a])return this.ts(!1,r,t.__tf__);return this.ts(!0,r,t.__tf__)}},{key:"rma",value:function(t,e,n){var r=this._tsid(n,"rma(".concat(e,")")),i=e,a=this.ts(0,r,t.__tf__);return a[0]=this.na(a[1])?this.sma(t,e,r)[0]:(t[0]+(i-1)*this.nz(a[1]))/i,a}},{key:"roc",value:function(t,e,n){var r=this._tsid(n,"roc(".concat(e,")"));return this.ts(100*(t[0]-t[e])/t[e],r,t.__tf__)}},{key:"round",value:function(t){return Math.round(t)}},{key:"rsi",value:function(t,e,n){if(!this.na(e)&&e.__id__){var r=this._tsid(n,"rsi(x,y)");h=100-100/(1+this.div(t,e,r)[0])}else{r=this._tsid(n,"rsi(".concat(e,")"));var i=this.change(t,1,n)[0],a=this.ts(Math.max(i,0),r+"1",t.__tf__),s=this.ts(-Math.min(i,0),r+"2",t.__tf__),o=this.rma(a,e,r+"3")[0],u=this.rma(s,e,r+"4")[0],h=0===u?100:0===o?0:100-100/(1+o/u)}return this.ts(h,r+"5",t.__tf__)}},{key:"sar",value:function(t,e,n,r,i){var a,s=this._tsid(r,"sar(".concat(t,",").concat(e,",").concat(n,")")),o=i||"",u=this.env.shared["high".concat(o)],h=this.env.shared["low".concat(o)],c=this.env.shared["close".concat(o)],f=this.ts(void 0,s+"1",i),l=this.ts(void 0,s+"2",i),_=this.ts(void 0,s+"3",i),d=this.ts(void 0,s+"4",i),v=i?f.__len__-1:_t.iter,p=!1;return v>=1&&(a=f[1],1===v?(c[0]>c[1]?(l[0]=1,_[0]=Math.max(u[0],u[1]),a=Math.min(h[0],h[1])):(l[0]=-1,_[0]=Math.min(h[0],h[1]),a=Math.max(u[0],u[1])),d[0]=t):(l[0]=l[1],d[0]=d[1],_[0]=_[1]),1===l[0]?(u[0]>_[0]&&(_[0]=u[0],d[0]=Math.min(d[0]+e,n)),h[0]<=a&&(l[0]=-1,f[0]=_[0],_[0]=h[0],d[0]=t,p=!0)):(h[0]<_[0]&&(_[0]=h[0],d[0]=Math.min(d[0]+e,n)),u[0]>=a&&(l[0]=1,f[0]=_[0],_[0]=u[0],d[0]=t,p=!0)),p||(f[0]=a+d[0]*(_[0]-a),1===l[0]&&f[0]>=h[0]&&(f[0]=h[0]-0),-1===l[0]&&f[0]<=u[0]&&(f[0]=u[0]+0))),f}},{key:"second",value:function(t){return new Date(t||_t.t).getUTCSeconds()}},{key:"sign",value:function(t){return Math.sign(t)}},{key:"sin",value:function(t){return Math.sin(t)}},{key:"sma",value:function(t,e,n){for(var r=this._tsid(n,"sma(".concat(e,")")),i=0,a=0;a<e;a++)i+=t[a];return this.ts(i/e,r,t.__tf__)}},{key:"sqrt",value:function(t){return Math.sqrt(t)}},{key:"stdev",value:function(t,e,n){for(var r,i,a=this._tsid(n,"stdev(".concat(e,")")),s=this.sma(t,e,a),o=0,u=0;u<e;u++){var h=(r=t[u],i=-s[0],r+i);o+=h*h}return this.ts(Math.sqrt(o/e),a,t.__tf__)}},{key:"stoch",value:function(t,e,n,r,i){var a=this._tsid(i,"sum(".concat(r,")")),s=100*(t[0]-this.lowest(n,r)[0]),o=this.highest(e,r)[0]-this.lowest(n,r)[0];return this.ts(s/o,a,t.__tf__)}},{key:"sum",value:function(t,e,n){for(var r=this._tsid(n,"sum(".concat(e,")")),i=0,a=0;a<e;a++)i+=t[a];return this.ts(i,r,t.__tf__)}},{key:"supertrend",value:function(t,e,n,r){var i=this._tsid(n,"supertrend(".concat(t,",").concat(e,")")),a=r||"",s=this.env.shared["high".concat(a)],o=this.env.shared["low".concat(a)],u=this.env.shared["close".concat(a)],h=.5*(s[0]+o[0]),c=t*this.atr(e,i+"1",r)[0],f=this.ts(h-c,i+"2",r),l=this.nz(f[1],f[0]);f[0]=u[1]>l?Math.max(f[0],l):f[0];var _=this.ts(h+c,i+"3",r),d=this.nz(_[1],_);_[0]=u[1]<d?Math.min(_[0],d):_[0];var v=this.ts(1,i+"4",r);return v[0]=this.nz(v[1],v[0]),v[0]=-1===v[0]&&u[0]>d?1:1===v[0]&&u[0]<l?-1:v[0],[this.ts(1===v[0]?f[0]:_[0],i+"5",r),this.neg(v,i+"6")]}},{key:"swma",value:function(t,e){var n=this._tsid(e,"swma"),r=t[3]*this.SWMA[0]+t[2]*this.SWMA[1]+t[1]*this.SWMA[2]+t[0]*this.SWMA[3];return this.ts(r,n,t.__tf__)}},{key:"sym",value:function(t,e,n){void 0===e&&(e={});var r=e.id||this._tsid(n,"sym");if(e.id=r,this.env.syms[r])return this.env.syms[r].update(t),this.env.syms[r];switch(p()(t)){case"object":var i=new Y(t,e);this.env.syms[r]=i,t.__id__?i.data_type=1:i.data_type=0;break;case"number":i=new Y(null,e),i.data_type=2;break;case"string":e.tf=t,i=new Y(_t.data.ohlcv.data,e),i.data_type=0}return this.env.syms[r]=i,i}},{key:"tan",value:function(t){return Math.tan(t)}},{key:"time",value:function(t,e){}},{key:"timestamp",value:function(){}},{key:"tr",value:function(t,e,n){void 0===t&&(t=!1);var r=this._tsid(e,"tr(".concat(t,")")),i=n||"",a=this.env.shared["high".concat(i)],s=this.env.shared["low".concat(i)],o=this.env.shared["close".concat(i)],u=0;return u=this.na(o[1])&&t?a[0]-s[0]:Math.max(a[0]-s[0],Math.abs(a[0]-o[1]),Math.abs(s[0]-o[1])),this.ts(u,r,n)}},{key:"tsi",value:function(t,e,n,r){var i=this._tsid(r,"tsi(".concat(e,",").concat(n,")")),a=this.change(t,1,i+"0"),s=this.ts(Math.abs(a[0]),i+"1",t.__tf__),o=this.ema(this.ema(a,n,i+"1"),e,i+"2")[0]/this.ema(this.ema(s,n,i+"3"),e,i+"4")[0];return this.ts(o,i,t.__tf__)}},{key:"variance",value:function(t,e){}},{key:"vwap",value:function(t){}},{key:"vwma",value:function(t,e,n){var r=this._tsid(n,"vwma(".concat(e,")")),i=this.env.shared.vol,a=this.ts(t[0]*i[0],r+"1",t.__tf__),s=this.sma(a,e,r+"2")[0]/this.sma(i,e,r+"3")[0];return this.ts(s,r+"4",t.__tf__)}},{key:"weekofyear",value:function(t){var e=new Date(t||_t.t);e.setUTCHours(0,0,0,0),e.setDate(e.getUTCDate()+3-(e.getUTCDay()+6)%7);var n=new Date(e.getUTCFullYear(),0,4);return 1+Math.round(((e-n)/864e5-3+(n.getUTCDay()+6)%7)/7)}},{key:"wma",value:function(t,e,n){for(var r=this._tsid(n,"wma(".concat(e,")")),i=0,a=0,s=0;s<e;s++){var o=(e-s)*e;i+=o,a+=t[s]*o}return this.ts(a/i,r,t.__tf__)}},{key:"wpr",value:function(t,e,n){var r=this._tsid(e,"wpr(".concat(t,")")),i=n||"",a=this.env.shared["high".concat(i)],s=this.env.shared["low".concat(i)],o=this.env.shared["close".concat(i)],u=this.highest(a,t,r),h=this.lowest(s,t,r),c=(u[0]-o[0])/(u[0]-h[0]);return this.ts(100*-c,r,n)}},{key:"year",value:function(t){return new Date(t||_t.t).getUTCFullYear()}}]),t}();function J(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return K(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return K(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function K(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var Q,tt=/(function |)([$A-Z_][0-9A-Z_$\.]*)[\s]*?\((.*?\s*)\)/im,et=/(function |)([\$A-Z_][\$\.0-9A-Z_]*)[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*?\(([\s\S]*[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)\)/gim,nt=function(){function t(e,n){l()(this,t),this.std=_t.std_inject(new X(this)),this.id=e.uuid,this.src=e,this.output=z("output",[]),this.data=[],this.tss={},this.syms={},this.shared=n,this.output.box_maker=this.make_box(e.src),this.onchart={},this.offchart={}}return d()(t,[{key:"build",value:function(){this.output.box_maker(this,this.shared,_t),delete this.output.box_maker}},{key:"init",value:function(){this.output.init()}},{key:"step",value:function(t){void 0===t&&(t=!0),t&&this.unshift();var e=this.output.update();this.copy(e,t),this.limit()}},{key:"unshift",value:function(){for(var t in this.output.unshift(void 0),this.tss)this.tss[t].__tf__||this.tss[t].unshift(void 0)}},{key:"limit",value:function(){var t=this.output;for(var e in t.length=t.__len__||5,this.tss){var n=this.tss[e];n.length=n.__len__||5}}},{key:"copy",value:function(t,e){void 0===e&&(e=!0);var n=this.output.__offset__;null!=t&&(this.output[0]=t.__id__?t[0]:t,n=n||t.__offset__);var r=this.output[0],a=_t.t;if(n&&(a+=n*_t.tf),null!=r&&r.length)s=[a].concat(i()(r));else var s=[a,r];e?this.data.push(s):this.data[this.data.length-1]=s}},{key:"make_box",value:function(t){var e,n=Object.getPrototypeOf(this.std),r="",i=J(Object.getOwnPropertyNames(n));try{for(i.s();!(e=i.n()).done;){"constructor"!==(s=e.value)&&(r+="const std_".concat(s," = self.std.").concat(s,".bind(self.std)\n"))}}catch(t){i.e(t)}finally{i.f()}var a="";for(var s in t.props||{}){if(void 0!==t.props[s].val)var o=t.props[s].val;else o=void 0!==this.src.sett[s]?this.src.sett[s]:t.props[s].def;a+="var ".concat(s," = ").concat(JSON.stringify(o),"\n")}var u="";for(var s in this.shared)this.shared[s]&&this.shared[s].__id__&&(u+="const ".concat(s," = shared.").concat(s,"\n"));var h="";for(var s in t.data||{}){var c=_t.match_ds(this.id,t.data[s].type);if(this.shared.dss[c])h+="const ".concat(s," = shared.dss['").concat(c,"'].data\n");else{var f=t.data[s].type;console.warn("Dataset '".concat(f,"' is undefined"))}}try{return Function("self,shared,se","\n                'use strict';\n\n                // Built-in functions (aliases)\n                ".concat(r,"\n\n                // Modules (API / interfaces)\n                ").concat(this.make_modules(),"\n\n                // Timeseries\n                ").concat(u,"\n\n                // Direct data ts\n                const data = self.data\n                const ohlcv = shared.dss.ohlcv.data\n                ").concat(h,"\n\n                // Script's properties (init)\n                ").concat(a,"\n\n                // Globals\n                const settings = self.src.sett\n                const tf = shared.tf\n                const range = shared.range\n\n                this.init = (_id = 'root') => {\n                    ").concat(this.prep(t.init_src),"\n                }\n\n                this.update = (_id = 'root') => {\n                    const t = shared.t()\n                    const iter = shared.iter()\n                    ").concat(this.prep(t.upd_src),"\n                }\n\n                this.post = (_id = 'root') => {\n                    ").concat(this.prep(t.post_src),"\n                }\n            "))}catch(t){return Function("self,shared","\n                'use strict';\n                this.init = () => {}\n                this.update = () => {}\n                this.post = () => {}\n            ")}}},{key:"make_modules",value:function(){var t="";for(var e in _t.mods)_t.mods[e].api&&(t+="const ".concat(e," = se.mods['").concat(e,"'].api[self.id]"),t+="\n");return t}},{key:"prep",value:function(t){t="\t\t  let _pref = `${_id}<-"+this.src.use_for[0]+"<-`\n"+t,et.lastIndex=0;var e=0;do{var n=et.exec(t);if(n){var r=n[1].trim(),i=n[2];n[3];if("function"===r);else{var a=n.index+n[0].indexOf("(");this.std[i]&&(t=this.postfix(t,n,++e),a+=4),et.lastIndex=a}}}while(n);return I(t,"std_")}},{key:"postfix",value:function(t,e,n){for(var r=this.get_args(this.fdef(e[2])).length,i=this.parentheses(e[0]),a=this.get_args_2(i),s=a.length;s<r;s++)a.push("void 0");return a.push('_pref+"f'.concat(n,'"')),t.replace(i,"std_".concat(e[2],"(").concat(a.join(", "),")"))}},{key:"parentheses",value:function(t){for(var e=0,n=!1,r=0;r<t.length;r++)if("("===t[r]?(e++,n=!0):")"===t[r]&&e--,n&&0===e)return t.substr(0,r+1);return t}},{key:"fdef",value:function(t){return this.std[t].toString()}},{key:"get_args",value:function(t){var e=this.regex_clone(tt);e.lastIndex=0;var n=e.exec(t);return n[3].trim().length?n[3].split(",").map((function(t){return t.trim()})).filter((function(t){return"_id"!==t&&"_tf"!==t})):[]}},{key:"get_args_2",value:function(t){for(var e,n=[],r=0,a=0,s=!1,o=!1,u=!1,h=0;h<t.length;h++)"("===t[h]&&(r++,e||(e=[h+1])),")"===t[h]&&r--,"["===t[h]&&a++,"]"===t[h]&&a--,"'"===t[h]&&(s=!s),'"'===t[h]&&(o=!o),"`"===t[h]&&(u=!u),","!==t[h]||1!==r||a||s||o||u||e&&(e[1]=h,n.push(e),e=[h+1]),0===r&&e&&(e[1]=h,n.push(e),e=null);return n.map((function(e){return t.slice.apply(t,i()(e))})).filter((function(t){return/[^\s]+/.exec(t)}))}},{key:"regex_clone",value:function(t){return new RegExp(t.source,t.flags)}},{key:"send_modify",value:function(t){_t.send("modify-overlay",{uuid:this.id,fields:t})}}]),t}(),rt=(n(6),function(){return(new Date).getTime()}),it=function(t){return new Promise((function(e,n){return setTimeout(e,t)}))};"onorientationchange"in(Q="undefined"!=typeof window?window:{})&&(!!navigator.maxTouchPoints||!!navigator.msMaxTouchPoints||"ontouchstart"in Q||Q.DocumentTouch&&(document,Q.DocumentTouch));function at(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return st(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return st(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function st(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var ot=/(open|high|low|close|vol)(\d+)(\w*)/gm,ut=/(a?tr|kcw?|dmi|sar|supertrend|wpr)(\d+?\w*)\s*\(/gm,ht=/(?:hl2|hlc3|ohlc4)/gm,ct={parse:function(t){var e=this,n=t.src,r="".concat(n.init_src,"\n").concat(n.upd_src,"\n").concat(n.post_src);ot.lastIndex=0,ut.lastIndex=0,ht.lastIndex=0;do{if(a=ot.exec(r)){if(a[0]in _t.tss)continue;var i=_t.tss[a[0]]=z(a[0],[]);i.__tf__=L(a[2],a[3]),i.__fn__=H(a[1]).bind(i)}}while(a);do{if(a=ht.exec(r)){if(a[0]in _t.tss)continue;this.parse_ts_sym(a[0])}}while(a);do{var a;if(a=ut.exec(r))if("continue"===function(){var t=a[1]+a[2],n=a[2];if(t in _t.std_plus)return"continue";switch(a[1]){case"tr":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e){return void 0===t&&(t=!1),this.tr(t,e,n)};break;case"atr":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e){return this.atr(t,e,n)};break;case"kc":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e,r,i,a){return void 0===i&&(i=!0),this.kc(t,e,r,i,a,n)};break;case"kcw":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e,r,i,a){return void 0===i&&(i=!0),this.kcw(t,e,r,i,a,n)};break;case"dmi":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e,r){return this.dmi(t,e,r,n)};break;case"sar":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e,r,i){return this.sar(t,e,r,i,n)};break;case"supertrend":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e,r){return this.supertrend(t,e,r,n)};break;case"wpr":e.deps(["high","low","close"],a[2]),_t.std_plus[t]=function(t,e){return this.wpr(t,e,n)}}}())continue}while(a)},parse_ts_sym:function(t,e){switch(t){case"hl2":_t.tss.hl2=z("hl2",[]),_t.tss.hl2.__fn__=function(){return.5*(_t.high[0]+_t.low[0])};break;case"hlc3":_t.tss.hlc3=z("hlc3",[]),_t.tss.hlc3.__fn__=function(){return(_t.high[0]+_t.low[0]+_t.close[0])/3};break;case"ohlc4":_t.tss.ohlc4=z("ohlc4",[]),_t.tss.ohlc4.__fn__=function(){return.25*(_t.open[0]+_t.high[0]+_t.low[0]+_t.close[0])}}},deps:function(t,e){var n,r=at(t);try{for(r.s();!(n=r.n()).done;){var i=n.value,a=i+e;if(!(a in _t.tss)){var s=_t.tss[a]=z(a,[]);s.__tf__=D(e),s.__fn__=H(i).bind(s)}}}catch(t){r.e(t)}finally{r.f()}}};function ft(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return lt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lt(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function lt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var _t=new(function(){function t(){l()(this,t),this.map={},this.data={},this.exec_id=null,this.queue=[],this.delta_queue=[],this.update_queue=[],this.sett={},this.state={},this.mods={},this.std_plus={},this.tf=void 0}var e,n;return d()(t,[{key:"exec_all",value:function(){var t=this;clearTimeout(this.exec_id),this.data.ohlcv&&(this.exec_id=setTimeout(c()(u.a.mark((function e(){return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.init_state(Object.keys(t.map))){e.next=2;break}return e.abrupt("return");case 2:for(t.re_init_map();t.queue.length;)t.exec(t.queue.shift());if(!Object.keys(t.map).length){e.next=8;break}return e.next=7,t.run();case 7:t.drain_queues();case 8:t.send_state();case 9:case"end":return e.stop()}}),e)}))),10))}},{key:"exec_sel",value:(n=c()(u.a.mark((function t(e){var n,r,i,a,s=this;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.data.ohlcv){t.next=2;break}return t.abrupt("return");case 2:if(n=Object.keys(e).filter((function(t){return t in s.map})),this.init_state(n)){t.next=6;break}return this.delta_queue.push(e),t.abrupt("return");case 6:t.t0=u.a.keys(e);case 7:if((t.t1=t.t0()).done){t.next=16;break}if(r=t.t1.value,this.map[r]){t.next=11;break}return t.abrupt("continue",7);case 11:for(a in i=this.map[r].src.props||{})a in e[r]&&(i[a].val=e[r][a]);this.exec(this.map[r]),t.next=7;break;case 16:return t.next=18,this.run(n);case 18:this.drain_queues(),this.send_state();case 20:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"exec",value:function(t){var e=this;for(var n in t.src.conf||(t.src.conf={}),t.src.init&&(t.src.init_src=T(t.src.init)),t.src.update&&(t.src.upd_src=T(t.src.update)),t.src.post&&(t.src.post_src=T(t.src.post)),ct.parse(t),this.mods)this.mods[n].pre_env&&this.mods[n].pre_env(t.uuid,t);for(var n in t.env=new nt(t,Object.assign(this.shared,{open:this.open,high:this.high,low:this.low,close:this.close,vol:this.vol,dss:this.data,t:function(){return e.t},iter:function(){return e.iter},tf:this.tf,range:this.range,onclose:!0},this.tss)),this.map[t.uuid]=t,this.mods)this.mods[n].new_env&&this.mods[n].new_env(t.uuid,t);t.env.build()}},{key:"update",value:function(t){var e=this;if(this.data.ohlcv&&this.data.ohlcv.data.length)if(this.running)this.update_queue.push(t);else{var n=this.make_mods_hooks("pre_step"),r=this.make_mods_hooks("post_step"),i=function(t,i){for(var a=0;a<n.length;a++)n[a](t);var s,o=ft(t);try{for(o.s();!(s=o.n()).done;){var u=s.value;e.map[u].env.step(i)}}catch(t){o.e(t)}finally{o.f()}for(a=0;a<r.length;a++)r[a](t)};try{var a=this.data.ohlcv.data,s=a.length-1,o=a[s],u=Object.keys(this.map),h=!1;this.shared.event="update";var c,f=ft(t);try{for(f.s();!(c=f.n()).done;){var l=c.value;if(l[0]>o[0])this.shared.onclose=!0,i(u,!1),a.push(l),h=!0,s++;else{if(l[0]<o[0])continue;a[s]=l}}}catch(t){f.e(t)}finally{f.f()}this.iter=s,this.t=a[s][0],this.step(a[s],h),this.shared.onclose=!1,i(u,h),this.limit(),this.send_update(),this.send_state()}catch(t){console.log(t)}}}},{key:"init_state",value:function(t){var e=t.join(",");return this.running?(this._restart=e===this.task,!1):(this.open=z("open",[]),this.high=z("high",[]),this.low=z("low",[]),this.close=z("close",[]),this.vol=z("vol",[]),this.tss={},this.std_plus={},this.shared={},this.iter=0,this.t=0,this.skip=!1,this.running=!0,this.task=e,!0)}},{key:"std_inject",value:function(t){var e=Object.getPrototypeOf(t);return Object.assign(e,this.std_plus),t}},{key:"send_state",value:function(){this.send("engine-state",{scripts:Object.keys(this.map).length,last_perf:this.perf,iter:this.iter,last_t:this.t,data_size:this.data_size,running:!1})}},{key:"send_update",value:function(){this.send("overlay-update",this.format_update())}},{key:"re_init_map",value:function(){for(var t in this.map)this.exec(this.map[t])}},{key:"run",value:(e=c()(u.a.mark((function t(e){var n,r,i,a,s,o,h,c,f,l,_,d,v,p;return u.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.send("engine-state",{running:!0}),n=rt(),e=e||Object.keys(this.map),this.pre_run_mods(e),r=this.make_mods_hooks("pre_step"),i=this.make_mods_hooks("post_step"),t.prev=6,a=ft(e);try{for(a.s();!(s=a.n()).done;)o=s.value,this.map[o].env.init()}catch(t){a.e(t)}finally{a.f()}h=this.data.ohlcv.data,c=this.start(h),this.shared.event="step",f=c;case 13:if(!(f<h.length)){t.next=32;break}if(f%5e3!=0){t.next=17;break}return t.next=17,it(0);case 17:if(!this.restarted()){t.next=19;break}return t.abrupt("return");case 19:for(this.iter=f-c,this.t=h[f][0],this.step(h[f]),this.shared.onclose=f!==h.length-1,l=0;l<r.length;l++)r[l](e);_=ft(e);try{for(_.s();!(d=_.n()).done;)o=d.value,this.map[o].env.step()}catch(t){_.e(t)}finally{_.f()}for(l=0;l<i.length;l++)i[l](e);this.custom_main&&this.make_ohlcv(),this.limit();case 29:f++,t.next=13;break;case 32:v=ft(e);try{for(v.s();!(p=v.n()).done;)o=p.value,this.map[o].env.output.post()}catch(t){v.e(t)}finally{v.f()}t.next=39;break;case 36:t.prev=36,t.t0=t.catch(6),console.log(t.t0);case 39:this.post_run_mods(e),this.perf=rt()-n,this.running=!1,this.send("overlay-data",this.format_map(e));case 43:case"end":return t.stop()}}),t,this,[[6,36]])}))),function(t){return e.apply(this,arguments)})},{key:"step",value:function(t,e){if(void 0===e&&(e=!0),e)for(var n in this.open.unshift(t[1]),this.high.unshift(t[2]),this.low.unshift(t[3]),this.close.unshift(t[4]),this.vol.unshift(t[5]),this.tss)this.tss[n].__tf__?this.tss[n].__fn__():this.tss[n].unshift(this.tss[n].__fn__());else for(var n in this.open[0]=t[1],this.high[0]=t[2],this.low[0]=t[3],this.close[0]=t[4],this.vol[0]=t[5],this.tss)this.tss[n]=this.tss[n].__fn__()}},{key:"limit",value:function(){this.open.length=this.open.__len__||5,this.high.length=this.high.__len__||5,this.low.length=this.low.__len__||5,this.close.length=this.close.__len__||5,this.vol.length=this.vol.__len__||5}},{key:"start",value:function(t){var e=this.sett.script_depth;return e?Math.max(t.length-e,0):0}},{key:"drain_queues",value:function(){if(this.queue.length)this.exec_all();else if(this.delta_queue.length)this.exec_sel(this.delta_queue.pop()),this.delta_queue=[];else for(;this.update_queue.length;){var t=this.update_queue.shift();this.update(t)}}},{key:"format_map",value:function(t,e,n){var r,i=[],a=ft(t=t||Object.keys(this.map));try{for(a.s();!(r=a.n()).done;){var o=r.value,u=this.map[o],h=function(t){return t};if(!1!==u.output&&"none"!==u.output||n){if("range"===u.output||e){var c=e||this.range,f=s()(c,2),l=f[0],_=f[1];h=function(t){return t.filter((function(t){return t[0]>=l&&t[0]<=_}))}}i.push({id:o,data:h(u.env.data),new_ovs:{onchart:F(u.env.onchart,h),offchart:F(u.env.offchart,h)}})}else i.push({id:o,data:null})}}catch(t){a.e(t)}finally{a.f()}return this.custom_main&&i.push({id:"chart",data:this.data.ohlcv.data}),i}},{key:"format_update",value:function(){var t=[];for(var e in this.map){var n=this.map[e];if(!1!==n.output){t.push({id:e,data:n.env.data[n.env.data.length-1]});for(var r=0,i=["onchart","offchart"];r<i.length;r++){var a=i[r];for(var e in n.env[a]){var s=n.env[a][e];t.push({id:"".concat(a,".").concat(e),data:s.data[s.data.length-1]})}}}else t.push({id:e,data:null})}return t}},{key:"restarted",value:function(){return!!this._restart&&(this._restart=!1,this.running=!1,this.perf=0,!0)}},{key:"remove_scripts",value:function(t){var e,n=ft(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;delete this.map[r]}}catch(t){n.e(t)}finally{n.f()}this.send_state()}},{key:"pre_run_mods",value:function(t){for(var e in this.mods)this.mods[e].pre_run&&this.mods[e].pre_run(t)}},{key:"post_run_mods",value:function(t){for(var e in this.mods)this.mods[e].post_run&&this.mods[e].post_run(t)}},{key:"make_mods_hooks",value:function(t){var e=[];for(var n in this.mods)this.mods[n][t]&&e.push(this.mods[n][t].bind(this.mods[n]));return e}},{key:"data_required",value:function(t){var e=this,n=Object.values(this.map);t&&n.push(t);for(var r=[{type:"OHLCV"}],a=0,s=n;a<s.length;a++){if((t=s[a]).src.data){var o=Object.values(t.src.data);r.push.apply(r,i()(o.map((function(e){return{id:t.uuid,type:e.type}}))))}}var u=r.filter((function(t){return!Object.values(e.data).find((function(e){return e.type===t.type}))}));return u.length?u:null}},{key:"match_ds",value:function(t,e){for(var t in this.data)if(this.data[t].type===e)return t}},{key:"make_ohlcv",value:function(){var t=this.custom_main,e=this.t+this.tf;t.update(null,e)&&this.data.ohlcv.data.push([e,t.open[0],t.high[0],t.low[0],t.close[0],t.vol[0]])}},{key:"recalc_size",value:function(){for(;;){var t=P(this.data)/1048576,e=this.sett.ww_ram_limit;if(!(e&&t>e))break;this.limit_size()}this.data_size=+t.toFixed(2),this.send_state()}},{key:"limit_size",value:function(){var t=Object.values(this.data).map((function(t){return{id:t.id,t:t.last_upd}}));t.sort((function(t,e){return t.t-e.t})),t.length&&delete this.data[t[0].id]}}]),t}());n(7);function dt(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return vt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vt(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var pt=function(){function t(e,n){l()(this,t),this.last_upd=B(),this.id=e,Array.isArray(n)?(this.data=n,"ohlcv"===e&&(this.type="OHLCV")):(this.data=n.data,this.type=n.type)}return d()(t,[{key:"merge",value:function(t){var e=this.data.length;if(e){var n=this.data[0][0],r=this.data[e-1][0],i=t.filter((function(t){return t[0]<n})),a=t.filter((function(t){return t[0]>r}));this.data=i.concat(this.data,a)}else this.data=t}},{key:"op",value:function(t,e){switch(this.last_upd=B(),e.type){case"set":this.data=e.data,t.recalc_size();break;case"del":delete t.data[this.id],t.recalc_size();break;case"mrg":this.merge(e.data),t.recalc_size()}}}],[{key:"update_all",value:function(t,e){for(var n in e)if("ohlcv"!==n){var r=n.split(".")[1]||n;if(t.data[r]){var i,a=t.data[r].data,s=a[a.length-1],o=dt(e[n]);try{for(o.s();!(i=o.n()).done;){var u=i.value;(!s||u[0]>s[0])&&a.push(u)}}catch(t){o.e(t)}finally{o.f()}t.data[r].last_upd=B()}}}}]),t}(),yt=!1;self.onmessage=async t=>{switch(t.data.type){case"update-dc-settings":_t.sett=t.data.data;break;case"exec-script":(e=_t.data_required(t.data.data.s))&&!yt&&(yt=!0,self.postMessage({type:"request-data",data:e})),_t.tf=D(t.data.data.tf),_t.range=t.data.data.range,_t.queue.push(t.data.data.s),_t.exec_all();break;case"exec-all-scripts":var e;(e=_t.data_required(t.data.data.s))&&!yt&&(yt=!0,self.postMessage({type:"request-data",data:e})),_t.tf=D(t.data.data.tf),_t.range=t.data.data.range,_t.exec_all();break;case"upload-data":for(var n in self.postMessage({type:"data-uploaded"}),await it(1),t.data.data){let e=t.data.data[n];_t.data[n]=new pt(n,e)}_t.recalc_size(),yt=!1,_t.exec_all();break;case"upload-module":let r=function(t){var e={};for(var n in t)if("main"!==n&&"id"!==n){var r=E(t[n]);e[n]=new Function(r,N(t[n]))}return e}(t.data.data);_t.mods[t.data.data.id]=new new Function("mod","se","lib",N(t.data.data.main))(t.data.data.id,_t,r);break;case"module-event":break;case"update-data":pt.update_all(_t,t.data.data),t.data.data.ohlcv&&_t.update(t.data.data.ohlcv);break;case"get-dataset":self.postMessage({id:t.data.id,data:_t.data[t.data.data]});break;case"dataset-op":await it(1),t.data.data.id in _t.data&&_t.data[t.data.data.id].op(_t,t.data.data),t.data.data.exec&&_t.exec_all();break;case"update-ov-settings":_t.tf=D(t.data.data.tf),_t.range=t.data.data.range,_t.exec_sel(t.data.data.delta);break;case"send-meta-info":_t.tf=D(t.data.data.tf),_t.range=t.data.data.range;break;case"remove-scripts":_t.remove_scripts(t.data.data)}},_t.send=(t,e)=>{switch(t){case"overlay-data":case"overlay-update":case"engine-state":case"modify-overlay":case"module-data":case"script-signal":self.postMessage({type:t,data:e})}}}]);