@glandais/vcyclist-engine 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,50 +30,55 @@
30
30
  var imul = Math.imul;
31
31
  var hypot = Math.hypot;
32
32
  var sign = Math.sign;
33
- var protoOf = kotlin_kotlin.$_$.c7;
34
- var initMetadataForCompanion = kotlin_kotlin.$_$.o6;
33
+ var protoOf = kotlin_kotlin.$_$.d7;
34
+ var initMetadataForCompanion = kotlin_kotlin.$_$.p6;
35
35
  var VOID = kotlin_kotlin.$_$.a;
36
- var getNumberHashCode = kotlin_kotlin.$_$.j6;
37
- var equals = kotlin_kotlin.$_$.g6;
38
- var initMetadataForClass = kotlin_kotlin.$_$.n6;
39
- var toString = kotlin_kotlin.$_$.f7;
40
- var hashCode = kotlin_kotlin.$_$.m6;
41
- var getBooleanHashCode = kotlin_kotlin.$_$.i6;
36
+ var getNumberHashCode = kotlin_kotlin.$_$.k6;
37
+ var equals = kotlin_kotlin.$_$.h6;
38
+ var initMetadataForClass = kotlin_kotlin.$_$.o6;
39
+ var toString = kotlin_kotlin.$_$.g7;
40
+ var hashCode = kotlin_kotlin.$_$.n6;
41
+ var initMetadataForObject = kotlin_kotlin.$_$.u6;
42
+ var getBooleanHashCode = kotlin_kotlin.$_$.j6;
42
43
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.a2;
43
44
  var Unit_instance = kotlin_kotlin.$_$.g1;
44
- var CoroutineImpl = kotlin_kotlin.$_$.x4;
45
+ var CoroutineImpl = kotlin_kotlin.$_$.y4;
45
46
  var PointPerDistance_instance = kotlin_io_github_glandais_gpx.$_$.k;
46
47
  var ElevationStep_instance = kotlin_io_github_glandais_gpx.$_$.h;
47
- var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.i4;
48
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.j4;
48
49
  var PointPerSecond_instance = kotlin_io_github_glandais_gpx.$_$.l;
49
50
  var PathSimplifier_instance = kotlin_io_github_glandais_gpx.$_$.i;
50
- var initMetadataForCoroutine = kotlin_kotlin.$_$.p6;
51
- var initMetadataForObject = kotlin_kotlin.$_$.t6;
51
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.q6;
52
+ var enumEntries = kotlin_kotlin.$_$.a5;
53
+ var Enum = kotlin_kotlin.$_$.l9;
52
54
  var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j1;
53
55
  var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i1;
54
- var last = kotlin_kotlin.$_$.o3;
55
- var toIntArray = kotlin_kotlin.$_$.a4;
56
- var sortedWith = kotlin_kotlin.$_$.y3;
57
- var toMutableList = kotlin_kotlin.$_$.e4;
56
+ var last = kotlin_kotlin.$_$.p3;
57
+ var toIntArray = kotlin_kotlin.$_$.b4;
58
+ var sortedWith = kotlin_kotlin.$_$.z3;
59
+ var toMutableList = kotlin_kotlin.$_$.f4;
58
60
  var first = kotlin_kotlin.$_$.i3;
59
- var removeAll = kotlin_kotlin.$_$.t3;
60
- var numberRangeToNumber = kotlin_kotlin.$_$.y6;
61
+ var removeAll = kotlin_kotlin.$_$.u3;
62
+ var numberRangeToNumber = kotlin_kotlin.$_$.z6;
61
63
  var collectionSizeOrDefault = kotlin_kotlin.$_$.x2;
62
64
  var Vector3D = kotlin_io_github_glandais_elevation.$_$.g;
63
65
  var emptyList = kotlin_kotlin.$_$.f3;
64
- var coerceIn = kotlin_kotlin.$_$.m7;
66
+ var coerceIn = kotlin_kotlin.$_$.n7;
65
67
  var DouglasPeucker_instance = kotlin_io_github_glandais_elevation.$_$.b;
66
- var FunctionAdapter = kotlin_kotlin.$_$.u5;
67
- var isInterface = kotlin_kotlin.$_$.v6;
68
- var Comparator = kotlin_kotlin.$_$.i9;
69
- var compareValues = kotlin_kotlin.$_$.g4;
70
- var until = kotlin_kotlin.$_$.q7;
71
- var Pair = kotlin_kotlin.$_$.p9;
72
- var listOf = kotlin_kotlin.$_$.p3;
68
+ var FunctionAdapter = kotlin_kotlin.$_$.v5;
69
+ var isInterface = kotlin_kotlin.$_$.w6;
70
+ var Comparator = kotlin_kotlin.$_$.k9;
71
+ var compareValues = kotlin_kotlin.$_$.h4;
72
+ var until = kotlin_kotlin.$_$.r7;
73
+ var Pair = kotlin_kotlin.$_$.r9;
74
+ var listOf = kotlin_kotlin.$_$.q3;
73
75
  var Default_getInstance = kotlin_kotlin.$_$.b1;
74
- var isFinite = kotlin_kotlin.$_$.ca;
76
+ var Companion_instance = kotlin_kotlin.$_$.e1;
77
+ var equals_0 = kotlin_kotlin.$_$.h8;
78
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.ia;
79
+ var isFinite = kotlin_kotlin.$_$.ea;
75
80
  var PointField_TEMPERATURE_getInstance = kotlin_io_github_glandais_gpx.$_$.c;
76
- var isNaN_0 = kotlin_kotlin.$_$.ea;
81
+ var isNaN_0 = kotlin_kotlin.$_$.ga;
77
82
  var get_entries = kotlin_io_github_glandais_gpx.$_$.u;
78
83
  var Path = kotlin_io_github_glandais_gpx.$_$.t;
79
84
  var GpxParser_instance = kotlin_io_github_glandais_gpx.$_$.d;
@@ -82,36 +87,39 @@
82
87
  var tracksAsPaths = kotlin_io_github_glandais_gpx.$_$.q;
83
88
  var segmentsAsPaths = kotlin_io_github_glandais_gpx.$_$.o;
84
89
  var GpxPathKind_TRACK_getInstance = kotlin_io_github_glandais_gpx.$_$.b;
85
- var setOf = kotlin_kotlin.$_$.w3;
90
+ var setOf = kotlin_kotlin.$_$.x3;
86
91
  var GpxPathKind_ROUTE_getInstance = kotlin_io_github_glandais_gpx.$_$.a;
87
92
  var GpxWriter_instance = kotlin_io_github_glandais_gpx.$_$.e;
88
- var toList = kotlin_kotlin.$_$.d4;
93
+ var toList = kotlin_kotlin.$_$.e4;
89
94
  var toGpxDocument = kotlin_io_github_glandais_gpx.$_$.p;
90
95
  var Companion_getInstance = kotlin_kotlin.$_$.d1;
91
- var numberToLong = kotlin_kotlin.$_$.o5;
96
+ var numberToLong = kotlin_kotlin.$_$.p5;
92
97
  var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
93
98
  var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
94
99
  var Companion_getInstance_0 = kotlin_io_github_glandais_gpx.$_$.j;
95
100
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.c2;
96
101
  var CsvWriter_instance = kotlin_io_github_glandais_gpx.$_$.f;
97
- var firstOrNull = kotlin_kotlin.$_$.g8;
102
+ var firstOrNull = kotlin_kotlin.$_$.i8;
98
103
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b;
99
- var Char = kotlin_kotlin.$_$.h9;
104
+ var Char = kotlin_kotlin.$_$.j9;
100
105
  var CsvOptions = kotlin_io_github_glandais_gpx.$_$.r;
101
106
  var JsonWriter_instance = kotlin_io_github_glandais_gpx.$_$.g;
102
107
  var JsonOptions = kotlin_io_github_glandais_gpx.$_$.s;
103
108
  var toFitBytes = kotlin_io_github_glandais_fit.$_$.a;
104
109
  var Companion_getInstance_1 = kotlin_kotlin.$_$.c1;
105
110
  var DurationUnit_MILLISECONDS_getInstance = kotlin_kotlin.$_$.w;
106
- var toDuration = kotlin_kotlin.$_$.g9;
111
+ var toDuration = kotlin_kotlin.$_$.i9;
107
112
  var toFitBytes_0 = kotlin_io_github_glandais_fit.$_$.b;
108
- var toNumber = kotlin_kotlin.$_$.t5;
113
+ var toNumber = kotlin_kotlin.$_$.u5;
109
114
  var GpxWaypoint = kotlin_io_github_glandais_gpx.$_$.m;
110
- var THROW_CCE = kotlin_kotlin.$_$.s9;
115
+ var joinToString = kotlin_kotlin.$_$.l3;
116
+ var sorted = kotlin_kotlin.$_$.a4;
117
+ var THROW_CCE = kotlin_kotlin.$_$.u9;
111
118
  var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
112
119
  var ElevationProvider = kotlin_io_github_glandais_elevation.$_$.d;
113
- var initMetadataForLambda = kotlin_kotlin.$_$.s6;
114
- var constructCallableReference = kotlin_kotlin.$_$.d6;
120
+ var initMetadataForLambda = kotlin_kotlin.$_$.t6;
121
+ var constructCallableReference = kotlin_kotlin.$_$.e6;
122
+ var setOf_0 = kotlin_kotlin.$_$.y3;
115
123
  //endregion
116
124
  //region block: pre-declaration
117
125
  initMetadataForCompanion(Companion);
@@ -121,12 +129,14 @@
121
129
  initMetadataForClass(CoursePhysics, 'CoursePhysics');
122
130
  initMetadataForCompanion(Companion_1);
123
131
  initMetadataForClass(Cyclist, 'Cyclist', Cyclist);
132
+ initMetadataForObject(EngineConstants, 'EngineConstants');
124
133
  initMetadataForClass(SimplifyPathOptions, 'SimplifyPathOptions', SimplifyPathOptions);
125
134
  initMetadataForClass(WPrimeBalanceOptions, 'WPrimeBalanceOptions', WPrimeBalanceOptions);
126
135
  initMetadataForCompanion(Companion_2);
127
136
  initMetadataForClass(EnhanceOptions, 'EnhanceOptions', EnhanceOptions);
