@opengeoweb/cap 12.2.0 → 12.4.1

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 (32) hide show
  1. package/index.esm.js +272 -951
  2. package/package.json +16 -16
  3. package/src/lib/CapDemo.stories.d.ts +2 -1
  4. package/src/lib/components/ComponentsLookUp/componentsLookUp.d.ts +1 -3
  5. package/src/lib/components/GanttChart/GanttModule.stories.d.ts +1 -0
  6. package/src/lib/components/MapViewCap/MapViewCapConnect.d.ts +1 -1
  7. package/src/lib/components/MapViewCap/MapViewCapConnectWrapper.d.ts +1 -1
  8. package/src/lib/components/Providers/Providers.d.ts +6 -6
  9. package/src/lib/components/WarningListCap/WarningListCap.d.ts +4 -2
  10. package/src/lib/components/WarningListCap/WarningListRowCap/WarningListRowCapConnect.d.ts +2 -1
  11. package/src/lib/components/types.d.ts +0 -3
  12. package/src/lib/store/index.d.ts +0 -4
  13. package/src/lib/store/store.d.ts +2 -11
  14. package/src/lib/store/types.d.ts +0 -27
  15. package/src/lib/utils/addFeedAddressToCustomGeoJsonFeature.d.ts +1 -1
  16. package/src/lib/utils/cap-api/api.d.ts +12 -0
  17. package/src/lib/utils/cap-api/fakeApi.d.ts +2 -0
  18. package/src/lib/utils/cap-api/hooks.d.ts +10 -0
  19. package/src/lib/utils/highlightGeoJson.d.ts +1 -1
  20. package/src/lib/utils/i18n.d.ts +1 -0
  21. package/src/lib/utils/mockAlert.d.ts +0 -17
  22. package/src/lib/utils/mockCapData.d.ts +1 -4
  23. package/src/lib/utils/mockGeoJson.d.ts +0 -2
  24. package/src/lib/store/mockStore.d.ts +0 -21
  25. package/src/lib/store/reducer.d.ts +0 -12
  26. package/src/lib/store/reducer.spec.d.ts +0 -1
  27. package/src/lib/store/selector.spec.d.ts +0 -1
  28. package/src/lib/store/selectors.d.ts +0 -15
  29. package/src/lib/utils/api.d.ts +0 -20
  30. package/src/lib/utils/api.spec.d.ts +0 -1
  31. package/src/lib/utils/fakeApi.d.ts +0 -2
  32. package/src/lib/utils/fakeApi.spec.d.ts +0 -1
package/index.esm.js CHANGED
@@ -1,19 +1,20 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useApiContext, useApi, createNonAuthApiInstance, ApiProvider } from '@opengeoweb/api';
3
- import { Grid2, Typography, Box, Card, CircularProgress } from '@mui/material';
2
+ import { Grid, Typography, Box, LinearProgress, Card, CircularProgress } from '@mui/material';
4
3
  import { Box as Box$1 } from '@mui/system';
5
- import { dateUtils, AlertBanner } from '@opengeoweb/shared';
6
- import { useSelector, useDispatch } from 'react-redux';
7
- import { createEntityAdapter, createSlice, createSelector, combineReducers, configureStore } from '@reduxjs/toolkit';
4
+ import { dateUtils, AlertBanner, sessionStorageProvider, usePrevious } from '@opengeoweb/shared';
8
5
  import React, { useMemo } from 'react';
9
6
  import i18n from 'i18next';
10
7
  import { useTranslation } from 'react-i18next';
11
8
  import { ConfigurableMapConnect } from '@opengeoweb/core';
12
9
  import '@opengeoweb/timeslider';
13
10
  import { isOpenLayersEnabled, OpenLayersFeatureLayer, genericOpenLayersFeatureStyle, MapViewLayer, MapWarningProperties } from '@opengeoweb/webmap-react';
11
+ import { useQuery, useQueries } from '@tanstack/react-query';
12
+ import { handleResponse } from '@opengeoweb/api';
14
13
  import { GeoJSON } from 'ol/format';
15
- import { mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, syncGroupsReducer, layerReducer, serviceReducer, mapReducer, mapSelectors } from '@opengeoweb/store';
14
+ import { useSelector } from 'react-redux';
15
+ import { mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, syncGroupsReducer, layerReducer, serviceReducer, mapReducer } from '@opengeoweb/store';
16
16
  import { webmapUtils } from '@opengeoweb/webmap';
17
+ import { combineReducers, configureStore } from '@reduxjs/toolkit';
17
18
 
