velo-plot 2.0.0 → 3.0.0

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.
Files changed (265) hide show
  1. package/README.md +15 -8
  2. package/dist/{ChartCore-BhQ4j7f5.js → ChartCore-BpzRvN4Y.js} +998 -855
  3. package/dist/ChartCore-BpzRvN4Y.js.map +1 -0
  4. package/dist/a11y-Bw6urYpr.js +105 -0
  5. package/dist/a11y-Bw6urYpr.js.map +1 -0
  6. package/dist/angular/hooks-entry.d.ts +1 -0
  7. package/dist/angular/hooks.d.ts +26 -0
  8. package/dist/angular/index.d.ts +8 -0
  9. package/dist/angular/velo-plot.component.d.ts +46 -0
  10. package/dist/angular-hooks.d.ts +1 -0
  11. package/dist/angular-hooks.js +9 -0
  12. package/dist/angular-hooks.js.map +1 -0
  13. package/dist/angular.d.ts +1 -0
  14. package/dist/angular.js +166 -0
  15. package/dist/angular.js.map +1 -0
  16. package/dist/assets/indicator.worker-bv0zC4EX.js.map +1 -1
  17. package/dist/astro/StackedPlot.astro +19 -0
  18. package/dist/astro/VeloPlot.astro +23 -0
  19. package/dist/{axisFormat-SPX-CD5s.js → axisFormat-CzumxpCL.js} +3 -3
  20. package/dist/axisFormat-CzumxpCL.js.map +1 -0
  21. package/dist/bindings/shared/a11y.d.ts +26 -0
  22. package/dist/bindings/shared/chartLifecycle.d.ts +16 -0
  23. package/dist/bindings/shared/chartSyncBridge.d.ts +8 -0
  24. package/dist/bindings/shared/dimensions.d.ts +1 -0
  25. package/dist/bindings/shared/index.d.ts +9 -0
  26. package/dist/bindings/shared/indicatorBridge.d.ts +11 -0
  27. package/dist/bindings/shared/optionsSync.d.ts +7 -0
  28. package/dist/bindings/shared/seriesDiff.d.ts +8 -0
  29. package/dist/bindings/shared/stackedSync.d.ts +9 -0
  30. package/dist/bindings/shared/types.d.ts +46 -0
  31. package/dist/bindings/test-utils/index.d.ts +35 -0
  32. package/dist/bindings/test-utils/mockLifecycle.d.ts +120 -0
  33. package/dist/bindings/test-utils/vitestSveltePlugin.d.ts +3 -0
  34. package/dist/chartSyncBridge-DbWrwtyP.js +57 -0
  35. package/dist/chartSyncBridge-DbWrwtyP.js.map +1 -0
  36. package/dist/core/Chart.d.ts +1 -1
  37. package/dist/core/InteractionManager.d.ts +7 -1
  38. package/dist/core/OverlayRenderer.d.ts +5 -0
  39. package/dist/core/annotations/types.d.ts +1 -1
  40. package/dist/core/chart/ChartAxisManager.d.ts +2 -0
  41. package/dist/core/chart/ChartCore.d.ts +17 -2
  42. package/dist/core/chart/ChartPluginBridge.d.ts +1 -0
  43. package/dist/core/chart/ChartRenderLoop.d.ts +2 -0
  44. package/dist/core/chart/ChartStateManager.d.ts +2 -0
  45. package/dist/core/chart/types.d.ts +6 -1
  46. package/dist/core/clipboard/index.d.ts +1 -1
  47. package/dist/core/debug/index.d.ts +1 -1
  48. package/dist/core/keybindings/index.d.ts +1 -1
  49. package/dist/core/loading/index.d.ts +1 -1
  50. package/dist/core/locale/index.d.ts +1 -1
  51. package/dist/core/stacked/paneResize.d.ts +3 -0
  52. package/dist/core/stacked/types.d.ts +10 -0
  53. package/dist/core/sync/index.d.ts +0 -1
  54. package/dist/core/theme-editor/index.d.ts +1 -1
  55. package/dist/createStackedChart-Dm-YqUT7.js +756 -0
  56. package/dist/createStackedChart-Dm-YqUT7.js.map +1 -0
  57. package/dist/examples/PluginDemonstration.d.ts +1 -1
  58. package/dist/gpuRenderer-BpaMYz-k.js.map +1 -1
  59. package/dist/hooks-CYPCxoZx.js +69 -0
  60. package/dist/hooks-CYPCxoZx.js.map +1 -0
  61. package/dist/{index-D7dTq6VB.js → index-0InEyj0q.js} +130 -134
  62. package/dist/index-0InEyj0q.js.map +1 -0
  63. package/dist/index-BMiZoKmm.js.map +1 -1
  64. package/dist/{index-DoYxf1cV.js → index-CWxIHdwX.js} +38 -98
  65. package/dist/index-CWxIHdwX.js.map +1 -0
  66. package/dist/{index-CUGS98p4.js → index-CaXWSOTk.js} +3 -6
  67. package/dist/index-CaXWSOTk.js.map +1 -0
  68. package/dist/index-Dag88bW4.js.map +1 -1
  69. package/dist/index-qhscKTDy.js.map +1 -1
  70. package/dist/{index-CWipqOLP.js → index-qunX30Xu.js} +2 -2
  71. package/dist/index-qunX30Xu.js.map +1 -0
  72. package/dist/index-x4stH3jD.js.map +1 -1
  73. package/dist/{index.core-fpZ1dYN0.js → index.core-BmZe2jRQ.js} +30 -29
  74. package/dist/index.core-BmZe2jRQ.js.map +1 -0
  75. package/dist/index.core.d.ts +1 -1
  76. package/dist/index.d.ts +3 -3
  77. package/dist/indicators--eJGmVox.js.map +1 -1
  78. package/dist/{mockDatafeed-Cdg5hKEo.js → mockDatafeed-DHIDPcpX.js} +150 -146
  79. package/dist/mockDatafeed-DHIDPcpX.js.map +1 -0
  80. package/dist/optionsSync-QUiN4Inw.js +119 -0
  81. package/dist/optionsSync-QUiN4Inw.js.map +1 -0
  82. package/dist/plugins/3d/index.d.ts +2 -2
  83. package/dist/plugins/3d.d.ts +2 -2
  84. package/dist/plugins/3d.js.map +1 -1
  85. package/dist/plugins/analysis/contours.d.ts +31 -0
  86. package/dist/plugins/analysis/index.d.ts +1 -1
  87. package/dist/plugins/analysis/indicators.d.ts +1 -1
  88. package/dist/plugins/analysis.d.ts +2 -2
  89. package/dist/plugins/analysis.js +495 -408
  90. package/dist/plugins/analysis.js.map +1 -1
  91. package/dist/plugins/annotations/index.d.ts +1 -1
  92. package/dist/plugins/annotations.d.ts +2 -2
  93. package/dist/plugins/annotations.js.map +1 -1
  94. package/dist/plugins/anomaly-detection.js +1 -1
  95. package/dist/plugins/anomaly-detection.js.map +1 -1
  96. package/dist/plugins/broken-axis.d.ts +2 -2
  97. package/dist/plugins/broken-axis.js +170 -181
  98. package/dist/plugins/broken-axis.js.map +1 -1
  99. package/dist/plugins/builtins/crosshair/CrosshairPlugin.d.ts +1 -1
  100. package/dist/plugins/builtins/index.d.ts +1 -1
  101. package/dist/plugins/caching.d.ts +2 -2
  102. package/dist/plugins/clipboard/index.d.ts +2 -2
  103. package/dist/plugins/clipboard.d.ts +2 -2
  104. package/dist/plugins/clipboard.js.map +1 -1
  105. package/dist/plugins/context-menu/index.d.ts +1 -1
  106. package/dist/plugins/context-menu.d.ts +2 -2
  107. package/dist/plugins/context-menu.js +1 -1
  108. package/dist/plugins/context-menu.js.map +1 -1
  109. package/dist/plugins/data-export/index.d.ts +1 -1
  110. package/dist/plugins/data-export.d.ts +2 -2
  111. package/dist/plugins/data-export.js +2 -2
  112. package/dist/plugins/data-export.js.map +1 -1
  113. package/dist/plugins/data-transform.d.ts +2 -2
  114. package/dist/plugins/data-transform.js +19 -19
  115. package/dist/plugins/data-transform.js.map +1 -1
  116. package/dist/plugins/debug/index.d.ts +2 -2
  117. package/dist/plugins/debug.d.ts +2 -2
  118. package/dist/plugins/debug.js +2 -2
  119. package/dist/plugins/debug.js.map +1 -1
  120. package/dist/plugins/forecasting/algorithms.d.ts +7 -2
  121. package/dist/plugins/forecasting/index.d.ts +1 -1
  122. package/dist/plugins/forecasting/types.d.ts +13 -3
  123. package/dist/plugins/forecasting.js +355 -175
  124. package/dist/plugins/forecasting.js.map +1 -1
  125. package/dist/plugins/gpu/index.d.ts +2 -2
  126. package/dist/plugins/gpu.d.ts +2 -2
  127. package/dist/plugins/gpu.js.map +1 -1
  128. package/dist/plugins/i18n/index.d.ts +2 -2
  129. package/dist/plugins/i18n.d.ts +2 -2
  130. package/dist/plugins/i18n.js.map +1 -1
  131. package/dist/plugins/index.d.ts +1 -1
  132. package/dist/plugins/keyboard.d.ts +2 -2
  133. package/dist/plugins/keyboard.js +65 -5
  134. package/dist/plugins/keyboard.js.map +1 -1
  135. package/dist/plugins/latex/symbols.d.ts +50 -0
  136. package/dist/plugins/latex/types.d.ts +13 -1
  137. package/dist/plugins/latex.js +351 -331
  138. package/dist/plugins/latex.js.map +1 -1
  139. package/dist/plugins/lazy-load.d.ts +2 -2
  140. package/dist/plugins/loading/index.d.ts +1 -1
  141. package/dist/plugins/loading.d.ts +2 -2
  142. package/dist/plugins/ml-integration/native-algorithms.d.ts +24 -4
  143. package/dist/plugins/ml-integration/types.d.ts +19 -0
  144. package/dist/plugins/ml-integration.d.ts +2 -2
  145. package/dist/plugins/ml-integration.js +190 -139
  146. package/dist/plugins/ml-integration.js.map +1 -1
  147. package/dist/plugins/offscreen.d.ts +2 -2
  148. package/dist/plugins/pattern-recognition/types.d.ts +28 -1
  149. package/dist/plugins/pattern-recognition.d.ts +2 -2
  150. package/dist/plugins/pattern-recognition.js +417 -344
  151. package/dist/plugins/pattern-recognition.js.map +1 -1
  152. package/dist/plugins/radar.d.ts +2 -2
  153. package/dist/plugins/regression.d.ts +2 -2
  154. package/dist/plugins/regression.js +1 -1
  155. package/dist/plugins/regression.js.map +1 -1
  156. package/dist/plugins/roi.js +9 -9
  157. package/dist/plugins/roi.js.map +1 -1
  158. package/dist/plugins/snapshot/index.d.ts +1 -1
  159. package/dist/plugins/snapshot/types.d.ts +1 -1
  160. package/dist/plugins/snapshot.d.ts +2 -2
  161. package/dist/plugins/snapshot.js +36 -36
  162. package/dist/plugins/snapshot.js.map +1 -1
  163. package/dist/plugins/streaming/index.d.ts +2 -2
  164. package/dist/plugins/streaming.d.ts +2 -2
  165. package/dist/plugins/sync/index.d.ts +3 -2
  166. package/dist/plugins/sync.d.ts +2 -2
  167. package/dist/plugins/sync.js +1 -1
  168. package/dist/plugins/sync.js.map +1 -1
  169. package/dist/plugins/theme-editor/index.d.ts +1 -1
  170. package/dist/plugins/theme-editor.d.ts +2 -2
  171. package/dist/plugins/tools/index.d.ts +1 -1
  172. package/dist/plugins/tools/tooltip/index.d.ts +1 -1
  173. package/dist/plugins/tools.d.ts +2 -2
  174. package/dist/plugins/tools.js +1 -1
  175. package/dist/plugins/types.d.ts +1 -1
  176. package/dist/plugins/video-recorder.d.ts +2 -2
  177. package/dist/plugins/virtualization.d.ts +2 -2
  178. package/dist/plugins/virtualization.js +1 -1
  179. package/dist/pool-DZ8shSqv.js +109 -0
  180. package/dist/pool-DZ8shSqv.js.map +1 -0
  181. package/dist/react/StackedPlot.d.ts +31 -0
  182. package/dist/react/VeloPlot.d.ts +29 -0
  183. package/dist/react/index.d.ts +25 -3
  184. package/dist/react/useChartSync.d.ts +8 -0
  185. package/dist/react/useIndicator.d.ts +12 -0
  186. package/dist/react/useVeloPlot.d.ts +19 -0
  187. package/dist/react.js +328 -24
  188. package/dist/react.js.map +1 -1
  189. package/dist/scientific/index.d.ts +48 -0
  190. package/dist/scientific.d.ts +1 -0
  191. package/dist/scientific.js +91 -0
  192. package/dist/scientific.js.map +1 -0
  193. package/dist/solid/VeloPlot.d.ts +16 -0
  194. package/dist/solid/index.d.ts +13 -0
  195. package/dist/solid/useChartSync.d.ts +6 -0
  196. package/dist/solid/useIndicator.d.ts +11 -0
  197. package/dist/solid/useStackedPlot.d.ts +14 -0
  198. package/dist/solid/useVeloPlot.d.ts +18 -0
  199. package/dist/solid.d.ts +1 -0
  200. package/dist/solid.js +172 -0
  201. package/dist/solid.js.map +1 -0
  202. package/dist/stackedSync-tnrunZMt.js +100 -0
  203. package/dist/stackedSync-tnrunZMt.js.map +1 -0
  204. package/dist/svelte/StackedPlot.svelte +29 -0
  205. package/dist/svelte/StackedPlot.test.ts +114 -0
  206. package/dist/svelte/VeloPlot.svelte +44 -0
  207. package/dist/svelte/VeloPlot.test.ts +105 -0
  208. package/dist/svelte/index.d.ts +11 -0
  209. package/dist/svelte/index.test.ts +20 -0
  210. package/dist/svelte/index.ts +15 -0
  211. package/dist/svelte/useChartSync.d.ts +8 -0
  212. package/dist/svelte/useChartSync.test.ts +49 -0
  213. package/dist/svelte/useChartSync.ts +29 -0
  214. package/dist/svelte/useIndicator.d.ts +13 -0
  215. package/dist/svelte/useIndicator.test.ts +67 -0
  216. package/dist/svelte/useIndicator.ts +43 -0
  217. package/dist/svelte/useStackedPlot.d.ts +16 -0
  218. package/dist/svelte/useStackedPlot.test.ts +76 -0
  219. package/dist/svelte/useStackedPlot.ts +54 -0
  220. package/dist/svelte/useVeloPlot.d.ts +21 -0
  221. package/dist/svelte/useVeloPlot.test.ts +100 -0
  222. package/dist/svelte/useVeloPlot.ts +81 -0
  223. package/dist/svelte.d.ts +1 -0
  224. package/dist/svelte.js +143 -0
  225. package/dist/svelte.js.map +1 -0
  226. package/dist/symbols-DT0eLlpW.js +568 -0
  227. package/dist/symbols-DT0eLlpW.js.map +1 -0
  228. package/dist/testing/index.d.ts +1 -1
  229. package/dist/theme/index.d.ts +2 -1
  230. package/dist/trading.js +7 -7
  231. package/dist/types.d.ts +1 -1
  232. package/dist/{utils-BK5UUXxj.js → utils-Dx0h0bgQ.js} +9 -9
  233. package/dist/{utils-BK5UUXxj.js.map → utils-Dx0h0bgQ.js.map} +1 -1
  234. package/dist/velo-plot.full.js +444 -433
  235. package/dist/velo-plot.full.js.map +1 -1
  236. package/dist/velo-plot.js +15 -15
  237. package/dist/vue/StackedPlot.vue.d.ts +48 -0
  238. package/dist/vue/VeloPlot.vue.d.ts +64 -0
  239. package/dist/vue/index.d.ts +250 -0
  240. package/dist/vue/useChartSync.d.ts +52 -0
  241. package/dist/vue/useIndicator.d.ts +23 -0
  242. package/dist/vue/useStackedPlot.d.ts +15 -0
  243. package/dist/vue/useVeloPlot.d.ts +20 -0
  244. package/dist/vue.d.ts +1 -0
  245. package/dist/vue.js +312 -0
  246. package/dist/vue.js.map +1 -0
  247. package/dist/workers/indicatorsAsync.d.ts +26 -0
  248. package/dist/workers/pool.d.ts +9 -0
  249. package/package.json +88 -10
  250. package/dist/ChartCore-BhQ4j7f5.js.map +0 -1
  251. package/dist/SciPlot-GJvw7GJo.js +0 -463
  252. package/dist/SciPlot-GJvw7GJo.js.map +0 -1
  253. package/dist/axisFormat-SPX-CD5s.js.map +0 -1
  254. package/dist/createStackedChart-DJSmqerD.js +0 -706
  255. package/dist/createStackedChart-DJSmqerD.js.map +0 -1
  256. package/dist/index-CUGS98p4.js.map +0 -1
  257. package/dist/index-CWipqOLP.js.map +0 -1
  258. package/dist/index-D7dTq6VB.js.map +0 -1
  259. package/dist/index-DoYxf1cV.js.map +0 -1
  260. package/dist/index.core-fpZ1dYN0.js.map +0 -1
  261. package/dist/mockDatafeed-Cdg5hKEo.js.map +0 -1
  262. package/dist/pool-15HMCNv8.js +0 -88
  263. package/dist/pool-15HMCNv8.js.map +0 -1
  264. package/dist/react/SciPlot.d.ts +0 -60
  265. package/dist/react/useSciPlot.d.ts +0 -56