128
137
  initMetadataForCoroutine($enhanceCourseCOROUTINE$, CoroutineImpl);
129
138
  initMetadataForObject(Enhancer, 'Enhancer', VOID, VOID, VOID, [3]);
139
+ initMetadataForClass(RoadCondition, 'RoadCondition', VOID, Enum);
130
140
  initMetadataForClass(Climb, 'Climb');
131
141
  initMetadataForClass(ClimbPart, 'ClimbPart');
132
142
  initMetadataForCompanion(Companion_3);
@@ -141,21 +151,29 @@
141
151
  initMetadataForObject(AeroProviderConstant, 'AeroProviderConstant');
142
152
  initMetadataForCompanion(Companion_5);
143
153
  initMetadataForClass(CyclistPowerProviderBase, 'CyclistPowerProviderBase');
154
+ initMetadataForCompanion(Companion_6);
155
+ initMetadataForClass(PowerModel, 'PowerModel', VOID, Enum);
156
+ initMetadataForClass(CyclistPowerSpec, 'CyclistPowerSpec', CyclistPowerSpec);
144
157
  initMetadataForObject(GravPowerProvider, 'GravPowerProvider');
145
158
  initMetadataForClass(Harmonic, 'Harmonic');
146
159
  initMetadataForObject(MaxSpeedComputer, 'MaxSpeedComputer');
147
160
  initMetadataForObject(MuscularPowerProvider, 'MuscularPowerProvider');
148
161
  initMetadataForObject(PowerComputer, 'PowerComputer');
149
162
  initMetadataForClass(PowerProviderConstant, 'PowerProviderConstant', VOID, CyclistPowerProviderBase);
150
- initMetadataForCompanion(Companion_6);
163
+ initMetadataForCompanion(Companion_7);
164
+ initMetadataForClass(PowerProviderCriticalPower, 'PowerProviderCriticalPower', VOID, CyclistPowerProviderBase);
165
+ initMetadataForCompanion(Companion_8);
151
166
  initMetadataForClass(PowerProviderDurability, 'PowerProviderDurability', VOID, CyclistPowerProviderBase);
152
167
  initMetadataForObject(PowerProviderFromData, 'PowerProviderFromData');
168
+ initMetadataForClass(PowerProviderSlewLimited, 'PowerProviderSlewLimited');
169
+ initMetadataForCompanion(Companion_9);
170
+ initMetadataForClass(PowerProviderTerrainPacing, 'PowerProviderTerrainPacing');
153
171
  initMetadataForObject(RhoProviderDefault, 'RhoProviderDefault');
154
172
  initMetadataForObject(RhoProviderEstimate, 'RhoProviderEstimate');
155
173
  initMetadataForObject(RollingResistancePowerProvider, 'RollingResistancePowerProvider');
156
174
  initMetadataForObject(VirtualizeService, 'VirtualizeService');
157
175
  initMetadataForObject(WheelBearingsPowerProvider, 'WheelBearingsPowerProvider');
158
- initMetadataForCompanion(Companion_7);
176
+ initMetadataForCompanion(Companion_10);
159
177
  initMetadataForClass(Wind, 'Wind');
160
178
  initMetadataForObject(WindProviderNone, 'WindProviderNone');
161
179
  initMetadataForClass(WindProviderConstant, 'WindProviderConstant');
@@ -164,14 +182,14 @@
164
182
  initMetadataForLambda(enhanceWithCourse$slambda, CoroutineImpl, VOID, [1]);
165
183
  //endregion
166
184
  function Companion() {
167
- Companion_instance = this;
185
+ Companion_instance_0 = this;
168
186
  this.DEFAULT_1 = new Bike();
169
187
  }
170
- var Companion_instance;
188
+ var Companion_instance_0;
171
189
  function Companion_getInstance_2() {
172
- if (Companion_instance == null)
190
+ if (Companion_instance_0 == null)
173
191
  new Companion();
174
- return Companion_instance;
192
+ return Companion_instance_0;
175
193
  }
176
194
  function Bike(crr, inertiaFront, inertiaRear, wheelRadiusM, efficiency, maxPedalingLeanAngleDeg) {
177
195
  Companion_getInstance_2();
@@ -269,14 +287,14 @@
269
287
  return true;
270
288
  };
271
289
  function Companion_0() {
272
- Companion_instance_0 = this;
290
+ Companion_instance_1 = this;
273
291
  this.DEFAULT_CYCLIST_POWER_PROVIDER_1 = new PowerProviderConstant(280.0);
274
292
  }
275
- var Companion_instance_0;
293
+ var Companion_instance_1;
276
294
  function Companion_getInstance_3() {
277
- if (Companion_instance_0 == null)
295
+ if (Companion_instance_1 == null)
278
296
  new Companion_0();
279
- return Companion_instance_0;
297
+ return Companion_instance_1;
280
298
  }
281
299
  function CoursePhysics(course, rhoProvider, aeroProvider, windProvider, cyclistPowerProvider) {
282
300
  Companion_getInstance_3();
@@ -339,14 +357,14 @@
339
357
  return true;
340
358
  };
341
359
  function Companion_1() {
342
- Companion_instance_1 = this;
360
+ Companion_instance_2 = this;
343
361
  this.DEFAULT_1 = new Cyclist();
344
362
  }
345
- var Companion_instance_1;
363
+ var Companion_instance_2;
346
364
  function Companion_getInstance_4() {
347
- if (Companion_instance_1 == null)
365
+ if (Companion_instance_2 == null)
348
366
  new Companion_1();
349
- return Companion_instance_1;
367
+ return Companion_instance_2;
350
368
  }
351
369
  function Cyclist(massKg, maxBrakeG, cd, frontalAreaM2, maxLeanAngleDeg, maxSpeedKmH) {
352
370
  Companion_getInstance_4();
@@ -405,6 +423,43 @@
405
423
  return false;
406
424
  return true;
407
425
  };
426
+ function EngineConstants() {
427
+ EngineConstants_instance = this;
428
+ this.G_1 = 9.80665;
429
+ this.MINIMAL_SPEED_1 = 0.5555555555555556;
430
+ this.DEFAULT_CRR_1 = 0.004;
431
+ this.DEFAULT_INERTIA_FRONT_1 = 0.05;
432
+ this.DEFAULT_INERTIA_REAR_1 = 0.07;
433
+ this.DEFAULT_WHEEL_RADIUS_M_1 = 0.35;
434
+ this.DEFAULT_DRIVETRAIN_EFFICIENCY_1 = 0.976;
435
+ this.DEFAULT_MAX_PEDALING_LEAN_ANGLE_DEG_1 = 20.0;
436
+ this.DEFAULT_CYCLIST_MASS_KG_1 = 80.0;
437
+ this.DEFAULT_CYCLIST_POWER_W_1 = 280.0;
438
+ this.DEFAULT_MAX_POWER_SLEW_W_PER_S_1 = 50.0;
439
+ this.DEFAULT_MAX_BRAKE_G_1 = 0.4;
440
+ this.DEFAULT_MAX_LEAN_ANGLE_DEG_1 = 35.0;
441
+ this.DRY_ROAD_MU_1 = 0.9;
442
+ this.WET_ROAD_MU_1 = 0.36;
443
+ this.PITCH_OVER_BRAKE_G_1 = 0.63;
444
+ var tmp = this;
445
+ // Inline function 'kotlin.math.tan' call
446
+ var x = 0.6108652381980153;
447
+ tmp.RIDER_GRIP_FRACTION_1 = Math.tan(x) / 0.9;
448
+ this.RIDER_BRAKE_FRACTION_1 = 0.634920634920635;
449
+ this.DEFAULT_MAX_LEAN_ANGLE_RAD_1 = 0.6108652381980153;
450
+ this.DEFAULT_MAX_SPEED_KMH_1 = 100.0;
451
+ this.DEFAULT_CRITICAL_POWER_W_1 = 250.0;
452
+ this.DEFAULT_W_PRIME_J_1 = 20000.0;
453
+ this.DEFAULT_DRAG_COEFFICIENT_1 = 0.7;
454
+ this.DEFAULT_FRONTAL_AREA_M2__1 = 0.5;
455
+ this.DEFAULT_AIR_DENSITY_1 = 1.225;
456
+ }
457
+ var EngineConstants_instance;
458
+ function EngineConstants_getInstance() {
459
+ if (EngineConstants_instance == null)
460
+ new EngineConstants();
461
+ return EngineConstants_instance;
462
+ }
408
463
  function SimplifyPathOptions(enabled, toleranceM, zExaggeration) {
409
464
  enabled = enabled === VOID ? true : enabled;
410
465
  toleranceM = toleranceM === VOID ? 10.0 : toleranceM;
@@ -476,14 +531,14 @@
476
531
  return true;
477
532
  };
478
533
  function Companion_2() {
479
- Companion_instance_2 = this;
534
+ Companion_instance_3 = this;
480
535
  this.DEFAULT_1 = new EnhanceOptions();
481
536
  }
482
- var Companion_instance_2;
537
+ var Companion_instance_3;
483
538
  function Companion_getInstance_5() {
484
- if (Companion_instance_2 == null)
539
+ if (Companion_instance_3 == null)
485
540
  new Companion_2();
486
- return Companion_instance_2;
541
+ return Companion_instance_3;
487
542
  }
488
543
  function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
489
544
  Companion_getInstance_5();
@@ -639,6 +694,48 @@
639
694
  function Enhancer_getInstance() {
640
695
  return Enhancer_instance;
641
696
  }