18
19
  var en = {
19
20
  "map-view-cap-error-title": "Something went wrong with loading the configuration file",
@@ -58,117 +59,6 @@ var capTrans = {
58
59
  nl: nl
59
60
  };
60
61
 
61
- /* *
62
- * Licensed under the Apache License, Version 2.0 (the "License");
63
- * you may not use this file except in compliance with the License.
64
- * You may obtain a copy of the License at
65
- *
66
- * http://www.apache.org/licenses/LICENSE-2.0
67
- *
68
- * Unless required by applicable law or agreed to in writing, software
69
- * distributed under the License is distributed on an "AS IS" BASIS,
70
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71
- * See the License for the specific language governing permissions and
72
- * limitations under the License.
73
- *
74
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
75
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
76
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
77
- * */
78
- var feedAdapter = createEntityAdapter();
79
- var feedInitialState = feedAdapter.getInitialState();
80
- var alertAdapter = createEntityAdapter({
81
- // we use identifier as id
82
- selectId: function selectId(capAlert) {
83
- return capAlert.identifier;
84
- }
85
- });
86
- var alertInitialState = alertAdapter.getInitialState();
87
- var initialState = {
88
- feeds: feedInitialState,
89
- alerts: alertInitialState
90
- };
91
- var slice = createSlice({
92
- initialState: initialState,
93
- name: 'capReducer',
94
- reducers: {
95
- addManyAlerts: function addManyAlerts(draft, action) {
96
- alertAdapter.upsertMany(draft.alerts, action.payload);
97
- },
98
- addManyAlertsToFeed: function addManyAlertsToFeed(draft, action) {
99
- feedAdapter.upsertOne(draft.feeds, {
100
- id: action.payload.feedId,
101
- lastUpdated: Date.now(),
102
- alertIds: action.payload.alertIds
103
- });
104
- },
105
- setFeedLastUpdatedTimes: function setFeedLastUpdatedTimes(draft, action) {
106
- feedAdapter.updateMany(draft.feeds, action.payload);
107
- }
108
- }
109
- });
110
- var capReducer = slice.reducer,
111
- capActions = slice.actions;
112
-
113
- /* *
114
- * Licensed under the Apache License, Version 2.0 (the "License");
115
- * you may not use this file except in compliance with the License.
116
- * You may obtain a copy of the License at
117
- *
118
- * http://www.apache.org/licenses/LICENSE-2.0
119
- *
120
- * Unless required by applicable law or agreed to in writing, software
121
- * distributed under the License is distributed on an "AS IS" BASIS,
122
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123
- * See the License for the specific language governing permissions and
124
- * limitations under the License.
125
- *
126
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
127
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
128
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
129
- * */
130
- var getCapStore = function getCapStore(store) {
131
- if (store && store.cap) {
132
- return store.cap;
133
- }
134
- return null;
135
- };
136
- var _feedAdapter$getSelec = feedAdapter.getSelectors(function (state) {
137
- return state.cap.feeds;
138
- }),
139
- getCapFeedById = _feedAdapter$getSelec.selectById,
140
- getCapFeeds = _feedAdapter$getSelec.selectAll;
141
- var _alertAdapter$getSele = alertAdapter.getSelectors(function (state) {
142
- return state.cap.alerts;
143
- }),
144
- getAlertById = _alertAdapter$getSele.selectById,
145
- getAlerts = _alertAdapter$getSele.selectAll,
146
- getAlertIds = _alertAdapter$getSele.selectIds;
147
- var getAlertsInEffect = createSelector(getAlerts, function (_state, selectedTime) {
148
- return selectedTime;
149
- }, function (alerts, selectedTime) {
150
- return alerts.filter(function (alert) {
151
- return dateUtils.isBetween(dateUtils.createDate(selectedTime), dateUtils.createDate(alert.onset), dateUtils.createDate(alert.expires), '[)');
152
- });
153
- });
154
- var getLastUpdatedTimes = createSelector(getCapFeeds, function (feeds) {
155
- return feeds.map(function (feed) {
156
- return feed.lastUpdated;
157
- });
158
- });
159
-
160
- var selectors = /*#__PURE__*/Object.freeze({
161
- __proto__: null,
162
- getAlertById: getAlertById,
163
- getAlertIds: getAlertIds,
164
- getAlerts: getAlerts,
165
- getAlertsInEffect: getAlertsInEffect,
166
- getCapFeedById: getCapFeedById,
167
- getCapFeeds: getCapFeeds,
168
- getCapStore: getCapStore,
169
- getLastUpdatedTimes: getLastUpdatedTimes
170
- });
171
-
172
62
  function _arrayLikeToArray(r, a) {
173
63
  (null == a || a > r.length) && (a = r.length);
174
64
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -177,34 +67,6 @@ function _arrayLikeToArray(r, a) {
177
67
  function _arrayWithHoles(r) {
178
68
  if (Array.isArray(r)) return r;
179
69
  }
180
- function _arrayWithoutHoles(r) {
181
- if (Array.isArray(r)) return _arrayLikeToArray(r);
182
- }
183
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
184
- try {
185
- var i = n[a](c),
186
- u = i.value;
187
- } catch (n) {
188
- return void e(n);
189
- }
190
- i.done ? t(u) : Promise.resolve(u).then(r, o);
191
- }
192
- function _asyncToGenerator(n) {
193
- return function () {
194
- var t = this,
195
- e = arguments;
196
- return new Promise(function (r, o) {
197
- var a = n.apply(t, e);
198
- function _next(n) {
199
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
200
- }
201
- function _throw(n) {
202
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
203
- }
204
- _next(void 0);
205
- });
206
- };
207
- }
208
70
  function _createForOfIteratorHelper(r, e) {
209
71
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
210
72
  if (!t) {
@@ -261,9 +123,6 @@ function _defineProperty(e, r, t) {
261
123
  writable: true
262
124
  }) : e[r] = t, e;
263
125
  }
264
- function _iterableToArray(r) {
265
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
266
- }
267
126
  function _iterableToArrayLimit(r, l) {
268
127
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
269
128
  if (null != t) {
@@ -291,9 +150,6 @@ function _iterableToArrayLimit(r, l) {
291
150
  function _nonIterableRest() {
292
151
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
293
152
  }
294
- function _nonIterableSpread() {
295
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
296
- }
297
153
  function ownKeys(e, r) {
298
154
  var t = Object.keys(e);
299
155
  if (Object.getOwnPropertySymbols) {
@@ -315,313 +171,9 @@ function _objectSpread2(e) {
315
171
  }
316
172
  return e;
317
173
  }
318
- function _regeneratorRuntime() {
319
- _regeneratorRuntime = function () {
320
- return e;
321
- };
322
- var t,
323
- e = {},
324
- r = Object.prototype,
325
- n = r.hasOwnProperty,
326
- o = Object.defineProperty || function (t, e, r) {
327
- t[e] = r.value;
328
- },
329
- i = "function" == typeof Symbol ? Symbol : {},
330
- a = i.iterator || "@@iterator",
331
- c = i.asyncIterator || "@@asyncIterator",
332
- u = i.toStringTag || "@@toStringTag";
333
- function define(t, e, r) {
334
- return Object.defineProperty(t, e, {
335
- value: r,
336
- enumerable: true,
337
- configurable: true,
338
- writable: true
339
- }), t[e];
340
- }
341
- try {
342
- define({}, "");
343
- } catch (t) {
344
- define = function (t, e, r) {
345
- return t[e] = r;
346
- };
347
- }
348
- function wrap(t, e, r, n) {
349
- var i = e && e.prototype instanceof Generator ? e : Generator,
350
- a = Object.create(i.prototype),
351
- c = new Context(n || []);
352
- return o(a, "_invoke", {
353
- value: makeInvokeMethod(t, r, c)
354
- }), a;
355
- }
356
- function tryCatch(t, e, r) {
357
- try {
358
- return {
359
- type: "normal",
360
- arg: t.call(e, r)
361
- };
362
- } catch (t) {
363
- return {
364
- type: "throw",
365
- arg: t
366
- };
367
- }
368
- }
369
- e.wrap = wrap;
370
- var h = "suspendedStart",
371
- l = "suspendedYield",
372
- f = "executing",
373
- s = "completed",
374
- y = {};
375
- function Generator() {}
376
- function GeneratorFunction() {}
377
- function GeneratorFunctionPrototype() {}
378
- var p = {};
379
- define(p, a, function () {
380
- return this;
381
- });
382
- var d = Object.getPrototypeOf,
383
- v = d && d(d(values([])));
384
- v && v !== r && n.call(v, a) && (p = v);
385
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
386
- function defineIteratorMethods(t) {
387
- ["next", "throw", "return"].forEach(function (e) {
388
- define(t, e, function (t) {
389
- return this._invoke(e, t);
390
- });
391
- });
392
- }
393
- function AsyncIterator(t, e) {
394
- function invoke(r, o, i, a) {
395
- var c = tryCatch(t[r], t, o);
396
- if ("throw" !== c.type) {
397
- var u = c.arg,
398
- h = u.value;
399
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
400
- invoke("next", t, i, a);
401
- }, function (t) {
402
- invoke("throw", t, i, a);
403
- }) : e.resolve(h).then(function (t) {
404
- u.value = t, i(u);
405
- }, function (t) {
406
- return invoke("throw", t, i, a);
407
- });
408
- }
409
- a(c.arg);
410
- }
411
- var r;
412
- o(this, "_invoke", {
413
- value: function (t, n) {
414
- function callInvokeWithMethodAndArg() {
415
- return new e(function (e, r) {
416
- invoke(t, n, e, r);
417
- });
418
- }
419
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
420
- }
421
- });
422
- }
423
- function makeInvokeMethod(e, r, n) {
424
- var o = h;
425
- return function (i, a) {
426
- if (o === f) throw Error("Generator is already running");
427
- if (o === s) {
428
- if ("throw" === i) throw a;
429
- return {
430
- value: t,
431
- done: true
432
- };
433
- }
434
- for (n.method = i, n.arg = a;;) {
435
- var c = n.delegate;
436
- if (c) {
437
- var u = maybeInvokeDelegate(c, n);
438
- if (u) {
439
- if (u === y) continue;
440
- return u;
441
- }
442
- }
443
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
444
- if (o === h) throw o = s, n.arg;
445
- n.dispatchException(n.arg);
446
- } else "return" === n.method && n.abrupt("return", n.arg);
447
- o = f;
448
- var p = tryCatch(e, r, n);
449
- if ("normal" === p.type) {
450
- if (o = n.done ? s : l, p.arg === y) continue;
451
- return {
452
- value: p.arg,
453
- done: n.done
454
- };
455
- }
456
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
457
- }
458
- };
459
- }
460
- function maybeInvokeDelegate(e, r) {
461
- var n = r.method,
462
- o = e.iterator[n];
463
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
464
- var i = tryCatch(o, e.iterator, r.arg);
465
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
466
- var a = i.arg;
467
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
468
- }
469
- function pushTryEntry(t) {
470
- var e = {
471
- tryLoc: t[0]
472
- };
473
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
474
- }
475
- function resetTryEntry(t) {
476
- var e = t.completion || {};
477
- e.type = "normal", delete e.arg, t.completion = e;
478
- }
479
- function Context(t) {
480
- this.tryEntries = [{
481
- tryLoc: "root"
482
- }], t.forEach(pushTryEntry, this), this.reset(true);
483
- }
484
- function values(e) {
485
- if (e || "" === e) {
486
- var r = e[a];
487
- if (r) return r.call(e);
488
- if ("function" == typeof e.next) return e;
489
- if (!isNaN(e.length)) {
490
- var o = -1,
491
- i = function next() {
492
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
493
- return next.value = t, next.done = true, next;
494
- };
495
- return i.next = i;
496
- }
497
- }
498
- throw new TypeError(typeof e + " is not iterable");
499
- }
500
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
501
- value: GeneratorFunctionPrototype,
502
- configurable: true
503
- }), o(GeneratorFunctionPrototype, "constructor", {
504
- value: GeneratorFunction,
505
- configurable: true
506
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
507
- var e = "function" == typeof t && t.constructor;
508
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
509
- }, e.mark = function (t) {
510
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
511
- }, e.awrap = function (t) {
512
- return {
513
- __await: t
514
- };
515
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
516
- return this;
517
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
518
- void 0 === i && (i = Promise);
519
- var a = new AsyncIterator(wrap(t, r, n, o), i);
520
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
521
- return t.done ? t.value : a.next();
522
- });
523
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
524
- return this;
525
- }), define(g, "toString", function () {
526
- return "[object Generator]";
527
- }), e.keys = function (t) {
528
- var e = Object(t),
529
- r = [];
530
- for (var n in e) r.push(n);
531
- return r.reverse(), function next() {
532
- for (; r.length;) {
533
- var t = r.pop();
534
- if (t in e) return next.value = t, next.done = false, next;
535
- }
536
- return next.done = true, next;
537
- };
538
- }, e.values = values, Context.prototype = {
539
- constructor: Context,
540
- reset: function (e) {
541
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
542
- },
543
- stop: function () {
544
- this.done = true;
545
- var t = this.tryEntries[0].completion;
546
- if ("throw" === t.type) throw t.arg;
547
- return this.rval;
548
- },
549
- dispatchException: function (e) {
550
- if (this.done) throw e;
551
- var r = this;
552
- function handle(n, o) {
553
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
554
- }
555
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
556
- var i = this.tryEntries[o],
557
- a = i.completion;
558
- if ("root" === i.tryLoc) return handle("end");
559
- if (i.tryLoc <= this.prev) {
560
- var c = n.call(i, "catchLoc"),
561
- u = n.call(i, "finallyLoc");
562
- if (c && u) {
563
- if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
564
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
565
- } else if (c) {
566
- if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
567
- } else {
568
- if (!u) throw Error("try statement without catch or finally");
569
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
570
- }
571
- }
572
- }
573
- },
574
- abrupt: function (t, e) {
575
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
576
- var o = this.tryEntries[r];
577
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
578
- var i = o;
579
- break;
580
- }
581
- }
582
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
583
- var a = i ? i.completion : {};
584
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
585
- },
586
- complete: function (t, e) {
587
- if ("throw" === t.type) throw t.arg;
588
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
589
- },
590
- finish: function (t) {
591
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
592
- var r = this.tryEntries[e];
593
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
594
- }
595
- },
596
- catch: function (t) {
597
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
598
- var r = this.tryEntries[e];
599
- if (r.tryLoc === t) {
600
- var n = r.completion;
601
- if ("throw" === n.type) {
602
- var o = n.arg;
603
- resetTryEntry(r);
604
- }
605
- return o;
606
- }
607
- }
608
- throw Error("illegal catch attempt");
609
- },
610
- delegateYield: function (e, r, n) {
611
- return this.delegate = {
612
- iterator: values(e),
613
- resultName: r,
614
- nextLoc: n
615
- }, "next" === this.method && (this.arg = t), y;
616
- }
617
- }, e;
618
- }
619
174
  function _slicedToArray(r, e) {
620
175
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
621
176
  }
