@opengeoweb/cap 14.3.0 → 14.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/index.esm.js +820 -482
  2. package/package.json +9 -9
  3. package/src/lib/CapDemo.stories.d.ts +1 -2
  4. package/src/lib/components/ComponentsLookUp/componentsLookUp.d.ts +2 -2
  5. package/src/lib/components/GanttChart/Gantt.d.ts +1 -1
  6. package/src/lib/components/GanttChart/GanttModule.d.ts +1 -1
  7. package/src/lib/components/GanttChart/GanttWrapper.d.ts +1 -1
  8. package/src/lib/components/GanttChart/mockTasks.d.ts +1 -1
  9. package/src/lib/components/GanttChart/utils.d.ts +2 -2
  10. package/src/lib/components/MapViewCap/MapViewCapConnect.d.ts +2 -2
  11. package/src/lib/components/MapViewCap/MapViewCapConnectWrapper.d.ts +1 -1
  12. package/src/lib/components/Providers/Providers.d.ts +5 -5
  13. package/src/lib/components/WarningListCap/WarningListCap.d.ts +2 -2
  14. package/src/lib/components/WarningListCap/WarningListCapConnect.d.ts +1 -1
  15. package/src/lib/components/WarningListCap/WarningListRowCap/WarningListRowCapConnect.d.ts +2 -2
  16. package/src/lib/store/store.d.ts +3 -2
  17. package/src/lib/store/types.d.ts +1 -1
  18. package/src/lib/utils/addColors.d.ts +1 -1
  19. package/src/lib/utils/addFeedAddressToCustomGeoJsonFeature.d.ts +1 -1
  20. package/src/lib/utils/cap-api/api.d.ts +1 -1
  21. package/src/lib/utils/cap-api/hooks.d.ts +3 -3
  22. package/src/lib/utils/findEventIndexInLanguage.d.ts +1 -1
  23. package/src/lib/utils/highlightGeoJson.d.ts +2 -2
  24. package/src/lib/utils/i18n.d.ts +1 -1
  25. package/src/lib/utils/mockAlert.d.ts +1 -1
  26. package/src/lib/utils/mockCapData.d.ts +1 -1
  27. package/src/lib/utils/mockGeoJson.d.ts +1 -1
  28. package/src/lib/utils/mockGeoJsonMultipleFeatures.d.ts +1 -1
package/index.esm.js CHANGED
@@ -1,19 +1,19 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Grid, Typography, Box, LinearProgress, Card, CircularProgress } from '@mui/material';
3
- import { Box as Box$1 } from '@mui/system';
4
- import { dateUtils, AlertBanner, sessionStorageProvider, usePrevious } from '@opengeoweb/shared';
5
- import React, { useMemo } from 'react';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { CircularProgress, Grid, Typography, Box as Box$1, LinearProgress, Card } from '@mui/material';
3
+ import { Box } from '@mui/system';
4
+ import { sessionStorageProvider, dateUtils, usePrevious, AlertBanner } from '@opengeoweb/shared';
6
5
  import i18n from 'i18next';
7
- import { useTranslation } from 'react-i18next';
8
- import { ConfigurableMapConnect } from '@opengeoweb/core';
9
- import '@opengeoweb/time-slider';
10
- import { OpenLayersFeatureLayer, genericOpenLayersFeatureStyle, MapWarningProperties } from '@opengeoweb/webmap-react';
11
- import { useQuery, useQueries } from '@tanstack/react-query';
12
- import { handleResponse } from '@opengeoweb/api';
13
6
  import { GeoJSON } from 'ol/format';
7
+ import React, { useMemo } from 'react';
14
8
  import { useSelector } from 'react-redux';
9
+ import { ConfigurableMapConnect } from '@opengeoweb/core';
15
10
  import { mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, syncGroupsReducer, layerReducer, serviceReducer, mapReducer } from '@opengeoweb/store';
16
11
  import { webmapUtils } from '@opengeoweb/webmap';
12
+ import { OpenLayersFeatureLayer, genericOpenLayersFeatureStyle, MapWarningProperties } from '@opengeoweb/webmap-react';
13
+ import { useQuery, useQueries } from '@tanstack/react-query';
14
+ import { handleResponse } from '@opengeoweb/api';
15
+ import { useTranslation } from 'react-i18next';
16
+ import '@opengeoweb/time-slider';
17
17
  import { combineReducers, configureStore } from '@reduxjs/toolkit';
18
18
 