697
+ var static_init_called;
698
+ function static_init() {
699
+ if (static_init_called)
700
+ return Unit_instance;
701
+ static_init_called = true;
702
+ // Inline function 'kotlin.math.tan' call
703
+ var x = 0.6108652381980153;
704
+ var tmp$ret$0 = Math.tan(x);
705
+ RoadCondition_DRY_instance = new RoadCondition('DRY', 0, tmp$ret$0, 0.4);
706
+ RoadCondition_WET_instance = new RoadCondition('WET', 1, EngineConstants_getInstance().RIDER_GRIP_FRACTION_1 * 0.36, 0.634920634920635 * 0.36);
707
+ }
708
+ var RoadCondition_DRY_instance;
709
+ var RoadCondition_WET_instance;
710
+ function values() {
711
+ static_init();
712
+ return [RoadCondition_DRY_getInstance(), RoadCondition_WET_getInstance()];
713
+ }
714
+ function get_entries_0() {
715
+ static_init();
716
+ if ($ENTRIES == null)
717
+ $ENTRIES = enumEntries(values());
718
+ return $ENTRIES;
719
+ }
720
+ var $ENTRIES;
721
+ function RoadCondition(name, ordinal, mu, maxBrakeG) {
722
+ Enum.call(this, name, ordinal);
723
+ this.mu_1 = mu;
724
+ this.maxBrakeG_1 = maxBrakeG;
725
+ }
726
+ protoOf(RoadCondition).get_leanAngleDeg_9xbhfm_k$ = function () {
727
+ // Inline function 'kotlin.math.atan' call
728
+ var x = this.mu_1;
729
+ return Math.atan(x) * 180.0 / 3.141592653589793;
730
+ };
731
+ function RoadCondition_DRY_getInstance() {
732
+ static_init();
733
+ return RoadCondition_DRY_instance;
734
+ }
735
+ function RoadCondition_WET_getInstance() {
736
+ static_init();
737
+ return RoadCondition_WET_instance;
738
+ }
642
739
  function Climb(startIndex, endIndex, startDistanceM, endDistanceM, startElevationM, endElevationM, positiveElevationM, negativeElevationM, parts) {
643
740
  this.startIndex_1 = startIndex;
644
741
  this.endIndex_1 = endIndex;
@@ -763,14 +860,14 @@
763
860
  return true;
764
861
  };
765
862
  function Companion_3() {
766
- Companion_instance_3 = this;
863
+ Companion_instance_4 = this;
767
864
  this.DEFAULT_1 = new ClimbOptions();
768
865
  }
769
- var Companion_instance_3;
866
+ var Companion_instance_4;
770
867
  function Companion_getInstance_6() {
771
- if (Companion_instance_3 == null)
868
+ if (Companion_instance_4 == null)
772
869
  new Companion_3();
773
- return Companion_instance_3;
870
+ return Companion_instance_4;
774
871
  }
775
872
  function ClimbOptions(minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGradeRatio, booster, maxAnalysisPoints) {
776
873
  Companion_getInstance_6();
@@ -874,9 +971,9 @@
874
971
  }
875
972
  return new Profile(tmp_6, tmp_10, indices);
876
973
  };
877
- var Companion_instance_4;
974
+ var Companion_instance_5;
878
975
  function Companion_getInstance_7() {
879
- return Companion_instance_4;
976
+ return Companion_instance_5;
880
977
  }
881
978
  function Profile(distance, elevation, sourceIndex) {
882
979
  this.distance_1 = distance;
@@ -1129,7 +1226,7 @@
1129
1226
  // Inline function 'kotlin.comparisons.maxOf' call
1130
1227
  var b_0 = Math.min(tmp0_0, b);
1131
1228
  var minClimbElevation = Math.max(tmp0, b_0);
1132
- var profile = Companion_instance_4.of_tmvbpf_k$(path, options.maxAnalysisPoints_1);
1229
+ var profile = Companion_instance_5.of_tmvbpf_k$(path, options.maxAnalysisPoints_1);
1133
1230
  // Inline function 'kotlin.collections.mapNotNull' call
1134
1231
  var tmp0_1 = until(0, profile.get_size_woubt6_k$());
1135
1232
  // Inline function 'kotlin.collections.mapNotNullTo' call
@@ -1327,9 +1424,9 @@
1327
1424
  this.TOLERANCE_1 = 0.05;
1328
1425
  this.MAX_MULTIPLIER_1 = 3.0;
1329
1426
  }
1330
- var Companion_instance_5;
1427
+ var Companion_instance_6;
1331
1428
  function Companion_getInstance_8() {
1332
- return Companion_instance_5;
1429
+ return Companion_instance_6;
1333
1430
  }
1334
1431
  function CyclistPowerProviderBase(useHarmonics, random) {
1335
1432
  random = random === VOID ? Default_getInstance() : random;
@@ -1376,6 +1473,173 @@
1376
1473
  path.setPCyclistPowerNeeded_54po1x_k$(pointIndex, powerNeeded);
1377
1474
  return power;
1378
1475
  };
1476
+ var static_init_called_0;
1477
+ function static_init_0() {
1478
+ if (static_init_called_0)
1479
+ return Unit_instance;
1480
+ static_init_called_0 = true;
1481
+ PowerModel_CONSTANT_instance = new PowerModel('CONSTANT', 0, 'constant');
1482
+ PowerModel_DURABILITY_instance = new PowerModel('DURABILITY', 1, 'durability');
1483
+ PowerModel_CRITICAL_POWER_instance = new PowerModel('CRITICAL_POWER', 2, 'critical-power');
1484
+ PowerModel_FROM_DATA_instance = new PowerModel('FROM_DATA', 3, 'from_data');
1485
+ if (Companion_instance_7 == null) {
1486
+ Companion_instance;
1487
+ new Companion_6();
1488
+ }
1489
+ }
1490
+ var PowerModel_CONSTANT_instance;
1491
+ var PowerModel_DURABILITY_instance;
1492
+ var PowerModel_CRITICAL_POWER_instance;
1493
+ var PowerModel_FROM_DATA_instance;
1494
+ function Companion_6() {
1495
+ }
1496
+ protoOf(Companion_6).get_ids_18j3qp_k$ = function () {
1497
+ // Inline function 'kotlin.collections.map' call
1498
+ var this_0 = get_entries_1();
1499
+ // Inline function 'kotlin.collections.mapTo' call
1500
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1501
+ var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
1502
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
1503
+ var item = _iterator__ex2g4s.next_20eer_k$();
1504
+ var tmp$ret$2 = item.id_1;
1505
+ destination.add_utx5q5_k$(tmp$ret$2);
1506
+ }
1507
+ return destination;
1508
+ };
1509
+ protoOf(Companion_6).fromIdOrNull_83jhaj_k$ = function (id) {
1510
+ var tmp0 = get_entries_1();
1511
+ var tmp$ret$0;
1512
+ $l$block: {
1513
+ // Inline function 'kotlin.collections.firstOrNull' call
1514
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
1515
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
1516
+ var element = _iterator__ex2g4s.next_20eer_k$();
1517
+ if (equals_0(element.id_1, id, true)) {
1518
+ tmp$ret$0 = element;
1519
+ break $l$block;
1520
+ }
1521
+ }
1522
+ tmp$ret$0 = null;
1523
+ }
1524
+ return tmp$ret$0;
1525
+ };
1526
+ var Companion_instance_7;
1527
+ function Companion_getInstance_9() {
1528
+ return Companion_instance_7;
1529
+ }
1530
+ function values_0() {
1531
+ static_init_0();
1532
+ return [PowerModel_CONSTANT_getInstance(), PowerModel_DURABILITY_getInstance(), PowerModel_CRITICAL_POWER_getInstance(), PowerModel_FROM_DATA_getInstance()];
1533
+ }
1534
+ function get_entries_1() {
1535
+ static_init_0();
1536
+ if ($ENTRIES_0 == null)
1537
+ $ENTRIES_0 = enumEntries(values_0());
1538
+ return $ENTRIES_0;
1539
+ }
1540
+ var $ENTRIES_0;
1541
+ function PowerModel(name, ordinal, id) {
1542
+ Enum.call(this, name, ordinal);
1543
+ this.id_1 = id;
1544
+ }
1545
+ protoOf(PowerModel).toString = function () {
1546
+ return this.id_1;
1547
+ };
1548
+ function baseProvider($this) {
1549
+ var tmp;
1550
+ switch ($this.model_1.ordinal_1) {
1551
+ case 0:
1552
+ tmp = new PowerProviderConstant($this.powerW_1, $this.useHarmonics_1);
1553
+ break;
1554
+ case 1:
1555
+ tmp = new PowerProviderDurability($this.powerW_1, $this.criticalPowerW_1, VOID, VOID, $this.useHarmonics_1);
1556
+ break;
1557
+ case 2:
1558
+ tmp = new PowerProviderCriticalPower($this.powerW_1, $this.criticalPowerW_1, $this.wPrimeJ_1, VOID, $this.useHarmonics_1);
1559
+ break;
1560
+ case 3:
1561
+ tmp = PowerProviderFromData_instance;
1562
+ break;
1563
+ default:
1564
+ noWhenBranchMatchedException();
1565
+ break;
1566
+ }
1567
+ return tmp;
1568
+ }
1569
+ function CyclistPowerSpec(model, powerW, criticalPowerW, wPrimeJ, useHarmonics, pacing, maxSlewWPerS) {
1570
+ model = model === VOID ? PowerModel_CONSTANT_getInstance() : model;
1571
+ powerW = powerW === VOID ? 280.0 : powerW;
1572
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
1573
+ wPrimeJ = wPrimeJ === VOID ? 20000.0 : wPrimeJ;
1574
+ useHarmonics = useHarmonics === VOID ? false : useHarmonics;
1575
+ pacing = pacing === VOID ? false : pacing;
1576
+ maxSlewWPerS = maxSlewWPerS === VOID ? 0.0 : maxSlewWPerS;
1577
+ this.model_1 = model;
1578
+ this.powerW_1 = powerW;
1579
+ this.criticalPowerW_1 = criticalPowerW;
1580
+ this.wPrimeJ_1 = wPrimeJ;
1581
+ this.useHarmonics_1 = useHarmonics;
1582
+ this.pacing_1 = pacing;
1583
+ this.maxSlewWPerS_1 = maxSlewWPerS;
1584
+ }
1585
+ protoOf(CyclistPowerSpec).toProvider_gnvkvo_k$ = function () {
1586
+ var provider = baseProvider(this);
1587
+ if (this.pacing_1)
1588
+ provider = new PowerProviderTerrainPacing(provider);
1589
+ if (this.maxSlewWPerS_1 > 0.0)
1590
+ provider = new PowerProviderSlewLimited(provider, this.maxSlewWPerS_1);
1591
+ return provider;
1592
+ };
1593
+ protoOf(CyclistPowerSpec).toString = function () {
1594
+ return 'CyclistPowerSpec(model=' + this.model_1.toString() + ', powerW=' + this.powerW_1 + ', criticalPowerW=' + this.criticalPowerW_1 + ', wPrimeJ=' + this.wPrimeJ_1 + ', useHarmonics=' + this.useHarmonics_1 + ', pacing=' + this.pacing_1 + ', maxSlewWPerS=' + this.maxSlewWPerS_1 + ')';
1595
+ };
1596
+ protoOf(CyclistPowerSpec).hashCode = function () {
1597
+ var result = this.model_1.hashCode();
1598
+ result = imul(result, 31) + getNumberHashCode(this.powerW_1) | 0;
1599
+ result = imul(result, 31) + getNumberHashCode(this.criticalPowerW_1) | 0;
1600
+ result = imul(result, 31) + getNumberHashCode(this.wPrimeJ_1) | 0;
1601
+ result = imul(result, 31) + getBooleanHashCode(this.useHarmonics_1) | 0;
1602
+ result = imul(result, 31) + getBooleanHashCode(this.pacing_1) | 0;
1603
+ result = imul(result, 31) + getNumberHashCode(this.maxSlewWPerS_1) | 0;
1604
+ return result;
1605
+ };
1606
+ protoOf(CyclistPowerSpec).equals = function (other) {
1607
+ if (this === other)
1608
+ return true;
1609
+ if (!(other instanceof CyclistPowerSpec))
1610
+ return false;
1611
+ if (!this.model_1.equals(other.model_1))
1612
+ return false;
1613
+ if (!equals(this.powerW_1, other.powerW_1))
1614
+ return false;
1615
+ if (!equals(this.criticalPowerW_1, other.criticalPowerW_1))
1616
+ return false;
1617
+ if (!equals(this.wPrimeJ_1, other.wPrimeJ_1))
1618
+ return false;
1619
+ if (!(this.useHarmonics_1 === other.useHarmonics_1))
1620
+ return false;
1621
+ if (!(this.pacing_1 === other.pacing_1))
1622
+ return false;
1623
+ if (!equals(this.maxSlewWPerS_1, other.maxSlewWPerS_1))
1624
+ return false;
1625
+ return true;
1626
+ };
1627
+ function PowerModel_CONSTANT_getInstance() {
1628
+ static_init_0();
1629
+ return PowerModel_CONSTANT_instance;
1630
+ }
1631
+ function PowerModel_DURABILITY_getInstance() {
1632
+ static_init_0();
1633
+ return PowerModel_DURABILITY_instance;
1634
+ }
1635
+ function PowerModel_CRITICAL_POWER_getInstance() {
1636
+ static_init_0();
1637
+ return PowerModel_CRITICAL_POWER_instance;
1638
+ }
1639
+ function PowerModel_FROM_DATA_getInstance() {
1640
+ static_init_0();
1641
+ return PowerModel_FROM_DATA_instance;
1642
+ }
1379
1643
  function GravPowerProvider() {
1380
1644
  }
