@glandais/vcyclist-engine 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3401 @@
1
+ (function (factory) {
2
+ if (typeof define === 'function' && define.amd)
3
+ define(['exports', './kotlin-kotlin-stdlib.js', './vcyclist-elevation.js', './xmlutil-core.js'], factory);
4
+ else if (typeof exports === 'object')
5
+ factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./vcyclist-elevation.js'), require('./xmlutil-core.js'));
6
+ else {
7
+ if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
8
+ throw new Error("Error loading module 'vcyclist-gpx'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'vcyclist-gpx'.");
9
+ }
10
+ if (typeof globalThis['vcyclist-elevation'] === 'undefined') {
11
+ throw new Error("Error loading module 'vcyclist-gpx'. Its dependency 'vcyclist-elevation' was not found. Please, check whether 'vcyclist-elevation' is loaded prior to 'vcyclist-gpx'.");
12
+ }
13
+ if (typeof globalThis['xmlutil-core'] === 'undefined') {
14
+ throw new Error("Error loading module 'vcyclist-gpx'. Its dependency 'xmlutil-core' was not found. Please, check whether 'xmlutil-core' is loaded prior to 'vcyclist-gpx'.");
15
+ }
16
+ globalThis['vcyclist-gpx'] = factory(typeof globalThis['vcyclist-gpx'] === 'undefined' ? {} : globalThis['vcyclist-gpx'], globalThis['kotlin-kotlin-stdlib'], globalThis['vcyclist-elevation'], globalThis['xmlutil-core']);
17
+ }
18
+ }(function (_, kotlin_kotlin, kotlin_io_github_glandais_elevation, kotlin_io_github_pdvrieze_xmlutil_core) {
19
+ 'use strict';
20
+ //region block: imports
21
+ var imul = Math.imul;
22
+ var VOID = kotlin_kotlin.$_$.a;
23
+ var toString = kotlin_kotlin.$_$.s8;
24
+ var protoOf = kotlin_kotlin.$_$.y5;
25
+ var getNumberHashCode = kotlin_kotlin.$_$.f5;
26
+ var getStringHashCode = kotlin_kotlin.$_$.h5;
27
+ var equals = kotlin_kotlin.$_$.d5;
28
+ var initMetadataForClass = kotlin_kotlin.$_$.j5;
29
+ var emptyList = kotlin_kotlin.$_$.p2;
30
+ var toString_0 = kotlin_kotlin.$_$.a6;
31
+ var hashCode = kotlin_kotlin.$_$.i5;
32
+ var listOf = kotlin_kotlin.$_$.z2;
33
+ var initMetadataForCompanion = kotlin_kotlin.$_$.k5;
34
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.x;
35
+ var addAll = kotlin_kotlin.$_$.e2;
36
+ var Unit_instance = kotlin_kotlin.$_$.t;
37
+ var constructCallableReference = kotlin_kotlin.$_$.b5;
38
+ var lazy = kotlin_kotlin.$_$.o8;
39
+ var KProperty1 = kotlin_kotlin.$_$.p6;
40
+ var getPropertyCallableRef = kotlin_kotlin.$_$.g5;
41
+ var collectionSizeOrDefault = kotlin_kotlin.$_$.j2;
42
+ var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.w;
43
+ var checkIndexOverflow = kotlin_kotlin.$_$.i2;
44
+ var getOrNull = kotlin_kotlin.$_$.t2;
45
+ var MathConstants_getInstance = kotlin_io_github_glandais_elevation.$_$.d;
46
+ var isNaN_0 = kotlin_kotlin.$_$.n8;
47
+ var numberToLong = kotlin_kotlin.$_$.q4;
48
+ var Long = kotlin_kotlin.$_$.b8;
49
+ var compare = kotlin_kotlin.$_$.j4;
50
+ var roundToLong = kotlin_kotlin.$_$.c6;
51
+ var add = kotlin_kotlin.$_$.i4;
52
+ var roundToInt = kotlin_kotlin.$_$.b6;
53
+ var get_xmlStreaming = kotlin_io_github_pdvrieze_xmlutil_core.$_$.d;
54
+ var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.n1;
55
+ var Exception = kotlin_kotlin.$_$.z7;
56
+ var IllegalArgumentException = kotlin_kotlin.$_$.a8;
57
+ var IllegalArgumentException_init_$Create$_0 = kotlin_kotlin.$_$.m1;
58
+ var EventType_START_ELEMENT_getInstance = kotlin_io_github_pdvrieze_xmlutil_core.$_$.a;
59
+ var THROW_CCE = kotlin_kotlin.$_$.g8;
60
+ var isCharSequence = kotlin_kotlin.$_$.q5;
61
+ var trim = kotlin_kotlin.$_$.t7;
62
+ var charSequenceLength = kotlin_kotlin.$_$.z4;
63
+ var isBlank = kotlin_kotlin.$_$.c7;
64
+ var toDoubleOrNull = kotlin_kotlin.$_$.o7;
65
+ var numberToInt = kotlin_kotlin.$_$.w5;
66
+ var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.g1;
67
+ var Companion_getInstance = kotlin_kotlin.$_$.r;
68
+ var initMetadataForObject = kotlin_kotlin.$_$.p5;
69
+ var firstOrNull = kotlin_kotlin.$_$.r2;
70
+ var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.o1;
71
+ var toNumber = kotlin_kotlin.$_$.s4;
72
+ var XmlDeclMode_None_getInstance = kotlin_io_github_pdvrieze_xmlutil_core.$_$.b;
73
+ var newGenericWriter = kotlin_io_github_pdvrieze_xmlutil_core.$_$.c;
74
+ var charCodeAt = kotlin_kotlin.$_$.x4;
75
+ var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b;
76
+ var substring = kotlin_kotlin.$_$.l7;
77
+ var isHighSurrogate = kotlin_kotlin.$_$.e7;
78
+ var isLowSurrogate = kotlin_kotlin.$_$.f7;
79
+ var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.f;
80
+ var StringBuilder_init_$Create$_0 = kotlin_kotlin.$_$.f1;
81
+ var Pair = kotlin_kotlin.$_$.d8;
82
+ var substring_0 = kotlin_kotlin.$_$.m7;
83
+ var toLong = kotlin_kotlin.$_$.r7;
84
+ var numberRangeToNumber = kotlin_kotlin.$_$.u5;
85
+ var ClosedRange = kotlin_kotlin.$_$.e6;
86
+ var isInterface = kotlin_kotlin.$_$.r5;
87
+ var contains = kotlin_kotlin.$_$.j6;
88
+ var convertToInt = kotlin_kotlin.$_$.k4;
89
+ var NumberFormatException = kotlin_kotlin.$_$.c8;
90
+ var isDigit = kotlin_kotlin.$_$.d7;
91
+ var isWhitespace = kotlin_kotlin.$_$.g7;
92
+ var setOf = kotlin_kotlin.$_$.f3;
93
+ var toDouble = kotlin_kotlin.$_$.p7;
94
+ var round = kotlin_kotlin.$_$.d6;
95
+ var divide = kotlin_kotlin.$_$.l4;
96
+ var equalsLong = kotlin_kotlin.$_$.m4;
97
+ var modulo = kotlin_kotlin.$_$.o4;
98
+ var padStart = kotlin_kotlin.$_$.h7;
99
+ var longArray = kotlin_kotlin.$_$.t5;
100
+ var multiply = kotlin_kotlin.$_$.p4;
101
+ var isInfinite = kotlin_kotlin.$_$.m8;
102
+ var charSequenceGet = kotlin_kotlin.$_$.y4;
103
+ var replace = kotlin_kotlin.$_$.i7;
104
+ var toString_1 = kotlin_kotlin.$_$.g;
105
+ var Char__hashCode_impl_otmys = kotlin_kotlin.$_$.d;
106
+ var getBooleanHashCode = kotlin_kotlin.$_$.e5;
107
+ var get_lastIndex = kotlin_kotlin.$_$.w2;
108
+ var toString_2 = kotlin_kotlin.$_$.s7;
109
+ var CoroutineImpl = kotlin_kotlin.$_$.d4;
110
+ var LatLon = kotlin_io_github_glandais_elevation.$_$.g;
111
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.o3;
112
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.l5;
113
+ var ElevationSmoother_instance = kotlin_io_github_glandais_elevation.$_$.c;
114
+ var until = kotlin_kotlin.$_$.l6;
115
+ var LatLonElevation = kotlin_io_github_glandais_elevation.$_$.f;
116
+ var arrayCopy = kotlin_kotlin.$_$.f2;
117
+ var Distance_instance = kotlin_io_github_glandais_elevation.$_$.a;
118
+ var DouglasPeucker_instance = kotlin_io_github_glandais_elevation.$_$.b;
119
+ var mapCapacity = kotlin_kotlin.$_$.b3;
120
+ var coerceAtLeast = kotlin_kotlin.$_$.f6;
121
+ var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.a1;
122
+ var enumEntries = kotlin_kotlin.$_$.f4;
123
+ var Enum = kotlin_kotlin.$_$.x7;
124
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.p8;
125
+ var LinkedHashMap_init_$Create$_0 = kotlin_kotlin.$_$.b1;
126
+ var subtract = kotlin_kotlin.$_$.r4;
127
+ var get_ONE = kotlin_kotlin.$_$.h4;
128
+ var sorted = kotlin_kotlin.$_$.h3;
129
+ //endregion
130
+ //region block: pre-declaration
131
+ initMetadataForClass(GpxWaypoint, 'GpxWaypoint');
132
+ initMetadataForClass(GpxDocument, 'GpxDocument');
133
+ initMetadataForCompanion(Companion);
134
+ initMetadataForClass(GpxTrack, 'GpxTrack');
135
+ initMetadataForClass(GpxSegment, 'GpxSegment');
136
+ initMetadataForClass(GpxTrackPoint, 'GpxTrackPoint');
137
+ initMetadataForClass(ExtensionsAccumulator, 'ExtensionsAccumulator', ExtensionsAccumulator);
138
+ initMetadataForObject(GpxParser, 'GpxParser');
139
+ initMetadataForObject(GpxWriter, 'GpxWriter');
140
+ initMetadataForClass(NumericRef, 'NumericRef');
141
+ initMetadataForObject(GpxXmlRepair, 'GpxXmlRepair');
142
+ initMetadataForClass(RepairResult, 'RepairResult');
143
+ initMetadataForObject(CsvNumberFormat, 'CsvNumberFormat');
144
+ initMetadataForObject(CsvWriter, 'CsvWriter');
145
+ initMetadataForClass(CsvOptions, 'CsvOptions', CsvOptions);
146
+ initMetadataForObject(JsonWriter, 'JsonWriter');
147
+ initMetadataForClass(JsonOptions, 'JsonOptions', JsonOptions);
148
+ initMetadataForCoroutine($fixElevationCOROUTINE$, CoroutineImpl);
149
+ initMetadataForObject(ElevationStep, 'ElevationStep', VOID, VOID, VOID, [2]);
150
+ initMetadataForClass(GeneratedPath, 'GeneratedPath');
151
+ initMetadataForCompanion(Companion_0);
152
+ initMetadataForClass(BoundsRad, 'BoundsRad');
153
+ initMetadataForCompanion(Companion_1);
154
+ initMetadataForClass(Path, 'Path', VOID, GeneratedPath);
155
+ initMetadataForObject(PathSimplifier, 'PathSimplifier');
156
+ initMetadataForCompanion(Companion_2);
157
+ initMetadataForClass(PointField, 'PointField', VOID, Enum);
158
+ initMetadataForClass(PointFieldCategory, 'PointFieldCategory', VOID, Enum);
159
+ initMetadataForClass(Copy, 'Copy');
160
+ initMetadataForClass(Interpolate, 'Interpolate');
161
+ initMetadataForObject(PointPerDistance, 'PointPerDistance');
162
+ initMetadataForClass(Copy_0, 'Copy');
163
+ initMetadataForClass(Interpolate_0, 'Interpolate');
164
+ initMetadataForObject(PointPerSecond, 'PointPerSecond');
165
+ //endregion
166
+ function GpxWaypoint(latitudeDeg, longitudeDeg, elevationM, name, description, symbol, type, timeEpochMs) {
167
+ elevationM = elevationM === VOID ? null : elevationM;
168
+ name = name === VOID ? null : name;
169
+ description = description === VOID ? null : description;
170
+ symbol = symbol === VOID ? null : symbol;
171
+ type = type === VOID ? null : type;
172
+ timeEpochMs = timeEpochMs === VOID ? null : timeEpochMs;
173
+ this.u1p_1 = latitudeDeg;
174
+ this.v1p_1 = longitudeDeg;
175
+ this.w1p_1 = elevationM;
176
+ this.x1p_1 = name;
177
+ this.y1p_1 = description;
178
+ this.z1p_1 = symbol;
179
+ this.a1q_1 = type;
180
+ this.b1q_1 = timeEpochMs;
181
+ }
182
+ protoOf(GpxWaypoint).toString = function () {
183
+ return 'GpxWaypoint(latitudeDeg=' + this.u1p_1 + ', longitudeDeg=' + this.v1p_1 + ', elevationM=' + this.w1p_1 + ', name=' + this.x1p_1 + ', description=' + this.y1p_1 + ', symbol=' + this.z1p_1 + ', type=' + this.a1q_1 + ', timeEpochMs=' + toString(this.b1q_1) + ')';
184
+ };
185
+ protoOf(GpxWaypoint).hashCode = function () {
186
+ var result = getNumberHashCode(this.u1p_1);
187
+ result = imul(result, 31) + getNumberHashCode(this.v1p_1) | 0;
188
+ result = imul(result, 31) + (this.w1p_1 == null ? 0 : getNumberHashCode(this.w1p_1)) | 0;
189
+ result = imul(result, 31) + (this.x1p_1 == null ? 0 : getStringHashCode(this.x1p_1)) | 0;
190
+ result = imul(result, 31) + (this.y1p_1 == null ? 0 : getStringHashCode(this.y1p_1)) | 0;
191
+ result = imul(result, 31) + (this.z1p_1 == null ? 0 : getStringHashCode(this.z1p_1)) | 0;
192
+ result = imul(result, 31) + (this.a1q_1 == null ? 0 : getStringHashCode(this.a1q_1)) | 0;
193
+ result = imul(result, 31) + (this.b1q_1 == null ? 0 : this.b1q_1.hashCode()) | 0;
194
+ return result;
195
+ };
196
+ protoOf(GpxWaypoint).equals = function (other) {
197
+ if (this === other)
198
+ return true;
199
+ if (!(other instanceof GpxWaypoint))
200
+ return false;
201
+ if (!equals(this.u1p_1, other.u1p_1))
202
+ return false;
203
+ if (!equals(this.v1p_1, other.v1p_1))
204
+ return false;
205
+ if (!equals(this.w1p_1, other.w1p_1))
206
+ return false;
207
+ if (!(this.x1p_1 == other.x1p_1))
208
+ return false;
209
+ if (!(this.y1p_1 == other.y1p_1))
210
+ return false;
211
+ if (!(this.z1p_1 == other.z1p_1))
212
+ return false;
213
+ if (!(this.a1q_1 == other.a1q_1))
214
+ return false;
215
+ if (!equals(this.b1q_1, other.b1q_1))
216
+ return false;
217
+ return true;
218
+ };
219
+ function GpxDocument(name, tracks, waypoints) {
220
+ name = name === VOID ? 'noname' : name;
221
+ waypoints = waypoints === VOID ? emptyList() : waypoints;
222
+ this.c1q_1 = name;
223
+ this.d1q_1 = tracks;
224
+ this.e1q_1 = waypoints;
225
+ }
226
+ protoOf(GpxDocument).toString = function () {
227
+ return 'GpxDocument(name=' + this.c1q_1 + ', tracks=' + toString_0(this.d1q_1) + ', waypoints=' + toString_0(this.e1q_1) + ')';
228
+ };
229
+ protoOf(GpxDocument).hashCode = function () {
230
+ var result = getStringHashCode(this.c1q_1);
231
+ result = imul(result, 31) + hashCode(this.d1q_1) | 0;
232
+ result = imul(result, 31) + hashCode(this.e1q_1) | 0;
233
+ return result;
234
+ };
235
+ protoOf(GpxDocument).equals = function (other) {
236
+ if (this === other)
237
+ return true;
238
+ if (!(other instanceof GpxDocument))
239
+ return false;
240
+ if (!(this.c1q_1 === other.c1q_1))
241
+ return false;
242
+ if (!equals(this.d1q_1, other.d1q_1))
243
+ return false;
244
+ if (!equals(this.e1q_1, other.e1q_1))
245
+ return false;
246
+ return true;
247
+ };
248
+ function Companion() {
249
+ }
250
+ protoOf(Companion).f1q = function (name, type, points) {
251
+ return new GpxTrack(name, type, listOf(new GpxSegment(points)));
252
+ };
253
+ var Companion_instance;
254
+ function Companion_getInstance_0() {
255
+ return Companion_instance;
256
+ }
257
+ function GpxTrack$points$delegate$lambda(this$0) {
258
+ return function () {
259
+ // Inline function 'kotlin.collections.flatMap' call
260
+ var tmp0 = this$0.i1q_1;
261
+ // Inline function 'kotlin.collections.flatMapTo' call
262
+ var destination = ArrayList_init_$Create$();
263
+ var _iterator__ex2g4s = tmp0.i();
264
+ while (_iterator__ex2g4s.j()) {
265
+ var element = _iterator__ex2g4s.k();
266
+ var list = element.k1q_1;
267
+ addAll(destination, list);
268
+ }
269
+ return destination;
270
+ };
271
+ }
272
+ function GpxTrack$_get_points_$ref_4x48pr() {
273
+ return constructCallableReference(function (p0) {
274
+ return p0.l1q();
275
+ }, 1, 0, 5);
276
+ }
277
+ function GpxTrack(name, type, segments) {
278
+ name = name === VOID ? null : name;
279
+ type = type === VOID ? null : type;
280
+ this.g1q_1 = name;
281
+ this.h1q_1 = type;
282
+ this.i1q_1 = segments;
283
+ var tmp = this;
284
+ tmp.j1q_1 = lazy(GpxTrack$points$delegate$lambda(this));
285
+ }
286
+ protoOf(GpxTrack).l1q = function () {
287
+ var tmp0 = this.j1q_1;
288
+ var tmp = KProperty1;
289
+ // Inline function 'kotlin.getValue' call
290
+ getPropertyCallableRef('points', 1, tmp, GpxTrack$_get_points_$ref_4x48pr(), null);
291
+ return tmp0.i1();
292
+ };
293
+ protoOf(GpxTrack).toString = function () {
294
+ return 'GpxTrack(name=' + this.g1q_1 + ', type=' + this.h1q_1 + ', segments=' + toString_0(this.i1q_1) + ')';
295
+ };
296
+ protoOf(GpxTrack).hashCode = function () {
297
+ var result = this.g1q_1 == null ? 0 : getStringHashCode(this.g1q_1);
298
+ result = imul(result, 31) + (this.h1q_1 == null ? 0 : getStringHashCode(this.h1q_1)) | 0;
299
+ result = imul(result, 31) + hashCode(this.i1q_1) | 0;
300
+ return result;
301
+ };
302
+ protoOf(GpxTrack).equals = function (other) {
303
+ if (this === other)
304
+ return true;
305
+ if (!(other instanceof GpxTrack))
306
+ return false;
307
+ if (!(this.g1q_1 == other.g1q_1))
308
+ return false;
309
+ if (!(this.h1q_1 == other.h1q_1))
310
+ return false;
311
+ if (!equals(this.i1q_1, other.i1q_1))
312
+ return false;
313
+ return true;
314
+ };
315
+ function GpxSegment(points) {
316
+ this.k1q_1 = points;
317
+ }
318
+ protoOf(GpxSegment).toString = function () {
319
+ return 'GpxSegment(points=' + toString_0(this.k1q_1) + ')';
320
+ };
321
+ protoOf(GpxSegment).hashCode = function () {
322
+ return hashCode(this.k1q_1);
323
+ };
324
+ protoOf(GpxSegment).equals = function (other) {
325
+ if (this === other)
326
+ return true;
327
+ if (!(other instanceof GpxSegment))
328
+ return false;
329
+ if (!equals(this.k1q_1, other.k1q_1))
330
+ return false;
331
+ return true;
332
+ };
333
+ function GpxTrackPoint(latitudeDeg, longitudeDeg, elevationM, timeEpochMs, heartRate, cadence, temperatureC, powerW) {
334
+ elevationM = elevationM === VOID ? null : elevationM;
335
+ timeEpochMs = timeEpochMs === VOID ? null : timeEpochMs;
336
+ heartRate = heartRate === VOID ? null : heartRate;
337
+ cadence = cadence === VOID ? null : cadence;
338
+ temperatureC = temperatureC === VOID ? null : temperatureC;
339
+ powerW = powerW === VOID ? null : powerW;
340
+ this.m1q_1 = latitudeDeg;
341
+ this.n1q_1 = longitudeDeg;
342
+ this.o1q_1 = elevationM;
343
+ this.p1q_1 = timeEpochMs;
344
+ this.q1q_1 = heartRate;
345
+ this.r1q_1 = cadence;
346
+ this.s1q_1 = temperatureC;
347
+ this.t1q_1 = powerW;
348
+ }
349
+ protoOf(GpxTrackPoint).toString = function () {
350
+ return 'GpxTrackPoint(latitudeDeg=' + this.m1q_1 + ', longitudeDeg=' + this.n1q_1 + ', elevationM=' + this.o1q_1 + ', timeEpochMs=' + toString(this.p1q_1) + ', heartRate=' + this.q1q_1 + ', cadence=' + this.r1q_1 + ', temperatureC=' + this.s1q_1 + ', powerW=' + this.t1q_1 + ')';
351
+ };
352
+ protoOf(GpxTrackPoint).hashCode = function () {
353
+ var result = getNumberHashCode(this.m1q_1);
354
+ result = imul(result, 31) + getNumberHashCode(this.n1q_1) | 0;
355
+ result = imul(result, 31) + (this.o1q_1 == null ? 0 : getNumberHashCode(this.o1q_1)) | 0;
356
+ result = imul(result, 31) + (this.p1q_1 == null ? 0 : this.p1q_1.hashCode()) | 0;
357
+ result = imul(result, 31) + (this.q1q_1 == null ? 0 : this.q1q_1) | 0;
358
+ result = imul(result, 31) + (this.r1q_1 == null ? 0 : this.r1q_1) | 0;
359
+ result = imul(result, 31) + (this.s1q_1 == null ? 0 : getNumberHashCode(this.s1q_1)) | 0;
360
+ result = imul(result, 31) + (this.t1q_1 == null ? 0 : getNumberHashCode(this.t1q_1)) | 0;
361
+ return result;
362
+ };
363
+ protoOf(GpxTrackPoint).equals = function (other) {
364
+ if (this === other)
365
+ return true;
366
+ if (!(other instanceof GpxTrackPoint))
367
+ return false;
368
+ if (!equals(this.m1q_1, other.m1q_1))
369
+ return false;
370
+ if (!equals(this.n1q_1, other.n1q_1))
371
+ return false;
372
+ if (!equals(this.o1q_1, other.o1q_1))
373
+ return false;
374
+ if (!equals(this.p1q_1, other.p1q_1))
375
+ return false;
376
+ if (!(this.q1q_1 == other.q1q_1))
377
+ return false;
378
+ if (!(this.r1q_1 == other.r1q_1))
379
+ return false;
380
+ if (!equals(this.s1q_1, other.s1q_1))
381
+ return false;
382
+ if (!equals(this.t1q_1, other.t1q_1))
383
+ return false;
384
+ return true;
385
+ };
386
+ function toGpxDocument(_this__u8e3s4, name, trackName, startTime) {
387
+ name = name === VOID ? 'noname' : name;
388
+ trackName = trackName === VOID ? null : trackName;
389
+ startTime = startTime === VOID ? null : startTime;
390
+ return new GpxDocument(name, listOf(toGpxTrack(_this__u8e3s4, trackName, VOID, startTime)));
391
+ }
392
+ function pathsToGpxDocument(paths, name, trackNames, waypoints, type, startTime) {
393
+ name = name === VOID ? 'noname' : name;
394
+ trackNames = trackNames === VOID ? null : trackNames;
395
+ waypoints = waypoints === VOID ? emptyList() : waypoints;
396
+ type = type === VOID ? 'cycling' : type;
397
+ startTime = startTime === VOID ? null : startTime;
398
+ // Inline function 'kotlin.collections.mapIndexed' call
399
+ // Inline function 'kotlin.collections.mapIndexedTo' call
400
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(paths, 10));
401
+ var index = 0;
402
+ var _iterator__ex2g4s = paths.i();
403
+ while (_iterator__ex2g4s.j()) {
404
+ var item = _iterator__ex2g4s.k();
405
+ var _unary__edvuaz = index;
406
+ index = _unary__edvuaz + 1 | 0;
407
+ var i = checkIndexOverflow(_unary__edvuaz);
408
+ var tmp$ret$2 = toGpxTrack(item, trackNames == null ? null : getOrNull(trackNames, i), type, startTime);
409
+ destination.h(tmp$ret$2);
410
+ }
411
+ return new GpxDocument(name, destination, waypoints);
412
+ }
413
+ function toGpxTrack(_this__u8e3s4, name, type, startTime) {
414
+ name = name === VOID ? null : name;
415
+ type = type === VOID ? 'cycling' : type;
416
+ startTime = startTime === VOID ? null : startTime;
417
+ var startTimeMs = startTime == null ? null : startTime.ud();
418
+ // Inline function 'kotlin.collections.List' call
419
+ // Inline function 'kotlin.collections.MutableList' call
420
+ var size = _this__u8e3s4.u1q_1;
421
+ var list = ArrayList_init_$Create$_0(size);
422
+ // Inline function 'kotlin.repeat' call
423
+ var inductionVariable = 0;
424
+ if (inductionVariable < size)
425
+ do {
426
+ var index = inductionVariable;
427
+ inductionVariable = inductionVariable + 1 | 0;
428
+ var tmp = _this__u8e3s4.w1q(index) * MathConstants_getInstance().uw_1;
429
+ var tmp_0 = _this__u8e3s4.x1q(index) * MathConstants_getInstance().uw_1;
430
+ // Inline function 'kotlin.takeUnless' call
431
+ var this_0 = _this__u8e3s4.y1q(index);
432
+ var tmp_1;
433
+ if (!isNaN_0(this_0)) {
434
+ tmp_1 = this_0;
435
+ } else {
436
+ tmp_1 = null;
437
+ }
438
+ var tmp_2 = tmp_1;
439
+ var tmp_3;
440
+ if (isNaN_0(_this__u8e3s4.z1q(index))) {
441
+ tmp_3 = null;
442
+ } else if (!(startTimeMs == null)) {
443
+ tmp_3 = add(startTimeMs, roundToLong(_this__u8e3s4.z1q(index)));
444
+ } else {
445
+ // Inline function 'kotlin.takeIf' call
446
+ var this_1 = numberToLong(_this__u8e3s4.z1q(index));
447
+ var tmp_4;
448
+ if (compare(this_1, new Long(0, 0)) > 0) {
449
+ tmp_4 = this_1;
450
+ } else {
451
+ tmp_4 = null;
452
+ }
453
+ tmp_3 = tmp_4;
454
+ }
455
+ var tmp_5 = tmp_3;
456
+ // Inline function 'kotlin.takeUnless' call
457
+ var this_2 = _this__u8e3s4.a1r(index);
458
+ var tmp_6;
459
+ if (!isNaN_0(this_2)) {
460
+ tmp_6 = this_2;
461
+ } else {
462
+ tmp_6 = null;
463
+ }
464
+ var tmp0_safe_receiver = tmp_6;
465
+ var tmp_7 = tmp0_safe_receiver == null ? null : roundToInt(tmp0_safe_receiver);
466
+ // Inline function 'kotlin.takeUnless' call
467
+ var this_3 = _this__u8e3s4.b1r(index);
468
+ var tmp_8;
469
+ if (!isNaN_0(this_3)) {
470
+ tmp_8 = this_3;
471
+ } else {
472
+ tmp_8 = null;
473
+ }
474
+ var tmp1_safe_receiver = tmp_8;
475
+ var tmp_9 = tmp1_safe_receiver == null ? null : roundToInt(tmp1_safe_receiver);
476
+ // Inline function 'kotlin.takeUnless' call
477
+ var this_4 = _this__u8e3s4.c1r(index);
478
+ var tmp_10;
479
+ if (!isNaN_0(this_4)) {
480
+ tmp_10 = this_4;
481
+ } else {
482
+ tmp_10 = null;
483
+ }
484
+ var tmp_11 = tmp_10;
485
+ // Inline function 'kotlin.takeUnless' call
486
+ var this_5 = _this__u8e3s4.d1r(index);
487
+ var tmp_12;
488
+ if (!isNaN_0(this_5)) {
489
+ tmp_12 = this_5;
490
+ } else {
491
+ tmp_12 = null;
492
+ }
493
+ var tmp$ret$15 = tmp_12;
494
+ var tmp$ret$4 = new GpxTrackPoint(tmp, tmp_0, tmp_2, tmp_5, tmp_7, tmp_9, tmp_11, tmp$ret$15);
495
+ list.h(tmp$ret$4);
496
+ }
497
+ while (inductionVariable < size);
498
+ var points = list;
499
+ return Companion_instance.f1q(name, type, points);
500
+ }
501
+ function parseOnce($this, xml) {
502
+ var tmp;
503
+ try {
504
+ tmp = get_xmlStreaming().w18(xml);
505
+ } catch ($p) {
506
+ var tmp_0;
507
+ if ($p instanceof IllegalArgumentException) {
508
+ var e = $p;
509
+ throw e;
510
+ } else {
511
+ if ($p instanceof Exception) {
512
+ var e_0 = $p;
513
+ throw IllegalArgumentException_init_$Create$('Invalid GPX XML: ' + e_0.message, e_0);
514
+ } else {
515
+ throw $p;
516
+ }
517
+ }
518
+ }
519
+ var reader = tmp;
520
+ var tmp_1;
521
+ try {
522
+ tmp_1 = parseDocument($this, reader);
523
+ } catch ($p_0) {
524
+ var tmp_2;
525
+ if ($p_0 instanceof IllegalArgumentException) {
526
+ var e_1 = $p_0;
527
+ throw e_1;
528
+ } else {
529
+ if ($p_0 instanceof Exception) {
530
+ var e_2 = $p_0;
531
+ throw IllegalArgumentException_init_$Create$('Invalid GPX XML: ' + e_2.message, e_2);
532
+ } else {
533
+ throw $p_0;
534
+ }
535
+ }
536
+ }
537
+ finally {
538
+ reader.e18();
539
+ }
540
+ return tmp_1;
541
+ }
542
+ function parseDocument($this, reader) {
543
+ while (reader.j()) {
544
+ var ev = reader.k();
545
+ if (ev.equals(EventType_START_ELEMENT_getInstance())) {
546
+ if (!(reader.r17() === 'gpx')) {
547
+ throw IllegalArgumentException_init_$Create$_0('Invalid GPX file: missing gpx root element (found ' + reader.r17() + ')');
548
+ }
549
+ return parseGpxRoot($this, reader);
550
+ }
551
+ }
552
+ throw IllegalArgumentException_init_$Create$_0('Invalid GPX file: missing gpx root element');
553
+ }
554
+ function parseGpxRoot($this, reader) {
555
+ var name = 'noname';
556
+ // Inline function 'kotlin.collections.mutableListOf' call
557
+ var tracks = ArrayList_init_$Create$();
558
+ // Inline function 'kotlin.collections.mutableListOf' call
559
+ var waypoints = ArrayList_init_$Create$();
560
+ while (reader.j()) {
561
+ var ev = reader.k();
562
+ switch (ev.o1_1) {
563
+ case 1:
564
+ switch (reader.r17()) {
565
+ case 'metadata':
566
+ var metaName = parseMetadataName($this, reader);
567
+ if (!(metaName == null))
568
+ name = metaName;
569
+ break;
570
+ case 'trk':
571
+ tracks.h(parseTrack($this, reader));
572
+ break;
573
+ case 'wpt':
574
+ waypoints.h(parseWaypoint($this, reader));
575
+ break;
576
+ default:
577
+ skipElement($this, reader);
578
+ break;
579
+ }
580
+
581
+ break;
582
+ case 2:
583
+ return new GpxDocument(name, tracks, waypoints);
584
+ default:
585
+ break;
586
+ }
587
+ }
588
+ return new GpxDocument(name, tracks, waypoints);
589
+ }
590
+ function parseMetadataName($this, reader) {
591
+ var name = null;
592
+ while (reader.j()) {
593
+ var ev = reader.k();
594
+ switch (ev.o1_1) {
595
+ case 1:
596
+ if (reader.r17() === 'name' && name == null) {
597
+ // Inline function 'kotlin.text.trim' call
598
+ var this_0 = readElementText($this, reader);
599
+ // Inline function 'kotlin.text.ifEmpty' call
600
+ var this_1 = toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
601
+ var tmp;
602
+ // Inline function 'kotlin.text.isEmpty' call
603
+ if (charSequenceLength(this_1) === 0) {
604
+ tmp = null;
605
+ } else {
606
+ tmp = this_1;
607
+ }
608
+ name = tmp;
609
+ } else {
610
+ skipElement($this, reader);
611
+ }
612
+
613
+ break;
614
+ case 2:
615
+ return name;
616
+ default:
617
+ break;
618
+ }
619
+ }
620
+ return name;
621
+ }
622
+ function parseTrack($this, reader) {
623
+ var name = null;
624
+ var type = null;
625
+ // Inline function 'kotlin.collections.mutableListOf' call
626
+ var segments = ArrayList_init_$Create$();
627
+ while (reader.j()) {
628
+ var ev = reader.k();
629
+ switch (ev.o1_1) {
630
+ case 1:
631
+ switch (reader.r17()) {
632
+ case 'name':
633
+ // Inline function 'kotlin.text.trim' call
634
+
635
+ var this_0 = readElementText($this, reader);
636
+ // Inline function 'kotlin.text.ifEmpty' call
637
+
638
+ var this_1 = toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
639
+ var tmp;
640
+ // Inline function 'kotlin.text.isEmpty' call
641
+
642
+ if (charSequenceLength(this_1) === 0) {
643
+ tmp = null;
644
+ } else {
645
+ tmp = this_1;
646
+ }
647
+
648
+ name = tmp;
649
+ break;
650
+ case 'type':
651
+ // Inline function 'kotlin.text.trim' call
652
+
653
+ var this_2 = readElementText($this, reader);
654
+ // Inline function 'kotlin.text.ifEmpty' call
655
+
656
+ var this_3 = toString_0(trim(isCharSequence(this_2) ? this_2 : THROW_CCE()));
657
+ var tmp_0;
658
+ // Inline function 'kotlin.text.isEmpty' call
659
+
660
+ if (charSequenceLength(this_3) === 0) {
661
+ tmp_0 = null;
662
+ } else {
663
+ tmp_0 = this_3;
664
+ }
665
+
666
+ type = tmp_0;
667
+ break;
668
+ case 'trkseg':
669
+ segments.h(parseTrackSegment($this, reader));
670
+ break;
671
+ default:
672
+ skipElement($this, reader);
673
+ break;
674
+ }
675
+
676
+ break;
677
+ case 2:
678
+ return new GpxTrack(name, type, segments);
679
+ default:
680
+ break;
681
+ }
682
+ }
683
+ return new GpxTrack(name, type, segments);
684
+ }
685
+ function parseTrackSegment($this, reader) {
686
+ // Inline function 'kotlin.collections.mutableListOf' call
687
+ var points = ArrayList_init_$Create$();
688
+ while (reader.j()) {
689
+ var ev = reader.k();
690
+ switch (ev.o1_1) {
691
+ case 1:
692
+ if (reader.r17() === 'trkpt') {
693
+ points.h(parseTrackPoint($this, reader));
694
+ } else {
695
+ skipElement($this, reader);
696
+ }
697
+
698
+ break;
699
+ case 2:
700
+ return new GpxSegment(points);
701
+ default:
702
+ break;
703
+ }
704
+ }
705
+ return new GpxSegment(points);
706
+ }
707
+ function parseTrackPoint($this, reader) {
708
+ var latStr = reader.c18(null, 'lat');
709
+ var lonStr = reader.c18(null, 'lon');
710
+ var tmp;
711
+ // Inline function 'kotlin.text.isNullOrBlank' call
712
+ if (latStr == null || isBlank(latStr)) {
713
+ tmp = true;
714
+ } else {
715
+ // Inline function 'kotlin.text.isNullOrBlank' call
716
+ tmp = lonStr == null || isBlank(lonStr);
717
+ }
718
+ if (tmp) {
719
+ throw IllegalArgumentException_init_$Create$_0('Invalid track point: missing latitude or longitude attribute');
720
+ }
721
+ var tmp0_elvis_lhs = toDoubleOrNull(latStr);
722
+ var tmp_0;
723
+ if (tmp0_elvis_lhs == null) {
724
+ throw IllegalArgumentException_init_$Create$_0("Invalid track point: latitude '" + latStr + "' is not a valid number");
725
+ } else {
726
+ tmp_0 = tmp0_elvis_lhs;
727
+ }
728
+ var lat = tmp_0;
729
+ var tmp1_elvis_lhs = toDoubleOrNull(lonStr);
730
+ var tmp_1;
731
+ if (tmp1_elvis_lhs == null) {
732
+ throw IllegalArgumentException_init_$Create$_0("Invalid track point: longitude '" + lonStr + "' is not a valid number");
733
+ } else {
734
+ tmp_1 = tmp1_elvis_lhs;
735
+ }
736
+ var lon = tmp_1;
737
+ var elevation = null;
738
+ var timeMs = null;
739
+ var ext = new ExtensionsAccumulator();
740
+ while (reader.j()) {
741
+ var ev = reader.k();
742
+ switch (ev.o1_1) {
743
+ case 1:
744
+ switch (reader.r17()) {
745
+ case 'ele':
746
+ // Inline function 'kotlin.text.trim' call
747
+
748
+ var this_0 = readElementText($this, reader);
749
+ var txt = toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
750
+ // Inline function 'kotlin.text.isNotEmpty' call
751
+
752
+ if (charSequenceLength(txt) > 0) {
753
+ var tmp4_elvis_lhs = toDoubleOrNull(txt);
754
+ elevation = tmp4_elvis_lhs == null ? elevation : tmp4_elvis_lhs;
755
+ }
756
+
757
+ break;
758
+ case 'time':
759
+ // Inline function 'kotlin.text.trim' call
760
+
761
+ var this_1 = readElementText($this, reader);
762
+ var txt_0 = toString_0(trim(isCharSequence(this_1) ? this_1 : THROW_CCE()));
763
+ // Inline function 'kotlin.text.isNotEmpty' call
764
+
765
+ if (charSequenceLength(txt_0) > 0)
766
+ timeMs = parseTimeIsoToMs($this, txt_0);
767
+ break;
768
+ case 'extensions':
769
+ parseExtensions($this, reader, ext);
770
+ break;
771
+ default:
772
+ skipElement($this, reader);
773
+ break;
774
+ }
775
+
776
+ break;
777
+ case 2:
778
+ return new GpxTrackPoint(lat, lon, elevation, timeMs, ext.e1r_1, ext.f1r_1, ext.g1r_1, ext.h1r_1);
779
+ default:
780
+ break;
781
+ }
782
+ }
783
+ return new GpxTrackPoint(lat, lon, elevation, timeMs, ext.e1r_1, ext.f1r_1, ext.g1r_1, ext.h1r_1);
784
+ }
785
+ function parseWaypoint($this, reader) {
786
+ var latStr = reader.c18(null, 'lat');
787
+ var lonStr = reader.c18(null, 'lon');
788
+ var tmp;
789
+ // Inline function 'kotlin.text.isNullOrBlank' call
790
+ if (latStr == null || isBlank(latStr)) {
791
+ tmp = true;
792
+ } else {
793
+ // Inline function 'kotlin.text.isNullOrBlank' call
794
+ tmp = lonStr == null || isBlank(lonStr);
795
+ }
796
+ if (tmp) {
797
+ throw IllegalArgumentException_init_$Create$_0('Invalid waypoint: missing latitude or longitude attribute');
798
+ }
799
+ var tmp0_elvis_lhs = toDoubleOrNull(latStr);
800
+ var tmp_0;
801
+ if (tmp0_elvis_lhs == null) {
802
+ throw IllegalArgumentException_init_$Create$_0("Invalid waypoint: latitude '" + latStr + "' is not a valid number");
803
+ } else {
804
+ tmp_0 = tmp0_elvis_lhs;
805
+ }
806
+ var lat = tmp_0;
807
+ var tmp1_elvis_lhs = toDoubleOrNull(lonStr);
808
+ var tmp_1;
809
+ if (tmp1_elvis_lhs == null) {
810
+ throw IllegalArgumentException_init_$Create$_0("Invalid waypoint: longitude '" + lonStr + "' is not a valid number");
811
+ } else {
812
+ tmp_1 = tmp1_elvis_lhs;
813
+ }
814
+ var lon = tmp_1;
815
+ var elevation = null;
816
+ var timeMs = null;
817
+ var name = null;
818
+ var description = null;
819
+ var symbol = null;
820
+ var type = null;
821
+ while (reader.j()) {
822
+ var ev = reader.k();
823
+ switch (ev.o1_1) {
824
+ case 1:
825
+ switch (reader.r17()) {
826
+ case 'ele':
827
+ // Inline function 'kotlin.text.trim' call
828
+
829
+ var this_0 = readElementText($this, reader);
830
+ var txt = toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
831
+ // Inline function 'kotlin.text.isNotEmpty' call
832
+
833
+ if (charSequenceLength(txt) > 0) {
834
+ var tmp4_elvis_lhs = toDoubleOrNull(txt);
835
+ elevation = tmp4_elvis_lhs == null ? elevation : tmp4_elvis_lhs;
836
+ }
837
+
838
+ break;
839
+ case 'time':
840
+ // Inline function 'kotlin.text.trim' call
841
+
842
+ var this_1 = readElementText($this, reader);
843
+ var txt_0 = toString_0(trim(isCharSequence(this_1) ? this_1 : THROW_CCE()));
844
+ // Inline function 'kotlin.text.isNotEmpty' call
845
+
846
+ if (charSequenceLength(txt_0) > 0)
847
+ timeMs = parseTimeIsoToMs($this, txt_0);
848
+ break;
849
+ case 'name':
850
+ // Inline function 'kotlin.text.trim' call
851
+
852
+ var this_2 = readElementText($this, reader);
853
+ // Inline function 'kotlin.text.ifEmpty' call
854
+
855
+ var this_3 = toString_0(trim(isCharSequence(this_2) ? this_2 : THROW_CCE()));
856
+ var tmp_2;
857
+ // Inline function 'kotlin.text.isEmpty' call
858
+
859
+ if (charSequenceLength(this_3) === 0) {
860
+ tmp_2 = null;
861
+ } else {
862
+ tmp_2 = this_3;
863
+ }
864
+
865
+ name = tmp_2;
866
+ break;
867
+ case 'desc':
868
+ // Inline function 'kotlin.text.trim' call
869
+
870
+ var this_4 = readElementText($this, reader);
871
+ // Inline function 'kotlin.text.ifEmpty' call
872
+
873
+ var this_5 = toString_0(trim(isCharSequence(this_4) ? this_4 : THROW_CCE()));
874
+ var tmp_3;
875
+ // Inline function 'kotlin.text.isEmpty' call
876
+
877
+ if (charSequenceLength(this_5) === 0) {
878
+ tmp_3 = null;
879
+ } else {
880
+ tmp_3 = this_5;
881
+ }
882
+
883
+ description = tmp_3;
884
+ break;
885
+ case 'sym':
886
+ // Inline function 'kotlin.text.trim' call
887
+
888
+ var this_6 = readElementText($this, reader);
889
+ // Inline function 'kotlin.text.ifEmpty' call
890
+
891
+ var this_7 = toString_0(trim(isCharSequence(this_6) ? this_6 : THROW_CCE()));
892
+ var tmp_4;
893
+ // Inline function 'kotlin.text.isEmpty' call
894
+
895
+ if (charSequenceLength(this_7) === 0) {
896
+ tmp_4 = null;
897
+ } else {
898
+ tmp_4 = this_7;
899
+ }
900
+
901
+ symbol = tmp_4;
902
+ break;
903
+ case 'type':
904
+ // Inline function 'kotlin.text.trim' call
905
+
906
+ var this_8 = readElementText($this, reader);
907
+ // Inline function 'kotlin.text.ifEmpty' call
908
+
909
+ var this_9 = toString_0(trim(isCharSequence(this_8) ? this_8 : THROW_CCE()));
910
+ var tmp_5;
911
+ // Inline function 'kotlin.text.isEmpty' call
912
+
913
+ if (charSequenceLength(this_9) === 0) {
914
+ tmp_5 = null;
915
+ } else {
916
+ tmp_5 = this_9;
917
+ }
918
+
919
+ type = tmp_5;
920
+ break;
921
+ default:
922
+ skipElement($this, reader);
923
+ break;
924
+ }
925
+
926
+ break;
927
+ case 2:
928
+ return new GpxWaypoint(lat, lon, elevation, name, description, symbol, type, timeMs);
929
+ default:
930
+ break;
931
+ }
932
+ }
933
+ return new GpxWaypoint(lat, lon, elevation, name, description, symbol, type, timeMs);
934
+ }
935
+ function parseExtensions($this, reader, ext) {
936
+ while (reader.j()) {
937
+ var ev = reader.k();
938
+ switch (ev.o1_1) {
939
+ case 1:
940
+ var ln = reader.r17();
941
+ // Inline function 'kotlin.text.lowercase' call
942
+
943
+ // Inline function 'kotlin.js.asDynamic' call
944
+
945
+ switch (ln.toLowerCase()) {
946
+ case 'power':
947
+ var tmp2_safe_receiver = readNumeric($this, reader);
948
+ if (tmp2_safe_receiver == null)
949
+ null;
950
+ else {
951
+ // Inline function 'kotlin.let' call
952
+ var tmp = ext;
953
+ var tmp0_elvis_lhs = ext.h1r_1;
954
+ tmp.h1r_1 = tmp0_elvis_lhs == null ? tmp2_safe_receiver : tmp0_elvis_lhs;
955
+ }
956
+
957
+ break;
958
+ case 'hr':
959
+ case 'heartrate':
960
+ var tmp3_safe_receiver = readNumeric($this, reader);
961
+ if (tmp3_safe_receiver == null)
962
+ null;
963
+ else {
964
+ // Inline function 'kotlin.let' call
965
+ if (ext.e1r_1 == null)
966
+ ext.e1r_1 = numberToInt(tmp3_safe_receiver);
967
+ }
968
+
969
+ break;
970
+ case 'cad':
971
+ case 'cadence':
972
+ var tmp4_safe_receiver = readNumeric($this, reader);
973
+ if (tmp4_safe_receiver == null)
974
+ null;
975
+ else {
976
+ // Inline function 'kotlin.let' call
977
+ if (ext.f1r_1 == null)
978
+ ext.f1r_1 = numberToInt(tmp4_safe_receiver);
979
+ }
980
+
981
+ break;
982
+ case 'atemp':
983
+ case 'temperature':
984
+ case 'temp':
985
+ var tmp5_safe_receiver = readNumeric($this, reader);
986
+ if (tmp5_safe_receiver == null)
987
+ null;
988
+ else {
989
+ // Inline function 'kotlin.let' call
990
+ var tmp_0 = ext;
991
+ var tmp0_elvis_lhs_0 = ext.g1r_1;
992
+ tmp_0.g1r_1 = tmp0_elvis_lhs_0 == null ? tmp5_safe_receiver : tmp0_elvis_lhs_0;
993
+ }
994
+
995
+ break;
996
+ default:
997
+ parseExtensions($this, reader, ext);
998
+ break;
999
+ }
1000
+
1001
+ break;
1002
+ case 2:
1003
+ return Unit_instance;
1004
+ default:
1005
+ break;
1006
+ }
1007
+ }
1008
+ }
1009
+ function readElementText($this, reader) {
1010
+ var sb = StringBuilder_init_$Create$();
1011
+ while (reader.j()) {
1012
+ var ev = reader.k();
1013
+ switch (ev.o1_1) {
1014
+ case 4:
1015
+ case 5:
1016
+ case 9:
1017
+ case 8:
1018
+ sb.v5(reader.w17());
1019
+ break;
1020
+ case 1:
1021
+ skipElement($this, reader);
1022
+ break;
1023
+ case 2:
1024
+ return sb.toString();
1025
+ default:
1026
+ break;
1027
+ }
1028
+ }
1029
+ return sb.toString();
1030
+ }
1031
+ function readNumeric($this, reader) {
1032
+ // Inline function 'kotlin.text.trim' call
1033
+ var this_0 = readElementText($this, reader);
1034
+ var txt = toString_0(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
1035
+ return toDoubleOrNull(txt);
1036
+ }
1037
+ function skipElement($this, reader) {
1038
+ var depth = 1;
1039
+ while (reader.j() && depth > 0) {
1040
+ switch (reader.k().o1_1) {
1041
+ case 1:
1042
+ depth = depth + 1 | 0;
1043
+ break;
1044
+ case 2:
1045
+ depth = depth - 1 | 0;
1046
+ break;
1047
+ default:
1048
+ break;
1049
+ }
1050
+ }
1051
+ }
1052
+ function parseTimeIsoToMs($this, text) {
1053
+ var tmp;
1054
+ try {
1055
+ tmp = Companion_getInstance().qd(text).ud();
1056
+ } catch ($p) {
1057
+ var tmp_0;
1058
+ if ($p instanceof IllegalArgumentException) {
1059
+ var e = $p;
1060
+ tmp_0 = null;
1061
+ } else {
1062
+ if ($p instanceof Error) {
1063
+ var e_0 = $p;
1064
+ tmp_0 = null;
1065
+ } else {
1066
+ throw $p;
1067
+ }
1068
+ }
1069
+ tmp = tmp_0;
1070
+ }
1071
+ return tmp;
1072
+ }
1073
+ function ExtensionsAccumulator(heartRate, cadence, temperatureC, powerW) {
1074
+ heartRate = heartRate === VOID ? null : heartRate;
1075
+ cadence = cadence === VOID ? null : cadence;
1076
+ temperatureC = temperatureC === VOID ? null : temperatureC;
1077
+ powerW = powerW === VOID ? null : powerW;
1078
+ this.e1r_1 = heartRate;
1079
+ this.f1r_1 = cadence;
1080
+ this.g1r_1 = temperatureC;
1081
+ this.h1r_1 = powerW;
1082
+ }
1083
+ function GpxParser() {
1084
+ }
1085
+ protoOf(GpxParser).i1r = function (xml, repairOnFailure) {
1086
+ var tmp;
1087
+ try {
1088
+ tmp = parseOnce(this, xml);
1089
+ } catch ($p) {
1090
+ var tmp_0;
1091
+ if ($p instanceof IllegalArgumentException) {
1092
+ var firstFailure = $p;
1093
+ if (!repairOnFailure)
1094
+ throw firstFailure;
1095
+ var repaired = GpxXmlRepair_getInstance().l1r(xml);
1096
+ var tmp_1;
1097
+ try {
1098
+ tmp_1 = parseOnce(this, repaired);
1099
+ } catch ($p_0) {
1100
+ var tmp_2;
1101
+ if ($p_0 instanceof IllegalArgumentException) {
1102
+ var secondFailure = $p_0;
1103
+ throw IllegalArgumentException_init_$Create$('Invalid GPX XML (repair attempted but parsing still failed): ' + secondFailure.message, secondFailure);
1104
+ } else {
1105
+ throw $p_0;
1106
+ }
1107
+ }
1108
+ tmp_0 = tmp_1;
1109
+ } else {
1110
+ throw $p;
1111
+ }
1112
+ tmp = tmp_0;
1113
+ }
1114
+ return tmp;
1115
+ };
1116
+ protoOf(GpxParser).m1r = function (xml, repairOnFailure, $super) {
1117
+ repairOnFailure = repairOnFailure === VOID ? true : repairOnFailure;
1118
+ return $super === VOID ? this.i1r(xml, repairOnFailure) : $super.i1r.call(this, xml, repairOnFailure);
1119
+ };
1120
+ var GpxParser_instance;
1121
+ function GpxParser_getInstance() {
1122
+ return GpxParser_instance;
1123
+ }
1124
+ function firstTrackAsPath(_this__u8e3s4) {
1125
+ var tmp0_elvis_lhs = firstOrNull(_this__u8e3s4.d1q_1);
1126
+ var tmp;
1127
+ if (tmp0_elvis_lhs == null) {
1128
+ // Inline function 'kotlin.error' call
1129
+ var message = 'GpxDocument has no track';
1130
+ throw IllegalStateException_init_$Create$(toString_0(message));
1131
+ } else {
1132
+ tmp = tmp0_elvis_lhs;
1133
+ }
1134
+ var track = tmp;
1135
+ return toPath(track);
1136
+ }
1137
+ function tracksAsPaths(_this__u8e3s4) {
1138
+ // Inline function 'kotlin.collections.filter' call
1139
+ var tmp0 = _this__u8e3s4.d1q_1;
1140
+ // Inline function 'kotlin.collections.filterTo' call
1141
+ var destination = ArrayList_init_$Create$();
1142
+ var _iterator__ex2g4s = tmp0.i();
1143
+ while (_iterator__ex2g4s.j()) {
1144
+ var element = _iterator__ex2g4s.k();
1145
+ // Inline function 'kotlin.collections.isNotEmpty' call
1146
+ if (!element.l1q().n()) {
1147
+ destination.h(element);
1148
+ }
1149
+ }
1150
+ // Inline function 'kotlin.collections.map' call
1151
+ // Inline function 'kotlin.collections.mapTo' call
1152
+ var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination, 10));
1153
+ var _iterator__ex2g4s_0 = destination.i();
1154
+ while (_iterator__ex2g4s_0.j()) {
1155
+ var item = _iterator__ex2g4s_0.k();
1156
+ var tmp$ret$6 = toPath(item);
1157
+ destination_0.h(tmp$ret$6);
1158
+ }
1159
+ return destination_0;
1160
+ }
1161
+ function segmentsAsPaths(_this__u8e3s4) {
1162
+ // Inline function 'kotlin.collections.flatMap' call
1163
+ var tmp0 = _this__u8e3s4.d1q_1;
1164
+ // Inline function 'kotlin.collections.flatMapTo' call
1165
+ var destination = ArrayList_init_$Create$();
1166
+ var _iterator__ex2g4s = tmp0.i();
1167
+ while (_iterator__ex2g4s.j()) {
1168
+ var element = _iterator__ex2g4s.k();
1169
+ var list = element.i1q_1;
1170
+ addAll(destination, list);
1171
+ }
1172
+ // Inline function 'kotlin.collections.filter' call
1173
+ // Inline function 'kotlin.collections.filterTo' call
1174
+ var destination_0 = ArrayList_init_$Create$();
1175
+ var _iterator__ex2g4s_0 = destination.i();
1176
+ while (_iterator__ex2g4s_0.j()) {
1177
+ var element_0 = _iterator__ex2g4s_0.k();
1178
+ // Inline function 'kotlin.collections.isNotEmpty' call
1179
+ if (!element_0.k1q_1.n()) {
1180
+ destination_0.h(element_0);
1181
+ }
1182
+ }
1183
+ // Inline function 'kotlin.collections.map' call
1184
+ // Inline function 'kotlin.collections.mapTo' call
1185
+ var destination_1 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination_0, 10));
1186
+ var _iterator__ex2g4s_1 = destination_0.i();
1187
+ while (_iterator__ex2g4s_1.j()) {
1188
+ var item = _iterator__ex2g4s_1.k();
1189
+ var tmp$ret$9 = toPath_0(item);
1190
+ destination_1.h(tmp$ret$9);
1191
+ }
1192
+ return destination_1;
1193
+ }
1194
+ function toPath(_this__u8e3s4) {
1195
+ return pointsToPath(_this__u8e3s4.l1q());
1196
+ }
1197
+ function toPath_0(_this__u8e3s4) {
1198
+ return pointsToPath(_this__u8e3s4.k1q_1);
1199
+ }
1200
+ function pointsToPath(points) {
1201
+ var path = new Path(points.l());
1202
+ var iterator = points.i();
1203
+ var index = 0;
1204
+ while (iterator.j()) {
1205
+ var i = index;
1206
+ index = index + 1 | 0;
1207
+ var p = iterator.k();
1208
+ path.n1r(i, p.m1q_1 * MathConstants_getInstance().tw_1);
1209
+ path.o1r(i, p.n1q_1 * MathConstants_getInstance().tw_1);
1210
+ var tmp0_elvis_lhs = p.o1q_1;
1211
+ path.p1r(i, tmp0_elvis_lhs == null ? 0.0 : tmp0_elvis_lhs);
1212
+ var tmp1_elvis_lhs = p.p1q_1;
1213
+ path.q1r(i, toNumber(tmp1_elvis_lhs == null ? new Long(0, 0) : tmp1_elvis_lhs));
1214
+ var tmp2_elvis_lhs = p.t1q_1;
1215
+ path.r1r(i, tmp2_elvis_lhs == null ? NaN : tmp2_elvis_lhs);
1216
+ var tmp3_safe_receiver = p.q1q_1;
1217
+ var tmp4_elvis_lhs = tmp3_safe_receiver == null ? null : tmp3_safe_receiver;
1218
+ path.s1r(i, tmp4_elvis_lhs == null ? NaN : tmp4_elvis_lhs);
1219
+ var tmp5_safe_receiver = p.r1q_1;
1220
+ var tmp6_elvis_lhs = tmp5_safe_receiver == null ? null : tmp5_safe_receiver;
1221
+ path.t1r(i, tmp6_elvis_lhs == null ? NaN : tmp6_elvis_lhs);
1222
+ var tmp7_elvis_lhs = p.s1q_1;
1223
+ path.u1r(i, tmp7_elvis_lhs == null ? NaN : tmp7_elvis_lhs);
1224
+ }
1225
+ path.e1s();
1226
+ return path;
1227
+ }
1228
+ function writeDocument($this, w, document) {
1229
+ w.w19('', 'http://www.topografix.com/GPX/1/1');
1230
+ w.w19('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
1231
+ w.w19('gpxtpx', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');
1232
+ w.y19('http://www.topografix.com/GPX/1/1', 'gpx', '');
1233
+ w.a1a(null, 'version', null, '1.1');
1234
+ w.a1a(null, 'creator', null, '@glandais/vcyclist');
1235
+ w.x19('', 'http://www.topografix.com/GPX/1/1');
1236
+ w.x19('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
1237
+ w.x19('gpxtpx', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');
1238
+ w.a1a('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation', 'xsi', 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd');
1239
+ writeMetadata($this, w, document.c1q_1);
1240
+ var _iterator__ex2g4s = document.e1q_1.i();
1241
+ while (_iterator__ex2g4s.j()) {
1242
+ var waypoint = _iterator__ex2g4s.k();
1243
+ writeWaypoint($this, w, waypoint);
1244
+ }
1245
+ var _iterator__ex2g4s_0 = document.d1q_1.i();
1246
+ while (_iterator__ex2g4s_0.j()) {
1247
+ var track = _iterator__ex2g4s_0.k();
1248
+ writeTrack($this, w, track);
1249
+ }
1250
+ w.d1a('http://www.topografix.com/GPX/1/1', 'gpx', '');
1251
+ }
1252
+ function writeWaypoint($this, w, waypoint) {
1253
+ w.y19('http://www.topografix.com/GPX/1/1', 'wpt', '');
1254
+ w.a1a(null, 'lat', null, waypoint.u1p_1.toString());
1255
+ w.a1a(null, 'lon', null, waypoint.v1p_1.toString());
1256
+ var tmp0_safe_receiver = waypoint.w1p_1;
1257
+ if (tmp0_safe_receiver == null)
1258
+ null;
1259
+ else {
1260
+ // Inline function 'kotlin.let' call
1261
+ writeSimpleText(GpxWriter_instance, w, 'ele', tmp0_safe_receiver.toString());
1262
+ }
1263
+ var tmp1_safe_receiver = waypoint.b1q_1;
1264
+ if (tmp1_safe_receiver == null)
1265
+ null;
1266
+ else {
1267
+ // Inline function 'kotlin.let' call
1268
+ writeSimpleText(GpxWriter_instance, w, 'time', Companion_getInstance().nd(tmp1_safe_receiver).toString());
1269
+ }
1270
+ var tmp2_safe_receiver = waypoint.x1p_1;
1271
+ if (tmp2_safe_receiver == null)
1272
+ null;
1273
+ else {
1274
+ // Inline function 'kotlin.let' call
1275
+ writeSimpleText(GpxWriter_instance, w, 'name', tmp2_safe_receiver);
1276
+ }
1277
+ var tmp3_safe_receiver = waypoint.y1p_1;
1278
+ if (tmp3_safe_receiver == null)
1279
+ null;
1280
+ else {
1281
+ // Inline function 'kotlin.let' call
1282
+ writeSimpleText(GpxWriter_instance, w, 'desc', tmp3_safe_receiver);
1283
+ }
1284
+ var tmp4_safe_receiver = waypoint.z1p_1;
1285
+ if (tmp4_safe_receiver == null)
1286
+ null;
1287
+ else {
1288
+ // Inline function 'kotlin.let' call
1289
+ writeSimpleText(GpxWriter_instance, w, 'sym', tmp4_safe_receiver);
1290
+ }
1291
+ var tmp5_safe_receiver = waypoint.a1q_1;
1292
+ if (tmp5_safe_receiver == null)
1293
+ null;
1294
+ else {
1295
+ // Inline function 'kotlin.let' call
1296
+ writeSimpleText(GpxWriter_instance, w, 'type', tmp5_safe_receiver);
1297
+ }
1298
+ w.d1a('http://www.topografix.com/GPX/1/1', 'wpt', '');
1299
+ }
1300
+ function writeMetadata($this, w, name) {
1301
+ w.y19('http://www.topografix.com/GPX/1/1', 'metadata', '');
1302
+ writeSimpleText($this, w, 'name', name);
1303
+ w.d1a('http://www.topografix.com/GPX/1/1', 'metadata', '');
1304
+ }
1305
+ function writeTrack($this, w, track) {
1306
+ w.y19('http://www.topografix.com/GPX/1/1', 'trk', '');
1307
+ var tmp0_safe_receiver = track.g1q_1;
1308
+ if (tmp0_safe_receiver == null)
1309
+ null;
1310
+ else {
1311
+ // Inline function 'kotlin.let' call
1312
+ writeSimpleText(GpxWriter_instance, w, 'name', tmp0_safe_receiver);
1313
+ }
1314
+ var tmp1_safe_receiver = track.h1q_1;
1315
+ if (tmp1_safe_receiver == null)
1316
+ null;
1317
+ else {
1318
+ // Inline function 'kotlin.let' call
1319
+ writeSimpleText(GpxWriter_instance, w, 'type', tmp1_safe_receiver);
1320
+ }
1321
+ var _iterator__ex2g4s = track.i1q_1.i();
1322
+ while (_iterator__ex2g4s.j()) {
1323
+ var segment = _iterator__ex2g4s.k();
1324
+ w.y19('http://www.topografix.com/GPX/1/1', 'trkseg', '');
1325
+ var _iterator__ex2g4s_0 = segment.k1q_1.i();
1326
+ while (_iterator__ex2g4s_0.j()) {
1327
+ var p = _iterator__ex2g4s_0.k();
1328
+ writeTrackPoint($this, w, p);
1329
+ }
1330
+ w.d1a('http://www.topografix.com/GPX/1/1', 'trkseg', '');
1331
+ }
1332
+ w.d1a('http://www.topografix.com/GPX/1/1', 'trk', '');
1333
+ }
1334
+ function writeTrackPoint($this, w, p) {
1335
+ w.y19('http://www.topografix.com/GPX/1/1', 'trkpt', '');
1336
+ w.a1a(null, 'lat', null, p.m1q_1.toString());
1337
+ w.a1a(null, 'lon', null, p.n1q_1.toString());
1338
+ var tmp0_safe_receiver = p.p1q_1;
1339
+ if (tmp0_safe_receiver == null)
1340
+ null;
1341
+ else {
1342
+ // Inline function 'kotlin.let' call
1343
+ writeSimpleText(GpxWriter_instance, w, 'time', Companion_getInstance().nd(tmp0_safe_receiver).toString());
1344
+ }
1345
+ var tmp1_safe_receiver = p.o1q_1;
1346
+ if (tmp1_safe_receiver == null)
1347
+ null;
1348
+ else {
1349
+ // Inline function 'kotlin.let' call
1350
+ writeSimpleText(GpxWriter_instance, w, 'ele', tmp1_safe_receiver.toString());
1351
+ }
1352
+ var hasGarminExt = !(p.q1q_1 == null) || !(p.r1q_1 == null) || !(p.s1q_1 == null);
1353
+ var hasPower = !(p.t1q_1 == null);
1354
+ if (hasGarminExt || hasPower) {
1355
+ w.y19('http://www.topografix.com/GPX/1/1', 'extensions', '');
1356
+ if (hasPower) {
1357
+ writeSimpleText($this, w, 'power', p.t1q_1.toString());
1358
+ }
1359
+ if (hasGarminExt) {
1360
+ w.y19('http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'TrackPointExtension', 'gpxtpx');
1361
+ var tmp2_safe_receiver = p.q1q_1;
1362
+ if (tmp2_safe_receiver == null)
1363
+ null;
1364
+ else {
1365
+ // Inline function 'kotlin.let' call
1366
+ writeNamespaced(GpxWriter_instance, w, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'hr', 'gpxtpx', tmp2_safe_receiver.toString());
1367
+ }
1368
+ var tmp3_safe_receiver = p.r1q_1;
1369
+ if (tmp3_safe_receiver == null)
1370
+ null;
1371
+ else {
1372
+ // Inline function 'kotlin.let' call
1373
+ writeNamespaced(GpxWriter_instance, w, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'cad', 'gpxtpx', tmp3_safe_receiver.toString());
1374
+ }
1375
+ var tmp4_safe_receiver = p.s1q_1;
1376
+ if (tmp4_safe_receiver == null)
1377
+ null;
1378
+ else {
1379
+ // Inline function 'kotlin.let' call
1380
+ writeNamespaced(GpxWriter_instance, w, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'atemp', 'gpxtpx', tmp4_safe_receiver.toString());
1381
+ }
1382
+ w.d1a('http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'TrackPointExtension', 'gpxtpx');
1383
+ }
1384
+ w.d1a('http://www.topografix.com/GPX/1/1', 'extensions', '');
1385
+ }
1386
+ w.d1a('http://www.topografix.com/GPX/1/1', 'trkpt', '');
1387
+ }
1388
+ function writeSimpleText($this, w, localName, text) {
1389
+ w.y19('http://www.topografix.com/GPX/1/1', localName, '');
1390
+ w.z19(text);
1391
+ w.d1a('http://www.topografix.com/GPX/1/1', localName, '');
1392
+ }
1393
+ function writeNamespaced($this, w, namespace, localName, prefix, text) {
1394
+ w.y19(namespace, localName, prefix);
1395
+ w.z19(text);
1396
+ w.d1a(namespace, localName, prefix);
1397
+ }
1398
+ function GpxWriter() {
1399
+ this.f1s_1 = 'http://www.topografix.com/GPX/1/1';
1400
+ this.g1s_1 = 'http://www.w3.org/2001/XMLSchema-instance';
1401
+ this.h1s_1 = 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1';
1402
+ this.i1s_1 = 'xsi';
1403
+ this.j1s_1 = 'gpxtpx';
1404
+ this.k1s_1 = 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd';
1405
+ this.l1s_1 = '@glandais/vcyclist';
1406
+ }
1407
+ protoOf(GpxWriter).m1s = function (document) {
1408
+ var out = StringBuilder_init_$Create$();
1409
+ out.v5('<?xml version="1.0" encoding="UTF-8"?>\n');
1410
+ var writer = newGenericWriter(get_xmlStreaming(), out, false, XmlDeclMode_None_getInstance());
1411
+ try {
1412
+ writeDocument(this, writer, document);
1413
+ }finally {
1414
+ writer.e18();
1415
+ }
1416
+ return out.toString();
1417
+ };
1418
+ protoOf(GpxWriter).n1s = function (paths, name, trackNames, waypoints, startTime) {
1419
+ return this.m1s(pathsToGpxDocument(paths, name, trackNames, waypoints, VOID, startTime));
1420
+ };
1421
+ protoOf(GpxWriter).o1s = function (paths, name, trackNames, waypoints, startTime, $super) {
1422
+ name = name === VOID ? 'noname' : name;
1423
+ trackNames = trackNames === VOID ? null : trackNames;
1424
+ waypoints = waypoints === VOID ? emptyList() : waypoints;
1425
+ startTime = startTime === VOID ? null : startTime;
1426
+ return $super === VOID ? this.n1s(paths, name, trackNames, waypoints, startTime) : $super.n1s.call(this, paths, name, trackNames, waypoints, startTime);
1427
+ };
1428
+ var GpxWriter_instance;
1429
+ function GpxWriter_getInstance() {
1430
+ return GpxWriter_instance;
1431
+ }
1432
+ function stripBom($this, xml) {
1433
+ var tmp;
1434
+ var tmp_0;
1435
+ // Inline function 'kotlin.text.isNotEmpty' call
1436
+ if (charSequenceLength(xml) > 0) {
1437
+ tmp_0 = charCodeAt(xml, 0) === _Char___init__impl__6a9atx(65279);
1438
+ } else {
1439
+ tmp_0 = false;
1440
+ }
1441
+ if (tmp_0) {
1442
+ tmp = substring(xml, 1);
1443
+ } else {
1444
+ tmp = null;
1445
+ }
1446
+ return tmp;
1447
+ }
1448
+ function stripIllegalControlChars($this, xml) {
1449
+ var count = 0;
1450
+ var sb = null;
1451
+ var i = 0;
1452
+ var n = xml.length;
1453
+ $l$loop: while (i < n) {
1454
+ var c = charCodeAt(xml, i);
1455
+ if (isHighSurrogate(c) && (i + 1 | 0) < n && isLowSurrogate(charCodeAt(xml, i + 1 | 0))) {
1456
+ var tmp0_safe_receiver = sb;
1457
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.w5(c);
1458
+ if (tmp1_safe_receiver == null)
1459
+ null;
1460
+ else
1461
+ tmp1_safe_receiver.w5(charCodeAt(xml, i + 1 | 0));
1462
+ i = i + 2 | 0;
1463
+ continue $l$loop;
1464
+ }
1465
+ // Inline function 'kotlin.code' call
1466
+ var code = Char__toInt_impl_vasixd(c);
1467
+ var allowed = code === 9 || code === 10 || code === 13 || (32 <= code ? code <= 55295 : false) || (57344 <= code ? code <= 65533 : false);
1468
+ if (allowed) {
1469
+ var tmp2_safe_receiver = sb;
1470
+ if (tmp2_safe_receiver == null)
1471
+ null;
1472
+ else
1473
+ tmp2_safe_receiver.w5(c);
1474
+ } else {
1475
+ if (sb == null)
1476
+ sb = StringBuilder_init_$Create$_0(xml.length).y8(xml, 0, i);
1477
+ count = count + 1 | 0;
1478
+ }
1479
+ i = i + 1 | 0;
1480
+ }
1481
+ return count > 0 ? new Pair(toString(sb), count) : null;
1482
+ }
1483
+ function escapeBareAmpersands($this, xml) {
1484
+ var count = 0;
1485
+ var sb = null;
1486
+ var i = 0;
1487
+ var n = xml.length;
1488
+ while (i < n) {
1489
+ var c = charCodeAt(xml, i);
1490
+ if (c === _Char___init__impl__6a9atx(38)) {
1491
+ if (!(findReferenceEnd($this, xml, i) === -1)) {
1492
+ var tmp0_safe_receiver = sb;
1493
+ if (tmp0_safe_receiver == null)
1494
+ null;
1495
+ else
1496
+ tmp0_safe_receiver.w5(c);
1497
+ } else {
1498
+ if (sb == null)
1499
+ sb = StringBuilder_init_$Create$_0(xml.length + 16 | 0).y8(xml, 0, i);
1500
+ sb.v5('&amp;');
1501
+ count = count + 1 | 0;
1502
+ }
1503
+ } else {
1504
+ var tmp1_safe_receiver = sb;
1505
+ if (tmp1_safe_receiver == null)
1506
+ null;
1507
+ else
1508
+ tmp1_safe_receiver.w5(c);
1509
+ }
1510
+ i = i + 1 | 0;
1511
+ }
1512
+ return count > 0 ? new Pair(toString(sb), count) : null;
1513
+ }
1514
+ function recombineSurrogatePairReferences($this, xml) {
1515
+ var refs = findNumericReferences($this, xml);
1516
+ if (refs.l() < 2)
1517
+ return null;
1518
+ var count = 0;
1519
+ var sb = StringBuilder_init_$Create$_0(xml.length);
1520
+ var copiedUpTo = 0;
1521
+ var i = 0;
1522
+ while (i < refs.l()) {
1523
+ var high = refs.m(i);
1524
+ var low = getOrNull(refs, i + 1 | 0);
1525
+ if (!(low == null) && high.q1s_1 === low.p1s_1 && isHighSurrogate_0($this, high.r1s_1) && isLowSurrogate_0($this, low.r1s_1)) {
1526
+ sb.y8(xml, copiedUpTo, high.p1s_1);
1527
+ var codePoint = (65536 + imul(high.r1s_1 - 55296 | 0, 1024) | 0) + (low.r1s_1 - 56320 | 0) | 0;
1528
+ sb.v5('&#').a9(codePoint).w5(_Char___init__impl__6a9atx(59));
1529
+ copiedUpTo = low.q1s_1;
1530
+ count = count + 1 | 0;
1531
+ i = i + 2 | 0;
1532
+ } else {
1533
+ i = i + 1 | 0;
1534
+ }
1535
+ }
1536
+ if (count === 0)
1537
+ return null;
1538
+ sb.y8(xml, copiedUpTo, xml.length);
1539
+ return new Pair(sb.toString(), count);
1540
+ }
1541
+ function NumericRef(start, end, value) {
1542
+ this.p1s_1 = start;
1543
+ this.q1s_1 = end;
1544
+ this.r1s_1 = value;
1545
+ }
1546
+ protoOf(NumericRef).toString = function () {
1547
+ return 'NumericRef(start=' + this.p1s_1 + ', end=' + this.q1s_1 + ', value=' + this.r1s_1 + ')';
1548
+ };
1549
+ protoOf(NumericRef).hashCode = function () {
1550
+ var result = this.p1s_1;
1551
+ result = imul(result, 31) + this.q1s_1 | 0;
1552
+ result = imul(result, 31) + this.r1s_1 | 0;
1553
+ return result;
1554
+ };
1555
+ protoOf(NumericRef).equals = function (other) {
1556
+ if (this === other)
1557
+ return true;
1558
+ if (!(other instanceof NumericRef))
1559
+ return false;
1560
+ if (!(this.p1s_1 === other.p1s_1))
1561
+ return false;
1562
+ if (!(this.q1s_1 === other.q1s_1))
1563
+ return false;
1564
+ if (!(this.r1s_1 === other.r1s_1))
1565
+ return false;
1566
+ return true;
1567
+ };
1568
+ function findNumericReferences($this, xml) {
1569
+ // Inline function 'kotlin.collections.mutableListOf' call
1570
+ var refs = ArrayList_init_$Create$();
1571
+ var i = 0;
1572
+ var n = xml.length;
1573
+ $l$loop: while (i < n) {
1574
+ if (charCodeAt(xml, i) === _Char___init__impl__6a9atx(38) && (i + 1 | 0) < n && charCodeAt(xml, i + 1 | 0) === _Char___init__impl__6a9atx(35)) {
1575
+ var end = findReferenceEnd($this, xml, i);
1576
+ if (!(end === -1)) {
1577
+ var value = parseNumericReferenceValue($this, substring_0(xml, i + 2 | 0, end));
1578
+ if (!(value === -1)) {
1579
+ refs.h(new NumericRef(i, end + 1 | 0, value));
1580
+ }
1581
+ i = end + 1 | 0;
1582
+ continue $l$loop;
1583
+ }
1584
+ }
1585
+ i = i + 1 | 0;
1586
+ }
1587
+ return refs;
1588
+ }
1589
+ function parseNumericReferenceValue($this, body) {
1590
+ var tmp;
1591
+ try {
1592
+ var tmp_0;
1593
+ // Inline function 'kotlin.text.isNotEmpty' call
1594
+ if (charSequenceLength(body) > 0) {
1595
+ tmp_0 = charCodeAt(body, 0) === _Char___init__impl__6a9atx(120) || charCodeAt(body, 0) === _Char___init__impl__6a9atx(88);
1596
+ } else {
1597
+ tmp_0 = false;
1598
+ }
1599
+ var hex = tmp_0;
1600
+ var raw = toLong(hex ? substring(body, 1) : body, hex ? 16 : 10);
1601
+ var tmp_1;
1602
+ // Inline function 'kotlin.ranges.contains' call
1603
+ var this_0 = numberRangeToNumber(0, 1114111);
1604
+ if (contains(isInterface(this_0, ClosedRange) ? this_0 : THROW_CCE(), raw)) {
1605
+ tmp_1 = convertToInt(raw);
1606
+ } else {
1607
+ tmp_1 = -1;
1608
+ }
1609
+ tmp = tmp_1;
1610
+ } catch ($p) {
1611
+ var tmp_2;
1612
+ if ($p instanceof NumberFormatException) {
1613
+ var e = $p;
1614
+ tmp_2 = -1;
1615
+ } else {
1616
+ throw $p;
1617
+ }
1618
+ tmp = tmp_2;
1619
+ }
1620
+ return tmp;
1621
+ }
1622
+ function isHighSurrogate_0($this, codePoint) {
1623
+ return 55296 <= codePoint ? codePoint <= 56319 : false;
1624
+ }
1625
+ function isLowSurrogate_0($this, codePoint) {
1626
+ return 56320 <= codePoint ? codePoint <= 57343 : false;
1627
+ }
1628
+ function findReferenceEnd($this, xml, amp) {
1629
+ var n = xml.length;
1630
+ var j = amp + 1 | 0;
1631
+ if (j >= n)
1632
+ return -1;
1633
+ if (charCodeAt(xml, j) === _Char___init__impl__6a9atx(35)) {
1634
+ j = j + 1 | 0;
1635
+ var hex = j < n && (charCodeAt(xml, j) === _Char___init__impl__6a9atx(120) || charCodeAt(xml, j) === _Char___init__impl__6a9atx(88));
1636
+ if (hex) {
1637
+ j = j + 1 | 0;
1638
+ }
1639
+ var digitsStart = j;
1640
+ while (j < n && (j - digitsStart | 0) < 20 && (hex ? isHexDigit($this, charCodeAt(xml, j)) : isDigit(charCodeAt(xml, j)))) {
1641
+ j = j + 1 | 0;
1642
+ }
1643
+ return j > digitsStart && j < n && charCodeAt(xml, j) === _Char___init__impl__6a9atx(59) ? j : -1;
1644
+ }
1645
+ var nameStart = j;
1646
+ while (j < n && (j - nameStart | 0) < 20 && !(charCodeAt(xml, j) === _Char___init__impl__6a9atx(59)) && !(charCodeAt(xml, j) === _Char___init__impl__6a9atx(38)) && !isWhitespace(charCodeAt(xml, j))) {
1647
+ j = j + 1 | 0;
1648
+ }
1649
+ if (j >= n || !(charCodeAt(xml, j) === _Char___init__impl__6a9atx(59)))
1650
+ return -1;
1651
+ return $this.j1r_1.e1(substring_0(xml, nameStart, j)) ? j : -1;
1652
+ }
1653
+ function isHexDigit($this, $receiver) {
1654
+ return isDigit($receiver) || (_Char___init__impl__6a9atx(97) <= $receiver ? $receiver <= _Char___init__impl__6a9atx(102) : false) || (_Char___init__impl__6a9atx(65) <= $receiver ? $receiver <= _Char___init__impl__6a9atx(70) : false);
1655
+ }
1656
+ function GpxXmlRepair() {
1657
+ GpxXmlRepair_instance = this;
1658
+ this.j1r_1 = setOf(['amp', 'lt', 'gt', 'apos', 'quot']);
1659
+ this.k1r_1 = 20;
1660
+ }
1661
+ protoOf(GpxXmlRepair).l1r = function (xml) {
1662
+ return this.u1s(xml).s1s_1;
1663
+ };
1664
+ protoOf(GpxXmlRepair).u1s = function (xml) {
1665
+ // Inline function 'kotlin.collections.mutableListOf' call
1666
+ var repairs = ArrayList_init_$Create$();
1667
+ var current = xml;
1668
+ var tmp0_safe_receiver = stripBom(this, current);
1669
+ if (tmp0_safe_receiver == null)
1670
+ null;
1671
+ else {
1672
+ // Inline function 'kotlin.let' call
1673
+ current = tmp0_safe_receiver;
1674
+ // Inline function 'kotlin.collections.plusAssign' call
1675
+ var element = 'removed leading UTF-8 BOM (U+FEFF)';
1676
+ repairs.h(element);
1677
+ }
1678
+ var tmp1_safe_receiver = stripIllegalControlChars(this, current);
1679
+ if (tmp1_safe_receiver == null)
1680
+ null;
1681
+ else {
1682
+ // Inline function 'kotlin.let' call
1683
+ var repairedXml = tmp1_safe_receiver.qe();
1684
+ var count = tmp1_safe_receiver.re();
1685
+ current = repairedXml;
1686
+ // Inline function 'kotlin.collections.plusAssign' call
1687
+ var element_0 = 'removed ' + count + ' illegal XML 1.0 control character(s)';
1688
+ repairs.h(element_0);
1689
+ }
1690
+ var tmp2_safe_receiver = recombineSurrogatePairReferences(this, current);
1691
+ if (tmp2_safe_receiver == null)
1692
+ null;
1693
+ else {
1694
+ // Inline function 'kotlin.let' call
1695
+ var repairedXml_0 = tmp2_safe_receiver.qe();
1696
+ var count_0 = tmp2_safe_receiver.re();
1697
+ current = repairedXml_0;
1698
+ // Inline function 'kotlin.collections.plusAssign' call
1699
+ var element_1 = 'recombined ' + count_0 + ' surrogate-pair numeric character reference(s)';
1700
+ repairs.h(element_1);
1701
+ }
1702
+ var tmp3_safe_receiver = escapeBareAmpersands(this, current);
1703
+ if (tmp3_safe_receiver == null)
1704
+ null;
1705
+ else {
1706
+ // Inline function 'kotlin.let' call
1707
+ var repairedXml_1 = tmp3_safe_receiver.qe();
1708
+ var count_1 = tmp3_safe_receiver.re();
1709
+ current = repairedXml_1;
1710
+ // Inline function 'kotlin.collections.plusAssign' call
1711
+ var element_2 = 'escaped ' + count_1 + " bare '&' character(s)";
1712
+ repairs.h(element_2);
1713
+ }
1714
+ return new RepairResult(current, repairs);
1715
+ };
1716
+ var GpxXmlRepair_instance;
1717
+ function GpxXmlRepair_getInstance() {
1718
+ if (GpxXmlRepair_instance == null)
1719
+ new GpxXmlRepair();
1720
+ return GpxXmlRepair_instance;
1721
+ }
1722
+ function RepairResult(xml, repairs) {
1723
+ this.s1s_1 = xml;
1724
+ this.t1s_1 = repairs;
1725
+ }
1726
+ protoOf(RepairResult).toString = function () {
1727
+ return 'RepairResult(xml=' + this.s1s_1 + ', repairs=' + toString_0(this.t1s_1) + ')';
1728
+ };
1729
+ protoOf(RepairResult).hashCode = function () {
1730
+ var result = getStringHashCode(this.s1s_1);
1731
+ result = imul(result, 31) + hashCode(this.t1s_1) | 0;
1732
+ return result;
1733
+ };
1734
+ protoOf(RepairResult).equals = function (other) {
1735
+ if (this === other)
1736
+ return true;
1737
+ if (!(other instanceof RepairResult))
1738
+ return false;
1739
+ if (!(this.s1s_1 === other.s1s_1))
1740
+ return false;
1741
+ if (!equals(this.t1s_1, other.t1s_1))
1742
+ return false;
1743
+ return true;
1744
+ };
1745
+ function formatShortestRoundTrip($this, value) {
1746
+ var inductionVariable = 0;
1747
+ if (inductionVariable <= 12)
1748
+ do {
1749
+ var d = inductionVariable;
1750
+ inductionVariable = inductionVariable + 1 | 0;
1751
+ var candidate = formatFixed($this, value, d);
1752
+ if (toDouble(candidate) === value)
1753
+ return candidate;
1754
+ }
1755
+ while (inductionVariable <= 12);
1756
+ return formatFixed($this, value, 12);
1757
+ }
1758
+ function formatFixed($this, value, decimals) {
1759
+ var negative = value < 0.0;
1760
+ // Inline function 'kotlin.math.abs' call
1761
+ var absValue = Math.abs(value);
1762
+ var scale = toNumber($this.w1s_1[decimals]);
1763
+ var scaledLong = numberToLong(round(absValue * scale));
1764
+ var whole = $this.w1s_1[decimals];
1765
+ var intPart = divide(scaledLong, whole);
1766
+ var sign = negative && !equalsLong(scaledLong, new Long(0, 0)) ? '-' : '';
1767
+ var tmp;
1768
+ if (decimals === 0) {
1769
+ tmp = sign + intPart.toString();
1770
+ } else {
1771
+ var fracPart = padStart(modulo(scaledLong, whole).toString(), decimals, _Char___init__impl__6a9atx(48));
1772
+ tmp = sign + intPart.toString() + '.' + fracPart;
1773
+ }
1774
+ return tmp;
1775
+ }
1776
+ function CsvNumberFormat() {
1777
+ CsvNumberFormat_instance = this;
1778
+ this.v1s_1 = 12;
1779
+ var tmp = this;
1780
+ // Inline function 'kotlin.also' call
1781
+ var this_0 = longArray(13);
1782
+ var p = new Long(1, 0);
1783
+ var inductionVariable = 0;
1784
+ var last = this_0.length - 1 | 0;
1785
+ if (inductionVariable <= last)
1786
+ do {
1787
+ var i = inductionVariable;
1788
+ inductionVariable = inductionVariable + 1 | 0;
1789
+ this_0[i] = p;
1790
+ p = multiply(p, new Long(10, 0));
1791
+ }
1792
+ while (inductionVariable <= last);
1793
+ tmp.w1s_1 = this_0;
1794
+ }
1795
+ protoOf(CsvNumberFormat).x1s = function (value, decimals) {
1796
+ if (isNaN_0(value))
1797
+ return '';
1798
+ if (isInfinite(value))
1799
+ return value > 0 ? 'Infinity' : '-Infinity';
1800
+ var tmp;
1801
+ if (!(decimals == null)) {
1802
+ // Inline function 'kotlin.require' call
1803
+ if (!(0 <= decimals ? decimals <= 12 : false)) {
1804
+ var message = 'decimals must be in 0..12, was ' + decimals;
1805
+ throw IllegalArgumentException_init_$Create$_0(toString_0(message));
1806
+ }
1807
+ tmp = formatFixed(this, value, decimals);
1808
+ } else {
1809
+ tmp = formatShortestRoundTrip(this, value);
1810
+ }
1811
+ return tmp;
1812
+ };
1813
+ var CsvNumberFormat_instance;
1814
+ function CsvNumberFormat_getInstance() {
1815
+ if (CsvNumberFormat_instance == null)
1816
+ new CsvNumberFormat();
1817
+ return CsvNumberFormat_instance;
1818
+ }
1819
+ function headerFor($this, field, unitsInHeader) {
1820
+ return unitsInHeader ? field.a1t_1 + ' (' + field.b1t_1 + ')' : field.a1t_1;
1821
+ }
1822
+ function appendRow($this, sb, cells, options) {
1823
+ var iterator = cells.i();
1824
+ var index = 0;
1825
+ while (iterator.j()) {
1826
+ var i = index;
1827
+ index = index + 1 | 0;
1828
+ var cell = iterator.k();
1829
+ if (i > 0) {
1830
+ sb.w5(options.h1t_1);
1831
+ }
1832
+ sb.v5(escapeCsvCell($this, cell, options.h1t_1));
1833
+ }
1834
+ }
1835
+ function escapeCsvCell($this, cell, separator) {
1836
+ var tmp$ret$0;
1837
+ $l$block: {
1838
+ // Inline function 'kotlin.text.any' call
1839
+ var inductionVariable = 0;
1840
+ while (inductionVariable < charSequenceLength(cell)) {
1841
+ var element = charSequenceGet(cell, inductionVariable);
1842
+ inductionVariable = inductionVariable + 1 | 0;
1843
+ if (element === separator || element === _Char___init__impl__6a9atx(34) || element === _Char___init__impl__6a9atx(10) || element === _Char___init__impl__6a9atx(13)) {
1844
+ tmp$ret$0 = true;
1845
+ break $l$block;
1846
+ }
1847
+ }
1848
+ tmp$ret$0 = false;
1849
+ }
1850
+ var needsQuoting = tmp$ret$0;
1851
+ var tmp;
1852
+ if (needsQuoting) {
1853
+ tmp = '"' + replace(cell, '"', '""') + '"';
1854
+ } else {
1855
+ tmp = cell;
1856
+ }
1857
+ return tmp;
1858
+ }
1859
+ function CsvWriter() {
1860
+ }
1861
+ protoOf(CsvWriter).l1t = function (path, options) {
1862
+ var tmp0_elvis_lhs = options.g1t_1;
1863
+ var fields = tmp0_elvis_lhs == null ? get_entries() : tmp0_elvis_lhs;
1864
+ var sb = StringBuilder_init_$Create$();
1865
+ // Inline function 'kotlin.collections.map' call
1866
+ // Inline function 'kotlin.collections.mapTo' call
1867
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(fields, 10));
1868
+ var _iterator__ex2g4s = fields.i();
1869
+ while (_iterator__ex2g4s.j()) {
1870
+ var item = _iterator__ex2g4s.k();
1871
+ var tmp$ret$2 = headerFor(CsvWriter_instance, item, options.i1t_1);
1872
+ destination.h(tmp$ret$2);
1873
+ }
1874
+ appendRow(this, sb, destination, options);
1875
+ var inductionVariable = 0;
1876
+ var last = path.u1q_1;
1877
+ if (inductionVariable < last)
1878
+ do {
1879
+ var i = inductionVariable;
1880
+ inductionVariable = inductionVariable + 1 | 0;
1881
+ sb.v5(options.k1t_1);
1882
+ // Inline function 'kotlin.collections.map' call
1883
+ // Inline function 'kotlin.collections.mapTo' call
1884
+ var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(fields, 10));
1885
+ var _iterator__ex2g4s_0 = fields.i();
1886
+ while (_iterator__ex2g4s_0.j()) {
1887
+ var item_0 = _iterator__ex2g4s_0.k();
1888
+ var tmp$ret$5 = CsvNumberFormat_getInstance().x1s(path.m1t(i, item_0), options.j1t_1);
1889
+ destination_0.h(tmp$ret$5);
1890
+ }
1891
+ appendRow(this, sb, destination_0, options);
1892
+ }
1893
+ while (inductionVariable < last);
1894
+ return sb.toString();
1895
+ };
1896
+ var CsvWriter_instance;
1897
+ function CsvWriter_getInstance() {
1898
+ return CsvWriter_instance;
1899
+ }
1900
+ function CsvOptions(fields, separator, unitsInHeader, decimals, lineSeparator) {
1901
+ fields = fields === VOID ? null : fields;
1902
+ separator = separator === VOID ? _Char___init__impl__6a9atx(44) : separator;
1903
+ unitsInHeader = unitsInHeader === VOID ? true : unitsInHeader;
1904
+ decimals = decimals === VOID ? null : decimals;
1905
+ lineSeparator = lineSeparator === VOID ? '\n' : lineSeparator;
1906
+ this.g1t_1 = fields;
1907
+ this.h1t_1 = separator;
1908
+ this.i1t_1 = unitsInHeader;
1909
+ this.j1t_1 = decimals;
1910
+ this.k1t_1 = lineSeparator;
1911
+ }
1912
+ protoOf(CsvOptions).toString = function () {
1913
+ return 'CsvOptions(fields=' + toString(this.g1t_1) + ', separator=' + toString_1(this.h1t_1) + ', unitsInHeader=' + this.i1t_1 + ', decimals=' + this.j1t_1 + ', lineSeparator=' + this.k1t_1 + ')';
1914
+ };
1915
+ protoOf(CsvOptions).hashCode = function () {
1916
+ var result = this.g1t_1 == null ? 0 : hashCode(this.g1t_1);
1917
+ result = imul(result, 31) + Char__hashCode_impl_otmys(this.h1t_1) | 0;
1918
+ result = imul(result, 31) + getBooleanHashCode(this.i1t_1) | 0;
1919
+ result = imul(result, 31) + (this.j1t_1 == null ? 0 : this.j1t_1) | 0;
1920
+ result = imul(result, 31) + getStringHashCode(this.k1t_1) | 0;
1921
+ return result;
1922
+ };
1923
+ protoOf(CsvOptions).equals = function (other) {
1924
+ if (this === other)
1925
+ return true;
1926
+ if (!(other instanceof CsvOptions))
1927
+ return false;
1928
+ if (!equals(this.g1t_1, other.g1t_1))
1929
+ return false;
1930
+ if (!(this.h1t_1 === other.h1t_1))
1931
+ return false;
1932
+ if (!(this.i1t_1 === other.i1t_1))
1933
+ return false;
1934
+ if (!(this.j1t_1 == other.j1t_1))
1935
+ return false;
1936
+ if (!(this.k1t_1 === other.k1t_1))
1937
+ return false;
1938
+ return true;
1939
+ };
1940
+ function appendMeta($this, sb, path, fields, decimals, indent, nl, colon) {
1941
+ var inner = indent + indent;
1942
+ appendKeyRaw($this, sb, indent, 'meta', colon);
1943
+ sb.w5(_Char___init__impl__6a9atx(123)).v5(nl);
1944
+ appendKeyValueRaw($this, sb, inner, 'totalDistance', numberOrNull($this, path.x1r_1, decimals), colon);
1945
+ sb.w5(_Char___init__impl__6a9atx(44)).v5(nl);
1946
+ appendKeyValueRaw($this, sb, inner, 'durationMs', numberOrNull($this, path.c1s_1, decimals), colon);
1947
+ sb.w5(_Char___init__impl__6a9atx(44)).v5(nl);
1948
+ appendKeyValueRaw($this, sb, inner, 'elevationGain', numberOrNull($this, path.a1s_1, decimals), colon);
1949
+ sb.w5(_Char___init__impl__6a9atx(44)).v5(nl);
1950
+ appendKeyValueRaw($this, sb, inner, 'elevationLoss', numberOrNull($this, path.b1s_1, decimals), colon);
1951
+ sb.w5(_Char___init__impl__6a9atx(44)).v5(nl);
1952
+ appendKeyRaw($this, sb, inner, 'units', colon);
1953
+ sb.w5(_Char___init__impl__6a9atx(123)).v5(nl);
1954
+ var innerUnits = inner + indent;
1955
+ var iterator = fields.i();
1956
+ var index = 0;
1957
+ while (iterator.j()) {
1958
+ var i = index;
1959
+ index = index + 1 | 0;
1960
+ var field = iterator.k();
1961
+ appendKeyValueRaw($this, sb, innerUnits, $this.n1t(field.a1t_1), '"' + $this.n1t(field.b1t_1) + '"', colon);
1962
+ if (!(i === get_lastIndex(fields))) {
1963
+ sb.w5(_Char___init__impl__6a9atx(44));
1964
+ }
1965
+ sb.v5(nl);
1966
+ }
1967
+ sb.v5(inner).w5(_Char___init__impl__6a9atx(125)).v5(nl);
1968
+ sb.v5(indent).w5(_Char___init__impl__6a9atx(125));
1969
+ }
1970
+ function appendFields($this, sb, path, fields, options, indent, nl, colon) {
1971
+ sb.w5(_Char___init__impl__6a9atx(123)).v5(nl);
1972
+ var inner = indent + indent;
1973
+ var iterator = fields.i();
1974
+ var index = 0;
1975
+ while (iterator.j()) {
1976
+ var fi = index;
1977
+ index = index + 1 | 0;
1978
+ var field = iterator.k();
1979
+ appendKeyRaw($this, sb, inner, $this.n1t(field.a1t_1), colon);
1980
+ sb.w5(_Char___init__impl__6a9atx(91));
1981
+ var inductionVariable = 0;
1982
+ var last = path.u1q_1;
1983
+ if (inductionVariable < last)
1984
+ do {
1985
+ var i = inductionVariable;
1986
+ inductionVariable = inductionVariable + 1 | 0;
1987
+ if (i > 0) {
1988
+ sb.w5(_Char___init__impl__6a9atx(44));
1989
+ }
1990
+ sb.v5(numberOrNull($this, path.m1t(i, field), options.q1t_1));
1991
+ }
1992
+ while (inductionVariable < last);
1993
+ sb.w5(_Char___init__impl__6a9atx(93));
1994
+ if (!(fi === get_lastIndex(fields))) {
1995
+ sb.w5(_Char___init__impl__6a9atx(44));
1996
+ }
1997
+ sb.v5(nl);
1998
+ }
1999
+ sb.v5(indent).w5(_Char___init__impl__6a9atx(125));
2000
+ }
2001
+ function numberOrNull($this, value, decimals) {
2002
+ decimals = decimals === VOID ? null : decimals;
2003
+ var tmp;
2004
+ if (isNaN_0(value) || isInfinite(value)) {
2005
+ tmp = 'null';
2006
+ } else {
2007
+ tmp = CsvNumberFormat_getInstance().x1s(value, decimals);
2008
+ }
2009
+ return tmp;
2010
+ }
2011
+ function appendKeyRaw($this, sb, indent, key, colon) {
2012
+ sb.v5(indent).w5(_Char___init__impl__6a9atx(34)).v5(key).w5(_Char___init__impl__6a9atx(34)).v5(colon);
2013
+ }
2014
+ function appendKeyValueRaw($this, sb, indent, key, rawValue, colon) {
2015
+ appendKeyRaw($this, sb, indent, key, colon);
2016
+ sb.v5(rawValue);
2017
+ }
2018
+ function JsonWriter() {
2019
+ }
2020
+ protoOf(JsonWriter).s1t = function (path, options) {
2021
+ var tmp0_elvis_lhs = options.o1t_1;
2022
+ var fields = tmp0_elvis_lhs == null ? get_entries() : tmp0_elvis_lhs;
2023
+ var sb = StringBuilder_init_$Create$();
2024
+ var indent = options.p1t_1 ? ' ' : '';
2025
+ var nl = options.p1t_1 ? '\n' : '';
2026
+ var colon = options.p1t_1 ? ': ' : ':';
2027
+ sb.w5(_Char___init__impl__6a9atx(123)).v5(nl);
2028
+ appendKeyValueRaw(this, sb, indent, 'size', path.u1q_1.toString(), colon);
2029
+ sb.w5(_Char___init__impl__6a9atx(44)).v5(nl);
2030
+ if (options.r1t_1) {
2031
+ appendMeta(this, sb, path, fields, options.q1t_1, indent, nl, colon);
2032
+ sb.w5(_Char___init__impl__6a9atx(44)).v5(nl);
2033
+ }
2034
+ appendKeyRaw(this, sb, indent, 'fields', colon);
2035
+ appendFields(this, sb, path, fields, options, indent, nl, colon);
2036
+ sb.v5(nl).w5(_Char___init__impl__6a9atx(125));
2037
+ return sb.toString();
2038
+ };
2039
+ protoOf(JsonWriter).n1t = function (value) {
2040
+ var sb = StringBuilder_init_$Create$_0(value.length);
2041
+ var inductionVariable = 0;
2042
+ var last = value.length;
2043
+ while (inductionVariable < last) {
2044
+ var c = charCodeAt(value, inductionVariable);
2045
+ inductionVariable = inductionVariable + 1 | 0;
2046
+ if (c === _Char___init__impl__6a9atx(34))
2047
+ sb.v5('\\"');
2048
+ else if (c === _Char___init__impl__6a9atx(92))
2049
+ sb.v5('\\\\');
2050
+ else if (c === _Char___init__impl__6a9atx(10))
2051
+ sb.v5('\\n');
2052
+ else if (c === _Char___init__impl__6a9atx(13))
2053
+ sb.v5('\\r');
2054
+ else if (c === _Char___init__impl__6a9atx(9))
2055
+ sb.v5('\\t');
2056
+ else {
2057
+ // Inline function 'kotlin.code' call
2058
+ if (Char__toInt_impl_vasixd(c) < 32) {
2059
+ var tmp = sb.v5('\\u');
2060
+ // Inline function 'kotlin.code' call
2061
+ var tmp$ret$1 = Char__toInt_impl_vasixd(c);
2062
+ tmp.v5(padStart(toString_2(tmp$ret$1, 16), 4, _Char___init__impl__6a9atx(48)));
2063
+ } else {
2064
+ sb.w5(c);
2065
+ }
2066
+ }
2067
+ }
2068
+ return sb.toString();
2069
+ };
2070
+ var JsonWriter_instance;
2071
+ function JsonWriter_getInstance() {
2072
+ return JsonWriter_instance;
2073
+ }
2074
+ function JsonOptions(fields, pretty, decimals, includeMeta) {
2075
+ fields = fields === VOID ? null : fields;
2076
+ pretty = pretty === VOID ? false : pretty;
2077
+ decimals = decimals === VOID ? null : decimals;
2078
+ includeMeta = includeMeta === VOID ? true : includeMeta;
2079
+ this.o1t_1 = fields;
2080
+ this.p1t_1 = pretty;
2081
+ this.q1t_1 = decimals;
2082
+ this.r1t_1 = includeMeta;
2083
+ }
2084
+ protoOf(JsonOptions).toString = function () {
2085
+ return 'JsonOptions(fields=' + toString(this.o1t_1) + ', pretty=' + this.p1t_1 + ', decimals=' + this.q1t_1 + ', includeMeta=' + this.r1t_1 + ')';
2086
+ };
2087
+ protoOf(JsonOptions).hashCode = function () {
2088
+ var result = this.o1t_1 == null ? 0 : hashCode(this.o1t_1);
2089
+ result = imul(result, 31) + getBooleanHashCode(this.p1t_1) | 0;
2090
+ result = imul(result, 31) + (this.q1t_1 == null ? 0 : this.q1t_1) | 0;
2091
+ result = imul(result, 31) + getBooleanHashCode(this.r1t_1) | 0;
2092
+ return result;
2093
+ };
2094
+ protoOf(JsonOptions).equals = function (other) {
2095
+ if (this === other)
2096
+ return true;
2097
+ if (!(other instanceof JsonOptions))
2098
+ return false;
2099
+ if (!equals(this.o1t_1, other.o1t_1))
2100
+ return false;
2101
+ if (!(this.p1t_1 === other.p1t_1))
2102
+ return false;
2103
+ if (!(this.q1t_1 == other.q1t_1))
2104
+ return false;
2105
+ if (!(this.r1t_1 === other.r1t_1))
2106
+ return false;
2107
+ return true;
2108
+ };
2109
+ function copyAllSlots($this, source) {
2110
+ var out = new Path(source.u1q_1);
2111
+ var inductionVariable = 0;
2112
+ var last = source.u1q_1;
2113
+ if (inductionVariable < last)
2114
+ do {
2115
+ var i = inductionVariable;
2116
+ inductionVariable = inductionVariable + 1 | 0;
2117
+ var _iterator__ex2g4s = get_entries().i();
2118
+ while (_iterator__ex2g4s.j()) {
2119
+ var field = _iterator__ex2g4s.k();
2120
+ out.t1t(i, field, source.m1t(i, field));
2121
+ }
2122
+ }
2123
+ while (inductionVariable < last);
2124
+ return out;
2125
+ }
2126
+ function $fixElevationCOROUTINE$(_this__u8e3s4, source, provider, resultContinuation) {
2127
+ CoroutineImpl.call(this, resultContinuation);
2128
+ this.c1u_1 = _this__u8e3s4;
2129
+ this.d1u_1 = source;
2130
+ this.e1u_1 = provider;
2131
+ }
2132
+ protoOf($fixElevationCOROUTINE$).p6 = function () {
2133
+ var suspendResult = this.j6_1;
2134
+ $sm: do
2135
+ try {
2136
+ var tmp = this.h6_1;
2137
+ switch (tmp) {
2138
+ case 0:
2139
+ this.i6_1 = 2;
2140
+ if (this.d1u_1.u1q_1 === 0)
2141
+ return new Path(0);
2142
+ var size = this.d1u_1.u1q_1;
2143
+ var list = ArrayList_init_$Create$_0(size);
2144
+ var inductionVariable = 0;
2145
+ if (inductionVariable < size)
2146
+ do {
2147
+ var index = inductionVariable;
2148
+ inductionVariable = inductionVariable + 1 | 0;
2149
+ list.h(new LatLon(this.d1u_1.w1q(index) * MathConstants_getInstance().uw_1, this.d1u_1.x1q(index) * MathConstants_getInstance().uw_1));
2150
+ }
2151
+ while (inductionVariable < size);
2152
+ var coords = list;
2153
+ this.h6_1 = 1;
2154
+ suspendResult = this.e1u_1.u10(coords, VOID, this);
2155
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
2156
+ return suspendResult;
2157
+ }
2158
+
2159
+ continue $sm;
2160
+ case 1:
2161
+ var corrected = suspendResult;
2162
+ var out = copyAllSlots(this.c1u_1, this.d1u_1);
2163
+ var inductionVariable_0 = 0;
2164
+ var last = out.u1q_1;
2165
+ if (inductionVariable_0 < last)
2166
+ do {
2167
+ var i = inductionVariable_0;
2168
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2169
+ out.p1r(i, corrected.m(i).yw());
2170
+ }
2171
+ while (inductionVariable_0 < last);
2172
+ out.e1s();
2173
+ return out;
2174
+ case 2:
2175
+ throw this.k6_1;
2176
+ }
2177
+ } catch ($p) {
2178
+ var e = $p;
2179
+ if (this.i6_1 === 2) {
2180
+ throw e;
2181
+ } else {
2182
+ this.h6_1 = this.i6_1;
2183
+ this.k6_1 = e;
2184
+ }
2185
+ }
2186
+ while (true);
2187
+ };
2188
+ function ElevationStep() {
2189
+ this.f1u_1 = 150.0;
2190
+ }
2191
+ protoOf(ElevationStep).g1u = function (source, provider, $completion) {
2192
+ var tmp = new $fixElevationCOROUTINE$(this, source, provider, $completion);
2193
+ tmp.j6_1 = Unit_instance;
2194
+ tmp.k6_1 = null;
2195
+ return tmp.p6();
2196
+ };
2197
+ protoOf(ElevationStep).h1u = function (source, windowM) {
2198
+ if (source.u1q_1 === 0)
2199
+ return new Path(0);
2200
+ // Inline function 'kotlin.collections.List' call
2201
+ // Inline function 'kotlin.collections.MutableList' call
2202
+ var size = source.u1q_1;
2203
+ var list = ArrayList_init_$Create$_0(size);
2204
+ // Inline function 'kotlin.repeat' call
2205
+ var inductionVariable = 0;
2206
+ if (inductionVariable < size)
2207
+ do {
2208
+ var index = inductionVariable;
2209
+ inductionVariable = inductionVariable + 1 | 0;
2210
+ var tmp$ret$4 = source.i1u(index);
2211
+ list.h(tmp$ret$4);
2212
+ }
2213
+ while (inductionVariable < size);
2214
+ var coords = list;
2215
+ var smoothed = ElevationSmoother_instance.nw(coords, windowM);
2216
+ var out = copyAllSlots(this, source);
2217
+ var inductionVariable_0 = 0;
2218
+ var last = out.u1q_1;
2219
+ if (inductionVariable_0 < last)
2220
+ do {
2221
+ var i = inductionVariable_0;
2222
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2223
+ out.p1r(i, smoothed.m(i).yw());
2224
+ }
2225
+ while (inductionVariable_0 < last);
2226
+ out.e1s();
2227
+ return out;
2228
+ };
2229
+ protoOf(ElevationStep).j1u = function (source, windowM, $super) {
2230
+ windowM = windowM === VOID ? 150.0 : windowM;
2231
+ return $super === VOID ? this.h1u(source, windowM) : $super.h1u.call(this, source, windowM);
2232
+ };
2233
+ var ElevationStep_instance;
2234
+ function ElevationStep_getInstance() {
2235
+ return ElevationStep_instance;
2236
+ }
2237
+ function GeneratedPath(size) {
2238
+ this.u1q_1 = size;
2239
+ // Inline function 'kotlin.require' call
2240
+ if (!(this.u1q_1 >= 0)) {
2241
+ var message = 'Negative size: ' + this.u1q_1;
2242
+ throw IllegalArgumentException_init_$Create$_0(toString_0(message));
2243
+ }
2244
+ this.v1q_1 = new Float64Array(imul(this.u1q_1, 36));
2245
+ }
2246
+ protoOf(GeneratedPath).m1t = function (i, field) {
2247
+ return this.v1q_1[imul(i, 36) + field.o1_1 | 0];
2248
+ };
2249
+ protoOf(GeneratedPath).t1t = function (i, field, v) {
2250
+ this.v1q_1[imul(i, 36) + field.o1_1 | 0] = v;
2251
+ };
2252
+ protoOf(GeneratedPath).w1q = function (i) {
2253
+ return this.v1q_1[imul(i, 36) + 0 | 0];
2254
+ };
2255
+ protoOf(GeneratedPath).n1r = function (i, v) {
2256
+ this.v1q_1[imul(i, 36) + 0 | 0] = v;
2257
+ };
2258
+ protoOf(GeneratedPath).x1q = function (i) {
2259
+ return this.v1q_1[imul(i, 36) + 1 | 0];
2260
+ };
2261
+ protoOf(GeneratedPath).o1r = function (i, v) {
2262
+ this.v1q_1[imul(i, 36) + 1 | 0] = v;
2263
+ };
2264
+ protoOf(GeneratedPath).k1u = function (i) {
2265
+ return this.v1q_1[imul(i, 36) + 2 | 0];
2266
+ };
2267
+ protoOf(GeneratedPath).l1u = function (i, v) {
2268
+ this.v1q_1[imul(i, 36) + 2 | 0] = v;
2269
+ };
2270
+ protoOf(GeneratedPath).m1u = function (i, v) {
2271
+ this.v1q_1[imul(i, 36) + 3 | 0] = v;
2272
+ };
2273
+ protoOf(GeneratedPath).z1q = function (i) {
2274
+ return this.v1q_1[imul(i, 36) + 4 | 0];
2275
+ };
2276
+ protoOf(GeneratedPath).q1r = function (i, v) {
2277
+ this.v1q_1[imul(i, 36) + 4 | 0] = v;
2278
+ };
2279
+ protoOf(GeneratedPath).n1u = function (i) {
2280
+ return this.v1q_1[imul(i, 36) + 5 | 0];
2281
+ };
2282
+ protoOf(GeneratedPath).o1u = function (i, v) {
2283
+ this.v1q_1[imul(i, 36) + 5 | 0] = v;
2284
+ };
2285
+ protoOf(GeneratedPath).p1u = function (i) {
2286
+ return this.v1q_1[imul(i, 36) + 6 | 0];
2287
+ };
2288
+ protoOf(GeneratedPath).q1u = function (i, v) {
2289
+ this.v1q_1[imul(i, 36) + 6 | 0] = v;
2290
+ };
2291
+ protoOf(GeneratedPath).r1u = function (i) {
2292
+ return this.v1q_1[imul(i, 36) + 7 | 0];
2293
+ };
2294
+ protoOf(GeneratedPath).s1u = function (i, v) {
2295
+ this.v1q_1[imul(i, 36) + 7 | 0] = v;
2296
+ };
2297
+ protoOf(GeneratedPath).y1q = function (i) {
2298
+ return this.v1q_1[imul(i, 36) + 8 | 0];
2299
+ };
2300
+ protoOf(GeneratedPath).p1r = function (i, v) {
2301
+ this.v1q_1[imul(i, 36) + 8 | 0] = v;
2302
+ };
2303
+ protoOf(GeneratedPath).t1u = function (i) {
2304
+ return this.v1q_1[imul(i, 36) + 9 | 0];
2305
+ };
2306
+ protoOf(GeneratedPath).u1u = function (i, v) {
2307
+ this.v1q_1[imul(i, 36) + 9 | 0] = v;
2308
+ };
2309
+ protoOf(GeneratedPath).v1u = function (i, v) {
2310
+ this.v1q_1[imul(i, 36) + 10 | 0] = v;
2311
+ };
2312
+ protoOf(GeneratedPath).w1u = function (i, v) {
2313
+ this.v1q_1[imul(i, 36) + 11 | 0] = v;
2314
+ };
2315
+ protoOf(GeneratedPath).x1u = function (i, v) {
2316
+ this.v1q_1[imul(i, 36) + 12 | 0] = v;
2317
+ };
2318
+ protoOf(GeneratedPath).y1u = function (i, v) {
2319
+ this.v1q_1[imul(i, 36) + 13 | 0] = v;
2320
+ };
2321
+ protoOf(GeneratedPath).z1u = function (i, v) {
2322
+ this.v1q_1[imul(i, 36) + 14 | 0] = v;
2323
+ };
2324
+ protoOf(GeneratedPath).a1v = function (i, v) {
2325
+ this.v1q_1[imul(i, 36) + 15 | 0] = v;
2326
+ };
2327
+ protoOf(GeneratedPath).b1v = function (i, v) {
2328
+ this.v1q_1[imul(i, 36) + 16 | 0] = v;
2329
+ };
2330
+ protoOf(GeneratedPath).c1v = function (i, v) {
2331
+ this.v1q_1[imul(i, 36) + 17 | 0] = v;
2332
+ };
2333
+ protoOf(GeneratedPath).d1r = function (i) {
2334
+ return this.v1q_1[imul(i, 36) + 18 | 0];
2335
+ };
2336
+ protoOf(GeneratedPath).r1r = function (i, v) {
2337
+ this.v1q_1[imul(i, 36) + 18 | 0] = v;
2338
+ };
2339
+ protoOf(GeneratedPath).d1v = function (i, v) {
2340
+ this.v1q_1[imul(i, 36) + 19 | 0] = v;
2341
+ };
2342
+ protoOf(GeneratedPath).e1v = function (i, v) {
2343
+ this.v1q_1[imul(i, 36) + 20 | 0] = v;
2344
+ };
2345
+ protoOf(GeneratedPath).f1v = function (i, v) {
2346
+ this.v1q_1[imul(i, 36) + 21 | 0] = v;
2347
+ };
2348
+ protoOf(GeneratedPath).g1v = function (i, v) {
2349
+ this.v1q_1[imul(i, 36) + 22 | 0] = v;
2350
+ };
2351
+ protoOf(GeneratedPath).h1v = function (i, v) {
2352
+ this.v1q_1[imul(i, 36) + 23 | 0] = v;
2353
+ };
2354
+ protoOf(GeneratedPath).i1v = function (i, v) {
2355
+ this.v1q_1[imul(i, 36) + 24 | 0] = v;
2356
+ };
2357
+ protoOf(GeneratedPath).j1v = function (i, v) {
2358
+ this.v1q_1[imul(i, 36) + 25 | 0] = v;
2359
+ };
2360
+ protoOf(GeneratedPath).k1v = function (i) {
2361
+ return this.v1q_1[imul(i, 36) + 26 | 0];
2362
+ };
2363
+ protoOf(GeneratedPath).l1v = function (i, v) {
2364
+ this.v1q_1[imul(i, 36) + 26 | 0] = v;
2365
+ };
2366
+ protoOf(GeneratedPath).m1v = function (i) {
2367
+ return this.v1q_1[imul(i, 36) + 27 | 0];
2368
+ };
2369
+ protoOf(GeneratedPath).n1v = function (i, v) {
2370
+ this.v1q_1[imul(i, 36) + 27 | 0] = v;
2371
+ };
2372
+ protoOf(GeneratedPath).o1v = function (i) {
2373
+ return this.v1q_1[imul(i, 36) + 28 | 0];
2374
+ };
2375
+ protoOf(GeneratedPath).p1v = function (i, v) {
2376
+ this.v1q_1[imul(i, 36) + 28 | 0] = v;
2377
+ };
2378
+ protoOf(GeneratedPath).q1v = function (i, v) {
2379
+ this.v1q_1[imul(i, 36) + 29 | 0] = v;
2380
+ };
2381
+ protoOf(GeneratedPath).r1v = function (i, v) {
2382
+ this.v1q_1[imul(i, 36) + 30 | 0] = v;
2383
+ };
2384
+ protoOf(GeneratedPath).c1r = function (i) {
2385
+ return this.v1q_1[imul(i, 36) + 31 | 0];
2386
+ };
2387
+ protoOf(GeneratedPath).u1r = function (i, v) {
2388
+ this.v1q_1[imul(i, 36) + 31 | 0] = v;
2389
+ };
2390
+ protoOf(GeneratedPath).s1v = function (i, v) {
2391
+ this.v1q_1[imul(i, 36) + 32 | 0] = v;
2392
+ };
2393
+ protoOf(GeneratedPath).t1v = function (i, v) {
2394
+ this.v1q_1[imul(i, 36) + 33 | 0] = v;
2395
+ };
2396
+ protoOf(GeneratedPath).a1r = function (i) {
2397
+ return this.v1q_1[imul(i, 36) + 34 | 0];
2398
+ };
2399
+ protoOf(GeneratedPath).s1r = function (i, v) {
2400
+ this.v1q_1[imul(i, 36) + 34 | 0] = v;
2401
+ };
2402
+ protoOf(GeneratedPath).b1r = function (i) {
2403
+ return this.v1q_1[imul(i, 36) + 35 | 0];
2404
+ };
2405
+ protoOf(GeneratedPath).t1r = function (i, v) {
2406
+ this.v1q_1[imul(i, 36) + 35 | 0] = v;
2407
+ };
2408
+ function Companion_0() {
2409
+ Companion_instance_0 = this;
2410
+ this.u1v_1 = new BoundsRad(0.0, 0.0, 0.0, 0.0);
2411
+ }
2412
+ var Companion_instance_0;
2413
+ function Companion_getInstance_1() {
2414
+ if (Companion_instance_0 == null)
2415
+ new Companion_0();
2416
+ return Companion_instance_0;
2417
+ }
2418
+ function BoundsRad(minLat, maxLat, minLon, maxLon) {
2419
+ Companion_getInstance_1();
2420
+ this.v1v_1 = minLat;
2421
+ this.w1v_1 = maxLat;
2422
+ this.x1v_1 = minLon;
2423
+ this.y1v_1 = maxLon;
2424
+ }
2425
+ protoOf(BoundsRad).toString = function () {
2426
+ return 'BoundsRad(minLat=' + this.v1v_1 + ', maxLat=' + this.w1v_1 + ', minLon=' + this.x1v_1 + ', maxLon=' + this.y1v_1 + ')';
2427
+ };
2428
+ protoOf(BoundsRad).hashCode = function () {
2429
+ var result = getNumberHashCode(this.v1v_1);
2430
+ result = imul(result, 31) + getNumberHashCode(this.w1v_1) | 0;
2431
+ result = imul(result, 31) + getNumberHashCode(this.x1v_1) | 0;
2432
+ result = imul(result, 31) + getNumberHashCode(this.y1v_1) | 0;
2433
+ return result;
2434
+ };
2435
+ protoOf(BoundsRad).equals = function (other) {
2436
+ if (this === other)
2437
+ return true;
2438
+ if (!(other instanceof BoundsRad))
2439
+ return false;
2440
+ if (!equals(this.v1v_1, other.v1v_1))
2441
+ return false;
2442
+ if (!equals(this.w1v_1, other.w1v_1))
2443
+ return false;
2444
+ if (!equals(this.x1v_1, other.x1v_1))
2445
+ return false;
2446
+ if (!equals(this.y1v_1, other.y1v_1))
2447
+ return false;
2448
+ return true;
2449
+ };
2450
+ function copyStatsFrom($this, other) {
2451
+ $this.x1r_1 = other.x1r_1;
2452
+ $this.y1r_1 = other.y1r_1;
2453
+ $this.z1r_1 = other.z1r_1;
2454
+ $this.a1s_1 = other.a1s_1;
2455
+ $this.b1s_1 = other.b1s_1;
2456
+ $this.c1s_1 = other.c1s_1;
2457
+ $this.d1s_1 = other.d1s_1;
2458
+ }
2459
+ function resetStats($this) {
2460
+ $this.x1r_1 = 0.0;
2461
+ $this.y1r_1 = 0.0;
2462
+ $this.z1r_1 = 0.0;
2463
+ $this.a1s_1 = 0.0;
2464
+ $this.b1s_1 = 0.0;
2465
+ $this.c1s_1 = 0.0;
2466
+ $this.d1s_1 = Companion_getInstance_1().u1v_1;
2467
+ }
2468
+ function computeBearing($this, from, to) {
2469
+ var lat1 = $this.w1q(from);
2470
+ var lon1 = $this.x1q(from);
2471
+ var lat2 = $this.w1q(to);
2472
+ var lon2 = $this.x1q(to);
2473
+ // Inline function 'kotlin.math.cos' call
2474
+ var x1 = lon1 * Math.cos(lat1);
2475
+ var y1 = lat1;
2476
+ // Inline function 'kotlin.math.cos' call
2477
+ var x2 = lon2 * Math.cos(lat2);
2478
+ var y2 = lat2;
2479
+ var dy = y2 - y1;
2480
+ var dx = x2 - x1;
2481
+ // Inline function 'kotlin.math.atan2' call
2482
+ var y = -dy;
2483
+ return Math.atan2(y, dx);
2484
+ }
2485
+ function Companion_1() {
2486
+ }
2487
+ var Companion_instance_1;
2488
+ function Companion_getInstance_2() {
2489
+ return Companion_instance_1;
2490
+ }
2491
+ function Path(size) {
2492
+ GeneratedPath.call(this, size);
2493
+ this.x1r_1 = 0.0;
2494
+ this.y1r_1 = 0.0;
2495
+ this.z1r_1 = 0.0;
2496
+ this.a1s_1 = 0.0;
2497
+ this.b1s_1 = 0.0;
2498
+ this.c1s_1 = 0.0;
2499
+ this.d1s_1 = Companion_getInstance_1().u1v_1;
2500
+ }
2501
+ protoOf(Path).z1v = function () {
2502
+ return until(0, this.u1q_1);
2503
+ };
2504
+ protoOf(Path).a1w = function (i) {
2505
+ return this.w1q(i) * MathConstants_getInstance().uw_1;
2506
+ };
2507
+ protoOf(Path).b1w = function (i) {
2508
+ return this.x1q(i) * MathConstants_getInstance().uw_1;
2509
+ };
2510
+ protoOf(Path).i1u = function (i) {
2511
+ return new LatLonElevation(this.a1w(i), this.b1w(i), this.y1q(i));
2512
+ };
2513
+ protoOf(Path).c1w = function () {
2514
+ var out = new Path(this.u1q_1);
2515
+ var tmp0 = this.v1q_1;
2516
+ var tmp2 = out.v1q_1;
2517
+ // Inline function 'kotlin.collections.copyInto' call
2518
+ var endIndex = this.v1q_1.length;
2519
+ // Inline function 'kotlin.js.unsafeCast' call
2520
+ // Inline function 'kotlin.js.asDynamic' call
2521
+ var tmp = tmp0;
2522
+ // Inline function 'kotlin.js.unsafeCast' call
2523
+ // Inline function 'kotlin.js.asDynamic' call
2524
+ arrayCopy(tmp, tmp2, 0, 0, endIndex);
2525
+ copyStatsFrom(out, this);
2526
+ return out;
2527
+ };
2528
+ protoOf(Path).e1s = function () {
2529
+ resetStats(this);
2530
+ if (this.u1q_1 === 0)
2531
+ return Unit_instance;
2532
+ var timeStart = this.z1q(0);
2533
+ var cumDist = 0.0;
2534
+ var minLat = Infinity;
2535
+ var maxLat = -Infinity;
2536
+ var minLon = Infinity;
2537
+ var maxLon = -Infinity;
2538
+ var minEle = Infinity;
2539
+ var maxEle = -Infinity;
2540
+ var gain = 0.0;
2541
+ var loss = 0.0;
2542
+ var inductionVariable = 0;
2543
+ var last = this.u1q_1;
2544
+ if (inductionVariable < last)
2545
+ do {
2546
+ var i = inductionVariable;
2547
+ inductionVariable = inductionVariable + 1 | 0;
2548
+ var lat = this.w1q(i);
2549
+ var lon = this.x1q(i);
2550
+ var ele = this.y1q(i);
2551
+ // Inline function 'kotlin.math.min' call
2552
+ var a = minLat;
2553
+ minLat = Math.min(a, lat);
2554
+ // Inline function 'kotlin.math.max' call
2555
+ var a_0 = maxLat;
2556
+ maxLat = Math.max(a_0, lat);
2557
+ // Inline function 'kotlin.math.min' call
2558
+ var a_1 = minLon;
2559
+ minLon = Math.min(a_1, lon);
2560
+ // Inline function 'kotlin.math.max' call
2561
+ var a_2 = maxLon;
2562
+ maxLon = Math.max(a_2, lon);
2563
+ // Inline function 'kotlin.math.min' call
2564
+ var a_3 = minEle;
2565
+ minEle = Math.min(a_3, ele);
2566
+ // Inline function 'kotlin.math.max' call
2567
+ var a_4 = maxEle;
2568
+ maxEle = Math.max(a_4, ele);
2569
+ if (i > 0) {
2570
+ var prevCoord = new LatLon(this.a1w(i - 1 | 0), this.b1w(i - 1 | 0));
2571
+ var curCoord = new LatLon(this.a1w(i), this.b1w(i));
2572
+ cumDist = cumDist + Distance_instance.rw(prevCoord, curCoord);
2573
+ var dEle = ele - this.y1q(i - 1 | 0);
2574
+ if (dEle > 0)
2575
+ gain = gain + dEle;
2576
+ else
2577
+ loss = loss + dEle;
2578
+ }
2579
+ this.l1u(i, cumDist);
2580
+ }
2581
+ while (inductionVariable < last);
2582
+ this.x1r_1 = cumDist;
2583
+ this.y1r_1 = minEle === Infinity ? 0.0 : minEle;
2584
+ this.z1r_1 = maxEle === -Infinity ? 0.0 : maxEle;
2585
+ this.a1s_1 = gain;
2586
+ this.b1s_1 = loss;
2587
+ this.d1s_1 = new BoundsRad(minLat, maxLat, minLon, maxLon);
2588
+ this.c1s_1 = this.u1q_1 >= 2 ? this.z1q(this.u1q_1 - 1 | 0) - timeStart : 0.0;
2589
+ var inductionVariable_0 = 0;
2590
+ var last_0 = this.u1q_1;
2591
+ if (inductionVariable_0 < last_0)
2592
+ $l$loop: do {
2593
+ var i_0 = inductionVariable_0;
2594
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2595
+ this.o1u(i_0, (this.z1q(i_0) - timeStart) / 1000.0);
2596
+ if (this.u1q_1 <= 1)
2597
+ continue $l$loop;
2598
+ // Inline function 'kotlin.math.max' call
2599
+ var b = i_0 - 1 | 0;
2600
+ var im1 = Math.max(0, b);
2601
+ var tmp0 = this.u1q_1 - 1 | 0;
2602
+ // Inline function 'kotlin.math.min' call
2603
+ var b_0 = i_0 + 1 | 0;
2604
+ var ip1 = Math.min(tmp0, b_0);
2605
+ this.s1u(i_0, computeBearing(this, im1, ip1));
2606
+ var dDist = (this.k1u(ip1) - this.k1u(im1)) / 2.0;
2607
+ var dEle_0 = (this.y1q(ip1) - this.y1q(im1)) / 2.0;
2608
+ var grade = dDist === 0.0 ? 0.0 : dEle_0 / dDist;
2609
+ this.u1u(i_0, grade);
2610
+ var dTime = (this.z1q(ip1) - this.z1q(im1)) / 2000.0;
2611
+ this.m1u(i_0, dDist);
2612
+ this.q1u(i_0, dTime);
2613
+ this.n1v(i_0, dTime === 0.0 ? 0.0 : dDist / dTime);
2614
+ }
2615
+ while (inductionVariable_0 < last_0);
2616
+ };
2617
+ function PathSimplifier() {
2618
+ }
2619
+ protoOf(PathSimplifier).d1w = function (path, toleranceM, zExaggeration) {
2620
+ if (path.u1q_1 <= 2)
2621
+ return path.c1w();
2622
+ var coords = ArrayList_init_$Create$_0(path.u1q_1);
2623
+ var inductionVariable = 0;
2624
+ var last = path.u1q_1;
2625
+ if (inductionVariable < last)
2626
+ do {
2627
+ var i = inductionVariable;
2628
+ inductionVariable = inductionVariable + 1 | 0;
2629
+ // Inline function 'kotlin.collections.plusAssign' call
2630
+ var element = new LatLonElevation(path.w1q(i) * MathConstants_getInstance().uw_1, path.x1q(i) * MathConstants_getInstance().uw_1, path.y1q(i));
2631
+ coords.h(element);
2632
+ }
2633
+ while (inductionVariable < last);
2634
+ var simplified = DouglasPeucker_instance.ow(coords, toleranceM, zExaggeration);
2635
+ var retainedIndices = ArrayList_init_$Create$_0(simplified.l());
2636
+ var cursor = 0;
2637
+ var _iterator__ex2g4s = simplified.i();
2638
+ while (_iterator__ex2g4s.j()) {
2639
+ var kept = _iterator__ex2g4s.k();
2640
+ while (cursor < coords.l() && !(coords.m(cursor) === kept)) {
2641
+ cursor = cursor + 1 | 0;
2642
+ }
2643
+ if (cursor === coords.l()) {
2644
+ // Inline function 'kotlin.error' call
2645
+ var message = 'PathSimplifier: retained point not found in source';
2646
+ throw IllegalStateException_init_$Create$(toString_0(message));
2647
+ }
2648
+ // Inline function 'kotlin.collections.plusAssign' call
2649
+ var element_0 = cursor;
2650
+ retainedIndices.h(element_0);
2651
+ cursor = cursor + 1 | 0;
2652
+ }
2653
+ var out = new Path(retainedIndices.l());
2654
+ var iterator = retainedIndices.i();
2655
+ var index = 0;
2656
+ while (iterator.j()) {
2657
+ var dstIdx = index;
2658
+ index = index + 1 | 0;
2659
+ var srcIdx = iterator.k();
2660
+ var _iterator__ex2g4s_0 = get_entries().i();
2661
+ while (_iterator__ex2g4s_0.j()) {
2662
+ var field = _iterator__ex2g4s_0.k();
2663
+ out.t1t(dstIdx, field, path.m1t(srcIdx, field));
2664
+ }
2665
+ }
2666
+ out.e1s();
2667
+ return out;
2668
+ };
2669
+ var PathSimplifier_instance;
2670
+ function PathSimplifier_getInstance() {
2671
+ return PathSimplifier_instance;
2672
+ }
2673
+ var PointField_LATITUDE_instance;
2674
+ var PointField_LONGITUDE_instance;
2675
+ var PointField_DISTANCE_instance;
2676
+ var PointField_DX_instance;
2677
+ var PointField_TIME_instance;
2678
+ var PointField_ELAPSED_instance;
2679
+ var PointField_DT_instance;
2680
+ var PointField_BEARING_instance;
2681
+ var PointField_ELEVATION_instance;
2682
+ var PointField_GRADE_instance;
2683
+ var PointField_RADIUS_instance;
2684
+ var PointField_AERO_COEF_instance;
2685
+ var PointField_WIND_BEARING_instance;
2686
+ var PointField_WIND_ALPHA_instance;
2687
+ var PointField_P_AERO_instance;
2688
+ var PointField_P_GRAVITY_instance;
2689
+ var PointField_P_ROLLING_RESISTANCE_instance;
2690
+ var PointField_P_WHEEL_BEARINGS_instance;
2691
+ var PointField_P_INPUT_POWER_instance;
2692
+ var PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_instance;
2693
+ var PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_HARMONICS_instance;
2694
+ var PointField_P_CYCLIST_PROVIDED_POWER_NEEDED_instance;
2695
+ var PointField_P_CYCLIST_PROVIDED_MUSCULAR_instance;
2696
+ var PointField_P_CYCLIST_PROVIDED_WHEEL_instance;
2697
+ var PointField_P_COMPUTED_TOTAL_POWER_instance;
2698
+ var PointField_P_COMPUTED_WHEEL_POWER_instance;
2699
+ var PointField_POWER_instance;
2700
+ var PointField_SPEED_instance;
2701
+ var PointField_SPEED_MAX_instance;
2702
+ var PointField_SPEED_MAX_INCLINE_instance;
2703
+ var PointField_VIRT_SPEED_CURRENT_instance;
2704
+ var PointField_TEMPERATURE_instance;
2705
+ var PointField_WIND_SPEED_instance;
2706
+ var PointField_WIND_DIRECTION_instance;
2707
+ var PointField_HEART_RATE_instance;
2708
+ var PointField_CADENCE_instance;
2709
+ function Companion_2() {
2710
+ Companion_instance_2 = this;
2711
+ this.e1w_1 = 36;
2712
+ var tmp = this;
2713
+ // Inline function 'kotlin.collections.associateBy' call
2714
+ var this_0 = get_entries();
2715
+ var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16);
2716
+ // Inline function 'kotlin.collections.associateByTo' call
2717
+ var destination = LinkedHashMap_init_$Create$(capacity);
2718
+ var _iterator__ex2g4s = this_0.i();
2719
+ while (_iterator__ex2g4s.j()) {
2720
+ var element = _iterator__ex2g4s.k();
2721
+ var tmp$ret$2 = element.a1t_1;
2722
+ destination.c3(tmp$ret$2, element);
2723
+ }
2724
+ tmp.f1w_1 = destination;
2725
+ }
2726
+ protoOf(Companion_2).g1w = function (prop) {
2727
+ return this.f1w_1.k1(prop);
2728
+ };
2729
+ var Companion_instance_2;
2730
+ function Companion_getInstance_3() {
2731
+ PointField_initEntries();
2732
+ if (Companion_instance_2 == null)
2733
+ new Companion_2();
2734
+ return Companion_instance_2;
2735
+ }
2736
+ function values() {
2737
+ return [PointField_LATITUDE_getInstance(), PointField_LONGITUDE_getInstance(), PointField_DISTANCE_getInstance(), PointField_DX_getInstance(), PointField_TIME_getInstance(), PointField_ELAPSED_getInstance(), PointField_DT_getInstance(), PointField_BEARING_getInstance(), PointField_ELEVATION_getInstance(), PointField_GRADE_getInstance(), PointField_RADIUS_getInstance(), PointField_AERO_COEF_getInstance(), PointField_WIND_BEARING_getInstance(), PointField_WIND_ALPHA_getInstance(), PointField_P_AERO_getInstance(), PointField_P_GRAVITY_getInstance(), PointField_P_ROLLING_RESISTANCE_getInstance(), PointField_P_WHEEL_BEARINGS_getInstance(), PointField_P_INPUT_POWER_getInstance(), PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_getInstance(), PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_HARMONICS_getInstance(), PointField_P_CYCLIST_PROVIDED_POWER_NEEDED_getInstance(), PointField_P_CYCLIST_PROVIDED_MUSCULAR_getInstance(), PointField_P_CYCLIST_PROVIDED_WHEEL_getInstance(), PointField_P_COMPUTED_TOTAL_POWER_getInstance(), PointField_P_COMPUTED_WHEEL_POWER_getInstance(), PointField_POWER_getInstance(), PointField_SPEED_getInstance(), PointField_SPEED_MAX_getInstance(), PointField_SPEED_MAX_INCLINE_getInstance(), PointField_VIRT_SPEED_CURRENT_getInstance(), PointField_TEMPERATURE_getInstance(), PointField_WIND_SPEED_getInstance(), PointField_WIND_DIRECTION_getInstance(), PointField_HEART_RATE_getInstance(), PointField_CADENCE_getInstance()];
2738
+ }
2739
+ function get_entries() {
2740
+ if ($ENTRIES == null)
2741
+ $ENTRIES = enumEntries(values());
2742
+ return $ENTRIES;
2743
+ }
2744
+ var PointField_entriesInitialized;
2745
+ function PointField_initEntries() {
2746
+ if (PointField_entriesInitialized)
2747
+ return Unit_instance;
2748
+ PointField_entriesInitialized = true;
2749
+ PointField_LATITUDE_instance = new PointField('LATITUDE', 0, 'latitude', 'radians', 'Latitude (radians)', PointFieldCategory_COORDINATES_getInstance(), true, true);
2750
+ PointField_LONGITUDE_instance = new PointField('LONGITUDE', 1, 'longitude', 'radians', 'Longitude (radians)', PointFieldCategory_COORDINATES_getInstance(), true, true);
2751
+ PointField_DISTANCE_instance = new PointField('DISTANCE', 2, 'distance', 'meters', 'Distance (meters)', PointFieldCategory_COORDINATES_getInstance());
2752
+ PointField_DX_instance = new PointField('DX', 3, 'dx', 'meters', 'dx (meters)', PointFieldCategory_COORDINATES_getInstance());
2753
+ PointField_TIME_instance = new PointField('TIME', 4, 'time', 'ms', 'Timestamp (ms since epoch)', PointFieldCategory_TEMPORAL_getInstance(), true);
2754
+ PointField_ELAPSED_instance = new PointField('ELAPSED', 5, 'elapsed', 'ms', 'Elapsed duration (ms)', PointFieldCategory_TEMPORAL_getInstance());
2755
+ PointField_DT_instance = new PointField('DT', 6, 'dt', 'ms', 'dt (ms)', PointFieldCategory_TEMPORAL_getInstance());
2756
+ PointField_BEARING_instance = new PointField('BEARING', 7, 'bearing', 'radians', 'Direction bearing (radians)', PointFieldCategory_ANGLES_getInstance(), VOID, true);
2757
+ PointField_ELEVATION_instance = new PointField('ELEVATION', 8, 'elevation', 'meters', 'Elevation (meters)', PointFieldCategory_ELEVATION_getInstance());
2758
+ PointField_GRADE_instance = new PointField('GRADE', 9, 'grade', '%', 'Road grade/slope (%)', PointFieldCategory_GRADE_getInstance());
2759
+ PointField_RADIUS_instance = new PointField('RADIUS', 10, 'radius', 'meters', 'Turn radius (meters)', PointFieldCategory_RADIUS_getInstance());
2760
+ PointField_AERO_COEF_instance = new PointField('AERO_COEF', 11, 'aeroCoef', 'aero', 'Aerodynamic coefficient', PointFieldCategory_AERO_COEF_getInstance());
2761
+ PointField_WIND_BEARING_instance = new PointField('WIND_BEARING', 12, 'windBearing', 'radians', 'Wind bearing (radians)', PointFieldCategory_CYCLIST_WIND_getInstance(), VOID, true);
2762
+ PointField_WIND_ALPHA_instance = new PointField('WIND_ALPHA', 13, 'windAlpha', 'radians', 'Wind angle (radians)', PointFieldCategory_CYCLIST_WIND_getInstance(), VOID, true);
2763
+ PointField_P_AERO_instance = new PointField('P_AERO', 14, 'pAero', 'watts', 'Aerodynamic power', PointFieldCategory_POWER_PHYSICS_getInstance());
2764
+ PointField_P_GRAVITY_instance = new PointField('P_GRAVITY', 15, 'pGravity', 'watts', 'Gravitational power', PointFieldCategory_POWER_PHYSICS_getInstance());
2765
+ PointField_P_ROLLING_RESISTANCE_instance = new PointField('P_ROLLING_RESISTANCE', 16, 'pRollingResistance', 'watts', 'Rolling resistance power', PointFieldCategory_POWER_PHYSICS_getInstance());
2766
+ PointField_P_WHEEL_BEARINGS_instance = new PointField('P_WHEEL_BEARINGS', 17, 'pWheelBearings', 'watts', 'Wheel bearings power', PointFieldCategory_POWER_PHYSICS_getInstance());
2767
+ PointField_P_INPUT_POWER_instance = new PointField('P_INPUT_POWER', 18, 'pInputPower', 'watts', 'GPX input power', PointFieldCategory_POWER_CYCLIST_getInstance());
2768
+ PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_instance = new PointField('P_CYCLIST_PROVIDED_OPTIMAL_POWER', 19, 'pCyclistProvidedOptimalPower', 'watts', 'Optimal power', PointFieldCategory_POWER_CYCLIST_getInstance());
2769
+ PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_HARMONICS_instance = new PointField('P_CYCLIST_PROVIDED_OPTIMAL_POWER_HARMONICS', 20, 'pCyclistProvidedOptimalPowerWithHarmonics', 'watts', 'Optimal power with harmonics', PointFieldCategory_POWER_CYCLIST_getInstance());
2770
+ PointField_P_CYCLIST_PROVIDED_POWER_NEEDED_instance = new PointField('P_CYCLIST_PROVIDED_POWER_NEEDED', 21, 'pCyclistPowerNeeded', 'watts', 'Power needed', PointFieldCategory_POWER_CYCLIST_getInstance());
2771
+ PointField_P_CYCLIST_PROVIDED_MUSCULAR_instance = new PointField('P_CYCLIST_PROVIDED_MUSCULAR', 22, 'pCyclistProvidedMuscular', 'watts', 'Raw cyclist power', PointFieldCategory_POWER_CYCLIST_getInstance());
2772
+ PointField_P_CYCLIST_PROVIDED_WHEEL_instance = new PointField('P_CYCLIST_PROVIDED_WHEEL', 23, 'pCyclistProvidedWheel', 'watts', 'Cyclist power transmitted to ground', PointFieldCategory_POWER_CYCLIST_getInstance());
2773
+ PointField_P_COMPUTED_TOTAL_POWER_instance = new PointField('P_COMPUTED_TOTAL_POWER', 24, 'pComputedTotalPower', 'watts', 'Power from kinetic energy change', PointFieldCategory_POWER_POST_getInstance());
2774
+ PointField_P_COMPUTED_WHEEL_POWER_instance = new PointField('P_COMPUTED_WHEEL_POWER', 25, 'pComputedWheelPower', 'watts', 'Wheel power from kinetic energy change', PointFieldCategory_POWER_POST_getInstance());
2775
+ PointField_POWER_instance = new PointField('POWER', 26, 'pComputedPower', 'watts', 'Total power (watts)', PointFieldCategory_POWER_POST_getInstance());
2776
+ PointField_SPEED_instance = new PointField('SPEED', 27, 'speed', 'm/s', 'Current speed (m/s)', PointFieldCategory_SPEED_getInstance());
2777
+ PointField_SPEED_MAX_instance = new PointField('SPEED_MAX', 28, 'speedMax', 'm/s', 'Maximum speed (m/s)', PointFieldCategory_SPEED_getInstance());
2778
+ PointField_SPEED_MAX_INCLINE_instance = new PointField('SPEED_MAX_INCLINE', 29, 'speedMaxIncline', 'm/s', 'Max speed on incline (m/s)', PointFieldCategory_SPEED_getInstance());
2779
+ PointField_VIRT_SPEED_CURRENT_instance = new PointField('VIRT_SPEED_CURRENT', 30, 'virtSpeedCurrent', 'm/s', 'Virtual current speed (m/s)', PointFieldCategory_SPEED_getInstance());
2780
+ PointField_TEMPERATURE_instance = new PointField('TEMPERATURE', 31, 'temperature', 'celsius', 'Temperature (celsius)', PointFieldCategory_ENVIRONMENTAL_getInstance());
2781
+ PointField_WIND_SPEED_instance = new PointField('WIND_SPEED', 32, 'windSpeed', 'm/s', 'Wind speed (m/s)', PointFieldCategory_ENVIRONMENTAL_getInstance());
2782
+ PointField_WIND_DIRECTION_instance = new PointField('WIND_DIRECTION', 33, 'windDirection', 'radians', 'Wind direction (radians)', PointFieldCategory_ENVIRONMENTAL_getInstance(), VOID, true);
2783
+ PointField_HEART_RATE_instance = new PointField('HEART_RATE', 34, 'heartRate', 'bpm', 'Heart rate (bpm)', PointFieldCategory_PHYSIOLOGICAL_getInstance());
2784
+ PointField_CADENCE_instance = new PointField('CADENCE', 35, 'cadence', 'rpm', 'Pedaling cadence (rpm)', PointFieldCategory_PHYSIOLOGICAL_getInstance());
2785
+ Companion_getInstance_3();
2786
+ }
2787
+ var $ENTRIES;
2788
+ function PointField(name, ordinal, prop, unit, shortDescription, category, notSelectable, anglesInRadians) {
2789
+ notSelectable = notSelectable === VOID ? false : notSelectable;
2790
+ anglesInRadians = anglesInRadians === VOID ? false : anglesInRadians;
2791
+ Enum.call(this, name, ordinal);
2792
+ this.a1t_1 = prop;
2793
+ this.b1t_1 = unit;
2794
+ this.c1t_1 = shortDescription;
2795
+ this.d1t_1 = category;
2796
+ this.e1t_1 = notSelectable;
2797
+ this.f1t_1 = anglesInRadians;
2798
+ }
2799
+ function PointField_LATITUDE_getInstance() {
2800
+ PointField_initEntries();
2801
+ return PointField_LATITUDE_instance;
2802
+ }
2803
+ function PointField_LONGITUDE_getInstance() {
2804
+ PointField_initEntries();
2805
+ return PointField_LONGITUDE_instance;
2806
+ }
2807
+ function PointField_DISTANCE_getInstance() {
2808
+ PointField_initEntries();
2809
+ return PointField_DISTANCE_instance;
2810
+ }
2811
+ function PointField_DX_getInstance() {
2812
+ PointField_initEntries();
2813
+ return PointField_DX_instance;
2814
+ }
2815
+ function PointField_TIME_getInstance() {
2816
+ PointField_initEntries();
2817
+ return PointField_TIME_instance;
2818
+ }
2819
+ function PointField_ELAPSED_getInstance() {
2820
+ PointField_initEntries();
2821
+ return PointField_ELAPSED_instance;
2822
+ }
2823
+ function PointField_DT_getInstance() {
2824
+ PointField_initEntries();
2825
+ return PointField_DT_instance;
2826
+ }
2827
+ function PointField_BEARING_getInstance() {
2828
+ PointField_initEntries();
2829
+ return PointField_BEARING_instance;
2830
+ }
2831
+ function PointField_ELEVATION_getInstance() {
2832
+ PointField_initEntries();
2833
+ return PointField_ELEVATION_instance;
2834
+ }
2835
+ function PointField_GRADE_getInstance() {
2836
+ PointField_initEntries();
2837
+ return PointField_GRADE_instance;
2838
+ }
2839
+ function PointField_RADIUS_getInstance() {
2840
+ PointField_initEntries();
2841
+ return PointField_RADIUS_instance;
2842
+ }
2843
+ function PointField_AERO_COEF_getInstance() {
2844
+ PointField_initEntries();
2845
+ return PointField_AERO_COEF_instance;
2846
+ }
2847
+ function PointField_WIND_BEARING_getInstance() {
2848
+ PointField_initEntries();
2849
+ return PointField_WIND_BEARING_instance;
2850
+ }
2851
+ function PointField_WIND_ALPHA_getInstance() {
2852
+ PointField_initEntries();
2853
+ return PointField_WIND_ALPHA_instance;
2854
+ }
2855
+ function PointField_P_AERO_getInstance() {
2856
+ PointField_initEntries();
2857
+ return PointField_P_AERO_instance;
2858
+ }
2859
+ function PointField_P_GRAVITY_getInstance() {
2860
+ PointField_initEntries();
2861
+ return PointField_P_GRAVITY_instance;
2862
+ }
2863
+ function PointField_P_ROLLING_RESISTANCE_getInstance() {
2864
+ PointField_initEntries();
2865
+ return PointField_P_ROLLING_RESISTANCE_instance;
2866
+ }
2867
+ function PointField_P_WHEEL_BEARINGS_getInstance() {
2868
+ PointField_initEntries();
2869
+ return PointField_P_WHEEL_BEARINGS_instance;
2870
+ }
2871
+ function PointField_P_INPUT_POWER_getInstance() {
2872
+ PointField_initEntries();
2873
+ return PointField_P_INPUT_POWER_instance;
2874
+ }
2875
+ function PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_getInstance() {
2876
+ PointField_initEntries();
2877
+ return PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_instance;
2878
+ }
2879
+ function PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_HARMONICS_getInstance() {
2880
+ PointField_initEntries();
2881
+ return PointField_P_CYCLIST_PROVIDED_OPTIMAL_POWER_HARMONICS_instance;
2882
+ }
2883
+ function PointField_P_CYCLIST_PROVIDED_POWER_NEEDED_getInstance() {
2884
+ PointField_initEntries();
2885
+ return PointField_P_CYCLIST_PROVIDED_POWER_NEEDED_instance;
2886
+ }
2887
+ function PointField_P_CYCLIST_PROVIDED_MUSCULAR_getInstance() {
2888
+ PointField_initEntries();
2889
+ return PointField_P_CYCLIST_PROVIDED_MUSCULAR_instance;
2890
+ }
2891
+ function PointField_P_CYCLIST_PROVIDED_WHEEL_getInstance() {
2892
+ PointField_initEntries();
2893
+ return PointField_P_CYCLIST_PROVIDED_WHEEL_instance;
2894
+ }
2895
+ function PointField_P_COMPUTED_TOTAL_POWER_getInstance() {
2896
+ PointField_initEntries();
2897
+ return PointField_P_COMPUTED_TOTAL_POWER_instance;
2898
+ }
2899
+ function PointField_P_COMPUTED_WHEEL_POWER_getInstance() {
2900
+ PointField_initEntries();
2901
+ return PointField_P_COMPUTED_WHEEL_POWER_instance;
2902
+ }
2903
+ function PointField_POWER_getInstance() {
2904
+ PointField_initEntries();
2905
+ return PointField_POWER_instance;
2906
+ }
2907
+ function PointField_SPEED_getInstance() {
2908
+ PointField_initEntries();
2909
+ return PointField_SPEED_instance;
2910
+ }
2911
+ function PointField_SPEED_MAX_getInstance() {
2912
+ PointField_initEntries();
2913
+ return PointField_SPEED_MAX_instance;
2914
+ }
2915
+ function PointField_SPEED_MAX_INCLINE_getInstance() {
2916
+ PointField_initEntries();
2917
+ return PointField_SPEED_MAX_INCLINE_instance;
2918
+ }
2919
+ function PointField_VIRT_SPEED_CURRENT_getInstance() {
2920
+ PointField_initEntries();
2921
+ return PointField_VIRT_SPEED_CURRENT_instance;
2922
+ }
2923
+ function PointField_TEMPERATURE_getInstance() {
2924
+ PointField_initEntries();
2925
+ return PointField_TEMPERATURE_instance;
2926
+ }
2927
+ function PointField_WIND_SPEED_getInstance() {
2928
+ PointField_initEntries();
2929
+ return PointField_WIND_SPEED_instance;
2930
+ }
2931
+ function PointField_WIND_DIRECTION_getInstance() {
2932
+ PointField_initEntries();
2933
+ return PointField_WIND_DIRECTION_instance;
2934
+ }
2935
+ function PointField_HEART_RATE_getInstance() {
2936
+ PointField_initEntries();
2937
+ return PointField_HEART_RATE_instance;
2938
+ }
2939
+ function PointField_CADENCE_getInstance() {
2940
+ PointField_initEntries();
2941
+ return PointField_CADENCE_instance;
2942
+ }
2943
+ var PointFieldCategory_COORDINATES_instance;
2944
+ var PointFieldCategory_TEMPORAL_instance;
2945
+ var PointFieldCategory_ANGLES_instance;
2946
+ var PointFieldCategory_ELEVATION_instance;
2947
+ var PointFieldCategory_GRADE_instance;
2948
+ var PointFieldCategory_RADIUS_instance;
2949
+ var PointFieldCategory_AERO_COEF_instance;
2950
+ var PointFieldCategory_CYCLIST_WIND_instance;
2951
+ var PointFieldCategory_POWER_PHYSICS_instance;
2952
+ var PointFieldCategory_POWER_CYCLIST_instance;
2953
+ var PointFieldCategory_POWER_POST_instance;
2954
+ var PointFieldCategory_SPEED_instance;
2955
+ var PointFieldCategory_ENVIRONMENTAL_instance;
2956
+ var PointFieldCategory_PHYSIOLOGICAL_instance;
2957
+ var PointFieldCategory_entriesInitialized;
2958
+ function PointFieldCategory_initEntries() {
2959
+ if (PointFieldCategory_entriesInitialized)
2960
+ return Unit_instance;
2961
+ PointFieldCategory_entriesInitialized = true;
2962
+ PointFieldCategory_COORDINATES_instance = new PointFieldCategory('COORDINATES', 0, 'coordinates', 'Coordinates');
2963
+ PointFieldCategory_TEMPORAL_instance = new PointFieldCategory('TEMPORAL', 1, 'temporal', 'Temporal');
2964
+ PointFieldCategory_ANGLES_instance = new PointFieldCategory('ANGLES', 2, 'angles', 'Angles');
2965
+ PointFieldCategory_ELEVATION_instance = new PointFieldCategory('ELEVATION', 3, 'elevation', '\uD83C\uDFD4\uFE0F Elevation');
2966
+ PointFieldCategory_GRADE_instance = new PointFieldCategory('GRADE', 4, 'grade', '\uD83D\uDCD0 Grade');
2967
+ PointFieldCategory_RADIUS_instance = new PointFieldCategory('RADIUS', 5, 'radius', 'Radius');
2968
+ PointFieldCategory_AERO_COEF_instance = new PointFieldCategory('AERO_COEF', 6, 'aero_coef', 'Aero coef');
2969
+ PointFieldCategory_CYCLIST_WIND_instance = new PointFieldCategory('CYCLIST_WIND', 7, 'cyclist_wind', 'Cyclist wind');
2970
+ PointFieldCategory_POWER_PHYSICS_instance = new PointFieldCategory('POWER_PHYSICS', 8, 'power_physics', '\u26A1 Power Physics');
2971
+ PointFieldCategory_POWER_CYCLIST_instance = new PointFieldCategory('POWER_CYCLIST', 9, 'power_cyclist', '\u26A1 Power Cyclist');
2972
+ PointFieldCategory_POWER_POST_instance = new PointFieldCategory('POWER_POST', 10, 'power_post', '\u26A1 Power Post processed');
2973
+ PointFieldCategory_SPEED_instance = new PointFieldCategory('SPEED', 11, 'speed', 'Speed & Motion');
2974
+ PointFieldCategory_ENVIRONMENTAL_instance = new PointFieldCategory('ENVIRONMENTAL', 12, 'environmental', 'Environmental');
2975
+ PointFieldCategory_PHYSIOLOGICAL_instance = new PointFieldCategory('PHYSIOLOGICAL', 13, 'physiological', 'Physiological');
2976
+ }
2977
+ function PointFieldCategory(name, ordinal, id, displayName) {
2978
+ Enum.call(this, name, ordinal);
2979
+ this.j1w_1 = id;
2980
+ this.k1w_1 = displayName;
2981
+ }
2982
+ function PointFieldCategory_COORDINATES_getInstance() {
2983
+ PointFieldCategory_initEntries();
2984
+ return PointFieldCategory_COORDINATES_instance;
2985
+ }
2986
+ function PointFieldCategory_TEMPORAL_getInstance() {
2987
+ PointFieldCategory_initEntries();
2988
+ return PointFieldCategory_TEMPORAL_instance;
2989
+ }
2990
+ function PointFieldCategory_ANGLES_getInstance() {
2991
+ PointFieldCategory_initEntries();
2992
+ return PointFieldCategory_ANGLES_instance;
2993
+ }
2994
+ function PointFieldCategory_ELEVATION_getInstance() {
2995
+ PointFieldCategory_initEntries();
2996
+ return PointFieldCategory_ELEVATION_instance;
2997
+ }
2998
+ function PointFieldCategory_GRADE_getInstance() {
2999
+ PointFieldCategory_initEntries();
3000
+ return PointFieldCategory_GRADE_instance;
3001
+ }
3002
+ function PointFieldCategory_RADIUS_getInstance() {
3003
+ PointFieldCategory_initEntries();
3004
+ return PointFieldCategory_RADIUS_instance;
3005
+ }
3006
+ function PointFieldCategory_AERO_COEF_getInstance() {
3007
+ PointFieldCategory_initEntries();
3008
+ return PointFieldCategory_AERO_COEF_instance;
3009
+ }
3010
+ function PointFieldCategory_CYCLIST_WIND_getInstance() {
3011
+ PointFieldCategory_initEntries();
3012
+ return PointFieldCategory_CYCLIST_WIND_instance;
3013
+ }
3014
+ function PointFieldCategory_POWER_PHYSICS_getInstance() {
3015
+ PointFieldCategory_initEntries();
3016
+ return PointFieldCategory_POWER_PHYSICS_instance;
3017
+ }
3018
+ function PointFieldCategory_POWER_CYCLIST_getInstance() {
3019
+ PointFieldCategory_initEntries();
3020
+ return PointFieldCategory_POWER_CYCLIST_instance;
3021
+ }
3022
+ function PointFieldCategory_POWER_POST_getInstance() {
3023
+ PointFieldCategory_initEntries();
3024
+ return PointFieldCategory_POWER_POST_instance;
3025
+ }
3026
+ function PointFieldCategory_SPEED_getInstance() {
3027
+ PointFieldCategory_initEntries();
3028
+ return PointFieldCategory_SPEED_instance;
3029
+ }
3030
+ function PointFieldCategory_ENVIRONMENTAL_getInstance() {
3031
+ PointFieldCategory_initEntries();
3032
+ return PointFieldCategory_ENVIRONMENTAL_instance;
3033
+ }
3034
+ function PointFieldCategory_PHYSIOLOGICAL_getInstance() {
3035
+ PointFieldCategory_initEntries();
3036
+ return PointFieldCategory_PHYSIOLOGICAL_instance;
3037
+ }
3038
+ function Copy(sourceIndex) {
3039
+ this.l1w_1 = sourceIndex;
3040
+ }
3041
+ protoOf(Copy).toString = function () {
3042
+ return 'Copy(sourceIndex=' + this.l1w_1 + ')';
3043
+ };
3044
+ protoOf(Copy).hashCode = function () {
3045
+ return this.l1w_1;
3046
+ };
3047
+ protoOf(Copy).equals = function (other) {
3048
+ if (this === other)
3049
+ return true;
3050
+ if (!(other instanceof Copy))
3051
+ return false;
3052
+ if (!(this.l1w_1 === other.l1w_1))
3053
+ return false;
3054
+ return true;
3055
+ };
3056
+ function Interpolate(from, to, coef) {
3057
+ this.m1w_1 = from;
3058
+ this.n1w_1 = to;
3059
+ this.o1w_1 = coef;
3060
+ }
3061
+ protoOf(Interpolate).toString = function () {
3062
+ return 'Interpolate(from=' + this.m1w_1 + ', to=' + this.n1w_1 + ', coef=' + this.o1w_1 + ')';
3063
+ };
3064
+ protoOf(Interpolate).hashCode = function () {
3065
+ var result = this.m1w_1;
3066
+ result = imul(result, 31) + this.n1w_1 | 0;
3067
+ result = imul(result, 31) + getNumberHashCode(this.o1w_1) | 0;
3068
+ return result;
3069
+ };
3070
+ protoOf(Interpolate).equals = function (other) {
3071
+ if (this === other)
3072
+ return true;
3073
+ if (!(other instanceof Interpolate))
3074
+ return false;
3075
+ if (!(this.m1w_1 === other.m1w_1))
3076
+ return false;
3077
+ if (!(this.n1w_1 === other.n1w_1))
3078
+ return false;
3079
+ if (!equals(this.o1w_1, other.o1w_1))
3080
+ return false;
3081
+ return true;
3082
+ };
3083
+ function buildPlan($this, source, minDistanceM, maxDistanceM) {
3084
+ var n = source.u1q_1;
3085
+ var plan = ArrayList_init_$Create$_0(n);
3086
+ // Inline function 'kotlin.collections.plusAssign' call
3087
+ var element = new Copy(0);
3088
+ plan.h(element);
3089
+ var lastAddedDistance = source.k1u(0);
3090
+ var lastAddedIndex = 0;
3091
+ var inductionVariable = 1;
3092
+ if (inductionVariable < n)
3093
+ $l$loop: do {
3094
+ var i = inductionVariable;
3095
+ inductionVariable = inductionVariable + 1 | 0;
3096
+ var curDist = source.k1u(i);
3097
+ var gap = curDist - lastAddedDistance;
3098
+ if (gap < minDistanceM)
3099
+ continue $l$loop;
3100
+ else if (gap <= maxDistanceM) {
3101
+ // Inline function 'kotlin.collections.plusAssign' call
3102
+ var element_0 = new Copy(i);
3103
+ plan.h(element_0);
3104
+ lastAddedDistance = curDist;
3105
+ lastAddedIndex = i;
3106
+ } else {
3107
+ // Inline function 'kotlin.math.ceil' call
3108
+ var x = gap / maxDistanceM;
3109
+ var tmp$ret$2 = Math.ceil(x);
3110
+ var numSegments = numberToInt(tmp$ret$2);
3111
+ var spacing = gap / numSegments;
3112
+ var index1 = lastAddedIndex;
3113
+ var inductionVariable_0 = 1;
3114
+ if (inductionVariable_0 < numSegments)
3115
+ do {
3116
+ var j = inductionVariable_0;
3117
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3118
+ var targetDistance = lastAddedDistance + j * spacing;
3119
+ while (index1 < (i - 1 | 0) && source.k1u(index1 + 1 | 0) < targetDistance) {
3120
+ index1 = index1 + 1 | 0;
3121
+ }
3122
+ var dist1 = source.k1u(index1);
3123
+ var dist2 = source.k1u(index1 + 1 | 0);
3124
+ var coef = (targetDistance - dist1) / (dist2 - dist1);
3125
+ // Inline function 'kotlin.collections.plusAssign' call
3126
+ var element_1 = new Interpolate(index1, index1 + 1 | 0, coef);
3127
+ plan.h(element_1);
3128
+ }
3129
+ while (inductionVariable_0 < numSegments);
3130
+ // Inline function 'kotlin.collections.plusAssign' call
3131
+ var element_2 = new Copy(i);
3132
+ plan.h(element_2);
3133
+ lastAddedDistance = curDist;
3134
+ lastAddedIndex = i;
3135
+ }
3136
+ }
3137
+ while (inductionVariable < n);
3138
+ return plan;
3139
+ }
3140
+ function materialize($this, source, plan) {
3141
+ var out = new Path(plan.l());
3142
+ var iterator = plan.i();
3143
+ var index = 0;
3144
+ while (iterator.j()) {
3145
+ var dstIdx = index;
3146
+ index = index + 1 | 0;
3147
+ var op = iterator.k();
3148
+ if (op instanceof Copy) {
3149
+ copyFields($this, source, op.l1w_1, out, dstIdx);
3150
+ } else {
3151
+ if (op instanceof Interpolate) {
3152
+ interpolateFields($this, source, op.m1w_1, op.n1w_1, op.o1w_1, out, dstIdx);
3153
+ } else {
3154
+ noWhenBranchMatchedException();
3155
+ }
3156
+ }
3157
+ }
3158
+ out.e1s();
3159
+ return out;
3160
+ }
3161
+ function copyFields($this, src, srcIdx, dst, dstIdx) {
3162
+ var _iterator__ex2g4s = get_entries().i();
3163
+ while (_iterator__ex2g4s.j()) {
3164
+ var field = _iterator__ex2g4s.k();
3165
+ dst.t1t(dstIdx, field, src.m1t(srcIdx, field));
3166
+ }
3167
+ }
3168
+ function interpolateFields($this, src, i1, i2, coef, dst, dstIdx) {
3169
+ var _iterator__ex2g4s = get_entries().i();
3170
+ while (_iterator__ex2g4s.j()) {
3171
+ var field = _iterator__ex2g4s.k();
3172
+ var v1 = src.m1t(i1, field);
3173
+ var v2 = src.m1t(i2, field);
3174
+ var v = isNaN_0(v1) || isNaN_0(v2) ? NaN : v1 + (v2 - v1) * coef;
3175
+ dst.t1t(dstIdx, field, v);
3176
+ }
3177
+ }
3178
+ function PointPerDistance() {
3179
+ }
3180
+ protoOf(PointPerDistance).p1w = function (source, minDistanceM, maxDistanceM) {
3181
+ return this.q1w(source, minDistanceM, maxDistanceM);
3182
+ };
3183
+ protoOf(PointPerDistance).q1w = function (source, minDistanceM, maxDistanceM) {
3184
+ // Inline function 'kotlin.require' call
3185
+ if (!(maxDistanceM > 0.0)) {
3186
+ var message = 'maxDistanceM must be > 0, got ' + maxDistanceM;
3187
+ throw IllegalArgumentException_init_$Create$_0(toString_0(message));
3188
+ }
3189
+ if (source.u1q_1 === 0)
3190
+ return new Path(0);
3191
+ if (source.u1q_1 === 1) {
3192
+ var out = new Path(1);
3193
+ copyFields(this, source, 0, out, 0);
3194
+ out.e1s();
3195
+ return out;
3196
+ }
3197
+ var plan = buildPlan(this, source, minDistanceM, maxDistanceM);
3198
+ return materialize(this, source, plan);
3199
+ };
3200
+ var PointPerDistance_instance;
3201
+ function PointPerDistance_getInstance() {
3202
+ return PointPerDistance_instance;
3203
+ }
3204
+ function Copy_0(sourceIndex) {
3205
+ this.r1w_1 = sourceIndex;
3206
+ }
3207
+ protoOf(Copy_0).toString = function () {
3208
+ return 'Copy(sourceIndex=' + this.r1w_1 + ')';
3209
+ };
3210
+ protoOf(Copy_0).hashCode = function () {
3211
+ return this.r1w_1;
3212
+ };
3213
+ protoOf(Copy_0).equals = function (other) {
3214
+ if (this === other)
3215
+ return true;
3216
+ if (!(other instanceof Copy_0))
3217
+ return false;
3218
+ if (!(this.r1w_1 === other.r1w_1))
3219
+ return false;
3220
+ return true;
3221
+ };
3222
+ function Interpolate_0(from, to, coef) {
3223
+ this.s1w_1 = from;
3224
+ this.t1w_1 = to;
3225
+ this.u1w_1 = coef;
3226
+ }
3227
+ protoOf(Interpolate_0).toString = function () {
3228
+ return 'Interpolate(from=' + this.s1w_1 + ', to=' + this.t1w_1 + ', coef=' + this.u1w_1 + ')';
3229
+ };
3230
+ protoOf(Interpolate_0).hashCode = function () {
3231
+ var result = this.s1w_1;
3232
+ result = imul(result, 31) + this.t1w_1 | 0;
3233
+ result = imul(result, 31) + getNumberHashCode(this.u1w_1) | 0;
3234
+ return result;
3235
+ };
3236
+ protoOf(Interpolate_0).equals = function (other) {
3237
+ if (this === other)
3238
+ return true;
3239
+ if (!(other instanceof Interpolate_0))
3240
+ return false;
3241
+ if (!(this.s1w_1 === other.s1w_1))
3242
+ return false;
3243
+ if (!(this.t1w_1 === other.t1w_1))
3244
+ return false;
3245
+ if (!equals(this.u1w_1, other.u1w_1))
3246
+ return false;
3247
+ return true;
3248
+ };
3249
+ function buildPlan_0($this, source) {
3250
+ var plan = LinkedHashMap_init_$Create$_0();
3251
+ var n = source.u1q_1;
3252
+ var inductionVariable = 0;
3253
+ if (inductionVariable < n)
3254
+ $l$loop_0: do {
3255
+ var i = inductionVariable;
3256
+ inductionVariable = inductionVariable + 1 | 0;
3257
+ var time1 = source.z1q(i);
3258
+ // Inline function 'kotlin.math.floor' call
3259
+ var x = time1 / 1000.0;
3260
+ var tmp$ret$0 = Math.floor(x);
3261
+ var epoch1 = numberToLong(tmp$ret$0);
3262
+ var msInSec1 = subtract(numberToLong(time1), multiply(epoch1, new Long(1000, 0)));
3263
+ if (i === 0 && !equalsLong(msInSec1, new Long(0, 0))) {
3264
+ // Inline function 'kotlin.collections.set' call
3265
+ var value = new Copy_0(i);
3266
+ plan.c3(epoch1, value);
3267
+ }
3268
+ if (i === (n - 1 | 0)) {
3269
+ if (!equalsLong(msInSec1, new Long(0, 0))) {
3270
+ var tmp2 = add(epoch1, new Long(1, 0));
3271
+ // Inline function 'kotlin.collections.set' call
3272
+ var value_0 = new Copy_0(i);
3273
+ plan.c3(tmp2, value_0);
3274
+ }
3275
+ continue $l$loop_0;
3276
+ }
3277
+ var time2 = source.z1q(i + 1 | 0);
3278
+ // Inline function 'kotlin.math.floor' call
3279
+ var x_0 = time2 / 1000.0;
3280
+ var tmp$ret$3 = Math.floor(x_0);
3281
+ var epoch2 = numberToLong(tmp$ret$3);
3282
+ if (equalsLong(epoch1, epoch2))
3283
+ continue $l$loop_0;
3284
+ var duration12 = time2 - time1;
3285
+ var epochStart = equalsLong(msInSec1, new Long(0, 0)) ? epoch1 : add(epoch1, new Long(1, 0));
3286
+ var epochEnd = epoch2;
3287
+ var e = epochStart;
3288
+ while (compare(e, epochEnd) <= 0) {
3289
+ // Inline function 'kotlin.Long.times' call
3290
+ var this_0 = e;
3291
+ var epochTime = toNumber(this_0) * 1000.0;
3292
+ var coef = (epochTime - time1) / duration12;
3293
+ var tmp2_0 = e;
3294
+ // Inline function 'kotlin.collections.set' call
3295
+ var value_1 = new Interpolate_0(i, i + 1 | 0, coef);
3296
+ plan.c3(tmp2_0, value_1);
3297
+ var _unary__edvuaz = e;
3298
+ e = add(_unary__edvuaz, get_ONE());
3299
+ }
3300
+ }
3301
+ while (inductionVariable < n);
3302
+ return plan;
3303
+ }
3304
+ function materialize_0($this, source, plan) {
3305
+ var sortedEpochs = sorted(plan.l1());
3306
+ var out = new Path(sortedEpochs.l());
3307
+ var iterator = sortedEpochs.i();
3308
+ var index = 0;
3309
+ $l$loop: while (iterator.j()) {
3310
+ var idx = index;
3311
+ index = index + 1 | 0;
3312
+ var epoch = iterator.k();
3313
+ var tmp0_elvis_lhs = plan.k1(epoch);
3314
+ var tmp;
3315
+ if (tmp0_elvis_lhs == null) {
3316
+ continue $l$loop;
3317
+ } else {
3318
+ tmp = tmp0_elvis_lhs;
3319
+ }
3320
+ var data = tmp;
3321
+ if (data instanceof Copy_0) {
3322
+ copyFields_0($this, source, data.r1w_1, out, idx);
3323
+ } else {
3324
+ if (data instanceof Interpolate_0) {
3325
+ interpolateFields_0($this, source, data.s1w_1, data.t1w_1, data.u1w_1, out, idx);
3326
+ } else {
3327
+ noWhenBranchMatchedException();
3328
+ }
3329
+ }
3330
+ out.q1r(idx, toNumber(multiply(epoch, new Long(1000, 0))));
3331
+ }
3332
+ out.e1s();
3333
+ return out;
3334
+ }
3335
+ function copyFields_0($this, src, srcIdx, dst, dstIdx) {
3336
+ var _iterator__ex2g4s = get_entries().i();
3337
+ while (_iterator__ex2g4s.j()) {
3338
+ var field = _iterator__ex2g4s.k();
3339
+ dst.t1t(dstIdx, field, src.m1t(srcIdx, field));
3340
+ }
3341
+ }
3342
+ function interpolateFields_0($this, src, i1, i2, coef, dst, dstIdx) {
3343
+ var _iterator__ex2g4s = get_entries().i();
3344
+ while (_iterator__ex2g4s.j()) {
3345
+ var field = _iterator__ex2g4s.k();
3346
+ var v1 = src.m1t(i1, field);
3347
+ var v2 = src.m1t(i2, field);
3348
+ var v = isNaN_0(v1) || isNaN_0(v2) ? NaN : v1 + (v2 - v1) * coef;
3349
+ dst.t1t(dstIdx, field, v);
3350
+ }
3351
+ }
3352
+ function PointPerSecond() {
3353
+ }
3354
+ protoOf(PointPerSecond).v1w = function (source) {
3355
+ if (source.u1q_1 === 0)
3356
+ return new Path(0);
3357
+ var plan = buildPlan_0(this, source);
3358
+ return materialize_0(this, source, plan);
3359
+ };
3360
+ var PointPerSecond_instance;
3361
+ function PointPerSecond_getInstance() {
3362
+ return PointPerSecond_instance;
3363
+ }
3364
+ //region block: init
3365
+ Companion_instance = new Companion();
3366
+ GpxParser_instance = new GpxParser();
3367
+ GpxWriter_instance = new GpxWriter();
3368
+ CsvWriter_instance = new CsvWriter();
3369
+ JsonWriter_instance = new JsonWriter();
3370
+ ElevationStep_instance = new ElevationStep();
3371
+ Companion_instance_1 = new Companion_1();
3372
+ PathSimplifier_instance = new PathSimplifier();
3373
+ PointPerDistance_instance = new PointPerDistance();
3374
+ PointPerSecond_instance = new PointPerSecond();
3375
+ //endregion
3376
+ //region block: exports
3377
+ _.$_$ = _.$_$ || {};
3378
+ _.$_$.a = GpxParser_instance;
3379
+ _.$_$.b = GpxWriter_instance;
3380
+ _.$_$.c = CsvWriter_instance;
3381
+ _.$_$.d = JsonWriter_instance;
3382
+ _.$_$.e = ElevationStep_instance;
3383
+ _.$_$.f = PathSimplifier_instance;
3384
+ _.$_$.g = Companion_getInstance_3;
3385
+ _.$_$.h = PointPerDistance_instance;
3386
+ _.$_$.i = PointPerSecond_instance;
3387
+ _.$_$.j = PointField_TEMPERATURE_getInstance;
3388
+ _.$_$.k = GpxWaypoint;
3389
+ _.$_$.l = firstTrackAsPath;
3390
+ _.$_$.m = segmentsAsPaths;
3391
+ _.$_$.n = toGpxDocument;
3392
+ _.$_$.o = tracksAsPaths;
3393
+ _.$_$.p = CsvOptions;
3394
+ _.$_$.q = JsonOptions;
3395
+ _.$_$.r = Path;
3396
+ _.$_$.s = get_entries;
3397
+ //endregion
3398
+ return _;
3399
+ }));
3400
+
3401
+ //# sourceMappingURL=vcyclist-gpx.js.map