@@ -1,18 +1,18 @@
1
- import { a as A, s as W, d as _, i as z } from "../math-Ddm2EZjj.js";
2
- import { c as on } from "../math-Ddm2EZjj.js";
3
- import { g as E, f as T, d as H, s as X, m as Y, a as N, b as O, v as Z, c as G } from "../utils-BK5UUXxj.js";
4
- import { h as sn, e as cn, i as an } from "../utils-BK5UUXxj.js";
1
+ import { a as F, s as W, d as _, i as z } from "../math-Ddm2EZjj.js";
2
+ import { c as cn } from "../math-Ddm2EZjj.js";
3
+ import { c as E, f as T, i as H, s as X, m as Y, d as N, e as O, v as Z, h as G } from "../utils-Dx0h0bgQ.js";
4
+ import { b as ln, a as fn, g as un } from "../utils-Dx0h0bgQ.js";
5
5
  import { r as K, e as Q, s as U } from "../indicators--eJGmVox.js";
6
- import { i as fn, j as un, g as hn, f as mn, k as gn, d as dn, m as Mn, c as wn, n as pn, o as yn, p as Fn, b as An, h as bn, a as In, t as qn, v as xn, w as Pn } from "../indicators--eJGmVox.js";
6
+ import { i as mn, j as gn, g as dn, f as Mn, k as wn, d as pn, m as yn, c as bn, n as Fn, o as An, p as xn, b as In, h as qn, a as Pn, t as vn, v as kn, w as $n } from "../indicators--eJGmVox.js";
7
7
  function J(e, r, o, t = {}) {
8
8
  const n = e.series.get(r);
9
9
  if (!n) throw new Error(`Series ${r} not found`);
10
- const s = n.getData();
11
- if (!s || s.x.length < 2) return "";
12
- const c = L(s.x, s.y, o, t), i = n.getBounds(), l = (i == null ? void 0 : i.xMin) ?? 0, a = ((i == null ? void 0 : i.xMax) ?? 1) - l, u = 200, h = new Float32Array(u), m = new Float32Array(u);
10
+ const c = n.getData();
11
+ if (!c || c.x.length < 2) return "";
12
+ const s = C(c.x, c.y, o, t), a = n.getBounds(), l = (a == null ? void 0 : a.xMin) ?? 0, i = ((a == null ? void 0 : a.xMax) ?? 1) - l, u = 200, h = new Float32Array(u), m = new Float32Array(u);
13
13
  for (let d = 0; d < u; d++) {
14
- const w = l + d / (u - 1) * a;
15
- h[d] = w, m[d] = c.predict(w);
14
+ const w = l + d / (u - 1) * i;
15
+ h[d] = w, m[d] = s.predict(w);
16
16
  }
17
17
  const g = `${r}-fit-${Date.now()}`, M = n.getStyle();
18
18
  return e.addSeries({
@@ -28,10 +28,10 @@ function J(e, r, o, t = {}) {
28
28
  }
29
29
  }), e.addAnnotation({
30
30
  type: "text",
31
- x: l + a * 0.05,
32
- y: c.predict(l + a * 0.05),
33
- text: `${c.equation}
34
- (R² = ${c.rSquared.toFixed(4)})`,
31
+ x: l + i * 0.05,
32
+ y: s.predict(l + i * 0.05),
33
+ text: `${s.equation}
34
+ (R² = ${s.rSquared.toFixed(4)})`,
35
35
  fontSize: 12,
36
36
  backgroundColor: "rgba(0,0,0,0.7)",
37
37
  color: M.color || "#ffffff",
@@ -40,50 +40,50 @@ function J(e, r, o, t = {}) {
40
40
  interactive: !0
41
41
  }), g;
42
42
  }
43
- function x(e) {
44
- const r = e.length, o = C(r), t = new Float64Array(o);
45
- for (let s = 0; s < r; s++)
46
- t[s] = e[s];
43
+ function q(e) {
44
+ const r = e.length, o = R(r), t = new Float64Array(o);
45
+ for (let c = 0; c < r; c++)
46
+ t[c] = e[c];
47
47
  const n = new Array(o);
48
- for (let s = 0; s < o; s++)
49
- n[s] = { re: t[s], im: 0 };
50
- b(n);
51
- for (let s = 2; s <= o; s *= 2) {
52
- const c = s / 2, i = -2 * Math.PI / s;
53
- for (let l = 0; l < o; l += s)
54
- for (let f = 0; f < c; f++) {
55
- const a = i * f, u = Math.cos(a), h = Math.sin(a), m = l + f, g = l + f + c, M = u * n[g].re - h * n[g].im, d = u * n[g].im + h * n[g].re;
48
+ for (let c = 0; c < o; c++)
49
+ n[c] = { re: t[c], im: 0 };
50
+ A(n);
51
+ for (let c = 2; c <= o; c *= 2) {
52
+ const s = c / 2, a = -2 * Math.PI / c;
53
+ for (let l = 0; l < o; l += c)
54
+ for (let f = 0; f < s; f++) {
55
+ const i = a * f, u = Math.cos(i), h = Math.sin(i), m = l + f, g = l + f + s, M = u * n[g].re - h * n[g].im, d = u * n[g].im + h * n[g].re;
56
56
  n[g].re = n[m].re - M, n[g].im = n[m].im - d, n[m].re = n[m].re + M, n[m].im = n[m].im + d;
57
57
  }
58
58
  }
59
59
  return n;
60
60
  }
61
61
  function V(e) {
62
- const r = e.length, o = e.map((s) => ({ re: s.re, im: -s.im })), t = tt(o), n = new Float32Array(r);
63
- for (let s = 0; s < r; s++)
64
- n[s] = t[s].re / r;
62
+ const r = e.length, o = e.map((c) => ({ re: c.re, im: -c.im })), t = tt(o), n = new Float32Array(r);
63
+ for (let c = 0; c < r; c++)
64
+ n[c] = t[c].re / r;
65
65
  return n;
66
66
  }
67
67
  function tt(e) {
68
68
  const r = e.length, o = e.map((t) => ({ ...t }));
69
- b(o);
69
+ A(o);
70
70
  for (let t = 2; t <= r; t *= 2) {
71
- const n = t / 2, s = -2 * Math.PI / t;
72
- for (let c = 0; c < r; c += t)
73
- for (let i = 0; i < n; i++) {
74
- const l = s * i, f = Math.cos(l), a = Math.sin(l), u = c + i, h = c + i + n, m = f * o[h].re - a * o[h].im, g = f * o[h].im + a * o[h].re;
71
+ const n = t / 2, c = -2 * Math.PI / t;
72
+ for (let s = 0; s < r; s += t)
73
+ for (let a = 0; a < n; a++) {
74
+ const l = c * a, f = Math.cos(l), i = Math.sin(l), u = s + a, h = s + a + n, m = f * o[h].re - i * o[h].im, g = f * o[h].im + i * o[h].re;
75
75
  o[h].re = o[u].re - m, o[h].im = o[u].im - g, o[u].re = o[u].re + m, o[u].im = o[u].im + g;
76
76
  }
77
77
  }
78
78
  return o;
79
79
  }
80
- function b(e) {
80
+ function A(e) {
81
81
  const r = e.length, o = Math.log2(r);
82
82
  for (let t = 0; t < r; t++) {
83
83
  const n = nt(t, o);
84
84
  if (n > t) {
85
- const s = e[t];
86
- e[t] = e[n], e[n] = s;
85
+ const c = e[t];
86
+ e[t] = e[n], e[n] = c;
87
87
  }
88
88
  }
89
89
  }
@@ -93,49 +93,49 @@ function nt(e, r) {
93
93
  o = o << 1 | e & 1, e >>= 1;
94
94
  return o;
95
95
  }
96
- function C(e) {
96
+ function R(e) {
97
97
  let r = 1;
98
98
  for (; r < e; ) r *= 2;
99
99
  return r;
100
100
  }
101
- function j(e, r = 1) {
102
- const o = x(e), t = o.length, n = t / 2, s = new Float32Array(n), c = new Float32Array(n), i = new Float32Array(n), l = new Float32Array(t), f = new Float32Array(t);
103
- for (let a = 0; a < t; a++)
104
- l[a] = o[a].re, f[a] = o[a].im;
105
- for (let a = 0; a < n; a++)
106
- s[a] = a * r / t, c[a] = Math.sqrt(o[a].re * o[a].re + o[a].im * o[a].im) / t, i[a] = Math.atan2(o[a].im, o[a].re);
107
- for (let a = 1; a < n; a++)
108
- c[a] *= 2;
101
+ function L(e, r = 1) {
102
+ const o = q(e), t = o.length, n = t / 2, c = new Float32Array(n), s = new Float32Array(n), a = new Float32Array(n), l = new Float32Array(t), f = new Float32Array(t);
103
+ for (let i = 0; i < t; i++)
104
+ l[i] = o[i].re, f[i] = o[i].im;
105
+ for (let i = 0; i < n; i++)
106
+ c[i] = i * r / t, s[i] = Math.sqrt(o[i].re * o[i].re + o[i].im * o[i].im) / t, a[i] = Math.atan2(o[i].im, o[i].re);
107
+ for (let i = 1; i < n; i++)
108
+ s[i] *= 2;
109
109
  return {
110
- frequency: s,
111
- magnitude: c,
112
- phase: i,
110
+ frequency: c,
111
+ magnitude: s,
112
+ phase: a,
113
113
  complex: o,
114
114
  real: l,
115
115
  imag: f
116
116
  };
117
117
  }
118
- function kt(e, r = 1) {
119
- const o = j(e, r), t = o.frequency.length, n = new Float32Array(t), s = new Float32Array(t);
120
- for (let c = 0; c < t; c++)
121
- n[c] = o.magnitude[c] * o.magnitude[c], s[c] = 10 * Math.log10(Math.max(n[c], 1e-20));
118
+ function Lt(e, r = 1) {
119
+ const o = L(e, r), t = o.frequency.length, n = new Float32Array(t), c = new Float32Array(t);
120
+ for (let s = 0; s < t; s++)
121
+ n[s] = o.magnitude[s] * o.magnitude[s], c[s] = 10 * Math.log10(Math.max(n[s], 1e-20));
122
122
  return {
123
123
  frequency: o.frequency,
124
124
  power: n,
125
- powerDb: s
125
+ powerDb: c
126
126
  };
127
127
  }
128
- function Rt(e, r = 1, o = 0) {
129
- const t = j(e, r);
130
- let n = 0, s = 0;
131
- for (let c = 0; c < t.magnitude.length; c++)
132
- t.frequency[c] >= o && t.magnitude[c] > n && (n = t.magnitude[c], s = c);
128
+ function Ct(e, r = 1, o = 0) {
129
+ const t = L(e, r);
130
+ let n = 0, c = 0;
131
+ for (let s = 0; s < t.magnitude.length; s++)
132
+ t.frequency[s] >= o && t.magnitude[s] > n && (n = t.magnitude[s], c = s);
133
133
  return {
134
- frequency: t.frequency[s],
134
+ frequency: t.frequency[c],
135
135
  magnitude: n
136
136
  };
137
137
  }
138
- function Ct(e) {
138
+ function St(e) {
139
139
  const r = e.length, o = new Float32Array(r);
140
140
  for (let t = 0; t < r; t++) {
141
141
  const n = 0.5 * (1 - Math.cos(2 * Math.PI * t / (r - 1)));
@@ -143,7 +143,7 @@ function Ct(e) {
143
143
  }
144
144
  return o;
145
145
  }
146
- function jt(e) {
146
+ function Bt(e) {
147
147
  const r = e.length, o = new Float32Array(r);
148
148
  for (let t = 0; t < r; t++) {
149
149
  const n = 0.54 - 0.46 * Math.cos(2 * Math.PI * t / (r - 1));
@@ -151,61 +151,61 @@ function jt(e) {
151
151
  }
152
152
  return o;
153
153
  }
154
- function Lt(e) {
155
- const r = e.length, o = new Float32Array(r), t = 0.42, n = 0.5, s = 0.08;
156
- for (let c = 0; c < r; c++) {
157
- const i = t - n * Math.cos(2 * Math.PI * c / (r - 1)) + s * Math.cos(4 * Math.PI * c / (r - 1));
158
- o[c] = e[c] * i;
154
+ function Dt(e) {
155
+ const r = e.length, o = new Float32Array(r), t = 0.42, n = 0.5, c = 0.08;
156
+ for (let s = 0; s < r; s++) {
157
+ const a = t - n * Math.cos(2 * Math.PI * s / (r - 1)) + c * Math.cos(4 * Math.PI * s / (r - 1));
158
+ o[s] = e[s] * a;
159
159
  }
160
160
  return o;
161
161
  }
162
- function St(e, r = 1) {
163
- const o = x(e), t = o.length, n = t / 2, s = new Float32Array(t), c = new Float32Array(t), i = new Float32Array(t), l = new Float32Array(t), f = new Float32Array(t);
164
- for (let a = 0; a < t; a++)
165
- s[a] = o[a].re, c[a] = o[a].im, i[a] = a * r / t, l[a] = Math.sqrt(o[a].re * o[a].re + o[a].im * o[a].im), f[a] = Math.atan2(o[a].im, o[a].re);
162
+ function Wt(e, r = 1) {
163
+ const o = q(e), t = o.length, n = t / 2, c = new Float32Array(t), s = new Float32Array(t), a = new Float32Array(t), l = new Float32Array(t), f = new Float32Array(t);
164
+ for (let i = 0; i < t; i++)
165
+ c[i] = o[i].re, s[i] = o[i].im, a[i] = i * r / t, l[i] = Math.sqrt(o[i].re * o[i].re + o[i].im * o[i].im), f[i] = Math.atan2(o[i].im, o[i].re);
166
166
  return {
167
- real: s,
168
- imag: c,
169
- frequency: i,
167
+ real: c,
168
+ imag: s,
169
+ frequency: a,
170
170
  magnitude: l,
171
171
  phase: f,
172
172
  length: t,
173
173
  nyquist: n
174
174
  };
175
175
  }
176
- function Bt(e, r) {
176
+ function _t(e, r) {
177
177
  const o = e.length;
178
178
  if (r.length !== o)
179
179
  throw new Error("Real and imaginary arrays must have the same length");
180
- const t = C(o), n = new Array(t);
181
- for (let a = 0; a < t; a++)
182
- n[a] = {
183
- re: a < o ? e[a] : 0,
184
- im: a < o ? r[a] : 0
180
+ const t = R(o), n = new Array(t);
181
+ for (let i = 0; i < t; i++)
182
+ n[i] = {
183
+ re: i < o ? e[i] : 0,
184
+ im: i < o ? r[i] : 0
185
185
  };
186
- b(n);
187
- for (let a = 2; a <= t; a *= 2) {
188
- const u = a / 2, h = -2 * Math.PI / a;
189
- for (let m = 0; m < t; m += a)
186
+ A(n);
187
+ for (let i = 2; i <= t; i *= 2) {
188
+ const u = i / 2, h = -2 * Math.PI / i;
189
+ for (let m = 0; m < t; m += i)
190
190
  for (let g = 0; g < u; g++) {
191
- const M = h * g, d = Math.cos(M), w = Math.sin(M), p = m + g, y = m + g + u, F = d * n[y].re - w * n[y].im, P = d * n[y].im + w * n[y].re;
192
- n[y].re = n[p].re - F, n[y].im = n[p].im - P, n[p].re = n[p].re + F, n[p].im = n[p].im + P;
191
+ const M = h * g, d = Math.cos(M), w = Math.sin(M), p = m + g, y = m + g + u, b = d * n[y].re - w * n[y].im, P = d * n[y].im + w * n[y].re;
192
+ n[y].re = n[p].re - b, n[y].im = n[p].im - P, n[p].re = n[p].re + b, n[p].im = n[p].im + P;
193
193
  }
194
194
  }
195
- const s = new Float32Array(t), c = new Float32Array(t), i = new Float32Array(t), l = new Float32Array(t), f = new Float32Array(t);
196
- for (let a = 0; a < t; a++)
197
- s[a] = n[a].re, c[a] = n[a].im, i[a] = a / t, l[a] = Math.sqrt(n[a].re * n[a].re + n[a].im * n[a].im), f[a] = Math.atan2(n[a].im, n[a].re);
195
+ const c = new Float32Array(t), s = new Float32Array(t), a = new Float32Array(t), l = new Float32Array(t), f = new Float32Array(t);
196
+ for (let i = 0; i < t; i++)
197
+ c[i] = n[i].re, s[i] = n[i].im, a[i] = i / t, l[i] = Math.sqrt(n[i].re * n[i].re + n[i].im * n[i].im), f[i] = Math.atan2(n[i].im, n[i].re);
198
198
  return {
199
- real: s,
200
- imag: c,
201
- frequency: i,
199
+ real: c,
200
+ imag: s,
201
+ frequency: a,
202
202
  magnitude: l,
203
203
  phase: f,
204
204
  length: t,
205
205
  nyquist: t / 2
206
206
  };
207
207
  }
208
- function Dt(e) {
208
+ function zt(e) {
209
209
  const r = e.length, o = new Float32Array(r), t = new Float32Array(r);
210
210
  for (let n = 0; n < r; n++)
211
211
  o[n] = e[n].re, t[n] = e[n].im;
@@ -220,27 +220,27 @@ function et(e, r) {
220
220
  t[n] = { re: e[n], im: r[n] };
221
221
  return t;
222
222
  }
223
- function Wt(e, r) {
223
+ function Et(e, r) {
224
224
  const o = et(e, r);
225
225
  return V(o);
226
226
  }
227
- function _t(e) {
228
- const r = e.length, t = e.map((c) => ({ re: c.re, im: -c.im })).map((c) => ({ ...c }));
229
- b(t);
230
- for (let c = 2; c <= r; c *= 2) {
231
- const i = c / 2, l = -2 * Math.PI / c;
232
- for (let f = 0; f < r; f += c)
233
- for (let a = 0; a < i; a++) {
234
- const u = l * a, h = Math.cos(u), m = Math.sin(u), g = f + a, M = f + a + i, d = h * t[M].re - m * t[M].im, w = h * t[M].im + m * t[M].re;
227
+ function Tt(e) {
228
+ const r = e.length, t = e.map((s) => ({ re: s.re, im: -s.im })).map((s) => ({ ...s }));
229
+ A(t);
230
+ for (let s = 2; s <= r; s *= 2) {
231
+ const a = s / 2, l = -2 * Math.PI / s;
232
+ for (let f = 0; f < r; f += s)
233
+ for (let i = 0; i < a; i++) {
234
+ const u = l * i, h = Math.cos(u), m = Math.sin(u), g = f + i, M = f + i + a, d = h * t[M].re - m * t[M].im, w = h * t[M].im + m * t[M].re;
235
235
  t[M].re = t[g].re - d, t[M].im = t[g].im - w, t[g].re = t[g].re + d, t[g].im = t[g].im + w;
236
236
  }
237
237
  }
238
- const n = new Float32Array(r), s = new Float32Array(r);
239
- for (let c = 0; c < r; c++)
240
- n[c] = t[c].re / r, s[c] = -t[c].im / r;
241
- return { real: n, imag: s };
238
+ const n = new Float32Array(r), c = new Float32Array(r);
239
+ for (let s = 0; s < r; s++)
240
+ n[s] = t[s].re / r, c[s] = -t[s].im / r;
241
+ return { real: n, imag: c };
242
242
  }
243
- function zt(e) {
243
+ function Ht(e) {
244
244
  const r = e.nyquist;
245
245
  return {
246
246
  real: e.real.slice(0, r),
@@ -250,11 +250,11 @@ function zt(e) {
250
250
  phase: e.phase.slice(0, r)
251
251
  };
252
252
  }
253
- function L(e, r, o, t = {}) {
253
+ function C(e, r, o, t = {}) {
254
254
  if (e.length < 2) throw new Error("At least 2 points are required for fitting");
255
255
  switch (o) {
256
256
  case "linear":
257
- return I(e, r, t);
257
+ return x(e, r, t);
258
258
  case "polynomial":
259
259
  return ot(e, r, t.degree ?? 2, t);
260
260
  case "exponential":
@@ -267,44 +267,44 @@ function L(e, r, o, t = {}) {
267
267
  throw new Error(`Unsupported fit type: ${o}`);
268
268
  }
269
269
  }
270
- function I(e, r, o) {
270
+ function x(e, r, o) {
271
271
  const t = e.length;
272
- let n = 0, s = 0, c = 0, i = 0;
272
+ let n = 0, c = 0, s = 0, a = 0;
273
273
  for (let m = 0; m < t; m++)
274
- n += e[m], s += r[m], c += e[m] * r[m], i += e[m] * e[m];
275
- const l = (t * c - n * s) / (t * i - n * n), f = (s - l * n) / t, a = (m) => l * m + f, u = o.precision ?? 4, h = o.label || "y";
274
+ n += e[m], c += r[m], s += e[m] * r[m], a += e[m] * e[m];
275
+ const l = (t * s - n * c) / (t * a - n * n), f = (c - l * n) / t, i = (m) => l * m + f, u = o.precision ?? 4, h = o.label || "y";
276
276
  return {
277
277
  type: "linear",
278
278
  coefficients: [l, f],
279
279
  equation: `${h} = ${l.toFixed(u)}x ${f >= 0 ? "+" : "-"} ${Math.abs(f).toFixed(u)}`,
280
- rSquared: A(e, r, a),
281
- predict: a
280
+ rSquared: F(e, r, i),
281
+ predict: i
282
282
  };
283
283
  }
284
284
  function ot(e, r, o, t) {
285
- const n = e.length, s = o + 1, c = Array.from({ length: s }, () => new Array(s).fill(0)), i = new Array(s).fill(0);
286
- for (let m = 0; m < s; m++) {
287
- for (let M = 0; M < s; M++) {
285
+ const n = e.length, c = o + 1, s = Array.from({ length: c }, () => new Array(c).fill(0)), a = new Array(c).fill(0);
286
+ for (let m = 0; m < c; m++) {
287
+ for (let M = 0; M < c; M++) {
288
288
  let d = 0;
289
289
  for (let w = 0; w < n; w++)
290
290
  d += Math.pow(e[w], m + M);
291
- c[m][M] = d;
291
+ s[m][M] = d;
292
292
  }
293
293
  let g = 0;
294
294
  for (let M = 0; M < n; M++)
295
295
  g += r[M] * Math.pow(e[M], m);
296
- i[m] = g;
296
+ a[m] = g;
297
297
  }
298
- const l = W(c, i), f = (m) => {
298
+ const l = W(s, a), f = (m) => {
299
299
  let g = 0;
300
300
  for (let M = 0; M < l.length; M++)
301
301
  g += l[M] * Math.pow(m, M);
302
302
  return g;
303
- }, a = t.precision ?? 4;
303
+ }, i = t.precision ?? 4;
304
304
  let u = "y = ";
305
305
  for (let m = l.length - 1; m >= 0; m--) {
306
306
  const g = l[m];
307
- m < l.length - 1 ? u += g >= 0 ? " + " : " - " : g < 0 && (u += "-"), u += `${Math.abs(g).toFixed(a)}${m > 0 ? m > 1 ? `x^${m}` : "x" : ""}`;
307
+ m < l.length - 1 ? u += g >= 0 ? " + " : " - " : g < 0 && (u += "-"), u += `${Math.abs(g).toFixed(i)}${m > 0 ? m > 1 ? `x^${m}` : "x" : ""}`;
308
308
  }
309
309
  const h = t.label || "y";
310
310
  return {
@@ -312,127 +312,127 @@ function ot(e, r, o, t) {
312
312
  coefficients: l,
313
313
  equation: `${h} = ${u.substring(4)}`,
314
314
  // replace "y = " with custom label
315
- rSquared: A(e, r, f),
315
+ rSquared: F(e, r, f),
316
316
  predict: f
317
317
  };
318
318
  }
319
319
  function rt(e, r, o) {
320
- const t = e.length, n = [], s = [];
320
+ const t = e.length, n = [], c = [];
321
321
  for (let h = 0; h < t; h++)
322
- r[h] > 0 && (n.push(e[h]), s.push(Math.log(r[h])));
323
- const c = I(n, s, o), i = c.coefficients[0], l = Math.exp(c.coefficients[1]), f = (h) => l * Math.exp(i * h), a = o.precision ?? 4, u = o.label || "y";
322
+ r[h] > 0 && (n.push(e[h]), c.push(Math.log(r[h])));
323
+ const s = x(n, c, o), a = s.coefficients[0], l = Math.exp(s.coefficients[1]), f = (h) => l * Math.exp(a * h), i = o.precision ?? 4, u = o.label || "y";
324
324
  return {
325
325
  type: "exponential",
326
- coefficients: [l, i],
327
- equation: `${u} = ${l.toFixed(a)} * e^(${i.toFixed(a)}x)`,
328
- rSquared: A(e, r, f),
326
+ coefficients: [l, a],
327
+ equation: `${u} = ${l.toFixed(i)} * e^(${a.toFixed(i)}x)`,
328
+ rSquared: F(e, r, f),
329
329
  predict: f
330
330
  };
331
331
  }
332
332
  function st(e, r, o) {
333
- const t = e.length, n = [], s = [];
333
+ const t = e.length, n = [], c = [];
334
334
  for (let h = 0; h < t; h++)
335
- e[h] > 0 && (n.push(Math.log(e[h])), s.push(r[h]));
336
- const c = I(n, s, o), i = c.coefficients[0], l = c.coefficients[1], f = (h) => l + i * Math.log(h), a = o.precision ?? 4, u = o.label || "y";
335
+ e[h] > 0 && (n.push(Math.log(e[h])), c.push(r[h]));
336
+ const s = x(n, c, o), a = s.coefficients[0], l = s.coefficients[1], f = (h) => l + a * Math.log(h), i = o.precision ?? 4, u = o.label || "y";
337
337
  return {
338
338
  type: "logarithmic",
339
- coefficients: [l, i],
340
- equation: `${u} = ${l.toFixed(a)} ${i >= 0 ? "+" : "-"} ${Math.abs(i).toFixed(a)} * ln(x)`,
341
- rSquared: A(e, r, f),
339
+ coefficients: [l, a],
340
+ equation: `${u} = ${l.toFixed(i)} ${a >= 0 ? "+" : "-"} ${Math.abs(a).toFixed(i)} * ln(x)`,
341
+ rSquared: F(e, r, f),
342
342
  predict: f
343
343
  };
344
344
  }
345
345
  function ct(e, r, o) {
346
- const t = e.length, n = [], s = [];
346
+ const t = e.length, n = [], c = [];
347
347
  for (let h = 0; h < t; h++)
348
- e[h] > 0 && r[h] > 0 && (n.push(Math.log(e[h])), s.push(Math.log(r[h])));
349
- const c = I(n, s, o), i = c.coefficients[0], l = Math.exp(c.coefficients[1]), f = (h) => l * Math.pow(h, i), a = o.precision ?? 4, u = o.label || "y";
348
+ e[h] > 0 && r[h] > 0 && (n.push(Math.log(e[h])), c.push(Math.log(r[h])));
349
+ const s = x(n, c, o), a = s.coefficients[0], l = Math.exp(s.coefficients[1]), f = (h) => l * Math.pow(h, a), i = o.precision ?? 4, u = o.label || "y";
350
350
  return {
351
351
  type: "power",
352
- coefficients: [l, i],
353
- equation: `${u} = ${l.toFixed(a)} * x^(${i.toFixed(a)})`,
354
- rSquared: A(e, r, f),
352
+ coefficients: [l, a],
353
+ equation: `${u} = ${l.toFixed(i)} * x^(${a.toFixed(i)})`,
354
+ rSquared: F(e, r, f),
355
355
  predict: f
356
356
  };
357
357
  }
358
- function Et(e, r, o, t = 5) {
359
- const n = r / (o / 2), s = S(Math.min(n, 0.99), t);
360
- return q(e, s);
358
+ function Xt(e, r, o, t = 5) {
359
+ const n = r / (o / 2), c = S(Math.min(n, 0.99), t);
360
+ return I(e, c);
361
361
  }
362
- function Tt(e, r, o, t = 5) {
363
- const n = r / (o / 2), s = it(Math.min(n, 0.99), t);
364
- return q(e, s);
362
+ function Yt(e, r, o, t = 5) {
363
+ const n = r / (o / 2), c = at(Math.min(n, 0.99), t);
364
+ return I(e, c);
365
365
  }
366
- function Ht(e, r, o, t, n = 5) {
367
- const s = r / (t / 2), c = o / (t / 2), i = B(
368
- Math.max(s, 0.01),
369
- Math.min(c, 0.99),
366
+ function Nt(e, r, o, t, n = 5) {
367
+ const c = r / (t / 2), s = o / (t / 2), a = B(
368
+ Math.max(c, 0.01),
369
+ Math.min(s, 0.99),
370
370
  n
371
371
  );
372
- return q(e, i);
372
+ return I(e, a);
373
373
  }
374
- function Xt(e, r, o, t, n = 5) {
375
- const s = r / (t / 2), c = o / (t / 2), i = at(
376
- Math.max(s, 0.01),
377
- Math.min(c, 0.99),
374
+ function Ot(e, r, o, t, n = 5) {
375
+ const c = r / (t / 2), s = o / (t / 2), a = it(
376
+ Math.max(c, 0.01),
377
+ Math.min(s, 0.99),
378
378
  n
379
379
  );
380
- return q(e, i);
380
+ return I(e, a);
381
381
  }
382
382
  function S(e, r) {
383
383
  const o = 2 * r + 1, t = new Float32Array(o), n = e;
384
- for (let c = 0; c < o; c++) {
385
- const i = c - r;
386
- i === 0 ? t[c] = 2 * n : t[c] = Math.sin(2 * Math.PI * n * i) / (Math.PI * i), t[c] *= 0.54 - 0.46 * Math.cos(2 * Math.PI * c / (o - 1));
384
+ for (let s = 0; s < o; s++) {
385
+ const a = s - r;
386
+ a === 0 ? t[s] = 2 * n : t[s] = Math.sin(2 * Math.PI * n * a) / (Math.PI * a), t[s] *= 0.54 - 0.46 * Math.cos(2 * Math.PI * s / (o - 1));
387
387
  }
388
- let s = 0;
389
- for (let c = 0; c < o; c++) s += t[c];
390
- for (let c = 0; c < o; c++) t[c] /= s;
388
+ let c = 0;
389
+ for (let s = 0; s < o; s++) c += t[s];
390
+ for (let s = 0; s < o; s++) t[s] /= c;
391
391
  return t;
392
392
  }
393
- function it(e, r) {
393
+ function at(e, r) {
394
394
  const o = S(e, r), t = o.length, n = new Float32Array(t);
395
- for (let s = 0; s < t; s++)
396
- n[s] = -o[s];
395
+ for (let c = 0; c < t; c++)
396
+ n[c] = -o[c];
397
397
  return n[r] += 1, n;
398
398
  }
399
399
  function B(e, r, o) {
400
- const t = 2 * o + 1, n = new Float32Array(t), s = e, c = r;
401
- for (let i = 0; i < t; i++) {
402
- const l = i - o;
403
- l === 0 ? n[i] = 2 * (c - s) : n[i] = (Math.sin(2 * Math.PI * c * l) - Math.sin(2 * Math.PI * s * l)) / (Math.PI * l), n[i] *= 0.54 - 0.46 * Math.cos(2 * Math.PI * i / (t - 1));
400
+ const t = 2 * o + 1, n = new Float32Array(t), c = e, s = r;
401
+ for (let a = 0; a < t; a++) {
402
+ const l = a - o;
403
+ l === 0 ? n[a] = 2 * (s - c) : n[a] = (Math.sin(2 * Math.PI * s * l) - Math.sin(2 * Math.PI * c * l)) / (Math.PI * l), n[a] *= 0.54 - 0.46 * Math.cos(2 * Math.PI * a / (t - 1));
404
404
  }
405
405
  return n;
406
406
  }
407
- function at(e, r, o) {
408
- const t = B(e, r, o), n = t.length, s = new Float32Array(n);
409
- for (let c = 0; c < n; c++)
410
- s[c] = -t[c];
411
- return s[o] += 1, s;
407
+ function it(e, r, o) {
408
+ const t = B(e, r, o), n = t.length, c = new Float32Array(n);
409
+ for (let s = 0; s < n; s++)
410
+ c[s] = -t[s];
411
+ return c[o] += 1, c;
412
412
  }
413
- function q(e, r) {
414
- const o = e.length, t = r.length, n = Math.floor(t / 2), s = new Float32Array(o);
415
- for (let c = 0; c < o; c++) {
416
- let i = 0;
413
+ function I(e, r) {
414
+ const o = e.length, t = r.length, n = Math.floor(t / 2), c = new Float32Array(o);
415
+ for (let s = 0; s < o; s++) {
416
+ let a = 0;
417
417
  for (let l = 0; l < t; l++) {
418
- const f = c - n + l;
419
- f >= 0 && f < o && (i += e[f] * r[l]);
418
+ const f = s - n + l;
419
+ f >= 0 && f < o && (a += e[f] * r[l]);
420
420
  }
421
- s[c] = i;
421
+ c[s] = a;
422
422
  }
423
- return s;
423
+ return c;
424
424
  }
425
- function Yt(e, r) {
426
- const { type: o, cutoff: t, cutoffHigh: n, sampleRate: s = 1, order: c = 2 } = r, i = 2 * t / s, l = n ? 2 * n / s : void 0, { b: f, a } = ut(o, i, l);
427
- return D(e, f, a);
425
+ function Zt(e, r) {
426
+ const { type: o, cutoff: t, cutoffHigh: n, sampleRate: c = 1, order: s = 2 } = r, a = 2 * t / c, l = n ? 2 * n / c : void 0, { b: f, a: i } = ut(o, a, l);
427
+ return D(e, f, i);
428
428
  }
429
429
  function lt(e, r) {
430
- const { frequency: o, sampleRate: t, bandwidth: n = 1 } = r, { b: s, a: c } = ft(o, t, n);
431
- return D(e, s, c);
430
+ const { frequency: o, sampleRate: t, bandwidth: n = 1 } = r, { b: c, a: s } = ft(o, t, n);
431
+ return D(e, c, s);
432
432
  }
433
433
  function ft(e, r, o) {
434
- const t = 2 * Math.PI * e / r, s = 1 - 2 * Math.PI * o / r / 2, c = Math.cos(t), i = [1, -2 * c, 1], l = [1, -2 * s * c, s * s];
435
- return { b: i, a: l };
434
+ const t = 2 * Math.PI * e / r, c = 1 - 2 * Math.PI * o / r / 2, s = Math.cos(t), a = [1, -2 * s, 1], l = [1, -2 * c * s, c * c];
435
+ return { b: a, a: l };
436
436
  }
437
437
  function ut(e, r, o, t) {
438
438
  const n = Math.tan(Math.PI * r / 2);
@@ -441,158 +441,244 @@ function ut(e, r, o, t) {
441
441
  if (e === "highpass")
442
442
  return ht(n);
443
443
  if (e === "bandpass" && o) {
444
- const s = Math.tan(Math.PI * o / 2);
445
- return mt(n, s);
444
+ const c = Math.tan(Math.PI * o / 2);
445
+ return mt(n, c);
446
446
  } else if (e === "bandstop" && o) {
447
- const s = Math.tan(Math.PI * o / 2);
448
- return gt(n, s);
447
+ const c = Math.tan(Math.PI * o / 2);
448
+ return gt(n, c);
449
449
  }
450
450
  return v(n);
451
451
  }
452
452
  function v(e, r) {
453
- const o = e, t = o * o, n = Math.sqrt(2), s = 1 / (1 + n * o + t);
453
+ const o = e, t = o * o, n = Math.sqrt(2), c = 1 / (1 + n * o + t);
454
454
  return {
455
- b: [t * s, 2 * t * s, t * s],
456
- a: [1, 2 * (t - 1) * s, (1 - n * o + t) * s]
455
+ b: [t * c, 2 * t * c, t * c],
456
+ a: [1, 2 * (t - 1) * c, (1 - n * o + t) * c]
457
457
  };
458
458
  }
459
459
  function ht(e, r) {
460
- const o = e, t = o * o, n = Math.sqrt(2), s = 1 / (1 + n * o + t);
460
+ const o = e, t = o * o, n = Math.sqrt(2), c = 1 / (1 + n * o + t);
461
461
  return {
462
- b: [s, -2 * s, s],
463
- a: [1, 2 * (t - 1) * s, (1 - n * o + t) * s]
462
+ b: [c, -2 * c, c],
463
+ a: [1, 2 * (t - 1) * c, (1 - n * o + t) * c]
464
464
  };
465
465
  }
466
466
  function mt(e, r, o) {
467
- const t = Math.sqrt(e * r), n = r - e, s = t / n, c = 1 / (1 + t / s + t * t);
467
+ const t = Math.sqrt(e * r), n = r - e, c = t / n, s = 1 / (1 + t / c + t * t);
468
468
  return {
469
- b: [t / s * c, 0, -t / s * c],
470
- a: [1, 2 * (t * t - 1) * c, (1 - t / s + t * t) * c]
469
+ b: [t / c * s, 0, -t / c * s],
470
+ a: [1, 2 * (t * t - 1) * s, (1 - t / c + t * t) * s]
471
471
  };
472
472
  }
473
473
  function gt(e, r, o) {
474
- const t = Math.sqrt(e * r), n = r - e, s = t / n, c = 1 / (1 + t / s + t * t);
474
+ const t = Math.sqrt(e * r), n = r - e, c = t / n, s = 1 / (1 + t / c + t * t);
475
475
  return {
476
- b: [(1 + t * t) * c, 2 * (t * t - 1) * c, (1 + t * t) * c],
477
- a: [1, 2 * (t * t - 1) * c, (1 - t / s + t * t) * c]
476
+ b: [(1 + t * t) * s, 2 * (t * t - 1) * s, (1 + t * t) * s],
477
+ a: [1, 2 * (t * t - 1) * s, (1 - t / c + t * t) * s]
478
478
  };
479
479
  }
480
- function $(e, r, o) {
480
+ function k(e, r, o) {
481
481
  const t = e.length, n = new Float32Array(t);
482
- for (let s = 0; s < t; s++) {
483
- n[s] = r[0] * e[s];
484
- for (let c = 1; c < r.length; c++)
485
- s - c >= 0 && (n[s] += r[c] * e[s - c], n[s] -= o[c] * n[s - c]);
482
+ for (let c = 0; c < t; c++) {
483
+ n[c] = r[0] * e[c];
484
+ for (let s = 1; s < r.length; s++)
485
+ c - s >= 0 && (n[c] += r[s] * e[c - s], n[c] -= o[s] * n[c - s]);
486
486
  }
487
487
  return n;
488
488
  }
489
489
  function D(e, r, o) {
490
- const t = $(e, r, o), n = new Float32Array(t.length);
491
- for (let i = 0; i < t.length; i++)
492
- n[i] = t[t.length - 1 - i];
493
- const s = $(n, r, o), c = new Float32Array(s.length);
494
- for (let i = 0; i < s.length; i++)
495
- c[i] = s[s.length - 1 - i];
496
- return c;
490
+ const t = k(e, r, o), n = new Float32Array(t.length);
491
+ for (let a = 0; a < t.length; a++)
492
+ n[a] = t[t.length - 1 - a];
493
+ const c = k(n, r, o), s = new Float32Array(c.length);
494
+ for (let a = 0; a < c.length; a++)
495
+ s[a] = c[c.length - 1 - a];
496
+ return s;
497
497
  }
498
- function Nt(e, r = 0.3) {
498
+ function Gt(e, r = 0.3) {
499
499
  const o = e.length, t = new Float32Array(o);
500
500
  t[0] = e[0];
501
501
  for (let n = 1; n < o; n++)
502
502
  t[n] = r * e[n] + (1 - r) * t[n - 1];
503
503
  return t;
504
504
  }
505
- function Ot(e, r = 2) {
506
- const o = e.length, t = new Float32Array(o), n = Math.ceil(r * 3) * 2 + 1, s = Math.floor(n / 2), c = new Float32Array(n);
507
- let i = 0;
505
+ function Kt(e, r = 2) {
506
+ const o = e.length, t = new Float32Array(o), n = Math.ceil(r * 3) * 2 + 1, c = Math.floor(n / 2), s = new Float32Array(n);
507
+ let a = 0;
508
508
  for (let l = 0; l < n; l++) {
509
- const f = l - s;
510
- c[l] = Math.exp(-(f * f) / (2 * r * r)), i += c[l];
509
+ const f = l - c;
510
+ s[l] = Math.exp(-(f * f) / (2 * r * r)), a += s[l];
511
511
  }
512
512
  for (let l = 0; l < n; l++)
513
- c[l] /= i;
513
+ s[l] /= a;
514
514
  for (let l = 0; l < o; l++) {
515
515
  let f = 0;
516
- for (let a = 0; a < n; a++) {
517
- const u = l - s + a;
518
- u >= 0 && u < o && (f += e[u] * c[a]);
516
+ for (let i = 0; i < n; i++) {
517
+ const u = l - c + i;
518
+ u >= 0 && u < o && (f += e[u] * s[i]);
519
519
  }
520
520
  t[l] = f;
521
521
  }
522
522
  return t;
523
523
  }
524
- function Zt(e, r = 5, o = 2) {
525
- const t = e.length, n = new Float32Array(t), s = Math.floor(r / 2), c = dt(r);
526
- for (let i = 0; i < t; i++) {
524
+ function Qt(e, r = 5, o = 2) {
525
+ const t = e.length, n = new Float32Array(t), c = Math.floor(r / 2), s = dt(r);
526
+ for (let a = 0; a < t; a++) {
527
527
  let l = 0;
528
- for (let f = -s; f <= s; f++) {
529
- const a = i + f;
530
- a >= 0 && a < t ? l += e[a] * c[f + s] : a < 0 ? l += e[0] * c[f + s] : l += e[t - 1] * c[f + s];
528
+ for (let f = -c; f <= c; f++) {
529
+ const i = a + f;
530
+ i >= 0 && i < t ? l += e[i] * s[f + c] : i < 0 ? l += e[0] * s[f + c] : l += e[t - 1] * s[f + c];
531
531
  }
532
- n[i] = l;
532
+ n[a] = l;
533
533
  }
534
534
  return n;
535
535
  }
536
536
  function dt(e, r) {
537
537
  const o = Math.floor(e / 2), t = new Float32Array(e), n = 1 / e;
538
- for (let c = 0; c < e; c++) {
539
- const i = c - o;
540
- t[c] = n * (1 - i * i / ((o + 1) * (o + 1)));
538
+ for (let s = 0; s < e; s++) {
539
+ const a = s - o;
540
+ t[s] = n * (1 - a * a / ((o + 1) * (o + 1)));
541
541
  }
542
- let s = 0;
543
- for (let c = 0; c < e; c++) s += t[c];
544
- for (let c = 0; c < e; c++) t[c] /= s;
542
+ let c = 0;
543
+ for (let s = 0; s < e; s++) c += t[s];
544
+ for (let s = 0; s < e; s++) t[s] /= c;
545
545
  return t;
546
546
  }
547
- function Gt(e, r = 5) {
547
+ function Ut(e, r = 5) {
548
548
  const o = e.length, t = new Float32Array(o), n = Math.floor(r / 2);
549
- for (let s = 0; s < o; s++) {
550
- const c = [];
551
- for (let i = -n; i <= n; i++) {
552
- const l = s + i;
553
- l >= 0 && l < o && c.push(e[l]);
549
+ for (let c = 0; c < o; c++) {
550
+ const s = [];
551
+ for (let a = -n; a <= n; a++) {
552
+ const l = c + a;
553
+ l >= 0 && l < o && s.push(e[l]);
554
554
  }
555
- c.sort((i, l) => i - l), t[s] = c[Math.floor(c.length / 2)];
555
+ s.sort((a, l) => a - l), t[c] = s[Math.floor(s.length / 2)];
556
556
  }
557
557
  return t;
558
558
  }
559
- function Kt(e, r, o, t = {}) {
560
- const n = r.length, s = o.length, c = Math.min(...e), i = Math.max(...e), l = t.levels || Mt(c, i, t.numLevels || 10), f = [];
561
- for (const a of l) {
559
+ function Jt(e, r, o, t = {}) {
560
+ const n = r.length, c = o.length, s = Math.min(...e), a = Math.max(...e), l = t.levels || yt(s, a, t.numLevels || 10), f = [];
561
+ for (const i of l) {
562
562
  const u = [];
563
- for (let h = 0; h < s - 1; h++)
563
+ for (let h = 0; h < c - 1; h++)
564
564
  for (let m = 0; m < n - 1; m++) {
565
565
  const g = e[h * n + m], M = e[h * n + (m + 1)], d = e[(h + 1) * n + (m + 1)], w = e[(h + 1) * n + m];
566
- wt(m, h, g, M, d, w, a, r, o, u);
566
+ bt(m, h, g, M, d, w, i, r, o, u);
567
567
  }
568
568
  if (u.length > 0) {
569
569
  const h = [];
570
- for (const m of u)
571
- h.push({ x: m[0], y: m[1] }), h.push({ x: m[2], y: m[3] });
572
- f.push({ level: a, points: h });
570
+ for (const g of u)
571
+ h.push({ x: g[0], y: g[1] }), h.push({ x: g[2], y: g[3] });
572
+ const m = { level: i, points: h };
573
+ if (t.joinPaths || t.labels) {
574
+ const g = Mt(u);
575
+ m.polylines = g, t.labels && (m.labels = pt(
576
+ g,
577
+ i,
578
+ t.minLabelLength ?? 6,
579
+ t.labelFormatter ?? wt
580
+ ));
581
+ }
582
+ f.push(m);
573
583
  }
574
584
  }
575
585
  return f;
576
586
  }
577
- function Mt(e, r, o) {
587
+ function Mt(e, r = 1e-6) {
588
+ const o = e.map((a) => ({
589
+ a: { x: a[0], y: a[1] },
590
+ b: { x: a[2], y: a[3] },
591
+ used: !1
592
+ })), t = (a) => `${Math.round(a.x / r)}:${Math.round(a.y / r)}`, n = (a, l) => Math.abs(a.x - l.x) <= r && Math.abs(a.y - l.y) <= r, c = /* @__PURE__ */ new Map();
593
+ o.forEach((a, l) => {
594
+ for (const f of [a.a, a.b]) {
595
+ const i = t(f);
596
+ c.has(i) || c.set(i, []), c.get(i).push(l);
597
+ }
598
+ });
599
+ const s = [];
600
+ for (let a = 0; a < o.length; a++) {
601
+ if (o[a].used) continue;
602
+ o[a].used = !0;
603
+ const l = [o[a].a, o[a].b];
604
+ let f = !0;
605
+ for (; f; ) {
606
+ f = !1;
607
+ const i = l[l.length - 1], u = c.get(t(i)) ?? [];
608
+ for (const h of u) {
609
+ if (o[h].used) continue;
610
+ const m = o[h];
611
+ if (n(m.a, i)) {
612
+ l.push(m.b), m.used = !0, f = !0;
613
+ break;
614
+ } else if (n(m.b, i)) {
615
+ l.push(m.a), m.used = !0, f = !0;
616
+ break;
617
+ }
618
+ }
619
+ }
620
+ for (f = !0; f; ) {
621
+ f = !1;
622
+ const i = l[0], u = c.get(t(i)) ?? [];
623
+ for (const h of u) {
624
+ if (o[h].used) continue;
625
+ const m = o[h];
626
+ if (n(m.b, i)) {
627
+ l.unshift(m.a), m.used = !0, f = !0;
628
+ break;
629
+ } else if (n(m.a, i)) {
630
+ l.unshift(m.b), m.used = !0, f = !0;
631
+ break;
632
+ }
633
+ }
634
+ }
635
+ s.push(l);
636
+ }
637
+ return s;
638
+ }
639
+ function wt(e) {
640
+ const r = Math.abs(e);
641
+ return r !== 0 && (r < 0.01 || r >= 1e5) ? e.toExponential(1) : e.toFixed(2).replace(/\.00$/, "");
642
+ }
643
+ function pt(e, r, o, t) {
644
+ const n = [], c = t(r);
645
+ for (const s of e) {
646
+ if (s.length < o) continue;
647
+ let a = 0;
648
+ for (let d = 1; d < s.length; d++)
649
+ a += Math.hypot(s[d].x - s[d - 1].x, s[d].y - s[d - 1].y);
650
+ const l = a / 2;
651
+ let f = 0, i = Math.floor(s.length / 2);
652
+ for (let d = 1; d < s.length; d++)
653
+ if (f += Math.hypot(s[d].x - s[d - 1].x, s[d].y - s[d - 1].y), f >= l) {
654
+ i = d;
655
+ break;
656
+ }
657
+ const u = s[i], h = Math.min(3, Math.floor(s.length / 4)) || 1, m = s[Math.max(0, i - h)], g = s[Math.min(s.length - 1, i + h)];
658
+ let M = Math.atan2(g.y - m.y, g.x - m.x);
659
+ M > Math.PI / 2 && (M -= Math.PI), M < -Math.PI / 2 && (M += Math.PI), n.push({ x: u.x, y: u.y, level: r, text: c, angle: M });
660
+ }
661
+ return n;
662
+ }
663
+ function yt(e, r, o) {
578
664
  const t = [], n = (r - e) / (o + 1);
579
- for (let s = 1; s <= o; s++)
580
- t.push(e + s * n);
665
+ for (let c = 1; c <= o; c++)
666
+ t.push(e + c * n);
581
667
  return t;
582
668
  }
583
- function wt(e, r, o, t, n, s, c, i, l, f) {
584
- let a = 0;
585
- if (o >= c && (a |= 1), t >= c && (a |= 2), n >= c && (a |= 4), s >= c && (a |= 8), a === 0 || a === 15) return;
586
- const u = (M, d, w) => M + (d - M) * w, h = (M, d) => (c - M) / (d - M), m = (M) => {
669
+ function bt(e, r, o, t, n, c, s, a, l, f) {
670
+ let i = 0;
671
+ if (o >= s && (i |= 1), t >= s && (i |= 2), n >= s && (i |= 4), c >= s && (i |= 8), i === 0 || i === 15) return;
672
+ const u = (M, d, w) => M + (d - M) * w, h = (M, d) => (s - M) / (d - M), m = (M) => {
587
673
  switch (M) {
588
674
  case 0:
589
- return [u(i[e], i[e + 1], h(o, t)), l[r]];
675
+ return [u(a[e], a[e + 1], h(o, t)), l[r]];
590
676
  case 1:
591
- return [i[e + 1], u(l[r], l[r + 1], h(t, n))];
677
+ return [a[e + 1], u(l[r], l[r + 1], h(t, n))];
592
678
  case 2:
593
- return [u(i[e], i[e + 1], h(s, n)), l[r + 1]];
679
+ return [u(a[e], a[e + 1], h(c, n)), l[r + 1]];
594
680
  case 3:
595
- return [i[e], u(l[r], l[r + 1], h(o, s))];
681
+ return [a[e], u(l[r], l[r + 1], h(o, c))];
596
682
  default:
597
683
  return [0, 0];
598
684
  }
@@ -600,7 +686,7 @@ function wt(e, r, o, t, n, s, c, i, l, f) {
600
686
  const w = m(M), p = m(d);
601
687
  f.push([w[0], w[1], p[0], p[1]]);
602
688
  };
603
- switch (a) {
689
+ switch (i) {
604
690
  case 1:
605
691
  case 14:
606
692
  g(0, 3);
@@ -633,114 +719,114 @@ function wt(e, r, o, t, n, s, c, i, l, f) {
633
719
  break;
634
720
  }
635
721
  }
636
- function pt(e, r, o) {
637
- const t = e.length, n = r.length, s = o ?? Math.min(t, n) - 1, c = 2 * s + 1, i = new Float32Array(c), l = new Float32Array(c);
638
- let f = 0, a = 0;
722
+ function Ft(e, r, o) {
723
+ const t = e.length, n = r.length, c = o ?? Math.min(t, n) - 1, s = 2 * c + 1, a = new Float32Array(s), l = new Float32Array(s);
724
+ let f = 0, i = 0;
639
725
  for (let d = 0; d < t; d++) f += e[d];
640
- for (let d = 0; d < n; d++) a += r[d];
641
- f /= t, a /= n;
726
+ for (let d = 0; d < n; d++) i += r[d];
727
+ f /= t, i /= n;
642
728
  let u = 0, h = 0;
643
729
  for (let d = 0; d < t; d++) u += (e[d] - f) ** 2;
644
- for (let d = 0; d < n; d++) h += (r[d] - a) ** 2;
730
+ for (let d = 0; d < n; d++) h += (r[d] - i) ** 2;
645
731
  u = Math.sqrt(u / t), h = Math.sqrt(h / n);
646
732
  const m = u * h * Math.min(t, n);
647
733
  let g = -1 / 0, M = 0;
648
- for (let d = 0; d < c; d++) {
649
- const w = d - s;
734
+ for (let d = 0; d < s; d++) {
735
+ const w = d - c;
650
736
  l[d] = w;
651
737
  let p = 0;
652
738
  for (let y = 0; y < t; y++) {
653
- const F = y + w;
654
- F >= 0 && F < n && (p += (e[y] - f) * (r[F] - a));
739
+ const b = y + w;
740
+ b >= 0 && b < n && (p += (e[y] - f) * (r[b] - i));
655
741
  }
656
- i[d] = m > 0 ? p / m : 0, i[d] > g && (g = i[d], M = d);
742
+ a[d] = m > 0 ? p / m : 0, a[d] > g && (g = a[d], M = d);
657
743
  }
658
744
  return {
659
- correlation: i,
745
+ correlation: a,
660
746
  lags: l,
661
747
  maxCorrelation: g,
662
748
  lagAtMax: l[M]
663
749
  };
664
750
  }
665
- function Qt(e, r) {
666
- return pt(e, e, r);
751
+ function Vt(e, r) {
752
+ return Ft(e, e, r);
667
753
  }
668
- function Ut(e, r = {}) {
754
+ function tn(e, r = {}) {
669
755
  const { method: o = "zscore", windowSize: t } = r;
670
756
  switch (o) {
671
757
  case "zscore":
672
- return k(e, r.threshold ?? 3, t);
758
+ return $(e, r.threshold ?? 3, t);
673
759
  case "mad":
674
- return yt(e, r.threshold ?? 2.5);
760
+ return At(e, r.threshold ?? 2.5);
675
761
  case "iqr":
676
- return Ft(e, r.threshold ?? 1.5);
762
+ return xt(e, r.threshold ?? 1.5);
677
763
  case "isolation":
678
- return At(e, r.threshold ?? 0.5);
764
+ return It(e, r.threshold ?? 0.5);
679
765
  default:
680
- return k(e, 3, t);
766
+ return $(e, 3, t);
681
767
  }
682
768
  }
683
- function k(e, r, o) {
684
- const t = e.length, n = new Float32Array(t), s = [];
769
+ function $(e, r, o) {
770
+ const t = e.length, n = new Float32Array(t), c = [];
685
771
  if (o && o < t) {
686
- const c = Math.floor(o / 2);
687
- for (let i = 0; i < t; i++) {
688
- const l = Math.max(0, i - c), f = Math.min(t, i + c + 1);
689
- let a = 0;
690
- for (let h = l; h < f; h++) a += e[h];
691
- a /= f - l;
772
+ const s = Math.floor(o / 2);
773
+ for (let a = 0; a < t; a++) {
774
+ const l = Math.max(0, a - s), f = Math.min(t, a + s + 1);
775
+ let i = 0;
776
+ for (let h = l; h < f; h++) i += e[h];
777
+ i /= f - l;
692
778
  let u = 0;
693
- for (let h = l; h < f; h++) u += (e[h] - a) ** 2;
694
- u = Math.sqrt(u / (f - l)), n[i] = u > 0 ? Math.abs(e[i] - a) / u : 0, n[i] > r && s.push(i);
779
+ for (let h = l; h < f; h++) u += (e[h] - i) ** 2;
780
+ u = Math.sqrt(u / (f - l)), n[a] = u > 0 ? Math.abs(e[a] - i) / u : 0, n[a] > r && c.push(a);
695
781
  }
696
782
  } else {
697
- let c = 0;
698
- for (let l = 0; l < t; l++) c += e[l];
699
- c /= t;
700
- let i = 0;
701
- for (let l = 0; l < t; l++) i += (e[l] - c) ** 2;
702
- i = Math.sqrt(i / t);
783
+ let s = 0;
784
+ for (let l = 0; l < t; l++) s += e[l];
785
+ s /= t;
786
+ let a = 0;
787
+ for (let l = 0; l < t; l++) a += (e[l] - s) ** 2;
788
+ a = Math.sqrt(a / t);
703
789
  for (let l = 0; l < t; l++)
704
- n[l] = i > 0 ? Math.abs(e[l] - c) / i : 0, n[l] > r && s.push(l);
790
+ n[l] = a > 0 ? Math.abs(e[l] - s) / a : 0, n[l] > r && c.push(l);
705
791
  }
706
- return { indices: s, scores: n, threshold: r };
792
+ return { indices: c, scores: n, threshold: r };
707
793
  }
708
- function yt(e, r, o) {
709
- const t = e.length, n = new Float32Array(t), s = [], c = Array.from(e).sort((u, h) => u - h), i = c[Math.floor(t / 2)], a = 1.4826 * c.map((u) => Math.abs(u - i)).sort((u, h) => u - h)[Math.floor(t / 2)];
794
+ function At(e, r, o) {
795
+ const t = e.length, n = new Float32Array(t), c = [], s = Array.from(e).sort((u, h) => u - h), a = s[Math.floor(t / 2)], i = 1.4826 * s.map((u) => Math.abs(u - a)).sort((u, h) => u - h)[Math.floor(t / 2)];
710
796
  for (let u = 0; u < t; u++)
711
- n[u] = a > 0 ? Math.abs(e[u] - i) / a : 0, n[u] > r && s.push(u);
712
- return { indices: s, scores: n, threshold: r };
797
+ n[u] = i > 0 ? Math.abs(e[u] - a) / i : 0, n[u] > r && c.push(u);
798
+ return { indices: c, scores: n, threshold: r };
713
799
  }
714
- function Ft(e, r) {
715
- const o = e.length, t = new Float32Array(o), n = [], s = Array.from(e).sort((u, h) => u - h), c = s[Math.floor(o * 0.25)], i = s[Math.floor(o * 0.75)], l = i - c, f = c - r * l, a = i + r * l;
800
+ function xt(e, r) {
801
+ const o = e.length, t = new Float32Array(o), n = [], c = Array.from(e).sort((u, h) => u - h), s = c[Math.floor(o * 0.25)], a = c[Math.floor(o * 0.75)], l = a - s, f = s - r * l, i = a + r * l;
716
802
  for (let u = 0; u < o; u++)
717
- e[u] < f ? (t[u] = (f - e[u]) / l, n.push(u)) : e[u] > a ? (t[u] = (e[u] - a) / l, n.push(u)) : t[u] = 0;
803
+ e[u] < f ? (t[u] = (f - e[u]) / l, n.push(u)) : e[u] > i ? (t[u] = (e[u] - i) / l, n.push(u)) : t[u] = 0;
718
804
  return { indices: n, scores: t, threshold: r };
719
805
  }
720
- function At(e, r, o) {
721
- const t = e.length, n = new Float32Array(t), s = [], c = bt(e);
722
- for (let i = 0; i < t; i++) {
806
+ function It(e, r, o) {
807
+ const t = e.length, n = new Float32Array(t), c = [], s = qt(e);
808
+ for (let a = 0; a < t; a++) {
723
809
  let l = 0;
724
810
  for (let f = 0; f < t; f++)
725
- i !== f && Math.abs(e[i] - e[f]) < c && l++;
726
- n[i] = 1 - l / t, n[i] > r && s.push(i);
811
+ a !== f && Math.abs(e[a] - e[f]) < s && l++;
812
+ n[a] = 1 - l / t, n[a] > r && c.push(a);
727
813
  }
728
- return { indices: s, scores: n, threshold: r };
814
+ return { indices: c, scores: n, threshold: r };
729
815
  }
730
- function bt(e) {
816
+ function qt(e) {
731
817
  let r = 1 / 0, o = -1 / 0;
732
818
  for (let t = 0; t < e.length; t++)
733
819
  e[t] < r && (r = e[t]), e[t] > o && (o = e[t]);
734
820
  return (o - r) * 0.1;
735
821
  }
736
- function R(e, r) {
822
+ function j(e, r) {
737
823
  const o = e.length;
738
824
  if (o < 2) return 0;
739
825
  let t = 0;
740
826
  if (typeof r == "number") {
741
827
  const n = r;
742
- for (let s = 1; s < o; s++)
743
- t += (e[s - 1] + e[s]) * n / 2;
828
+ for (let c = 1; c < o; c++)
829
+ t += (e[c - 1] + e[c]) * n / 2;
744
830
  } else if (r)
745
831
  for (let n = 1; n < o; n++)
746
832
  t += (e[n - 1] + e[n]) * (r[n] - r[n - 1]) / 2;
@@ -749,28 +835,28 @@ function R(e, r) {
749
835
  t += (e[n - 1] + e[n]) / 2;
750
836
  return t;
751
837
  }
752
- function It(e, r) {
838
+ function Pt(e, r) {
753
839
  const o = e.length;
754
- if (o < 3) return R(e, r);
840
+ if (o < 3) return j(e, r);
755
841
  const t = o % 2 === 0 ? o - 1 : o;
756
842
  let n = 0;
757
843
  if (typeof r == "number") {
758
- const s = r;
844
+ const c = r;
759
845
  n = e[0] + e[t - 1];
760
- for (let c = 1; c < t - 1; c++)
761
- n += (c % 2 === 0 ? 2 : 4) * e[c];
762
- n *= s / 3, o !== t && (n += (e[o - 2] + e[o - 1]) * s / 2);
763
- } else return r ? R(e, r) : It(e, 1);
846
+ for (let s = 1; s < t - 1; s++)
847
+ n += (s % 2 === 0 ? 2 : 4) * e[s];
848
+ n *= c / 3, o !== t && (n += (e[o - 2] + e[o - 1]) * c / 2);
849
+ } else return r ? j(e, r) : Pt(e, 1);
764
850
  return n;
765
851
  }
766
- function Jt(e, r) {
852
+ function nn(e, r) {
767
853
  const o = e.length, t = new Float32Array(o);
768
854
  if (o < 2)
769
855
  return t[0] = 0, t;
770
856
  if (t[0] = 0, typeof r == "number") {
771
857
  const n = r;
772
- for (let s = 1; s < o; s++)
773
- t[s] = t[s - 1] + (e[s - 1] + e[s]) * n / 2;
858
+ for (let c = 1; c < o; c++)
859
+ t[c] = t[c - 1] + (e[c - 1] + e[c]) * n / 2;
774
860
  } else if (r)
775
861
  for (let n = 1; n < o; n++)
776
862
  t[n] = t[n - 1] + (e[n - 1] + e[n]) * (r[n] - r[n - 1]) / 2;
@@ -779,17 +865,17 @@ function Jt(e, r) {
779
865
  t[n] = t[n - 1] + (e[n - 1] + e[n]) / 2;
780
866
  return t;
781
867
  }
782
- function Vt(e, r) {
868
+ function en(e, r) {
783
869
  const o = e.length, t = r.length;
784
- let n = 0, s = 0;
870
+ let n = 0, c = 0;
785
871
  for (let g = 0; g < o; g++) n += e[g];
786
- for (let g = 0; g < t; g++) s += r[g];
787
- n /= o, s /= t;
788
- let c = 0, i = 0;
789
- for (let g = 0; g < o; g++) c += (e[g] - n) ** 2;
790
- for (let g = 0; g < t; g++) i += (r[g] - s) ** 2;
791
- c /= o - 1, i /= t - 1;
792
- const l = Math.sqrt(c / o + i / t), f = (n - s) / l, a = (c / o + i / t) ** 2, u = (c / o) ** 2 / (o - 1) + (i / t) ** 2 / (t - 1), h = a / u, m = 2 * (1 - qt(Math.abs(f)));
872
+ for (let g = 0; g < t; g++) c += r[g];
873
+ n /= o, c /= t;
874
+ let s = 0, a = 0;
875
+ for (let g = 0; g < o; g++) s += (e[g] - n) ** 2;
876
+ for (let g = 0; g < t; g++) a += (r[g] - c) ** 2;
877
+ s /= o - 1, a /= t - 1;
878
+ const l = Math.sqrt(s / o + a / t), f = (n - c) / l, i = (s / o + a / t) ** 2, u = (s / o) ** 2 / (o - 1) + (a / t) ** 2 / (t - 1), h = i / u, m = 2 * (1 - vt(Math.abs(f)));
793
879
  return {
794
880
  tStatistic: f,
795
881
  degreesOfFreedom: h,
@@ -797,23 +883,23 @@ function Vt(e, r) {
797
883
  significant: m < 0.05
798
884
  };
799
885
  }
800
- function qt(e) {
801
- const r = 0.254829592, o = -0.284496736, t = 1.421413741, n = -1.453152027, s = 1.061405429, c = 0.3275911, i = e < 0 ? -1 : 1;
886
+ function vt(e) {
887
+ const r = 0.254829592, o = -0.284496736, t = 1.421413741, n = -1.453152027, c = 1.061405429, s = 0.3275911, a = e < 0 ? -1 : 1;
802
888
  e = Math.abs(e) / Math.sqrt(2);
803
- const l = 1 / (1 + c * e), f = 1 - ((((s * l + n) * l + t) * l + o) * l + r) * l * Math.exp(-e * e);
804
- return 0.5 * (1 + i * f);
889
+ const l = 1 / (1 + s * e), f = 1 - ((((c * l + n) * l + t) * l + o) * l + r) * l * Math.exp(-e * e);
890
+ return 0.5 * (1 + a * f);
805
891
  }
806
- const xt = {
892
+ const kt = {
807
893
  name: "velo-plot-analysis",
808
894
  version: "1.0.0",
809
895
  description: "Data analysis and signal processing for velo-plot",
810
896
  provides: ["analysis"],
811
897
  tags: ["fft", "filters", "statistics", "math"]
812
898
  };
813
- function tn(e = {}) {
899
+ function on(e = {}) {
814
900
  let r;
815
901
  return {
816
- manifest: xt,
902
+ manifest: kt,
817
903
  onInit(o) {
818
904
  r = o;
819
905
  },
@@ -829,7 +915,7 @@ function tn(e = {}) {
829
915
  calculateStats: G,
830
916
  validateData: Z,
831
917
  // Signal Processing
832
- fft: (o) => x(o),
918
+ fft: (o) => q(o),
833
919
  detectPeaks: O,
834
920
  detectCycles: N,
835
921
  movingAverage: Y,
@@ -837,7 +923,7 @@ function tn(e = {}) {
837
923
  downsampleLTTB: H,
838
924
  singleFrequencyFilter: lt,
839
925
  // Fitting
840
- fitData: L,
926
+ fitData: C,
841
927
  // Indicators
842
928
  sma: U,
843
929
  ema: Q,
@@ -849,79 +935,80 @@ function tn(e = {}) {
849
935
  };
850
936
  }
851
937
  export {
852
- tn as PluginAnalysis,
853
- fn as adx,
854
- St as analyzeComplexSpectrum,
855
- j as analyzeSpectrum,
856
- un as aroon,
938
+ on as PluginAnalysis,
939
+ mn as adx,
940
+ Wt as analyzeComplexSpectrum,
941
+ L as analyzeSpectrum,
942
+ gn as aroon,
857
943
  et as arraysToComplex,
858
- hn as atr,
859
- Qt as autoCorrelation,
860
- Ht as bandPassFilter,
861
- Xt as bandStopFilter,
862
- Lt as blackmanWindow,
863
- mn as bollingerBands,
864
- Yt as butterworth,
865
- A as calculateR2,
944
+ dn as atr,
945
+ Vt as autoCorrelation,
946
+ Nt as bandPassFilter,
947
+ Ot as bandStopFilter,
948
+ Dt as blackmanWindow,
949
+ Mn as bollingerBands,
950
+ Zt as butterworth,
951
+ F as calculateR2,
866
952
  G as calculateStats,
867
- Dt as complexToArrays,
868
- pt as crossCorrelation,
869
- gn as cumsum,
870
- on as cumulativeIntegral,
871
- Jt as cumulativeIntegral2,
872
- tn as default,
873
- dn as dema,
953
+ zt as complexToArrays,
954
+ Ft as crossCorrelation,
955
+ wn as cumsum,
956
+ cn as cumulativeIntegral,
957
+ nn as cumulativeIntegral2,
958
+ on as default,
959
+ pn as dema,
874
960
  _ as derivative,
875
- Ut as detectAnomalies,
961
+ tn as detectAnomalies,
876
962
  N as detectCycles,
877
963
  O as detectPeaks,
878
- Rt as dominantFrequency,
964
+ Ct as dominantFrequency,
879
965
  H as downsampleLTTB,
880
966
  Q as ema,
881
- Nt as exponentialMovingAverage,
882
- x as fft,
883
- Bt as fftFromComplexInput,
884
- L as fitData,
885
- sn as formatScientific,
886
- cn as formatValue,
967
+ Gt as exponentialMovingAverage,
968
+ q as fft,
969
+ _t as fftFromComplexInput,
970
+ C as fitData,
971
+ ln as formatScientific,
972
+ fn as formatValue,
887
973
  T as formatWithPrefix,
888
- Ot as gaussianSmooth,
889
- Kt as generateContours,
974
+ Kt as gaussianSmooth,
975
+ Jt as generateContours,
890
976
  E as generateCycleColors,
891
- an as getBestPrefix,
892
- zt as getPositiveFrequencies,
893
- jt as hammingWindow,
894
- Ct as hanningWindow,
895
- Tt as highPassFilter,
977
+ un as getBestPrefix,
978
+ Ht as getPositiveFrequencies,
979
+ Bt as hammingWindow,
980
+ St as hanningWindow,
981
+ Yt as highPassFilter,
896
982
  V as ifft,
897
- _t as ifftComplex,
898
- Wt as ifftFromArrays,
983
+ Tt as ifftComplex,
984
+ Et as ifftFromArrays,
899
985
  z as integrate,
900
- Et as lowPassFilter,
901
- Mn as macd,
902
- Gt as medianFilter,
903
- wn as momentum,
986
+ Mt as joinSegments,
987
+ Xt as lowPassFilter,
988
+ yn as macd,
989
+ Ut as medianFilter,
990
+ bn as momentum,
904
991
  Y as movingAverage,
905
- C as nextPowerOf2,
906
- pn as normalize,
907
- yn as obv,
908
- Fn as percentChange,
909
- kt as powerSpectrum,
910
- An as roc,
992
+ R as nextPowerOf2,
993
+ Fn as normalize,
994
+ An as obv,
995
+ xn as percentChange,
996
+ Lt as powerSpectrum,
997
+ In as roc,
911
998
  K as rsi,
912
- Zt as savitzkyGolay,
913
- It as simpsonsIntegration,
999
+ Qt as savitzkyGolay,
1000
+ Pt as simpsonsIntegration,
914
1001
  lt as singleFrequencyFilter,
915
1002
  U as sma,
916
1003
  W as solveLinearSystem,
917
- bn as standardDeviation,
918
- In as stochastic,
1004
+ qn as standardDeviation,
1005
+ Pn as stochastic,
919
1006
  X as subtractBaseline,
920
- Vt as tTest,
921
- qn as tema,
922
- R as trapezoidalIntegration,
1007
+ en as tTest,
1008
+ vn as tema,
1009
+ j as trapezoidalIntegration,
923
1010
  Z as validateData,
924
- xn as vwap,
925
- Pn as wma
1011
+ kn as vwap,
1012
+ $n as wma
926
1013
  };
927
1014
  //# sourceMappingURL=analysis.js.map