1381
1645
  protoOf(GravPowerProvider).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
@@ -1666,13 +1930,96 @@
1666
1930
  protoOf(PowerProviderConstant).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1667
1931
  return this.power_1;
1668
1932
  };
1669
- function Companion_6() {
1933
+ function Companion_7() {
1934
+ this.DEFAULT_TAPER_START_FRACTION_1 = 0.5;
1935
+ }
1936
+ var Companion_instance_8;
1937
+ function Companion_getInstance_10() {
1938
+ return Companion_instance_8;
1939
+ }
1940
+ function PowerProviderCriticalPower(powerW, criticalPowerW, wPrimeJ, taperStartFraction, useHarmonics, random) {
1941
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
1942
+ wPrimeJ = wPrimeJ === VOID ? 20000.0 : wPrimeJ;
1943
+ taperStartFraction = taperStartFraction === VOID ? 0.5 : taperStartFraction;
1944
+ useHarmonics = useHarmonics === VOID ? false : useHarmonics;
1945
+ random = random === VOID ? Default_getInstance() : random;
1946
+ CyclistPowerProviderBase.call(this, useHarmonics, random);
1947
+ this.powerW_1 = powerW;
1948
+ this.criticalPowerW_1 = criticalPowerW;
1949
+ this.wPrimeJ_1 = wPrimeJ;
1950
+ this.taperStartFraction_1 = taperStartFraction;
1951
+ // Inline function 'kotlin.require' call
1952
+ if (!(this.powerW_1 > 0.0)) {
1953
+ var message = 'powerW must be > 0, got ' + this.powerW_1;
1954
+ throw IllegalArgumentException_init_$Create$(toString(message));
1955
+ }
1956
+ // Inline function 'kotlin.require' call
1957
+ if (!(this.criticalPowerW_1 > 0.0)) {
1958
+ var message_0 = 'criticalPowerW must be > 0, got ' + this.criticalPowerW_1;
1959
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
1960
+ }
1961
+ // Inline function 'kotlin.require' call
1962
+ if (!(this.wPrimeJ_1 > 0.0)) {
1963
+ var message_1 = 'wPrimeJ must be > 0, got ' + this.wPrimeJ_1;
1964
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
1965
+ }
1966
+ var containsArg = this.taperStartFraction_1;
1967
+ // Inline function 'kotlin.require' call
1968
+ if (!(0.0 <= containsArg ? containsArg <= 1.0 : false)) {
1969
+ var message_2 = 'taperStartFraction must be in [0, 1], got ' + this.taperStartFraction_1;
1970
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
1971
+ }
1972
+ this.lastIndex_1 = -1;
1973
+ this.lastElapsedS_1 = 0.0;
1974
+ this.lastPowerW_1 = 0.0;
1975
+ this.wPrimeBalanceJ_1 = this.wPrimeJ_1;
1976
+ }
1977
+ protoOf(PowerProviderCriticalPower).get_reserveFraction_7eakgb_k$ = function () {
1978
+ return this.wPrimeBalanceJ_1 / this.wPrimeJ_1;
1979
+ };
1980
+ protoOf(PowerProviderCriticalPower).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1981
+ if (pointIndex < this.lastIndex_1) {
1982
+ this.reset_5u6xz3_k$();
1983
+ }
1984
+ if (pointIndex > this.lastIndex_1) {
1985
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
1986
+ var dtS = elapsedS - this.lastElapsedS_1;
1987
+ if (dtS > 0.0 && isFinite(dtS)) {
1988
+ this.wPrimeBalanceJ_1 = WPrimeBalanceComputer_instance.step_447nu7_k$(this.wPrimeBalanceJ_1, this.lastPowerW_1, this.criticalPowerW_1, this.wPrimeJ_1, dtS);
1989
+ }
1990
+ if (isFinite(elapsedS))
1991
+ this.lastElapsedS_1 = elapsedS;
1992
+ this.lastIndex_1 = pointIndex;
1993
+ }
1994
+ var rationed = this.ration_enbpy2_k$(this.powerW_1);
1995
+ this.lastPowerW_1 = rationed;
1996
+ return rationed;
1997
+ };
1998
+ protoOf(PowerProviderCriticalPower).ration_enbpy2_k$ = function (target) {
1999
+ if (target <= this.criticalPowerW_1)
2000
+ return target;
2001
+ var tmp;
2002
+ if (this.taperStartFraction_1 <= 0.0) {
2003
+ tmp = 1.0;
2004
+ } else {
2005
+ tmp = coerceIn(this.get_reserveFraction_7eakgb_k$() / this.taperStartFraction_1, 0.0, 1.0);
2006
+ }
2007
+ var shape = tmp;
2008
+ return this.criticalPowerW_1 + (target - this.criticalPowerW_1) * shape;
2009
+ };
2010
+ protoOf(PowerProviderCriticalPower).reset_5u6xz3_k$ = function () {
2011
+ this.lastIndex_1 = -1;
2012
+ this.lastElapsedS_1 = 0.0;
2013
+ this.lastPowerW_1 = 0.0;
2014
+ this.wPrimeBalanceJ_1 = this.wPrimeJ_1;
2015
+ };
2016
+ function Companion_8() {
1670
2017
  this.DEFAULT_DECLINE_PER_KJ_PER_KG_1 = 0.006666666666666667;
1671
2018
  this.DEFAULT_MAX_DECLINE_1 = 0.2;
1672
2019
  }