19
19
  var en = {
@@ -59,6 +59,9 @@ var capTrans = {
59
59
  nl: nl
60
60
  };
61
61
 
62
+ function _OverloadYield(e, d) {
63
+ this.v = e, this.k = d;
64
+ }
62
65
  function _arrayLikeToArray(r, a) {
63
66
  (null == a || a > r.length) && (a = r.length);
64
67
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -67,6 +70,31 @@ function _arrayLikeToArray(r, a) {
67
70
  function _arrayWithHoles(r) {
68
71
  if (Array.isArray(r)) return r;
69
72
  }
73
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
74
+ try {
75
+ var i = n[a](c),
76
+ u = i.value;
77
+ } catch (n) {
78
+ return void e(n);
79
+ }
80
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
81
+ }
82
+ function _asyncToGenerator(n) {
83
+ return function () {
84
+ var t = this,
85
+ e = arguments;
86
+ return new Promise(function (r, o) {
87
+ var a = n.apply(t, e);
88
+ function _next(n) {
89
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
90
+ }
91
+ function _throw(n) {
92
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
93
+ }
94
+ _next(void 0);
95
+ });
96
+ };
97
+ }
70
98
  function _createForOfIteratorHelper(r, e) {
71
99
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
72
100
  if (!t) {
@@ -171,6 +199,181 @@ function _objectSpread2(e) {
171
199
  }
172
200
  return e;
173
201
  }
202
+ function _regenerator() {
203
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
204
+ var e,
205
+ t,
206
+ r = "function" == typeof Symbol ? Symbol : {},
207
+ n = r.iterator || "@@iterator",
208
+ o = r.toStringTag || "@@toStringTag";
209
+ function i(r, n, o, i) {
210
+ var c = n && n.prototype instanceof Generator ? n : Generator,
211
+ u = Object.create(c.prototype);
212
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
213
+ var i,
214
+ c,
215
+ u,
216
+ f = 0,
217
+ p = o || [],
218
+ y = false,
219
+ G = {
220
+ p: 0,
221
+ n: 0,
222
+ v: e,
223
+ a: d,
224
+ f: d.bind(e, 4),
225
+ d: function (t, r) {
226
+ return i = t, c = 0, u = e, G.n = r, a;
227
+ }
228
+ };
229
+ function d(r, n) {
230
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
231
+ var o,
232
+ i = p[t],
233
+ d = G.p,
234
+ l = i[2];
235
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
236
+ }
237
+ if (o || r > 1) return a;
238
+ throw y = true, n;
239
+ }
240
+ return function (o, p, l) {
241
+ if (f > 1) throw TypeError("Generator is already running");
242
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
243
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
244
+ try {
245
+ if (f = 2, i) {
246
+ if (c || (o = "next"), t = i[o]) {
247
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
248
+ if (!t.done) return t;
249
+ u = t.value, c < 2 && (c = 0);
250
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
251
+ i = e;
252
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
253
+ } catch (t) {
254
+ i = e, c = 1, u = t;
255
+ } finally {
256
+ f = 1;
257
+ }
258
+ }
259
+ return {
260
+ value: t,
261
+ done: y
262
+ };
263
+ };
264
+ }(r, o, i), true), u;
265
+ }
266
+ var a = {};
267
+ function Generator() {}
268
+ function GeneratorFunction() {}
269
+ function GeneratorFunctionPrototype() {}
270
+ t = Object.getPrototypeOf;
271
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
272
+ return this;
273
+ }), t),
274
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
275
+ function f(e) {
276
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
277
+ }
278
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
279
+ return this;
280
+ }), _regeneratorDefine(u, "toString", function () {
281
+ return "[object Generator]";
282
+ }), (_regenerator = function () {
283
+ return {
284
+ w: i,
285
+ m: f
286
+ };
287
+ })();
288
+ }
289
+ function _regeneratorAsync(n, e, r, t, o) {
290
+ var a = _regeneratorAsyncGen(n, e, r, t, o);
291
+ return a.next().then(function (n) {
292
+ return n.done ? n.value : a.next();
293
+ });
294
+ }
295
+ function _regeneratorAsyncGen(r, e, t, o, n) {
296
+ return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
297
+ }
298
+ function _regeneratorAsyncIterator(t, e) {
299
+ function n(r, o, i, f) {
300
+ try {
301
+ var c = t[r](o),
302
+ u = c.value;
303
+ return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
304
+ n("next", t, i, f);
305
+ }, function (t) {
306
+ n("throw", t, i, f);
307
+ }) : e.resolve(u).then(function (t) {
308
+ c.value = t, i(c);
309
+ }, function (t) {
310
+ return n("throw", t, i, f);
311
+ });
312
+ } catch (t) {
313
+ f(t);
314
+ }
315
+ }
316
+ var r;
317
+ this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
318
+ return this;
319
+ })), _regeneratorDefine(this, "_invoke", function (t, o, i) {
320
+ function f() {
321
+ return new e(function (e, r) {
322
+ n(t, i, e, r);
323
+ });
324
+ }
325
+ return r = r ? r.then(f, f) : f();
326
+ }, true);
327
+ }
328
+ function _regeneratorDefine(e, r, n, t) {
329
+ var i = Object.defineProperty;
330
+ try {
331
+ i({}, "", {});
332
+ } catch (e) {
333
+ i = 0;
334
+ }
335
+ _regeneratorDefine = function (e, r, n, t) {
336
+ if (r) i ? i(e, r, {
337
+ value: n,
338
+ enumerable: !t,
339
+ configurable: !t,
340
+ writable: !t
341
+ }) : e[r] = n;else {
342
+ function o(r, n) {
343
+ _regeneratorDefine(e, r, function (e) {
344
+ return this._invoke(r, n, e);
345
+ });
346
+ }
347
+ o("next", 0), o("throw", 1), o("return", 2);
348
+ }
349
+ }, _regeneratorDefine(e, r, n, t);
350
+ }
351
+ function _regeneratorKeys(e) {
352
+ var n = Object(e),
353
+ r = [];
354
+ for (var t in n) r.unshift(t);
355
+ return function e() {
356
+ for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = false, e;
357
+ return e.done = true, e;
358
+ };
359
+ }
360
+ function _regeneratorValues(e) {
361
+ if (null != e) {
362
+ var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
363
+ r = 0;
364
+ if (t) return t.call(e);
365
+ if ("function" == typeof e.next) return e;
366
+ if (!isNaN(e.length)) return {
367
+ next: function () {
368
+ return e && r >= e.length && (e = void 0), {
369
+ value: e && e[r++],
370
+ done: !e
371
+ };
372
+ }
373
+ };
374
+ }
375
+ throw new TypeError(typeof e + " is not iterable");
376
+ }
174
377
  function _slicedToArray(r, e) {
175
378
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
176
379
  }
@@ -195,6 +398,344 @@ function _unsupportedIterableToArray(r, a) {
195
398
  return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
196
399
  }
197
400
  }
