@glandais/vcyclist-engine 3.1.1 → 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,49 +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;
42
- var CoroutineImpl = kotlin_kotlin.$_$.x4;
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;
43
43
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.a2;
44
44
  var Unit_instance = kotlin_kotlin.$_$.g1;
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;
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;
74
80
  var PointField_TEMPERATURE_getInstance = kotlin_io_github_glandais_gpx.$_$.c;
75
- var isNaN_0 = kotlin_kotlin.$_$.da;
81
+ var isNaN_0 = kotlin_kotlin.$_$.ga;
76
82
  var get_entries = kotlin_io_github_glandais_gpx.$_$.u;
77
83
  var Path = kotlin_io_github_glandais_gpx.$_$.t;
78
84
  var GpxParser_instance = kotlin_io_github_glandais_gpx.$_$.d;
@@ -81,36 +87,39 @@
81
87
  var tracksAsPaths = kotlin_io_github_glandais_gpx.$_$.q;
82
88
  var segmentsAsPaths = kotlin_io_github_glandais_gpx.$_$.o;
83
89
  var GpxPathKind_TRACK_getInstance = kotlin_io_github_glandais_gpx.$_$.b;
84
- var setOf = kotlin_kotlin.$_$.w3;
90
+ var setOf = kotlin_kotlin.$_$.x3;
85
91
  var GpxPathKind_ROUTE_getInstance = kotlin_io_github_glandais_gpx.$_$.a;
86
92
  var GpxWriter_instance = kotlin_io_github_glandais_gpx.$_$.e;
87
- var toList = kotlin_kotlin.$_$.d4;
93
+ var toList = kotlin_kotlin.$_$.e4;
88
94
  var toGpxDocument = kotlin_io_github_glandais_gpx.$_$.p;
89
95
  var Companion_getInstance = kotlin_kotlin.$_$.d1;
90
- var numberToLong = kotlin_kotlin.$_$.o5;
96
+ var numberToLong = kotlin_kotlin.$_$.p5;
91
97
  var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
92
98
  var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
93
99
  var Companion_getInstance_0 = kotlin_io_github_glandais_gpx.$_$.j;
94
100
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.c2;
95
101
  var CsvWriter_instance = kotlin_io_github_glandais_gpx.$_$.f;
96
- var firstOrNull = kotlin_kotlin.$_$.g8;
102
+ var firstOrNull = kotlin_kotlin.$_$.i8;
97
103
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b;
98
- var Char = kotlin_kotlin.$_$.h9;
104
+ var Char = kotlin_kotlin.$_$.j9;
99
105
  var CsvOptions = kotlin_io_github_glandais_gpx.$_$.r;
100
106
  var JsonWriter_instance = kotlin_io_github_glandais_gpx.$_$.g;
101
107
  var JsonOptions = kotlin_io_github_glandais_gpx.$_$.s;
102
108
  var toFitBytes = kotlin_io_github_glandais_fit.$_$.a;
103
109
  var Companion_getInstance_1 = kotlin_kotlin.$_$.c1;
104
110
  var DurationUnit_MILLISECONDS_getInstance = kotlin_kotlin.$_$.w;
105
- var toDuration = kotlin_kotlin.$_$.g9;
111
+ var toDuration = kotlin_kotlin.$_$.i9;
106
112
  var toFitBytes_0 = kotlin_io_github_glandais_fit.$_$.b;
107
- var toNumber = kotlin_kotlin.$_$.t5;
113
+ var toNumber = kotlin_kotlin.$_$.u5;
108
114
  var GpxWaypoint = kotlin_io_github_glandais_gpx.$_$.m;
109
- 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;
110
118
  var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
111
119
  var ElevationProvider = kotlin_io_github_glandais_elevation.$_$.d;
112
- var initMetadataForLambda = kotlin_kotlin.$_$.s6;
113
- var constructCallableReference = kotlin_kotlin.$_$.d6;
120
+ var initMetadataForLambda = kotlin_kotlin.$_$.t6;
121
+ var constructCallableReference = kotlin_kotlin.$_$.e6;
122
+ var setOf_0 = kotlin_kotlin.$_$.y3;
114
123
  //endregion
115
124
  //region block: pre-declaration
116
125
  initMetadataForCompanion(Companion);
@@ -120,11 +129,14 @@
120
129
  initMetadataForClass(CoursePhysics, 'CoursePhysics');
121
130
  initMetadataForCompanion(Companion_1);
122
131
  initMetadataForClass(Cyclist, 'Cyclist', Cyclist);
132
+ initMetadataForObject(EngineConstants, 'EngineConstants');
123
133
  initMetadataForClass(SimplifyPathOptions, 'SimplifyPathOptions', SimplifyPathOptions);
134
+ initMetadataForClass(WPrimeBalanceOptions, 'WPrimeBalanceOptions', WPrimeBalanceOptions);
124
135
  initMetadataForCompanion(Companion_2);
125
136
  initMetadataForClass(EnhanceOptions, 'EnhanceOptions', EnhanceOptions);
126
137
  initMetadataForCoroutine($enhanceCourseCOROUTINE$, CoroutineImpl);
127
138
  initMetadataForObject(Enhancer, 'Enhancer', VOID, VOID, VOID, [3]);
139
+ initMetadataForClass(RoadCondition, 'RoadCondition', VOID, Enum);
128
140
  initMetadataForClass(Climb, 'Climb');
129
141
  initMetadataForClass(ClimbPart, 'ClimbPart');
130
142
  initMetadataForCompanion(Companion_3);
@@ -139,51 +151,74 @@
139
151
  initMetadataForObject(AeroProviderConstant, 'AeroProviderConstant');
140
152
  initMetadataForCompanion(Companion_5);
141
153
  initMetadataForClass(CyclistPowerProviderBase, 'CyclistPowerProviderBase');
154
+ initMetadataForCompanion(Companion_6);
155
+ initMetadataForClass(PowerModel, 'PowerModel', VOID, Enum);
156
+ initMetadataForClass(CyclistPowerSpec, 'CyclistPowerSpec', CyclistPowerSpec);
142
157
  initMetadataForObject(GravPowerProvider, 'GravPowerProvider');
143
158
  initMetadataForClass(Harmonic, 'Harmonic');
144
159
  initMetadataForObject(MaxSpeedComputer, 'MaxSpeedComputer');
145
160
  initMetadataForObject(MuscularPowerProvider, 'MuscularPowerProvider');
146
161
  initMetadataForObject(PowerComputer, 'PowerComputer');
147
162
  initMetadataForClass(PowerProviderConstant, 'PowerProviderConstant', VOID, CyclistPowerProviderBase);
148
- initMetadataForClass(PowerProviderConstantWithTiring, 'PowerProviderConstantWithTiring', VOID, CyclistPowerProviderBase);
163
+ initMetadataForCompanion(Companion_7);
164
+ initMetadataForClass(PowerProviderCriticalPower, 'PowerProviderCriticalPower', VOID, CyclistPowerProviderBase);
165
+ initMetadataForCompanion(Companion_8);
166
+ initMetadataForClass(PowerProviderDurability, 'PowerProviderDurability', VOID, CyclistPowerProviderBase);
149
167
  initMetadataForObject(PowerProviderFromData, 'PowerProviderFromData');
168
+ initMetadataForClass(PowerProviderSlewLimited, 'PowerProviderSlewLimited');
169
+ initMetadataForCompanion(Companion_9);
170
+ initMetadataForClass(PowerProviderTerrainPacing, 'PowerProviderTerrainPacing');
150
171
  initMetadataForObject(RhoProviderDefault, 'RhoProviderDefault');
151
172
  initMetadataForObject(RhoProviderEstimate, 'RhoProviderEstimate');
152
173
  initMetadataForObject(RollingResistancePowerProvider, 'RollingResistancePowerProvider');
153
174
  initMetadataForObject(VirtualizeService, 'VirtualizeService');
154
175
  initMetadataForObject(WheelBearingsPowerProvider, 'WheelBearingsPowerProvider');
155
- initMetadataForCompanion(Companion_6);
176
+ initMetadataForCompanion(Companion_10);
156
177
  initMetadataForClass(Wind, 'Wind');
157
178
  initMetadataForObject(WindProviderNone, 'WindProviderNone');
158
179
  initMetadataForClass(WindProviderConstant, 'WindProviderConstant');
180
+ initMetadataForObject(WPrimeBalanceComputer, 'WPrimeBalanceComputer');
159
181
  initMetadataForLambda(enhance$slambda, CoroutineImpl, VOID, [1]);
160
182
  initMetadataForLambda(enhanceWithCourse$slambda, CoroutineImpl, VOID, [1]);