1673
- var Companion_instance_6;
1674
- function Companion_getInstance_9() {
1675
- return Companion_instance_6;
2020
+ var Companion_instance_9;
2021
+ function Companion_getInstance_11() {
2022
+ return Companion_instance_9;
1676
2023
  }
1677
2024
  function PowerProviderDurability(powerW, criticalPowerW, declinePerKjPerKg, maxDecline, useHarmonics, random) {
1678
2025
  criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
@@ -1756,6 +2103,184 @@
1756
2103
  function PowerProviderFromData_getInstance() {
1757
2104
  return PowerProviderFromData_instance;
1758
2105
  }
2106
+ function PowerProviderSlewLimited(delegate, maxSlewWPerS) {
2107
+ maxSlewWPerS = maxSlewWPerS === VOID ? 50.0 : maxSlewWPerS;
2108
+ this.delegate_1 = delegate;
2109
+ this.maxSlewWPerS_1 = maxSlewWPerS;
2110
+ // Inline function 'kotlin.require' call
2111
+ if (!(this.maxSlewWPerS_1 > 0.0)) {
2112
+ var message = 'maxSlewWPerS must be > 0, got ' + this.maxSlewWPerS_1;
2113
+ throw IllegalArgumentException_init_$Create$(toString(message));
2114
+ }
2115
+ this.lastIndex_1 = -1;
2116
+ this.lastElapsedS_1 = 0.0;
2117
+ this.lastPowerW_1 = 0.0;
2118
+ }
2119
+ protoOf(PowerProviderSlewLimited).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
2120
+ var target = this.delegate_1.powerAt_ejucaq_k$(course, path, pointIndex);
2121
+ if (pointIndex < this.lastIndex_1) {
2122
+ this.reset_5u6xz3_k$();
2123
+ }
2124
+ if (pointIndex === this.lastIndex_1)
2125
+ return this.lastPowerW_1;
2126
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2127
+ var dtS = elapsedS - this.lastElapsedS_1;
2128
+ var tmp;
2129
+ if (dtS > 0.0 && isFinite(dtS)) {
2130
+ var budget = this.maxSlewWPerS_1 * dtS;
2131
+ var delta = target - this.lastPowerW_1;
2132
+ var tmp_0;
2133
+ // Inline function 'kotlin.math.abs' call
2134
+ if (Math.abs(delta) <= budget) {
2135
+ tmp_0 = target;
2136
+ } else {
2137
+ tmp_0 = this.lastPowerW_1 + (delta > 0 ? budget : -budget);
2138
+ }
2139
+ tmp = tmp_0;
2140
+ } else {
2141
+ tmp = this.lastPowerW_1;
2142
+ }
2143
+ var limited = tmp;
2144
+ if (isFinite(elapsedS))
2145
+ this.lastElapsedS_1 = elapsedS;
2146
+ this.lastIndex_1 = pointIndex;
2147
+ this.lastPowerW_1 = limited;
2148
+ return limited;
2149
+ };
2150
+ protoOf(PowerProviderSlewLimited).reset_5u6xz3_k$ = function () {
2151
+ this.lastIndex_1 = -1;
2152
+ this.lastElapsedS_1 = 0.0;
2153
+ this.lastPowerW_1 = 0.0;
2154
+ };
2155
+ function Companion_9() {
2156
+ this.DEFAULT_GRADIENT_GAIN_1 = 3.0;
2157
+ this.DEFAULT_HEADWIND_GAIN_PER_MS_1 = 0.02;
2158
+ this.DEFAULT_MIN_MULTIPLIER_1 = 0.5;
2159
+ this.DEFAULT_MAX_MULTIPLIER_1 = 1.3;
2160
+ this.DEFAULT_RAMP_DISTANCE_M_1 = 300.0;
2161
+ this.DEFAULT_ENERGY_BUDGET_SECONDS_1 = 600.0;
2162
+ }
2163
+ var Companion_instance_10;
2164
+ function Companion_getInstance_12() {
2165
+ return Companion_instance_10;
2166
+ }
2167
+ function PowerProviderTerrainPacing(delegate, gradientGain, headwindGainPerMS, minMultiplier, maxMultiplier, rampDistanceM, energyBudgetSeconds) {
2168
+ gradientGain = gradientGain === VOID ? 3.0 : gradientGain;
2169
+ headwindGainPerMS = headwindGainPerMS === VOID ? 0.02 : headwindGainPerMS;
2170
+ minMultiplier = minMultiplier === VOID ? 0.5 : minMultiplier;
2171
+ maxMultiplier = maxMultiplier === VOID ? 1.3 : maxMultiplier;
2172
+ rampDistanceM = rampDistanceM === VOID ? 300.0 : rampDistanceM;
2173
+ energyBudgetSeconds = energyBudgetSeconds === VOID ? 600.0 : energyBudgetSeconds;
2174
+ this.delegate_1 = delegate;
2175
+ this.gradientGain_1 = gradientGain;
2176
+ this.headwindGainPerMS_1 = headwindGainPerMS;
2177
+ this.minMultiplier_1 = minMultiplier;
2178
+ this.maxMultiplier_1 = maxMultiplier;
2179
+ this.rampDistanceM_1 = rampDistanceM;
2180
+ this.energyBudgetSeconds_1 = energyBudgetSeconds;
2181
+ // Inline function 'kotlin.require' call
2182
+ if (!(this.gradientGain_1 >= 0.0)) {
2183
+ var message = 'gradientGain must be >= 0, got ' + this.gradientGain_1;
2184
+ throw IllegalArgumentException_init_$Create$(toString(message));
2185
+ }
2186
+ // Inline function 'kotlin.require' call
2187
+ if (!(this.headwindGainPerMS_1 >= 0.0)) {
2188
+ var message_0 = 'headwindGainPerMS must be >= 0, got ' + this.headwindGainPerMS_1;
2189
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
2190
+ }
2191
+ // Inline function 'kotlin.require' call
2192
+ if (!(this.minMultiplier_1 > 0.0)) {
2193
+ var message_1 = 'minMultiplier must be > 0, got ' + this.minMultiplier_1;
2194
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
2195
+ }
2196
+ // Inline function 'kotlin.require' call
2197
+ if (!(this.maxMultiplier_1 >= this.minMultiplier_1)) {
2198
+ var message_2 = 'maxMultiplier (' + this.maxMultiplier_1 + ') must be >= minMultiplier (' + this.minMultiplier_1 + ')';
2199
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
2200
+ }
2201
+ // Inline function 'kotlin.require' call
2202
+ if (!(this.rampDistanceM_1 > 0.0)) {
2203
+ var message_3 = 'rampDistanceM must be > 0, got ' + this.rampDistanceM_1;
2204
+ throw IllegalArgumentException_init_$Create$(toString(message_3));
2205
+ }
2206
+ // Inline function 'kotlin.require' call
2207
+ if (!(this.energyBudgetSeconds_1 > 0.0)) {
2208
+ var message_4 = 'energyBudgetSeconds must be > 0, got ' + this.energyBudgetSeconds_1;
2209
+ throw IllegalArgumentException_init_$Create$(toString(message_4));
2210
+ }
2211
+ this.lastIndex_1 = -1;
2212
+ this.lastDistanceM_1 = 0.0;
2213
+ this.lastElapsedS_1 = 0.0;
2214
+ this.lastDeliveredW_1 = 0.0;
2215
+ this.lastTargetW_1 = 0.0;
2216
+ this.multiplier_1 = 1.0;
2217
+ this.energyDebtJ_1 = 0.0;
2218
+ }
2219
+ protoOf(PowerProviderTerrainPacing).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
2220
+ var target = this.delegate_1.powerAt_ejucaq_k$(course, path, pointIndex);
2221
+ if (pointIndex < this.lastIndex_1) {
2222
+ this.reset_5u6xz3_k$();
2223
+ }
2224
+ if (pointIndex > this.lastIndex_1) {
2225
+ var distanceM = path.distance_5s4s77_k$(pointIndex);
2226
+ var dx = distanceM - this.lastDistanceM_1;
2227
+ this.multiplier_1 = this.smooth_uy9sy9_k$(this.multiplier_1, this.rawMultiplier_2rfnpc_k$(path, pointIndex), dx);
2228
+ if (isFinite(distanceM))
2229
+ this.lastDistanceM_1 = distanceM;
2230
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2231
+ var dtS = elapsedS - this.lastElapsedS_1;
2232
+ if (dtS > 0.0 && isFinite(dtS)) {
2233
+ this.energyDebtJ_1 = this.energyDebtJ_1 + (this.lastDeliveredW_1 - this.lastTargetW_1) * dtS;
2234
+ }
2235
+ if (isFinite(elapsedS))
2236
+ this.lastElapsedS_1 = elapsedS;
2237
+ this.lastIndex_1 = pointIndex;
2238
+ }
2239
+ var delivered = target * this.multiplier_1 * this.energyCorrection_sm6t7b_k$(target);
2240
+ this.lastTargetW_1 = target;
2241
+ this.lastDeliveredW_1 = delivered;
2242
+ return delivered;
2243
+ };
2244
+ protoOf(PowerProviderTerrainPacing).energyCorrection_sm6t7b_k$ = function (target) {
2245
+ if (target <= 0.0)
2246
+ return 1.0;
2247
+ var budgetJ = target * this.energyBudgetSeconds_1;
2248
+ return coerceIn(1.0 - this.energyDebtJ_1 / budgetJ, this.minMultiplier_1, this.maxMultiplier_1);
2249
+ };
2250
+ protoOf(PowerProviderTerrainPacing).rawMultiplier_2rfnpc_k$ = function (path, pointIndex) {
2251
+ // Inline function 'kotlin.let' call
2252
+ var it = path.grade_c4yjz5_k$(pointIndex);
2253
+ var grade = isFinite(it) ? it : 0.0;
2254
+ // Inline function 'kotlin.let' call
2255
+ var it_0 = path.windSpeed_6m3dy1_k$(pointIndex);
2256
+ var windSpeed = isFinite(it_0) ? it_0 : 0.0;
2257
+ // Inline function 'kotlin.let' call
2258
+ var it_1 = path.windAlpha_7rjela_k$(pointIndex);
2259
+ var alpha = isFinite(it_1) ? it_1 : 0.0;
2260
+ // Inline function 'kotlin.math.cos' call
2261
+ var headwind = windSpeed * Math.cos(alpha);
2262
+ var raw = 1.0 + this.gradientGain_1 * grade + this.headwindGainPerMS_1 * headwind;
2263
+ return coerceIn(raw, this.minMultiplier_1, this.maxMultiplier_1);
2264
+ };
2265
+ protoOf(PowerProviderTerrainPacing).smooth_uy9sy9_k$ = function (current, raw, dx) {
2266
+ if (raw <= current)
2267
+ return raw;
2268
+ if (!isFinite(dx) || dx <= 0.0)
2269
+ return current;
2270
+ // Inline function 'kotlin.math.exp' call
2271
+ var x = -dx / this.rampDistanceM_1;
2272
+ var blend = 1.0 - Math.exp(x);
2273
+ return current + (raw - current) * blend;
2274
+ };
2275
+ protoOf(PowerProviderTerrainPacing).reset_5u6xz3_k$ = function () {
2276
+ this.lastIndex_1 = -1;
2277
+ this.lastDistanceM_1 = 0.0;
2278
+ this.lastElapsedS_1 = 0.0;
2279
+ this.lastDeliveredW_1 = 0.0;
2280
+ this.lastTargetW_1 = 0.0;
2281
+ this.multiplier_1 = 1.0;
2282
+ this.energyDebtJ_1 = 0.0;
2283
+ };
1759
2284
  function RhoProviderDefault() {
1760
2285
  }