401
+ function _regeneratorRuntime() {
402
+
403
+ var r = _regenerator(),
404
+ e = r.m(_regeneratorRuntime),
405
+ t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
406
+ function n(r) {
407
+ var e = "function" == typeof r && r.constructor;
408
+ return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
409
+ }
410
+ var o = {
411
+ throw: 1,
412
+ return: 2,
413
+ break: 3,
414
+ continue: 3
415
+ };
416
+ function a(r) {
417
+ var e, t;
418
+ return function (n) {
419
+ e || (e = {
420
+ stop: function () {
421
+ return t(n.a, 2);
422
+ },
423
+ catch: function () {
424
+ return n.v;
425
+ },
426
+ abrupt: function (r, e) {
427
+ return t(n.a, o[r], e);
428
+ },
429
+ delegateYield: function (r, o, a) {
430
+ return e.resultName = o, t(n.d, _regeneratorValues(r), a);
431
+ },
432
+ finish: function (r) {
433
+ return t(n.f, r);
434
+ }
435
+ }, t = function (r, t, o) {
436
+ n.p = e.prev, n.n = e.next;
437
+ try {
438
+ return r(t, o);
439
+ } finally {
440
+ e.next = n.n;
441
+ }
442
+ }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
443
+ try {
444
+ return r.call(this, e);
445
+ } finally {
446
+ n.p = e.prev, n.n = e.next;
447
+ }
448
+ };
449
+ }
450
+ return (_regeneratorRuntime = function () {
451
+ return {
452
+ wrap: function (e, t, n, o) {
453
+ return r.w(a(e), t, n, o && o.reverse());
454
+ },
455
+ isGeneratorFunction: n,
456
+ mark: r.m,
457
+ awrap: function (r, e) {
458
+ return new _OverloadYield(r, e);
459
+ },
460
+ AsyncIterator: _regeneratorAsyncIterator,
461
+ async: function (r, e, t, o, u) {
462
+ return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
463
+ },
464
+ keys: _regeneratorKeys,
465
+ values: _regeneratorValues
466
+ };
467
+ })();
468
+ }
469
+
470
+ /* *
471
+ * Licensed under the Apache License, Version 2.0 (the "License");
472
+ * you may not use this file except in compliance with the License.
473
+ * You may obtain a copy of the License at
474
+ *
475
+ * http://www.apache.org/licenses/LICENSE-2.0
476
+ *
477
+ * Unless required by applicable law or agreed to in writing, software
478
+ * distributed under the License is distributed on an "AS IS" BASIS,
479
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480
+ * See the License for the specific language governing permissions and
481
+ * limitations under the License.
482
+ *
483
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
484
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
485
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
486
+ * */
487
+ var addColors = function addColors(features) {
488
+ var severityStyles = {
489
+ Extreme: {
490
+ stroke: 'rgb(255, 9, 9)',
491
+ fill: 'rgba(255, 9, 9, 0.10)'
492
+ },
493
+ Severe: {
494
+ stroke: 'rgb(255, 165, 0)',
495
+ fill: 'rgba(255, 165, 0, 0.10)'
496
+ },
497
+ Moderate: {
498
+ stroke: 'rgb(248, 248, 0)',
499
+ fill: 'rgba(248, 248, 0, 0.10)'
500
+ },
501
+ Minor: {
502
+ stroke: 'rgb(106, 248, 108)',
503
+ fill: 'rgba(106, 248, 108, 0.10)'
504
+ }
505
+ };
506
+ var _iterator = _createForOfIteratorHelper(features),
507
+ _step;
508
+ try {
509
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
510
+ var feature = _step.value;
511
+ var severity = feature.properties.details.severity;
512
+ feature.properties.stroke = severityStyles[severity].stroke;
513
+ feature.properties.fill = severityStyles[severity].fill;
514
+ feature.properties['stroke-opacity'] = 1;
515
+ feature.properties['stroke-width'] = 2;
516
+ }
517
+ } catch (err) {
518
+ _iterator.e(err);
519
+ } finally {
520
+ _iterator.f();
521
+ }
522
+ return features;
523
+ };
524
+
525
+ /* *
526
+ * Licensed under the Apache License, Version 2.0 (the "License");
527
+ * you may not use this file except in compliance with the License.
528
+ * You may obtain a copy of the License at
529
+ *
530
+ * http://www.apache.org/licenses/LICENSE-2.0
531
+ *
532
+ * Unless required by applicable law or agreed to in writing, software
533
+ * distributed under the License is distributed on an "AS IS" BASIS,
534
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
535
+ * See the License for the specific language governing permissions and
536
+ * limitations under the License.
537
+ *
538
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
539
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
540
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
541
+ * */
542
+ var addFeedAddressToCustomGeoJSonFeature = function addFeedAddressToCustomGeoJSonFeature(feedAddress, features) {
543
+ return features.reduce(function (list, feature) {
544
+ return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
545
+ properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
546
+ details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
547
+ feedAddress: feedAddress
548
+ })
549
+ })
550
+ }));
551
+ }, []);
552
+ };
553
+
554
+ var _config$GW_CAP_BASE_U;
555
+ var config = sessionStorageProvider.getConfig();
556
+ var capBaseUrl = (_config$GW_CAP_BASE_U = config.GW_CAP_BASE_URL) !== null && _config$GW_CAP_BASE_U !== void 0 ? _config$GW_CAP_BASE_U : '';
557
+ var getConfig = /*#__PURE__*/function () {
558
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(productConfigKey) {
559
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
560
+ while (1) switch (_context.prev = _context.next) {
561
+ case 0:
562
+ return _context.abrupt("return",
563
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
564
+ fetch("assets/".concat(encodeURIComponent(productConfigKey))).then(handleResponse));
565
+ case 1:
566
+ case "end":
567
+ return _context.stop();
568
+ }
569
+ }, _callee);
570
+ }));
571
+ return function getConfig(_x) {
572
+ return _ref.apply(this, arguments);
573
+ };
574
+ }();
575
+ var getFeedLinks = /*#__PURE__*/function () {
576
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(feedAddress) {
577
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
578
+ while (1) switch (_context2.prev = _context2.next) {
579
+ case 0:
580
+ return _context2.abrupt("return", fetch("".concat(capBaseUrl, "/feedlinks?url=").concat(encodeURIComponent(feedAddress))).then(handleResponse).then(function (result) {
581
+ return result.map(function (link) {
582
+ return {
583
+ link: link,
584
+ feedAddress: feedAddress
585
+ };
586
+ });
587
+ }));
588
+ case 1:
589
+ case "end":
590
+ return _context2.stop();
591
+ }
592
+ }, _callee2);
593
+ }));
594
+ return function getFeedLinks(_x2) {
595
+ return _ref2.apply(this, arguments);
596
+ };
597
+ }();
598
+ var getSingleAlert = /*#__PURE__*/function () {
599
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(alertUrl) {
600
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
601
+ while (1) switch (_context3.prev = _context3.next) {
602
+ case 0:
603
+ return _context3.abrupt("return", fetch("".concat(capBaseUrl, "/singlealert?url=").concat(encodeURIComponent(alertUrl.link))).then(handleResponse).then(function (result) {
604
+ var alert = _objectSpread2(_objectSpread2({}, result.alert), {}, {
605
+ feedAddress: alertUrl.feedAddress
606
+ });
607
+ var features = addFeedAddressToCustomGeoJSonFeature(alertUrl.feedAddress, result.features.features);
608
+ return {
609
+ alert: alert,
610
+ features: features
611
+ };
612
+ }));
613
+ case 1:
614
+ case "end":
615
+ return _context3.stop();
616
+ }
617
+ }, _callee3);
618
+ }));
619
+ return function getSingleAlert(_x3) {
620
+ return _ref3.apply(this, arguments);
621
+ };
622
+ }();
623
+
624
+ var useGetConfig = function useGetConfig(productConfigKey) {
625
+ return useQuery({
626
+ queryKey: ['cap-config', productConfigKey],
627
+ queryFn: function () {
628
+ var _queryFn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
629
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
630
+ while (1) switch (_context.prev = _context.next) {
631
+ case 0:
632
+ return _context.abrupt("return", getConfig(productConfigKey));
633
+ case 1:
634
+ case "end":
635
+ return _context.stop();
636
+ }
637
+ }, _callee);
638
+ }));
639
+ function queryFn() {
640
+ return _queryFn.apply(this, arguments);
641
+ }
642
+ return queryFn;
643
+ }()
644
+ });
645
+ };
646
+ var useAllFeedLinks = function useAllFeedLinks(capPresets) {
647
+ var queries = useMemo(function () {
648
+ return capPresets.feeds.map(function (feed) {
649
+ return {
650
+ queryKey: ['feedLinks', feed.feedAddress],
651
+ queryFn: function () {
652
+ var _queryFn2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
653
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
654
+ while (1) switch (_context2.prev = _context2.next) {
655
+ case 0:
656
+ return _context2.abrupt("return", getFeedLinks(feed.feedAddress));
657
+ case 1:
658
+ case "end":
659
+ return _context2.stop();
660
+ }
661
+ }, _callee2);
662
+ }));
663
+ function queryFn() {
664
+ return _queryFn2.apply(this, arguments);
665
+ }
666
+ return queryFn;
667
+ }(),
668
+ refetchInterval: capPresets.pollInterval
669
+ };
670
+ });
671
+ }, [capPresets]);
672
+ var results = useQueries({
673
+ queries: queries,
674
+ combine: function combine(results) {
675
+ return {
676
+ results: results.flatMap(function (result) {
677
+ return result.data;
678
+ }).filter(function (result) {
679
+ return !!result;
680
+ }),
681
+ pending: results.some(function (result) {
682
+ return result.isPending;
683
+ })
684
+ };
685
+ }
686
+ });
687
+ return results;
688
+ };
689
+ var useAllFeedAlerts = function useAllFeedAlerts(capPresets) {
690
+ var _useAllFeedLinks = useAllFeedLinks(capPresets),
691
+ allFeeds = _useAllFeedLinks.results,
692
+ allFeedPending = _useAllFeedLinks.pending;
693
+ var queries = useMemo(function () {
694
+ return allFeeds.map(function (feed) {
695
+ return {
696
+ queryKey: ['feedAlert', feed],
697
+ queryFn: function () {
698
+ var _queryFn3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
699
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
700
+ while (1) switch (_context3.prev = _context3.next) {
701
+ case 0:
702
+ return _context3.abrupt("return", getSingleAlert(feed));
703
+ case 1:
704
+ case "end":
705
+ return _context3.stop();
706
+ }
707
+ }, _callee3);
708
+ }));
709
+ function queryFn() {
710
+ return _queryFn3.apply(this, arguments);
711
+ }
712
+ return queryFn;
713
+ }()
714
+ };
715
+ });
716
+ }, [allFeeds]);
717
+ var _useQueries = useQueries({
718
+ queries: queries,
719
+ combine: function combine(results) {
720
+ return {
721
+ alertResults: results.map(function (result) {
722
+ return result.data;
723
+ }).filter(function (result) {
724
+ return !!result;
725
+ }),
726
+ pending: results.some(function (result) {
727
+ return result.isPending;
728
+ })
729
+ };
730
+ }
731
+ }),
732
+ alertResults = _useQueries.alertResults,
733
+ alertsPending = _useQueries.pending;
734
+ return {
735
+ results: alertResults,
736
+ pending: allFeedPending || alertsPending
737
+ };
738
+ };
198
739
 