161
183
  //endregion
162
184
  function Companion() {
163
- Companion_instance = this;
185
+ Companion_instance_0 = this;
164
186
  this.DEFAULT_1 = new Bike();
165
187
  }
166
- var Companion_instance;
188
+ var Companion_instance_0;
167
189
  function Companion_getInstance_2() {
168
- if (Companion_instance == null)
190
+ if (Companion_instance_0 == null)
169
191
  new Companion();
170
- return Companion_instance;
192
+ return Companion_instance_0;
171
193
  }
172
- function Bike(crr, inertiaFront, inertiaRear, wheelRadiusM, efficiency) {
194
+ function Bike(crr, inertiaFront, inertiaRear, wheelRadiusM, efficiency, maxPedalingLeanAngleDeg) {
173
195
  Companion_getInstance_2();
174
196
  crr = crr === VOID ? 0.004 : crr;
175
197
  inertiaFront = inertiaFront === VOID ? 0.05 : inertiaFront;
176
198
  inertiaRear = inertiaRear === VOID ? 0.07 : inertiaRear;
177
199
  wheelRadiusM = wheelRadiusM === VOID ? 0.35 : wheelRadiusM;
178
200
  efficiency = efficiency === VOID ? 0.976 : efficiency;
201
+ maxPedalingLeanAngleDeg = maxPedalingLeanAngleDeg === VOID ? 20.0 : maxPedalingLeanAngleDeg;
179
202
  this.crr_1 = crr;
180
203
  this.inertiaFront_1 = inertiaFront;
181
204
  this.inertiaRear_1 = inertiaRear;
182
205
  this.wheelRadiusM_1 = wheelRadiusM;
183
206
  this.efficiency_1 = efficiency;
207
+ this.maxPedalingLeanAngleDeg_1 = maxPedalingLeanAngleDeg;
184
208
  }
209
+ protoOf(Bike).get_tanMaxPedalingLeanAngle_nft7tz_k$ = function () {
210
+ var tmp;
211
+ if (this.maxPedalingLeanAngleDeg_1 >= 90.0) {
212
+ tmp = Infinity;
213
+ } else {
214
+ // Inline function 'kotlin.math.tan' call
215
+ var x = this.maxPedalingLeanAngleDeg_1 * 3.141592653589793 / 180.0;
216
+ tmp = Math.tan(x);
217
+ }
218
+ return tmp;
219
+ };
185
220
  protoOf(Bike).toString = function () {
186
- return 'Bike(crr=' + this.crr_1 + ', inertiaFront=' + this.inertiaFront_1 + ', inertiaRear=' + this.inertiaRear_1 + ', wheelRadiusM=' + this.wheelRadiusM_1 + ', efficiency=' + this.efficiency_1 + ')';
221
+ return 'Bike(crr=' + this.crr_1 + ', inertiaFront=' + this.inertiaFront_1 + ', inertiaRear=' + this.inertiaRear_1 + ', wheelRadiusM=' + this.wheelRadiusM_1 + ', efficiency=' + this.efficiency_1 + ', maxPedalingLeanAngleDeg=' + this.maxPedalingLeanAngleDeg_1 + ')';
187
222
  };
188
223
  protoOf(Bike).hashCode = function () {
189
224
  var result = getNumberHashCode(this.crr_1);
@@ -191,6 +226,7 @@
191
226
  result = imul(result, 31) + getNumberHashCode(this.inertiaRear_1) | 0;
192
227
  result = imul(result, 31) + getNumberHashCode(this.wheelRadiusM_1) | 0;
193
228
  result = imul(result, 31) + getNumberHashCode(this.efficiency_1) | 0;
229
+ result = imul(result, 31) + getNumberHashCode(this.maxPedalingLeanAngleDeg_1) | 0;
194
230
  return result;
195
231
  };
196
232
  protoOf(Bike).equals = function (other) {
@@ -208,6 +244,8 @@
208
244
  return false;
209
245
  if (!equals(this.efficiency_1, other.efficiency_1))
210
246
  return false;
247
+ if (!equals(this.maxPedalingLeanAngleDeg_1, other.maxPedalingLeanAngleDeg_1))
248
+ return false;
211
249
  return true;
212
250
  };
213
251
  function Course(path, cyclist, bike) {
@@ -249,14 +287,14 @@
249
287
  return true;
250
288
  };
251
289
  function Companion_0() {
252
- Companion_instance_0 = this;
290
+ Companion_instance_1 = this;
253
291
  this.DEFAULT_CYCLIST_POWER_PROVIDER_1 = new PowerProviderConstant(280.0);
254
292
  }
255
- var Companion_instance_0;
293
+ var Companion_instance_1;
256
294
  function Companion_getInstance_3() {
257
- if (Companion_instance_0 == null)
295
+ if (Companion_instance_1 == null)
258
296
  new Companion_0();
259
- return Companion_instance_0;
297
+ return Companion_instance_1;
260
298
  }
261
299
  function CoursePhysics(course, rhoProvider, aeroProvider, windProvider, cyclistPowerProvider) {
262
300
  Companion_getInstance_3();
@@ -319,14 +357,14 @@
319
357
  return true;
320
358
  };
321
359
  function Companion_1() {
322
- Companion_instance_1 = this;
360
+ Companion_instance_2 = this;
323
361
  this.DEFAULT_1 = new Cyclist();
324
362
  }
325
- var Companion_instance_1;
363
+ var Companion_instance_2;
326
364
  function Companion_getInstance_4() {
327
- if (Companion_instance_1 == null)
365
+ if (Companion_instance_2 == null)
328
366
  new Companion_1();
329
- return Companion_instance_1;
367
+ return Companion_instance_2;
330
368
  }
331
369
  function Cyclist(massKg, maxBrakeG, cd, frontalAreaM2, maxLeanAngleDeg, maxSpeedKmH) {
332
370
  Companion_getInstance_4();
@@ -385,6 +423,43 @@
385
423
  return false;
386
424
  return true;
387
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
+ }
388
463
  function SimplifyPathOptions(enabled, toleranceM, zExaggeration) {
389
464
  enabled = enabled === VOID ? true : enabled;
390
465
  toleranceM = toleranceM === VOID ? 10.0 : toleranceM;
@@ -415,42 +490,85 @@
415
490
  return false;
416
491
  return true;
417
492
  };
493
+ function WPrimeBalanceOptions(enabled, criticalPowerW, wPrimeJ) {
494
+ enabled = enabled === VOID ? true : enabled;
495
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
496
+ wPrimeJ = wPrimeJ === VOID ? 20000.0 : wPrimeJ;
497
+ this.enabled_1 = enabled;
498
+ this.criticalPowerW_1 = criticalPowerW;
499
+ this.wPrimeJ_1 = wPrimeJ;
500
+ // Inline function 'kotlin.require' call
501
+ if (!(this.criticalPowerW_1 > 0.0)) {
502
+ var message = 'criticalPowerW must be > 0, got ' + this.criticalPowerW_1;
503
+ throw IllegalArgumentException_init_$Create$(toString(message));
504
+ }
505
+ // Inline function 'kotlin.require' call
506
+ if (!(this.wPrimeJ_1 > 0.0)) {
507
+ var message_0 = 'wPrimeJ must be > 0, got ' + this.wPrimeJ_1;
508
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
509
+ }
510
+ }
511
+ protoOf(WPrimeBalanceOptions).toString = function () {
512
+ return 'WPrimeBalanceOptions(enabled=' + this.enabled_1 + ', criticalPowerW=' + this.criticalPowerW_1 + ', wPrimeJ=' + this.wPrimeJ_1 + ')';
513
+ };
514
+ protoOf(WPrimeBalanceOptions).hashCode = function () {
515
+ var result = getBooleanHashCode(this.enabled_1);
516
+ result = imul(result, 31) + getNumberHashCode(this.criticalPowerW_1) | 0;
517
+ result = imul(result, 31) + getNumberHashCode(this.wPrimeJ_1) | 0;
518
+ return result;
519
+ };
520
+ protoOf(WPrimeBalanceOptions).equals = function (other) {
521
+ if (this === other)
522
+ return true;
523
+ if (!(other instanceof WPrimeBalanceOptions))
524
+ return false;
525
+ if (!(this.enabled_1 === other.enabled_1))
526
+ return false;
527
+ if (!equals(this.criticalPowerW_1, other.criticalPowerW_1))
528
+ return false;
529
+ if (!equals(this.wPrimeJ_1, other.wPrimeJ_1))
530
+ return false;
531
+ return true;
532
+ };
418
533
  function Companion_2() {
419
- Companion_instance_2 = this;
534
+ Companion_instance_3 = this;
420
535
  this.DEFAULT_1 = new EnhanceOptions();
421
536
  }
422
- var Companion_instance_2;
537
+ var Companion_instance_3;
423
538
  function Companion_getInstance_5() {
424
- if (Companion_instance_2 == null)
539
+ if (Companion_instance_3 == null)
425
540
  new Companion_2();
426
- return Companion_instance_2;
541
+ return Companion_instance_3;
427
542
  }
428
- function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath) {
543
+ function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
429
544
  Companion_getInstance_5();
430
545
  fixElevation = fixElevation === VOID ? true : fixElevation;
431
546
  computeMaxSpeeds = computeMaxSpeeds === VOID ? true : computeMaxSpeeds;
432
547
  virtualizeTrack = virtualizeTrack === VOID ? true : virtualizeTrack;
433
548
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? true : computeOnePointPerSecond;
434
549
  simplifyPath = simplifyPath === VOID ? new SimplifyPathOptions() : simplifyPath;
550
+ wPrimeBalance = wPrimeBalance === VOID ? new WPrimeBalanceOptions() : wPrimeBalance;
435
551
  this.fixElevation_1 = fixElevation;
436
552
  this.computeMaxSpeeds_1 = computeMaxSpeeds;
437
553
  this.virtualizeTrack_1 = virtualizeTrack;
438
554
  this.computeOnePointPerSecond_1 = computeOnePointPerSecond;
439
555
  this.simplifyPath_1 = simplifyPath;
556
+ this.wPrimeBalance_1 = wPrimeBalance;
440
557
  }