1761
2286
  protoOf(RhoProviderDefault).rho_pwqvzi_k$ = function (course, path, pointIndex) {
@@ -1904,18 +2429,18 @@
1904
2429
  function WheelBearingsPowerProvider_getInstance() {
1905
2430
  return WheelBearingsPowerProvider_instance;
1906
2431
  }
1907
- function Companion_7() {
1908
- Companion_instance_7 = this;
2432
+ function Companion_10() {
2433
+ Companion_instance_11 = this;
1909
2434
  this.NONE_1 = new Wind(0.0, 0.0);
1910
2435
  }
1911
- var Companion_instance_7;
1912
- function Companion_getInstance_10() {
1913
- if (Companion_instance_7 == null)
1914
- new Companion_7();
1915
- return Companion_instance_7;
2436
+ var Companion_instance_11;
2437
+ function Companion_getInstance_13() {
2438
+ if (Companion_instance_11 == null)
2439
+ new Companion_10();
2440
+ return Companion_instance_11;
1916
2441
  }
1917
2442
  function Wind(speedMS, directionRad) {
1918
- Companion_getInstance_10();
2443
+ Companion_getInstance_13();
1919
2444
  this.speedMS_1 = speedMS;
1920
2445
  this.directionRad_1 = directionRad;
1921
2446
  }
@@ -1941,7 +2466,7 @@
1941
2466
  function WindProviderNone() {
1942
2467
  }
1943
2468
  protoOf(WindProviderNone).wind_umf2tf_k$ = function (course, path, pointIndex) {
1944
- return Companion_getInstance_10().NONE_1;
2469
+ return Companion_getInstance_13().NONE_1;
1945
2470
  };
1946
2471
  var WindProviderNone_instance;
1947
2472
  function WindProviderNone_getInstance() {
@@ -1997,7 +2522,33 @@
1997
2522
  function WPrimeBalanceComputer_getInstance() {
1998
2523
  return WPrimeBalanceComputer_instance;
1999
2524
  }
2525
+ function get_POWER_PROVIDER_KEYS() {
2526
+ _init_properties_EngineJsApi_kt__9bputf();
2527
+ return POWER_PROVIDER_KEYS;
2528
+ }
2529
+ var POWER_PROVIDER_KEYS;
2530
+ function get_CYCLIST_KEYS() {
2531
+ _init_properties_EngineJsApi_kt__9bputf();
2532
+ return CYCLIST_KEYS;
2533
+ }
2534
+ var CYCLIST_KEYS;
2535
+ function get_BIKE_KEYS() {
2536
+ _init_properties_EngineJsApi_kt__9bputf();
2537
+ return BIKE_KEYS;
2538
+ }
2539
+ var BIKE_KEYS;
2540
+ function get_WIND_KEYS() {
2541
+ _init_properties_EngineJsApi_kt__9bputf();
2542
+ return WIND_KEYS;
2543
+ }
2544
+ var WIND_KEYS;
2545
+ function get_ENHANCE_OPTIONS_KEYS() {
2546
+ _init_properties_EngineJsApi_kt__9bputf();
2547
+ return ENHANCE_OPTIONS_KEYS;
2548
+ }
2549
+ var ENHANCE_OPTIONS_KEYS;
2000
2550
  function parseGpxWaypoints(xml) {
2551
+ _init_properties_EngineJsApi_kt__9bputf();
2001
2552
  // Inline function 'kotlin.collections.map' call
2002
2553
  var this_0 = GpxParser_instance.parse$default_ez0f31_k$(xml).waypoints_1;
2003
2554
  // Inline function 'kotlin.collections.mapTo' call
@@ -2012,24 +2563,29 @@
2012
2563
  return copyToArray(destination);
2013
2564
  }
2014
2565
  function parseGpx(xml) {
2566
+ _init_properties_EngineJsApi_kt__9bputf();
2015
2567
  return firstTrackAsPath(GpxParser_instance.parse$default_ez0f31_k$(xml));
2016
2568
  }
2017
2569
  function parseGpxTracks(xml) {
2570
+ _init_properties_EngineJsApi_kt__9bputf();
2018
2571
  // Inline function 'kotlin.collections.toTypedArray' call
2019
2572
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
2020
2573
  return copyToArray(this_0);
2021
2574
  }
2022
2575
  function parseGpxSegments(xml) {
2576
+ _init_properties_EngineJsApi_kt__9bputf();
2023
2577
  // Inline function 'kotlin.collections.toTypedArray' call
2024
2578
  var this_0 = segmentsAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
2025
2579
  return copyToArray(this_0);
2026
2580
  }
2027
2581
  function parseGpxTracksOnly(xml) {
2582
+ _init_properties_EngineJsApi_kt__9bputf();
2028
2583
  // Inline function 'kotlin.collections.toTypedArray' call
2029
2584
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_TRACK_getInstance()));
2030
2585
  return copyToArray(this_0);
2031
2586
  }
2032
2587
  function parseGpxRoutesOnly(xml) {
2588
+ _init_properties_EngineJsApi_kt__9bputf();
2033
2589
  // Inline function 'kotlin.collections.toTypedArray' call
2034
2590
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_ROUTE_getInstance()));
2035
2591
  return copyToArray(this_0);
@@ -2044,6 +2600,7 @@
2044
2600
  }
2045
2601
  waypoints = tmp;
2046
2602
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2603
+ _init_properties_EngineJsApi_kt__9bputf();
2047
2604
  var tmp_0 = GpxWriter_instance;
2048
2605
  var tmp_1 = toList(paths);
2049
2606
  // Inline function 'kotlin.collections.map' call
@@ -2060,40 +2617,51 @@
2060
2617
  return tmp_0.write$default_koqy5u_k$(tmp_1, VOID, VOID, destination, VOID, writeExtensions);
2061
2618
  }
2062
2619
  function pathSize(path) {
2620
+ _init_properties_EngineJsApi_kt__9bputf();
2063
2621
  return path.size_1;
2064
2622
  }
2065
2623
  function pathTotalDistance(path) {
2624
+ _init_properties_EngineJsApi_kt__9bputf();
2066
2625
  return path.totalDistance_1;
2067
2626
  }
2068
2627
  function pathDurationMs(path) {
2628
+ _init_properties_EngineJsApi_kt__9bputf();
2069
2629
  return path.durationMs_1;
2070
2630
  }
2071
2631
  function pathElevationGain(path) {
2632
+ _init_properties_EngineJsApi_kt__9bputf();
2072
2633
  return path.elevationGain_1;
2073
2634
  }
2074
2635
  function pathElevationLoss(path) {
2636
+ _init_properties_EngineJsApi_kt__9bputf();
2075
2637
  return path.elevationLoss_1;
2076
2638
  }
2077
2639
  function pointAt(path, i) {
2640
+ _init_properties_EngineJsApi_kt__9bputf();
2078
2641
  return pointObj(path.latitudeDeg_i25sm6_k$(i), path.longitudeDeg_ikk1un_k$(i), path.elevation_iziwkb_k$(i), path.time_ryc845_k$(i), path.speed_npav2n_k$(i), path.pComputedPower_g6dnn4_k$(i), path.distance_5s4s77_k$(i), path.grade_c4yjz5_k$(i));
2079
2642
  }
2080
2643
  function writeGpx(path, writeExtensions) {
2081
2644
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2645
+ _init_properties_EngineJsApi_kt__9bputf();
2082
2646
  return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized'), writeExtensions);
2083
2647
  }
2084
2648
  function writeGpxAt(path, startTimeEpochMs, writeExtensions) {
2085
2649
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2650
+ _init_properties_EngineJsApi_kt__9bputf();
2086
2651
  return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized', Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs))), writeExtensions);
2087
2652
  }
2088
2653
  function enhance(path, options) {
2654
+ _init_properties_EngineJsApi_kt__9bputf();
2089
2655
  var tmp = GlobalScope_instance;
2090
2656
  return promise(tmp, VOID, VOID, enhance$slambda_0(options, path, null));
2091
2657
  }
2092
2658
  function enhanceWithCourse(path, cyclist, bike, wind, power, options) {
2659
+ _init_properties_EngineJsApi_kt__9bputf();
2093
2660
  var tmp = GlobalScope_instance;
2094
2661
  return promise(tmp, VOID, VOID, enhanceWithCourse$slambda_0(options, path, cyclist, bike, wind, power, null));
2095
2662
  }
2096
2663
  function getField(path, i, fieldProp) {
2664
+ _init_properties_EngineJsApi_kt__9bputf();
2097
2665
  var tmp0_elvis_lhs = Companion_getInstance_0().byProp_kdf1eo_k$(fieldProp);
2098
2666
  var tmp;
2099
2667
  if (tmp0_elvis_lhs == null) {
@@ -2107,6 +2675,7 @@
2107
2675
  return path.get_z3le6l_k$(i, field);
2108
2676
  }
2109
2677
  function fieldDefinitions() {
2678
+ _init_properties_EngineJsApi_kt__9bputf();
2110
2679
  // Inline function 'kotlin.collections.map' call
2111
2680
  var this_0 = get_entries();
2112
2681
  // Inline function 'kotlin.collections.mapTo' call
@@ -2129,12 +2698,15 @@
2129
2698
  return copyToArray(destination);
2130
2699
  }
2131
2700
  function pathLatitudeDeg(path, i) {
2701
+ _init_properties_EngineJsApi_kt__9bputf();
2132
2702
  return path.latitudeDeg_i25sm6_k$(i);
2133
2703
  }
2134
2704
  function pathLongitudeDeg(path, i) {
2705
+ _init_properties_EngineJsApi_kt__9bputf();
2135
2706
  return path.longitudeDeg_ikk1un_k$(i);
2136
2707
  }
2137
2708
  function pathToCsv(path, separator, unitsInHeader) {
2709
+ _init_properties_EngineJsApi_kt__9bputf();
2138
2710
  var tmp = CsvWriter_instance;
2139
2711
  var tmp0_elvis_lhs = firstOrNull(separator);
2140
2712
  var tmp_0;
@@ -2147,13 +2719,16 @@
2147
2719
  return tmp.write_p5vnh4_k$(path, new CsvOptions(VOID, tmp_0, unitsInHeader));
2148
2720
  }
2149
2721
  function pathToJson(path, pretty) {
2722
+ _init_properties_EngineJsApi_kt__9bputf();
2150
2723
  return JsonWriter_instance.write_lwqeog_k$(path, new JsonOptions(VOID, pretty));
2151
2724
  }
2152
2725
  function pathToFit(path, name, startTimeEpochMs) {
2726
+ _init_properties_EngineJsApi_kt__9bputf();
2153
2727
  return toFitBytes(path, name, Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs)));
2154
2728
  }
2155
2729
  function pathsToFit(paths, name, startTimeEpochMs, interPathGapMs) {
2156
2730
  interPathGapMs = interPathGapMs === VOID ? 0.0 : interPathGapMs;
2731
+ _init_properties_EngineJsApi_kt__9bputf();
2157
2732
  var tmp = toList(paths);
2158
2733
  var tmp_0 = Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs));
