@wemap/providers 14.6.0-beta.4 → 14.6.0-beta.5

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.
package/dist/index.js CHANGED
@@ -1,9 +1,19 @@
1
- import { AbsoluteHeading, Attitude, Constants, GeoRelativePosition, Level, RelativePosition, UserPosition } from "@wemap/geo";
2
- import { Matrix, Matrix3, Matrix4, Quaternion, Rotations, Vector, Vector3, deg2rad, diffAngle, diffAngleLines, rad2deg, std } from "@wemap/maths";
3
- import { Edge, ItineraryInfoManager } from "@wemap/routers";
4
- import { Browser, BrowserUtils, TimeUtils, UserAgentUtils } from "@wemap/utils";
5
- import { Camera, SharedCameras, base64ToCanvas, canvasToBase64, reduceImageSize } from "@wemap/camera";
6
- var RelativeAttitude = class extends Attitude {}, AbsoluteAttitude = class extends Attitude {}, AbsolutePosition = class extends UserPosition {}, ProvidersOptions_default = {
1
+ import { AbsoluteHeading as e, Attitude as t, Constants as n, GeoRelativePosition as r, Level as i, RelativePosition as a, UserPosition as o } from "@wemap/geo";
2
+ import { Matrix as s, Matrix3 as c, Matrix4 as l, Quaternion as u, Rotations as d, Vector as f, Vector3 as p, deg2rad as m, diffAngle as h, diffAngleLines as g, rad2deg as _, std as v } from "@wemap/maths";
3
+ import { Edge as y, ItineraryInfoManager as b } from "@wemap/routers";
4
+ import { Browser as x, BrowserUtils as S, TimeUtils as C, UserAgentUtils as w } from "@wemap/utils";
5
+ import { Camera as ee, SharedCameras as T, base64ToCanvas as E, canvasToBase64 as te, reduceImageSize as ne } from "@wemap/camera";
6
+ //#region src/events/AbsolutePosition.ts
7
+ var re = class e extends o {
8
+ source;
9
+ static fromUserPosition(t, n) {
10
+ let r = new e(t.lat, t.lng, t.alt, t.level, t.time, t.accuracy, t.bearing);
11
+ return r.source = n, r;
12
+ }
13
+ clone() {
14
+ return e.fromUserPosition(super.clone(), this.source);
15
+ }
16
+ }, ie = class extends t {}, ae = class extends t {}, D = {
7
17
  useMapMatching: !0,
8
18
  ignoreProviders: [],
9
19
  optionalProviders: [],
@@ -12,12 +22,12 @@ var RelativeAttitude = class extends Attitude {}, AbsoluteAttitude = class exten
12
22
  get hasPoleStar() {
13
23
  return this.optionalProviders.includes("PoleStar");
14
24
  }
15
- }, __defProp = Object.defineProperty, __defNormalProp = (e, C, w) => C in e ? __defProp(e, C, {
25
+ }, oe = Object.defineProperty, se = (e, t, n) => t in e ? oe(e, t, {
16
26
  enumerable: !0,
17
27
  configurable: !0,
18
28
  writable: !0,
19
- value: w
20
- }) : e[C] = w, __publicField = (e, C, w) => (__defNormalProp(e, typeof C == "symbol" ? C : C + "", w), w), LEVELS_ORDER = [
29
+ value: n
30
+ }) : e[t] = n, O = (e, t, n) => (se(e, typeof t == "symbol" ? t : t + "", n), n), ce = [
21
31
  "error",
22
32
  "ok",
23
33
  "warn",
@@ -27,101 +37,101 @@ var RelativeAttitude = class extends Attitude {}, AbsoluteAttitude = class exten
27
37
  "log",
28
38
  "debug"
29
39
  ];
30
- function isWindowWithWemap(e) {
40
+ function le(e) {
31
41
  return "wemap" in e;
32
42
  }
33
- var _Logger = class e {
34
- static enable(C) {
35
- e.ENABLED = !!C;
43
+ var k = class e {
44
+ static enable(t) {
45
+ e.ENABLED = !!t;
36
46
  }
37
- static level(C) {
38
- return arguments.length && (e.LOG_LEVEL = C), e.LOG_LEVEL;
47
+ static level(t) {
48
+ return arguments.length && (e.LOG_LEVEL = t), e.LOG_LEVEL;
39
49
  }
40
50
  static clearHistory() {
41
51
  e.HISTORY = [];
42
52
  }
43
- static _canUseLog(C) {
44
- let w = LEVELS_ORDER.indexOf(C), T = LEVELS_ORDER.indexOf(e.LOG_LEVEL);
45
- return T === -1 ? !1 : w <= T;
53
+ static _canUseLog(t) {
54
+ let n = ce.indexOf(t), r = ce.indexOf(e.LOG_LEVEL);
55
+ return r !== -1 && n <= r;
46
56
  }
47
57
  static _getColorByType(e) {
48
- let C = null;
58
+ let t = null;
49
59
  switch (e) {
50
60
  case "flux":
51
- C = "background-color: #0083E0; color: #FFFFFF;";
61
+ t = "background-color: #0083E0; color: #FFFFFF;";
52
62
  break;
53
63
  case "ok":
54
- C = "background-color: #00FF22; color: #272727;";
64
+ t = "background-color: #00FF22; color: #272727;";
55
65
  break;
56
66
  case "deprecated":
57
- C = "background-color: #CA0AFA; color: #FFFFFF;";
67
+ t = "background-color: #CA0AFA; color: #FFFFFF;";
58
68
  break;
59
69
  case "error":
60
- C = "background-color: #CC0000; color: #FFFFFF;";
70
+ t = "background-color: #CC0000; color: #FFFFFF;";
61
71
  break;
62
72
  case "warn":
63
- C = "background-color: #DD7908; color: #FFFFFF;";
73
+ t = "background-color: #DD7908; color: #FFFFFF;";
64
74
  break;
65
75
  case "debug":
66
- C = "background-color: #999999; color: #FFFFFF;";
76
+ t = "background-color: #999999; color: #FFFFFF;";
67
77
  break;
68
78
  case "info":
69
- C = "background-color: #DCFF4E; color: #000000;";
79
+ t = "background-color: #DCFF4E; color: #000000;";
70
80
  break;
71
81
  default:
72
- C = "background-color: #F4F4F4; color: #999999;";
82
+ t = "background-color: #F4F4F4; color: #999999;";
73
83
  break;
74
84
  }
75
- return C;
85
+ return t;
76
86
  }
77
- static _getOriginByType(e, C) {
78
- let w = null, T = null, E = C;
87
+ static _getOriginByType(e, t) {
88
+ let n = null, r = null, i = t;
79
89
  if (arguments.length < 2) return "";
80
90
  try {
81
- for (w = "", T = e.stack && e.stack.length ? e.stack.split("\n").splice(3) : [], (E < 0 || E >= T.length) && (E = T.length); E;) w += "\r\n " + T[0].trim(), T = T.splice(1), E--;
82
- return w;
91
+ for (n = "", r = e.stack && e.stack.length ? e.stack.split("\n").splice(3) : [], (i < 0 || i >= r.length) && (i = r.length); i;) n += "\r\n " + r[0].trim(), r = r.splice(1), i--;
92
+ return n;
83
93
  } catch {
84
94
  return "";
85
95
  }
86
96
  }
87
- static _log(C, w, T) {
88
- let E = "color: auto;", D = "color: #6A6A6A;", O = typeof window < "u", k, A = null, j = null, M = null, N = null, F = "", I = !1;
89
- if (A = C, N = Error(w), O && (j = e._getColorByType(C)), M = e._getOriginByType(N, T), A === "deprecated" && (A = "warn", I = "deprecated"), O && (M = e._COLOR_TOKEN + M), k = (O ? e._COLOR_TOKEN : "") + " " + N.message, F = O ? e._COLOR_TOKEN : "", F += e._TYPE_PREFIX, F += I || C, F += e._TYPE_SUFFIX, typeof window < "u" && isWindowWithWemap(window)) {
97
+ static _log(t, n, r) {
98
+ let i = "color: auto;", a = "color: #6A6A6A;", o = typeof window < "u", s, c = null, l = null, u = null, d = null, f = "", p = !1;
99
+ if (c = t, d = Error(n), o && (l = e._getColorByType(t)), u = e._getOriginByType(d, r), c === "deprecated" && (c = "warn", p = "deprecated"), o && (u = e._COLOR_TOKEN + u), s = (o ? e._COLOR_TOKEN : "") + " " + d.message, f = o ? e._COLOR_TOKEN : "", f += e._TYPE_PREFIX, f += p || t, f += e._TYPE_SUFFIX, typeof window < "u" && le(window)) {
90
100
  let e = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
91
- F += "[" + Math.round(e - window.wemap.startTime) + "ms]";
101
+ f += "[" + Math.round(e - window.wemap.startTime) + "ms]";
92
102
  }
93
- return k = F + k, e.SHOW_ORIGIN && (k += M), e.HISTORY.push(k), !this._canUseLog(C) || arguments.length < 2 || !e.ENABLED ? !1 : (O ? console && C !== "ok" && C !== "flux" && C !== "deprecated" && console[C] && LEVELS_ORDER.indexOf(C) <= LEVELS_ORDER.indexOf("info") ? console[C](k, j, E, D) : console.log(k, j, E, D) : console.log(k), !0);
103
+ return s = f + s, e.SHOW_ORIGIN && (s += u), e.HISTORY.push(s), !this._canUseLog(t) || arguments.length < 2 || !e.ENABLED ? !1 : (o ? console && t !== "ok" && t !== "flux" && t !== "deprecated" && console[t] && ce.indexOf(t) <= ce.indexOf("info") ? console[t](s, l, i, a) : console.log(s, l, i, a) : console.log(s), !0);
94
104
  }
95
105
  static external(e) {
96
106
  return console.log("LIVEMAP :: " + e);
97
107
  }
98
- static flux(C) {
99
- return e._log("flux", C, 0);
108
+ static flux(t) {
109
+ return e._log("flux", t, 0);
100
110
  }
101
- static ok(C) {
102
- return e._log("ok", C, 1);
111
+ static ok(t) {
112
+ return e._log("ok", t, 1);
103
113
  }
104
- static error(C, w = -1) {
105
- return e._log("error", C, w);
114
+ static error(t, n = -1) {
115
+ return e._log("error", t, n);
106
116
  }
107
- static warn(C, w = 2) {
108
- return e._log("warn", C, w);
117
+ static warn(t, n = 2) {
118
+ return e._log("warn", t, n);
109
119
  }
110
- static deprecated(C, w = 2) {
111
- return e._log("deprecated", C, w);
120
+ static deprecated(t, n = 2) {
121
+ return e._log("deprecated", t, n);
112
122
  }
113
- static debug(C, w = -1) {
114
- return e._log("debug", C, w);
123
+ static debug(t, n = -1) {
124
+ return e._log("debug", t, n);
115
125
  }
116
- static info(C, w = 0) {
117
- return e._log("info", C, w);
126
+ static info(t, n = 0) {
127
+ return e._log("info", t, n);
118
128
  }
119
- static log(C, w = 1) {
120
- return e._log("log", C, w);
129
+ static log(t, n = 1) {
130
+ return e._log("log", t, n);
121
131
  }
122
132
  };
123
- __publicField(_Logger, "LOG_LEVEL", "debug"), __publicField(_Logger, "SHOW_ORIGIN", !0), __publicField(_Logger, "ENABLED", !0), __publicField(_Logger, "HISTORY", []), __publicField(_Logger, "_COLOR_TOKEN", "%c"), __publicField(_Logger, "_TYPE_PREFIX", "<<<< "), __publicField(_Logger, "_TYPE_SUFFIX", " >>>>");
124
- for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
133
+ O(k, "LOG_LEVEL", "debug"), O(k, "SHOW_ORIGIN", !0), O(k, "ENABLED", !0), O(k, "HISTORY", []), O(k, "_COLOR_TOKEN", "%c"), O(k, "_TYPE_PREFIX", "<<<< "), O(k, "_TYPE_SUFFIX", " >>>>");
134
+ for (var A = k, ue = new class {
125
135
  _enabled = !1;
126
136
  currentId = 0;
127
137
  objectsIdMap = /* @__PURE__ */ new WeakMap();
@@ -137,30 +147,30 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
137
147
  }
138
148
  initializeInterval() {
139
149
  this.interval ||= window.setInterval(() => {
140
- for (let [e, C] of Object.entries(this.pushEvents)) Logger.debug("Received " + C + " notifications from " + this.pushEventsRef[Number(e)].getName() + " last second");
150
+ for (let [e, t] of Object.entries(this.pushEvents)) A.debug("Received " + t + " notifications from " + this.pushEventsRef[Number(e)].getName() + " last second");
141
151
  this.pushEvents = {}, this.pushEventsRef = {};
142
152
  }, 1e3);
143
153
  }
144
154
  getObjectId(e) {
145
155
  return this.objectsIdMap.has(e) || this.objectsIdMap.set(e, ++this.currentId), this.objectsIdMap.get(e);
146
156
  }
147
- addEvent(e, C) {
157
+ addEvent(e, t) {
148
158
  if (!this.enabled) return;
149
159
  this.initDate ||= Date.now(), this.initializeInterval();
150
- let w = this.getObjectId(e), T = e.getName();
151
- Logger.debug(T + "[" + w + "]." + C);
160
+ let n = this.getObjectId(e), r = e.getName();
161
+ A.debug(r + "[" + n + "]." + t);
152
162
  }
153
163
  incrementNotifications(e) {
154
164
  if (!this.enabled) return;
155
- let C = this.getObjectId(e), w = this.pushEvents[C];
156
- w || (w = 0, this.pushEventsRef[C] = e), this.pushEvents[C] = w + 1;
165
+ let t = this.getObjectId(e), n = this.pushEvents[t];
166
+ n || (n = 0, this.pushEventsRef[t] = e), this.pushEvents[t] = n + 1;
157
167
  }
158
- }(), ContainsIgnoredProviderError_default = class e extends Error {
168
+ }(), de = class e extends Error {
159
169
  static DEFAULT_MESSAGE = "Contains ignored provider";
160
- constructor(C) {
161
- super(C || e.DEFAULT_MESSAGE);
170
+ constructor(t) {
171
+ super(t || e.DEFAULT_MESSAGE);
162
172
  }
163
- }, Provider_default = class e {
173
+ }, j = class e {
164
174
  static _callbackUniqueId = 0;
165
175
  static _uniqueId = 1;
166
176
  id;
@@ -169,10 +179,10 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
169
179
  _eventsCallbacks = [];
170
180
  _monitoringCallbacks = [];
171
181
  constructor() {
172
- this.id = e._uniqueId++, ProvidersLoggerOld_default.addEvent(this, "constructor");
182
+ this.id = e._uniqueId++, ue.addEvent(this, "constructor");
173
183
  }
174
184
  getAvailability() {
175
- return ProvidersOptions_default.ignoreProviders.includes(this.getName()) ? Promise.resolve(new ContainsIgnoredProviderError_default()) : this.availability();
185
+ return D.ignoreProviders.includes(this.getName()) ? Promise.resolve(new de()) : this.availability();
176
186
  }
177
187
  get hasNativeInterface() {
178
188
  return !!this.nativeInterface;
@@ -186,69 +196,73 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
186
196
  get useCameraNatively() {
187
197
  return !1;
188
198
  }
189
- addEventListener(C = null, w = null, T = !0) {
190
- let E = ++e._callbackUniqueId;
199
+ addEventListener(t = null, n = null, r = !0) {
200
+ let i = ++e._callbackUniqueId;
191
201
  if (this._eventsCallbacks.push({
192
- id: E,
193
- onEvent: C || (() => {}),
194
- onError: w || (() => {}),
195
- optional: !T
196
- }), !T || this.state !== "stopped") return E;
202
+ id: i,
203
+ onEvent: t || (() => {}),
204
+ onError: n || (() => {}),
205
+ optional: !r
206
+ }), !r || this.state !== "stopped") return i;
197
207
  this.state = "starting";
198
- let D = Promise.resolve();
199
- return ProvidersOptions_default.checkAvailabilityOnStart && (D = this.getAvailability()), (async () => {
200
- let e = await D;
208
+ let a = Promise.resolve();
209
+ return D.checkAvailabilityOnStart && (a = this.getAvailability()), (async () => {
210
+ let e = await a;
201
211
  if (e) {
202
212
  this.state = "stopped", this.notifyError(e);
203
213
  return;
204
214
  }
205
- ProvidersLoggerOld_default.addEvent(this, "start"), this.start(), this.state = "started", this._monitoringCallbacks.forEach((e) => e.onStarted?.());
206
- })(), E;
215
+ ue.addEvent(this, "start"), this.start(), this.state = "started", this._monitoringCallbacks.forEach((e) => e.onStarted?.());
216
+ })(), i;
207
217
  }
208
218
  removeEventListener(e) {
209
- let C = this._eventsCallbacks.find((C) => C.id === e);
210
- C && (this._eventsCallbacks = this._eventsCallbacks.filter((e) => e !== C), !C.optional && (this._eventsCallbacks.find((e) => !e.optional) || this.state !== "stopped" && (ProvidersLoggerOld_default.addEvent(this, "stop"), this.stop(), this.state = "stopped", this._monitoringCallbacks.forEach((e) => e.onStopped?.()))));
219
+ let t = this._eventsCallbacks.find((t) => t.id === e);
220
+ t && (this._eventsCallbacks = this._eventsCallbacks.filter((e) => e !== t), !t.optional && (this._eventsCallbacks.find((e) => !e.optional) || this.state !== "stopped" && (ue.addEvent(this, "stop"), this.stop(), this.state = "stopped", this._monitoringCallbacks.forEach((e) => e.onStopped?.()))));
211
221
  }
212
- addMonitoringListener(C, w) {
213
- let T = e._callbackUniqueId++;
222
+ addMonitoringListener(t, n) {
223
+ let r = e._callbackUniqueId++;
214
224
  return this._monitoringCallbacks.push({
215
- id: T,
216
- onStarted: C || null,
217
- onStopped: w || null
218
- }), T;
225
+ id: r,
226
+ onStarted: t || null,
227
+ onStopped: n || null
228
+ }), r;
219
229
  }
220
230
  removeMonitoringListener(e) {
221
- this._monitoringCallbacks = this._monitoringCallbacks.filter((C) => C.id !== e);
231
+ this._monitoringCallbacks = this._monitoringCallbacks.filter((t) => t.id !== e);
222
232
  }
223
233
  notify = (e) => {
224
- ProvidersLoggerOld_default.incrementNotifications(this), this._eventsCallbacks.forEach((C) => C.onEvent?.(e)), this._lastEvent = e;
234
+ let t = this._adaptBeforeNotify(e);
235
+ ue.incrementNotifications(this), this._eventsCallbacks.forEach((e) => e.onEvent?.(t)), this._lastEvent = t;
225
236
  };
237
+ _adaptBeforeNotify(e) {
238
+ return e;
239
+ }
226
240
  notifyError = (e) => {
227
- this._eventsCallbacks.forEach(({ id: C, onError: w }) => {
228
- ProvidersOptions_default.stopOnError && this.removeEventListener(C), w?.(e);
241
+ this._eventsCallbacks.forEach(({ id: t, onError: n }) => {
242
+ D.stopOnError && this.removeEventListener(t), n?.(e);
229
243
  });
230
244
  };
231
245
  get lastEvent() {
232
246
  return this._lastEvent;
233
247
  }
234
- }, AvailabilityHelper = class {
248
+ }, M = class {
235
249
  static async every(e) {
236
- for (let C of e) {
237
- let e = await C;
250
+ for (let t of e) {
251
+ let e = await t;
238
252
  if (e) return e;
239
253
  }
240
254
  return null;
241
255
  }
242
256
  static async some(e) {
243
- let C;
244
- for (let w of e) {
245
- let e = await w;
246
- if (e) C ||= e;
257
+ let t;
258
+ for (let n of e) {
259
+ let e = await n;
260
+ if (e) t ||= e;
247
261
  else return null;
248
262
  }
249
- return C || null;
263
+ return t || null;
250
264
  }
251
- }, gnmWmm2020 = [
265
+ }, fe = [
252
266
  [
253
267
  0,
254
268
  0,
@@ -444,7 +458,7 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
444
458
  -1.1,
445
459
  -.3
446
460
  ]
447
- ], hnmWmm2020 = [
461
+ ], pe = [
448
462
  [
449
463
  0,
450
464
  0,
@@ -640,7 +654,7 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
640
654
  0,
641
655
  .5
642
656
  ]
643
- ], gtnmWmm2020 = [
657
+ ], me = [
644
658
  [
645
659
  0,
646
660
  0,
@@ -836,7 +850,7 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
836
850
  0,
837
851
  -.1
838
852
  ]
839
- ], htnmWmm2020 = [
853
+ ], he = [
840
854
  [
841
855
  0,
842
856
  0,
@@ -1032,88 +1046,88 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
1032
1046
  0,
1033
1047
  -.1
1034
1048
  ]
1035
- ], globe = {
1049
+ ], N = {
1036
1050
  a: 6378.137,
1037
1051
  b: 6356.7523142,
1038
1052
  r0: 6371.2
1039
- }, zeroArray2D = function(e, C) {
1053
+ }, ge = function(e, t) {
1040
1054
  return Array(e).fill("").map(function(e) {
1041
- return Array(C).fill(0);
1055
+ return Array(t).fill(0);
1042
1056
  });
1043
- }, julianYearsSince2020 = function() {
1057
+ }, _e = function() {
1044
1058
  return (new Date(Date.now()).valueOf() / 864e5 + 2440587.5 - 2458850) / 365.25;
1045
- }, round = function(e, C) {
1046
- return Number(Math.round(Number(e + "e+" + C)) + "e-" + C);
1047
- }, normalizeInclination = function(e) {
1059
+ }, ve = function(e, t) {
1060
+ return Number(Math.round(Number(e + "e+" + t)) + "e-" + t);
1061
+ }, ye = function(e) {
1048
1062
  return e > 90 ? e - 180 : e < -90 ? e + 180 : e;
1049
- }, deg2rad$1 = function(e) {
1063
+ }, be = function(e) {
1050
1064
  return e * .017453292519943295;
1051
- }, rad2deg$1 = function(e) {
1065
+ }, xe = function(e) {
1052
1066
  return e * 57.29577951308232;
1053
- }, P = zeroArray2D(13, 13), DP = zeroArray2D(13, 13), gnm = zeroArray2D(13, 13), hnm = zeroArray2D(13, 13), sm = Array(13).fill(0), cm = Array(13).fill(0), root = Array(13).fill(0), roots = zeroArray2D(13, 13).map(function(e) {
1067
+ }, P = ge(13, 13), F = ge(13, 13), Se = ge(13, 13), Ce = ge(13, 13), we = Array(13).fill(0), Te = Array(13).fill(0), Ee = Array(13).fill(0), De = ge(13, 13).map(function(e) {
1054
1068
  return e.map(function(e) {
1055
1069
  return [0, 0];
1056
1070
  });
1057
- }), n = 2; n <= 12; n++) root[n] = Math.sqrt((2 * n - 1) / (2 * n));
1058
- for (var m = 0; m <= 12; m++) for (var mm = m * m, n = Math.max(m + 1, 2); n <= 12; n++) roots[m][n][0] = Math.sqrt((n - 1) * (n - 1) - mm), roots[m][n][1] = 1 / Math.sqrt(n * n - mm);
1059
- var field = function(e, C, w) {
1060
- w === void 0 && (w = 0);
1061
- var T = Math.cos(deg2rad$1(e)), E = Math.sin(deg2rad$1(e)), D = Math.sqrt(globe.a ** 2 * T ** 2 + globe.b ** 2 * E ** 2), O = Math.atan2(T * (w * D + globe.a ** 2), E * (w * D + globe.b ** 2)), k = Math.sqrt(w ** 2 + 2 * w * D + (globe.a ** 4 - (globe.a ** 4 - globe.b ** 4) * E ** 2) / (globe.a ** 2 - (globe.a ** 2 - globe.b ** 2) * E ** 2)), A = Math.cos(O), j = Math.sin(O), M = 1 / (j + (j === 0 ? 1e-8 : 0));
1062
- P[0][0] = 1, P[1][1] = j, P[1][0] = A, DP[1][0] = -j, DP[1][1] = A;
1063
- for (var N = 2; N <= 12; N++) P[N][N] = P[N - 1][N - 1] * j * root[N], DP[N][N] = (DP[N - 1][N - 1] * j + P[N - 1][N - 1] * A) * root[N];
1064
- for (var F = 0; F <= 12; F++) for (var N = Math.max(F + 1, 2); N <= 12; N++) P[N][F] = (P[N - 1][F] * A * (2 * N - 1) - P[N - 2][F] * roots[F][N][0]) * roots[F][N][1], DP[N][F] = ((DP[N - 1][F] * A - P[N - 1][F] * j) * (2 * N - 1) - DP[N - 2][F] * roots[F][N][0]) * roots[F][N][1];
1065
- for (var I = julianYearsSince2020(), N = 1; N <= 12; N++) for (var F = 0; F <= 12; F++) gnm[N][F] = gnmWmm2020[N][F] + I * gtnmWmm2020[N][F], hnm[N][F] = hnmWmm2020[N][F] + I * htnmWmm2020[N][F];
1066
- for (var F = 0; F <= 12; F++) sm[F] = Math.sin(F * deg2rad$1(C)), cm[F] = Math.cos(F * deg2rad$1(C));
1067
- for (var L = 0, R = 0, z = 0, B = globe.r0 / k, V = B ** 2, N = 1; N <= 12; N++) {
1068
- for (var H = 0, U = 0, W = 0, F = 0; F <= N; F++) {
1069
- var G = gnm[N][F] * cm[F] + hnm[N][F] * sm[F];
1070
- H += G * P[N][F], U += G * DP[N][F], W += F * (gnm[N][F] * sm[F] - hnm[N][F] * cm[F]) * P[N][F];
1071
+ }), I = 2; I <= 12; I++) Ee[I] = Math.sqrt((2 * I - 1) / (2 * I));
1072
+ for (var L = 0; L <= 12; L++) for (var Oe = L * L, I = Math.max(L + 1, 2); I <= 12; I++) De[L][I][0] = Math.sqrt((I - 1) * (I - 1) - Oe), De[L][I][1] = 1 / Math.sqrt(I * I - Oe);
1073
+ var ke = function(e, t, n) {
1074
+ n === void 0 && (n = 0);
1075
+ var r = Math.cos(be(e)), i = Math.sin(be(e)), a = Math.sqrt(N.a ** 2 * r ** 2 + N.b ** 2 * i ** 2), o = Math.atan2(r * (n * a + N.a ** 2), i * (n * a + N.b ** 2)), s = Math.sqrt(n ** 2 + 2 * n * a + (N.a ** 4 - (N.a ** 4 - N.b ** 4) * i ** 2) / (N.a ** 2 - (N.a ** 2 - N.b ** 2) * i ** 2)), c = Math.cos(o), l = Math.sin(o), u = 1 / (l + (l === 0 ? 1e-8 : 0));
1076
+ P[0][0] = 1, P[1][1] = l, P[1][0] = c, F[1][0] = -l, F[1][1] = c;
1077
+ for (var d = 2; d <= 12; d++) P[d][d] = P[d - 1][d - 1] * l * Ee[d], F[d][d] = (F[d - 1][d - 1] * l + P[d - 1][d - 1] * c) * Ee[d];
1078
+ for (var f = 0; f <= 12; f++) for (var d = Math.max(f + 1, 2); d <= 12; d++) P[d][f] = (P[d - 1][f] * c * (2 * d - 1) - P[d - 2][f] * De[f][d][0]) * De[f][d][1], F[d][f] = ((F[d - 1][f] * c - P[d - 1][f] * l) * (2 * d - 1) - F[d - 2][f] * De[f][d][0]) * De[f][d][1];
1079
+ for (var p = _e(), d = 1; d <= 12; d++) for (var f = 0; f <= 12; f++) Se[d][f] = fe[d][f] + p * me[d][f], Ce[d][f] = pe[d][f] + p * he[d][f];
1080
+ for (var f = 0; f <= 12; f++) we[f] = Math.sin(f * be(t)), Te[f] = Math.cos(f * be(t));
1081
+ for (var m = 0, h = 0, g = 0, _ = N.r0 / s, v = _ ** 2, d = 1; d <= 12; d++) {
1082
+ for (var y = 0, b = 0, x = 0, f = 0; f <= d; f++) {
1083
+ var S = Se[d][f] * Te[f] + Ce[d][f] * we[f];
1084
+ y += S * P[d][f], b += S * F[d][f], x += f * (Se[d][f] * we[f] - Ce[d][f] * Te[f]) * P[d][f];
1071
1085
  }
1072
- V *= B, L += (N + 1) * H * V, R -= U * V, z += W * V * M;
1086
+ v *= _, m += (d + 1) * y * v, h -= b * v, g += x * v * u;
1073
1087
  }
1074
- var K = O - (Math.PI / 2 - deg2rad$1(e)), q = Math.sin(K), J = Math.cos(K), Y = -R * J - L * q, X = z, Z = R * q - L * J, Q = Y !== 0 || X !== 0 ? round(rad2deg$1(Math.atan2(X, Y)), 2) : 0, $ = X !== 0 || Y !== 0 && Z !== 0 ? normalizeInclination(rad2deg$1(Math.atan2(Z * Math.sin(Math.atan2(X, Y)), X))) : 0;
1088
+ var C = o - (Math.PI / 2 - be(e)), w = Math.sin(C), ee = Math.cos(C), T = -h * ee - m * w, E = g, te = h * w - m * ee, ne = T !== 0 || E !== 0 ? ve(xe(Math.atan2(E, T)), 2) : 0, re = E !== 0 || T !== 0 && te !== 0 ? ye(xe(Math.atan2(te * Math.sin(Math.atan2(E, T)), E))) : 0;
1075
1089
  return {
1076
- declination: round(Q, 2),
1077
- inclination: round($, 2),
1078
- intensity: Math.round(Math.sqrt(Y ** 2 + X ** 2 + Z ** 2)),
1079
- northIntensity: Math.round(Y),
1080
- eastIntensity: Math.round(X),
1081
- verticalIntensity: Math.round(Z),
1082
- horizontalIntensity: Math.round(Math.sqrt(Y ** 2 + X ** 2))
1090
+ declination: ve(ne, 2),
1091
+ inclination: ve(re, 2),
1092
+ intensity: Math.round(Math.sqrt(T ** 2 + E ** 2 + te ** 2)),
1093
+ northIntensity: Math.round(T),
1094
+ eastIntensity: Math.round(E),
1095
+ verticalIntensity: Math.round(te),
1096
+ horizontalIntensity: Math.round(Math.sqrt(T ** 2 + E ** 2))
1083
1097
  };
1084
- }, AskImuOnDesktopError_default = class e extends Error {
1098
+ }, Ae = class e extends Error {
1085
1099
  static DEFAULT_MESSAGE = "It seems that you ask for IMU events on a desktop browser";
1086
- constructor(C) {
1087
- super(C || e.DEFAULT_MESSAGE);
1100
+ constructor(t) {
1101
+ super(t || e.DEFAULT_MESSAGE);
1088
1102
  }
1089
- }, MissingSensorError_default = class e extends Error {
1103
+ }, R = class e extends Error {
1090
1104
  static DEFAULT_MESSAGE = "Impossible to retrieve events, a sensor is missing";
1091
- constructor(C) {
1092
- super(C || e.DEFAULT_MESSAGE);
1105
+ constructor(t) {
1106
+ super(t || e.DEFAULT_MESSAGE);
1093
1107
  }
1094
1108
  from(e) {
1095
1109
  return this.message += " from " + e, this;
1096
1110
  }
1097
- }, MissingMagnetometerError_default = class extends MissingSensorError_default {
1111
+ }, je = class extends R {
1098
1112
  constructor(e) {
1099
1113
  super(e);
1100
1114
  }
1101
- }, GeolocationApiMissingError_default = class e extends Error {
1115
+ }, Me = class e extends Error {
1102
1116
  static DEFAULT_MESSAGE = "Geolocation api is missing";
1103
- constructor(C) {
1104
- super(C || e.DEFAULT_MESSAGE);
1117
+ constructor(t) {
1118
+ super(t || e.DEFAULT_MESSAGE);
1105
1119
  }
1106
- }, GeolocationPermissionDeniedError_default = class e extends Error {
1120
+ }, Ne = class e extends Error {
1107
1121
  static DEFAULT_MESSAGE = "Geolocation permission denied";
1108
- constructor(C) {
1109
- super(C || e.DEFAULT_MESSAGE);
1122
+ constructor(t) {
1123
+ super(t || e.DEFAULT_MESSAGE);
1110
1124
  }
1111
- }, GeolocationPositionUnavailableError_default = class e extends Error {
1125
+ }, Pe = class e extends Error {
1112
1126
  static DEFAULT_MESSAGE = "Geolocation position unavailable";
1113
- constructor(C) {
1114
- super(C || e.DEFAULT_MESSAGE);
1127
+ constructor(t) {
1128
+ super(t || e.DEFAULT_MESSAGE);
1115
1129
  }
1116
- }, Constants_default = { DEFAULT_ALTITUDE: 1.6 }, GnssWifiProvider_default = new class e extends Provider_default {
1130
+ }, Fe = { DEFAULT_ALTITUDE: 1.6 }, Ie = new class e extends j {
1117
1131
  static DEFAULT_DISCARD_POSITIONS_ABOVE = 50;
1118
1132
  discardPositionsAbove = e.DEFAULT_DISCARD_POSITIONS_ABOVE;
1119
1133
  enableHighAccuracy = !0;
@@ -1127,7 +1141,7 @@ var field = function(e, C, w) {
1127
1141
  };
1128
1142
  }
1129
1143
  availability() {
1130
- return typeof navigator == "object" && navigator.geolocation ? Promise.resolve() : Promise.resolve(new GeolocationApiMissingError_default());
1144
+ return typeof navigator == "object" && navigator.geolocation ? Promise.resolve() : Promise.resolve(new Me());
1131
1145
  }
1132
1146
  start() {
1133
1147
  navigator.geolocation.getCurrentPosition(this.onNewPosition, this.onPositionError, this.positionOptions), setTimeout(() => {
@@ -1138,38 +1152,38 @@ var field = function(e, C, w) {
1138
1152
  this.geoLocationId !== void 0 && navigator.geolocation.clearWatch(this.geoLocationId);
1139
1153
  }
1140
1154
  onNewPosition = (e) => {
1141
- let { coords: C } = e;
1142
- if (!C) return;
1143
- let w;
1144
- C.heading && (w = deg2rad(C.heading));
1145
- let T = TimeUtils.unixTimestampToPreciseTime(e.timestamp) / 1e3, E = new UserPosition(C.latitude, C.longitude, Constants_default.DEFAULT_ALTITUDE, null, T, C.accuracy, w);
1146
- this.enableHighAccuracy && typeof this.discardPositionsAbove == "number" && C.accuracy > this.discardPositionsAbove || this.notify(E);
1155
+ let { coords: t } = e;
1156
+ if (!t) return;
1157
+ let n;
1158
+ t.heading && (n = m(t.heading));
1159
+ let r = C.unixTimestampToPreciseTime(e.timestamp) / 1e3, i = new o(t.latitude, t.longitude, Fe.DEFAULT_ALTITUDE, null, r, t.accuracy, n);
1160
+ this.enableHighAccuracy && typeof this.discardPositionsAbove == "number" && t.accuracy > this.discardPositionsAbove || this.notify(i);
1147
1161
  };
1148
1162
  onPositionError = (e) => {
1149
- Logger.warn(`[Providers] watchPosition error: [${e.code}] ${e.message}`);
1150
- let C;
1163
+ A.warn(`[Providers] watchPosition error: [${e.code}] ${e.message}`);
1164
+ let t;
1151
1165
  switch (e.code) {
1152
1166
  case 1:
1153
- C = new GeolocationPermissionDeniedError_default(e.message);
1167
+ t = new Ne(e.message);
1154
1168
  break;
1155
1169
  case 2:
1156
- C = new GeolocationPositionUnavailableError_default(e.message);
1170
+ t = new Pe(e.message);
1157
1171
  break;
1158
- default: C = Error(e.message);
1172
+ default: t = Error(e.message);
1159
1173
  }
1160
- this.notifyError(C);
1174
+ this.notifyError(t);
1161
1175
  };
1162
- }(), MissingArCoreError_default = class e extends Error {
1176
+ }(), Le = class e extends Error {
1163
1177
  static DEFAULT_MESSAGE = "ARCore is missing";
1164
- constructor(C) {
1165
- super(C || e.DEFAULT_MESSAGE);
1178
+ constructor(t) {
1179
+ super(t || e.DEFAULT_MESSAGE);
1166
1180
  }
1167
- }, MissingNativeInterfaceError_default = class e extends Error {
1181
+ }, Re = class e extends Error {
1168
1182
  static DEFAULT_MESSAGE = "Native interface is missing. You are maybe trying to execute a code which is not available in a web browser";
1169
- constructor(C) {
1170
- super(C || e.DEFAULT_MESSAGE);
1183
+ constructor(t) {
1184
+ super(t || e.DEFAULT_MESSAGE);
1171
1185
  }
1172
- }, ArCoreProvider_default = new class e extends Provider_default {
1186
+ }, z = new class e extends j {
1173
1187
  static Payload = {
1174
1188
  Pose: {
1175
1189
  ref: 1,
@@ -1188,7 +1202,7 @@ var field = function(e, C, w) {
1188
1202
  size: 1
1189
1203
  }
1190
1204
  };
1191
- static RELATIVE_ATTITUDE_DRIFT = deg2rad(3) / 60;
1205
+ static RELATIVE_ATTITUDE_DRIFT = m(3) / 60;
1192
1206
  _nativeProvider;
1193
1207
  previousPosition = [
1194
1208
  0,
@@ -1198,7 +1212,7 @@ var field = function(e, C, w) {
1198
1212
  getName = () => "ArCore";
1199
1213
  availability() {
1200
1214
  try {
1201
- if (!this.nativeProvider.checkAvailability()) return Promise.resolve(new MissingArCoreError_default());
1215
+ if (!this.nativeProvider.checkAvailability()) return Promise.resolve(new Le());
1202
1216
  } catch (e) {
1203
1217
  return Promise.resolve(e);
1204
1218
  }
@@ -1215,28 +1229,28 @@ var field = function(e, C, w) {
1215
1229
  let e = JSON.parse(this.nativeProvider.getInfo());
1216
1230
  e.length > 1 && this.parsePayload(e), requestAnimationFrame(this.pullDataLoop);
1217
1231
  };
1218
- parsePayload(C) {
1219
- let w = C[0], T = 1, E, O, k, A, j = TimeUtils.preciseTime() / 1e3;
1220
- if (w & e.Payload.Pose.ref) {
1221
- E = new RelativeAttitude(C.slice(T, T + 4), j, e.RELATIVE_ATTITUDE_DRIFT);
1222
- let w = [
1223
- C[T + 4],
1224
- C[T + 5],
1225
- C[T + 6]
1232
+ parsePayload(t) {
1233
+ let n = t[0], r = 1, i, o, s, c, l = C.preciseTime() / 1e3;
1234
+ if (n & e.Payload.Pose.ref) {
1235
+ i = new ie(t.slice(r, r + 4), l, e.RELATIVE_ATTITUDE_DRIFT);
1236
+ let n = [
1237
+ t[r + 4],
1238
+ t[r + 5],
1239
+ t[r + 6]
1226
1240
  ];
1227
- O = new RelativePosition(w[0] - this.previousPosition[0], w[1] - this.previousPosition[1], w[2] - this.previousPosition[2], j, 1e-4), this.previousPosition = w, T += e.Payload.Pose.size;
1241
+ o = new a(n[0] - this.previousPosition[0], n[1] - this.previousPosition[1], n[2] - this.previousPosition[2], l, 1e-4), this.previousPosition = n, r += e.Payload.Pose.size;
1228
1242
  }
1229
- w & e.Payload.Barcode.ref && (A = C[T], T += e.Payload.Barcode.size), w & e.Payload.ProjMat.ref && (k = C.slice(T, T + e.Payload.ProjMat.size), T += e.Payload.ProjMat.size), this.notify({
1230
- relativePosition: O,
1231
- relativeAttitude: E,
1232
- ...A && { barcode: A },
1233
- ...k && { cameraProjection: k }
1243
+ n & e.Payload.Barcode.ref && (c = t[r], r += e.Payload.Barcode.size), n & e.Payload.ProjMat.ref && (s = t.slice(r, r + e.Payload.ProjMat.size), r += e.Payload.ProjMat.size), this.notify({
1244
+ relativePosition: o,
1245
+ relativeAttitude: i,
1246
+ ...c && { barcode: c },
1247
+ ...s && { cameraProjection: s }
1234
1248
  });
1235
1249
  }
1236
1250
  get nativeProvider() {
1237
1251
  if (!this._nativeProvider) {
1238
- if (!this.nativeInterface) throw new MissingNativeInterfaceError_default();
1239
- if (this._nativeProvider = this.nativeInterface.getArCoreProvider(), !this._nativeProvider) throw new MissingArCoreError_default();
1252
+ if (!this.nativeInterface) throw new Re();
1253
+ if (this._nativeProvider = this.nativeInterface.getArCoreProvider(), !this._nativeProvider) throw new Le();
1240
1254
  }
1241
1255
  return this._nativeProvider;
1242
1256
  }
@@ -1257,36 +1271,36 @@ var field = function(e, C, w) {
1257
1271
  get useCameraNatively() {
1258
1272
  return !0;
1259
1273
  }
1260
- }(), GeoRelativePositionFromArCoreProvider_default = new class extends Provider_default {
1274
+ }(), ze = new class extends j {
1261
1275
  absoluteAttitudeProviderId;
1262
1276
  arCoreProviderId;
1263
1277
  absoluteAttitudeEvent;
1264
1278
  getName = () => "GeoRelativePositionFromArCore";
1265
1279
  availability() {
1266
- return AvailabilityHelper.every([ArCoreProvider_default.getAvailability(), AbsoluteAttitudeProvider_default.getAvailability()]);
1280
+ return M.every([z.getAvailability(), X.getAvailability()]);
1267
1281
  }
1268
1282
  start() {
1269
- this.arCoreProviderId = ArCoreProvider_default.addEventListener(this.onArCoreEvents, this.notifyError), this.absoluteAttitudeProviderId = AbsoluteAttitudeProvider_default.addEventListener((e) => this.absoluteAttitudeEvent = e, this.notifyError);
1283
+ this.arCoreProviderId = z.addEventListener(this.onArCoreEvents, this.notifyError), this.absoluteAttitudeProviderId = X.addEventListener((e) => this.absoluteAttitudeEvent = e, this.notifyError);
1270
1284
  }
1271
1285
  stop() {
1272
- ArCoreProvider_default.removeEventListener(this.arCoreProviderId), AbsoluteAttitudeProvider_default.removeEventListener(this.absoluteAttitudeProviderId);
1286
+ z.removeEventListener(this.arCoreProviderId), X.removeEventListener(this.absoluteAttitudeProviderId);
1273
1287
  }
1274
1288
  onArCoreEvents = (e) => {
1275
- let C = e.relativeAttitude, w = e.relativePosition;
1276
- C && w && this.absoluteAttitudeEvent && this.compute(w, C, this.absoluteAttitudeEvent);
1289
+ let t = e.relativeAttitude, n = e.relativePosition;
1290
+ t && n && this.absoluteAttitudeEvent && this.compute(n, t, this.absoluteAttitudeEvent);
1277
1291
  };
1278
- compute(e, C, w) {
1279
- let E = w.heading - C.heading, D = Math.cos(E) * e.x - Math.sin(E) * e.z, O = -Math.sin(E) * e.x - Math.cos(E) * e.z, k = e.y, A = new GeoRelativePosition(D, O, k, e.time, 0, w.heading);
1280
- this.notify(A);
1292
+ compute(e, t, n) {
1293
+ let i = n.heading - t.heading, a = Math.cos(i) * e.x - Math.sin(i) * e.z, o = -Math.sin(i) * e.x - Math.cos(i) * e.z, s = e.y, c = new r(a, o, s, e.time, 0, n.heading);
1294
+ this.notify(c);
1281
1295
  }
1282
- }(), DEFAULT_RELATIVE_NOISES = {
1296
+ }(), Be = {
1283
1297
  acc: .5,
1284
1298
  gyr: .3
1285
- }, DEFAULT_ABSOLUTE_NOISES = {
1299
+ }, Ve = {
1286
1300
  acc: .5,
1287
1301
  gyr: .3,
1288
1302
  yc: 2
1289
- }, EkfAttitude_default = class {
1303
+ }, He = class {
1290
1304
  P;
1291
1305
  accRef;
1292
1306
  cRef;
@@ -1296,26 +1310,26 @@ var field = function(e, C, w) {
1296
1310
  0,
1297
1311
  0,
1298
1312
  1
1299
- ], C = [
1313
+ ], t = [
1300
1314
  -1,
1301
1315
  0,
1302
1316
  0
1303
1317
  ]) {
1304
- this.accRef = e, this.cRef = C, this.P = Matrix4.fromDiagVector([
1318
+ this.accRef = e, this.cRef = t, this.P = l.fromDiagVector([
1305
1319
  ,
1306
1320
  ,
1307
1321
  ,
1308
1322
  ,
1309
- ].fill(.1 ** 2)), this.quaternion = null, this.noises = {}, this.setRelativeNoises(DEFAULT_RELATIVE_NOISES), this.setAbsoluteNoises(DEFAULT_ABSOLUTE_NOISES);
1323
+ ].fill(.1 ** 2)), this.quaternion = null, this.noises = {}, this.setRelativeNoises(Be), this.setAbsoluteNoises(Ve);
1310
1324
  }
1311
1325
  setRelativeNoises(e) {
1312
1326
  this.noises.relative = {
1313
- acc: Matrix3.diag([
1327
+ acc: c.diag([
1314
1328
  ,
1315
1329
  ,
1316
1330
  ,
1317
1331
  ].fill(e.acc ** 2)),
1318
- gyr: Matrix3.diag([
1332
+ gyr: c.diag([
1319
1333
  ,
1320
1334
  ,
1321
1335
  ,
@@ -1324,90 +1338,90 @@ var field = function(e, C, w) {
1324
1338
  }
1325
1339
  setAbsoluteNoises(e) {
1326
1340
  this.noises.absolute = {
1327
- acc: Matrix3.diag([
1341
+ acc: c.diag([
1328
1342
  ,
1329
1343
  ,
1330
1344
  ,
1331
1345
  ].fill(e.acc ** 2)),
1332
- gyr: Matrix3.diag([
1346
+ gyr: c.diag([
1333
1347
  ,
1334
1348
  ,
1335
1349
  ,
1336
1350
  ].fill(e.gyr ** 2)),
1337
- yc: Matrix3.diag([
1351
+ yc: c.diag([
1338
1352
  ,
1339
1353
  ,
1340
1354
  ,
1341
1355
  ].fill(e.yc ** 2))
1342
1356
  };
1343
1357
  }
1344
- tryInitialize(e, C) {
1345
- let w = Vector3.normalize(e);
1346
- if (C) {
1347
- let e = Vector3.normalize(C), T = Vector3.normalize(Vector3.cross(e, w)), E = Vector3.cross(w, T), D = [
1358
+ tryInitialize(e, t) {
1359
+ let n = p.normalize(e);
1360
+ if (t) {
1361
+ let e = p.normalize(t), r = p.normalize(p.cross(e, n)), i = p.cross(n, r), a = [
1348
1362
  [
1349
- T[0],
1350
- E[0],
1351
- w[0]
1363
+ r[0],
1364
+ i[0],
1365
+ n[0]
1352
1366
  ],
1353
1367
  [
1354
- T[1],
1355
- E[1],
1356
- w[1]
1368
+ r[1],
1369
+ i[1],
1370
+ n[1]
1357
1371
  ],
1358
1372
  [
1359
- T[2],
1360
- E[2],
1361
- w[2]
1373
+ r[2],
1374
+ i[2],
1375
+ n[2]
1362
1376
  ]
1363
1377
  ];
1364
- this.quaternion = Quaternion.fromMatrix3Matlab(D);
1378
+ this.quaternion = u.fromMatrix3Matlab(a);
1365
1379
  } else {
1366
- let e = Vector3.dot(w, this.accRef) + 1, C = Vector3.cross(w, this.accRef), T = [
1380
+ let e = p.dot(n, this.accRef) + 1, t = p.cross(n, this.accRef), r = [
1367
1381
  e,
1368
- C[0],
1369
- C[1],
1370
- C[2]
1382
+ t[0],
1383
+ t[1],
1384
+ t[2]
1371
1385
  ];
1372
- T = Quaternion.normalize(T), this.quaternion = T;
1386
+ r = u.normalize(r), this.quaternion = r;
1373
1387
  }
1374
1388
  return this.quaternion;
1375
1389
  }
1376
- update(e, C, w, T) {
1377
- if (!this.quaternion) return this.tryInitialize(C, T);
1378
- let E = this.quaternion, D = E, O = Vector3.multiplyScalar(w, .5 * e), N = this.computeC([
1390
+ update(e, t, n, r) {
1391
+ if (!this.quaternion) return this.tryInitialize(t, r);
1392
+ let i = this.quaternion, a = i, o = p.multiplyScalar(n, .5 * e), d = this.computeC([
1379
1393
  1,
1380
- O[0],
1381
- O[1],
1382
- O[2]
1383
- ]), L = Matrix4.multiplyVector(N, E), R = Matrix3.diag([
1384
- D[0],
1385
- D[0],
1386
- D[0]
1387
- ]), z = Matrix3.skew([
1388
- D[1],
1389
- D[2],
1390
- D[3]
1391
- ]), B = [
1392
- -1 * D[1],
1393
- -1 * D[2],
1394
- -1 * D[3]
1395
- ], V = Matrix.concatRow([B], Matrix3.sum(z, R)), H = Matrix4.multiplyScalar(Matrix.multiply(Matrix.multiply(V, this.noises[T ? "absolute" : "relative"].gyr), Matrix.transpose(V)), (e / 2) ** 2), U = Matrix4.sum(Matrix4.multiply(Matrix4.multiply(N, this.P), Matrix4.transpose(N)), H), W = Vector3.normalize(C), G, K, q;
1396
- if (T) {
1397
- let e = Vector3.normalize(T), C = Vector3.cross(W, e), w = Vector3.normalize(C), E = Vector3.subtract(w, Quaternion.rotateMatlab(L, this.cRef)), D = Vector3.subtract(W, Quaternion.rotateMatlab(L, this.accRef));
1398
- G = Vector.concat(E, D);
1399
- let O = this.jacobianES(L, this.cRef), j = this.jacobianES(L, this.accRef);
1400
- q = Matrix.concatRow(O, j);
1401
- let N = Matrix.concatLine(this.noises.absolute.yc, Matrix3.zeros), R = Matrix.concatLine(Matrix3.zeros, this.noises.absolute.acc), z = Matrix.concatRow(N, R);
1402
- K = Matrix.multiply(Matrix.multiply(U, Matrix.transpose(q)), Matrix.inverse(Matrix.sum(Matrix.multiply(Matrix.multiply(q, U), Matrix.transpose(q)), z)));
1394
+ o[0],
1395
+ o[1],
1396
+ o[2]
1397
+ ]), m = l.multiplyVector(d, i), h = c.diag([
1398
+ a[0],
1399
+ a[0],
1400
+ a[0]
1401
+ ]), g = c.skew([
1402
+ a[1],
1403
+ a[2],
1404
+ a[3]
1405
+ ]), _ = [
1406
+ -1 * a[1],
1407
+ -1 * a[2],
1408
+ -1 * a[3]
1409
+ ], v = s.concatRow([_], c.sum(g, h)), y = l.multiplyScalar(s.multiply(s.multiply(v, this.noises[r ? "absolute" : "relative"].gyr), s.transpose(v)), (e / 2) ** 2), b = l.sum(l.multiply(l.multiply(d, this.P), l.transpose(d)), y), x = p.normalize(t), S, C, w;
1410
+ if (r) {
1411
+ let e = p.normalize(r), t = p.cross(x, e), n = p.normalize(t), i = p.subtract(n, u.rotateMatlab(m, this.cRef)), a = p.subtract(x, u.rotateMatlab(m, this.accRef));
1412
+ S = f.concat(i, a);
1413
+ let o = this.jacobianES(m, this.cRef), l = this.jacobianES(m, this.accRef);
1414
+ w = s.concatRow(o, l);
1415
+ let d = s.concatLine(this.noises.absolute.yc, c.zeros), h = s.concatLine(c.zeros, this.noises.absolute.acc), g = s.concatRow(d, h);
1416
+ C = s.multiply(s.multiply(b, s.transpose(w)), s.inverse(s.sum(s.multiply(s.multiply(w, b), s.transpose(w)), g)));
1403
1417
  } else {
1404
- G = Vector3.subtract(W, Quaternion.rotateMatlab(L, this.accRef)), q = this.jacobianES(L, this.accRef);
1418
+ S = p.subtract(x, u.rotateMatlab(m, this.accRef)), w = this.jacobianES(m, this.accRef);
1405
1419
  let e = this.noises.relative.acc;
1406
- K = Matrix.multiply(Matrix.multiply(U, Matrix.transpose(q)), Matrix3.inverse(Matrix3.sum(Matrix.multiply(Matrix.multiply(q, U), Matrix.transpose(q)), e)));
1420
+ C = s.multiply(s.multiply(b, s.transpose(w)), c.inverse(c.sum(s.multiply(s.multiply(w, b), s.transpose(w)), e)));
1407
1421
  }
1408
- E = Quaternion.sum(L, Matrix.multiplyVector(K, G));
1409
- let J = Matrix4.multiply(Matrix4.subtract(Matrix4.identity, Matrix.multiply(K, q)), U);
1410
- return E = Quaternion.normalize(E), this.quaternion = E, this.P = J, E;
1422
+ i = u.sum(m, s.multiplyVector(C, S));
1423
+ let ee = l.multiply(l.subtract(l.identity, s.multiply(C, w)), b);
1424
+ return i = u.normalize(i), this.quaternion = i, this.P = ee, i;
1411
1425
  }
1412
1426
  computeC(e) {
1413
1427
  return [
@@ -1437,38 +1451,38 @@ var field = function(e, C, w) {
1437
1451
  ]
1438
1452
  ];
1439
1453
  }
1440
- jacobianES(e, C) {
1441
- let [w, T, E, D] = e, [O, k, A] = C;
1454
+ jacobianES(e, t) {
1455
+ let [n, r, i, a] = e, [o, s, c] = t;
1442
1456
  return [
1443
1457
  [
1444
- 2 * D * k - 2 * E * A,
1445
- 2 * E * k + 2 * D * A,
1446
- 2 * T * k - 2 * w * A - 4 * E * O,
1447
- 2 * w * k + 2 * T * A - 4 * D * O
1458
+ 2 * a * s - 2 * i * c,
1459
+ 2 * i * s + 2 * a * c,
1460
+ 2 * r * s - 2 * n * c - 4 * i * o,
1461
+ 2 * n * s + 2 * r * c - 4 * a * o
1448
1462
  ],
1449
1463
  [
1450
- 2 * T * A - 2 * D * O,
1451
- 2 * w * A - 4 * T * k + 2 * E * O,
1452
- 2 * T * O + 2 * D * A,
1453
- 2 * E * A - 2 * w * O - 4 * D * k
1464
+ 2 * r * c - 2 * a * o,
1465
+ 2 * n * c - 4 * r * s + 2 * i * o,
1466
+ 2 * r * o + 2 * a * c,
1467
+ 2 * i * c - 2 * n * o - 4 * a * s
1454
1468
  ],
1455
1469
  [
1456
- 2 * E * O - 2 * T * k,
1457
- 2 * D * O - 4 * T * A - 2 * w * k,
1458
- 2 * w * O - 4 * E * A + 2 * D * k,
1459
- 2 * T * O + 2 * E * k
1470
+ 2 * i * o - 2 * r * s,
1471
+ 2 * a * o - 4 * r * c - 2 * n * s,
1472
+ 2 * n * o - 4 * i * c + 2 * a * s,
1473
+ 2 * r * o + 2 * i * s
1460
1474
  ]
1461
1475
  ];
1462
1476
  }
1463
- }, ImuProvider_default = new class extends Provider_default {
1477
+ }, B = new class extends j {
1464
1478
  getName = () => "IMU";
1465
1479
  availability() {
1466
- return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError_default());
1480
+ return S.isMobile ? Promise.resolve() : Promise.resolve(new Ae());
1467
1481
  }
1468
1482
  start() {
1469
- let e = () => window.addEventListener("devicemotion", this.parseDeviceMotionEvent, !0), C = DeviceMotionEvent.requestPermission || void 0;
1470
- C ? C().then((C) => {
1471
- if (C !== "granted") throw Error("Permission not granted");
1483
+ let e = () => window.addEventListener("devicemotion", this.parseDeviceMotionEvent, !0), t = DeviceMotionEvent.requestPermission || void 0;
1484
+ t ? t().then((t) => {
1485
+ if (t !== "granted") throw Error("Permission not granted");
1472
1486
  e();
1473
1487
  }).catch(this.notifyError) : e();
1474
1488
  }
@@ -1476,174 +1490,174 @@ var field = function(e, C, w) {
1476
1490
  window.removeEventListener("devicemotion", this.parseDeviceMotionEvent, !0);
1477
1491
  }
1478
1492
  parseDeviceMotionEvent = (e) => {
1479
- let C = e.timeStamp / 1e3, w;
1493
+ let t = e.timeStamp / 1e3, n;
1480
1494
  if (e.accelerationIncludingGravity) {
1481
- let { x: C, y: T, z: E } = e.accelerationIncludingGravity;
1482
- typeof C == "number" && typeof T == "number" && typeof E == "number" && (w = [
1483
- C,
1484
- T,
1485
- E
1486
- ], (BrowserUtils.getName() === Browser.SAFARI || BrowserUtils.getName() === Browser.IOS_WEBVIEW) && (w[0] *= -1, w[1] *= -1, w[2] *= -1));
1495
+ let { x: t, y: r, z: i } = e.accelerationIncludingGravity;
1496
+ typeof t == "number" && typeof r == "number" && typeof i == "number" && (n = [
1497
+ t,
1498
+ r,
1499
+ i
1500
+ ], (S.getName() === x.SAFARI || S.getName() === x.IOS_WEBVIEW) && (n[0] *= -1, n[1] *= -1, n[2] *= -1));
1487
1501
  }
1488
- let T;
1502
+ let r;
1489
1503
  if (e.rotationRate) {
1490
- let { alpha: C, beta: w, gamma: E } = e.rotationRate;
1491
- typeof C == "number" && typeof w == "number" && typeof E == "number" && (T = [
1492
- deg2rad(C),
1493
- deg2rad(w),
1494
- deg2rad(E)
1504
+ let { alpha: t, beta: n, gamma: i } = e.rotationRate;
1505
+ typeof t == "number" && typeof n == "number" && typeof i == "number" && (r = [
1506
+ m(t),
1507
+ m(n),
1508
+ m(i)
1495
1509
  ]);
1496
1510
  }
1497
- (w || T) && this.notify({
1498
- ...w && { acceleration: {
1499
- timestamp: C,
1500
- values: w
1511
+ (n || r) && this.notify({
1512
+ ...n && { acceleration: {
1513
+ timestamp: t,
1514
+ values: n
1501
1515
  } },
1502
- ...T && { angularRate: {
1503
- timestamp: C,
1504
- values: T
1516
+ ...r && { angularRate: {
1517
+ timestamp: t,
1518
+ values: r
1505
1519
  } }
1506
1520
  });
1507
1521
  };
1508
- }(), MissingAccelerometerError_default = class e extends MissingSensorError_default {
1522
+ }(), Ue = class e extends R {
1509
1523
  static DEFAULT_MESSAGE = "Impossible to retrieve Acceleration data";
1510
- constructor(C) {
1511
- super(C || e.DEFAULT_MESSAGE);
1524
+ constructor(t) {
1525
+ super(t || e.DEFAULT_MESSAGE);
1512
1526
  }
1513
- }, AccelerometerProvider_default = new class extends Provider_default {
1527
+ }, V = new class extends j {
1514
1528
  imuProviderId;
1515
1529
  getName = () => "Accelerometer";
1516
- availability = () => ImuProvider_default.getAvailability();
1530
+ availability = () => B.getAvailability();
1517
1531
  start() {
1518
- this.imuProviderId = ImuProvider_default.addEventListener((e) => {
1519
- e.acceleration ? this.notify(e.acceleration) : this.notifyError(new MissingAccelerometerError_default().from("devicemotion"));
1532
+ this.imuProviderId = B.addEventListener((e) => {
1533
+ e.acceleration ? this.notify(e.acceleration) : this.notifyError(new Ue().from("devicemotion"));
1520
1534
  }, this.notifyError);
1521
1535
  }
1522
1536
  stop() {
1523
- ImuProvider_default.removeEventListener(this.imuProviderId);
1537
+ B.removeEventListener(this.imuProviderId);
1524
1538
  }
1525
- }(), MissingGyroscopeError_default = class extends MissingSensorError_default {
1539
+ }(), We = class extends R {
1526
1540
  static DEFAULT_MESSAGE = "Impossible to retrieve Angular Rate data";
1527
1541
  constructor(e) {
1528
- super(e || MissingSensorError_default.DEFAULT_MESSAGE);
1542
+ super(e || R.DEFAULT_MESSAGE);
1529
1543
  }
1530
- }, GyroscopeProvider_default = new class extends Provider_default {
1544
+ }, H = new class extends j {
1531
1545
  imuProviderId;
1532
1546
  getName = () => "Gyroscope";
1533
- availability = () => ImuProvider_default.getAvailability();
1547
+ availability = () => B.getAvailability();
1534
1548
  start() {
1535
- this.imuProviderId = ImuProvider_default.addEventListener((e) => {
1536
- e.angularRate ? this.notify(e.angularRate) : this.notifyError(new MissingGyroscopeError_default().from("devicemotion"));
1549
+ this.imuProviderId = B.addEventListener((e) => {
1550
+ e.angularRate ? this.notify(e.angularRate) : this.notifyError(new We().from("devicemotion"));
1537
1551
  }, this.notifyError);
1538
1552
  }
1539
1553
  stop() {
1540
- ImuProvider_default.removeEventListener(this.imuProviderId);
1554
+ B.removeEventListener(this.imuProviderId);
1541
1555
  }
1542
- }(), RelativeAttitudeFromEkfProvider_default = new class e extends Provider_default {
1543
- static DEFAULT_DRIFT = deg2rad(5) / 60;
1556
+ }(), Ge = new class e extends j {
1557
+ static DEFAULT_DRIFT = m(5) / 60;
1544
1558
  accelerometerProviderId;
1545
- ekfAttitude = new EkfAttitude_default();
1559
+ ekfAttitude = new He();
1546
1560
  gyroscopeEvent;
1547
1561
  gyroscopeProviderId;
1548
1562
  lastTimestamp = 0;
1549
1563
  getName = () => "RelativeAttitudeFromEkf";
1550
1564
  availability() {
1551
- return AvailabilityHelper.every([AccelerometerProvider_default.getAvailability(), GyroscopeProvider_default.getAvailability()]);
1565
+ return M.every([V.getAvailability(), H.getAvailability()]);
1552
1566
  }
1553
1567
  start() {
1554
- this.accelerometerProviderId = AccelerometerProvider_default.addEventListener((e) => this.onAccelerometerEvent(e), (e) => this.notifyError(e)), this.gyroscopeProviderId = GyroscopeProvider_default.addEventListener((e) => this.gyroscopeEvent = e, (e) => this.notifyError(e));
1568
+ this.accelerometerProviderId = V.addEventListener((e) => this.onAccelerometerEvent(e), (e) => this.notifyError(e)), this.gyroscopeProviderId = H.addEventListener((e) => this.gyroscopeEvent = e, (e) => this.notifyError(e));
1555
1569
  }
1556
1570
  stop() {
1557
- AccelerometerProvider_default.removeEventListener(this.accelerometerProviderId), GyroscopeProvider_default.removeEventListener(this.gyroscopeProviderId);
1571
+ V.removeEventListener(this.accelerometerProviderId), H.removeEventListener(this.gyroscopeProviderId);
1558
1572
  }
1559
- onAccelerometerEvent = (C) => {
1573
+ onAccelerometerEvent = (t) => {
1560
1574
  if (!this.gyroscopeEvent) return;
1561
- let { values: w, timestamp: T } = C;
1575
+ let { values: n, timestamp: r } = t;
1562
1576
  if (this.lastTimestamp === 0) {
1563
- this.lastTimestamp = T;
1577
+ this.lastTimestamp = r;
1564
1578
  return;
1565
1579
  }
1566
- let E = T - this.lastTimestamp;
1567
- this.lastTimestamp = T;
1568
- let D = this.ekfAttitude.update(E, w, this.gyroscopeEvent.values);
1569
- if (D) {
1570
- let C = new RelativeAttitude(D, T, e.DEFAULT_DRIFT);
1571
- this.notify(C);
1580
+ let i = r - this.lastTimestamp;
1581
+ this.lastTimestamp = r;
1582
+ let a = this.ekfAttitude.update(i, n, this.gyroscopeEvent.values);
1583
+ if (a) {
1584
+ let t = new ie(a, r, e.DEFAULT_DRIFT);
1585
+ this.notify(t);
1572
1586
  }
1573
1587
  };
1574
- }(), RelativeAttitudeFromBrowserProvider_default = new class e extends Provider_default {
1575
- static DEFAULT_DRIFT = deg2rad(5) / 60;
1588
+ }(), Ke = new class e extends j {
1589
+ static DEFAULT_DRIFT = m(5) / 60;
1576
1590
  getName = () => "RelativeAttitudeFromBrowser";
1577
1591
  availability() {
1578
- return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError_default());
1592
+ return S.isMobile ? Promise.resolve() : Promise.resolve(new Ae());
1579
1593
  }
1580
1594
  start() {
1581
- let e = () => window.addEventListener("deviceorientation", this.onDeviceOrientationEvent, !0), C = DeviceOrientationEvent.requestPermission || void 0;
1582
- C ? C().then((C) => {
1583
- if (C !== "granted") throw Error("Permission not granted");
1595
+ let e = () => window.addEventListener("deviceorientation", this.onDeviceOrientationEvent, !0), t = DeviceOrientationEvent.requestPermission || void 0;
1596
+ t ? t().then((t) => {
1597
+ if (t !== "granted") throw Error("Permission not granted");
1584
1598
  e();
1585
1599
  }).catch((e) => this.notifyError(e)) : e();
1586
1600
  }
1587
1601
  stop() {
1588
1602
  window.removeEventListener("deviceorientation", this.onDeviceOrientationEvent, !0);
1589
1603
  }
1590
- onDeviceOrientationEvent = (C) => {
1591
- if (typeof C.alpha != "number" || typeof C.beta != "number" || typeof C.gamma != "number") {
1592
- this.notifyError(new MissingSensorError_default().from("deviceorientation"));
1604
+ onDeviceOrientationEvent = (t) => {
1605
+ if (typeof t.alpha != "number" || typeof t.beta != "number" || typeof t.gamma != "number") {
1606
+ this.notifyError(new R().from("deviceorientation"));
1593
1607
  return;
1594
1608
  }
1595
- let w = new RelativeAttitude(Rotations.eulerToQuaternionZXYDegrees([
1596
- C.alpha,
1597
- C.beta,
1598
- C.gamma
1599
- ]), C.timeStamp / 1e3, e.DEFAULT_DRIFT);
1600
- this.notify(w);
1609
+ let n = new ie(d.eulerToQuaternionZXYDegrees([
1610
+ t.alpha,
1611
+ t.beta,
1612
+ t.gamma
1613
+ ]), t.timeStamp / 1e3, e.DEFAULT_DRIFT);
1614
+ this.notify(n);
1601
1615
  };
1602
- }(), HighRotationsProvider_default = new class e extends Provider_default {
1616
+ }(), U = new class e extends j {
1603
1617
  static THRESHOLD = 10;
1604
1618
  static DELAY_CONSIDERATION = 3;
1605
1619
  gyroscopeProviderId;
1606
1620
  getName = () => "HighRotationsProvider";
1607
- availability = () => GyroscopeProvider_default.getAvailability();
1621
+ availability = () => H.getAvailability();
1608
1622
  start() {
1609
- this.gyroscopeProviderId = GyroscopeProvider_default.addEventListener(this._parseGyroscopeEvent, this.notifyError);
1623
+ this.gyroscopeProviderId = H.addEventListener(this._parseGyroscopeEvent, this.notifyError);
1610
1624
  }
1611
1625
  stop() {
1612
- GyroscopeProvider_default.removeEventListener(this.gyroscopeProviderId);
1626
+ H.removeEventListener(this.gyroscopeProviderId);
1613
1627
  }
1614
1628
  isInProgress() {
1615
- return !this.lastEvent || !GyroscopeProvider_default.lastEvent ? !1 : GyroscopeProvider_default.lastEvent.timestamp - this.lastEvent.timestamp < e.DELAY_CONSIDERATION;
1629
+ return !this.lastEvent || !H.lastEvent ? !1 : H.lastEvent.timestamp - this.lastEvent.timestamp < e.DELAY_CONSIDERATION;
1616
1630
  }
1617
- _parseGyroscopeEvent = (C) => {
1618
- let { values: w, timestamp: T } = C;
1619
- Vector3.norm(w) > e.THRESHOLD && this.notify({ timestamp: T });
1631
+ _parseGyroscopeEvent = (t) => {
1632
+ let { values: n, timestamp: r } = t;
1633
+ p.norm(n) > e.THRESHOLD && this.notify({ timestamp: r });
1620
1634
  };
1621
- }(), RelativeAttitudeFromInertialProvider_default = new class e extends Provider_default {
1622
- static DEFAULT_DRIFT = deg2rad(5) / 60;
1635
+ }(), W = new class e extends j {
1636
+ static DEFAULT_DRIFT = m(5) / 60;
1623
1637
  _highRotationsProviderId;
1624
1638
  listenerId;
1625
1639
  provider;
1626
1640
  getName = () => "RelativeAttitudeFromInertial";
1627
1641
  availability() {
1628
- return AvailabilityHelper.some([RelativeAttitudeFromEkfProvider_default.getAvailability(), RelativeAttitudeFromBrowserProvider_default.getAvailability()]);
1642
+ return M.some([Ge.getAvailability(), Ke.getAvailability()]);
1629
1643
  }
1630
1644
  start() {
1631
- RelativeAttitudeFromEkfProvider_default.getAvailability().then((e) => {
1632
- this.provider = e ? RelativeAttitudeFromBrowserProvider_default : RelativeAttitudeFromEkfProvider_default, this.listenerId = this.provider.addEventListener((e) => this._parseEvent(e), this.notifyError), this._highRotationsProviderId = HighRotationsProvider_default.addEventListener(null, this.notifyError);
1645
+ Ge.getAvailability().then((e) => {
1646
+ this.provider = e ? Ke : Ge, this.listenerId = this.provider.addEventListener((e) => this._parseEvent(e), this.notifyError), this._highRotationsProviderId = U.addEventListener(null, this.notifyError);
1633
1647
  });
1634
1648
  }
1635
- _parseEvent(C) {
1636
- let w = C.clone();
1637
- if (HighRotationsProvider_default.isInProgress()) {
1638
- let C = (w.accuracy || 0) + e.DEFAULT_DRIFT * 100;
1639
- C = Math.min(C, Math.PI), w.accuracy = C;
1649
+ _parseEvent(t) {
1650
+ let n = t.clone();
1651
+ if (U.isInProgress()) {
1652
+ let t = (n.accuracy || 0) + e.DEFAULT_DRIFT * 100;
1653
+ t = Math.min(t, Math.PI), n.accuracy = t;
1640
1654
  }
1641
- this.notify(w);
1655
+ this.notify(n);
1642
1656
  }
1643
1657
  stop() {
1644
- this.provider && (this.provider.removeEventListener(this.listenerId), delete this.provider), HighRotationsProvider_default.removeEventListener(this._highRotationsProviderId);
1658
+ this.provider && (this.provider.removeEventListener(this.listenerId), delete this.provider), U.removeEventListener(this._highRotationsProviderId);
1645
1659
  }
1646
- }(), StepDetectionLadetto_default = class e {
1660
+ }(), qe = class e {
1647
1661
  static MIN_TIME_BETWEEN_STEPS = .4;
1648
1662
  static MAX_FRENQUENCY = 4;
1649
1663
  static MIN_FRENQUENCY = 1;
@@ -1652,15 +1666,15 @@ var field = function(e, C, w) {
1652
1666
  lastVerticalAcc = 0;
1653
1667
  maxAcceleration = 0;
1654
1668
  lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
1655
- compute(C, w) {
1656
- let T = !1, E = w[2], D = C - this.lastStepTimestamp;
1657
- if (E > this.lastVerticalAcc) E > this.maxAcceleration && (this.maxAcceleration = E);
1658
- else if (this.maxAcceleration > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && D > e.MIN_TIME_BETWEEN_STEPS) {
1669
+ compute(t, n) {
1670
+ let r = !1, i = n[2], a = t - this.lastStepTimestamp;
1671
+ if (i > this.lastVerticalAcc) i > this.maxAcceleration && (this.maxAcceleration = i);
1672
+ else if (this.maxAcceleration > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && a > e.MIN_TIME_BETWEEN_STEPS) {
1659
1673
  this.maxAcceleration = 0;
1660
- let w = C - this.lastStepTimestamp;
1661
- this.frequency = Math.min(Math.max(1 / w, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), T = !0, this.lastStepTimestamp = C;
1674
+ let n = t - this.lastStepTimestamp;
1675
+ this.frequency = Math.min(Math.max(1 / n, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), r = !0, this.lastStepTimestamp = t;
1662
1676
  } else this.maxAcceleration = 0;
1663
- return this.lastVerticalAcc = E, T;
1677
+ return this.lastVerticalAcc = i, r;
1664
1678
  }
1665
1679
  get lastStepSize() {
1666
1680
  return this.frequency ? .45 + .2 * this.frequency : 0;
@@ -1668,7 +1682,7 @@ var field = function(e, C, w) {
1668
1682
  get speed() {
1669
1683
  return this.lastStepTimestamp ? this.lastStepSize * this.frequency : 0;
1670
1684
  }
1671
- }, StepDetectionMinMaxPeaks_default = class e {
1685
+ }, Je = class e {
1672
1686
  static WINDOW_TIME = .3;
1673
1687
  static MIN_TIME_BETWEEN_STEPS = .4;
1674
1688
  static MAX_FRENQUENCY = 4;
@@ -1678,17 +1692,17 @@ var field = function(e, C, w) {
1678
1692
  frequency = 0;
1679
1693
  lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
1680
1694
  slidingWindow = [];
1681
- compute(C, w) {
1682
- if (this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > C) return !1;
1683
- let T = -(2 ** 53 - 1), E = 2 ** 53 - 1, D = e.WINDOW_TIME;
1684
- if (this.slidingWindow.forEach((e, w, O) => {
1685
- e.timestamp < C - D ? O.splice(w, 1) : (T = Math.max(e.verticalAcc, T), E = Math.min(e.verticalAcc, E));
1695
+ compute(t, n) {
1696
+ if (this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > t) return !1;
1697
+ let r = -(2 ** 53 - 1), i = 2 ** 53 - 1, a = e.WINDOW_TIME;
1698
+ if (this.slidingWindow.forEach((e, n, o) => {
1699
+ e.timestamp < t - a ? o.splice(n, 1) : (r = Math.max(e.verticalAcc, r), i = Math.min(e.verticalAcc, i));
1686
1700
  }), this.slidingWindow.push({
1687
- timestamp: C,
1688
- verticalAcc: w[2]
1689
- }), T > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && E < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
1690
- let w = this.lastStepTimestamp ? C - this.lastStepTimestamp : 1;
1691
- return this.frequency = Math.min(Math.max(1 / w, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = C, !0;
1701
+ timestamp: t,
1702
+ verticalAcc: n[2]
1703
+ }), r > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && i < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
1704
+ let n = this.lastStepTimestamp ? t - this.lastStepTimestamp : 1;
1705
+ return this.frequency = Math.min(Math.max(1 / n, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = t, !0;
1692
1706
  }
1693
1707
  return !1;
1694
1708
  }
@@ -1698,7 +1712,7 @@ var field = function(e, C, w) {
1698
1712
  get speed() {
1699
1713
  return this.lastStepTimestamp ? this.lastStepSize * this.frequency : 0;
1700
1714
  }
1701
- }, StepDetectionMinMaxPeaks2_default = class e {
1715
+ }, Ye = class e {
1702
1716
  static WINDOW_TIME = .3;
1703
1717
  static MIN_TIME_BETWEEN_STEPS = .4;
1704
1718
  static MAX_FRENQUENCY = 4;
@@ -1710,18 +1724,18 @@ var field = function(e, C, w) {
1710
1724
  slidingWindow = [];
1711
1725
  lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
1712
1726
  previousVerticalAcc = 0;
1713
- compute(C, w, T) {
1714
- let E = this.influence * (w[2] * 2) + (1 - this.influence) * this.previousVerticalAcc;
1715
- if (this.previousVerticalAcc = E, Math.sqrt(T[0] ** 2 + T[1] ** 2 + T[2] ** 2) > .75 || this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > C) return !1;
1716
- let D = -(2 ** 53 - 1), O = 2 ** 53 - 1;
1717
- if (this.slidingWindow.forEach((w, T, E) => {
1718
- w.timestamp < C - e.WINDOW_TIME ? E.splice(T, 1) : (D = Math.max(w.verticalAcc, D), O = Math.min(w.verticalAcc, O));
1727
+ compute(t, n, r) {
1728
+ let i = this.influence * (n[2] * 2) + (1 - this.influence) * this.previousVerticalAcc;
1729
+ if (this.previousVerticalAcc = i, Math.sqrt(r[0] ** 2 + r[1] ** 2 + r[2] ** 2) > .75 || this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > t) return !1;
1730
+ let a = -(2 ** 53 - 1), o = 2 ** 53 - 1;
1731
+ if (this.slidingWindow.forEach((n, r, i) => {
1732
+ n.timestamp < t - e.WINDOW_TIME ? i.splice(r, 1) : (a = Math.max(n.verticalAcc, a), o = Math.min(n.verticalAcc, o));
1719
1733
  }), this.slidingWindow.push({
1720
- timestamp: C,
1721
- verticalAcc: E
1722
- }), D > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && O < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
1723
- let w = this.lastStepTimestamp ? C - this.lastStepTimestamp : 1;
1724
- return this.frequency = Math.min(Math.max(1 / w, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = C, !0;
1734
+ timestamp: t,
1735
+ verticalAcc: i
1736
+ }), a > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && o < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
1737
+ let n = this.lastStepTimestamp ? t - this.lastStepTimestamp : 1;
1738
+ return this.frequency = Math.min(Math.max(1 / n, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = t, !0;
1725
1739
  }
1726
1740
  return !1;
1727
1741
  }
@@ -1732,16 +1746,16 @@ var field = function(e, C, w) {
1732
1746
  return this.lastStepSize && this.frequency ? this.lastStepSize * this.frequency : 0;
1733
1747
  }
1734
1748
  mean(e) {
1735
- let C = 0, w = 0;
1736
- for (let w = 0; w < e.length; ++w) C += e[w].verticalAcc;
1737
- return w = C / e.length, w;
1749
+ let t = 0, n = 0;
1750
+ for (let n = 0; n < e.length; ++n) t += e[n].verticalAcc;
1751
+ return n = t / e.length, n;
1738
1752
  }
1739
1753
  stddev(e) {
1740
- let C = this.mean(e), w = 0;
1741
- for (let T = 0; T < e.length; ++T) w += (e[T].verticalAcc - C) ** 2;
1742
- return Math.sqrt(w / e.length);
1754
+ let t = this.mean(e), n = 0;
1755
+ for (let r = 0; r < e.length; ++r) n += (e[r].verticalAcc - t) ** 2;
1756
+ return Math.sqrt(n / e.length);
1743
1757
  }
1744
- }, StepDetectionMinMaxPeaks3_default = class e {
1758
+ }, Xe = class e {
1745
1759
  static WINDOW_TIME = .6;
1746
1760
  static MIN_TIME_BETWEEN_STEPS = .6;
1747
1761
  static MAX_FRENQUENCY = 4;
@@ -1754,33 +1768,33 @@ var field = function(e, C, w) {
1754
1768
  lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
1755
1769
  previousVerticalAcc = 0;
1756
1770
  previousHorizontalAcc = 0;
1757
- compute(C, w) {
1758
- let T = this.influence * w[2] + (1 - this.influence) * this.previousVerticalAcc;
1759
- if (this.previousVerticalAcc = T, this.slidingWindow = this.slidingWindow.filter((w) => w.timestamp >= C - e.WINDOW_TIME), this.slidingWindow.push({
1760
- timestamp: C,
1761
- verticalAcc: T
1762
- }), this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > C) return !1;
1763
- let E = Number.MIN_VALUE, D = -1, O = !1;
1764
- if (this.slidingWindow.forEach((C, w) => {
1765
- C.verticalAcc > E && C.verticalAcc >= e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && (E = C.verticalAcc, D = w, O = !0);
1766
- }), !O) return !1;
1767
- let k = !1, A = Number.MAX_VALUE;
1768
- for (let C = 0; C < D; C++) {
1769
- let w = this.slidingWindow[C].verticalAcc;
1770
- if (A = Math.min(A, w), w < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
1771
- k = !0;
1771
+ compute(t, n) {
1772
+ let r = this.influence * n[2] + (1 - this.influence) * this.previousVerticalAcc;
1773
+ if (this.previousVerticalAcc = r, this.slidingWindow = this.slidingWindow.filter((n) => n.timestamp >= t - e.WINDOW_TIME), this.slidingWindow.push({
1774
+ timestamp: t,
1775
+ verticalAcc: r
1776
+ }), this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > t) return !1;
1777
+ let i = Number.MIN_VALUE, a = -1, o = !1;
1778
+ if (this.slidingWindow.forEach((t, n) => {
1779
+ t.verticalAcc > i && t.verticalAcc >= e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && (i = t.verticalAcc, a = n, o = !0);
1780
+ }), !o) return !1;
1781
+ let s = !1, c = Number.MAX_VALUE;
1782
+ for (let t = 0; t < a; t++) {
1783
+ let n = this.slidingWindow[t].verticalAcc;
1784
+ if (c = Math.min(c, n), n < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
1785
+ s = !0;
1772
1786
  break;
1773
1787
  }
1774
1788
  }
1775
- if (!k) return !1;
1776
- let j = E - A, M = E - .5 * j, N = !1;
1777
- for (let e = D + 1; e < this.slidingWindow.length; e++) if (this.slidingWindow[e].verticalAcc <= M) {
1778
- N = !0;
1789
+ if (!s) return !1;
1790
+ let l = i - c, u = i - .5 * l, d = !1;
1791
+ for (let e = a + 1; e < this.slidingWindow.length; e++) if (this.slidingWindow[e].verticalAcc <= u) {
1792
+ d = !0;
1779
1793
  break;
1780
1794
  }
1781
- if (!N) return !1;
1782
- let F = this.lastStepTimestamp ? C - this.lastStepTimestamp : 1;
1783
- return this.frequency = Math.min(Math.max(1 / F, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = C, !0;
1795
+ if (!d) return !1;
1796
+ let f = this.lastStepTimestamp ? t - this.lastStepTimestamp : 1;
1797
+ return this.frequency = Math.min(Math.max(1 / f, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = t, !0;
1784
1798
  }
1785
1799
  get lastStepSize() {
1786
1800
  return this.frequency ? .45 + .2 * this.frequency : 0;
@@ -1789,16 +1803,16 @@ var field = function(e, C, w) {
1789
1803
  return this.lastStepSize && this.frequency ? this.lastStepSize * this.frequency : 0;
1790
1804
  }
1791
1805
  mean(e) {
1792
- let C = 0, w = 0;
1793
- for (let w = 0; w < e.length; ++w) C += e[w];
1794
- return w = C / e.length, w;
1806
+ let t = 0, n = 0;
1807
+ for (let n = 0; n < e.length; ++n) t += e[n];
1808
+ return n = t / e.length, n;
1795
1809
  }
1796
1810
  stddev(e) {
1797
- let C = this.mean(e), w = 0;
1798
- for (let T = 0; T < e.length; ++T) w += (e[T] - C) ** 2;
1799
- return Math.sqrt(w / e.length);
1811
+ let t = this.mean(e), n = 0;
1812
+ for (let r = 0; r < e.length; ++r) n += (e[r] - t) ** 2;
1813
+ return Math.sqrt(n / e.length);
1800
1814
  }
1801
- }, StepProvider_default = new class e extends Provider_default {
1815
+ }, G = new class e extends j {
1802
1816
  static DEFAULT_STEP_SIZE_MULTIPLIER = 1;
1803
1817
  static DEFAULT_ALGORITHM = "minMaxPeaks3";
1804
1818
  accelerometerProviderId;
@@ -1816,22 +1830,22 @@ var field = function(e, C, w) {
1816
1830
  }
1817
1831
  getName = () => "StepDetector";
1818
1832
  availability() {
1819
- return AvailabilityHelper.every([
1820
- AccelerometerProvider_default.getAvailability(),
1821
- GyroscopeProvider_default.getAvailability(),
1822
- RelativeAttitudeFromInertialProvider_default.getAvailability()
1833
+ return M.every([
1834
+ V.getAvailability(),
1835
+ H.getAvailability(),
1836
+ W.getAvailability()
1823
1837
  ]);
1824
1838
  }
1825
1839
  start() {
1826
- this.numOfSteps = 0, this.accelerometerProviderId = AccelerometerProvider_default.addEventListener(this.onAccelerometerEvent, this.notifyError), this.gyroscopeProviderId = GyroscopeProvider_default.addEventListener((e) => this.angularRateEvent = e, this.notifyError), this.attitudeProviderId = RelativeAttitudeFromInertialProvider_default.addEventListener((e) => this.attitudeEvent = e, this.notifyError);
1840
+ this.numOfSteps = 0, this.accelerometerProviderId = V.addEventListener(this.onAccelerometerEvent, this.notifyError), this.gyroscopeProviderId = H.addEventListener((e) => this.angularRateEvent = e, this.notifyError), this.attitudeProviderId = W.addEventListener((e) => this.attitudeEvent = e, this.notifyError);
1827
1841
  }
1828
1842
  stop() {
1829
- AccelerometerProvider_default.removeEventListener(this.accelerometerProviderId), GyroscopeProvider_default.removeEventListener(this.gyroscopeProviderId), RelativeAttitudeFromInertialProvider_default.removeEventListener(this.attitudeProviderId);
1843
+ V.removeEventListener(this.accelerometerProviderId), H.removeEventListener(this.gyroscopeProviderId), W.removeEventListener(this.attitudeProviderId);
1830
1844
  }
1831
- onAccelerometerEvent = (C) => {
1845
+ onAccelerometerEvent = (t) => {
1832
1846
  if (!this.attitudeEvent || !this.angularRateEvent) return;
1833
- let { values: w, timestamp: T } = C, E = e.computeLinearAcceleration(this.attitudeEvent.quaternion, w);
1834
- if (this.stepDetector.compute(T, E, this.angularRateEvent.values)) {
1847
+ let { values: n, timestamp: r } = t, i = e.computeLinearAcceleration(this.attitudeEvent.quaternion, n);
1848
+ if (this.stepDetector.compute(r, i, this.angularRateEvent.values)) {
1835
1849
  let e = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
1836
1850
  this.numOfSteps++, this.notify({
1837
1851
  size: e,
@@ -1839,9 +1853,9 @@ var field = function(e, C, w) {
1839
1853
  });
1840
1854
  }
1841
1855
  };
1842
- static computeLinearAcceleration(e, C) {
1843
- let T = Quaternion.rotateMatlab(Quaternion.inverse(e), C);
1844
- return T[2] -= Constants.EARTH_GRAVITY, T;
1856
+ static computeLinearAcceleration(e, t) {
1857
+ let r = u.rotateMatlab(u.inverse(e), t);
1858
+ return r[2] -= n.EARTH_GRAVITY, r;
1845
1859
  }
1846
1860
  set stepSizeMultiplier(e) {
1847
1861
  this._stepSizeMultiplier = e;
@@ -1852,17 +1866,16 @@ var field = function(e, C, w) {
1852
1866
  set algorithm(e) {
1853
1867
  switch (e) {
1854
1868
  case "ladetto":
1855
- this.stepDetector = new StepDetectionLadetto_default();
1869
+ this.stepDetector = new qe();
1856
1870
  break;
1857
1871
  case "minMaxPeaks":
1858
- this.stepDetector = new StepDetectionMinMaxPeaks_default();
1872
+ this.stepDetector = new Je();
1859
1873
  break;
1860
1874
  case "minMaxPeaks2":
1861
- this.stepDetector = new StepDetectionMinMaxPeaks2_default();
1875
+ this.stepDetector = new Ye();
1862
1876
  break;
1863
- case "minMaxPeaks3":
1864
1877
  default:
1865
- e = "minMaxPeaks3", this.stepDetector = new StepDetectionMinMaxPeaks3_default();
1878
+ e = "minMaxPeaks3", this.stepDetector = new Xe();
1866
1879
  break;
1867
1880
  }
1868
1881
  this._algorithm = e;
@@ -1870,42 +1883,43 @@ var field = function(e, C, w) {
1870
1883
  get algorithm() {
1871
1884
  return this._algorithm;
1872
1885
  }
1873
- }(), PdrProvider_default = new class extends Provider_default {
1886
+ }(), Ze = new class extends j {
1874
1887
  absoluteAttitudeProviderId;
1875
1888
  stepDetectionProviderId;
1876
1889
  attitudeEvent;
1877
- misalignmentError = deg2rad(3);
1890
+ misalignmentError = m(3);
1878
1891
  getName = () => "Pdr";
1879
1892
  availability() {
1880
- return AvailabilityHelper.every([StepProvider_default.getAvailability(), AbsoluteAttitudeProvider_default.getAvailability()]);
1893
+ return M.every([G.getAvailability(), X.getAvailability()]);
1881
1894
  }
1882
1895
  start() {
1883
- this.stepDetectionProviderId = StepProvider_default.addEventListener(this.onStepEvent, this.notifyError), this.absoluteAttitudeProviderId = AbsoluteAttitudeProvider_default.addEventListener((e) => this.attitudeEvent = e, this.notifyError);
1896
+ this.stepDetectionProviderId = G.addEventListener(this.onStepEvent, this.notifyError), this.absoluteAttitudeProviderId = X.addEventListener((e) => this.attitudeEvent = e, this.notifyError);
1884
1897
  }
1885
1898
  stop() {
1886
- StepProvider_default.removeEventListener(this.stepDetectionProviderId), AbsoluteAttitudeProvider_default.removeEventListener(this.absoluteAttitudeProviderId);
1899
+ G.removeEventListener(this.stepDetectionProviderId), X.removeEventListener(this.absoluteAttitudeProviderId);
1887
1900
  }
1888
1901
  onStepEvent = (e) => {
1889
1902
  if (!this.attitudeEvent) return;
1890
- let C = e.size, w = this.attitudeEvent, E = w.heading, D = w.accuracy + this.misalignmentError, O = C / 2 * Math.sin(D / 2), k = w.time, A = new GeoRelativePosition(C * Math.sin(E), C * Math.cos(E), 0, k, O, E);
1891
- this.notify(A);
1903
+ let t = e.size, n = this.attitudeEvent, i = n.heading, a = n.accuracy + this.misalignmentError, o = t / 2 * Math.sin(a / 2), s = n.time, c = new r(t * Math.sin(i), t * Math.cos(i), 0, s, o, i);
1904
+ this.notify(c);
1892
1905
  };
1893
- }(), GeoRelativePositionProvider_default = new class extends Provider_default {
1906
+ }(), Qe = new class extends j {
1894
1907
  providerId;
1895
1908
  geoRelativeProvider;
1896
1909
  getName = () => "GeoRelativePosition";
1897
1910
  availability() {
1898
- return AvailabilityHelper.some([PdrProvider_default.getAvailability(), GeoRelativePositionFromArCoreProvider_default.getAvailability()]);
1911
+ return M.some([Ze.getAvailability(), ze.getAvailability()]);
1899
1912
  }
1900
1913
  async start() {
1901
- this.geoRelativeProvider = await GeoRelativePositionFromArCoreProvider_default.getAvailability() ? PdrProvider_default : GeoRelativePositionFromArCoreProvider_default, this.providerId = this.geoRelativeProvider.addEventListener(this.notify, this.notifyError);
1914
+ let e = await ze.getAvailability();
1915
+ this.geoRelativeProvider = e ? Ze : ze, this.providerId = this.geoRelativeProvider.addEventListener(this.notify, this.notifyError);
1902
1916
  }
1903
1917
  stop() {
1904
1918
  this.geoRelativeProvider?.removeEventListener(this.providerId), delete this.geoRelativeProvider;
1905
1919
  }
1906
- }(), package_default = {
1920
+ }(), $e = {
1907
1921
  name: "@wemap/providers",
1908
- version: "14.6.0-beta.3",
1922
+ version: "14.6.0-beta.5",
1909
1923
  description: "Sensor, positioning and VPS providers for the Wemap SDK.",
1910
1924
  license: "UNLICENSED",
1911
1925
  author: "Wemap SAS",
@@ -1933,88 +1947,88 @@ var field = function(e, C, w) {
1933
1947
  sideEffects: !1,
1934
1948
  files: ["dist"],
1935
1949
  dependencies: {
1936
- "@wemap/camera": "14.6.0-beta.3",
1937
- "@wemap/core": "14.6.0-beta.3",
1938
- "@wemap/geo": "14.6.0-beta.3",
1939
- "@wemap/maths": "14.6.0-beta.3",
1940
- "@wemap/osm": "14.6.0-beta.3",
1941
- "@wemap/routers": "14.6.0-beta.3",
1942
- "@wemap/utils": "14.6.0-beta.3"
1950
+ "@wemap/camera": "14.6.0-beta.5",
1951
+ "@wemap/core": "14.6.0-beta.5",
1952
+ "@wemap/geo": "14.6.0-beta.5",
1953
+ "@wemap/maths": "14.6.0-beta.5",
1954
+ "@wemap/osm": "14.6.0-beta.5",
1955
+ "@wemap/routers": "14.6.0-beta.5",
1956
+ "@wemap/utils": "14.6.0-beta.5"
1943
1957
  },
1944
1958
  devDependencies: {
1945
1959
  "@wemap/logger-legacy": "^13.3.0",
1946
1960
  geomag: "^1.0.0"
1947
1961
  }
1948
- }, InclinationFromAccProvider_default = new class extends Provider_default {
1962
+ }, et = new class extends j {
1949
1963
  providerId;
1950
1964
  getName = () => "InclinationFromAcc";
1951
- availability = () => AccelerometerProvider_default.getAvailability();
1965
+ availability = () => V.getAvailability();
1952
1966
  start() {
1953
- this.providerId = AccelerometerProvider_default.addEventListener(this.onAccelerometerEvent, this.notifyError);
1967
+ this.providerId = V.addEventListener(this.onAccelerometerEvent, this.notifyError);
1954
1968
  }
1955
1969
  stop() {
1956
- AccelerometerProvider_default.removeEventListener(this.providerId);
1970
+ V.removeEventListener(this.providerId);
1957
1971
  }
1958
1972
  onAccelerometerEvent = (e) => {
1959
- let C = e.values, w = window.orientation || 0, T = Math.sqrt(C[0] * C[0] + C[1] * C[1] + C[2] * C[2]), E = [
1960
- C[0] / T,
1961
- C[1] / T,
1962
- C[2] / T
1963
- ], D = [
1964
- E[2] + 1,
1965
- E[1],
1966
- -E[0],
1973
+ let t = e.values, n = window.orientation || 0, r = Math.sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]), i = [
1974
+ t[0] / r,
1975
+ t[1] / r,
1976
+ t[2] / r
1977
+ ], a = [
1978
+ i[2] + 1,
1979
+ i[1],
1980
+ -i[0],
1967
1981
  0
1968
- ], O = Math.sqrt(D[0] * D[0] + D[1] * D[1] + D[2] * D[2]), k = [
1969
- D[0] / O,
1970
- D[1] / O,
1971
- D[2] / O,
1982
+ ], o = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]), s = [
1983
+ a[0] / o,
1984
+ a[1] / o,
1985
+ a[2] / o,
1972
1986
  0
1973
- ], A;
1974
- A = w === 0 ? Math.asin(2 * k[1] * k[0]) : w === 90 ? -Math.asin(2 * k[2] * k[0]) : w === -90 ? Math.asin(2 * k[2] * k[0]) : -Math.asin(2 * k[1] * k[0]), this.notify(A);
1987
+ ], c;
1988
+ c = n === 0 ? Math.asin(2 * s[1] * s[0]) : n === 90 ? -Math.asin(2 * s[2] * s[0]) : n === -90 ? Math.asin(2 * s[2] * s[0]) : -Math.asin(2 * s[1] * s[0]), this.notify(c);
1975
1989
  };
1976
- }(), InclinationFromRelativeAttitudeProvider_default = new class extends Provider_default {
1990
+ }(), tt = new class extends j {
1977
1991
  providerId;
1978
1992
  getName = () => "InclinationFromRelativeAttitude";
1979
- availability = () => RelativeAttitudeFromInertialProvider_default.getAvailability();
1993
+ availability = () => W.getAvailability();
1980
1994
  start() {
1981
- this.providerId = RelativeAttitudeFromInertialProvider_default.addEventListener((e) => {
1982
- let C = this.enuQuatToInclination(e.quaternion);
1983
- this.notify(C);
1995
+ this.providerId = W.addEventListener((e) => {
1996
+ let t = this.enuQuatToInclination(e.quaternion);
1997
+ this.notify(t);
1984
1998
  }, this.notifyError);
1985
1999
  }
1986
2000
  stop() {
1987
- RelativeAttitudeFromInertialProvider_default.removeEventListener(this.providerId);
2001
+ W.removeEventListener(this.providerId);
1988
2002
  }
1989
2003
  enuQuatToInclination(e) {
1990
- let C = window.orientation || 0;
1991
- return C === 0 ? Math.asin(2 * (e[2] * e[3] + e[1] * e[0])) : C === 90 ? Math.asin(2 * (e[1] * e[3] - e[2] * e[0])) : C === -90 ? Math.asin(2 * (e[2] * e[0] - e[1] * e[3])) : -Math.asin(2 * (e[2] * e[3] + e[1] * e[0]));
2004
+ let t = window.orientation || 0;
2005
+ return t === 0 ? Math.asin(2 * (e[2] * e[3] + e[1] * e[0])) : t === 90 ? Math.asin(2 * (e[1] * e[3] - e[2] * e[0])) : t === -90 ? Math.asin(2 * (e[2] * e[0] - e[1] * e[3])) : -Math.asin(2 * (e[2] * e[3] + e[1] * e[0]));
1992
2006
  }
1993
- }(), InclinationProvider_default = new class extends Provider_default {
2007
+ }(), K = new class extends j {
1994
2008
  provider;
1995
2009
  providerId;
1996
2010
  getName = () => "Inclination";
1997
2011
  availability() {
1998
- return AvailabilityHelper.some([InclinationFromAccProvider_default.getAvailability(), InclinationFromRelativeAttitudeProvider_default.getAvailability()]);
2012
+ return M.some([et.getAvailability(), tt.getAvailability()]);
1999
2013
  }
2000
2014
  async start() {
2001
2015
  let e = () => {
2002
- this.provider = InclinationFromAccProvider_default, this.providerId = this.provider.addEventListener(this.notify, this.notifyError);
2016
+ this.provider = et, this.providerId = this.provider.addEventListener(this.notify, this.notifyError);
2003
2017
  };
2004
- await InclinationFromRelativeAttitudeProvider_default.getAvailability() ? (this.provider = InclinationFromRelativeAttitudeProvider_default, this.providerId = this.provider.addEventListener(this.notify, () => {
2005
- InclinationFromRelativeAttitudeProvider_default.removeEventListener(this.providerId), e();
2018
+ await tt.getAvailability() ? (this.provider = tt, this.providerId = this.provider.addEventListener(this.notify, () => {
2019
+ tt.removeEventListener(this.providerId), e();
2006
2020
  })) : e();
2007
2021
  }
2008
2022
  stop() {
2009
2023
  this.provider && this.provider.removeEventListener(this.providerId);
2010
2024
  }
2011
- }(), VpsMetadata_default = class e {
2025
+ }(), nt = class e {
2012
2026
  size;
2013
2027
  calibration;
2014
2028
  coarse;
2015
2029
  device;
2016
- constructor(e, C = null, w = null, T = null) {
2017
- this.size = e, this.calibration = C, this.coarse = w, this.device = T;
2030
+ constructor(e, t = null, n = null, r = null) {
2031
+ this.size = e, this.calibration = t, this.coarse = n, this.device = r;
2018
2032
  }
2019
2033
  toJson() {
2020
2034
  return {
@@ -2027,47 +2041,47 @@ var field = function(e, C, w) {
2027
2041
  ...this.device !== null && { device: this.device }
2028
2042
  };
2029
2043
  }
2030
- static fromJson(w) {
2044
+ static fromJson(n) {
2031
2045
  return new e({
2032
- width: w.size[0],
2033
- height: w.size[1]
2034
- }, w.calibration, {
2035
- ...w.coarse?.position && { position: UserPosition.fromJson(w.coarse.position) },
2036
- ...w.coarse?.attitude && { attitude: Attitude.fromJson(w.coarse.attitude) }
2037
- }, w.device);
2038
- }
2039
- }, VpsRequest_default = class e {
2046
+ width: n.size[0],
2047
+ height: n.size[1]
2048
+ }, n.calibration, {
2049
+ ...n.coarse?.position && { position: o.fromJson(n.coarse.position) },
2050
+ ...n.coarse?.attitude && { attitude: t.fromJson(n.coarse.attitude) }
2051
+ }, n.device);
2052
+ }
2053
+ }, rt = class e {
2040
2054
  metadata;
2041
2055
  image;
2042
2056
  imageQuality;
2043
2057
  localPose;
2044
- constructor(e, C, w = .8, T = null) {
2045
- this.metadata = e, this.image = C, this.imageQuality = w, this.localPose = T;
2058
+ constructor(e, t, n = .8, r = null) {
2059
+ this.metadata = e, this.image = t, this.imageQuality = n, this.localPose = r;
2046
2060
  }
2047
2061
  toJson() {
2048
2062
  return {
2049
- image: canvasToBase64(this.image, "image/jpeg", this.imageQuality),
2063
+ image: te(this.image, "image/jpeg", this.imageQuality),
2050
2064
  ...this.localPose && { local_pose: this.localPose },
2051
2065
  ...this.metadata.toJson()
2052
2066
  };
2053
2067
  }
2054
- static fromJson(C) {
2055
- return new e(VpsMetadata_default.fromJson(C), base64ToCanvas(C.image));
2068
+ static fromJson(t) {
2069
+ return new e(nt.fromJson(t), E(t.image));
2056
2070
  }
2057
2071
  toFormData() {
2058
- let e = this.image.toDataURL("image/jpeg", this.imageQuality).split(",")[1] || "", C = atob(e), w = new Uint8Array(C.length);
2059
- for (let e = 0; e < C.length; e++) w[e] = C.charCodeAt(e);
2060
- let T = new FormData();
2061
- T.append("image", new Blob([w], { type: "image/jpeg" }), "image.jpg");
2062
- let E = this.metadata.toJson();
2063
- return E.calibration && T.append("calibration", JSON.stringify(E.calibration)), E.coarse && T.append("coarse", JSON.stringify(E.coarse)), E.device && T.append("device", JSON.stringify(E.device)), this.localPose && T.append("local_pose", JSON.stringify(this.localPose)), T;
2064
- }
2065
- }, VpsResponse_default = class e {
2072
+ let e = this.image.toDataURL("image/jpeg", this.imageQuality).split(",")[1] || "", t = atob(e), n = new Uint8Array(t.length);
2073
+ for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
2074
+ let r = new FormData();
2075
+ r.append("image", new Blob([n], { type: "image/jpeg" }), "image.jpg");
2076
+ let i = this.metadata.toJson();
2077
+ return i.calibration && r.append("calibration", JSON.stringify(i.calibration)), i.coarse && r.append("coarse", JSON.stringify(i.coarse)), i.device && r.append("device", JSON.stringify(i.device)), this.localPose && r.append("local_pose", JSON.stringify(this.localPose)), r;
2078
+ }
2079
+ }, it = class e {
2066
2080
  success;
2067
2081
  attitude;
2068
2082
  position;
2069
- constructor(e, C = null, w = null) {
2070
- this.success = e, this.attitude = C, this.position = w;
2083
+ constructor(e, t = null, n = null) {
2084
+ this.success = e, this.attitude = t, this.position = n;
2071
2085
  }
2072
2086
  toJson() {
2073
2087
  return {
@@ -2076,100 +2090,100 @@ var field = function(e, C, w) {
2076
2090
  position: this.position?.toJson()
2077
2091
  };
2078
2092
  }
2079
- static fromJson(w, T = null) {
2080
- let E = null;
2081
- w.attitude && (E = Attitude.fromJson(w.attitude), E.time = T);
2082
- let D = null;
2083
- return w.position && (D = UserPosition.fromJson(w.position), D.time = T), new e(w.success, E, D);
2084
- }
2085
- }, ImageRelocalization_default = class {
2086
- static _prepareRequest(e, C = null, w = null, T = null, E = null) {
2087
- let D = reduceImageSize(e, 720, 720), O = UserAgentUtils.getDeviceFromUserAgent() || {};
2088
- return T && (O.session_id = T.session_id, O.installation_id = T.installation_id, O.attempt_id = T.attempt_id, O.caller = T.caller), new VpsRequest_default(new VpsMetadata_default({
2089
- width: D.width,
2090
- height: D.height
2091
- }, C, w, O), D, .8, E);
2092
- }
2093
- static async relocalize(e, C, w = null, T = null, E = null, D = null, O = null) {
2094
- let k = TimeUtils.preciseTime() / 1e3, A = this._prepareRequest(C, w, T, E, D), j;
2093
+ static fromJson(n, r = null) {
2094
+ let i = null;
2095
+ n.attitude && (i = t.fromJson(n.attitude), i.time = r);
2096
+ let a = null;
2097
+ return n.position && (a = o.fromJson(n.position), a.time = r), new e(n.success, i, a);
2098
+ }
2099
+ }, at = class {
2100
+ static _prepareRequest(e, t = null, n = null, r = null, i = null) {
2101
+ let a = ne(e, 720, 720), o = w.getDeviceFromUserAgent() || {};
2102
+ return r && (o.session_id = r.session_id, o.installation_id = r.installation_id, o.attempt_id = r.attempt_id, o.caller = r.caller), new rt(new nt({
2103
+ width: a.width,
2104
+ height: a.height
2105
+ }, t, n, o), a, .8, i);
2106
+ }
2107
+ static async relocalize(e, t, n = null, r = null, i = null, a = null, o = null) {
2108
+ let s = C.preciseTime() / 1e3, c = this._prepareRequest(t, n, r, i, a), l;
2095
2109
  try {
2096
- let C = A.toFormData();
2097
- j = await fetch(e, {
2110
+ let t = c.toFormData();
2111
+ l = await fetch(e, {
2098
2112
  method: "POST",
2099
- body: C,
2100
- headers: Object.assign({ Accept: "application/vnd.geopose+json; version=1" }, O || {})
2113
+ body: t,
2114
+ headers: Object.assign({ Accept: "application/vnd.geopose+json; version=1" }, o || {})
2101
2115
  });
2102
2116
  } catch {
2103
- return Logger.debug("[VPS] Server respond error"), null;
2117
+ return A.debug("[VPS] Server respond error"), null;
2104
2118
  }
2105
- if (j.status !== 200) return Logger.debug("[VPS] Server respond error"), null;
2106
- let M = await j.json(), N = VpsResponse_default.fromJson(M, k);
2107
- return Logger.debug(`[VPS] Server respond ${N.success ? "success" : "not found"}`), N;
2119
+ if (l.status !== 200) return A.debug("[VPS] Server respond error"), null;
2120
+ let u = await l.json(), d = it.fromJson(u, s);
2121
+ return A.debug(`[VPS] Server respond ${d.success ? "success" : "not found"}`), d;
2108
2122
  }
2109
2123
  static getHeadingFromQuaternion(e) {
2110
- let [C, w, T, E] = e, D = Math.sqrt(2) / 2, O = [
2111
- D * (C - w),
2112
- D * (C + w),
2113
- D * (T + E),
2114
- D * (E - T)
2124
+ let [t, n, r, i] = e, a = Math.sqrt(2) / 2, o = [
2125
+ a * (t - n),
2126
+ a * (t + n),
2127
+ a * (r + i),
2128
+ a * (i - r)
2115
2129
  ];
2116
- return -Math.atan2(2 * O[3] * O[0] - 2 * O[2] * O[1], 1 - 2 * O[1] ** 2 - 2 * O[3] ** 2);
2130
+ return -Math.atan2(2 * o[3] * o[0] - 2 * o[2] * o[1], 1 - 2 * o[1] ** 2 - 2 * o[3] ** 2);
2117
2131
  }
2118
- }, RelativeAttitudeProvider_default = new class extends Provider_default {
2132
+ }, q = new class extends j {
2119
2133
  arCoreMonitoringId;
2120
2134
  arCoreProviderId;
2121
2135
  inertialProviderId;
2122
2136
  getName = () => "RelativeAttitude";
2123
- availability = () => RelativeAttitudeFromInertialProvider_default.getAvailability();
2137
+ availability = () => W.getAvailability();
2124
2138
  start() {
2125
- this.arCoreMonitoringId = ArCoreProvider_default.addMonitoringListener(() => {
2139
+ this.arCoreMonitoringId = z.addMonitoringListener(() => {
2126
2140
  this.listenArCore(), this.unlistenInertial();
2127
2141
  }, () => {
2128
2142
  this.unlistenArCore(), this.listenInertial();
2129
- }), ArCoreProvider_default.state === "started" ? this.listenArCore() : this.listenInertial();
2143
+ }), z.state === "started" ? this.listenArCore() : this.listenInertial();
2130
2144
  }
2131
2145
  stop() {
2132
- ArCoreProvider_default.removeMonitoringListener(this.arCoreMonitoringId), this.unlistenArCore(), this.unlistenInertial();
2146
+ z.removeMonitoringListener(this.arCoreMonitoringId), this.unlistenArCore(), this.unlistenInertial();
2133
2147
  }
2134
2148
  listenInertial = () => {
2135
- this.inertialProviderId = RelativeAttitudeFromInertialProvider_default.addEventListener(this.notify, this.notifyError);
2149
+ this.inertialProviderId = W.addEventListener(this.notify, this.notifyError);
2136
2150
  };
2137
2151
  unlistenInertial = () => {
2138
- RelativeAttitudeFromInertialProvider_default.removeEventListener(this.inertialProviderId);
2152
+ W.removeEventListener(this.inertialProviderId);
2139
2153
  };
2140
2154
  listenArCore = () => {
2141
- this.arCoreProviderId = ArCoreProvider_default.addEventListener((e) => this.notify(e.relativeAttitude), null, !1);
2155
+ this.arCoreProviderId = z.addEventListener((e) => this.notify(e.relativeAttitude), null, !1);
2142
2156
  };
2143
2157
  unlistenArCore = () => {
2144
- ArCoreProvider_default.removeEventListener(this.arCoreProviderId);
2158
+ z.removeEventListener(this.arCoreProviderId);
2145
2159
  };
2146
- }(), RelativeRotationCalc = class {
2160
+ }(), ot = class {
2147
2161
  _providerId;
2148
2162
  _isRunning = !1;
2149
2163
  _dataOnStart = null;
2150
2164
  tickStart() {
2151
- this._dataOnStart = null, !this._isRunning && (this._isRunning = !0, this._providerId = RelativeAttitudeFromBrowserProvider_default.addEventListener((e) => {
2165
+ this._dataOnStart = null, !this._isRunning && (this._isRunning = !0, this._providerId = Ke.addEventListener((e) => {
2152
2166
  this._dataOnStart ||= e;
2153
2167
  }));
2154
2168
  }
2155
2169
  tickEnd() {
2156
- if (!this._isRunning) return Logger.warn("You have to call tickStart before tickEnd"), null;
2157
- if (this._internalStop(), !this._dataOnStart) return Logger.warn("Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved."), null;
2158
- let e = RelativeAttitudeFromBrowserProvider_default.lastEvent;
2159
- return Attitude.diff(this._dataOnStart, e);
2170
+ if (!this._isRunning) return A.warn("You have to call tickStart before tickEnd"), null;
2171
+ if (this._internalStop(), !this._dataOnStart) return A.warn("Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved."), null;
2172
+ let e = Ke.lastEvent;
2173
+ return t.diff(this._dataOnStart, e);
2160
2174
  }
2161
2175
  _internalStop() {
2162
- RelativeAttitudeFromBrowserProvider_default.removeEventListener(this._providerId), delete this._providerId, this._isRunning = !1;
2176
+ Ke.removeEventListener(this._providerId), delete this._providerId, this._isRunning = !1;
2163
2177
  }
2164
2178
  release() {
2165
2179
  this._isRunning && this._internalStop();
2166
2180
  }
2167
- }, MissingPoleStarError_default = class e extends Error {
2181
+ }, st = class e extends Error {
2168
2182
  static DEFAULT_MESSAGE = "PoleStar is missing";
2169
- constructor(C) {
2170
- super(C || e.DEFAULT_MESSAGE);
2183
+ constructor(t) {
2184
+ super(t || e.DEFAULT_MESSAGE);
2171
2185
  }
2172
- }, PoleStarProvider_default = new class extends Provider_default {
2186
+ }, ct = new class extends j {
2173
2187
  getName = () => "PoleStar";
2174
2188
  constructor() {
2175
2189
  super(), this.addMethodsToNativeJsProvider();
@@ -2191,32 +2205,32 @@ var field = function(e, C, w) {
2191
2205
  this.nativeProvider.stop();
2192
2206
  }
2193
2207
  get nativeProvider() {
2194
- if (!this.nativeInterface) throw new MissingNativeInterfaceError_default();
2208
+ if (!this.nativeInterface) throw new Re();
2195
2209
  let e = this.nativeInterface.getPoleStarProvider();
2196
- if (!e) throw new MissingPoleStarError_default();
2210
+ if (!e) throw new st();
2197
2211
  return e;
2198
2212
  }
2199
2213
  addMethodsToNativeJsProvider() {
2200
2214
  this.nativeJsInterface && (this.nativeJsInterface.polestar = {
2201
2215
  callbackError: (e) => this.notifyError(Error(e)),
2202
2216
  callbackPosition: (e) => {
2203
- let C = JSON.parse(e), w = TimeUtils.unixTimestampToPreciseTime(C.time) / 1e3, T = new AbsolutePosition(C.lat, C.lng, Constants_default.DEFAULT_ALTITUDE, C.alt / 5, w, C.accuracy, deg2rad(C.bearing));
2204
- this.notify(T);
2217
+ let t = JSON.parse(e), n = C.unixTimestampToPreciseTime(t.time) / 1e3, r = new re(t.lat, t.lng, Fe.DEFAULT_ALTITUDE, t.alt / 5, n, t.accuracy, m(t.bearing));
2218
+ this.notify(r);
2205
2219
  }
2206
2220
  });
2207
2221
  }
2208
- }(), VpsProvider_default = new class e extends Provider_default {
2222
+ }(), J = new class e extends j {
2209
2223
  static MIN_TIME_BETWEEN_TWO_REQUESTS = 1e3;
2210
- static DEFAULT_MIN_INCLINATION_FOR_REQUEST = deg2rad(60);
2224
+ static DEFAULT_MIN_INCLINATION_FOR_REQUEST = m(60);
2211
2225
  static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST = 200;
2212
2226
  static DEFAULT_USE_COARSE_POSE = !0;
2213
- static DEFAULT_REQUEST_CALLER = `@wemap/providers(VpsProvider) ${package_default.version}`;
2214
- static CAMERA_TO_SMARTPHONE_ROT = Quaternion.fromAxisAngle([
2227
+ static DEFAULT_REQUEST_CALLER = `@wemap/providers(VpsProvider) ${$e.version}`;
2228
+ static CAMERA_TO_SMARTPHONE_ROT = u.fromAxisAngle([
2215
2229
  1,
2216
2230
  0,
2217
2231
  0
2218
2232
  ], Math.PI);
2219
- static ENU_TO_ARCORE_ROT = Quaternion.fromAxisAngle([
2233
+ static ENU_TO_ARCORE_ROT = u.fromAxisAngle([
2220
2234
  1,
2221
2235
  0,
2222
2236
  0
@@ -2240,18 +2254,18 @@ var field = function(e, C, w) {
2240
2254
  super(), this._sessionId = this._generateUuid();
2241
2255
  }
2242
2256
  getName = () => "Vps";
2243
- availability = () => Camera.checkAvailability();
2257
+ availability = () => ee.checkAvailability();
2244
2258
  start() {
2245
- this._inclinationProviderId = InclinationProvider_default.addEventListener(), this._relativeRotationCalc = new RelativeRotationCalc(), SharedCameras.on("added", this._onCameraDetected), SharedCameras.on("removed", this._onCameraRemoved), SharedCameras.list.length && (SharedCameras.list.length > 1 && Logger.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(SharedCameras.list[0].camera));
2259
+ this._inclinationProviderId = K.addEventListener(), this._relativeRotationCalc = new ot(), T.on("added", this._onCameraDetected), T.on("removed", this._onCameraRemoved), T.list.length && (T.list.length > 1 && A.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(T.list[0].camera));
2246
2260
  }
2247
2261
  stop() {
2248
- InclinationProvider_default.removeEventListener(this._inclinationProviderId), this._relativeRotationCalc?.release(), SharedCameras.off("added", this._onCameraDetected), SharedCameras.off("removed", this._onCameraRemoved), this._camera = null;
2262
+ K.removeEventListener(this._inclinationProviderId), this._relativeRotationCalc?.release(), T.off("added", this._onCameraDetected), T.off("removed", this._onCameraRemoved), this._camera = null;
2249
2263
  }
2250
2264
  _onCameraDetected = ({ camera: e }) => {
2251
- this._camera && Logger.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(e);
2265
+ this._camera && A.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(e);
2252
2266
  };
2253
2267
  _onCameraRemoved = () => {
2254
- this._camera ? (this._camera.off("started", this._internalStart), this._camera.off("stopped", this._internalStop)) : Logger.warn("There is no previously detected camera but once has stopped"), this._camera = null;
2268
+ this._camera ? (this._camera.off("started", this._internalStart), this._camera.off("stopped", this._internalStop)) : A.warn("There is no previously detected camera but once has stopped"), this._camera = null;
2255
2269
  };
2256
2270
  _useCamera(e) {
2257
2271
  this._camera = e, e.on("started", this._internalStart), e.on("stopped", this._internalStop), e.state === "started" && this._internalStart();
@@ -2261,41 +2275,41 @@ var field = function(e, C, w) {
2261
2275
  this.notifyError(/* @__PURE__ */ Error("VPS endpoint has not been set before calling start()"));
2262
2276
  return;
2263
2277
  }
2264
- let w = null, T = () => this.state === "stopped";
2265
- for (; !T();) {
2266
- if (w !== null) {
2267
- let C = TimeUtils.preciseTime() - w, T = Math.max(0, e.MIN_TIME_BETWEEN_TWO_REQUESTS - C);
2268
- await new Promise((e) => setTimeout(e, T));
2278
+ let n = null, r = () => this.state === "stopped";
2279
+ for (; !r();) {
2280
+ if (n !== null) {
2281
+ let t = C.preciseTime() - n, r = Math.max(0, e.MIN_TIME_BETWEEN_TWO_REQUESTS - t);
2282
+ await new Promise((e) => setTimeout(e, r));
2269
2283
  }
2270
- if (w = TimeUtils.preciseTime(), T() || !this._camera || this._camera.state !== "started") break;
2271
- let E = InclinationProvider_default.lastEvent ? InclinationProvider_default.lastEvent : null;
2272
- if (E !== null && E < this._minInclinationForRequest) {
2284
+ if (n = C.preciseTime(), r() || !this._camera || this._camera.state !== "started") break;
2285
+ let i = K.lastEvent ? K.lastEvent : null;
2286
+ if (i !== null && i < this._minInclinationForRequest) {
2273
2287
  await new Promise((e) => setTimeout(e, this._waitTimeMinInclinationForRequest));
2274
2288
  continue;
2275
2289
  }
2276
2290
  this._relativeRotationCalc?.tickStart();
2277
- let D = await this._camera.currentImage;
2278
- if (!D) continue;
2279
- let O = null, k = AbsolutePositionProvider_default.getBestPositionEvent(GnssWifiProvider_default.lastEvent, PoleStarProvider_default.lastEvent);
2280
- this._useCoarsePose && (k || AbsoluteAttitudeProvider_default.lastEvent) && (O = {
2281
- ...k && { position: k },
2282
- ...AbsoluteAttitudeProvider_default.lastEvent && { attitude: AbsoluteAttitudeProvider_default.lastEvent }
2291
+ let a = await this._camera.currentImage;
2292
+ if (!a) continue;
2293
+ let o = null, s = Y.getBestPositionEvent(Ie.lastEvent, ct.lastEvent);
2294
+ this._useCoarsePose && (s || X.lastEvent) && (o = {
2295
+ ...s && { position: s },
2296
+ ...X.lastEvent && { attitude: X.lastEvent }
2283
2297
  }), this._currentAttemptId === null && (this._attemptIdCounter += 1, this._currentAttemptId = this._attemptIdCounter);
2284
- let A = RelativeAttitudeProvider_default.lastEvent, j = GeoRelativePositionProvider_default.lastEvent, N = A && j ? {
2285
- position: Quaternion.rotate(e.ENU_TO_ARCORE_ROT, [
2286
- j.x,
2287
- j.y,
2288
- j.z
2298
+ let c = q.lastEvent, l = Qe.lastEvent, d = c && l ? {
2299
+ position: u.rotate(e.ENU_TO_ARCORE_ROT, [
2300
+ l.x,
2301
+ l.y,
2302
+ l.z
2289
2303
  ]),
2290
- orientation: Quaternion.multiply(e.ENU_TO_ARCORE_ROT, A.quaternion)
2291
- } : null, F = await ImageRelocalization_default.relocalize(this._endpoint, D, null, O, {
2304
+ orientation: u.multiply(e.ENU_TO_ARCORE_ROT, c.quaternion)
2305
+ } : null, f = await at.relocalize(this._endpoint, a, null, o, {
2292
2306
  session_id: this._sessionId,
2293
2307
  installation_id: null,
2294
2308
  ...this._currentAttemptId !== null && { attempt_id: this._currentAttemptId },
2295
2309
  caller: this._requestCaller
2296
- }, N);
2297
- if (!F || !F.success) {
2298
- this._scanFailureCallbacks.forEach(({ id: e, callback: C }) => C({
2310
+ }, d);
2311
+ if (!f || !f.success) {
2312
+ this._scanFailureCallbacks.forEach(({ id: e, callback: t }) => t({
2299
2313
  listenerId: e,
2300
2314
  sessionId: this._sessionId,
2301
2315
  attemptId: this._currentAttemptId
@@ -2303,39 +2317,39 @@ var field = function(e, C, w) {
2303
2317
  continue;
2304
2318
  }
2305
2319
  this._currentAttemptId = null;
2306
- let I = F.attitude.quaternion, R = Quaternion.multiply(I, e.CAMERA_TO_SMARTPHONE_ROT), z = Quaternion.multiply(Quaternion.fromAxisAngle([
2320
+ let p = f.attitude.quaternion, h = u.multiply(p, e.CAMERA_TO_SMARTPHONE_ROT), g = u.multiply(u.fromAxisAngle([
2307
2321
  0,
2308
2322
  0,
2309
2323
  1
2310
- ], deg2rad(window.orientation || 0)), R), B = this._relativeRotationCalc?.tickEnd() || new Attitude([
2324
+ ], m(window.orientation || 0)), h), _ = this._relativeRotationCalc?.tickEnd() || new t([
2311
2325
  1,
2312
2326
  0,
2313
2327
  0,
2314
2328
  0
2315
- ]), V = new AbsoluteAttitude(Quaternion.multiply(z, B.quaternion), F.attitude.time, F.attitude.accuracy), H = F.position.clone();
2316
- if (H.accuracy === null && (H.accuracy = 5), T()) break;
2329
+ ]), v = new ae(u.multiply(g, _.quaternion), f.attitude.time, f.attitude.accuracy), y = f.position.clone();
2330
+ if (y.accuracy === null && (y.accuracy = 5), r()) break;
2317
2331
  this.notify({
2318
- absoluteAttitude: V,
2319
- absolutePosition: H
2332
+ absoluteAttitude: v,
2333
+ absolutePosition: y
2320
2334
  });
2321
2335
  }
2322
2336
  };
2323
2337
  _internalStop = () => {};
2324
2338
  _generateUuid() {
2325
2339
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
2326
- let C = Math.random() * 16 | 0;
2327
- return (e === "x" ? C : C & 3 | 8).toString(16);
2340
+ let t = Math.random() * 16 | 0;
2341
+ return (e === "x" ? t : t & 3 | 8).toString(16);
2328
2342
  });
2329
2343
  }
2330
- addScanFailureListener(C) {
2331
- let w = ++e._scanFailureCallbackUniqueId;
2344
+ addScanFailureListener(t) {
2345
+ let n = ++e._scanFailureCallbackUniqueId;
2332
2346
  return this._scanFailureCallbacks.push({
2333
- id: w,
2334
- callback: C
2335
- }), w;
2347
+ id: n,
2348
+ callback: t
2349
+ }), n;
2336
2350
  }
2337
2351
  removeScanFailureListener(e) {
2338
- this._scanFailureCallbacks = this._scanFailureCallbacks.filter(({ id: C }) => C !== e);
2352
+ this._scanFailureCallbacks = this._scanFailureCallbacks.filter(({ id: t }) => t !== e);
2339
2353
  }
2340
2354
  resetCurrentAttempt() {
2341
2355
  this._currentAttemptId = null;
@@ -2370,7 +2384,7 @@ var field = function(e, C, w) {
2370
2384
  set requestCaller(e) {
2371
2385
  this._requestCaller = e;
2372
2386
  }
2373
- }(), AbsolutePositionProvider_default = new class e extends Provider_default {
2387
+ }(), Y = new class e extends j {
2374
2388
  static ACCURACY_RELOC_RATIO = 1;
2375
2389
  static USE_MM_FOR_FEED = !0;
2376
2390
  _polestarProviderId;
@@ -2382,75 +2396,81 @@ var field = function(e, C, w) {
2382
2396
  _waitUntilNextVpsPosition = !1;
2383
2397
  _lastPolestarFix = null;
2384
2398
  ignoreGnssWifi = !1;
2399
+ _lastKnownLevel = null;
2385
2400
  getName = () => "AbsolutePosition";
2401
+ _adaptBeforeNotify(e) {
2402
+ return e.level === null ? e.level = this._lastKnownLevel : this._lastKnownLevel = e.level, e;
2403
+ }
2386
2404
  availability() {
2387
- return AvailabilityHelper.some([
2388
- GeoRelativePositionProvider_default.getAvailability(),
2389
- GnssWifiProvider_default.getAvailability(),
2390
- ...ProvidersOptions_default.hasPoleStar ? [PoleStarProvider_default.getAvailability()] : [],
2391
- VpsProvider_default.getAvailability()
2405
+ return M.some([
2406
+ Qe.getAvailability(),
2407
+ Ie.getAvailability(),
2408
+ ...D.hasPoleStar ? [ct.getAvailability()] : [],
2409
+ J.getAvailability()
2392
2410
  ]);
2393
2411
  }
2394
2412
  start() {
2395
- GeoRelativePositionProvider_default.getAvailability().then((e) => {
2396
- e || (this._relativePositionProviderId = GeoRelativePositionProvider_default.addEventListener((e) => this._onRelativePosition(e)));
2397
- }), this._gnssWifiProviderId = GnssWifiProvider_default.addEventListener((e) => {
2413
+ Qe.getAvailability().then((e) => {
2414
+ e || (this._relativePositionProviderId = Qe.addEventListener((e) => this._onRelativePosition(e)));
2415
+ }), this._gnssWifiProviderId = Ie.addEventListener((e) => {
2398
2416
  if (this.ignoreGnssWifi) return;
2399
- let C = e.clone();
2400
- C.bearing = null, this._onAbsolutePosition(C, !1);
2401
- }), this._vpsProviderId = VpsProvider_default.addEventListener((e) => this._onAbsolutePosition(e.absolutePosition), this.notifyError, !1), ProvidersOptions_default.hasPoleStar && (this._polestarProviderId = PoleStarProvider_default.addEventListener((e) => {
2402
- if (this._lastPolestarFix = TimeUtils.preciseTime(), !this._onAbsolutePosition(e) && this.lastEvent?.level === null) {
2403
- let C = this.lastEvent.clone();
2404
- C.level = e.level, this.notify(C);
2417
+ let t = e.clone();
2418
+ t.bearing = null, this._onAbsolutePosition(t, "gnss-wifi", !1);
2419
+ }), this._vpsProviderId = J.addEventListener((e) => this._onAbsolutePosition(e.absolutePosition, "vps"), this.notifyError, !1), D.hasPoleStar && (this._polestarProviderId = ct.addEventListener((e) => {
2420
+ if (this._lastPolestarFix = C.preciseTime(), !this._onAbsolutePosition(e, "polestar") && this.lastEvent?.level === null) {
2421
+ let t = this.lastEvent.clone();
2422
+ t.level = e.level, this.notify(t);
2405
2423
  }
2406
- })), this._mapMatchingHandlerId = MapMatchingHandler_default.addEventListener();
2424
+ })), this._mapMatchingHandlerId = $.addEventListener();
2407
2425
  }
2408
2426
  stop() {
2409
- this._relativePositionProviderId && (GeoRelativePositionProvider_default.removeEventListener(this._relativePositionProviderId), delete this._relativePositionProviderId), this._gnssWifiProviderId && (GnssWifiProvider_default.removeEventListener(this._gnssWifiProviderId), delete this._gnssWifiProviderId), this._vpsProviderId && (VpsProvider_default.removeEventListener(this._vpsProviderId), delete this._vpsProviderId), this._polestarProviderId && (PoleStarProvider_default.removeEventListener(this._polestarProviderId), delete this._polestarProviderId), MapMatchingHandler_default.removeEventListener(this._mapMatchingHandlerId);
2410
- }
2411
- _shouldTakeIntoAccountNewAbsolutePosition(C, w = !0) {
2412
- let T = C, D = this.lastEvent || null;
2413
- if (!D) return !0;
2414
- let O = T.accuracy * e.ACCURACY_RELOC_RATIO <= D.accuracy;
2415
- if (O) return !0;
2416
- let k = D.distanceTo(T) > D.accuracy + T.accuracy;
2417
- if (k) return !0;
2418
- let A = k && T.accuracy <= D.accuracy;
2419
- return !!(O && A || w && !Level.equals(T.level, D.level));
2420
- }
2421
- _onAbsolutePosition(e, C = !0) {
2422
- if (!this._shouldTakeIntoAccountNewAbsolutePosition(e, C) && !this.useAllAbsolutePositions) return !1;
2423
- let w = e.clone(), T = this.lastEvent ? this.lastEvent : null;
2424
- return T && (C || (w.level = T.level), w.bearing === null && (w.bearing = T.bearing)), MapMatchingHandler_default.canUseMapMatching() ? MapMatchingHandler_default.notifyPositionFromAbsolute(w) : (this.notify(w), !0);
2427
+ this._relativePositionProviderId && (Qe.removeEventListener(this._relativePositionProviderId), delete this._relativePositionProviderId), this._gnssWifiProviderId && (Ie.removeEventListener(this._gnssWifiProviderId), delete this._gnssWifiProviderId), this._vpsProviderId && (J.removeEventListener(this._vpsProviderId), delete this._vpsProviderId), this._polestarProviderId && (ct.removeEventListener(this._polestarProviderId), delete this._polestarProviderId), $.removeEventListener(this._mapMatchingHandlerId);
2428
+ }
2429
+ _shouldTakeIntoAccountNewAbsolutePosition(t, n = !0) {
2430
+ let r = t, a = this.lastEvent || null;
2431
+ if (!a) return !0;
2432
+ let o = r.accuracy * e.ACCURACY_RELOC_RATIO <= a.accuracy;
2433
+ if (o) return !0;
2434
+ let s = a.distanceTo(r) > a.accuracy + r.accuracy;
2435
+ if (s) return !0;
2436
+ let c = s && r.accuracy <= a.accuracy;
2437
+ return !!(o && c || n && !i.equals(r.level, a.level));
2438
+ }
2439
+ _onAbsolutePosition(e, t, n = !0) {
2440
+ if (!this._shouldTakeIntoAccountNewAbsolutePosition(e, n) && !this.useAllAbsolutePositions) return !1;
2441
+ let r = re.fromUserPosition(e, t), i = this.lastEvent ? this.lastEvent : null;
2442
+ return i && (n || (r.level = i.level), r.bearing === null && (r.bearing = i.bearing)), $.canUseMapMatching() ? $.notifyPositionFromAbsolute(r) : (this.notify(r), !0);
2425
2443
  }
2426
2444
  _onRelativePosition(e) {
2427
2445
  if (!this.lastEvent || this._waitUntilNextVpsPosition) return !1;
2428
- let C = this.lastEvent, w = e, T = Math.sqrt(w.x ** 2 + w.y ** 2), E = Math.atan2(w.x, w.y), D = C.alt === null ? null : w.z, O = C.destinationPoint(T, E, D);
2429
- return O.bearing = w.bearing, O.time = w.time, O.accuracy += w.accuracy, MapMatchingHandler_default.canUseMapMatching() ? MapMatchingHandler_default.notifyPositionFromRelative(O) : (this.notify(O), !0);
2430
- }
2431
- feed(C) {
2432
- let w;
2433
- if (C instanceof UserPosition) {
2434
- if (C.time === null) throw Error("the time of the position is not defined");
2435
- if (C.accuracy === null) throw Error("the accuracy of the position is not defined");
2436
- w = C;
2446
+ let t = this.lastEvent, n = e, r = Math.sqrt(n.x ** 2 + n.y ** 2), i = Math.atan2(n.x, n.y), a = t.alt === null ? null : n.z, o = t.destinationPoint(r, i, a);
2447
+ o.bearing = n.bearing, o.time = n.time, o.accuracy += n.accuracy;
2448
+ let s = re.fromUserPosition(o, "relative");
2449
+ return $.canUseMapMatching() ? $.notifyPositionFromRelative(s) : (this.notify(s), !0);
2450
+ }
2451
+ feed(t) {
2452
+ let n;
2453
+ if (t instanceof o) {
2454
+ if (t.time === null) throw Error("the time of the position is not defined");
2455
+ if (t.accuracy === null) throw Error("the accuracy of the position is not defined");
2456
+ n = re.fromUserPosition(t, t.source ?? "feed");
2437
2457
  } else throw Error("data is nor an UserPosition or an AbsolutePositionEvent");
2438
- if (!e.USE_MM_FOR_FEED || !MapMatchingHandler_default.canUseMapMatching()) {
2439
- this.notify(w);
2458
+ if (!e.USE_MM_FOR_FEED || !$.canUseMapMatching()) {
2459
+ this.notify(n);
2440
2460
  return;
2441
2461
  }
2442
- MapMatchingHandler_default.notifyPositionFromFeed(w);
2462
+ $.notifyPositionFromFeed(n);
2443
2463
  }
2444
2464
  getBestPositionEvent(...e) {
2445
- return e.reduce((e, C) => {
2446
- if (!e) return C;
2447
- if (!C || C.accuracy === null || C.time === null) return e;
2448
- let { accuracy: w, time: T } = C, { accuracy: E, time: D } = e;
2449
- return w < E + 1.3888 * (T - D) ? C : e;
2465
+ return e.reduce((e, t) => {
2466
+ if (!e) return t;
2467
+ if (!t || t.accuracy === null || t.time === null) return e;
2468
+ let { accuracy: n, time: r } = t, { accuracy: i, time: a } = e;
2469
+ return n < i + 1.3888 * (r - a) ? t : e;
2450
2470
  }, null);
2451
2471
  }
2452
- }(), AbsoluteAttitudeFromBrowserProvider_default = new class e extends Provider_default {
2453
- DEFAULT_ACCURACY = deg2rad(15);
2472
+ }(), lt = new class e extends j {
2473
+ DEFAULT_ACCURACY = m(15);
2454
2474
  absolutePositionProviderId;
2455
2475
  absolutePositionEvent;
2456
2476
  declinationQuaternion;
@@ -2460,102 +2480,102 @@ var field = function(e, C, w) {
2460
2480
  iosIsSkyMode = null;
2461
2481
  getName = () => "AbsoluteAttitudeFromBrowser";
2462
2482
  availability() {
2463
- return BrowserUtils.isMobile ? Promise.resolve() : Promise.resolve(new AskImuOnDesktopError_default());
2483
+ return S.isMobile ? Promise.resolve() : Promise.resolve(new Ae());
2464
2484
  }
2465
2485
  start() {
2466
2486
  let e = () => {
2467
- switch (BrowserUtils.getName()) {
2468
- case Browser.CHROME:
2487
+ switch (S.getName()) {
2488
+ case x.CHROME:
2469
2489
  window.addEventListener("deviceorientationabsolute", this.onDeviceOrientationChromeEvent, !0);
2470
2490
  break;
2471
- case Browser.SAFARI:
2472
- case Browser.IOS_WEBVIEW:
2491
+ case x.SAFARI:
2492
+ case x.IOS_WEBVIEW:
2473
2493
  window.addEventListener("deviceorientation", this.onDeviceOrientationSafariEvent, !0);
2474
2494
  break;
2475
2495
  }
2476
- }, C = DeviceOrientationEvent.requestPermission || void 0;
2477
- C ? C().then((C) => {
2478
- if (C !== "granted") throw Error("Permission not granted");
2496
+ }, t = DeviceOrientationEvent.requestPermission || void 0;
2497
+ t ? t().then((t) => {
2498
+ if (t !== "granted") throw Error("Permission not granted");
2479
2499
  e();
2480
2500
  }).catch(this.notifyError) : e();
2481
- let w = AbsolutePositionProvider_default.lastEvent;
2482
- w ? this.onAbsolutePositionEvent(w) : this.absolutePositionProviderId = AbsolutePositionProvider_default.addEventListener(this.onAbsolutePositionEvent, this.notifyError, !1);
2501
+ let n = Y.lastEvent;
2502
+ n ? this.onAbsolutePositionEvent(n) : this.absolutePositionProviderId = Y.addEventListener(this.onAbsolutePositionEvent, this.notifyError, !1);
2483
2503
  }
2484
2504
  stop() {
2485
- switch (BrowserUtils.getName()) {
2486
- case Browser.CHROME:
2505
+ switch (S.getName()) {
2506
+ case x.CHROME:
2487
2507
  window.removeEventListener("deviceorientationabsolute", this.onDeviceOrientationChromeEvent, !0);
2488
2508
  break;
2489
- case Browser.SAFARI:
2490
- case Browser.IOS_WEBVIEW:
2509
+ case x.SAFARI:
2510
+ case x.IOS_WEBVIEW:
2491
2511
  window.removeEventListener("deviceorientation", this.onDeviceOrientationSafariEvent, !0);
2492
2512
  break;
2493
2513
  }
2494
- AbsolutePositionProvider_default.removeEventListener(this.absolutePositionProviderId);
2514
+ Y.removeEventListener(this.absolutePositionProviderId);
2495
2515
  }
2496
2516
  onDeviceOrientationChromeEvent = (e) => {
2497
2517
  if (this.magQuaternionTimestamp = e.timeStamp / 1e3, typeof e.alpha != "number" || typeof e.beta != "number" || typeof e.gamma != "number") {
2498
- this.notifyError(new MissingSensorError_default().from("deviceorientationabsolute"));
2518
+ this.notifyError(new R().from("deviceorientationabsolute"));
2499
2519
  return;
2500
2520
  }
2501
- this.magQuaternion = Rotations.eulerToQuaternionZXYDegrees([
2521
+ this.magQuaternion = d.eulerToQuaternionZXYDegrees([
2502
2522
  e.alpha,
2503
2523
  e.beta,
2504
2524
  e.gamma
2505
2525
  ]), this.compute();
2506
2526
  };
2507
- onDeviceOrientationSafariEvent = (C) => {
2508
- if (this.magQuaternionTimestamp = C.timeStamp / 1e3, typeof C.beta != "number" || typeof C.gamma != "number") {
2509
- this.notifyError(new MissingSensorError_default().from("deviceorientation"));
2527
+ onDeviceOrientationSafariEvent = (t) => {
2528
+ if (this.magQuaternionTimestamp = t.timeStamp / 1e3, typeof t.beta != "number" || typeof t.gamma != "number") {
2529
+ this.notifyError(new R().from("deviceorientation"));
2510
2530
  return;
2511
2531
  }
2512
- if (typeof C.webkitCompassHeading != "number") {
2513
- this.notifyError(new MissingMagnetometerError_default().from("deviceorientation"));
2532
+ if (typeof t.webkitCompassHeading != "number") {
2533
+ this.notifyError(new je().from("deviceorientation"));
2514
2534
  return;
2515
2535
  }
2516
- let w, [T, E, D, O] = Rotations.eulerToQuaternionZXYDegrees([
2517
- C.webkitCompassHeading,
2518
- C.beta,
2519
- C.gamma
2520
- ]), k = rad2deg(Math.acos(T ** 2 - E ** 2 - D ** 2 + O ** 2)), A = null;
2521
- k > 136 ? A = !0 : k < 134 ? A = !1 : this.iosPreviousQuat && this.iosIsSkyMode !== null && (A = Quaternion.distance([
2522
- T,
2523
- E,
2524
- D,
2525
- O
2536
+ let n, [r, i, a, o] = d.eulerToQuaternionZXYDegrees([
2537
+ t.webkitCompassHeading,
2538
+ t.beta,
2539
+ t.gamma
2540
+ ]), s = _(Math.acos(r ** 2 - i ** 2 - a ** 2 + o ** 2)), c = null;
2541
+ s > 136 ? c = !0 : s < 134 ? c = !1 : this.iosPreviousQuat && this.iosIsSkyMode !== null && (c = u.distance([
2542
+ r,
2543
+ i,
2544
+ a,
2545
+ o
2526
2546
  ], this.iosPreviousQuat) < .5 ? this.iosIsSkyMode : !this.iosIsSkyMode), this.iosPreviousQuat = [
2527
- T,
2528
- E,
2529
- D,
2530
- O
2531
- ], this.iosIsSkyMode = A, A !== void 0 && (w = A ? 180 - C.webkitCompassHeading : e.webkitCompassToHeading(C.webkitCompassHeading, C.beta, C.gamma), this.magQuaternion = Rotations.eulerToQuaternionZXYDegrees([
2532
- w,
2533
- C.beta,
2534
- C.gamma
2547
+ r,
2548
+ i,
2549
+ a,
2550
+ o
2551
+ ], this.iosIsSkyMode = c, c !== void 0 && (n = c ? 180 - t.webkitCompassHeading : e.webkitCompassToHeading(t.webkitCompassHeading, t.beta, t.gamma), this.magQuaternion = d.eulerToQuaternionZXYDegrees([
2552
+ n,
2553
+ t.beta,
2554
+ t.gamma
2535
2555
  ]), this.compute());
2536
2556
  };
2537
2557
  compute() {
2538
2558
  if (!this.declinationQuaternion || !this.magQuaternion || !this.absolutePositionEvent) return;
2539
- let e = new AbsoluteAttitude(Quaternion.multiply(this.declinationQuaternion, this.magQuaternion), this.magQuaternionTimestamp, this.DEFAULT_ACCURACY);
2559
+ let e = new ae(u.multiply(this.declinationQuaternion, this.magQuaternion), this.magQuaternionTimestamp, this.DEFAULT_ACCURACY);
2540
2560
  this.notify(e);
2541
2561
  }
2542
2562
  onAbsolutePositionEvent = (e) => {
2543
2563
  this.absolutePositionEvent = e;
2544
- let C = field(e.lat, e.lng);
2545
- this.declinationQuaternion = Quaternion.fromAxisAngle([
2564
+ let t = ke(e.lat, e.lng);
2565
+ this.declinationQuaternion = u.fromAxisAngle([
2546
2566
  0,
2547
2567
  0,
2548
2568
  1
2549
- ], -deg2rad(C.declination)), AbsolutePositionProvider_default.removeEventListener(this.absolutePositionProviderId), delete this.absolutePositionProviderId, this.compute();
2569
+ ], -m(t.declination)), Y.removeEventListener(this.absolutePositionProviderId), delete this.absolutePositionProviderId, this.compute();
2550
2570
  };
2551
- static webkitCompassToHeading(e, C, w) {
2552
- let T = deg2rad(e), E = deg2rad(C), D = deg2rad(w), O = Math.cos(T / 2), k = Math.cos(E / 2), A = Math.cos(D / 2), j = Math.sin(T / 2), M = Math.sin(E / 2), N = Math.sin(D / 2), F = O * k * A - j * M * N, I = j * k * A + O * M * N;
2553
- return rad2deg(-2 * Math.atan(I / F));
2571
+ static webkitCompassToHeading(e, t, n) {
2572
+ let r = m(e), i = m(t), a = m(n), o = Math.cos(r / 2), s = Math.cos(i / 2), c = Math.cos(a / 2), l = Math.sin(r / 2), u = Math.sin(i / 2), d = Math.sin(a / 2), f = o * s * c - l * u * d, p = l * s * c + o * u * d;
2573
+ return _(-2 * Math.atan(p / f));
2554
2574
  }
2555
- }(), AbsoluteAttitudeProvider_default = new class w extends Provider_default {
2556
- static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD = deg2rad(25);
2575
+ }(), X = new class n extends j {
2576
+ static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD = m(25);
2557
2577
  static REL_ABS_DIVERGENCE_TIME_THRESHOLD = 2.5;
2558
- static REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD = deg2rad(15);
2578
+ static REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD = m(15);
2559
2579
  _absAttitudeFromBrowser;
2560
2580
  _vpsProviderId;
2561
2581
  fromBrowserProviderId;
@@ -2573,17 +2593,17 @@ var field = function(e, C, w) {
2573
2593
  _callbackMagCalibration;
2574
2594
  getName = () => "AbsoluteAttitude";
2575
2595
  availability() {
2576
- return AvailabilityHelper.some([AbsoluteAttitudeFromBrowserProvider_default.getAvailability(), RelativeAttitudeProvider_default.getAvailability()]);
2596
+ return M.some([lt.getAvailability(), q.getAvailability()]);
2577
2597
  }
2578
2598
  start() {
2579
- this.fromBrowserProviderId = AbsoluteAttitudeFromBrowserProvider_default.addEventListener(this._onAttitudeFromBrowser, (e) => {
2599
+ this.fromBrowserProviderId = lt.addEventListener(this._onAttitudeFromBrowser, (e) => {
2580
2600
  this._attitudeFromBrowserErrored = !0, this._onError(e);
2581
- }), this._vpsProviderId = VpsProvider_default.addEventListener((e) => this._onAttitudeFromVps(e.absoluteAttitude), (e) => this.notifyError(e), !1), this.relativeAttitudeProviderId = RelativeAttitudeProvider_default.addEventListener(this._onRelativeAttitudeEvent, (e) => {
2601
+ }), this._vpsProviderId = J.addEventListener((e) => this._onAttitudeFromVps(e.absoluteAttitude), (e) => this.notifyError(e), !1), this.relativeAttitudeProviderId = q.addEventListener(this._onRelativeAttitudeEvent, (e) => {
2582
2602
  this._attitudeFromRelativeErrored = !0, this._onError(e);
2583
- }), this.inclinationProviderId = InclinationProvider_default.addEventListener(), this.highRotationProviderId = HighRotationsProvider_default.addEventListener();
2603
+ }), this.inclinationProviderId = K.addEventListener(), this.highRotationProviderId = U.addEventListener();
2584
2604
  }
2585
2605
  stop() {
2586
- AbsoluteAttitudeFromBrowserProvider_default.removeEventListener(this.fromBrowserProviderId), RelativeAttitudeProvider_default.removeEventListener(this.relativeAttitudeProviderId), InclinationProvider_default.removeEventListener(this.inclinationProviderId), HighRotationsProvider_default.removeEventListener(this.highRotationProviderId), VpsProvider_default.removeEventListener(this._vpsProviderId);
2606
+ lt.removeEventListener(this.fromBrowserProviderId), q.removeEventListener(this.relativeAttitudeProviderId), K.removeEventListener(this.inclinationProviderId), U.removeEventListener(this.highRotationProviderId), J.removeEventListener(this._vpsProviderId);
2587
2607
  }
2588
2608
  _setCallbackMagCalibration(e) {
2589
2609
  this._callbackMagCalibration = e;
@@ -2593,37 +2613,37 @@ var field = function(e, C, w) {
2593
2613
  };
2594
2614
  _forceHeadingForRelative = (e) => {
2595
2615
  if (this.lastEvent && e.accuracy > this.lastEvent.accuracy) return;
2596
- let C = (C) => {
2597
- let w = C.heading;
2598
- this._relAbsQuat = Quaternion.fromAxisAngle([
2616
+ let t = (t) => {
2617
+ let n = t.heading;
2618
+ this._relAbsQuat = u.fromAxisAngle([
2599
2619
  0,
2600
2620
  0,
2601
2621
  1
2602
- ], w - e.heading), this._relativeAccuracy = 0, this._lastForcedHeadingEvent = e;
2622
+ ], n - e.heading), this._relativeAccuracy = 0, this._lastForcedHeadingEvent = e;
2603
2623
  };
2604
2624
  if (this._relativeAttitude) {
2605
- C(this._relativeAttitude);
2625
+ t(this._relativeAttitude);
2606
2626
  return;
2607
2627
  }
2608
- let w = RelativeAttitudeProvider_default.addEventListener((e) => {
2609
- C(e), RelativeAttitudeProvider_default.removeEventListener(w);
2628
+ let n = q.addEventListener((e) => {
2629
+ t(e), q.removeEventListener(n);
2610
2630
  });
2611
2631
  };
2612
2632
  _onRelativeAttitudeEvent = (e) => {
2613
- let { quaternion: T, accuracy: E, time: D } = e;
2614
- if (this._relativeAttitude && (this._relativeAccuracy += (D - this._relativeAttitude.time) * E), this._relativeAttitude = e, !this._lastForcedHeadingEvent || !this._relAbsQuat) return;
2615
- let O = Math.min((this._lastForcedHeadingEvent.accuracy || 0) + this._relativeAccuracy, Math.PI), k = HighRotationsProvider_default.isInProgress(), A = !1;
2633
+ let { quaternion: r, accuracy: i, time: a } = e;
2634
+ if (this._relativeAttitude && (this._relativeAccuracy += (a - this._relativeAttitude.time) * i), this._relativeAttitude = e, !this._lastForcedHeadingEvent || !this._relAbsQuat) return;
2635
+ let o = Math.min((this._lastForcedHeadingEvent.accuracy || 0) + this._relativeAccuracy, Math.PI), s = U.isInProgress(), c = !1;
2616
2636
  if (this._absAttitudeFromBrowser) {
2617
- let { accuracy: e, heading: E } = this._absAttitudeFromBrowser;
2618
- if (this._wasHighRotationInProgress && !k) this._forceHeadingForRelative(this._absAttitudeFromBrowser);
2619
- else if (e < O) {
2620
- let e = new Attitude(Quaternion.multiply(this._relAbsQuat, T)), O = Math.abs(diffAngle(e.heading, E)), k = InclinationProvider_default.lastEvent;
2621
- O > w.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD && k !== null && Math.abs(k - Math.PI / 4) > w.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD && (A = !0, this._timeFirstDivergence !== null && D - this._timeFirstDivergence > w.REL_ABS_DIVERGENCE_TIME_THRESHOLD ? (this._forceHeadingForRelative(this._absAttitudeFromBrowser), this._callbackMagCalibration?.({ angle: O }), this._timeFirstDivergence = null) : this._timeFirstDivergence === null && (this._timeFirstDivergence = D));
2637
+ let { accuracy: e, heading: i } = this._absAttitudeFromBrowser;
2638
+ if (this._wasHighRotationInProgress && !s) this._forceHeadingForRelative(this._absAttitudeFromBrowser);
2639
+ else if (e < o) {
2640
+ let e = new t(u.multiply(this._relAbsQuat, r)), o = Math.abs(h(e.heading, i)), s = K.lastEvent;
2641
+ o > n.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD && s !== null && Math.abs(s - Math.PI / 4) > n.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD && (c = !0, this._timeFirstDivergence !== null && a - this._timeFirstDivergence > n.REL_ABS_DIVERGENCE_TIME_THRESHOLD ? (this._forceHeadingForRelative(this._absAttitudeFromBrowser), this._callbackMagCalibration?.({ angle: o }), this._timeFirstDivergence = null) : this._timeFirstDivergence === null && (this._timeFirstDivergence = a));
2622
2642
  }
2623
2643
  }
2624
- A || (this._timeFirstDivergence = null), this._wasHighRotationInProgress = k;
2625
- let j = new AbsoluteAttitude(Quaternion.multiply(this._relAbsQuat, T), D, O);
2626
- this.notify(j);
2644
+ c || (this._timeFirstDivergence = null), this._wasHighRotationInProgress = s;
2645
+ let l = new ae(u.multiply(this._relAbsQuat, r), a, o);
2646
+ this.notify(l);
2627
2647
  };
2628
2648
  _onAttitudeFromBrowser = (e) => {
2629
2649
  if (this._absAttitudeFromBrowser = e, !this._lastForcedHeadingEvent) {
@@ -2634,39 +2654,39 @@ var field = function(e, C, w) {
2634
2654
  _onAttitudeFromVps = (e) => {
2635
2655
  this._forceHeadingForRelative(e);
2636
2656
  };
2637
- feed(C) {
2638
- if (C instanceof AbsoluteHeading) {
2639
- if (C.time === null) throw Error("the time of the absolute heading is not defined");
2640
- if (C.accuracy === null) throw Error("the accuracy of the absolute heading is not defined");
2641
- this._forceHeadingForRelative(C);
2642
- } else if (C instanceof AbsoluteAttitude) {
2643
- if (C.time === null) throw Error("the time of the attitude is not defined");
2644
- if (C.accuracy === null) throw Error("the accuracy of the attitude is not defined");
2645
- this._forceHeadingForRelative(C);
2657
+ feed(t) {
2658
+ if (t instanceof e) {
2659
+ if (t.time === null) throw Error("the time of the absolute heading is not defined");
2660
+ if (t.accuracy === null) throw Error("the accuracy of the absolute heading is not defined");
2661
+ this._forceHeadingForRelative(t);
2662
+ } else if (t instanceof ae) {
2663
+ if (t.time === null) throw Error("the time of the attitude is not defined");
2664
+ if (t.accuracy === null) throw Error("the accuracy of the attitude is not defined");
2665
+ this._forceHeadingForRelative(t);
2646
2666
  } else throw Error("data is nor an AbsoluteHeading or an Attitude object");
2647
2667
  }
2648
- }(), TurnProvider_default = new class e extends Provider_default {
2668
+ }(), Z = new class e extends j {
2649
2669
  static SLIDING_WINDOW_TIME = .3;
2650
2670
  static STD_THRESHOLD = .075;
2651
2671
  static CONSIDER_TURN_UNTIL = 1;
2652
2672
  providerId;
2653
2673
  slidingWindow = [];
2654
2674
  getName = () => "Turn";
2655
- availability = () => RelativeAttitudeProvider_default.getAvailability();
2675
+ availability = () => q.getAvailability();
2656
2676
  start() {
2657
- this.providerId = RelativeAttitudeProvider_default.addEventListener(this._parseRelativeAttitude, this.notifyError);
2677
+ this.providerId = q.addEventListener(this._parseRelativeAttitude, this.notifyError);
2658
2678
  }
2659
2679
  stop() {
2660
- RelativeAttitudeProvider_default.removeEventListener(this.providerId);
2680
+ q.removeEventListener(this.providerId);
2661
2681
  }
2662
2682
  isTurning() {
2663
- return !this.lastEvent || !RelativeAttitudeProvider_default.lastEvent ? !1 : RelativeAttitudeProvider_default.lastEvent.time - this.lastEvent.timestamp < e.CONSIDER_TURN_UNTIL;
2683
+ return !this.lastEvent || !q.lastEvent ? !1 : q.lastEvent.time - this.lastEvent.timestamp < e.CONSIDER_TURN_UNTIL;
2664
2684
  }
2665
- _parseRelativeAttitude = (C) => {
2666
- let { heading: w } = C, T = C.time;
2667
- this.slidingWindow = this.slidingWindow.filter((C) => C[0] >= T - e.SLIDING_WINDOW_TIME), this.slidingWindow.push([T, w]), std(this.slidingWindow.map((e) => e[1])) > e.STD_THRESHOLD && this.notify({ timestamp: T });
2685
+ _parseRelativeAttitude = (t) => {
2686
+ let { heading: n } = t, r = t.time;
2687
+ this.slidingWindow = this.slidingWindow.filter((t) => t[0] >= r - e.SLIDING_WINDOW_TIME), this.slidingWindow.push([r, n]), v(this.slidingWindow.map((e) => e[1])) > e.STD_THRESHOLD && this.notify({ timestamp: r });
2668
2688
  };
2669
- }(), StraightLineProvider_default = new class e extends Provider_default {
2689
+ }(), Q = new class e extends j {
2670
2690
  static DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE = 2;
2671
2691
  _turnProviderId;
2672
2692
  _stepProviderId;
@@ -2674,13 +2694,13 @@ var field = function(e, C, w) {
2674
2694
  _stepsConsideredForStraightLine = e.DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE;
2675
2695
  getName = () => "StraightLine";
2676
2696
  availability() {
2677
- return AvailabilityHelper.every([TurnProvider_default.getAvailability(), StepProvider_default.getAvailability()]);
2697
+ return M.every([Z.getAvailability(), G.getAvailability()]);
2678
2698
  }
2679
2699
  start() {
2680
- this._turnProviderId = TurnProvider_default.addEventListener(this._onTurn), this._stepProviderId = StepProvider_default.addEventListener(this._onStep);
2700
+ this._turnProviderId = Z.addEventListener(this._onTurn), this._stepProviderId = G.addEventListener(this._onStep);
2681
2701
  }
2682
2702
  stop() {
2683
- TurnProvider_default.removeEventListener(this._turnProviderId), StepProvider_default.removeEventListener(this._stepProviderId);
2703
+ Z.removeEventListener(this._turnProviderId), G.removeEventListener(this._stepProviderId);
2684
2704
  }
2685
2705
  _onTurn = () => {
2686
2706
  this._countSteps >= this._stepsConsideredForStraightLine && this.notify(!1), this._countSteps = 0;
@@ -2700,8 +2720,8 @@ var field = function(e, C, w) {
2700
2720
  set stepsConsideredForStraightLine(e) {
2701
2721
  this._stepsConsideredForStraightLine = e;
2702
2722
  }
2703
- }(), MapMatchingHandler_default = new class C extends Provider_default {
2704
- static DEFAULT_MM_MAX_ANGLE = deg2rad(30);
2723
+ }(), $ = new class t extends j {
2724
+ static DEFAULT_MM_MAX_ANGLE = m(30);
2705
2725
  static DEFAULT_MM_MAX_DIST = 30;
2706
2726
  static DEFAULT_MM_MIN_DIST = 0;
2707
2727
  static DEFAULT_USE_ITINERARY_START_AS_POSITION = !1;
@@ -2711,20 +2731,20 @@ var field = function(e, C, w) {
2711
2731
  static DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING = 3;
2712
2732
  static DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING = 5;
2713
2733
  static DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE = 3;
2714
- static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD = deg2rad(3);
2734
+ static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD = m(3);
2715
2735
  static DEFAULT_USE_STRICT = !1;
2716
- _mapMatchingMaxDistance = C.DEFAULT_MM_MAX_DIST;
2717
- _mapMatchingMinDistance = C.DEFAULT_MM_MIN_DIST;
2718
- _mapMatchingMaxAngleBearing = C.DEFAULT_MM_MAX_ANGLE;
2719
- _useItineraryStartAsPosition = C.DEFAULT_USE_ITINERARY_START_AS_POSITION;
2720
- _useOrientationMatching = C.DEFAULT_USE_ORIENTATION_MATCHING;
2721
- _hugeJumpDistance = C.DEFAULT_MM_HUGE_JUMP_DISTANCE;
2722
- _disableMMCloseToATurnDistance = C.DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE;
2723
- _minStepsBetweenOrientationMatching = C.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;
2724
- _minStepsForOrientationMatching = C.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;
2725
- _lastProjectionsWindowSize = C.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;
2726
- _lastProjectionsEdgeAngleThreshold = C.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;
2727
- _useStrict = C.DEFAULT_USE_STRICT;
2736
+ _mapMatchingMaxDistance = t.DEFAULT_MM_MAX_DIST;
2737
+ _mapMatchingMinDistance = t.DEFAULT_MM_MIN_DIST;
2738
+ _mapMatchingMaxAngleBearing = t.DEFAULT_MM_MAX_ANGLE;
2739
+ _useItineraryStartAsPosition = t.DEFAULT_USE_ITINERARY_START_AS_POSITION;
2740
+ _useOrientationMatching = t.DEFAULT_USE_ORIENTATION_MATCHING;
2741
+ _hugeJumpDistance = t.DEFAULT_MM_HUGE_JUMP_DISTANCE;
2742
+ _disableMMCloseToATurnDistance = t.DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE;
2743
+ _minStepsBetweenOrientationMatching = t.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;
2744
+ _minStepsForOrientationMatching = t.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;
2745
+ _lastProjectionsWindowSize = t.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;
2746
+ _lastProjectionsEdgeAngleThreshold = t.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;
2747
+ _useStrict = t.DEFAULT_USE_STRICT;
2728
2748
  _graph = null;
2729
2749
  _internalProvidersStarted = !1;
2730
2750
  _straightLineProviderId;
@@ -2746,13 +2766,13 @@ var field = function(e, C, w) {
2746
2766
  this.graph && !this._internalProvidersStarted ? this._startInternalProviders() : !this.graph && this._internalProvidersStarted && this._stopInternalProviders();
2747
2767
  };
2748
2768
  _startInternalProviders() {
2749
- this.enabled && this._internalProvidersStarted || (this._straightLineProviderId = StraightLineProvider_default.addEventListener(), this._turnProviderId = TurnProvider_default.addEventListener(), this._stepProviderId = StepProvider_default.addEventListener(() => this._countStepsFromLastMatching++), this._internalProvidersStarted = !0);
2769
+ this.enabled && this._internalProvidersStarted || (this._straightLineProviderId = Q.addEventListener(), this._turnProviderId = Z.addEventListener(), this._stepProviderId = G.addEventListener(() => this._countStepsFromLastMatching++), this._internalProvidersStarted = !0);
2750
2770
  }
2751
2771
  _stopInternalProviders() {
2752
- this.enabled && !this._internalProvidersStarted || (StraightLineProvider_default.removeEventListener(this._straightLineProviderId), TurnProvider_default.removeEventListener(this._turnProviderId), StepProvider_default.removeEventListener(this._stepProviderId), this._internalProvidersStarted = !1);
2772
+ this.enabled && !this._internalProvidersStarted || (Q.removeEventListener(this._straightLineProviderId), Z.removeEventListener(this._turnProviderId), G.removeEventListener(this._stepProviderId), this._internalProvidersStarted = !1);
2753
2773
  }
2754
2774
  get enabled() {
2755
- return ProvidersOptions_default.useMapMatching;
2775
+ return D.useMapMatching;
2756
2776
  }
2757
2777
  get graph() {
2758
2778
  return this._graph;
@@ -2761,96 +2781,96 @@ var field = function(e, C, w) {
2761
2781
  this._graph = e, this._itineraryInfoManager = null, this.notify({ ...e && { graph: e } }), this._manageStartStop(), this.canUseMapMatching();
2762
2782
  }
2763
2783
  set itinerary(e) {
2764
- this._graph = e ? e.toGraph() : null, this._itineraryInfoManager = new ItineraryInfoManager(e), this.notify({ ...e && { itinerary: e } }), this._manageStartStop(), this.canUseMapMatching() && e && this._notifyPositionFromItineraryInput(e);
2784
+ this._graph = e ? e.toGraph() : null, this._itineraryInfoManager = new b(e), this.notify({ ...e && { itinerary: e } }), this._manageStartStop(), this.canUseMapMatching() && e && this._notifyPositionFromItineraryInput(e);
2765
2785
  }
2766
2786
  canUseMapMatching() {
2767
2787
  return this.enabled && this.graph;
2768
2788
  }
2769
2789
  _notifyPositionFromItineraryInput(e) {
2770
2790
  if (!this._useItineraryStartAsPosition || !e.origin) return;
2771
- let C = AbsolutePositionProvider_default.lastEvent || null, w = UserPosition.fromCoordinates(e.origin);
2772
- if (C) w.alt = C.alt, w.time = C.time, w.accuracy = C.accuracy + w.distanceTo(C), w.bearing = C.bearing;
2773
- else if (e.coords.length >= 2) w.alt = Constants_default.DEFAULT_ALTITUDE, w.time = TimeUtils.preciseTime(), w.accuracy = 0, w.bearing = e.coords[0].bearingTo(e.coords[1]);
2791
+ let t = Y.lastEvent || null, n = o.fromCoordinates(e.origin);
2792
+ if (t) n.alt = t.alt, n.time = t.time, n.accuracy = t.accuracy + n.distanceTo(t), n.bearing = t.bearing;
2793
+ else if (e.coords.length >= 2) n.alt = Fe.DEFAULT_ALTITUDE, n.time = C.preciseTime(), n.accuracy = 0, n.bearing = e.coords[0].bearingTo(e.coords[1]);
2774
2794
  else return;
2775
- let T = this.getProjection(w, !0);
2776
- T ? AbsolutePositionProvider_default.notify(T.coords) : AbsolutePositionProvider_default.notify(w);
2795
+ let r = this.getProjection(n, !0);
2796
+ r ? Y.notify(r.coords) : Y.notify(n);
2777
2797
  }
2778
2798
  notifyPositionFromFeed(e) {
2779
- let C = this.getProjection(e, !0, !1);
2780
- if (this._useStrict && C) {
2781
- AbsolutePositionProvider_default.notify(C.coords);
2799
+ let t = this.getProjection(e, !0, !1);
2800
+ if (this._useStrict && t) {
2801
+ Y.notify(t.coords);
2782
2802
  return;
2783
2803
  }
2784
- if (!C) {
2785
- AbsolutePositionProvider_default.notify(e);
2804
+ if (!t) {
2805
+ Y.notify(e);
2786
2806
  return;
2787
2807
  }
2788
- AbsolutePositionProvider_default.notify(C.coords);
2808
+ Y.notify(t.coords);
2789
2809
  }
2790
2810
  notifyPositionFromAbsolute(e) {
2791
2811
  if (this._useStrict) {
2792
- let C = this.getProjection(e);
2793
- if (C) return AbsolutePositionProvider_default.notify(C.coords), !0;
2812
+ let t = this.getProjection(e);
2813
+ if (t) return Y.notify(t.coords), !0;
2794
2814
  }
2795
- let C = null;
2796
- if (e.bearing !== null && (C = this.getProjection(e, !0, !0)), !C) return AbsolutePositionProvider_default.notify(e), !0;
2797
- let w = C.distanceFromNearestElement > this._hugeJumpDistance;
2798
- return w && !StraightLineProvider_default.isStraight() || w && this._detectWrongBigJump(C) ? !1 : (AbsolutePositionProvider_default.notify(C.coords), this.tryOrientationMatching(C), !0);
2815
+ let t = null;
2816
+ if (e.bearing !== null && (t = this.getProjection(e, !0, !0)), !t) return Y.notify(e), !0;
2817
+ let n = t.distanceFromNearestElement > this._hugeJumpDistance;
2818
+ return n && !Q.isStraight() || n && this._detectWrongBigJump(t) ? !1 : (Y.notify(t.coords), this.tryOrientationMatching(t), !0);
2799
2819
  }
2800
2820
  notifyPositionFromRelative(e) {
2801
- let C = this.getProjection(e, !0, !0);
2802
- if (this._useStrict && C) return AbsolutePositionProvider_default.notify(C.coords), !0;
2803
- if (TurnProvider_default.isTurning()) return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [], AbsolutePositionProvider_default.notify(e), !0;
2804
- if (C) {
2805
- this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections.push(C), this._lastProjections.length > this._lastProjectionsWindowSize && this._lastProjections.shift();
2806
- let w = C.distanceFromNearestElement > this._hugeJumpDistance;
2807
- return w && !StraightLineProvider_default.isStraight() || w && this._detectWrongBigJump(C) || !this._areLastProjectionsInTheSameDirection() || this._disableMMCloseToATurnDistance > 0 && this._hasTurnInCircle(C.coords, this._disableMMCloseToATurnDistance) ? (AbsolutePositionProvider_default.notify(e), !0) : (AbsolutePositionProvider_default.notify(C.coords), this.tryOrientationMatching(C), !0);
2821
+ let t = this.getProjection(e, !0, !0);
2822
+ if (this._useStrict && t) return Y.notify(t.coords), !0;
2823
+ if (Z.isTurning()) return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [], Y.notify(e), !0;
2824
+ if (t) {
2825
+ this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections.push(t), this._lastProjections.length > this._lastProjectionsWindowSize && this._lastProjections.shift();
2826
+ let n = t.distanceFromNearestElement > this._hugeJumpDistance;
2827
+ return n && !Q.isStraight() || n && this._detectWrongBigJump(t) || !this._areLastProjectionsInTheSameDirection() || this._disableMMCloseToATurnDistance > 0 && this._hasTurnInCircle(t.coords, this._disableMMCloseToATurnDistance) ? (Y.notify(e), !0) : (Y.notify(t.coords), this.tryOrientationMatching(t), !0);
2808
2828
  }
2809
- if (StraightLineProvider_default.isStraight()) {
2810
- let C = e.clone();
2811
- C.bearing = AbsoluteAttitudeFromBrowserProvider_default.lastEvent?.heading || null;
2812
- let w = this.getProjection(C, !0, !0);
2813
- if (w) return this._projectionsWithAbsAndWithoutRelAttitudeInARow.push(w), this._projectionsWithAbsAndWithoutRelAttitudeInARow.length < 3 || (this._lastProjections.push(w), this._lastProjections.length > this._lastProjectionsWindowSize && this._lastProjections.shift(), !this._areLastProjectionsInTheSameDirection()) ? (AbsolutePositionProvider_default.notify(e), !0) : (AbsolutePositionProvider_default.notify(w.coords), this.tryOrientationMatching(w), !0);
2829
+ if (Q.isStraight()) {
2830
+ let t = e.clone();
2831
+ t.bearing = lt.lastEvent?.heading || null;
2832
+ let n = this.getProjection(t, !0, !0);
2833
+ if (n) return this._projectionsWithAbsAndWithoutRelAttitudeInARow.push(n), this._projectionsWithAbsAndWithoutRelAttitudeInARow.length < 3 || (this._lastProjections.push(n), this._lastProjections.length > this._lastProjectionsWindowSize && this._lastProjections.shift(), !this._areLastProjectionsInTheSameDirection()) ? (Y.notify(e), !0) : (Y.notify(n.coords), this.tryOrientationMatching(n), !0);
2814
2834
  }
2815
- return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [], AbsolutePositionProvider_default.notify(e), !0;
2835
+ return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [], Y.notify(e), !0;
2816
2836
  }
2817
2837
  _detectWrongBigJump(e) {
2818
- if (this._itineraryInfoManager && AbsolutePositionProvider_default.lastEvent) {
2819
- let C = this._itineraryInfoManager.getInfo(AbsolutePositionProvider_default.lastEvent), w = this._itineraryInfoManager.getInfo(e.coords);
2820
- if (C && w && C.traveledDistance > w.traveledDistance && C.traveledDistance - w.traveledDistance > e.origin.accuracy && e.distanceFromNearestElement > e.origin.accuracy && e.origin.distanceTo(AbsolutePositionProvider_default.lastEvent) < e.origin.accuracy + AbsolutePositionProvider_default.lastEvent.accuracy) return !0;
2838
+ if (this._itineraryInfoManager && Y.lastEvent) {
2839
+ let t = this._itineraryInfoManager.getInfo(Y.lastEvent), n = this._itineraryInfoManager.getInfo(e.coords);
2840
+ if (t && n && t.traveledDistance > n.traveledDistance && t.traveledDistance - n.traveledDistance > e.origin.accuracy && e.distanceFromNearestElement > e.origin.accuracy && e.origin.distanceTo(Y.lastEvent) < e.origin.accuracy + Y.lastEvent.accuracy) return !0;
2821
2841
  }
2822
2842
  return !1;
2823
2843
  }
2824
2844
  _areLastProjectionsInTheSameDirection() {
2825
2845
  if (this._lastProjections.length === 0) return !1;
2826
2846
  let e = this._lastProjections[0];
2827
- return !this._lastProjections.some((C) => !(C.nearestElement instanceof Edge) || !(e.nearestElement instanceof Edge) || diffAngleLines(C.nearestElement.bearing, e.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold);
2847
+ return !this._lastProjections.some((t) => !(t.nearestElement instanceof y) || !(e.nearestElement instanceof y) || g(t.nearestElement.bearing, e.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold);
2828
2848
  }
2829
2849
  _nodeHasTurn(e) {
2830
2850
  if (!this._graph) return;
2831
- let w = this._graph.edges.filter((C) => C.vertex1 === e || C.vertex2 === e);
2832
- for (let e = 0; e < w.length; e++) for (let T = e + 1; T < w.length; T++) if (diffAngleLines(w[e].bearing, w[T].bearing) > C.DEFAULT_MM_MAX_ANGLE) return !0;
2851
+ let n = this._graph.edges.filter((t) => t.vertex1 === e || t.vertex2 === e);
2852
+ for (let e = 0; e < n.length; e++) for (let r = e + 1; r < n.length; r++) if (g(n[e].bearing, n[r].bearing) > t.DEFAULT_MM_MAX_ANGLE) return !0;
2833
2853
  return !1;
2834
2854
  }
2835
- _hasTurnInCircle(e, C) {
2836
- let w = this._graph;
2837
- return w ? w.vertices.filter((w) => w.coords.distanceTo(e) <= C && Level.intersect(w.coords.level, e.level)).some((e) => this._nodeHasTurn(e)) : !1;
2838
- }
2839
- tryOrientationMatching(C) {
2840
- if (!this._useOrientationMatching || this.state !== "started" || this._countStepsFromLastMatching < this._minStepsBetweenOrientationMatching || StraightLineProvider_default.numStepsDetectedFromLastTurn < this._minStepsForOrientationMatching) return;
2841
- let { nearestElement: w, origin: T } = C;
2842
- if (!(w instanceof Edge)) return;
2843
- let E, D = diffAngle(w.bearing, T.bearing), O = diffAngle(w.bearing + Math.PI, T.bearing);
2844
- E = Math.abs(D) < Math.abs(O) ? w.bearing : (w.bearing + Math.PI) % (2 * Math.PI);
2845
- let k = new AbsoluteHeading(E, T.time, 0);
2846
- AbsoluteAttitudeProvider_default._forceHeadingForRelative(k), this._countStepsFromLastMatching = 0;
2847
- }
2848
- getProjection(e, C, w) {
2849
- let T = {
2850
- ...C && !this._useStrict && { maxDistance: this._mapMatchingMaxDistance },
2851
- ...w && !this._useStrict && { maxBearingAngle: this._mapMatchingMaxAngleBearing }
2855
+ _hasTurnInCircle(e, t) {
2856
+ let n = this._graph;
2857
+ return n ? n.vertices.filter((n) => n.coords.distanceTo(e) <= t && i.intersect(n.coords.level, e.level)).some((e) => this._nodeHasTurn(e)) : !1;
2858
+ }
2859
+ tryOrientationMatching(t) {
2860
+ if (!this._useOrientationMatching || this.state !== "started" || this._countStepsFromLastMatching < this._minStepsBetweenOrientationMatching || Q.numStepsDetectedFromLastTurn < this._minStepsForOrientationMatching) return;
2861
+ let { nearestElement: n, origin: r } = t;
2862
+ if (!(n instanceof y)) return;
2863
+ let i, a = h(n.bearing, r.bearing), o = h(n.bearing + Math.PI, r.bearing);
2864
+ i = Math.abs(a) < Math.abs(o) ? n.bearing : (n.bearing + Math.PI) % (2 * Math.PI);
2865
+ let s = new e(i, r.time, 0);
2866
+ X._forceHeadingForRelative(s), this._countStepsFromLastMatching = 0;
2867
+ }
2868
+ getProjection(e, t, n) {
2869
+ let r = {
2870
+ ...t && !this._useStrict && { maxDistance: this._mapMatchingMaxDistance },
2871
+ ...n && !this._useStrict && { maxBearingAngle: this._mapMatchingMaxAngleBearing }
2852
2872
  };
2853
- return this._graph?.getProjection(e, T);
2873
+ return this._graph?.getProjection(e, r);
2854
2874
  }
2855
2875
  get maxDistance() {
2856
2876
  return this._mapMatchingMaxDistance;
@@ -2924,7 +2944,7 @@ var field = function(e, C, w) {
2924
2944
  set useStrict(e) {
2925
2945
  this._useStrict = e;
2926
2946
  }
2927
- }(), PositionSmoother_default = class e {
2947
+ }(), ut = class e {
2928
2948
  static DEFAULT_FREQUENCY = 60;
2929
2949
  static DEFAULT_FLYBY_TIME = 1;
2930
2950
  positionsQueue = [];
@@ -2932,22 +2952,22 @@ var field = function(e, C, w) {
2932
2952
  timeoutNotify;
2933
2953
  callback;
2934
2954
  frequency;
2935
- constructor(C, w = e.DEFAULT_FREQUENCY) {
2936
- this.callback = C, this.frequency = w;
2937
- }
2938
- feed(C, w = e.DEFAULT_FLYBY_TIME) {
2939
- if (!(C instanceof UserPosition)) throw TypeError("newPosition is not instance of UserPosition");
2940
- if (C.time === null) throw Error("newPosition does not have time property");
2941
- let T;
2942
- if (this.positionsQueue.length === 0 ? T = this.previousPosition : (T = this.positionsQueue[0], this.positionsQueue = []), T) {
2943
- let e = C.time, D = T.distanceTo(C), O = T.bearingTo(C), k = 1, A = this.frequency * w + 1, j = Level.clone(C.level);
2944
- for (; k < A + 1;) {
2945
- let w = T.destinationPoint(D * k / A, O);
2946
- w.time = e + (k - 1) / this.frequency, w.level = j, w.bearing = C.bearing, w.accuracy = Math.max(w.accuracy + (C.accuracy - w.accuracy) * k / A, 0), this.positionsQueue.push(w), k++;
2955
+ constructor(t, n = e.DEFAULT_FREQUENCY) {
2956
+ this.callback = t, this.frequency = n;
2957
+ }
2958
+ feed(t, n = e.DEFAULT_FLYBY_TIME) {
2959
+ if (!(t instanceof o)) throw TypeError("newPosition is not instance of UserPosition");
2960
+ if (t.time === null) throw Error("newPosition does not have time property");
2961
+ let r;
2962
+ if (this.positionsQueue.length === 0 ? r = this.previousPosition : (r = this.positionsQueue[0], this.positionsQueue = []), r) {
2963
+ let e = t.time, a = r.distanceTo(t), o = r.bearingTo(t), s = 1, c = this.frequency * n + 1, l = i.clone(t.level);
2964
+ for (; s < c + 1;) {
2965
+ let n = r.destinationPoint(a * s / c, o);
2966
+ n.time = e + (s - 1) / this.frequency, n.level = l, n.bearing = t.bearing, n.accuracy = Math.max(n.accuracy + (t.accuracy - n.accuracy) * s / c, 0), this.positionsQueue.push(n), s++;
2947
2967
  }
2948
2968
  this.timeoutNotify && clearTimeout(this.timeoutNotify);
2949
- } else this.positionsQueue.push(C.clone());
2950
- this.previousPosition = C, this._notifyNext();
2969
+ } else this.positionsQueue.push(t.clone());
2970
+ this.previousPosition = t, this._notifyNext();
2951
2971
  }
2952
2972
  _notifyNext = () => {
2953
2973
  this.positionsQueue.length && (this.callback?.(this.positionsQueue.shift()), this.positionsQueue.length === 0 ? delete this.timeoutNotify : this.timeoutNotify = setTimeout(this._notifyNext, 1e3 / this.frequency));
@@ -2955,78 +2975,78 @@ var field = function(e, C, w) {
2955
2975
  clear() {
2956
2976
  clearTimeout(this.timeoutNotify), delete this.timeoutNotify, this.positionsQueue = [];
2957
2977
  }
2958
- }, AttitudeSmoother_default = class e {
2959
- static ROTATION_SPEED_JUMP_THRESHOLD = deg2rad(180);
2960
- static ROTATION_SPEED_CONVERGENCE = deg2rad(10);
2961
- static HIGH_JUMP_THRESHOLD = deg2rad(20);
2962
- static ROTATION_SPEED_HIGH_JUMP_CONVERGENCE = deg2rad(100);
2963
- static PITCH_UNCERTAINITY_HEADING_THRESHOLD = deg2rad(5);
2978
+ }, dt = class e {
2979
+ static ROTATION_SPEED_JUMP_THRESHOLD = m(180);
2980
+ static ROTATION_SPEED_CONVERGENCE = m(10);
2981
+ static HIGH_JUMP_THRESHOLD = m(20);
2982
+ static ROTATION_SPEED_HIGH_JUMP_CONVERGENCE = m(100);
2983
+ static PITCH_UNCERTAINITY_HEADING_THRESHOLD = m(5);
2964
2984
  _previousAttitude;
2965
2985
  _smoothing = null;
2966
2986
  callback;
2967
2987
  constructor(e) {
2968
2988
  this.callback = e;
2969
2989
  }
2970
- feed(w) {
2971
- if (w.time === null) throw Error("newAttitude does not have time property");
2972
- let { _previousAttitude: T } = this;
2973
- if (this._previousAttitude = w, !T) {
2974
- this.callback(w);
2990
+ feed(n) {
2991
+ if (n.time === null) throw Error("newAttitude does not have time property");
2992
+ let { _previousAttitude: r } = this;
2993
+ if (this._previousAttitude = n, !r) {
2994
+ this.callback(n);
2975
2995
  return;
2976
2996
  }
2977
- if (e.isJump(T, w)) {
2978
- let E = this._smoothing === null ? T : this._smoothing.interpAttitude(T), D = E.heading, O = w.heading, k = diffAngle(O, D), A = Math.abs(k) < e.HIGH_JUMP_THRESHOLD ? e.ROTATION_SPEED_CONVERGENCE : e.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE, j = E.time, N = Math.abs(k) / A, F = k < 0 ? -1 : 1;
2997
+ if (e.isJump(r, n)) {
2998
+ let i = this._smoothing === null ? r : this._smoothing.interpAttitude(r), a = i.heading, o = n.heading, s = h(o, a), c = Math.abs(s) < e.HIGH_JUMP_THRESHOLD ? e.ROTATION_SPEED_CONVERGENCE : e.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE, l = i.time, d = Math.abs(s) / c, f = s < 0 ? -1 : 1;
2979
2999
  this._smoothing = {
2980
- toTime: j + N,
3000
+ toTime: l + d,
2981
3001
  interpAttitude: (e) => {
2982
- let w = D + A * (e.time - j) * F, T = Quaternion.fromAxisAngle([
3002
+ let n = c * (e.time - l), r = a + n * f, i = u.fromAxisAngle([
2983
3003
  0,
2984
3004
  0,
2985
3005
  1
2986
- ], O - w);
2987
- return new Attitude(Quaternion.multiply(T, e.quaternion), e.time, e.accuracy);
3006
+ ], o - r);
3007
+ return new t(u.multiply(i, e.quaternion), e.time, e.accuracy);
2988
3008
  }
2989
3009
  };
2990
3010
  }
2991
- if (this._smoothing !== null) if (w.time >= this._smoothing.toTime) this._smoothing = null;
3011
+ if (this._smoothing !== null) if (n.time >= this._smoothing.toTime) this._smoothing = null;
2992
3012
  else {
2993
- let e = this._smoothing.interpAttitude(w);
3013
+ let e = this._smoothing.interpAttitude(n);
2994
3014
  this.callback(e);
2995
3015
  return;
2996
3016
  }
2997
- this.callback(w);
3017
+ this.callback(n);
2998
3018
  }
2999
- static isJump(C, w) {
3000
- let T = C.heading, E = w.heading, D = diffAngle(E, T), O = w.time - C.time, [k, A, j, M] = w.quaternion;
3001
- return Math.abs(Math.asin(2 * (k * A + j * M)) - Math.PI / 4) < e.PITCH_UNCERTAINITY_HEADING_THRESHOLD ? !1 : Math.abs(D) > e.ROTATION_SPEED_JUMP_THRESHOLD * O;
3019
+ static isJump(t, n) {
3020
+ let r = t.heading, i = n.heading, a = h(i, r), o = n.time - t.time, [s, c, l, u] = n.quaternion;
3021
+ return Math.abs(Math.asin(2 * (s * c + l * u)) - Math.PI / 4) < e.PITCH_UNCERTAINITY_HEADING_THRESHOLD ? !1 : Math.abs(a) > e.ROTATION_SPEED_JUMP_THRESHOLD * o;
3002
3022
  }
3003
- }, MagnetometerCalibrationProvider_default = new class extends Provider_default {
3023
+ }, ft = new class extends j {
3004
3024
  getName = () => "MagnetometerCalibrationProvider";
3005
- availability = () => AbsoluteAttitudeProvider_default.getAvailability();
3025
+ availability = () => X.getAvailability();
3006
3026
  constructor() {
3007
- super(), AbsoluteAttitudeProvider_default._setCallbackMagCalibration((e) => this.state === "started" && this.notify(e));
3027
+ super(), X._setCallbackMagCalibration((e) => this.state === "started" && this.notify(e));
3008
3028
  }
3009
3029
  start() {}
3010
3030
  stop() {}
3011
- }(), IpResolveServerError_default = class e extends Error {
3031
+ }(), pt = class e extends Error {
3012
3032
  static DEFAULT_MESSAGE = "IP Resolver failed";
3013
- constructor(C) {
3014
- super(C || e.DEFAULT_MESSAGE);
3033
+ constructor(t) {
3034
+ super(t || e.DEFAULT_MESSAGE);
3015
3035
  }
3016
- }, IpProvider_default = new class extends Provider_default {
3036
+ }, mt = new class extends j {
3017
3037
  getName = () => "Ip";
3018
3038
  availability = () => Promise.resolve();
3019
3039
  async start() {
3020
3040
  let e = await fetch("https://ipinfo.io/geo?token=24a7ca2f3b489d");
3021
3041
  if (!e) {
3022
- this.notifyError(new IpResolveServerError_default());
3042
+ this.notifyError(new pt());
3023
3043
  return;
3024
3044
  }
3025
- let C = TimeUtils.preciseTime() / 1e3, w = (await e.json()).loc.split(","), T = new UserPosition(parseFloat(w[0]), parseFloat(w[1]), null, null, C, 1e5);
3026
- this.notify(T);
3045
+ let t = C.preciseTime() / 1e3, n = (await e.json()).loc.split(","), r = new o(parseFloat(n[0]), parseFloat(n[1]), null, null, t, 1e5);
3046
+ this.notify(r);
3027
3047
  }
3028
3048
  stop() {}
3029
- }(), VpsBackgroundScanner = class e {
3049
+ }(), ht = class e {
3030
3050
  static MAX_CONSECUTIVE_FAILURES = 10;
3031
3051
  intervalMs;
3032
3052
  enabled;
@@ -3039,8 +3059,8 @@ var field = function(e, C, w) {
3039
3059
  statusCallbacks = /* @__PURE__ */ new Set();
3040
3060
  onResult;
3041
3061
  onError;
3042
- constructor(e, C, w) {
3043
- this.onResult = C, this.onError = w, this.intervalMs = e.intervalMs ?? 3e4, this.enabled = e.enabled ?? !1, this._status = this.enabled ? "idle" : "disabled";
3062
+ constructor(e, t, n) {
3063
+ this.onResult = t, this.onError = n, this.intervalMs = e.intervalMs ?? 3e4, this.enabled = e.enabled ?? !1, this._status = this.enabled ? "idle" : "disabled";
3044
3064
  }
3045
3065
  get status() {
3046
3066
  return this._status;
@@ -3062,10 +3082,10 @@ var field = function(e, C, w) {
3062
3082
  }, this.intervalMs), this.setStatus("scheduled"));
3063
3083
  }
3064
3084
  async cancelRunningScan() {
3065
- this.isBackgroundScanRunning && (this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null, VpsProvider_default.stop()), this.scanFailureListenerId !== null && (VpsProvider_default.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled"));
3085
+ this.isBackgroundScanRunning && (this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null, J.stop()), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled"));
3066
3086
  }
3067
3087
  clear() {
3068
- this.clearTimeoutOnly(), this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (VpsProvider_default.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
3088
+ this.clearTimeoutOnly(), this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
3069
3089
  }
3070
3090
  runNow() {
3071
3091
  this.enabled && (this.clearTimeoutOnly(), this.startBackgroundScan());
@@ -3075,60 +3095,61 @@ var field = function(e, C, w) {
3075
3095
  }
3076
3096
  async startBackgroundScan() {
3077
3097
  if (!this.enabled || this.isBackgroundScanRunning || this.listenerId !== null) return;
3078
- let C = await VpsProvider_default.getAvailability();
3079
- if (C instanceof Error) {
3080
- this.onError(C), this.setStatus("idle");
3098
+ let t = await J.getAvailability();
3099
+ if (t instanceof Error) {
3100
+ this.onError(t), this.setStatus("idle");
3081
3101
  return;
3082
3102
  }
3083
- this.isBackgroundScanRunning = !0, this.setStatus("scanning"), this.scanFailureListenerId = VpsProvider_default.addScanFailureListener((C) => {
3084
- !this.isBackgroundScanRunning || this.scanFailureListenerId === null || C.listenerId !== this.scanFailureListenerId || (this.consecutiveFailures += 1, this.consecutiveFailures >= e.MAX_CONSECUTIVE_FAILURES && (this.consecutiveFailures = 0, VpsProvider_default.resetCurrentAttempt(), this.cleanupListener(), this.schedule()));
3085
- }), this.listenerId = VpsProvider_default.addEventListener((e) => {
3103
+ this.isBackgroundScanRunning = !0, this.setStatus("scanning"), this.scanFailureListenerId = J.addScanFailureListener((t) => {
3104
+ !this.isBackgroundScanRunning || this.scanFailureListenerId === null || t.listenerId !== this.scanFailureListenerId || (this.consecutiveFailures += 1, this.consecutiveFailures >= e.MAX_CONSECUTIVE_FAILURES && (this.consecutiveFailures = 0, J.resetCurrentAttempt(), this.cleanupListener(), this.schedule()));
3105
+ }), this.listenerId = J.addEventListener((e) => {
3086
3106
  this.consecutiveFailures = 0, this.cleanupListener(), this.onResult(e), this.schedule();
3087
3107
  }, (e) => {
3088
3108
  this.cleanupListener(), this.onError(e), this.schedule();
3089
3109
  });
3090
3110
  }
3091
3111
  cleanupListener() {
3092
- this.listenerId !== null && (VpsProvider_default.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (VpsProvider_default.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), VpsProvider_default.stop(), this.isBackgroundScanRunning = !1, this.enabled ? this.setStatus("idle") : this.setStatus("disabled");
3112
+ this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), J.stop(), this.isBackgroundScanRunning = !1, this.enabled ? this.setStatus("idle") : this.setStatus("disabled");
3093
3113
  }
3094
3114
  setStatus(e) {
3095
- this._status !== e && (this._status = e, this.statusCallbacks.forEach((C) => {
3115
+ this._status !== e && (this._status = e, this.statusCallbacks.forEach((t) => {
3096
3116
  try {
3097
- C(e);
3117
+ t(e);
3098
3118
  } catch (e) {
3099
3119
  console.error("[VpsBackgroundScanner] Error in status listener", e);
3100
3120
  }
3101
3121
  }));
3102
3122
  }
3103
- }, BarcodeProvider_default = new class extends Provider_default {
3123
+ }, gt = new class extends j {
3104
3124
  providerId;
3105
3125
  getName = () => "Barcode";
3106
- availability = () => ArCoreProvider_default.getAvailability();
3126
+ availability = () => z.getAvailability();
3107
3127
  start() {
3108
- ArCoreProvider_default.enableBarcodeScanner(), this.providerId = ArCoreProvider_default.addEventListener((e) => e.barcode && this.notify(e.barcode), this.notifyError);
3128
+ z.enableBarcodeScanner(), this.providerId = z.addEventListener((e) => e.barcode && this.notify(e.barcode), this.notifyError);
3109
3129
  }
3110
3130
  stop() {
3111
- ArCoreProvider_default.disableBarcodeScanner(), ArCoreProvider_default.removeEventListener(this.providerId);
3131
+ z.disableBarcodeScanner(), z.removeEventListener(this.providerId);
3112
3132
  }
3113
- }(), CameraNativeProvider_default = new class extends Provider_default {
3133
+ }(), _t = new class extends j {
3114
3134
  providerId;
3115
3135
  getName = () => "CameraNative";
3116
3136
  availability = () => Promise.resolve();
3117
3137
  start() {
3118
- ArCoreProvider_default.state !== "stopped" && this.notify("started"), this.providerId = ArCoreProvider_default.addMonitoringListener(() => this.notify("started"), () => this.notify("stopped"));
3138
+ z.state !== "stopped" && this.notify("started"), this.providerId = z.addMonitoringListener(() => this.notify("started"), () => this.notify("stopped"));
3119
3139
  }
3120
3140
  stop() {
3121
- ArCoreProvider_default.removeMonitoringListener(this.providerId);
3141
+ z.removeMonitoringListener(this.providerId);
3122
3142
  }
3123
- }(), CameraProjectionMatrixProvider_default = new class extends Provider_default {
3143
+ }(), vt = new class extends j {
3124
3144
  providerId;
3125
3145
  getName = () => "CameraProjectionMatrix";
3126
- availability = () => ArCoreProvider_default.getAvailability();
3146
+ availability = () => z.getAvailability();
3127
3147
  start() {
3128
- this.providerId = ArCoreProvider_default.addEventListener((e) => e.cameraProjection && this.notify(e.cameraProjection), this.notifyError);
3148
+ this.providerId = z.addEventListener((e) => e.cameraProjection && this.notify(e.cameraProjection), this.notifyError);
3129
3149
  }
3130
3150
  stop() {
3131
- ArCoreProvider_default.removeEventListener(this.providerId);
3151
+ z.removeEventListener(this.providerId);
3132
3152
  }
3133
3153
  }();
3134
- export { AbsoluteAttitude, AbsoluteAttitudeFromBrowserProvider_default as AbsoluteAttitudeFromBrowserProvider, AbsoluteAttitudeProvider_default as AbsoluteAttitudeProvider, AbsolutePosition, AbsolutePositionProvider_default as AbsolutePositionProvider, AccelerometerProvider_default as AccelerometerProvider, ArCoreProvider_default as ArCoreProvider, AttitudeSmoother_default as AttitudeSmoother, BarcodeProvider_default as BarcodeProvider, CameraNativeProvider_default as CameraNativeProvider, CameraProjectionMatrixProvider_default as CameraProjectionMatrixProvider, Constants_default as Constants, GeoRelativePositionFromArCoreProvider_default as GeoRelativePositionFromArCoreProvider, GeoRelativePositionProvider_default as GeoRelativePositionProvider, GnssWifiProvider_default as GnssWifiProvider, GyroscopeProvider_default as GyroscopeProvider, HighRotationsProvider_default as HighRotationsProvider, ImageRelocalization_default as ImageRelocalization, ImuProvider_default as ImuProvider, InclinationFromAccProvider_default as InclinationFromAccProvider, InclinationFromRelativeAttitudeProvider_default as InclinationFromRelativeAttitudeProvider, InclinationProvider_default as InclinationProvider, IpProvider_default as IpProvider, MagnetometerCalibrationProvider_default as MagnetometerCalibrationProvider, MapMatchingHandler_default as MapMatchingHandler, PdrProvider_default as PdrProvider, PoleStarProvider_default as PoleStarProvider, PositionSmoother_default as PositionSmoother, ProvidersLoggerOld_default as ProvidersLoggerOld, ProvidersOptions_default as ProvidersOptions, RelativeAttitude, RelativeAttitudeFromBrowserProvider_default as RelativeAttitudeFromBrowserProvider, RelativeAttitudeFromEkfProvider_default as RelativeAttitudeFromEkfProvider, RelativeAttitudeFromInertialProvider_default as RelativeAttitudeFromInertialProvider, RelativeAttitudeProvider_default as RelativeAttitudeProvider, RelativeRotationCalc, StepDetectionMinMaxPeaks2_default as StepDetectionMinMaxPeaks2, StepDetectionMinMaxPeaks3_default as StepDetectionMinMaxPeaks3, StepProvider_default as StepProvider, StraightLineProvider_default as StraightLineProvider, TurnProvider_default as TurnProvider, VpsBackgroundScanner, VpsMetadata_default as VpsMetadata, VpsProvider_default as VpsProvider, VpsRequest_default as VpsRequest, VpsResponse_default as VpsResponse };
3154
+ //#endregion
3155
+ export { ae as AbsoluteAttitude, lt as AbsoluteAttitudeFromBrowserProvider, X as AbsoluteAttitudeProvider, re as AbsolutePosition, Y as AbsolutePositionProvider, V as AccelerometerProvider, z as ArCoreProvider, dt as AttitudeSmoother, gt as BarcodeProvider, _t as CameraNativeProvider, vt as CameraProjectionMatrixProvider, Fe as Constants, ze as GeoRelativePositionFromArCoreProvider, Qe as GeoRelativePositionProvider, Ie as GnssWifiProvider, H as GyroscopeProvider, U as HighRotationsProvider, at as ImageRelocalization, B as ImuProvider, et as InclinationFromAccProvider, tt as InclinationFromRelativeAttitudeProvider, K as InclinationProvider, mt as IpProvider, ft as MagnetometerCalibrationProvider, $ as MapMatchingHandler, Ze as PdrProvider, ct as PoleStarProvider, ut as PositionSmoother, ue as ProvidersLoggerOld, D as ProvidersOptions, ie as RelativeAttitude, Ke as RelativeAttitudeFromBrowserProvider, Ge as RelativeAttitudeFromEkfProvider, W as RelativeAttitudeFromInertialProvider, q as RelativeAttitudeProvider, ot as RelativeRotationCalc, Ye as StepDetectionMinMaxPeaks2, Xe as StepDetectionMinMaxPeaks3, G as StepProvider, Q as StraightLineProvider, Z as TurnProvider, ht as VpsBackgroundScanner, nt as VpsMetadata, J as VpsProvider, rt as VpsRequest, it as VpsResponse };