@sipemu/anofox-forecast 0.4.4 → 0.4.5

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,5 +1,11 @@
1
1
  let wasm;
2
2
 
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
+ }
8
+
3
9
  function _assertClass(instance, klass) {
4
10
  if (!(instance instanceof klass)) {
5
11
  throw new Error(`expected instance of ${klass.name}`);
@@ -11,6 +17,19 @@ function getArrayF64FromWasm0(ptr, len) {
11
17
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
12
18
  }
13
19
 
20
+ function getArrayU8FromWasm0(ptr, len) {
21
+ ptr = ptr >>> 0;
22
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
23
+ }
24
+
25
+ let cachedDataViewMemory0 = null;
26
+ function getDataViewMemory0() {
27
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
28
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
29
+ }
30
+ return cachedDataViewMemory0;
31
+ }
32
+
14
33
  let cachedFloat64ArrayMemory0 = null;
15
34
  function getFloat64ArrayMemory0() {
16
35
  if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
@@ -40,6 +59,15 @@ function getUint8ArrayMemory0() {
40
59
  return cachedUint8ArrayMemory0;
41
60
  }
42
61
 
62
+ function handleError(f, args) {
63
+ try {
64
+ return f.apply(this, args);
65
+ } catch (e) {
66
+ const idx = addToExternrefTable0(e);
67
+ wasm.__wbindgen_exn_store(idx);
68
+ }
69
+ }
70
+
43
71
  function isLikeNone(x) {
44
72
  return x === undefined || x === null;
45
73
  }
@@ -58,6 +86,16 @@ function passArrayF64ToWasm0(arg, malloc) {
58
86
  return ptr;
59
87
  }
60
88
 
89
+ function passArrayJsValueToWasm0(array, malloc) {
90
+ const ptr = malloc(array.length * 4, 4) >>> 0;
91
+ for (let i = 0; i < array.length; i++) {
92
+ const add = addToExternrefTable0(array[i]);
93
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
94
+ }
95
+ WASM_VECTOR_LEN = array.length;
96
+ return ptr;
97
+ }
98
+
61
99
  function passStringToWasm0(arg, malloc, realloc) {
62
100
  if (realloc === undefined) {
63
101
  const buf = cachedTextEncoder.encode(arg);
@@ -146,6 +184,14 @@ const AutoETSForecasterFinalization = (typeof FinalizationRegistry === 'undefine
146
184
  ? { register: () => {}, unregister: () => {} }
147
185
  : new FinalizationRegistry(ptr => wasm.__wbg_autoetsforecaster_free(ptr >>> 0, 1));
148
186
 
187
+ const AutoEnsembleForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
188
+ ? { register: () => {}, unregister: () => {} }
189
+ : new FinalizationRegistry(ptr => wasm.__wbg_autoensembleforecaster_free(ptr >>> 0, 1));
190
+
191
+ const AutoForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
192
+ ? { register: () => {}, unregister: () => {} }
193
+ : new FinalizationRegistry(ptr => wasm.__wbg_autoforecaster_free(ptr >>> 0, 1));
194
+
149
195
  const AutoTBATSForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
150
196
  ? { register: () => {}, unregister: () => {} }
151
197
  : new FinalizationRegistry(ptr => wasm.__wbg_autotbatsforecaster_free(ptr >>> 0, 1));
@@ -154,6 +200,10 @@ const AutoThetaForecasterFinalization = (typeof FinalizationRegistry === 'undefi
154
200
  ? { register: () => {}, unregister: () => {} }
155
201
  : new FinalizationRegistry(ptr => wasm.__wbg_autothetaforecaster_free(ptr >>> 0, 1));
156
202
 
203
+ const CalendarAnnotationsFinalization = (typeof FinalizationRegistry === 'undefined')
204
+ ? { register: () => {}, unregister: () => {} }
205
+ : new FinalizationRegistry(ptr => wasm.__wbg_calendarannotations_free(ptr >>> 0, 1));
206
+
157
207
  const CrostonForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
158
208
  ? { register: () => {}, unregister: () => {} }
159
209
  : new FinalizationRegistry(ptr => wasm.__wbg_crostonforecaster_free(ptr >>> 0, 1));
@@ -166,6 +216,10 @@ const ETSForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
166
216
  ? { register: () => {}, unregister: () => {} }
167
217
  : new FinalizationRegistry(ptr => wasm.__wbg_etsforecaster_free(ptr >>> 0, 1));
168
218
 
219
+ const EnsembleForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
220
+ ? { register: () => {}, unregister: () => {} }
221
+ : new FinalizationRegistry(ptr => wasm.__wbg_ensembleforecaster_free(ptr >>> 0, 1));
222
+
169
223
  const ForecastFinalization = (typeof FinalizationRegistry === 'undefined')
170
224
  ? { register: () => {}, unregister: () => {} }
171
225
  : new FinalizationRegistry(ptr => wasm.__wbg_forecast_free(ptr >>> 0, 1));
@@ -186,6 +240,54 @@ const IMAPAForecasterFinalization = (typeof FinalizationRegistry === 'undefined'
186
240
  ? { register: () => {}, unregister: () => {} }
187
241
  : new FinalizationRegistry(ptr => wasm.__wbg_imapaforecaster_free(ptr >>> 0, 1));
188
242
 
243
+ const JsBacktestConfigFinalization = (typeof FinalizationRegistry === 'undefined')
244
+ ? { register: () => {}, unregister: () => {} }
245
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsbacktestconfig_free(ptr >>> 0, 1));
246
+
247
+ const JsBacktestResultFinalization = (typeof FinalizationRegistry === 'undefined')
248
+ ? { register: () => {}, unregister: () => {} }
249
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsbacktestresult_free(ptr >>> 0, 1));
250
+
251
+ const JsConformalPredictorFinalization = (typeof FinalizationRegistry === 'undefined')
252
+ ? { register: () => {}, unregister: () => {} }
253
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsconformalpredictor_free(ptr >>> 0, 1));
254
+
255
+ const JsConformalResultFinalization = (typeof FinalizationRegistry === 'undefined')
256
+ ? { register: () => {}, unregister: () => {} }
257
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsconformalresult_free(ptr >>> 0, 1));
258
+
259
+ const JsHistoricalSimResultFinalization = (typeof FinalizationRegistry === 'undefined')
260
+ ? { register: () => {}, unregister: () => {} }
261
+ : new FinalizationRegistry(ptr => wasm.__wbg_jshistoricalsimresult_free(ptr >>> 0, 1));
262
+
263
+ const JsHistoricalSimulatorFinalization = (typeof FinalizationRegistry === 'undefined')
264
+ ? { register: () => {}, unregister: () => {} }
265
+ : new FinalizationRegistry(ptr => wasm.__wbg_jshistoricalsimulator_free(ptr >>> 0, 1));
266
+
267
+ const JsNormalPredictorFinalization = (typeof FinalizationRegistry === 'undefined')
268
+ ? { register: () => {}, unregister: () => {} }
269
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsnormalpredictor_free(ptr >>> 0, 1));
270
+
271
+ const JsNormalResultFinalization = (typeof FinalizationRegistry === 'undefined')
272
+ ? { register: () => {}, unregister: () => {} }
273
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsnormalresult_free(ptr >>> 0, 1));
274
+
275
+ const JsPointForecastsFinalization = (typeof FinalizationRegistry === 'undefined')
276
+ ? { register: () => {}, unregister: () => {} }
277
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspointforecasts_free(ptr >>> 0, 1));
278
+
279
+ const JsPostProcessorFinalization = (typeof FinalizationRegistry === 'undefined')
280
+ ? { register: () => {}, unregister: () => {} }
281
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspostprocessor_free(ptr >>> 0, 1));
282
+
283
+ const JsPredictionIntervalsFinalization = (typeof FinalizationRegistry === 'undefined')
284
+ ? { register: () => {}, unregister: () => {} }
285
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspredictionintervals_free(ptr >>> 0, 1));
286
+
287
+ const JsTrainedModelFinalization = (typeof FinalizationRegistry === 'undefined')
288
+ ? { register: () => {}, unregister: () => {} }
289
+ : new FinalizationRegistry(ptr => wasm.__wbg_jstrainedmodel_free(ptr >>> 0, 1));
290
+
189
291
  const MFLESForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
190
292
  ? { register: () => {}, unregister: () => {} }
191
293
  : new FinalizationRegistry(ptr => wasm.__wbg_mflesforecaster_free(ptr >>> 0, 1));
@@ -268,6 +370,18 @@ export class ADIDAForecaster {
268
370
  const ptr = this.__destroy_into_raw();
269
371
  wasm.__wbg_adidaforecaster_free(ptr, 0);
270
372
  }
373
+ /**
374
+ * @param {number} horizon
375
+ * @param {number} level
376
+ * @returns {Forecast}
377
+ */
378
+ predictWithIntervals(horizon, level) {
379
+ const ret = wasm.adidaforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
380
+ if (ret[2]) {
381
+ throw takeFromExternrefTable0(ret[1]);
382
+ }
383
+ return Forecast.__wrap(ret[0]);
384
+ }
271
385
  /**
272
386
  * @param {TimeSeries} series
273
387
  */