2159
2734
  Companion_getInstance_1();
@@ -2163,12 +2738,15 @@
2163
2738
  return toFitBytes_0(tmp, name, tmp_0, VOID, tmp$ret$0);
2164
2739
  }
2165
2740
  function dominantHeadwindAzimuth(path) {
2741
+ _init_properties_EngineJsApi_kt__9bputf();
2166
2742
  return dominantHeadwindAzimuthDeg(path);
2167
2743
  }
2168
2744
  function dominantHeadwindAzimuthOfTracks(paths) {
2745
+ _init_properties_EngineJsApi_kt__9bputf();
2169
2746
  return dominantHeadwindAzimuthDeg_0(toList(paths));
2170
2747
  }
2171
2748
  function detectClimbs(path) {
2749
+ _init_properties_EngineJsApi_kt__9bputf();
2172
2750
  // Inline function 'kotlin.collections.map' call
2173
2751
  var this_0 = ClimbDetector_instance.detect$default_6ml3ny_k$(path);
2174
2752
  // Inline function 'kotlin.collections.mapTo' call
@@ -2183,6 +2761,7 @@
2183
2761
  return copyToArray(destination);
2184
2762
  }
2185
2763
  function detectClimbsWithOptions(path, minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGrade, booster) {
2764
+ _init_properties_EngineJsApi_kt__9bputf();
2186
2765
  // Inline function 'kotlin.collections.map' call
2187
2766
  var this_0 = ClimbDetector_instance.detect_llooq2_k$(path, new ClimbOptions(minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGrade, booster));
2188
2767
  // Inline function 'kotlin.collections.mapTo' call
@@ -2197,6 +2776,7 @@
2197
2776
  return copyToArray(destination);
2198
2777
  }
2199
2778
  function waypointObj(w) {
2779
+ _init_properties_EngineJsApi_kt__9bputf();
2200
2780
  var o = {};
2201
2781
  o.latitudeDeg = w.latitudeDeg_1;
2202
2782
  o.longitudeDeg = w.longitudeDeg_1;
@@ -2211,6 +2791,7 @@
2211
2791
  return o;
2212
2792
  }
2213
2793
  function pointObj(latitudeDeg, longitudeDeg, elevation, timeMs, speed, pComputedPower, distance, grade) {
2794
+ _init_properties_EngineJsApi_kt__9bputf();
2214
2795
  var o = {};
2215
2796
  o.latitudeDeg = latitudeDeg;
2216
2797
  o.longitudeDeg = longitudeDeg;
@@ -2224,6 +2805,7 @@
2224
2805
  return o;
2225
2806
  }
2226
2807
  function toGpxWaypoint(_this__u8e3s4) {
2808
+ _init_properties_EngineJsApi_kt__9bputf();
2227
2809
  var tmp = _this__u8e3s4.latitudeDeg;
2228
2810
  var tmp_0 = _this__u8e3s4.longitudeDeg;
2229
2811
  var tmp_1 = _this__u8e3s4.elevationM;
@@ -2235,8 +2817,10 @@
2235
2817
  return new GpxWaypoint(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp0_safe_receiver == null ? null : numberToLong(tmp0_safe_receiver));
2236
2818
  }
2237
2819
  function toEnhanceOptions(_this__u8e3s4) {
2820
+ _init_properties_EngineJsApi_kt__9bputf();
2238
2821
  if (_this__u8e3s4 == null)
2239
2822
  return defaultJsOptions();
2823
+ requireOnlyKeys(_this__u8e3s4, 'EnhanceOptionsDto', get_ENHANCE_OPTIONS_KEYS());
2240
2824
  var tmp0_elvis_lhs = _this__u8e3s4.fixElevation;
2241
2825
  var tmp = tmp0_elvis_lhs == null ? false : tmp0_elvis_lhs;
2242
2826
  var tmp1_elvis_lhs = _this__u8e3s4.computeMaxSpeeds;
@@ -2250,19 +2834,78 @@
2250
2834
  var tmp5_elvis_lhs = _this__u8e3s4.simplifyToleranceM;
2251
2835
  var tmp_4 = tmp5_elvis_lhs == null ? 10.0 : tmp5_elvis_lhs;
2252
2836
  var tmp6_elvis_lhs = _this__u8e3s4.simplifyZExaggeration;
2253
- return new EnhanceOptions(tmp, tmp_0, tmp_1, tmp_2, new SimplifyPathOptions(tmp_3, tmp_4, tmp6_elvis_lhs == null ? 3.0 : tmp6_elvis_lhs));
2837
+ var tmp_5 = new SimplifyPathOptions(tmp_3, tmp_4, tmp6_elvis_lhs == null ? 3.0 : tmp6_elvis_lhs);
2838
+ var tmp7_elvis_lhs = _this__u8e3s4.wPrimeBalanceEnabled;
2839
+ var tmp_6 = tmp7_elvis_lhs == null ? (new WPrimeBalanceOptions()).enabled_1 : tmp7_elvis_lhs;
2840
+ var tmp8_elvis_lhs = _this__u8e3s4.wPrimeBalanceCriticalPower;
2841
+ var tmp_7 = tmp8_elvis_lhs == null ? 250.0 : tmp8_elvis_lhs;
2842
+ var tmp9_elvis_lhs = _this__u8e3s4.wPrimeBalanceWPrime;
2843
+ return new EnhanceOptions(tmp, tmp_0, tmp_1, tmp_2, tmp_5, new WPrimeBalanceOptions(tmp_6, tmp_7, tmp9_elvis_lhs == null ? 20000.0 : tmp9_elvis_lhs));
2254
2844
  }
2255
2845
  function defaultJsOptions() {
2846
+ _init_properties_EngineJsApi_kt__9bputf();
2256
2847
  return new EnhanceOptions(false, true, true, false, new SimplifyPathOptions(false));
2257
2848
  }
2258
2849
  function toCyclist(_this__u8e3s4) {
2850
+ _init_properties_EngineJsApi_kt__9bputf();
2259
2851
  if (_this__u8e3s4 == null)
2260
2852
  return new Cyclist();
2261
- return new Cyclist(_this__u8e3s4.massKg, _this__u8e3s4.maxBrakeG, _this__u8e3s4.cd, _this__u8e3s4.frontalAreaM2, _this__u8e3s4.maxLeanAngleDeg, _this__u8e3s4.maxSpeedKmH);
2853
+ requireOnlyKeys(_this__u8e3s4, 'CyclistDto', get_CYCLIST_KEYS());
2854
+ var tmp0_safe_receiver = _this__u8e3s4.roadCondition;
2855
+ var condition = tmp0_safe_receiver == null ? null : toRoadCondition(tmp0_safe_receiver);
2856
+ var tmp = _this__u8e3s4.massKg;
2857
+ var tmp2_elvis_lhs = condition == null ? null : condition.maxBrakeG_1;
2858
+ var tmp_0 = tmp2_elvis_lhs == null ? _this__u8e3s4.maxBrakeG : tmp2_elvis_lhs;
2859
+ var tmp_1 = _this__u8e3s4.cd;
2860
+ var tmp_2 = _this__u8e3s4.frontalAreaM2;
2861
+ var tmp4_elvis_lhs = condition == null ? null : condition.get_leanAngleDeg_9xbhfm_k$();
2862
+ return new Cyclist(tmp, tmp_0, tmp_1, tmp_2, tmp4_elvis_lhs == null ? _this__u8e3s4.maxLeanAngleDeg : tmp4_elvis_lhs, _this__u8e3s4.maxSpeedKmH);
2863
+ }
2864
+ function toRoadCondition(_this__u8e3s4) {
2865
+ _init_properties_EngineJsApi_kt__9bputf();
2866
+ var tmp0 = get_entries_0();
2867
+ var tmp$ret$0;
2868
+ $l$block: {
2869
+ // Inline function 'kotlin.collections.firstOrNull' call
2870
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
2871
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
2872
+ var element = _iterator__ex2g4s.next_20eer_k$();
2873
+ if (equals_0(element.name_1, _this__u8e3s4, true)) {
2874
+ tmp$ret$0 = element;
2875
+ break $l$block;
2876
+ }
2877
+ }
2878
+ tmp$ret$0 = null;
2879
+ }
2880
+ var tmp0_elvis_lhs = tmp$ret$0;
2881
+ var tmp;
2882
+ if (tmp0_elvis_lhs == null) {
2883
+ var tmp_0 = 'Unknown CyclistDto.roadCondition: ' + _this__u8e3s4 + ' (expected one of ';
2884
+ // Inline function 'kotlin.collections.map' call
2885
+ var this_0 = get_entries_0();
2886
+ // Inline function 'kotlin.collections.mapTo' call
2887
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
2888
+ var _iterator__ex2g4s_0 = this_0.iterator_jk1svi_k$();
2889
+ while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
2890
+ var item = _iterator__ex2g4s_0.next_20eer_k$();
2891
+ // Inline function 'kotlin.text.lowercase' call
2892
+ // Inline function 'kotlin.js.asDynamic' call
2893
+ var tmp$ret$4 = item.name_1.toLowerCase();
2894
+ destination.add_utx5q5_k$(tmp$ret$4);
2895
+ }
2896
+ // Inline function 'kotlin.error' call
2897
+ var message = tmp_0 + (toString(destination) + ')');
2898
+ throw IllegalStateException_init_$Create$(toString(message));
2899
+ } else {
2900
+ tmp = tmp0_elvis_lhs;
2901
+ }
2902
+ return tmp;
2262
2903
  }
2263
2904
  function toBike(_this__u8e3s4) {
2905
+ _init_properties_EngineJsApi_kt__9bputf();
2264
2906
  if (_this__u8e3s4 == null)
2265
2907
  return new Bike();
2908
+ requireOnlyKeys(_this__u8e3s4, 'BikeDto', get_BIKE_KEYS());
2266
2909
  var tmp = _this__u8e3s4.crr;
2267
2910
  var tmp_0 = _this__u8e3s4.inertiaFront;
2268
2911
  var tmp_1 = _this__u8e3s4.inertiaRear;
@@ -2272,41 +2915,71 @@
2272
2915
  return new Bike(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp0_elvis_lhs == null ? 20.0 : tmp0_elvis_lhs);
2273
2916
  }