622
- function _toConsumableArray(r) {
623
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
624
- }
625
177
  function _toPrimitive(t, r) {
626
178
  if ("object" != typeof t || !t) return t;
627
179
  var e = t[Symbol.toPrimitive];
@@ -730,7 +282,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
730
282
  expires = _ref.expires;
731
283
  var _useCapTranslation = useCapTranslation(),
732
284
  t = _useCapTranslation.t;
733
- return jsxs(Grid2, {
285
+ return jsxs(Grid, {
734
286
  container: true,
735
287
  sx: {
736
288
  border: severityStyles[severity].border,
@@ -740,7 +292,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
740
292
  marginBottom: '20px',
741
293
  width: '100%'
742
294
  },
743
- children: [jsxs(Grid2, {
295
+ children: [jsxs(Grid, {
744
296
  size: {
745
297
  xs: 4
746
298
  },
@@ -755,7 +307,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
755
307
  "data-testid": "event",
756
308
  children: event ? "".concat(event) : ''
757
309
  })]
758
- }), jsxs(Grid2, {
310
+ }), jsxs(Grid, {
759
311
  size: {
760
312
  xs: 4
761
313
  },
@@ -770,7 +322,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
770
322
  "data-testid": "severity",
771
323
  children: severity ? "".concat(severity) : ''
772
324
  })]
773
- }), jsxs(Grid2, {
325
+ }), jsxs(Grid, {
774
326
  size: {
775
327
  xs: 4
776
328
  },
@@ -791,15 +343,12 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
791
343
 
792
344
  var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
793
345
  var _alert$languages;
794
- var alertId = _ref.alertId,
346
+ var alert = _ref.alert,
795
347
  capWarningPresets = _ref.capWarningPresets;
796
348
  var _React$useState = React.useState(0),
797
349
  _React$useState2 = _slicedToArray(_React$useState, 2),
798
350
  languageIndex = _React$useState2[0],
799
351
  setLanguageIndex = _React$useState2[1];
800
- var alert = useSelector(function (store) {
801
- return getAlertById(store, alertId);
802
- });
803
352
  var alertHasLanguages = Boolean(alert === null || alert === void 0 || (_alert$languages = alert.languages) === null || _alert$languages === void 0 ? void 0 : _alert$languages.length);
804
353
  var language = i18n.language;
805
354
  React.useEffect(function () {
@@ -819,16 +368,24 @@ var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
819
368
 
820
369
  var WarningListCap = function WarningListCap(_ref) {
821
370
  var capWarningPresets = _ref.capWarningPresets,
822
- alertIds = _ref.alertIds;
371
+ alerts = _ref.alerts,
372
+ _ref$isPending = _ref.isPending,
373
+ isPending = _ref$isPending === void 0 ? false : _ref$isPending;
823
374
  var _useCapTranslation = useCapTranslation(),
824
375
  t = _useCapTranslation.t;
825
- return jsx(Box, {
376
+ return jsxs(Box, {
826
377
  sx: {
827
378
  width: '100%',
828
379
  height: '100%',
829
380
  display: 'flex'
830
381
  },
831
- children: jsxs(Card, {
382
+ children: [isPending && jsx(LinearProgress, {
383
+ color: "secondary",
384
+ sx: {
385
+ position: 'absolute',
386
+ width: '100%'
387
+ }
388
+ }), jsxs(Card, {
832
389
  sx: {
833
390
  justifyContent: 'center',
834
391
  alignItems: 'center',
@@ -841,7 +398,10 @@ var WarningListCap = function WarningListCap(_ref) {
841
398
  position: 'relative'
842
399
  },
843
400
  "data-testid": "warningList",
844
- children: [alertIds.length > 0 && jsx(Box, {
401
+ children: [!isPending && !alerts.length && jsx(AlertBanner, {
402
+ title: "No results",
403
+ severity: "warning"
404
+ }), alerts.length > 0 && jsx(Box, {
845
405
  sx: {
846
406
  position: 'sticky',
847
407
  top: 0,
@@ -850,67 +410,16 @@ var WarningListCap = function WarningListCap(_ref) {
850
410
  justifyContent: 'center'
851
411
  },
852
412
  children: jsx(AlertBanner, {
853
- title: t('warning-list-cap-alert-banner-title')
413
+ title: t('warning-list-cap-alert-banner-title'),
414
+ severity: "info"
854
415
  })
855
- }), alertIds.length === 0 ? jsx(Box, {
856
- sx: {
857
- position: 'absolute',
858
- left: '50%',
859
- top: '20%',
860
- zIndex: '100'
861
- },
862
- children: jsx(CircularProgress, {})
863
- }) : null, alertIds.map(function (id) {
416
+ }), alerts.map(function (alert) {
864
417
  return jsx(WarningListRowCapConnect, {
865
- alertId: id,
418
+ alert: alert,
866
419
  capWarningPresets: capWarningPresets
867
- }, id);
420
+ }, alert.identifier);
868
421
  })]
869
- })
870
- });
871
- };
872
-
873
- var WarningListCapConnect = function WarningListCapConnect(_ref) {
874
- var capWarningPresets = _ref.capWarningPresets;
875
- var alertIDs = useSelector(function (store) {
876
- return getAlertIds(store);
877
- });
878
- return jsx(WarningListCap, {
879
- capWarningPresets: capWarningPresets,
880
- alertIds: alertIDs
881
- });
882
- };
883
-
884
- var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
885
- var productConfigKey = _ref.productConfigKey;
886
- var _useApiContext = useApiContext(),
887
- api = _useApiContext.api;
888
- var _useCapTranslation = useCapTranslation(),
889
- t = _useCapTranslation.t;
890
- var _useApi = useApi(api.getCapConfiguration, productConfigKey),
891
- productConfig = _useApi.result,
892
- isConfigLoading = _useApi.isLoading,
893
- error = _useApi.error;
894
- if (isConfigLoading) {
895
- return jsx(Box$1, {
896
- sx: {
897
- display: 'flex',
898
- justifyContent: 'center',
899
- alignItems: 'center'
900
- },
901
- children: jsx(CircularProgress, {
902
- "data-testid": "loadingSpinner"
903
- })
904
- });
905
- }
906
- if (error) {
907
- return jsx(AlertBanner, {
908
- title: t('warning-list-cap-error-title'),
909
- info: error.message
910
- });
911
- }
912
- return jsx(WarningListCapConnect, {
913
- capWarningPresets: productConfig
422
+ })]
914
423
  });
915
424
  };
916
425
 
@@ -931,33 +440,44 @@ var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
931
440
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
932
441
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
933
442
  * */
934
- var getApiRoutes = function getApiRoutes(axiosInstance, nonAuthAxiosInstance) {
935
- return {
936
- getCapConfiguration: function getCapConfiguration(productConfigKey) {
937
- return nonAuthAxiosInstance.get("/assets/".concat(productConfigKey));
938
- },
939
- getAllAlerts: function getAllAlerts(thirdPartyApiUrl) {
940
- return axiosInstance.get("/allalerts?url=".concat(thirdPartyApiUrl));
941
- },
942
- getFeedLinks: function getFeedLinks(thirdPartyApiUrl) {
943
- return axiosInstance.get("/feedlinks?url=".concat(thirdPartyApiUrl));
944
- },
945
- getSingleAlert: function getSingleAlert(alertUrl) {
946
- return axiosInstance.get("/singlealert?url=".concat(alertUrl));
947
- },
948
- getLastUpdated: function getLastUpdated(thirdPartyApiUrl) {
949
- return axiosInstance.get("/poll_feed?url=".concat(thirdPartyApiUrl));
950
- }
951
- };
952
- };
953
- var createApi = function createApi(props) {
954
- var axiosInstance = createNonAuthApiInstance(props);
955
- var nonAuthAxiosInstance = createNonAuthApiInstance({});
956
- return getApiRoutes(axiosInstance, nonAuthAxiosInstance);
443
+ var addFeedAddressToCustomGeoJSonFeature = function addFeedAddressToCustomGeoJSonFeature(feedAddress, features) {
444
+ return features.reduce(function (list, feature) {
445
+ return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
446
+ properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
447
+ details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
448
+ feedAddress: feedAddress
449
+ })
450
+ })
451
+ }));
452
+ }, []);
957
453
  };
958
454
 
959
- var mockLastUpdated = {
960
- lastUpdated: 1666096534
455
+ var config = sessionStorageProvider.getConfig();
456
+ var capBaseUrl = config.GW_CAP_BASE_URL || '';
457
+ var getConfig = function getConfig(productConfigKey) {
458
+ return fetch("assets/".concat(encodeURIComponent(productConfigKey))).then(handleResponse);
459
+ };
460
+ var getFeedLinks = function getFeedLinks(feedAddress) {
461
+ return fetch("".concat(capBaseUrl, "/feedlinks?url=").concat(encodeURIComponent(feedAddress))).then(handleResponse).then(function (result) {
462
+ return result.map(function (link) {
463
+ return {
464
+ link: link,
465
+ feedAddress: feedAddress
466
+ };
467
+ });
468
+ });
469
+ };
470
+ var getSingleAlert = function getSingleAlert(alertUrl) {
471
+ return fetch("".concat(capBaseUrl, "/singlealert?url=").concat(encodeURIComponent(alertUrl.link))).then(handleResponse).then(function (result) {
472
+ var alert = _objectSpread2(_objectSpread2({}, result.alert), {}, {
473
+ feedAddress: alertUrl.feedAddress
474
+ });
475
+ var features = addFeedAddressToCustomGeoJSonFeature(alertUrl.feedAddress, result.features.features);
476
+ return {
477
+ alert: alert,
478
+ features: features
479
+ };
480
+ });
961
481
  };
962
482
 
963
483
  /* *
@@ -973,105 +493,126 @@ var mockLastUpdated = {
973
493
  * See the License for the specific language governing permissions and
974
494
  * limitations under the License.
975
495
  *
976
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
977
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
978
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
496
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
497
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
498
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
979
499
  * */
980
- var mockCapStateWithAlerts = {
981
- alerts: {
982
- ids: ['2.49.0.1.246.0.0.2022'],
983
- entities: {
984
- '2.49.0.1.246.0.0.2022': {
985
- identifier: '2.49.0.1.246.0.0.2022',
986
- feedAddress: 'https://alerts.fmi.fi/cap/feed/rss_en-GB.rss',
987
- severity: 'Extreme',
988
- certainty: 'Likely',
989
- onset: '2022-07-07T00:00:00+03:00',
990
- expires: '2022-07-07T23:53:10+03:00',
991
- languages: [{
992
- areaDesc: 'Uusimaa ja Kymenlaakso',
993
- language: 'fi-FI',
994
- event: 'Metsäpalovaroitus',
995
- senderName: 'Ilmatieteen laitos',
996
- headline: 'Oranssi metsäpalovaroitus: Uusimaa ja Kymenlaakso, to 0.00 - 23.53',
997
- description: 'Metsäpalojen vaara on erittäin suuri keskiviikon ja torstain välisestä yöstä torstain ja perjantain väliseen yöhön 30 % todennäköisyydellä.'
998
- }, {
999
- areaDesc: 'Nyland och Kymmenedalen',
1000
- language: 'sv-FI',
1001
- event: 'Varning för skogsbrand',
1002
- senderName: 'Meteorologiska institutet',
1003
- headline: 'Orange varning för skogsbrand: Nyland och Kymmenedalen, to 0.00 - 23.53',
1004
- description: 'Risken för skogsbränder är mycket hög på från och med natten mellan onsdag och torsdag fram till natten mellan torsdag och fredag med 30 % sannolikhet.'
1005
- }, {
1006
- areaDesc: 'Uusimaa and Kymenlaakso',
1007
- language: 'en-GB',
1008
- event: 'Forest fire warning',
1009
- senderName: 'Finnish Meteorological Institute',
1010
- headline: 'Orange forest fire warning: Uusimaa and Kymenlaakso, Thu 0.00 - 23.53',
1011
- description: 'A risk of forest fires is very high on from the night between Wednesday and Thursday to the night between Thursday and Friday with probability of 30 %.'
1012
- }]
1013
- }
500
+ var useGetConfig = function useGetConfig(productConfigKey) {
501
+ return useQuery({
502
+ queryKey: ['cap-config', productConfigKey],
503
+ queryFn: function queryFn() {
504
+ return getConfig(productConfigKey);
1014
505
  }
1015
- },
1016
- feeds: {
1017
- ids: [],
1018
- entities: {}
1019
- }
506
+ });
1020
507
  };
1021
- var mockCapStateWithFeeds = {
1022
- alerts: {
1023
- ids: [],
1024
- entities: {}
1025
- },
1026
- feeds: {
1027
- ids: ['https://alerts.fmi.fi/cap/feed/rss_en-GB.rss', 'https://api.met.no/weatherapi/metalerts/1.1'],
1028
- entities: {
1029
- 'https://alerts.fmi.fi/cap/feed/rss_en-GB.rss': {
1030
- id: 'https://alerts.fmi.fi/cap/feed/rss_en-GB.rss',
1031
- lastUpdated: mockLastUpdated.lastUpdated
1032
- },
1033
- 'https://api.met.no/weatherapi/metalerts/1.1': {
1034
- id: 'https://api.met.no/weatherapi/metalerts/1.1',
1035
- lastUpdated: mockLastUpdated.lastUpdated
1036
- }
508
+ var useAllFeedLinks = function useAllFeedLinks(capPresets) {
509
+ var queries = useMemo(function () {
510
+ return capPresets.feeds.map(function (feed) {
511
+ return {
512
+ queryKey: ['feedLinks', feed.feedAddress],
513
+ queryFn: function queryFn() {
514
+ return getFeedLinks(feed.feedAddress);
515
+ },
516
+ refetchInterval: capPresets.pollInterval
517
+ };
518
+ });
519
+ }, [capPresets]);
520
+ var results = useQueries({
521
+ queries: queries,
522
+ combine: function combine(results) {
523
+ return {
524
+ results: results.flatMap(function (result) {
525
+ return result.data;
526
+ }).filter(function (result) {
527
+ return !!result;
528
+ }),
529
+ pending: results.some(function (result) {
530
+ return result.isPending;
531
+ })
532
+ };
1037
533
  }
1038
- }
534
+ });
535
+ return results;
536
+ };
537
+ var useAllFeedAlerts = function useAllFeedAlerts(capPresets) {
538
+ var _useAllFeedLinks = useAllFeedLinks(capPresets),
539
+ allFeeds = _useAllFeedLinks.results,
540
+ allFeedPending = _useAllFeedLinks.pending;
541
+ var queries = useMemo(function () {
542
+ return allFeeds.map(function (feed) {
543
+ return {
544
+ queryKey: ['feedAlert', feed],
545
+ queryFn: function queryFn() {
546
+ return getSingleAlert(feed);
547
+ }
548
+ };
549
+ });
550
+ }, [allFeeds]);
551
+ var _useQueries = useQueries({
552
+ queries: queries,
553
+ combine: function combine(results) {
554
+ return {
555
+ alertResults: results.map(function (result) {
556
+ return result.data;
557
+ }).filter(function (result) {
558
+ return !!result;
559
+ }),
560
+ pending: results.some(function (result) {
561
+ return result.isPending;
562
+ })
563
+ };
564
+ }
565
+ }),
566
+ alertResults = _useQueries.alertResults,
567
+ alertsPending = _useQueries.pending;
568
+ return {
569
+ results: alertResults,
570
+ pending: allFeedPending || alertsPending
571
+ };
1039
572
  };
1040
573
 
1041
- /* *
1042
- * Licensed under the Apache License, Version 2.0 (the "License");
1043
- * you may not use this file except in compliance with the License.
1044
- * You may obtain a copy of the License at
1045
- *
1046
- * http://www.apache.org/licenses/LICENSE-2.0
1047
- *
1048
- * Unless required by applicable law or agreed to in writing, software
1049
- * distributed under the License is distributed on an "AS IS" BASIS,
1050
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1051
- * See the License for the specific language governing permissions and
1052
- * limitations under the License.
1053
- *
1054
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1055
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1056
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1057
- * */
1058
- var capReducersMap = {
1059
- webmap: mapReducer,
1060
- services: serviceReducer,
1061
- layers: layerReducer,
1062
- syncGroups: syncGroupsReducer,
1063
- cap: capReducer
574
+ var WarningListCapConnect = function WarningListCapConnect(_ref) {
575
+ var capWarningPresets = _ref.capWarningPresets;
576
+ var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
577
+ feedAlerts = _useAllFeedAlerts.results,
578
+ pending = _useAllFeedAlerts.pending;
579
+ return jsx(WarningListCap, {
580
+ capWarningPresets: capWarningPresets,
581
+ alerts: feedAlerts.map(function (fa) {
582
+ return fa.alert;
583
+ }),
584
+ isPending: pending
585
+ });
1064
586
  };
1065
- var capMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, syncGroupsListener.middleware, genericListener.middleware, openlayersListener.middleware];
1066
- var capRootReducer = combineReducers(capReducersMap);
1067
- var createMockStore = function createMockStore(mockState) {
1068
- return configureStore({
1069
- reducer: capRootReducer,
1070
- preloadedState: mockState,
1071
- middleware: function middleware(getDefaultMiddleware) {
1072
- return getDefaultMiddleware().concat(capMiddlewares);
1073
- },
1074
- devTools: true
587
+
588
+ var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
589
+ var productConfigKey = _ref.productConfigKey;
590
+ var _useCapTranslation = useCapTranslation(),
591
+ t = _useCapTranslation.t;
592
+ var _useGetConfig = useGetConfig(productConfigKey),
593
+ productConfig = _useGetConfig.data,
594
+ isPending = _useGetConfig.isPending,
595
+ error = _useGetConfig.error;
596
+ if (isPending) {
597
+ return jsx(Box$1, {
598
+ sx: {
599
+ display: 'flex',
600
+ justifyContent: 'center',
601
+ alignItems: 'center'
602
+ },
603
+ children: jsx(CircularProgress, {
604
+ "data-testid": "loadingSpinner"
605
+ })
606
+ });
607
+ }
608
+ if (error) {
609
+ return jsx(AlertBanner, {
610
+ title: t('warning-list-cap-error-title'),
611
+ info: error.message
612
+ });
613
+ }
614
+ return jsx(WarningListCapConnect, {
615
+ capWarningPresets: productConfig
1075
616
  });
1076
617
  };
1077
618
 
@@ -1162,45 +703,6 @@ var addColors = function addColors(features) {
1162
703
  return features;
1163
704
  };
1164
705
 
1165
- /* *
1166
- * Licensed under the Apache License, Version 2.0 (the "License");
1167
- * you may not use this file except in compliance with the License.
1168
- * You may obtain a copy of the License at
1169
- *
1170
- * http://www.apache.org/licenses/LICENSE-2.0
1171
- *
1172
- * Unless required by applicable law or agreed to in writing, software
1173
- * distributed under the License is distributed on an "AS IS" BASIS,
1174
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1175
- * See the License for the specific language governing permissions and
1176
- * limitations under the License.
1177
- *
1178
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1179
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1180
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1181
- * */
1182
- var addFeedAdressToCustomGeoJSonFeature = function addFeedAdressToCustomGeoJSonFeature(feedAddress, features) {
1183
- return features.reduce(function (list, feature) {
1184
- return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
1185
- properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
1186
- details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
1187
- feedAddress: feedAddress
1188
- })
1189
- })
1190
- }));
1191
- }, []);
1192
- };
1193
-
1194
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
1195
- var isPromiseFulfilled = function isPromiseFulfilled(result) {
1196
- return result.status === 'fulfilled';
1197
- };
1198
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
1199
- var promiseSuccesses = function promiseSuccesses(results) {
1200
- return results.reduce(function (acc, result) {
1201
- return isPromiseFulfilled(result) ? [].concat(_toConsumableArray(acc), [result.value]) : acc;
1202
- }, []);
1203
- };
1204
706
  var MapViewCapConnect = function MapViewCapConnect(_ref) {
1205
707
  var id = _ref.id,
1206
708
  title = _ref.title,
@@ -1209,239 +711,18 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
1209
711
  capWarningPresets = _ref.capWarningPresets,
1210
712
  layers = _ref.layers,
1211
713
  children = _ref.children;
1212
- var _useApiContext = useApiContext(),
1213
- api = _useApiContext.api;
1214
- var dispatch = useDispatch();
1215
- var previousFeatures = React.useRef(null);
714
+ var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
715
+ feedAlertsResult = _useAllFeedAlerts.results;
1216
716
  var _React$useState = React.useState({}),
1217
717
  _React$useState2 = _slicedToArray(_React$useState, 2),
1218
718
  featuresByAlert = _React$useState2[0],
1219
719
  setFeaturesByAlert = _React$useState2[1];
1220
- var _React$useState3 = React.useState(null),
720
+ var _React$useState3 = React.useState(undefined),
1221
721
  _React$useState4 = _slicedToArray(_React$useState3, 2),
1222
722
  selectedFeatureEvent = _React$useState4[0],
1223
723
  setSelectedFeatureEvent = _React$useState4[1];
1224
724
  var mapIdRef = React.useRef(id || webmapUtils.generateMapId());
1225
725
  var layerIdRef = React.useRef(webmapUtils.generateLayerId());
1226
- var currentLastUpdatedTimes = useSelector(function (store) {
1227
- return getLastUpdatedTimes(store);
1228
- });
1229
- var fetchData = /*#__PURE__*/function () {
1230
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(links, feedAddress) {
1231
- var alertsAndFeaturesPromises, alertsAndFeatures, realAlertsAndFeatures, alerts, featuresByAlert, combinedFeatures;
1232
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1233
- while (1) switch (_context2.prev = _context2.next) {
1234
- case 0:
1235
- alertsAndFeaturesPromises = links.map( /*#__PURE__*/function () {
1236
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(alertUrl) {
1237
- var _yield$api$getSingleA, data, alert, features;
1238
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1239
- while (1) switch (_context.prev = _context.next) {
1240
- case 0:
1241
- _context.next = 2;
1242
- return api.getSingleAlert(alertUrl);
1243
- case 2:
1244
- _yield$api$getSingleA = _context.sent;
1245
- data = _yield$api$getSingleA.data;
1246
- alert = _objectSpread2(_objectSpread2({}, data.alert), {}, {
1247
- feedAddress: feedAddress
1248
- });
1249
- features = addFeedAdressToCustomGeoJSonFeature(feedAddress, data.features.features);
1250
- return _context.abrupt("return", {
1251
- alert: alert,
1252
- features: features
1253
- });
1254
- case 7:
1255
- case "end":
1256
- return _context.stop();
1257
- }
1258
- }, _callee);
1259
- }));
1260
- return function (_x3) {
1261
- return _ref3.apply(this, arguments);
1262
- };
1263
- }());
1264
- _context2.next = 3;
1265
- return Promise.allSettled(alertsAndFeaturesPromises);
1266
- case 3:
1267
- alertsAndFeatures = _context2.sent;
1268
- realAlertsAndFeatures = alertsAndFeatures.reduce(function (alerts, result) {
1269
- return (
1270
- // endpoints may throttle requests and return empty alerts
1271
- isPromiseFulfilled(result) && result.value.alert ? [].concat(_toConsumableArray(alerts), [result.value]) : alerts
1272
- );
1273
- }, []);
1274
- alerts = realAlertsAndFeatures.map(function (_ref4) {
1275
- var alert = _ref4.alert;
1276
- return _objectSpread2({}, alert);
1277
- });
1278
- dispatch(capActions.addManyAlerts(alerts));
1279
- dispatch(capActions.addManyAlertsToFeed({
1280
- feedId: feedAddress,
1281
- alertIds: alerts.map(function (alert) {
1282
- return alert.identifier;
1283
- })
1284
- }));
1285
- featuresByAlert = realAlertsAndFeatures.reduce(function (byId, _ref5) {
1286
- var alert = _ref5.alert,
1287
- features = _ref5.features;
1288
- return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alert.identifier, addColors(features)));
1289
- }, {});
1290
- combinedFeatures = _objectSpread2(_objectSpread2({}, previousFeatures.current), featuresByAlert);
1291
- setFeaturesByAlert(combinedFeatures);
1292
- previousFeatures.current = combinedFeatures;
1293
- case 12:
1294
- case "end":
1295
- return _context2.stop();
1296
- }
1297
- }, _callee2);
1298
- }));
1299
- return function fetchData(_x, _x2) {
1300
- return _ref2.apply(this, arguments);
1301
- };
1302
- }();
1303
- var fetchDataFromAllFeeds = /*#__PURE__*/function () {
1304
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1305
- var feedPromises, feedLinks;
1306
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1307
- while (1) switch (_context4.prev = _context4.next) {
1308
- case 0:
1309
- feedPromises = capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.feeds.map( /*#__PURE__*/function () {
1310
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref7) {
1311
- var feedAddress, _yield$api$getFeedLin, links;
1312
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1313
- while (1) switch (_context3.prev = _context3.next) {
1314
- case 0:
1315
- feedAddress = _ref7.feedAddress;
1316
- _context3.next = 3;
1317
- return api.getFeedLinks(feedAddress);
1318
- case 3:
1319
- _yield$api$getFeedLin = _context3.sent;
1320
- links = _yield$api$getFeedLin.data;
1321
- return _context3.abrupt("return", {
1322
- links: links,
1323
- feedAddress: feedAddress
1324
- });
1325
- case 6:
1326
- case "end":
1327
- return _context3.stop();
1328
- }
1329
- }, _callee3);
1330
- }));
1331
- return function (_x4) {
1332
- return _ref8.apply(this, arguments);
1333
- };
1334
- }());
1335
- _context4.t0 = promiseSuccesses;
1336
- _context4.next = 4;
1337
- return Promise.allSettled(feedPromises);
1338
- case 4:
1339
- _context4.t1 = _context4.sent;
1340
- feedLinks = (0, _context4.t0)(_context4.t1);
1341
- feedLinks.forEach(function (_ref9) {
1342
- var links = _ref9.links,
1343
- feedAddress = _ref9.feedAddress;
1344
- void fetchData(links, feedAddress);
1345
- });
1346
- case 7:
1347
- case "end":
1348
- return _context4.stop();
1349
- }
1350
- }, _callee4);
1351
- }));
1352
- return function fetchDataFromAllFeeds() {
1353
- return _ref6.apply(this, arguments);
1354
- };
1355
- }();
1356
- var pollAndUpdate = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1357
- var lastUpdatedPromises, lastUpdateTimes;
1358
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1359
- while (1) switch (_context7.prev = _context7.next) {
1360
- case 0:
1361
- lastUpdatedPromises = capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.feeds.map( /*#__PURE__*/function () {
1362
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(feed) {
1363
- var _yield$api$getLastUpd, updated;
1364
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1365
- while (1) switch (_context5.prev = _context5.next) {
1366
- case 0:
1367
- _context5.next = 2;
1368
- return api.getLastUpdated(feed.feedAddress);
1369
- case 2:
1370
- _yield$api$getLastUpd = _context5.sent;
1371
- updated = _yield$api$getLastUpd.data;
1372
- return _context5.abrupt("return", {
1373
- id: feed.feedAddress,
1374
- changes: {
1375
- lastUpdated: updated.lastUpdated
1376
- }
1377
- });
1378
- case 5:
1379
- case "end":
1380
- return _context5.stop();
1381
- }
1382
- }, _callee5);
1383
- }));
1384
- return function (_x5) {
1385
- return _ref11.apply(this, arguments);
1386
- };
1387
- }());
1388
- if (!lastUpdatedPromises) {
1389
- _context7.next = 9;
1390
- break;
1391
- }
1392
- _context7.t0 = promiseSuccesses;
1393
- _context7.next = 5;
1394
- return Promise.allSettled(lastUpdatedPromises);
1395
- case 5:
1396
- _context7.t1 = _context7.sent;
1397
- lastUpdateTimes = (0, _context7.t0)(_context7.t1);
1398
- lastUpdateTimes.forEach( /*#__PURE__*/function () {
1399
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(feed, i) {
1400
- var _yield$api$getFeedLin2, links;
1401
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1402
- while (1) switch (_context6.prev = _context6.next) {
1403
- case 0:
1404
- if (!dateUtils.isAfter(feed.changes.lastUpdated, currentLastUpdatedTimes[i])) {
1405
- _context6.next = 6;
1406
- break;
1407
- }
1408
- _context6.next = 3;
1409
- return api.getFeedLinks(feed.id);
1410
- case 3:
1411
- _yield$api$getFeedLin2 = _context6.sent;
1412
- links = _yield$api$getFeedLin2.data;
1413
- void fetchData(links, feed.id);
1414
- case 6:
1415
- case "end":
1416
- return _context6.stop();
1417
- }
1418
- }, _callee6);
1419
- }));
1420
- return function (_x6, _x7) {
1421
- return _ref12.apply(this, arguments);
1422
- };
1423
- }());
1424
- dispatch(capActions.setFeedLastUpdatedTimes(lastUpdateTimes));
1425
- case 9:
1426
- case "end":
1427
- return _context7.stop();
1428
- }
1429
- }, _callee7);
1430
- })), [currentLastUpdatedTimes]);
1431
- React.useEffect(function () {
1432
- void fetchDataFromAllFeeds();
1433
- // eslint-disable-next-line react-hooks/exhaustive-deps
1434
- }, []);
1435
- React.useEffect(function () {
1436
- var _capWarningPresets$po;
1437
- var pollInterval = (_capWarningPresets$po = capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.pollInterval) !== null && _capWarningPresets$po !== void 0 ? _capWarningPresets$po : 300000;
1438
- var timer = setInterval(function () {
1439
- void pollAndUpdate();
1440
- }, pollInterval);
1441
- return function () {
1442
- clearInterval(timer);
1443
- };
1444
- }, [capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.pollInterval, currentLastUpdatedTimes, pollAndUpdate]);
1445
726
  var parentSizeRef = React.useRef(null);