199
740
  /* *
200
741
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -249,458 +790,23 @@ var findEventIndexInLanguage = function findEventIndexInLanguage(language, langu
249
790
  * See the License for the specific language governing permissions and
250
791
  * limitations under the License.
251
792
  *
252
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
253
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
793
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
794
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
254
795
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
255
796
  * */
256
- var CAP_NAMESPACE = 'cap';
257
- var useCapTranslation = function useCapTranslation() {
258
- return useTranslation(CAP_NAMESPACE);
259
- };
260
-
261
- var severityStyles = {
262
- Extreme: {
263
- border: 'solid 5px rgb(255, 9, 9)',
264
- background: 'rgba(255, 9, 9, 0.15)'
265
- },
266
- Severe: {
267
- border: 'solid 5px rgb(255, 165, 0)',
268
- background: 'rgba(255, 165, 0, 0.15)'
269
- },
270
- Moderate: {
271
- border: 'solid 5px rgb(248, 248, 0)',
272
- background: 'rgba(248, 248, 0, 0.15)'
273
- },
274
- Minor: {
275
- border: 'solid 5px rgb(106, 248, 108)',
276
- background: 'rgba(106, 248, 108, 0.15)'
277
- }
278
- };
279
- var WarningListRowCap = function WarningListRowCap(_ref) {
280
- var event = _ref.event,
281
- severity = _ref.severity,
282
- expires = _ref.expires;
283
- var _useCapTranslation = useCapTranslation(),
284
- t = _useCapTranslation.t;
285
- return jsxs(Grid, {
286
- container: true,
287
- sx: {
288
- border: severityStyles[severity].border,
289
- background: severityStyles[severity].background,
290
- padding: '5px',
291
- marginTop: '20px',
292
- marginBottom: '20px',
293
- width: '100%'
294
- },
295
- children: [jsxs(Grid, {
296
- size: {
297
- xs: 4
298
- },
299
- children: [jsx(Typography, {
300
- variant: "overline",
301
- children: t('warning-list-row-event')
302
- }), jsx(Typography, {
303
- variant: "subtitle2",
304
- sx: {
305
- fontWeight: 'normal'
306
- },
307
- "data-testid": "event",
308
- children: event || ''
309
- })]
310
- }), jsxs(Grid, {
311
- size: {
312
- xs: 4
313
- },
314
- children: [jsx(Typography, {
315
- variant: "overline",
316
- children: t('warning-list-row-severity')
317
- }), jsx(Typography, {
318
- variant: "subtitle2",
319
- sx: {
320
- fontWeight: 'normal'
321
- },
322
- "data-testid": "severity",
323
- children: severity || ''
324
- })]
325
- }), jsxs(Grid, {
326
- size: {
327
- xs: 4
328
- },
329
- children: [jsx(Typography, {
330
- variant: "overline",
331
- children: t('warning-list-row-expires')
332
- }), jsx(Typography, {
333
- variant: "subtitle2",
334
- sx: {
335
- fontWeight: 'normal'
336
- },
337
- "data-testid": "expires",
338
- children: expires ? dateUtils.dateToString(dateUtils.createDate(expires), "dd MMM yyyy, HH:mm 'UTC'") : t('warning-list-row-not-expired')
339
- })]
340
- })]
341
- });
342
- };
343
-
344
- var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
345
- var _alert$languages;
346
- var alert = _ref.alert,
347
- capWarningPresets = _ref.capWarningPresets;
348
- var _React$useState = React.useState(0),
349
- _React$useState2 = _slicedToArray(_React$useState, 2),
350
- languageIndex = _React$useState2[0],
351
- setLanguageIndex = _React$useState2[1];
352
- var alertHasLanguages = Boolean(alert === null || alert === void 0 || (_alert$languages = alert.languages) === null || _alert$languages === void 0 ? void 0 : _alert$languages.length);
353
- var language = i18n.language;
354
- React.useEffect(function () {
355
- if (alert && alertHasLanguages) {
356
- var foundLanguageIndex = findEventIndexInLanguage(language, alert.languages, capWarningPresets, alert.feedAddress);
357
- setLanguageIndex(foundLanguageIndex);
358
- }
359
- }, [alert, language, alertHasLanguages, capWarningPresets]);
360
- return jsx("div", {
361
- children: alert && alertHasLanguages && jsx(WarningListRowCap, {
362
- event: alert.languages[languageIndex].event,
363
- severity: alert.severity,
364
- expires: alert.expires
365
- })
366
- });
367
- };
368
-
369
- var WarningListCap = function WarningListCap(_ref) {
370
- var capWarningPresets = _ref.capWarningPresets,
371
- alerts = _ref.alerts,
372
- _ref$isPending = _ref.isPending,
373
- isPending = _ref$isPending === void 0 ? false : _ref$isPending;
374
- var _useCapTranslation = useCapTranslation(),
375
- t = _useCapTranslation.t;
376
- return jsxs(Box, {
377
- sx: {
378
- width: '100%',
379
- height: '100%',
380
- display: 'flex'
381
- },
382
- children: [isPending && jsx(LinearProgress, {
383
- color: "secondary",
384
- sx: {
385
- position: 'absolute',
386
- width: '100%'
387
- }
388
- }), jsxs(Card, {
389
- sx: {
390
- justifyContent: 'center',
391
- alignItems: 'center',
392
- overflow: 'auto',
393
- height: '95%',
394
- width: '100%',
395
- padding: '10px',
396
- margin: '20px',
397
- marginBottom: '10px',
398
- position: 'relative'
399
- },
400
- "data-testid": "warningList",
401
- children: [!isPending && !alerts.length && jsx(AlertBanner, {
402
- title: "No results",
403
- severity: "warning"
404
- }), alerts.length > 0 && jsx(Box, {
405
- sx: {
406
- position: 'sticky',
407
- top: 0,
408
- width: '100%',
409
- display: 'flex',
410
- justifyContent: 'center'
411
- },
412
- children: jsx(AlertBanner, {
413
- title: t('warning-list-cap-alert-banner-title'),
414
- severity: "info"
415
- })
416
- }), alerts.map(function (alert) {
417
- return jsx(WarningListRowCapConnect, {
418
- alert: alert,
419
- capWarningPresets: capWarningPresets
420
- }, alert.identifier);
421
- })]
422
- })]
423
- });
424
- };
425
-
426
- /* *
427
- * Licensed under the Apache License, Version 2.0 (the "License");
428
- * you may not use this file except in compliance with the License.
429
- * You may obtain a copy of the License at
430
- *
431
- * http://www.apache.org/licenses/LICENSE-2.0
432
- *
433
- * Unless required by applicable law or agreed to in writing, software
434
- * distributed under the License is distributed on an "AS IS" BASIS,
435
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
436
- * See the License for the specific language governing permissions and
437
- * limitations under the License.
438
- *
439
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
440
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
441
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
442
- * */
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
- }, []);
453
- };
454
-
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
- });
481
- };
482
-
483
- /* *
484
- * Licensed under the Apache License, Version 2.0 (the "License");
485
- * you may not use this file except in compliance with the License.
486
- * You may obtain a copy of the License at
487
- *
488
- * http://www.apache.org/licenses/LICENSE-2.0
489
- *
490
- * Unless required by applicable law or agreed to in writing, software
491
- * distributed under the License is distributed on an "AS IS" BASIS,
492
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
493
- * See the License for the specific language governing permissions and
494
- * limitations under the License.
495
- *
496
- * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
497
- * Copyright 2025 - Finnish Meteorological Institute (FMI)
498
- * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
499
- * */
500
- var useGetConfig = function useGetConfig(productConfigKey) {
501
- return useQuery({
502
- queryKey: ['cap-config', productConfigKey],
503
- queryFn: function queryFn() {
504
- return getConfig(productConfigKey);
505
- }
506
- });
507
- };
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
- };
533
- }
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
- };
572
- };
573
-
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
- });
586
- };
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
616
- });
617
- };
618
-
619
- /* *
620
- * Licensed under the Apache License, Version 2.0 (the "License");
621
- * you may not use this file except in compliance with the License.
622
- * You may obtain a copy of the License at
623
- *
624
- * http://www.apache.org/licenses/LICENSE-2.0
625
- *
626
- * Unless required by applicable law or agreed to in writing, software
627
- * distributed under the License is distributed on an "AS IS" BASIS,
628
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629
- * See the License for the specific language governing permissions and
630
- * limitations under the License.
631
- *
632
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
633
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
634
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
635
- * */
636
- var highlightGeoJson = function highlightGeoJson(currentFeatures, featureResults) {
637
- return Object.entries(currentFeatures).reduce(function (byId, _ref) {
638
- var _ref2 = _slicedToArray(_ref, 2),
639
- alertId = _ref2[0],
640
- features = _ref2[1];
641
- var isSelected = alertId === (featureResults === null || featureResults === void 0 ? void 0 : featureResults.feature.properties.details.identifier);
642
- return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alertId, features.map(function (feature) {
643
- var recoloredFeature = _objectSpread2({}, feature);
644
- recoloredFeature.properties.fill = isSelected ? feature.properties.fill.replace('0.10', '0.25') : recoloredFeature.properties.fill = feature.properties.fill.replace('0.25', '0.10');
645
- recoloredFeature.properties['stroke-width'] = isSelected ? 3 : 2;
646
- return recoloredFeature;
647
- })));
648
- }, {});
649
- };
650
-
651
- /* *
652
- * Licensed under the Apache License, Version 2.0 (the "License");
653
- * you may not use this file except in compliance with the License.
654
- * You may obtain a copy of the License at
655
- *
656
- * http://www.apache.org/licenses/LICENSE-2.0
657
- *
658
- * Unless required by applicable law or agreed to in writing, software
659
- * distributed under the License is distributed on an "AS IS" BASIS,
660
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
661
- * See the License for the specific language governing permissions and
662
- * limitations under the License.
663
- *
664
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
665
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
666
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
667
- * */
668
- var addColors = function addColors(features) {
669
- var severityStyles = {
670
- Extreme: {
671
- stroke: 'rgb(255, 9, 9)',
672
- fill: 'rgba(255, 9, 9, 0.10)'
673
- },
674
- Severe: {
675
- stroke: 'rgb(255, 165, 0)',
676
- fill: 'rgba(255, 165, 0, 0.10)'
677
- },
678
- Moderate: {
679
- stroke: 'rgb(248, 248, 0)',
680
- fill: 'rgba(248, 248, 0, 0.10)'
681
- },
682
- Minor: {
683
- stroke: 'rgb(106, 248, 108)',
684
- fill: 'rgba(106, 248, 108, 0.10)'
685
- }
686
- };
687
- var _iterator = _createForOfIteratorHelper(features),
688
- _step;
689
- try {
690
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
691
- var feature = _step.value;
692
- var severity = feature.properties.details.severity;
693
- feature.properties.stroke = severityStyles[severity].stroke;
694
- feature.properties.fill = severityStyles[severity].fill;
695
- feature.properties['stroke-opacity'] = 1;
696
- feature.properties['stroke-width'] = 2;
697
- }
698
- } catch (err) {
699
- _iterator.e(err);
700
- } finally {
701
- _iterator.f();
702
- }
703
- return features;
797
+ var highlightGeoJson = function highlightGeoJson(currentFeatures, featureResults) {
798
+ return Object.entries(currentFeatures).reduce(function (byId, _ref) {
799
+ var _ref2 = _slicedToArray(_ref, 2),
800
+ alertId = _ref2[0],
801
+ features = _ref2[1];
802
+ var isSelected = alertId === (featureResults === null || featureResults === void 0 ? void 0 : featureResults.feature.properties.details.identifier);
803
+ return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alertId, features.map(function (feature) {
804
+ var recoloredFeature = _objectSpread2({}, feature);
805
+ recoloredFeature.properties.fill = isSelected ? feature.properties.fill.replace('0.10', '0.25') : recoloredFeature.properties.fill = feature.properties.fill.replace('0.25', '0.10');
806
+ recoloredFeature.properties['stroke-width'] = isSelected ? 3 : 2;
807
+ return recoloredFeature;
808
+ })));
809
+ }, {});
704
810
  };
