mobility-toolbox-js 2.0.0-beta.52 → 2.0.0-beta.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +26 -3
  2. package/api/RealtimeAPI.d.ts +79 -84
  3. package/api/RealtimeAPI.d.ts.map +1 -1
  4. package/api/RealtimeAPI.js +102 -266
  5. package/common/api/WebSocketAPI.d.ts +13 -15
  6. package/common/api/WebSocketAPI.d.ts.map +1 -1
  7. package/common/controls/ControlCommon.d.ts +1 -1
  8. package/common/controls/ControlCommon.d.ts.map +1 -1
  9. package/common/layers/LayerCommon.d.ts +1 -0
  10. package/common/layers/LayerCommon.d.ts.map +1 -1
  11. package/common/layers/LayerCommon.js +3 -0
  12. package/common/mixins/RealtimeLayerMixin.d.ts +5 -5
  13. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
  14. package/common/mixins/RealtimeLayerMixin.js +6 -6
  15. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
  16. package/common/mixins/UserInteractionsLayerMixin.js +7 -10
  17. package/common/styles/realtimeDefaultStyle.d.ts +2 -2
  18. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
  19. package/common/styles/realtimeDelayStyle.d.ts +2 -2
  20. package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
  21. package/common/styles/realtimeSimpleStyle.d.ts +2 -1
  22. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
  23. package/common/typedefs.js +3 -3
  24. package/common/utils/{createTrackerFilters.d.ts → createRealtimeFilters.d.ts} +3 -3
  25. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  26. package/common/utils/{createTrackerFilters.js → createRealtimeFilters.js} +2 -2
  27. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  28. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  29. package/common/utils/debounceDeparturesMessages.js +24 -0
  30. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  31. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  32. package/common/utils/debounceWebsocketMessages.js +29 -0
  33. package/common/utils/getMapboxRender.d.ts +3 -3
  34. package/common/utils/getMapboxRender.d.ts.map +1 -1
  35. package/common/utils/getMapboxRender.js +2 -1
  36. package/common/utils/getMaplibreRender.d.ts +3 -1
  37. package/common/utils/getMaplibreRender.d.ts.map +1 -1
  38. package/common/utils/getMaplibreRender.js +4 -4
  39. package/common/utils/getRealtimeModeSuffix.d.ts +4 -2
  40. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -1
  41. package/common/utils/getUrlWithParams.d.ts +2 -2
  42. package/common/utils/getUrlWithParams.d.ts.map +1 -1
  43. package/common/utils/getVehiclePosition.d.ts +7 -5
  44. package/common/utils/getVehiclePosition.d.ts.map +1 -1
  45. package/common/utils/index.d.ts +5 -2
  46. package/common/utils/index.js +6 -3
  47. package/common/utils/realtimeConfig.d.ts +49 -0
  48. package/common/utils/realtimeConfig.d.ts.map +1 -0
  49. package/common/utils/{trackerConfig.js → realtimeConfig.js} +17 -17
  50. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  51. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  52. package/common/utils/sortAndFilterDepartures.js +58 -0
  53. package/common/utils/sortByDelay.d.ts +1 -1
  54. package/common/utils/sortByDelay.d.ts.map +1 -1
  55. package/common/utils/timeUtils.d.ts +23 -4
  56. package/common/utils/timeUtils.d.ts.map +1 -1
  57. package/common/utils/timeUtils.js +1 -1
  58. package/mapbox/layers/RealtimeLayer.d.ts +4 -4
  59. package/mbt.js +349 -410
  60. package/mbt.js.map +3 -3
  61. package/mbt.min.js +62 -62
  62. package/mbt.min.js.map +3 -3
  63. package/ol/controls/RoutingControl.d.ts +95 -91
  64. package/ol/controls/RoutingControl.d.ts.map +1 -1
  65. package/ol/controls/RoutingControl.js +100 -90
  66. package/ol/layers/Layer.d.ts +3 -2
  67. package/ol/layers/Layer.d.ts.map +1 -1
  68. package/ol/layers/Layer.js +2 -0
  69. package/ol/layers/MapGlLayer.d.ts.map +1 -1
  70. package/ol/layers/MapGlLayer.js +3 -5
  71. package/ol/layers/MapboxLayer.d.ts +1 -1
  72. package/ol/layers/MapboxLayer.d.ts.map +1 -1
  73. package/ol/layers/MapboxLayer.js +1 -0
  74. package/ol/layers/MapboxStyleLayer.js +4 -2
  75. package/ol/layers/MaplibreLayer.d.ts +2 -1
  76. package/ol/layers/MaplibreLayer.d.ts.map +1 -1
  77. package/ol/layers/RealtimeLayer.d.ts +8 -6
  78. package/ol/layers/RealtimeLayer.d.ts.map +1 -1
  79. package/ol/layers/RealtimeLayer.js +3 -3
  80. package/ol/layers/RoutingLayer.d.ts +15 -5
  81. package/ol/layers/RoutingLayer.d.ts.map +1 -1
  82. package/ol/layers/RoutingLayer.js +3 -2
  83. package/ol/styles/fullTrajectoryStyle.d.ts +2 -2
  84. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
  85. package/package.json +1 -1
  86. package/types/common.d.ts +6 -1
  87. package/types/realtime.d.ts +0 -2
  88. package/common/utils/cleanStopTime.d.ts +0 -8
  89. package/common/utils/cleanStopTime.d.ts.map +0 -1
  90. package/common/utils/cleanStopTime.js +0 -25
  91. package/common/utils/createTrackerFilters.d.ts.map +0 -1
  92. package/common/utils/trackerConfig.d.ts +0 -24
  93. package/common/utils/trackerConfig.d.ts.map +0 -1
package/mbt.js CHANGED
@@ -33293,7 +33293,9 @@ uniform ${i3} ${o3} u_${a3};
33293
33293
  StopsAPI: () => StopsAPI_default,
33294
33294
  VectorLayer: () => VectorLayer_default2,
33295
33295
  WMSLayer: () => WMSLayer_default,
33296
- createTrackerFilters: () => createTrackerFilters_default,
33296
+ createRealtimeFilters: () => createRealtimeFilters_default,
33297
+ debounceDeparturesMessages: () => debounceDeparturesMessages_default,
33298
+ debounceWebsocketMessages: () => debounceWebsocketMessages_default,
33297
33299
  fullTrajectoryDelayStyle: () => fullTrajectoryDelayStyle_default,
33298
33300
  fullTrajectoryStyle: () => fullTrajectoryStyle_default,
33299
33301
  getCircleCanvas: () => getCircleCanvas,
@@ -33309,13 +33311,14 @@ uniform ${i3} ${o3} u_${a3};
33309
33311
  getUTCTimeString: () => getUTCTimeString,
33310
33312
  getUrlWithParams: () => getUrlWithParams_default,
33311
33313
  pad: () => pad,
33314
+ realtimeConfig: () => realtimeConfig_exports,
33312
33315
  realtimeDefaultStyle: () => realtimeDefaultStyle_default,
33313
33316
  realtimeDelayStyle: () => realtimeDelayStyle_default,
33314
33317
  realtimeSimpleStyle: () => realtimeSimpleStyle_default,
33315
33318
  removeDuplicate: () => removeDuplicate_default,
33316
33319
  renderTrajectories: () => renderTrajectories_default,
33317
- sortByDelay: () => sortByDelay_default,
33318
- trackerConfig: () => trackerConfig_exports
33320
+ sortAndFilterDepartures: () => sortAndFilterDepartures_default,
33321
+ sortByDelay: () => sortByDelay_default
33319
33322
  });
33320
33323
 
33321
33324
  // node_modules/ol/events/Event.js
@@ -33862,7 +33865,7 @@ uniform ${i3} ${o3} u_${a3};
33862
33865
  }(Observable_default);
33863
33866
  var Object_default = BaseObject;
33864
33867
 
33865
- // src/common/utils/getUrlWithParams.js
33868
+ // src/common/utils/getUrlWithParams.ts
33866
33869
  var getUrlWithParams = (url, params) => {
33867
33870
  const newUrl = new URL(url);
33868
33871
  const searchParams = params || {};
@@ -34136,55 +34139,33 @@ uniform ${i3} ${o3} u_${a3};
34136
34139
  };
34137
34140
  var WebSocketAPI_default = WebSocketAPI;
34138
34141
 