1446
727
  var _React$useState5 = React.useState(window.innerWidth / 2),
1447
728
  _React$useState6 = _slicedToArray(_React$useState5, 2),
@@ -1457,15 +738,34 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
1457
738
  };
1458
739
  }, []);
1459
740
  var highLightGeoJsonOnClick = function highLightGeoJsonOnClick(featureResults) {
1460
- var nextState = highlightGeoJson(featuresByAlert, featureResults);
1461
741
  setSelectedFeatureEvent(featureResults);
1462
- setFeaturesByAlert(nextState);
742
+ setFeaturesByAlert(function (previous) {
743
+ return highlightGeoJson(previous, featureResults);
744
+ });
1463
745
  };
746
+ var selectedTime = useSelector(function (store) {
747
+ return mapSelectors.getSelectedTime(store, mapIdRef.current);
748
+ });
749
+ var selectedDate = useMemo(function () {
750
+ return dateUtils.createDate(dateUtils.fromUnix(selectedTime).toISOString());
751
+ }, [selectedTime]);
752
+ var alertsInEffect = useMemo(function () {
753
+ return feedAlertsResult.filter(function (alert) {
754
+ return dateUtils.isBetween(selectedDate, dateUtils.createDate(alert.alert.onset), dateUtils.createDate(alert.alert.expires), '[)');
755
+ });
756
+ }, [feedAlertsResult, selectedDate]);
757
+ var alertIdsInEffect = useMemo(function () {
758
+ return alertsInEffect.map(function (_ref2) {
759
+ var alert = _ref2.alert;
760
+ return alert.identifier;
761
+ });
762
+ }, [alertsInEffect]);
763
+ var previousAlertIdsInEffect = usePrevious(alertIdsInEffect);
1464
764
  var clickOnFeature = useMemo(function () {
1465
765
  return {
1466
- onClick: function onClick(f) {
1467
- var featureResults = f.length === 0 ? undefined : {
1468
- feature: new GeoJSON().writeFeatureObject(f[0]),
766
+ onClick: function onClick(feature) {
767
+ var featureResults = feature.length === 0 ? undefined : {
768
+ feature: new GeoJSON().writeFeatureObject(feature[0]),
1469
769
  coordinateIndexInFeature: null,
1470
770
  featureIndex: null,
1471
771
  screenCoords: null,
@@ -1480,17 +780,17 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
1480
780
  }
1481
781
  };
1482
782
  }, []);
1483
- var selectedTime = useSelector(function (store) {
1484
- return mapSelectors.getSelectedTime(store, mapIdRef.current);
1485
- });
1486
- var alertsInEffect = useSelector(function (store) {
1487
- return getAlertsInEffect(store, dateUtils.fromUnix(selectedTime).toISOString());
1488
- });
783
+ React.useEffect(function () {
784
+ if (JSON.stringify(alertIdsInEffect) !== JSON.stringify(previousAlertIdsInEffect)) {
785
+ var _featuresByAlert = alertsInEffect.reduce(function (byId, _ref3) {
786
+ var alert = _ref3.alert,
787
+ features = _ref3.features;
788
+ return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alert.identifier, addColors(features)));
789
+ }, {});
790
+ setFeaturesByAlert(_featuresByAlert);
791
+ }
792
+ }, [alertIdsInEffect, alertsInEffect, previousAlertIdsInEffect]);
1489
793
  var geoJsonObject = useMemo(function () {
1490
- var alertIdsInEffect = alertsInEffect.map(function (_ref13) {
1491
- var identifier = _ref13.identifier;
1492
- return identifier;
1493
- });
1494
794
  var featuresInEffect = Object.keys(featuresByAlert).filter(function (id) {
1495
795
  return alertIdsInEffect.includes(id);
1496
796
  }).flatMap(function (id) {
@@ -1500,7 +800,8 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
1500
800
  type: 'FeatureCollection',
1501
801
  features: featuresInEffect
1502
802
  };
1503
- }, [featuresByAlert, alertsInEffect]);
803
+ // eslint-disable-next-line react-hooks/exhaustive-deps
804
+ }, [featuresByAlert]);
1504
805
  var useOl = isOpenLayersEnabled();