441
- protoOf(EnhanceOptions).copy_8buhav_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath) {
442
- return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath);
558
+ protoOf(EnhanceOptions).copy_bazpxz_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
559
+ return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
443
560
  };
444
- protoOf(EnhanceOptions).copy$default_9zz8ww_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, $super) {
561
+ protoOf(EnhanceOptions).copy$default_2rfmrp_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, $super) {
445
562
  fixElevation = fixElevation === VOID ? this.fixElevation_1 : fixElevation;
446
563
  computeMaxSpeeds = computeMaxSpeeds === VOID ? this.computeMaxSpeeds_1 : computeMaxSpeeds;
447
564
  virtualizeTrack = virtualizeTrack === VOID ? this.virtualizeTrack_1 : virtualizeTrack;
448
565
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? this.computeOnePointPerSecond_1 : computeOnePointPerSecond;
449
566
  simplifyPath = simplifyPath === VOID ? this.simplifyPath_1 : simplifyPath;
450
- return $super === VOID ? this.copy_8buhav_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath) : $super.copy_8buhav_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath);
567
+ wPrimeBalance = wPrimeBalance === VOID ? this.wPrimeBalance_1 : wPrimeBalance;
568
+ return $super === VOID ? this.copy_bazpxz_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) : $super.copy_bazpxz_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
451
569
  };
452
570
  protoOf(EnhanceOptions).toString = function () {
453
- return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ')';
571
+ return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ', wPrimeBalance=' + this.wPrimeBalance_1.toString() + ')';
454
572
  };
455
573
  protoOf(EnhanceOptions).hashCode = function () {
456
574
  var result = getBooleanHashCode(this.fixElevation_1);
@@ -458,6 +576,7 @@
458
576
  result = imul(result, 31) + getBooleanHashCode(this.virtualizeTrack_1) | 0;
459
577
  result = imul(result, 31) + getBooleanHashCode(this.computeOnePointPerSecond_1) | 0;
460
578
  result = imul(result, 31) + this.simplifyPath_1.hashCode() | 0;
579
+ result = imul(result, 31) + this.wPrimeBalance_1.hashCode() | 0;
461
580
  return result;
462
581
  };
463
582
  protoOf(EnhanceOptions).equals = function (other) {
@@ -475,6 +594,8 @@
475
594
  return false;
476
595
  if (!this.simplifyPath_1.equals(other.simplifyPath_1))
477
596
  return false;
597
+ if (!this.wPrimeBalance_1.equals(other.wPrimeBalance_1))
598
+ return false;
478
599
  return true;
479
600
  };
480
601
  function $enhanceCourseCOROUTINE$(_this__u8e3s4, course, options, elevationProvider, resultContinuation) {
@@ -532,6 +653,10 @@
532
653
  this.path0__1 = PointPerSecond_instance.computeOnePointPerSecond_7sah9a_k$(this.path0__1);
533
654
  }
534
655
 
656
+ if (this.options_1.wPrimeBalance_1.enabled_1) {
657
+ WPrimeBalanceComputer_instance.compute_ewvoaz_k$(this.path0__1, this.options_1.wPrimeBalance_1);
658
+ }
659
+
535
660
  if (this.options_1.simplifyPath_1.enabled_1) {
536
661
  this.path0__1 = PathSimplifier_instance.simplify_gxhj7b_k$(this.path0__1, this.options_1.simplifyPath_1.toleranceM_1, this.options_1.simplifyPath_1.zExaggeration_1);
537
662
  }
@@ -557,7 +682,7 @@
557
682
  return new CoursePhysics(new Course(path), RhoProviderEstimate_instance, AeroProviderConstant_instance, WindProviderNone_instance, new PowerProviderConstant(280.0));
558
683
  };
559
684
  protoOf(Enhancer).enhanceCourseDefault_jm937y_k$ = function (path, elevationProvider, options, $completion) {
560
- return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_9zz8ww_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
685
+ return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_2rfmrp_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
561
686
  };
562
687
  protoOf(Enhancer).enhanceCourse_mout3j_k$ = function (course, options, elevationProvider, $completion) {
563
688
  var tmp = new $enhanceCourseCOROUTINE$(this, course, options, elevationProvider, $completion);
@@ -569,6 +694,48 @@
569
694
  function Enhancer_getInstance() {
570
695
  return Enhancer_instance;
571
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
+ }
572
739
  function Climb(startIndex, endIndex, startDistanceM, endDistanceM, startElevationM, endElevationM, positiveElevationM, negativeElevationM, parts) {
573
740
  this.startIndex_1 = startIndex;
574
741
  this.endIndex_1 = endIndex;
@@ -693,14 +860,14 @@
693
860
  return true;
694
861
  };
695
862
  function Companion_3() {
696
- Companion_instance_3 = this;
863
+ Companion_instance_4 = this;
697
864
  this.DEFAULT_1 = new ClimbOptions();
698
865
  }
699
- var Companion_instance_3;
866
+ var Companion_instance_4;
700
867
  function Companion_getInstance_6() {
701
- if (Companion_instance_3 == null)
868
+ if (Companion_instance_4 == null)
702
869
  new Companion_3();
703
- return Companion_instance_3;
870
+ return Companion_instance_4;
704
871
  }
705
872
  function ClimbOptions(minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGradeRatio, booster, maxAnalysisPoints) {
706
873
  Companion_getInstance_6();
@@ -804,9 +971,9 @@
804
971
  }
805
972
  return new Profile(tmp_6, tmp_10, indices);
806
973
  };
807
- var Companion_instance_4;
974
+ var Companion_instance_5;
808
975
  function Companion_getInstance_7() {
809
- return Companion_instance_4;
976
+ return Companion_instance_5;
810
977
  }
811
978
  function Profile(distance, elevation, sourceIndex) {
812
979
  this.distance_1 = distance;
@@ -1059,7 +1226,7 @@
1059
1226
  // Inline function 'kotlin.comparisons.maxOf' call
1060
1227
  var b_0 = Math.min(tmp0_0, b);
1061
1228
  var minClimbElevation = Math.max(tmp0, b_0);
1062
- 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);
1063
1230
  // Inline function 'kotlin.collections.mapNotNull' call
1064
1231
  var tmp0_1 = until(0, profile.get_size_woubt6_k$());
1065
1232
  // Inline function 'kotlin.collections.mapNotNullTo' call
@@ -1257,9 +1424,9 @@
1257
1424
  this.TOLERANCE_1 = 0.05;
1258
1425
  this.MAX_MULTIPLIER_1 = 3.0;
1259
1426
  }
1260
- var Companion_instance_5;
1427
+ var Companion_instance_6;
1261
1428
  function Companion_getInstance_8() {
1262
- return Companion_instance_5;
1429
+ return Companion_instance_6;
1263
1430
  }
1264
1431
  function CyclistPowerProviderBase(useHarmonics, random) {
1265
1432
  random = random === VOID ? Default_getInstance() : random;
@@ -1306,6 +1473,173 @@
1306
1473
  path.setPCyclistPowerNeeded_54po1x_k$(pointIndex, powerNeeded);
1307
1474
  return power;
1308
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
+ }
1309
1643
  function GravPowerProvider() {
1310
1644
  }