705
811
 
706
812
  var MapViewCapConnect = function MapViewCapConnect(_ref) {
@@ -721,6 +827,7 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
721
827
  _React$useState4 = _slicedToArray(_React$useState3, 2),
722
828
  selectedFeatureEvent = _React$useState4[0],
723
829
  setSelectedFeatureEvent = _React$useState4[1];
830
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
724
831
  var mapIdRef = React.useRef(id || webmapUtils.generateMapId());
725
832
  var parentSizeRef = React.useRef(null);
726
833
  var _React$useState5 = React.useState(window.innerWidth / 2),
@@ -797,34 +904,56 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
797
904
  }, [featuresByAlert]);
798
905
  return jsx("div", {
799
906
  "data-testid": "mapViewCap",
907
+ ref: parentSizeRef,
800
908
  style: {
801
909
  height: '100%',
802
910
  width: '100%'
803
911
  },
804
- ref: parentSizeRef,
805
912
  children: jsxs(ConfigurableMapConnect, {
806
- id: mapIdRef.current,
807
- title: title,
808
- layers: layers || [],
809
913
  "data-testid": "capWarningMap",
914
+ id: mapIdRef.current,
810
915
  initialBbox: bbox,
916
+ layers: layers !== null && layers !== void 0 ? layers : [],
811
917
  srs: srs,
918
+ title: title,
812
919
  children: [jsx(OpenLayersFeatureLayer, {
920
+ clickOnFeature: clickOnFeature,
813
921
  featureCollection: geoJsonObject,
814
922
  style: genericOpenLayersFeatureStyle,
815
- clickOnFeature: clickOnFeature,
816
- zIndex: 1000,
817
- testId: "MapViewCap-features"
818
- }), selectedFeatureEvent && jsx(MapWarningProperties, {
923
+ testId: "MapViewCap-features",
924
+ zIndex: 1000
925
+ }), selectedFeatureEvent ? jsx(MapWarningProperties, {
819
926
  "data-testid": "mapWarnings",
820
- selectedFeatureProperties: selectedFeatureEvent.feature.properties.details,
821
927
  languageIndex: findEventIndexInLanguage(i18n.language, selectedFeatureEvent.feature.properties.details.languages, capWarningPresets, selectedFeatureEvent.feature.properties.details.feedAddress),
822
- parentSize: parentSize
823
- }), children]
928
+ parentSize: parentSize,
929
+ selectedFeatureProperties: selectedFeatureEvent.feature.properties.details
930
+ }) : null, children]
824
931
  })