1505
806
  return jsx("div", {
1506
807
  "data-testid": "mapViewCap",
@@ -1544,15 +845,13 @@ var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
1544
845
  srs = _ref.srs,
1545
846
  productConfigKey = _ref.productConfigKey,
1546
847
  layers = _ref.layers;
1547
- var _useApiContext = useApiContext(),
1548
- api = _useApiContext.api;
1549
848
  var _useCapTranslation = useCapTranslation(),
1550
849
  t = _useCapTranslation.t;
1551
- var _useApi = useApi(api.getCapConfiguration, productConfigKey),
1552
- capWarningPresets = _useApi.result,
1553
- isConfigLoading = _useApi.isLoading,
1554
- error = _useApi.error;
1555
- if (isConfigLoading) {
850
+ var _useGetConfig = useGetConfig(productConfigKey),
851
+ capWarningPresets = _useGetConfig.data,
852
+ isPending = _useGetConfig.isPending,
853
+ error = _useGetConfig.error;
854
+ if (isPending) {
1556
855
  return jsx(Box$1, {
1557
856
  sx: {
1558
857
  display: 'flex',
@@ -1589,38 +888,23 @@ var ComponentsLookUp = function ComponentsLookUp(_ref) {
1589
888
  var componentType = _ref.componentType,
1590
889
  initialProps = _ref.initialProps,
1591
890
  productConfigKey = _ref.productConfigKey,
1592
- config = _ref.config,
1593
891
  id = _ref.id;
1594
- // TODO: implement polling when backend is ready
1595
- // NOTE: Fetching data inside this component might not work, as using React Hooks causes Invalid Hook Call -errors in tests.
1596
892
  switch (componentType) {
1597
893
  case 'CapWarningMap':
1598
894
  {
1599
895
  var _initialProps$mapPres, _initialProps$mapPres2;
1600
- return jsx(ApiProvider, {
1601
- config: {
1602
- baseURL: config.baseURL
1603
- },
1604
- createApi: createApi,
1605
- children: jsx(MapViewCapConnectWrapper, {
1606
- id: id,
1607
- bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
1608
- srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs,
1609
- layers: initialProps.mapPreset.layers,
1610
- productConfigKey: productConfigKey
1611
- })
896
+ return jsx(MapViewCapConnectWrapper, {
897
+ id: id,
898
+ bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
899
+ srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs,
900
+ layers: initialProps.mapPreset.layers,
901
+ productConfigKey: productConfigKey
1612
902
  });
1613
903
  }
1614
904
  case 'CapWarningList':
1615
905
  {
1616
- return jsx(ApiProvider, {
1617
- config: {
1618
- baseURL: config.baseURL
1619
- },
1620
- createApi: createApi,
1621
- children: jsx(WarningListCapConnectWrapper, {
1622
- productConfigKey: productConfigKey
1623
- })
906
+ return jsx(WarningListCapConnectWrapper, {
907
+ productConfigKey: productConfigKey
1624
908
  });
1625
909
  }
1626
910
  default:
@@ -1628,4 +912,41 @@ var ComponentsLookUp = function ComponentsLookUp(_ref) {
1628
912
  }
1629
913
  };
1630
914
 
1631
- export { CAP_NAMESPACE, ComponentsLookUp, capActions, capMiddlewares, capReducer, capReducersMap, selectors as capSelectors, capTrans as capTranslations, createMockStore, mockCapStateWithAlerts, mockCapStateWithFeeds };
915
+ /* *
916
+ * Licensed under the Apache License, Version 2.0 (the "License");
917
+ * you may not use this file except in compliance with the License.
918
+ * You may obtain a copy of the License at
919
+ *
920
+ * http://www.apache.org/licenses/LICENSE-2.0
921
+ *
922
+ * Unless required by applicable law or agreed to in writing, software
923
+ * distributed under the License is distributed on an "AS IS" BASIS,
924
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
925
+ * See the License for the specific language governing permissions and
926
+ * limitations under the License.
927
+ *
928
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
929
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
930
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
931
+ * */
932
+ var capReducersMap = {
933
+ webmap: mapReducer,
934
+ services: serviceReducer,
935
+ layers: layerReducer,
936
+ syncGroups: syncGroupsReducer
937
+ };
938
+ var capMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, syncGroupsListener.middleware, genericListener.middleware, openlayersListener.middleware];
939
+ var capRootReducer = combineReducers(capReducersMap);
940
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
941
+ var createMockStore = function createMockStore(mockState) {
942
+ return configureStore({
943
+ reducer: capRootReducer,
944
+ preloadedState: mockState,
945
+ middleware: function middleware(getDefaultMiddleware) {
946
+ return getDefaultMiddleware().concat(capMiddlewares);
947
+ },
948
+ devTools: true
949
+ });
950
+ };
951
+
952
+ export { CAP_NAMESPACE, ComponentsLookUp, capTrans as capTranslations, createMockStore };