ohlcv-indicators 3.5.0 → 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,4225 +1 @@
1
- var OHLCV_INDICATORS;
2
-
3
- /******/ (() => {
4
- // webpackBootstrap
5
- /******/ "use strict";
6
- /******/ // The require scope
7
- /******/ var t = {
8
- /******/ // define getter functions for harmony exports
9
- /******/ d: (e, r) => {
10
- /******/ for (var n in r)
11
- /******/ t.o(r, n) && !t.o(e, n) &&
12
- /******/ Object.defineProperty(e, n, {
13
- enumerable: !0,
14
- get: r[n]
15
- })
16
- /******/;
17
- /******/ },
18
- /******/ o: (t, e) => Object.prototype.hasOwnProperty.call(t, e)
19
- /******/ ,
20
- /******/ // define __esModule on exports
21
- /******/ r: t => {
22
- /******/ "undefined" != typeof Symbol && Symbol.toStringTag &&
23
- /******/ Object.defineProperty(t, Symbol.toStringTag, {
24
- value: "Module"
25
- })
26
- /******/ , Object.defineProperty(t, "__esModule", {
27
- value: !0
28
- });
29
- }
30
- /******/ }, e = {};
31
- /******/
32
- /************************************************************************/
33
- /******/ /* webpack/runtime/define property getters */
34
- /******/
35
- // This entry need to be wrapped in an IIFE because it declares 'OHLCV_INDICATORS' on top-level, which conflicts with the current library output.
36
- (() => {
37
- // ./src/utilities/validators.js
38
- function r(t, e) {
39
- return function(t) {
40
- if (Array.isArray(t)) return t;
41
- }(t) || function(t, e) {
42
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
43
- if (null != r) {
44
- var n, o, i, a, u = [], l = !0, c = !1;
45
- try {
46
- if (i = (r = r.call(t)).next, 0 === e) {
47
- if (Object(r) !== r) return;
48
- l = !1;
49
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
50
- } catch (t) {
51
- c = !0, o = t;
52
- } finally {
53
- try {
54
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
55
- } finally {
56
- if (c) throw o;
57
- }
58
- }
59
- return u;
60
- }
61
- }(t, e) || i(t, e) || function() {
62
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
63
- }();
64
- }
65
- function n(t) {
66
- return n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
67
- return typeof t;
68
- } : function(t) {
69
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
70
- }, n(t);
71
- }
72
- function o(t, e) {
73
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
74
- if (!r) {
75
- if (Array.isArray(t) || (r = i(t)) || e && t && "number" == typeof t.length) {
76
- r && (t = r);
77
- var n = 0, o = function() {};
78
- return {
79
- s: o,
80
- n: function() {
81
- return n >= t.length ? {
82
- done: !0
83
- } : {
84
- done: !1,
85
- value: t[n++]
86
- };
87
- },
88
- e: function(t) {
89
- throw t;
90
- },
91
- f: o
92
- };
93
- }
94
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95
- }
96
- var a, u = !0, l = !1;
97
- return {
98
- s: function() {
99
- r = r.call(t);
100
- },
101
- n: function() {
102
- var t = r.next();
103
- return u = t.done, t;
104
- },
105
- e: function(t) {
106
- l = !0, a = t;
107
- },
108
- f: function() {
109
- try {
110
- u || null == r.return || r.return();
111
- } finally {
112
- if (l) throw a;
113
- }
114
- }
115
- };
116
- }
117
- function i(t, e) {
118
- if (t) {
119
- if ("string" == typeof t) return a(t, e);
120
- var r = {}.toString.call(t).slice(8, -1);
121
- 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) ? a(t, e) : void 0;
122
- }
123
- }
124
- function a(t, e) {
125
- (null == e || e > t.length) && (e = t.length);
126
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
127
- return n;
128
- }
129
- // ESM COMPAT FLAG
130
- t.r(e),
131
- // EXPORTS
132
- t.d(e, {
133
- default: () => /* binding */ rn
134
- });
135
- var u = function(t, e) {
136
- if (!Array.isArray(t)) throw new Error('Property "inputParams" must be an "Array" or "Set".');
137
- var r, n = o(t);
138
- try {
139
- for (n.s(); !(r = n.n()).done; ) {
140
- var i, a = o(r.value.params);
141
- try {
142
- for (a.s(); !(i = a.n()).done; ) {
143
- var u = i.value;
144
- 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.");
145
- }
146
- } catch (t) {
147
- a.e(t);
148
- } finally {
149
- a.f();
150
- }
151
- }
152
- } catch (t) {
153
- n.e(t);
154
- } finally {
155
- n.f();
156
- }
157
- }, l = function(t) {
158
- 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.');
159
- }, c = function(t, e, r) {
160
- if (!Array.isArray(t)) throw new Error('Param "'.concat(e, '" must be an array in "').concat(r, '".'));
161
- return !0;
162
- }, s = function(t, e, r) {
163
- if (!Boolean(t) || "object" == !n(t)) throw new Error('Param "'.concat(e, '" must be an object in "').concat(r, '".'));
164
- return !0;
165
- }, f = function(t, e, r, n) {
166
- if (c(t, "arrayOptions", "".concat(n, ".").concat(r, ".validateArrayOptions")),
167
- !t.includes(e.toString())) throw new Error('Param "'.concat(r, '" must be any of the following values [').concat(t.join(", "), '] in "').concat(n, '".'));
168
- return !0;
169
- }, y = function(t, e, r) {
170
- if ("boolean" != typeof t) throw new Error('Param "'.concat(e, '" must be an boolean in "').concat(r, '".'));
171
- return !0;
172
- }, p = function(t, e, r, n) {
173
- s(e, "options", "".concat(n, ".").concat(r, ".validateNumber"));
174
- var o = e.allowDecimals, i = void 0 !== o && o, a = e.min, u = e.max, l = i ? "number" : "integer";
175
- if ("number" != typeof t || !1 === i && !Number.isInteger(t)) throw new Error('Param "'.concat(r, '" must be an integer in "').concat(n, '".'));
176
- 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".'));
177
- if (t < a) throw new Error('Param "'.concat(r, '" must be an ').concat(l, " greater than or equal to ").concat(a, ' in "').concat(n, '".'));
178
- if (t > u) throw new Error('Param "'.concat(r, '" must be an ').concat(l, " lower than or equal to ").concat(u, ' in "').concat(n, '".'));
179
- return !0;
180
- }, // 0, 1, 2 or 3
181
- // The maximum value of DP and Big.DP.
182
- h = 1e6, // 0 to 1000000
183
- // The maximum magnitude of the exponent argument to the pow method.
184
- v = 1e6, // true or false
185
- /**************************************************************************************************/
186
- // Error messages.
187
- m = "[big.js] ", d = m + "Invalid ", b = d + "decimal places", g = d + "rounding mode", w = m + "Division by zero",
188
- // The shared prototype object.
189
- O = {}, S = void 0, j = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
190
- /*
191
- * Round Big x to a maximum of sd significant digits using rounding mode rm.
192
- *
193
- * x {Big} The Big to round.
194
- * sd {number} Significant digits: integer, 0 to MAX_DP inclusive.
195
- * rm {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
196
- * [more] {boolean} Whether the result of division was truncated.
197
- */
198
- function P(t, e, r, n) {
199
- var o = t.c;
200
- if (r === S && (r = t.constructor.RM), 0 !== r && 1 !== r && 2 !== r && 3 !== r) throw Error(g);
201
- 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] !== S))),
202
- o.length = 1, n ? (
203
- // 1, 0.1, 0.01, 0.001, 0.0001 etc.
204
- t.e = t.e - e + 1, o[0] = 1) :
205
- // Zero.
206
- o[0] = t.e = 0; else if (e < o.length) {
207
- // Round up?
208
- if (
209
- // xc[sd] is the digit after the digit that may be rounded up.
210
- n = 1 === r && o[e] >= 5 || 2 === r && (o[e] > 5 || 5 === o[e] && (n || o[e + 1] !== S || 1 & o[e - 1])) || 3 === r && (n || !!o[0]),
211
- // Remove any digits after the required precision.
212
- o.length = e, n)
213
- // Rounding up may mean the previous digit has to be rounded up.
214
- for (;++o[--e] > 9; ) if (o[e] = 0, 0 === e) {
215
- ++t.e, o.unshift(1);
216
- break;
217
- }
218
- // Remove trailing zeros.
219
- for (e = o.length; !o[--e]; ) o.pop();
220
- }
221
- return t;
222
- }
223
- /*
224
- * Return a string representing the value of Big x in normal or exponential notation.
225
- * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf.
226
- */ function _(t, e, r) {
227
- var n = t.e, o = t.c.join(""), i = o.length;
228
- // Exponential notation?
229
- if (e) o = o.charAt(0) + (i > 1 ? "." + o.slice(1) : "") + (n < 0 ? "e" : "e+") + n;
230
- // Normal notation.
231
- else if (n < 0) {
232
- for (;++n; ) o = "0" + o;
233
- o = "0." + o;
234
- } 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));
235
- return t.s < 0 && r ? "-" + o : o;
236
- }
237
- // Prototype/instance methods
238
- /*
239
- * Return a new Big whose value is the absolute value of this Big.
240
- */ O.abs = function() {
241
- var t = new this.constructor(this);
242
- return t.s = 1, t;
243
- },
244
- /*
245
- * Return 1 if the value of this Big is greater than the value of Big y,
246
- * -1 if the value of this Big is less than the value of Big y, or
247
- * 0 if they have the same value.
248
- */
249
- O.cmp = function(t) {
250
- 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;
251
- // Either zero?
252
- if (!n[0] || !o[0]) return n[0] ? i : o[0] ? -a : 0;
253
- // Signs differ?
254
- if (i != a) return i;
255
- // Compare exponents.
256
- if (e = i < 0, u != l) return u > l ^ e ? 1 : -1;
257
- // Compare digit by digit.
258
- 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;
259
- // Compare lengths.
260
- return u == l ? 0 : u > l ^ e ? 1 : -1;
261
- },
262
- /*
263
- * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded,
264
- * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
265
- */
266
- O.div = function(t) {
267
- var e = this, r = e.constructor, n = e.c, // dividend
268
- o = (t = new r(t)).c, // divisor
269
- i = e.s == t.s ? 1 : -1, a = r.DP;
270
- if (a !== ~~a || a < 0 || a > h) throw Error(b);
271
- // Divisor is zero?
272
- if (!o[0]) throw Error(w);
273
- // Dividend is 0? Return +-0.
274
- if (!n[0]) return t.s = i, t.c = [ t.e = 0 ], t;
275
- var u, l, c, s, f, y = o.slice(), p = u = o.length, v = n.length, m = n.slice(0, u), // remainder
276
- d = m.length, g = t, // quotient
277
- O = g.c = [], j = 0, _ = a + (g.e = e.e - t.e) + 1;
278
- // precision of the result
279
- // Add zeros to make remainder as long as divisor.
280
- for (g.s = i, i = _ < 0 ? 0 : _,
281
- // Create version of divisor with leading zero.
282
- y.unshift(0); d++ < u; ) m.push(0);
283
- do {
284
- // n is how many times the divisor goes into current remainder.
285
- for (c = 0; c < 10; c++) {
286
- // Compare divisor and remainder.
287
- if (u != (d = m.length)) s = u > d ? 1 : -1; else for (f = -1, s = 0; ++f < u; ) if (o[f] != m[f]) {
288
- s = o[f] > m[f] ? 1 : -1;
289
- break;
290
- }
291
- // If divisor < remainder, subtract divisor from remainder.
292
- if (!(s < 0)) break;
293
- // Remainder can't be more than 1 digit longer than divisor.
294
- // Equalise lengths using divisor with extra leading zero?
295
- for (l = d == u ? o : y; d; ) {
296
- if (m[--d] < l[d]) {
297
- for (f = d; f && !m[--f]; ) m[f] = 9;
298
- --m[f], m[d] += 10;
299
- }
300
- m[d] -= l[d];
301
- }
302
- for (;!m[0]; ) m.shift();
303
- }
304
- // Add the digit n to the result array.
305
- O[j++] = s ? c : ++c,
306
- // Update the remainder.
307
- m[0] && s ? m[d] = n[p] || 0 : m = [ n[p] ];
308
- } while ((p++ < v || m[0] !== S) && i--);
309
- // Leading zero? Do not remove if result is simply zero (qi == 1).
310
- return O[0] || 1 == j || (
311
- // There can't be more than one zero.
312
- O.shift(), g.e--, _--),
313
- // Round?
314
- j > _ && P(g, _, r.RM, m[0] !== S), g;
315
- },
316
- /*
317
- * Return true if the value of this Big is equal to the value of Big y, otherwise return false.
318
- */
319
- O.eq = function(t) {
320
- return 0 === this.cmp(t);
321
- },
322
- /*
323
- * Return true if the value of this Big is greater than the value of Big y, otherwise return
324
- * false.
325
- */
326
- O.gt = function(t) {
327
- return this.cmp(t) > 0;
328
- },
329
- /*
330
- * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise
331
- * return false.
332
- */
333
- O.gte = function(t) {
334
- return this.cmp(t) > -1;
335
- },
336
- /*
337
- * Return true if the value of this Big is less than the value of Big y, otherwise return false.
338
- */
339
- O.lt = function(t) {
340
- return this.cmp(t) < 0;
341
- },
342
- /*
343
- * Return true if the value of this Big is less than or equal to the value of Big y, otherwise
344
- * return false.
345
- */
346
- O.lte = function(t) {
347
- return this.cmp(t) < 1;
348
- },
349
- /*
350
- * Return a new Big whose value is the value of this Big minus the value of Big y.
351
- */
352
- O.minus = O.sub = function(t) {
353
- var e, r, n, o, i = this, a = i.constructor, u = i.s, l = (t = new a(t)).s;
354
- // Signs differ?
355
- if (u != l) return t.s = -l, i.plus(t);
356
- var c = i.c.slice(), s = i.e, f = t.c, y = t.e;
357
- // Either zero?
358
- if (!c[0] || !f[0]) return f[0] ? t.s = -l : c[0] ? t = new a(i) : t.s = 1,
359
- t;
360
- // Determine which is the bigger number. Prepend zeros to equalise exponents.
361
- if (u = s - y) {
362
- for ((o = u < 0) ? (u = -u, n = c) : (y = s, n = f), n.reverse(), l = u; l--; ) n.push(0);
363
- n.reverse();
364
- } else for (
365
- // Exponents equal. Check digit by digit.
366
- r = ((o = c.length < f.length) ? c : f).length, u = l = 0; l < r; l++) if (c[l] != f[l]) {
367
- o = c[l] < f[l];
368
- break;
369
- }
370
- // x < y? Point xc to the array of the bigger number.
371
- /*
372
- * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only
373
- * needs to start at yc.length.
374
- */
375
- 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;
376
- // Subtract yc from xc.
377
- for (l = e; r > u; ) {
378
- if (c[--r] < f[r]) {
379
- for (e = r; e && !c[--e]; ) c[e] = 9;
380
- --c[e], c[r] += 10;
381
- }
382
- c[r] -= f[r];
383
- }
384
- // Remove trailing zeros.
385
- for (;0 === c[--l]; ) c.pop();
386
- // Remove leading zeros and adjust exponent accordingly.
387
- for (;0 === c[0]; ) c.shift(), --y;
388
- return c[0] || (
389
- // n - n = +0
390
- t.s = 1,
391
- // Result must be zero.
392
- c = [ y = 0 ]), t.c = c, t.e = y, t;
393
- },
394
- /*
395
- * Return a new Big whose value is the value of this Big modulo the value of Big y.
396
- */
397
- O.mod = function(t) {
398
- var e, r = this, n = r.constructor, o = r.s, i = (t = new n(t)).s;
399
- if (!t.c[0]) throw Error(w);
400
- return r.s = t.s = 1, e = 1 == t.cmp(r), r.s = o, t.s = i, e ? new n(r) : (o = n.DP,
401
- i = n.RM, n.DP = n.RM = 0, r = r.div(t), n.DP = o, n.RM = i, this.minus(r.times(t)));
402
- },
403
- /*
404
- * Return a new Big whose value is the value of this Big negated.
405
- */
406
- O.neg = function() {
407
- var t = new this.constructor(this);
408
- return t.s = -t.s, t;
409
- },
410
- /*
411
- * Return a new Big whose value is the value of this Big plus the value of Big y.
412
- */
413
- O.plus = O.add = function(t) {
414
- var e, r, n, o = this, i = o.constructor;
415
- // Signs differ?
416
- if (t = new i(t), o.s != t.s) return t.s = -t.s, o.minus(t);
417
- var a = o.e, u = o.c, l = t.e, c = t.c;
418
- // Either zero?
419
- if (!u[0] || !c[0]) return c[0] || (u[0] ? t = new i(o) : t.s = o.s),
420
- t;
421
- // Prepend zeros to equalise exponents.
422
- // Note: reverse faster than unshifts.
423
- if (u = u.slice(), e = a - l) {
424
- for (e > 0 ? (l = a, n = c) : (e = -e, n = u), n.reverse(); e--; ) n.push(0);
425
- n.reverse();
426
- }
427
- // Point xc to the longer array.
428
- // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
429
- 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;
430
- // No need to check for zero, as +x + +y != 0 && -x + -y != 0
431
- // Remove trailing zeros.
432
- for (r && (u.unshift(r), ++l), e = u.length; 0 === u[--e]; ) u.pop();
433
- return t.c = u, t.e = l, t;
434
- },
435
- /*
436
- * Return a Big whose value is the value of this Big raised to the power n.
437
- * If n is negative, round to a maximum of Big.DP decimal places using rounding
438
- * mode Big.RM.
439
- *
440
- * n {number} Integer, -MAX_POWER to MAX_POWER inclusive.
441
- */
442
- O.pow = function(t) {
443
- var e = this, r = new e.constructor("1"), n = r, o = t < 0;
444
- if (t !== ~~t || t < -1e6 || t > v) throw Error(d + "exponent");
445
- for (o && (t = -t); 1 & t && (n = n.times(e)), t >>= 1; ) e = e.times(e);
446
- return o ? r.div(n) : n;
447
- },
448
- /*
449
- * Return a new Big whose value is the value of this Big rounded to a maximum precision of sd
450
- * significant digits using rounding mode rm, or Big.RM if rm is not specified.
451
- *
452
- * sd {number} Significant digits: integer, 1 to MAX_DP inclusive.
453
- * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
454
- */
455
- O.prec = function(t, e) {
456
- if (t !== ~~t || t < 1 || t > h) throw Error(d + "precision");
457
- return P(new this.constructor(this), t, e);
458
- },
459
- /*
460
- * Return a new Big whose value is the value of this Big rounded to a maximum of dp decimal places
461
- * using rounding mode rm, or Big.RM if rm is not specified.
462
- * If dp is negative, round to an integer which is a multiple of 10**-dp.
463
- * If dp is not specified, round to 0 decimal places.
464
- *
465
- * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
466
- * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
467
- */
468
- O.round = function(t, e) {
469
- if (t === S) t = 0; else if (t !== ~~t || t < -h || t > h) throw Error(b);
470
- return P(new this.constructor(this), t + this.e + 1, e);
471
- },
472
- /*
473
- * Return a new Big whose value is the square root of the value of this Big, rounded, if
474
- * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM.
475
- */
476
- O.sqrt = function() {
477
- var t, e, r, n = this, o = n.constructor, i = n.s, a = n.e, u = new o("0.5");
478
- // Zero?
479
- if (!n.c[0]) return new o(n);
480
- // Negative?
481
- if (i < 0) throw Error(m + "No square root");
482
- // Estimate.
483
- // Math.sqrt underflow/overflow?
484
- // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
485
- 0 === (i = Math.sqrt(n + "")) || i === 1 / 0 ? ((e = n.c.join("")).length + a & 1 || (e += "0"),
486
- 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 + ""),
487
- a = t.e + (o.DP += 4);
488
- // Newton-Raphson iteration.
489
- do {
490
- r = t, t = u.times(r.plus(n.div(r)));
491
- } while (r.c.slice(0, a).join("") !== t.c.slice(0, a).join(""));
492
- return P(t, (o.DP -= 4) + t.e + 1, o.RM);
493
- },
494
- /*
495
- * Return a new Big whose value is the value of this Big times the value of Big y.
496
- */
497
- O.times = O.mul = function(t) {
498
- 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;
499
- // Determine sign of result.
500
- // Return signed 0 if either 0.
501
- if (t.s = r.s == t.s ? 1 : -1, !o[0] || !i[0]) return t.c = [ t.e = 0 ], t;
502
- // Initialise exponent of result as x.e + y.e.
503
- // Initialise coefficient array of result with zeros.
504
- for (t.e = l + c,
505
- // If array xc has fewer digits than yc, swap xc and yc, and lengths.
506
- a < u && (e = o, o = i, i = e, c = a, a = u, u = c), e = new Array(c = a + u); c--; ) e[c] = 0;
507
- // Multiply.
508
- // i is initially xc.length.
509
- for (l = u; l--; ) {
510
- // a is yc.length.
511
- for (u = 0, c = a + l; c > l; )
512
- // Current sum of products at this digit position, plus carry.
513
- u = e[c] + i[l] * o[c - l - 1] + u, e[c--] = u % 10,
514
- // carry
515
- u = u / 10 | 0;
516
- e[c] = u;
517
- }
518
- // Increment result exponent if there is a final carry, otherwise remove leading zero.
519
- // Remove trailing zeros.
520
- for (u ? ++t.e : e.shift(), l = e.length; !e[--l]; ) e.pop();
521
- return t.c = e, t;
522
- },
523
- /*
524
- * Return a string representing the value of this Big in exponential notation rounded to dp fixed
525
- * decimal places using rounding mode rm, or Big.RM if rm is not specified.
526
- *
527
- * dp? {number} Decimal places: integer, 0 to MAX_DP inclusive.
528
- * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
529
- */
530
- O.toExponential = function(t, e) {
531
- var r = this, n = r.c[0];
532
- if (t !== S) {
533
- if (t !== ~~t || t < 0 || t > h) throw Error(b);
534
- for (r = P(new r.constructor(r), ++t, e); r.c.length < t; ) r.c.push(0);
535
- }
536
- return _(r, !0, !!n);
537
- },
538
- /*
539
- * Return a string representing the value of this Big in normal notation rounded to dp fixed
540
- * decimal places using rounding mode rm, or Big.RM if rm is not specified.
541
- *
542
- * dp? {number} Decimal places: integer, 0 to MAX_DP inclusive.
543
- * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
544
- *
545
- * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
546
- * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
547
- */
548
- O.toFixed = function(t, e) {
549
- var r = this, n = r.c[0];
550
- if (t !== S) {
551
- if (t !== ~~t || t < 0 || t > h) throw Error(b);
552
- // x.e may have changed if the value is rounded up.
553
- for (t = t + (r = P(new r.constructor(r), t + r.e + 1, e)).e + 1; r.c.length < t; ) r.c.push(0);
554
- }
555
- return _(r, !1, !!n);
556
- },
557
- /*
558
- * Return a string representing the value of this Big.
559
- * Return exponential notation if this Big has a positive exponent equal to or greater than
560
- * Big.PE, or a negative exponent equal to or less than Big.NE.
561
- * Omit the sign for negative zero.
562
- */
563
- O[Symbol.for("nodejs.util.inspect.custom")] = O.toJSON = O.toString = function() {
564
- var t = this, e = t.constructor;
565
- return _(t, t.e <= e.NE || t.e >= e.PE, !!t.c[0]);
566
- },
567
- /*
568
- * Return the value of this Big as a primitve number.
569
- */
570
- O.toNumber = function() {
571
- var t = Number(_(this, !0, !0));
572
- if (!0 === this.constructor.strict && !this.eq(t.toString())) throw Error(m + "Imprecise conversion");
573
- return t;
574
- },
575
- /*
576
- * Return a string representing the value of this Big rounded to sd significant digits using
577
- * rounding mode rm, or Big.RM if rm is not specified.
578
- * Use exponential notation if sd is less than the number of digits necessary to represent
579
- * the integer part of the value in normal notation.
580
- *
581
- * sd {number} Significant digits: integer, 1 to MAX_DP inclusive.
582
- * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up).
583
- */
584
- O.toPrecision = function(t, e) {
585
- var r = this, n = r.constructor, o = r.c[0];
586
- if (t !== S) {
587
- if (t !== ~~t || t < 1 || t > h) throw Error(d + "precision");
588
- for (r = P(new n(r), t, e); r.c.length < t; ) r.c.push(0);
589
- }
590
- return _(r, t <= r.e || r.e <= n.NE || r.e >= n.PE, !!o);
591
- },
592
- /*
593
- * Return a string representing the value of this Big.
594
- * Return exponential notation if this Big has a positive exponent equal to or greater than
595
- * Big.PE, or a negative exponent equal to or less than Big.NE.
596
- * Include the sign for negative zero.
597
- */
598
- O.valueOf = function() {
599
- var t = this, e = t.constructor;
600
- if (!0 === e.strict) throw Error(m + "valueOf disallowed");
601
- return _(t, t.e <= e.NE || t.e >= e.PE, !0);
602
- };
603
- // Export
604
- (
605
- /*
606
- * Create and return a Big constructor.
607
- */
608
- function t() {
609
- /*
610
- * The Big constructor and exported function.
611
- * Create and return a new instance of a Big number object.
612
- *
613
- * n {number|string|Big} A numeric value.
614
- */
615
- function e(r) {
616
- var n = this;
617
- // Enable constructor usage without new.
618
- if (!(n instanceof e)) return r === S ? t() : new e(r);
619
- // Duplicate.
620
- if (r instanceof e) n.s = r.s, n.e = r.e, n.c = r.c.slice(); else {
621
- if ("string" != typeof r) {
622
- if (!0 === e.strict && "bigint" != typeof r) throw TypeError(d + "value");
623
- // Minus zero?
624
- r = 0 === r && 1 / r < 0 ? "-0" : String(r);
625
- }
626
- !
627
- /*
628
- * Parse the number or string value passed to a Big constructor.
629
- *
630
- * x {Big} A Big number instance.
631
- * n {number|string} A numeric value.
632
- */
633
- function(t, e) {
634
- var r, n, o;
635
- if (!j.test(e)) throw Error(d + "number");
636
- // Determine sign.
637
- // Decimal point?
638
- t.s = "-" == e.charAt(0) ? (e = e.slice(1), -1) : 1, (r = e.indexOf(".")) > -1 && (e = e.replace(".", ""));
639
- // Exponential form?
640
- (n = e.search(/e/i)) > 0 ? (
641
- // Determine exponent.
642
- r < 0 && (r = n), r += +e.slice(n + 1), e = e.substring(0, n)) : r < 0 && (
643
- // Integer.
644
- r = e.length);
645
- // Determine leading zeros.
646
- for (o = e.length, n = 0; n < o && "0" == e.charAt(n); ) ++n;
647
- if (n == o)
648
- // Zero.
649
- t.c = [ t.e = 0 ]; else {
650
- // Determine trailing zeros.
651
- for (;o > 0 && "0" == e.charAt(--o); ) ;
652
- // Convert string to array of digits without leading/trailing zeros.
653
- for (t.e = r - n - 1, t.c = [], r = 0; n <= o; ) t.c[r++] = +e.charAt(n++);
654
- }
655
- }(n, r);
656
- }
657
- // Retain a reference to this Big constructor.
658
- // Shadow Big.prototype.constructor which points to Object.
659
- n.constructor = e;
660
- }
661
- return e.prototype = O, e.DP = 20, e.RM = 1, e.NE = -7, e.PE = 21, e.strict = false,
662
- e.roundDown = 0, e.roundHalfUp = 1, e.roundHalfEven = 2, e.roundUp = 3, e;
663
- })();
664
- /// <reference types="https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/big.js/index.d.ts" />
665
- /* harmony default export */ // ./node_modules/trading-signals/dist/error/NotEnoughDataError.js
666
- function N(t) {
667
- return N = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
668
- return typeof t;
669
- } : function(t) {
670
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
671
- }, N(t);
672
- }
673
- function T(t, e) {
674
- for (var r = 0; r < e.length; r++) {
675
- var n = e[r];
676
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
677
- Object.defineProperty(t, A(n.key), n);
678
- }
679
- }
680
- function A(t) {
681
- var e = function(t, e) {
682
- if ("object" != N(t) || !t) return t;
683
- var r = t[Symbol.toPrimitive];
684
- if (void 0 !== r) {
685
- var n = r.call(t, e || "default");
686
- if ("object" != N(n)) return n;
687
- throw new TypeError("@@toPrimitive must return a primitive value.");
688
- }
689
- return ("string" === e ? String : Number)(t);
690
- }(t, "string");
691
- return "symbol" == N(e) ? e : e + "";
692
- }
693
- function E(t, e, r) {
694
- return e = D(e), function(t, e) {
695
- if (e && ("object" == N(e) || "function" == typeof e)) return e;
696
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
697
- return function(t) {
698
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
699
- return t;
700
- }(t);
701
- }(t, x() ? Reflect.construct(e, r || [], D(t).constructor) : e.apply(t, r));
702
- }
703
- function k(t) {
704
- var e = "function" == typeof Map ? new Map : void 0;
705
- return k = function(t) {
706
- if (null === t || !function(t) {
707
- try {
708
- return -1 !== Function.toString.call(t).indexOf("[native code]");
709
- } catch (e) {
710
- return "function" == typeof t;
711
- }
712
- }(t)) return t;
713
- if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
714
- if (void 0 !== e) {
715
- if (e.has(t)) return e.get(t);
716
- e.set(t, r);
717
- }
718
- function r() {
719
- return function(t, e, r) {
720
- if (x()) return Reflect.construct.apply(null, arguments);
721
- var n = [ null ];
722
- n.push.apply(n, e);
723
- var o = new (t.bind.apply(t, n));
724
- return r && I(o, r.prototype), o;
725
- }(t, arguments, D(this).constructor);
726
- }
727
- return r.prototype = Object.create(t.prototype, {
728
- constructor: {
729
- value: r,
730
- enumerable: !1,
731
- writable: !0,
732
- configurable: !0
733
- }
734
- }), I(r, t);
735
- }, k(t);
736
- }
737
- function x() {
738
- try {
739
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
740
- } catch (t) {}
741
- return (x = function() {
742
- return !!t;
743
- })();
744
- }
745
- function I(t, e) {
746
- return I = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
747
- return t.__proto__ = e, t;
748
- }, I(t, e);
749
- }
750
- function D(t) {
751
- return D = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
752
- return t.__proto__ || Object.getPrototypeOf(t);
753
- }, D(t);
754
- }
755
- var M = function(t) {
756
- function e() {
757
- var t, r = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "Not enough data";
758
- return function(t, e) {
759
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
760
- }(this, e), t = E(this, e, [ r ]), Object.setPrototypeOf(t, (this instanceof e ? this.constructor : void 0).prototype),
761
- t.name = "NotEnoughDataError", t;
762
- }
763
- return function(t, e) {
764
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
765
- t.prototype = Object.create(e && e.prototype, {
766
- constructor: {
767
- value: t,
768
- writable: !0,
769
- configurable: !0
770
- }
771
- }), Object.defineProperty(t, "prototype", {
772
- writable: !1
773
- }), e && I(t, e);
774
- }(e, t), r = e, n && T(r.prototype, n), o && T(r, o), Object.defineProperty(r, "prototype", {
775
- writable: !1
776
- }), r;
777
- var r, n, o;
778
- }( k(Error));
779
- // ./node_modules/trading-signals/dist/Indicator.js
780
- function R(t) {
781
- return R = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
782
- return typeof t;
783
- } : function(t) {
784
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
785
- }, R(t);
786
- }
787
- function C(t, e) {
788
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
789
- }
790
- function F(t, e) {
791
- for (var r = 0; r < e.length; r++) {
792
- var n = e[r];
793
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
794
- Object.defineProperty(t, H(n.key), n);
795
- }
796
- }
797
- function L(t, e, r) {
798
- return e && F(t.prototype, e), r && F(t, r), Object.defineProperty(t, "prototype", {
799
- writable: !1
800
- }), t;
801
- }
802
- function B(t, e, r) {
803
- return (e = H(e)) in t ? Object.defineProperty(t, e, {
804
- value: r,
805
- enumerable: !0,
806
- configurable: !0,
807
- writable: !0
808
- }) : t[e] = r, t;
809
- }
810
- function H(t) {
811
- var e = function(t, e) {
812
- if ("object" != R(t) || !t) return t;
813
- var r = t[Symbol.toPrimitive];
814
- if (void 0 !== r) {
815
- var n = r.call(t, e || "default");
816
- if ("object" != R(n)) return n;
817
- throw new TypeError("@@toPrimitive must return a primitive value.");
818
- }
819
- return ("string" === e ? String : Number)(t);
820
- }(t, "string");
821
- return "symbol" == R(e) ? e : e + "";
822
- }
823
- var V = function() {
824
- return L((function t() {
825
- C(this, t), B(this, "previousHighest", void 0), B(this, "highest", void 0), B(this, "previousLowest", void 0),
826
- B(this, "lowest", void 0), B(this, "previousResult", void 0), B(this, "result", void 0);
827
- }), [ {
828
- key: "isStable",
829
- get: function() {
830
- return void 0 !== this.result;
831
- }
832
- }, {
833
- key: "getResult",
834
- value: function() {
835
- if (void 0 === this.result) throw new M;
836
- return this.result;
837
- }
838
- }, {
839
- key: "setResult",
840
- value: function(t, e) {
841
- return e && (this.highest = this.previousHighest, this.lowest = this.previousLowest,
842
- this.result = this.previousResult), void 0 === this.highest ? this.highest = t : t > this.highest ? (this.previousHighest = this.highest,
843
- this.highest = t) : this.previousHighest = this.highest, void 0 === this.lowest ? this.lowest = t : t < this.lowest ? (this.previousLowest = this.lowest,
844
- this.lowest = t) : this.previousLowest = this.lowest, this.previousResult = this.result,
845
- this.result = t;
846
- }
847
- }, {
848
- key: "replace",
849
- value: function(t) {
850
- return this.update(t, !0);
851
- }
852
- } ]);
853
- }();
854
- // ./node_modules/trading-signals/dist/MA/MovingAverage.js
855
- function U(t) {
856
- return U = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
857
- return typeof t;
858
- } : function(t) {
859
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
860
- }, U(t);
861
- }
862
- function $(t, e) {
863
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
864
- }
865
- function q(t, e) {
866
- for (var r = 0; r < e.length; r++) {
867
- var n = e[r];
868
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
869
- Object.defineProperty(t, W(n.key), n);
870
- }
871
- }
872
- function z(t, e, r) {
873
- return e && q(t.prototype, e), r && q(t, r), Object.defineProperty(t, "prototype", {
874
- writable: !1
875
- }), t;
876
- }
877
- function G(t, e, r) {
878
- return e = Y(e), function(t, e) {
879
- if (e && ("object" == U(e) || "function" == typeof e)) return e;
880
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
881
- return function(t) {
882
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
883
- return t;
884
- }(t);
885
- }(t, K() ? Reflect.construct(e, r || [], Y(t).constructor) : e.apply(t, r));
886
- }
887
- function K() {
888
- try {
889
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
890
- } catch (t) {}
891
- return (K = function() {
892
- return !!t;
893
- })();
894
- }
895
- function Y(t) {
896
- return Y = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
897
- return t.__proto__ || Object.getPrototypeOf(t);
898
- }, Y(t);
899
- }
900
- function J(t, e) {
901
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
902
- t.prototype = Object.create(e && e.prototype, {
903
- constructor: {
904
- value: t,
905
- writable: !0,
906
- configurable: !0
907
- }
908
- }), Object.defineProperty(t, "prototype", {
909
- writable: !1
910
- }), e && Z(t, e);
911
- }
912
- function Z(t, e) {
913
- return Z = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
914
- return t.__proto__ = e, t;
915
- }, Z(t, e);
916
- }
917
- function Q(t, e, r) {
918
- return (e = W(e)) in t ? Object.defineProperty(t, e, {
919
- value: r,
920
- enumerable: !0,
921
- configurable: !0,
922
- writable: !0
923
- }) : t[e] = r, t;
924
- }
925
- function W(t) {
926
- var e = function(t, e) {
927
- if ("object" != U(t) || !t) return t;
928
- var r = t[Symbol.toPrimitive];
929
- if (void 0 !== r) {
930
- var n = r.call(t, e || "default");
931
- if ("object" != U(n)) return n;
932
- throw new TypeError("@@toPrimitive must return a primitive value.");
933
- }
934
- return ("string" === e ? String : Number)(t);
935
- }(t, "string");
936
- return "symbol" == U(e) ? e : e + "";
937
- }
938
- var X = function(t) {
939
- function e(t) {
940
- var r;
941
- return $(this, e), Q(r = G(this, e), "interval", void 0), r.interval = t, r;
942
- }
943
- return J(e, t), z(e, [ {
944
- key: "updates",
945
- value: function(t) {
946
- var e = this;
947
- return t.forEach((function(t) {
948
- return e.update(t);
949
- })), this.result;
950
- }
951
- }, {
952
- key: "replace",
953
- value: function(t) {
954
- return this.update(t, !0);
955
- }
956
- } ]);
957
- }(V);
958
- // ./node_modules/trading-signals/dist/SMA/SMA.js
959
- function tt(t) {
960
- return tt = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
961
- return typeof t;
962
- } : function(t) {
963
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
964
- }, tt(t);
965
- }
966
- function et(t, e) {
967
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
968
- }
969
- function rt(t, e) {
970
- for (var r = 0; r < e.length; r++) {
971
- var n = e[r];
972
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
973
- Object.defineProperty(t, st(n.key), n);
974
- }
975
- }
976
- function nt(t, e, r) {
977
- return e && rt(t.prototype, e), r && rt(t, r), Object.defineProperty(t, "prototype", {
978
- writable: !1
979
- }), t;
980
- }
981
- function ot(t, e, r) {
982
- return e = at(e), function(t, e) {
983
- if (e && ("object" == tt(e) || "function" == typeof e)) return e;
984
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
985
- return function(t) {
986
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
987
- return t;
988
- }(t);
989
- }(t, it() ? Reflect.construct(e, r || [], at(t).constructor) : e.apply(t, r));
990
- }
991
- function it() {
992
- try {
993
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
994
- } catch (t) {}
995
- return (it = function() {
996
- return !!t;
997
- })();
998
- }
999
- function at(t) {
1000
- return at = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
1001
- return t.__proto__ || Object.getPrototypeOf(t);
1002
- }, at(t);
1003
- }
1004
- function ut(t, e) {
1005
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
1006
- t.prototype = Object.create(e && e.prototype, {
1007
- constructor: {
1008
- value: t,
1009
- writable: !0,
1010
- configurable: !0
1011
- }
1012
- }), Object.defineProperty(t, "prototype", {
1013
- writable: !1
1014
- }), e && lt(t, e);
1015
- }
1016
- function lt(t, e) {
1017
- return lt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
1018
- return t.__proto__ = e, t;
1019
- }, lt(t, e);
1020
- }
1021
- function ct(t, e, r) {
1022
- return (e = st(e)) in t ? Object.defineProperty(t, e, {
1023
- value: r,
1024
- enumerable: !0,
1025
- configurable: !0,
1026
- writable: !0
1027
- }) : t[e] = r, t;
1028
- }
1029
- function st(t) {
1030
- var e = function(t, e) {
1031
- if ("object" != tt(t) || !t) return t;
1032
- var r = t[Symbol.toPrimitive];
1033
- if (void 0 !== r) {
1034
- var n = r.call(t, e || "default");
1035
- if ("object" != tt(n)) return n;
1036
- throw new TypeError("@@toPrimitive must return a primitive value.");
1037
- }
1038
- return ("string" === e ? String : Number)(t);
1039
- }(t, "string");
1040
- return "symbol" == tt(e) ? e : e + "";
1041
- }
1042
- var ft = function(t) {
1043
- function e() {
1044
- var t;
1045
- et(this, e);
1046
- for (var r = arguments.length, n = new Array(r), o = 0; o < r; o++) n[o] = arguments[o];
1047
- return ct(t = ot(this, e, [].concat(n)), "prices", []), t;
1048
- }
1049
- return ut(e, t), nt(e, [ {
1050
- key: "update",
1051
- value: function(t) {
1052
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1053
- if (this.prices.length && e ? this.prices[this.prices.length - 1] = t : this.prices.push(t),
1054
- this.prices.length > this.interval && this.prices.shift(), this.prices.length === this.interval) {
1055
- var r = this.prices.reduce((function(t, e) {
1056
- return t + e;
1057
- }), 0);
1058
- return this.setResult(r / this.prices.length, e);
1059
- }
1060
- }
1061
- } ]);
1062
- }(X);
1063
- // ./node_modules/trading-signals/dist/WSMA/WSMA.js
1064
- function yt(t) {
1065
- return yt = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1066
- return typeof t;
1067
- } : function(t) {
1068
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1069
- }, yt(t);
1070
- }
1071
- function pt(t, e) {
1072
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1073
- }
1074
- function ht(t, e) {
1075
- for (var r = 0; r < e.length; r++) {
1076
- var n = e[r];
1077
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1078
- Object.defineProperty(t, St(n.key), n);
1079
- }
1080
- }
1081
- function vt(t, e, r) {
1082
- return e && ht(t.prototype, e), r && ht(t, r), Object.defineProperty(t, "prototype", {
1083
- writable: !1
1084
- }), t;
1085
- }
1086
- function mt(t, e, r) {
1087
- return e = bt(e), function(t, e) {
1088
- if (e && ("object" == yt(e) || "function" == typeof e)) return e;
1089
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
1090
- return function(t) {
1091
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1092
- return t;
1093
- }(t);
1094
- }(t, dt() ? Reflect.construct(e, r || [], bt(t).constructor) : e.apply(t, r));
1095
- }
1096
- function dt() {
1097
- try {
1098
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
1099
- } catch (t) {}
1100
- return (dt = function() {
1101
- return !!t;
1102
- })();
1103
- }
1104
- function bt(t) {
1105
- return bt = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
1106
- return t.__proto__ || Object.getPrototypeOf(t);
1107
- }, bt(t);
1108
- }
1109
- function gt(t, e) {
1110
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
1111
- t.prototype = Object.create(e && e.prototype, {
1112
- constructor: {
1113
- value: t,
1114
- writable: !0,
1115
- configurable: !0
1116
- }
1117
- }), Object.defineProperty(t, "prototype", {
1118
- writable: !1
1119
- }), e && wt(t, e);
1120
- }
1121
- function wt(t, e) {
1122
- return wt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
1123
- return t.__proto__ = e, t;
1124
- }, wt(t, e);
1125
- }
1126
- function Ot(t, e, r) {
1127
- return (e = St(e)) in t ? Object.defineProperty(t, e, {
1128
- value: r,
1129
- enumerable: !0,
1130
- configurable: !0,
1131
- writable: !0
1132
- }) : t[e] = r, t;
1133
- }
1134
- function St(t) {
1135
- var e = function(t, e) {
1136
- if ("object" != yt(t) || !t) return t;
1137
- var r = t[Symbol.toPrimitive];
1138
- if (void 0 !== r) {
1139
- var n = r.call(t, e || "default");
1140
- if ("object" != yt(n)) return n;
1141
- throw new TypeError("@@toPrimitive must return a primitive value.");
1142
- }
1143
- return ("string" === e ? String : Number)(t);
1144
- }(t, "string");
1145
- return "symbol" == yt(e) ? e : e + "";
1146
- }
1147
- var jt = function(t) {
1148
- function e(t) {
1149
- var r;
1150
- return pt(this, e), Ot(r = mt(this, e), "interval", void 0), Ot(r, "indicator", void 0),
1151
- Ot(r, "smoothingFactor", void 0), r.interval = t, r.indicator = new ft(t), r.smoothingFactor = 1 / r.interval,
1152
- r;
1153
- }
1154
- return gt(e, t), vt(e, [ {
1155
- key: "updates",
1156
- value: function(t) {
1157
- var e = this;
1158
- return t.forEach((function(t) {
1159
- return e.update(t);
1160
- })), this.result;
1161
- }
1162
- }, {
1163
- key: "update",
1164
- value: function(t) {
1165
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], r = this.indicator.update(t);
1166
- if (e && void 0 !== this.previousResult) {
1167
- var n = (t - this.previousResult) * this.smoothingFactor;
1168
- return this.setResult(n + this.previousResult, e);
1169
- }
1170
- if (!e && void 0 !== this.result) {
1171
- var o = (t - this.result) * this.smoothingFactor;
1172
- return this.setResult(o + this.result, e);
1173
- }
1174
- if (void 0 === this.result && void 0 !== r) return this.setResult(r, e);
1175
- }
1176
- } ]);
1177
- }(V);
1178
- function Pt(t) {
1179
- return t.length ? t.reduce((function(t, e) {
1180
- return t + e;
1181
- }), 0) / t.length : 0;
1182
- }
1183
- // ./node_modules/trading-signals/dist/TR/TR.js
1184
- function _t(t) {
1185
- return _t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1186
- return typeof t;
1187
- } : function(t) {
1188
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1189
- }, _t(t);
1190
- }
1191
- function Nt(t, e) {
1192
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1193
- }
1194
- function Tt(t, e) {
1195
- for (var r = 0; r < e.length; r++) {
1196
- var n = e[r];
1197
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1198
- Object.defineProperty(t, Rt(n.key), n);
1199
- }
1200
- }
1201
- function At(t, e, r) {
1202
- return e && Tt(t.prototype, e), r && Tt(t, r), Object.defineProperty(t, "prototype", {
1203
- writable: !1
1204
- }), t;
1205
- }
1206
- function Et(t, e, r) {
1207
- return e = xt(e), function(t, e) {
1208
- if (e && ("object" == _t(e) || "function" == typeof e)) return e;
1209
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
1210
- return function(t) {
1211
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1212
- return t;
1213
- }(t);
1214
- }(t, kt() ? Reflect.construct(e, r || [], xt(t).constructor) : e.apply(t, r));
1215
- }
1216
- function kt() {
1217
- try {
1218
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
1219
- } catch (t) {}
1220
- return (kt = function() {
1221
- return !!t;
1222
- })();
1223
- }
1224
- function xt(t) {
1225
- return xt = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
1226
- return t.__proto__ || Object.getPrototypeOf(t);
1227
- }, xt(t);
1228
- }
1229
- function It(t, e) {
1230
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
1231
- t.prototype = Object.create(e && e.prototype, {
1232
- constructor: {
1233
- value: t,
1234
- writable: !0,
1235
- configurable: !0
1236
- }
1237
- }), Object.defineProperty(t, "prototype", {
1238
- writable: !1
1239
- }), e && Dt(t, e);
1240
- }
1241
- function Dt(t, e) {
1242
- return Dt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
1243
- return t.__proto__ = e, t;
1244
- }, Dt(t, e);
1245
- }
1246
- function Mt(t, e, r) {
1247
- return (e = Rt(e)) in t ? Object.defineProperty(t, e, {
1248
- value: r,
1249
- enumerable: !0,
1250
- configurable: !0,
1251
- writable: !0
1252
- }) : t[e] = r, t;
1253
- }
1254
- function Rt(t) {
1255
- var e = function(t, e) {
1256
- if ("object" != _t(t) || !t) return t;
1257
- var r = t[Symbol.toPrimitive];
1258
- if (void 0 !== r) {
1259
- var n = r.call(t, e || "default");
1260
- if ("object" != _t(n)) return n;
1261
- throw new TypeError("@@toPrimitive must return a primitive value.");
1262
- }
1263
- return ("string" === e ? String : Number)(t);
1264
- }(t, "string");
1265
- return "symbol" == _t(e) ? e : e + "";
1266
- }
1267
- var Ct = function(t) {
1268
- function e() {
1269
- var t;
1270
- Nt(this, e);
1271
- for (var r = arguments.length, n = new Array(r), o = 0; o < r; o++) n[o] = arguments[o];
1272
- return Mt(t = Et(this, e, [].concat(n)), "previousCandle", void 0), Mt(t, "twoPreviousCandle", void 0),
1273
- t;
1274
- }
1275
- return It(e, t), At(e, [ {
1276
- key: "update",
1277
- value: function(t) {
1278
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], r = t.high, n = t.low, o = r - n;
1279
- if (this.previousCandle && e && (this.previousCandle = this.twoPreviousCandle),
1280
- this.previousCandle) {
1281
- var i = Math.abs(r - this.previousCandle.close), a = Math.abs(n - this.previousCandle.close);
1282
- return this.twoPreviousCandle = this.previousCandle, this.previousCandle = t, this.setResult(Math.max(o, i, a), e);
1283
- }
1284
- return this.twoPreviousCandle = this.previousCandle, this.previousCandle = t, this.setResult(o, e);
1285
- }
1286
- } ]);
1287
- }(V);
1288
- // ./node_modules/trading-signals/dist/ATR/ATR.js
1289
- function Ft(t) {
1290
- return Ft = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1291
- return typeof t;
1292
- } : function(t) {
1293
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1294
- }, Ft(t);
1295
- }
1296
- function Lt(t, e) {
1297
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1298
- }
1299
- function Bt(t, e) {
1300
- for (var r = 0; r < e.length; r++) {
1301
- var n = e[r];
1302
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1303
- Object.defineProperty(t, Kt(n.key), n);
1304
- }
1305
- }
1306
- function Ht(t, e, r) {
1307
- return e && Bt(t.prototype, e), r && Bt(t, r), Object.defineProperty(t, "prototype", {
1308
- writable: !1
1309
- }), t;
1310
- }
1311
- function Vt(t, e, r) {
1312
- return e = $t(e), function(t, e) {
1313
- if (e && ("object" == Ft(e) || "function" == typeof e)) return e;
1314
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
1315
- return function(t) {
1316
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1317
- return t;
1318
- }(t);
1319
- }(t, Ut() ? Reflect.construct(e, r || [], $t(t).constructor) : e.apply(t, r));
1320
- }
1321
- function Ut() {
1322
- try {
1323
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
1324
- } catch (t) {}
1325
- return (Ut = function() {
1326
- return !!t;
1327
- })();
1328
- }
1329
- function $t(t) {
1330
- return $t = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
1331
- return t.__proto__ || Object.getPrototypeOf(t);
1332
- }, $t(t);
1333
- }
1334
- function qt(t, e) {
1335
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
1336
- t.prototype = Object.create(e && e.prototype, {
1337
- constructor: {
1338
- value: t,
1339
- writable: !0,
1340
- configurable: !0
1341
- }
1342
- }), Object.defineProperty(t, "prototype", {
1343
- writable: !1
1344
- }), e && zt(t, e);
1345
- }
1346
- function zt(t, e) {
1347
- return zt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
1348
- return t.__proto__ = e, t;
1349
- }, zt(t, e);
1350
- }
1351
- function Gt(t, e, r) {
1352
- return (e = Kt(e)) in t ? Object.defineProperty(t, e, {
1353
- value: r,
1354
- enumerable: !0,
1355
- configurable: !0,
1356
- writable: !0
1357
- }) : t[e] = r, t;
1358
- }
1359
- function Kt(t) {
1360
- var e = function(t, e) {
1361
- if ("object" != Ft(t) || !t) return t;
1362
- var r = t[Symbol.toPrimitive];
1363
- if (void 0 !== r) {
1364
- var n = r.call(t, e || "default");
1365
- if ("object" != Ft(n)) return n;
1366
- throw new TypeError("@@toPrimitive must return a primitive value.");
1367
- }
1368
- return ("string" === e ? String : Number)(t);
1369
- }(t, "string");
1370
- return "symbol" == Ft(e) ? e : e + "";
1371
- }
1372
- var Yt = function(t) {
1373
- function e(t) {
1374
- var r, n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : jt;
1375
- return Lt(this, e), Gt(r = Vt(this, e), "interval", void 0), Gt(r, "tr", void 0),
1376
- Gt(r, "smoothing", void 0), r.interval = t, r.tr = new Ct, r.smoothing = new n(t),
1377
- r;
1378
- }
1379
- return qt(e, t), Ht(e, [ {
1380
- key: "update",
1381
- value: function(t) {
1382
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], r = this.tr.update(t, e);
1383
- if (this.smoothing.update(r, e), this.smoothing.isStable) return this.setResult(this.smoothing.getResult(), e);
1384
- }
1385
- } ]);
1386
- }(V);
1387
- // ./node_modules/trading-signals/dist/BBANDS/BollingerBands.js
1388
- function Jt(t) {
1389
- return Jt = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1390
- return typeof t;
1391
- } : function(t) {
1392
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1393
- }, Jt(t);
1394
- }
1395
- function Zt(t, e) {
1396
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1397
- }
1398
- function Qt(t, e) {
1399
- for (var r = 0; r < e.length; r++) {
1400
- var n = e[r];
1401
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1402
- Object.defineProperty(t, te(n.key), n);
1403
- }
1404
- }
1405
- function Wt(t, e, r) {
1406
- return e && Qt(t.prototype, e), r && Qt(t, r), Object.defineProperty(t, "prototype", {
1407
- writable: !1
1408
- }), t;
1409
- }
1410
- function Xt(t, e, r) {
1411
- return (e = te(e)) in t ? Object.defineProperty(t, e, {
1412
- value: r,
1413
- enumerable: !0,
1414
- configurable: !0,
1415
- writable: !0
1416
- }) : t[e] = r, t;
1417
- }
1418
- function te(t) {
1419
- var e = function(t, e) {
1420
- if ("object" != Jt(t) || !t) return t;
1421
- var r = t[Symbol.toPrimitive];
1422
- if (void 0 !== r) {
1423
- var n = r.call(t, e || "default");
1424
- if ("object" != Jt(n)) return n;
1425
- throw new TypeError("@@toPrimitive must return a primitive value.");
1426
- }
1427
- return ("string" === e ? String : Number)(t);
1428
- }(t, "string");
1429
- return "symbol" == Jt(e) ? e : e + "";
1430
- }
1431
- var ee = function() {
1432
- return Wt((function t(e) {
1433
- var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 2;
1434
- Zt(this, t), Xt(this, "interval", void 0), Xt(this, "deviationMultiplier", void 0),
1435
- Xt(this, "prices", []), Xt(this, "result", void 0), this.interval = e, this.deviationMultiplier = r;
1436
- }), [ {
1437
- key: "update",
1438
- value: function(t) {
1439
- if (this.prices.push(t), this.prices.length > this.interval) {
1440
- this.prices.shift();
1441
- var e = Pt(this.prices), r = function(t, e) {
1442
- var r = e || Pt(t), n = Pt(t.map((function(t) {
1443
- return t - r;
1444
- })).map((function(t) {
1445
- return t * t;
1446
- })));
1447
- return Math.sqrt(n);
1448
- }(this.prices, e);
1449
- return this.result = {
1450
- lower: e - r * this.deviationMultiplier,
1451
- middle: e,
1452
- upper: e + r * this.deviationMultiplier
1453
- };
1454
- }
1455
- }
1456
- }, {
1457
- key: "getResult",
1458
- value: function() {
1459
- if (void 0 === this.result) throw new M;
1460
- return this.result;
1461
- }
1462
- }, {
1463
- key: "isStable",
1464
- get: function() {
1465
- return void 0 !== this.result;
1466
- }
1467
- } ]);
1468
- }();
1469
- // ./node_modules/trading-signals/dist/EMA/EMA.js
1470
- function re(t) {
1471
- return re = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1472
- return typeof t;
1473
- } : function(t) {
1474
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1475
- }, re(t);
1476
- }
1477
- function ne(t, e) {
1478
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1479
- }
1480
- function oe(t, e) {
1481
- for (var r = 0; r < e.length; r++) {
1482
- var n = e[r];
1483
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1484
- Object.defineProperty(t, ye(n.key), n);
1485
- }
1486
- }
1487
- function ie(t, e, r) {
1488
- return e && oe(t.prototype, e), r && oe(t, r), Object.defineProperty(t, "prototype", {
1489
- writable: !1
1490
- }), t;
1491
- }
1492
- function ae(t, e, r) {
1493
- return e = le(e), function(t, e) {
1494
- if (e && ("object" == re(e) || "function" == typeof e)) return e;
1495
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
1496
- return function(t) {
1497
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1498
- return t;
1499
- }(t);
1500
- }(t, ue() ? Reflect.construct(e, r || [], le(t).constructor) : e.apply(t, r));
1501
- }
1502
- function ue() {
1503
- try {
1504
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
1505
- } catch (t) {}
1506
- return (ue = function() {
1507
- return !!t;
1508
- })();
1509
- }
1510
- function le(t) {
1511
- return le = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
1512
- return t.__proto__ || Object.getPrototypeOf(t);
1513
- }, le(t);
1514
- }
1515
- function ce(t, e) {
1516
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
1517
- t.prototype = Object.create(e && e.prototype, {
1518
- constructor: {
1519
- value: t,
1520
- writable: !0,
1521
- configurable: !0
1522
- }
1523
- }), Object.defineProperty(t, "prototype", {
1524
- writable: !1
1525
- }), e && se(t, e);
1526
- }
1527
- function se(t, e) {
1528
- return se = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
1529
- return t.__proto__ = e, t;
1530
- }, se(t, e);
1531
- }
1532
- function fe(t, e, r) {
1533
- return (e = ye(e)) in t ? Object.defineProperty(t, e, {
1534
- value: r,
1535
- enumerable: !0,
1536
- configurable: !0,
1537
- writable: !0
1538
- }) : t[e] = r, t;
1539
- }
1540
- function ye(t) {
1541
- var e = function(t, e) {
1542
- if ("object" != re(t) || !t) return t;
1543
- var r = t[Symbol.toPrimitive];
1544
- if (void 0 !== r) {
1545
- var n = r.call(t, e || "default");
1546
- if ("object" != re(n)) return n;
1547
- throw new TypeError("@@toPrimitive must return a primitive value.");
1548
- }
1549
- return ("string" === e ? String : Number)(t);
1550
- }(t, "string");
1551
- return "symbol" == re(e) ? e : e + "";
1552
- }
1553
- var pe = function(t) {
1554
- function e(t) {
1555
- var r;
1556
- return ne(this, e), fe(r = ae(this, e, [ t ]), "interval", void 0), fe(r, "pricesCounter", 0),
1557
- fe(r, "weightFactor", void 0), r.interval = t, r.weightFactor = 2 / (r.interval + 1),
1558
- r;
1559
- }
1560
- return ce(e, t), ie(e, [ {
1561
- key: "update",
1562
- value: function(t) {
1563
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1564
- return e ? e && 0 === this.pricesCounter && this.pricesCounter++ : this.pricesCounter++,
1565
- 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);
1566
- }
1567
- }, {
1568
- key: "getResult",
1569
- value: function() {
1570
- if (this.pricesCounter < this.interval) throw new M;
1571
- return this.result;
1572
- }
1573
- }, {
1574
- key: "isStable",
1575
- get: function() {
1576
- try {
1577
- return this.getResult(), !0;
1578
- } catch (t) {
1579
- return !1;
1580
- }
1581
- }
1582
- } ]);
1583
- }(X);
1584
- // ./node_modules/trading-signals/dist/MACD/MACD.js
1585
- function he(t) {
1586
- return he = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1587
- return typeof t;
1588
- } : function(t) {
1589
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1590
- }, he(t);
1591
- }
1592
- function ve(t, e) {
1593
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1594
- }
1595
- function me(t, e) {
1596
- for (var r = 0; r < e.length; r++) {
1597
- var n = e[r];
1598
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1599
- Object.defineProperty(t, ge(n.key), n);
1600
- }
1601
- }
1602
- function de(t, e, r) {
1603
- return e && me(t.prototype, e), r && me(t, r), Object.defineProperty(t, "prototype", {
1604
- writable: !1
1605
- }), t;
1606
- }
1607
- function be(t, e, r) {
1608
- return (e = ge(e)) in t ? Object.defineProperty(t, e, {
1609
- value: r,
1610
- enumerable: !0,
1611
- configurable: !0,
1612
- writable: !0
1613
- }) : t[e] = r, t;
1614
- }
1615
- function ge(t) {
1616
- var e = function(t, e) {
1617
- if ("object" != he(t) || !t) return t;
1618
- var r = t[Symbol.toPrimitive];
1619
- if (void 0 !== r) {
1620
- var n = r.call(t, e || "default");
1621
- if ("object" != he(n)) return n;
1622
- throw new TypeError("@@toPrimitive must return a primitive value.");
1623
- }
1624
- return ("string" === e ? String : Number)(t);
1625
- }(t, "string");
1626
- return "symbol" == he(e) ? e : e + "";
1627
- }
1628
- var we = function() {
1629
- return de((function t(e, r, n) {
1630
- ve(this, t), be(this, "short", void 0), be(this, "long", void 0), be(this, "signal", void 0),
1631
- be(this, "prices", []), be(this, "result", void 0), this.short = e, this.long = r,
1632
- this.signal = n;
1633
- }), [ {
1634
- key: "getResult",
1635
- value: function() {
1636
- if (void 0 === this.result) throw new M;
1637
- return this.result;
1638
- }
1639
- }, {
1640
- key: "isStable",
1641
- get: function() {
1642
- return void 0 !== this.result;
1643
- }
1644
- }, {
1645
- key: "update",
1646
- value: function(t) {
1647
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1648
- this.prices.length && e ? this.prices[this.prices.length - 1] = t : this.prices.push(t);
1649
- var r = this.short.update(t, e), n = this.long.update(t, e);
1650
- if (this.prices.length > this.long.interval && this.prices.shift(), this.prices.length === this.long.interval) {
1651
- var o = r - n, i = this.signal.update(o, e);
1652
- return this.result = {
1653
- histogram: o - i,
1654
- macd: o,
1655
- signal: i
1656
- };
1657
- }
1658
- }
1659
- } ]);
1660
- }();
1661
- // ./node_modules/trading-signals/dist/RSI/RSI.js
1662
- function Oe(t) {
1663
- return Oe = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1664
- return typeof t;
1665
- } : function(t) {
1666
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1667
- }, Oe(t);
1668
- }
1669
- function Se(t, e) {
1670
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
1671
- }
1672
- function je(t, e) {
1673
- for (var r = 0; r < e.length; r++) {
1674
- var n = e[r];
1675
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
1676
- Object.defineProperty(t, xe(n.key), n);
1677
- }
1678
- }
1679
- function Pe(t, e, r) {
1680
- return e && je(t.prototype, e), r && je(t, r), Object.defineProperty(t, "prototype", {
1681
- writable: !1
1682
- }), t;
1683
- }
1684
- function _e(t, e, r) {
1685
- return e = Te(e), function(t, e) {
1686
- if (e && ("object" == Oe(e) || "function" == typeof e)) return e;
1687
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
1688
- return function(t) {
1689
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1690
- return t;
1691
- }(t);
1692
- }(t, Ne() ? Reflect.construct(e, r || [], Te(t).constructor) : e.apply(t, r));
1693
- }
1694
- function Ne() {
1695
- try {
1696
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
1697
- } catch (t) {}
1698
- return (Ne = function() {
1699
- return !!t;
1700
- })();
1701
- }
1702
- function Te(t) {
1703
- return Te = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
1704
- return t.__proto__ || Object.getPrototypeOf(t);
1705
- }, Te(t);
1706
- }
1707
- function Ae(t, e) {
1708
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
1709
- t.prototype = Object.create(e && e.prototype, {
1710
- constructor: {
1711
- value: t,
1712
- writable: !0,
1713
- configurable: !0
1714
- }
1715
- }), Object.defineProperty(t, "prototype", {
1716
- writable: !1
1717
- }), e && Ee(t, e);
1718
- }
1719
- function Ee(t, e) {
1720
- return Ee = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
1721
- return t.__proto__ = e, t;
1722
- }, Ee(t, e);
1723
- }
1724
- function ke(t, e, r) {
1725
- return (e = xe(e)) in t ? Object.defineProperty(t, e, {
1726
- value: r,
1727
- enumerable: !0,
1728
- configurable: !0,
1729
- writable: !0
1730
- }) : t[e] = r, t;
1731
- }
1732
- function xe(t) {
1733
- var e = function(t, e) {
1734
- if ("object" != Oe(t) || !t) return t;
1735
- var r = t[Symbol.toPrimitive];
1736
- if (void 0 !== r) {
1737
- var n = r.call(t, e || "default");
1738
- if ("object" != Oe(n)) return n;
1739
- throw new TypeError("@@toPrimitive must return a primitive value.");
1740
- }
1741
- return ("string" === e ? String : Number)(t);
1742
- }(t, "string");
1743
- return "symbol" == Oe(e) ? e : e + "";
1744
- }
1745
- var Ie = function(t) {
1746
- function e(t) {
1747
- var r, n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : jt;
1748
- return Se(this, e), ke(r = _e(this, e), "interval", void 0), ke(r, "previousPrices", []),
1749
- ke(r, "avgGain", void 0), ke(r, "avgLoss", void 0), ke(r, "maxValue", 100), r.interval = t,
1750
- r.avgGain = new n(r.interval), r.avgLoss = new n(r.interval), r;
1751
- }
1752
- return Ae(e, t), Pe(e, [ {
1753
- key: "update",
1754
- value: function(t) {
1755
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1756
- if (this.previousPrices.length && e ? this.previousPrices[this.previousPrices.length - 1] = t : this.previousPrices.push(t),
1757
- !(this.previousPrices.length < 2)) {
1758
- var r = t, n = this.previousPrices[this.previousPrices.length - 2];
1759
- if (r > n ? (this.avgLoss.update(0, e), this.avgGain.update(t - n, e)) : (this.avgLoss.update(n - r, e),
1760
- this.avgGain.update(0, e)), this.avgGain.isStable) {
1761
- var o = this.avgLoss.getResult();
1762
- if (0 === o) return this.setResult(100, e);
1763
- var i = this.avgGain.getResult() / o;
1764
- return this.setResult(this.maxValue - this.maxValue / (i + 1), e);
1765
- }
1766
- }
1767
- }
1768
- } ]);
1769
- }(V);
1770
- // ./src/oscillators/rsi.js
1771
- function De(t) {
1772
- return De = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1773
- return typeof t;
1774
- } : function(t) {
1775
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1776
- }, De(t);
1777
- }
1778
- function Me(t, e, r) {
1779
- return (e = function(t) {
1780
- var e = function(t, e) {
1781
- if ("object" != De(t) || !t) return t;
1782
- var r = t[Symbol.toPrimitive];
1783
- if (void 0 !== r) {
1784
- var n = r.call(t, e || "default");
1785
- if ("object" != De(n)) return n;
1786
- throw new TypeError("@@toPrimitive must return a primitive value.");
1787
- }
1788
- return ("string" === e ? String : Number)(t);
1789
- }(t, "string");
1790
- return "symbol" == De(e) ? e : e + "";
1791
- }(e)) in t ? Object.defineProperty(t, e, {
1792
- value: r,
1793
- enumerable: !0,
1794
- configurable: !0,
1795
- writable: !0
1796
- }) : t[e] = r, t;
1797
- }
1798
- var Re = {
1799
- ema: pe,
1800
- sma: ft
1801
- }, Ce = function(t, e, r, n, o) {
1802
- var i = o.target, a = (o.lag, o.precomputed), u = t.verticalOhlcv, l = t.instances, c = a.keyName;
1803
- if (0 === e && !u.hasOwnProperty(i)) throw new Error("Target property ".concat(i, " not found in verticalOhlcv for ").concat(r, "."));
1804
- // Retrieve the current price value.
1805
- var s = u[i][e], f = l[c];
1806
- // Update the moving average instance.
1807
- f.update(s);
1808
- var y = NaN;
1809
- try {
1810
- y = f.getResult();
1811
- } catch (t) {}
1812
- // Always push the MA value (even if NaN).
1813
- return t.pushToMain({
1814
- index: e,
1815
- key: c,
1816
- value: y
1817
- }), !0;
1818
- }, Fe = function(t) {
1819
- 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) : "", y = "".concat(i, "_").concat(r).concat(f);
1820
- // Create the main moving average instance.
1821
- return a[y] = new Re[i](r), u[y] = new Float64Array(s).fill(NaN), l.add(y), o > 0 && e.lag([ y ], o),
1822
- c[y] = "Float64Array", {
1823
- keyName: y
1824
- };
1825
- };
1826
- // ./src/moving-averages/macd.js
1827
- function Le(t) {
1828
- return Le = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1829
- return typeof t;
1830
- } : function(t) {
1831
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1832
- }, Le(t);
1833
- }
1834
- function Be(t, e, r) {
1835
- return (e = function(t) {
1836
- var e = function(t, e) {
1837
- if ("object" != Le(t) || !t) return t;
1838
- var r = t[Symbol.toPrimitive];
1839
- if (void 0 !== r) {
1840
- var n = r.call(t, e || "default");
1841
- if ("object" != Le(n)) return n;
1842
- throw new TypeError("@@toPrimitive must return a primitive value.");
1843
- }
1844
- return ("string" === e ? String : Number)(t);
1845
- }(t, "string");
1846
- return "symbol" == Le(e) ? e : e + "";
1847
- }(e)) in t ? Object.defineProperty(t, e, {
1848
- value: r,
1849
- enumerable: !0,
1850
- configurable: !0,
1851
- writable: !0
1852
- }) : t[e] = r, t;
1853
- }
1854
- function He(t, e) {
1855
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
1856
- if (!r) {
1857
- if (Array.isArray(t) || (r = function(t, e) {
1858
- if (t) {
1859
- if ("string" == typeof t) return Ve(t, e);
1860
- var r = {}.toString.call(t).slice(8, -1);
1861
- 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) ? Ve(t, e) : void 0;
1862
- }
1863
- }(t)) || e && t && "number" == typeof t.length) {
1864
- r && (t = r);
1865
- var n = 0, o = function() {};
1866
- return {
1867
- s: o,
1868
- n: function() {
1869
- return n >= t.length ? {
1870
- done: !0
1871
- } : {
1872
- done: !1,
1873
- value: t[n++]
1874
- };
1875
- },
1876
- e: function(t) {
1877
- throw t;
1878
- },
1879
- f: o
1880
- };
1881
- }
1882
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1883
- }
1884
- var i, a = !0, u = !1;
1885
- return {
1886
- s: function() {
1887
- r = r.call(t);
1888
- },
1889
- n: function() {
1890
- var t = r.next();
1891
- return a = t.done, t;
1892
- },
1893
- e: function(t) {
1894
- u = !0, i = t;
1895
- },
1896
- f: function() {
1897
- try {
1898
- a || null == r.return || r.return();
1899
- } finally {
1900
- if (u) throw i;
1901
- }
1902
- }
1903
- };
1904
- }
1905
- function Ve(t, e) {
1906
- (null == e || e > t.length) && (e = t.length);
1907
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
1908
- return n;
1909
- }
1910
- var Ue = "close";
1911
- // ./src/utilities/numberUtilities.js
1912
- function $e(t) {
1913
- return $e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1914
- return typeof t;
1915
- } : function(t) {
1916
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1917
- }, $e(t);
1918
- }
1919
- // Helper to clean non-numeric characters (except "-" at the start and decimal point)
1920
- var qe = {
1921
- number: function(t) {
1922
- return t;
1923
- },
1924
- numberCleanString: function(t) {
1925
- return Number(t);
1926
- },
1927
- numberDirtyString: function(t) {
1928
- return Number(t.replace(/(?!^-)[^0-9.]/g, ""));
1929
- }
1930
- }, ze = function(t) {
1931
- var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1932
- // 1) true numbers
1933
- if ("number" == typeof t && !Number.isNaN(t)) return "number";
1934
- // 2) strings
1935
- if ("string" == typeof t) {
1936
- var r = t.trim(), n = /^-?\d+(\.\d+)?$/;
1937
- // a) clean numeric string: only digits and an optional single period
1938
- if (n.test(r)) return "numberCleanString";
1939
- // b) dirty numeric string: contains non-digits (dollar, commas, letters, etc.)
1940
- // but once you strip those out, you're left with a valid number
1941
- var o = r.replace(/[^0-9.]/g, "");
1942
- if (o && n.test(o)) return "numberDirtyString";
1943
- }
1944
- if (e) throw new TypeError("Invalid input: expected a number or numeric string");
1945
- return $e(t);
1946
- }, Ge = function(t, e) {
1947
- var r = Math.pow(10, e);
1948
- // add a tiny epsilon to mitigate floating-point quirks around .5
1949
- return Math.round((t + Number.EPSILON) * r) / r;
1950
- };
1951
- // ./src/moving-averages/donchianChannel.js
1952
- function Ke(t) {
1953
- return function(t) {
1954
- if (Array.isArray(t)) return Je(t);
1955
- }(t) || function(t) {
1956
- if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"]) return Array.from(t);
1957
- }(t) || Ye(t) || function() {
1958
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1959
- }();
1960
- }
1961
- function Ye(t, e) {
1962
- if (t) {
1963
- if ("string" == typeof t) return Je(t, e);
1964
- var r = {}.toString.call(t).slice(8, -1);
1965
- 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;
1966
- }
1967
- }
1968
- function Je(t, e) {
1969
- (null == e || e > t.length) && (e = t.length);
1970
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
1971
- return n;
1972
- }
1973
- // ./src/moving-averages/bollingerBands.js
1974
- function Ze(t) {
1975
- return Ze = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1976
- return typeof t;
1977
- } : function(t) {
1978
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
1979
- }, Ze(t);
1980
- }
1981
- function Qe(t, e) {
1982
- var r = Object.keys(t);
1983
- if (Object.getOwnPropertySymbols) {
1984
- var n = Object.getOwnPropertySymbols(t);
1985
- e && (n = n.filter((function(e) {
1986
- return Object.getOwnPropertyDescriptor(t, e).enumerable;
1987
- }))), r.push.apply(r, n);
1988
- }
1989
- return r;
1990
- }
1991
- function We(t, e, r) {
1992
- return (e = function(t) {
1993
- var e = function(t, e) {
1994
- if ("object" != Ze(t) || !t) return t;
1995
- var r = t[Symbol.toPrimitive];
1996
- if (void 0 !== r) {
1997
- var n = r.call(t, e || "default");
1998
- if ("object" != Ze(n)) return n;
1999
- throw new TypeError("@@toPrimitive must return a primitive value.");
2000
- }
2001
- return ("string" === e ? String : Number)(t);
2002
- }(t, "string");
2003
- return "symbol" == Ze(e) ? e : e + "";
2004
- }(e)) in t ? Object.defineProperty(t, e, {
2005
- value: r,
2006
- enumerable: !0,
2007
- configurable: !0,
2008
- writable: !0
2009
- }) : t[e] = r, t;
2010
- }
2011
- function Xe(t, e) {
2012
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2013
- if (!r) {
2014
- if (Array.isArray(t) || (r = function(t, e) {
2015
- if (t) {
2016
- if ("string" == typeof t) return tr(t, e);
2017
- var r = {}.toString.call(t).slice(8, -1);
2018
- 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;
2019
- }
2020
- }(t)) || e && t && "number" == typeof t.length) {
2021
- r && (t = r);
2022
- var n = 0, o = function() {};
2023
- return {
2024
- s: o,
2025
- n: function() {
2026
- return n >= t.length ? {
2027
- done: !0
2028
- } : {
2029
- done: !1,
2030
- value: t[n++]
2031
- };
2032
- },
2033
- e: function(t) {
2034
- throw t;
2035
- },
2036
- f: o
2037
- };
2038
- }
2039
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2040
- }
2041
- var i, a = !0, u = !1;
2042
- return {
2043
- s: function() {
2044
- r = r.call(t);
2045
- },
2046
- n: function() {
2047
- var t = r.next();
2048
- return a = t.done, t;
2049
- },
2050
- e: function(t) {
2051
- u = !0, i = t;
2052
- },
2053
- f: function() {
2054
- try {
2055
- a || null == r.return || r.return();
2056
- } finally {
2057
- if (u) throw i;
2058
- }
2059
- }
2060
- };
2061
- }
2062
- function tr(t, e) {
2063
- (null == e || e > t.length) && (e = t.length);
2064
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
2065
- return n;
2066
- }
2067
- // ./src/oscillators/volumeOscillator.js
2068
- function er(t) {
2069
- return er = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
2070
- return typeof t;
2071
- } : function(t) {
2072
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
2073
- }, er(t);
2074
- }
2075
- function rr(t, e, r) {
2076
- return (e = function(t) {
2077
- var e = function(t, e) {
2078
- if ("object" != er(t) || !t) return t;
2079
- var r = t[Symbol.toPrimitive];
2080
- if (void 0 !== r) {
2081
- var n = r.call(t, e || "default");
2082
- if ("object" != er(n)) return n;
2083
- throw new TypeError("@@toPrimitive must return a primitive value.");
2084
- }
2085
- return ("string" === e ? String : Number)(t);
2086
- }(t, "string");
2087
- return "symbol" == er(e) ? e : e + "";
2088
- }(e)) in t ? Object.defineProperty(t, e, {
2089
- value: r,
2090
- enumerable: !0,
2091
- configurable: !0,
2092
- writable: !0
2093
- }) : t[e] = r, t;
2094
- }
2095
- // ./src/utilities/dateUtilities.js
2096
- function nr(t) {
2097
- return nr = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
2098
- return typeof t;
2099
- } : function(t) {
2100
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
2101
- }, nr(t);
2102
- }
2103
- var or = {
2104
- string: function(t) {
2105
- return t.toISOString();
2106
- },
2107
- milliseconds: function(t) {
2108
- return t.getTime();
2109
- },
2110
- seconds: function(t) {
2111
- return t.getTime() / 1e3;
2112
- },
2113
- object: function(t) {
2114
- return t;
2115
- }
2116
- }, ir = {
2117
- dateObject: function(t) {
2118
- return t;
2119
- },
2120
- dateMilliseconds: function(t) {
2121
- return new Date(t);
2122
- },
2123
- dateSeconds: function(t) {
2124
- return new Date(1e3 * t);
2125
- },
2126
- dateIncompleteDayString: function(t) {
2127
- return new Date("".concat(t, " 00:00:00"));
2128
- },
2129
- dateCompleteDateString: function(t) {
2130
- return new Date(t);
2131
- }
2132
- }, ar = function(t) {
2133
- // Regex for a UTC Time Format where the string ends with "Z".
2134
- 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() {
2135
- throw new Error('Invalid "'.concat(nr(t), '" date value passed in selectDateFormatter. Supported formats: \n-').concat(e.join("\n- ")));
2136
- };
2137
- // Regex for a Timezone Offset Format,
2138
- // which includes a plus or minus sign followed by HH:MM at the end.
2139
- if ("object" === nr(t)) {
2140
- if (t instanceof Date && !isNaN(t.valueOf())) return "dateObject";
2141
- r();
2142
- } else {
2143
- if ("number" == typeof t)
2144
- // Use a numeric threshold based on the absolute value: typically,
2145
- // if the absolute value is below 1e11, then it's a seconds timestamp.
2146
- // Otherwise, it's a milliseconds timestamp.
2147
- return Math.abs(t) < 1e11 ? "dateSeconds" : "dateMillseconds";
2148
- if ("string" == typeof t) {
2149
- 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";
2150
- if (/^\d{4}-\d{2}-\d{2}$/.test(t)) return "dateIncompleteDayString";
2151
- r();
2152
- } else r();
2153
- }
2154
- };
2155
- // ./src/utilities/assignTypes.js
2156
- function ur(t, e) {
2157
- return function(t) {
2158
- if (Array.isArray(t)) return t;
2159
- }(t) || function(t, e) {
2160
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2161
- if (null != r) {
2162
- var n, o, i, a, u = [], l = !0, c = !1;
2163
- try {
2164
- if (i = (r = r.call(t)).next, 0 === e) {
2165
- if (Object(r) !== r) return;
2166
- l = !1;
2167
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
2168
- } catch (t) {
2169
- c = !0, o = t;
2170
- } finally {
2171
- try {
2172
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
2173
- } finally {
2174
- if (c) throw o;
2175
- }
2176
- }
2177
- return u;
2178
- }
2179
- }(t, e) || function(t, e) {
2180
- if (t) {
2181
- if ("string" == typeof t) return lr(t, e);
2182
- var r = {}.toString.call(t).slice(8, -1);
2183
- 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;
2184
- }
2185
- }(t, e) || function() {
2186
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2187
- }();
2188
- }
2189
- function lr(t, e) {
2190
- (null == e || e > t.length) && (e = t.length);
2191
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
2192
- return n;
2193
- }
2194
- var cr = new Set([ "open", "high", "low", "close" ]), sr = function(t, e) {
2195
- return "Array" === t ? new Array(e).fill(null) : "Float64Array" === t ? new Float64Array(e).fill(NaN) : "Int32Array" === t ? new Int32Array(e).fill(NaN) : void 0;
2196
- };
2197
- // ./src/studies/lag.js
2198
- function fr(t, e) {
2199
- return function(t) {
2200
- if (Array.isArray(t)) return t;
2201
- }(t) || function(t, e) {
2202
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2203
- if (null != r) {
2204
- var n, o, i, a, u = [], l = !0, c = !1;
2205
- try {
2206
- if (i = (r = r.call(t)).next, 0 === e) {
2207
- if (Object(r) !== r) return;
2208
- l = !1;
2209
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
2210
- } catch (t) {
2211
- c = !0, o = t;
2212
- } finally {
2213
- try {
2214
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
2215
- } finally {
2216
- if (c) throw o;
2217
- }
2218
- }
2219
- return u;
2220
- }
2221
- }(t, e) || pr(t, e) || function() {
2222
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2223
- }();
2224
- }
2225
- function yr(t, e) {
2226
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2227
- if (!r) {
2228
- if (Array.isArray(t) || (r = pr(t)) || e && t && "number" == typeof t.length) {
2229
- r && (t = r);
2230
- var n = 0, o = function() {};
2231
- return {
2232
- s: o,
2233
- n: function() {
2234
- return n >= t.length ? {
2235
- done: !0
2236
- } : {
2237
- done: !1,
2238
- value: t[n++]
2239
- };
2240
- },
2241
- e: function(t) {
2242
- throw t;
2243
- },
2244
- f: o
2245
- };
2246
- }
2247
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2248
- }
2249
- var i, a = !0, u = !1;
2250
- return {
2251
- s: function() {
2252
- r = r.call(t);
2253
- },
2254
- n: function() {
2255
- var t = r.next();
2256
- return a = t.done, t;
2257
- },
2258
- e: function(t) {
2259
- u = !0, i = t;
2260
- },
2261
- f: function() {
2262
- try {
2263
- a || null == r.return || r.return();
2264
- } finally {
2265
- if (u) throw i;
2266
- }
2267
- }
2268
- };
2269
- }
2270
- function pr(t, e) {
2271
- if (t) {
2272
- if ("string" == typeof t) return hr(t, e);
2273
- var r = {}.toString.call(t).slice(8, -1);
2274
- 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) ? hr(t, e) : void 0;
2275
- }
2276
- }
2277
- function hr(t, e) {
2278
- (null == e || e > t.length) && (e = t.length);
2279
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
2280
- return n;
2281
- }
2282
- var vr = function(t, e) {
2283
- var r = t.instances, n = t.verticalOhlcv, o = t.len, i = t.arrayTypes, a = t.priceBased;
2284
- if (0 === e) {
2285
- var u, l = [], c = yr(t.inputParams);
2286
- try {
2287
- for (c.s(); !(u = c.n()).done; ) {
2288
- var s = u.value;
2289
- "lag" === s.key && l.push(s.params);
2290
- }
2291
- } catch (t) {
2292
- c.e(t);
2293
- } finally {
2294
- c.f();
2295
- }
2296
- for (var f = 0, y = l; f < y.length; f++) {
2297
- var p, h = fr(y[f], 2), v = h[0], m = h[1], d = yr(v);
2298
- try {
2299
- for (d.s(); !(p = d.n()).done; ) {
2300
- var b = p.value;
2301
- if (a.has(b)) for (var g = 1; g <= m; g++) a.add("".concat(b, "_lag_").concat(g));
2302
- }
2303
- } catch (t) {
2304
- d.e(t);
2305
- } finally {
2306
- d.f();
2307
- }
2308
- }
2309
- r.lag = {
2310
- lagParams: l
2311
- };
2312
- }
2313
- var w, O = yr(r.lag.lagParams);
2314
- try {
2315
- for (O.s(); !(w = O.n()).done; ) {
2316
- var S, j = fr(w.value, 2), P = j[0], _ = j[1], N = yr(P);
2317
- try {
2318
- for (N.s(); !(S = N.n()).done; ) {
2319
- var T = S.value, A = n[T];
2320
- // Initialize lagged arrays only on the first index
2321
- if (0 === e) for (var E = 1; E <= _; E++) {
2322
- var k = "".concat(T, "_lag_").concat(E);
2323
- 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.'));
2324
- n[k] = sr(i[T], o), i[k] = i[T];
2325
- }
2326
- // Populate lagged values
2327
- for (var x = 1; x <= _; x++) {
2328
- var I = "".concat(T, "_lag_").concat(x), D = e - x, M = D <= 0 || void 0 === A[D] ? null : A[D];
2329
- t.pushToMain({
2330
- index: e,
2331
- key: I,
2332
- value: M
2333
- });
2334
- }
2335
- }
2336
- } catch (t) {
2337
- N.e(t);
2338
- } finally {
2339
- N.f();
2340
- }
2341
- }
2342
- } catch (t) {
2343
- O.e(t);
2344
- } finally {
2345
- O.f();
2346
- }
2347
- return !0;
2348
- };
2349
- // ./src/studies/findCrosses.js
2350
- function mr(t, e) {
2351
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2352
- if (!r) {
2353
- if (Array.isArray(t) || (r = function(t, e) {
2354
- if (t) {
2355
- if ("string" == typeof t) return dr(t, e);
2356
- var r = {}.toString.call(t).slice(8, -1);
2357
- 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) ? dr(t, e) : void 0;
2358
- }
2359
- }(t)) || e && t && "number" == typeof t.length) {
2360
- r && (t = r);
2361
- var n = 0, o = function() {};
2362
- return {
2363
- s: o,
2364
- n: function() {
2365
- return n >= t.length ? {
2366
- done: !0
2367
- } : {
2368
- done: !1,
2369
- value: t[n++]
2370
- };
2371
- },
2372
- e: function(t) {
2373
- throw t;
2374
- },
2375
- f: o
2376
- };
2377
- }
2378
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2379
- }
2380
- var i, a = !0, u = !1;
2381
- return {
2382
- s: function() {
2383
- r = r.call(t);
2384
- },
2385
- n: function() {
2386
- var t = r.next();
2387
- return a = t.done, t;
2388
- },
2389
- e: function(t) {
2390
- u = !0, i = t;
2391
- },
2392
- f: function() {
2393
- try {
2394
- a || null == r.return || r.return();
2395
- } finally {
2396
- if (u) throw i;
2397
- }
2398
- }
2399
- };
2400
- }
2401
- function dr(t, e) {
2402
- (null == e || e > t.length) && (e = t.length);
2403
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
2404
- return n;
2405
- }
2406
- function br(t) {
2407
- return br = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
2408
- return typeof t;
2409
- } : function(t) {
2410
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
2411
- }, br(t);
2412
- }
2413
- function gr(t, e) {
2414
- for (var r = 0; r < e.length; r++) {
2415
- var n = e[r];
2416
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
2417
- Object.defineProperty(t, wr(n.key), n);
2418
- }
2419
- }
2420
- function wr(t) {
2421
- var e = function(t, e) {
2422
- if ("object" != br(t) || !t) return t;
2423
- var r = t[Symbol.toPrimitive];
2424
- if (void 0 !== r) {
2425
- var n = r.call(t, e || "default");
2426
- if ("object" != br(n)) return n;
2427
- throw new TypeError("@@toPrimitive must return a primitive value.");
2428
- }
2429
- return ("string" === e ? String : Number)(t);
2430
- }(t, "string");
2431
- return "symbol" == br(e) ? e : e + "";
2432
- }
2433
- var Or = function(t, e) {
2434
- return t > e;
2435
- }, Sr = function(t, e) {
2436
- return t < e;
2437
- }, jr = function() {
2438
- return t = function t() {
2439
- !function(t, e) {
2440
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
2441
- }(this, t), Object.assign(this, {
2442
- interval: 0,
2443
- prevState: .5,
2444
- prevFast: NaN,
2445
- prevSlow: NaN,
2446
- prevHigh: NaN,
2447
- prevLow: NaN,
2448
- areHighAndLowUndefined: !1,
2449
- crossIndexes: {
2450
- up: [],
2451
- down: []
2452
- }
2453
- });
2454
- }, (e = [ {
2455
- key: "update",
2456
- value: function(t, e) {
2457
- var r = e.fast, n = e.high, o = e.slow, i = e.low, a = this.prevState;
2458
- this.areHighAndLowUndefined || void 0 !== n && void 0 !== i || (this.areHighAndLowUndefined = !0),
2459
- Number.isNaN(r) || Number.isNaN(o) || function(t, e) {
2460
- return t === e;
2461
- }(r, o) ? a = .5 : Or(r, o) ? a = this.areHighAndLowUndefined ? 1 : [ i, o, this.prevLow, this.prevSlow ].every((function(t) {
2462
- return !Number.isNaN(t);
2463
- })) && Sr(i, o) && Or(this.prevLow, this.prevSlow) ? 0 : 1 : Sr(r, o) && (a = this.areHighAndLowUndefined ? 0 : [ n, o, this.prevHigh, this.prevSlow ].every((function(t) {
2464
- return !Number.isNaN(t);
2465
- })) && Or(n, o) && Sr(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--),
2466
- 1 === this.interval && this.crossIndexes.up.push(t), -1 === this.interval && this.crossIndexes.down.push(t),
2467
- //save prev state
2468
- Object.assign(this, {
2469
- prevState: a,
2470
- prevFast: r,
2471
- prevSlow: o,
2472
- prevHigh: n,
2473
- prevLow: i
2474
- });
2475
- }
2476
- }, {
2477
- key: "getResult",
2478
- value: function() {
2479
- return this.interval;
2480
- }
2481
- } ]) && gr(t.prototype, e), r && gr(t, r), Object.defineProperty(t, "prototype", {
2482
- writable: !1
2483
- }), t;
2484
- var t, e, r;
2485
- }(), Pr = function(t, e) {
2486
- var r = t.verticalOhlcv, n = t.instances, o = t.len, i = t.arrayTypes, a = t.verticalOhlcvTempCols;
2487
- if (0 === e) {
2488
- var u = t.inputParams;
2489
- n.crossPairsList = u.reduce((function(t, e) {
2490
- var r = e.key, n = e.params;
2491
- if ("crossPairs" === r) {
2492
- var o, i = mr(n);
2493
- try {
2494
- for (i.s(); !(o = i.n()).done; ) {
2495
- var a, u = mr(o.value);
2496
- try {
2497
- for (u.s(); !(a = u.n()).done; ) {
2498
- var l = a.value;
2499
- t.push(l);
2500
- }
2501
- } catch (t) {
2502
- u.e(t);
2503
- } finally {
2504
- u.f();
2505
- }
2506
- }
2507
- } catch (t) {
2508
- i.e(t);
2509
- } finally {
2510
- i.f();
2511
- }
2512
- }
2513
- return t;
2514
- }), []);
2515
- }
2516
- var l, c = mr(n.crossPairsList);
2517
- try {
2518
- for (c.s(); !(l = c.n()).done; ) {
2519
- var s = l.value, f = s.fast, y = s.slow;
2520
- if (null != f && null != y) {
2521
- var p = "".concat(f, "_x_").concat(y);
2522
- if (0 === e) {
2523
- if ("number" == typeof y && (a.add(y.toString()), r[y.toString()] = new Int32Array(o).fill(y)),
2524
- "price" !== f && !r.hasOwnProperty(f)) throw Error('fast "'.concat(f, ' not found in crossPairs"'));
2525
- if (!r.hasOwnProperty(y)) throw Error('slow "'.concat(y, ' not found in crossPairs"'));
2526
- n[p] = new jr, r[p] = new Int32Array(o).fill(NaN), i[p] = "Int32Array";
2527
- }
2528
- var h = void 0, v = void 0, m = void 0, d = void 0, b = void 0;
2529
- "price" === f ? (v = r.close[e], m = r.high[e], d = r.low[e], b = r[y][e], n[p].update(e, {
2530
- fast: v,
2531
- slow: b,
2532
- high: m,
2533
- low: d
2534
- })) : (h = r[f][e], b = r[y][e], n[p].update(e, {
2535
- fast: h,
2536
- slow: b
2537
- })), t.pushToMain({
2538
- index: e,
2539
- key: p,
2540
- value: n[p].getResult()
2541
- });
2542
- }
2543
- }
2544
- } catch (t) {
2545
- c.e(t);
2546
- } finally {
2547
- c.f();
2548
- }
2549
- };
2550
- // ./src/studies/dateTime.js
2551
- function _r(t) {
2552
- return _r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
2553
- return typeof t;
2554
- } : function(t) {
2555
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
2556
- }, _r(t);
2557
- }
2558
- function Nr(t, e) {
2559
- var r = Object.keys(t);
2560
- if (Object.getOwnPropertySymbols) {
2561
- var n = Object.getOwnPropertySymbols(t);
2562
- e && (n = n.filter((function(e) {
2563
- return Object.getOwnPropertyDescriptor(t, e).enumerable;
2564
- }))), r.push.apply(r, n);
2565
- }
2566
- return r;
2567
- }
2568
- function Tr(t, e, r) {
2569
- return (e = function(t) {
2570
- var e = function(t, e) {
2571
- if ("object" != _r(t) || !t) return t;
2572
- var r = t[Symbol.toPrimitive];
2573
- if (void 0 !== r) {
2574
- var n = r.call(t, e || "default");
2575
- if ("object" != _r(n)) return n;
2576
- throw new TypeError("@@toPrimitive must return a primitive value.");
2577
- }
2578
- return ("string" === e ? String : Number)(t);
2579
- }(t, "string");
2580
- return "symbol" == _r(e) ? e : e + "";
2581
- }(e)) in t ? Object.defineProperty(t, e, {
2582
- value: r,
2583
- enumerable: !0,
2584
- configurable: !0,
2585
- writable: !0
2586
- }) : t[e] = r, t;
2587
- }
2588
- var Ar = function(t) {
2589
- 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();
2590
- return {
2591
- month: e,
2592
- year: r,
2593
- hour: n,
2594
- minute: o,
2595
- day_of_the_week: i,
2596
- day_of_the_month: a,
2597
- week_of_the_month: Math.ceil((a + u) / 7)
2598
- };
2599
- };
2600
- // ./src/studies/scaler.js
2601
- function Er(t) {
2602
- return function(t) {
2603
- if (Array.isArray(t)) return Dr(t);
2604
- }(t) || function(t) {
2605
- if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"]) return Array.from(t);
2606
- }(t) || Ir(t) || function() {
2607
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2608
- }();
2609
- }
2610
- function kr(t, e) {
2611
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2612
- if (!r) {
2613
- if (Array.isArray(t) || (r = Ir(t)) || e && t && "number" == typeof t.length) {
2614
- r && (t = r);
2615
- var n = 0, o = function() {};
2616
- return {
2617
- s: o,
2618
- n: function() {
2619
- return n >= t.length ? {
2620
- done: !0
2621
- } : {
2622
- done: !1,
2623
- value: t[n++]
2624
- };
2625
- },
2626
- e: function(t) {
2627
- throw t;
2628
- },
2629
- f: o
2630
- };
2631
- }
2632
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2633
- }
2634
- var i, a = !0, u = !1;
2635
- return {
2636
- s: function() {
2637
- r = r.call(t);
2638
- },
2639
- n: function() {
2640
- var t = r.next();
2641
- return a = t.done, t;
2642
- },
2643
- e: function(t) {
2644
- u = !0, i = t;
2645
- },
2646
- f: function() {
2647
- try {
2648
- a || null == r.return || r.return();
2649
- } finally {
2650
- if (u) throw i;
2651
- }
2652
- }
2653
- };
2654
- }
2655
- function xr(t, e) {
2656
- return function(t) {
2657
- if (Array.isArray(t)) return t;
2658
- }
2659
- /* General scaler: supports "minmax" and "zscore" types */ (t) || function(t, e) {
2660
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2661
- if (null != r) {
2662
- var n, o, i, a, u = [], l = !0, c = !1;
2663
- try {
2664
- if (i = (r = r.call(t)).next, 0 === e) {
2665
- if (Object(r) !== r) return;
2666
- l = !1;
2667
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
2668
- } catch (t) {
2669
- c = !0, o = t;
2670
- } finally {
2671
- try {
2672
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
2673
- } finally {
2674
- if (c) throw o;
2675
- }
2676
- }
2677
- return u;
2678
- }
2679
- }(t, e) || Ir(t, e) || function() {
2680
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2681
- }();
2682
- }
2683
- function Ir(t, e) {
2684
- if (t) {
2685
- if ("string" == typeof t) return Dr(t, e);
2686
- var r = {}.toString.call(t).slice(8, -1);
2687
- 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) ? Dr(t, e) : void 0;
2688
- }
2689
- }
2690
- function Dr(t, e) {
2691
- (null == e || e > t.length) && (e = t.length);
2692
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
2693
- return n;
2694
- }
2695
- // ./src/core-functions/mainLoop.js
2696
- function Mr(t) {
2697
- return function(t) {
2698
- if (Array.isArray(t)) return Lr(t);
2699
- }(t) || function(t) {
2700
- if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"]) return Array.from(t);
2701
- }(t) || Fr(t) || function() {
2702
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2703
- }();
2704
- }
2705
- function Rr(t, e) {
2706
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2707
- if (!r) {
2708
- if (Array.isArray(t) || (r = Fr(t)) || e && t && "number" == typeof t.length) {
2709
- r && (t = r);
2710
- var n = 0, o = function() {};
2711
- return {
2712
- s: o,
2713
- n: function() {
2714
- return n >= t.length ? {
2715
- done: !0
2716
- } : {
2717
- done: !1,
2718
- value: t[n++]
2719
- };
2720
- },
2721
- e: function(t) {
2722
- throw t;
2723
- },
2724
- f: o
2725
- };
2726
- }
2727
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2728
- }
2729
- var i, a = !0, u = !1;
2730
- return {
2731
- s: function() {
2732
- r = r.call(t);
2733
- },
2734
- n: function() {
2735
- var t = r.next();
2736
- return a = t.done, t;
2737
- },
2738
- e: function(t) {
2739
- u = !0, i = t;
2740
- },
2741
- f: function() {
2742
- try {
2743
- a || null == r.return || r.return();
2744
- } finally {
2745
- if (u) throw i;
2746
- }
2747
- }
2748
- };
2749
- }
2750
- function Cr(t, e) {
2751
- return function(t) {
2752
- if (Array.isArray(t)) return t;
2753
- }
2754
- // Map indicator keys to their respective functions
2755
- (t) || function(t, e) {
2756
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
2757
- if (null != r) {
2758
- var n, o, i, a, u = [], l = !0, c = !1;
2759
- try {
2760
- if (i = (r = r.call(t)).next, 0 === e) {
2761
- if (Object(r) !== r) return;
2762
- l = !1;
2763
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
2764
- } catch (t) {
2765
- c = !0, o = t;
2766
- } finally {
2767
- try {
2768
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
2769
- } finally {
2770
- if (c) throw o;
2771
- }
2772
- }
2773
- return u;
2774
- }
2775
- }(t, e) || Fr(t, e) || function() {
2776
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2777
- }();
2778
- }
2779
- function Fr(t, e) {
2780
- if (t) {
2781
- if ("string" == typeof t) return Lr(t, e);
2782
- var r = {}.toString.call(t).slice(8, -1);
2783
- 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;
2784
- }
2785
- }
2786
- function Lr(t, e) {
2787
- (null == e || e > t.length) && (e = t.length);
2788
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
2789
- return n;
2790
- }
2791
- var Br = {
2792
- dateTime: function(t, e, r) {
2793
- var n = r.lag, o = t.instances, i = t.verticalOhlcv;
2794
- if (0 === e) {
2795
- var a = t.len, u = t.dateType, l = t.arrayTypes;
2796
- if (!u) throw Error('dateTime method found and invalid "date" in input ohlcv');
2797
- Object.assign(o, {
2798
- dateTime: {
2799
- prevDateStr: i.date[0],
2800
- sessionDailyIndexCount: 0,
2801
- sessionIntradayIndexCount: 0,
2802
- cachedDayInfo: i.date[0]
2803
- }
2804
- });
2805
- 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++) {
2806
- l[f[s]] = "Int32Array";
2807
- }
2808
- Object.assign(i, function(t) {
2809
- for (var e = 1; e < arguments.length; e++) {
2810
- var r = null != arguments[e] ? arguments[e] : {};
2811
- e % 2 ? Nr(Object(r), !0).forEach((function(e) {
2812
- Tr(t, e, r[e]);
2813
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : Nr(Object(r)).forEach((function(e) {
2814
- Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e));
2815
- }));
2816
- }
2817
- return t;
2818
- }({}, Object.fromEntries(c.map((function(t) {
2819
- return [ t, new Int32Array(a).fill(NaN) ];
2820
- }))))), n > 0 && t.lag(c, n);
2821
- }
2822
- var y = i.date[e], p = Ar(y), h = p.day_of_the_week, v = p.day_of_the_month, m = p.week_of_the_month, d = p.month, b = p.year, g = p.hour, w = p.minute, O = y;
2823
- O !== o.dateTime.prevDateStr && (o.dateTime.prevDateStr = O, o.dateTime.sessionDailyIndexCount++,
2824
- o.dateTime.sessionIntradayIndexCount = 0), t.pushToMain({
2825
- index: e,
2826
- key: "session_daily_index",
2827
- value: o.dateTime.sessionDailyIndexCount
2828
- }), t.pushToMain({
2829
- index: e,
2830
- key: "session_intraday_index",
2831
- value: o.dateTime.sessionIntradayIndexCount
2832
- }), t.pushToMain({
2833
- index: e,
2834
- key: "day_of_the_week",
2835
- value: h
2836
- }), t.pushToMain({
2837
- index: e,
2838
- key: "day_of_the_month",
2839
- value: v
2840
- }), t.pushToMain({
2841
- index: e,
2842
- key: "week_of_the_month",
2843
- value: m
2844
- }), t.pushToMain({
2845
- index: e,
2846
- key: "month",
2847
- value: d
2848
- }), t.pushToMain({
2849
- index: e,
2850
- key: "year",
2851
- value: b
2852
- }), t.pushToMain({
2853
- index: e,
2854
- key: "hour",
2855
- value: g
2856
- }), t.pushToMain({
2857
- index: e,
2858
- key: "minute",
2859
- value: w
2860
- }), o.dateTime.sessionIntradayIndexCount++;
2861
- },
2862
- rsi: function(t, e, r, n) {
2863
- 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);
2864
- // Initialization on the first index.
2865
- if (0 === e) {
2866
- var f = t.crossPairsList, y = t.len, p = t.arrayTypes;
2867
- if (!a.hasOwnProperty(o)) throw new Error("Target property ".concat(o, " not found in verticalOhlcv for rsi."));
2868
- f.push({
2869
- fast: c,
2870
- slow: s,
2871
- isDefault: !0
2872
- }), Object.assign(u, Me(Me({}, c, new Ie(r)), s, new ft(r))), Object.assign(a, Me(Me({}, c, new Float64Array(y).fill(NaN)), s, new Float64Array(y).fill(NaN)));
2873
- var h = [ c, s ];
2874
- i > 0 && t.lag(h, i);
2875
- for (var v = 0, m = h; v < m.length; v++) {
2876
- p[m[v]] = "Float64Array";
2877
- }
2878
- }
2879
- var d = a[o][e], b = NaN, g = NaN;
2880
- // Update the RSI indicator.
2881
- u[c].update(d);
2882
- try {
2883
- b = u[c].getResult();
2884
- } catch (t) {
2885
- b = NaN;
2886
- }
2887
- // Always push the RSI value, using NaN as a fallback.
2888
- t.pushToMain({
2889
- index: e,
2890
- key: c,
2891
- value: b
2892
- }),
2893
- // Update the SMA indicator only if a valid RSI value is available.
2894
- Number.isNaN(b) || u[s].update(b);
2895
- try {
2896
- g = u[s].getResult();
2897
- } catch (t) {
2898
- g = NaN;
2899
- }
2900
- // Always push the smoothed RSI value.
2901
- t.pushToMain({
2902
- index: e,
2903
- key: s,
2904
- value: g
2905
- });
2906
- },
2907
- atr: function(t, e, r, n) {
2908
- var o = n.lag, i = n.type, a = t.verticalOhlcv, u = t.instances, l = "percentage" === i ? "atr_".concat(r, "_percentage") : "atr_".concat(r);
2909
- if (0 === e) {
2910
- var c = t.instances, s = t.verticalOhlcv, f = t.arrayTypes, y = t.len, p = t.priceBased;
2911
- c[l] = new Yt(r, jt), "price" === i && p.add(l), s[l] = new Float64Array(y).fill(NaN),
2912
- f[l] = "Float64Array", o > 0 && t.lag([ l ], o);
2913
- }
2914
- // Retrieve the current price value.
2915
- var h = {
2916
- high: a.high[e],
2917
- low: a.low[e],
2918
- close: a.close[e]
2919
- }, v = u[l];
2920
- // Update the moving average instance.
2921
- v.update(h);
2922
- var m = NaN;
2923
- try {
2924
- m = v.getResult();
2925
- } catch (t) {}
2926
- return "percentage" === i && (m = Number.isNaN(m) ? NaN : m / h.close),
2927
- // Always push the MA value (even if NaN).
2928
- t.pushToMain({
2929
- index: e,
2930
- key: l,
2931
- value: m
2932
- }), !0;
2933
- },
2934
- ema: Ce,
2935
- sma: Ce,
2936
- macd: function(t, e, r, n, o, i) {
2937
- var a = i.target, u = i.lag, l = i.precomputed, c = t.verticalOhlcv, s = t.instances, f = l.instanceKey;
2938
- // Initialization on the first index.
2939
- if (0 === e) {
2940
- var y = t.inputParams, p = t.crossPairsList, h = t.priceBased, v = t.len, m = t.arrayTypes;
2941
- if (!c.hasOwnProperty(a)) throw new Error("Target property ".concat(a, " not found in verticalOhlcv for macd."));
2942
- var d, b = 0, g = He(y);
2943
- try {
2944
- for (g.s(); !(d = g.n()).done; ) {
2945
- "macd" === d.value.key && b++;
2946
- }
2947
- // Choose a display prefix based on the number of indicators.
2948
- } catch (t) {
2949
- g.e(t);
2950
- } finally {
2951
- g.f();
2952
- }
2953
- 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);
2954
- // Build the keys.
2955
- p.push({
2956
- fast: O,
2957
- slow: S,
2958
- isDefault: !0
2959
- }), s.hasOwnProperty("macd") || (s.macd = {
2960
- numberOfIndicators: b,
2961
- settings: {}
2962
- }), s.macd.settings[f] = new we(new pe(r), new pe(n), new pe(o)), Object.assign(c, Be(Be(Be({}, O, new Float64Array(v).fill(NaN)), S, new Float64Array(v).fill(NaN)), j, new Float64Array(v).fill(NaN)))[j].forEach((function(t) {
2963
- h.add(t);
2964
- }));
2965
- var P = [ O, S, j ];
2966
- u > 0 && t.lag(P, u);
2967
- for (var _ = 0, N = P; _ < N.length; _++) {
2968
- m[N[_]] = "Float64Array";
2969
- }
2970
- }
2971
- 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), D = a === Ue ? "".concat(k, "_histogram") : "".concat(k, "_histogram_").concat(a), M = E[f], R = c[a][e];
2972
- M.update(R);
2973
- var C = {};
2974
- try {
2975
- C = M.getResult();
2976
- } catch (t) {
2977
- // If the result is unavailable, macdResult remains NaN.
2978
- }
2979
- // Always push values; use NaN as fallback when macdResult is missing.
2980
- return t.pushToMain({
2981
- index: e,
2982
- key: x,
2983
- value: C ? C.macd : NaN
2984
- }), t.pushToMain({
2985
- index: e,
2986
- key: I,
2987
- value: C ? C.signal : NaN
2988
- }), t.pushToMain({
2989
- index: e,
2990
- key: D,
2991
- value: C ? C.histogram : NaN
2992
- }), !0;
2993
- },
2994
- relativeVolume: function(t, e, r, n) {
2995
- var o = n.lag, i = "relative_volume_".concat(r), a = t.instances, u = t.verticalOhlcv;
2996
- if (0 === e) {
2997
- var l = t.len, c = t.arrayTypes;
2998
- a[i] = {
2999
- instance: new ft(r),
3000
- prevRelativeVolumeSma: NaN
3001
- }, u[i] = new Float64Array(l).fill(NaN), o > 0 && t.lag([ i ], o), c[i] = "Float64Array";
3002
- }
3003
- var s = u.volume[e], f = a[i].instance;
3004
- f.update(s);
3005
- var y = NaN;
3006
- try {
3007
- y = f.getResult();
3008
- } catch (t) {}
3009
- var p = a[i].prevRelativeVolumeSma, h = NaN;
3010
- // Only calculate relative volume if both current SMA and previous SMA are valid numbers and prevSma is not zero.
3011
- return Number.isNaN(y) || Number.isNaN(p) || (h = s / p), t.pushToMain({
3012
- index: e,
3013
- key: i,
3014
- value: h
3015
- }), a[i].prevRelativeVolumeSma = y, !0;
3016
- },
3017
- donchianChannels: function(t, e, r, n, o) {
3018
- var i = t.verticalOhlcv, a = t.instances, u = t.len, l = t.inputParams, c = t.priceBased, s = t.arrayTypes, f = t.lag, y = o.height, p = o.range, h = o.decimals, v = "".concat(r, "_").concat(n);
3019
- // ---- INIT (only at first bar) ----
3020
- if (0 === e) {
3021
- // how many donchianChannels calls in this session?
3022
- var m = l.filter((function(t) {
3023
- return "donchianChannels" === t.key;
3024
- })).length, d = "donchian_channel", b = m > 1 ? "".concat(d, "_").concat(v) : d, g = [ "upper", "basis", "lower" ].map((function(t) {
3025
- return "".concat(b, "_").concat(t);
3026
- }));
3027
- y && g.push("".concat(b, "_height"));
3028
- var w, O = function(t, e) {
3029
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
3030
- if (!r) {
3031
- if (Array.isArray(t) || (r = Ye(t)) || e && t && "number" == typeof t.length) {
3032
- r && (t = r);
3033
- var n = 0, o = function() {};
3034
- return {
3035
- s: o,
3036
- n: function() {
3037
- return n >= t.length ? {
3038
- done: !0
3039
- } : {
3040
- done: !1,
3041
- value: t[n++]
3042
- };
3043
- },
3044
- e: function(t) {
3045
- throw t;
3046
- },
3047
- f: o
3048
- };
3049
- }
3050
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3051
- }
3052
- var i, a = !0, u = !1;
3053
- return {
3054
- s: function() {
3055
- r = r.call(t);
3056
- },
3057
- n: function() {
3058
- var t = r.next();
3059
- return a = t.done, t;
3060
- },
3061
- e: function(t) {
3062
- u = !0, i = t;
3063
- },
3064
- f: function() {
3065
- try {
3066
- a || null == r.return || r.return();
3067
- } finally {
3068
- if (u) throw i;
3069
- }
3070
- }
3071
- };
3072
- }(p);
3073
- try {
3074
- for (O.s(); !(w = O.n()).done; ) {
3075
- var S = w.value;
3076
- if (!(S in i) || !c.has(S)) throw new Error('Invalid range key "'.concat(S, '". Only price-based keys are allowed: ').concat(Ke(c)));
3077
- g.push("".concat(b, "_range_").concat(S));
3078
- }
3079
- // bootstrap instance
3080
- } catch (t) {
3081
- O.e(t);
3082
- } finally {
3083
- O.f();
3084
- }
3085
- a.donchian_channel || (a.donchian_channel = {
3086
- numberOfIndicators: m,
3087
- settings: {}
3088
- }), a.donchian_channel.numberOfIndicators = m, a.donchian_channel.settings[v] = {
3089
- maxDeque: [],
3090
- minDeque: []
3091
- },
3092
- // allocate & fill NaNs
3093
- Object.assign(i, Object.fromEntries(g.map((function(t) {
3094
- return [ t, new Float64Array(u).fill(NaN) ];
3095
- })))),
3096
- // apply lag if requested
3097
- f > 0 && t.lag(g, f),
3098
- // mark price-based outputs
3099
- [ "upper", "basis", "lower" ].forEach((function(t) {
3100
- return c.add("".concat(b, "_").concat(t));
3101
- })), g.forEach((function(t) {
3102
- return s[t] = "Float64Array";
3103
- }));
3104
- }
3105
- // ---- PER-BAR COMPUTATION ----
3106
- 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) {
3107
- return "".concat(N, "_").concat(t);
3108
- }));
3109
- y && I.push("".concat(N, "_height"));
3110
- var D = p.map((function(t) {
3111
- return "".concat(N, "_range_").concat(t);
3112
- }));
3113
- // not enough data → push NaNs
3114
- if (x < 0 || k + 1 > u) return [].concat(Ke(I), Ke(D)).forEach((function(r) {
3115
- return t.pushToMain({
3116
- index: e,
3117
- key: r,
3118
- value: NaN
3119
- });
3120
- })), !0;
3121
- var M = i.high, R = i.low, C = function(t, e, r) {
3122
- for (;t.length && t[0] < x; ) t.shift();
3123
- for (;t.length && r(e[t.at(-1)], e[k]); ) t.pop();
3124
- t.push(k);
3125
- };
3126
- // tiny helper to keep deques up-to-date
3127
- C(A, M, (function(t, e) {
3128
- return t <= e;
3129
- })), C(E, R, (function(t, e) {
3130
- return t >= e;
3131
- }));
3132
- // single “bounds exist?” flag instead of repeated isNaN
3133
- var F = A.length && E.length, L = F ? M[A[0]] : NaN, B = F ? R[E[0]] : NaN, H = F ? (L + B) / 2 : NaN;
3134
- if (t.pushToMain({
3135
- index: e,
3136
- key: "".concat(N, "_upper"),
3137
- value: L
3138
- }), t.pushToMain({
3139
- index: e,
3140
- key: "".concat(N, "_basis"),
3141
- value: H
3142
- }), t.pushToMain({
3143
- index: e,
3144
- key: "".concat(N, "_lower"),
3145
- value: B
3146
- }), y) {
3147
- // avoid divide-by-zero
3148
- var V = F && B ? (L - B) / B : NaN;
3149
- t.pushToMain({
3150
- index: e,
3151
- key: "".concat(N, "_height"),
3152
- value: null === h ? V : Ge(V, h)
3153
- });
3154
- }
3155
- // precompute spread once
3156
- // for each extra range key, use price===price to skip NaNs
3157
- for (var U = F ? L - B : NaN, $ = 0; $ < p.length; $++) {
3158
- var q = i[p[$]][e], z = F && q == q && U ? (q - B) / U : NaN;
3159
- t.pushToMain({
3160
- index: e,
3161
- key: D[$],
3162
- value: null === h ? z : Ge(z, h)
3163
- });
3164
- }
3165
- return !0;
3166
- },
3167
- bollingerBands: function(t, e, r, n, o) {
3168
- var i, a, u, l, c, s, f, y = o.height, p = o.range, h = void 0 === p ? [] : p, 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);
3169
- // Initialization on the first call.
3170
- if (0 === e) {
3171
- var S = t.priceBased, j = t.inputParams, P = t.verticalOhlcv, _ = t.len, N = t.arrayTypes;
3172
- if (!(v in P)) throw new Error('bollingerBands could not find target "'.concat(v, '"'));
3173
- var T, A = 0, E = Xe(j);
3174
- try {
3175
- for (E.s(); !(T = E.n()).done; ) {
3176
- "bollingerBands" === T.value.key && A++;
3177
- }
3178
- } catch (t) {
3179
- E.e(t);
3180
- } finally {
3181
- E.f();
3182
- }
3183
- f = A > 1 ? "bollinger_bands_".concat(O) : "bollinger_bands".concat(w),
3184
- // Only create the container if it doesn't already exist.
3185
- g.bollinger_bands || (g.bollinger_bands = {
3186
- numberOfIndicators: A,
3187
- settings: {}
3188
- }),
3189
- // Add (or override) the indicator instance keyed by indicatorKey.
3190
- g.bollinger_bands.settings[O] = new ee(r, n);
3191
- var k = [ "".concat(f, "_upper"), "".concat(f, "_middle"), "".concat(f, "_lower") ];
3192
- y && k.push("".concat(f, "_height"));
3193
- // Set up additional arrays for each range property.
3194
- var x, I = Xe(h);
3195
- try {
3196
- for (I.s(); !(x = I.n()).done; ) {
3197
- var D = x.value;
3198
- if (!(D in P) || !S.has(D)) throw new Error('Invalid range item value "'.concat(D, '" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(S)));
3199
- k.push("".concat(f, "_range_").concat(D));
3200
- }
3201
- } catch (t) {
3202
- I.e(t);
3203
- } finally {
3204
- I.f();
3205
- }
3206
- var M = Object.fromEntries(k.map((function(t) {
3207
- return [ t, new Float64Array(_).fill(NaN) ];
3208
- })));
3209
- Object.assign(P, function(t) {
3210
- for (var e = 1; e < arguments.length; e++) {
3211
- var r = null != arguments[e] ? arguments[e] : {};
3212
- e % 2 ? Qe(Object(r), !0).forEach((function(e) {
3213
- We(t, e, r[e]);
3214
- })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : Qe(Object(r)).forEach((function(e) {
3215
- Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e));
3216
- }));
3217
- }
3218
- return t;
3219
- }({}, M)), m > 0 && t.lag(k, m), [ "".concat(f, "_upper"), "".concat(f, "_middle"), "".concat(f, "_lower") ].forEach((function(t) {
3220
- S.add(t);
3221
- }));
3222
- for (var R = 0, C = k; R < C.length; R++) {
3223
- N[C[R]] = "Float64Array";
3224
- }
3225
- }
3226
- // Derive prefix for subsequent calls if not set.
3227
- f || (f = g.bollinger_bands.numberOfIndicators > 1 ? "bollinger_bands_".concat(O) : "bollinger_bands".concat(w));
3228
- var F = f, L = g.bollinger_bands.settings[O], B = b[v][e];
3229
- // Update the indicator with the current value.
3230
- L.update(B);
3231
- // Attempt to retrieve the result.
3232
- var H = {};
3233
- try {
3234
- H = L.getResult();
3235
- } catch (t) {
3236
- // If not available, result stays {}.
3237
- }
3238
- // Use NaN fallbacks for the primary values.
3239
- 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;
3240
- // Process height if requested.
3241
- if (
3242
- // Always push the indicator outputs.
3243
- t.pushToMain({
3244
- index: e,
3245
- key: "".concat(F, "_upper"),
3246
- value: V
3247
- }), t.pushToMain({
3248
- index: e,
3249
- key: "".concat(F, "_middle"),
3250
- value: U
3251
- }), t.pushToMain({
3252
- index: e,
3253
- key: "".concat(F, "_lower"),
3254
- value: $
3255
- }), y) {
3256
- var q = NaN;
3257
- Number.isNaN($) || Number.isNaN(V) || (q = (V - $) / $), t.pushToMain({
3258
- index: e,
3259
- key: "".concat(F, "_height"),
3260
- value: null === d ? q : Ge(q, d)
3261
- });
3262
- }
3263
- // Process each range property.
3264
- var z, G = Xe(h);
3265
- try {
3266
- for (G.s(); !(z = G.n()).done; ) {
3267
- var K = z.value, Y = NaN, J = b[K][e];
3268
- Number.isNaN(J) || Number.isNaN($) || Number.isNaN(V) || (Y = (J - $) / (V - $)),
3269
- t.pushToMain({
3270
- index: e,
3271
- key: "".concat(F, "_range_").concat(K),
3272
- value: null === d ? Y : Ge(Y, d)
3273
- });
3274
- }
3275
- } catch (t) {
3276
- G.e(t);
3277
- } finally {
3278
- G.f();
3279
- }
3280
- return !0;
3281
- },
3282
- volumeOscillator: function(t, e, r, n, o) {
3283
- var i = o.lag, a = t.verticalOhlcv, u = t.instances, l = a.volume[e], c = "volume_oscillator_".concat(r, "_").concat(n);
3284
- if (0 === e) {
3285
- var s = t.crossPairsList, f = t.len, y = t.arrayTypes;
3286
- Object.assign(u, rr({}, c, {
3287
- fastEMA: new pe(r),
3288
- slowEMA: new pe(n)
3289
- })), a[c] = new Float64Array(f).fill(NaN), s.push({
3290
- fast: c,
3291
- slow: 0,
3292
- isDefault: !0
3293
- }), i > 0 && t.lag([ c ], i), y[c] = "Float64Array";
3294
- }
3295
- var p = u[c], h = p.fastEMA, v = p.slowEMA;
3296
- h.update(l), v.update(l);
3297
- var m = NaN, d = NaN;
3298
- try {
3299
- m = h.getResult();
3300
- } catch (t) {}
3301
- try {
3302
- d = v.getResult();
3303
- } catch (t) {}
3304
- var b = NaN;
3305
- return Number.isNaN(m) || Number.isNaN(d) || (b = 100 * (m - d) / d), t.pushToMain({
3306
- index: e,
3307
- key: c,
3308
- value: b
3309
- }), !0;
3310
- },
3311
- scaler: function(t, e, r, n, o) {
3312
- var i = o.type, a = o.group, u = o.range, l = o.lag, c = o.precomputed, s = o.decimals, f = c.groupKey, y = c.groupKeyLen, p = t.verticalOhlcv, h = t.instances, v = t.arrayTypes, m = "".concat(i, "_").concat(r);
3313
- if (0 === e) {
3314
- var d = t.len;
3315
- h.hasOwnProperty("scaler") || (h.scaler = {
3316
- windows: {}
3317
- });
3318
- var b, g = kr(n);
3319
- try {
3320
- var w = function() {
3321
- var e = b.value;
3322
- if (!p.hasOwnProperty(e)) throw new Error('Target property "'.concat(e, '" not found in verticalOhlcv'));
3323
- var r = "".concat(m, "_").concat(e);
3324
- p[r] = new Float64Array(d).fill(NaN), v[r] = "Float64Array";
3325
- var n = a ? f : e;
3326
- if (h.scaler.windows[n] = [], a && (t.scaledGroups[f] || (t.scaledGroups[f] = []),
3327
- t.scaledGroups[f].push(r)), l > 0) {
3328
- if (a) {
3329
- var o, i = Array.from({
3330
- length: l
3331
- }).map((function(t, e) {
3332
- return "".concat(r, "_lag_").concat(e + 1);
3333
- }));
3334
- (o = t.scaledGroups[f]).push.apply(o, Er(i));
3335
- }
3336
- t.lag([ r ], l);
3337
- }
3338
- };
3339
- for (g.s(); !(b = g.n()).done; ) w();
3340
- } catch (t) {
3341
- g.e(t);
3342
- } finally {
3343
- g.f();
3344
- }
3345
- }
3346
- var O, S = h.scaler.windows, j = kr(n);
3347
- // update windows with current values
3348
- try {
3349
- for (j.s(); !(O = j.n()).done; ) {
3350
- var P = O.value, _ = p[P][e], N = S[a ? f : P];
3351
- N.push(_), N.length > (a ? r * y : r) && N.shift();
3352
- }
3353
- } catch (t) {
3354
- j.e(t);
3355
- } finally {
3356
- j.f();
3357
- }
3358
- var T, A = e + 1 >= r, E = kr(n);
3359
- // scale values once enough data
3360
- try {
3361
- var k = function() {
3362
- var r, n, o, l, c, y, h = T.value, v = p[h][e], d = "".concat(m, "_").concat(h), b = null;
3363
- if (A) {
3364
- var g = S[a ? f : h];
3365
- if ("minmax" === i) {
3366
- var w = Math.min.apply(Math, Er(g)), O = Math.max.apply(Math, Er(g));
3367
- r = v, n = w, o = O, l = xr(u, 2), c = l[0], y = l[1], b = (Math.min(Math.max(r, n), o) - n) / (o - n) * (y - c) + c;
3368
- } else {
3369
- if ("zscore" !== i) throw new Error('Unknown scaler type "'.concat(i, '"'));
3370
- var j = g.reduce((function(t, e) {
3371
- return t + e;
3372
- }), 0) / g.length, P = g.reduce((function(t, e) {
3373
- return t + Math.pow(e - j, 2);
3374
- }), 0) / g.length, _ = Math.sqrt(P);
3375
- b = function(t, e, r) {
3376
- return 0 === r ? 0 : (t - e) / r;
3377
- }(v, j, _);
3378
- }
3379
- }
3380
- t.pushToMain({
3381
- index: e,
3382
- key: d,
3383
- value: null === s ? b : Ge(b, s)
3384
- });
3385
- };
3386
- for (E.s(); !(T = E.n()).done; ) k();
3387
- } catch (t) {
3388
- E.e(t);
3389
- } finally {
3390
- E.f();
3391
- }
3392
- }
3393
- }, Hr = function(t, e) {
3394
- for (var r = t.length, n = new ft(e), o = new Array(r), i = 0, a = 0, u = 0, l = 0; l < r; l++) if (n.update(t[l]),
3395
- n.isStable) {
3396
- var c = n.getResult();
3397
- o[l] = c, i += c, a += c * c, u++;
3398
- } else o[l] = null;
3399
- var s = i / u, f = a / u - s * s, y = Math.sqrt(f);
3400
- return o.map((function(t) {
3401
- return null !== t ? (t - s) / y : null;
3402
- }));
3403
- }, Vr = function(t, e) {
3404
- var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 5;
3405
- if (t.length !== e.length) throw new Error("Both arrays must have the same length");
3406
- for (var n = Hr(t, r), o = Hr(e, r), i = t.length, a = [], u = 0, l = 0, c = 0, s = 0, f = 0, y = 0, p = -1, h = 0; h < i; h++) {
3407
- if (null !== n[h] && null !== o[h]) {
3408
- p = h;
3409
- break;
3410
- }
3411
- a.push(0);
3412
- }
3413
- if (-1 === p)
3414
- // No valid data points
3415
- return new Array(i).fill(0);
3416
- for (var v = p; v < i; v++) {
3417
- var m = n[v], d = o[v];
3418
- if (null !== m && null !== d) if (u += m, l += d, c += m * d, s += m * m, f += d * d,
3419
- ++y < 2) a.push(0); else {
3420
- var b = y * c - u * l, g = Math.sqrt((y * s - u * u) * (y * f - l * l)), w = 0 === g ? 0 : b / g;
3421
- a.push(w);
3422
- } else
3423
- // Reset sums and counts when encountering null values
3424
- u = l = c = s = f = y = 0, a.push(0);
3425
- }
3426
- return a;
3427
- };
3428
- // ./src/utilities/verticalToHorizontal.js
3429
- function Ur(t, e) {
3430
- return function(t) {
3431
- if (Array.isArray(t)) return t;
3432
- }(t) || function(t, e) {
3433
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
3434
- if (null != r) {
3435
- var n, o, i, a, u = [], l = !0, c = !1;
3436
- try {
3437
- if (i = (r = r.call(t)).next, 0 === e) {
3438
- if (Object(r) !== r) return;
3439
- l = !1;
3440
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
3441
- } catch (t) {
3442
- c = !0, o = t;
3443
- } finally {
3444
- try {
3445
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
3446
- } finally {
3447
- if (c) throw o;
3448
- }
3449
- }
3450
- return u;
3451
- }
3452
- }(t, e) || function(t, e) {
3453
- if (t) {
3454
- if ("string" == typeof t) return $r(t, e);
3455
- var r = {}.toString.call(t).slice(8, -1);
3456
- 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) ? $r(t, e) : void 0;
3457
- }
3458
- }(t, e) || function() {
3459
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3460
- }();
3461
- }
3462
- function $r(t, e) {
3463
- (null == e || e > t.length) && (e = t.length);
3464
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
3465
- return n;
3466
- }
3467
- var qr = function(t) {
3468
- var e = t.main, r = t.skipNull, n = void 0 !== r && r, o = t.startIndex, i = void 0 === o ? 0 : o, a = t.dateFormat, u = e.precisionMultiplier, l = e.priceBased, c = e.precision, s = e.verticalOhlcv, f = e.invalidValueIndex, y = e.len, p = e.verticalOhlcvKeyNames, h = e.verticalOhlcvTempCols;
3469
- if (0 === p.length) return [];
3470
- for (var v = n && f >= 0 ? f + 1 : 0, m = Math.max(v, i), d = y - m, b = Array.from({
3471
- length: d
3472
- }, (function() {
3473
- return {};
3474
- })), g = 0, w = Object.entries(s); g < w.length; g++) {
3475
- var O = Ur(w[g], 2), S = O[0], j = O[1];
3476
- if (!h.has(S)) for (var P = l.has(S) && c, _ = m; _ < y; _++) b[_ - m][S] = P ? j[_] / u : "date" === S ? or[a](j[_]) : j[_];
3477
- }
3478
- return b;
3479
- };
3480
- function zr(t, e) {
3481
- return function(t) {
3482
- if (Array.isArray(t)) return t;
3483
- }(t) || function(t, e) {
3484
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
3485
- if (null != r) {
3486
- var n, o, i, a, u = [], l = !0, c = !1;
3487
- try {
3488
- if (i = (r = r.call(t)).next, 0 === e) {
3489
- if (Object(r) !== r) return;
3490
- l = !1;
3491
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
3492
- } catch (t) {
3493
- c = !0, o = t;
3494
- } finally {
3495
- try {
3496
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
3497
- } finally {
3498
- if (c) throw o;
3499
- }
3500
- }
3501
- return u;
3502
- }
3503
- }(t, e) || Gr(t, e) || function() {
3504
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3505
- }();
3506
- }
3507
- function Gr(t, e) {
3508
- if (t) {
3509
- if ("string" == typeof t) return Kr(t, e);
3510
- var r = {}.toString.call(t).slice(8, -1);
3511
- 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) ? Kr(t, e) : void 0;
3512
- }
3513
- }
3514
- function Kr(t, e) {
3515
- (null == e || e > t.length) && (e = t.length);
3516
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
3517
- return n;
3518
- }
3519
- var Yr = function(t, e) {
3520
- var r = t.precision, n = t.priceBased;
3521
- if (!1 === r) return 1;
3522
- var o, i = 1, a = // ./src/utilities/precisionMultiplier.js
3523
- function(t, e) {
3524
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
3525
- if (!r) {
3526
- if (Array.isArray(t) || (r = Gr(t)) || e && t && "number" == typeof t.length) {
3527
- r && (t = r);
3528
- var n = 0, o = function() {};
3529
- return {
3530
- s: o,
3531
- n: function() {
3532
- return n >= t.length ? {
3533
- done: !0
3534
- } : {
3535
- done: !1,
3536
- value: t[n++]
3537
- };
3538
- },
3539
- e: function(t) {
3540
- throw t;
3541
- },
3542
- f: o
3543
- };
3544
- }
3545
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3546
- }
3547
- var i, a = !0, u = !1;
3548
- return {
3549
- s: function() {
3550
- r = r.call(t);
3551
- },
3552
- n: function() {
3553
- var t = r.next();
3554
- return a = t.done, t;
3555
- },
3556
- e: function(t) {
3557
- u = !0, i = t;
3558
- },
3559
- f: function() {
3560
- try {
3561
- a || null == r.return || r.return();
3562
- } finally {
3563
- if (u) throw i;
3564
- }
3565
- }
3566
- };
3567
- }(Object.entries(e).filter((function(t) {
3568
- var e = zr(t, 2), r = e[0];
3569
- e[1];
3570
- return n.has(r);
3571
- })).map((function(t) {
3572
- var e = zr(t, 2);
3573
- e[0];
3574
- return e[1];
3575
- })));
3576
- try {
3577
- for (a.s(); !(o = a.n()).done; ) {
3578
- var u = o.value, l = zr(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;
3579
- f > i && (i = f);
3580
- }
3581
- } catch (t) {
3582
- a.e(t);
3583
- } finally {
3584
- a.f();
3585
- }
3586
- return i;
3587
- };
3588
- // ./index.js
3589
- function Jr(t) {
3590
- return Jr = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
3591
- return typeof t;
3592
- } : function(t) {
3593
- return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
3594
- }, Jr(t);
3595
- }
3596
- function Zr(t) {
3597
- return function(t) {
3598
- if (Array.isArray(t)) return Xr(t);
3599
- }(t) || function(t) {
3600
- if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"]) return Array.from(t);
3601
- }(t) || Wr(t) || function() {
3602
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3603
- }();
3604
- }
3605
- function Qr(t, e) {
3606
- return function(t) {
3607
- if (Array.isArray(t)) return t;
3608
- }(t) || function(t, e) {
3609
- var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
3610
- if (null != r) {
3611
- var n, o, i, a, u = [], l = !0, c = !1;
3612
- try {
3613
- if (i = (r = r.call(t)).next, 0 === e) {
3614
- if (Object(r) !== r) return;
3615
- l = !1;
3616
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== e); l = !0) ;
3617
- } catch (t) {
3618
- c = !0, o = t;
3619
- } finally {
3620
- try {
3621
- if (!l && null != r.return && (a = r.return(), Object(a) !== a)) return;
3622
- } finally {
3623
- if (c) throw o;
3624
- }
3625
- }
3626
- return u;
3627
- }
3628
- }(t, e) || Wr(t, e) || function() {
3629
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3630
- }();
3631
- }
3632
- function Wr(t, e) {
3633
- if (t) {
3634
- if ("string" == typeof t) return Xr(t, e);
3635
- var r = {}.toString.call(t).slice(8, -1);
3636
- 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) ? Xr(t, e) : void 0;
3637
- }
3638
- }
3639
- function Xr(t, e) {
3640
- (null == e || e > t.length) && (e = t.length);
3641
- for (var r = 0, n = Array(e); r < e; r++) n[r] = t[r];
3642
- return n;
3643
- }
3644
- function tn(t, e) {
3645
- for (var r = 0; r < e.length; r++) {
3646
- var n = e[r];
3647
- n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0),
3648
- Object.defineProperty(t, en(n.key), n);
3649
- }
3650
- }
3651
- function en(t) {
3652
- var e = function(t, e) {
3653
- if ("object" != Jr(t) || !t) return t;
3654
- var r = t[Symbol.toPrimitive];
3655
- if (void 0 !== r) {
3656
- var n = r.call(t, e || "default");
3657
- if ("object" != Jr(n)) return n;
3658
- throw new TypeError("@@toPrimitive must return a primitive value.");
3659
- }
3660
- return ("string" === e ? String : Number)(t);
3661
- }
3662
- //precomputed
3663
- /**
3664
- * Class OHLCV_INDICATORS
3665
- *
3666
- * This class provides methods for calculating and managing technical indicators
3667
- * on financial OHLCV (Open, High, Low, Close, Volume) data. It enables users
3668
- * to parallel compute various technical indicators in 1 single loop.
3669
- * OHLCV datasets.
3670
- */ (t, "string");
3671
- return "symbol" == Jr(e) ? e : e + "";
3672
- }
3673
- var rn = function() {
3674
- return t = function t(e) {
3675
- var r = this, n = e.input, o = e.ticker, i = void 0 === o ? null : o, a = e.precision, l = void 0 === a || a, s = e.inputParams, f = void 0 === s ? null : s, h = e.chunkProcess, v = void 0 === h ? 2e3 : h;
3676
- if (function(t, e) {
3677
- if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
3678
- }(this, t), c(n, "input", null !== i ? "contructor ".concat(i) : "constuctor"),
3679
- 0 === n.length) throw Error("input OHLCV must not be empty: " + i);
3680
- y(l, "precision", "constructor"), p(v, {
3681
- min: 100,
3682
- max: 5e4,
3683
- allowDecimals: !1
3684
- }, "chunkProcess", "constructor"), this.chunkProcess = v, this.firstRow = n[0];
3685
- var m = function(t) {
3686
- for (var e = {}, r = {}, n = 0, o = Object.entries(t); n < o.length; n++) {
3687
- var i = ur(o[n], 2), a = i[0], u = i[1];
3688
- if ("date" === a) e[a] = ar(u), r[a] = "Array"; else if ("volume" === a) e[a] = ze(u, !0),
3689
- r[a] = "Int32Array"; else if (cr.has(a)) e[a] = ze(u, !0), r[a] = "Float64Array"; else {
3690
- var l = ze(u, !1);
3691
- e[a] = l, r[a] = "number" === l ? "Float64Array" : "Array";
3692
- }
3693
- }
3694
- return {
3695
- inputTypes: e,
3696
- arrayTypes: r
3697
- };
3698
- }(this.firstRow), d = m.inputTypes, b = m.arrayTypes;
3699
- if (this.inputTypes = d, this.arrayTypes = b, !this.firstRow.hasOwnProperty("close")) throw Error('input OHLCV array objects require at least "close" property: '.concat(i));
3700
- return this.dateType = this.inputTypes.date ? this.inputTypes.date : null, this.isComputed = !1,
3701
- this.input = n, this.priceBased = new Set([ "open", "high", "low", "close" ]), this.len = n.length,
3702
- this.instances = {}, this.crossPairsList = [], this.verticalOhlcv = {}, this.verticalOhlcvKeyNames = [],
3703
- this.verticalOhlcvTempCols = new Set, this.utilities = {
3704
- correlation: Vr
3705
- }, this.invalidValueIndex = -1, this.precision = l, this.precisionMultiplier = Yr(this, this.firstRow),
3706
- this.scaledGroups = {}, this.pushToMain = function(t) {
3707
- var e = t.index, n = t.key, o = t.value;
3708
- return function(t) {
3709
- var e = t.main, r = t.index, n = t.key, o = t.value, i = e.verticalOhlcv;
3710
- return null == o || Number.isNaN(o) ? (e.invalidValueIndex = r, i[n][r] = o, !1) : (i[n][r] = o,
3711
- !0);
3712
- }({
3713
- main: r,
3714
- index: e,
3715
- key: n,
3716
- value: o
3717
- });
3718
- }, null !== f && (u(f, this.len), this.inputParams = f, this.compute()), this.inputParams = [],
3719
- this;
3720
- }, e = [ {
3721
- key: "getDataAsCols",
3722
- value: function() {
3723
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
3724
- this.compute();
3725
- var e = t.skipNull, r = void 0 === e || e, n = t.dateFormat, o = void 0 === n ? "string" : n;
3726
- f(Object.keys(or), o, "dateFormat", "getDataAsCols"), s(t, "options", "getDataAsCols");
3727
- for (var i = this.precisionMultiplier, a = this.precision, u = this.invalidValueIndex, l = this.len, c = this.verticalOhlcv, y = this.priceBased, p = this.arrayTypes, h = this.verticalOhlcvTempCols, v = {}, m = r ? u + 1 : 0, d = l - m, b = 0, g = Object.entries(c); b < g.length; b++) {
3728
- var w = Qr(g[b], 2), O = w[0], S = w[1];
3729
- if (!h.has(O)) {
3730
- var j = y.has(O) && a;
3731
- v[O] = sr(p[O], d);
3732
- for (var P = m; P < l; P++) v[O][P] = j ? S[P] / i : "date" === O ? or[o](S[P]) : S[P];
3733
- }
3734
- }
3735
- return v;
3736
- }
3737
- }, {
3738
- key: "getData",
3739
- value: function() {
3740
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
3741
- //getData method returns the last object (row) of the new OHLCV with indicators: {open, high, low, close, rsi_14, bollinger_bands_upper}
3742
- this.compute();
3743
- var e = t.skipNull, r = void 0 === e || e, n = t.dateFormat, o = void 0 === n ? "string" : n;
3744
- return f(Object.keys(or), o, "dateFormat", "getData"), s(t, "options", "getData"),
3745
- qr({
3746
- main: this,
3747
- skipNull: r,
3748
- startIndex: 0,
3749
- dateFormat: o
3750
- });
3751
- }
3752
- }, {
3753
- key: "getLastValues",
3754
- value: function() {
3755
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
3756
- this.compute();
3757
- var e = t.dateFormat, r = void 0 === e ? "string" : e;
3758
- return f(Object.keys(or), r, "dateFormat", "getData"), qr({
3759
- skipNull: !1,
3760
- main: this,
3761
- startIndex: this.len - 1,
3762
- dateFormat: r
3763
- })[0];
3764
- }
3765
- }, {
3766
- key: "compute",
3767
- value: function() {
3768
- // If we've already computed, bail out immediately
3769
- return this.isComputed || (
3770
- // Mark as “in progress”
3771
- this.isComputed = !1,
3772
- // Figure out whether there’s a date field in the inputs
3773
- // Only run the full loop once (or when new data appears later,
3774
- // if you extend this to reset isComputed elsewhere)
3775
- this.len > 0 && (function(t, e) {
3776
- var r = e.len, n = e.inputParams, o = e.priceBased, i = e.precisionMultiplier, a = e.arrayTypes, l = e.verticalOhlcv, c = e.verticalOhlcvKeyNames, s = e.inputTypes, f = e.chunkProcess;
3777
- u(n, r);
3778
- for (var y = 0, p = Object.keys(s); y < p.length; y++) {
3779
- var h = p[y];
3780
- l[h] = sr(a[h], r);
3781
- }
3782
- // Process each row in the input
3783
- for (var v = 0; v < r; v += f) for (var m = Math.min(v + f, r), d = v; d < m; d++) {
3784
- for (var b = t[d], g = 0, w = Object.entries(s); g < w.length; g++) {
3785
- var O = Cr(w[g], 2), S = O[0], j = O[1], P = b[S];
3786
- if (qe.hasOwnProperty(j)) {
3787
- var _ = qe[j](P);
3788
- i > 1 && o.has(S) && (_ *= i), e.pushToMain({
3789
- index: d,
3790
- key: S,
3791
- value: _
3792
- });
3793
- } else ir.hasOwnProperty(j) ? e.pushToMain({
3794
- index: d,
3795
- key: S,
3796
- value: ir[j](P)
3797
- }) : e.pushToMain({
3798
- index: d,
3799
- key: S,
3800
- value: P
3801
- });
3802
- }
3803
- // Run all indicator functions except for the ones processed later
3804
- var N, T = Rr(n);
3805
- try {
3806
- for (T.s(); !(N = T.n()).done; ) {
3807
- var A = N.value, E = A.key, k = A.params;
3808
- "lag" !== E && "crossPairs" !== E &&
3809
- // resolve fn on-demand, no per-item object allocation here
3810
- Br[E].apply(Br, [ e, d ].concat(Mr(k)));
3811
- }
3812
- // Process these indicators separately (ensuring their execution order)
3813
- } catch (t) {
3814
- T.e(t);
3815
- } finally {
3816
- T.f();
3817
- }
3818
- vr(e, d), Pr(e, d), t[d] = null;
3819
- }
3820
- c.push.apply(c, Mr(Object.keys(l)));
3821
- }(this.input, this), this.isComputed = !0,
3822
- //flushing after mainLoop
3823
- this.input = [], this.instances = {}, this.firstRow = [])), this;
3824
- }
3825
- }, {
3826
- key: "crossPairs",
3827
- value: function() {
3828
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], e = "crossPairs";
3829
- return l(this), c(t, "arr", e), this.crossPairsList = [].concat(Zr(this.crossPairsList), Zr(t)),
3830
- this.inputParams.push({
3831
- key: e,
3832
- params: [ this.crossPairsList ]
3833
- }), this;
3834
- }
3835
- }, {
3836
- key: "lag",
3837
- value: function() {
3838
- 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";
3839
- l(this), c(t, "colKeys", r), p(e, {
3840
- min: 1,
3841
- max: this.len,
3842
- allowDecimals: !1
3843
- }, "lookback", r), this.inputParams.push({
3844
- key: r,
3845
- params: [ t, e ]
3846
- });
3847
- var n, o = function(t, e) {
3848
- var r = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
3849
- if (!r) {
3850
- if (Array.isArray(t) || (r = Wr(t)) || e && t && "number" == typeof t.length) {
3851
- r && (t = r);
3852
- var n = 0, o = function() {};
3853
- return {
3854
- s: o,
3855
- n: function() {
3856
- return n >= t.length ? {
3857
- done: !0
3858
- } : {
3859
- done: !1,
3860
- value: t[n++]
3861
- };
3862
- },
3863
- e: function(t) {
3864
- throw t;
3865
- },
3866
- f: o
3867
- };
3868
- }
3869
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3870
- }
3871
- var i, a = !0, u = !1;
3872
- return {
3873
- s: function() {
3874
- r = r.call(t);
3875
- },
3876
- n: function() {
3877
- var t = r.next();
3878
- return a = t.done, t;
3879
- },
3880
- e: function(t) {
3881
- u = !0, i = t;
3882
- },
3883
- f: function() {
3884
- try {
3885
- a || null == r.return || r.return();
3886
- } finally {
3887
- if (u) throw i;
3888
- }
3889
- }
3890
- };
3891
- }(t);
3892
- try {
3893
- for (o.s(); !(n = o.n()).done; ) {
3894
- var i = n.value;
3895
- this.priceBased.has(i) && this.priceBased.add(i);
3896
- }
3897
- } catch (t) {
3898
- o.e(t);
3899
- } finally {
3900
- o.f();
3901
- }
3902
- return this;
3903
- }
3904
- }, {
3905
- key: "relativeVolume",
3906
- value: function() {
3907
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 10, e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r = "relativeVolume";
3908
- if (!this.inputTypes.hasOwnProperty("volume")) throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');
3909
- l(this), p(t, {
3910
- min: 1,
3911
- max: this.len,
3912
- allowDecimals: !1
3913
- }, "size", r), s(e, "options", r);
3914
- var n = e.lag, o = void 0 === n ? 0 : n;
3915
- return p(o, {
3916
- min: 0,
3917
- max: this.len,
3918
- allowDecimals: !1
3919
- }, "options.lag", r), this.inputParams.push({
3920
- key: r,
3921
- params: [ t, {
3922
- lag: o
3923
- } ]
3924
- }), this;
3925
- }
3926
- }, {
3927
- key: "atr",
3928
- value: function() {
3929
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 14, e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r = "atr";
3930
- l(this), p(t, {
3931
- min: 1,
3932
- max: this.len,
3933
- allowDecimals: !1
3934
- }, "size", r), s(e, "options", r);
3935
- var n = e.lag, o = void 0 === n ? 0 : n, i = e.type, a = void 0 === i ? "price" : i;
3936
- return p(o, {
3937
- min: 0,
3938
- max: this.len,
3939
- allowDecimals: !1
3940
- }, "options.lag", r), f([ "price", "percentage" ], a, "options.type", r), this.inputParams.push({
3941
- key: r,
3942
- params: [ t, {
3943
- lag: o,
3944
- type: a
3945
- } ]
3946
- }), this;
3947
- }
3948
- }, {
3949
- key: "ema",
3950
- value: function() {
3951
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 5, e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r = "ema";
3952
- l(this), p(t, {
3953
- min: 1,
3954
- max: this.len,
3955
- allowDecimals: !1
3956
- }, "size", r), s(e, "options", r);
3957
- var n = e.target, o = void 0 === n ? "close" : n, i = e.lag, a = void 0 === i ? 0 : i;
3958
- p(a, {
3959
- min: 0,
3960
- max: this.len,
3961
- allowDecimals: !1
3962
- }, "options.lag", r);
3963
- var u = Fe({
3964
- main: this,
3965
- size: t,
3966
- target: o,
3967
- lag: a,
3968
- methodName: r
3969
- });
3970
- return this.inputParams.push({
3971
- key: r,
3972
- params: [ r, t, {
3973
- target: o,
3974
- lag: a,
3975
- precomputed: u
3976
- } ]
3977
- }), this;
3978
- }
3979
- }, {
3980
- key: "sma",
3981
- value: function() {
3982
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 5, e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r = "sma";
3983
- l(this), p(t, {
3984
- min: 1,
3985
- max: this.len,
3986
- allowDecimals: !1
3987
- }, "size", r), s(e, "options", r);
3988
- var n = e.target, o = void 0 === n ? "close" : n, i = e.lag, a = void 0 === i ? 0 : i;
3989
- p(a, {
3990
- min: 0,
3991
- max: this.len,
3992
- allowDecimals: !1
3993
- }, "options.lag", r);
3994
- var u = Fe({
3995
- main: this,
3996
- size: t,
3997
- target: o,
3998
- lag: a,
3999
- methodName: r
4000
- });
4001
- return this.inputParams.push({
4002
- key: r,
4003
- params: [ r, t, {
4004
- target: o,
4005
- lag: a,
4006
- precomputed: u
4007
- } ]
4008
- }), this;
4009
- }
4010
- }, {
4011
- key: "macd",
4012
- value: function() {
4013
- 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";
4014
- l(this), p(t, {
4015
- min: 1,
4016
- max: this.len,
4017
- allowDecimals: !1
4018
- }, "fast", o), p(e, {
4019
- min: 1,
4020
- max: this.len,
4021
- allowDecimals: !1
4022
- }, "slow", o), p(r, {
4023
- min: 1,
4024
- max: this.len,
4025
- allowDecimals: !1
4026
- }, "signal", o), s(n, "options", o);
4027
- var i = n.target, a = void 0 === i ? "close" : i, u = n.lag, c = void 0 === u ? 0 : u;
4028
- p(c, {
4029
- min: 0,
4030
- max: this.len,
4031
- allowDecimals: !1
4032
- }, "options.lag", o);
4033
- var f = {
4034
- instanceKey: "".concat(t, "_").concat(e, "_").concat(r).concat("close" === a ? "" : "_".concat(a))
4035
- };
4036
- return this.inputParams.push({
4037
- key: o,
4038
- params: [ t, e, r, {
4039
- target: a,
4040
- lag: c,
4041
- precomputed: f
4042
- } ]
4043
- }), this;
4044
- }
4045
- }, {
4046
- key: "bollingerBands",
4047
- value: function() {
4048
- 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";
4049
- l(this), p(t, {
4050
- min: 1,
4051
- max: this.len,
4052
- allowDecimals: !1
4053
- }, "size", n), p(e, {
4054
- min: .01,
4055
- max: 50,
4056
- allowDecimals: !0
4057
- }, "stdDev", n), s(r, "options", n);
4058
- var o = r.target, i = void 0 === o ? "close" : o, a = r.height, u = void 0 !== a && a, f = r.range, h = void 0 === f ? [] : f, v = r.lag, m = void 0 === v ? 0 : v, d = r.decimals, b = void 0 === d ? null : d;
4059
- return c(h, "options.range", n), p(m, {
4060
- min: 0,
4061
- max: this.len,
4062
- allowDecimals: !1
4063
- }, "options.lag", n), y(u, "options.height", n), null !== b && p(b, {
4064
- min: 1,
4065
- max: 15,
4066
- allowDecimals: !1
4067
- }, "decimals", n), this.inputParams.push({
4068
- key: n,
4069
- params: [ t, e, {
4070
- target: i,
4071
- height: u,
4072
- range: h,
4073
- lag: m,
4074
- decimals: b
4075
- } ]
4076
- }), this;
4077
- }
4078
- }, {
4079
- key: "rsi",
4080
- value: function() {
4081
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 14, e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r = "rsi";
4082
- l(this), p(t, {
4083
- min: 1,
4084
- max: this.len,
4085
- allowDecimals: !1
4086
- }, "size", r), s(e, "options", r);
4087
- var n = e.target, o = void 0 === n ? "close" : n, i = e.lag, a = void 0 === i ? 0 : i;
4088
- return p(a, {
4089
- min: 0,
4090
- max: this.len,
4091
- allowDecimals: !1
4092
- }, "options.lag", r), this.inputParams.push({
4093
- key: r,
4094
- params: [ t, {
4095
- target: o,
4096
- lag: a
4097
- } ]
4098
- }), this;
4099
- }
4100
- }, {
4101
- key: "donchianChannels",
4102
- value: function() {
4103
- 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";
4104
- l(this), p(t, {
4105
- min: 1,
4106
- max: this.len,
4107
- allowDecimals: !1
4108
- }, "size", n), p(e, {
4109
- min: 0,
4110
- max: this.len,
4111
- allowDecimals: !1
4112
- }, "offset", n), s(r, "options", n);
4113
- var o = r.height, i = void 0 !== o && o, a = r.range, u = void 0 === a ? [] : a, f = r.lag, h = void 0 === f ? 0 : f, v = r.decimals, m = void 0 === v ? null : v;
4114
- return c(u, "options.range", n), p(h, {
4115
- min: 0,
4116
- max: this.len,
4117
- allowDecimals: !1
4118
- }, "options.lag", n), y(i, "options.height", n), null !== m && p(m, {
4119
- min: 1,
4120
- max: 15,
4121
- allowDecimals: !1
4122
- }, "decimals", n), this.inputParams.push({
4123
- key: n,
4124
- params: [ t, e, {
4125
- height: i,
4126
- range: u,
4127
- lag: h,
4128
- decimals: m
4129
- } ]
4130
- }), this;
4131
- }
4132
- }, {
4133
- key: "volumeOscillator",
4134
- value: function() {
4135
- 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";
4136
- if (!this.inputTypes.hasOwnProperty("volume")) throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');
4137
- l(this), p(t, {
4138
- min: 1,
4139
- max: this.len,
4140
- allowDecimals: !1
4141
- }, "fastSize", n), p(e, {
4142
- min: t,
4143
- max: this.len,
4144
- allowDecimals: !1
4145
- }, "slowSize", n), s(r, "options", n);
4146
- var o = r.lag, i = void 0 === o ? 0 : o;
4147
- return p(i, {
4148
- min: 0,
4149
- max: this.len,
4150
- allowDecimals: !1
4151
- }, "options.lag", n), this.inputParams.push({
4152
- key: n,
4153
- params: [ t, e, {
4154
- lag: i
4155
- } ]
4156
- }), this;
4157
- }
4158
- }, {
4159
- key: "dateTime",
4160
- value: function() {
4161
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, e = "dateTime";
4162
- l(this), s(t, "options", e);
4163
- var r = t.lag, n = void 0 === r ? 0 : r;
4164
- return p(n, {
4165
- min: 0,
4166
- max: this.len,
4167
- allowDecimals: !1
4168
- }, "options.lag", e), this.inputParams.push({
4169
- key: e,
4170
- params: [ {
4171
- lag: n
4172
- } ]
4173
- }), this;
4174
- }
4175
- }, {
4176
- key: "scaler",
4177
- value: function(t) {
4178
- var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [], n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, o = "scaler";
4179
- l(this), p(t, {
4180
- min: 1,
4181
- max: this.len,
4182
- allowDecimals: !1
4183
- }, "size", o), c(e, "colKeys", o);
4184
- var i = n.group, a = void 0 !== i && i, u = n.range, s = void 0 === u ? [ 0, 1 ] : u, h = n.lag, v = void 0 === h ? 0 : h, m = n.type, d = void 0 === m ? "minmax" : m, b = n.decimals, g = void 0 === b ? null : b;
4185
- y(a, "options.group", o), function(t, e, n) {
4186
- if (c(t, e, n), 2 !== t.length) throw new Error('Invalid "'.concat(e, '" array length: expected 2 items, but got ').concat(t.length, ' in "').concat(n, ".").concat(e, '".'));
4187
- var o = r(t, 2), i = o[0], a = o[1];
4188
- if (p(i, {
4189
- min: -100,
4190
- max: a,
4191
- allowDecimals: !1
4192
- }, "min", n), p(a, {
4193
- min: i,
4194
- max: 100,
4195
- allowDecimals: !1
4196
- }, "max", n), i === a) throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(n, ".").concat(e, '".'));
4197
- }(s, "options.range", o), f([ "minmax", "zscore" ], d, "options.type", o), null !== g && p(g, {
4198
- min: 1,
4199
- max: 15,
4200
- allowDecimals: !1
4201
- }, "decimals", o);
4202
- var w = {
4203
- groupKey: a ? "".concat(d, "_").concat(t, "_group_").concat(e.join("_")) : "",
4204
- groupKeyLen: e.length
4205
- };
4206
- return this.inputParams.push({
4207
- key: o,
4208
- params: [ t, e, {
4209
- type: d,
4210
- group: a,
4211
- range: s,
4212
- lag: v,
4213
- precomputed: w,
4214
- decimals: g
4215
- } ]
4216
- }), this;
4217
- }
4218
- } ], e && tn(t.prototype, e), n && tn(t, n), Object.defineProperty(t, "prototype", {
4219
- writable: !1
4220
- }), t;
4221
- var t, e, n;
4222
- }();
4223
- })(), OHLCV_INDICATORS = e;
4224
- })
4225
- /******/ ();
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})();