825
932
  });
826
933
  };
827
934
 
935
+ /* *
936
+ * Licensed under the Apache License, Version 2.0 (the "License");
937
+ * you may not use this file except in compliance with the License.
938
+ * You may obtain a copy of the License at
939
+ *
940
+ * http://www.apache.org/licenses/LICENSE-2.0
941
+ *
942
+ * Unless required by applicable law or agreed to in writing, software
943
+ * distributed under the License is distributed on an "AS IS" BASIS,
944
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
945
+ * See the License for the specific language governing permissions and
946
+ * limitations under the License.
947
+ *
948
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
949
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
950
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
951
+ * */
952
+ var CAP_NAMESPACE = 'cap';
953
+ var useCapTranslation = function useCapTranslation() {
954
+ return useTranslation(CAP_NAMESPACE);
955
+ };
956
+
828
957
  var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
829
958
  var id = _ref.id,
830
959
  title = _ref.title,
@@ -839,7 +968,7 @@ var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
839
968
  isPending = _useGetConfig.isPending,
840
969
  error = _useGetConfig.error;
841
970
  if (isPending) {
842
- return jsx(Box$1, {
971
+ return jsx(Box, {
843
972
  sx: {
844
973
  display: 'flex',
845
974
  justifyContent: 'center',
@@ -852,17 +981,227 @@ var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
852
981
  }
853
982
  if (error) {
854
983
  return jsx(AlertBanner, {
855
- title: t('map-view-cap-error-title'),
856
- info: error.message
984
+ info: error.message,
985
+ title: t('map-view-cap-error-title')
857
986
  });
858
987
  }
859
988
  return jsx(MapViewCapConnect, {
989
+ bbox: bbox,
860
990
  capWarningPresets: capWarningPresets,
861
991
  id: id,
862
- title: title,
863
- bbox: bbox,
992
+ layers: layers,
864
993
  srs: srs,
865
- layers: layers
994
+ title: title
995
+ });
996
+ };
997
+
998
+ var severityStyles = {
999
+ Extreme: {
1000
+ border: 'solid 5px rgb(255, 9, 9)',
1001
+ background: 'rgba(255, 9, 9, 0.15)'
1002
+ },
1003
+ Severe: {
1004
+ border: 'solid 5px rgb(255, 165, 0)',
1005
+ background: 'rgba(255, 165, 0, 0.15)'
1006
+ },
1007
+ Moderate: {
1008
+ border: 'solid 5px rgb(248, 248, 0)',
1009
+ background: 'rgba(248, 248, 0, 0.15)'
1010
+ },
1011
+ Minor: {
1012
+ border: 'solid 5px rgb(106, 248, 108)',
1013
+ background: 'rgba(106, 248, 108, 0.15)'
1014
+ }
1015
+ };
1016
+ var WarningListRowCap = function WarningListRowCap(_ref) {
1017
+ var event = _ref.event,
1018
+ severity = _ref.severity,
1019
+ expires = _ref.expires;
1020
+ var _useCapTranslation = useCapTranslation(),
1021
+ t = _useCapTranslation.t;
1022
+ return jsxs(Grid, {
1023
+ container: true,
1024
+ sx: {
1025
+ border: severityStyles[severity].border,
1026
+ background: severityStyles[severity].background,
1027
+ padding: '5px',
1028
+ marginTop: '20px',
1029
+ marginBottom: '20px',
1030
+ width: '100%'
1031
+ },
1032
+ children: [jsxs(Grid, {
1033
+ size: {
1034
+ xs: 4
1035
+ },
1036
+ children: [jsx(Typography, {
1037
+ variant: "overline",
1038
+ children: t('warning-list-row-event')
1039
+ }), jsx(Typography, {
1040
+ "data-testid": "event",
1041
+ sx: {
1042
+ fontWeight: 'normal'
1043
+ },
1044
+ variant: "subtitle2",
1045
+ children: event || ''
1046
+ })]
1047
+ }), jsxs(Grid, {
1048
+ size: {
1049
+ xs: 4
1050
+ },
1051
+ children: [jsx(Typography, {
1052
+ variant: "overline",
1053
+ children: t('warning-list-row-severity')
1054
+ }), jsx(Typography, {
1055
+ "data-testid": "severity",
1056
+ sx: {
1057
+ fontWeight: 'normal'
1058
+ },
1059
+ variant: "subtitle2",
1060
+ children: severity || ''
1061
+ })]
1062
+ }), jsxs(Grid, {
1063
+ size: {
1064
+ xs: 4
1065
+ },
1066
+ children: [jsx(Typography, {
1067
+ variant: "overline",
1068
+ children: t('warning-list-row-expires')
1069
+ }), jsx(Typography, {
1070
+ "data-testid": "expires",
1071
+ sx: {
1072
+ fontWeight: 'normal'
1073
+ },
1074
+ variant: "subtitle2",
1075
+ children: expires ? dateUtils.dateToString(dateUtils.createDate(expires), "dd MMM yyyy, HH:mm 'UTC'") : t('warning-list-row-not-expired')
1076
+ })]
1077
+ })]
1078
+ });
1079
+ };
1080
+
1081
+ var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
1082
+ var _alert$languages;
1083
+ var alert = _ref.alert,
1084
+ capWarningPresets = _ref.capWarningPresets;
1085
+ var _React$useState = React.useState(0),
1086
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1087
+ languageIndex = _React$useState2[0],
1088
+ setLanguageIndex = _React$useState2[1];
1089
+ var alertHasLanguages = Boolean(alert === null || alert === void 0 || (_alert$languages = alert.languages) === null || _alert$languages === void 0 ? void 0 : _alert$languages.length);
1090
+ var language = i18n.language;
1091
+ React.useEffect(function () {
1092
+ if (alert && alertHasLanguages) {
1093
+ var foundLanguageIndex = findEventIndexInLanguage(language, alert.languages, capWarningPresets, alert.feedAddress);
1094
+ setLanguageIndex(foundLanguageIndex);
1095
+ }
1096
+ }, [alert, language, alertHasLanguages, capWarningPresets]);
1097
+ return jsx("div", {
1098
+ children: alert && alertHasLanguages ? jsx(WarningListRowCap, {
1099
+ event: alert.languages[languageIndex].event,
1100
+ expires: alert.expires,
1101
+ severity: alert.severity
1102
+ }) : null
1103
+ });
1104
+ };
1105
+
1106
+ var WarningListCap = function WarningListCap(_ref) {
1107
+ var capWarningPresets = _ref.capWarningPresets,
1108
+ alerts = _ref.alerts,
1109
+ _ref$isPending = _ref.isPending,
1110
+ isPending = _ref$isPending === void 0 ? false : _ref$isPending;
1111
+ var _useCapTranslation = useCapTranslation(),
1112
+ t = _useCapTranslation.t;
1113
+ return jsxs(Box$1, {
1114
+ sx: {
1115
+ width: '100%',
1116
+ height: '100%',
1117
+ display: 'flex'
1118
+ },
1119
+ children: [isPending ? jsx(LinearProgress, {
1120
+ color: "secondary",
1121
+ sx: {
1122
+ position: 'absolute',
1123
+ width: '100%'
1124
+ }
1125
+ }) : null, jsxs(Card, {
1126
+ "data-testid": "warningList",
1127
+ sx: {
1128
+ justifyContent: 'center',
1129
+ alignItems: 'center',
1130
+ overflow: 'auto',
1131
+ height: '95%',
1132
+ width: '100%',
1133
+ padding: '10px',
1134
+ margin: '20px',
1135
+ marginBottom: '10px',
1136
+ position: 'relative'
1137
+ },
1138
+ children: [!isPending && !alerts.length && jsx(AlertBanner, {
1139
+ severity: "warning",
1140
+ title: "No results"
1141
+ }), alerts.length > 0 && jsx(Box$1, {
1142
+ sx: {
1143
+ position: 'sticky',
1144
+ top: 0,
1145
+ width: '100%',
1146
+ display: 'flex',
1147
+ justifyContent: 'center'
1148
+ },
1149
+ children: jsx(AlertBanner, {
1150
+ severity: "info",
1151
+ title: t('warning-list-cap-alert-banner-title')
1152
+ })
1153
+ }), alerts.map(function (alert) {
1154
+ return jsx(WarningListRowCapConnect, {
1155
+ alert: alert,
1156
+ capWarningPresets: capWarningPresets
1157
+ }, alert.identifier);
1158
+ })]
1159
+ })]
1160
+ });
1161
+ };
1162
+
1163
+ var WarningListCapConnect = function WarningListCapConnect(_ref) {
1164
+ var capWarningPresets = _ref.capWarningPresets;
1165
+ var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
1166
+ feedAlerts = _useAllFeedAlerts.results,
1167
+ pending = _useAllFeedAlerts.pending;
1168
+ return jsx(WarningListCap, {
1169
+ alerts: feedAlerts.map(function (fa) {
1170
+ return fa.alert;
1171
+ }),
1172
+ capWarningPresets: capWarningPresets,
1173
+ isPending: pending
1174
+ });
1175
+ };
1176
+
1177
+ var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
1178
+ var productConfigKey = _ref.productConfigKey;
1179
+ var _useCapTranslation = useCapTranslation(),
1180
+ t = _useCapTranslation.t;
1181
+ var _useGetConfig = useGetConfig(productConfigKey),
1182
+ productConfig = _useGetConfig.data,
1183
+ isPending = _useGetConfig.isPending,
1184
+ error = _useGetConfig.error;
1185
+ if (isPending) {
1186
+ return jsx(Box, {
1187
+ sx: {
1188
+ display: 'flex',
1189
+ justifyContent: 'center',
1190
+ alignItems: 'center'
1191
+ },
1192
+ children: jsx(CircularProgress, {
1193
+ "data-testid": "loadingSpinner"
1194
+ })
1195
+ });
1196
+ }
1197
+ if (error) {
1198
+ return jsx(AlertBanner, {
1199
+ info: error.message,
1200
+ title: t('warning-list-cap-error-title')
1201
+ });
1202
+ }
1203
+ return jsx(WarningListCapConnect, {
1204
+ capWarningPresets: productConfig
866
1205
  });
867
1206
  };
868
1207
 
@@ -881,11 +1220,11 @@ var ComponentsLookUp = function ComponentsLookUp(_ref) {
881
1220
  {
882
1221
  var _initialProps$mapPres, _initialProps$mapPres2;
883
1222
  return jsx(MapViewCapConnectWrapper, {
884
- id: id,
885
1223
  bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
886
- srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs,
1224
+ id: id,
887
1225
  layers: initialProps.mapPreset.layers,
888
- productConfigKey: productConfigKey
1226
+ productConfigKey: productConfigKey,
1227
+ srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs
889
1228
  });
890
1229
  }
891
1230
  case 'CapWarningList':
@@ -924,7 +1263,6 @@ var capReducersMap = {
924
1263
  };
925
1264
  var capMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, syncGroupsListener.middleware, genericListener.middleware, openlayersListener.middleware];
926
1265
  var capRootReducer = combineReducers(capReducersMap);
927
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
928
1266
  var createMockStore = function createMockStore(mockState) {
929
1267
  return configureStore({
930
1268
  reducer: capRootReducer,