ohlcv-indicators 3.5.1 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{function r(t){return r="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},r(t)}function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw a}}}}function o(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}t.r(e),t.d(e,{default:()=>mr});var a=function(t,e){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var r,o=n(t);try{for(o.s();!(r=o.n()).done;){var i,a=n(r.value.params);try{for(a.s();!(i=a.n()).done;){var u=i.value;if("number"==typeof u&&u>e)throw console.log(u,e),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}},u=function(t){if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" , "getDataAsCols" or "getData" methods are called.')},l=function(t,e,r){if(!Array.isArray(t))throw new Error('Param "'.concat(e,'" must be an array in "').concat(r,'".'));return!0},c=function(t,e,n){if(!Boolean(t)||"object"==!r(t))throw new Error('Param "'.concat(e,'" must be an object in "').concat(n,'".'));return!0},s=function(t,e,r,n){if(l(t,"arrayOptions","".concat(n,".").concat(r,".validateArrayOptions")),!t.includes(e.toString()))throw new Error('Param "'.concat(r,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},f=function(t,e,r){if("boolean"!=typeof t)throw new Error('Param "'.concat(e,'" must be an boolean in "').concat(r,'".'));return!0},p=function(t,e,r,n){c(e,"options","".concat(n,".").concat(r,".validateNumber"));var o=e.allowDecimals,i=void 0!==o&&o,a=e.min,u=e.max,l=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(r,'" must be an integer in "').concat(n,'".'));if("number"!=typeof a||"number"!=typeof u||a>=u)throw new Error('Param "min" must be a valid '.concat(l,' lower than "max" "').concat(n,".").concat(r,'.validateNumber".'));if(t<a)throw new Error('Param "'.concat(r,'" must be an ').concat(l," greater than or equal to ").concat(a,' in "').concat(n,'".'));if(t>u)throw new Error('Param "'.concat(r,'" must be an ').concat(l," lower than or equal to ").concat(u,' in "').concat(n,'".'));return!0},y=1e6,h="[big.js] ",v=h+"Invalid ",m=v+"decimal places",d=v+"rounding mode",b=h+"Division by zero",g={},w=void 0,O=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function S(t,e,r,n){var o=t.c;if(r===w&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(d);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==w))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==w||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function j(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function P(t){return P="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},P(t)}function _(t){var e="function"==typeof Map?new Map:void 0;return _=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(N())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&T(o,r.prototype),o}(t,arguments,A(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),T(r,t)},_(t)}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(N=function(){return!!t})()}function T(t,e){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},T(t,e)}function A(t){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},A(t)}g.abs=function(){var t=new this.constructor(this);return t.s=1,t},g.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,u=r.e,l=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,u!=l)return u>l^e?1:-1;for(a=(u=n.length)<(l=o.length)?u:l,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return u==l?0:u>l^e?1:-1},g.div=function(t){var e=this,r=e.constructor,n=e.c,o=(t=new r(t)).c,i=e.s==t.s?1:-1,a=r.DP;if(a!==~~a||a<0||a>y)throw Error(m);if(!o[0])throw Error(b);if(!n[0])return t.s=i,t.c=[t.e=0],t;var u,l,c,s,f,p=o.slice(),h=u=o.length,v=n.length,d=n.slice(0,u),g=d.length,O=t,j=O.c=[],P=0,_=a+(O.e=e.e-t.e)+1;for(O.s=i,i=_<0?0:_,p.unshift(0);g++<u;)d.push(0);do{for(c=0;c<10;c++){if(u!=(g=d.length))s=u>g?1:-1;else for(f=-1,s=0;++f<u;)if(o[f]!=d[f]){s=o[f]>d[f]?1:-1;break}if(!(s<0))break;for(l=g==u?o:p;g;){if(d[--g]<l[g]){for(f=g;f&&!d[--f];)d[f]=9;--d[f],d[g]+=10}d[g]-=l[g]}for(;!d[0];)d.shift()}j[P++]=s?c:++c,d[0]&&s?d[g]=n[h]||0:d=[n[h]]}while((h++<v||d[0]!==w)&&i--);return j[0]||1==P||(j.shift(),O.e--,_--),P>_&&S(O,_,r.RM,d[0]!==w),O},g.eq=function(t){return 0===this.cmp(t)},g.gt=function(t){return this.cmp(t)>0},g.gte=function(t){return this.cmp(t)>-1},g.lt=function(t){return this.cmp(t)<0},g.lte=function(t){return this.cmp(t)<1},g.minus=g.sub=function(t){var e,r,n,o,i=this,a=i.constructor,u=i.s,l=(t=new a(t)).s;if(u!=l)return t.s=-l,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,p=t.e;if(!c[0]||!f[0])return f[0]?t.s=-l:c[0]?t=new a(i):t.s=1,t;if(u=s-p){for((o=u<0)?(u=-u,n=c):(p=s,n=f),n.reverse(),l=u;l--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,u=l=0;l<r;l++)if(c[l]!=f[l]){o=c[l]<f[l];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(l=(r=f.length)-(e=c.length))>0)for(;l--;)c[e++]=0;for(l=e;r>u;){if(c[--r]<f[r]){for(e=r;e&&!c[--e];)c[e]=9;--c[e],c[r]+=10}c[r]-=f[r]}for(;0===c[--l];)c.pop();for(;0===c[0];)c.shift(),--p;return c[0]||(t.s=1,c=[p=0]),t.c=c,t.e=p,t},g.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(b);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},g.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},g.plus=g.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,u=o.c,l=t.e,c=t.c;if(!u[0]||!c[0])return c[0]||(u[0]?t=new i(o):t.s=o.s),t;if(u=u.slice(),e=a-l){for(e>0?(l=a,n=c):(e=-e,n=u),n.reverse();e--;)n.push(0);n.reverse()}for(u.length-c.length<0&&(n=c,c=u,u=n),e=c.length,r=0;e;u[e]%=10)r=(u[--e]=u[e]+c[e]+r)/10|0;for(r&&(u.unshift(r),++l),e=u.length;0===u[--e];)u.pop();return t.c=u,t.e=l,t},g.pow=function(t){var e=this,r=new e.constructor("1"),n=r,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(v+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},g.prec=function(t,e){if(t!==~~t||t<1||t>y)throw Error(v+"precision");return S(new this.constructor(this),t,e)},g.round=function(t,e){if(t===w)t=0;else if(t!==~~t||t<-y||t>y)throw Error(m);return S(new this.constructor(this),t+this.e+1,e)},g.sqrt=function(){var t,e,r,n=this,o=n.constructor,i=n.s,a=n.e,u=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(h+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((e=n.c.join("")).length+a&1||(e+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new o(((i=Math.sqrt(e))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):t=new o(i+""),a=t.e+(o.DP+=4);do{r=t,t=u.times(r.plus(n.div(r)))}while(r.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return S(t,(o.DP-=4)+t.e+1,o.RM)},g.times=g.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,a=o.length,u=i.length,l=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=l+c,a<u&&(e=o,o=i,i=e,c=a,a=u,u=c),e=new Array(c=a+u);c--;)e[c]=0;for(l=u;l--;){for(u=0,c=a+l;c>l;)u=e[c]+i[l]*o[c-l-1]+u,e[c--]=u%10,u=u/10|0;e[c]=u}for(u?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t},g.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==w){if(t!==~~t||t<0||t>y)throw Error(m);for(r=S(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return j(r,!0,!!n)},g.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==w){if(t!==~~t||t<0||t>y)throw Error(m);for(t=t+(r=S(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length<t;)r.c.push(0)}return j(r,!1,!!n)},g[Symbol.for("nodejs.util.inspect.custom")]=g.toJSON=g.toString=function(){var t=this,e=t.constructor;return j(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},g.toNumber=function(){var t=Number(j(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(h+"Imprecise conversion");return t},g.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==w){if(t!==~~t||t<1||t>y)throw Error(v+"precision");for(r=S(new n(r),t,e);r.c.length<t;)r.c.push(0)}return j(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!o)},g.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(h+"valueOf disallowed");return j(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===w?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(v+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!O.test(e))throw Error(v+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=g,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var E=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=A(e),function(t,e){if(e&&("object"==P(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)}(t,N()?Reflect.construct(e,r||[],A(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(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&&T(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(_(Error));function k(t){return k="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},k(t)}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,M(n.key),n)}}function I(t,e,r){return(e=M(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function M(t){var e=function(t,e){if("object"!=k(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}var D=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),I(this,"previousHighest",void 0),I(this,"highest",void 0),I(this,"previousLowest",void 0),I(this,"lowest",void 0),I(this,"previousResult",void 0),I(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&x(t.prototype,e),r&&x(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function R(t){return R="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},R(t)}function C(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,V(n.key),n)}}function F(t,e,r){return e=B(e),function(t,e){if(e&&("object"==R(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)}(t,L()?Reflect.construct(e,r||[],B(t).constructor):e.apply(t,r))}function L(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(L=function(){return!!t})()}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}function H(t,e){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},H(t,e)}function V(t){var e=function(t,e){if("object"!=R(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=R(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(e)?e:e+""}var U=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=F(this,e),i=void 0,(o=V(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(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&&H(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&C(r.prototype,n),o&&C(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function $(t){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(t)}function q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,J(n.key),n)}}function z(t,e,r){return e=K(e),function(t,e){if(e&&("object"==$(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)}(t,G()?Reflect.construct(e,r||[],K(t).constructor):e.apply(t,r))}function G(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(G=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}function J(t){var e=function(t,e){if("object"!=$(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$(e)?e:e+""}var W=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),u=0;u<i;u++)a[u]=arguments[u];return r=t=z(this,e,[].concat(a)),o=[],(n=J(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(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&&Y(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(U);function Z(t){return Z="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},Z(t)}function Q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ot(n.key),n)}}function X(t,e,r){return e=et(e),function(t,e){if(e&&("object"==Z(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)}(t,tt()?Reflect.construct(e,r||[],et(t).constructor):e.apply(t,r))}function tt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tt=function(){return!!t})()}function et(t){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},et(t)}function rt(t,e){return rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rt(t,e)}function nt(t,e,r){return(e=ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ot(t){var e=function(t,e){if("object"!=Z(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Z(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Z(e)?e:e+""}var it=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),nt(r=X(this,e),"interval",void 0),nt(r,"indicator",void 0),nt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new W(t),r.smoothingFactor=1/r.interval,r}return function(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&&rt(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&Q(r.prototype,n),o&&Q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function at(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function ut(t){return ut="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},ut(t)}function lt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ht(n.key),n)}}function ct(t,e,r){return e=ft(e),function(t,e){if(e&&("object"==ut(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)}(t,st()?Reflect.construct(e,r||[],ft(t).constructor):e.apply(t,r))}function st(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(st=function(){return!!t})()}function ft(t){return ft=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ft(t)}function pt(t,e){return pt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},pt(t,e)}function yt(t,e,r){return(e=ht(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ht(t){var e=function(t,e){if("object"!=ut(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ut(e)?e:e+""}var vt=function(t){function e(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return yt(t=ct(this,e,[].concat(n)),"previousCandle",void 0),yt(t,"twoPreviousCandle",void 0),t}return function(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&&pt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.high,n=t.low,o=r-n;if(this.previousCandle&&e&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(r-this.previousCandle.close),a=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,a),e)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,e)}}],n&<(r.prototype,n),o&<(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function mt(t){return mt="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},mt(t)}function dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function bt(t,e,r){return e=wt(e),function(t,e){if(e&&("object"==mt(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)}(t,gt()?Reflect.construct(e,r||[],wt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function wt(t){return wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wt(t)}function Ot(t,e){return Ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ot(t,e)}function St(t,e,r){return(e=jt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jt(t){var e=function(t,e){if("object"!=mt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}var Pt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),St(r=bt(this,e),"interval",void 0),St(r,"tr",void 0),St(r,"smoothing",void 0),r.interval=t,r.tr=new vt,r.smoothing=new n(t),r}return function(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&&Ot(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tr.update(t,e);if(this.smoothing.update(r,e),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),e)}}],n&&dt(r.prototype,n),o&&dt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function _t(t){return _t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_t(t)}function Nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,At(n.key),n)}}function Tt(t,e,r){return(e=At(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function At(t){var e=function(t,e){if("object"!=_t(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}var Et=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),Tt(this,"interval",void 0),Tt(this,"deviationMultiplier",void 0),Tt(this,"prices",[]),Tt(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=at(this.prices),r=function(t,e){var r=e||at(t),n=at(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&Nt(t.prototype,e),r&&Nt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function kt(t){return kt="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},kt(t)}function xt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ft(n.key),n)}}function It(t,e,r){return e=Dt(e),function(t,e){if(e&&("object"==kt(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)}(t,Mt()?Reflect.construct(e,r||[],Dt(t).constructor):e.apply(t,r))}function Mt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Mt=function(){return!!t})()}function Dt(t){return Dt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Dt(t)}function Rt(t,e){return Rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rt(t,e)}function Ct(t,e,r){return(e=Ft(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ft(t){var e=function(t,e){if("object"!=kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kt(e)?e:e+""}var Lt=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ct(r=It(this,e,[t]),"interval",void 0),Ct(r,"pricesCounter",0),Ct(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(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&&Rt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new E;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&xt(r.prototype,n),o&&xt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(U);function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Ht(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ut(n.key),n)}}function Vt(t,e,r){return(e=Ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ut(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}var $t=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),Vt(this,"short",void 0),Vt(this,"long",void 0),Vt(this,"signal",void 0),Vt(this,"prices",[]),Vt(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new E;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&Ht(t.prototype,e),r&&Ht(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function qt(t){return qt="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},qt(t)}function zt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zt(n.key),n)}}function Gt(t,e,r){return e=Yt(e),function(t,e){if(e&&("object"==qt(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)}(t,Kt()?Reflect.construct(e,r||[],Yt(t).constructor):e.apply(t,r))}function Kt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Kt=function(){return!!t})()}function Yt(t){return Yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Yt(t)}function Jt(t,e){return Jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jt(t,e)}function Wt(t,e,r){return(e=Zt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zt(t){var e=function(t,e){if("object"!=qt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}var Qt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Wt(r=Gt(this,e),"interval",void 0),Wt(r,"previousPrices",[]),Wt(r,"avgGain",void 0),Wt(r,"avgLoss",void 0),Wt(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(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&&Jt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&zt(r.prototype,n),o&&zt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function Xt(t){return Xt="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},Xt(t)}function te(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Xt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ee={ema:Lt,sma:W},re=function(t,e,r,n,o){var i=o.target,a=(o.lag,o.precomputed),u=t.verticalOhlcv,l=t.instances,c=a.keyName;if(0===e&&!u.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(r,"."));var s=u[i][e],f=l[c];f.update(s);var p=NaN;try{p=f.getResult()}catch(t){}return t.pushToMain({index:e,key:c,value:p}),!0},ne=function(t){var e=t.main,r=t.size,n=t.target,o=t.lag,i=t.methodName,a=e.instances,u=e.verticalOhlcv,l=e.priceBased,c=e.arrayTypes,s=e.len,f="close"!==n?"_".concat(n):"",p="".concat(i,"_").concat(r).concat(f);return a[p]=new ee[i](r),u[p]=new Float64Array(s).fill(NaN),l.add(p),o>0&&e.lag([p],o),c[p]="Float64Array",{keyName:p}};function oe(t){return oe="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},oe(t)}function ie(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ae(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ue="close";function le(t){return le="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},le(t)}var ce={number:function(t){return t},numberCleanString:function(t){return Number(t)},numberDirtyString:function(t){return Number(t.replace(/(?!^-)[^0-9.]/g,""))}},se=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"==typeof t&&!Number.isNaN(t))return"number";if("string"==typeof t){var r=t.trim(),n=/^-?\d+(\.\d+)?$/;if(n.test(r))return"numberCleanString";var o=r.replace(/[^0-9.]/g,"");if(o&&n.test(o))return"numberDirtyString"}if(e)throw new TypeError("Invalid input: expected a number or numeric string");return le(t)},fe=function(t,e){var r=Math.pow(10,e);return Math.round((t+Number.EPSILON)*r)/r};function pe(t){return function(t){if(Array.isArray(t))return he(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ye(t)||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 ye(t,e){if(t){if("string"==typeof t)return he(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?he(t,e):void 0}}function he(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ve(t){return ve="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},ve(t)}function me(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function de(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=ve(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ve(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function be(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ge(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ge(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function ge(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function we(t){return we="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},we(t)}function Oe(t){return Oe="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},Oe(t)}var Se={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},je={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},Pe=function(t){var e=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],r=function(){throw new Error('Invalid "'.concat(Oe(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(e.join("\n- ")))};if("object"===Oe(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";r()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";r()}else r()}};function _e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ne(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ne(t,e):void 0}}(t,e)||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 Ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Te=new Set(["open","high","low","close"]),Ae=function(t,e){return"Array"===t?new Array(e).fill(null):"Float64Array"===t?new Float64Array(e).fill(NaN):"Int32Array"===t?new Int32Array(e).fill(NaN):void 0};function Ee(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||xe(t,e)||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 ke(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=xe(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function xe(t,e){if(t){if("string"==typeof t)return Ie(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ie(t,e):void 0}}function Ie(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Me=function(t,e){var r=t.instances,n=t.verticalOhlcv,o=t.len,i=t.arrayTypes,a=t.priceBased;if(0===e){var u,l=[],c=ke(t.inputParams);try{for(c.s();!(u=c.n()).done;){var s=u.value;"lag"===s.key&&l.push(s.params)}}catch(t){c.e(t)}finally{c.f()}for(var f=0,p=l;f<p.length;f++){var y,h=Ee(p[f],2),v=h[0],m=h[1],d=ke(v);try{for(d.s();!(y=d.n()).done;){var b=y.value;if(a.has(b))for(var g=1;g<=m;g++)a.add("".concat(b,"_lag_").concat(g))}}catch(t){d.e(t)}finally{d.f()}}r.lag={lagParams:l}}var w,O=ke(r.lag.lagParams);try{for(O.s();!(w=O.n()).done;){var S,j=Ee(w.value,2),P=j[0],_=j[1],N=ke(P);try{for(N.s();!(S=N.n()).done;){var T=S.value,A=n[T];if(0===e)for(var E=1;E<=_;E++){var k="".concat(T,"_lag_").concat(E);if(!i.hasOwnProperty(T))throw new Error('Lag processing invoked by "'.concat(T,'" expected arrayTypes to have a "').concat(T,'" property, but it wasn’t found.'));n[k]=Ae(i[T],o),i[k]=i[T]}for(var x=1;x<=_;x++){var I="".concat(T,"_lag_").concat(x),M=e-x,D=M<=0||void 0===A[M]?null:A[M];t.pushToMain({index:e,key:I,value:D})}}}catch(t){N.e(t)}finally{N.f()}}}catch(t){O.e(t)}finally{O.f()}return!0};function De(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Re(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Re(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ce(t){return Ce="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},Ce(t)}function Fe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Le(n.key),n)}}function Le(t){var e=function(t,e){if("object"!=Ce(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ce(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ce(e)?e:e+""}var Be=function(t,e){return t>e},He=function(t,e){return t<e},Ve=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1,crossIndexes:{up:[],down:[]}})},(e=[{key:"update",value:function(t,e){var r=e.fast,n=e.high,o=e.slow,i=e.low,a=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(r)||Number.isNaN(o)||function(t,e){return t===e}(r,o)?a=.5:Be(r,o)?a=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&He(i,o)&&Be(this.prevLow,this.prevSlow)?0:1:He(r,o)&&(a=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&Be(n,o)&&He(this.prevHigh,this.prevSlow)?1:0),.5===a?this.interval=0:1===a?this.prevState<=.5?this.interval=1:this.interval++:0===a&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(t),-1===this.interval&&this.crossIndexes.down.push(t),Object.assign(this,{prevState:a,prevFast:r,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&Fe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ue=function(t,e){var r=t.verticalOhlcv,n=t.instances,o=t.len,i=t.arrayTypes,a=t.verticalOhlcvTempCols;if(0===e){var u=t.inputParams;n.crossPairsList=u.reduce((function(t,e){var r=e.key,n=e.params;if("crossPairs"===r){var o,i=De(n);try{for(i.s();!(o=i.n()).done;){var a,u=De(o.value);try{for(u.s();!(a=u.n()).done;){var l=a.value;t.push(l)}}catch(t){u.e(t)}finally{u.f()}}}catch(t){i.e(t)}finally{i.f()}}return t}),[])}var l,c=De(n.crossPairsList);try{for(c.s();!(l=c.n()).done;){var s=l.value,f=s.fast,p=s.slow;if(null!=f&&null!=p){var y="".concat(f,"_x_").concat(p);if(0===e){if("number"==typeof p&&(a.add(p.toString()),r[p.toString()]=new Int32Array(o).fill(p)),"price"!==f&&!r.hasOwnProperty(f))throw Error('fast "'.concat(f,' not found in crossPairs"'));if(!r.hasOwnProperty(p))throw Error('slow "'.concat(p,' not found in crossPairs"'));n[y]=new Ve,r[y]=new Int32Array(o).fill(NaN),i[y]="Int32Array"}var h=void 0,v=void 0,m=void 0,d=void 0,b=void 0;"price"===f?(v=r.close[e],m=r.high[e],d=r.low[e],b=r[p][e],n[y].update(e,{fast:v,slow:b,high:m,low:d})):(h=r[f][e],b=r[p][e],n[y].update(e,{fast:h,slow:b})),t.pushToMain({index:e,key:y,value:n[y].getResult()})}}}catch(t){c.e(t)}finally{c.f()}};function $e(t){return $e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$e(t)}function qe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ze(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=$e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$e(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ge(t){return function(t){if(Array.isArray(t))return Je(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ye(t)||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 Ke(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ye(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Ye(t,e){if(t){if("string"==typeof t)return Je(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Je(t,e):void 0}}function Je(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function We(t){return function(t){if(Array.isArray(t))return tr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Xe(t)||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 Ze(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Xe(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Qe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||Xe(t,e)||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 Xe(t,e){if(t){if("string"==typeof t)return tr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?tr(t,e):void 0}}function tr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var er={dateTime:function(t,e,r){var n=r.lag,o=t.instances,i=t.verticalOhlcv;if(0===e){var a=t.len,u=t.dateType,l=t.arrayTypes;if(!u)throw Error('dateTime method found and invalid "date" in input ohlcv');Object.assign(o,{dateTime:{prevDateStr:i.date[0],sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:i.date[0]}});for(var c=["day_of_the_week","day_of_the_month","week_of_the_month","minute","hour","month","year","session_daily_index","session_intraday_index"],s=0,f=c;s<f.length;s++)l[f[s]]="Int32Array";Object.assign(i,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?qe(Object(r),!0).forEach((function(e){ze(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},Object.fromEntries(c.map((function(t){return[t,new Int32Array(a).fill(NaN)]}))))),n>0&&t.lag(c,n)}var p=i.date[e],y=function(t){var e=t.getMonth(),r=t.getFullYear(),n=t.getHours(),o=t.getMinutes(),i=t.getDay(),a=t.getDate(),u=new Date(t.getFullYear(),t.getMonth(),1).getDay();return{month:e,year:r,hour:n,minute:o,day_of_the_week:i,day_of_the_month:a,week_of_the_month:Math.ceil((a+u)/7)}}(p),h=y.day_of_the_week,v=y.day_of_the_month,m=y.week_of_the_month,d=y.month,b=y.year,g=y.hour,w=y.minute,O=p;O!==o.dateTime.prevDateStr&&(o.dateTime.prevDateStr=O,o.dateTime.sessionDailyIndexCount++,o.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:o.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:o.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:h}),t.pushToMain({index:e,key:"day_of_the_month",value:v}),t.pushToMain({index:e,key:"week_of_the_month",value:m}),t.pushToMain({index:e,key:"month",value:d}),t.pushToMain({index:e,key:"year",value:b}),t.pushToMain({index:e,key:"hour",value:g}),t.pushToMain({index:e,key:"minute",value:w}),o.dateTime.sessionIntradayIndexCount++},rsi:function(t,e,r,n){var o=n.target,i=n.lag,a=t.verticalOhlcv,u=t.instances,l="close"===o?"":"_".concat(o),c="rsi_".concat(r).concat(l),s="rsi_sma_".concat(r).concat(l);if(0===e){var f=t.crossPairsList,p=t.len,y=t.arrayTypes;if(!a.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));f.push({fast:c,slow:s,isDefault:!0}),Object.assign(u,te(te({},c,new Qt(r)),s,new W(r))),Object.assign(a,te(te({},c,new Float64Array(p).fill(NaN)),s,new Float64Array(p).fill(NaN)));var h=[c,s];i>0&&t.lag(h,i);for(var v=0,m=h;v<m.length;v++)y[m[v]]="Float64Array"}var d=a[o][e],b=NaN,g=NaN;u[c].update(d);try{b=u[c].getResult()}catch(t){b=NaN}t.pushToMain({index:e,key:c,value:b}),Number.isNaN(b)||u[s].update(b);try{g=u[s].getResult()}catch(t){g=NaN}t.pushToMain({index:e,key:s,value:g})},atr:function(t,e,r,n){var o=n.lag,i=n.percentage,a=n.upper,u=n.lower,l=t.verticalOhlcv,c=t.instances,s="atr_".concat(r);if(0===e){var f=t.instances,p=t.verticalOhlcv,y=t.arrayTypes,h=t.len,v=t.priceBased;f[s]=new Pt(r,it);var m=[s];i&&m.push("".concat(s,"_percentage")),null!==a&&m.push("".concat(s,"_upper")),null!==u&&m.push("".concat(s,"_lower"));for(var d=0,b=m;d<b.length;d++){var g=b[d];g.endsWith("_percentage")||v.add(g),p[g]=new Float64Array(h).fill(NaN),y[g]="Float64Array"}o>0&&t.lag(m,o)}var w={high:l.high[e],low:l.low[e],close:l.close[e]},O=c[s];O.update(w);var S=NaN;try{S=O.getResult()}catch(t){}if(i){var j=Number.isNaN(S)?NaN:S/w.close;t.pushToMain({index:e,key:"".concat(s,"_percentage"),value:j})}if(null!==a){var P=Number.isNaN(S)?NaN:w.close+S*a;t.pushToMain({index:e,key:"".concat(s,"_upper"),value:P})}if(null!==u){var _=Number.isNaN(S)?NaN:w.close-S*u;t.pushToMain({index:e,key:"".concat(s,"_lower"),value:_})}return t.pushToMain({index:e,key:s,value:S}),!0},ema:re,sma:re,macd:function(t,e,r,n,o,i){var a=i.target,u=i.lag,l=i.precomputed,c=t.verticalOhlcv,s=t.instances,f=l.instanceKey;if(0===e){var p=t.inputParams,y=t.crossPairsList,h=t.priceBased,v=t.len,m=t.arrayTypes;if(!c.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var d,b=0,g=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return ae(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ae(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(p);try{for(g.s();!(d=g.n()).done;)"macd"===d.value.key&&b++}catch(t){g.e(t)}finally{g.f()}var w=b>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",O=a===ue?"".concat(w,"_diff"):"".concat(w,"_diff_").concat(a),S=a===ue?"".concat(w,"_dea"):"".concat(w,"_dea_").concat(a),j=a===ue?"".concat(w,"_histogram"):"".concat(w,"_histogram_").concat(a);y.push({fast:O,slow:S,isDefault:!0}),s.hasOwnProperty("macd")||(s.macd={numberOfIndicators:b,settings:{}}),s.macd.settings[f]=new $t(new Lt(r),new Lt(n),new Lt(o)),Object.assign(c,ie(ie(ie({},O,new Float64Array(v).fill(NaN)),S,new Float64Array(v).fill(NaN)),j,new Float64Array(v).fill(NaN)))[j].forEach((function(t){h.add(t)}));var P=[O,S,j];u>0&&t.lag(P,u);for(var _=0,N=P;_<N.length;_++)m[N[_]]="Float64Array"}var T=s.macd,A=T.numberOfIndicators,E=T.settings,k=A>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",x=a===ue?"".concat(k,"_diff"):"".concat(k,"_diff_").concat(a),I=a===ue?"".concat(k,"_dea"):"".concat(k,"_dea_").concat(a),M=a===ue?"".concat(k,"_histogram"):"".concat(k,"_histogram_").concat(a),D=E[f],R=c[a][e];D.update(R);var C={};try{C=D.getResult()}catch(t){}return t.pushToMain({index:e,key:x,value:C?C.macd:NaN}),t.pushToMain({index:e,key:I,value:C?C.signal:NaN}),t.pushToMain({index:e,key:M,value:C?C.histogram:NaN}),!0},relativeVolume:function(t,e,r,n){var o=n.lag,i="relative_volume_".concat(r),a=t.instances,u=t.verticalOhlcv;if(0===e){var l=t.len,c=t.arrayTypes;a[i]={instance:new W(r),prevRelativeVolumeSma:NaN},u[i]=new Float64Array(l).fill(NaN),o>0&&t.lag([i],o),c[i]="Float64Array"}var s=u.volume[e],f=a[i].instance;f.update(s);var p=NaN;try{p=f.getResult()}catch(t){}var y=a[i].prevRelativeVolumeSma,h=NaN;return Number.isNaN(p)||Number.isNaN(y)||(h=s/y),t.pushToMain({index:e,key:i,value:h}),a[i].prevRelativeVolumeSma=p,!0},donchianChannels:function(t,e,r,n,o){var i=t.verticalOhlcv,a=t.instances,u=t.len,l=t.inputParams,c=t.priceBased,s=t.arrayTypes,f=t.lag,p=o.height,y=o.range,h=o.decimals,v="".concat(r,"_").concat(n);if(0===e){var m=l.filter((function(t){return"donchianChannels"===t.key})).length,d="donchian_channel",b=m>1?"".concat(d,"_").concat(v):d,g=["upper","basis","lower"].map((function(t){return"".concat(b,"_").concat(t)}));p&&g.push("".concat(b,"_height"));var w,O=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ye(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(y);try{for(O.s();!(w=O.n()).done;){var S=w.value;if(!(S in i)||!c.has(S))throw new Error('Invalid range key "'.concat(S,'". Only price-based keys are allowed: ').concat(pe(c)));g.push("".concat(b,"_range_").concat(S))}}catch(t){O.e(t)}finally{O.f()}a.donchian_channel||(a.donchian_channel={numberOfIndicators:m,settings:{}}),a.donchian_channel.numberOfIndicators=m,a.donchian_channel.settings[v]={maxDeque:[],minDeque:[]},Object.assign(i,Object.fromEntries(g.map((function(t){return[t,new Float64Array(u).fill(NaN)]})))),f>0&&t.lag(g,f),["upper","basis","lower"].forEach((function(t){return c.add("".concat(b,"_").concat(t))})),g.forEach((function(t){return s[t]="Float64Array"}))}var j=a.donchian_channel,P=j.numberOfIndicators,_=j.settings,N=P>1?"donchian_channel_".concat(v):"donchian_channel",T=_[v],A=T.maxDeque,E=T.minDeque,k=e-n,x=k-r+1,I=["upper","basis","lower"].map((function(t){return"".concat(N,"_").concat(t)}));p&&I.push("".concat(N,"_height"));var M=y.map((function(t){return"".concat(N,"_range_").concat(t)}));if(x<0||k+1>u)return[].concat(pe(I),pe(M)).forEach((function(r){return t.pushToMain({index:e,key:r,value:NaN})})),!0;var D=i.high,R=i.low,C=function(t,e,r){for(;t.length&&t[0]<x;)t.shift();for(;t.length&&r(e[t.at(-1)],e[k]);)t.pop();t.push(k)};C(A,D,(function(t,e){return t<=e})),C(E,R,(function(t,e){return t>=e}));var F=A.length&&E.length,L=F?D[A[0]]:NaN,B=F?R[E[0]]:NaN,H=F?(L+B)/2:NaN;if(t.pushToMain({index:e,key:"".concat(N,"_upper"),value:L}),t.pushToMain({index:e,key:"".concat(N,"_basis"),value:H}),t.pushToMain({index:e,key:"".concat(N,"_lower"),value:B}),p){var V=F&&B?(L-B)/B:NaN;t.pushToMain({index:e,key:"".concat(N,"_height"),value:null===h?V:fe(V,h)})}for(var U=F?L-B:NaN,$=0;$<y.length;$++){var q=i[y[$]][e],z=F&&q==q&&U?(q-B)/U:NaN;t.pushToMain({index:e,key:M[$],value:null===h?z:fe(z,h)})}return!0},bollingerBands:function(t,e,r,n,o){var i,a,u,l,c,s,f,p=o.height,y=o.range,h=void 0===y?[]:y,v=o.target,m=o.lag,d=o.decimals,b=t.verticalOhlcv,g=t.instances,w="close"===v?"":"_".concat(v),O="".concat(r,"_").concat(n).concat(w);if(0===e){var S=t.priceBased,j=t.inputParams,P=t.verticalOhlcv,_=t.len,N=t.arrayTypes;if(!(v in P))throw new Error('bollingerBands could not find target "'.concat(v,'"'));var T,A=0,E=be(j);try{for(E.s();!(T=E.n()).done;)"bollingerBands"===T.value.key&&A++}catch(t){E.e(t)}finally{E.f()}f=A>1?"bollinger_bands_".concat(O):"bollinger_bands".concat(w),g.bollinger_bands||(g.bollinger_bands={numberOfIndicators:A,settings:{}}),g.bollinger_bands.settings[O]=new Et(r,n);var k=["".concat(f,"_upper"),"".concat(f,"_middle"),"".concat(f,"_lower")];p&&k.push("".concat(f,"_height"));var x,I=be(h);try{for(I.s();!(x=I.n()).done;){var M=x.value;if(!(M in P)||!S.has(M))throw new Error('Invalid range item value "'.concat(M,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(S)));k.push("".concat(f,"_range_").concat(M))}}catch(t){I.e(t)}finally{I.f()}var D=Object.fromEntries(k.map((function(t){return[t,new Float64Array(_).fill(NaN)]})));Object.assign(P,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?me(Object(r),!0).forEach((function(e){de(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):me(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},D)),m>0&&t.lag(k,m),["".concat(f,"_upper"),"".concat(f,"_middle"),"".concat(f,"_lower")].forEach((function(t){S.add(t)}));for(var R=0,C=k;R<C.length;R++)N[C[R]]="Float64Array"}f||(f=g.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(O):"bollinger_bands".concat(w));var F=f,L=g.bollinger_bands.settings[O],B=b[v][e];L.update(B);var H={};try{H=L.getResult()}catch(t){}var V=null!==(i=null===(a=H)||void 0===a?void 0:a.upper)&&void 0!==i?i:NaN,U=null!==(u=null===(l=H)||void 0===l?void 0:l.middle)&&void 0!==u?u:NaN,$=null!==(c=null===(s=H)||void 0===s?void 0:s.lower)&&void 0!==c?c:NaN;if(t.pushToMain({index:e,key:"".concat(F,"_upper"),value:V}),t.pushToMain({index:e,key:"".concat(F,"_middle"),value:U}),t.pushToMain({index:e,key:"".concat(F,"_lower"),value:$}),p){var q=NaN;Number.isNaN($)||Number.isNaN(V)||(q=(V-$)/$),t.pushToMain({index:e,key:"".concat(F,"_height"),value:null===d?q:fe(q,d)})}var z,G=be(h);try{for(G.s();!(z=G.n()).done;){var K=z.value,Y=NaN,J=b[K][e];Number.isNaN(J)||Number.isNaN($)||Number.isNaN(V)||(Y=(J-$)/(V-$)),t.pushToMain({index:e,key:"".concat(F,"_range_").concat(K),value:null===d?Y:fe(Y,d)})}}catch(t){G.e(t)}finally{G.f()}return!0},volumeOscillator:function(t,e,r,n,o){var i,a,u,l=o.lag,c=t.verticalOhlcv,s=t.instances,f=c.volume[e],p="volume_oscillator_".concat(r,"_").concat(n);if(0===e){var y=t.crossPairsList,h=t.len,v=t.arrayTypes;Object.assign(s,(i={},a=p,u={fastEMA:new Lt(r),slowEMA:new Lt(n)},(a=function(t){var e=function(t,e){if("object"!=we(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=we(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==we(e)?e:e+""}(a))in i?Object.defineProperty(i,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):i[a]=u,i)),c[p]=new Float64Array(h).fill(NaN),y.push({fast:p,slow:0,isDefault:!0}),l>0&&t.lag([p],l),v[p]="Float64Array"}var m=s[p],d=m.fastEMA,b=m.slowEMA;d.update(f),b.update(f);var g=NaN,w=NaN;try{g=d.getResult()}catch(t){}try{w=b.getResult()}catch(t){}var O=NaN;return Number.isNaN(g)||Number.isNaN(w)||(O=100*(g-w)/w),t.pushToMain({index:e,key:p,value:O}),!0},scaler:function(t,e,r,n,o){var i=o.type,a=o.group,u=o.range,l=o.lag,c=o.precomputed,s=o.decimals,f=c.groupKey,p=c.groupKeyLen,y=t.verticalOhlcv,h=t.instances,v=t.arrayTypes,m="".concat(i,"_").concat(r);if(0===e){var d=t.len;h.hasOwnProperty("scaler")||(h.scaler={windows:{}});var b,g=Ke(n);try{var w=function(){var e=b.value;if(!y.hasOwnProperty(e))throw new Error('Target property "'.concat(e,'" not found in verticalOhlcv'));var r="".concat(m,"_").concat(e);y[r]=new Float64Array(d).fill(NaN),v[r]="Float64Array";var n=a?f:e;if(h.scaler.windows[n]=[],a&&(t.scaledGroups[f]||(t.scaledGroups[f]=[]),t.scaledGroups[f].push(r)),l>0){if(a){var o,i=Array.from({length:l}).map((function(t,e){return"".concat(r,"_lag_").concat(e+1)}));(o=t.scaledGroups[f]).push.apply(o,Ge(i))}t.lag([r],l)}};for(g.s();!(b=g.n()).done;)w()}catch(t){g.e(t)}finally{g.f()}}var O,S=h.scaler.windows,j=Ke(n);try{for(j.s();!(O=j.n()).done;){var P=O.value,_=y[P][e],N=S[a?f:P];N.push(_),N.length>(a?r*p:r)&&N.shift()}}catch(t){j.e(t)}finally{j.f()}var T,A=e+1>=r,E=Ke(n);try{var k=function(){var r,n,o,l,c,p,h,v,d=T.value,b=y[d][e],g="".concat(m,"_").concat(d),w=null;if(A){var O=S[a?f:d];if("minmax"===i){r=b,n=Math.min.apply(Math,Ge(O)),o=Math.max.apply(Math,Ge(O)),v=2,l=function(t){if(Array.isArray(t))return t}(h=u)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(h,v)||Ye(h,v)||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.")}(),c=l[0],p=l[1],w=(Math.min(Math.max(r,n),o)-n)/(o-n)*(p-c)+c}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var j=O.reduce((function(t,e){return t+e}),0)/O.length,P=O.reduce((function(t,e){return t+Math.pow(e-j,2)}),0)/O.length,_=Math.sqrt(P);w=function(t,e,r){return 0===r?0:(t-e)/r}(b,j,_)}}t.pushToMain({index:e,key:g,value:null===s?w:fe(w,s)})};for(E.s();!(T=E.n()).done;)k()}catch(t){E.e(t)}finally{E.f()}}},rr=function(t,e){for(var r=t.length,n=new W(e),o=new Array(r),i=0,a=0,u=0,l=0;l<r;l++)if(n.update(t[l]),n.isStable){var c=n.getResult();o[l]=c,i+=c,a+=c*c,u++}else o[l]=null;var s=i/u,f=a/u-s*s,p=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/p:null}))},nr=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=rr(t,r),o=rr(e,r),i=t.length,a=[],u=0,l=0,c=0,s=0,f=0,p=0,y=-1,h=0;h<i;h++){if(null!==n[h]&&null!==o[h]){y=h;break}a.push(0)}if(-1===y)return new Array(i).fill(0);for(var v=y;v<i;v++){var m=n[v],d=o[v];if(null!==m&&null!==d)if(u+=m,l+=d,c+=m*d,s+=m*m,f+=d*d,++p<2)a.push(0);else{var b=p*c-u*l,g=Math.sqrt((p*s-u*u)*(p*f-l*l)),w=0===g?0:b/g;a.push(w)}else u=l=c=s=f=p=0,a.push(0)}return a};function or(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ir=function(t){var e,r,n=t.main,o=t.skipNull,i=void 0!==o&&o,a=t.startIndex,u=void 0===a?0:a,l=t.dateFormat,c=n.precisionMultiplier,s=n.priceBased,f=n.precision,p=n.verticalOhlcv,y=n.invalidValueIndex,h=n.len,v=n.verticalOhlcvKeyNames,m=n.verticalOhlcvTempCols;if(0===v.length)return[];for(var d=i&&y>=0?y+1:0,b=Math.max(d,u),g=h-b,w=Array.from({length:g},(function(){return{}})),O=0,S=Object.entries(p);O<S.length;O++){var j=(e=S[O],r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(e,r)||function(t,e){if(t){if("string"==typeof t)return or(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?or(t,e):void 0}}(e,r)||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.")}()),P=j[0],_=j[1];if(!m.has(P))for(var N=s.has(P)&&f,T=b;T<h;T++)w[T-b][P]=N?_[T]/c:"date"===P?Se[l](_[T]):_[T]}return w};function ar(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||ur(t,e)||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 ur(t,e){if(t){if("string"==typeof t)return lr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?lr(t,e):void 0}}function lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function cr(t){return cr="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},cr(t)}function sr(t){return function(t){if(Array.isArray(t))return yr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||pr(t)||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 fr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||pr(t,e)||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 pr(t,e){if(t){if("string"==typeof t)return yr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yr(t,e):void 0}}function yr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function hr(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vr(n.key),n)}}function vr(t){var e=function(t,e){if("object"!=cr(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=cr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cr(e)?e:e+""}var mr=function(){return t=function t(e){var r=this,n=e.input,o=e.ticker,i=void 0===o?null:o,u=e.precision,c=void 0===u||u,s=e.inputParams,y=void 0===s?null:s,h=e.chunkProcess,v=void 0===h?2e3:h;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),l(n,"input",null!==i?"contructor ".concat(i):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+i);f(c,"precision","constructor"),p(v,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),this.chunkProcess=v,this.firstRow=n[0];var m=function(t){for(var e={},r={},n=0,o=Object.entries(t);n<o.length;n++){var i=_e(o[n],2),a=i[0],u=i[1];if("date"===a)e[a]=Pe(u),r[a]="Array";else if("volume"===a)e[a]=se(u,!0),r[a]="Int32Array";else if(Te.has(a))e[a]=se(u,!0),r[a]="Float64Array";else{var l=se(u,!1);e[a]=l,r[a]="number"===l?"Float64Array":"Array"}}return{inputTypes:e,arrayTypes:r}}(this.firstRow),d=m.inputTypes,b=m.arrayTypes;if(this.inputTypes=d,this.arrayTypes=b,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(i));return this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.input=n,this.priceBased=new Set(["open","high","low","close"]),this.len=n.length,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={correlation:nr},this.invalidValueIndex=-1,this.precision=c,this.precisionMultiplier=function(t,e){var r=t.precision,n=t.priceBased;if(!1===r)return 1;var o,i=1,a=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ur(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(Object.entries(e).filter((function(t){var e=ar(t,2),r=e[0];return e[1],n.has(r)})).map((function(t){var e=ar(t,2);return e[0],e[1]})));try{for(a.s();!(o=a.n()).done;){var u=o.value,l=ar(String(u).split("."),2)[1],c=void 0===l?"":l,s=Math.max(4,c.length),f=s>1?Math.pow(10,s-1):1;f>i&&(i=f)}}catch(t){a.e(t)}finally{a.f()}return i}(this,this.firstRow),this.scaledGroups={},this.pushToMain=function(t){var e=t.index,n=t.key,o=t.value;return function(t){var e=t.main,r=t.index,n=t.key,o=t.value,i=e.verticalOhlcv;return null==o||Number.isNaN(o)?(e.invalidValueIndex=r,i[n][r]=o,!1):(i[n][r]=o,!0)}({main:r,index:e,key:n,value:o})},null!==y&&(a(y,this.len),this.inputParams=y,this.compute()),this.inputParams=[],this},e=[{key:"getDataAsCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e||e,n=t.dateFormat,o=void 0===n?"string":n;s(Object.keys(Se),o,"dateFormat","getDataAsCols"),c(t,"options","getDataAsCols");for(var i=this.precisionMultiplier,a=this.precision,u=this.invalidValueIndex,l=this.len,f=this.verticalOhlcv,p=this.priceBased,y=this.arrayTypes,h=this.verticalOhlcvTempCols,v={},m=r?u+1:0,d=l-m,b=0,g=Object.entries(f);b<g.length;b++){var w=fr(g[b],2),O=w[0],S=w[1];if(!h.has(O)){var j=p.has(O)&&a;v[O]=Ae(y[O],d);for(var P=m;P<l;P++)v[O][P]=j?S[P]/i:"date"===O?Se[o](S[P]):S[P]}}return v}},{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e||e,n=t.dateFormat,o=void 0===n?"string":n;return s(Object.keys(Se),o,"dateFormat","getData"),c(t,"options","getData"),ir({main:this,skipNull:r,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.dateFormat,r=void 0===e?"string":e;return s(Object.keys(Se),r,"dateFormat","getData"),ir({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:r})[0]}},{key:"compute",value:function(){return this.isComputed||(this.isComputed=!1,this.len>0&&(function(t,e){var r=e.len,n=e.inputParams,o=e.priceBased,i=e.precisionMultiplier,u=e.arrayTypes,l=e.verticalOhlcv,c=e.verticalOhlcvKeyNames,s=e.inputTypes,f=e.chunkProcess;a(n,r);for(var p=0,y=Object.keys(s);p<y.length;p++){var h=y[p];l[h]=Ae(u[h],r)}for(var v=0;v<r;v+=f)for(var m=Math.min(v+f,r),d=v;d<m;d++){for(var b=t[d],g=0,w=Object.entries(s);g<w.length;g++){var O=Qe(w[g],2),S=O[0],j=O[1],P=b[S];if(ce.hasOwnProperty(j)){var _=ce[j](P);i>1&&o.has(S)&&(_*=i),e.pushToMain({index:d,key:S,value:_})}else je.hasOwnProperty(j)?e.pushToMain({index:d,key:S,value:je[j](P)}):e.pushToMain({index:d,key:S,value:P})}var N,T=Ze(n);try{for(T.s();!(N=T.n()).done;){var A=N.value,E=A.key,k=A.params;"lag"!==E&&"crossPairs"!==E&&er[E].apply(er,[e,d].concat(We(k)))}}catch(t){T.e(t)}finally{T.f()}Me(e,d),Ue(e,d),t[d]=null}c.push.apply(c,We(Object.keys(l)))}(this.input,this),this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[])),this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e="crossPairs";return u(this),l(t,"arr",e),this.crossPairsList=[].concat(sr(this.crossPairsList),sr(t)),this.inputParams.push({key:e,params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r="lag";u(this),l(t,"colKeys",r),p(e,{min:1,max:this.len,allowDecimals:!1},"lookback",r),this.inputParams.push({key:r,params:[t,e]});var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=pr(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(t);try{for(o.s();!(n=o.n()).done;){var i=n.value;this.priceBased.has(i)&&this.priceBased.add(i)}}catch(t){o.e(t)}finally{o.f()}return this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.lag,o=void 0===n?0:n;return p(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,params:[t,{lag:o}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="atr";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.percentage,a=void 0!==i&&i,l=e.upper,s=void 0===l?null:l,y=e.lower,h=void 0===y?null:y;return p(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),f(a,"options.percentage","atr"),null!==s&&p(s,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==h&&p(h,{min:.001,max:100,allowDecimals:!0},"options.lower","atr"),this.inputParams.push({key:r,params:[t,{lag:o,percentage:a,upper:s,lower:h}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="ema";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,a=void 0===i?0:i;p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",r);var l=ne({main:this,size:t,target:o,lag:a,methodName:r});return this.inputParams.push({key:r,params:[r,t,{target:o,lag:a,precomputed:l}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="sma";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,a=void 0===i?0:i;p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",r);var l=ne({main:this,size:t,target:o,lag:a,methodName:r});return this.inputParams.push({key:r,params:[r,t,{target:o,lag:a,precomputed:l}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),p(e,{min:1,max:this.len,allowDecimals:!1},"slow",o),p(r,{min:1,max:this.len,allowDecimals:!1},"signal",o),c(n,"options",o);var i=n.target,a=void 0===i?"close":i,l=n.lag,s=void 0===l?0:l;p(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var f={instanceKey:"".concat(t,"_").concat(e,"_").concat(r).concat("close"===a?"":"_".concat(a))};return this.inputParams.push({key:o,params:[t,e,r,{target:a,lag:s,precomputed:f}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),p(e,{min:.01,max:50,allowDecimals:!0},"stdDev",n),c(r,"options",n);var o=r.target,i=void 0===o?"close":o,a=r.height,s=void 0!==a&&a,y=r.range,h=void 0===y?[]:y,v=r.lag,m=void 0===v?0:v,d=r.decimals,b=void 0===d?null:d;return l(h,"options.range",n),p(m,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(s,"options.height",n),null!==b&&p(b,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,params:[t,e,{target:i,height:s,range:h,lag:m,decimals:b}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="rsi";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,a=void 0===i?0:i;return p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,params:[t,{target:o,lag:a}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),p(e,{min:0,max:this.len,allowDecimals:!1},"offset",n),c(r,"options",n);var o=r.height,i=void 0!==o&&o,a=r.range,s=void 0===a?[]:a,y=r.lag,h=void 0===y?0:y,v=r.decimals,m=void 0===v?null:v;return l(s,"options.range",n),p(h,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(i,"options.height",n),null!==m&&p(m,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,params:[t,e,{height:i,range:s,lag:h,decimals:m}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"fastSize",n),p(e,{min:t,max:this.len,allowDecimals:!1},"slowSize",n),c(r,"options",n);var o=r.lag,i=void 0===o?0:o;return p(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,params:[t,e,{lag:i}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="dateTime";u(this),c(t,"options",e);var r=t.lag,n=void 0===r?0:r;return p(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this.inputParams.push({key:e,params:[{lag:n}]}),this}},{key:"scaler",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="scaler";u(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),l(e,"colKeys",n);var i=r.group,a=void 0!==i&&i,c=r.range,y=void 0===c?[0,1]:c,h=r.lag,v=void 0===h?0:h,m=r.type,d=void 0===m?"minmax":m,b=r.decimals,g=void 0===b?null:b;f(a,"options.group",n),function(t,e,r){if(l(t,e,r),2!==t.length)throw new Error('Invalid "'.concat(e,'" array length: expected 2 items, but got ').concat(t.length,' in "').concat(r,".").concat(e,'".'));var n=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||o(t,e)||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.")}()}(t,2),i=n[0],a=n[1];if(p(i,{min:-100,max:a,allowDecimals:!1},"min",r),p(a,{min:i,max:100,allowDecimals:!1},"max",r),i===a)throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(r,".").concat(e,'".'))}(y,"options.range",n),s(["minmax","zscore"],d,"options.type",n),null!==g&&p(g,{min:1,max:15,allowDecimals:!1},"decimals",n);var w={groupKey:a?"".concat(d,"_").concat(t,"_group_").concat(e.join("_")):"",groupKeyLen:e.length};return this.inputParams.push({key:n,params:[t,e,{type:d,group:a,range:y,lag:v,precomputed:w,decimals:g}]}),this}}],e&&hr(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
|
1
|
+
var OHLCV_INDICATORS;(()=>{"use strict";var t={788:(t,e,r)=>{r.r(e),r.d(e,{isAnyArray:()=>o});const n=Object.prototype.toString;function o(t){const e=n.call(t);return e.endsWith("Array]")&&!e.includes("Big")}},718:(t,e,r)=>{r.r(e),r.d(e,{default:()=>o});var n=r(788);function o(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.isAnyArray)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!(0,n.isAnyArray)(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.isAnyArray)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,o=void 0===r?0:r,i=e.toIndex,s=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=o||s>t.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],u=o+1;u<s;u++)t[u]<a&&(a=t[u]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,n.isAnyArray)(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,o=void 0===r?0:r,i=e.toIndex,s=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=o||s>t.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],u=o+1;u<s;u++)t[u]>a&&(a=t[u]);return a}(t);if(o===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=r.min,a=void 0===s?r.autoMinMax?o:0:s,u=r.max,l=void 0===u?r.autoMinMax?i:1:u;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var c=(l-a)/(i-o),h=0;h<t.length;h++)e[h]=(t[h]-o)*c+a;return e}},673:(t,e,r)=>{var n=r(788),o=r(718);const i=" ".repeat(2),s=" ".repeat(4);function a(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:a="auto"}=e;return`${t.constructor.name} {\n${i}[\n${s}${function(t,e,r,n,o){const{rows:i,columns:a}=t,l=Math.min(i,e),c=Math.min(a,r),h=[];if("auto"===o){o=!1;t:for(let e=0;e<l;e++)for(let r=0;r<c;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<l;e++){let r=[];for(let i=0;i<c;i++)r.push(u(t.get(e,i),n,o));h.push(`${r.join(" ")}`)}return c!==a&&(h[h.length-1]+=` ... ${a-r} more columns`),l!==i&&h.push(`... ${i-e} more rows`),h.join(`\n${s}`)}(t,r,n,o,a)}\n${i}]\n${i}rows: ${t.rows}\n${i}columns: ${t.columns}\n}`}function u(t,e,r){return(t>=0&&r?` ${l(t,e-1)}`:l(t,e)).padEnd(e)}function l(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function c(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function h(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function f(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function m(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function p(t,e){if(!n.isAnyArray(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}function y(t,e){if(!n.isAnyArray(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}function g(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(v("startRow",e),v("endRow",r),v("startColumn",n),v("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function d(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function v(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function w(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class b{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new x(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new x(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new x(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new x(t,e)}static ones(t,e){return new x(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new x(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let s=o-n,a=new x(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*s);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new x(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return b.isMatrix(t)?t:new x(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let s=o;s<e;s++){let e=t.get(r,s)-i*t.get(n,s);t.set(r,s,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new x(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){c(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return x.rowVector(this.getRow(t))}setRow(t,e){c(this,t),e=f(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){c(this,t),c(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){h(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return x.columnVector(this.getColumn(t))}setColumn(t,e){h(this,t),e=m(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){h(this,t),h(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=f(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=m(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){c(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){h(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){w(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){w(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(c(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){c(this,t),w(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(c(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){c(this,t),w(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(h(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){h(this,t),w(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(h(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){h(this,t),w(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){b.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new x(e,n),i=new Float64Array(r);for(let s=0;s<n;s++){for(let e=0;e<r;e++)i[e]=t.get(e,s);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,s,e)}}return o}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=x.eye(this.rows),r=this;for(let n=t;n>=1;n/=2)1&n&&(e=e.mmul(r)),r=r.mmul(r);return e}strassen2x2(t){t=x.checkMatrix(t);let e=new x(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),s=this.get(1,0),a=t.get(1,0),u=this.get(1,1),l=t.get(1,1),c=(r+u)*(n+l),h=(s+u)*n,f=r*(i-l),m=u*(a-n),p=(r+o)*l,y=c+m-p+(o-u)*(a+l),g=f+p,d=h+m,v=c-h+f+(s-r)*(n+i);return e.set(0,0,y),e.set(0,1,g),e.set(1,0,d),e.set(1,1,v),e}strassen3x3(t){t=x.checkMatrix(t);let e=new x(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),s=this.get(1,1),a=this.get(1,2),u=this.get(2,0),l=this.get(2,1),c=this.get(2,2),h=t.get(0,0),f=t.get(0,1),m=t.get(0,2),p=t.get(1,0),y=t.get(1,1),g=t.get(1,2),d=t.get(2,0),v=t.get(2,1),w=t.get(2,2),b=(r-i)*(-f+y),S=(-r+i+s)*(h-f+y),M=(i+s)*(-h+f),O=r*h,E=(-r+u+l)*(h-m+g),j=(-r+u)*(m-g),A=(u+l)*(-h+m),N=(-o+l+c)*(y+d-v),P=(o-c)*(y-v),_=o*d,T=(l+c)*(-d+v),k=(-o+s+a)*(g+d-w),I=(o-a)*(g-w),R=(s+a)*(-d+w),C=O+_+n*p,D=(r+n+o-i-s-l-c)*y+S+M+O+N+_+T,F=O+E+A+(r+n+o-s-a-u-l)*g+_+k+R,V=b+s*(-h+f+p-y-g-d+w)+S+O+_+k+I,q=b+S+M+O+a*v,L=_+k+I+R+i*m,z=O+E+j+l*(-h+m+p-y-g-d+v)+N+P+_,U=N+P+_+T+u*f,$=O+E+j+A+c*w;return e.set(0,0,C),e.set(0,1,D),e.set(0,2,F),e.set(1,0,V),e.set(1,1,q),e.set(1,2,L),e.set(2,0,z),e.set(2,1,U),e.set(2,2,$),e}mmulStrassen(t){t=x.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function s(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=b.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let a=Math.max(r,o),u=Math.max(n,i);return e=s(e,a,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=s(e,n+1,o+1),r=s(r,n+1,o+1)):n%2==1?(e=s(e,n+1,o),r=s(r,n+1,o)):o%2==1&&(e=s(e,n,o+1),r=s(r,n,o+1));let i=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,a-1),l=r.subMatrix(0,i-1,0,a-1),c=e.subMatrix(0,i-1,a,e.columns-1),h=r.subMatrix(0,i-1,a,r.columns-1),f=e.subMatrix(i,e.rows-1,0,a-1),m=r.subMatrix(i,r.rows-1,0,a-1),p=e.subMatrix(i,e.rows-1,a,e.columns-1),y=r.subMatrix(i,r.rows-1,a,r.columns-1),g=t(b.add(u,p),b.add(l,y),i,a),d=t(b.add(f,p),l,i,a),v=t(u,b.sub(h,y),i,a),w=t(p,b.sub(m,l),i,a),S=t(b.add(u,c),y,i,a),x=t(b.sub(f,u),b.add(l,h),i,a),M=t(b.sub(c,p),b.add(m,y),i,a),O=b.add(g,w);O.sub(S),O.add(M);let E=b.add(v,S),j=b.add(d,w),A=b.sub(g,d);A.add(v),A.add(x);let N=b.zeros(2*O.rows,2*O.columns);return N=N.setSubMatrix(O,0,0),N=N.setSubMatrix(E,O.rows,0),N=N.setSubMatrix(j,0,O.columns),N=N.setSubMatrix(A,O.rows,O.columns),N.subMatrix(0,n-1,0,o-1)}(e,t=s(t,a,u),a,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new x(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&o(i,{min:e,max:r,output:i}),n.setRow(t,i)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new x(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&o(i,{min:e,max:r,output:i}),n.setColumn(t,i)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=x.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new x(e*n,r*o);for(let s=0;s<e;s++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let a=0;a<o;a++)i.set(n*s+r,o*e+a,this.get(s,e)*t.get(r,a));return i}kroneckerSum(t){if(t=x.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(x.eye(r,r)),o=x.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new x(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=S){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=S){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){g(this,t,e,r,n);let o=new x(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new x(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new x(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=x.checkMatrix(t)).isEmpty())return this;g(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){p(this,t),y(this,e);let r=new x(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){return this.constructor.copy(this,new x(this.rows,this.columns))}static copy(t,e){for(const[r,n,o]of t.entries())e.set(r,n,o);return e}sum(t){switch(t){case"row":return function(t){let e=d(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=d(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=d(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=d(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:o=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!n.isAnyArray(o))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<n;s++){let n=0,a=0,u=0;for(let e=0;e<o;e++)u=t.get(s,e)-r[s],n+=u,a+=u*u;e?i.push((a-n*n/o)/(o-1)):i.push((a-n*n/o)/o)}return i}(this,r,o);case"column":if(!n.isAnyArray(o))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let s=0;s<o;s++){let o=0,a=0,u=0;for(let e=0;e<n;e++)u=t.get(e,s)-r[s],o+=u,a+=u*u;e?i.push((a-o*o/n)/(n-1)):i.push((a-o*o/n)/n)}return i}(this,r,o);case void 0:if("number"!=typeof o)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let s=0,a=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,s+=u,a+=u*u;return e?(a-s*s/i)/(i-1):(a-s*s/i)/i}(this,r,o);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!n.isAnyArray(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!n.isAnyArray(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=t.get(r,e)**2/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!n.isAnyArray(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=t.get(e,r)**2/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!n.isAnyArray(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=t.get(o,n)**2/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return a(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function S(t,e){return t-e}b.prototype.klass="Matrix","undefined"!=typeof Symbol&&(b.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return a(this)}),b.random=b.rand,b.randomInt=b.randInt,b.diagonal=b.diag,b.prototype.diagonal=b.prototype.diag,b.identity=b.eye,b.prototype.negate=b.prototype.neg,b.prototype.tensorProduct=b.prototype.kroneckerProduct;class x extends b{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(t,e){if(super(),x.isMatrix(t))this.#t(t.rows,t.columns),x.copy(t,this);else if(Number.isInteger(t)&&t>=0)this.#t(t,e);else{if(!n.isAnyArray(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}this.rows=t,this.columns=e}}}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return c(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),c(this,t,!0),e=Float64Array.from(f(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){h(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),h(this,t,!0),e=m(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)**t);return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)**t.get(e,r));return this}}(b,x);class M extends b{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return x.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),x.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=x.copy(t,new x(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new x(t,t);else if(this.#e=new x(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new M(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())t.set(e,r,n);return t}toMatrix(){return new x(this)}get(t,e){return this.#e.get(t,e)}set(t,e,r){return this.#e.set(t,e,r),this.#e.set(e,t,r),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const r=e.slice();return r.splice(t,1),this.#e.addRow(t,r),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[r,n]of t.entries())n||e.push(r);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let r=0,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=++n);return e}static fromCompact(t){const e=t.length,r=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const n=new M(r);for(let o=0,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=++i);return n}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield[t,e,r],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const r=this.get(t,e);yield r,++e>=this.diagonalSize&&(e=++t)}}}M.prototype.klassType="SymmetricMatrix";class O extends M{static isDistanceMatrix(t){return M.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new M(this)}clone(){const t=new O(this.diagonalSize);for(const[e,r,n]of this.upperRightEntries())e!==r&&t.set(e,r,n);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let r=1,n=0,o=0;o<e.length;o++)e[o]=this.get(n,r),++r>=t&&(r=1+ ++n);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const n=new this(r);for(let o=1,i=0,s=0;s<e;s++)n.set(o,i,t[s]),++o>=r&&(o=1+ ++i);return n}}O.prototype.klassSubType="DistanceMatrix";class E extends b{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class j extends E{constructor(t,e,r){p(t,e),y(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class A extends b{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let n=this._calculateIndex(t,e);return this.data[n]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class N extends b{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}class P{constructor(t){let e,r,n,o,i,s,a,u,l,c=(t=N.checkMatrix(t)).clone(),h=c.rows,f=c.columns,m=new Float64Array(h),p=1;for(e=0;e<h;e++)m[e]=e;for(u=new Float64Array(h),r=0;r<f;r++){for(e=0;e<h;e++)u[e]=c.get(e,r);for(e=0;e<h;e++){for(l=Math.min(e,r),i=0,n=0;n<l;n++)i+=c.get(e,n)*u[n];u[e]-=i,c.set(e,r,u[e])}for(o=r,e=r+1;e<h;e++)Math.abs(u[e])>Math.abs(u[o])&&(o=e);if(o!==r){for(n=0;n<f;n++)s=c.get(o,n),c.set(o,n,c.get(r,n)),c.set(r,n,s);a=m[o],m[o]=m[r],m[r]=a,p=-p}if(r<h&&0!==c.get(r,r))for(e=r+1;e<h;e++)c.set(e,r,c.get(e,r)/c.get(r,r))}this.LU=c,this.pivotVector=m,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let r=0;r<e;r++)if(0===t.get(r,r))return!0;return!1}solve(t){t=x.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let r,n,o,i=t.columns,s=t.subMatrixRow(this.pivotVector,0,i-1),a=e.columns;for(o=0;o<a;o++)for(r=o+1;r<a;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o));for(o=a-1;o>=0;o--){for(n=0;n<i;n++)s.set(o,n,s.get(o,n)/e.get(o,o));for(r=0;r<o;r++)for(n=0;n<i;n++)s.set(r,n,s.get(r,n)-s.get(o,n)*e.get(r,o))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,r=t.columns;for(let n=0;n<r;n++)e*=t.get(n,n);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o>e?n.set(o,e,t.get(o,e)):o===e?n.set(o,e,1):n.set(o,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new x(e,r);for(let o=0;o<e;o++)for(let e=0;e<r;e++)o<=e?n.set(o,e,t.get(o,e)):n.set(o,e,0);return n}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function _(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class T{constructor(t){let e,r,n,o,i=(t=N.checkMatrix(t)).clone(),s=t.rows,a=t.columns,u=new Float64Array(a);for(n=0;n<a;n++){let t=0;for(e=n;e<s;e++)t=_(t,i.get(e,n));if(0!==t){for(i.get(n,n)<0&&(t=-t),e=n;e<s;e++)i.set(e,n,i.get(e,n)/t);for(i.set(n,n,i.get(n,n)+1),r=n+1;r<a;r++){for(o=0,e=n;e<s;e++)o+=i.get(e,n)*i.get(e,r);for(o=-o/i.get(n,n),e=n;e<s;e++)i.set(e,r,i.get(e,r)+o*i.get(e,n))}}u[n]=-t}this.QR=i,this.Rdiag=u}solve(t){t=x.checkMatrix(t);let e=this.QR,r=e.rows;if(t.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let n,o,i,s,a=t.columns,u=t.clone(),l=e.columns;for(i=0;i<l;i++)for(o=0;o<a;o++){for(s=0,n=i;n<r;n++)s+=e.get(n,i)*u.get(n,o);for(s=-s/e.get(i,i),n=i;n<r;n++)u.set(n,o,u.get(n,o)+s*e.get(n,i))}for(i=l-1;i>=0;i--){for(o=0;o<a;o++)u.set(i,o,u.get(i,o)/this.Rdiag[i]);for(n=0;n<i;n++)for(o=0;o<a;o++)u.set(n,o,u.get(n,o)-u.get(i,o)*e.get(n,i))}return u.subMatrix(0,l-1,0,a-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,r=this.QR,n=r.columns,o=new x(n,n);for(t=0;t<n;t++)for(e=0;e<n;e++)t<e?o.set(t,e,r.get(t,e)):t===e?o.set(t,e,this.Rdiag[t]):o.set(t,e,0);return o}get orthogonalMatrix(){let t,e,r,n,o=this.QR,i=o.rows,s=o.columns,a=new x(i,s);for(r=s-1;r>=0;r--){for(t=0;t<i;t++)a.set(t,r,0);for(a.set(r,r,1),e=r;e<s;e++)if(0!==o.get(r,r)){for(n=0,t=r;t<i;t++)n+=o.get(t,r)*a.get(t,e);for(n=-n/o.get(r,r),t=r;t<i;t++)a.set(t,e,a.get(t,e)+n*o.get(t,r))}}return a}}class k{constructor(t,e={}){if((t=N.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:s=!1}=e;let a,u=Boolean(o),l=Boolean(i),c=!1;if(r<n)if(s){a=t.transpose(),r=a.rows,n=a.columns,c=!0;let e=u;u=l,l=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let h=Math.min(r,n),f=Math.min(r+1,n),m=new Float64Array(f),p=new x(r,h),y=new x(n,n),g=new Float64Array(n),d=new Float64Array(r),v=new Float64Array(f);for(let t=0;t<f;t++)v[t]=t;let w=Math.min(r-1,n),b=Math.max(0,Math.min(n-2,r)),S=Math.max(w,b);for(let t=0;t<S;t++){if(t<w){m[t]=0;for(let e=t;e<r;e++)m[t]=_(m[t],a.get(e,t));if(0!==m[t]){a.get(t,t)<0&&(m[t]=-m[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/m[t]);a.set(t,t,a.get(t,t)+1)}m[t]=-m[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==m[t]){let n=0;for(let o=t;o<r;o++)n+=a.get(o,t)*a.get(o,e);n=-n/a.get(t,t);for(let o=t;o<r;o++)a.set(o,e,a.get(o,e)+n*a.get(o,t))}g[e]=a.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)p.set(e,t,a.get(e,t));if(t<b){g[t]=0;for(let e=t+1;e<n;e++)g[t]=_(g[t],g[e]);if(0!==g[t]){g[t+1]<0&&(g[t]=0-g[t]);for(let e=t+1;e<n;e++)g[e]/=g[t];g[t+1]+=1}if(g[t]=-g[t],t+1<r&&0!==g[t]){for(let e=t+1;e<r;e++)d[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)d[e]+=g[r]*a.get(e,r);for(let e=t+1;e<n;e++){let n=-g[e]/g[t+1];for(let o=t+1;o<r;o++)a.set(o,e,a.get(o,e)+n*d[o])}}if(l)for(let e=t+1;e<n;e++)y.set(e,t,g[e])}}let M=Math.min(n,r+1);if(w<n&&(m[w]=a.get(w,w)),r<M&&(m[M-1]=0),b+1<M&&(g[b]=a.get(b,M-1)),g[M-1]=0,u){for(let t=w;t<h;t++){for(let e=0;e<r;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==m[t]){for(let e=t+1;e<h;e++){let n=0;for(let o=t;o<r;o++)n+=p.get(o,t)*p.get(o,e);n=-n/p.get(t,t);for(let o=t;o<r;o++)p.set(o,e,p.get(o,e)+n*p.get(o,t))}for(let e=t;e<r;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<r;e++)p.set(e,t,0);p.set(t,t,1)}}if(l)for(let t=n-1;t>=0;t--){if(t<b&&0!==g[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=y.get(o,t)*y.get(o,e);r=-r/y.get(t+1,t);for(let o=t+1;o<n;o++)y.set(o,e,y.get(o,e)+r*y.get(o,t))}for(let e=0;e<n;e++)y.set(e,t,0);y.set(t,t,1)}let O=M-1,E=Number.EPSILON;for(;M>0;){let t,e;for(t=M-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+E*Math.abs(m[t]+Math.abs(m[t+1]));if(Math.abs(g[t])<=e||Number.isNaN(g[t])){g[t]=0;break}}if(t===M-2)e=4;else{let r;for(r=M-1;r>=t&&r!==t;r--){let e=(r!==M?Math.abs(g[r]):0)+(r!==t+1?Math.abs(g[r-1]):0);if(Math.abs(m[r])<=E*e){m[r]=0;break}}r===t?e=3:r===M-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=g[M-2];g[M-2]=0;for(let r=M-2;r>=t;r--){let o=_(m[r],e),i=m[r]/o,s=e/o;if(m[r]=o,r!==t&&(e=-s*g[r-1],g[r-1]=i*g[r-1]),l)for(let t=0;t<n;t++)o=i*y.get(t,r)+s*y.get(t,M-1),y.set(t,M-1,-s*y.get(t,r)+i*y.get(t,M-1)),y.set(t,r,o)}break}case 2:{let e=g[t-1];g[t-1]=0;for(let n=t;n<M;n++){let o=_(m[n],e),i=m[n]/o,s=e/o;if(m[n]=o,e=-s*g[n],g[n]=i*g[n],u)for(let e=0;e<r;e++)o=i*p.get(e,n)+s*p.get(e,t-1),p.set(e,t-1,-s*p.get(e,n)+i*p.get(e,t-1)),p.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(m[M-1]),Math.abs(m[M-2]),Math.abs(g[M-2]),Math.abs(m[t]),Math.abs(g[t])),o=m[M-1]/e,i=m[M-2]/e,s=g[M-2]/e,a=m[t]/e,c=g[t]/e,h=((i+o)*(i-o)+s*s)/2,f=o*s*(o*s);let d=0;0===h&&0===f||(d=h<0?0-Math.sqrt(h*h+f):Math.sqrt(h*h+f),d=f/(h+d));let v=(a+o)*(a-o)+d,w=a*c;for(let e=t;e<M-1;e++){let o=_(v,w);0===o&&(o=Number.MIN_VALUE);let i=v/o,s=w/o;if(e!==t&&(g[e-1]=o),v=i*m[e]+s*g[e],g[e]=i*g[e]-s*m[e],w=s*m[e+1],m[e+1]=i*m[e+1],l)for(let t=0;t<n;t++)o=i*y.get(t,e)+s*y.get(t,e+1),y.set(t,e+1,-s*y.get(t,e)+i*y.get(t,e+1)),y.set(t,e,o);if(o=_(v,w),0===o&&(o=Number.MIN_VALUE),i=v/o,s=w/o,m[e]=o,v=i*g[e]+s*m[e+1],m[e+1]=-s*g[e]+i*m[e+1],w=s*g[e+1],g[e+1]=i*g[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*p.get(t,e)+s*p.get(t,e+1),p.set(t,e+1,-s*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o)}g[M-2]=v;break}case 4:if(m[t]<=0&&(m[t]=m[t]<0?-m[t]:0,l))for(let e=0;e<=O;e++)y.set(e,t,-y.get(e,t));for(;t<O&&!(m[t]>=m[t+1]);){let e=m[t];if(m[t]=m[t+1],m[t+1]=e,l&&t<n-1)for(let r=0;r<n;r++)e=y.get(r,t+1),y.set(r,t+1,y.get(r,t)),y.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=p.get(n,t+1),p.set(n,t+1,p.get(n,t)),p.set(n,t,e);t++}M--}}if(c){let t=y;y=p,p=t}this.m=r,this.n=n,this.s=m,this.U=p,this.V=y}solve(t){let e=t,r=this.threshold,n=this.s.length,o=x.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,s=this.rightSingularVectors,a=s.mmul(o),u=s.rows,l=i.rows,c=x.zeros(u,l);for(let t=0;t<u;t++)for(let e=0;e<l;e++){let r=0;for(let o=0;o<n;o++)r+=a.get(t,o)*i.get(e,o);c.set(t,e,r)}return c.mmul(e)}solveForDiagonal(t){return this.solve(x.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new x(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,s=i.rows,a=i.columns,u=new x(r,s);for(let t=0;t<r;t++)for(let e=0;e<s;e++){let r=0;for(let n=0;n<a;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return x.diag(this.s)}}function I(t,e,r=!1){return t=N.checkMatrix(t),e=N.checkMatrix(e),r?new k(t).solve(e):t.isSquare()?new P(t).solve(e):new T(t).solve(e)}function R(t,e){let r=[];for(let n=0;n<t;n++)n!==e&&r.push(n);return r}function C(t,e,r,n=1e-9,o=1e-9){if(t>o)return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<n&&t.set(e,0,0);return t.to1DArray()}}class D{constructor(t,e={}){const{assumeSymmetric:r=!1}=e;if(!(t=N.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let n,o,i=t.columns,s=new x(i,i),a=new Float64Array(i),u=new Float64Array(i),l=t,c=!1;if(c=!!r||t.isSymmetric(),c){for(n=0;n<i;n++)for(o=0;o<i;o++)s.set(n,o,l.get(n,o));!function(t,e,r,n){let o,i,s,a,u,l,c,h;for(u=0;u<t;u++)r[u]=n.get(t-1,u);for(a=t-1;a>0;a--){for(h=0,s=0,l=0;l<a;l++)h+=Math.abs(r[l]);if(0===h)for(e[a]=r[a-1],u=0;u<a;u++)r[u]=n.get(a-1,u),n.set(a,u,0),n.set(u,a,0);else{for(l=0;l<a;l++)r[l]/=h,s+=r[l]*r[l];for(o=r[a-1],i=Math.sqrt(s),o>0&&(i=-i),e[a]=h*i,s-=o*i,r[a-1]=o-i,u=0;u<a;u++)e[u]=0;for(u=0;u<a;u++){for(o=r[u],n.set(u,a,o),i=e[u]+n.get(u,u)*o,l=u+1;l<=a-1;l++)i+=n.get(l,u)*r[l],e[l]+=n.get(l,u)*o;e[u]=i}for(o=0,u=0;u<a;u++)e[u]/=s,o+=e[u]*r[u];for(c=o/(s+s),u=0;u<a;u++)e[u]-=c*r[u];for(u=0;u<a;u++){for(o=r[u],i=e[u],l=u;l<=a-1;l++)n.set(l,u,n.get(l,u)-(o*e[l]+i*r[l]));r[u]=n.get(a-1,u),n.set(a,u,0)}}r[a]=s}for(a=0;a<t-1;a++){if(n.set(t-1,a,n.get(a,a)),n.set(a,a,1),s=r[a+1],0!==s){for(l=0;l<=a;l++)r[l]=n.get(l,a+1)/s;for(u=0;u<=a;u++){for(i=0,l=0;l<=a;l++)i+=n.get(l,a+1)*n.get(l,u);for(l=0;l<=a;l++)n.set(l,u,n.get(l,u)-i*r[l])}}for(l=0;l<=a;l++)n.set(l,a+1,0)}for(u=0;u<t;u++)r[u]=n.get(t-1,u),n.set(t-1,u,0);n.set(t-1,t-1,1),e[0]=0}(i,u,a,s),function(t,e,r,n){let o,i,s,a,u,l,c,h,f,m,p,y,g,d,v,w;for(s=1;s<t;s++)e[s-1]=e[s];e[t-1]=0;let b=0,S=0,x=Number.EPSILON;for(l=0;l<t;l++){for(S=Math.max(S,Math.abs(r[l])+Math.abs(e[l])),c=l;c<t&&!(Math.abs(e[c])<=x*S);)c++;if(c>l)do{for(o=r[l],h=(r[l+1]-o)/(2*e[l]),f=_(h,1),h<0&&(f=-f),r[l]=e[l]/(h+f),r[l+1]=e[l]*(h+f),m=r[l+1],i=o-r[l],s=l+2;s<t;s++)r[s]-=i;for(b+=i,h=r[c],p=1,y=p,g=p,d=e[l+1],v=0,w=0,s=c-1;s>=l;s--)for(g=y,y=p,w=v,o=p*e[s],i=p*h,f=_(h,e[s]),e[s+1]=v*f,v=e[s]/f,p=h/f,h=p*r[s]-v*o,r[s+1]=i+v*(p*o+v*r[s]),u=0;u<t;u++)i=n.get(u,s+1),n.set(u,s+1,v*n.get(u,s)+p*i),n.set(u,s,p*n.get(u,s)-v*i);h=-v*w*g*d*e[l]/m,e[l]=v*h,r[l]=p*h}while(Math.abs(e[l])>x*S);r[l]=r[l]+b,e[l]=0}for(s=0;s<t-1;s++){for(u=s,h=r[s],a=s+1;a<t;a++)r[a]<h&&(u=a,h=r[a]);if(u!==s)for(r[u]=r[s],r[s]=h,a=0;a<t;a++)h=n.get(a,s),n.set(a,s,n.get(a,u)),n.set(a,u,h)}}(i,u,a,s)}else{let t=new x(i,i),e=new Float64Array(i);for(o=0;o<i;o++)for(n=0;n<i;n++)t.set(n,o,l.get(n,o));!function(t,e,r,n){let o,i,s,a,u,l,c,h=t-1;for(l=1;l<=h-1;l++){for(c=0,a=l;a<=h;a++)c+=Math.abs(e.get(a,l-1));if(0!==c){for(s=0,a=h;a>=l;a--)r[a]=e.get(a,l-1)/c,s+=r[a]*r[a];for(i=Math.sqrt(s),r[l]>0&&(i=-i),s-=r[l]*i,r[l]=r[l]-i,u=l;u<t;u++){for(o=0,a=h;a>=l;a--)o+=r[a]*e.get(a,u);for(o/=s,a=l;a<=h;a++)e.set(a,u,e.get(a,u)-o*r[a])}for(a=0;a<=h;a++){for(o=0,u=h;u>=l;u--)o+=r[u]*e.get(a,u);for(o/=s,u=l;u<=h;u++)e.set(a,u,e.get(a,u)-o*r[u])}r[l]=c*r[l],e.set(l,l-1,c*i)}}for(a=0;a<t;a++)for(u=0;u<t;u++)n.set(a,u,a===u?1:0);for(l=h-1;l>=1;l--)if(0!==e.get(l,l-1)){for(a=l+1;a<=h;a++)r[a]=e.get(a,l-1);for(u=l;u<=h;u++){for(i=0,a=l;a<=h;a++)i+=r[a]*n.get(a,u);for(i=i/r[l]/e.get(l,l-1),a=l;a<=h;a++)n.set(a,u,n.get(a,u)+i*r[a])}}}(i,t,e,s),function(t,e,r,n,o){let i,s,a,u,l,c,h,f,m,p,y,g,d,v,w,b=t-1,S=t-1,x=Number.EPSILON,M=0,O=0,E=0,j=0,A=0,N=0,P=0,_=0;for(i=0;i<t;i++)for((i<0||i>S)&&(r[i]=o.get(i,i),e[i]=0),s=Math.max(i-1,0);s<t;s++)O+=Math.abs(o.get(i,s));for(;b>=0;){for(u=b;u>0&&(N=Math.abs(o.get(u-1,u-1))+Math.abs(o.get(u,u)),0===N&&(N=O),!(Math.abs(o.get(u,u-1))<x*N));)u--;if(u===b)o.set(b,b,o.get(b,b)+M),r[b]=o.get(b,b),e[b]=0,b--,_=0;else if(u===b-1){if(h=o.get(b,b-1)*o.get(b-1,b),E=(o.get(b-1,b-1)-o.get(b,b))/2,j=E*E+h,P=Math.sqrt(Math.abs(j)),o.set(b,b,o.get(b,b)+M),o.set(b-1,b-1,o.get(b-1,b-1)+M),f=o.get(b,b),j>=0){for(P=E>=0?E+P:E-P,r[b-1]=f+P,r[b]=r[b-1],0!==P&&(r[b]=f-h/P),e[b-1]=0,e[b]=0,f=o.get(b,b-1),N=Math.abs(f)+Math.abs(P),E=f/N,j=P/N,A=Math.sqrt(E*E+j*j),E/=A,j/=A,s=b-1;s<t;s++)P=o.get(b-1,s),o.set(b-1,s,j*P+E*o.get(b,s)),o.set(b,s,j*o.get(b,s)-E*P);for(i=0;i<=b;i++)P=o.get(i,b-1),o.set(i,b-1,j*P+E*o.get(i,b)),o.set(i,b,j*o.get(i,b)-E*P);for(i=0;i<=S;i++)P=n.get(i,b-1),n.set(i,b-1,j*P+E*n.get(i,b)),n.set(i,b,j*n.get(i,b)-E*P)}else r[b-1]=f+E,r[b]=f+E,e[b-1]=P,e[b]=-P;b-=2,_=0}else{if(f=o.get(b,b),m=0,h=0,u<b&&(m=o.get(b-1,b-1),h=o.get(b,b-1)*o.get(b-1,b)),10===_){for(M+=f,i=0;i<=b;i++)o.set(i,i,o.get(i,i)-f);N=Math.abs(o.get(b,b-1))+Math.abs(o.get(b-1,b-2)),f=m=.75*N,h=-.4375*N*N}if(30===_&&(N=(m-f)/2,N=N*N+h,N>0)){for(N=Math.sqrt(N),m<f&&(N=-N),N=f-h/((m-f)/2+N),i=0;i<=b;i++)o.set(i,i,o.get(i,i)-N);M+=N,f=m=h=.964}for(_+=1,l=b-2;l>=u&&(P=o.get(l,l),A=f-P,N=m-P,E=(A*N-h)/o.get(l+1,l)+o.get(l,l+1),j=o.get(l+1,l+1)-P-A-N,A=o.get(l+2,l+1),N=Math.abs(E)+Math.abs(j)+Math.abs(A),E/=N,j/=N,A/=N,l!==u)&&!(Math.abs(o.get(l,l-1))*(Math.abs(j)+Math.abs(A))<x*(Math.abs(E)*(Math.abs(o.get(l-1,l-1))+Math.abs(P)+Math.abs(o.get(l+1,l+1)))));)l--;for(i=l+2;i<=b;i++)o.set(i,i-2,0),i>l+2&&o.set(i,i-3,0);for(a=l;a<=b-1&&(v=a!==b-1,a!==l&&(E=o.get(a,a-1),j=o.get(a+1,a-1),A=v?o.get(a+2,a-1):0,f=Math.abs(E)+Math.abs(j)+Math.abs(A),0!==f&&(E/=f,j/=f,A/=f)),0!==f);a++)if(N=Math.sqrt(E*E+j*j+A*A),E<0&&(N=-N),0!==N){for(a!==l?o.set(a,a-1,-N*f):u!==l&&o.set(a,a-1,-o.get(a,a-1)),E+=N,f=E/N,m=j/N,P=A/N,j/=E,A/=E,s=a;s<t;s++)E=o.get(a,s)+j*o.get(a+1,s),v&&(E+=A*o.get(a+2,s),o.set(a+2,s,o.get(a+2,s)-E*P)),o.set(a,s,o.get(a,s)-E*f),o.set(a+1,s,o.get(a+1,s)-E*m);for(i=0;i<=Math.min(b,a+3);i++)E=f*o.get(i,a)+m*o.get(i,a+1),v&&(E+=P*o.get(i,a+2),o.set(i,a+2,o.get(i,a+2)-E*A)),o.set(i,a,o.get(i,a)-E),o.set(i,a+1,o.get(i,a+1)-E*j);for(i=0;i<=S;i++)E=f*n.get(i,a)+m*n.get(i,a+1),v&&(E+=P*n.get(i,a+2),n.set(i,a+2,n.get(i,a+2)-E*A)),n.set(i,a,n.get(i,a)-E),n.set(i,a+1,n.get(i,a+1)-E*j)}}}if(0!==O){for(b=t-1;b>=0;b--)if(E=r[b],j=e[b],0===j)for(u=b,o.set(b,b,1),i=b-1;i>=0;i--){for(h=o.get(i,i)-E,A=0,s=u;s<=b;s++)A+=o.get(i,s)*o.get(s,b);if(e[i]<0)P=h,N=A;else if(u=i,0===e[i]?o.set(i,b,0!==h?-A/h:-A/(x*O)):(f=o.get(i,i+1),m=o.get(i+1,i),j=(r[i]-E)*(r[i]-E)+e[i]*e[i],c=(f*N-P*A)/j,o.set(i,b,c),o.set(i+1,b,Math.abs(f)>Math.abs(P)?(-A-h*c)/f:(-N-m*c)/P)),c=Math.abs(o.get(i,b)),x*c*c>1)for(s=i;s<=b;s++)o.set(s,b,o.get(s,b)/c)}else if(j<0)for(u=b-1,Math.abs(o.get(b,b-1))>Math.abs(o.get(b-1,b))?(o.set(b-1,b-1,j/o.get(b,b-1)),o.set(b-1,b,-(o.get(b,b)-E)/o.get(b,b-1))):(w=F(0,-o.get(b-1,b),o.get(b-1,b-1)-E,j),o.set(b-1,b-1,w[0]),o.set(b-1,b,w[1])),o.set(b,b-1,0),o.set(b,b,1),i=b-2;i>=0;i--){for(p=0,y=0,s=u;s<=b;s++)p+=o.get(i,s)*o.get(s,b-1),y+=o.get(i,s)*o.get(s,b);if(h=o.get(i,i)-E,e[i]<0)P=h,A=p,N=y;else if(u=i,0===e[i]?(w=F(-p,-y,h,j),o.set(i,b-1,w[0]),o.set(i,b,w[1])):(f=o.get(i,i+1),m=o.get(i+1,i),g=(r[i]-E)*(r[i]-E)+e[i]*e[i]-j*j,d=2*(r[i]-E)*j,0===g&&0===d&&(g=x*O*(Math.abs(h)+Math.abs(j)+Math.abs(f)+Math.abs(m)+Math.abs(P))),w=F(f*A-P*p+j*y,f*N-P*y-j*p,g,d),o.set(i,b-1,w[0]),o.set(i,b,w[1]),Math.abs(f)>Math.abs(P)+Math.abs(j)?(o.set(i+1,b-1,(-p-h*o.get(i,b-1)+j*o.get(i,b))/f),o.set(i+1,b,(-y-h*o.get(i,b)-j*o.get(i,b-1))/f)):(w=F(-A-m*o.get(i,b-1),-N-m*o.get(i,b),P,j),o.set(i+1,b-1,w[0]),o.set(i+1,b,w[1]))),c=Math.max(Math.abs(o.get(i,b-1)),Math.abs(o.get(i,b))),x*c*c>1)for(s=i;s<=b;s++)o.set(s,b-1,o.get(s,b-1)/c),o.set(s,b,o.get(s,b)/c)}for(i=0;i<t;i++)if(i<0||i>S)for(s=i;s<t;s++)n.set(i,s,o.get(i,s));for(s=t-1;s>=0;s--)for(i=0;i<=S;i++){for(P=0,a=0;a<=Math.min(s,S);a++)P+=n.get(i,a)*o.get(a,s);n.set(i,s,P)}}}(i,u,a,s,t)}this.n=i,this.e=u,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,r=this.n,n=this.e,o=this.d,i=new x(r,r);for(t=0;t<r;t++){for(e=0;e<r;e++)i.set(t,e,0);i.set(t,t,o[t]),n[t]>0?i.set(t,t+1,n[t]):n[t]<0&&i.set(t,t-1,n[t])}return i}}function F(t,e,r,n){let o,i;return Math.abs(r)>Math.abs(n)?(o=n/r,i=r+o*n,[(t+o*e)/i,(e-o*t)/i]):(o=r/n,i=n+o*r,[(o*t+e)/i,(o*e-t)/i])}class V{constructor(t){if(!(t=N.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,n,o=t,i=o.rows,s=new x(i,i),a=!0;for(r=0;r<i;r++){let t=0;for(n=0;n<r;n++){let i=0;for(e=0;e<n;e++)i+=s.get(n,e)*s.get(r,e);i=(o.get(r,n)-i)/s.get(n,n),s.set(r,n,i),t+=i*i}for(t=o.get(r,r)-t,a&&=t>0,s.set(r,r,Math.sqrt(Math.max(t,0))),n=r+1;n<i;n++)s.set(r,n,0)}this.L=s,this.positiveDefinite=a}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=N.checkMatrix(t);let e=this.L,r=e.rows;if(t.rows!==r)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let n,o,i,s=t.columns,a=t.clone();for(i=0;i<r;i++)for(o=0;o<s;o++){for(n=0;n<i;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(i,n));a.set(i,o,a.get(i,o)/e.get(i,i))}for(i=r-1;i>=0;i--)for(o=0;o<s;o++){for(n=i+1;n<r;n++)a.set(i,o,a.get(i,o)-a.get(n,o)*e.get(n,i));a.set(i,o,a.get(i,o)/e.get(i,i))}return a}get lowerTriangularMatrix(){return this.L}}class q{constructor(t,e={}){t=N.checkMatrix(t);let{Y:r}=e;const{scaleScores:o=!1,maxIterations:i=1e3,terminationCriteria:s=1e-10}=e;let a;if(r){if(r=n.isAnyArray(r)&&"number"==typeof r[0]?x.columnVector(r):N.checkMatrix(r),r.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=r.getColumnVector(0)}else a=t.getColumnVector(0);let u,l,c,h,f=1;for(let e=0;e<i&&f>s;e++)c=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),u=t.mmul(c).div(c.transpose().mmul(c).get(0,0)),e>0&&(f=u.clone().sub(h).pow(2).sum()),h=u.clone(),r?(l=r.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),l=l.div(l.norm()),a=r.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=u;if(r){let e=t.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0));e=e.div(e.norm());let n=t.clone().sub(u.clone().mmul(e.transpose())),o=a.transpose().mmul(u).div(u.transpose().mmul(u).get(0,0)),i=r.clone().sub(u.clone().mulS(o.get(0,0)).mmul(l.transpose()));this.t=u,this.p=e.transpose(),this.w=c.transpose(),this.q=l,this.u=a,this.s=u.transpose().mmul(u),this.xResidual=n,this.yResidual=i,this.betas=o}else this.w=c.transpose(),this.s=u.transpose().mmul(u).sqrt(),this.t=o?u.clone().div(this.s.get(0,0)):u,this.xResidual=t.sub(u.mmul(c.transpose()))}}e.y3=b,e.jy=V,e.oN=V,e.Hc=O,e.cg=D,e.hj=D,e.LU=P,e.Tb=P,e.uq=x,e.Zm=class extends E{constructor(t,e){y(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},e.Dq=class extends E{constructor(t,e){h(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}},e.__=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},e.q0=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},e.lh=class extends E{constructor(t,e){p(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},e.pI=class extends E{constructor(t,e){c(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}},e.zC=j,e.zg=class extends E{constructor(t,e,r,n,o){g(t,e,r,n,o),super(t,r-e+1,o-n+1),this.startRow=e,this.startColumn=n}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},e.g6=class extends E{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}},e.OL=q,e.ks=q,e.QR=T,e.jp=T,e.mk=k,e.W2=k,e.l=M,e.KY=A,e.dv=N,e.BR=function(t,e=t,r={}){t=new x(t);let o=!1;if("object"!=typeof e||x.isMatrix(e)||n.isAnyArray(e)?e=new x(e):(r=e,e=t,o=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:s=!0}=r;i&&(t.center("column"),o||e.center("column")),s&&(t.scale("column"),o||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),u=o?a:e.standardDeviation("column",{unbiased:!0}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let r=0;r<l.columns;r++)l.set(e,r,l.get(e,r)*(1/(a[e]*u[r]))*(1/(t.rows-1)));return l},e.Wu=function(t,e=t,r={}){t=new x(t);let o=!1;if("object"!=typeof e||x.isMatrix(e)||n.isAnyArray(e)?e=new x(e):(r=e,e=t,o=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=r;i&&(t=t.center("column"),o||(e=e.center("column")));const s=t.transpose().mmul(e);for(let e=0;e<s.rows;e++)for(let r=0;r<s.columns;r++)s.set(e,r,s.get(e,r)*(1/(t.rows-1)));return s},e.a4=function t(e){if((e=x.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let r,n,o,i;if(2===e.columns)return r=e.get(0,0),n=e.get(0,1),o=e.get(1,0),i=e.get(1,1),r*i-n*o;if(3===e.columns){let i,s,a;return i=new j(e,[1,2],[1,2]),s=new j(e,[1,2],[0,2]),a=new j(e,[1,2],[0,1]),r=e.get(0,0),n=e.get(0,1),o=e.get(0,2),r*t(i)-n*t(s)+o*t(a)}return new P(e).determinant}throw Error("determinant can only be calculated for a square matrix")},e.DI=function(t,e=!1){return t=N.checkMatrix(t),e?new k(t).inverse():I(t,x.eye(t.rows))},e.Jo=function(t,e={}){const{thresholdValue:r=1e-9,thresholdError:n=1e-9}=e;let o=(t=x.checkMatrix(t)).rows,i=new x(o,o);for(let e=0;e<o;e++){let s=x.columnVector(t.getRow(e)),a=t.subMatrixRow(R(o,e)).transpose(),u=new k(a).solve(s),l=x.sub(s,a.mmul(u)).abs().max();i.setRow(e,C(l,u,e,r,n))}return i},e.Zi=function(t,e=Number.EPSILON){if((t=x.checkMatrix(t)).isEmpty())return t.transpose();let r=new k(t,{autoTranspose:!0}),n=r.leftSingularVectors,o=r.rightSingularVectors,i=r.diagonal;for(let t=0;t<i.length;t++)Math.abs(i[t])>e?i[t]=1/i[t]:i[t]=0;return o.mmul(x.diag(i).mmul(n.transpose()))},e.kH=I,e.LV=function(t,e){if(n.isAnyArray(t))return t[0]&&n.isAnyArray(t[0])?new N(t):new A(t,e);throw new Error("the argument is not an array")}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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 s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function o(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r.r(n),r.d(n,{default:()=>jr});var s=function(t,r){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var n,o=e(t);try{for(o.s();!(n=o.n()).done;){var i,s=e(n.value.params);try{for(s.s();!(i=s.n()).done;){var a=i.value;if("number"==typeof a&&a>r)throw console.log(a,r),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){s.e(t)}finally{s.f()}}}catch(t){o.e(t)}finally{o.f()}},a=function(t){if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" , "getDataAsCols" or "getData" methods are called.')},u=function(t,e,r){if(!Array.isArray(t))throw new Error('Param "'.concat(e,'" must be an array in "').concat(r,'".'));return!0},l=function(e,r,n){if(!Boolean(e)||"object"==!t(e))throw new Error('Param "'.concat(r,'" must be an object in "').concat(n,'".'));return!0},c=function(t,e,r,n){if(u(t,"arrayOptions","".concat(n,".").concat(r,".validateArrayOptions")),!t.includes(e.toString()))throw new Error('Param "'.concat(r,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},h=function(t,e,r){if("boolean"!=typeof t)throw new Error('Param "'.concat(e,'" must be an boolean in "').concat(r,'".'));return!0},f=function(t,e,r,n){l(e,"options","".concat(n,".").concat(r,".validateNumber"));var o=e.allowDecimals,i=void 0!==o&&o,s=e.min,a=e.max,u=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(r,'" must be an integer in "').concat(n,'".'));if("number"!=typeof s||"number"!=typeof a||s>=a)throw new Error('Param "min" must be a valid '.concat(u,' lower than "max" "').concat(n,".").concat(r,'.validateNumber".'));if(t<s)throw new Error('Param "'.concat(r,'" must be an ').concat(u," greater than or equal to ").concat(s,' in "').concat(n,'".'));if(t>a)throw new Error('Param "'.concat(r,'" must be an ').concat(u," lower than or equal to ").concat(a,' in "').concat(n,'".'));return!0},m=1e6,p="[big.js] ",y=p+"Invalid ",g=y+"decimal places",d=y+"rounding mode",v=p+"Division by zero",w={},b=void 0,S=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function x(t,e,r,n){var o=t.c;if(r===b&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(d);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==b))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==b||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function M(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function O(t){return O="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},O(t)}function E(t){var e="function"==typeof Map?new Map:void 0;return E=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(j())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&A(o,r.prototype),o}(t,arguments,N(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),A(r,t)},E(t)}function j(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(j=function(){return!!t})()}function A(t,e){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},A(t,e)}function N(t){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},N(t)}w.abs=function(){var t=new this.constructor(this);return t.s=1,t},w.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,s=t.s,a=r.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-s:0;if(i!=s)return i;if(e=i<0,a!=u)return a>u^e?1:-1;for(s=(a=n.length)<(u=o.length)?a:u,i=-1;++i<s;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return a==u?0:a>u^e?1:-1},w.div=function(t){var e=this,r=e.constructor,n=e.c,o=(t=new r(t)).c,i=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>m)throw Error(g);if(!o[0])throw Error(v);if(!n[0])return t.s=i,t.c=[t.e=0],t;var a,u,l,c,h,f=o.slice(),p=a=o.length,y=n.length,d=n.slice(0,a),w=d.length,S=t,M=S.c=[],O=0,E=s+(S.e=e.e-t.e)+1;for(S.s=i,i=E<0?0:E,f.unshift(0);w++<a;)d.push(0);do{for(l=0;l<10;l++){if(a!=(w=d.length))c=a>w?1:-1;else for(h=-1,c=0;++h<a;)if(o[h]!=d[h]){c=o[h]>d[h]?1:-1;break}if(!(c<0))break;for(u=w==a?o:f;w;){if(d[--w]<u[w]){for(h=w;h&&!d[--h];)d[h]=9;--d[h],d[w]+=10}d[w]-=u[w]}for(;!d[0];)d.shift()}M[O++]=c?l:++l,d[0]&&c?d[w]=n[p]||0:d=[n[p]]}while((p++<y||d[0]!==b)&&i--);return M[0]||1==O||(M.shift(),S.e--,E--),O>E&&x(S,E,r.RM,d[0]!==b),S},w.eq=function(t){return 0===this.cmp(t)},w.gt=function(t){return this.cmp(t)>0},w.gte=function(t){return this.cmp(t)>-1},w.lt=function(t){return this.cmp(t)<0},w.lte=function(t){return this.cmp(t)<1},w.minus=w.sub=function(t){var e,r,n,o,i=this,s=i.constructor,a=i.s,u=(t=new s(t)).s;if(a!=u)return t.s=-u,i.plus(t);var l=i.c.slice(),c=i.e,h=t.c,f=t.e;if(!l[0]||!h[0])return h[0]?t.s=-u:l[0]?t=new s(i):t.s=1,t;if(a=c-f){for((o=a<0)?(a=-a,n=l):(f=c,n=h),n.reverse(),u=a;u--;)n.push(0);n.reverse()}else for(r=((o=l.length<h.length)?l:h).length,a=u=0;u<r;u++)if(l[u]!=h[u]){o=l[u]<h[u];break}if(o&&(n=l,l=h,h=n,t.s=-t.s),(u=(r=h.length)-(e=l.length))>0)for(;u--;)l[e++]=0;for(u=e;r>a;){if(l[--r]<h[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=h[r]}for(;0===l[--u];)l.pop();for(;0===l[0];)l.shift(),--f;return l[0]||(t.s=1,l=[f=0]),t.c=l,t.e=f,t},w.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(v);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},w.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},w.plus=w.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var s=o.e,a=o.c,u=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new i(o):t.s=o.s),t;if(a=a.slice(),e=s-u){for(e>0?(u=s,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+l[e]+r)/10|0;for(r&&(a.unshift(r),++u),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=u,t},w.pow=function(t){var e=this,r=new e.constructor("1"),n=r,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(y+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},w.prec=function(t,e){if(t!==~~t||t<1||t>m)throw Error(y+"precision");return x(new this.constructor(this),t,e)},w.round=function(t,e){if(t===b)t=0;else if(t!==~~t||t<-m||t>m)throw Error(g);return x(new this.constructor(this),t+this.e+1,e)},w.sqrt=function(){var t,e,r,n=this,o=n.constructor,i=n.s,s=n.e,a=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(p+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((e=n.c.join("")).length+s&1||(e+="0"),s=((s+1)/2|0)-(s<0||1&s),t=new o(((i=Math.sqrt(e))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+s)):t=new o(i+""),s=t.e+(o.DP+=4);do{r=t,t=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join("")!==t.c.slice(0,s).join(""));return x(t,(o.DP-=4)+t.e+1,o.RM)},w.times=w.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,s=o.length,a=i.length,u=r.e,l=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+l,s<a&&(e=o,o=i,i=e,l=s,s=a,a=l),e=new Array(l=s+a);l--;)e[l]=0;for(u=a;u--;){for(a=0,l=s+u;l>u;)a=e[l]+i[u]*o[l-u-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},w.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==b){if(t!==~~t||t<0||t>m)throw Error(g);for(r=x(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return M(r,!0,!!n)},w.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==b){if(t!==~~t||t<0||t>m)throw Error(g);for(t=t+(r=x(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length<t;)r.c.push(0)}return M(r,!1,!!n)},w[Symbol.for("nodejs.util.inspect.custom")]=w.toJSON=w.toString=function(){var t=this,e=t.constructor;return M(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},w.toNumber=function(){var t=Number(M(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(p+"Imprecise conversion");return t},w.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==b){if(t!==~~t||t<1||t>m)throw Error(y+"precision");for(r=x(new n(r),t,e);r.c.length<t;)r.c.push(0)}return M(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!o)},w.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(p+"valueOf disallowed");return M(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===b?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(y+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!S.test(e))throw Error(y+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=w,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var P=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=N(e),function(t,e){if(e&&("object"==O(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)}(t,j()?Reflect.construct(e,r||[],N(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(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&&A(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(E(Error));function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function T(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,I(n.key),n)}}function k(t,e,r){return(e=I(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function I(t){var e=function(t,e){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(e)?e:e+""}var R=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),k(this,"previousHighest",void 0),k(this,"highest",void 0),k(this,"previousLowest",void 0),k(this,"lowest",void 0),k(this,"previousResult",void 0),k(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new P;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&T(t.prototype,e),r&&T(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function C(t){return C="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},C(t)}function D(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,z(n.key),n)}}function F(t,e,r){return e=q(e),function(t,e){if(e&&("object"==C(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)}(t,V()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function L(t,e){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},L(t,e)}function z(t){var e=function(t,e){if("object"!=C(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=C(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==C(e)?e:e+""}var U=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=F(this,e),i=void 0,(o=z(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(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&&L(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&D(r.prototype,n),o&&D(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function $(t){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(t)}function B(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function H(t,e,r){return e=G(e),function(t,e){if(e&&("object"==$(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)}(t,Y()?Reflect.construct(e,r||[],G(t).constructor):e.apply(t,r))}function Y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Y=function(){return!!t})()}function G(t){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},G(t)}function K(t,e){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},K(t,e)}function W(t){var e=function(t,e){if("object"!=$(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$(e)?e:e+""}var J=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return r=t=H(this,e,[].concat(s)),o=[],(n=W(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(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&&K(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&B(r.prototype,n),o&&B(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(U);function Q(t){return Q="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},Q(t)}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ot(n.key),n)}}function X(t,e,r){return e=et(e),function(t,e){if(e&&("object"==Q(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)}(t,tt()?Reflect.construct(e,r||[],et(t).constructor):e.apply(t,r))}function tt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tt=function(){return!!t})()}function et(t){return et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},et(t)}function rt(t,e){return rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rt(t,e)}function nt(t,e,r){return(e=ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ot(t){var e=function(t,e){if("object"!=Q(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(e)?e:e+""}var it=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),nt(r=X(this,e),"interval",void 0),nt(r,"indicator",void 0),nt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new J(t),r.smoothingFactor=1/r.interval,r}return function(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&&rt(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&Z(r.prototype,n),o&&Z(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function st(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function at(t){return at="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},at(t)}function ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,pt(n.key),n)}}function lt(t,e,r){return e=ht(e),function(t,e){if(e&&("object"==at(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)}(t,ct()?Reflect.construct(e,r||[],ht(t).constructor):e.apply(t,r))}function ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ct=function(){return!!t})()}function ht(t){return ht=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ht(t)}function ft(t,e){return ft=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ft(t,e)}function mt(t,e,r){return(e=pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pt(t){var e=function(t,e){if("object"!=at(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=at(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==at(e)?e:e+""}var yt=function(t){function e(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return mt(t=lt(this,e,[].concat(n)),"previousCandle",void 0),mt(t,"twoPreviousCandle",void 0),t}return function(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&&ft(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.high,n=t.low,o=r-n;if(this.previousCandle&&e&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(r-this.previousCandle.close),s=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,s),e)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,e)}}],n&&ut(r.prototype,n),o&&ut(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function gt(t){return gt="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},gt(t)}function dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Mt(n.key),n)}}function vt(t,e,r){return e=bt(e),function(t,e){if(e&&("object"==gt(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)}(t,wt()?Reflect.construct(e,r||[],bt(t).constructor):e.apply(t,r))}function wt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wt=function(){return!!t})()}function bt(t){return bt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bt(t)}function St(t,e){return St=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},St(t,e)}function xt(t,e,r){return(e=Mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mt(t){var e=function(t,e){if("object"!=gt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var Ot=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),xt(r=vt(this,e),"interval",void 0),xt(r,"tr",void 0),xt(r,"smoothing",void 0),r.interval=t,r.tr=new yt,r.smoothing=new n(t),r}return function(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&&St(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tr.update(t,e);if(this.smoothing.update(r,e),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),e)}}],n&&dt(r.prototype,n),o&&dt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function Et(t){return Et="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},Et(t)}function jt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nt(n.key),n)}}function At(t,e,r){return(e=Nt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Nt(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}var Pt=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),At(this,"interval",void 0),At(this,"deviationMultiplier",void 0),At(this,"prices",[]),At(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=st(this.prices),r=function(t,e){var r=e||st(t),n=st(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new P;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&jt(t.prototype,e),r&&jt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function _t(t){return _t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_t(t)}function Tt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ft(n.key),n)}}function kt(t,e,r){return e=Rt(e),function(t,e){if(e&&("object"==_t(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)}(t,It()?Reflect.construct(e,r||[],Rt(t).constructor):e.apply(t,r))}function It(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(It=function(){return!!t})()}function Rt(t){return Rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rt(t)}function Ct(t,e){return Ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ct(t,e)}function Dt(t,e,r){return(e=Ft(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ft(t){var e=function(t,e){if("object"!=_t(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}var Vt=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Dt(r=kt(this,e,[t]),"interval",void 0),Dt(r,"pricesCounter",0),Dt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(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&&Ct(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new P;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&Tt(r.prototype,n),o&&Tt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(U);function qt(t){return qt="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},qt(t)}function Lt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ut(n.key),n)}}function zt(t,e,r){return(e=Ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ut(t){var e=function(t,e){if("object"!=qt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}var $t=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),zt(this,"short",void 0),zt(this,"long",void 0),zt(this,"signal",void 0),zt(this,"prices",[]),zt(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new P;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&Lt(t.prototype,e),r&&Lt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Ht(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qt(n.key),n)}}function Yt(t,e,r){return e=Kt(e),function(t,e){if(e&&("object"==Bt(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)}(t,Gt()?Reflect.construct(e,r||[],Kt(t).constructor):e.apply(t,r))}function Gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Gt=function(){return!!t})()}function Kt(t){return Kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Kt(t)}function Wt(t,e){return Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wt(t,e)}function Jt(t,e,r){return(e=Qt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Qt(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}var Zt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Jt(r=Yt(this,e),"interval",void 0),Jt(r,"previousPrices",[]),Jt(r,"avgGain",void 0),Jt(r,"avgLoss",void 0),Jt(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(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&&Wt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&Ht(r.prototype,n),o&&Ht(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(R);function Xt(t){return Xt="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},Xt(t)}function te(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Xt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ee={ema:Vt,sma:J},re=function(t,e,r,n,o){var i=o.target,s=(o.lag,o.precomputed),a=t.verticalOhlcv,u=t.instances,l=s.keyName;if(0===e&&!a.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(r,"."));var c=a[i][e],h=u[l];h.update(c);var f=NaN;try{f=h.getResult()}catch(t){}return t.pushToMain({index:e,key:l,value:f}),!0},ne=function(t){var e=t.main,r=t.size,n=t.target,o=t.lag,i=t.methodName,s=e.instances,a=e.verticalOhlcv,u=e.priceBased,l=e.arrayTypes,c=e.len,h="close"!==n?"_".concat(n):"",f="".concat(i,"_").concat(r).concat(h);return s[f]=new ee[i](r),a[f]=new Float64Array(c).fill(NaN),u.add(f),o>0&&e.lag([f],o),l[f]="Float64Array",{keyName:f}};function oe(t){return oe="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},oe(t)}function ie(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function se(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ae="close";function ue(t){return ue="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},ue(t)}var le={number:function(t){return t},numberCleanString:function(t){return Number(t)},numberDirtyString:function(t){return Number(t.replace(/(?!^-)[^0-9.]/g,""))}},ce=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"==typeof t&&!Number.isNaN(t))return"number";if("string"==typeof t){var r=t.trim(),n=/^-?\d+(\.\d+)?$/;if(n.test(r))return"numberCleanString";var o=r.replace(/[^0-9.]/g,"");if(o&&n.test(o))return"numberDirtyString"}if(e)throw new TypeError("Invalid input: expected a number or numeric string");return ue(t)},he=function(t,e){var r=Math.pow(10,e);return Math.round((t+Number.EPSILON)*r)/r};function fe(t){return function(t){if(Array.isArray(t))return pe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||me(t)||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 me(t,e){if(t){if("string"==typeof t)return pe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pe(t,e):void 0}}function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ye(t){return ye="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},ye(t)}function ge(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function de(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=ye(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ye(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ye(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ve(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return we(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?we(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function we(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function be(t){return be="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},be(t)}function Se(t){return Se="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},Se(t)}var xe={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},Me={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},Oe=function(t){var e=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],r=function(){throw new Error('Invalid "'.concat(Se(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(e.join("\n- ")))};if("object"===Se(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";r()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";r()}else r()}};function Ee(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return je(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?je(t,e):void 0}}(t,e)||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 je(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ae=new Set(["open","high","low","close"]),Ne=function(t,e){return"Array"===t?new Array(e).fill(null):"Float64Array"===t?new Float64Array(e).fill(NaN):"Int32Array"===t?new Int32Array(e).fill(NaN):void 0};function Pe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||Te(t,e)||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 _e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Te(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Te(t,e){if(t){if("string"==typeof t)return ke(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ke(t,e):void 0}}function ke(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ie=function(t,e){var r=t.instances,n=t.verticalOhlcv,o=t.len,i=t.arrayTypes,s=t.priceBased;if(0===e){var a,u=[],l=_e(t.inputParams);try{for(l.s();!(a=l.n()).done;){var c=a.value;"lag"===c.key&&u.push(c.params)}}catch(t){l.e(t)}finally{l.f()}for(var h=0,f=u;h<f.length;h++){var m,p=Pe(f[h],2),y=p[0],g=p[1],d=_e(y);try{for(d.s();!(m=d.n()).done;){var v=m.value;if(s.has(v))for(var w=1;w<=g;w++)s.add("".concat(v,"_lag_").concat(w))}}catch(t){d.e(t)}finally{d.f()}}r.lag={lagParams:u}}var b,S=_e(r.lag.lagParams);try{for(S.s();!(b=S.n()).done;){var x,M=Pe(b.value,2),O=M[0],E=M[1],j=_e(O);try{for(j.s();!(x=j.n()).done;){var A=x.value,N=n[A];if(0===e)for(var P=1;P<=E;P++){var _="".concat(A,"_lag_").concat(P);if(!i.hasOwnProperty(A))throw new Error('Lag processing invoked by "'.concat(A,'" expected arrayTypes to have a "').concat(A,'" property, but it wasn’t found.'));n[_]=Ne(i[A],o),i[_]=i[A]}for(var T=1;T<=E;T++){var k="".concat(A,"_lag_").concat(T),I=e-T,R=I<=0||void 0===N[I]?null:N[I];t.pushToMain({index:e,key:k,value:R})}}}catch(t){j.e(t)}finally{j.f()}}}catch(t){S.e(t)}finally{S.f()}return!0};function Re(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ce(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ce(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Ce(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function De(t){return De="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},De(t)}function Fe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ve(n.key),n)}}function Ve(t){var e=function(t,e){if("object"!=De(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=De(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==De(e)?e:e+""}var qe=function(t,e){return t>e},Le=function(t,e){return t<e},ze=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1,crossIndexes:{up:[],down:[]}})},(e=[{key:"update",value:function(t,e){var r=e.fast,n=e.high,o=e.slow,i=e.low,s=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(r)||Number.isNaN(o)||function(t,e){return t===e}(r,o)?s=.5:qe(r,o)?s=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&Le(i,o)&&qe(this.prevLow,this.prevSlow)?0:1:Le(r,o)&&(s=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&qe(n,o)&&Le(this.prevHigh,this.prevSlow)?1:0),.5===s?this.interval=0:1===s?this.prevState<=.5?this.interval=1:this.interval++:0===s&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(t),-1===this.interval&&this.crossIndexes.down.push(t),Object.assign(this,{prevState:s,prevFast:r,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&Fe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ue=function(t,e){var r=t.verticalOhlcv,n=t.instances,o=t.len,i=t.arrayTypes,s=t.verticalOhlcvTempCols;if(0===e){var a=t.inputParams;n.crossPairsList=a.reduce((function(t,e){var r=e.key,n=e.params;if("crossPairs"===r){var o,i=Re(n);try{for(i.s();!(o=i.n()).done;){var s,a=Re(o.value);try{for(a.s();!(s=a.n()).done;){var u=s.value;t.push(u)}}catch(t){a.e(t)}finally{a.f()}}}catch(t){i.e(t)}finally{i.f()}}return t}),[])}var u,l=Re(n.crossPairsList);try{for(l.s();!(u=l.n()).done;){var c=u.value,h=c.fast,f=c.slow;if(null!=h&&null!=f){var m="".concat(h,"_x_").concat(f);if(0===e){if("number"==typeof f&&(s.add(f.toString()),r[f.toString()]=new Int32Array(o).fill(f)),"price"!==h&&!r.hasOwnProperty(h))throw Error('fast "'.concat(h,' not found in crossPairs"'));if(!r.hasOwnProperty(f))throw Error('slow "'.concat(f,' not found in crossPairs"'));n[m]=new ze,r[m]=new Int32Array(o).fill(NaN),i[m]="Int32Array"}var p=void 0,y=void 0,g=void 0,d=void 0,v=void 0;"price"===h?(y=r.close[e],g=r.high[e],d=r.low[e],v=r[f][e],n[m].update(e,{fast:y,slow:v,high:g,low:d})):(p=r[h][e],v=r[f][e],n[m].update(e,{fast:p,slow:v})),t.pushToMain({index:e,key:m,value:n[m].getResult()})}}}catch(t){l.e(t)}finally{l.f()}};function $e(t){return $e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$e(t)}function Be(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function He(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=$e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$e(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ye(t){return function(t){if(Array.isArray(t))return We(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ke(t)||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 Ge(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ke(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Ke(t,e){if(t){if("string"==typeof t)return We(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?We(t,e):void 0}}function We(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Je=r(673);Je.y3,Je.jy,Je.oN,Je.Hc;const Qe=Je.cg,Ze=(Je.hj,Je.LU,Je.Tb,Je.uq),Xe=(Je.Zm,Je.Dq,Je.__,Je.q0,Je.lh,Je.pI,Je.zC,Je.zg,Je.g6),tr=Je.OL,er=(Je.ks,Je.QR,Je.jp,Je.mk);Je.W2,Je.l,Je.KY,Je.dv,Je.BR,Je.Wu,Je.uq,Je.uq,Je.a4,Je.DI,Je.Jo,Je.Zi,Je.kH,Je.LV;class rr{constructor(t,e={},r){if(this.U=null,this.S=null,r)return this.center=r.center,this.scale=r.scale,this.means=r.means,this.stdevs=r.stdevs,this.U=Ze.checkMatrix(r.U),this.S=r.S,this.R=r.R,void(this.excludedFeatures=r.excludedFeatures||[]);let n;Array.isArray(t),n=new Ze(t);const{isCovarianceMatrix:o=!1,method:i="SVD",nCompNIPALS:s=2,center:a=!0,scale:u=!1,ignoreZeroVariance:l=!1}=e;if(this.center=a,this.scale=u,this.means=null,this.stdevs=null,this.excludedFeatures=[],o)this._computeFromCovarianceMatrix(n);else switch(this._adjust(n,l),i){case"covarianceMatrix":{const t=new Xe(n).mmul(n).div(n.rows-1);this._computeFromCovarianceMatrix(t);break}case"NIPALS":this._computeWithNIPALS(n,s);break;case"SVD":{const t=new er(n,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=t.rightSingularVectors;const e=t.diagonal,r=[];for(const t of e)r.push(t*t/(n.rows-1));this.S=r;break}default:throw new Error(`unknown method: ${i}`)}}static load(t){if("string"!=typeof t.name)throw new TypeError("model must have a name property");if("PCA"!==t.name)throw new RangeError(`invalid model: ${t.name}`);return new rr(void 0,void 0,t)}predict(t,e={}){const{nComponents:r=this.U.columns}=e;let n;if(Array.isArray(t),n=new Ze(t),this.center&&(n.subRowVector(this.means),this.scale)){for(let t of this.excludedFeatures)n.removeColumn(t);n.divRowVector(this.stdevs)}let o=n.mmul(this.U);return o.subMatrix(0,o.rows-1,0,r-1)}invert(t){let e=(t=Ze.checkMatrix(t)).mmul(this.U.transpose());return this.center&&(this.scale&&e.mulRowVector(this.stdevs),e.addRowVector(this.means)),e}getExplainedVariance(){let t=0;if(this.S)for(const e of this.S)t+=e;return this.S?this.S.map((e=>e/t)):[]}getCumulativeVariance(){let t=this.getExplainedVariance();for(let e=1;e<t.length;e++)t[e]+=t[e-1];return t}getEigenvectors(){return this.U}getEigenvalues(){return this.S}getStandardDeviations(){return this.S.map((t=>Math.sqrt(t)))}getLoadings(){return this.U.transpose()}toJSON(){return{name:"PCA",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,U:this.U,S:this.S,excludedFeatures:this.excludedFeatures}}_adjust(t,e){if(this.center){const r=t.mean("column"),n=this.scale?t.standardDeviation("column",{mean:r}):null;if(this.means=r,t.subRowVector(r),this.scale){for(let r=0;r<n.length;r++)if(0===n[r]){if(!e)throw new RangeError(`Cannot scale the dataset (standard deviation is zero at index ${r}`);t.removeColumn(r),n.splice(r,1),this.excludedFeatures.push(r),r--}this.stdevs=n,t.divRowVector(n)}}}_computeFromCovarianceMatrix(t){const e=new Qe(t,{assumeSymmetric:!0});this.U=e.eigenvectorMatrix,this.U.flipRows(),this.S=e.realEigenvalues,this.S.reverse()}_computeWithNIPALS(t,e){this.U=new Ze(e,t.columns),this.S=[];let r=t;for(let t=0;t<e;t++){let e=new tr(r);this.U.setRow(t,e.w.transpose()),this.S.push(Math.pow(e.s.get(0,0),2)),r=e.xResidual}this.U=this.U.transpose()}}function nr(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=or(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function or(t,e){if(t){if("string"==typeof t)return ir(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ir(t,e):void 0}}function ir(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function sr(t){return function(t){if(Array.isArray(t))return lr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ur(t)||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 ar(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ur(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function ur(t,e){if(t){if("string"==typeof t)return lr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?lr(t,e):void 0}}function lr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var cr={dateTime:function(t,e,r){var n=r.lag,o=t.instances,i=t.verticalOhlcv;if(0===e){var s=t.len,a=t.dateType,u=t.arrayTypes;if(!a)throw Error('dateTime method found and invalid "date" in input ohlcv');Object.assign(o,{dateTime:{prevDateStr:i.date[0],sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:i.date[0]}});for(var l=["day_of_the_week","day_of_the_month","week_of_the_month","minute","hour","month","year","session_daily_index","session_intraday_index"],c=0,h=l;c<h.length;c++)u[h[c]]="Int32Array";Object.assign(i,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Be(Object(r),!0).forEach((function(e){He(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Be(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},Object.fromEntries(l.map((function(t){return[t,new Int32Array(s).fill(NaN)]}))))),n>0&&t.lag(l,n)}var f=i.date[e],m=function(t){var e=t.getMonth(),r=t.getFullYear(),n=t.getHours(),o=t.getMinutes(),i=t.getDay(),s=t.getDate(),a=new Date(t.getFullYear(),t.getMonth(),1).getDay();return{month:e,year:r,hour:n,minute:o,day_of_the_week:i,day_of_the_month:s,week_of_the_month:Math.ceil((s+a)/7)}}(f),p=m.day_of_the_week,y=m.day_of_the_month,g=m.week_of_the_month,d=m.month,v=m.year,w=m.hour,b=m.minute,S=f;S!==o.dateTime.prevDateStr&&(o.dateTime.prevDateStr=S,o.dateTime.sessionDailyIndexCount++,o.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:o.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:o.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:p}),t.pushToMain({index:e,key:"day_of_the_month",value:y}),t.pushToMain({index:e,key:"week_of_the_month",value:g}),t.pushToMain({index:e,key:"month",value:d}),t.pushToMain({index:e,key:"year",value:v}),t.pushToMain({index:e,key:"hour",value:w}),t.pushToMain({index:e,key:"minute",value:b}),o.dateTime.sessionIntradayIndexCount++},rsi:function(t,e,r,n){var o=n.target,i=n.lag,s=t.verticalOhlcv,a=t.instances,u="close"===o?"":"_".concat(o),l="rsi_".concat(r).concat(u),c="rsi_sma_".concat(r).concat(u);if(0===e){var h=t.crossPairsList,f=t.len,m=t.arrayTypes;if(!s.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));h.push({fast:l,slow:c,isDefault:!0}),Object.assign(a,te(te({},l,new Zt(r)),c,new J(r))),Object.assign(s,te(te({},l,new Float64Array(f).fill(NaN)),c,new Float64Array(f).fill(NaN)));var p=[l,c];i>0&&t.lag(p,i);for(var y=0,g=p;y<g.length;y++)m[g[y]]="Float64Array"}var d=s[o][e],v=NaN,w=NaN;a[l].update(d);try{v=a[l].getResult()}catch(t){v=NaN}t.pushToMain({index:e,key:l,value:v}),Number.isNaN(v)||a[c].update(v);try{w=a[c].getResult()}catch(t){w=NaN}t.pushToMain({index:e,key:c,value:w})},atr:function(t,e,r,n){var o=n.lag,i=n.percentage,s=n.upper,a=n.lower,u=t.verticalOhlcv,l=t.instances,c="atr_".concat(r);if(0===e){var h=t.instances,f=t.verticalOhlcv,m=t.arrayTypes,p=t.len,y=t.priceBased;h[c]=new Ot(r,it);var g=[c];i&&g.push("".concat(c,"_percentage")),null!==s&&g.push("".concat(c,"_upper")),null!==a&&g.push("".concat(c,"_lower"));for(var d=0,v=g;d<v.length;d++){var w=v[d];w.endsWith("_percentage")||y.add(w),f[w]=new Float64Array(p).fill(NaN),m[w]="Float64Array"}o>0&&t.lag(g,o)}var b={high:u.high[e],low:u.low[e],close:u.close[e]},S=l[c];S.update(b);var x=NaN;try{x=S.getResult()}catch(t){}if(i){var M=Number.isNaN(x)?NaN:x/b.close;t.pushToMain({index:e,key:"".concat(c,"_percentage"),value:M})}if(null!==s){var O=Number.isNaN(x)?NaN:b.close+x*s;t.pushToMain({index:e,key:"".concat(c,"_upper"),value:O})}if(null!==a){var E=Number.isNaN(x)?NaN:b.close-x*a;t.pushToMain({index:e,key:"".concat(c,"_lower"),value:E})}return t.pushToMain({index:e,key:c,value:x}),!0},ema:re,sma:re,macd:function(t,e,r,n,o,i){var s=i.target,a=i.lag,u=i.precomputed,l=t.verticalOhlcv,c=t.instances,h=u.instanceKey;if(0===e){var f=t.inputParams,m=t.crossPairsList,p=t.priceBased,y=t.len,g=t.arrayTypes;if(!l.hasOwnProperty(s))throw new Error("Target property ".concat(s," not found in verticalOhlcv for macd."));var d,v=0,w=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return se(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?se(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(f);try{for(w.s();!(d=w.n()).done;)"macd"===d.value.key&&v++}catch(t){w.e(t)}finally{w.f()}var b=v>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",S=s===ae?"".concat(b,"_diff"):"".concat(b,"_diff_").concat(s),x=s===ae?"".concat(b,"_dea"):"".concat(b,"_dea_").concat(s),M=s===ae?"".concat(b,"_histogram"):"".concat(b,"_histogram_").concat(s);m.push({fast:S,slow:x,isDefault:!0}),c.hasOwnProperty("macd")||(c.macd={numberOfIndicators:v,settings:{}}),c.macd.settings[h]=new $t(new Vt(r),new Vt(n),new Vt(o)),Object.assign(l,ie(ie(ie({},S,new Float64Array(y).fill(NaN)),x,new Float64Array(y).fill(NaN)),M,new Float64Array(y).fill(NaN)))[M].forEach((function(t){p.add(t)}));var O=[S,x,M];a>0&&t.lag(O,a);for(var E=0,j=O;E<j.length;E++)g[j[E]]="Float64Array"}var A=c.macd,N=A.numberOfIndicators,P=A.settings,_=N>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",T=s===ae?"".concat(_,"_diff"):"".concat(_,"_diff_").concat(s),k=s===ae?"".concat(_,"_dea"):"".concat(_,"_dea_").concat(s),I=s===ae?"".concat(_,"_histogram"):"".concat(_,"_histogram_").concat(s),R=P[h],C=l[s][e];R.update(C);var D={};try{D=R.getResult()}catch(t){}return t.pushToMain({index:e,key:T,value:D?D.macd:NaN}),t.pushToMain({index:e,key:k,value:D?D.signal:NaN}),t.pushToMain({index:e,key:I,value:D?D.histogram:NaN}),!0},relativeVolume:function(t,e,r,n){var o=n.lag,i="relative_volume_".concat(r),s=t.instances,a=t.verticalOhlcv;if(0===e){var u=t.len,l=t.arrayTypes;s[i]={instance:new J(r),prevRelativeVolumeSma:NaN},a[i]=new Float64Array(u).fill(NaN),o>0&&t.lag([i],o),l[i]="Float64Array"}var c=a.volume[e],h=s[i].instance;h.update(c);var f=NaN;try{f=h.getResult()}catch(t){}var m=s[i].prevRelativeVolumeSma,p=NaN;return Number.isNaN(f)||Number.isNaN(m)||(p=c/m),t.pushToMain({index:e,key:i,value:p}),s[i].prevRelativeVolumeSma=f,!0},donchianChannels:function(t,e,r,n,o){var i=t.verticalOhlcv,s=t.instances,a=t.len,u=t.inputParams,l=t.priceBased,c=t.arrayTypes,h=t.lag,f=o.height,m=o.range,p=o.decimals,y="".concat(r,"_").concat(n);if(0===e){var g=u.filter((function(t){return"donchianChannels"===t.key})).length,d="donchian_channel",v=g>1?"".concat(d,"_").concat(y):d,w=["upper","basis","lower"].map((function(t){return"".concat(v,"_").concat(t)}));f&&w.push("".concat(v,"_height"));var b,S=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=me(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(m);try{for(S.s();!(b=S.n()).done;){var x=b.value;if(!(x in i)||!l.has(x))throw new Error('Invalid range key "'.concat(x,'". Only price-based keys are allowed: ').concat(fe(l)));w.push("".concat(v,"_range_").concat(x))}}catch(t){S.e(t)}finally{S.f()}s.donchian_channel||(s.donchian_channel={numberOfIndicators:g,settings:{}}),s.donchian_channel.numberOfIndicators=g,s.donchian_channel.settings[y]={maxDeque:[],minDeque:[]},Object.assign(i,Object.fromEntries(w.map((function(t){return[t,new Float64Array(a).fill(NaN)]})))),h>0&&t.lag(w,h),["upper","basis","lower"].forEach((function(t){return l.add("".concat(v,"_").concat(t))})),w.forEach((function(t){return c[t]="Float64Array"}))}var M=s.donchian_channel,O=M.numberOfIndicators,E=M.settings,j=O>1?"donchian_channel_".concat(y):"donchian_channel",A=E[y],N=A.maxDeque,P=A.minDeque,_=e-n,T=_-r+1,k=["upper","basis","lower"].map((function(t){return"".concat(j,"_").concat(t)}));f&&k.push("".concat(j,"_height"));var I=m.map((function(t){return"".concat(j,"_range_").concat(t)}));if(T<0||_+1>a)return[].concat(fe(k),fe(I)).forEach((function(r){return t.pushToMain({index:e,key:r,value:NaN})})),!0;var R=i.high,C=i.low,D=function(t,e,r){for(;t.length&&t[0]<T;)t.shift();for(;t.length&&r(e[t.at(-1)],e[_]);)t.pop();t.push(_)};D(N,R,(function(t,e){return t<=e})),D(P,C,(function(t,e){return t>=e}));var F=N.length&&P.length,V=F?R[N[0]]:NaN,q=F?C[P[0]]:NaN,L=F?(V+q)/2:NaN;if(t.pushToMain({index:e,key:"".concat(j,"_upper"),value:V}),t.pushToMain({index:e,key:"".concat(j,"_basis"),value:L}),t.pushToMain({index:e,key:"".concat(j,"_lower"),value:q}),f){var z=F&&q?(V-q)/q:NaN;t.pushToMain({index:e,key:"".concat(j,"_height"),value:null===p?z:he(z,p)})}for(var U=F?V-q:NaN,$=0;$<m.length;$++){var B=i[m[$]][e],H=F&&B==B&&U?(B-q)/U:NaN;t.pushToMain({index:e,key:I[$],value:null===p?H:he(H,p)})}return!0},bollingerBands:function(t,e,r,n,o){var i,s,a,u,l,c,h,f=o.height,m=o.range,p=void 0===m?[]:m,y=o.target,g=o.lag,d=o.decimals,v=t.verticalOhlcv,w=t.instances,b="close"===y?"":"_".concat(y),S="".concat(r,"_").concat(n).concat(b);if(0===e){var x=t.priceBased,M=t.inputParams,O=t.verticalOhlcv,E=t.len,j=t.arrayTypes;if(!(y in O))throw new Error('bollingerBands could not find target "'.concat(y,'"'));var A,N=0,P=ve(M);try{for(P.s();!(A=P.n()).done;)"bollingerBands"===A.value.key&&N++}catch(t){P.e(t)}finally{P.f()}h=N>1?"bollinger_bands_".concat(S):"bollinger_bands".concat(b),w.bollinger_bands||(w.bollinger_bands={numberOfIndicators:N,settings:{}}),w.bollinger_bands.settings[S]=new Pt(r,n);var _=["".concat(h,"_upper"),"".concat(h,"_middle"),"".concat(h,"_lower")];f&&_.push("".concat(h,"_height"));var T,k=ve(p);try{for(k.s();!(T=k.n()).done;){var I=T.value;if(!(I in O)||!x.has(I))throw new Error('Invalid range item value "'.concat(I,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(x)));_.push("".concat(h,"_range_").concat(I))}}catch(t){k.e(t)}finally{k.f()}var R=Object.fromEntries(_.map((function(t){return[t,new Float64Array(E).fill(NaN)]})));Object.assign(O,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ge(Object(r),!0).forEach((function(e){de(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},R)),g>0&&t.lag(_,g),["".concat(h,"_upper"),"".concat(h,"_middle"),"".concat(h,"_lower")].forEach((function(t){x.add(t)}));for(var C=0,D=_;C<D.length;C++)j[D[C]]="Float64Array"}h||(h=w.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(S):"bollinger_bands".concat(b));var F=h,V=w.bollinger_bands.settings[S],q=v[y][e];V.update(q);var L={};try{L=V.getResult()}catch(t){}var z=null!==(i=null===(s=L)||void 0===s?void 0:s.upper)&&void 0!==i?i:NaN,U=null!==(a=null===(u=L)||void 0===u?void 0:u.middle)&&void 0!==a?a:NaN,$=null!==(l=null===(c=L)||void 0===c?void 0:c.lower)&&void 0!==l?l:NaN;if(t.pushToMain({index:e,key:"".concat(F,"_upper"),value:z}),t.pushToMain({index:e,key:"".concat(F,"_middle"),value:U}),t.pushToMain({index:e,key:"".concat(F,"_lower"),value:$}),f){var B=NaN;Number.isNaN($)||Number.isNaN(z)||(B=(z-$)/$),t.pushToMain({index:e,key:"".concat(F,"_height"),value:null===d?B:he(B,d)})}var H,Y=ve(p);try{for(Y.s();!(H=Y.n()).done;){var G=H.value,K=NaN,W=v[G][e];Number.isNaN(W)||Number.isNaN($)||Number.isNaN(z)||(K=(W-$)/(z-$)),t.pushToMain({index:e,key:"".concat(F,"_range_").concat(G),value:null===d?K:he(K,d)})}}catch(t){Y.e(t)}finally{Y.f()}return!0},volumeOscillator:function(t,e,r,n,o){var i,s,a,u=o.lag,l=t.verticalOhlcv,c=t.instances,h=l.volume[e],f="volume_oscillator_".concat(r,"_").concat(n);if(0===e){var m=t.crossPairsList,p=t.len,y=t.arrayTypes;Object.assign(c,(i={},s=f,a={fastEMA:new Vt(r),slowEMA:new Vt(n)},(s=function(t){var e=function(t,e){if("object"!=be(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==be(e)?e:e+""}(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i)),l[f]=new Float64Array(p).fill(NaN),m.push({fast:f,slow:0,isDefault:!0}),u>0&&t.lag([f],u),y[f]="Float64Array"}var g=c[f],d=g.fastEMA,v=g.slowEMA;d.update(h),v.update(h);var w=NaN,b=NaN;try{w=d.getResult()}catch(t){}try{b=v.getResult()}catch(t){}var S=NaN;return Number.isNaN(w)||Number.isNaN(b)||(S=100*(w-b)/b),t.pushToMain({index:e,key:f,value:S}),!0},scaler:function(t,e,r,n,o){var i=o.type,s=o.group,a=o.range,u=o.lag,l=o.precomputed,c=o.decimals,h=l.groupKey,f=l.groupKeyLen,m=t.verticalOhlcv,p=t.instances,y=t.arrayTypes,g="".concat(i,"_").concat(r);if(0===e){var d=t.len,v=t.scaledLabels;if(v.has(g))throw new Error('Method "scaler" cannot have both "size" and "options.type" parameters specified together.');v.add(g),p.hasOwnProperty("scaler")||(p.scaler={windows:{}});var w,b=Ge(n);try{var S=function(){var e=w.value;if(!m.hasOwnProperty(e))throw new Error('Target property "'.concat(e,'" not found in verticalOhlcv'));var r="".concat(g,"_").concat(e);m[r]=new Float64Array(d).fill(NaN),y[r]="Float64Array";var n=s?h:e;if(p.scaler.windows[n]=[],s&&(t.scaledGroups[h]||(t.scaledGroups[h]=[]),t.scaledGroups[h].push(r)),u>0){if(s){var o,i=Array.from({length:u}).map((function(t,e){return"".concat(r,"_lag_").concat(e+1)}));(o=t.scaledGroups[h]).push.apply(o,Ye(i))}t.lag([r],u)}};for(b.s();!(w=b.n()).done;)S()}catch(t){b.e(t)}finally{b.f()}}var x,M=p.scaler.windows,O=Ge(n);try{for(O.s();!(x=O.n()).done;){var E=x.value,j=m[E][e],A=M[s?h:E];A.push(j),A.length>(s?r*f:r)&&A.shift()}}catch(t){O.e(t)}finally{O.f()}var N,P=e+1>=r,_=Ge(n);try{var T=function(){var r,n,o,u,l,f,p,y,d=N.value,v=m[d][e],w="".concat(g,"_").concat(d),b=null;if(P){var S=M[s?h:d];if("minmax"===i){r=v,n=Math.min.apply(Math,Ye(S)),o=Math.max.apply(Math,Ye(S)),y=2,u=function(t){if(Array.isArray(t))return t}(p=a)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(p,y)||Ke(p,y)||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.")}(),l=u[0],f=u[1],b=(Math.min(Math.max(r,n),o)-n)/(o-n)*(f-l)+l}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var x=S.reduce((function(t,e){return t+e}),0)/S.length,O=S.reduce((function(t,e){return t+Math.pow(e-x,2)}),0)/S.length,E=Math.sqrt(O);b=function(t,e,r){return 0===r?0:(t-e)/r}(v,x,E)}}t.pushToMain({index:e,key:w,value:null===c?b:he(b,c)})};for(_.s();!(N=_.n()).done;)T()}catch(t){_.e(t)}finally{_.f()}}},hr=function(t,e){var r,n,o=e.len,i=e.inputParams,a=e.priceBased,u=e.precisionMultiplier,l=e.arrayTypes,c=e.verticalOhlcv,h=e.verticalOhlcvKeyNames,f=e.inputTypes,m=e.chunkProcess;e.scaledGroups,s(i,o);for(var p=0,y=Object.keys(f);p<y.length;p++){var g=y[p];c[g]=Ne(l[g],o)}for(var d=0;d<o;d+=m)for(var v=Math.min(d+m,o),w=d;w<v;w++){for(var b=t[w],S=0,x=Object.entries(f);S<x.length;S++){var M=(r=x[S],n=2,function(t){if(Array.isArray(t))return t}(r)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(r,n)||ur(r,n)||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.")}()),O=M[0],E=M[1],j=b[O];if(le.hasOwnProperty(E)){var A=le[E](j);u>1&&a.has(O)&&(A*=u),e.pushToMain({index:w,key:O,value:A})}else Me.hasOwnProperty(E)?e.pushToMain({index:w,key:O,value:Me[E](j)}):e.pushToMain({index:w,key:O,value:j})}var N,P=ar(i);try{for(P.s();!(N=P.n()).done;){var _=N.value,T=_.key,k=_.params;"lag"!==T&&"crossPairs"!==T&&cr[T].apply(cr,[e,w].concat(sr(k)))}}catch(t){P.e(t)}finally{P.f()}Ie(e,w),Ue(e,w),t[w]=null}!function(t){var e,r=t.inputParams,n=t.invalidValueIndex,o=t.len,i=t.verticalOhlcv,s=n+1,a=nr(r);try{var u=function(){var t=e.value,r=t.key,n=t.params;if("scaler"!==r)return 0;var a=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||or(t,e)||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.")}()}(n,3),u=a[0],l=a[1],c=a[2],h=c.type,f=c.group,m=c.lag,p=c.pca,y=c.pcaSource;if(!f||!p)return 0;var g,d=l.map((function(t){return"".concat(h,"_").concat(u,"_").concat(t)})),v=[],w=nr(d);try{for(w.s();!(g=w.n()).done;)for(var b=g.value,S=1;S<=m;S++)v.push("".concat(b,"_lag_").concat(S))}catch(t){w.e(t)}finally{w.f()}d.push.apply(d,v);for(var x=o-s,M=d.length,O=new Array(x),E=s;E<o;E++){var j,A=new Float64Array(M),N=0,P=nr(d);try{for(P.s();!(j=P.n()).done;){var _=j.value;A[N++]=i[_][E]}}catch(t){P.e(t)}finally{P.f()}O[E-s]=A}if(!y){var T,k=nr(d);try{for(k.s();!(T=k.n()).done;){var I=T.value;delete i[I]}}catch(t){k.e(t)}finally{k.f()}}var R=function(t){return function(t){if(Array.isArray(t))return ir(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||or(t)||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.")}()}(new rr(O).predict(O)),C="pca_".concat(h,"_").concat(u);i[C]=new Array(o).fill(null);for(var D=0;D<R.length;D++)i[C][D+s+1]=R[D]};for(a.s();!(e=a.n()).done;)u()}catch(t){a.e(t)}finally{a.f()}}(e),h.push.apply(h,sr(Object.keys(c)))},fr=function(t,e){for(var r=t.length,n=new J(e),o=new Array(r),i=0,s=0,a=0,u=0;u<r;u++)if(n.update(t[u]),n.isStable){var l=n.getResult();o[u]=l,i+=l,s+=l*l,a++}else o[u]=null;var c=i/a,h=s/a-c*c,f=Math.sqrt(h);return o.map((function(t){return null!==t?(t-c)/f:null}))},mr=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=fr(t,r),o=fr(e,r),i=t.length,s=[],a=0,u=0,l=0,c=0,h=0,f=0,m=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){m=p;break}s.push(0)}if(-1===m)return new Array(i).fill(0);for(var y=m;y<i;y++){var g=n[y],d=o[y];if(null!==g&&null!==d)if(a+=g,u+=d,l+=g*d,c+=g*g,h+=d*d,++f<2)s.push(0);else{var v=f*l-a*u,w=Math.sqrt((f*c-a*a)*(f*h-u*u)),b=0===w?0:v/w;s.push(b)}else a=u=l=c=h=f=0,s.push(0)}return s};function pr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var yr=function(t){var e,r,n=t.main,o=t.skipNull,i=void 0!==o&&o,s=t.startIndex,a=void 0===s?0:s,u=t.dateFormat,l=n.precisionMultiplier,c=n.priceBased,h=n.precision,f=n.verticalOhlcv,m=n.invalidValueIndex,p=n.len,y=n.verticalOhlcvKeyNames,g=n.verticalOhlcvTempCols;if(0===y.length)return[];for(var d=i&&m>=0?m+1:0,v=Math.max(d,a),w=p-v,b=Array.from({length:w},(function(){return{}})),S=0,x=Object.entries(f);S<x.length;S++){var M=(e=x[S],r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(e,r)||function(t,e){if(t){if("string"==typeof t)return pr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pr(t,e):void 0}}(e,r)||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.")}()),O=M[0],E=M[1];if(!g.has(O))for(var j=c.has(O)&&h,A=v;A<p;A++)b[A-v][O]=j?E[A]/l:"date"===O?xe[u](E[A]):E[A]}return b};function gr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||dr(t,e)||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 dr(t,e){if(t){if("string"==typeof t)return vr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vr(t,e):void 0}}function vr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function wr(t){return wr="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},wr(t)}function br(t){return function(t){if(Array.isArray(t))return Mr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||xr(t)||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 Sr(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||xr(t,e)||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 xr(t,e){if(t){if("string"==typeof t)return Mr(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mr(t,e):void 0}}function Mr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Or(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Er(n.key),n)}}function Er(t){var e=function(t,e){if("object"!=wr(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=wr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wr(e)?e:e+""}var jr=function(){return t=function t(e){var r=this,n=e.input,o=e.ticker,i=void 0===o?null:o,a=e.precision,l=void 0===a||a,c=e.inputParams,m=void 0===c?null:c,p=e.chunkProcess,y=void 0===p?2e3:p;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),u(n,"input",null!==i?"contructor ".concat(i):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+i);h(l,"precision","constructor"),f(y,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),this.chunkProcess=y,this.firstRow=n[0];var g=function(t){for(var e={},r={},n=0,o=Object.entries(t);n<o.length;n++){var i=Ee(o[n],2),s=i[0],a=i[1];if("date"===s)e[s]=Oe(a),r[s]="Array";else if("volume"===s)e[s]=ce(a,!0),r[s]="Int32Array";else if(Ae.has(s))e[s]=ce(a,!0),r[s]="Float64Array";else{var u=ce(a,!1);e[s]=u,r[s]="number"===u?"Float64Array":"Array"}}return{inputTypes:e,arrayTypes:r}}(this.firstRow),d=g.inputTypes,v=g.arrayTypes;if(this.inputTypes=d,this.arrayTypes=v,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(i));return this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.input=n,this.priceBased=new Set(["open","high","low","close"]),this.len=n.length,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={correlation:mr},this.invalidValueIndex=-1,this.precision=l,this.precisionMultiplier=function(t,e){var r=t.precision,n=t.priceBased;if(!1===r)return 1;var o,i=1,s=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=dr(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(Object.entries(e).filter((function(t){var e=gr(t,2),r=e[0];return e[1],n.has(r)})).map((function(t){var e=gr(t,2);return e[0],e[1]})));try{for(s.s();!(o=s.n()).done;){var a=o.value,u=gr(String(a).split("."),2)[1],l=void 0===u?"":u,c=Math.max(4,l.length),h=c>1?Math.pow(10,c-1):1;h>i&&(i=h)}}catch(t){s.e(t)}finally{s.f()}return i}(this,this.firstRow),this.scaledGroups={},this.scaledLabels=new Set,this.pushToMain=function(t){var e=t.index,n=t.key,o=t.value;return function(t){var e=t.main,r=t.index,n=t.key,o=t.value,i=e.verticalOhlcv;return null==o||Number.isNaN(o)?(e.invalidValueIndex=r,i[n][r]=o,!1):(i[n][r]=o,!0)}({main:r,index:e,key:n,value:o})},null!==m&&(s(m,this.len),this.inputParams=m,this.compute()),this.inputParams=[],this},e=[{key:"getDataAsCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e||e,n=t.dateFormat,o=void 0===n?"string":n;c(Object.keys(xe),o,"dateFormat","getDataAsCols"),l(t,"options","getDataAsCols");for(var i=this.precisionMultiplier,s=this.precision,a=this.invalidValueIndex,u=this.len,h=this.verticalOhlcv,f=this.priceBased,m=this.arrayTypes,p=this.verticalOhlcvTempCols,y={},g=r?a+1:0,d=u-g,v=0,w=Object.entries(h);v<w.length;v++){var b=Sr(w[v],2),S=b[0],x=b[1];if(!p.has(S)){var M=f.has(S)&&s;y[S]=Ne(m[S],d);for(var O=g;O<u;O++)y[S][O]=M?x[O]/i:"date"===S?xe[o](x[O]):x[O]}}return y}},{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e||e,n=t.dateFormat,o=void 0===n?"string":n;return c(Object.keys(xe),o,"dateFormat","getData"),l(t,"options","getData"),yr({main:this,skipNull:r,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.dateFormat,r=void 0===e?"string":e;return c(Object.keys(xe),r,"dateFormat","getData"),yr({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:r})[0]}},{key:"compute",value:function(){return this.isComputed||(this.isComputed=!1,this.len>0&&(hr(this.input,this),this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[])),this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e="crossPairs";return a(this),u(t,"arr",e),this.crossPairsList=[].concat(br(this.crossPairsList),br(t)),this.inputParams.push({key:e,params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r="lag";a(this),u(t,"colKeys",r),f(e,{min:1,max:this.len,allowDecimals:!1},"lookback",r),this.inputParams.push({key:r,params:[t,e]});var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=xr(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}(t);try{for(o.s();!(n=o.n()).done;){var i=n.value;this.priceBased.has(i)&&this.priceBased.add(i)}}catch(t){o.e(t)}finally{o.f()}return this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.lag,o=void 0===n?0:n;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,params:[t,{lag:o}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="atr";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.percentage,s=void 0!==i&&i,u=e.upper,c=void 0===u?null:u,m=e.lower,p=void 0===m?null:m;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),h(s,"options.percentage","atr"),null!==c&&f(c,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==p&&f(p,{min:.001,max:100,allowDecimals:!0},"options.lower","atr"),this.inputParams.push({key:r,params:[t,{lag:o,percentage:s,upper:c,lower:p}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="ema";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,s=void 0===i?0:i;f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",r);var u=ne({main:this,size:t,target:o,lag:s,methodName:r});return this.inputParams.push({key:r,params:[r,t,{target:o,lag:s,precomputed:u}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="sma";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,s=void 0===i?0:i;f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",r);var u=ne({main:this,size:t,target:o,lag:s,methodName:r});return this.inputParams.push({key:r,params:[r,t,{target:o,lag:s,precomputed:u}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),f(e,{min:1,max:this.len,allowDecimals:!1},"slow",o),f(r,{min:1,max:this.len,allowDecimals:!1},"signal",o),l(n,"options",o);var i=n.target,s=void 0===i?"close":i,u=n.lag,c=void 0===u?0:u;f(c,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var h={instanceKey:"".concat(t,"_").concat(e,"_").concat(r).concat("close"===s?"":"_".concat(s))};return this.inputParams.push({key:o,params:[t,e,r,{target:s,lag:c,precomputed:h}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),f(e,{min:.01,max:50,allowDecimals:!0},"stdDev",n),l(r,"options",n);var o=r.target,i=void 0===o?"close":o,s=r.height,c=void 0!==s&&s,m=r.range,p=void 0===m?[]:m,y=r.lag,g=void 0===y?0:y,d=r.decimals,v=void 0===d?null:d;return u(p,"options.range",n),f(g,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),h(c,"options.height",n),null!==v&&f(v,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,params:[t,e,{target:i,height:c,range:p,lag:g,decimals:v}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="rsi";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),l(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,s=void 0===i?0:i;return f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,params:[t,{target:o,lag:s}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),f(e,{min:0,max:this.len,allowDecimals:!1},"offset",n),l(r,"options",n);var o=r.height,i=void 0!==o&&o,s=r.range,c=void 0===s?[]:s,m=r.lag,p=void 0===m?0:m,y=r.decimals,g=void 0===y?null:y;return u(c,"options.range",n),f(p,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),h(i,"options.height",n),null!==g&&f(g,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,params:[t,e,{height:i,range:c,lag:p,decimals:g}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"fastSize",n),f(e,{min:t,max:this.len,allowDecimals:!1},"slowSize",n),l(r,"options",n);var o=r.lag,i=void 0===o?0:o;return f(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,params:[t,e,{lag:i}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="dateTime";a(this),l(t,"options",e);var r=t.lag,n=void 0===r?0:r;return f(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this.inputParams.push({key:e,params:[{lag:n}]}),this}},{key:"scaler",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="scaler";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),u(e,"colKeys",n);var i=r.group,s=void 0!==i&&i,l=r.range,m=void 0===l?[0,1]:l,p=r.lag,y=void 0===p?0:p,g=r.type,d=void 0===g?"zscore":g,v=r.decimals,w=void 0===v?null:v,b=r.pca,S=void 0!==b&&b,x=r.pcaSource,M=void 0!==x&&x;h(s,"options.group",n),h(S,"options.pca",n),h(M,"options.pcaSource",n),function(t,e,r){if(u(t,e,r),2!==t.length)throw new Error('Invalid "'.concat(e,'" array length: expected 2 items, but got ').concat(t.length,' in "').concat(r,".").concat(e,'".'));var n=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw o}}return a}}(t,e)||o(t,e)||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.")}()}(t,2),i=n[0],s=n[1];if(f(i,{min:-100,max:s,allowDecimals:!1},"min",r),f(s,{min:i,max:100,allowDecimals:!1},"max",r),i===s)throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(r,".").concat(e,'".'))}(m,"options.range",n),c(["minmax","zscore"],d,"options.type",n),null!==w&&f(w,{min:1,max:15,allowDecimals:!1},"decimals",n);var O={groupKey:s?"".concat(d,"_").concat(t,"_group_").concat(e.join("_")):"",groupKeyLen:e.length};return this.inputParams.push({key:n,params:[t,e,{type:d,group:s,range:m,lag:y,precomputed:O,decimals:w,pca:S,pcaSource:M}]}),this}}],e&&Or(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=n})();
|
package/index.js
CHANGED
|
@@ -67,6 +67,7 @@ export default class OHLCV_INDICATORS {
|
|
|
67
67
|
this.precision = precision
|
|
68
68
|
this.precisionMultiplier = calcPrecisionMultiplier(this, this.firstRow)
|
|
69
69
|
this.scaledGroups = {}
|
|
70
|
+
this.scaledLabels = new Set()
|
|
70
71
|
|
|
71
72
|
this.pushToMain = ({index, key, value}) => pushToMain({main: this, index, key, value})
|
|
72
73
|
|
|
@@ -456,9 +457,11 @@ export default class OHLCV_INDICATORS {
|
|
|
456
457
|
validateNumber(size, {min: 1, max: this.len, allowDecimals: false}, 'size', methodName)
|
|
457
458
|
validateArray(colKeys, 'colKeys', methodName)
|
|
458
459
|
|
|
459
|
-
const {group = false, range = [0, 1], lag = 0, type = '
|
|
460
|
+
const {group = false, range = [0, 1], lag = 0, type = 'zscore', decimals = null, pca = false, pcaSource = false} = options
|
|
460
461
|
|
|
461
462
|
validateBoolean(group, 'options.group', methodName)
|
|
463
|
+
validateBoolean(pca, 'options.pca', methodName)
|
|
464
|
+
validateBoolean(pcaSource, 'options.pcaSource', methodName)
|
|
462
465
|
validateArrayOfRanges(range, 'options.range', methodName)
|
|
463
466
|
validateArrayOptions(['minmax', 'zscore'], type, 'options.type', methodName)
|
|
464
467
|
|
|
@@ -468,7 +471,7 @@ export default class OHLCV_INDICATORS {
|
|
|
468
471
|
const groupKeyLen = colKeys.length
|
|
469
472
|
const precomputed = {groupKey, groupKeyLen}
|
|
470
473
|
|
|
471
|
-
this.inputParams.push({key: methodName, params: [size, colKeys, {type, group, range, lag, precomputed, decimals}]})
|
|
474
|
+
this.inputParams.push({key: methodName, params: [size, colKeys, {type, group, range, lag, precomputed, decimals, pca, pcaSource}]})
|
|
472
475
|
return this
|
|
473
476
|
}
|
|
474
477
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"author": "https://jaimelias.com/",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"
|
|
15
|
+
"ml-pca": "^4.1.1",
|
|
16
|
+
"trading-signals": "^5.0.4",
|
|
17
|
+
"xy-scale": "^1.4.1"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
20
|
"@babel/core": "^7.25.2",
|
|
@@ -9,13 +9,15 @@ import { volumeOscillator } from "../oscillators/volumeOscillator.js";
|
|
|
9
9
|
import { lag } from "../studies/lag.js";
|
|
10
10
|
import { crossPairs } from "../studies/findCrosses.js";
|
|
11
11
|
import { dateTime } from "../studies/dateTime.js";
|
|
12
|
-
import { scaler } from "../
|
|
12
|
+
import { scaler } from "../machine-learning/scaler.js";
|
|
13
13
|
import { atr } from "../volatility/atr.js";
|
|
14
14
|
|
|
15
15
|
import { buildArray } from "../utilities/assignTypes.js";
|
|
16
16
|
import { numberFormater } from "../utilities/numberUtilities.js";
|
|
17
17
|
import { dateFormaters } from "../utilities/dateUtilities.js";
|
|
18
18
|
|
|
19
|
+
import { pca } from "../machine-learning/pca.js";
|
|
20
|
+
|
|
19
21
|
// Map indicator keys to their respective functions
|
|
20
22
|
const indicatorFunctions = {
|
|
21
23
|
dateTime,
|
|
@@ -33,7 +35,7 @@ const indicatorFunctions = {
|
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
export const mainLoop = (input, main) => {
|
|
36
|
-
const { len, inputParams, priceBased, precisionMultiplier, arrayTypes, verticalOhlcv, verticalOhlcvKeyNames, inputTypes, chunkProcess } = main;
|
|
38
|
+
const { len, inputParams, priceBased, precisionMultiplier, arrayTypes, verticalOhlcv, verticalOhlcvKeyNames, inputTypes, chunkProcess, scaledGroups } = main;
|
|
37
39
|
|
|
38
40
|
validateInputParams(inputParams, len)
|
|
39
41
|
|
|
@@ -89,5 +91,7 @@ export const mainLoop = (input, main) => {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
pca(main)
|
|
95
|
+
|
|
92
96
|
verticalOhlcvKeyNames.push(...Object.keys(verticalOhlcv))
|
|
93
97
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PCA } from "ml-pca";
|
|
2
|
+
|
|
3
|
+
export const pca = main => {
|
|
4
|
+
|
|
5
|
+
const {inputParams, invalidValueIndex, len, verticalOhlcv} = main
|
|
6
|
+
const startIndex = invalidValueIndex + 1
|
|
7
|
+
|
|
8
|
+
for(const rowParams of inputParams)
|
|
9
|
+
{
|
|
10
|
+
const {key: indicatorName, params} = rowParams
|
|
11
|
+
|
|
12
|
+
if(indicatorName !== 'scaler') continue
|
|
13
|
+
|
|
14
|
+
const [size, keyNames, options] = params
|
|
15
|
+
|
|
16
|
+
const {type, group, lag, pca: pcaBoolean, pcaSource} = options
|
|
17
|
+
|
|
18
|
+
if(!group || !pcaBoolean) continue
|
|
19
|
+
|
|
20
|
+
const scaledKeyNames = keyNames.map(v => `${type}_${size}_${v}`)
|
|
21
|
+
const laggedKeys = []
|
|
22
|
+
|
|
23
|
+
for (const k of scaledKeyNames) {
|
|
24
|
+
for (let step = 1; step <= lag; step++) {
|
|
25
|
+
laggedKeys.push(`${k}_lag_${step}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
scaledKeyNames.push(...laggedKeys)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const diffLen = len - startIndex
|
|
33
|
+
const numCols = scaledKeyNames.length
|
|
34
|
+
const tempArr = new Array(diffLen)
|
|
35
|
+
|
|
36
|
+
for (let i = startIndex; i < len; i++) {
|
|
37
|
+
|
|
38
|
+
const row = new Float64Array(numCols);
|
|
39
|
+
|
|
40
|
+
let j = 0
|
|
41
|
+
|
|
42
|
+
for (const key of scaledKeyNames) {
|
|
43
|
+
row[j++] = verticalOhlcv[key][i]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
tempArr[i - startIndex] = row
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if(!pcaSource)
|
|
50
|
+
{
|
|
51
|
+
for (const key of scaledKeyNames) {
|
|
52
|
+
delete verticalOhlcv[key]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const pca = new PCA(tempArr)
|
|
57
|
+
const predictions = [...pca.predict(tempArr)]
|
|
58
|
+
|
|
59
|
+
const verticalKey = `pca_${type}_${size}`
|
|
60
|
+
verticalOhlcv[verticalKey] = new Array(len).fill(null)
|
|
61
|
+
|
|
62
|
+
for(let x = 0; x < predictions.length; x++)
|
|
63
|
+
{
|
|
64
|
+
verticalOhlcv[verticalKey][x + startIndex + 1] = predictions[x]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
@@ -19,7 +19,13 @@ export const scaler = (main, index, size, colKeys, {type, group, range, lag, pre
|
|
|
19
19
|
const prefix = `${type}_${size}`;
|
|
20
20
|
|
|
21
21
|
if (index === 0) {
|
|
22
|
-
const { len } = main;
|
|
22
|
+
const { len, scaledLabels } = main;
|
|
23
|
+
|
|
24
|
+
if(scaledLabels.has(prefix))
|
|
25
|
+
{
|
|
26
|
+
throw new Error(`Method "scaler" cannot have both "size" and "options.type" parameters specified together.`)
|
|
27
|
+
}
|
|
28
|
+
scaledLabels.add(prefix)
|
|
23
29
|
|
|
24
30
|
if(!instances.hasOwnProperty('scaler'))
|
|
25
31
|
{
|