2274
2917
  function toWindProvider(_this__u8e3s4) {
2918
+ _init_properties_EngineJsApi_kt__9bputf();
2275
2919
  if (_this__u8e3s4 == null)
2276
2920
  return WindProviderNone_instance;
2921
+ requireOnlyKeys(_this__u8e3s4, 'WindDto', get_WIND_KEYS());
2277
2922
  return new WindProviderConstant(new Wind(_this__u8e3s4.windSpeed, _this__u8e3s4.windDirection * 3.141592653589793 / 180.0));
2278
2923
  }
2279
2924
  function toCyclistPowerProvider(_this__u8e3s4) {
2925
+ _init_properties_EngineJsApi_kt__9bputf();
2926
+ return toPowerSpec(_this__u8e3s4).toProvider_gnvkvo_k$();
2927
+ }
2928
+ function toPowerSpec(_this__u8e3s4) {
2929
+ _init_properties_EngineJsApi_kt__9bputf();
2280
2930
  if (_this__u8e3s4 == null)
2281
- return new PowerProviderConstant(250.0, false);
2931
+ return new CyclistPowerSpec();
2932
+ requireOnlyKeys(_this__u8e3s4, 'PowerProviderDto', get_POWER_PROVIDER_KEYS());
2933
+ var defaults = new CyclistPowerSpec();
2934
+ var tmp0_elvis_lhs = Companion_instance_7.fromIdOrNull_83jhaj_k$(_this__u8e3s4.type);
2282
2935
  var tmp;
2283
- switch (_this__u8e3s4.type) {
2284
- case 'constant':
2285
- var tmp1_elvis_lhs = _this__u8e3s4.power;
2286
- var tmp_0 = tmp1_elvis_lhs == null ? 250.0 : tmp1_elvis_lhs;
2287
- var tmp2_elvis_lhs = _this__u8e3s4.useHarmonics;
2288
- tmp = new PowerProviderConstant(tmp_0, tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs);
2289
- break;
2290
- case 'durability':
2291
- var tmp3_elvis_lhs = _this__u8e3s4.power;
2292
- var tmp_1 = tmp3_elvis_lhs == null ? 250.0 : tmp3_elvis_lhs;
2293
- var tmp4_elvis_lhs = _this__u8e3s4.criticalPower;
2294
- var tmp_2 = tmp4_elvis_lhs == null ? 250.0 : tmp4_elvis_lhs;
2295
- var tmp5_elvis_lhs = _this__u8e3s4.useHarmonics;
2296
- tmp = new PowerProviderDurability(tmp_1, tmp_2, VOID, VOID, tmp5_elvis_lhs == null ? false : tmp5_elvis_lhs);
2297
- break;
2298
- case 'from_data':
2299
- tmp = PowerProviderFromData_instance;
2300
- break;
2301
- default:
2302
- // Inline function 'kotlin.error' call
2303
-
2304
- var message = 'Unknown PowerProviderDto.type: ' + _this__u8e3s4.type;
2305
- throw IllegalStateException_init_$Create$(toString(message));
2936
+ if (tmp0_elvis_lhs == null) {
2937
+ // Inline function 'kotlin.error' call
2938
+ var message = 'Unknown PowerProviderDto.type: ' + _this__u8e3s4.type + ' (expected one of ' + toString(Companion_instance_7.get_ids_18j3qp_k$()) + ')';
2939
+ throw IllegalStateException_init_$Create$(toString(message));
2940
+ } else {
2941
+ tmp = tmp0_elvis_lhs;
2942
+ }
2943
+ var tmp_0 = tmp;
2944
+ var tmp1_elvis_lhs = _this__u8e3s4.power;
2945
+ var tmp_1 = tmp1_elvis_lhs == null ? defaults.powerW_1 : tmp1_elvis_lhs;
2946
+ var tmp2_elvis_lhs = _this__u8e3s4.criticalPower;
2947
+ var tmp_2 = tmp2_elvis_lhs == null ? defaults.criticalPowerW_1 : tmp2_elvis_lhs;
2948
+ var tmp3_elvis_lhs = _this__u8e3s4.wPrime;
2949
+ var tmp_3 = tmp3_elvis_lhs == null ? defaults.wPrimeJ_1 : tmp3_elvis_lhs;
2950
+ var tmp4_elvis_lhs = _this__u8e3s4.useHarmonics;
2951
+ var tmp_4 = tmp4_elvis_lhs == null ? defaults.useHarmonics_1 : tmp4_elvis_lhs;
2952
+ var tmp5_elvis_lhs = _this__u8e3s4.pacing;
2953
+ var tmp_5 = tmp5_elvis_lhs == null ? defaults.pacing_1 : tmp5_elvis_lhs;
2954
+ var tmp6_elvis_lhs = _this__u8e3s4.maxSlewWPerS;
2955
+ return new CyclistPowerSpec(tmp_0, tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp6_elvis_lhs == null ? defaults.maxSlewWPerS_1 : tmp6_elvis_lhs);
2956
+ }
2957
+ function requireOnlyKeys(_this__u8e3s4, dtoName, allowed) {
2958
+ _init_properties_EngineJsApi_kt__9bputf();
2959
+ // Inline function 'kotlin.js.unsafeCast' call
2960
+ var keys = Object.keys(_this__u8e3s4);
2961
+ // Inline function 'kotlin.collections.filterNot' call
2962
+ // Inline function 'kotlin.collections.filterNotTo' call
2963
+ var destination = ArrayList_init_$Create$();
2964
+ var inductionVariable = 0;
2965
+ var last = keys.length;
2966
+ while (inductionVariable < last) {
2967
+ var element = keys[inductionVariable];
2968
+ inductionVariable = inductionVariable + 1 | 0;
2969
+ if (!allowed.contains_aljjnj_k$(element)) {
2970
+ destination.add_utx5q5_k$(element);
2971
+ }
2972
+ }
2973
+ var unknown = destination;
2974
+ // Inline function 'kotlin.collections.isNotEmpty' call
2975
+ if (!unknown.isEmpty_y1axqb_k$()) {
2976
+ // Inline function 'kotlin.error' call
2977
+ var message = 'Unknown ' + dtoName + ' key(s): ' + joinToString(unknown) + ' \u2014 expected one of ' + joinToString(sorted(allowed));
2978
+ throw IllegalStateException_init_$Create$(toString(message));
2306
2979
  }
2307
- return tmp;
2308
2980
  }
2309
2981
  function toDto(_this__u8e3s4) {
2982
+ _init_properties_EngineJsApi_kt__9bputf();
2310
2983
  var o = {};
2311
2984
  o.startDistanceM = _this__u8e3s4.startDistanceM_1;
2312
2985
  o.endDistanceM = _this__u8e3s4.endDistanceM_1;
@@ -2319,6 +2992,7 @@
2319
2992
  return o;
2320
2993
  }
2321
2994
  function toDto_0(_this__u8e3s4) {
2995
+ _init_properties_EngineJsApi_kt__9bputf();
2322
2996
  var o = {};
2323
2997
  o.startIndex = _this__u8e3s4.startIndex_1;
2324
2998
  o.endIndex = _this__u8e3s4.endIndex_1;
@@ -2468,19 +3142,33 @@
2468
3142
  return i.invoke_jiwoso_k$($this$promise, $completion);
2469
3143
  }, 1);
2470
3144
  }
3145
+ var properties_initialized_EngineJsApi_kt_2x4hj5;
3146
+ function _init_properties_EngineJsApi_kt__9bputf() {
3147
+ if (!properties_initialized_EngineJsApi_kt_2x4hj5) {
3148
+ properties_initialized_EngineJsApi_kt_2x4hj5 = true;
3149
+ POWER_PROVIDER_KEYS = setOf_0(['type', 'power', 'useHarmonics', 'criticalPower', 'wPrime', 'pacing', 'maxSlewWPerS']);
3150
+ CYCLIST_KEYS = setOf_0(['massKg', 'cd', 'frontalAreaM2', 'maxLeanAngleDeg', 'maxBrakeG', 'maxSpeedKmH', 'roadCondition']);
3151
+ BIKE_KEYS = setOf_0(['crr', 'inertiaFront', 'inertiaRear', 'wheelRadiusM', 'efficiency', 'maxPedalingLeanAngleDeg']);
3152
+ WIND_KEYS = setOf_0(['windSpeed', 'windDirection']);
3153
+ ENHANCE_OPTIONS_KEYS = setOf_0(['fixElevation', 'computeMaxSpeeds', 'virtualizeTrack', 'computeOnePointPerSecond', 'simplifyEnabled', 'simplifyToleranceM', 'simplifyZExaggeration', 'wPrimeBalanceEnabled', 'wPrimeBalanceCriticalPower', 'wPrimeBalanceWPrime']);
3154
+ }
3155
+ }
2471
3156
  //region block: init
2472
3157
  Enhancer_instance = new Enhancer();
2473
- Companion_instance_4 = new Companion_4();
3158
+ Companion_instance_5 = new Companion_4();
2474
3159
  ClimbDetector_instance = new ClimbDetector();
2475
3160
  AeroPowerProvider_instance = new AeroPowerProvider();
2476
3161
  AeroProviderConstant_instance = new AeroProviderConstant();
2477
- Companion_instance_5 = new Companion_5();
3162
+ Companion_instance_6 = new Companion_5();
3163
+ Companion_instance_7 = new Companion_6();
2478
3164
  GravPowerProvider_instance = new GravPowerProvider();
2479
3165
  MaxSpeedComputer_instance = new MaxSpeedComputer();
2480
3166
  MuscularPowerProvider_instance = new MuscularPowerProvider();
2481
3167
  PowerComputer_instance = new PowerComputer();
2482
- Companion_instance_6 = new Companion_6();
3168
+ Companion_instance_8 = new Companion_7();
3169
+ Companion_instance_9 = new Companion_8();
2483
3170
  PowerProviderFromData_instance = new PowerProviderFromData();
3171
+ Companion_instance_10 = new Companion_9();
2484
3172
  RhoProviderDefault_instance = new RhoProviderDefault();
2485
3173
  RhoProviderEstimate_instance = new RhoProviderEstimate();
2486
3174
  RollingResistancePowerProvider_instance = new RollingResistancePowerProvider();