@m4l/gclick-realtime 1.4.0 → 1.5.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.
@@ -1,26 +1,34 @@
1
- import { getVptValueWithGuard as P } from "../../payload/getVptValueWithGuard.js";
2
- import { GNSSEnumSignal as y, GNSSEnumMotionStatus as u, ADCPowerEnum as T } from "../../contracts/constants.js";
3
- import { calculateDistanceMeters as z, calculatePolylineDistanceMeters as ie, resolveFrameSpeedKph as oe, interpolateCoordinate as ae, calculateCourseDegrees as re } from "../shared/helpers.js";
4
- import { createRealTimeDummySimulationConfigFromPreset as le, REAL_TIME_DUMMY_SIMULATION_PRESETS as ue } from "../catalogs/presets.js";
5
- import { REAL_TIME_DUMMY_DEFAULT_SCENARIO_ID as ce, REAL_TIME_DUMMY_SCENARIOS as N, REAL_TIME_DUMMY_DEFAULT_PLAYBACK as R } from "../catalogs/scenarios.js";
6
- import S from "../../node_modules/lodash-es/cloneDeep.js";
7
- import { REAL_TIME_DUMMY_ROUTE_TEMPLATES as x } from "../catalogs/routes.js";
8
- import { REAL_TIME_DUMMY_EXECUTION_PLANS as F } from "../catalogs/plans.js";
9
- import { REAL_TIME_DUMMY_DEVICE_BLUEPRINTS as K } from "../catalogs/blueprints.js";
10
- import w from "../../node_modules/lodash-es/merge.js";
11
- import { REAL_TIME_DUMMY_DEFAULT_ICON_ID as de, REAL_TIME_DUMMY_BASE_DEVICE_TEMPLATE as pe } from "../catalogs/baseDeviceTemplate.js";
12
- import E from "../../node_modules/lodash-es/unset.js";
13
- const _ = Date.parse("2026-04-21T12:00:00.000Z"), J = [
1
+ import { getVptValueWithGuard as b } from "../../payload/getVptValueWithGuard.js";
2
+ import { GNSSEnumSignal as T, ADCPowerEnum as D, GNSSEnumMotionStatus as p } from "../../contracts/constants.js";
3
+ import { calculateDistanceMeters as J, calculatePolylineDistanceMeters as ie, resolveFrameSpeedKph as oe, interpolateCoordinate as re, calculateCourseDegrees as ue } from "../shared/helpers.js";
4
+ import { createRealTimeDummySimulationConfigFromPreset as ce, REAL_TIME_DUMMY_SIMULATION_PRESETS as le } from "../catalogs/presets.js";
5
+ import { REAL_TIME_DUMMY_DEFAULT_SCENARIO_ID as de, REAL_TIME_DUMMY_SCENARIOS as U, REAL_TIME_DUMMY_DEFAULT_PLAYBACK as k } from "../catalogs/scenarios.js";
6
+ import E from "../../node_modules/lodash-es/cloneDeep.js";
7
+ import { REAL_TIME_DUMMY_ROUTE_TEMPLATES as G } from "../catalogs/routes.js";
8
+ import { REAL_TIME_DUMMY_EXECUTION_PLANS as N } from "../catalogs/plans.js";
9
+ import { REAL_TIME_DUMMY_DEVICE_BLUEPRINTS as x } from "../catalogs/blueprints.js";
10
+ import I from "../../node_modules/lodash-es/merge.js";
11
+ import { REAL_TIME_DUMMY_DEFAULT_ICON_ID as pe, REAL_TIME_DUMMY_BASE_DEVICE_TEMPLATE as me } from "../catalogs/baseDeviceTemplate.js";
12
+ import h from "../../node_modules/lodash-es/unset.js";
13
+ const C = Date.parse("2026-04-21T12:00:00.000Z"), Q = [
14
14
  "gnssCourse",
15
15
  "gnssLatitude",
16
16
  "gnssLongitude",
17
17
  "gnssSpeed"
18
+ ], ee = [
19
+ "adcPowerBackupLevel",
20
+ "adcPowerBackupStatus",
21
+ "adcPowerBackupVolt",
22
+ "adcPowerMainLevel",
23
+ "adcPowerMainStatus",
24
+ "adcPowerMainVolt",
25
+ "adcPowerSrcMainBatteryType"
18
26
  ];
19
- function L(e, t) {
27
+ function R(e, t) {
20
28
  return Object.hasOwn(e, t);
21
29
  }
22
- const me = "rt_devices";
23
- function ve(e) {
30
+ const ve = "rt_devices";
31
+ function fe(e) {
24
32
  if (e)
25
33
  return {
26
34
  bgColor: e.color,
@@ -28,7 +36,7 @@ function ve(e) {
28
36
  name: e.name
29
37
  };
30
38
  }
31
- function fe(e) {
39
+ function ge(e) {
32
40
  if (e)
33
41
  return {
34
42
  color: e.bgColor,
@@ -36,207 +44,216 @@ function fe(e) {
36
44
  name: e.name
37
45
  };
38
46
  }
39
- function D(e, t) {
47
+ function S(e, t) {
40
48
  if (!e)
41
49
  return e;
42
50
  const n = Date.parse(e);
43
51
  return Number.isFinite(n) ? new Date(
44
- t + (n - _)
52
+ t + (n - C)
45
53
  ).toISOString() : e;
46
54
  }
47
- function U(e) {
55
+ function L(e) {
48
56
  return typeof e == "object" && e !== null && "value" in e;
49
57
  }
50
- function ge(e, t, n) {
51
- const i = e.vpts?.vptGnss?.[t];
52
- U(i) && (i.updatedAt = D(
53
- i.updatedAt,
58
+ function Me(e, t, n) {
59
+ const a = e.vpts?.vptGnss?.[t];
60
+ L(a) && (a.updatedAt = S(
61
+ a.updatedAt,
54
62
  n
55
63
  ));
56
64
  }
57
- function q(e, t) {
58
- e && (e.updatedAt = D(
65
+ function F(e, t) {
66
+ e && (e.updatedAt = S(
59
67
  e.updatedAt,
60
68
  t
61
- ), e.value = D(
69
+ ), e.value = S(
62
70
  e.value,
63
71
  t
64
72
  ) ?? e.value);
65
73
  }
66
- function B(e, t) {
67
- e && (e.updatedAt = D(
74
+ function K(e, t) {
75
+ e && (e.updatedAt = S(
68
76
  e.updatedAt,
69
77
  t
70
- ), e.value = D(
78
+ ), e.value = S(
71
79
  e.value,
72
80
  t
73
81
  ) ?? e.value);
74
82
  }
75
- function $(e, t) {
76
- e && (e.updatedAt = D(
83
+ function q(e, t) {
84
+ e && (e.updatedAt = S(
77
85
  e.updatedAt,
78
86
  t
79
87
  ));
80
88
  }
81
- function Me(e, t, n) {
82
- const i = e.vpts?.vptGnss?.[t];
83
- U(i) && (i.updatedAt = n);
89
+ function ye(e, t, n) {
90
+ const a = e.vpts?.vptGnss?.[t];
91
+ L(a) && (a.updatedAt = n);
84
92
  }
85
- function j(e, t) {
93
+ function Y(e, t) {
86
94
  e && (e.updatedAt = t, e.value = t);
87
95
  }
88
- function Y(e, t) {
96
+ function $(e, t) {
89
97
  e && (e.updatedAt = t, e.value = t);
90
98
  }
91
- function W(e, t) {
99
+ function j(e, t) {
92
100
  e && (e.updatedAt = t);
93
101
  }
94
- function b(e, t, n) {
95
- return U(e) ? {
102
+ function P(e, t, n) {
103
+ return L(e) ? {
96
104
  ...e,
97
105
  updatedAt: n,
98
106
  value: t
99
107
  } : t;
100
108
  }
101
109
  function X(e, t) {
102
- return B(
110
+ return K(
103
111
  e.reportProfiles?.generalEvents?.reportProfileLastEventDate,
104
112
  t
105
- ), $(
113
+ ), q(
106
114
  e.reportProfiles?.generalEvents?.reportProfileLastEventId,
107
115
  t
108
- ), B(
116
+ ), K(
109
117
  e.reportProfiles?.systemEvents?.reportProfileLastEventDate,
110
118
  t
111
- ), $(
119
+ ), q(
112
120
  e.reportProfiles?.systemEvents?.reportProfileLastEventId,
113
121
  t
114
122
  ), Object.values(e.vpts?.vptDiX ?? {}).forEach((n) => {
115
- n.diXStatus && (n.diXStatus.updatedAt = D(
123
+ n.diXStatus && (n.diXStatus.updatedAt = S(
116
124
  n.diXStatus.updatedAt,
117
125
  t
118
- )), n.diXValue && (n.diXValue.updatedAt = D(
126
+ )), n.diXValue && (n.diXValue.updatedAt = S(
119
127
  n.diXValue.updatedAt,
120
128
  t
121
129
  ));
122
130
  }), Object.values(e.vpts?.vptDoX ?? {}).forEach((n) => {
123
- n.diXValue && (n.diXValue.updatedAt = D(
131
+ n.diXValue && (n.diXValue.updatedAt = S(
124
132
  n.diXValue.updatedAt,
125
133
  t
126
134
  ));
127
- }), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = D(
135
+ }), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = S(
128
136
  e.vpts.vptGnss.gnssMotionStatus.updatedAt,
129
137
  t
130
- )), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = D(
138
+ )), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = S(
131
139
  e.vpts.vptGnss.gnssSignal.updatedAt,
132
140
  t
133
- )), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = D(
141
+ )), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = S(
134
142
  e.vpts.vptIgnition.ignitionValue.updatedAt,
135
143
  t
136
- )), J.forEach((n) => {
137
- ge(e, n, t);
138
- }), e.vpts?.vptNetwork && (q(
144
+ )), ee.forEach((n) => {
145
+ const a = e.vpts?.vptAdcPower?.[n];
146
+ L(a) && (a.updatedAt = S(
147
+ a.updatedAt,
148
+ t
149
+ ));
150
+ }), Q.forEach((n) => {
151
+ Me(e, n, t);
152
+ }), e.vpts?.vptNetwork && (F(
139
153
  e.vpts.vptNetwork.networkLastConnectionDate,
140
154
  t
141
- ), q(
155
+ ), F(
142
156
  e.vpts.vptNetwork.networkLastEventDate,
143
157
  t
144
158
  )), e;
145
159
  }
146
160
  function De(e, t) {
147
- const n = S(e);
161
+ const n = E(e);
148
162
  return X(n.current, t), n;
149
163
  }
150
164
  function Se(e, t) {
151
- const n = S(e), i = new Date(t).toISOString();
152
- return Y(
165
+ const n = E(e), a = new Date(t).toISOString();
166
+ return $(
153
167
  n.current.reportProfiles?.generalEvents?.reportProfileLastEventDate,
154
- i
155
- ), W(
168
+ a
169
+ ), j(
156
170
  n.current.reportProfiles?.generalEvents?.reportProfileLastEventId,
157
- i
158
- ), Y(
171
+ a
172
+ ), $(
159
173
  n.current.reportProfiles?.systemEvents?.reportProfileLastEventDate,
160
- i
161
- ), W(
174
+ a
175
+ ), j(
162
176
  n.current.reportProfiles?.systemEvents?.reportProfileLastEventId,
163
- i
177
+ a
164
178
  ), Object.values(n.current.vpts?.vptDiX ?? {}).forEach((s) => {
165
- s.diXStatus && (s.diXStatus.updatedAt = i), s.diXValue && (s.diXValue.updatedAt = i);
179
+ s.diXStatus && (s.diXStatus.updatedAt = a), s.diXValue && (s.diXValue.updatedAt = a);
166
180
  }), Object.values(n.current.vpts?.vptDoX ?? {}).forEach((s) => {
167
- s.diXValue && (s.diXValue.updatedAt = i);
168
- }), n.current.vpts?.vptGnss?.gnssMotionStatus && (n.current.vpts.vptGnss.gnssMotionStatus.updatedAt = i), n.current.vpts?.vptGnss?.gnssSignal && (n.current.vpts.vptGnss.gnssSignal.updatedAt = i), n.current.vpts?.vptIgnition?.ignitionValue && (n.current.vpts.vptIgnition.ignitionValue.updatedAt = i), J.forEach((s) => {
169
- Me(
181
+ s.diXValue && (s.diXValue.updatedAt = a);
182
+ }), n.current.vpts?.vptGnss?.gnssMotionStatus && (n.current.vpts.vptGnss.gnssMotionStatus.updatedAt = a), n.current.vpts?.vptGnss?.gnssSignal && (n.current.vpts.vptGnss.gnssSignal.updatedAt = a), n.current.vpts?.vptIgnition?.ignitionValue && (n.current.vpts.vptIgnition.ignitionValue.updatedAt = a), ee.forEach((s) => {
183
+ const o = n.current.vpts?.vptAdcPower?.[s];
184
+ L(o) && (o.updatedAt = a);
185
+ }), Q.forEach((s) => {
186
+ ye(
170
187
  n.current,
171
188
  s,
172
- i
189
+ a
173
190
  );
174
- }), n.current.vpts?.vptNetwork && (j(
191
+ }), n.current.vpts?.vptNetwork && (Y(
175
192
  n.current.vpts.vptNetwork.networkLastConnectionDate,
176
- i
177
- ), j(
193
+ a
194
+ ), Y(
178
195
  n.current.vpts.vptNetwork.networkLastEventDate,
179
- i
196
+ a
180
197
  )), n;
181
198
  }
182
199
  function Ee(e, t) {
183
- const n = S(e);
200
+ const n = E(e);
184
201
  if (n.type === "delete")
185
202
  return n;
186
203
  if (n.type === "new") {
187
- const i = n.payload;
188
- return X(i.current, t), n;
204
+ const a = n.payload;
205
+ return X(a.current, t), n;
189
206
  }
190
207
  return X(
191
208
  n.payload.current,
192
209
  t
193
210
  ), n;
194
211
  }
195
- function H(e, t) {
212
+ function W(e, t) {
196
213
  return {
197
- ...R,
214
+ ...k,
198
215
  ...e,
199
216
  ...t,
200
217
  framesPerTick: Math.max(
201
218
  1,
202
- t?.framesPerTick ?? e?.framesPerTick ?? R.framesPerTick
219
+ t?.framesPerTick ?? e?.framesPerTick ?? k.framesPerTick
203
220
  ),
204
221
  intervalMs: Math.max(
205
222
  1,
206
- t?.intervalMs ?? e?.intervalMs ?? R.intervalMs
223
+ t?.intervalMs ?? e?.intervalMs ?? k.intervalMs
207
224
  ),
208
225
  logicalSampleSeconds: Math.max(
209
226
  1,
210
- t?.logicalSampleSeconds ?? e?.logicalSampleSeconds ?? R.logicalSampleSeconds
227
+ t?.logicalSampleSeconds ?? e?.logicalSampleSeconds ?? k.logicalSampleSeconds
211
228
  )
212
229
  };
213
230
  }
214
- function ye(e) {
215
- if (!L(K, e))
231
+ function he(e) {
232
+ if (!R(x, e))
216
233
  throw new Error(`Unknown dummy blueprint "${e}"`);
217
- return K[e];
234
+ return x[e];
218
235
  }
219
- function he(e) {
220
- if (!L(x, e))
236
+ function Te(e) {
237
+ if (!R(G, e))
221
238
  throw new Error(`Unknown dummy route "${e}"`);
222
- return x[e];
239
+ return G[e];
223
240
  }
224
- function Ie(e) {
225
- if (!L(F, e))
241
+ function we(e) {
242
+ if (!R(N, e))
226
243
  throw new Error(`Unknown dummy plan "${e}"`);
227
- return F[e];
244
+ return N[e];
228
245
  }
229
- function Te(e) {
230
- const t = ue[e];
246
+ function Ie(e) {
247
+ const t = le[e];
231
248
  if (!t)
232
249
  throw new Error(`Unknown dummy simulation preset "${e}"`);
233
250
  return t;
234
251
  }
235
- function we(e) {
252
+ function Le(e) {
236
253
  const t = e.reduce(
237
- (n, i, s, a) => {
238
- const o = i.assignment.resourceSerialId;
239
- return a.findIndex((r) => r.assignment.resourceSerialId === o) !== s && !n.includes(o) && n.push(o), n;
254
+ (n, a, s, o) => {
255
+ const i = a.assignment.resourceSerialId;
256
+ return o.findIndex((r) => r.assignment.resourceSerialId === i) !== s && !n.includes(i) && n.push(i), n;
240
257
  },
241
258
  []
242
259
  );
@@ -245,50 +262,50 @@ function we(e) {
245
262
  `Dummy simulation resolved duplicate device ids: ${t.join(", ")}. Each preset must contribute its own unique resourceSerialId values.`
246
263
  );
247
264
  }
248
- function Re(e) {
249
- const t = e?.presetId, n = t ? Te(t).simulation : void 0, i = e?.scenarioId ?? n?.scenarioId ?? ce;
250
- if (!L(N, i))
251
- throw new Error(`Unknown dummy scenario "${i}"`);
252
- const s = N[i], a = (e?.devices ?? n?.devices ?? s.devices).map(
253
- (o) => ({
254
- assignment: o,
255
- blueprint: ye(o.blueprintId),
256
- plan: Ie(o.planId),
257
- route: he(o.routeId)
265
+ function ke(e) {
266
+ const t = e?.presetId, n = t ? Ie(t).simulation : void 0, a = e?.scenarioId ?? n?.scenarioId ?? de;
267
+ if (!R(U, a))
268
+ throw new Error(`Unknown dummy scenario "${a}"`);
269
+ const s = U[a], o = (e?.devices ?? n?.devices ?? s.devices).map(
270
+ (i) => ({
271
+ assignment: i,
272
+ blueprint: he(i.blueprintId),
273
+ plan: we(i.planId),
274
+ route: Te(i.routeId)
258
275
  })
259
276
  );
260
- return we(a), {
261
- devices: a,
262
- playback: H(
263
- H(s.playback, n?.playback),
277
+ return Le(o), {
278
+ devices: o,
279
+ playback: W(
280
+ W(s.playback, n?.playback),
264
281
  e?.playback
265
282
  )
266
283
  };
267
284
  }
268
- function Q(e) {
285
+ function te(e) {
269
286
  switch (e) {
270
- case y.noSignal:
287
+ case T.noSignal:
271
288
  return 2;
272
- case y.acceptable:
289
+ case T.acceptable:
273
290
  return 19;
274
- case y.reliable:
291
+ case T.reliable:
275
292
  default:
276
293
  return 31;
277
294
  }
278
295
  }
279
- function be(e) {
296
+ function Pe(e) {
280
297
  switch (e) {
281
- case y.noSignal:
298
+ case T.noSignal:
282
299
  return {
283
300
  gnssHdop: 4.9,
284
301
  gnssSatellitesInUse: 0
285
302
  };
286
- case y.acceptable:
303
+ case T.acceptable:
287
304
  return {
288
305
  gnssHdop: 1.7,
289
306
  gnssSatellitesInUse: 8
290
307
  };
291
- case y.reliable:
308
+ case T.reliable:
292
309
  default:
293
310
  return {
294
311
  gnssHdop: 0.8,
@@ -299,143 +316,145 @@ function be(e) {
299
316
  function O(e, t, n) {
300
317
  return Math.min(n, Math.max(t, e));
301
318
  }
302
- function Z(e) {
319
+ function H(e) {
303
320
  return Math.round(e * 10) / 10;
304
321
  }
305
- function k(e, t) {
306
- return e <= 0 ? T.lost : t === "12" ? e >= 12.4 ? T.ok : T.low : e >= 24.8 ? T.ok : T.low;
322
+ function Z(e, t) {
323
+ return e <= 0 ? D.lost : t === "4.5" ? e >= 4.1 ? D.ok : D.low : t === "12" ? e >= 12.4 ? D.ok : D.low : e >= 24.8 ? D.ok : D.low;
307
324
  }
308
- function ee(e) {
309
- const t = (e - 24.3) / 3.599999999999998;
310
- return Math.round(O(t, 0, 1) * 100);
325
+ function z(e, t) {
326
+ const [n, a] = t === "4.5" ? [3.8, 4.2] : t === "12" ? [12, 13.8] : [24.3, 27.9], s = (e - n) / (a - n);
327
+ return Math.round(O(s, 0, 1) * 100);
311
328
  }
312
329
  function A(e, t) {
313
- const n = [0, 0.04, -0.03, 0.06, -0.02], i = n[t % n.length] ?? 0;
330
+ const n = [0, 0.04, -0.03, 0.06, -0.02], a = n[t % n.length] ?? 0;
314
331
  let s = e.ignition ? 13.6 : 12.3;
315
332
  switch (e.motionStatus) {
316
- case u.notDetectable:
333
+ case p.notDetectable:
317
334
  s = e.ignition ? 12.4 : 12.1;
318
335
  break;
319
- case u.off:
336
+ case p.off:
320
337
  s = 12.2;
321
338
  break;
322
- case u.towing:
339
+ case p.towing:
323
340
  s = 12.1;
324
341
  break;
325
- case u.stopped:
342
+ case p.stopped:
326
343
  s = e.ignition ? 12.5 : 12.2;
327
344
  break;
328
- case u.stoppedRalenti:
345
+ case p.stoppedRalenti:
329
346
  s = 13.4;
330
347
  break;
331
- case u.stoppedExcesiveRalenti:
348
+ case p.stoppedExcesiveRalenti:
332
349
  s = 13.3;
333
350
  break;
334
- case u.maxSpeed:
351
+ case p.maxSpeed:
335
352
  s = 13.8;
336
353
  break;
337
- case u.moving:
354
+ case p.moving:
338
355
  default:
339
356
  s = e.ignition ? 13.6 : 12.3;
340
357
  break;
341
358
  }
342
- e.signal === y.noSignal && (s -= 0.2);
343
- let a = e.ignition ? 26.3 : 25.2;
359
+ e.signal === T.noSignal && (s -= 0.2);
360
+ let o = e.ignition ? 4.16 : 4.04;
344
361
  switch (e.motionStatus) {
345
- case u.notDetectable:
346
- a = e.ignition ? 25.2 : 24.9;
362
+ case p.notDetectable:
363
+ o = e.ignition ? 4.05 : 3.98;
347
364
  break;
348
- case u.off:
349
- a = 25;
365
+ case p.off:
366
+ o = 4;
350
367
  break;
351
- case u.towing:
352
- a = 24.9;
368
+ case p.towing:
369
+ o = 3.96;
353
370
  break;
354
- case u.stopped:
355
- a = e.ignition ? 25.4 : 25;
371
+ case p.stopped:
372
+ o = e.ignition ? 4.08 : 4;
356
373
  break;
357
- case u.stoppedRalenti:
358
- a = 26.1;
374
+ case p.stoppedRalenti:
375
+ o = 4.13;
359
376
  break;
360
- case u.stoppedExcesiveRalenti:
361
- a = 25.9;
377
+ case p.stoppedExcesiveRalenti:
378
+ o = 4.1;
362
379
  break;
363
- case u.maxSpeed:
364
- a = 26.6;
380
+ case p.maxSpeed:
381
+ o = 4.18;
365
382
  break;
366
- case u.moving:
383
+ case p.moving:
367
384
  default:
368
- a = e.ignition ? 26.4 : 25.2;
385
+ o = e.ignition ? 4.16 : 4.04;
369
386
  break;
370
387
  }
371
- e.signal === y.acceptable && (a -= 0.2), e.signal === y.noSignal && (a -= 0.5);
372
- const o = Z(O(s + i, 11.8, 13.9)), l = Z(O(a + i * 2, 24, 27.9));
388
+ e.signal === T.acceptable && (o -= 0.03), e.signal === T.noSignal && (o -= 0.08);
389
+ const i = H(O(s + a, 11.8, 13.9)), u = H(O(o + a / 2, 3.8, 4.2));
373
390
  return {
374
- backupChargeLevel: ee(l),
375
- backupStatus: k(l, "24"),
376
- backupVolt: l,
377
- mainStatus: k(o, "12"),
378
- mainVolt: o
391
+ backupLevel: z(u, "4.5"),
392
+ backupStatus: Z(u, "4.5"),
393
+ backupVolt: u,
394
+ mainLevel: z(i, "12"),
395
+ mainStatus: Z(i, "12"),
396
+ mainVolt: i,
397
+ srcMainBatteryType: 0
379
398
  };
380
399
  }
381
- function Pe(e) {
400
+ function be(e) {
382
401
  return Object.fromEntries(
383
- Object.entries(e.vpts?.vptDiX ?? {}).map(([t, n]) => [t, !!P(n.diXValue, !1)])
402
+ Object.entries(e.vpts?.vptDiX ?? {}).map(([t, n]) => [t, !!b(n.diXValue, !1)])
384
403
  );
385
404
  }
386
- function ke(e) {
405
+ function Re(e) {
387
406
  return Object.fromEntries(
388
- Object.entries(e.vpts?.vptDoX ?? {}).map(([t, n]) => [t, !!P(n.diXValue, !1)])
407
+ Object.entries(e.vpts?.vptDoX ?? {}).map(([t, n]) => [t, !!b(n.diXValue, !1)])
389
408
  );
390
409
  }
391
- function G(e, t) {
392
- return e.motionStatus !== void 0 ? e.motionStatus : t.ignition ? e.speedKph >= 55 ? u.maxSpeed : u.moving : u.towing;
393
- }
394
- function te(e, t) {
395
- return e.motionStatus !== void 0 ? e.motionStatus : t.ignition ? u.stopped : u.off;
410
+ function B(e, t) {
411
+ return e.motionStatus !== void 0 ? e.motionStatus : t.ignition ? e.speedKph >= 55 ? p.maxSpeed : p.moving : p.towing;
396
412
  }
397
413
  function ne(e, t) {
414
+ return e.motionStatus !== void 0 ? e.motionStatus : t.ignition ? p.stopped : p.off;
415
+ }
416
+ function se(e, t) {
398
417
  const n = t.signal ?? e.signal;
399
418
  return {
400
419
  diX: t.diX ? { ...e.diX, ...t.diX } : { ...e.diX },
401
420
  doX: t.doX ? { ...e.doX, ...t.doX } : { ...e.doX },
402
421
  ignition: t.ignition ?? e.ignition,
403
- modemCsq: t.modemCsq ?? (t.signal !== void 0 ? Q(n) : e.modemCsq),
422
+ modemCsq: t.modemCsq ?? (t.signal !== void 0 ? te(n) : e.modemCsq),
404
423
  signal: n
405
424
  };
406
425
  }
407
- function Le(e, t) {
426
+ function Ae(e, t) {
408
427
  return e.omitDeviceIcon ?? t.omitDeviceIcon ?? !1;
409
428
  }
410
- function Ae(e, t) {
411
- const n = S(pe);
412
- w(n.current, t.currentPatch ?? {}), w(n.current, e.currentPatch ?? {}), w(n.settings, t.settingsPatch ?? {}), n.settings.active = e.active ?? t.active ?? n.settings.active, n.alias = e.alias ?? t.alias ?? n.alias;
413
- const i = e.group ?? t.group ?? n.settings.group, s = e.department ?? t.department ?? n.department ?? fe(i);
414
- if (n.department = s, n.settings.group = i ?? ve(s), n.settings.iconBgColor = e.iconBgColor ?? t.iconBgColor ?? n.settings.iconBgColor, Le(e, t))
429
+ function Ve(e, t) {
430
+ const n = E(me);
431
+ I(n.current, t.currentPatch ?? {}), I(n.current, e.currentPatch ?? {}), I(n.settings, t.settingsPatch ?? {}), n.settings.active = e.active ?? t.active ?? n.settings.active, n.alias = e.alias ?? t.alias ?? n.alias;
432
+ const a = e.group ?? t.group ?? n.settings.group, s = e.department ?? t.department ?? n.department ?? ge(a);
433
+ if (n.department = s, n.settings.group = a ?? fe(s), n.settings.iconBgColor = e.iconBgColor ?? t.iconBgColor ?? n.settings.iconBgColor, Ae(e, t))
415
434
  n.deviceIcon = void 0;
416
435
  else {
417
436
  n.deviceIcon ??= {
418
- iconId: de
437
+ iconId: pe
419
438
  };
420
- const o = e.iconId ?? t.iconId ?? n.deviceIcon.iconId;
421
- n.deviceIcon.iconId = o;
439
+ const i = e.iconId ?? t.iconId ?? n.deviceIcon.iconId;
440
+ n.deviceIcon.iconId = i;
422
441
  }
423
442
  n.name = e.name ?? t.name, n.settings.properties?.internal_name && (n.settings.properties.internal_name.value = `${n.name}-${e.resourceSerialId}`);
424
- const a = String(e.resourceSerialId);
443
+ const o = String(e.resourceSerialId);
425
444
  return {
426
445
  ...n,
427
- id: Number(a)
446
+ id: Number(o)
428
447
  };
429
448
  }
430
- function Ve(e) {
431
- const t = e.current.vpts?.vptGnss?.gnssSignal?.value ?? y.reliable;
449
+ function _e(e) {
450
+ const t = e.current.vpts?.vptGnss?.gnssSignal?.value ?? T.reliable;
432
451
  return {
433
- diX: Pe(e.current),
434
- doX: ke(e.current),
435
- ignition: !!P(e.current.vpts?.vptIgnition?.ignitionValue, !0),
436
- modemCsq: P(
452
+ diX: be(e.current),
453
+ doX: Re(e.current),
454
+ ignition: !!b(e.current.vpts?.vptIgnition?.ignitionValue, !0),
455
+ modemCsq: b(
437
456
  e.current.vpts?.vptModem?.modemCsq,
438
- Q(t)
457
+ te(t)
439
458
  ),
440
459
  signal: t
441
460
  };
@@ -446,139 +465,144 @@ function Ce(e, t) {
446
465
  const n = Number(e.resourceSerialId);
447
466
  return Number.isFinite(n) ? Math.abs(n) % 12 * t.logicalSampleSeconds * 4 : 0;
448
467
  }
449
- function _e(e, t) {
468
+ function Xe(e, t) {
450
469
  if (e.emissionOffsetMs !== void 0)
451
470
  return Math.max(0, e.emissionOffsetMs % t.intervalMs);
452
471
  const n = Number(e.resourceSerialId);
453
472
  return Number.isFinite(n) ? Math.abs(n * 137 % t.intervalMs) : 0;
454
473
  }
455
- function Xe(e) {
474
+ function Oe(e) {
456
475
  return {
457
- cumulativeDistancesMeters: e.waypoints.reduce((n, i, s, a) => {
476
+ cumulativeDistancesMeters: e.waypoints.reduce((n, a, s, o) => {
458
477
  if (s === 0)
459
478
  return n.push(0), n;
460
- const o = a[s - 1], l = n[s - 1] ?? 0;
461
- return n.push(l + z(o, i)), n;
479
+ const i = o[s - 1], u = n[s - 1] ?? 0;
480
+ return n.push(u + J(i, a)), n;
462
481
  }, []),
463
482
  totalDistanceMeters: ie(e.waypoints),
464
483
  waypoints: e.waypoints
465
484
  };
466
485
  }
467
- function Oe(e) {
486
+ function Be(e) {
468
487
  const t = e.waypoints[0], n = e.waypoints[e.waypoints.length - 1];
469
- return !t || !n ? !1 : z(t, n) <= 1;
488
+ return !t || !n ? !1 : J(t, n) <= 1;
470
489
  }
471
490
  function Ue(e) {
472
491
  return e.phases.reduce((t, n) => n.type !== "drive" ? t : t + n.speedKph * 1e3 / 3600 * n.durationSeconds, 0);
473
492
  }
474
493
  function Ge(e, t, n) {
475
- const i = Ue(n), s = Math.max(150, t.totalDistanceMeters * 0.03);
476
- if (i > t.totalDistanceMeters + s)
494
+ const a = Ue(n), s = Math.max(150, t.totalDistanceMeters * 0.03);
495
+ if (a > t.totalDistanceMeters + s)
477
496
  throw new Error(
478
497
  `Dummy plan "${n.planId}" exceeds route "${e.routeId}" by ${Math.round(
479
- i - t.totalDistanceMeters
498
+ a - t.totalDistanceMeters
480
499
  )} meters`
481
500
  );
482
501
  }
483
502
  function V(e, t, n) {
484
- const i = e.waypoints[0];
485
- if (!i)
503
+ const a = e.waypoints[0];
504
+ if (!a)
486
505
  throw new Error("Dummy route must contain at least one waypoint");
487
506
  if (e.waypoints.length === 1 || e.totalDistanceMeters <= 0)
488
507
  return {
489
- address: i.address,
508
+ address: a.address,
490
509
  course: n,
491
- lat: i.lat,
492
- lng: i.lng
510
+ lat: a.lat,
511
+ lng: a.lng
493
512
  };
494
513
  const s = Math.min(
495
514
  Math.max(0, t),
496
515
  e.totalDistanceMeters
497
516
  );
498
- for (let o = 0; o < e.waypoints.length - 1; o += 1) {
499
- const l = e.waypoints[o], r = e.waypoints[o + 1], m = e.cumulativeDistancesMeters[o] ?? 0, d = e.cumulativeDistancesMeters[o + 1] ?? m;
500
- if (s > d && o < e.waypoints.length - 2)
517
+ for (let i = 0; i < e.waypoints.length - 1; i += 1) {
518
+ const u = e.waypoints[i], r = e.waypoints[i + 1], M = e.cumulativeDistancesMeters[i] ?? 0, v = e.cumulativeDistancesMeters[i + 1] ?? M;
519
+ if (s > v && i < e.waypoints.length - 2)
501
520
  continue;
502
- const p = Math.max(0, d - m), v = p === 0 ? 0 : (s - m) / p, c = ae(l, r, v), f = p === 0 ? n : re(l, r);
521
+ const f = Math.max(0, v - M), l = f === 0 ? 0 : (s - M) / f, c = re(u, r, l), d = f === 0 ? n : ue(u, r);
503
522
  return {
504
- address: v < 0.5 ? l.address : r.address,
505
- course: f,
523
+ address: l < 0.5 ? u.address : r.address,
524
+ course: d,
506
525
  lat: c.lat,
507
526
  lng: c.lng
508
527
  };
509
528
  }
510
- const a = e.waypoints[e.waypoints.length - 1];
529
+ const o = e.waypoints[e.waypoints.length - 1];
511
530
  return {
512
- address: a.address,
531
+ address: o.address,
513
532
  course: n,
514
- lat: a.lat,
515
- lng: a.lng
533
+ lat: o.lat,
534
+ lng: o.lng
516
535
  };
517
536
  }
518
537
  function Ne(e, t, n) {
519
- const i = t.phases.find((r) => r.type !== "delete");
520
- if (!i)
538
+ const a = t.phases.find((r) => r.type !== "delete");
539
+ if (!a)
521
540
  throw new Error(`Dummy plan "${t.planId}" must contain at least one executable phase`);
522
- const s = ne(n, i), a = V(e, 0, 0), o = i.type === "drive" ? G(i, s) : te(i, s), l = A(
541
+ const s = se(n, a), o = V(e, 0, 0), i = a.type === "drive" ? B(a, s) : ne(a, s), u = A(
523
542
  {
524
543
  ignition: s.ignition,
525
- motionStatus: o,
544
+ motionStatus: i,
526
545
  signal: s.signal
527
546
  },
528
547
  0
529
548
  );
530
549
  return {
531
550
  cursor: {
532
- currentTimestampMs: _,
551
+ currentTimestampMs: C,
533
552
  frameIndex: 0,
534
- lastCourse: a.course,
553
+ lastCourse: o.course,
535
554
  odometerMeters: 0,
536
555
  routeDistanceMeters: 0
537
556
  },
538
557
  frameState: {
539
- address: a.address,
540
- backupVolt: l.backupVolt,
541
- course: a.course,
558
+ address: o.address,
559
+ backupLevel: u.backupLevel,
560
+ backupStatus: u.backupStatus,
561
+ backupVolt: u.backupVolt,
562
+ course: o.course,
542
563
  diX: { ...s.diX },
543
564
  doX: { ...s.doX },
544
565
  ignition: s.ignition,
545
- lat: a.lat,
546
- lng: a.lng,
547
- mainVolt: l.mainVolt,
566
+ lat: o.lat,
567
+ lng: o.lng,
568
+ mainLevel: u.mainLevel,
569
+ mainStatus: u.mainStatus,
570
+ mainVolt: u.mainVolt,
548
571
  modemCsq: s.modemCsq,
549
- motionStatus: o,
572
+ motionStatus: i,
550
573
  odometerMeters: 0,
551
574
  signal: s.signal,
552
- speedKph: i.type === "drive" ? i.speedKph : 0,
553
- timestampMs: _
575
+ speedKph: a.type === "drive" ? a.speedKph : 0,
576
+ srcMainBatteryType: u.srcMainBatteryType,
577
+ timestampMs: C
554
578
  },
555
579
  persistentState: s
556
580
  };
557
581
  }
558
- function xe(e, t, n, i, s) {
559
- const a = t.reduce((g, M, h) => ((M.type === "new" || M.type === "update") && g.push(h), g), []);
560
- if (!a.length)
582
+ function xe(e, t, n, a, s) {
583
+ const o = t.reduce((m, g, y) => ((g.type === "new" || g.type === "update") && m.push(y), m), []);
584
+ if (!o.length)
561
585
  return {
562
586
  initialMessageIndex: 1,
563
587
  initialResource: e,
564
588
  playbackMessages: t
565
589
  };
566
- const o = Ce(i, n), l = Math.floor(o / n.logicalSampleSeconds), r = Math.min(l, a.length - 1), m = a[r], d = t[m], p = (d.type === "new", d.payload.current), v = {
590
+ const i = Ce(a, n), u = Math.floor(i / n.logicalSampleSeconds), r = Math.min(u, o.length - 1), M = o[r], v = t[M], f = (v.type === "new", v.payload.current), l = {
567
591
  ...e,
568
- current: S(p)
569
- }, c = t.slice(m + 1), f = n.loop ? t.slice(1, m + 1) : [];
592
+ current: E(f)
593
+ }, c = t.slice(M + 1), d = n.loop ? t.slice(1, M + 1) : [];
570
594
  return {
571
595
  initialMessageIndex: 1,
572
- initialResource: v,
596
+ initialResource: l,
573
597
  playbackMessages: [
574
598
  {
575
- payload: v,
599
+ payload: l,
576
600
  resourceTypeId: s,
577
- resourceSerialId: i.resourceSerialId,
601
+ resourceSerialId: a.resourceSerialId,
578
602
  type: "new"
579
603
  },
580
604
  ...c,
581
- ...f
605
+ ...d
582
606
  ]
583
607
  };
584
608
  }
@@ -586,57 +610,57 @@ function Fe(e, t) {
586
610
  const n = t.messagePayloadPatches ?? [];
587
611
  if (!n.length)
588
612
  return e;
589
- const i = {
613
+ const a = {
590
614
  ...e,
591
- initialResource: S(e.initialResource),
592
- messages: e.messages.map((s) => S(s))
615
+ initialResource: E(e.initialResource),
616
+ messages: e.messages.map((s) => E(s))
593
617
  };
594
618
  return n.forEach((s) => {
595
- const a = i.messages[s.messageIndex];
596
- if (!a)
619
+ const o = a.messages[s.messageIndex];
620
+ if (!o)
597
621
  throw new Error(
598
622
  `Dummy hostile payload patch targeted missing message index ${s.messageIndex} for device ${t.resourceSerialId}.`
599
623
  );
600
- if (a.type === "delete")
624
+ if (o.type === "delete")
601
625
  throw new Error(
602
626
  `Dummy hostile payload patch cannot target delete message index ${s.messageIndex} for device ${t.resourceSerialId}.`
603
627
  );
604
- w(
605
- a.payload,
606
- S(s.payloadPatch)
607
- ), s.messageIndex === 0 && a.type === "new" && w(
608
- i.initialResource,
609
- S(s.payloadPatch)
628
+ I(
629
+ o.payload,
630
+ E(s.payloadPatch)
631
+ ), s.messageIndex === 0 && o.type === "new" && I(
632
+ a.initialResource,
633
+ E(s.payloadPatch)
610
634
  );
611
- }), i;
635
+ }), a;
612
636
  }
613
637
  function Ke(e, t) {
614
- const n = t.omittedGnssFields, i = t.omitSyntheticModemTimestamps === !0;
615
- if (!n?.gnssLatitude && !n?.gnssLongitude && !n?.gnssMotionStatus && !n?.gnssSignal && !i)
638
+ const n = t.omittedGnssFields, a = t.omitSyntheticModemTimestamps === !0;
639
+ if (!n?.gnssLatitude && !n?.gnssLongitude && !n?.gnssMotionStatus && !n?.gnssSignal && !a)
616
640
  return e;
617
641
  const s = {
618
642
  ...e,
619
- initialResource: S(e.initialResource),
620
- messages: e.messages.map((o) => S(o))
621
- }, a = (o) => {
622
- n?.gnssLatitude && E(o, "vpts.vptGnss.gnssLatitude"), n?.gnssLongitude && E(o, "vpts.vptGnss.gnssLongitude"), n?.gnssMotionStatus && E(o, "vpts.vptGnss.gnssMotionStatus"), n?.gnssSignal && E(o, "vpts.vptGnss.gnssSignal"), i && (E(o, "reportProfiles.generalEvents.reportProfileLastEventDate"), E(o, "reportProfiles.generalEvents.reportProfileLastEventId"), E(o, "reportProfiles.systemEvents.reportProfileLastEventDate"), E(o, "reportProfiles.systemEvents.reportProfileLastEventId"), E(o, "vpts.vptNetwork.networkLastConnectionDate"), E(o, "vpts.vptNetwork.networkLastEventDate"));
643
+ initialResource: E(e.initialResource),
644
+ messages: e.messages.map((i) => E(i))
645
+ }, o = (i) => {
646
+ n?.gnssLatitude && h(i, "vpts.vptGnss.gnssLatitude"), n?.gnssLongitude && h(i, "vpts.vptGnss.gnssLongitude"), n?.gnssMotionStatus && h(i, "vpts.vptGnss.gnssMotionStatus"), n?.gnssSignal && h(i, "vpts.vptGnss.gnssSignal"), a && (h(i, "reportProfiles.generalEvents.reportProfileLastEventDate"), h(i, "reportProfiles.generalEvents.reportProfileLastEventId"), h(i, "reportProfiles.systemEvents.reportProfileLastEventDate"), h(i, "reportProfiles.systemEvents.reportProfileLastEventId"), h(i, "vpts.vptNetwork.networkLastConnectionDate"), h(i, "vpts.vptNetwork.networkLastEventDate"));
623
647
  };
624
- return a(
648
+ return o(
625
649
  s.initialResource.current
626
- ), s.messages.forEach((o) => {
627
- if (o.type !== "delete") {
628
- if (o.type === "new") {
629
- a(o.payload.current);
650
+ ), s.messages.forEach((i) => {
651
+ if (i.type !== "delete") {
652
+ if (i.type === "new") {
653
+ o(i.payload.current);
630
654
  return;
631
655
  }
632
- a(
633
- o.payload.current
656
+ o(
657
+ i.payload.current
634
658
  );
635
659
  }
636
660
  }), s;
637
661
  }
638
- function C(e, t) {
639
- const n = new Date(t.timestampMs).toISOString(), i = be(t.signal), s = S(e);
662
+ function _(e, t) {
663
+ const n = new Date(t.timestampMs).toISOString(), a = Pe(t.signal), s = E(e);
640
664
  return s.reportProfiles = {
641
665
  ...s.reportProfiles,
642
666
  generalEvents: {
@@ -670,45 +694,45 @@ function C(e, t) {
670
694
  }
671
695
  }
672
696
  }, s.vpts = s.vpts ?? {}, s.vpts.vptDiX = Object.fromEntries(
673
- Object.entries(t.diX).map(([a, o]) => [
674
- a,
697
+ Object.entries(t.diX).map(([o, i]) => [
698
+ o,
675
699
  {
676
700
  diXStatus: { value: !0, updatedAt: n },
677
- diXValue: { value: o, updatedAt: n }
701
+ diXValue: { value: i, updatedAt: n }
678
702
  }
679
703
  ])
680
704
  ), s.vpts.vptDoX = Object.fromEntries(
681
- Object.entries(t.doX).map(([a, o]) => [
682
- a,
705
+ Object.entries(t.doX).map(([o, i]) => [
706
+ o,
683
707
  {
684
- diXValue: { value: o, updatedAt: n }
708
+ diXValue: { value: i, updatedAt: n }
685
709
  }
686
710
  ])
687
711
  ), s.vpts.vptGnss = {
688
712
  ...s.vpts.vptGnss,
689
713
  gnssAddress: t.address,
690
714
  gnssAltitude: 1520,
691
- gnssCourse: b(
715
+ gnssCourse: P(
692
716
  s.vpts.vptGnss?.gnssCourse,
693
717
  Math.round(t.course),
694
718
  n
695
719
  ),
696
- gnssHdop: i.gnssHdop,
697
- gnssLatitude: b(
720
+ gnssHdop: a.gnssHdop,
721
+ gnssLatitude: P(
698
722
  s.vpts.vptGnss?.gnssLatitude,
699
723
  t.lat,
700
724
  n
701
725
  ),
702
- gnssLongitude: b(
726
+ gnssLongitude: P(
703
727
  s.vpts.vptGnss?.gnssLongitude,
704
728
  t.lng,
705
729
  n
706
730
  ),
707
731
  gnssMotionStatus: { value: t.motionStatus, updatedAt: n },
708
732
  gnssOdometer: Math.round(t.odometerMeters),
709
- gnssSatellitesInUse: i.gnssSatellitesInUse,
733
+ gnssSatellitesInUse: a.gnssSatellitesInUse,
710
734
  gnssSignal: { value: t.signal, updatedAt: n },
711
- gnssSpeed: b(
735
+ gnssSpeed: P(
712
736
  s.vpts.vptGnss?.gnssSpeed,
713
737
  t.speedKph,
714
738
  n
@@ -733,45 +757,80 @@ function C(e, t) {
733
757
  updatedAt: n,
734
758
  value: n
735
759
  }
736
- }, s.vpts.vptADCPower = {
737
- backupChargeLevel: ee(t.backupVolt),
738
- backupStatus: k(t.backupVolt, "24"),
739
- backupVolt: t.backupVolt,
740
- mainStatus: k(t.mainVolt, "12"),
741
- mainVolt: t.mainVolt
760
+ }, s.vpts.vptAdcPower = {
761
+ adcPowerBackupLevel: {
762
+ state: "current",
763
+ updatedAt: n,
764
+ value: t.backupLevel
765
+ },
766
+ adcPowerBackupStatus: {
767
+ state: "current",
768
+ updatedAt: n,
769
+ value: t.backupStatus
770
+ },
771
+ adcPowerBackupVolt: {
772
+ state: "current",
773
+ updatedAt: n,
774
+ value: t.backupVolt
775
+ },
776
+ adcPowerMainLevel: {
777
+ state: "current",
778
+ updatedAt: n,
779
+ value: t.mainLevel
780
+ },
781
+ adcPowerMainStatus: {
782
+ state: "current",
783
+ updatedAt: n,
784
+ value: t.mainStatus
785
+ },
786
+ adcPowerMainVolt: {
787
+ state: "current",
788
+ updatedAt: n,
789
+ value: t.mainVolt
790
+ },
791
+ adcPowerSrcMainBatteryType: {
792
+ state: "current",
793
+ updatedAt: n,
794
+ value: t.srcMainBatteryType
795
+ }
742
796
  }, s;
743
797
  }
744
- function se(e, t) {
798
+ function ae(e, t) {
745
799
  return Math.max(1, Math.ceil(e.durationSeconds / t.logicalSampleSeconds));
746
800
  }
747
- function qe(e, t, n, i, s, a, o, l, r) {
748
- const m = se(a, l);
749
- for (let d = 0; d < m; d += 1) {
750
- const p = oe(a.speedKph, r.frameIndex + 1), v = p * 1e3 / 3600 * l.logicalSampleSeconds, c = Math.min(
801
+ function qe(e, t, n, a, s, o, i, u, r) {
802
+ const M = ae(o, u);
803
+ for (let v = 0; v < M; v += 1) {
804
+ const f = oe(o.speedKph, r.frameIndex + 1), l = f * 1e3 / 3600 * u.logicalSampleSeconds, c = Math.min(
751
805
  s.totalDistanceMeters,
752
- r.routeDistanceMeters + v
753
- ), f = c - r.routeDistanceMeters, g = V(s, c, r.lastCourse);
754
- r.currentTimestampMs += l.logicalSampleSeconds * 1e3, r.frameIndex += 1, r.lastCourse = g.course, r.odometerMeters += f, r.routeDistanceMeters = c;
755
- const M = {
756
- address: g.address,
806
+ r.routeDistanceMeters + l
807
+ ), d = c - r.routeDistanceMeters, m = V(s, c, r.lastCourse);
808
+ r.currentTimestampMs += u.logicalSampleSeconds * 1e3, r.frameIndex += 1, r.lastCourse = m.course, r.odometerMeters += d, r.routeDistanceMeters = c;
809
+ const g = {
810
+ address: m.address,
811
+ backupLevel: 0,
812
+ backupStatus: D.lost,
757
813
  backupVolt: 0,
758
- course: g.course,
759
- diX: { ...o.diX },
760
- doX: { ...o.doX },
761
- ignition: o.ignition,
762
- lat: g.lat,
763
- lng: g.lng,
814
+ course: m.course,
815
+ diX: { ...i.diX },
816
+ doX: { ...i.doX },
817
+ ignition: i.ignition,
818
+ lat: m.lat,
819
+ lng: m.lng,
820
+ mainLevel: 0,
821
+ mainStatus: D.lost,
764
822
  mainVolt: 0,
765
- modemCsq: o.modemCsq,
766
- motionStatus: G(a, o),
823
+ modemCsq: i.modemCsq,
824
+ motionStatus: B(o, i),
767
825
  odometerMeters: r.odometerMeters,
768
- signal: o.signal,
769
- speedKph: f > 0 ? p : 0,
826
+ signal: i.signal,
827
+ speedKph: d > 0 ? f : 0,
828
+ srcMainBatteryType: 0,
770
829
  timestampMs: r.currentTimestampMs
771
- }, h = A(M, r.frameIndex);
772
- M.mainVolt = h.mainVolt, M.backupVolt = h.backupVolt, e.push({
830
+ }, y = A(g, r.frameIndex);
831
+ g.mainLevel = y.mainLevel, g.mainStatus = y.mainStatus, g.mainVolt = y.mainVolt, g.backupLevel = y.backupLevel, g.backupStatus = y.backupStatus, g.backupVolt = y.backupVolt, g.srcMainBatteryType = y.srcMainBatteryType, e.push({
773
832
  payload: {
774
- current: C(i, M)
833
+ current: _(a, g)
775
834
  },
776
835
  resourceTypeId: t,
777
836
  resourceSerialId: n,
@@ -779,31 +838,36 @@ function qe(e, t, n, i, s, a, o, l, r) {
779
838
  });
780
839
  }
781
840
  }
782
- function Be(e, t, n, i, s, a, o, l, r) {
783
- const m = se(a, l);
784
- for (let d = 0; d < m; d += 1) {
785
- const p = V(s, r.routeDistanceMeters, r.lastCourse);
786
- r.currentTimestampMs += l.logicalSampleSeconds * 1e3, r.frameIndex += 1;
787
- const v = {
788
- address: p.address,
841
+ function Ye(e, t, n, a, s, o, i, u, r) {
842
+ const M = ae(o, u);
843
+ for (let v = 0; v < M; v += 1) {
844
+ const f = V(s, r.routeDistanceMeters, r.lastCourse);
845
+ r.currentTimestampMs += u.logicalSampleSeconds * 1e3, r.frameIndex += 1;
846
+ const l = {
847
+ address: f.address,
848
+ backupLevel: 0,
849
+ backupStatus: D.lost,
789
850
  backupVolt: 0,
790
- course: a.courseOverrideDegrees ?? r.lastCourse,
791
- diX: { ...o.diX },
792
- doX: { ...o.doX },
793
- ignition: o.ignition,
794
- lat: p.lat,
795
- lng: p.lng,
851
+ course: o.courseOverrideDegrees ?? r.lastCourse,
852
+ diX: { ...i.diX },
853
+ doX: { ...i.doX },
854
+ ignition: i.ignition,
855
+ lat: f.lat,
856
+ lng: f.lng,
857
+ mainLevel: 0,
858
+ mainStatus: D.lost,
796
859
  mainVolt: 0,
797
- modemCsq: o.modemCsq,
798
- motionStatus: te(a, o),
860
+ modemCsq: i.modemCsq,
861
+ motionStatus: ne(o, i),
799
862
  odometerMeters: r.odometerMeters,
800
- signal: o.signal,
863
+ signal: i.signal,
801
864
  speedKph: 0,
865
+ srcMainBatteryType: 0,
802
866
  timestampMs: r.currentTimestampMs
803
- }, c = A(v, r.frameIndex);
804
- v.mainVolt = c.mainVolt, v.backupVolt = c.backupVolt, e.push({
867
+ }, c = A(l, r.frameIndex);
868
+ l.mainLevel = c.mainLevel, l.mainStatus = c.mainStatus, l.mainVolt = c.mainVolt, l.backupLevel = c.backupLevel, l.backupStatus = c.backupStatus, l.backupVolt = c.backupVolt, l.srcMainBatteryType = c.srcMainBatteryType, e.push({
805
869
  payload: {
806
- current: C(i, v)
870
+ current: _(a, l)
807
871
  },
808
872
  resourceTypeId: t,
809
873
  resourceSerialId: n,
@@ -815,177 +879,182 @@ function $e({
815
879
  baseCurrent: e,
816
880
  cursor: t,
817
881
  messages: n,
818
- persistentState: i,
882
+ persistentState: a,
819
883
  playback: s,
820
- resourceTypeId: a,
821
- resourceSerialId: o,
822
- routeIndex: l,
884
+ resourceTypeId: o,
885
+ resourceSerialId: i,
886
+ routeIndex: u,
823
887
  speedKph: r
824
888
  }) {
825
- if (r === void 0 || !Oe(l) || t.routeDistanceMeters >= l.totalDistanceMeters)
889
+ if (r === void 0 || !Be(u) || t.routeDistanceMeters >= u.totalDistanceMeters)
826
890
  return;
827
- const m = Math.max(r, 8);
828
- for (; t.routeDistanceMeters < l.totalDistanceMeters; ) {
829
- const d = m * 1e3 / 3600 * s.logicalSampleSeconds, p = Math.min(
830
- l.totalDistanceMeters,
831
- t.routeDistanceMeters + d
832
- ), v = p - t.routeDistanceMeters, c = V(l, p, t.lastCourse);
833
- t.currentTimestampMs += s.logicalSampleSeconds * 1e3, t.frameIndex += 1, t.lastCourse = c.course, t.odometerMeters += v, t.routeDistanceMeters = p;
834
- const f = {
891
+ const M = Math.max(r, 8);
892
+ for (; t.routeDistanceMeters < u.totalDistanceMeters; ) {
893
+ const v = M * 1e3 / 3600 * s.logicalSampleSeconds, f = Math.min(
894
+ u.totalDistanceMeters,
895
+ t.routeDistanceMeters + v
896
+ ), l = f - t.routeDistanceMeters, c = V(u, f, t.lastCourse);
897
+ t.currentTimestampMs += s.logicalSampleSeconds * 1e3, t.frameIndex += 1, t.lastCourse = c.course, t.odometerMeters += l, t.routeDistanceMeters = f;
898
+ const d = {
835
899
  address: c.address,
900
+ backupLevel: 0,
901
+ backupStatus: D.lost,
836
902
  backupVolt: 0,
837
903
  course: c.course,
838
- diX: { ...i.diX },
839
- doX: { ...i.doX },
840
- ignition: i.ignition,
904
+ diX: { ...a.diX },
905
+ doX: { ...a.doX },
906
+ ignition: a.ignition,
841
907
  lat: c.lat,
842
908
  lng: c.lng,
909
+ mainLevel: 0,
910
+ mainStatus: D.lost,
843
911
  mainVolt: 0,
844
- modemCsq: i.modemCsq,
845
- motionStatus: G(
912
+ modemCsq: a.modemCsq,
913
+ motionStatus: B(
846
914
  {
847
915
  durationSeconds: s.logicalSampleSeconds,
848
- speedKph: m
916
+ speedKph: M
849
917
  },
850
- i
918
+ a
851
919
  ),
852
920
  odometerMeters: t.odometerMeters,
853
- signal: i.signal,
854
- speedKph: v > 0 ? m : 0,
921
+ signal: a.signal,
922
+ speedKph: l > 0 ? M : 0,
923
+ srcMainBatteryType: 0,
855
924
  timestampMs: t.currentTimestampMs
856
- }, g = A(f, t.frameIndex);
857
- f.mainVolt = g.mainVolt, f.backupVolt = g.backupVolt, n.push({
925
+ }, m = A(d, t.frameIndex);
926
+ d.mainLevel = m.mainLevel, d.mainStatus = m.mainStatus, d.mainVolt = m.mainVolt, d.backupLevel = m.backupLevel, d.backupStatus = m.backupStatus, d.backupVolt = m.backupVolt, d.srcMainBatteryType = m.srcMainBatteryType, n.push({
858
927
  payload: {
859
- current: C(e, f)
928
+ current: _(e, d)
860
929
  },
861
- resourceTypeId: a,
862
- resourceSerialId: o,
930
+ resourceTypeId: o,
931
+ resourceSerialId: i,
863
932
  type: "update"
864
933
  });
865
934
  }
866
935
  }
867
936
  function je(e, t, n) {
868
- const { assignment: i, blueprint: s, plan: a, route: o } = e, l = Xe(o);
869
- Ge(o, l, a);
870
- const r = Ae(i, s), m = Ve(r), { cursor: d, frameState: p, persistentState: v } = Ne(
871
- l,
872
- a,
873
- m
937
+ const { assignment: a, blueprint: s, plan: o, route: i } = e, u = Oe(i);
938
+ Ge(i, u, o);
939
+ const r = Ve(a, s), M = _e(r), { cursor: v, frameState: f, persistentState: l } = Ne(
940
+ u,
941
+ o,
942
+ M
874
943
  ), c = {
875
944
  ...r,
876
- current: C(r.current, p)
945
+ current: _(r.current, f)
877
946
  };
878
- let f = v, g = a.phases.find((I) => I.type === "drive")?.speedKph;
879
- const M = [
947
+ let d = l, m = o.phases.find((w) => w.type === "drive")?.speedKph;
948
+ const g = [
880
949
  {
881
950
  payload: c,
882
951
  resourceTypeId: n,
883
- resourceSerialId: i.resourceSerialId,
952
+ resourceSerialId: a.resourceSerialId,
884
953
  type: "new"
885
954
  }
886
955
  ];
887
- for (const I of a.phases) {
888
- if (I.type === "delete") {
889
- M.push({
956
+ for (const w of o.phases) {
957
+ if (w.type === "delete") {
958
+ g.push({
890
959
  payload: {},
891
960
  resourceTypeId: n,
892
- resourceSerialId: i.resourceSerialId,
961
+ resourceSerialId: a.resourceSerialId,
893
962
  type: "delete"
894
963
  });
895
964
  break;
896
965
  }
897
- if (f = ne(f, I), I.type === "drive") {
898
- g = I.speedKph, qe(
899
- M,
966
+ if (d = se(d, w), w.type === "drive") {
967
+ m = w.speedKph, qe(
968
+ g,
900
969
  n,
901
- i.resourceSerialId,
970
+ a.resourceSerialId,
902
971
  r.current,
903
- l,
904
- I,
905
- f,
972
+ u,
973
+ w,
974
+ d,
906
975
  t,
907
- d
976
+ v
908
977
  );
909
978
  continue;
910
979
  }
911
- Be(
912
- M,
980
+ Ye(
981
+ g,
913
982
  n,
914
- i.resourceSerialId,
983
+ a.resourceSerialId,
915
984
  r.current,
916
- l,
917
- I,
918
- f,
985
+ u,
986
+ w,
987
+ d,
919
988
  t,
920
- d
989
+ v
921
990
  );
922
991
  }
923
992
  $e({
924
993
  baseCurrent: r.current,
925
- cursor: d,
926
- messages: M,
927
- persistentState: f,
994
+ cursor: v,
995
+ messages: g,
996
+ persistentState: d,
928
997
  playback: t,
929
998
  resourceTypeId: n,
930
- resourceSerialId: i.resourceSerialId,
931
- routeIndex: l,
932
- speedKph: g
999
+ resourceSerialId: a.resourceSerialId,
1000
+ routeIndex: u,
1001
+ speedKph: m
933
1002
  });
934
- const h = xe(
1003
+ const y = xe(
935
1004
  r,
936
- M,
1005
+ g,
937
1006
  t,
938
- i,
1007
+ a,
939
1008
  n
940
1009
  );
941
1010
  return Ke(
942
1011
  Fe({
943
- emissionOffsetMs: _e(i, t),
944
- initialMessageIndex: h.initialMessageIndex,
945
- initialResource: h.initialResource,
946
- messages: h.playbackMessages,
947
- resourceSerialId: i.resourceSerialId
948
- }, i),
949
- i
1012
+ emissionOffsetMs: Xe(a, t),
1013
+ initialMessageIndex: y.initialMessageIndex,
1014
+ initialResource: y.initialResource,
1015
+ messages: y.playbackMessages,
1016
+ resourceSerialId: a.resourceSerialId
1017
+ }, a),
1018
+ a
950
1019
  );
951
1020
  }
952
- function Ye(e, t) {
953
- const n = Re(e), i = t?.resourceTypeId ?? me, s = {
954
- devices: n.devices.map((a) => je(
955
- a,
1021
+ function We(e, t) {
1022
+ const n = ke(e), a = t?.resourceTypeId ?? ve, s = {
1023
+ devices: n.devices.map((o) => je(
1024
+ o,
956
1025
  n.playback,
957
- i
1026
+ a
958
1027
  )),
959
1028
  playback: n.playback
960
1029
  };
961
1030
  return t?.wallClockStartAtMs === void 0 ? s : {
962
1031
  ...s,
963
- devices: s.devices.map((a) => ({
964
- ...a,
1032
+ devices: s.devices.map((o) => ({
1033
+ ...o,
965
1034
  initialResource: De(
966
- a.initialResource,
1035
+ o.initialResource,
967
1036
  t.wallClockStartAtMs
968
1037
  ),
969
- messages: a.messages.map((o) => Ee(
970
- o,
1038
+ messages: o.messages.map((i) => Ee(
1039
+ i,
971
1040
  t.wallClockStartAtMs
972
1041
  ))
973
1042
  }))
974
1043
  };
975
1044
  }
976
- function We(e, t) {
977
- return Ye(e).devices.reduce((i, s) => (i[s.resourceSerialId] = t?.wallClockStartAtMs === void 0 ? s.initialResource : Se(
1045
+ function He(e, t) {
1046
+ return We(e).devices.reduce((a, s) => (a[s.resourceSerialId] = t?.wallClockStartAtMs === void 0 ? s.initialResource : Se(
978
1047
  s.initialResource,
979
1048
  t.wallClockStartAtMs
980
- ), i), {});
1049
+ ), a), {});
981
1050
  }
982
- function He({
1051
+ function Ze({
983
1052
  resourceTypeId: e,
984
1053
  simulation: t
985
1054
  }) {
986
1055
  const n = Date.now();
987
1056
  return {
988
- initialHashResources: We(t, {
1057
+ initialHashResources: He(t, {
989
1058
  wallClockStartAtMs: n
990
1059
  }),
991
1060
  resourceTypeId: e,
@@ -994,22 +1063,22 @@ function He({
994
1063
  wallClockStartAtMs: n
995
1064
  };
996
1065
  }
997
- function lt({
1066
+ function ct({
998
1067
  presetId: e,
999
1068
  resourceTypeId: t,
1000
1069
  simulationOverrides: n
1001
1070
  }) {
1002
- return He({
1071
+ return Ze({
1003
1072
  resourceTypeId: t,
1004
- simulation: le({
1073
+ simulation: ce({
1005
1074
  overrides: n,
1006
1075
  presetId: e
1007
1076
  })
1008
1077
  });
1009
1078
  }
1010
1079
  export {
1011
- Ye as buildRealTimeDummyRuntimeModel,
1012
- We as createRealTimeDummyInitialResources,
1013
- He as createRealTimeDummyResourceTypeConfig,
1014
- lt as createRealTimeDummyResourceTypeConfigFromPreset
1080
+ We as buildRealTimeDummyRuntimeModel,
1081
+ He as createRealTimeDummyInitialResources,
1082
+ Ze as createRealTimeDummyResourceTypeConfig,
1083
+ ct as createRealTimeDummyResourceTypeConfigFromPreset
1015
1084
  };