1311
1645
  protoOf(GravPowerProvider).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
@@ -1354,9 +1688,15 @@
1354
1688
  function computeCorneringLimit($this, course, currentIndex, window_0) {
1355
1689
  var path = course.path_1;
1356
1690
  var radius = computeRadiusWindowed($this, path, currentIndex, window_0);
1357
- // Inline function 'kotlin.math.sqrt' call
1358
- var x = 9.80665 * radius * course.cyclist_1.get_tanMaxLeanAngle_qqiag1_k$();
1359
- var vMax = Math.sqrt(x);
1691
+ var tmp;
1692
+ if (radius >= 200.0) {
1693
+ tmp = course.cyclist_1.get_maxSpeedMS_xz2r7y_k$();
1694
+ } else {
1695
+ // Inline function 'kotlin.math.sqrt' call
1696
+ var x = 9.80665 * radius * course.cyclist_1.get_tanMaxLeanAngle_qqiag1_k$();
1697
+ tmp = Math.sqrt(x);
1698
+ }
1699
+ var vMax = tmp;
1360
1700
  // Inline function 'kotlin.math.min' call
1361
1701
  var a = course.cyclist_1.get_maxSpeedMS_xz2r7y_k$();
1362
1702
  var result = Math.min(a, vMax);
@@ -1387,14 +1727,46 @@
1387
1727
  path.setRadius_p1cueq_k$(i, clamped);
1388
1728
  return clamped;
1389
1729
  }
1390
- function computeBrakingLimit($this, course, currentIndex, nextIndex) {
1730
+ function computeBrakingLimit($this, course, currentIndex, nextIndex, corneringLimit) {
1391
1731
  var path = course.path_1;
1392
1732
  var vf = path.speedMax_mjo2cl_k$(nextIndex);
1393
- var a = course.cyclist_1.get_maxBrakeMS2_nzouxw_k$();
1733
+ var aXMax = course.cyclist_1.get_maxBrakeMS2_nzouxw_k$();
1394
1734
  var d = path.distance_5s4s77_k$(nextIndex) - path.distance_5s4s77_k$(currentIndex);
1735
+ var radius = path.radius_84q0sm_k$(currentIndex);
1736
+ if (radius >= 200.0 || !isFinite(radius) || radius <= 0.0) {
1737
+ // Inline function 'kotlin.math.sqrt' call
1738
+ var x = vf * vf + 2.0 * aXMax * d;
1739
+ // Inline function 'kotlin.math.min' call
1740
+ var b = Math.sqrt(x);
1741
+ return Math.min(corneringLimit, b);
1742
+ }
1743
+ var aYMax = 9.80665 * course.cyclist_1.get_tanMaxLeanAngle_qqiag1_k$();
1744
+ if (computeBrakingLimit$slack(radius, aYMax, aXMax, vf, d, corneringLimit) >= 0.0)
1745
+ return corneringLimit;
1746
+ // Inline function 'kotlin.math.min' call
1747
+ var low = Math.min(vf, corneringLimit);
1748
+ var high = corneringLimit;
1749
+ // Inline function 'kotlin.repeat' call
1750
+ var inductionVariable = 0;
1751
+ if (inductionVariable < 24)
1752
+ do {
1753
+ var index = inductionVariable;
1754
+ inductionVariable = inductionVariable + 1 | 0;
1755
+ var mid = (low + high) / 2.0;
1756
+ if (computeBrakingLimit$slack(radius, aYMax, aXMax, vf, d, mid) >= 0.0)
1757
+ low = mid;
1758
+ else
1759
+ high = mid;
1760
+ }
1761
+ while (inductionVariable < 24);
1762
+ return low;
1763
+ }
1764
+ function computeBrakingLimit$slack(radius, aYMax, aXMax, vf, d, v) {
1765
+ var lateralFraction = coerceIn(v * v / radius / aYMax, 0.0, 1.0);
1395
1766
  // Inline function 'kotlin.math.sqrt' call
1396
- var x = vf * vf + 2.0 * a * d;
1397
- return Math.sqrt(x);
1767
+ var x = 1.0 - lateralFraction * lateralFraction;
1768
+ var aX = aXMax * Math.sqrt(x);
1769
+ return vf * vf + 2.0 * aX * d - v * v;
1398
1770
  }
1399
1771
  function MaxSpeedComputer() {
1400
1772
  this.MAX_RADIUS_M_1 = 200.0;
@@ -1402,6 +1774,7 @@
1402
1774
  this.END_SPEED_MS_1 = 2.0;
1403
1775
  this.BEARING_THRESHOLD_1 = 0.001;
1404
1776
  this.DEFAULT_WINDOW_1 = 10;
1777
+ this.ELLIPSE_ITERATIONS_1 = 24;
1405
1778
  }
1406
1779
  protoOf(MaxSpeedComputer).computeMaxSpeeds_jc4v4o_k$ = function (course) {
1407
1780
  var path = course.path_1;
@@ -1415,10 +1788,7 @@
1415
1788
  path.setSpeedMax_7xvqir_k$(i, 2.0);
1416
1789
  } else {
1417
1790
  var cornering = computeCorneringLimit(this, course, i, 10);
1418
- var braking = computeBrakingLimit(this, course, i, i + 1 | 0);
1419
- // Inline function 'kotlin.math.min' call
1420
- var tmp$ret$0 = Math.min(cornering, braking);
1421
- path.setSpeedMax_7xvqir_k$(i, tmp$ret$0);
1791
+ path.setSpeedMax_7xvqir_k$(i, computeBrakingLimit(this, course, i, i + 1 | 0, cornering));
1422
1792
  }
1423
1793
  }
1424
1794
  while (0 <= inductionVariable);
@@ -1439,12 +1809,23 @@
1439
1809
  function MuscularPowerProvider() {
1440
1810
  }
1441
1811
  protoOf(MuscularPowerProvider).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
1442
- var muscular = course.cyclistPowerProvider_1.powerAt_ejucaq_k$(course, path, pointIndex);
1812
+ var intent = course.cyclistPowerProvider_1.powerAt_ejucaq_k$(course, path, pointIndex);
1813
+ var muscular = this.pedalsClear_b5t5mh_k$(course, path, pointIndex) ? intent : 0.0;
1443
1814
  path.setPCyclistProvidedMuscular_aori9q_k$(pointIndex, muscular);
1444
1815
  var wheel = muscular * course.get_bike_wojgoa_k$().efficiency_1;
1445
1816
  path.setPCyclistProvidedWheel_ofsihz_k$(pointIndex, wheel);
1446
1817
  return wheel;
1447
1818
  };
1819
+ protoOf(MuscularPowerProvider).pedalsClear_b5t5mh_k$ = function (course, path, pointIndex) {
1820
+ var radius = path.radius_84q0sm_k$(pointIndex);
1821
+ if (!isFinite(radius) || radius <= 0.0)
1822
+ return true;
1823
+ var speed = path.speed_npav2n_k$(pointIndex);
1824
+ if (!isFinite(speed))
1825
+ return true;
1826
+ var tanLean = speed * speed / (9.80665 * radius);
1827
+ return tanLean <= course.get_bike_wojgoa_k$().get_tanMaxPedalingLeanAngle_nft7tz_k$();
1828
+ };
1448
1829
  var MuscularPowerProvider_instance;