34139
- // src/common/utils/cleanStopTime.ts
34140
- var cleanStopTime = (content) => {
34141
- content.stations.forEach((station) => {
34142
- station.arrivalTimeWithDelay = station.arrivalTime;
34143
- if (station.departureTime) {
34144
- station.departureTimeWithDelay = station.departureTime;
34145
- }
34146
- if (station.arrivalDelay) {
34147
- station.arrivalTime -= station.arrivalDelay;
34148
- if (station.departureTime) {
34149
- station.departureTime -= station.arrivalDelay;
34150
- }
34142
+ // src/common/utils/debounceWebsocketMessages.ts
34143
+ var debounceWebsocketMessages = (onUpdate, getObjectId, timeout = 100) => {
34144
+ const updateTimeout = {};
34145
+ const objectsById = {};
34146
+ const objects = [];
34147
+ return (data) => {
34148
+ const { source, content } = data;
34149
+ if (updateTimeout[source]) {
34150
+ window.clearTimeout(updateTimeout[source]);
34151
+ }
34152
+ if (getObjectId) {
34153
+ objectsById[getObjectId(content)] = content;
34154
+ } else {
34155
+ objects.push(content);
34151
34156
  }
34152
- });
34153
- return content;
34157
+ updateTimeout[source] = window.setTimeout(() => {
34158
+ const objectToReturn = getObjectId ? Object.values(objectsById) : objects;
34159
+ onUpdate(objectToReturn);
34160
+ }, timeout);
34161
+ };
34154
34162
  };
34155
- var cleanStopTime_default = cleanStopTime;
34163
+ var debounceWebsocketMessages_default = debounceWebsocketMessages;
34156
34164
 
34157
- // src/common/utils/getRealtimeModeSuffix.js
34165
+ // src/common/utils/getRealtimeModeSuffix.ts
34158
34166
  var getModeSuffix = (mode, modes) => mode === modes.SCHEMATIC ? "_schematic" : "";
34159
34167
  var getRealtimeModeSuffix_default = getModeSuffix;
34160
34168
 
34161
- // src/common/utils/compareDepartures.ts
34162
- var compareDepartures = (a, b, sortByMinArrivalTime = false) => {
34163
- const topStates = ["HIDDEN", "LEAVING", "BOARDING"];
34164
- const aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
34165
- const bTop = b.has_fzo && topStates.indexOf(b.state) > -1;
34166
- if (aTop || bTop) {
34167
- if (aTop !== bTop) {
34168
- return aTop ? -1 : 1;
34169
- }
34170
- if (a.state !== b.state) {
34171
- return topStates.indexOf(a.state) - topStates.indexOf(b.state);
34172
- }
34173
- }
34174
- let aDuration = null;
34175
- let bDuration = null;
34176
- const now = Date.now();
34177
- if (sortByMinArrivalTime) {
34178
- aDuration = new Date(a.min_arrival_time || a.time).getTime() - now;
34179
- bDuration = new Date(b.min_arrival_time || b.time).getTime() - now;
34180
- } else {
34181
- aDuration = new Date(a.time).getTime() - now;
34182
- bDuration = new Date(b.time).getTime() - now;
34183
- }
34184
- return aDuration - bDuration;
34185
- };
34186
- var compareDepartures_default = compareDepartures;
34187
-
34188
34169
  // src/api/RealtimeAPI.ts
34189
34170
  var RealtimeModes = {
34190
34171
  RAW: "raw",
@@ -34194,10 +34175,6 @@ uniform ${i3} ${o3} u_${a3};
34194
34175
  var RealtimeAPI = class {
34195
34176
  constructor(options = {}) {
34196
34177
  this.defineProperties(options);
34197
- this.subscribedStationUic = void 0;
34198
- this.departureUpdateTimeout = void 0;
34199
- this.maxDepartureAge = 30;
34200
- this.extraGeoms = {};
34201
34178
  this.prefix = options.prefix || "";
34202
34179
  this.onOpen = this.onOpen.bind(this);
34203
34180
  }
@@ -34209,8 +34186,11 @@ uniform ${i3} ${o3} u_${a3};
34209
34186
  const { apiKey } = opt;
34210
34187
  let { url, projection, bbox, buffer: buffer2 = [100, 100] } = opt;
34211
34188
  const wsApi = new WebSocketAPI_default();
34189
+ if (!url) {
34190
+ url = "wss://api.geops.io/tracker-ws/v1/";
34191
+ }
34212
34192
  if (apiKey) {
34213
- url = `${url || "wss://api.geops.io/tracker-ws/v1/"}?key=${apiKey}`;
34193
+ url = `${url}?key=${apiKey}`;
34214
34194
  }
34215
34195
  Object.defineProperties(this, {
34216
34196
  url: {
@@ -34306,92 +34286,32 @@ uniform ${i3} ${o3} u_${a3};
34306
34286
  this.reconnectTimeout = window.setTimeout(() => this.open(), this.reconnectTimeoutMs);
34307
34287
  }
34308
34288
  }
34309
- subscribe(channel, onSuccess, onError, quiet = false) {
34289
+ subscribe(channel, onSuccess, onError = () => {
34290
+ }, quiet = false) {
34310
34291
  if (!channel || !onSuccess) {
34311
34292
  return;
34312
34293
  }
34313
34294
  this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
34314
34295
  }
34315
- unsubscribe(channel, suffix = "", cb) {
34316
- this.wsApi.unsubscribe(`${channel}${getRealtimeModeSuffix_default(RealtimeModes.SCHEMATIC, RealtimeModes)}${suffix}`, cb);
34317
- this.wsApi.unsubscribe(`${channel}${getRealtimeModeSuffix_default(RealtimeModes.TOPOGRAPHIC, RealtimeModes)}${suffix || ""}`, cb);
34318
- }
34319
- filterDepartures(depObject, sortByMinArrivalTime = false) {
34320
- const departures = Object.keys(depObject).map((k) => depObject[k]);
34321
- departures.sort((a, b) => compareDepartures_default(a, b, sortByMinArrivalTime));
34322
- const futureDate = new Date();
34323
- futureDate.setMinutes(futureDate.getMinutes() + this.maxDepartureAge);
34324
- const future = futureDate.getTime();
34325
- const pastDate = new Date();
34326
- pastDate.setMinutes(pastDate.getMinutes() - this.maxDepartureAge);
34327
- const past = pastDate.getTime();
34328
- const departureArray = [];
34329
- const platformsBoarding = [];
34330
- let previousDeparture = null;
34331
- for (let i = departures.length - 1; i >= 0; i -= 1) {
34332
- const departure = {
34333
- ...departures[i]
34334
- };
34335
- const time = new Date(departure.time).getTime();
34336
- if (time > past && time < future) {
34337
- if (departure.state === "BOARDING") {
34338
- if (platformsBoarding.indexOf(departure.platform) === -1) {
34339
- platformsBoarding.push(departure.platform);
34340
- } else {
34341
- departure.state = "HIDDEN";
34342
- }
34343
- }
34344
- if (previousDeparture && departure.to[0] === previousDeparture.to[0] && Math.abs(time - previousDeparture.time) < 1e3 && departure.line.name === previousDeparture.line.name) {
34345
- departure.state = "HIDDEN";
34346
- }
34347
- if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
34348
- departure.cancelled = true;
34349
- }
34350
- previousDeparture = departure;
34351
- previousDeparture.time = time;
34352
- departureArray.unshift(departure);
34353
- }
34354
- }
34355
- return departureArray;
34296
+ unsubscribe(channel, suffix = "", onMessage) {
34297
+ const suffixSchenatic = getRealtimeModeSuffix_default(RealtimeModes.SCHEMATIC, RealtimeModes);
34298
+ const suffixTopographic = getRealtimeModeSuffix_default(RealtimeModes.TOPOGRAPHIC, RealtimeModes);
34299
+ this.wsApi.unsubscribe(`${channel}${suffixSchenatic}${suffix || ""}`, onMessage);
34300
+ this.wsApi.unsubscribe(`${channel}${suffixTopographic}${suffix || ""}`, onMessage);
34356
34301
  }
34357
- subscribeDepartures(stationId, sortByMinArrivalTime, onMessage) {
34358
- window.clearTimeout(this.departureUpdateTimeout);
34359
- this.unsubscribeDepartures();
34360
- this.subscribedStationUic = stationId;
34361
- const channel = stationId ? `timetable_${stationId}` : null;
34362
- const departureObject = {};
34363
- if (!channel) {
34364
- return;
34365
- }
34366
- const onSuccess = (data) => {
34367
- if (data.source === channel) {
34368
- const content = data.content || {};
34369
- const tDiff = new Date(content.timestamp).getTime() - Date.now();
34370
- departureObject[content.call_id] = { ...content, timediff: tDiff };
34371
- window.clearTimeout(this.departureUpdateTimeout);
34372
- this.departureUpdateTimeout = window.setTimeout(() => {
34373
- const departures = this.filterDepartures(departureObject, sortByMinArrivalTime || false);
34374
- onMessage(departures);
34375
- }, 100);
34376
- }
34377
- };
34378
- this.subscribe(channel, onSuccess, () => {
34379
- onMessage([]);
34380
- });
34302
+ subscribeDepartures(stationId, onMessage, onError = () => {
34303
+ }, quiet = false) {
34304
+ this.subscribe(`timetable_${stationId}`, onMessage, onError, quiet);
34381
34305
  }
34382
- unsubscribeDepartures(cb) {
34383
- if (this.subscribedStationUic) {
34384
- this.unsubscribe(`timetable_${this.subscribedStationUic}`, "", cb);
34385
- this.subscribedStationUic = void 0;
34386
- }
34306
+ unsubscribeDepartures(id, onMessage) {
34307
+ this.unsubscribe(`timetable_${id}`, "", onMessage);
34387
34308
  }
34388
- subscribeDisruptions(onMessage) {
34389
- this.subscribe(`${this.prefix}newsticker`, (data) => {
34390
- onMessage(data.content);
34391
- });
34309
+ subscribeDisruptions(onMessage, onError = () => {
34310
+ }, quiet = false) {
34311
+ this.subscribe(`${this.prefix}newsticker`, onMessage, onError, quiet);
34392
34312
  }
34393
- unsubscribeDisruptions(cb) {
34394
- this.unsubscribe(`${this.prefix}newsticker`, "", cb);
34313
+ unsubscribeDisruptions(onMessage) {
34314
+ this.unsubscribe(`${this.prefix}newsticker`, "", onMessage);
34395
34315
  }
34396
34316
  getStation(uic, mode) {
34397
34317
  const params = {
@@ -34399,77 +34319,45 @@ uniform ${i3} ${o3} u_${a3};
34399
34319
  args: uic
34400
34320
  };
34401
34321
  return new Promise((resolve, reject) => {
34402
- this.wsApi.get(params, (data) => {
34403
- if (data.content) {
34404
- resolve(data.content);
34405
- } else {
34406
- reject();
34407
- }
34408
- });
34322
+ this.wsApi.get(params, resolve, reject);
34409
34323
  });
34410
34324
  }
34411
- getStations(mode) {
34412
- const stations = [];
34413
- const params = {
34414
- channel: `station${getRealtimeModeSuffix_default(mode, RealtimeModes)}`
34415
- };
34416
- window.clearTimeout(this.stationUpdateTimeout);
34417
- return new Promise((resolve, reject) => {
34418
- this.wsApi.get(params, (data) => {
34419
- if (data.content) {
34420
- stations.push(data.content);
34421
- window.clearTimeout(this.stationUpdateTimeout);
34422
- this.stationUpdateTimeout = window.setTimeout(() => {
34423
- resolve(stations);
34424
- }, 50);
34425
- } else {
34426
- reject(data.content);
34427
- }
34428
- });
34325
+ getStations(mode, timeout = 100) {
34326
+ return new Promise((resolve) => {
34327
+ this.wsApi.get({
34328
+ channel: `station${getRealtimeModeSuffix_default(mode, RealtimeModes)}`
34329
+ }, debounceWebsocketMessages_default(resolve, void 0, timeout));
34429
34330
  });
34430
34331
  }
34431
- subscribeStations(mode, onMessage) {
34432
- this.unsubscribeStations();
34433
- this.subscribe(`station${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, (data) => {
34434
- if (data.content) {
34435
- onMessage(data.content);
34436
- }
34437
- });
34332
+ subscribeStations(mode, onMessage, onError = () => {
34333
+ }, quiet = false) {
34334
+ this.subscribe(`station${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, onError, quiet);
34438
34335
  }
34439
- unsubscribeStations(cb) {
34440
- window.clearTimeout(this.stationUpdateTimeout);
34441
- this.unsubscribe("station", "", cb);
34442
- }
34443
- subscribeExtraGeoms(onMessage) {
34444
- this.subscribe("extra_geoms", (data) => {
34445
- const extraGeom = data.content;
34446
- if (extraGeom) {
34447
- const { ref } = extraGeom.properties;
34448
- if (extraGeom.type === "Feature") {
34449
- this.extraGeoms[ref] = extraGeom;
34450
- } else {
34451
- delete this.extraGeoms[ref];
34452
- }
34453
- onMessage(Object.keys(this.extraGeoms).map((key) => this.extraGeoms[key]));
34454
- }
34455
- });
34336
+ unsubscribeStations(onMessage) {
34337
+ this.unsubscribe("station", "", onMessage);
34338
+ }
34339
+ subscribeExtraGeoms(onMessage, onError = () => {
34340
+ }, quiet = false) {
34341
+ this.subscribe("extra_geoms", onMessage, onError, quiet);
34456
34342
  }
34457
- unsubscribeExtraGeoms(cb) {
34458
- this.unsubscribe("extra_geoms", "", cb);
34343
+ unsubscribeExtraGeoms(onMessage) {
34344
+ this.unsubscribe("extra_geoms", "", onMessage);
34459
34345
  }
34460
- subscribeTrajectory(mode, onMessage, quiet = false) {
34346
+ subscribeTrajectory(mode, onMessage, onError = () => {
34347
+ }, quiet = false) {
34461
34348
  this.unsubscribeTrajectory(onMessage);
34462
- this.subscribe(`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, void 0, quiet);
34349
+ this.subscribe(`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, onError, quiet);
34463
34350
  }
34464
- unsubscribeTrajectory(cb) {
34465
- this.unsubscribe(`trajectory`, "", cb);
34351
+ unsubscribeTrajectory(onMessage) {
34352
+ this.unsubscribe(`trajectory`, "", onMessage);
34466
34353
  }
34467
- subscribeDeletedVehicles(mode, onMessage, quiet = false) {
34354
+ subscribeDeletedVehicles(mode, onMessage, onError = () => {
34355
+ }, quiet = false) {
34468
34356
  this.unsubscribeDeletedVehicles(onMessage);
34469
- this.subscribe(`deleted_vehicles${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, void 0, quiet);
34357
+ this.subscribe(`deleted_vehicles${getRealtimeModeSuffix_default(mode, RealtimeModes)}`, onMessage, onError, quiet);
34470
34358
  }
34471
- unsubscribeDeletedVehicles(cb) {
34472
- this.unsubscribe("deleted_vehicles", "", cb);
34359
+ unsubscribeDeletedVehicles(onMessage) {
34360
+ this.unsubscribe("deleted_vehicles", "", onMessage);
34473
34361
  }
34474
34362
  getFullTrajectory(id, mode, generalizationLevel) {
34475
34363
  const channel = [`full_trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`];
@@ -34482,72 +34370,37 @@ uniform ${i3} ${o3} u_${a3};
34482
34370
  const params = {
34483
34371
  channel: channel.join("_")
34484
34372
  };
34485
- return new Promise((resolve) => {
34486
- this.wsApi.get(params, (data) => {
34487
- if (data.content) {
34488
- resolve(data.content);
34489
- }
34490
- });
34373
+ return new Promise((resolve, reject) => {
34374
+ this.wsApi.get(params, resolve, reject);
34491
34375
  });
34492
34376
  }
34493
- getFullTrajectories(ids, mode, generalizationLevel) {
34494
- const promises = ids.map((id) => this.getFullTrajectory(id, mode, generalizationLevel));
34495
- return Promise.all(promises);
34377
+ subscribeFullTrajectory(id, mode, onMessage, onError = () => {
34378
+ }, quiet = false) {
34379
+ this.subscribe(`full_trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}_${id}`, onMessage, onError, quiet);
34496
34380
  }
34497
- subscribeFullTrajectory(id, mode) {
34498
- this.unsubscribeFullTrajectory(id);
34499
- this.subscribe(`full_trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}_${id}`, (data) => {
34500
- console.log("subscribe full_trajectory", data);
34501
- }, (err) => {
34502
- console.log("subscribe full_trajectory error", err);
34503
- });
34504
- }
34505
- unsubscribeFullTrajectory(id, cb) {
34506
- this.unsubscribe("full_trajectory", `_${id}`, cb);
34381
+ unsubscribeFullTrajectory(id, onMessage) {
34382
+ this.unsubscribe("full_trajectory", `_${id}`, onMessage);
34507
34383
  }
34508
34384
  getStopSequence(id) {
34509
- const params = {
34510
- channel: `stopsequence_${id}`
34511
- };
34512
34385
  return new Promise((resolve, reject) => {
34513
- this.wsApi.get(params, (data) => {
34514
- const content = data.content;
34515
- if (content && content.length) {
34516
- const stopSequences = content.map((stopSequence) => cleanStopTime_default(stopSequence));
34517
- resolve(stopSequences);
34518
- }
34519
- resolve([]);
34520
- }, (err) => {
34521
- reject(err);
34522
- });
34386
+ this.wsApi.get({
34387
+ channel: `stopsequence_${id}`
34388
+ }, resolve, reject);
34523
34389
  });
34524
34390
  }
34525
- getStopSequences(ids) {
34526
- const promises = ids.map((id) => this.getStopSequence(id));
34527
- return Promise.all(promises);
34528
- }
34529
- subscribeStopSequence(id, onMessage) {
34530
- window.clearTimeout(this.fullTrajectoryUpdateTimeout);
34531
- this.unsubscribeStopSequence(id);
34532
- this.subscribe(`stopsequence_${id}`, (data) => {
34533
- const content = data.content;
34534
- if (content && content.length) {
34535
- const stopSequences = content.map((stopSequence) => cleanStopTime_default(stopSequence));
34536
- onMessage(stopSequences);
34537
- }
34538
- }, (err) => {
34539
- console.log("subscribe stopsequence error", err);
34540
- });
34391
+ subscribeStopSequence(id, onMessage, onError = () => {
34392
+ }, quiet = false) {
34393
+ this.subscribe(`stopsequence_${id}`, onMessage, onError, quiet);
34541
34394
  }
34542
- unsubscribeStopSequence(id, cb) {
34543
- this.unsubscribe(`stopsequence`, `_${id}`, cb);
34395
+ unsubscribeStopSequence(id, onMessage) {
34396
+ this.unsubscribe(`stopsequence`, `_${id}`, onMessage);
34544
34397
  }
34545
- subscribeHealthCheck(onMessage) {
34546
- this.unsubscribeHealthCheck();
34547
- this.subscribe("healthcheck", onMessage);
34398
+ subscribeHealthCheck(onMessage, onError = () => {
34399
+ }, quiet = false) {
34400
+ this.subscribe("healthcheck", onMessage, onError, quiet);
34548
34401
  }
34549
- unsubscribeHealthCheck() {
34550
- this.unsubscribe("healthcheck");
34402
+ unsubscribeHealthCheck(onMessage) {
34403
+ this.unsubscribe("healthcheck", "", onMessage);
34551
34404
  }
34552
34405
  };
34553
34406
  var RealtimeAPI_default = RealtimeAPI;
@@ -34586,8 +34439,8 @@ uniform ${i3} ${o3} u_${a3};
34586
34439
  };
34587
34440
  var getMapboxMapCopyrights_default = getMapboxMapCopyrights;
34588
34441
 
34589
- // src/common/utils/createTrackerFilters.ts
34590
- var createFilters = (line, route, operator, regexLine) => {
34442
+ // src/common/utils/createRealtimeFilters.ts
34443
+ var createRealtimeFilters = (line, route, operator, regexLine) => {
34591
34444
  const filterList = [];
34592
34445
  if (!line && !route && !operator && !regexLine) {
34593
34446
  return null;
@@ -34646,7 +34499,7 @@ uniform ${i3} ${o3} u_${a3};
34646
34499
  return true;
34647
34500
  };
34648
34501
  };
34649
- var createTrackerFilters_default = createFilters;
34502
+ var createRealtimeFilters_default = createRealtimeFilters;
34650
34503
 
34651
34504
  // src/common/utils/getLayersAsFlatArray.ts
34652
34505
  var getLayersAsFlatArray = (layersOrLayer) => {
@@ -34664,7 +34517,7 @@ uniform ${i3} ${o3} u_${a3};
34664
34517
  };
34665
34518
  var getLayersAsFlatArray_default = getLayersAsFlatArray;
34666
34519
 
34667
- // src/common/utils/timeUtils.js
34520
+ // src/common/utils/timeUtils.ts
34668
34521
  var getUTCDateString = (now = new Date()) => {
34669
34522
  let month = (now.getUTCMonth() + 1).toString();
34670
34523
  month = month.length === 1 ? `0${month}` : month;
@@ -34677,7 +34530,7 @@ uniform ${i3} ${o3} u_${a3};
34677
34530
  date.getUTCMinutes(),
34678
34531
  `${date.getUTCSeconds()}.${date.getUTCMilliseconds()}`
34679
34532
  ].join(":");
34680
- var pad = (integer) => integer < 10 ? `0${integer}` : integer;
34533
+ var pad = (integer) => integer < 10 ? `0${integer}` : `${integer}`;
34681
34534
  var getHoursAndMinutes = (timeInMs) => {
34682
34535
  if (!timeInMs || timeInMs <= 0) {
34683
34536
  return "";
@@ -34686,7 +34539,7 @@ uniform ${i3} ${o3} u_${a3};
34686
34539
  return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
34687
34540
  };
34688
34541
 
34689
- // src/common/utils/sortByDelay.js
34542
+ // src/common/utils/sortByDelay.ts
34690
34543
  var sortByDelay = (traj1, traj2) => {
34691
34544
  const props1 = traj1.properties;
34692
34545
  const props2 = traj2.properties;
@@ -34866,7 +34719,7 @@ uniform ${i3} ${o3} u_${a3};
34866
34719
  CIRCLE: "Circle"
34867
34720
  };
34868
34721
 
34869
- // src/common/utils/getVehiclePosition.js
34722
+ // src/common/utils/getVehiclePosition.ts
34870
34723
  var getVehiclePosition = (now, trajectory, noInterpolate) => {
34871
34724
  const {
34872
34725
  time_intervals: timeIntervals,
@@ -35871,22 +35724,22 @@ uniform ${i3} ${o3} u_${a3};
35871
35724
  }
35872
35725
  addCommon();
35873
35726
 
35874
- // src/common/utils/getMaplibreRender.js
35727
+ // src/common/utils/getMaplibreRender.ts
35875
35728
  function getMaplibreRender(maplibreLayer) {
35729
+ const emptyDiv = document.createElement("div");
35876
35730
  return (frameState) => {
35877
35731
  const { map, mbMap, olLayer } = maplibreLayer;
35878
35732
  if (!map || !mbMap) {
35879
- return null;
35733
+ return emptyDiv;
35880
35734
  }
35881
35735
  const canvas2 = mbMap.getCanvas();
35882
35736
  const { viewState } = frameState;
35883
- const opacity = olLayer.getOpacity();
35884
- canvas2.style.opacity = opacity;
35737
+ const opacity = olLayer?.getOpacity() || 1;
35738
+ canvas2.style.opacity = `${opacity}`;
35885
35739
  mbMap.jumpTo({
35886
35740
  center: toLonLat(viewState.center),
35887
35741
  zoom: viewState.zoom - 1,
35888
- bearing: toDegrees(-viewState.rotation),
35889
- animate: false
35742
+ bearing: toDegrees(-viewState.rotation)
35890
35743
  });
35891
35744
  if (!canvas2.isConnected) {
35892
35745
  map.render();
@@ -35900,10 +35753,11 @@ uniform ${i3} ${o3} u_${a3};
35900
35753
 
35901
35754
  // src/common/utils/getMapboxRender.ts
35902
35755
  function getMapboxRender(mapoxLayer) {
35756
+ const emptyDiv = document.createElement("div");
35903
35757
  return (frameState) => {
35904
35758
  const { map, mbMap, renderState, olLayer } = mapoxLayer;
35905
35759
  if (!map || !mbMap) {
35906
- return document.createElement("div");
35760
+ return emptyDiv;
35907
35761
  }
35908
35762
  let changed = false;
35909
35763
  const canvas2 = mbMap.getCanvas();
@@ -35956,9 +35810,95 @@ uniform ${i3} ${o3} u_${a3};
35956
35810
  };
35957
35811
  }
35958
35812
 
35959
- // src/common/utils/trackerConfig.js
35960
- var trackerConfig_exports = {};
35961
- __export(trackerConfig_exports, {
35813
+ // src/common/utils/compareDepartures.ts
35814
+ var compareDepartures = (a, b, sortByMinArrivalTime = false) => {
35815
+ const topStates = ["HIDDEN", "LEAVING", "BOARDING"];
35816
+ const aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
35817
+ const bTop = b.has_fzo && topStates.indexOf(b.state) > -1;
35818
+ if (aTop || bTop) {
35819
+ if (aTop !== bTop) {
35820
+ return aTop ? -1 : 1;
35821
+ }
35822
+ if (a.state !== b.state) {
35823
+ return topStates.indexOf(a.state) - topStates.indexOf(b.state);
35824
+ }
35825
+ }
35826
+ let aDuration = null;
35827
+ let bDuration = null;
35828
+ const now = Date.now();
35829
+ if (sortByMinArrivalTime) {
35830
+ aDuration = new Date(a.min_arrival_time || a.time).getTime() - now;
35831
+ bDuration = new Date(b.min_arrival_time || b.time).getTime() - now;
35832
+ } else {
35833
+ aDuration = new Date(a.time).getTime() - now;
35834
+ bDuration = new Date(b.time).getTime() - now;
35835
+ }
35836
+ return aDuration - bDuration;
35837
+ };
35838
+ var compareDepartures_default = compareDepartures;
35839
+
35840
+ // src/common/utils/sortAndFilterDepartures.ts
35841
+ var sortAndfilterDepartures = (depObject, sortByMinArrivalTime = false, maxDepartureAge = 30) => {
35842
+ const departures = Object.keys(depObject).map((k) => depObject[k]);
35843
+ departures.sort((a, b) => compareDepartures_default(a, b, sortByMinArrivalTime));
35844
+ const futureDate = new Date();
35845
+ futureDate.setMinutes(futureDate.getMinutes() + maxDepartureAge);
35846
+ const future = futureDate.getTime();
35847
+ const pastDate = new Date();
35848
+ pastDate.setMinutes(pastDate.getMinutes() - maxDepartureAge);
35849
+ const past = pastDate.getTime();
35850
+ const departureArray = [];
35851
+ const platformsBoarding = [];
35852
+ let previousDeparture = null;
35853
+ for (let i = departures.length - 1; i >= 0; i -= 1) {
35854
+ const departure = {
35855
+ ...departures[i]
35856
+ };
35857
+ const time = new Date(departure.time).getTime();
35858
+ if (time > past && time < future) {
35859
+ if (departure.state === "BOARDING") {
35860
+ if (!platformsBoarding.includes(departure.platform)) {
35861
+ platformsBoarding.push(departure.platform);
35862
+ } else {
35863
+ departure.state = "HIDDEN";
35864
+ }
35865
+ }
35866
+ if (previousDeparture && departure.to[0] === previousDeparture.to[0] && Math.abs(time - previousDeparture.time) < 1e3 && departure.line.name === previousDeparture.line.name) {
35867
+ departure.state = "HIDDEN";
35868
+ }
35869
+ if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
35870
+ departure.cancelled = true;
35871
+ }
35872
+ previousDeparture = departure;
35873
+ previousDeparture.time = time;
35874
+ departureArray.unshift(departure);
35875
+ }
35876
+ }
35877
+ return departureArray;
35878
+ };
35879
+ var sortAndFilterDepartures_default = sortAndfilterDepartures;
35880
+
35881
+ // src/common/utils/debounceDeparturesMessages.ts
35882
+ var debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = true, maxDepartureAge = 30, timeout = 100) => {
35883
+ const departureUpdateTimeout = {};
35884
+ const departureObject = {};
35885
+ return (data) => {
35886
+ const { source, content: departure } = data;
35887
+ if (departureUpdateTimeout[source]) {
35888
+ window.clearTimeout(departureUpdateTimeout[source]);
35889
+ }
35890
+ departureObject[departure.call_id] = departure;
35891
+ departureUpdateTimeout[source] = window.setTimeout(() => {
35892
+ const departures = sortAndFilterDepartures_default(departureObject, sortByMinArrivalTime || false, maxDepartureAge);
35893
+ onDeparturesUpdate(departures);
35894
+ }, timeout);
35895
+ };
35896
+ };
35897
+ var debounceDeparturesMessages_default = debounceDeparturesMessages;
35898
+
35899
+ // src/common/utils/realtimeConfig.ts
35900
+ var realtimeConfig_exports = {};
35901
+ __export(realtimeConfig_exports, {
35962
35902
  bgColors: () => bgColors,
35963
35903
  getBgColor: () => getBgColor,
35964
35904
  getDelayColor: () => getDelayColor,
@@ -35970,18 +35910,18 @@ uniform ${i3} ${o3} u_${a3};
35970
35910
  textColors: () => textColors,
35971
35911
  types: () => types
35972
35912
  });
35973
- var trackerRadiusMapping = {
35974
- 0: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35975
- 1: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35976
- 2: [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
35977
- 3: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35978
- 4: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35979
- 5: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35980
- 6: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35981
- 7: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35982
- 8: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35983
- 9: [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15]
35984
- };
35913
+ var radiusMapping = [
35914
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35915
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35916
+ [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
35917
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35918
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35919
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35920
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35921
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35922
+ [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
35923
+ [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15]
35924
+ ];
35985
35925
  var types = [
35986
35926
  /^Tram/i,
35987
35927
  /^Subway( \/ Metro \/ S-Bahn)?/i,
@@ -36027,25 +35967,25 @@ uniform ${i3} ${o3} u_${a3};
36027
35967
  var getRadius = (type, zoom) => {
36028
35968
  try {
36029
35969
  const typeIdx = getTypeIndex(type || 0);
36030
- return trackerRadiusMapping[typeIdx][zoom];
35970
+ return radiusMapping[typeIdx][zoom];
36031
35971
  } catch (e) {
36032
35972
  return 1;
36033
35973
  }
36034
35974
  };
36035
- var getBgColor = (type = 0) => {
35975
+ var getBgColor = (type) => {
36036
35976
  try {
36037
35977
  const typeIdx = getTypeIndex(type);
36038
35978
  return bgColors[typeIdx];
36039
35979
  } catch (e) {
36040
- return 1;
35980
+ return "#ffffff";
36041
35981
  }
36042
35982
  };
36043
- var getTextColor = (type = 0) => {
35983
+ var getTextColor = (type) => {
36044
35984
  try {
36045
35985
  const typeIdx = getTypeIndex(type);
36046
35986
  return textColors[typeIdx];
36047
35987
  } catch (e) {
36048
- return 1;
35988
+ return "#ffffff";
36049
35989
  }
36050
35990
  };
36051
35991
  var getTextSize = (ctx, markerSize, text, fontSize) => {
@@ -37264,8 +37204,8 @@ uniform ${i3} ${o3} u_${a3};
37264
37204
  }();
37265
37205
  var tmpTransform = create();
37266
37206
  var Geometry = function(_super) {
37267
- __extends11(Geometry2, _super);
37268
- function Geometry2() {
37207
+ __extends11(Geometry3, _super);
37208
+ function Geometry3() {
37269
37209
  var _this = _super.call(this) || this;
37270
37210
  _this.extent_ = createEmpty();
37271
37211
  _this.extentRevision_ = -1;
@@ -37281,31 +37221,31 @@ uniform ${i3} ${o3} u_${a3};
37281
37221
  });
37282
37222
  return _this;
37283
37223
  }
37284
- Geometry2.prototype.simplifyTransformed = function(squaredTolerance, opt_transform) {
37224
+ Geometry3.prototype.simplifyTransformed = function(squaredTolerance, opt_transform) {
37285
37225
  return this.simplifyTransformedInternal(this.getRevision(), squaredTolerance, opt_transform);
37286
37226
  };
37287
- Geometry2.prototype.clone = function() {
37227
+ Geometry3.prototype.clone = function() {
37288
37228
  return abstract();
37289
37229
  };
37290
- Geometry2.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {
37230
+ Geometry3.prototype.closestPointXY = function(x, y, closestPoint, minSquaredDistance) {
37291
37231
  return abstract();
37292
37232
  };
37293
- Geometry2.prototype.containsXY = function(x, y) {
37233
+ Geometry3.prototype.containsXY = function(x, y) {
37294
37234
  var coord = this.getClosestPoint([x, y]);
37295
37235
  return coord[0] === x && coord[1] === y;
37296
37236
  };
37297
- Geometry2.prototype.getClosestPoint = function(point2, opt_closestPoint) {
37237
+ Geometry3.prototype.getClosestPoint = function(point2, opt_closestPoint) {
37298
37238
  var closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
37299
37239
  this.closestPointXY(point2[0], point2[1], closestPoint, Infinity);
37300
37240
  return closestPoint;
37301
37241
  };
37302
- Geometry2.prototype.intersectsCoordinate = function(coordinate) {
37242
+ Geometry3.prototype.intersectsCoordinate = function(coordinate) {
37303
37243
  return this.containsXY(coordinate[0], coordinate[1]);
37304
37244
  };
37305
- Geometry2.prototype.computeExtent = function(extent) {
37245
+ Geometry3.prototype.computeExtent = function(extent) {
37306
37246
  return abstract();
37307
37247
  };
37308
- Geometry2.prototype.getExtent = function(opt_extent) {
37248
+ Geometry3.prototype.getExtent = function(opt_extent) {
37309
37249
  if (this.extentRevision_ != this.getRevision()) {
37310
37250
  var extent = this.computeExtent(this.extent_);
37311
37251
  if (isNaN(extent[0]) || isNaN(extent[1])) {
@@ -37315,31 +37255,31 @@ uniform ${i3} ${o3} u_${a3};
37315
37255
  }
37316
37256
  return returnOrUpdate(this.extent_, opt_extent);
37317
37257
  };
37318
- Geometry2.prototype.rotate = function(angle, anchor) {
37258
+ Geometry3.prototype.rotate = function(angle, anchor) {
37319
37259
  abstract();
37320
37260
  };
37321
- Geometry2.prototype.scale = function(sx, opt_sy, opt_anchor) {
37261
+ Geometry3.prototype.scale = function(sx, opt_sy, opt_anchor) {
37322
37262
  abstract();
37323
37263
  };
37324
- Geometry2.prototype.simplify = function(tolerance) {
37264
+ Geometry3.prototype.simplify = function(tolerance) {
37325
37265
  return this.getSimplifiedGeometry(tolerance * tolerance);
37326
37266
  };
37327
- Geometry2.prototype.getSimplifiedGeometry = function(squaredTolerance) {
37267
+ Geometry3.prototype.getSimplifiedGeometry = function(squaredTolerance) {
37328
37268
  return abstract();
37329
37269
  };
37330
- Geometry2.prototype.getType = function() {
37270
+ Geometry3.prototype.getType = function() {
37331
37271
  return abstract();
37332
37272
  };
37333
- Geometry2.prototype.applyTransform = function(transformFn) {
37273
+ Geometry3.prototype.applyTransform = function(transformFn) {
37334
37274
  abstract();
37335
37275
  };
37336
- Geometry2.prototype.intersectsExtent = function(extent) {
37276
+ Geometry3.prototype.intersectsExtent = function(extent) {
37337
37277
  return abstract();
37338
37278
  };
37339
- Geometry2.prototype.translate = function(deltaX, deltaY) {
37279
+ Geometry3.prototype.translate = function(deltaX, deltaY) {
37340
37280
  abstract();
37341
37281
  };
37342
- Geometry2.prototype.transform = function(source, destination) {
37282
+ Geometry3.prototype.transform = function(source, destination) {
37343
37283
  var sourceProj = get3(source);
37344
37284
  var transformFn = sourceProj.getUnits() == Units_default.TILE_PIXELS ? function(inCoordinates, outCoordinates, stride) {
37345
37285
  var pixelExtent = sourceProj.getExtent();
@@ -37352,7 +37292,7 @@ uniform ${i3} ${o3} u_${a3};
37352
37292
  this.applyTransform(transformFn);
37353
37293
  return this;
37354
37294
  };
37355
- return Geometry2;
37295
+ return Geometry3;
37356
37296
  }(Object_default);
37357
37297
  var Geometry_default = Geometry;
37358
37298
 
@@ -47856,10 +47796,13 @@ uniform ${i3} ${o3} u_${a3};
47856
47796
  var Layer2 = class extends Object_default {
47857
47797
  constructor(options = {}) {
47858
47798
  super();
47799
+ this.properties = {};
47800
+ this.options = {};
47859
47801
  this.defineProperties(options);
47860
47802
  if (options.properties) {
47861
47803
  this.setProperties(options.properties);
47862
47804
  }
47805
+ this.options = options;
47863
47806
  this.visible = options.visible === void 0 ? true : !!options.visible;
47864
47807
  this.group = options.group;
47865
47808
  this.copyrights = options.copyrights;
@@ -48107,10 +48050,9 @@ uniform ${i3} ${o3} u_${a3};
48107
48050
  event: evt
48108
48051
  };
48109
48052
  return this.getFeatureInfoAtCoordinate(coordinate).then((featureInfo) => {
48110
- this.dispatchEvent({
48111
- type: "user:click",
48112
- target: featureInfo
48113
- });
48053
+ const event = new Event_default("user:click");
48054
+ event.target = featureInfo;
48055
+ this.dispatchEvent(event);
48114
48056
  return featureInfo;
48115
48057
  }).catch(() => emptyFeatureInfo);
48116
48058
  }
@@ -48123,10 +48065,9 @@ uniform ${i3} ${o3} u_${a3};
48123
48065
  event: evt
48124
48066
  };
48125
48067
  return this.getFeatureInfoAtCoordinate(coordinate).then((featureInfo) => {
48126
- this.dispatchEvent({
48127
- type: "user:hover",
48128
- target: featureInfo
48129
- });
48068
+ const event = new Event_default("user:hover");
48069
+ event.target = featureInfo;
48070
+ this.dispatchEvent(event);
48130
48071
  return featureInfo;
48131
48072
  }).catch(() => emptyFeatureInfo);
48132
48073
  }
@@ -48222,7 +48163,7 @@ uniform ${i3} ${o3} u_${a3};
48222
48163
  };
48223
48164
  var Layer_default4 = Layer3;
48224
48165
 
48225
- // src/ol/layers/RoutingLayer.js
48166
+ // src/ol/layers/RoutingLayer.ts
48226
48167
  var circleStyle = new Circle_default({
48227
48168
  radius: 6,
48228
48169
  fill: new Fill_default({
@@ -48259,7 +48200,7 @@ uniform ${i3} ${o3} u_${a3};
48259
48200
  const maxResolution = feature2.get("maxResolution");
48260
48201
  const inRange = resolution <= minResolution && resolution > maxResolution;
48261
48202
  if (minResolution && maxResolution && !inRange) {
48262
- return null;
48203
+ return [];
48263
48204
  }
48264
48205
  const mot = feature2.get("mot");
48265
48206
  if (mot !== "foot") {
@@ -48268,8 +48209,9 @@ uniform ${i3} ${o3} u_${a3};
48268
48209
  return [dashedRedLine];
48269
48210
  };
48270
48211
  var RoutingLayer = class extends Layer_default4 {
48271
- constructor(options = {}) {
48212
+ constructor(options) {
48272
48213
  super(options);
48214
+ this.options = {};
48273
48215
  this.olLayer = options.olLayer || new Vector_default({
48274
48216
  source: new Vector_default2(),
48275
48217
  style: options.style || defaultStyleFunction
@@ -48281,7 +48223,7 @@ uniform ${i3} ${o3} u_${a3};
48281
48223
  };
48282
48224
  var RoutingLayer_default = RoutingLayer;
48283
48225
 
48284
- // src/ol/controls/RoutingControl.js
48226
+ // src/ol/controls/RoutingControl.ts
48285
48227
  var REGEX_VIA_POINT = /^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/;
48286
48228
  var REGEX_VIA_POINT_COORD = /^([\d.]+),([\d.]+)$/;
48287
48229
  var REGEX_VIA_POINT_STATION_ID = /^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/;
@@ -48289,13 +48231,27 @@ uniform ${i3} ${o3} u_${a3};
48289
48231
  var getFlatCoordinatesFromSegments = (segmentArray) => {
48290
48232
  const coords = [];
48291
48233
  segmentArray.forEach((seg) => {
48292
- coords.push(...seg.getGeometry().getCoordinates());
48234
+ const coordArr = seg.getGeometry()?.getCoordinates();
48235
+ if (coordArr?.length) {
48236
+ coords.push(...coordArr);
48237
+ }
48293
48238
  });
48294
48239
  return coords;
48295
48240
  };
48296
48241
  var RoutingControl = class extends ControlCommon_default {
48297
48242
  constructor(options = {}) {
48298
48243
  super(options);
48244
+ this.viaPoints = [];
48245
+ this.loading = false;
48246
+ this.graphs = [];
48247
+ this.modify = true;
48248
+ this.useRawViaPoints = false;
48249
+ this.snapToClosestStation = false;
48250
+ this.cacheStationData = {};
48251
+ this.abortControllers = {};
48252
+ this.segments = [];
48253
+ this.format = new GeoJSON_default({ featureProjection: "EPSG:3857" });
48254
+ this.initialRouteDrag = {};
48299
48255
  Object.defineProperties(this, {
48300
48256
  mot: {
48301
48257
  get: () => this.get("mot"),
@@ -48325,14 +48281,11 @@ uniform ${i3} ${o3} u_${a3};
48325
48281
  this.graphs = options.graphs || [["osm", 0, 99]];
48326
48282
  this.mot = options.mot || "bus";
48327
48283
  this.modify = options.modify !== false;
48328
- this.routingApiParams = options.routingApiParams || {};
48284
+ this.routingApiParams = options.routingApiParams;
48329
48285
  this.useRawViaPoints = options.useRawViaPoints || false;
48330
48286
  this.snapToClosestStation = options.snapToClosestStation || false;
48331
- this.cacheStationData = {};
48332
- this.abortControllers = [];
48333
48287
  this.apiKey = options.apiKey;
48334
48288
  this.stopsApiKey = options.stopsApiKey || this.apiKey;
48335
- this.segments = [];
48336
48289
  this.stopsApiUrl = options.stopsApiUrl || "https://api.geops.io/stops/v1/";
48337
48290
  this.api = new RoutingAPI_default({
48338
48291
  ...options
@@ -48342,18 +48295,13 @@ uniform ${i3} ${o3} u_${a3};
48342
48295
  style: options.style
48343
48296
  });
48344
48297
  this.onRouteError = options.onRouteError || ((error) => {
48345
- this.dispatchEvent({
48346
- type: "change:route",
48347
- target: this
48348
- });
48298
+ this.dispatchEvent(new Event_default("change:route"));
48349
48299
  this.reset();
48350
48300
  console.error(error);
48351
48301
  });
48352
- this.viaPoints = [];
48353
48302
  this.onMapClick = this.onMapClick.bind(this);
48354
48303
  this.onModifyEnd = this.onModifyEnd.bind(this);
48355
48304
  this.onModifyStart = this.onModifyStart.bind(this);
48356
- this.apiChangeListener = () => this.drawRoute();
48357
48305
  this.createModifyInteraction();
48358
48306
  }
48359
48307
  static getGraphsResolutions(graphs, map) {
@@ -48366,44 +48314,33 @@ uniform ${i3} ${o3} u_${a3};
48366
48314
  addViaPoint(coordinatesOrString, index = -1, overwrite = 0) {
48367
48315
  this.viaPoints.splice(index === -1 ? this.viaPoints.length : index, overwrite, coordinatesOrString);
48368
48316
  this.drawRoute();
48369
- this.dispatchEvent({
48370
- type: "change:route",
48371
- target: this
48372
- });
48317
+ this.dispatchEvent(new Event_default("change:route"));
48373
48318
  }
48374
- removeViaPoint(index = this.viaPoints.length - 1) {
48319
+ removeViaPoint(index = (this.viaPoints || []).length - 1) {
48375
48320
  if (this.viaPoints.length && this.viaPoints[index]) {
48376
48321
  this.viaPoints.splice(index, 1);
48377
48322
  }
48378
48323
  this.drawRoute();
48379
- this.dispatchEvent({
48380
- type: "change:route",
48381
- target: this
48382
- });
48324
+ this.dispatchEvent(new Event_default("change:route"));
48383
48325
  }
48384
48326
  setViaPoints(coordinateArray) {
48385
48327
  this.viaPoints = [...coordinateArray];
48386
48328
  this.drawRoute();
48387
- this.dispatchEvent({
48388
- type: "change:route",
48389
- target: this
48390
- });
48329
+ this.dispatchEvent(new Event_default("change:route"));
48391
48330
  }
48392
48331
  reset() {
48393
48332
  this.abortRequests();
48394
48333
  this.viaPoints = [];
48395
- this.routingLayer.olLayer.getSource().clear();
48396
- this.dispatchEvent({
48397
- type: "change:route",
48398
- target: this
48399
- });
48334
+ this.routingLayer?.olLayer?.getSource()?.clear();
48335
+ this.dispatchEvent(new Event_default("change:route"));
48400
48336
  }
48401
48337
  abortRequests() {
48402
- this.graphs.forEach(([graph]) => {
48403
- if (this.abortControllers[graph]) {
48404
- this.abortControllers[graph].abort();
48338
+ this.graphs.forEach((graph) => {
48339
+ const graphName = graph[0];
48340
+ if (this.abortControllers[graphName]) {
48341
+ this.abortControllers[graphName].abort();
48405
48342
  }
48406
- this.abortControllers[graph] = new AbortController();
48343
+ this.abortControllers[graphName] = new AbortController();
48407
48344
  });
48408
48345
  this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]?.abort();
48409
48346
  this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY] = new AbortController();
@@ -48411,7 +48348,7 @@ uniform ${i3} ${o3} u_${a3};
48411
48348
  }
48412
48349
  drawRoute() {
48413
48350
  this.abortRequests();
48414
- this.routingLayer.olLayer.getSource().clear();
48351
+ this.routingLayer?.olLayer?.getSource()?.clear();
48415
48352
  if (!this.viaPoints.length) {
48416
48353
  return null;
48417
48354
  }
@@ -48420,26 +48357,29 @@ uniform ${i3} ${o3} u_${a3};
48420
48357
  }
48421
48358
  const formattedViaPoints = this.viaPoints.map((viaPoint) => {
48422
48359
  if (Array.isArray(viaPoint)) {
48423
- const projection = this.map.getView().getProjection();
48360
+ const projection = this.map?.getView().getProjection();
48424
48361
  const [lon, lat] = toLonLat(viaPoint, projection);
48425
48362
  return this.snapToClosestStation ? [`@${lat}`, lon] : [lat, lon];
48426
48363
  }
48427
48364
  return this.useRawViaPoints ? viaPoint : `!${viaPoint}`;
48428
48365
  });
48429
48366
  this.loading = true;
48430
- this.routingLayer.olLayer.getSource().clear();
48367
+ this.routingLayer?.olLayer?.getSource()?.clear();
48431
48368
  this.viaPoints.forEach((viaPoint, idx) => this.drawViaPoint(viaPoint, idx, this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]));
48432
48369
  return Promise.all(this.graphs.map(([graph], index) => {
48433
48370
  const { signal } = this.abortControllers[graph];
48371
+ if (!this.api) {
48372
+ return Promise.resolve([]);
48373
+ }
48434
48374
  return this.api.route({
48435
48375
  graph,
48436
48376
  via: `${formattedViaPoints.join("|")}`,
48437
- mot: `${this.mot}`,
48377
+ mot: this.mot,
48438
48378
  "resolve-hops": false,
48439
48379
  elevation: false,
48440
48380
  "coord-radius": 100,
48441
48381
  "coord-punish": 1e3,
48442
- ...this.routingApiParams
48382
+ ...this.routingApiParams || {}
48443
48383
  }, { signal }).then((featureCollection) => {
48444
48384
  this.segments = this.format.readFeatures(featureCollection);
48445
48385
  if (this.mot === "foot") {
@@ -48464,19 +48404,18 @@ uniform ${i3} ${o3} u_${a3};
48464
48404
  });
48465
48405
  routeFeature.set("graph", graph);
48466
48406
  routeFeature.set("mot", this.mot);
48467
- routeFeature.set("minResolution", this.graphsResolutions[index][0]);
48468
- routeFeature.set("maxResolution", this.graphsResolutions[index][1]);
48469
- this.routingLayer.olLayer.getSource().addFeature(routeFeature);
48407
+ if (this.graphsResolutions && this.graphsResolutions[index]?.length >= 2) {
48408
+ routeFeature.set("minResolution", this.graphsResolutions[index][0]);
48409
+ routeFeature.set("maxResolution", this.graphsResolutions[index][1]);
48410
+ }
48411
+ this.routingLayer?.olLayer?.getSource()?.addFeature(routeFeature);
48470
48412
  this.loading = false;
48471
48413
  }).catch((error) => {
48472
48414
  if (error.name === "AbortError") {
48473
48415
  return;
48474
48416
  }
48475
48417
  this.segments = [];
48476
- this.dispatchEvent({
48477
- type: "error",
48478
- target: this
48479
- });
48418
+ this.dispatchEvent(new Event_default("error"));
48480
48419
  this.onRouteError(error, this);
48481
48420
  this.loading = false;
48482
48421
  });
@@ -48487,14 +48426,14 @@ uniform ${i3} ${o3} u_${a3};
48487
48426
  pointFeature.set("viaPointIdx", idx);
48488
48427
  if (Array.isArray(viaPoint)) {
48489
48428
  pointFeature.setGeometry(new Point_default(viaPoint));
48490
- this.routingLayer.olLayer.getSource().addFeature(pointFeature);
48429
+ this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
48491
48430
  return Promise.resolve(pointFeature);
48492
48431
  }
48493
48432
  if (!this.useRawViaPoints || REGEX_VIA_POINT_STATION_ID.test(viaPoint)) {
48494
48433
  let stationId;
48495
48434
  let track2;
48496
48435
  if (this.useRawViaPoints) {
48497
- [, stationId, , track2] = REGEX_VIA_POINT_STATION_ID.exec(viaPoint);
48436
+ [, stationId, , track2] = REGEX_VIA_POINT_STATION_ID.exec(viaPoint) || [];
48498
48437
  } else {
48499
48438
  [stationId, track2] = viaPoint.split("$");
48500
48439
  }
@@ -48503,33 +48442,30 @@ uniform ${i3} ${o3} u_${a3};
48503
48442
  this.cacheStationData[viaPoint] = fromLonLat(coordinates2);
48504
48443
  pointFeature.set("viaPointTrack", track2);
48505
48444
  pointFeature.setGeometry(new Point_default(fromLonLat(coordinates2)));
48506
- this.routingLayer.olLayer.getSource().addFeature(pointFeature);
48445
+ this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
48507
48446
  return pointFeature;
48508
48447
  }).catch((error) => {
48509
48448
  if (error.name === "AbortError") {
48510
48449
  return;
48511
48450
  }
48512
- this.dispatchEvent({
48513
- type: "error",
48514
- target: this
48515
- });
48451
+ this.dispatchEvent(new Event_default("error"));
48516
48452
  this.onRouteError(error, this);
48517
48453
  this.loading = false;
48518
48454
  });
48519
48455
  }
48520
48456
  if (this.useRawViaPoints && REGEX_VIA_POINT_COORD.test(viaPoint)) {
48521
- const [lat2, lon2] = REGEX_VIA_POINT_COORD.exec(viaPoint);
48522
- const coordinates2 = fromLonLat([parseFloat(lon2), parseFloat(lat2)], this.map.getView().getProjection());
48457
+ const [lat2, lon2] = REGEX_VIA_POINT_COORD.exec(viaPoint) || [];
48458
+ const coordinates2 = fromLonLat([parseFloat(lon2), parseFloat(lat2)], this.map?.getView().getProjection());
48523
48459
  pointFeature.setGeometry(new Point_default(coordinates2));
48524
- this.routingLayer.olLayer.getSource().addFeature(pointFeature);
48460
+ this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
48525
48461
  return Promise.resolve(pointFeature);
48526
48462
  }
48527
- const [, stationName, , lat, lon, , track] = REGEX_VIA_POINT.exec(viaPoint);
48463
+ const [, stationName, , lat, lon, , track] = REGEX_VIA_POINT.exec(viaPoint) || [];
48528
48464
  if (lon && lat) {
48529
- const coordinates2 = fromLonLat([parseFloat(lon), parseFloat(lat)], this.map.getView().getProjection());
48465
+ const coordinates2 = fromLonLat([parseFloat(lon), parseFloat(lat)], this.map?.getView().getProjection());
48530
48466
  pointFeature.set("viaPointTrack", track);
48531
48467
  pointFeature.setGeometry(new Point_default(coordinates2));
48532
- this.routingLayer.olLayer.getSource().addFeature(pointFeature);
48468
+ this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
48533
48469
  return Promise.resolve(pointFeature);
48534
48470
  }
48535
48471
  if (stationName) {
@@ -48538,13 +48474,10 @@ uniform ${i3} ${o3} u_${a3};
48538
48474
  this.cacheStationData[viaPoint] = fromLonLat(coordinates2);
48539
48475
  pointFeature.set("viaPointTrack", track);
48540
48476
  pointFeature.setGeometry(new Point_default(fromLonLat(coordinates2)));
48541
- this.routingLayer.olLayer.getSource().addFeature(pointFeature);
48477
+ this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
48542
48478
  return pointFeature;
48543
48479
  }).catch((error) => {
48544
- this.dispatchEvent({
48545
- type: "error",
48546
- target: this
48547
- });
48480
+ this.dispatchEvent(new Event_default("error"));
48548
48481
  this.onRouteError(error, this);
48549
48482
  this.loading = false;
48550
48483
  return null;
@@ -48552,21 +48485,21 @@ uniform ${i3} ${o3} u_${a3};
48552
48485
  }
48553
48486
  return Promise.resolve(null);
48554
48487
  }
48555
- onMapClick(e) {
48556
- const feats = e.target.getFeaturesAtPixel(e.pixel);
48488
+ onMapClick(evt) {
48489
+ const feats = evt.target.getFeaturesAtPixel(evt.pixel);
48557
48490
  const viaPoint = feats.find((feat) => feat.getGeometry()?.getType() === GeometryType_default.POINT && feat.get("viaPointIdx") !== void 0);
48558
48491
  if (viaPoint) {
48559
48492
  this.removeViaPoint(viaPoint.get("viaPointIdx"));
48560
48493
  return;
48561
48494
  }
48562
- this.addViaPoint(e.coordinate);
48495
+ this.addViaPoint(evt.coordinate);
48563
48496
  }
48564
48497
  onModifyStart(evt) {
48565
48498
  let segmentIndex = -1;
48566
48499
  const route = evt.features.getArray().find((feat) => feat.getGeometry()?.getType() === GeometryType_default.LINE_STRING);
48567
- if (route) {
48568
- const closestExtent = buffer(new Point_default(route.getGeometry().getClosestPoint(evt.mapBrowserEvent.coordinate)).getExtent(), 1e-3);
48569
- segmentIndex = this.segments.findIndex((segment) => segment.getGeometry().intersectsExtent(closestExtent));
48500
+ if (route && route.getGeometry() && evt.mapBrowserEvent.coordinate) {
48501
+ const closestExtent = buffer(new Point_default(route.getGeometry()?.getClosestPoint(evt.mapBrowserEvent.coordinate)).getExtent(), 1e-3);
48502
+ segmentIndex = this.segments.findIndex((segment) => segment.getGeometry()?.intersectsExtent(closestExtent));
48570
48503
  }
48571
48504
  const viaPoint = (evt.features.getArray().filter((feat) => feat.getGeometry()?.getType() === GeometryType_default.POINT) || [])[0];
48572
48505
  this.initialRouteDrag = {
@@ -48577,7 +48510,7 @@ uniform ${i3} ${o3} u_${a3};
48577
48510
  }
48578
48511
  onModifyEnd(evt) {
48579
48512
  const coord = evt.mapBrowserEvent.coordinate;
48580
- const { oldRoute, viaPoint, segmentIndex } = this.initialRouteDrag;
48513
+ const { oldRoute, viaPoint, segmentIndex } = this.initialRouteDrag || {};
48581
48514
  if (viaPoint) {
48582
48515
  return this.addViaPoint(coord, viaPoint.get("viaPointIdx"), 1);
48583
48516
  }
@@ -48587,7 +48520,7 @@ uniform ${i3} ${o3} u_${a3};
48587
48520
  if (segmentIndex === -1) {
48588
48521
  return Promise.reject(new Error("No segment found"));
48589
48522
  }
48590
- return this.addViaPoint(coord, segmentIndex + 1);
48523
+ return this.addViaPoint(coord, (segmentIndex || 0) + 1);
48591
48524
  }
48592
48525
  createDefaultElement() {
48593
48526
  this.element = document.createElement("button");
@@ -48602,9 +48535,9 @@ uniform ${i3} ${o3} u_${a3};
48602
48535
  }
48603
48536
  createModifyInteraction() {
48604
48537
  this.modifyInteraction = new Modify_default({
48605
- source: this.routingLayer.olLayer.getSource(),
48538
+ source: this.routingLayer?.olLayer?.getSource() || void 0,
48606
48539
  pixelTolerance: 4,
48607
- hitDetection: this.routingLayer.olLayer,
48540
+ hitDetection: this.routingLayer?.olLayer,
48608
48541
  deleteCondition: (e) => {
48609
48542
  const feats = e.target.getFeaturesAtPixel(e.pixel, {
48610
48543
  hitTolerance: 5
@@ -48626,10 +48559,12 @@ uniform ${i3} ${o3} u_${a3};
48626
48559
  return;
48627
48560
  }
48628
48561
  this.removeListeners();
48629
- this.onMapClickKey = this.map.on("singleclick", this.onMapClick);
48562
+ this.onMapClickKey = this.map?.on("singleclick", this.onMapClick);
48630
48563
  }
48631
48564
  removeListeners() {
48632
- unByKey(this.onMapClickKey);
48565
+ if (this.onMapClickKey) {
48566
+ unByKey(this.onMapClickKey);
48567
+ }
48633
48568
  }
48634
48569
  activate() {
48635
48570
  super.activate();
@@ -48638,20 +48573,23 @@ uniform ${i3} ${o3} u_${a3};
48638
48573
  featureProjection: this.map.getView().getProjection()
48639
48574
  });
48640
48575
  this.graphsResolutions = RoutingControl.getGraphsResolutions(this.graphs, this.map);
48641
- this.map.removeInteraction(this.modifyInteraction);
48642
- this.routingLayer.attachToMap(this.map);
48643
- this.map.addInteraction(this.modifyInteraction);
48644
- this.modifyInteraction.setActive(this.modify);
48576
+ if (this.modifyInteraction) {
48577
+ this.map.removeInteraction(this.modifyInteraction);
48578
+ }
48579
+ this.routingLayer?.attachToMap(this.map);
48580
+ if (this.modifyInteraction) {
48581
+ this.map.addInteraction(this.modifyInteraction);
48582
+ }
48583
+ this.modifyInteraction?.setActive(this.modify);
48645
48584
  this.addListeners();
48646
- } else {
48647
- this.format = new GeoJSON_default({ featureProjection: "EPSG:3857" });
48648
- this.graphsResolutions = this.graphs;
48649
48585
  }
48650
48586
  }
48651
48587
  deactivate() {
48652
48588
  if (this.map) {
48653
- this.routingLayer.detachFromMap(this.map);
48654
- this.map.removeInteraction(this.modifyInteraction);
48589
+ this.routingLayer?.detachFromMap();
48590
+ if (this.modifyInteraction) {
48591
+ this.map.removeInteraction(this.modifyInteraction);
48592
+ }
48655
48593
  this.removeListeners();
48656
48594
  this.reset();
48657
48595
  }
@@ -48850,10 +48788,7 @@ uniform ${i3} ${o3} u_${a3};
48850
48788
  });
48851
48789
  this.mbMap.once("load", () => {
48852
48790
  this.loaded = true;
48853
- this.dispatchEvent({
48854
- type: "load",
48855
- target: this
48856
- });
48791
+ this.dispatchEvent(new Event_default("load"));
48857
48792
  });
48858
48793
  this.mbMap.on("idle", this.updateAttribution);
48859
48794
  }
@@ -49006,8 +48941,9 @@ uniform ${i3} ${o3} u_${a3};
49006
48941
  };
49007
48942
  }
49008
48943
  if (!this.styleLayersFilter && this.styleLayers) {
49009
- const ids = this.styleLayers.map((s) => s.id);
49010
- this.styleLayersFilter = (styleLayer) => ids.includes(styleLayer.id);
48944
+ this.styleLayersFilter = (styleLayer) => {
48945
+ return !!this.styleLayers?.find((sl) => styleLayer.id === sl.id);
48946
+ };
49011
48947
  }
49012
48948
  }
49013
48949
  attachToMap(map) {
@@ -49283,7 +49219,7 @@ uniform ${i3} ${o3} u_${a3};
49283
49219
  value: style || realtimeDefaultStyle_default
49284
49220
  },
49285
49221
  styleOptions: {
49286
- value: { ...trackerConfig_exports, ...styleOptions || {} }
49222
+ value: { ...realtimeConfig_exports, ...styleOptions || {} }
49287
49223
  },
49288
49224
  speed: {
49289
49225
  get: () => currSpeed,
@@ -49370,8 +49306,8 @@ uniform ${i3} ${o3} u_${a3};
49370
49306
  this.renderTrajectories();
49371
49307
  this.startUpdateTime();
49372
49308
  this.api.open();
49373
- this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49374
- this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49309
+ this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, void 0, this.isUpdateBboxOnMoveEnd);
49310
+ this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, void 0, this.isUpdateBboxOnMoveEnd);
49375
49311
  if (this.isUpdateBboxOnMoveEnd) {
49376
49312
  this.setBbox();
49377
49313
  }
@@ -49471,8 +49407,8 @@ uniform ${i3} ${o3} u_${a3};
49471
49407
  return;
49472
49408
  }
49473
49409
  this.mode = mode;
49474
- this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49475
- this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
49410
+ this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, void 0, this.isUpdateBboxOnMoveEnd);
49411
+ this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, void 0, this.isUpdateBboxOnMoveEnd);
49476
49412
  }
49477
49413
  getRefreshTimeInMs(zoom = 0) {
49478
49414
  const roundedZoom = zoom !== void 0 ? Math.round(zoom) : -1;
@@ -49878,9 +49814,9 @@ uniform ${i3} ${o3} u_${a3};
49878
49814
  super.setBbox(newExtent, newZoom);
49879
49815
  }
49880
49816
  highlightTrajectory(id) {
49881
- this.api.getFullTrajectory(id, this.mode, this.generalizationLevel).then((fullTrajectory) => {
49882
- const vectorSource = this.vectorLayer.getSource();
49883
- vectorSource.clear();
49817
+ this.api.getFullTrajectory(id, this.mode, this.generalizationLevel).then((data) => {
49818
+ const fullTrajectory = data.content;
49819
+ this.vectorLayer.getSource().clear();
49884
49820
  if (!fullTrajectory || !fullTrajectory.features || !fullTrajectory.features.length) {
49885
49821
  return;
49886
49822
  }
@@ -49976,7 +49912,9 @@ uniform ${i3} ${o3} u_${a3};
49976
49912
  RealtimeModes: () => RealtimeModes,
49977
49913
  RoutingAPI: () => RoutingAPI_default,
49978
49914
  StopsAPI: () => StopsAPI_default,
49979
- createTrackerFilters: () => createTrackerFilters_default,
49915
+ createRealtimeFilters: () => createRealtimeFilters_default,
49916
+ debounceDeparturesMessages: () => debounceDeparturesMessages_default,
49917
+ debounceWebsocketMessages: () => debounceWebsocketMessages_default,
49980
49918
  getCircleCanvas: () => getCircleCanvas,
49981
49919
  getDelayBgCanvas: () => getDelayBgCanvas,
49982
49920
  getDelayTextCanvas: () => getDelayTextCanvas,
@@ -49992,13 +49930,14 @@ uniform ${i3} ${o3} u_${a3};
49992
49930
  getUTCTimeString: () => getUTCTimeString,
49993
49931
  getUrlWithParams: () => getUrlWithParams_default,
49994
49932
  pad: () => pad,
49933
+ realtimeConfig: () => realtimeConfig_exports,
49995
49934
  realtimeDefaultStyle: () => realtimeDefaultStyle_default,
49996
49935
  realtimeDelayStyle: () => realtimeDelayStyle_default,
49997
49936
  realtimeSimpleStyle: () => realtimeSimpleStyle_default,
49998
49937
  removeDuplicate: () => removeDuplicate_default,
49999
49938
  renderTrajectories: () => renderTrajectories_default,
50000
- sortByDelay: () => sortByDelay_default,
50001
- trackerConfig: () => trackerConfig_exports
49939
+ sortAndFilterDepartures: () => sortAndFilterDepartures_default,
49940
+ sortByDelay: () => sortByDelay_default
50002
49941
  });
50003
49942
 
50004
49943
  // src/mapbox/controls/CopyrightControl.ts