@m4l/gclick-realtime 1.0.4 → 1.1.0

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