1449
1830
  function MuscularPowerProvider_getInstance() {
1450
1831
  return MuscularPowerProvider_instance;
@@ -1452,7 +1833,9 @@
1452
1833
  function getDtInner($this, pSum, equivalentMass, currentSpeed, dx, dt1Init, dt2Init) {
1453
1834
  var dt1 = dt1Init;
1454
1835
  var dt2 = dt2Init;
1455
- var tol = dx / 1.0E7;
1836
+ // Inline function 'kotlin.math.max' call
1837
+ var a = dx / 1.0E7;
1838
+ var tol = Math.max(a, 1.0E-12);
1456
1839
  while (dt2 - dt1 >= tol) {
1457
1840
  var dtMid = (dt1 + dt2) / 2.0;
1458
1841
  var dxMid = $this.getDx_xtszre_k$(pSum, equivalentMass, currentSpeed, dtMid);
@@ -1464,6 +1847,7 @@
1464
1847
  return (dt1 + dt2) / 2.0;
1465
1848
  }
1466
1849
  function PowerComputer() {
1850
+ this.MIN_DT_TOLERANCE_1 = 1.0E-12;
1467
1851
  }
1468
1852
  protoOf(PowerComputer).getNewPower_puvq9i_k$ = function (course, path, pointIndex, withCyclist) {
1469
1853
  var pSum = 0.0;
@@ -1477,12 +1861,14 @@
1477
1861
  return pSum;
1478
1862
  };
1479
1863
  protoOf(PowerComputer).getDx_xtszre_k$ = function (pSum, equivalentMass, currentSpeed, dt) {
1864
+ // Inline function 'kotlin.math.max' call
1865
+ var b = dt * pSum / (0.5 * equivalentMass) + currentSpeed * currentSpeed;
1480
1866
  // Inline function 'kotlin.math.sqrt' call
1481
- var x = dt * pSum / (0.5 * equivalentMass) + currentSpeed * currentSpeed;
1867
+ var x = Math.max(0.0, b);
1482
1868
  var tmp0 = Math.sqrt(x);
1483
1869
  // Inline function 'kotlin.math.max' call
1484
- var b = 0.5555555555555556;
1485
- var newSpeed = Math.max(tmp0, b);
1870
+ var b_0 = 0.5555555555555556;
1871
+ var newSpeed = Math.max(tmp0, b_0);
1486
1872
  return (currentSpeed + newSpeed) * dt / 2.0;
1487
1873
  };
1488
1874
  protoOf(PowerComputer).getTotPower_kfbciq_k$ = function (equivalentMass, s1, s2, dt) {
@@ -1497,17 +1883,28 @@
1497
1883
  };
1498
1884
  protoOf(PowerComputer).computeCyclistPower_kgcsa3_k$ = function (course, path, equivalentMass, i) {
1499
1885
  if (i === 0) {
1886
+ path.setPComputedPower_c3m6yw_k$(i, 0.0);
1887
+ path.setPBrake_iza4qj_k$(i, 0.0);
1888
+ return Unit_instance;
1889
+ }
1890
+ var dtSeconds = path.dt_17uzp4_k$(i) / 1000.0;
1891
+ if (dtSeconds <= 0.0) {
1892
+ path.setPComputedTotalPower_wm6di_k$(i, 0.0);
1893
+ path.setPComputedWheelPower_qplog3_k$(i, 0.0);
1894
+ path.setPBrake_iza4qj_k$(i, 0.0);
1500
1895
  path.setPComputedPower_c3m6yw_k$(i, 0.0);
1501
1896
  return Unit_instance;
1502
1897
  }
1503
1898
  var resistive = this.getNewPower_puvq9i_k$(course, path, i - 1 | 0, false);
1504
1899
  var s1 = path.speed_npav2n_k$(i - 1 | 0);
1505
1900
  var s2 = path.speed_npav2n_k$(i);
1506
- var dtSeconds = path.dt_17uzp4_k$(i) / 1000.0;
1507
1901
  var totPower = this.getTotPower_kfbciq_k$(equivalentMass, s1, s2, dtSeconds);
1508
1902
  path.setPComputedTotalPower_wm6di_k$(i, totPower);
1509
1903
  var powerWheel = totPower - resistive;
1510
1904
  path.setPComputedWheelPower_qplog3_k$(i, powerWheel);
1905
+ // Inline function 'kotlin.math.min' call
1906
+ var tmp$ret$0 = Math.min(0.0, powerWheel);
1907
+ path.setPBrake_iza4qj_k$(i, tmp$ret$0);
1511
1908
  // Inline function 'kotlin.math.max' call
1512
1909
  var computed = Math.max(0.0, powerWheel) / course.get_bike_wojgoa_k$().efficiency_1;
1513
1910
  path.setPComputedPower_c3m6yw_k$(i, computed);
@@ -1533,24 +1930,169 @@
1533
1930
  protoOf(PowerProviderConstant).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1534
1931
  return this.power_1;
1535
1932
  };
1536
- function PowerProviderConstantWithTiring(power, useHarmonics, durationSeconds, random) {
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;
1537
1944
  useHarmonics = useHarmonics === VOID ? false : useHarmonics;
1538
1945
  random = random === VOID ? Default_getInstance() : random;
1539
1946
  CyclistPowerProviderBase.call(this, useHarmonics, random);
1540
- this.power_1 = power;
1541
- this.durationSeconds_1 = durationSeconds;
1947
+ this.powerW_1 = powerW;
1948
+ this.criticalPowerW_1 = criticalPowerW;
1949
+ this.wPrimeJ_1 = wPrimeJ;
1950
+ this.taperStartFraction_1 = taperStartFraction;
1542
1951
  // Inline function 'kotlin.require' call
1543
- if (!(this.durationSeconds_1 > 0.0)) {
1544
- var message = 'durationSeconds must be > 0, got ' + this.durationSeconds_1;
1952
+ if (!(this.powerW_1 > 0.0)) {
1953
+ var message = 'powerW must be > 0, got ' + this.powerW_1;
1545
1954
  throw IllegalArgumentException_init_$Create$(toString(message));
1546
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;
1547
1976
  }
1548
- protoOf(PowerProviderConstantWithTiring).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1549
- var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
1550
- // Inline function 'kotlin.math.max' call
1551
- var b = 1.0 - 0.6 * elapsedS / this.durationSeconds_1;
1552
- var c = Math.max(0.5, b);
1553
- return this.power_1 * c;
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() {
2017
+ this.DEFAULT_DECLINE_PER_KJ_PER_KG_1 = 0.006666666666666667;
2018
+ this.DEFAULT_MAX_DECLINE_1 = 0.2;
2019
+ }
2020
+ var Companion_instance_9;
2021
+ function Companion_getInstance_11() {
2022
+ return Companion_instance_9;
2023
+ }
2024
+ function PowerProviderDurability(powerW, criticalPowerW, declinePerKjPerKg, maxDecline, useHarmonics, random) {
2025
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
2026
+ declinePerKjPerKg = declinePerKjPerKg === VOID ? 0.006666666666666667 : declinePerKjPerKg;
2027
+ maxDecline = maxDecline === VOID ? 0.2 : maxDecline;
2028
+ useHarmonics = useHarmonics === VOID ? false : useHarmonics;
2029
+ random = random === VOID ? Default_getInstance() : random;
2030
+ CyclistPowerProviderBase.call(this, useHarmonics, random);
2031
+ this.powerW_1 = powerW;
2032
+ this.criticalPowerW_1 = criticalPowerW;
2033
+ this.declinePerKjPerKg_1 = declinePerKjPerKg;
2034
+ this.maxDecline_1 = maxDecline;
2035
+ // Inline function 'kotlin.require' call
2036
+ if (!(this.powerW_1 > 0.0)) {
2037
+ var message = 'powerW must be > 0, got ' + this.powerW_1;
2038
+ throw IllegalArgumentException_init_$Create$(toString(message));
2039
+ }
2040
+ // Inline function 'kotlin.require' call
2041
+ if (!(this.criticalPowerW_1 > 0.0)) {
2042
+ var message_0 = 'criticalPowerW must be > 0, got ' + this.criticalPowerW_1;
2043
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
2044
+ }
2045
+ // Inline function 'kotlin.require' call
2046
+ if (!(this.declinePerKjPerKg_1 >= 0.0)) {
2047
+ var message_1 = 'declinePerKjPerKg must be >= 0, got ' + this.declinePerKjPerKg_1;
2048
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
2049
+ }
2050
+ var containsArg = this.maxDecline_1;
2051
+ // Inline function 'kotlin.require' call
2052
+ if (!(0.0 <= containsArg ? containsArg <= 1.0 : false)) {
2053
+ var message_2 = 'maxDecline must be in [0, 1], got ' + this.maxDecline_1;
2054
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
2055
+ }
2056
+ this.lastIndex_1 = -1;
2057
+ this.lastElapsedS_1 = 0.0;
2058
+ this.lastPowerW_1 = 0.0;
2059
+ this.supraCriticalWorkJ_1 = 0.0;
2060
+ this.massKgForDose_1 = 80.0;
2061
+ }
2062
+ protoOf(PowerProviderDurability).get_decline_qrtukt_k$ = function () {
2063
+ var tmp0 = this.maxDecline_1;
2064
+ // Inline function 'kotlin.math.min' call
2065
+ var b = this.declinePerKjPerKg_1 * this.supraCriticalWorkJ_1 / 1000.0 / this.massKgForDose_1;
2066
+ return Math.min(tmp0, b);
2067
+ };
2068
+ protoOf(PowerProviderDurability).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
2069
+ this.massKgForDose_1 = course.get_cyclist_lkc0de_k$().massKg_1;
2070
+ if (pointIndex < this.lastIndex_1) {
2071
+ this.reset_5u6xz3_k$();
2072
+ }
2073
+ if (pointIndex > this.lastIndex_1) {
2074
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2075
+ var dtS = elapsedS - this.lastElapsedS_1;
2076
+ if (dtS > 0.0 && isFinite(dtS)) {
2077
+ var tmp = this;
2078
+ var tmp_0 = this.supraCriticalWorkJ_1;
2079
+ // Inline function 'kotlin.math.max' call
2080
+ var b = this.lastPowerW_1 - this.criticalPowerW_1;
2081
+ tmp.supraCriticalWorkJ_1 = tmp_0 + Math.max(0.0, b) * dtS;
2082
+ }
2083
+ if (isFinite(elapsedS))
2084
+ this.lastElapsedS_1 = elapsedS;
2085
+ this.lastIndex_1 = pointIndex;
2086
+ }
2087
+ var faded = this.powerW_1 * (1.0 - this.get_decline_qrtukt_k$());
2088
+ this.lastPowerW_1 = faded;
2089
+ return faded;
2090
+ };
2091
+ protoOf(PowerProviderDurability).reset_5u6xz3_k$ = function () {
2092
+ this.lastIndex_1 = -1;
2093
+ this.lastElapsedS_1 = 0.0;
2094
+ this.lastPowerW_1 = 0.0;
2095
+ this.supraCriticalWorkJ_1 = 0.0;
1554
2096
  };
1555
2097
  function PowerProviderFromData() {
1556
2098
  }
@@ -1561,6 +2103,184 @@
1561
2103
  function PowerProviderFromData_getInstance() {
1562
2104
  return PowerProviderFromData_instance;
1563
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
+ };
1564
2284
  function RhoProviderDefault() {
1565
2285
  }
1566
2286
  protoOf(RhoProviderDefault).rho_pwqvzi_k$ = function (course, path, pointIndex) {
@@ -1644,8 +2364,19 @@
1644
2364
  out.setVirtSpeedCurrent_kvg8yv_k$(0, speed);
1645
2365
  var i = 1;
1646
2366
  var iter = 0;
1647
- $l$loop: while (i < n) {
2367
+ $l$loop_0: while (i < n) {
1648
2368
  var dx = input.distance_5s4s77_k$(i) - input.distance_5s4s77_k$(i - 1 | 0);
2369
+ if (dx <= 0.0) {
2370
+ copyAllFields(this, input, i, out, i);
2371
+ out.setTime_rfmvcd_k$(i, timeMs);
2372
+ out.setElapsed_916ug_k$(i, timeMs - startTimeMs);
2373
+ out.setDx_uk0ky4_k$(i, 0.0);
2374
+ out.setDt_sgarxs_k$(i, 0.0);
2375
+ out.setSpeed_1slan1_k$(i, speed);
2376
+ out.setVirtSpeedCurrent_kvg8yv_k$(i, speed);
2377
+ i = i + 1 | 0;
2378
+ continue $l$loop_0;
2379
+ }
1649
2380
  var pSum = PowerComputer_instance.getNewPower_puvq9i_k$(course, out, i - 1 | 0, true);
1650
2381
  var dt = PowerComputer_instance.getDt_t0pcee_k$(pSum, mEq, speed, dx);
1651
2382
  var speedNew = 2.0 * dx / dt - speed;
@@ -1667,7 +2398,7 @@
1667
2398
  var _unary__edvuaz = iter;
1668
2399
  iter = _unary__edvuaz + 1 | 0;
1669
2400
  if (_unary__edvuaz > 100000)
1670
- break $l$loop;
2401
+ break $l$loop_0;
1671
2402
  }
1672
2403
  var progression = out.get_indices_xelk8u_k$();
1673
2404
  var inductionVariable = progression.first_1;
@@ -1698,18 +2429,18 @@
1698
2429
  function WheelBearingsPowerProvider_getInstance() {
1699
2430
  return WheelBearingsPowerProvider_instance;
1700
2431
  }
1701
- function Companion_6() {
1702
- Companion_instance_6 = this;
2432
+ function Companion_10() {
2433
+ Companion_instance_11 = this;
1703
2434
  this.NONE_1 = new Wind(0.0, 0.0);
1704
2435
  }
1705
- var Companion_instance_6;
1706
- function Companion_getInstance_9() {
1707
- if (Companion_instance_6 == null)
1708
- new Companion_6();
1709
- return Companion_instance_6;
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;
1710
2441
  }
1711
2442
  function Wind(speedMS, directionRad) {
1712
- Companion_getInstance_9();
2443
+ Companion_getInstance_13();
1713
2444
  this.speedMS_1 = speedMS;
1714
2445
  this.directionRad_1 = directionRad;
1715
2446
  }
@@ -1735,7 +2466,7 @@
1735
2466
  function WindProviderNone() {
1736
2467
  }
1737
2468
  protoOf(WindProviderNone).wind_umf2tf_k$ = function (course, path, pointIndex) {
1738
- return Companion_getInstance_9().NONE_1;
2469
+ return Companion_getInstance_13().NONE_1;
1739
2470
  };
1740
2471
  var WindProviderNone_instance;
1741
2472
  function WindProviderNone_getInstance() {
@@ -1747,7 +2478,77 @@
1747
2478
  protoOf(WindProviderConstant).wind_umf2tf_k$ = function (course, path, pointIndex) {
1748
2479
  return this.wind_1;
1749
2480
  };
2481
+ function WPrimeBalanceComputer() {
2482
+ }
2483
+ protoOf(WPrimeBalanceComputer).compute_ewvoaz_k$ = function (path, options) {
2484
+ if (path.size_1 === 0)
2485
+ return Unit_instance;
2486
+ var cp = options.criticalPowerW_1;
2487
+ var wPrime = options.wPrimeJ_1;
2488
+ var balance = wPrime;
2489
+ path.setWPrimeBalance_stwqkw_k$(0, balance);
2490
+ var inductionVariable = 1;
2491
+ var last = path.size_1;
2492
+ if (inductionVariable < last)
2493
+ do {
2494
+ var i = inductionVariable;
2495
+ inductionVariable = inductionVariable + 1 | 0;
2496
+ var dtSeconds = (path.time_ryc845_k$(i) - path.time_ryc845_k$(i - 1 | 0)) / 1000.0;
2497
+ var power = path.pComputedPower_g6dnn4_k$(i);
2498
+ if (isFinite(dtSeconds) && dtSeconds > 0.0 && isFinite(power)) {
2499
+ balance = this.step_447nu7_k$(balance, power, cp, wPrime, dtSeconds);
2500
+ }
2501
+ path.setWPrimeBalance_stwqkw_k$(i, balance);
2502
+ }
2503
+ while (inductionVariable < last);
2504
+ };
2505
+ protoOf(WPrimeBalanceComputer).step_447nu7_k$ = function (balance, power, cp, wPrime, dtSeconds) {
2506
+ var tmp;
2507
+ if (power >= cp) {
2508
+ tmp = balance - (power - cp) * dtSeconds;
2509
+ } else {
2510
+ var tmp_0 = wPrime - balance;
2511
+ // Inline function 'kotlin.math.exp' call
2512
+ var x = -(cp - power) * dtSeconds / wPrime;
2513
+ tmp = wPrime - tmp_0 * Math.exp(x);
2514
+ }
2515
+ var next = tmp;
2516
+ // Inline function 'kotlin.math.max' call
2517
+ // Inline function 'kotlin.math.min' call
2518
+ var b = Math.max(0.0, next);
2519
+ return Math.min(wPrime, b);
2520
+ };
2521
+ var WPrimeBalanceComputer_instance;
2522
+ function WPrimeBalanceComputer_getInstance() {
2523
+ return WPrimeBalanceComputer_instance;
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;
1750
2550
  function parseGpxWaypoints(xml) {
2551
+ _init_properties_EngineJsApi_kt__9bputf();
1751
2552
  // Inline function 'kotlin.collections.map' call
1752
2553
  var this_0 = GpxParser_instance.parse$default_ez0f31_k$(xml).waypoints_1;
1753
2554
  // Inline function 'kotlin.collections.mapTo' call
@@ -1762,24 +2563,29 @@
1762
2563
  return copyToArray(destination);
1763
2564
  }
1764
2565
  function parseGpx(xml) {
2566
+ _init_properties_EngineJsApi_kt__9bputf();
1765
2567
  return firstTrackAsPath(GpxParser_instance.parse$default_ez0f31_k$(xml));
1766
2568
  }
1767
2569
  function parseGpxTracks(xml) {
2570
+ _init_properties_EngineJsApi_kt__9bputf();
1768
2571
  // Inline function 'kotlin.collections.toTypedArray' call
1769
2572
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
1770
2573
  return copyToArray(this_0);
1771
2574
  }
1772
2575
  function parseGpxSegments(xml) {
2576
+ _init_properties_EngineJsApi_kt__9bputf();
1773
2577
  // Inline function 'kotlin.collections.toTypedArray' call
1774
2578
  var this_0 = segmentsAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
1775
2579
  return copyToArray(this_0);
1776
2580
  }
1777
2581
  function parseGpxTracksOnly(xml) {
2582
+ _init_properties_EngineJsApi_kt__9bputf();
1778
2583
  // Inline function 'kotlin.collections.toTypedArray' call
1779
2584
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_TRACK_getInstance()));
1780
2585
  return copyToArray(this_0);
1781
2586
  }
1782
2587
  function parseGpxRoutesOnly(xml) {
2588
+ _init_properties_EngineJsApi_kt__9bputf();
1783
2589
  // Inline function 'kotlin.collections.toTypedArray' call
1784
2590
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_ROUTE_getInstance()));
1785
2591
  return copyToArray(this_0);
@@ -1794,6 +2600,7 @@
1794
2600
  }
1795
2601
  waypoints = tmp;
1796
2602
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2603
+ _init_properties_EngineJsApi_kt__9bputf();
1797
2604
  var tmp_0 = GpxWriter_instance;
1798
2605
  var tmp_1 = toList(paths);
1799
2606
  // Inline function 'kotlin.collections.map' call
@@ -1810,40 +2617,51 @@
1810
2617
  return tmp_0.write$default_koqy5u_k$(tmp_1, VOID, VOID, destination, VOID, writeExtensions);
1811
2618
  }
1812
2619
  function pathSize(path) {
2620
+ _init_properties_EngineJsApi_kt__9bputf();
1813
2621
  return path.size_1;
1814
2622
  }
1815
2623
  function pathTotalDistance(path) {
2624
+ _init_properties_EngineJsApi_kt__9bputf();
1816
2625
  return path.totalDistance_1;
1817
2626
  }
1818
2627
  function pathDurationMs(path) {
2628
+ _init_properties_EngineJsApi_kt__9bputf();
1819
2629
  return path.durationMs_1;
1820
2630
  }
1821
2631
  function pathElevationGain(path) {
2632
+ _init_properties_EngineJsApi_kt__9bputf();
1822
2633
  return path.elevationGain_1;
1823
2634
  }
1824
2635
  function pathElevationLoss(path) {
2636
+ _init_properties_EngineJsApi_kt__9bputf();
1825
2637
  return path.elevationLoss_1;
1826
2638
  }
1827
2639
  function pointAt(path, i) {
2640
+ _init_properties_EngineJsApi_kt__9bputf();
1828
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));
1829
2642
  }
1830
2643
  function writeGpx(path, writeExtensions) {
1831
2644
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2645
+ _init_properties_EngineJsApi_kt__9bputf();
1832
2646
  return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized'), writeExtensions);
1833
2647
  }
1834
2648
  function writeGpxAt(path, startTimeEpochMs, writeExtensions) {
1835
2649
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
2650
+ _init_properties_EngineJsApi_kt__9bputf();
1836
2651
  return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized', Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs))), writeExtensions);
1837
2652
  }
1838
2653
  function enhance(path, options) {
2654
+ _init_properties_EngineJsApi_kt__9bputf();
1839
2655
  var tmp = GlobalScope_instance;
1840
2656
  return promise(tmp, VOID, VOID, enhance$slambda_0(options, path, null));
1841
2657
  }
1842
2658
  function enhanceWithCourse(path, cyclist, bike, wind, power, options) {
2659
+ _init_properties_EngineJsApi_kt__9bputf();
1843
2660
  var tmp = GlobalScope_instance;
1844
2661
  return promise(tmp, VOID, VOID, enhanceWithCourse$slambda_0(options, path, cyclist, bike, wind, power, null));
1845
2662
  }
1846
2663
  function getField(path, i, fieldProp) {
2664
+ _init_properties_EngineJsApi_kt__9bputf();
1847
2665
  var tmp0_elvis_lhs = Companion_getInstance_0().byProp_kdf1eo_k$(fieldProp);
1848
2666
  var tmp;
1849
2667
  if (tmp0_elvis_lhs == null) {
@@ -1857,6 +2675,7 @@
1857
2675
  return path.get_z3le6l_k$(i, field);
1858
2676
  }
1859
2677
  function fieldDefinitions() {
2678
+ _init_properties_EngineJsApi_kt__9bputf();
1860
2679
  // Inline function 'kotlin.collections.map' call
1861
2680
  var this_0 = get_entries();
1862
2681
  // Inline function 'kotlin.collections.mapTo' call
@@ -1879,12 +2698,15 @@
1879
2698
  return copyToArray(destination);
1880
2699
  }
1881
2700
  function pathLatitudeDeg(path, i) {
2701
+ _init_properties_EngineJsApi_kt__9bputf();
1882
2702
  return path.latitudeDeg_i25sm6_k$(i);
1883
2703
  }
1884
2704
  function pathLongitudeDeg(path, i) {
2705
+ _init_properties_EngineJsApi_kt__9bputf();
1885
2706
  return path.longitudeDeg_ikk1un_k$(i);
1886
2707
  }
1887
2708
  function pathToCsv(path, separator, unitsInHeader) {
2709
+ _init_properties_EngineJsApi_kt__9bputf();
1888
2710
  var tmp = CsvWriter_instance;
1889
2711
  var tmp0_elvis_lhs = firstOrNull(separator);
1890
2712
  var tmp_0;
@@ -1897,13 +2719,16 @@
1897
2719
  return tmp.write_p5vnh4_k$(path, new CsvOptions(VOID, tmp_0, unitsInHeader));
1898
2720
  }
1899
2721
  function pathToJson(path, pretty) {
2722
+ _init_properties_EngineJsApi_kt__9bputf();
1900
2723
  return JsonWriter_instance.write_lwqeog_k$(path, new JsonOptions(VOID, pretty));
1901
2724
  }
1902
2725
  function pathToFit(path, name, startTimeEpochMs) {
2726
+ _init_properties_EngineJsApi_kt__9bputf();
1903
2727
  return toFitBytes(path, name, Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs)));
1904
2728
  }
