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