@@ -566,49 +680,115 @@ export class AutoETSForecaster {
566
680
  if (Symbol.dispose) AutoETSForecaster.prototype[Symbol.dispose] = AutoETSForecaster.prototype.free;
567
681
 
568
682
  /**
569
- * AutoTBATS - Automatic TBATS model selection.
683
+ * Automatic ensemble that selects top-K models across families.
684
+ *
685
+ * Fits AutoARIMA, AutoETS, and AutoTheta, ranks them by in-sample MSE,
686
+ * and combines the top-K into a weighted ensemble forecast.
570
687
  */
571
- export class AutoTBATSForecaster {
688
+ export class AutoEnsembleForecaster {
689
+ static __wrap(ptr) {
690
+ ptr = ptr >>> 0;
691
+ const obj = Object.create(AutoEnsembleForecaster.prototype);
692
+ obj.__wbg_ptr = ptr;
693
+ AutoEnsembleForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
694
+ return obj;
695
+ }
572
696
  __destroy_into_raw() {
573
697
  const ptr = this.__wbg_ptr;
574
698
  this.__wbg_ptr = 0;
575
- AutoTBATSForecasterFinalization.unregister(this);
699
+ AutoEnsembleForecasterFinalization.unregister(this);
576
700
  return ptr;
577
701
  }
578
702
  free() {
579
703
  const ptr = this.__destroy_into_raw();
580
- wasm.__wbg_autotbatsforecaster_free(ptr, 0);
704
+ wasm.__wbg_autoensembleforecaster_free(ptr, 0);
705
+ }
706
+ /**
707
+ * Get all candidate scores as a JSON object.
708
+ *
709
+ * Returns an array of `{ name, score }` objects sorted by score (ascending).
710
+ * @returns {any}
711
+ */
712
+ allScores() {
713
+ const ret = wasm.autoensembleforecaster_allScores(this.__wbg_ptr);
714
+ if (ret[2]) {
715
+ throw takeFromExternrefTable0(ret[1]);
716
+ }
717
+ return takeFromExternrefTable0(ret[0]);
718
+ }
719
+ /**
720
+ * Get the number of models in the ensemble.
721
+ * @returns {number}
722
+ */
723
+ modelCount() {
724
+ const ret = wasm.autoensembleforecaster_modelCount(this.__wbg_ptr);
725
+ return ret >>> 0;
726
+ }
727
+ /**
728
+ * Create with custom configuration.
729
+ *
730
+ * @param topK - Number of top models to include in ensemble (default: 3)
731
+ * @param seasonalPeriod - Seasonal period (0 or undefined for non-seasonal)
732
+ * @param {number | null} [top_k]
733
+ * @param {number | null} [seasonal_period]
734
+ * @returns {AutoEnsembleForecaster}
735
+ */
736
+ static withConfig(top_k, seasonal_period) {
737
+ const ret = wasm.autoensembleforecaster_withConfig(isLikeNone(top_k) ? 0x100000001 : (top_k) >>> 0, isLikeNone(seasonal_period) ? 0x100000001 : (seasonal_period) >>> 0);
738
+ return AutoEnsembleForecaster.__wrap(ret);
739
+ }
740
+ /**
741
+ * Predict with prediction intervals.
742
+ *
743
+ * @param horizon - Number of steps to forecast
744
+ * @param level - Confidence level (e.g., 0.95 for 95% intervals)
745
+ * @returns Forecast with combined predictions and intervals
746
+ * @param {number} horizon
747
+ * @param {number} level
748
+ * @returns {Forecast}
749
+ */
750
+ predictWithIntervals(horizon, level) {
751
+ const ret = wasm.autoensembleforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
752
+ if (ret[2]) {
753
+ throw takeFromExternrefTable0(ret[1]);
754
+ }
755
+ return Forecast.__wrap(ret[0]);
581
756
  }
582
757
  /**
758
+ * Fit the ensemble to a time series.
759
+ *
760
+ * Fits all candidate models, selects the top-K, and builds the ensemble.
761
+ *
762
+ * @param series - TimeSeries to fit
583
763
  * @param {TimeSeries} series
584
764
  */
585
765
  fit(series) {
586
766
  _assertClass(series, TimeSeries);
587
- const ret = wasm.autotbatsforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
767
+ const ret = wasm.autoensembleforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
588
768
  if (ret[1]) {
589
769
  throw takeFromExternrefTable0(ret[0]);
590
770
  }
591
771
  }
592
772
  /**
593
- * @param seasonal_periods - Array of seasonal periods
594
- * @param {Uint32Array} seasonal_periods
773
+ * Create a new AutoEnsembleForecaster with default configuration.
774
+ *
775
+ * By default, uses top-3 models with weighted MSE combination.
595
776
  */
596
- constructor(seasonal_periods) {
597
- const ptr0 = passArray32ToWasm0(seasonal_periods, wasm.__wbindgen_malloc);
598
- const len0 = WASM_VECTOR_LEN;
599
- const ret = wasm.autotbatsforecaster_new(ptr0, len0);
777
+ constructor() {
778
+ const ret = wasm.autoensembleforecaster_new();
600
779
  this.__wbg_ptr = ret >>> 0;
601
- AutoTBATSForecasterFinalization.register(this, this.__wbg_ptr, this);
780
+ AutoEnsembleForecasterFinalization.register(this, this.__wbg_ptr, this);
602
781
  return this;
603
782
  }
604
783
  /**
784
+ * Get the model name.
605
785
  * @returns {string}
606
786
  */
607
787
  get name() {
608
788
  let deferred1_0;
609
789
  let deferred1_1;
610
790
  try {
611
- const ret = wasm.autotbatsforecaster_name(this.__wbg_ptr);
791
+ const ret = wasm.autoensembleforecaster_name(this.__wbg_ptr);
612
792
  deferred1_0 = ret[0];
613
793
  deferred1_1 = ret[1];
614
794
  return getStringFromWasm0(ret[0], ret[1]);
@@ -617,69 +797,158 @@ export class AutoTBATSForecaster {
617
797
  }
618
798
  }
619
799
  /**
800
+ * Predict future values.
801
+ *
802
+ * @param horizon - Number of steps to forecast
803
+ * @returns Forecast with combined point predictions
620
804
  * @param {number} horizon
621
805
  * @returns {Forecast}
622
806
  */
623
807
  predict(horizon) {
624
- const ret = wasm.autotbatsforecaster_predict(this.__wbg_ptr, horizon);
808
+ const ret = wasm.autoensembleforecaster_predict(this.__wbg_ptr, horizon);
625
809
  if (ret[2]) {
626
810
  throw takeFromExternrefTable0(ret[1]);
627
811
  }
628
812
  return Forecast.__wrap(ret[0]);
629
813
  }
814
+ /**
815
+ * Create a seasonal AutoEnsembleForecaster.
816
+ *
817
+ * @param period - Seasonal period
818
+ * @param {number} period
819
+ * @returns {AutoEnsembleForecaster}
820
+ */
821
+ static seasonal(period) {
822
+ const ret = wasm.autoensembleforecaster_seasonal(period);
823
+ return AutoEnsembleForecaster.__wrap(ret);
824
+ }
630
825
  }
631
- if (Symbol.dispose) AutoTBATSForecaster.prototype[Symbol.dispose] = AutoTBATSForecaster.prototype.free;
826
+ if (Symbol.dispose) AutoEnsembleForecaster.prototype[Symbol.dispose] = AutoEnsembleForecaster.prototype.free;
632
827
 
633
828
  /**
634
- * AutoTheta - Automatic Theta model selection.
829
+ * Automatic model selection across ARIMA, ETS, and Theta families.
830
+ *
831
+ * Fits all enabled auto models and selects the best one based on
832
+ * in-sample MSE or cross-validation error.
635
833
  */
636
- export class AutoThetaForecaster {
834
+ export class AutoForecaster {
835
+ static __wrap(ptr) {
836
+ ptr = ptr >>> 0;
837
+ const obj = Object.create(AutoForecaster.prototype);
838
+ obj.__wbg_ptr = ptr;
839
+ AutoForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
840
+ return obj;
841
+ }
637
842
  __destroy_into_raw() {
638
843
  const ptr = this.__wbg_ptr;
639
844
  this.__wbg_ptr = 0;
640
- AutoThetaForecasterFinalization.unregister(this);
845
+ AutoForecasterFinalization.unregister(this);
641
846
  return ptr;
642
847
  }
643
848
  free() {
644
849
  const ptr = this.__destroy_into_raw();
645
- wasm.__wbg_autothetaforecaster_free(ptr, 0);
850
+ wasm.__wbg_autoforecaster_free(ptr, 0);
851
+ }
852
+ /**
853
+ * Get all candidate scores as a JSON object.
854
+ *
855
+ * Returns an array of `{ name, score }` objects sorted by score (ascending).
856
+ * @returns {any}
857
+ */
858
+ allScores() {
859
+ const ret = wasm.autoforecaster_allScores(this.__wbg_ptr);
860
+ if (ret[2]) {
861
+ throw takeFromExternrefTable0(ret[1]);
862
+ }
863
+ return takeFromExternrefTable0(ret[0]);
864
+ }
865
+ /**
866
+ * Create an AutoForecaster with custom configuration.
867
+ *
868
+ * @param seasonalPeriod - Seasonal period (0 or undefined for non-seasonal)
869
+ * @param includeArima - Include AutoARIMA candidate (default: true)
870
+ * @param includeEts - Include AutoETS candidate (default: true)
871
+ * @param includeTheta - Include AutoTheta candidate (default: true)
872
+ * @param useCrossValidation - Use cross-validation instead of in-sample MSE (default: false)
873
+ * @param {number | null} [seasonal_period]
874
+ * @param {boolean | null} [include_arima]
875
+ * @param {boolean | null} [include_ets]
876
+ * @param {boolean | null} [include_theta]
877
+ * @param {boolean | null} [use_cross_validation]
878
+ * @returns {AutoForecaster}
879
+ */
880
+ static withConfig(seasonal_period, include_arima, include_ets, include_theta, use_cross_validation) {
881
+ const ret = wasm.autoforecaster_withConfig(isLikeNone(seasonal_period) ? 0x100000001 : (seasonal_period) >>> 0, isLikeNone(include_arima) ? 0xFFFFFF : include_arima ? 1 : 0, isLikeNone(include_ets) ? 0xFFFFFF : include_ets ? 1 : 0, isLikeNone(include_theta) ? 0xFFFFFF : include_theta ? 1 : 0, isLikeNone(use_cross_validation) ? 0xFFFFFF : use_cross_validation ? 1 : 0);
882
+ return AutoForecaster.__wrap(ret);
883
+ }
884
+ /**
885
+ * Get the name of the selected model.
886
+ *
887
+ * @returns Name of the best model, or undefined if not yet fitted
888
+ * @returns {string | undefined}
889
+ */
890
+ selectedModelName() {
891
+ const ret = wasm.autoforecaster_selectedModelName(this.__wbg_ptr);
892
+ let v1;
893
+ if (ret[0] !== 0) {
894
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
895
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
896
+ }
897
+ return v1;
646
898
  }
647
899
  /**
900
+ * Predict with prediction intervals.
901
+ *
902
+ * @param horizon - Number of steps to forecast
903
+ * @param level - Confidence level (e.g., 0.95 for 95% intervals)
904
+ * @returns Forecast with point predictions and intervals
648
905
  * @param {number} horizon
649
906
  * @param {number} level
650
907
  * @returns {Forecast}
651
908
  */
652
909
  predictWithIntervals(horizon, level) {
653
- const ret = wasm.autothetaforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
910
+ const ret = wasm.autoforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
654
911
  if (ret[2]) {
655
912
  throw takeFromExternrefTable0(ret[1]);
656
913
  }
657
914
  return Forecast.__wrap(ret[0]);
658
915
  }
659
916
  /**
917
+ * Fit the model to a time series.
918
+ *
919
+ * Fits all candidate models and selects the best one.
920
+ *
921
+ * @param series - TimeSeries to fit
660
922
  * @param {TimeSeries} series
661
923
  */
662
924
  fit(series) {
663
925
  _assertClass(series, TimeSeries);
664
- const ret = wasm.autothetaforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
926
+ const ret = wasm.autoforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
665
927
  if (ret[1]) {
666
928
  throw takeFromExternrefTable0(ret[0]);
667
929
  }
668
930
  }
931
+ /**
932
+ * Create a new AutoForecaster with default configuration.
933
+ *
934
+ * By default, includes AutoARIMA, AutoETS, and AutoTheta candidates
935
+ * and uses in-sample MSE for model selection.
936
+ */
669
937
  constructor() {
670
- const ret = wasm.autothetaforecaster_new();
938
+ const ret = wasm.autoforecaster_new();
671
939
  this.__wbg_ptr = ret >>> 0;
672
- AutoThetaForecasterFinalization.register(this, this.__wbg_ptr, this);
940
+ AutoForecasterFinalization.register(this, this.__wbg_ptr, this);
673
941
  return this;
674
942
  }
675
943
  /**
944
+ * Get the model name.
676
945
  * @returns {string}
677
946
  */
678
947
  get name() {
679
948
  let deferred1_0;
680
949
  let deferred1_1;
681
950
  try {
682
- const ret = wasm.autothetaforecaster_name(this.__wbg_ptr);
951
+ const ret = wasm.autoforecaster_name(this.__wbg_ptr);
683
952
  deferred1_0 = ret[0];
684
953
  deferred1_1 = ret[1];
685
954
  return getStringFromWasm0(ret[0], ret[1]);
@@ -688,47 +957,68 @@ export class AutoThetaForecaster {
688
957
  }
689
958
  }
690
959
  /**
960
+ * Predict future values.
961
+ *
962
+ * @param horizon - Number of steps to forecast
963
+ * @returns Forecast with point predictions
691
964
  * @param {number} horizon
692
965
  * @returns {Forecast}
693
966
  */
694
967
  predict(horizon) {
695
- const ret = wasm.autothetaforecaster_predict(this.__wbg_ptr, horizon);
968
+ const ret = wasm.autoforecaster_predict(this.__wbg_ptr, horizon);
696
969
  if (ret[2]) {
697
970
  throw takeFromExternrefTable0(ret[1]);
698
971
  }
699
972
  return Forecast.__wrap(ret[0]);
700
973
  }
974
+ /**
975
+ * Create a seasonal AutoForecaster.
976
+ *
977
+ * @param period - Seasonal period (e.g., 12 for monthly data with yearly seasonality)
978
+ * @param {number} period
979
+ * @returns {AutoForecaster}
980
+ */
981
+ static seasonal(period) {
982
+ const ret = wasm.autoforecaster_seasonal(period);
983
+ return AutoForecaster.__wrap(ret);
984
+ }
701
985
  }
702
- if (Symbol.dispose) AutoThetaForecaster.prototype[Symbol.dispose] = AutoThetaForecaster.prototype.free;
986
+ if (Symbol.dispose) AutoForecaster.prototype[Symbol.dispose] = AutoForecaster.prototype.free;
703
987
 
704
988
  /**
705
- * Croston's method for intermittent demand forecasting.
989
+ * AutoTBATS - Automatic TBATS model selection.
706
990
  */
707
- export class CrostonForecaster {
991
+ export class AutoTBATSForecaster {
708
992
  __destroy_into_raw() {
709
993
  const ptr = this.__wbg_ptr;
710
994
  this.__wbg_ptr = 0;
711
- CrostonForecasterFinalization.unregister(this);
995
+ AutoTBATSForecasterFinalization.unregister(this);
712
996
  return ptr;
713
997
  }
714
998
  free() {
715
999
  const ptr = this.__destroy_into_raw();
716
- wasm.__wbg_crostonforecaster_free(ptr, 0);
1000
+ wasm.__wbg_autotbatsforecaster_free(ptr, 0);
717
1001
  }
718
1002
  /**
719
1003
  * @param {TimeSeries} series
720
1004
  */
721
1005
  fit(series) {
722
1006
  _assertClass(series, TimeSeries);
723
- const ret = wasm.crostonforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1007
+ const ret = wasm.autotbatsforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
724
1008
  if (ret[1]) {
725
1009
  throw takeFromExternrefTable0(ret[0]);
726
1010
  }
727
1011
  }
728
- constructor() {
729
- const ret = wasm.crostonforecaster_new();
1012
+ /**
1013
+ * @param seasonal_periods - Array of seasonal periods
1014
+ * @param {Uint32Array} seasonal_periods
1015
+ */
1016
+ constructor(seasonal_periods) {
1017
+ const ptr0 = passArray32ToWasm0(seasonal_periods, wasm.__wbindgen_malloc);
1018
+ const len0 = WASM_VECTOR_LEN;
1019
+ const ret = wasm.autotbatsforecaster_new(ptr0, len0);
730
1020
  this.__wbg_ptr = ret >>> 0;
731
- CrostonForecasterFinalization.register(this, this.__wbg_ptr, this);
1021
+ AutoTBATSForecasterFinalization.register(this, this.__wbg_ptr, this);
732
1022
  return this;
733
1023
  }
734
1024
  /**
@@ -738,7 +1028,7 @@ export class CrostonForecaster {
738
1028
  let deferred1_0;
739
1029
  let deferred1_1;
740
1030
  try {
741
- const ret = wasm.crostonforecaster_name(this.__wbg_ptr);
1031
+ const ret = wasm.autotbatsforecaster_name(this.__wbg_ptr);
742
1032
  deferred1_0 = ret[0];
743
1033
  deferred1_1 = ret[1];
744
1034
  return getStringFromWasm0(ret[0], ret[1]);
@@ -751,35 +1041,28 @@ export class CrostonForecaster {
751
1041
  * @returns {Forecast}
752
1042
  */
753
1043
  predict(horizon) {
754
- const ret = wasm.crostonforecaster_predict(this.__wbg_ptr, horizon);
1044
+ const ret = wasm.autotbatsforecaster_predict(this.__wbg_ptr, horizon);
755
1045
  if (ret[2]) {
756
1046
  throw takeFromExternrefTable0(ret[1]);
757
1047
  }
758
1048
  return Forecast.__wrap(ret[0]);
759
1049
  }
760
1050
  }
761
- if (Symbol.dispose) CrostonForecaster.prototype[Symbol.dispose] = CrostonForecaster.prototype.free;
1051
+ if (Symbol.dispose) AutoTBATSForecaster.prototype[Symbol.dispose] = AutoTBATSForecaster.prototype.free;
762
1052
 
763
1053
  /**
764
- * Dynamic Theta forecaster - updates coefficients dynamically.
1054
+ * AutoTheta - Automatic Theta model selection.
765
1055
  */
766
- export class DynamicThetaForecaster {
767
- static __wrap(ptr) {
768
- ptr = ptr >>> 0;
769
- const obj = Object.create(DynamicThetaForecaster.prototype);
770
- obj.__wbg_ptr = ptr;
771
- DynamicThetaForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
772
- return obj;
773
- }
1056
+ export class AutoThetaForecaster {
774
1057
  __destroy_into_raw() {
775
1058
  const ptr = this.__wbg_ptr;
776
1059
  this.__wbg_ptr = 0;
777
- DynamicThetaForecasterFinalization.unregister(this);
1060
+ AutoThetaForecasterFinalization.unregister(this);
778
1061
  return ptr;
779
1062
  }
780
1063
  free() {
781
1064
  const ptr = this.__destroy_into_raw();
782
- wasm.__wbg_dynamicthetaforecaster_free(ptr, 0);
1065
+ wasm.__wbg_autothetaforecaster_free(ptr, 0);
783
1066
  }
784
1067
  /**
785
1068
  * @param {number} horizon
@@ -787,7 +1070,7 @@ export class DynamicThetaForecaster {
787
1070
  * @returns {Forecast}
788
1071
  */
789
1072
  predictWithIntervals(horizon, level) {
790
- const ret = wasm.dynamicthetaforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
1073
+ const ret = wasm.autothetaforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
791
1074
  if (ret[2]) {
792
1075
  throw takeFromExternrefTable0(ret[1]);
793
1076
  }
@@ -798,19 +1081,15 @@ export class DynamicThetaForecaster {
798
1081
  */
799
1082
  fit(series) {
800
1083
  _assertClass(series, TimeSeries);
801
- const ret = wasm.dynamicthetaforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1084
+ const ret = wasm.autothetaforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
802
1085
  if (ret[1]) {
803
1086
  throw takeFromExternrefTable0(ret[0]);
804
1087
  }
805
1088
  }
806
- /**
807
- * @param alpha - Smoothing parameter for the forecast
808
- * @param {number} alpha
809
- */
810
- constructor(alpha) {
811
- const ret = wasm.dynamicthetaforecaster_new(alpha);
1089
+ constructor() {
1090
+ const ret = wasm.autothetaforecaster_new();
812
1091
  this.__wbg_ptr = ret >>> 0;
813
- DynamicThetaForecasterFinalization.register(this, this.__wbg_ptr, this);
1092
+ AutoThetaForecasterFinalization.register(this, this.__wbg_ptr, this);
814
1093
  return this;
815
1094
  }
816
1095
  /**
@@ -820,7 +1099,7 @@ export class DynamicThetaForecaster {
820
1099
  let deferred1_0;
821
1100
  let deferred1_1;
822
1101
  try {
823
- const ret = wasm.dynamicthetaforecaster_name(this.__wbg_ptr);
1102
+ const ret = wasm.autothetaforecaster_name(this.__wbg_ptr);
824
1103
  deferred1_0 = ret[0];
825
1104
  deferred1_1 = ret[1];
826
1105
  return getStringFromWasm0(ret[0], ret[1]);
@@ -833,311 +1112,274 @@ export class DynamicThetaForecaster {
833
1112
  * @returns {Forecast}
834
1113
  */
835
1114
  predict(horizon) {
836
- const ret = wasm.dynamicthetaforecaster_predict(this.__wbg_ptr, horizon);
1115
+ const ret = wasm.autothetaforecaster_predict(this.__wbg_ptr, horizon);
837
1116
  if (ret[2]) {
838
1117
  throw takeFromExternrefTable0(ret[1]);
839
1118
  }
840
1119
  return Forecast.__wrap(ret[0]);
841
1120
  }
842
- /**
843
- * Create a seasonal Dynamic Theta model.
844
- * @param period - Seasonal period
845
- * @param {number} period
846
- * @returns {DynamicThetaForecaster}
847
- */
848
- static seasonal(period) {
849
- const ret = wasm.dynamicthetaforecaster_seasonal(period);
850
- return DynamicThetaForecaster.__wrap(ret);
851
- }
852
- /**
853
- * Create an optimized Dynamic Theta model.
854
- * @returns {DynamicThetaForecaster}
855
- */
856
- static optimized() {
857
- const ret = wasm.dynamicthetaforecaster_optimized();
858
- return DynamicThetaForecaster.__wrap(ret);
859
- }
860
1121
  }
861
- if (Symbol.dispose) DynamicThetaForecaster.prototype[Symbol.dispose] = DynamicThetaForecaster.prototype.free;
1122
+ if (Symbol.dispose) AutoThetaForecaster.prototype[Symbol.dispose] = AutoThetaForecaster.prototype.free;
862
1123
 
863
1124
  /**
864
- * ETS (Error-Trend-Seasonal) state-space model.
1125
+ * Calendar annotations for holidays and external regressors.
865
1126
  *
866
- * Use string codes: "A" = Additive, "M" = Multiplicative, "N" = None
867
- * Or use standard ETS notation like "ANN", "AAA", "MAM", "AAdM".
1127
+ * Use this to define holidays, events, promotions, or any named
1128
+ * numeric regressors that can influence a forecast. Attach to a
1129
+ * `TimeSeries` via `TimeSeries.setCalendar()` before fitting a
1130
+ * model that supports exogenous variables.
868
1131
  *
869
- * Follows the ETS taxonomy from FPP3: <https://otexts.com/fpp3/taxonomy.html>
1132
+ * @example
1133
+ * ```js
1134
+ * const cal = new CalendarAnnotations();
1135
+ * cal.addHoliday(new Date("2024-12-25").getTime());
1136
+ * cal.addHoliday(new Date("2025-01-01").getTime());
1137
+ * cal.addRegressor("promo", new Float64Array([0,0,1,1,0,0,0]));
870
1138
  *
871
- * Note: Some combinations are invalid/unstable per FPP3:
872
- * - MAA (Multiplicative error + Additive trend + Additive seasonal)
873
- * - MAdA (Multiplicative error + Damped trend + Additive seasonal)
1139
+ * const ts = TimeSeries.withTimestamps(values, timestamps);
1140
+ * ts.setCalendar(cal);
1141
+ * ```
874
1142
  */
875
- export class ETSForecaster {
1143
+ export class CalendarAnnotations {
876
1144
  static __wrap(ptr) {
877
1145
  ptr = ptr >>> 0;
878
- const obj = Object.create(ETSForecaster.prototype);
1146
+ const obj = Object.create(CalendarAnnotations.prototype);
879
1147
  obj.__wbg_ptr = ptr;
880
- ETSForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
1148
+ CalendarAnnotationsFinalization.register(obj, obj.__wbg_ptr, obj);
881
1149
  return obj;
882
1150
  }
883
1151
  __destroy_into_raw() {
884
1152
  const ptr = this.__wbg_ptr;
885
1153
  this.__wbg_ptr = 0;
886
- ETSForecasterFinalization.unregister(this);
1154
+ CalendarAnnotationsFinalization.unregister(this);
887
1155
  return ptr;
888
1156
  }
889
1157
  free() {
890
1158
  const ptr = this.__destroy_into_raw();
891
- wasm.__wbg_etsforecaster_free(ptr, 0);
1159
+ wasm.__wbg_calendarannotations_free(ptr, 0);
892
1160
  }
893
1161
  /**
894
- * Create an ETS model from standard notation.
895
- *
896
- * @param notation - ETS notation string like "ANN", "AAA", "MAM", "AAdM"
897
- * @param period - Seasonal period (required if notation has seasonal component)
1162
+ * Check if a specific date is a holiday.
898
1163
  *
899
- * Format: ErrorTrendSeasonal
900
- * - Error: A (additive) or M (multiplicative)
901
- * - Trend: N (none), A (additive), or Ad (additive damped)
902
- * - Seasonal: N (none), A (additive), or M (multiplicative)
1164
+ * @param timestamp_ms - Date to check as milliseconds since Unix epoch
1165
+ * @returns true if the date matches any registered holiday
1166
+ * @param {number} timestamp_ms
1167
+ * @returns {boolean}
1168
+ */
1169
+ isHoliday(timestamp_ms) {
1170
+ const ret = wasm.calendarannotations_isHoliday(this.__wbg_ptr, timestamp_ms);
1171
+ return ret !== 0;
1172
+ }
1173
+ /**
1174
+ * Add a single holiday date.
903
1175
  *
904
- * Examples:
905
- * - "ANN" - Simple exponential smoothing
906
- * - "AAN" - Holt's linear method
907
- * - "AAA" - Holt-Winters additive
908
- * - "MAM" - Multiplicative Holt-Winters
909
- * - "AAdM" - Damped trend with multiplicative seasonal
1176
+ * @param timestamp_ms - Holiday date as milliseconds since Unix epoch
1177
+ * @param {number} timestamp_ms
1178
+ */
1179
+ addHoliday(timestamp_ms) {
1180
+ wasm.calendarannotations_addHoliday(this.__wbg_ptr, timestamp_ms);
1181
+ }
1182
+ /**
1183
+ * Get holiday dates as milliseconds since Unix epoch.
1184
+ * @returns {Float64Array}
1185
+ */
1186
+ getHolidays() {
1187
+ const ret = wasm.calendarannotations_getHolidays(this.__wbg_ptr);
1188
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1189
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1190
+ return v1;
1191
+ }
1192
+ /**
1193
+ * Set multiple holiday dates at once (replaces any existing holidays).
910
1194
  *
911
- * @throws Error for invalid notation or unstable combinations (MAA, MAdA)
912
- * @param {string} notation
913
- * @param {number} period
914
- * @returns {ETSForecaster}
1195
+ * @param timestamps_ms - Array of holiday dates as milliseconds since Unix epoch
1196
+ * @param {Float64Array} timestamps_ms
915
1197
  */
916
- static fromNotation(notation, period) {
917
- const ptr0 = passStringToWasm0(notation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1198
+ setHolidays(timestamps_ms) {
1199
+ const ptr0 = passArrayF64ToWasm0(timestamps_ms, wasm.__wbindgen_malloc);
918
1200
  const len0 = WASM_VECTOR_LEN;
919
- const ret = wasm.etsforecaster_fromNotation(ptr0, len0, period);
920
- if (ret[2]) {
921
- throw takeFromExternrefTable0(ret[1]);
922
- }
923
- return ETSForecaster.__wrap(ret[0]);
1201
+ wasm.calendarannotations_setHolidays(this.__wbg_ptr, ptr0, len0);
924
1202
  }
925
1203
  /**
926
- * Check if an ETS specification is valid/stable.
1204
+ * Add a named regressor with values aligned to the time series.
927
1205
  *
928
- * @param error - Error type: "A" or "M"
929
- * @param trend - Trend type: "N", "A", or "Ad"
930
- * @param seasonal - Seasonal type: "N", "A", or "M"
931
- * @returns true if the combination is stable and usable
1206
+ * The values array must have the same length as the time series this
1207
+ * will be attached to. Common examples: promotional flags (0/1),
1208
+ * temperature, price changes, etc.
932
1209
  *
933
- * Invalid combinations (return false):
934
- * - M,A,A - Multiplicative error with additive trend and additive seasonal
935
- * - M,Ad,A - Multiplicative error with damped trend and additive seasonal
936
- * @param {string} error
937
- * @param {string} trend
938
- * @param {string} seasonal
939
- * @returns {boolean}
1210
+ * @param name - Name of the regressor (e.g., "promo", "temperature")
1211
+ * @param values - Array of numeric values, one per time step
1212
+ * @param {string} name
1213
+ * @param {Float64Array} values
940
1214
  */
941
- static isValidSpec(error, trend, seasonal) {
942
- const ptr0 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1215
+ addRegressor(name, values) {
1216
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
943
1217
  const len0 = WASM_VECTOR_LEN;
944
- const ptr1 = passStringToWasm0(trend, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1218
+ const ptr1 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
945
1219
  const len1 = WASM_VECTOR_LEN;
946
- const ptr2 = passStringToWasm0(seasonal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
947
- const len2 = WASM_VECTOR_LEN;
948
- const ret = wasm.etsforecaster_isValidSpec(ptr0, len0, ptr1, len1, ptr2, len2);
949
- return ret !== 0;
950
- }
951
- /**
952
- * @param {TimeSeries} series
953
- */
954
- fit(series) {
955
- _assertClass(series, TimeSeries);
956
- const ret = wasm.etsforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
957
- if (ret[1]) {
958
- throw takeFromExternrefTable0(ret[0]);
959
- }
1220
+ wasm.calendarannotations_addRegressor(this.__wbg_ptr, ptr0, len0, ptr1, len1);
960
1221
  }
961
1222
  /**
962
- * Create an ETS model with specified components.
963
- * @param error - Error type: "A" (additive) or "M" (multiplicative)
964
- * @param trend - Trend type: "N" (none), "A" (additive), or "Ad" (additive damped)
965
- * @param seasonal - Seasonal type: "N" (none), "A" (additive), or "M" (multiplicative)
966
- * @param period - Seasonal period (ignored if seasonal is "N")
967
- * @throws Error if the combination is unstable (MAA or MAdA)
968
- * @param {string} error
969
- * @param {string} trend
970
- * @param {string} seasonal
971
- * @param {number} period
1223
+ * Get values for a named regressor.
1224
+ *
1225
+ * @param name - Regressor name
1226
+ * @returns Array of values, or undefined if the regressor does not exist
1227
+ * @param {string} name
1228
+ * @returns {Float64Array | undefined}
972
1229
  */
973
- constructor(error, trend, seasonal, period) {
974
- const ptr0 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1230
+ getRegressor(name) {
1231
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
975
1232
  const len0 = WASM_VECTOR_LEN;
976
- const ptr1 = passStringToWasm0(trend, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
977
- const len1 = WASM_VECTOR_LEN;
978
- const ptr2 = passStringToWasm0(seasonal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
979
- const len2 = WASM_VECTOR_LEN;
980
- const ret = wasm.etsforecaster_new(ptr0, len0, ptr1, len1, ptr2, len2, period);
981
- if (ret[2]) {
982
- throw takeFromExternrefTable0(ret[1]);
1233
+ const ret = wasm.calendarannotations_getRegressor(this.__wbg_ptr, ptr0, len0);
1234
+ let v2;
1235
+ if (ret[0] !== 0) {
1236
+ v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1237
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
983
1238
  }
984
- this.__wbg_ptr = ret[0] >>> 0;
985
- ETSForecasterFinalization.register(this, this.__wbg_ptr, this);
986
- return this;
1239
+ return v2;
987
1240
  }
988
1241
  /**
989
- * @returns {string}
1242
+ * Get the number of holidays.
1243
+ * @returns {number}
990
1244
  */
991
- get name() {
992
- let deferred1_0;
993
- let deferred1_1;
994
- try {
995
- const ret = wasm.etsforecaster_name(this.__wbg_ptr);
996
- deferred1_0 = ret[0];
997
- deferred1_1 = ret[1];
998
- return getStringFromWasm0(ret[0], ret[1]);
999
- } finally {
1000
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1001
- }
1245
+ holidayCount() {
1246
+ const ret = wasm.calendarannotations_holidayCount(this.__wbg_ptr);
1247
+ return ret >>> 0;
1002
1248
  }
1003
1249
  /**
1004
- * @param {number} horizon
1005
- * @returns {Forecast}
1250
+ * Check whether any regressors have been added.
1251
+ * @returns {boolean}
1006
1252
  */
1007
- predict(horizon) {
1008
- const ret = wasm.etsforecaster_predict(this.__wbg_ptr, horizon);
1009
- if (ret[2]) {
1010
- throw takeFromExternrefTable0(ret[1]);
1011
- }
1012
- return Forecast.__wrap(ret[0]);
1013
- }
1014
- }
1015
- if (Symbol.dispose) ETSForecaster.prototype[Symbol.dispose] = ETSForecaster.prototype.free;
1016
-
1017
- /**
1018
- * Forecast result wrapper for JavaScript.
1019
- *
1020
- * Contains point predictions and optional prediction intervals.
1021
- */
1022
- export class Forecast {
1023
- static __wrap(ptr) {
1024
- ptr = ptr >>> 0;
1025
- const obj = Object.create(Forecast.prototype);
1026
- obj.__wbg_ptr = ptr;
1027
- ForecastFinalization.register(obj, obj.__wbg_ptr, obj);
1028
- return obj;
1029
- }
1030
- __destroy_into_raw() {
1031
- const ptr = this.__wbg_ptr;
1032
- this.__wbg_ptr = 0;
1033
- ForecastFinalization.unregister(this);
1034
- return ptr;
1035
- }
1036
- free() {
1037
- const ptr = this.__destroy_into_raw();
1038
- wasm.__wbg_forecast_free(ptr, 0);
1253
+ hasRegressors() {
1254
+ const ret = wasm.calendarannotations_hasRegressors(this.__wbg_ptr);
1255
+ return ret !== 0;
1039
1256
  }
1040
1257
  /**
1041
- * Get lower prediction interval bounds.
1258
+ * Check if a specific date is a business day (not weekend, not holiday).
1042
1259
  *
1043
- * @returns Array of lower bounds, or undefined if not available
1044
- * @returns {Float64Array | undefined}
1260
+ * @param timestamp_ms - Date to check as milliseconds since Unix epoch
1261
+ * @returns true if the date is a weekday and not a holiday
1262
+ * @param {number} timestamp_ms
1263
+ * @returns {boolean}
1045
1264
  */
1046
- get lower() {
1047
- const ret = wasm.forecast_lower(this.__wbg_ptr);
1048
- let v1;
1049
- if (ret[0] !== 0) {
1050
- v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1051
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1052
- }
1053
- return v1;
1265
+ isBusinessDay(timestamp_ms) {
1266
+ const ret = wasm.calendarannotations_isBusinessDay(this.__wbg_ptr, timestamp_ms);
1267
+ return ret !== 0;
1054
1268
  }
1055
1269
  /**
1056
- * Get upper prediction interval bounds.
1057
- *
1058
- * @returns Array of upper bounds, or undefined if not available
1059
- * @returns {Float64Array | undefined}
1270
+ * Get the number of named regressors.
1271
+ * @returns {number}
1060
1272
  */
1061
- get upper() {
1062
- const ret = wasm.forecast_upper(this.__wbg_ptr);
1063
- let v1;
1064
- if (ret[0] !== 0) {
1065
- v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1066
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1067
- }
1068
- return v1;
1273
+ regressorCount() {
1274
+ const ret = wasm.calendarannotations_regressorCount(this.__wbg_ptr);
1275
+ return ret >>> 0;
1069
1276
  }
1070
1277
  /**
1071
- * Get point predictions.
1072
- * @returns {Float64Array}
1278
+ * Get the names of all registered regressors.
1279
+ * @returns {any}
1073
1280
  */
1074
- get values() {
1075
- const ret = wasm.forecast_values(this.__wbg_ptr);
1076
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1077
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1078
- return v1;
1281
+ regressorNames() {
1282
+ const ret = wasm.calendarannotations_regressorNames(this.__wbg_ptr);
1283
+ if (ret[2]) {
1284
+ throw takeFromExternrefTable0(ret[1]);
1285
+ }
1286
+ return takeFromExternrefTable0(ret[0]);
1079
1287
  }
1080
1288
  /**
1081
- * Get the forecast horizon (number of predictions).
1082
- * @returns {number}
1289
+ * Create an empty CalendarAnnotations instance.
1083
1290
  */
1084
- get horizon() {
1085
- const ret = wasm.forecast_horizon(this.__wbg_ptr);
1086
- return ret >>> 0;
1291
+ constructor() {
1292
+ const ret = wasm.calendarannotations_new();
1293
+ this.__wbg_ptr = ret >>> 0;
1294
+ CalendarAnnotationsFinalization.register(this, this.__wbg_ptr, this);
1295
+ return this;
1087
1296
  }
1088
1297
  /**
1089
- * Check if lower prediction interval is available.
1090
- * @returns {boolean}
1298
+ * Serialize the calendar annotations to a JSON string.
1299
+ *
1300
+ * Useful for persisting or transferring annotations between contexts.
1301
+ *
1302
+ * @returns JSON string with `{ holidays: number[], regressors: { [name]: number[] } }`
1303
+ * @returns {string}
1091
1304
  */
1092
- hasLower() {
1093
- const ret = wasm.forecast_hasLower(this.__wbg_ptr);
1094
- return ret !== 0;
1305
+ toJSON() {
1306
+ let deferred2_0;
1307
+ let deferred2_1;
1308
+ try {
1309
+ const ret = wasm.calendarannotations_toJSON(this.__wbg_ptr);
1310
+ var ptr1 = ret[0];
1311
+ var len1 = ret[1];
1312
+ if (ret[3]) {
1313
+ ptr1 = 0; len1 = 0;
1314
+ throw takeFromExternrefTable0(ret[2]);
1315
+ }
1316
+ deferred2_0 = ptr1;
1317
+ deferred2_1 = len1;
1318
+ return getStringFromWasm0(ptr1, len1);
1319
+ } finally {
1320
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1321
+ }
1095
1322
  }
1096
1323
  /**
1097
- * Check if upper prediction interval is available.
1098
- * @returns {boolean}
1324
+ * Deserialize calendar annotations from a JSON string.
1325
+ *
1326
+ * @param json - JSON string produced by `toJSON()`
1327
+ * @returns A new CalendarAnnotations instance
1328
+ * @param {string} json
1329
+ * @returns {CalendarAnnotations}
1099
1330
  */
1100
- hasUpper() {
1101
- const ret = wasm.forecast_hasUpper(this.__wbg_ptr);
1102
- return ret !== 0;
1331
+ static fromJSON(json) {
1332
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1333
+ const len0 = WASM_VECTOR_LEN;
1334
+ const ret = wasm.calendarannotations_fromJSON(ptr0, len0);
1335
+ if (ret[2]) {
1336
+ throw takeFromExternrefTable0(ret[1]);
1337
+ }
1338
+ return CalendarAnnotations.__wrap(ret[0]);
1103
1339
  }
1104
1340
  }
1105
- if (Symbol.dispose) Forecast.prototype[Symbol.dispose] = Forecast.prototype.free;
1341
+ if (Symbol.dispose) CalendarAnnotations.prototype[Symbol.dispose] = CalendarAnnotations.prototype.free;
1106
1342
 
1107
1343
  /**
1108
- * GARCH - Generalized Autoregressive Conditional Heteroskedasticity.
1344
+ * Croston's method for intermittent demand forecasting.
1109
1345
  */
1110
- export class GARCHForecaster {
1346
+ export class CrostonForecaster {
1111
1347
  __destroy_into_raw() {
1112
1348
  const ptr = this.__wbg_ptr;
1113
1349
  this.__wbg_ptr = 0;
1114
- GARCHForecasterFinalization.unregister(this);
1350
+ CrostonForecasterFinalization.unregister(this);
1115
1351
  return ptr;
1116
1352
  }
1117
1353
  free() {
1118
1354
  const ptr = this.__destroy_into_raw();
1119
- wasm.__wbg_garchforecaster_free(ptr, 0);
1355
+ wasm.__wbg_crostonforecaster_free(ptr, 0);
1356
+ }
1357
+ /**
1358
+ * @param {number} horizon
1359
+ * @param {number} level
1360
+ * @returns {Forecast}
1361
+ */
1362
+ predictWithIntervals(horizon, level) {
1363
+ const ret = wasm.crostonforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
1364
+ if (ret[2]) {
1365
+ throw takeFromExternrefTable0(ret[1]);
1366
+ }
1367
+ return Forecast.__wrap(ret[0]);
1120
1368
  }
1121
1369
  /**
1122
1370
  * @param {TimeSeries} series
1123
1371
  */
1124
1372
  fit(series) {
1125
1373
  _assertClass(series, TimeSeries);
1126
- const ret = wasm.garchforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1374
+ const ret = wasm.crostonforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1127
1375
  if (ret[1]) {
1128
1376
  throw takeFromExternrefTable0(ret[0]);
1129
1377
  }
1130
1378
  }
1131
- /**
1132
- * @param p - GARCH order (lagged variance terms)
1133
- * @param q - ARCH order (lagged squared residuals)
1134
- * @param {number} p
1135
- * @param {number} q
1136
- */
1137
- constructor(p, q) {
1138
- const ret = wasm.garchforecaster_new(p, q);
1379
+ constructor() {
1380
+ const ret = wasm.crostonforecaster_new();
1139
1381
  this.__wbg_ptr = ret >>> 0;
1140
- GARCHForecasterFinalization.register(this, this.__wbg_ptr, this);
1382
+ CrostonForecasterFinalization.register(this, this.__wbg_ptr, this);
1141
1383
  return this;
1142
1384
  }
1143
1385
  /**
@@ -1147,7 +1389,7 @@ export class GARCHForecaster {
1147
1389
  let deferred1_0;
1148
1390
  let deferred1_1;
1149
1391
  try {
1150
- const ret = wasm.garchforecaster_name(this.__wbg_ptr);
1392
+ const ret = wasm.crostonforecaster_name(this.__wbg_ptr);
1151
1393
  deferred1_0 = ret[0];
1152
1394
  deferred1_1 = ret[1];
1153
1395
  return getStringFromWasm0(ret[0], ret[1]);
@@ -1160,49 +1402,66 @@ export class GARCHForecaster {
1160
1402
  * @returns {Forecast}
1161
1403
  */
1162
1404
  predict(horizon) {
1163
- const ret = wasm.garchforecaster_predict(this.__wbg_ptr, horizon);
1405
+ const ret = wasm.crostonforecaster_predict(this.__wbg_ptr, horizon);
1164
1406
  if (ret[2]) {
1165
1407
  throw takeFromExternrefTable0(ret[1]);
1166
1408
  }
1167
1409
  return Forecast.__wrap(ret[0]);
1168
1410
  }
1169
1411
  }
1170
- if (Symbol.dispose) GARCHForecaster.prototype[Symbol.dispose] = GARCHForecaster.prototype.free;
1412
+ if (Symbol.dispose) CrostonForecaster.prototype[Symbol.dispose] = CrostonForecaster.prototype.free;
1171
1413
 
1172
1414
  /**
1173
- * Holt Linear Trend (Double Exponential Smoothing) forecaster.
1415
+ * Dynamic Theta forecaster - updates coefficients dynamically.
1174
1416
  */
1175
- export class HoltForecaster {
1417
+ export class DynamicThetaForecaster {
1418
+ static __wrap(ptr) {
1419
+ ptr = ptr >>> 0;
1420
+ const obj = Object.create(DynamicThetaForecaster.prototype);
1421
+ obj.__wbg_ptr = ptr;
1422
+ DynamicThetaForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
1423
+ return obj;
1424
+ }
1176
1425
  __destroy_into_raw() {
1177
1426
  const ptr = this.__wbg_ptr;
1178
1427
  this.__wbg_ptr = 0;
1179
- HoltForecasterFinalization.unregister(this);
1428
+ DynamicThetaForecasterFinalization.unregister(this);
1180
1429
  return ptr;
1181
1430
  }
1182
1431
  free() {
1183
1432
  const ptr = this.__destroy_into_raw();
1184
- wasm.__wbg_holtforecaster_free(ptr, 0);
1433
+ wasm.__wbg_dynamicthetaforecaster_free(ptr, 0);
1434
+ }
1435
+ /**
1436
+ * @param {number} horizon
1437
+ * @param {number} level
1438
+ * @returns {Forecast}
1439
+ */
1440
+ predictWithIntervals(horizon, level) {
1441
+ const ret = wasm.dynamicthetaforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
1442
+ if (ret[2]) {
1443
+ throw takeFromExternrefTable0(ret[1]);
1444
+ }
1445
+ return Forecast.__wrap(ret[0]);
1185
1446
  }
1186
1447
  /**
1187
1448
  * @param {TimeSeries} series
1188
1449
  */
1189
1450
  fit(series) {
1190
1451
  _assertClass(series, TimeSeries);
1191
- const ret = wasm.holtforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1452
+ const ret = wasm.dynamicthetaforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1192
1453
  if (ret[1]) {
1193
1454
  throw takeFromExternrefTable0(ret[0]);
1194
1455
  }
1195
1456
  }
1196
1457
  /**
1197
- * @param alpha - Level smoothing parameter (0 < alpha <= 1)
1198
- * @param beta - Trend smoothing parameter (0 < beta <= 1)
1458
+ * @param alpha - Smoothing parameter for the forecast
1199
1459
  * @param {number} alpha
1200
- * @param {number} beta
1201
1460
  */
1202
- constructor(alpha, beta) {
1203
- const ret = wasm.holtforecaster_new(alpha, beta);
1461
+ constructor(alpha) {
1462
+ const ret = wasm.dynamicthetaforecaster_new(alpha);
1204
1463
  this.__wbg_ptr = ret >>> 0;
1205
- HoltForecasterFinalization.register(this, this.__wbg_ptr, this);
1464
+ DynamicThetaForecasterFinalization.register(this, this.__wbg_ptr, this);
1206
1465
  return this;
1207
1466
  }
1208
1467
  /**
@@ -1212,7 +1471,7 @@ export class HoltForecaster {
1212
1471
  let deferred1_0;
1213
1472
  let deferred1_1;
1214
1473
  try {
1215
- const ret = wasm.holtforecaster_name(this.__wbg_ptr);
1474
+ const ret = wasm.dynamicthetaforecaster_name(this.__wbg_ptr);
1216
1475
  deferred1_0 = ret[0];
1217
1476
  deferred1_1 = ret[1];
1218
1477
  return getStringFromWasm0(ret[0], ret[1]);
@@ -1225,91 +1484,157 @@ export class HoltForecaster {
1225
1484
  * @returns {Forecast}
1226
1485
  */
1227
1486
  predict(horizon) {
1228
- const ret = wasm.holtforecaster_predict(this.__wbg_ptr, horizon);
1487
+ const ret = wasm.dynamicthetaforecaster_predict(this.__wbg_ptr, horizon);
1229
1488
  if (ret[2]) {
1230
1489
  throw takeFromExternrefTable0(ret[1]);
1231
1490
  }
1232
1491
  return Forecast.__wrap(ret[0]);
1233
1492
  }
1493
+ /**
1494
+ * Create a seasonal Dynamic Theta model.
1495
+ * @param period - Seasonal period
1496
+ * @param {number} period
1497
+ * @returns {DynamicThetaForecaster}
1498
+ */
1499
+ static seasonal(period) {
1500
+ const ret = wasm.dynamicthetaforecaster_seasonal(period);
1501
+ return DynamicThetaForecaster.__wrap(ret);
1502
+ }
1503
+ /**
1504
+ * Create an optimized Dynamic Theta model.
1505
+ * @returns {DynamicThetaForecaster}
1506
+ */
1507
+ static optimized() {
1508
+ const ret = wasm.dynamicthetaforecaster_optimized();
1509
+ return DynamicThetaForecaster.__wrap(ret);
1510
+ }
1234
1511
  }
1235
- if (Symbol.dispose) HoltForecaster.prototype[Symbol.dispose] = HoltForecaster.prototype.free;
1512
+ if (Symbol.dispose) DynamicThetaForecaster.prototype[Symbol.dispose] = DynamicThetaForecaster.prototype.free;
1236
1513
 
1237
1514
  /**
1238
- * Holt-Winters (Triple Exponential Smoothing) forecaster.
1515
+ * ETS (Error-Trend-Seasonal) state-space model.
1516
+ *
1517
+ * Use string codes: "A" = Additive, "M" = Multiplicative, "N" = None
1518
+ * Or use standard ETS notation like "ANN", "AAA", "MAM", "AAdM".
1519
+ *
1520
+ * Follows the ETS taxonomy from FPP3: <https://otexts.com/fpp3/taxonomy.html>
1521
+ *
1522
+ * Note: Some combinations are invalid/unstable per FPP3:
1523
+ * - MAA (Multiplicative error + Additive trend + Additive seasonal)
1524
+ * - MAdA (Multiplicative error + Damped trend + Additive seasonal)
1239
1525
  */
1240
- export class HoltWintersForecaster {
1526
+ export class ETSForecaster {
1241
1527
  static __wrap(ptr) {
1242
1528
  ptr = ptr >>> 0;
1243
- const obj = Object.create(HoltWintersForecaster.prototype);
1529
+ const obj = Object.create(ETSForecaster.prototype);
1244
1530
  obj.__wbg_ptr = ptr;
1245
- HoltWintersForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
1531
+ ETSForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
1246
1532
  return obj;
1247
1533
  }
1248
1534
  __destroy_into_raw() {
1249
1535
  const ptr = this.__wbg_ptr;
1250
1536
  this.__wbg_ptr = 0;
1251
- HoltWintersForecasterFinalization.unregister(this);
1537
+ ETSForecasterFinalization.unregister(this);
1252
1538
  return ptr;
1253
1539
  }
1254
1540
  free() {
1255
1541
  const ptr = this.__destroy_into_raw();
1256
- wasm.__wbg_holtwintersforecaster_free(ptr, 0);
1542
+ wasm.__wbg_etsforecaster_free(ptr, 0);
1257
1543
  }
1258
1544
  /**
1259
- * Create with multiplicative seasonality.
1260
- * @param {number} alpha
1261
- * @param {number} beta
1262
- * @param {number} gamma
1545
+ * Create an ETS model from standard notation.
1546
+ *
1547
+ * @param notation - ETS notation string like "ANN", "AAA", "MAM", "AAdM"
1548
+ * @param period - Seasonal period (required if notation has seasonal component)
1549
+ *
1550
+ * Format: ErrorTrendSeasonal
1551
+ * - Error: A (additive) or M (multiplicative)
1552
+ * - Trend: N (none), A (additive), or Ad (additive damped)
1553
+ * - Seasonal: N (none), A (additive), or M (multiplicative)
1554
+ *
1555
+ * Examples:
1556
+ * - "ANN" - Simple exponential smoothing
1557
+ * - "AAN" - Holt's linear method
1558
+ * - "AAA" - Holt-Winters additive
1559
+ * - "MAM" - Multiplicative Holt-Winters
1560
+ * - "AAdM" - Damped trend with multiplicative seasonal
1561
+ *
1562
+ * @throws Error for invalid notation or unstable combinations (MAA, MAdA)
1563
+ * @param {string} notation
1263
1564
  * @param {number} period
1264
- * @returns {HoltWintersForecaster}
1565
+ * @returns {ETSForecaster}
1265
1566
  */
1266
- static multiplicative(alpha, beta, gamma, period) {
1267
- const ret = wasm.holtwintersforecaster_multiplicative(alpha, beta, gamma, period);
1268
- return HoltWintersForecaster.__wrap(ret);
1567
+ static fromNotation(notation, period) {
1568
+ const ptr0 = passStringToWasm0(notation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1569
+ const len0 = WASM_VECTOR_LEN;
1570
+ const ret = wasm.etsforecaster_fromNotation(ptr0, len0, period);
1571
+ if (ret[2]) {
1572
+ throw takeFromExternrefTable0(ret[1]);
1573
+ }
1574
+ return ETSForecaster.__wrap(ret[0]);
1575
+ }
1576
+ /**
1577
+ * Check if an ETS specification is valid/stable.
1578
+ *
1579
+ * @param error - Error type: "A" or "M"
1580
+ * @param trend - Trend type: "N", "A", or "Ad"
1581
+ * @param seasonal - Seasonal type: "N", "A", or "M"
1582
+ * @returns true if the combination is stable and usable
1583
+ *
1584
+ * Invalid combinations (return false):
1585
+ * - M,A,A - Multiplicative error with additive trend and additive seasonal
1586
+ * - M,Ad,A - Multiplicative error with damped trend and additive seasonal
1587
+ * @param {string} error
1588
+ * @param {string} trend
1589
+ * @param {string} seasonal
1590
+ * @returns {boolean}
1591
+ */
1592
+ static isValidSpec(error, trend, seasonal) {
1593
+ const ptr0 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1594
+ const len0 = WASM_VECTOR_LEN;
1595
+ const ptr1 = passStringToWasm0(trend, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1596
+ const len1 = WASM_VECTOR_LEN;
1597
+ const ptr2 = passStringToWasm0(seasonal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1598
+ const len2 = WASM_VECTOR_LEN;
1599
+ const ret = wasm.etsforecaster_isValidSpec(ptr0, len0, ptr1, len1, ptr2, len2);
1600
+ return ret !== 0;
1269
1601
  }
1270
1602
  /**
1271
1603
  * @param {TimeSeries} series
1272
1604
  */
1273
1605
  fit(series) {
1274
1606
  _assertClass(series, TimeSeries);
1275
- const ret = wasm.holtwintersforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1607
+ const ret = wasm.etsforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1276
1608
  if (ret[1]) {
1277
1609
  throw takeFromExternrefTable0(ret[0]);
1278
1610
  }
1279
1611
  }
1280
1612
  /**
1281
- * Create with additive seasonality.
1282
- * @param alpha - Level smoothing parameter
1283
- * @param beta - Trend smoothing parameter
1284
- * @param gamma - Seasonal smoothing parameter
1285
- * @param period - Seasonal period
1286
- * @param {number} alpha
1287
- * @param {number} beta
1288
- * @param {number} gamma
1289
- * @param {number} period
1290
- */
1291
- constructor(alpha, beta, gamma, period) {
1292
- const ret = wasm.holtwintersforecaster_new(alpha, beta, gamma, period);
1293
- this.__wbg_ptr = ret >>> 0;
1294
- HoltWintersForecasterFinalization.register(this, this.__wbg_ptr, this);
1295
- return this;
1296
- }
1297
- /**
1298
- * Create with automatic parameter optimization.
1299
- * @param period - Seasonal period
1300
- * @param seasonal_type - "additive" or "multiplicative"
1613
+ * Create an ETS model with specified components.
1614
+ * @param error - Error type: "A" (additive) or "M" (multiplicative)
1615
+ * @param trend - Trend type: "N" (none), "A" (additive), or "Ad" (additive damped)
1616
+ * @param seasonal - Seasonal type: "N" (none), "A" (additive), or "M" (multiplicative)
1617
+ * @param period - Seasonal period (ignored if seasonal is "N")
1618
+ * @throws Error if the combination is unstable (MAA or MAdA)
1619
+ * @param {string} error
1620
+ * @param {string} trend
1621
+ * @param {string} seasonal
1301
1622
  * @param {number} period
1302
- * @param {string} seasonal_type
1303
- * @returns {HoltWintersForecaster}
1304
1623
  */
1305
- static auto(period, seasonal_type) {
1306
- const ptr0 = passStringToWasm0(seasonal_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1624
+ constructor(error, trend, seasonal, period) {
1625
+ const ptr0 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1307
1626
  const len0 = WASM_VECTOR_LEN;
1308
- const ret = wasm.holtwintersforecaster_auto(period, ptr0, len0);
1627
+ const ptr1 = passStringToWasm0(trend, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1628
+ const len1 = WASM_VECTOR_LEN;
1629
+ const ptr2 = passStringToWasm0(seasonal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1630
+ const len2 = WASM_VECTOR_LEN;
1631
+ const ret = wasm.etsforecaster_new(ptr0, len0, ptr1, len1, ptr2, len2, period);
1309
1632
  if (ret[2]) {
1310
1633
  throw takeFromExternrefTable0(ret[1]);
1311
1634
  }
1312
- return HoltWintersForecaster.__wrap(ret[0]);
1635
+ this.__wbg_ptr = ret[0] >>> 0;
1636
+ ETSForecasterFinalization.register(this, this.__wbg_ptr, this);
1637
+ return this;
1313
1638
  }
1314
1639
  /**
1315
1640
  * @returns {string}
@@ -1318,7 +1643,7 @@ export class HoltWintersForecaster {
1318
1643
  let deferred1_0;
1319
1644
  let deferred1_1;
1320
1645
  try {
1321
- const ret = wasm.holtwintersforecaster_name(this.__wbg_ptr);
1646
+ const ret = wasm.etsforecaster_name(this.__wbg_ptr);
1322
1647
  deferred1_0 = ret[0];
1323
1648
  deferred1_1 = ret[1];
1324
1649
  return getStringFromWasm0(ret[0], ret[1]);
@@ -1331,53 +1656,124 @@ export class HoltWintersForecaster {
1331
1656
  * @returns {Forecast}
1332
1657
  */
1333
1658
  predict(horizon) {
1334
- const ret = wasm.holtwintersforecaster_predict(this.__wbg_ptr, horizon);
1659
+ const ret = wasm.etsforecaster_predict(this.__wbg_ptr, horizon);
1335
1660
  if (ret[2]) {
1336
1661
  throw takeFromExternrefTable0(ret[1]);
1337
1662
  }
1338
1663
  return Forecast.__wrap(ret[0]);
1339
1664
  }
1340
1665
  }
1341
- if (Symbol.dispose) HoltWintersForecaster.prototype[Symbol.dispose] = HoltWintersForecaster.prototype.free;
1666
+ if (Symbol.dispose) ETSForecaster.prototype[Symbol.dispose] = ETSForecaster.prototype.free;
1342
1667
 
1343
1668
  /**
1344
- * IMAPA (Intermittent Multiple Aggregation Prediction Algorithm).
1669
+ * Ensemble forecaster that combines multiple models.
1670
+ *
1671
+ * Supports mean, median, weighted MSE, and custom-weight combination.
1672
+ * Models are specified by name strings (e.g., "naive", "sma5", "ses").
1345
1673
  */
1346
- export class IMAPAForecaster {
1674
+ export class EnsembleForecaster {
1347
1675
  __destroy_into_raw() {
1348
1676
  const ptr = this.__wbg_ptr;
1349
1677
  this.__wbg_ptr = 0;
1350
- IMAPAForecasterFinalization.unregister(this);
1678
+ EnsembleForecasterFinalization.unregister(this);
1351
1679
  return ptr;
1352
1680
  }
1353
1681
  free() {
1354
1682
  const ptr = this.__destroy_into_raw();
1355
- wasm.__wbg_imapaforecaster_free(ptr, 0);
1683
+ wasm.__wbg_ensembleforecaster_free(ptr, 0);
1684
+ }
1685
+ /**
1686
+ * Set the combination method to median.
1687
+ */
1688
+ setMedian() {
1689
+ wasm.ensembleforecaster_setMedian(this.__wbg_ptr);
1690
+ }
1691
+ /**
1692
+ * Get the number of models in the ensemble.
1693
+ * @returns {number}
1694
+ */
1695
+ modelCount() {
1696
+ const ret = wasm.ensembleforecaster_modelCount(this.__wbg_ptr);
1697
+ return ret >>> 0;
1698
+ }
1699
+ /**
1700
+ * Set custom combination weights.
1701
+ *
1702
+ * Weights are normalized to sum to 1. Length must match number of models.
1703
+ *
1704
+ * @param weights - Array of combination weights
1705
+ * @param {Float64Array} weights
1706
+ */
1707
+ setWeights(weights) {
1708
+ const ptr0 = passArrayF64ToWasm0(weights, wasm.__wbindgen_malloc);
1709
+ const len0 = WASM_VECTOR_LEN;
1710
+ wasm.ensembleforecaster_setWeights(this.__wbg_ptr, ptr0, len0);
1711
+ }
1712
+ /**
1713
+ * Set the combination method to weighted MSE.
1714
+ */
1715
+ setWeightedMse() {
1716
+ wasm.ensembleforecaster_setWeightedMse(this.__wbg_ptr);
1717
+ }
1718
+ /**
1719
+ * Predict with prediction intervals.
1720
+ *
1721
+ * @param horizon - Number of steps to forecast
1722
+ * @param level - Confidence level (e.g., 0.95 for 95% intervals)
1723
+ * @returns Forecast with combined predictions and intervals
1724
+ * @param {number} horizon
1725
+ * @param {number} level
1726
+ * @returns {Forecast}
1727
+ */
1728
+ predictWithIntervals(horizon, level) {
1729
+ const ret = wasm.ensembleforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
1730
+ if (ret[2]) {
1731
+ throw takeFromExternrefTable0(ret[1]);
1732
+ }
1733
+ return Forecast.__wrap(ret[0]);
1356
1734
  }
1357
1735
  /**
1736
+ * Fit all models in the ensemble.
1737
+ *
1738
+ * @param series - TimeSeries to fit
1358
1739
  * @param {TimeSeries} series
1359
1740
  */
1360
1741
  fit(series) {
1361
1742
  _assertClass(series, TimeSeries);
1362
- const ret = wasm.imapaforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1743
+ const ret = wasm.ensembleforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1363
1744
  if (ret[1]) {
1364
1745
  throw takeFromExternrefTable0(ret[0]);
1365
1746
  }
1366
1747
  }
1367
- constructor() {
1368
- const ret = wasm.imapaforecaster_new();
1369
- this.__wbg_ptr = ret >>> 0;
1370
- IMAPAForecasterFinalization.register(this, this.__wbg_ptr, this);
1748
+ /**
1749
+ * Create an ensemble from an array of model name strings.
1750
+ *
1751
+ * Supported names: "naive", "mean", "rwdrift", "ses", "holt",
1752
+ * "autoarima", "autoets", "autotheta", "sma5", "wa10", etc.
1753
+ *
1754
+ * @param modelNames - Array of model name strings
1755
+ * @param {string[]} model_names
1756
+ */
1757
+ constructor(model_names) {
1758
+ const ptr0 = passArrayJsValueToWasm0(model_names, wasm.__wbindgen_malloc);
1759
+ const len0 = WASM_VECTOR_LEN;
1760
+ const ret = wasm.ensembleforecaster_new(ptr0, len0);
1761
+ if (ret[2]) {
1762
+ throw takeFromExternrefTable0(ret[1]);
1763
+ }
1764
+ this.__wbg_ptr = ret[0] >>> 0;
1765
+ EnsembleForecasterFinalization.register(this, this.__wbg_ptr, this);
1371
1766
  return this;
1372
1767
  }
1373
1768
  /**
1769
+ * Get the model name.
1374
1770
  * @returns {string}
1375
1771
  */
1376
1772
  get name() {
1377
1773
  let deferred1_0;
1378
1774
  let deferred1_1;
1379
1775
  try {
1380
- const ret = wasm.imapaforecaster_name(this.__wbg_ptr);
1776
+ const ret = wasm.ensembleforecaster_name(this.__wbg_ptr);
1381
1777
  deferred1_0 = ret[0];
1382
1778
  deferred1_1 = ret[1];
1383
1779
  return getStringFromWasm0(ret[0], ret[1]);
@@ -1386,22 +1782,1264 @@ export class IMAPAForecaster {
1386
1782
  }
1387
1783
  }
1388
1784
  /**
1785
+ * Predict future values using the combined ensemble.
1786
+ *
1787
+ * @param horizon - Number of steps to forecast
1788
+ * @returns Forecast with combined point predictions
1389
1789
  * @param {number} horizon
1390
1790
  * @returns {Forecast}
1391
1791
  */
1392
1792
  predict(horizon) {
1393
- const ret = wasm.imapaforecaster_predict(this.__wbg_ptr, horizon);
1793
+ const ret = wasm.ensembleforecaster_predict(this.__wbg_ptr, horizon);
1394
1794
  if (ret[2]) {
1395
1795
  throw takeFromExternrefTable0(ret[1]);
1396
1796
  }
1397
1797
  return Forecast.__wrap(ret[0]);
1398
1798
  }
1399
1799
  }
1400
- if (Symbol.dispose) IMAPAForecaster.prototype[Symbol.dispose] = IMAPAForecaster.prototype.free;
1800
+ if (Symbol.dispose) EnsembleForecaster.prototype[Symbol.dispose] = EnsembleForecaster.prototype.free;
1401
1801
 
1402
1802
  /**
1403
- * MFLES - Multiple Frequency Locally Estimated Scatterplot Smoothing.
1404
- */
1803
+ * Forecast result wrapper for JavaScript.
1804
+ *
1805
+ * Contains point predictions and optional prediction intervals.
1806
+ */
1807
+ export class Forecast {
1808
+ static __wrap(ptr) {
1809
+ ptr = ptr >>> 0;
1810
+ const obj = Object.create(Forecast.prototype);
1811
+ obj.__wbg_ptr = ptr;
1812
+ ForecastFinalization.register(obj, obj.__wbg_ptr, obj);
1813
+ return obj;
1814
+ }
1815
+ __destroy_into_raw() {
1816
+ const ptr = this.__wbg_ptr;
1817
+ this.__wbg_ptr = 0;
1818
+ ForecastFinalization.unregister(this);
1819
+ return ptr;
1820
+ }
1821
+ free() {
1822
+ const ptr = this.__destroy_into_raw();
1823
+ wasm.__wbg_forecast_free(ptr, 0);
1824
+ }
1825
+ /**
1826
+ * Get lower prediction interval bounds.
1827
+ *
1828
+ * @returns Array of lower bounds, or undefined if not available
1829
+ * @returns {Float64Array | undefined}
1830
+ */
1831
+ get lower() {
1832
+ const ret = wasm.forecast_lower(this.__wbg_ptr);
1833
+ let v1;
1834
+ if (ret[0] !== 0) {
1835
+ v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1836
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1837
+ }
1838
+ return v1;
1839
+ }
1840
+ /**
1841
+ * Get upper prediction interval bounds.
1842
+ *
1843
+ * @returns Array of upper bounds, or undefined if not available
1844
+ * @returns {Float64Array | undefined}
1845
+ */
1846
+ get upper() {
1847
+ const ret = wasm.forecast_upper(this.__wbg_ptr);
1848
+ let v1;
1849
+ if (ret[0] !== 0) {
1850
+ v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1851
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1852
+ }
1853
+ return v1;
1854
+ }
1855
+ /**
1856
+ * Get point predictions.
1857
+ * @returns {Float64Array}
1858
+ */
1859
+ get values() {
1860
+ const ret = wasm.forecast_values(this.__wbg_ptr);
1861
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1862
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1863
+ return v1;
1864
+ }
1865
+ /**
1866
+ * Get the forecast horizon (number of predictions).
1867
+ * @returns {number}
1868
+ */
1869
+ get horizon() {
1870
+ const ret = wasm.forecast_horizon(this.__wbg_ptr);
1871
+ return ret >>> 0;
1872
+ }
1873
+ /**
1874
+ * Check if lower prediction interval is available.
1875
+ * @returns {boolean}
1876
+ */
1877
+ hasLower() {
1878
+ const ret = wasm.forecast_hasLower(this.__wbg_ptr);
1879
+ return ret !== 0;
1880
+ }
1881
+ /**
1882
+ * Check if upper prediction interval is available.
1883
+ * @returns {boolean}
1884
+ */
1885
+ hasUpper() {
1886
+ const ret = wasm.forecast_hasUpper(this.__wbg_ptr);
1887
+ return ret !== 0;
1888
+ }
1889
+ }
1890
+ if (Symbol.dispose) Forecast.prototype[Symbol.dispose] = Forecast.prototype.free;
1891
+
1892
+ /**
1893
+ * GARCH - Generalized Autoregressive Conditional Heteroskedasticity.
1894
+ */
1895
+ export class GARCHForecaster {
1896
+ __destroy_into_raw() {
1897
+ const ptr = this.__wbg_ptr;
1898
+ this.__wbg_ptr = 0;
1899
+ GARCHForecasterFinalization.unregister(this);
1900
+ return ptr;
1901
+ }
1902
+ free() {
1903
+ const ptr = this.__destroy_into_raw();
1904
+ wasm.__wbg_garchforecaster_free(ptr, 0);
1905
+ }
1906
+ /**
1907
+ * @param {number} horizon
1908
+ * @param {number} level
1909
+ * @returns {Forecast}
1910
+ */
1911
+ predictWithIntervals(horizon, level) {
1912
+ const ret = wasm.garchforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
1913
+ if (ret[2]) {
1914
+ throw takeFromExternrefTable0(ret[1]);
1915
+ }
1916
+ return Forecast.__wrap(ret[0]);
1917
+ }
1918
+ /**
1919
+ * @param {TimeSeries} series
1920
+ */
1921
+ fit(series) {
1922
+ _assertClass(series, TimeSeries);
1923
+ const ret = wasm.garchforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
1924
+ if (ret[1]) {
1925
+ throw takeFromExternrefTable0(ret[0]);
1926
+ }
1927
+ }
1928
+ /**
1929
+ * @param p - GARCH order (lagged variance terms)
1930
+ * @param q - ARCH order (lagged squared residuals)
1931
+ * @param {number} p
1932
+ * @param {number} q
1933
+ */
1934
+ constructor(p, q) {
1935
+ const ret = wasm.garchforecaster_new(p, q);
1936
+ this.__wbg_ptr = ret >>> 0;
1937
+ GARCHForecasterFinalization.register(this, this.__wbg_ptr, this);
1938
+ return this;
1939
+ }
1940
+ /**
1941
+ * @returns {string}
1942
+ */
1943
+ get name() {
1944
+ let deferred1_0;
1945
+ let deferred1_1;
1946
+ try {
1947
+ const ret = wasm.garchforecaster_name(this.__wbg_ptr);
1948
+ deferred1_0 = ret[0];
1949
+ deferred1_1 = ret[1];
1950
+ return getStringFromWasm0(ret[0], ret[1]);
1951
+ } finally {
1952
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1953
+ }
1954
+ }
1955
+ /**
1956
+ * @param {number} horizon
1957
+ * @returns {Forecast}
1958
+ */
1959
+ predict(horizon) {
1960
+ const ret = wasm.garchforecaster_predict(this.__wbg_ptr, horizon);
1961
+ if (ret[2]) {
1962
+ throw takeFromExternrefTable0(ret[1]);
1963
+ }
1964
+ return Forecast.__wrap(ret[0]);
1965
+ }
1966
+ }
1967
+ if (Symbol.dispose) GARCHForecaster.prototype[Symbol.dispose] = GARCHForecaster.prototype.free;
1968
+
1969
+ /**
1970
+ * Holt Linear Trend (Double Exponential Smoothing) forecaster.
1971
+ */
1972
+ export class HoltForecaster {
1973
+ __destroy_into_raw() {
1974
+ const ptr = this.__wbg_ptr;
1975
+ this.__wbg_ptr = 0;
1976
+ HoltForecasterFinalization.unregister(this);
1977
+ return ptr;
1978
+ }
1979
+ free() {
1980
+ const ptr = this.__destroy_into_raw();
1981
+ wasm.__wbg_holtforecaster_free(ptr, 0);
1982
+ }
1983
+ /**
1984
+ * @param {number} horizon
1985
+ * @param {number} level
1986
+ * @returns {Forecast}
1987
+ */
1988
+ predictWithIntervals(horizon, level) {
1989
+ const ret = wasm.holtforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
1990
+ if (ret[2]) {
1991
+ throw takeFromExternrefTable0(ret[1]);
1992
+ }
1993
+ return Forecast.__wrap(ret[0]);
1994
+ }
1995
+ /**
1996
+ * @param {TimeSeries} series
1997
+ */
1998
+ fit(series) {
1999
+ _assertClass(series, TimeSeries);
2000
+ const ret = wasm.holtforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
2001
+ if (ret[1]) {
2002
+ throw takeFromExternrefTable0(ret[0]);
2003
+ }
2004
+ }
2005
+ /**
2006
+ * @param alpha - Level smoothing parameter (0 < alpha <= 1)
2007
+ * @param beta - Trend smoothing parameter (0 < beta <= 1)
2008
+ * @param {number} alpha
2009
+ * @param {number} beta
2010
+ */
2011
+ constructor(alpha, beta) {
2012
+ const ret = wasm.holtforecaster_new(alpha, beta);
2013
+ this.__wbg_ptr = ret >>> 0;
2014
+ HoltForecasterFinalization.register(this, this.__wbg_ptr, this);
2015
+ return this;
2016
+ }
2017
+ /**
2018
+ * @returns {string}
2019
+ */
2020
+ get name() {
2021
+ let deferred1_0;
2022
+ let deferred1_1;
2023
+ try {
2024
+ const ret = wasm.holtforecaster_name(this.__wbg_ptr);
2025
+ deferred1_0 = ret[0];
2026
+ deferred1_1 = ret[1];
2027
+ return getStringFromWasm0(ret[0], ret[1]);
2028
+ } finally {
2029
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2030
+ }
2031
+ }
2032
+ /**
2033
+ * @param {number} horizon
2034
+ * @returns {Forecast}
2035
+ */
2036
+ predict(horizon) {
2037
+ const ret = wasm.holtforecaster_predict(this.__wbg_ptr, horizon);
2038
+ if (ret[2]) {
2039
+ throw takeFromExternrefTable0(ret[1]);
2040
+ }
2041
+ return Forecast.__wrap(ret[0]);
2042
+ }
2043
+ }
2044
+ if (Symbol.dispose) HoltForecaster.prototype[Symbol.dispose] = HoltForecaster.prototype.free;
2045
+
2046
+ /**
2047
+ * Holt-Winters (Triple Exponential Smoothing) forecaster.
2048
+ */
2049
+ export class HoltWintersForecaster {
2050
+ static __wrap(ptr) {
2051
+ ptr = ptr >>> 0;
2052
+ const obj = Object.create(HoltWintersForecaster.prototype);
2053
+ obj.__wbg_ptr = ptr;
2054
+ HoltWintersForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
2055
+ return obj;
2056
+ }
2057
+ __destroy_into_raw() {
2058
+ const ptr = this.__wbg_ptr;
2059
+ this.__wbg_ptr = 0;
2060
+ HoltWintersForecasterFinalization.unregister(this);
2061
+ return ptr;
2062
+ }
2063
+ free() {
2064
+ const ptr = this.__destroy_into_raw();
2065
+ wasm.__wbg_holtwintersforecaster_free(ptr, 0);
2066
+ }
2067
+ /**
2068
+ * Create with multiplicative seasonality.
2069
+ * @param {number} alpha
2070
+ * @param {number} beta
2071
+ * @param {number} gamma
2072
+ * @param {number} period
2073
+ * @returns {HoltWintersForecaster}
2074
+ */
2075
+ static multiplicative(alpha, beta, gamma, period) {
2076
+ const ret = wasm.holtwintersforecaster_multiplicative(alpha, beta, gamma, period);
2077
+ return HoltWintersForecaster.__wrap(ret);
2078
+ }
2079
+ /**
2080
+ * @param {number} horizon
2081
+ * @param {number} level
2082
+ * @returns {Forecast}
2083
+ */
2084
+ predictWithIntervals(horizon, level) {
2085
+ const ret = wasm.holtwintersforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
2086
+ if (ret[2]) {
2087
+ throw takeFromExternrefTable0(ret[1]);
2088
+ }
2089
+ return Forecast.__wrap(ret[0]);
2090
+ }
2091
+ /**
2092
+ * @param {TimeSeries} series
2093
+ */
2094
+ fit(series) {
2095
+ _assertClass(series, TimeSeries);
2096
+ const ret = wasm.holtwintersforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
2097
+ if (ret[1]) {
2098
+ throw takeFromExternrefTable0(ret[0]);
2099
+ }
2100
+ }
2101
+ /**
2102
+ * Create with additive seasonality.
2103
+ * @param alpha - Level smoothing parameter
2104
+ * @param beta - Trend smoothing parameter
2105
+ * @param gamma - Seasonal smoothing parameter
2106
+ * @param period - Seasonal period
2107
+ * @param {number} alpha
2108
+ * @param {number} beta
2109
+ * @param {number} gamma
2110
+ * @param {number} period
2111
+ */
2112
+ constructor(alpha, beta, gamma, period) {
2113
+ const ret = wasm.holtwintersforecaster_new(alpha, beta, gamma, period);
2114
+ this.__wbg_ptr = ret >>> 0;
2115
+ HoltWintersForecasterFinalization.register(this, this.__wbg_ptr, this);
2116
+ return this;
2117
+ }
2118
+ /**
2119
+ * Create with automatic parameter optimization.
2120
+ * @param period - Seasonal period
2121
+ * @param seasonal_type - "additive" or "multiplicative"
2122
+ * @param {number} period
2123
+ * @param {string} seasonal_type
2124
+ * @returns {HoltWintersForecaster}
2125
+ */
2126
+ static auto(period, seasonal_type) {
2127
+ const ptr0 = passStringToWasm0(seasonal_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2128
+ const len0 = WASM_VECTOR_LEN;
2129
+ const ret = wasm.holtwintersforecaster_auto(period, ptr0, len0);
2130
+ if (ret[2]) {
2131
+ throw takeFromExternrefTable0(ret[1]);
2132
+ }
2133
+ return HoltWintersForecaster.__wrap(ret[0]);
2134
+ }
2135
+ /**
2136
+ * @returns {string}
2137
+ */
2138
+ get name() {
2139
+ let deferred1_0;
2140
+ let deferred1_1;
2141
+ try {
2142
+ const ret = wasm.holtwintersforecaster_name(this.__wbg_ptr);
2143
+ deferred1_0 = ret[0];
2144
+ deferred1_1 = ret[1];
2145
+ return getStringFromWasm0(ret[0], ret[1]);
2146
+ } finally {
2147
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2148
+ }
2149
+ }
2150
+ /**
2151
+ * @param {number} horizon
2152
+ * @returns {Forecast}
2153
+ */
2154
+ predict(horizon) {
2155
+ const ret = wasm.holtwintersforecaster_predict(this.__wbg_ptr, horizon);
2156
+ if (ret[2]) {
2157
+ throw takeFromExternrefTable0(ret[1]);
2158
+ }
2159
+ return Forecast.__wrap(ret[0]);
2160
+ }
2161
+ }
2162
+ if (Symbol.dispose) HoltWintersForecaster.prototype[Symbol.dispose] = HoltWintersForecaster.prototype.free;
2163
+
2164
+ /**
2165
+ * IMAPA (Intermittent Multiple Aggregation Prediction Algorithm).
2166
+ */
2167
+ export class IMAPAForecaster {
2168
+ __destroy_into_raw() {
2169
+ const ptr = this.__wbg_ptr;
2170
+ this.__wbg_ptr = 0;
2171
+ IMAPAForecasterFinalization.unregister(this);
2172
+ return ptr;
2173
+ }
2174
+ free() {
2175
+ const ptr = this.__destroy_into_raw();
2176
+ wasm.__wbg_imapaforecaster_free(ptr, 0);
2177
+ }
2178
+ /**
2179
+ * @param {number} horizon
2180
+ * @param {number} level
2181
+ * @returns {Forecast}
2182
+ */
2183
+ predictWithIntervals(horizon, level) {
2184
+ const ret = wasm.imapaforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
2185
+ if (ret[2]) {
2186
+ throw takeFromExternrefTable0(ret[1]);
2187
+ }
2188
+ return Forecast.__wrap(ret[0]);
2189
+ }
2190
+ /**
2191
+ * @param {TimeSeries} series
2192
+ */
2193
+ fit(series) {
2194
+ _assertClass(series, TimeSeries);
2195
+ const ret = wasm.imapaforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
2196
+ if (ret[1]) {
2197
+ throw takeFromExternrefTable0(ret[0]);
2198
+ }
2199
+ }
2200
+ constructor() {
2201
+ const ret = wasm.imapaforecaster_new();
2202
+ this.__wbg_ptr = ret >>> 0;
2203
+ IMAPAForecasterFinalization.register(this, this.__wbg_ptr, this);
2204
+ return this;
2205
+ }
2206
+ /**
2207
+ * @returns {string}
2208
+ */
2209
+ get name() {
2210
+ let deferred1_0;
2211
+ let deferred1_1;
2212
+ try {
2213
+ const ret = wasm.imapaforecaster_name(this.__wbg_ptr);
2214
+ deferred1_0 = ret[0];
2215
+ deferred1_1 = ret[1];
2216
+ return getStringFromWasm0(ret[0], ret[1]);
2217
+ } finally {
2218
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2219
+ }
2220
+ }
2221
+ /**
2222
+ * @param {number} horizon
2223
+ * @returns {Forecast}
2224
+ */
2225
+ predict(horizon) {
2226
+ const ret = wasm.imapaforecaster_predict(this.__wbg_ptr, horizon);
2227
+ if (ret[2]) {
2228
+ throw takeFromExternrefTable0(ret[1]);
2229
+ }
2230
+ return Forecast.__wrap(ret[0]);
2231
+ }
2232
+ }
2233
+ if (Symbol.dispose) IMAPAForecaster.prototype[Symbol.dispose] = IMAPAForecaster.prototype.free;
2234
+
2235
+ /**
2236
+ * Configuration for backtesting a postprocessor.
2237
+ */
2238
+ export class JsBacktestConfig {
2239
+ static __wrap(ptr) {
2240
+ ptr = ptr >>> 0;
2241
+ const obj = Object.create(JsBacktestConfig.prototype);
2242
+ obj.__wbg_ptr = ptr;
2243
+ JsBacktestConfigFinalization.register(obj, obj.__wbg_ptr, obj);
2244
+ return obj;
2245
+ }
2246
+ __destroy_into_raw() {
2247
+ const ptr = this.__wbg_ptr;
2248
+ this.__wbg_ptr = 0;
2249
+ JsBacktestConfigFinalization.unregister(this);
2250
+ return ptr;
2251
+ }
2252
+ free() {
2253
+ const ptr = this.__destroy_into_raw();
2254
+ wasm.__wbg_jsbacktestconfig_free(ptr, 0);
2255
+ }
2256
+ /**
2257
+ * Set the initial training window size.
2258
+ * @param {number} size
2259
+ * @returns {JsBacktestConfig}
2260
+ */
2261
+ initialWindow(size) {
2262
+ const ptr = this.__destroy_into_raw();
2263
+ const ret = wasm.jsbacktestconfig_initialWindow(ptr, size);
2264
+ return JsBacktestConfig.__wrap(ret);
2265
+ }
2266
+ /**
2267
+ * Create a new backtest configuration with default settings.
2268
+ *
2269
+ * Defaults: initial_window=50, step=1, horizon=1, expanding=true.
2270
+ */
2271
+ constructor() {
2272
+ const ret = wasm.jsbacktestconfig_new();
2273
+ this.__wbg_ptr = ret >>> 0;
2274
+ JsBacktestConfigFinalization.register(this, this.__wbg_ptr, this);
2275
+ return this;
2276
+ }
2277
+ /**
2278
+ * Set the step size between folds.
2279
+ * @param {number} step
2280
+ * @returns {JsBacktestConfig}
2281
+ */
2282
+ step(step) {
2283
+ const ptr = this.__destroy_into_raw();
2284
+ const ret = wasm.jsbacktestconfig_step(ptr, step);
2285
+ return JsBacktestConfig.__wrap(ret);
2286
+ }
2287
+ /**
2288
+ * Set the forecast horizon.
2289
+ * @param {number} horizon
2290
+ * @returns {JsBacktestConfig}
2291
+ */
2292
+ horizon(horizon) {
2293
+ const ptr = this.__destroy_into_raw();
2294
+ const ret = wasm.jsbacktestconfig_horizon(ptr, horizon);
2295
+ return JsBacktestConfig.__wrap(ret);
2296
+ }
2297
+ /**
2298
+ * Set whether to use expanding (true) or rolling (false) window.
2299
+ * @param {boolean} expanding
2300
+ * @returns {JsBacktestConfig}
2301
+ */
2302
+ expanding(expanding) {
2303
+ const ptr = this.__destroy_into_raw();
2304
+ const ret = wasm.jsbacktestconfig_expanding(ptr, expanding);
2305
+ return JsBacktestConfig.__wrap(ret);
2306
+ }
2307
+ }
2308
+ if (Symbol.dispose) JsBacktestConfig.prototype[Symbol.dispose] = JsBacktestConfig.prototype.free;
2309
+
2310
+ /**
2311
+ * Results from backtesting a postprocessor.
2312
+ */
2313
+ export class JsBacktestResult {
2314
+ static __wrap(ptr) {
2315
+ ptr = ptr >>> 0;
2316
+ const obj = Object.create(JsBacktestResult.prototype);
2317
+ obj.__wbg_ptr = ptr;
2318
+ JsBacktestResultFinalization.register(obj, obj.__wbg_ptr, obj);
2319
+ return obj;
2320
+ }
2321
+ __destroy_into_raw() {
2322
+ const ptr = this.__wbg_ptr;
2323
+ this.__wbg_ptr = 0;
2324
+ JsBacktestResultFinalization.unregister(this);
2325
+ return ptr;
2326
+ }
2327
+ free() {
2328
+ const ptr = this.__destroy_into_raw();
2329
+ wasm.__wbg_jsbacktestresult_free(ptr, 0);
2330
+ }
2331
+ /**
2332
+ * Get average interval width across all folds.
2333
+ * @returns {number}
2334
+ */
2335
+ intervalWidths() {
2336
+ const ret = wasm.jsbacktestresult_intervalWidths(this.__wbg_ptr);
2337
+ return ret;
2338
+ }
2339
+ /**
2340
+ * Get calibration error (absolute deviation from target coverage).
2341
+ * @param {number} target_coverage
2342
+ * @returns {number}
2343
+ */
2344
+ calibrationError(target_coverage) {
2345
+ const ret = wasm.jsbacktestresult_calibrationError(this.__wbg_ptr, target_coverage);
2346
+ return ret;
2347
+ }
2348
+ /**
2349
+ * Get the number of backtest folds.
2350
+ * @returns {number}
2351
+ */
2352
+ numFolds() {
2353
+ const ret = wasm.jsbacktestresult_numFolds(this.__wbg_ptr);
2354
+ return ret >>> 0;
2355
+ }
2356
+ /**
2357
+ * Get overall coverage across all folds.
2358
+ * @returns {number}
2359
+ */
2360
+ get coverage() {
2361
+ const ret = wasm.jsbacktestresult_coverage(this.__wbg_ptr);
2362
+ return ret;
2363
+ }
2364
+ }
2365
+ if (Symbol.dispose) JsBacktestResult.prototype[Symbol.dispose] = JsBacktestResult.prototype.free;
2366
+
2367
+ /**
2368
+ * Conformal predictor for distribution-free prediction intervals.
2369
+ *
2370
+ * Provides coverage-guaranteed intervals without distributional assumptions.
2371
+ */
2372
+ export class JsConformalPredictor {
2373
+ static __wrap(ptr) {
2374
+ ptr = ptr >>> 0;
2375
+ const obj = Object.create(JsConformalPredictor.prototype);
2376
+ obj.__wbg_ptr = ptr;
2377
+ JsConformalPredictorFinalization.register(obj, obj.__wbg_ptr, obj);
2378
+ return obj;
2379
+ }
2380
+ __destroy_into_raw() {
2381
+ const ptr = this.__wbg_ptr;
2382
+ this.__wbg_ptr = 0;
2383
+ JsConformalPredictorFinalization.unregister(this);
2384
+ return ptr;
2385
+ }
2386
+ free() {
2387
+ const ptr = this.__destroy_into_raw();
2388
+ wasm.__wbg_jsconformalpredictor_free(ptr, 0);
2389
+ }
2390
+ /**
2391
+ * Create a conformal predictor with the Jackknife+ method.
2392
+ *
2393
+ * @param coverage - Target coverage level in (0, 1)
2394
+ * @param {number} coverage
2395
+ * @returns {JsConformalPredictor}
2396
+ */
2397
+ static jackknifePlus(coverage) {
2398
+ const ret = wasm.jsconformalpredictor_jackknifePlus(coverage);
2399
+ return JsConformalPredictor.__wrap(ret);
2400
+ }
2401
+ /**
2402
+ * Generate prediction intervals for new point forecasts.
2403
+ *
2404
+ * @param result - A fitted JsConformalResult from calibrate()
2405
+ * @param pointForecasts - New point forecast values
2406
+ * @param {JsConformalResult} result
2407
+ * @param {Float64Array} point_forecasts
2408
+ * @returns {JsPredictionIntervals}
2409
+ */
2410
+ predictIntervals(result, point_forecasts) {
2411
+ _assertClass(result, JsConformalResult);
2412
+ const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
2413
+ const len0 = WASM_VECTOR_LEN;
2414
+ const ret = wasm.jsconformalpredictor_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
2415
+ return JsPredictionIntervals.__wrap(ret);
2416
+ }
2417
+ /**
2418
+ * Create a split conformal predictor.
2419
+ *
2420
+ * @param coverage - Target coverage level in (0, 1), e.g. 0.90
2421
+ * @param {number} coverage
2422
+ */
2423
+ constructor(coverage) {
2424
+ const ret = wasm.jsconformalpredictor_new(coverage);
2425
+ this.__wbg_ptr = ret >>> 0;
2426
+ JsConformalPredictorFinalization.register(this, this.__wbg_ptr, this);
2427
+ return this;
2428
+ }
2429
+ /**
2430
+ * Calibrate (fit) the predictor on historical forecasts and actuals.
2431
+ *
2432
+ * @param forecasts - Historical point forecast values
2433
+ * @param actuals - Corresponding actual observed values
2434
+ * @param {Float64Array} forecasts
2435
+ * @param {Float64Array} actuals
2436
+ * @returns {JsConformalResult}
2437
+ */
2438
+ calibrate(forecasts, actuals) {
2439
+ const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
2440
+ const len0 = WASM_VECTOR_LEN;
2441
+ const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2442
+ const len1 = WASM_VECTOR_LEN;
2443
+ const ret = wasm.jsconformalpredictor_calibrate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2444
+ if (ret[2]) {
2445
+ throw takeFromExternrefTable0(ret[1]);
2446
+ }
2447
+ return JsConformalResult.__wrap(ret[0]);
2448
+ }
2449
+ /**
2450
+ * Create a conformal predictor with the cross-validation method.
2451
+ *
2452
+ * @param coverage - Target coverage level in (0, 1)
2453
+ * @param nFolds - Number of cross-validation folds
2454
+ * @param {number} coverage
2455
+ * @param {number} n_folds
2456
+ * @returns {JsConformalPredictor}
2457
+ */
2458
+ static crossVal(coverage, n_folds) {
2459
+ const ret = wasm.jsconformalpredictor_crossVal(coverage, n_folds);
2460
+ return JsConformalPredictor.__wrap(ret);
2461
+ }
2462
+ }
2463
+ if (Symbol.dispose) JsConformalPredictor.prototype[Symbol.dispose] = JsConformalPredictor.prototype.free;
2464
+
2465
+ /**
2466
+ * Conformal prediction result — stores calibration data from fitting.
2467
+ */
2468
+ export class JsConformalResult {
2469
+ static __wrap(ptr) {
2470
+ ptr = ptr >>> 0;
2471
+ const obj = Object.create(JsConformalResult.prototype);
2472
+ obj.__wbg_ptr = ptr;
2473
+ JsConformalResultFinalization.register(obj, obj.__wbg_ptr, obj);
2474
+ return obj;
2475
+ }
2476
+ __destroy_into_raw() {
2477
+ const ptr = this.__wbg_ptr;
2478
+ this.__wbg_ptr = 0;
2479
+ JsConformalResultFinalization.unregister(this);
2480
+ return ptr;
2481
+ }
2482
+ free() {
2483
+ const ptr = this.__destroy_into_raw();
2484
+ wasm.__wbg_jsconformalresult_free(ptr, 0);
2485
+ }
2486
+ /**
2487
+ * Get the quantile value (interval half-width).
2488
+ * @returns {number}
2489
+ */
2490
+ quantileValue() {
2491
+ const ret = wasm.jsconformalresult_quantileValue(this.__wbg_ptr);
2492
+ return ret;
2493
+ }
2494
+ /**
2495
+ * Get the nonconformity scores.
2496
+ * @returns {Float64Array}
2497
+ */
2498
+ scores() {
2499
+ const ret = wasm.jsconformalresult_scores(this.__wbg_ptr);
2500
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2501
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2502
+ return v1;
2503
+ }
2504
+ /**
2505
+ * Get the coverage level.
2506
+ * @returns {number}
2507
+ */
2508
+ get coverage() {
2509
+ const ret = wasm.jsconformalresult_coverage(this.__wbg_ptr);
2510
+ return ret;
2511
+ }
2512
+ }
2513
+ if (Symbol.dispose) JsConformalResult.prototype[Symbol.dispose] = JsConformalResult.prototype.free;
2514
+
2515
+ /**
2516
+ * Historical simulation result — stores the empirical error distribution.
2517
+ */
2518
+ export class JsHistoricalSimResult {
2519
+ static __wrap(ptr) {
2520
+ ptr = ptr >>> 0;
2521
+ const obj = Object.create(JsHistoricalSimResult.prototype);
2522
+ obj.__wbg_ptr = ptr;
2523
+ JsHistoricalSimResultFinalization.register(obj, obj.__wbg_ptr, obj);
2524
+ return obj;
2525
+ }
2526
+ __destroy_into_raw() {
2527
+ const ptr = this.__wbg_ptr;
2528
+ this.__wbg_ptr = 0;
2529
+ JsHistoricalSimResultFinalization.unregister(this);
2530
+ return ptr;
2531
+ }
2532
+ free() {
2533
+ const ptr = this.__destroy_into_raw();
2534
+ wasm.__wbg_jshistoricalsimresult_free(ptr, 0);
2535
+ }
2536
+ /**
2537
+ * Get the quantile values.
2538
+ * @returns {Float64Array}
2539
+ */
2540
+ quantileValues() {
2541
+ const ret = wasm.jshistoricalsimresult_quantileValues(this.__wbg_ptr);
2542
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2543
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2544
+ return v1;
2545
+ }
2546
+ /**
2547
+ * Get the sorted errors.
2548
+ * @returns {Float64Array}
2549
+ */
2550
+ errors() {
2551
+ const ret = wasm.jshistoricalsimresult_errors(this.__wbg_ptr);
2552
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2553
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2554
+ return v1;
2555
+ }
2556
+ }
2557
+ if (Symbol.dispose) JsHistoricalSimResult.prototype[Symbol.dispose] = JsHistoricalSimResult.prototype.free;
2558
+
2559
+ /**
2560
+ * Historical simulator — non-parametric prediction intervals
2561
+ * based on the empirical error distribution.
2562
+ */
2563
+ export class JsHistoricalSimulator {
2564
+ static __wrap(ptr) {
2565
+ ptr = ptr >>> 0;
2566
+ const obj = Object.create(JsHistoricalSimulator.prototype);
2567
+ obj.__wbg_ptr = ptr;
2568
+ JsHistoricalSimulatorFinalization.register(obj, obj.__wbg_ptr, obj);
2569
+ return obj;
2570
+ }
2571
+ __destroy_into_raw() {
2572
+ const ptr = this.__wbg_ptr;
2573
+ this.__wbg_ptr = 0;
2574
+ JsHistoricalSimulatorFinalization.unregister(this);
2575
+ return ptr;
2576
+ }
2577
+ free() {
2578
+ const ptr = this.__destroy_into_raw();
2579
+ wasm.__wbg_jshistoricalsimulator_free(ptr, 0);
2580
+ }
2581
+ /**
2582
+ * Create a simulator with a rolling window.
2583
+ *
2584
+ * @param quantiles - Sorted quantile levels in (0,1)
2585
+ * @param window - Number of recent observations to use
2586
+ * @param {Float64Array} quantiles
2587
+ * @param {number} window
2588
+ * @returns {JsHistoricalSimulator}
2589
+ */
2590
+ static withWindow(quantiles, window) {
2591
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2592
+ const len0 = WASM_VECTOR_LEN;
2593
+ const ret = wasm.jshistoricalsimulator_withWindow(ptr0, len0, window);
2594
+ return JsHistoricalSimulator.__wrap(ret);
2595
+ }
2596
+ /**
2597
+ * Generate prediction intervals for new point forecasts.
2598
+ *
2599
+ * @param result - A fitted JsHistoricalSimResult from simulate()
2600
+ * @param pointForecasts - New point forecast values
2601
+ * @param {JsHistoricalSimResult} result
2602
+ * @param {Float64Array} point_forecasts
2603
+ * @returns {JsPredictionIntervals}
2604
+ */
2605
+ predictIntervals(result, point_forecasts) {
2606
+ _assertClass(result, JsHistoricalSimResult);
2607
+ const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
2608
+ const len0 = WASM_VECTOR_LEN;
2609
+ const ret = wasm.jshistoricalsimulator_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
2610
+ if (ret[2]) {
2611
+ throw takeFromExternrefTable0(ret[1]);
2612
+ }
2613
+ return JsPredictionIntervals.__wrap(ret[0]);
2614
+ }
2615
+ /**
2616
+ * Create a new historical simulator.
2617
+ *
2618
+ * @param quantiles - Sorted quantile levels in (0,1), e.g. [0.1, 0.5, 0.9]
2619
+ * @param {Float64Array} quantiles
2620
+ */
2621
+ constructor(quantiles) {
2622
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2623
+ const len0 = WASM_VECTOR_LEN;
2624
+ const ret = wasm.jshistoricalsimulator_new(ptr0, len0);
2625
+ this.__wbg_ptr = ret >>> 0;
2626
+ JsHistoricalSimulatorFinalization.register(this, this.__wbg_ptr, this);
2627
+ return this;
2628
+ }
2629
+ /**
2630
+ * Fit the simulator on historical forecasts and actuals.
2631
+ *
2632
+ * @param forecasts - Historical point forecast values
2633
+ * @param actuals - Corresponding actual observed values
2634
+ * @param {Float64Array} forecasts
2635
+ * @param {Float64Array} actuals
2636
+ * @returns {JsHistoricalSimResult}
2637
+ */
2638
+ simulate(forecasts, actuals) {
2639
+ const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
2640
+ const len0 = WASM_VECTOR_LEN;
2641
+ const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2642
+ const len1 = WASM_VECTOR_LEN;
2643
+ const ret = wasm.jshistoricalsimulator_simulate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2644
+ if (ret[2]) {
2645
+ throw takeFromExternrefTable0(ret[1]);
2646
+ }
2647
+ return JsHistoricalSimResult.__wrap(ret[0]);
2648
+ }
2649
+ }
2650
+ if (Symbol.dispose) JsHistoricalSimulator.prototype[Symbol.dispose] = JsHistoricalSimulator.prototype.free;
2651
+
2652
+ /**
2653
+ * Normal predictor — assumes Gaussian forecast errors.
2654
+ *
2655
+ * Generates quantile-based prediction intervals from the estimated
2656
+ * error mean and standard deviation.
2657
+ */
2658
+ export class JsNormalPredictor {
2659
+ __destroy_into_raw() {
2660
+ const ptr = this.__wbg_ptr;
2661
+ this.__wbg_ptr = 0;
2662
+ JsNormalPredictorFinalization.unregister(this);
2663
+ return ptr;
2664
+ }
2665
+ free() {
2666
+ const ptr = this.__destroy_into_raw();
2667
+ wasm.__wbg_jsnormalpredictor_free(ptr, 0);
2668
+ }
2669
+ /**
2670
+ * Generate prediction intervals for new point forecasts.
2671
+ *
2672
+ * Returns intervals using the first and last quantile as bounds.
2673
+ *
2674
+ * @param result - A fitted JsNormalResult from fit()
2675
+ * @param pointForecasts - New point forecast values
2676
+ * @param {JsNormalResult} result
2677
+ * @param {Float64Array} point_forecasts
2678
+ * @returns {JsPredictionIntervals}
2679
+ */
2680
+ predictIntervals(result, point_forecasts) {
2681
+ _assertClass(result, JsNormalResult);
2682
+ const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
2683
+ const len0 = WASM_VECTOR_LEN;
2684
+ const ret = wasm.jsnormalpredictor_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
2685
+ if (ret[2]) {
2686
+ throw takeFromExternrefTable0(ret[1]);
2687
+ }
2688
+ return JsPredictionIntervals.__wrap(ret[0]);
2689
+ }
2690
+ /**
2691
+ * Fit the predictor on historical forecasts and actuals.
2692
+ *
2693
+ * @param forecasts - Historical point forecast values
2694
+ * @param actuals - Corresponding actual observed values
2695
+ * @param {Float64Array} forecasts
2696
+ * @param {Float64Array} actuals
2697
+ * @returns {JsNormalResult}
2698
+ */
2699
+ fit(forecasts, actuals) {
2700
+ const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
2701
+ const len0 = WASM_VECTOR_LEN;
2702
+ const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2703
+ const len1 = WASM_VECTOR_LEN;
2704
+ const ret = wasm.jsnormalpredictor_fit(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2705
+ if (ret[2]) {
2706
+ throw takeFromExternrefTable0(ret[1]);
2707
+ }
2708
+ return JsNormalResult.__wrap(ret[0]);
2709
+ }
2710
+ /**
2711
+ * Create a new normal predictor.
2712
+ *
2713
+ * @param quantiles - Sorted quantile levels in (0,1), e.g. [0.1, 0.5, 0.9]
2714
+ * @param {Float64Array} quantiles
2715
+ */
2716
+ constructor(quantiles) {
2717
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2718
+ const len0 = WASM_VECTOR_LEN;
2719
+ const ret = wasm.jsnormalpredictor_new(ptr0, len0);
2720
+ this.__wbg_ptr = ret >>> 0;
2721
+ JsNormalPredictorFinalization.register(this, this.__wbg_ptr, this);
2722
+ return this;
2723
+ }
2724
+ }
2725
+ if (Symbol.dispose) JsNormalPredictor.prototype[Symbol.dispose] = JsNormalPredictor.prototype.free;
2726
+
2727
+ /**
2728
+ * Normal prediction result — stores Gaussian fit parameters.
2729
+ */
2730
+ export class JsNormalResult {
2731
+ static __wrap(ptr) {
2732
+ ptr = ptr >>> 0;
2733
+ const obj = Object.create(JsNormalResult.prototype);
2734
+ obj.__wbg_ptr = ptr;
2735
+ JsNormalResultFinalization.register(obj, obj.__wbg_ptr, obj);
2736
+ return obj;
2737
+ }
2738
+ __destroy_into_raw() {
2739
+ const ptr = this.__wbg_ptr;
2740
+ this.__wbg_ptr = 0;
2741
+ JsNormalResultFinalization.unregister(this);
2742
+ return ptr;
2743
+ }
2744
+ free() {
2745
+ const ptr = this.__destroy_into_raw();
2746
+ wasm.__wbg_jsnormalresult_free(ptr, 0);
2747
+ }
2748
+ /**
2749
+ * Get the mean error (bias).
2750
+ * @returns {number}
2751
+ */
2752
+ get mean() {
2753
+ const ret = wasm.jsnormalresult_mean(this.__wbg_ptr);
2754
+ return ret;
2755
+ }
2756
+ /**
2757
+ * Get the standard deviation of errors.
2758
+ * @returns {number}
2759
+ */
2760
+ stdDev() {
2761
+ const ret = wasm.jsnormalresult_stdDev(this.__wbg_ptr);
2762
+ return ret;
2763
+ }
2764
+ }
2765
+ if (Symbol.dispose) JsNormalResult.prototype[Symbol.dispose] = JsNormalResult.prototype.free;
2766
+
2767
+ /**
2768
+ * Point forecasts — a sequence of predicted values.
2769
+ *
2770
+ * Used as input for postprocessing methods.
2771
+ */
2772
+ export class JsPointForecasts {
2773
+ __destroy_into_raw() {
2774
+ const ptr = this.__wbg_ptr;
2775
+ this.__wbg_ptr = 0;
2776
+ JsPointForecastsFinalization.unregister(this);
2777
+ return ptr;
2778
+ }
2779
+ free() {
2780
+ const ptr = this.__destroy_into_raw();
2781
+ wasm.__wbg_jspointforecasts_free(ptr, 0);
2782
+ }
2783
+ /**
2784
+ * Create point forecasts from an array of values.
2785
+ * @param {Float64Array} values
2786
+ */
2787
+ constructor(values) {
2788
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
2789
+ const len0 = WASM_VECTOR_LEN;
2790
+ const ret = wasm.jspointforecasts_new(ptr0, len0);
2791
+ this.__wbg_ptr = ret >>> 0;
2792
+ JsPointForecastsFinalization.register(this, this.__wbg_ptr, this);
2793
+ return this;
2794
+ }
2795
+ /**
2796
+ * Get the number of forecast points.
2797
+ * @returns {number}
2798
+ */
2799
+ get length() {
2800
+ const ret = wasm.jspointforecasts_length(this.__wbg_ptr);
2801
+ return ret >>> 0;
2802
+ }
2803
+ /**
2804
+ * Get the forecast values.
2805
+ * @returns {Float64Array}
2806
+ */
2807
+ get values() {
2808
+ const ret = wasm.jspointforecasts_values(this.__wbg_ptr);
2809
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2810
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2811
+ return v1;
2812
+ }
2813
+ /**
2814
+ * Check if empty.
2815
+ * @returns {boolean}
2816
+ */
2817
+ isEmpty() {
2818
+ const ret = wasm.jspointforecasts_isEmpty(this.__wbg_ptr);
2819
+ return ret !== 0;
2820
+ }
2821
+ }
2822
+ if (Symbol.dispose) JsPointForecasts.prototype[Symbol.dispose] = JsPointForecasts.prototype.free;
2823
+
2824
+ /**
2825
+ * Unified postprocessor that wraps conformal, normal, and historical simulation
2826
+ * methods behind a single API.
2827
+ */
2828
+ export class JsPostProcessor {
2829
+ static __wrap(ptr) {
2830
+ ptr = ptr >>> 0;
2831
+ const obj = Object.create(JsPostProcessor.prototype);
2832
+ obj.__wbg_ptr = ptr;
2833
+ JsPostProcessorFinalization.register(obj, obj.__wbg_ptr, obj);
2834
+ return obj;
2835
+ }
2836
+ __destroy_into_raw() {
2837
+ const ptr = this.__wbg_ptr;
2838
+ this.__wbg_ptr = 0;
2839
+ JsPostProcessorFinalization.unregister(this);
2840
+ return ptr;
2841
+ }
2842
+ free() {
2843
+ const ptr = this.__destroy_into_raw();
2844
+ wasm.__wbg_jspostprocessor_free(ptr, 0);
2845
+ }
2846
+ /**
2847
+ * Create a historical simulation postprocessor.
2848
+ *
2849
+ * @param quantiles - Sorted quantile levels in (0,1)
2850
+ * @param {Float64Array} quantiles
2851
+ * @returns {JsPostProcessor}
2852
+ */
2853
+ static historicalSim(quantiles) {
2854
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2855
+ const len0 = WASM_VECTOR_LEN;
2856
+ const ret = wasm.jspostprocessor_historicalSim(ptr0, len0);
2857
+ return JsPostProcessor.__wrap(ret);
2858
+ }
2859
+ /**
2860
+ * Generate prediction intervals from a trained model.
2861
+ *
2862
+ * @param trained - A JsTrainedModel from train()
2863
+ * @param forecasts - New point forecasts
2864
+ * @param {JsTrainedModel} trained
2865
+ * @param {JsPointForecasts} forecasts
2866
+ * @returns {JsPredictionIntervals}
2867
+ */
2868
+ predictIntervals(trained, forecasts) {
2869
+ _assertClass(trained, JsTrainedModel);
2870
+ _assertClass(forecasts, JsPointForecasts);
2871
+ const ret = wasm.jspostprocessor_predictIntervals(this.__wbg_ptr, trained.__wbg_ptr, forecasts.__wbg_ptr);
2872
+ if (ret[2]) {
2873
+ throw takeFromExternrefTable0(ret[1]);
2874
+ }
2875
+ return JsPredictionIntervals.__wrap(ret[0]);
2876
+ }
2877
+ /**
2878
+ * Train the postprocessor on historical data.
2879
+ *
2880
+ * @param forecasts - JsPointForecasts with historical predictions
2881
+ * @param actuals - Corresponding actual observed values
2882
+ * @param {JsPointForecasts} forecasts
2883
+ * @param {Float64Array} actuals
2884
+ * @returns {JsTrainedModel}
2885
+ */
2886
+ train(forecasts, actuals) {
2887
+ _assertClass(forecasts, JsPointForecasts);
2888
+ const ptr0 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2889
+ const len0 = WASM_VECTOR_LEN;
2890
+ const ret = wasm.jspostprocessor_train(this.__wbg_ptr, forecasts.__wbg_ptr, ptr0, len0);
2891
+ if (ret[2]) {
2892
+ throw takeFromExternrefTable0(ret[1]);
2893
+ }
2894
+ return JsTrainedModel.__wrap(ret[0]);
2895
+ }
2896
+ /**
2897
+ * Create a normal prediction postprocessor.
2898
+ *
2899
+ * @param quantiles - Sorted quantile levels in (0,1)
2900
+ * @param {Float64Array} quantiles
2901
+ * @returns {JsPostProcessor}
2902
+ */
2903
+ static normal(quantiles) {
2904
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2905
+ const len0 = WASM_VECTOR_LEN;
2906
+ const ret = wasm.jspostprocessor_normal(ptr0, len0);
2907
+ return JsPostProcessor.__wrap(ret);
2908
+ }
2909
+ /**
2910
+ * Create a conformal prediction postprocessor.
2911
+ *
2912
+ * @param coverage - Target coverage level in (0, 1), e.g. 0.90
2913
+ * @param {number} coverage
2914
+ * @returns {JsPostProcessor}
2915
+ */
2916
+ static conformal(coverage) {
2917
+ const ret = wasm.jspostprocessor_conformal(coverage);
2918
+ return JsPostProcessor.__wrap(ret);
2919
+ }
2920
+ }
2921
+ if (Symbol.dispose) JsPostProcessor.prototype[Symbol.dispose] = JsPostProcessor.prototype.free;
2922
+
2923
+ /**
2924
+ * Prediction intervals with lower bounds, upper bounds, and a coverage level.
2925
+ */
2926
+ export class JsPredictionIntervals {
2927
+ static __wrap(ptr) {
2928
+ ptr = ptr >>> 0;
2929
+ const obj = Object.create(JsPredictionIntervals.prototype);
2930
+ obj.__wbg_ptr = ptr;
2931
+ JsPredictionIntervalsFinalization.register(obj, obj.__wbg_ptr, obj);
2932
+ return obj;
2933
+ }
2934
+ __destroy_into_raw() {
2935
+ const ptr = this.__wbg_ptr;
2936
+ this.__wbg_ptr = 0;
2937
+ JsPredictionIntervalsFinalization.unregister(this);
2938
+ return ptr;
2939
+ }
2940
+ free() {
2941
+ const ptr = this.__destroy_into_raw();
2942
+ wasm.__wbg_jspredictionintervals_free(ptr, 0);
2943
+ }
2944
+ /**
2945
+ * Compute empirical coverage given actual values.
2946
+ * @param {Float64Array} actuals
2947
+ * @returns {number | undefined}
2948
+ */
2949
+ empiricalCoverage(actuals) {
2950
+ const ptr0 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2951
+ const len0 = WASM_VECTOR_LEN;
2952
+ const ret = wasm.jspredictionintervals_empiricalCoverage(this.__wbg_ptr, ptr0, len0);
2953
+ return ret[0] === 0 ? undefined : ret[1];
2954
+ }
2955
+ /**
2956
+ * Get the lower bounds.
2957
+ * @returns {Float64Array}
2958
+ */
2959
+ get lower() {
2960
+ const ret = wasm.jspredictionintervals_lower(this.__wbg_ptr);
2961
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2962
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2963
+ return v1;
2964
+ }
2965
+ /**
2966
+ * Get the upper bounds.
2967
+ * @returns {Float64Array}
2968
+ */
2969
+ get upper() {
2970
+ const ret = wasm.jspredictionintervals_upper(this.__wbg_ptr);
2971
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2972
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2973
+ return v1;
2974
+ }
2975
+ /**
2976
+ * Get the number of intervals.
2977
+ * @returns {number}
2978
+ */
2979
+ get length() {
2980
+ const ret = wasm.jspredictionintervals_length(this.__wbg_ptr);
2981
+ return ret >>> 0;
2982
+ }
2983
+ /**
2984
+ * Get the interval widths.
2985
+ * @returns {Float64Array}
2986
+ */
2987
+ widths() {
2988
+ const ret = wasm.jspredictionintervals_widths(this.__wbg_ptr);
2989
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2990
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2991
+ return v1;
2992
+ }
2993
+ /**
2994
+ * Get the coverage level (e.g. 0.90).
2995
+ * @returns {number}
2996
+ */
2997
+ get coverage() {
2998
+ const ret = wasm.jsnormalresult_mean(this.__wbg_ptr);
2999
+ return ret;
3000
+ }
3001
+ /**
3002
+ * Get the interval midpoints.
3003
+ * @returns {Float64Array}
3004
+ */
3005
+ midpoints() {
3006
+ const ret = wasm.jspredictionintervals_midpoints(this.__wbg_ptr);
3007
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3008
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3009
+ return v1;
3010
+ }
3011
+ }
3012
+ if (Symbol.dispose) JsPredictionIntervals.prototype[Symbol.dispose] = JsPredictionIntervals.prototype.free;
3013
+
3014
+ /**
3015
+ * An opaque handle to a trained postprocessing model.
3016
+ *
3017
+ * Returned by `JsPostProcessor.train()` and consumed by prediction methods.
3018
+ */
3019
+ export class JsTrainedModel {
3020
+ static __wrap(ptr) {
3021
+ ptr = ptr >>> 0;
3022
+ const obj = Object.create(JsTrainedModel.prototype);
3023
+ obj.__wbg_ptr = ptr;
3024
+ JsTrainedModelFinalization.register(obj, obj.__wbg_ptr, obj);
3025
+ return obj;
3026
+ }
3027
+ __destroy_into_raw() {
3028
+ const ptr = this.__wbg_ptr;
3029
+ this.__wbg_ptr = 0;
3030
+ JsTrainedModelFinalization.unregister(this);
3031
+ return ptr;
3032
+ }
3033
+ free() {
3034
+ const ptr = this.__destroy_into_raw();
3035
+ wasm.__wbg_jstrainedmodel_free(ptr, 0);
3036
+ }
3037
+ }
3038
+ if (Symbol.dispose) JsTrainedModel.prototype[Symbol.dispose] = JsTrainedModel.prototype.free;
3039
+
3040
+ /**
3041
+ * MFLES - Multiple Frequency Locally Estimated Scatterplot Smoothing.
3042
+ */
1405
3043
  export class MFLESForecaster {
1406
3044
  __destroy_into_raw() {
1407
3045
  const ptr = this.__wbg_ptr;
@@ -1413,6 +3051,18 @@ export class MFLESForecaster {
1413
3051
  const ptr = this.__destroy_into_raw();
1414
3052
  wasm.__wbg_mflesforecaster_free(ptr, 0);
1415
3053
  }
3054
+ /**
3055
+ * @param {number} horizon
3056
+ * @param {number} level
3057
+ * @returns {Forecast}
3058
+ */
3059
+ predictWithIntervals(horizon, level) {
3060
+ const ret = wasm.mflesforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
3061
+ if (ret[2]) {
3062
+ throw takeFromExternrefTable0(ret[1]);
3063
+ }
3064
+ return Forecast.__wrap(ret[0]);
3065
+ }
1416
3066
  /**
1417
3067
  * @param {TimeSeries} series
1418
3068
  */
@@ -1914,6 +3564,18 @@ export class SESForecaster {
1914
3564
  const ptr = this.__destroy_into_raw();
1915
3565
  wasm.__wbg_sesforecaster_free(ptr, 0);
1916
3566
  }
3567
+ /**
3568
+ * @param {number} horizon
3569
+ * @param {number} level
3570
+ * @returns {Forecast}
3571
+ */
3572
+ predictWithIntervals(horizon, level) {
3573
+ const ret = wasm.sesforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
3574
+ if (ret[2]) {
3575
+ throw takeFromExternrefTable0(ret[1]);
3576
+ }
3577
+ return Forecast.__wrap(ret[0]);
3578
+ }
1917
3579
  /**
1918
3580
  * @param {TimeSeries} series
1919
3581
  */
@@ -2233,6 +3895,13 @@ if (Symbol.dispose) SeasonalWindowAverageForecaster.prototype[Symbol.dispose] =
2233
3895
  * TBATS - Trigonometric seasonality, Box-Cox, ARMA errors, Trend, Seasonal.
2234
3896
  */
2235
3897
  export class TBATSForecaster {
3898
+ static __wrap(ptr) {
3899
+ ptr = ptr >>> 0;
3900
+ const obj = Object.create(TBATSForecaster.prototype);
3901
+ obj.__wbg_ptr = ptr;
3902
+ TBATSForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
3903
+ return obj;
3904
+ }
2236
3905
  __destroy_into_raw() {
2237
3906
  const ptr = this.__wbg_ptr;
2238
3907
  this.__wbg_ptr = 0;
@@ -2243,6 +3912,65 @@ export class TBATSForecaster {
2243
3912
  const ptr = this.__destroy_into_raw();
2244
3913
  wasm.__wbg_tbatsforecaster_free(ptr, 0);
2245
3914
  }
3915
+ /**
3916
+ * Enable Box-Cox transformation.
3917
+ *
3918
+ * @param lambda - Box-Cox parameter (0 = log, 1 = identity)
3919
+ * @param {number} lambda
3920
+ */
3921
+ setBoxCox(lambda) {
3922
+ wasm.tbatsforecaster_setBoxCox(this.__wbg_ptr, lambda);
3923
+ }
3924
+ /**
3925
+ * Set Fourier K (number of harmonics) for each seasonal period.
3926
+ *
3927
+ * @param k - Array of K values (one per seasonal period)
3928
+ * @param {Uint32Array} k
3929
+ */
3930
+ setFourierK(k) {
3931
+ const ptr0 = passArray32ToWasm0(k, wasm.__wbindgen_malloc);
3932
+ const len0 = WASM_VECTOR_LEN;
3933
+ wasm.tbatsforecaster_setFourierK(this.__wbg_ptr, ptr0, len0);
3934
+ }
3935
+ /**
3936
+ * Enable damped trend.
3937
+ *
3938
+ * @param phi - Damping parameter (typically 0.8-0.99)
3939
+ * @param {number} phi
3940
+ */
3941
+ setDampedTrend(phi) {
3942
+ wasm.tbatsforecaster_setDampedTrend(this.__wbg_ptr, phi);
3943
+ }
3944
+ /**
3945
+ * Create a TBATSForecaster with specified seasonal periods.
3946
+ *
3947
+ * @param periods - Array of seasonal periods
3948
+ * @returns A new TBATSForecaster
3949
+ * @param {Uint32Array} periods
3950
+ * @returns {TBATSForecaster}
3951
+ */
3952
+ static withSeasonalPeriods(periods) {
3953
+ const ptr0 = passArray32ToWasm0(periods, wasm.__wbindgen_malloc);
3954
+ const len0 = WASM_VECTOR_LEN;
3955
+ const ret = wasm.tbatsforecaster_new(ptr0, len0);
3956
+ return TBATSForecaster.__wrap(ret);
3957
+ }
3958
+ /**
3959
+ * Predict with prediction intervals.
3960
+ *
3961
+ * @param horizon - Number of steps to forecast
3962
+ * @param level - Confidence level (e.g., 0.95 for 95% intervals)
3963
+ * @param {number} horizon
3964
+ * @param {number} level
3965
+ * @returns {Forecast}
3966
+ */
3967
+ predictWithIntervals(horizon, level) {
3968
+ const ret = wasm.tbatsforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
3969
+ if (ret[2]) {
3970
+ throw takeFromExternrefTable0(ret[1]);
3971
+ }
3972
+ return Forecast.__wrap(ret[0]);
3973
+ }
2246
3974
  /**
2247
3975
  * @param {TimeSeries} series
2248
3976
  */
@@ -2291,6 +4019,17 @@ export class TBATSForecaster {
2291
4019
  }
2292
4020
  return Forecast.__wrap(ret[0]);
2293
4021
  }
4022
+ /**
4023
+ * Set ARMA error orders.
4024
+ *
4025
+ * @param p - AR order
4026
+ * @param q - MA order
4027
+ * @param {number} p
4028
+ * @param {number} q
4029
+ */
4030
+ setArma(p, q) {
4031
+ wasm.tbatsforecaster_setArma(this.__wbg_ptr, p, q);
4032
+ }
2294
4033
  }
2295
4034
  if (Symbol.dispose) TBATSForecaster.prototype[Symbol.dispose] = TBATSForecaster.prototype.free;
2296
4035
 
@@ -2308,6 +4047,18 @@ export class TSBForecaster {
2308
4047
  const ptr = this.__destroy_into_raw();
2309
4048
  wasm.__wbg_tsbforecaster_free(ptr, 0);
2310
4049
  }
4050
+ /**
4051
+ * @param {number} horizon
4052
+ * @param {number} level
4053
+ * @returns {Forecast}
4054
+ */
4055
+ predictWithIntervals(horizon, level) {
4056
+ const ret = wasm.tsbforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
4057
+ if (ret[2]) {
4058
+ throw takeFromExternrefTable0(ret[1]);
4059
+ }
4060
+ return Forecast.__wrap(ret[0]);
4061
+ }
2311
4062
  /**
2312
4063
  * @param {TimeSeries} series
2313
4064
  */
@@ -2448,6 +4199,33 @@ export class TimeSeries {
2448
4199
  const ptr = this.__destroy_into_raw();
2449
4200
  wasm.__wbg_timeseries_free(ptr, 0);
2450
4201
  }
4202
+ /**
4203
+ * Check if calendar annotations are attached.
4204
+ * @returns {boolean}
4205
+ */
4206
+ hasCalendar() {
4207
+ const ret = wasm.timeseries_hasCalendar(this.__wbg_ptr);
4208
+ return ret !== 0;
4209
+ }
4210
+ /**
4211
+ * Attach calendar annotations (holidays, regressors) to this time series.
4212
+ *
4213
+ * Models that support exogenous variables will automatically use the
4214
+ * calendar annotations during fitting.
4215
+ *
4216
+ * @param calendar - CalendarAnnotations instance
4217
+ * @param {CalendarAnnotations} calendar
4218
+ */
4219
+ setCalendar(calendar) {
4220
+ _assertClass(calendar, CalendarAnnotations);
4221
+ wasm.timeseries_setCalendar(this.__wbg_ptr, calendar.__wbg_ptr);
4222
+ }
4223
+ /**
4224
+ * Remove calendar annotations from this time series.
4225
+ */
4226
+ clearCalendar() {
4227
+ wasm.timeseries_clearCalendar(this.__wbg_ptr);
4228
+ }
2451
4229
  /**
2452
4230
  * Create a time series with timestamps.
2453
4231
  *
@@ -2604,6 +4382,264 @@ export class WindowAverageForecaster {
2604
4382
  }
2605
4383
  if (Symbol.dispose) WindowAverageForecaster.prototype[Symbol.dispose] = WindowAverageForecaster.prototype.free;
2606
4384
 
4385
+ /**
4386
+ * Perform the Augmented Dickey-Fuller (ADF) test for unit root.
4387
+ *
4388
+ * Tests the null hypothesis that the series has a unit root (non-stationary).
4389
+ * Rejection (low p-value, negative statistic below critical values) implies
4390
+ * stationarity.
4391
+ *
4392
+ * @param values - Array of numeric values
4393
+ * @param maxLags - Maximum lags to include (default: (n-1)^(1/3))
4394
+ * @returns Object with `statistic`, `pValue`, `lags`, `isStationary`, and `criticalValues`
4395
+ * @param {Float64Array} values
4396
+ * @param {number | null} [max_lags]
4397
+ * @returns {any}
4398
+ */
4399
+ export function adfTest(values, max_lags) {
4400
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4401
+ const len0 = WASM_VECTOR_LEN;
4402
+ const ret = wasm.adfTest(ptr0, len0, isLikeNone(max_lags) ? 0x100000001 : (max_lags) >>> 0);
4403
+ if (ret[2]) {
4404
+ throw takeFromExternrefTable0(ret[1]);
4405
+ }
4406
+ return takeFromExternrefTable0(ret[0]);
4407
+ }
4408
+
4409
+ /**
4410
+ * Compute the approximate entropy of a time series.
4411
+ *
4412
+ * Measures the complexity/regularity of a time series, including self-matches.
4413
+ *
4414
+ * @param values - Array of numeric values
4415
+ * @param m - Embedding dimension (typically 2)
4416
+ * @param r - Tolerance (typically 0.2 * standard deviation)
4417
+ * @returns Approximate entropy, or NaN if insufficient data
4418
+ * @param {Float64Array} values
4419
+ * @param {number} m
4420
+ * @param {number} r
4421
+ * @returns {number}
4422
+ */
4423
+ export function approximateEntropy(values, m, r) {
4424
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4425
+ const len0 = WASM_VECTOR_LEN;
4426
+ const ret = wasm.approximateEntropy(ptr0, len0, m, r);
4427
+ return ret;
4428
+ }
4429
+
4430
+ /**
4431
+ * Compute the autocorrelation of a time series at a specific lag.
4432
+ *
4433
+ * @param values - Array of numeric values
4434
+ * @param lag - Lag value
4435
+ * @returns Autocorrelation coefficient at the given lag
4436
+ * @param {Float64Array} values
4437
+ * @param {number} lag
4438
+ * @returns {number}
4439
+ */
4440
+ export function autocorrelation(values, lag) {
4441
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4442
+ const len0 = WASM_VECTOR_LEN;
4443
+ const ret = wasm.autocorrelation(ptr0, len0, lag);
4444
+ return ret;
4445
+ }
4446
+
4447
+ /**
4448
+ * Run a backtest on a postprocessor.
4449
+ *
4450
+ * @param processor - The postprocessor to evaluate
4451
+ * @param forecasts - All historical point forecasts
4452
+ * @param actuals - All historical actual values
4453
+ * @param config - Backtest configuration
4454
+ * @param {JsPostProcessor} processor
4455
+ * @param {JsPointForecasts} forecasts
4456
+ * @param {Float64Array} actuals
4457
+ * @param {JsBacktestConfig} config
4458
+ * @returns {JsBacktestResult}
4459
+ */
4460
+ export function backtestPostProcessor(processor, forecasts, actuals, config) {
4461
+ _assertClass(processor, JsPostProcessor);
4462
+ _assertClass(forecasts, JsPointForecasts);
4463
+ const ptr0 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
4464
+ const len0 = WASM_VECTOR_LEN;
4465
+ _assertClass(config, JsBacktestConfig);
4466
+ var ptr1 = config.__destroy_into_raw();
4467
+ const ret = wasm.backtestPostProcessor(processor.__wbg_ptr, forecasts.__wbg_ptr, ptr0, len0, ptr1);
4468
+ if (ret[2]) {
4469
+ throw takeFromExternrefTable0(ret[1]);
4470
+ }
4471
+ return JsBacktestResult.__wrap(ret[0]);
4472
+ }
4473
+
4474
+ /**
4475
+ * Generate a bootstrap forecast with empirical prediction intervals.
4476
+ *
4477
+ * Uses residual bootstrap: resamples fitted residuals, generates synthetic
4478
+ * series, re-fits the model, and collects forecast distributions to
4479
+ * compute confidence intervals.
4480
+ *
4481
+ * @param values - Array of numeric values
4482
+ * @param timestamps - Optional array of timestamps as milliseconds since epoch
4483
+ * @param modelType - Model type: "naive", "ses", "holt", "autoarima", "autoets", "autotheta", "sma5", etc.
4484
+ * @param horizon - Number of steps to forecast
4485
+ * @param level - Confidence level (e.g., 0.95 for 95% intervals)
4486
+ * @param nSamples - Number of bootstrap samples (default: 200)
4487
+ * @returns Object with `point`, `lower`, `upper`, `level`, `nSamples`
4488
+ * @param {Float64Array} values
4489
+ * @param {Float64Array | null | undefined} timestamps
4490
+ * @param {string} model_type
4491
+ * @param {number} horizon
4492
+ * @param {number} level
4493
+ * @param {number | null} [n_samples]
4494
+ * @returns {any}
4495
+ */
4496
+ export function bootstrapForecast(values, timestamps, model_type, horizon, level, n_samples) {
4497
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4498
+ const len0 = WASM_VECTOR_LEN;
4499
+ var ptr1 = isLikeNone(timestamps) ? 0 : passArrayF64ToWasm0(timestamps, wasm.__wbindgen_malloc);
4500
+ var len1 = WASM_VECTOR_LEN;
4501
+ const ptr2 = passStringToWasm0(model_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4502
+ const len2 = WASM_VECTOR_LEN;
4503
+ const ret = wasm.bootstrapForecast(ptr0, len0, ptr1, len1, ptr2, len2, horizon, level, isLikeNone(n_samples) ? 0x100000001 : (n_samples) >>> 0);
4504
+ if (ret[2]) {
4505
+ throw takeFromExternrefTable0(ret[1]);
4506
+ }
4507
+ return takeFromExternrefTable0(ret[0]);
4508
+ }
4509
+
4510
+ /**
4511
+ * Perform time series cross-validation with expanding window.
4512
+ *
4513
+ * Evaluates a forecasting model using multiple train/test splits where
4514
+ * the training window grows with each fold.
4515
+ *
4516
+ * @param values - Array of numeric values
4517
+ * @param timestamps - Optional array of timestamps as milliseconds since epoch
4518
+ * @param modelType - Model type: "naive", "ses", "holt", "autoarima", "autoets", "autotheta", "sma5", etc.
4519
+ * @param horizon - Forecast horizon for each fold
4520
+ * @param initialWindow - Initial training window size (default: max(10, length/3))
4521
+ * @returns Object with `rmse`, `mae`, `mape`, `smape`, `folds`, `maeStd`, `rmseStd`
4522
+ * @param {Float64Array} values
4523
+ * @param {Float64Array | null | undefined} timestamps
4524
+ * @param {string} model_type
4525
+ * @param {number} horizon
4526
+ * @param {number | null} [initial_window]
4527
+ * @returns {any}
4528
+ */
4529
+ export function crossValidate(values, timestamps, model_type, horizon, initial_window) {
4530
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4531
+ const len0 = WASM_VECTOR_LEN;
4532
+ var ptr1 = isLikeNone(timestamps) ? 0 : passArrayF64ToWasm0(timestamps, wasm.__wbindgen_malloc);
4533
+ var len1 = WASM_VECTOR_LEN;
4534
+ const ptr2 = passStringToWasm0(model_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4535
+ const len2 = WASM_VECTOR_LEN;
4536
+ const ret = wasm.crossValidate(ptr0, len0, ptr1, len1, ptr2, len2, horizon, isLikeNone(initial_window) ? 0x100000001 : (initial_window) >>> 0);
4537
+ if (ret[2]) {
4538
+ throw takeFromExternrefTable0(ret[1]);
4539
+ }
4540
+ return takeFromExternrefTable0(ret[0]);
4541
+ }
4542
+
4543
+ /**
4544
+ * Detect changepoints in a time series using the PELT algorithm.
4545
+ *
4546
+ * Returns an object with `changepoints` (indices), `segments` (boundary pairs),
4547
+ * `cost`, `nChangepoints`, and `segmentMeans`.
4548
+ *
4549
+ * @param values - Array of numeric values
4550
+ * @param penalty - Penalty for each changepoint (controls number of changepoints; higher = fewer)
4551
+ * @param costFunction - Cost function: "l1", "l2" (default), "normal", "poisson", "linearTrend", "meanVariance", or "cusum"
4552
+ * @param minSegmentLength - Minimum segment length (default: 2)
4553
+ * @returns Object with changepoint detection results
4554
+ * @param {Float64Array} values
4555
+ * @param {number} penalty
4556
+ * @param {string | null} [cost_function]
4557
+ * @param {number | null} [min_segment_length]
4558
+ * @returns {any}
4559
+ */
4560
+ export function detectChangepoints(values, penalty, cost_function, min_segment_length) {
4561
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4562
+ const len0 = WASM_VECTOR_LEN;
4563
+ var ptr1 = isLikeNone(cost_function) ? 0 : passStringToWasm0(cost_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4564
+ var len1 = WASM_VECTOR_LEN;
4565
+ const ret = wasm.detectChangepoints(ptr0, len0, penalty, ptr1, len1, isLikeNone(min_segment_length) ? 0x100000001 : (min_segment_length) >>> 0);
4566
+ if (ret[2]) {
4567
+ throw takeFromExternrefTable0(ret[1]);
4568
+ }
4569
+ return takeFromExternrefTable0(ret[0]);
4570
+ }
4571
+
4572
+ /**
4573
+ * Detect changepoints using BIC penalty (penalty = log(n)).
4574
+ *
4575
+ * BIC penalty automatically adapts to series length, providing a good
4576
+ * default for most use cases.
4577
+ *
4578
+ * @param values - Array of numeric values
4579
+ * @param costFunction - Cost function (default: "l2")
4580
+ * @returns Object with changepoint detection results
4581
+ * @param {Float64Array} values
4582
+ * @param {string | null} [cost_function]
4583
+ * @returns {any}
4584
+ */
4585
+ export function detectChangepointsBic(values, cost_function) {
4586
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4587
+ const len0 = WASM_VECTOR_LEN;
4588
+ var ptr1 = isLikeNone(cost_function) ? 0 : passStringToWasm0(cost_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4589
+ var len1 = WASM_VECTOR_LEN;
4590
+ const ret = wasm.detectChangepointsBic(ptr0, len0, ptr1, len1);
4591
+ if (ret[2]) {
4592
+ throw takeFromExternrefTable0(ret[1]);
4593
+ }
4594
+ return takeFromExternrefTable0(ret[0]);
4595
+ }
4596
+
4597
+ /**
4598
+ * Run comprehensive residual diagnostics.
4599
+ *
4600
+ * Combines Ljung-Box (autocorrelation), Durbin-Watson (first-order autocorrelation),
4601
+ * and Jarque-Bera (normality) tests into a single diagnostic report.
4602
+ *
4603
+ * @param residuals - Array of model residuals
4604
+ * @param fittedParams - Number of fitted model parameters (default: 0)
4605
+ * @returns Object with `ljungBox`, `durbinWatson`, `jarqueBera`, `mean`, `variance`, `n`, and `isAdequate`
4606
+ * @param {Float64Array} residuals
4607
+ * @param {number | null} [fitted_params]
4608
+ * @returns {any}
4609
+ */
4610
+ export function diagnoseResiduals(residuals, fitted_params) {
4611
+ const ptr0 = passArrayF64ToWasm0(residuals, wasm.__wbindgen_malloc);
4612
+ const len0 = WASM_VECTOR_LEN;
4613
+ const ret = wasm.diagnoseResiduals(ptr0, len0, isLikeNone(fitted_params) ? 0x100000001 : (fitted_params) >>> 0);
4614
+ if (ret[2]) {
4615
+ throw takeFromExternrefTable0(ret[1]);
4616
+ }
4617
+ return takeFromExternrefTable0(ret[0]);
4618
+ }
4619
+
4620
+ /**
4621
+ * Perform the Durbin-Watson test for first-order autocorrelation.
4622
+ *
4623
+ * The statistic ranges from 0 to 4:
4624
+ * - Near 0: Strong positive autocorrelation
4625
+ * - Near 2: No autocorrelation
4626
+ * - Near 4: Strong negative autocorrelation
4627
+ *
4628
+ * @param residuals - Array of model residuals
4629
+ * @returns Object with `statistic` and `interpretation`
4630
+ * @param {Float64Array} residuals
4631
+ * @returns {any}
4632
+ */
4633
+ export function durbinWatson(residuals) {
4634
+ const ptr0 = passArrayF64ToWasm0(residuals, wasm.__wbindgen_malloc);
4635
+ const len0 = WASM_VECTOR_LEN;
4636
+ const ret = wasm.durbinWatson(ptr0, len0);
4637
+ if (ret[2]) {
4638
+ throw takeFromExternrefTable0(ret[1]);
4639
+ }
4640
+ return takeFromExternrefTable0(ret[0]);
4641
+ }
4642
+
2607
4643
  /**
2608
4644
  * Initialize the WASM module.
2609
4645
  *
@@ -2613,6 +4649,237 @@ export function init() {
2613
4649
  wasm.init();
2614
4650
  }
2615
4651
 
4652
+ /**
4653
+ * Perform the Jarque-Bera test for normality of residuals.
4654
+ *
4655
+ * Tests the null hypothesis that residuals are normally distributed by
4656
+ * examining skewness and kurtosis. A high statistic (low p-value) suggests
4657
+ * non-normality.
4658
+ *
4659
+ * @param residuals - Array of model residuals
4660
+ * @returns Object with `statistic`, `pValue`, `isNormal`, `skewness`, and `excessKurtosis`
4661
+ * @param {Float64Array} residuals
4662
+ * @returns {any}
4663
+ */
4664
+ export function jarqueBera(residuals) {
4665
+ const ptr0 = passArrayF64ToWasm0(residuals, wasm.__wbindgen_malloc);
4666
+ const len0 = WASM_VECTOR_LEN;
4667
+ const ret = wasm.jarqueBera(ptr0, len0);
4668
+ if (ret[2]) {
4669
+ throw takeFromExternrefTable0(ret[1]);
4670
+ }
4671
+ return takeFromExternrefTable0(ret[0]);
4672
+ }
4673
+
4674
+ /**
4675
+ * Perform the KPSS test for stationarity.
4676
+ *
4677
+ * Tests the null hypothesis that the series is (level) stationary.
4678
+ * Rejection (high statistic above critical values) implies non-stationarity.
4679
+ *
4680
+ * Note: ADF and KPSS test opposite null hypotheses:
4681
+ * - ADF: H0 = non-stationary, reject = stationary
4682
+ * - KPSS: H0 = stationary, reject = non-stationary
4683
+ *
4684
+ * @param values - Array of numeric values
4685
+ * @param lags - Number of lags for HAC variance (default: 4*(n/100)^0.25)
4686
+ * @returns Object with `statistic`, `pValue`, `lags`, `isStationary`, and `criticalValues`
4687
+ * @param {Float64Array} values
4688
+ * @param {number | null} [lags]
4689
+ * @returns {any}
4690
+ */
4691
+ export function kpssTest(values, lags) {
4692
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4693
+ const len0 = WASM_VECTOR_LEN;
4694
+ const ret = wasm.kpssTest(ptr0, len0, isLikeNone(lags) ? 0x100000001 : (lags) >>> 0);
4695
+ if (ret[2]) {
4696
+ throw takeFromExternrefTable0(ret[1]);
4697
+ }
4698
+ return takeFromExternrefTable0(ret[0]);
4699
+ }
4700
+
4701
+ /**
4702
+ * Compute the excess kurtosis (fourth standardized moment) of a time series.
4703
+ *
4704
+ * Measures the "tailedness" of the distribution. A normal distribution has
4705
+ * excess kurtosis of 0.
4706
+ *
4707
+ * @param values - Array of numeric values
4708
+ * @returns Excess kurtosis, or NaN if fewer than 4 values
4709
+ * @param {Float64Array} values
4710
+ * @returns {number}
4711
+ */
4712
+ export function kurtosis(values) {
4713
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4714
+ const len0 = WASM_VECTOR_LEN;
4715
+ const ret = wasm.kurtosis(ptr0, len0);
4716
+ return ret;
4717
+ }
4718
+
4719
+ /**
4720
+ * Perform the Ljung-Box test for autocorrelation in residuals.
4721
+ *
4722
+ * Tests the null hypothesis that residuals are independently distributed
4723
+ * (white noise). A low p-value suggests significant autocorrelation remains.
4724
+ *
4725
+ * @param residuals - Array of model residuals
4726
+ * @param lags - Number of lags to include (default: min(10, n/5))
4727
+ * @param fittedParams - Number of fitted model parameters (for df adjustment, default: 0)
4728
+ * @returns Object with `statistic`, `pValue`, `lags`, `df`, and `isWhiteNoise`
4729
+ * @param {Float64Array} residuals
4730
+ * @param {number | null} [lags]
4731
+ * @param {number | null} [fitted_params]
4732
+ * @returns {any}
4733
+ */
4734
+ export function ljungBox(residuals, lags, fitted_params) {
4735
+ const ptr0 = passArrayF64ToWasm0(residuals, wasm.__wbindgen_malloc);
4736
+ const len0 = WASM_VECTOR_LEN;
4737
+ const ret = wasm.ljungBox(ptr0, len0, isLikeNone(lags) ? 0x100000001 : (lags) >>> 0, isLikeNone(fitted_params) ? 0x100000001 : (fitted_params) >>> 0);
4738
+ if (ret[2]) {
4739
+ throw takeFromExternrefTable0(ret[1]);
4740
+ }
4741
+ return takeFromExternrefTable0(ret[0]);
4742
+ }
4743
+
4744
+ /**
4745
+ * Compute the arithmetic mean of a time series.
4746
+ *
4747
+ * @param values - Array of numeric values
4748
+ * @returns Arithmetic mean, or NaN if empty
4749
+ * @param {Float64Array} values
4750
+ * @returns {number}
4751
+ */
4752
+ export function mean(values) {
4753
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4754
+ const len0 = WASM_VECTOR_LEN;
4755
+ const ret = wasm.mean(ptr0, len0);
4756
+ return ret;
4757
+ }
4758
+
4759
+ /**
4760
+ * Perform MSTL (Multiple Seasonal-Trend decomposition using LOESS).
4761
+ *
4762
+ * Decomposes a time series with multiple seasonal periods into trend,
4763
+ * multiple seasonal components, and remainder.
4764
+ *
4765
+ * @param values - Array of numeric values
4766
+ * @param periods - Array of seasonal periods (e.g., [7, 365] for daily data)
4767
+ * @returns Object with `trend`, `seasonals` (array of arrays), `seasonalPeriods`, `remainder`, and `trendStrength`
4768
+ * @param {Float64Array} values
4769
+ * @param {Uint32Array} periods
4770
+ * @returns {any}
4771
+ */
4772
+ export function mstlDecompose(values, periods) {
4773
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4774
+ const len0 = WASM_VECTOR_LEN;
4775
+ const ptr1 = passArray32ToWasm0(periods, wasm.__wbindgen_malloc);
4776
+ const len1 = WASM_VECTOR_LEN;
4777
+ const ret = wasm.mstlDecompose(ptr0, len0, ptr1, len1);
4778
+ if (ret[2]) {
4779
+ throw takeFromExternrefTable0(ret[1]);
4780
+ }
4781
+ return takeFromExternrefTable0(ret[0]);
4782
+ }
4783
+
4784
+ /**
4785
+ * Compute the partial autocorrelation of a time series at a specific lag.
4786
+ *
4787
+ * Uses the Durbin-Levinson algorithm.
4788
+ *
4789
+ * @param values - Array of numeric values
4790
+ * @param lag - Lag value (must be >= 1)
4791
+ * @returns Partial autocorrelation coefficient at the given lag
4792
+ * @param {Float64Array} values
4793
+ * @param {number} lag
4794
+ * @returns {number}
4795
+ */
4796
+ export function partialAutocorrelation(values, lag) {
4797
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4798
+ const len0 = WASM_VECTOR_LEN;
4799
+ const ret = wasm.partialAutocorrelation(ptr0, len0, lag);
4800
+ return ret;
4801
+ }
4802
+
4803
+ /**
4804
+ * Compute the sample entropy of a time series.
4805
+ *
4806
+ * Measures the complexity/regularity of a time series. Lower values indicate
4807
+ * more regularity. Unlike approximate entropy, excludes self-matches.
4808
+ *
4809
+ * @param values - Array of numeric values
4810
+ * @param m - Embedding dimension (typically 2)
4811
+ * @param r - Tolerance (typically 0.2 * standard deviation)
4812
+ * @returns Sample entropy, or NaN if insufficient data
4813
+ * @param {Float64Array} values
4814
+ * @param {number} m
4815
+ * @param {number} r
4816
+ * @returns {number}
4817
+ */
4818
+ export function sampleEntropy(values, m, r) {
4819
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4820
+ const len0 = WASM_VECTOR_LEN;
4821
+ const ret = wasm.sampleEntropy(ptr0, len0, m, r);
4822
+ return ret;
4823
+ }
4824
+
4825
+ /**
4826
+ * Compute the skewness (third standardized moment) of a time series.
4827
+ *
4828
+ * Measures the asymmetry of the distribution.
4829
+ *
4830
+ * @param values - Array of numeric values
4831
+ * @returns Skewness, or NaN if fewer than 3 values
4832
+ * @param {Float64Array} values
4833
+ * @returns {number}
4834
+ */
4835
+ export function skewness(values) {
4836
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4837
+ const len0 = WASM_VECTOR_LEN;
4838
+ const ret = wasm.skewness(ptr0, len0);
4839
+ return ret;
4840
+ }
4841
+
4842
+ /**
4843
+ * Perform STL (Seasonal-Trend decomposition using LOESS).
4844
+ *
4845
+ * Decomposes a time series into trend, seasonal, and remainder components.
4846
+ *
4847
+ * @param values - Array of numeric values
4848
+ * @param period - Seasonal period (e.g., 12 for monthly data)
4849
+ * @param robust - Enable robust fitting to reduce outlier influence (default: false)
4850
+ * @returns Object with `trend`, `seasonal`, `remainder`, `seasonalStrength`, and `trendStrength`
4851
+ * @param {Float64Array} values
4852
+ * @param {number} period
4853
+ * @param {boolean | null} [robust]
4854
+ * @returns {any}
4855
+ */
4856
+ export function stlDecompose(values, period, robust) {
4857
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4858
+ const len0 = WASM_VECTOR_LEN;
4859
+ const ret = wasm.stlDecompose(ptr0, len0, period, isLikeNone(robust) ? 0xFFFFFF : robust ? 1 : 0);
4860
+ if (ret[2]) {
4861
+ throw takeFromExternrefTable0(ret[1]);
4862
+ }
4863
+ return takeFromExternrefTable0(ret[0]);
4864
+ }
4865
+
4866
+ /**
4867
+ * Compute the population variance of a time series.
4868
+ *
4869
+ * Uses population formula (n denominator) matching tsfresh.
4870
+ *
4871
+ * @param values - Array of numeric values
4872
+ * @returns Population variance, or NaN if empty
4873
+ * @param {Float64Array} values
4874
+ * @returns {number}
4875
+ */
4876
+ export function variance(values) {
4877
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
4878
+ const len0 = WASM_VECTOR_LEN;
4879
+ const ret = wasm.variance(ptr0, len0);
4880
+ return ret;
4881
+ }
4882
+
2616
4883
  /**
2617
4884
  * Get the library version.
2618
4885
  * @returns {string}
@@ -2669,17 +4936,156 @@ function __wbg_get_imports() {
2669
4936
  const ret = Error(getStringFromWasm0(arg0, arg1));
2670
4937
  return ret;
2671
4938
  };
4939
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
4940
+ const ret = String(arg1);
4941
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4942
+ const len1 = WASM_VECTOR_LEN;
4943
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4944
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4945
+ };
4946
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
4947
+ const ret = typeof(arg0) === 'function';
4948
+ return ret;
4949
+ };
4950
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
4951
+ const val = arg0;
4952
+ const ret = typeof(val) === 'object' && val !== null;
4953
+ return ret;
4954
+ };
4955
+ imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
4956
+ const ret = typeof(arg0) === 'string';
4957
+ return ret;
4958
+ };
4959
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
4960
+ const ret = arg0 === undefined;
4961
+ return ret;
4962
+ };
4963
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
4964
+ const obj = arg1;
4965
+ const ret = typeof(obj) === 'string' ? obj : undefined;
4966
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4967
+ var len1 = WASM_VECTOR_LEN;
4968
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4969
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4970
+ };
2672
4971
  imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
2673
4972
  throw new Error(getStringFromWasm0(arg0, arg1));
2674
4973
  };
4974
+ imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
4975
+ const ret = arg0.call(arg1, arg2);
4976
+ return ret;
4977
+ }, arguments) };
4978
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
4979
+ const ret = arg0.call(arg1);
4980
+ return ret;
4981
+ }, arguments) };
4982
+ imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
4983
+ const ret = arg0.crypto;
4984
+ return ret;
4985
+ };
4986
+ imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
4987
+ arg0.getRandomValues(arg1);
4988
+ }, arguments) };
2675
4989
  imports.wbg.__wbg_getTime_ad1e9878a735af08 = function(arg0) {
2676
4990
  const ret = arg0.getTime();
2677
4991
  return ret;
2678
4992
  };
4993
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
4994
+ const ret = arg0.length;
4995
+ return ret;
4996
+ };
4997
+ imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
4998
+ const ret = arg0.msCrypto;
4999
+ return ret;
5000
+ };
2679
5001
  imports.wbg.__wbg_new_0_23cedd11d9b40c9d = function() {
2680
5002
  const ret = new Date();
2681
5003
  return ret;
2682
5004
  };
5005
+ imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
5006
+ const ret = new Object();
5007
+ return ret;
5008
+ };
5009
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
5010
+ const ret = new Array();
5011
+ return ret;
5012
+ };
5013
+ imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
5014
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
5015
+ return ret;
5016
+ };
5017
+ imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
5018
+ const ret = new Uint8Array(arg0 >>> 0);
5019
+ return ret;
5020
+ };
5021
+ imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
5022
+ const ret = arg0.node;
5023
+ return ret;
5024
+ };
5025
+ imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
5026
+ const ret = arg0.process;
5027
+ return ret;
5028
+ };
5029
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
5030
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
5031
+ };
5032
+ imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
5033
+ arg0.randomFillSync(arg1);
5034
+ }, arguments) };
5035
+ imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
5036
+ const ret = module.require;
5037
+ return ret;
5038
+ }, arguments) };
5039
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
5040
+ arg0[arg1] = arg2;
5041
+ };
5042
+ imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
5043
+ arg0[arg1 >>> 0] = arg2;
5044
+ };
5045
+ imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
5046
+ const ret = typeof global === 'undefined' ? null : global;
5047
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5048
+ };
5049
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
5050
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
5051
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5052
+ };
5053
+ imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
5054
+ const ret = typeof self === 'undefined' ? null : self;
5055
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5056
+ };
5057
+ imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
5058
+ const ret = typeof window === 'undefined' ? null : window;
5059
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5060
+ };
5061
+ imports.wbg.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) {
5062
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
5063
+ return ret;
5064
+ };
5065
+ imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
5066
+ const ret = arg0.versions;
5067
+ return ret;
5068
+ };
5069
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
5070
+ // Cast intrinsic for `Ref(String) -> Externref`.
5071
+ const ret = getStringFromWasm0(arg0, arg1);
5072
+ return ret;
5073
+ };
5074
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
5075
+ // Cast intrinsic for `U64 -> Externref`.
5076
+ const ret = BigInt.asUintN(64, arg0);
5077
+ return ret;
5078
+ };
5079
+ imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
5080
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
5081
+ const ret = getArrayU8FromWasm0(arg0, arg1);
5082
+ return ret;
5083
+ };
5084
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
5085
+ // Cast intrinsic for `F64 -> Externref`.
5086
+ const ret = arg0;
5087
+ return ret;
5088
+ };
2683
5089
  imports.wbg.__wbindgen_init_externref_table = function() {
2684
5090
  const table = wasm.__wbindgen_externrefs;
2685
5091
  const offset = table.grow(4);
@@ -2696,6 +5102,7 @@ function __wbg_get_imports() {
2696
5102
  function __wbg_finalize_init(instance, module) {
2697
5103
  wasm = instance.exports;
2698
5104
  __wbg_init.__wbindgen_wasm_module = module;
5105
+ cachedDataViewMemory0 = null;
2699
5106
  cachedFloat64ArrayMemory0 = null;
2700
5107
  cachedUint32ArrayMemory0 = null;
2701
5108
  cachedUint8ArrayMemory0 = null;