1905
2729
  function pathsToFit(paths, name, startTimeEpochMs, interPathGapMs) {
1906
2730
  interPathGapMs = interPathGapMs === VOID ? 0.0 : interPathGapMs;
2731
+ _init_properties_EngineJsApi_kt__9bputf();
1907
2732
  var tmp = toList(paths);
1908
2733
  var tmp_0 = Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs));
1909
2734
  Companion_getInstance_1();
@@ -1913,12 +2738,15 @@
1913
2738
  return toFitBytes_0(tmp, name, tmp_0, VOID, tmp$ret$0);
1914
2739
  }
1915
2740
  function dominantHeadwindAzimuth(path) {
2741
+ _init_properties_EngineJsApi_kt__9bputf();
1916
2742
  return dominantHeadwindAzimuthDeg(path);
1917
2743
  }
1918
2744
  function dominantHeadwindAzimuthOfTracks(paths) {
2745
+ _init_properties_EngineJsApi_kt__9bputf();
1919
2746
  return dominantHeadwindAzimuthDeg_0(toList(paths));
1920
2747
  }
1921
2748
  function detectClimbs(path) {
2749
+ _init_properties_EngineJsApi_kt__9bputf();
1922
2750
  // Inline function 'kotlin.collections.map' call
1923
2751
  var this_0 = ClimbDetector_instance.detect$default_6ml3ny_k$(path);
1924
2752
  // Inline function 'kotlin.collections.mapTo' call
@@ -1933,6 +2761,7 @@
1933
2761
  return copyToArray(destination);
1934
2762
  }
1935
2763
  function detectClimbsWithOptions(path, minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGrade, booster) {
2764
+ _init_properties_EngineJsApi_kt__9bputf();
1936
2765
  // Inline function 'kotlin.collections.map' call
1937
2766
  var this_0 = ClimbDetector_instance.detect_llooq2_k$(path, new ClimbOptions(minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGrade, booster));
1938
2767
  // Inline function 'kotlin.collections.mapTo' call
@@ -1947,6 +2776,7 @@
1947
2776
  return copyToArray(destination);
1948
2777
  }
1949
2778
  function waypointObj(w) {
2779
+ _init_properties_EngineJsApi_kt__9bputf();
1950
2780
  var o = {};
1951
2781
  o.latitudeDeg = w.latitudeDeg_1;
1952
2782
  o.longitudeDeg = w.longitudeDeg_1;
@@ -1961,6 +2791,7 @@
1961
2791
  return o;
1962
2792
  }
1963
2793
  function pointObj(latitudeDeg, longitudeDeg, elevation, timeMs, speed, pComputedPower, distance, grade) {
2794
+ _init_properties_EngineJsApi_kt__9bputf();
1964
2795
  var o = {};
1965
2796
  o.latitudeDeg = latitudeDeg;
1966
2797
  o.longitudeDeg = longitudeDeg;
@@ -1974,6 +2805,7 @@
1974
2805
  return o;
1975
2806
  }
1976
2807
  function toGpxWaypoint(_this__u8e3s4) {
2808
+ _init_properties_EngineJsApi_kt__9bputf();
1977
2809
  var tmp = _this__u8e3s4.latitudeDeg;
1978
2810
  var tmp_0 = _this__u8e3s4.longitudeDeg;
1979
2811
  var tmp_1 = _this__u8e3s4.elevationM;
@@ -1985,8 +2817,10 @@
1985
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));
1986
2818
  }
1987
2819
  function toEnhanceOptions(_this__u8e3s4) {
2820
+ _init_properties_EngineJsApi_kt__9bputf();
1988
2821
  if (_this__u8e3s4 == null)
1989
2822
  return defaultJsOptions();
2823
+ requireOnlyKeys(_this__u8e3s4, 'EnhanceOptionsDto', get_ENHANCE_OPTIONS_KEYS());
1990
2824
  var tmp0_elvis_lhs = _this__u8e3s4.fixElevation;
1991
2825
  var tmp = tmp0_elvis_lhs == null ? false : tmp0_elvis_lhs;
1992
2826
  var tmp1_elvis_lhs = _this__u8e3s4.computeMaxSpeeds;
@@ -2000,57 +2834,152 @@
2000
2834
  var tmp5_elvis_lhs = _this__u8e3s4.simplifyToleranceM;
2001
2835
  var tmp_4 = tmp5_elvis_lhs == null ? 10.0 : tmp5_elvis_lhs;
2002
2836
  var tmp6_elvis_lhs = _this__u8e3s4.simplifyZExaggeration;
2003
- 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));
2004
2844
  }
2005
2845
  function defaultJsOptions() {
2846
+ _init_properties_EngineJsApi_kt__9bputf();
2006
2847
  return new EnhanceOptions(false, true, true, false, new SimplifyPathOptions(false));
2007
2848
  }
2008
2849
  function toCyclist(_this__u8e3s4) {
2850
+ _init_properties_EngineJsApi_kt__9bputf();
2009
2851
  if (_this__u8e3s4 == null)
2010
2852
  return new Cyclist();
2011
- 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;
2012
2903
  }
2013
2904
  function toBike(_this__u8e3s4) {
2905
+ _init_properties_EngineJsApi_kt__9bputf();
2014
2906
  if (_this__u8e3s4 == null)
2015
2907
  return new Bike();
2016
- return new Bike(_this__u8e3s4.crr, _this__u8e3s4.inertiaFront, _this__u8e3s4.inertiaRear, _this__u8e3s4.wheelRadiusM, _this__u8e3s4.efficiency);
2908
+ requireOnlyKeys(_this__u8e3s4, 'BikeDto', get_BIKE_KEYS());
2909
+ var tmp = _this__u8e3s4.crr;
2910
+ var tmp_0 = _this__u8e3s4.inertiaFront;
2911
+ var tmp_1 = _this__u8e3s4.inertiaRear;
2912
+ var tmp_2 = _this__u8e3s4.wheelRadiusM;
2913
+ var tmp_3 = _this__u8e3s4.efficiency;
2914
+ var tmp0_elvis_lhs = _this__u8e3s4.maxPedalingLeanAngleDeg;
2915
+ return new Bike(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp0_elvis_lhs == null ? 20.0 : tmp0_elvis_lhs);
2017
2916
  }
2018
2917
  function toWindProvider(_this__u8e3s4) {
2918
+ _init_properties_EngineJsApi_kt__9bputf();
2019
2919
  if (_this__u8e3s4 == null)
2020
2920
  return WindProviderNone_instance;
2921
+ requireOnlyKeys(_this__u8e3s4, 'WindDto', get_WIND_KEYS());
2021
2922
  return new WindProviderConstant(new Wind(_this__u8e3s4.windSpeed, _this__u8e3s4.windDirection * 3.141592653589793 / 180.0));
2022
2923
  }
2023
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();
2024
2930
  if (_this__u8e3s4 == null)
2025
- 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);
2026
2935
  var tmp;
2027
- switch (_this__u8e3s4.type) {
2028
- case 'constant':
2029
- var tmp1_elvis_lhs = _this__u8e3s4.power;
2030
- var tmp_0 = tmp1_elvis_lhs == null ? 250.0 : tmp1_elvis_lhs;
2031
- var tmp2_elvis_lhs = _this__u8e3s4.useHarmonics;
2032
- tmp = new PowerProviderConstant(tmp_0, tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs);
2033
- break;
2034
- case 'constant_tiring':
2035
- var tmp3_elvis_lhs = _this__u8e3s4.power;
2036
- var tmp_1 = tmp3_elvis_lhs == null ? 250.0 : tmp3_elvis_lhs;
2037
- var tmp4_elvis_lhs = _this__u8e3s4.useHarmonics;
2038
- var tmp_2 = tmp4_elvis_lhs == null ? false : tmp4_elvis_lhs;
2039
- var tmp5_elvis_lhs = _this__u8e3s4.tiringDuration;
2040
- tmp = new PowerProviderConstantWithTiring(tmp_1, tmp_2, tmp5_elvis_lhs == null ? 7200.0 : tmp5_elvis_lhs);
2041
- break;
2042
- case 'from_data':
2043
- tmp = PowerProviderFromData_instance;
2044
- break;
2045
- default:
2046
- // Inline function 'kotlin.error' call
2047
-
2048
- var message = 'Unknown PowerProviderDto.type: ' + _this__u8e3s4.type;
2049
- 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));
2050
2979
  }
2051
- return tmp;
2052
2980
  }
2053
2981
  function toDto(_this__u8e3s4) {
2982
+ _init_properties_EngineJsApi_kt__9bputf();
2054
2983
  var o = {};
2055
2984
  o.startDistanceM = _this__u8e3s4.startDistanceM_1;
2056
2985
  o.endDistanceM = _this__u8e3s4.endDistanceM_1;
@@ -2063,6 +2992,7 @@
2063
2992
  return o;
2064
2993
  }
2065
2994
  function toDto_0(_this__u8e3s4) {
2995
+ _init_properties_EngineJsApi_kt__9bputf();
2066
2996
  var o = {};
2067
2997
  o.startIndex = _this__u8e3s4.startIndex_1;
2068
2998
  o.endIndex = _this__u8e3s4.endIndex_1;
@@ -2212,24 +3142,40 @@
2212
3142
  return i.invoke_jiwoso_k$($this$promise, $completion);
2213
3143
  }, 1);
2214
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
+ }
2215
3156
  //region block: init
2216
3157
  Enhancer_instance = new Enhancer();
2217
- Companion_instance_4 = new Companion_4();
3158
+ Companion_instance_5 = new Companion_4();
2218
3159
  ClimbDetector_instance = new ClimbDetector();
2219
3160
  AeroPowerProvider_instance = new AeroPowerProvider();
2220
3161
  AeroProviderConstant_instance = new AeroProviderConstant();
2221
- Companion_instance_5 = new Companion_5();
3162
+ Companion_instance_6 = new Companion_5();
3163
+ Companion_instance_7 = new Companion_6();
2222
3164
  GravPowerProvider_instance = new GravPowerProvider();
2223
3165
  MaxSpeedComputer_instance = new MaxSpeedComputer();
2224
3166
  MuscularPowerProvider_instance = new MuscularPowerProvider();
2225
3167
  PowerComputer_instance = new PowerComputer();
3168
+ Companion_instance_8 = new Companion_7();
3169
+ Companion_instance_9 = new Companion_8();
2226
3170
  PowerProviderFromData_instance = new PowerProviderFromData();
3171
+ Companion_instance_10 = new Companion_9();
2227
3172
  RhoProviderDefault_instance = new RhoProviderDefault();
2228
3173
  RhoProviderEstimate_instance = new RhoProviderEstimate();
2229
3174
  RollingResistancePowerProvider_instance = new RollingResistancePowerProvider();
2230
3175
  VirtualizeService_instance = new VirtualizeService();
2231
3176
  WheelBearingsPowerProvider_instance = new WheelBearingsPowerProvider();
2232
3177
  WindProviderNone_instance = new WindProviderNone();
3178
+ WPrimeBalanceComputer_instance = new WPrimeBalanceComputer();
2233
3179
  //endregion
2234
3180
  //region block: exports
2235
3181
  function $jsExportAll$(_) {