@opengeoweb/store 9.9.0 → 9.10.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.
package/index.esm.js CHANGED
@@ -1,16 +1,16 @@
1
- import { current, produce } from 'immer';
2
- import { webmapUtils, LayerType, webmapTestSettings, WMLayer, handleMomentISOString, getCapabilities } from '@opengeoweb/webmap';
3
- import { createAction, createSlice, createSelector, createEntityAdapter } from '@reduxjs/toolkit';
1
+ import { webmapUtils, LayerType, webmapTestSettings, WMLayer, getWMJSMapById, getMapImageStore, getAlternativeImage, handleMomentISOString, getCapabilities } from '@opengeoweb/webmap';
2
+ import { createAction, createSlice, createSelector, createEntityAdapter, createListenerMiddleware } from '@reduxjs/toolkit';
4
3
  import { getGeoJson, moveFeature, createInterSections, getLastEmptyFeatureIndex, defaultLayers, addSelectionTypeToGeoJSON, getFeatureCollection, emptyGeoJSON, defaultIntersectionStyleProperties } from '@opengeoweb/webmap-react';
5
4
  export { defaultLayers } from '@opengeoweb/webmap-react';
6
- import { dateUtils, withEggs } from '@opengeoweb/shared';
5
+ import { dateUtils, metronome, withEggs } from '@opengeoweb/shared';
6
+ import { produce } from 'immer';
7
7
  import { isEqual, compact } from 'lodash';
8
8
  import { createStore as createStore$1 } from '@redux-eggs/redux-toolkit';
9
9
  import { getSagaExtension } from '@redux-eggs/saga-extension';
10
- import { takeEvery, takeLatest, put, select, call, all, delay } from 'redux-saga/effects';
10
+ import { call, takeEvery, takeLatest, select, put, all, take, delay } from 'redux-saga/effects';
11
+ import { eventChannel } from 'redux-saga';
11
12
  import React, { useCallback, useEffect } from 'react';
12
13
  import { Provider, useDispatch, useSelector } from 'react-redux';
13
- import { ThemeWrapper, lightTheme } from '@opengeoweb/theme';
14
14
 
15
15
  function _iterableToArrayLimit(r, l) {
16
16
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
@@ -481,6 +481,16 @@ function __rest(s, e) {
481
481
  return t;
482
482
  }
483
483
 
484
+ function __awaiter(thisArg, _arguments, P, generator) {
485
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
486
+ return new (P || (P = Promise))(function (resolve, reject) {
487
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
488
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
489
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
490
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
491
+ });
492
+ }
493
+
484
494
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
485
495
  var e = new Error(message);
486
496
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -1157,10 +1167,10 @@ var setBbox = createAction('GENERIC_SETBBOX');
1157
1167
  *
1158
1168
  * These actions should not be used by components directly. Components should only use the generic actions.
1159
1169
  */
1160
- var setTimeSync = createAction('GENERIC_SYNC_SETTIME', function (payload, targets, groups) {
1170
+ var setTimeSync = createAction('GENERIC_SYNC_SETTIME', function (setTimePayload, targets, groups) {
1161
1171
  return {
1162
1172
  payload: {
1163
- source: setTime(payload),
1173
+ source: setTimePayload && setTime(setTimePayload),
1164
1174
  groups: groups,
1165
1175
  targets: targets
1166
1176
  }
@@ -1584,18 +1594,18 @@ var slice$7 = createSlice({
1584
1594
  _action$payload17$rea = _action$payload17.reason,
1585
1595
  reason = _action$payload17$rea === void 0 ? '' : _action$payload17$rea,
1586
1596
  geoJSONIntersectionLayerId = _action$payload17.geoJSONIntersectionLayerId,
1587
- geoJSONIntersectionBoundsLayerId = _action$payload17.geoJSONIntersectionBoundsLayerId;
1597
+ geoJSONIntersectionBoundsLayerId = _action$payload17.geoJSONIntersectionBoundsLayerId,
1598
+ selectionType = _action$payload17.selectionType;
1588
1599
  var currentLayer = draft.byId[layerId];
1589
1600
  if (!currentLayer) {
1590
1601
  return;
1591
1602
  }
1592
1603
  var updatedGeoJSON = getGeoJson(geojson, shouldAllowMultipleShapes);
1593
1604
  if (shouldAllowMultipleShapes) {
1594
- var _current = current(currentLayer),
1595
- currentGeoJSON = _current.geojson,
1596
- _current$selectedFeat = _current.selectedFeatureIndex,
1597
- selectedFeatureIndex = _current$selectedFeat === void 0 ? 0 : _current$selectedFeat;
1598
- var newFeatureIndex = moveFeature(currentGeoJSON, updatedGeoJSON, selectedFeatureIndex, reason);
1605
+ var currentGeoJSON = currentLayer.geojson,
1606
+ _currentLayer$selecte = currentLayer.selectedFeatureIndex,
1607
+ selectedFeatureIndex = _currentLayer$selecte === void 0 ? 0 : _currentLayer$selecte;
1608
+ var newFeatureIndex = moveFeature(currentGeoJSON, updatedGeoJSON, selectedFeatureIndex, reason, selectionType);
1599
1609
  if (newFeatureIndex !== undefined) {
1600
1610
  currentLayer.selectedFeatureIndex = newFeatureIndex;
1601
1611
  }
@@ -1607,8 +1617,8 @@ var slice$7 = createSlice({
1607
1617
  if (!intersectionLayer || !intersectionBoundsLayer) {
1608
1618
  return;
1609
1619
  }
1610
- var bounds = current(intersectionBoundsLayer).geojson;
1611
- var geoJSONProperties = current(intersectionLayer).defaultGeoJSONProperties || ((_b = (_a = current(currentLayer).geojson) === null || _a === void 0 ? void 0 : _a.features[0]) === null || _b === void 0 ? void 0 : _b.properties);
1620
+ var bounds = intersectionBoundsLayer.geojson;
1621
+ var geoJSONProperties = intersectionLayer.defaultGeoJSONProperties || ((_b = (_a = currentLayer.geojson) === null || _a === void 0 ? void 0 : _a.features[0]) === null || _b === void 0 ? void 0 : _b.properties);
1612
1622
  intersectionLayer.geojson = createInterSections(updatedGeoJSON, bounds, geoJSONProperties);
1613
1623
  }
1614
1624
  },
@@ -1659,7 +1669,7 @@ var slice$7 = createSlice({
1659
1669
  draft.byId[layerId].isInEditMode = false;
1660
1670
  draft.byId[layerId].drawMode = '';
1661
1671
  if (exitMultipleShapes) {
1662
- var currentGeoJSON = current(draft.byId[layerId].geojson);
1672
+ var currentGeoJSON = draft.byId[layerId].geojson;
1663
1673
  var lastFeatureIndex = currentGeoJSON !== undefined && getLastEmptyFeatureIndex(currentGeoJSON);
1664
1674
  if (currentGeoJSON && lastFeatureIndex !== undefined) {
1665
1675
  var newGeoJSON = Object.assign(Object.assign({}, currentGeoJSON), {
@@ -1680,10 +1690,13 @@ var slice$7 = createSlice({
1680
1690
  targetsFromAction = _action$payload21.targets,
1681
1691
  source = _action$payload21.source;
1682
1692
  /* Because we want backwards compatibility with the previous code, we also need to listen to the original source action */
1683
- var targets = [{
1684
- targetId: source.payload.sourceId,
1685
- value: source.payload.value
1686
- }];
1693
+ var targets = [];
1694
+ if (source) {
1695
+ targets.push({
1696
+ targetId: source.payload.sourceId,
1697
+ value: source.payload.value
1698
+ });
1699
+ }
1687
1700
  /* And then append the targets form the action */
1688
1701
  targets.push.apply(targets, _toConsumableArray(targetsFromAction));
1689
1702
  targets.forEach(function (payload) {
@@ -1708,7 +1721,7 @@ var slice$7 = createSlice({
1708
1721
  return targets.reduce(function (prevState, target) {
1709
1722
  var action = {
1710
1723
  payload: target,
1711
- type: source.type
1724
+ type: source && source.type
1712
1725
  };
1713
1726
  /* Handle the Layer action with the same logic, using the same reducer */
1714
1727
  return reducer$7(prevState, action);
@@ -2544,16 +2557,27 @@ var slice$5 = createSlice({
2544
2557
  });
2545
2558
  },
2546
2559
  mapStartAnimation: function mapStartAnimation(draft, action) {
2547
- var mapId = action.payload.mapId;
2560
+ var _action$payload3 = action.payload,
2561
+ mapId = _action$payload3.mapId,
2562
+ timeList = _action$payload3.timeList,
2563
+ start = _action$payload3.start,
2564
+ end = _action$payload3.end;
2548
2565
  if (!draft.byId[mapId]) {
2549
2566
  return;
2550
2567
  }
2551
2568
  draft.byId[mapId].isAnimating = true;
2552
- if (action.payload.start) {
2553
- draft.byId[mapId].animationStartTime = action.payload.start;
2554
- }
2555
- if (action.payload.end) {
2556
- draft.byId[mapId].animationEndTime = action.payload.end;
2569
+ // Animation is defined by one of the following:
2570
+ // - start, end and interval for a continuous animation loop with constant interval
2571
+ // - timeList, for a custom timeList
2572
+ if (start && end) {
2573
+ draft.byId[mapId].animationStartTime = start;
2574
+ draft.byId[mapId].animationEndTime = end;
2575
+ draft.byId[mapId].timeList = undefined;
2576
+ }
2577
+ if (timeList && timeList.length >= 0) {
2578
+ draft.byId[mapId].animationStartTime = undefined;
2579
+ draft.byId[mapId].animationEndTime = undefined;
2580
+ draft.byId[mapId].timeList = timeList;
2557
2581
  }
2558
2582
  if (action.payload.interval && action.payload.interval !== draft.byId[mapId].timeStep) {
2559
2583
  draft.byId[mapId].timeStep = action.payload.interval;
@@ -2568,66 +2592,66 @@ var slice$5 = createSlice({
2568
2592
  draft.byId[mapId].isAnimating = false;
2569
2593
  },
2570
2594
  setTimeSliderSpan: function setTimeSliderSpan(draft, action) {
2571
- var _action$payload3 = action.payload,
2572
- mapId = _action$payload3.mapId,
2573
- timeSliderSpan = _action$payload3.timeSliderSpan;
2595
+ var _action$payload4 = action.payload,
2596
+ mapId = _action$payload4.mapId,
2597
+ timeSliderSpan = _action$payload4.timeSliderSpan;
2574
2598
  if (!draft.byId[mapId]) {
2575
2599
  return;
2576
2600
  }
2577
2601
  draft.byId[mapId].timeSliderSpan = timeSliderSpan;
2578
2602
  },
2579
2603
  setTimeStep: function setTimeStep(draft, action) {
2580
- var _action$payload4 = action.payload,
2581
- mapId = _action$payload4.mapId,
2582
- timeStep = _action$payload4.timeStep;
2604
+ var _action$payload5 = action.payload,
2605
+ mapId = _action$payload5.mapId,
2606
+ timeStep = _action$payload5.timeStep;
2583
2607
  if (!draft.byId[mapId]) {
2584
2608
  return;
2585
2609
  }
2586
2610
  draft.byId[mapId].timeStep = timeStep;
2587
2611
  },
2588
2612
  setAnimationStartTime: function setAnimationStartTime(draft, action) {
2589
- var _action$payload5 = action.payload,
2590
- mapId = _action$payload5.mapId,
2591
- animationStartTime = _action$payload5.animationStartTime;
2613
+ var _action$payload6 = action.payload,
2614
+ mapId = _action$payload6.mapId,
2615
+ animationStartTime = _action$payload6.animationStartTime;
2592
2616
  if (!draft.byId[mapId]) {
2593
2617
  return;
2594
2618
  }
2595
2619
  draft.byId[mapId].animationStartTime = animationStartTime;
2596
2620
  },
2597
2621
  setAnimationEndTime: function setAnimationEndTime(draft, action) {
2598
- var _action$payload6 = action.payload,
2599
- mapId = _action$payload6.mapId,
2600
- animationEndTime = _action$payload6.animationEndTime;
2622
+ var _action$payload7 = action.payload,
2623
+ mapId = _action$payload7.mapId,
2624
+ animationEndTime = _action$payload7.animationEndTime;
2601
2625
  if (!draft.byId[mapId]) {
2602
2626
  return;
2603
2627
  }
2604
2628
  draft.byId[mapId].animationEndTime = animationEndTime;
2605
2629
  },
2606
2630
  setAnimationDelay: function setAnimationDelay(draft, action) {
2607
- var _action$payload7 = action.payload,
2608
- mapId = _action$payload7.mapId,
2609
- animationDelay = _action$payload7.animationDelay;
2631
+ var _action$payload8 = action.payload,
2632
+ mapId = _action$payload8.mapId,
2633
+ animationDelay = _action$payload8.animationDelay;
2610
2634
  if (!draft.byId[mapId]) {
2611
2635
  return;
2612
2636
  }
2613
2637
  draft.byId[mapId].animationDelay = animationDelay;
2614
2638
  },
2615
2639
  layerMoveLayer: function layerMoveLayer(draft, action) {
2616
- var _action$payload8 = action.payload,
2617
- oldIndex = _action$payload8.oldIndex,
2618
- newIndex = _action$payload8.newIndex,
2619
- mapId = _action$payload8.mapId;
2640
+ var _action$payload9 = action.payload,
2641
+ oldIndex = _action$payload9.oldIndex,
2642
+ newIndex = _action$payload9.newIndex,
2643
+ mapId = _action$payload9.mapId;
2620
2644
  if (!draft.byId[mapId]) {
2621
2645
  return;
2622
2646
  }
2623
2647
  draft.byId[mapId].mapLayers = moveArrayElements(draft.byId[mapId].mapLayers, oldIndex, newIndex);
2624
2648
  },
2625
2649
  setAutoLayerId: function setAutoLayerId(draft, action) {
2626
- var _action$payload9 = action.payload,
2627
- mapId = _action$payload9.mapId,
2628
- layerId = _action$payload9.layerId,
2629
- autoTimeStepLayerId = _action$payload9.autoTimeStepLayerId,
2630
- autoUpdateLayerId = _action$payload9.autoUpdateLayerId;
2650
+ var _action$payload10 = action.payload,
2651
+ mapId = _action$payload10.mapId,
2652
+ layerId = _action$payload10.layerId,
2653
+ autoTimeStepLayerId = _action$payload10.autoTimeStepLayerId,
2654
+ autoUpdateLayerId = _action$payload10.autoUpdateLayerId;
2631
2655
  var map = draft.byId[mapId];
2632
2656
  if (!map) {
2633
2657
  return;
@@ -2644,9 +2668,9 @@ var slice$5 = createSlice({
2644
2668
  }
2645
2669
  },
2646
2670
  setAutoTimestepLayerId: function setAutoTimestepLayerId(draft, action) {
2647
- var _action$payload10 = action.payload,
2648
- mapId = _action$payload10.mapId,
2649
- autoTimestepLayerId = _action$payload10.autoTimestepLayerId;
2671
+ var _action$payload11 = action.payload,
2672
+ mapId = _action$payload11.mapId,
2673
+ autoTimestepLayerId = _action$payload11.autoTimestepLayerId;
2650
2674
  var map = draft.byId[mapId];
2651
2675
  if (!map) {
2652
2676
  return;
@@ -2654,9 +2678,9 @@ var slice$5 = createSlice({
2654
2678
  map.autoTimeStepLayerId = autoTimestepLayerId;
2655
2679
  },
2656
2680
  setAutoUpdateLayerId: function setAutoUpdateLayerId(draft, action) {
2657
- var _action$payload11 = action.payload,
2658
- mapId = _action$payload11.mapId,
2659
- autoUpdateLayerId = _action$payload11.autoUpdateLayerId;
2681
+ var _action$payload12 = action.payload,
2682
+ mapId = _action$payload12.mapId,
2683
+ autoUpdateLayerId = _action$payload12.autoUpdateLayerId;
2660
2684
  var map = draft.byId[mapId];
2661
2685
  if (!map) {
2662
2686
  return;
@@ -2664,135 +2688,135 @@ var slice$5 = createSlice({
2664
2688
  map.autoUpdateLayerId = autoUpdateLayerId;
2665
2689
  },
2666
2690
  setTimeSliderWidth: function setTimeSliderWidth(draft, action) {
2667
- var _action$payload12 = action.payload,
2668
- mapId = _action$payload12.mapId,
2669
- timeSliderWidth = _action$payload12.timeSliderWidth;
2691
+ var _action$payload13 = action.payload,
2692
+ mapId = _action$payload13.mapId,
2693
+ timeSliderWidth = _action$payload13.timeSliderWidth;
2670
2694
  if (!draft.byId[mapId]) {
2671
2695
  return;
2672
2696
  }
2673
2697
  draft.byId[mapId].timeSliderWidth = timeSliderWidth;
2674
2698
  },
2675
2699
  setTimeSliderCenterTime: function setTimeSliderCenterTime(draft, action) {
2676
- var _action$payload13 = action.payload,
2677
- mapId = _action$payload13.mapId,
2678
- timeSliderCenterTime = _action$payload13.timeSliderCenterTime;
2700
+ var _action$payload14 = action.payload,
2701
+ mapId = _action$payload14.mapId,
2702
+ timeSliderCenterTime = _action$payload14.timeSliderCenterTime;
2679
2703
  if (!draft.byId[mapId]) {
2680
2704
  return;
2681
2705
  }
2682
2706
  draft.byId[mapId].timeSliderCenterTime = timeSliderCenterTime;
2683
2707
  },
2684
2708
  setTimeSliderUnfilteredSelectedTime: function setTimeSliderUnfilteredSelectedTime(draft, action) {
2685
- var _action$payload14 = action.payload,
2686
- mapId = _action$payload14.mapId,
2687
- timeSliderUnfilteredSelectedTime = _action$payload14.timeSliderUnfilteredSelectedTime;
2709
+ var _action$payload15 = action.payload,
2710
+ mapId = _action$payload15.mapId,
2711
+ timeSliderUnfilteredSelectedTime = _action$payload15.timeSliderUnfilteredSelectedTime;
2688
2712
  if (!draft.byId[mapId]) {
2689
2713
  return;
2690
2714
  }
2691
2715
  draft.byId[mapId].timeSliderUnfilteredSelectedTime = timeSliderUnfilteredSelectedTime;
2692
2716
  },
2693
2717
  setTimeSliderSecondsPerPx: function setTimeSliderSecondsPerPx(draft, action) {
2694
- var _action$payload15 = action.payload,
2695
- mapId = _action$payload15.mapId,
2696
- timeSliderSecondsPerPx = _action$payload15.timeSliderSecondsPerPx;
2718
+ var _action$payload16 = action.payload,
2719
+ mapId = _action$payload16.mapId,
2720
+ timeSliderSecondsPerPx = _action$payload16.timeSliderSecondsPerPx;
2697
2721
  if (!draft.byId[mapId]) {
2698
2722
  return;
2699
2723
  }
2700
2724
  draft.byId[mapId].timeSliderSecondsPerPx = timeSliderSecondsPerPx;
2701
2725
  },
2702
2726
  toggleAutoUpdate: function toggleAutoUpdate(draft, action) {
2703
- var _action$payload16 = action.payload,
2704
- mapId = _action$payload16.mapId,
2705
- shouldAutoUpdate = _action$payload16.shouldAutoUpdate;
2727
+ var _action$payload17 = action.payload,
2728
+ mapId = _action$payload17.mapId,
2729
+ shouldAutoUpdate = _action$payload17.shouldAutoUpdate;
2706
2730
  if (!draft.byId[mapId]) {
2707
2731
  return;
2708
2732
  }
2709
2733
  draft.byId[mapId].isAutoUpdating = shouldAutoUpdate;
2710
2734
  },
2711
2735
  setEndTimeOverriding: function setEndTimeOverriding(draft, action) {
2712
- var _action$payload17 = action.payload,
2713
- mapId = _action$payload17.mapId,
2714
- shouldEndtimeOverride = _action$payload17.shouldEndtimeOverride;
2736
+ var _action$payload18 = action.payload,
2737
+ mapId = _action$payload18.mapId,
2738
+ shouldEndtimeOverride = _action$payload18.shouldEndtimeOverride;
2715
2739
  if (!draft.byId[mapId]) {
2716
2740
  return;
2717
2741
  }
2718
2742
  draft.byId[mapId].shouldEndtimeOverride = shouldEndtimeOverride;
2719
2743
  },
2720
2744
  toggleTimestepAuto: function toggleTimestepAuto(draft, action) {
2721
- var _action$payload18 = action.payload,
2722
- mapId = _action$payload18.mapId,
2723
- timestepAuto = _action$payload18.timestepAuto;
2745
+ var _action$payload19 = action.payload,
2746
+ mapId = _action$payload19.mapId,
2747
+ timestepAuto = _action$payload19.timestepAuto;
2724
2748
  if (!draft.byId[mapId]) {
2725
2749
  return;
2726
2750
  }
2727
2751
  draft.byId[mapId].isTimestepAuto = timestepAuto;
2728
2752
  },
2729
2753
  toggleTimeSpanAuto: function toggleTimeSpanAuto(draft, action) {
2730
- var _action$payload19 = action.payload,
2731
- mapId = _action$payload19.mapId,
2732
- timeSpanAuto = _action$payload19.timeSpanAuto;
2754
+ var _action$payload20 = action.payload,
2755
+ mapId = _action$payload20.mapId,
2756
+ timeSpanAuto = _action$payload20.timeSpanAuto;
2733
2757
  if (!draft.byId[mapId]) {
2734
2758
  return;
2735
2759
  }
2736
2760
  draft.byId[mapId].isTimeSpanAuto = timeSpanAuto;
2737
2761
  },
2738
2762
  toggleTimeSliderHover: function toggleTimeSliderHover(draft, action) {
2739
- var _action$payload20 = action.payload,
2740
- mapId = _action$payload20.mapId,
2741
- isTimeSliderHoverOn = _action$payload20.isTimeSliderHoverOn;
2763
+ var _action$payload21 = action.payload,
2764
+ mapId = _action$payload21.mapId,
2765
+ isTimeSliderHoverOn = _action$payload21.isTimeSliderHoverOn;
2742
2766
  if (!draft.byId[mapId]) {
2743
2767
  return;
2744
2768
  }
2745
2769
  draft.byId[mapId].isTimeSliderHoverOn = isTimeSliderHoverOn;
2746
2770
  },
2747
2771
  toggleTimeSliderIsVisible: function toggleTimeSliderIsVisible(draft, action) {
2748
- var _action$payload21 = action.payload,
2749
- mapId = _action$payload21.mapId,
2750
- isTimeSliderVisible = _action$payload21.isTimeSliderVisible;
2772
+ var _action$payload22 = action.payload,
2773
+ mapId = _action$payload22.mapId,
2774
+ isTimeSliderVisible = _action$payload22.isTimeSliderVisible;
2751
2775
  if (!draft.byId[mapId]) {
2752
2776
  return;
2753
2777
  }
2754
2778
  draft.byId[mapId].isTimeSliderVisible = isTimeSliderVisible;
2755
2779
  },
2756
2780
  toggleZoomControls: function toggleZoomControls(draft, action) {
2757
- var _action$payload22 = action.payload,
2758
- mapId = _action$payload22.mapId,
2759
- shouldShowZoomControls = _action$payload22.shouldShowZoomControls;
2781
+ var _action$payload23 = action.payload,
2782
+ mapId = _action$payload23.mapId,
2783
+ shouldShowZoomControls = _action$payload23.shouldShowZoomControls;
2760
2784
  if (!draft.byId[mapId]) {
2761
2785
  return;
2762
2786
  }
2763
2787
  draft.byId[mapId].shouldShowZoomControls = shouldShowZoomControls;
2764
2788
  },
2765
2789
  setMapPinLocation: function setMapPinLocation(draft, action) {
2766
- var _action$payload23 = action.payload,
2767
- mapId = _action$payload23.mapId,
2768
- mapPinLocation = _action$payload23.mapPinLocation;
2790
+ var _action$payload24 = action.payload,
2791
+ mapId = _action$payload24.mapId,
2792
+ mapPinLocation = _action$payload24.mapPinLocation;
2769
2793
  if (!draft.byId[mapId]) {
2770
2794
  return;
2771
2795
  }
2772
2796
  draft.byId[mapId].mapPinLocation = mapPinLocation;
2773
2797
  },
2774
2798
  setDisableMapPin: function setDisableMapPin(draft, action) {
2775
- var _action$payload24 = action.payload,
2776
- mapId = _action$payload24.mapId,
2777
- disableMapPin = _action$payload24.disableMapPin;
2799
+ var _action$payload25 = action.payload,
2800
+ mapId = _action$payload25.mapId,
2801
+ disableMapPin = _action$payload25.disableMapPin;
2778
2802
  if (!draft.byId[mapId]) {
2779
2803
  return;
2780
2804
  }
2781
2805
  draft.byId[mapId].disableMapPin = disableMapPin;
2782
2806
  },
2783
2807
  toggleMapPinIsVisible: function toggleMapPinIsVisible(draft, action) {
2784
- var _action$payload25 = action.payload,
2785
- mapId = _action$payload25.mapId,
2786
- displayMapPin = _action$payload25.displayMapPin;
2808
+ var _action$payload26 = action.payload,
2809
+ mapId = _action$payload26.mapId,
2810
+ displayMapPin = _action$payload26.displayMapPin;
2787
2811
  if (!draft.byId[mapId]) {
2788
2812
  return;
2789
2813
  }
2790
2814
  draft.byId[mapId].displayMapPin = displayMapPin;
2791
2815
  },
2792
2816
  setDockedLayerManagerSize: function setDockedLayerManagerSize(draft, action) {
2793
- var _action$payload26 = action.payload,
2794
- mapId = _action$payload26.mapId,
2795
- dockedLayerManagerSize = _action$payload26.dockedLayerManagerSize;
2817
+ var _action$payload27 = action.payload,
2818
+ mapId = _action$payload27.mapId,
2819
+ dockedLayerManagerSize = _action$payload27.dockedLayerManagerSize;
2796
2820
  if (!draft.byId[mapId]) {
2797
2821
  return;
2798
2822
  }
@@ -2806,10 +2830,10 @@ var slice$5 = createSlice({
2806
2830
  },
2807
2831
  extraReducers: function extraReducers(builder) {
2808
2832
  builder.addCase(layerActions.addLayer, function (draft, action) {
2809
- var _action$payload27 = action.payload,
2810
- layerId = _action$payload27.layerId,
2811
- mapId = _action$payload27.mapId,
2812
- layer = _action$payload27.layer;
2833
+ var _action$payload28 = action.payload,
2834
+ layerId = _action$payload28.layerId,
2835
+ mapId = _action$payload28.mapId,
2836
+ layer = _action$payload28.layer;
2813
2837
  if (!draft.byId[mapId]) {
2814
2838
  return;
2815
2839
  }
@@ -2828,9 +2852,9 @@ var slice$5 = createSlice({
2828
2852
  draft.byId[mapId].mapLayers.unshift(layerId);
2829
2853
  }
2830
2854
  }).addCase(layerActions.duplicateMapLayer, function (draft, action) {
2831
- var _action$payload28 = action.payload,
2832
- newLayerId = _action$payload28.newLayerId,
2833
- mapId = _action$payload28.mapId;
2855
+ var _action$payload29 = action.payload,
2856
+ newLayerId = _action$payload29.newLayerId,
2857
+ mapId = _action$payload29.mapId;
2834
2858
  if (!draft.byId[mapId]) {
2835
2859
  return;
2836
2860
  }
@@ -2840,10 +2864,10 @@ var slice$5 = createSlice({
2840
2864
  }
2841
2865
  draft.byId[mapId].mapLayers.unshift(newLayerId);
2842
2866
  }).addCase(layerActions.addBaseLayer, function (draft, action) {
2843
- var _action$payload29 = action.payload,
2844
- layer = _action$payload29.layer,
2845
- layerId = _action$payload29.layerId,
2846
- mapId = _action$payload29.mapId;
2867
+ var _action$payload30 = action.payload,
2868
+ layer = _action$payload30.layer,
2869
+ layerId = _action$payload30.layerId,
2870
+ mapId = _action$payload30.mapId;
2847
2871
  if (!draft.byId[mapId]) {
2848
2872
  return;
2849
2873
  }
@@ -2899,9 +2923,9 @@ var slice$5 = createSlice({
2899
2923
  }
2900
2924
  }
2901
2925
  }).addCase(layerActions.setBaseLayers, function (draft, action) {
2902
- var _action$payload30 = action.payload,
2903
- layers = _action$payload30.layers,
2904
- mapId = _action$payload30.mapId;
2926
+ var _action$payload31 = action.payload,
2927
+ layers = _action$payload31.layers,
2928
+ mapId = _action$payload31.mapId;
2905
2929
  // Split into base and overlayers
2906
2930
  var baseLayers = [];
2907
2931
  var overLayers = [];
@@ -2931,9 +2955,9 @@ var slice$5 = createSlice({
2931
2955
  }
2932
2956
  }
2933
2957
  }).addCase(layerActions.layerDelete, function (draft, action) {
2934
- var _action$payload31 = action.payload,
2935
- mapId = _action$payload31.mapId,
2936
- layerId = _action$payload31.layerId;
2958
+ var _action$payload32 = action.payload,
2959
+ mapId = _action$payload32.mapId,
2960
+ layerId = _action$payload32.layerId;
2937
2961
  var map = draft.byId[mapId];
2938
2962
  if (!map) {
2939
2963
  return;
@@ -2959,9 +2983,9 @@ var slice$5 = createSlice({
2959
2983
  return id !== layerId;
2960
2984
  });
2961
2985
  }).addCase(layerActions.baseLayerDelete, function (draft, action) {
2962
- var _action$payload32 = action.payload,
2963
- mapId = _action$payload32.mapId,
2964
- layerId = _action$payload32.layerId;
2986
+ var _action$payload33 = action.payload,
2987
+ mapId = _action$payload33.mapId,
2988
+ layerId = _action$payload33.layerId;
2965
2989
  if (!draft.byId[mapId]) {
2966
2990
  return;
2967
2991
  }
@@ -2972,19 +2996,22 @@ var slice$5 = createSlice({
2972
2996
  return id !== layerId;
2973
2997
  });
2974
2998
  }).addCase(layerActions.layerChangeDimension, function (draft, action) {
2975
- var _action$payload33 = action.payload,
2976
- layerId = _action$payload33.layerId,
2977
- dimension = _action$payload33.dimension;
2999
+ var _action$payload34 = action.payload,
3000
+ layerId = _action$payload34.layerId,
3001
+ dimension = _action$payload34.dimension;
2978
3002
  produceDraftStateSetMapDimensionFromLayerChangeDimension(draft, layerId, dimension);
2979
3003
  }).addCase(setTimeSync, function (draft, action) {
2980
- var _action$payload34 = action.payload,
2981
- targetsFromAction = _action$payload34.targets,
2982
- source = _action$payload34.source;
3004
+ var _action$payload35 = action.payload,
3005
+ targetsFromAction = _action$payload35.targets,
3006
+ source = _action$payload35.source;
2983
3007
  /* Because we want backwards compatibility with the previous code, we also need to listen to the original source action */
2984
- var targets = [{
2985
- targetId: source.payload.sourceId,
2986
- value: source.payload.value
2987
- }];
3008
+ var targets = [];
3009
+ if (source) {
3010
+ targets.push({
3011
+ targetId: source.payload.sourceId,
3012
+ value: source.payload.value
3013
+ });
3014
+ }
2988
3015
  /* And then append the targets form the action */
2989
3016
  targets.push.apply(targets, _toConsumableArray(targetsFromAction));
2990
3017
  targets.forEach(function (target) {
@@ -3000,15 +3027,18 @@ var slice$5 = createSlice({
3000
3027
  }
3001
3028
  });
3002
3029
  }).addCase(setBboxSync, function (draft, action) {
3003
- var _action$payload35 = action.payload,
3004
- targetsFromAction = _action$payload35.targets,
3005
- source = _action$payload35.source;
3030
+ var _action$payload36 = action.payload,
3031
+ targetsFromAction = _action$payload36.targets,
3032
+ source = _action$payload36.source;
3006
3033
  /* Because we want backwards compatibility with the previous code, we also need to listen to the original source action */
3007
- var targets = [{
3008
- targetId: source.payload.sourceId,
3009
- bbox: source.payload.bbox,
3010
- srs: source.payload.srs
3011
- }];
3034
+ var targets = [];
3035
+ if (source) {
3036
+ targets.push({
3037
+ targetId: source.payload.sourceId,
3038
+ bbox: source.payload.bbox,
3039
+ srs: source.payload.srs
3040
+ });
3041
+ }
3012
3042
  /* And then append the targets form the action */
3013
3043
  targets.push.apply(targets, _toConsumableArray(targetsFromAction));
3014
3044
  targets.forEach(function (payload) {
@@ -3031,13 +3061,13 @@ var slice$5 = createSlice({
3031
3061
  * These targets can be used as payloads in new Layer actions.
3032
3062
  * These actions are here handled via the layer reducer, as it is the same logic
3033
3063
  */
3034
- var _action$payload36 = action.payload,
3035
- targets = _action$payload36.targets,
3036
- source = _action$payload36.source;
3064
+ var _action$payload37 = action.payload,
3065
+ targets = _action$payload37.targets,
3066
+ source = _action$payload37.source;
3037
3067
  return targets.reduce(function (prevState, target) {
3038
3068
  var action = {
3039
3069
  payload: target,
3040
- type: source.type
3070
+ type: source && source.type
3041
3071
  };
3042
3072
  /* Handle the Layer action with the same logic, using the same reducer */
3043
3073
  return reducer$5(prevState, action);
@@ -3054,9 +3084,9 @@ var slice$5 = createSlice({
3054
3084
  });
3055
3085
  return draft;
3056
3086
  }).addCase(mapChangeDimension, function (draft, action) {
3057
- var _action$payload37 = action.payload,
3058
- mapId = _action$payload37.mapId,
3059
- dimensionFromAction = _action$payload37.dimension;
3087
+ var _action$payload38 = action.payload,
3088
+ mapId = _action$payload38.mapId,
3089
+ dimensionFromAction = _action$payload38.dimension;
3060
3090
  produceDraftStateSetWebMapDimension(draft, mapId, dimensionFromAction, true);
3061
3091
  }).addCase(setMapPreset, function (draft, action) {
3062
3092
  var mapId = action.payload.mapId;
@@ -3076,9 +3106,9 @@ var slice$5 = createSlice({
3076
3106
  draft.byId[mapId].animationDelay = defaultAnimationDelayAtStart;
3077
3107
  draft.byId[mapId].dockedLayerManagerSize = '';
3078
3108
  }).addCase(uiActions.registerDialog, function (draft, action) {
3079
- var _action$payload38 = action.payload,
3080
- mapId = _action$payload38.mapId,
3081
- type = _action$payload38.type;
3109
+ var _action$payload39 = action.payload,
3110
+ mapId = _action$payload39.mapId,
3111
+ type = _action$payload39.type;
3082
3112
  if (!draft.byId[mapId]) {
3083
3113
  return;
3084
3114
  }
@@ -3537,32 +3567,34 @@ var setBboxOrTimeSync = function setBboxOrTimeSync(draft, action) {
3537
3567
  return null;
3538
3568
  }
3539
3569
  };
3540
- var payloadKey = getPayLoadKey(action.type);
3541
- if (!source.payload || !payloadKey) {
3542
- console.warn('Wrong sync action: ', action);
3543
- return;
3544
- }
3545
- if (draft.sources.byId[source.payload.sourceId]) {
3546
- if (!draft.sources.byId[source.payload.sourceId].payloadByType) {
3547
- draft.sources.byId[source.payload.sourceId].payloadByType = {};
3570
+ if (source) {
3571
+ var payloadKey = getPayLoadKey(action.type);
3572
+ if (!source.payload || !payloadKey) {
3573
+ console.warn('Wrong sync action: ', action);
3574
+ return;
3548
3575
  }
3549
- draft.sources.byId[source.payload.sourceId].payloadByType[payloadKey] = source.payload;
3550
- }
3551
- /* Update all targets */
3552
- targets.forEach(function (target) {
3553
- if (draft.sources.byId[target.targetId]) {
3554
- if (!draft.sources.byId[target.targetId].payloadByType) {
3555
- draft.sources.byId[target.targetId].payloadByType = {};
3576
+ if (draft.sources.byId[source.payload.sourceId]) {
3577
+ if (!draft.sources.byId[source.payload.sourceId].payloadByType) {
3578
+ draft.sources.byId[source.payload.sourceId].payloadByType = {};
3556
3579
  }
3557
- draft.sources.byId[target.targetId].payloadByType[payloadKey] = source.payload;
3558
- }
3559
- });
3560
- /* Set the value in the group */
3561
- groups.forEach(function (group) {
3562
- if (draft.groups.byId[group]) {
3563
- draft.groups.byId[group].payloadByType[payloadKey] = source.payload;
3580
+ draft.sources.byId[source.payload.sourceId].payloadByType[payloadKey] = source.payload;
3564
3581
  }
3565
- });
3582
+ /* Update all targets */
3583
+ targets.forEach(function (target) {
3584
+ if (draft.sources.byId[target.targetId]) {
3585
+ if (!draft.sources.byId[target.targetId].payloadByType) {
3586
+ draft.sources.byId[target.targetId].payloadByType = {};
3587
+ }
3588
+ draft.sources.byId[target.targetId].payloadByType[payloadKey] = source.payload;
3589
+ }
3590
+ });
3591
+ /* Set the value in the group */
3592
+ groups.forEach(function (group) {
3593
+ if (draft.groups.byId[group]) {
3594
+ draft.groups.byId[group].payloadByType[payloadKey] = source.payload;
3595
+ }
3596
+ });
3597
+ }
3566
3598
  };
3567
3599
  var _slice$actions = slice$4.actions,
3568
3600
  syncGroupAddGroup = _slice$actions.syncGroupAddGroup,
@@ -4694,6 +4726,35 @@ var getIsEnabledLayersForMapDimension = createSelector(getMapLayerIdsEnabled, fu
4694
4726
  var getDockedLayerManagerSize = createSelector(getMapById, function (store) {
4695
4727
  return store ? store.dockedLayerManagerSize : 'sizeSmall';
4696
4728
  }, selectorMemoizationOptions);
4729
+ /**
4730
+ * Returns the animation list for given map id
4731
+ * @param {object} store store: object - store object
4732
+ * @param {string} mapId mapId: string - Id of the map
4733
+ * @returns {animationList} returnType: WebMapAnimationList, list of timesteps to animate for this map.
4734
+ */
4735
+ var getAnimationList = createSelector(getMapById, getAnimationStartTime, getAnimationEndTime$1, getMapTimeStep, function (mapStore, animationStart, animationEnd, animationInterval) {
4736
+ // Animation is defined by one of the following:
4737
+ // - start, end and interval for a continuous animation loop with constant interval
4738
+ // - timeList, for a custom timeList
4739
+ // Here the animation is defined by a timeList
4740
+ if (mapStore && (mapStore === null || mapStore === void 0 ? void 0 : mapStore.timeList) && mapStore.timeList.length > 0) {
4741
+ return mapStore.timeList;
4742
+ }
4743
+ // Here the animation is defined by a start/stop/interval
4744
+ var roundedStart = roundWithTimeStep(Number(animationStart && dateUtils.unix(dateUtils.utc(animationStart))), animationInterval, 'ceil');
4745
+ var roundedEnd = roundWithTimeStep(Number(animationEnd && dateUtils.unix(dateUtils.utc(animationEnd))), animationInterval, 'floor');
4746
+ var timeList = [];
4747
+ var unixStart = dateUtils.unix(dateUtils.fromUnix(roundedStart));
4748
+ var unixEnd = dateUtils.unix(dateUtils.fromUnix(roundedEnd));
4749
+ var intervalSeconds = animationInterval * 60;
4750
+ for (var j = unixStart; j <= unixEnd; j += intervalSeconds) {
4751
+ timeList.push({
4752
+ name: 'time',
4753
+ value: dateUtils.fromUnix(j).toISOString()
4754
+ });
4755
+ }
4756
+ return timeList;
4757
+ }, selectorMemoizationOptions);
4697
4758
 
4698
4759
  var selectors$2 = /*#__PURE__*/Object.freeze({
4699
4760
  __proto__: null,
@@ -4751,7 +4812,8 @@ var selectors$2 = /*#__PURE__*/Object.freeze({
4751
4812
  getMapPreset: getMapPreset,
4752
4813
  getMapLayerIdsEnabled: getMapLayerIdsEnabled,
4753
4814
  getIsEnabledLayersForMapDimension: getIsEnabledLayersForMapDimension,
4754
- getDockedLayerManagerSize: getDockedLayerManagerSize
4815
+ getDockedLayerManagerSize: getDockedLayerManagerSize,
4816
+ getAnimationList: getAnimationList
4755
4817
  });
4756
4818
 
4757
4819
  /* *
@@ -5208,23 +5270,110 @@ var storeTestSettings = /*#__PURE__*/Object.freeze({
5208
5270
  WmMultiDimensionServices: WmMultiDimensionServices
5209
5271
  });
5210
5272
 
5211
- var _marked$6 = /*#__PURE__*/_regeneratorRuntime().mark(updateAnimation),
5212
- _marked2$4 = /*#__PURE__*/_regeneratorRuntime().mark(handleBaseLayersSaga),
5213
- _marked3$2 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$5);
5214
- // Expects start, end time as Date object and interval in minutes
5215
- var generateTimeList = function generateTimeList(start, end, interval) {
5216
- var timeList = [];
5217
- var unixStart = dateUtils.unix(start);
5218
- var unixEnd = dateUtils.unix(end);
5219
- var intervalSeconds = interval * 60;
5220
- for (var j = unixStart; j <= unixEnd; j += intervalSeconds) {
5221
- timeList.push({
5222
- name: 'time',
5223
- value: dateUtils.fromUnix(j).toISOString()
5224
- });
5273
+ /* A map with all the timerIds and their current step */
5274
+ var stepMap = new Map();
5275
+ /**
5276
+ * Returns the next step for given timerId.
5277
+ * @param timerId The timer id
5278
+ * @param numberOfStepsInAnimation Animation length in steps
5279
+ * @param numStepsToGoForward Amount of steps to go forwards, defaults to 1. Can be positive and negative
5280
+ * @returns
5281
+ */
5282
+ var getNextStep = function getNextStep(timerId, numberOfStepsInAnimation) {
5283
+ var numStepsToGoForward = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
5284
+ var currentStep = getCurrentStep(timerId);
5285
+ var nextStep = currentStep + numStepsToGoForward;
5286
+ var nextStepClipped = (nextStep % numberOfStepsInAnimation + numberOfStepsInAnimation) % numberOfStepsInAnimation;
5287
+ return nextStepClipped;
5288
+ };
5289
+ /**
5290
+ * Set step for the timerId
5291
+ * @param timerId
5292
+ * @param timerStep
5293
+ */
5294
+ var setStep = function setStep(timerId, timerStep) {
5295
+ stepMap.set(timerId, timerStep);
5296
+ };
5297
+ /**
5298
+ * Gets the current step for the timer
5299
+ * @param timerId
5300
+ * @returns
5301
+ */
5302
+ var getCurrentStep = function getCurrentStep(timerId) {
5303
+ return stepMap.get(timerId) || 0;
5304
+ };
5305
+ var MAX_NUMBER_STEPS_FORWARD_TO_PREFETCH = 2;
5306
+ var MAX_NUMBER_OF_PARALLEL_LOADING_IMAGES = 8;
5307
+ /**
5308
+ * This prefetches all images connected to the same sync group as provided timerId
5309
+ * @param timerId The timerId
5310
+ * @param animationListValues List of animation steps in isostring to animate
5311
+ * @param targets List of targets to check
5312
+ * @returns True if all maps are ready to go forward, false if the map has no data to display yet.
5313
+ */
5314
+ var prefetchAnimationTargetsForSaga = function prefetchAnimationTargetsForSaga(timerId, animationListValues, targets) {
5315
+ var timerShouldStepForward = true;
5316
+ // The following code prefetches/buffers for all maps in the group
5317
+ for (var numPrefetch = 0; numPrefetch < MAX_NUMBER_STEPS_FORWARD_TO_PREFETCH; numPrefetch += 1) {
5318
+ var nextStep = getNextStep(timerId, animationListValues.length, numPrefetch + 1);
5319
+ var nextTimeValueStepToCheck = animationListValues[nextStep];
5320
+ var _iterator = _createForOfIteratorHelper(targets),
5321
+ _step;
5322
+ try {
5323
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5324
+ var target = _step.value;
5325
+ var targetMapId = target.targetId;
5326
+ var wmMap = getWMJSMapById(targetMapId);
5327
+ if (wmMap) {
5328
+ var layersImageUrls = wmMap.getWMSRequests([{
5329
+ name: 'time',
5330
+ currentValue: nextTimeValueStepToCheck
5331
+ }]);
5332
+ var _iterator2 = _createForOfIteratorHelper(layersImageUrls),
5333
+ _step2;
5334
+ try {
5335
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
5336
+ var layersImageUrl = _step2.value;
5337
+ var image = getMapImageStore.getImage(layersImageUrl.url);
5338
+ if (!image.isLoaded()) {
5339
+ if (getMapImageStore.getNumImagesLoading() < MAX_NUMBER_OF_PARALLEL_LOADING_IMAGES) {
5340
+ image.load();
5341
+ }
5342
+ if (numPrefetch === 0) {
5343
+ var altImage = getAlternativeImage(layersImageUrl.url, getMapImageStore, wmMap.getBBOX());
5344
+ // No alternative image available yet, so skipping animation.
5345
+ if (!altImage) {
5346
+ // This is useful to indicate that the map is loading and has nothing yet to display.
5347
+ // console.warn('No data available: Not stepping forward');
5348
+ timerShouldStepForward = false;
5349
+ }
5350
+ }
5351
+ }
5352
+ }
5353
+ } catch (err) {
5354
+ _iterator2.e(err);
5355
+ } finally {
5356
+ _iterator2.f();
5357
+ }
5358
+ } else {
5359
+ return false; // Map was not registered so there is nothing to prefetch
5360
+ }
5361
+ }
5362
+ } catch (err) {
5363
+ _iterator.e(err);
5364
+ } finally {
5365
+ _iterator.f();
5366
+ }
5225
5367
  }
5226
- return timeList;
5368
+ return timerShouldStepForward;
5227
5369
  };
5370
+
5371
+ var _marked$5 = /*#__PURE__*/_regeneratorRuntime().mark(updateAnimation),
5372
+ _marked2$3 = /*#__PURE__*/_regeneratorRuntime().mark(handleBaseLayersSaga),
5373
+ _marked3$1 = /*#__PURE__*/_regeneratorRuntime().mark(metronomeSaga),
5374
+ _marked4 = /*#__PURE__*/_regeneratorRuntime().mark(metronomeSagaWithChannel),
5375
+ _marked5 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$4);
5376
+ // Expects start, end time as Date object and interval in minutes
5228
5377
  var getAnimationEndTime = function getAnimationEndTime(animationEndTime) {
5229
5378
  var ISOtime = dateUtils.parseISO(animationEndTime);
5230
5379
  if (dateUtils.isValid(ISOtime)) {
@@ -5256,49 +5405,42 @@ var isAnimationEndTimeValid = function isAnimationEndTimeValid(animationEndTime)
5256
5405
  var parsedDate = dateUtils.parseISO(animationEndTime);
5257
5406
  return dateUtils.isValid(parsedDate);
5258
5407
  };
5259
- var validInitialAnimationStep = function validInitialAnimationStep(initialAnimationStep, draw) {
5260
- return !!initialAnimationStep && !!(draw === null || draw === void 0 ? void 0 : draw.length) && initialAnimationStep >= 0 && draw.length > initialAnimationStep;
5261
- };
5262
- function updateMapDraw(mapId, draw, initialAnimationStep) {
5263
- var webMap = webmapUtils.getWMJSMapById(mapId);
5264
- if (webMap) {
5265
- webMap.getListener().suspendEvents();
5266
- webMap.stopAnimating();
5267
- if (initialAnimationStep && validInitialAnimationStep(initialAnimationStep, draw)) {
5268
- webMap.initialAnimationStep = initialAnimationStep;
5269
- } else {
5270
- webMap.initialAnimationStep = 0;
5271
- }
5272
- webMap.draw(draw);
5273
- webMap.getListener().resumeEvents();
5274
- }
5275
- }
5276
5408
  function startAnimationSaga(_ref) {
5277
5409
  var payload = _ref.payload;
5278
5410
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5279
- var mapId, start, initialTime, end, interval, timeList, roundedStart, roundedEnd, animationList, initialAnimationStep;
5411
+ var mapId, initialTime, speedDelay, speed, timeList, initalTimerStep;
5280
5412
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5281
5413
  while (1) switch (_context.prev = _context.next) {
5282
5414
  case 0:
5283
- mapId = payload.mapId, start = payload.start, initialTime = payload.initialTime, end = payload.end, interval = payload.interval, timeList = payload.timeList;
5284
- roundedStart = roundWithTimeStep(Number(start && dateUtils.unix(dateUtils.utc(start))), interval, 'ceil');
5285
- roundedEnd = roundWithTimeStep(Number(end && dateUtils.unix(dateUtils.utc(end))), interval, 'floor');
5286
- animationList = timeList || generateTimeList(dateUtils.fromUnix(roundedStart), dateUtils.fromUnix(roundedEnd), interval);
5287
- _context.next = 6;
5288
- return animationList;
5289
- case 6:
5290
- initialAnimationStep = initialTime && animationList ? animationList.findIndex(function (time) {
5291
- return new Date(time.value) >= new Date(initialTime);
5292
- }) : undefined;
5293
- _context.next = 9;
5294
- return updateMapDraw(mapId, animationList, initialAnimationStep);
5295
- case 9:
5415
+ mapId = payload.mapId, initialTime = payload.initialTime;
5416
+ _context.next = 3;
5417
+ return select(getMapAnimationDelay, mapId);
5418
+ case 3:
5419
+ speedDelay = _context.sent;
5420
+ speed = 1000 / (speedDelay || 1);
5421
+ metronome.register(null, speed, mapId);
5422
+ _context.next = 8;
5423
+ return select(getAnimationList, mapId);
5424
+ case 8:
5425
+ timeList = _context.sent;
5426
+ // In case of the timeList
5427
+ if (timeList && timeList.length > 0) {
5428
+ // Determine animation step based on initialTime and timeList
5429
+ initalTimerStep = timeList === null || timeList === void 0 ? void 0 : timeList.findIndex(function (timeNameValue) {
5430
+ return timeNameValue.value === initialTime;
5431
+ });
5432
+ if (initalTimerStep !== -1) {
5433
+ setStep(mapId, initalTimerStep);
5434
+ }
5435
+ }
5436
+ case 10:
5296
5437
  case "end":
5297
5438
  return _context.stop();
5298
5439
  }
5299
5440
  }, _callee);
5300
5441
  })();
5301
5442
  }
5443
+ // eslint-disable-next-line require-yield
5302
5444
  function stopAnimationSaga(_ref2) {
5303
5445
  var payload = _ref2.payload;
5304
5446
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
@@ -5307,9 +5449,8 @@ function stopAnimationSaga(_ref2) {
5307
5449
  while (1) switch (_context2.prev = _context2.next) {
5308
5450
  case 0:
5309
5451
  mapId = payload.mapId;
5310
- _context2.next = 3;
5311
- return updateMapDraw(mapId, 'opengeoweb-core-map-reducer');
5312
- case 3:
5452
+ metronome.unregister(mapId);
5453
+ case 2:
5313
5454
  case "end":
5314
5455
  return _context2.stop();
5315
5456
  }
@@ -5344,7 +5485,7 @@ function deleteLayerSaga(_ref3) {
5344
5485
  })();
5345
5486
  }
5346
5487
  function updateAnimation(mapId, maxValue) {
5347
- var shouldEndtimeOverride$1, animationStart, animationStartUnix, animationEnd, animationEndUnix, t, deltaT, start, end, isAnimating$1, timeStep;
5488
+ var shouldEndtimeOverride$1, animationStart, animationEnd, animationEndUnix, maxTimeAsUnix, timeInSecondToShiftAnimationForwards, animationStartUnix, newAnimationStartTime, newAnimationEndTime;
5348
5489
  return _regeneratorRuntime().wrap(function updateAnimation$(_context4) {
5349
5490
  while (1) switch (_context4.prev = _context4.next) {
5350
5491
  case 0:
@@ -5362,17 +5503,17 @@ function updateAnimation(mapId, maxValue) {
5362
5503
  return select(getAnimationStartTime, mapId);
5363
5504
  case 7:
5364
5505
  animationStart = _context4.sent;
5365
- animationStartUnix = dateUtils.unix(dateUtils.utc(animationStart));
5366
- _context4.next = 11;
5506
+ _context4.next = 10;
5367
5507
  return select(getAnimationEndTime$1, mapId);
5368
- case 11:
5508
+ case 10:
5369
5509
  animationEnd = _context4.sent;
5370
5510
  animationEndUnix = dateUtils.unix(dateUtils.utc(animationEnd));
5371
- t = dateUtils.unix(dateUtils.utc(maxValue));
5372
- deltaT = t - animationEndUnix;
5373
- start = dateUtils.dateToString(dateUtils.fromUnix(animationStartUnix + deltaT), dateFormat);
5374
- end = dateUtils.dateToString(dateUtils.fromUnix(animationEndUnix + deltaT), dateFormat);
5375
- if (!(!start || !end)) {
5511
+ maxTimeAsUnix = dateUtils.unix(dateUtils.utc(maxValue));
5512
+ timeInSecondToShiftAnimationForwards = maxTimeAsUnix - animationEndUnix;
5513
+ animationStartUnix = dateUtils.unix(dateUtils.utc(animationStart));
5514
+ newAnimationStartTime = dateUtils.dateToString(dateUtils.fromUnix(animationStartUnix + timeInSecondToShiftAnimationForwards), dateFormat);
5515
+ newAnimationEndTime = dateUtils.dateToString(dateUtils.fromUnix(animationEndUnix + timeInSecondToShiftAnimationForwards), dateFormat);
5516
+ if (!(!newAnimationStartTime || !newAnimationEndTime)) {
5376
5517
  _context4.next = 19;
5377
5518
  break;
5378
5519
  }
@@ -5381,44 +5522,24 @@ function updateAnimation(mapId, maxValue) {
5381
5522
  _context4.next = 21;
5382
5523
  return put(mapActions.setAnimationEndTime({
5383
5524
  mapId: mapId,
5384
- animationEndTime: end
5525
+ animationEndTime: newAnimationEndTime
5385
5526
  }));
5386
5527
  case 21:
5387
5528
  _context4.next = 23;
5388
5529
  return put(mapActions.setAnimationStartTime({
5389
5530
  mapId: mapId,
5390
- animationStartTime: start
5531
+ animationStartTime: newAnimationStartTime
5391
5532
  }));
5392
5533
  case 23:
5393
- _context4.next = 25;
5394
- return select(isAnimating, mapId);
5395
- case 25:
5396
- isAnimating$1 = _context4.sent;
5397
- if (!isAnimating$1) {
5398
- _context4.next = 32;
5399
- break;
5400
- }
5401
- _context4.next = 29;
5402
- return select(getMapTimeStep, mapId);
5403
- case 29:
5404
- timeStep = _context4.sent;
5405
- _context4.next = 32;
5406
- return put(mapActions.mapStartAnimation({
5407
- mapId: mapId,
5408
- start: start,
5409
- end: end,
5410
- interval: timeStep
5411
- }));
5412
- case 32:
5413
5534
  case "end":
5414
5535
  return _context4.stop();
5415
5536
  }
5416
- }, _marked$6);
5537
+ }, _marked$5);
5417
5538
  }
5418
- function setLayerDimensionsSaga(_ref4) {
5539
+ function updateAnimationWithLatestUpdate(_ref4) {
5419
5540
  var payload = _ref4.payload;
5420
5541
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
5421
- var layerDimensions, dimensions, layerId, layer, newTimeDimension, mapId, autoUpdateLayerId, shouldAutoUpdate, prevTimeDimension, isAnimating$1, webmapInstance, isAutoUpdateLayer, incomingMaxTime, isIncomingMaxTimeLaterThanCurrentLayerTime, syncedMapIds;
5542
+ var layerDimensions, dimensions, layerId, layer, newTimeDimension, mapId, autoUpdateLayerId, shouldAutoUpdate, prevTimeDimension, isAutoUpdateLayer, incomingMaxTime, isIncomingMaxTimeLaterThanCurrentLayerTime;
5422
5543
  return _regeneratorRuntime().wrap(function _callee4$(_context5) {
5423
5544
  while (1) switch (_context5.prev = _context5.next) {
5424
5545
  case 0:
@@ -5457,76 +5578,30 @@ function setLayerDimensionsSaga(_ref4) {
5457
5578
  return select(getLayerTimeDimension, layerId);
5458
5579
  case 20:
5459
5580
  prevTimeDimension = _context5.sent;
5460
- _context5.next = 23;
5461
- return select(isAnimating, mapId);
5462
- case 23:
5463
- isAnimating$1 = _context5.sent;
5464
- webmapInstance = webmapUtils.getWMJSMapById(mapId);
5465
5581
  isAutoUpdateLayer = layerId === autoUpdateLayerId;
5466
5582
  incomingMaxTime = newTimeDimension === null || newTimeDimension === void 0 ? void 0 : newTimeDimension.maxValue;
5467
5583
  isIncomingMaxTimeLaterThanCurrentLayerTime = incomingMaxTime && (prevTimeDimension === null || prevTimeDimension === void 0 ? void 0 : prevTimeDimension.currentValue) && prevTimeDimension.currentValue !== incomingMaxTime;
5468
5584
  if (!(isAutoUpdateLayer &&
5469
5585
  // only update the active layer
5470
5586
  shouldAutoUpdate && isIncomingMaxTimeLaterThanCurrentLayerTime)) {
5471
- _context5.next = 42;
5472
- break;
5473
- }
5474
- if (isAnimating$1) {
5475
- _context5.next = 32;
5476
- break;
5477
- }
5478
- _context5.next = 32;
5479
- return put(layerActions.layerChangeDimension({
5480
- layerId: layerId,
5481
- origin: LayerActionOrigin.setLayerDimensionSaga,
5482
- dimension: {
5483
- name: 'time',
5484
- currentValue: incomingMaxTime
5485
- }
5486
- }));
5487
- case 32:
5488
- _context5.next = 34;
5489
- return select(getSyncedMapIdsForTimeslider);
5490
- case 34:
5491
- syncedMapIds = _context5.sent;
5492
- if (!syncedMapIds) {
5493
- _context5.next = 38;
5494
- break;
5495
- }
5496
- _context5.next = 38;
5497
- return all(syncedMapIds.map(function (syncedMapId) {
5498
- return put(setTime({
5499
- origin: 'mapStore saga',
5500
- sourceId: syncedMapId,
5501
- value: incomingMaxTime
5502
- }));
5503
- }));
5504
- case 38:
5505
- _context5.next = 40;
5506
- return call(updateAnimation, mapId, incomingMaxTime);
5507
- case 40:
5508
- _context5.next = 45;
5509
- break;
5510
- case 42:
5511
- if (!(isAnimating$1 && !webmapInstance.isAnimating && incomingMaxTime)) {
5512
- _context5.next = 45;
5587
+ _context5.next = 27;
5513
5588
  break;
5514
5589
  }
5515
- _context5.next = 45;
5590
+ _context5.next = 27;
5516
5591
  return call(updateAnimation, mapId, incomingMaxTime);
5517
- case 45:
5518
- _context5.next = 50;
5592
+ case 27:
5593
+ _context5.next = 32;
5519
5594
  break;
5520
- case 47:
5521
- _context5.prev = 47;
5595
+ case 29:
5596
+ _context5.prev = 29;
5522
5597
  _context5.t0 = _context5["catch"](0);
5523
5598
  // eslint-disable-next-line no-console
5524
5599
  console.warn(_context5.t0);
5525
- case 50:
5600
+ case 32:
5526
5601
  case "end":
5527
5602
  return _context5.stop();
5528
5603
  }
5529
- }, _callee4, null, [[0, 47]]);
5604
+ }, _callee4, null, [[0, 29]]);
5530
5605
  })();
5531
5606
  }
5532
5607
  function toggleAutoUpdateSaga(_ref5) {
@@ -5664,7 +5739,7 @@ function handleBaseLayersSaga(mapId, baseLayers) {
5664
5739
  case "end":
5665
5740
  return _context7.stop();
5666
5741
  }
5667
- }, _marked2$4);
5742
+ }, _marked2$3);
5668
5743
  }
5669
5744
  function setMapPresetSaga(_ref6) {
5670
5745
  var payload = _ref6.payload;
@@ -6019,7 +6094,8 @@ function unregisterMapSaga(_ref7) {
6019
6094
  return select(getLayersByMapId, mapId);
6020
6095
  case 3:
6021
6096
  layerList = _context9.sent;
6022
- _context9.next = 6;
6097
+ metronome.unregister(mapId);
6098
+ _context9.next = 7;
6023
6099
  return all(layerList.map(function (layer) {
6024
6100
  return put(layerActions.layerDelete({
6025
6101
  mapId: mapId,
@@ -6028,7 +6104,7 @@ function unregisterMapSaga(_ref7) {
6028
6104
  origin: LayerActionOrigin.unregisterMapSaga
6029
6105
  }));
6030
6106
  }));
6031
- case 6:
6107
+ case 7:
6032
6108
  case "end":
6033
6109
  return _context9.stop();
6034
6110
  }
@@ -6100,42 +6176,184 @@ function setStepBackwardOrForwardSaga(_ref8) {
6100
6176
  }, _callee8);
6101
6177
  })();
6102
6178
  }
6103
- function rootSaga$5() {
6104
- return _regeneratorRuntime().wrap(function rootSaga$(_context11) {
6105
- while (1) switch (_context11.prev = _context11.next) {
6179
+ /**
6180
+ * This saga is triggered by the metronome. An array of timerIds is given as argument.
6181
+ * It will update the animation loop of multiple maps and sliders
6182
+ * It will prefetch images for maps
6183
+ * @param timerIds string[] array of timerIds
6184
+ */
6185
+ function metronomeSaga(timerIds) {
6186
+ var targetsWithUpdateValue, _iterator, _step, _loop;
6187
+ return _regeneratorRuntime().wrap(function metronomeSaga$(_context12) {
6188
+ while (1) switch (_context12.prev = _context12.next) {
6106
6189
  case 0:
6107
- _context11.next = 2;
6190
+ targetsWithUpdateValue = [];
6191
+ _iterator = _createForOfIteratorHelper(timerIds);
6192
+ _context12.prev = 2;
6193
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
6194
+ var timerId, animationListValuesNameAndValue, animationListValues, targets, timerShouldStepForward, timerStep, updatedValue, speedDelay, speed;
6195
+ return _regeneratorRuntime().wrap(function _loop$(_context11) {
6196
+ while (1) switch (_context11.prev = _context11.next) {
6197
+ case 0:
6198
+ timerId = _step.value;
6199
+ _context11.next = 3;
6200
+ return select(getAnimationList, timerId);
6201
+ case 3:
6202
+ animationListValuesNameAndValue = _context11.sent;
6203
+ animationListValues = animationListValuesNameAndValue.map(function (nameAndValue) {
6204
+ return nameAndValue.value;
6205
+ });
6206
+ _context11.next = 7;
6207
+ return select(getTargets, {
6208
+ sourceId: timerId,
6209
+ origin: timerId
6210
+ }, SYNCGROUPS_TYPE_SETTIME);
6211
+ case 7:
6212
+ targets = _context11.sent;
6213
+ if (targets.length === 0) {
6214
+ // When there are no targets, default to one
6215
+ targets.push({
6216
+ targetId: timerId,
6217
+ value: ''
6218
+ });
6219
+ }
6220
+ timerShouldStepForward = prefetchAnimationTargetsForSaga(timerId, animationListValues, targets); // Determine the next step
6221
+ timerStep = timerShouldStepForward ? getNextStep(timerId, animationListValues.length) : getCurrentStep(timerId);
6222
+ setStep(timerId, timerStep);
6223
+ updatedValue = animationListValues[timerStep];
6224
+ targetsWithUpdateValue.push.apply(targetsWithUpdateValue, _toConsumableArray(targets.map(function (target) {
6225
+ return Object.assign(Object.assign({}, target), {
6226
+ value: updatedValue
6227
+ });
6228
+ })));
6229
+ _context11.next = 16;
6230
+ return select(getMapAnimationDelay, timerId);
6231
+ case 16:
6232
+ speedDelay = _context11.sent;
6233
+ speed = 1000 / (speedDelay || 1);
6234
+ metronome.setSpeed(timerId, speed);
6235
+ case 19:
6236
+ case "end":
6237
+ return _context11.stop();
6238
+ }
6239
+ }, _loop);
6240
+ });
6241
+ _iterator.s();
6242
+ case 5:
6243
+ if ((_step = _iterator.n()).done) {
6244
+ _context12.next = 9;
6245
+ break;
6246
+ }
6247
+ return _context12.delegateYield(_loop(), "t0", 7);
6248
+ case 7:
6249
+ _context12.next = 5;
6250
+ break;
6251
+ case 9:
6252
+ _context12.next = 14;
6253
+ break;
6254
+ case 11:
6255
+ _context12.prev = 11;
6256
+ _context12.t1 = _context12["catch"](2);
6257
+ _iterator.e(_context12.t1);
6258
+ case 14:
6259
+ _context12.prev = 14;
6260
+ _iterator.f();
6261
+ return _context12.finish(14);
6262
+ case 17:
6263
+ if (!(targetsWithUpdateValue.length > 0)) {
6264
+ _context12.next = 20;
6265
+ break;
6266
+ }
6267
+ _context12.next = 20;
6268
+ return put(setTimeSync(null, targetsWithUpdateValue, ['metronomesaga']));
6269
+ case 20:
6270
+ case "end":
6271
+ return _context12.stop();
6272
+ }
6273
+ }, _marked3$1, null, [[2, 11, 14, 17]]);
6274
+ }
6275
+ /**
6276
+ * Creates a channel for the metronome
6277
+ * @returns
6278
+ */
6279
+ function metronomeTicker() {
6280
+ return eventChannel(function (emitter) {
6281
+ metronome.handleTimerTicks = function (timerIds) {
6282
+ emitter(timerIds);
6283
+ };
6284
+ // The subscriber must return an unsubscribe function
6285
+ return function () {
6286
+ metronome.unregisterAllTimers();
6287
+ };
6288
+ });
6289
+ }
6290
+ /**
6291
+ * Makes a saga channel for the metronome ticker
6292
+ */
6293
+ function metronomeSagaWithChannel() {
6294
+ var channel, metronomeHandler;
6295
+ return _regeneratorRuntime().wrap(function metronomeSagaWithChannel$(_context13) {
6296
+ while (1) switch (_context13.prev = _context13.next) {
6297
+ case 0:
6298
+ _context13.next = 2;
6299
+ return call(metronomeTicker);
6300
+ case 2:
6301
+ channel = _context13.sent;
6302
+ case 3:
6303
+ _context13.next = 6;
6304
+ return take(channel);
6305
+ case 6:
6306
+ metronomeHandler = _context13.sent;
6307
+ _context13.next = 9;
6308
+ return call(metronomeSaga, metronomeHandler);
6309
+ case 9:
6310
+ _context13.next = 3;
6311
+ break;
6312
+ case 11:
6313
+ case "end":
6314
+ return _context13.stop();
6315
+ }
6316
+ }, _marked4);
6317
+ }
6318
+ function rootSaga$4() {
6319
+ return _regeneratorRuntime().wrap(function rootSaga$(_context14) {
6320
+ while (1) switch (_context14.prev = _context14.next) {
6321
+ case 0:
6322
+ _context14.next = 2;
6108
6323
  return takeLatest(mapActions.mapStopAnimation.type, stopAnimationSaga);
6109
6324
  case 2:
6110
- _context11.next = 4;
6325
+ _context14.next = 4;
6111
6326
  return takeLatest(mapActions.mapStartAnimation.type, startAnimationSaga);
6112
6327
  case 4:
6113
- _context11.next = 6;
6328
+ _context14.next = 6;
6114
6329
  return takeLatest(layerActions.layerDelete.type, deleteLayerSaga);
6115
6330
  case 6:
6116
- _context11.next = 8;
6117
- return takeLatest(layerActions.onUpdateLayerInformation.type, setLayerDimensionsSaga);
6331
+ _context14.next = 8;
6332
+ return takeLatest(layerActions.onUpdateLayerInformation.type, updateAnimationWithLatestUpdate);
6118
6333
  case 8:
6119
- _context11.next = 10;
6334
+ _context14.next = 10;
6120
6335
  return takeLatest(mapActions.toggleAutoUpdate.type, toggleAutoUpdateSaga);
6121
6336
  case 10:
6122
- _context11.next = 12;
6337
+ _context14.next = 12;
6123
6338
  return takeEvery(mapActions.setMapPreset.type, setMapPresetSaga);
6124
6339
  case 12:
6125
- _context11.next = 14;
6340
+ _context14.next = 14;
6126
6341
  return takeEvery(mapActions.unregisterMap.type, unregisterMapSaga);
6127
6342
  case 14:
6128
- _context11.next = 16;
6343
+ _context14.next = 16;
6129
6344
  return takeEvery(mapActions.setStepBackwardOrForward.type, setStepBackwardOrForwardSaga);
6130
6345
  case 16:
6346
+ _context14.next = 18;
6347
+ return call(metronomeSagaWithChannel);
6348
+ case 18:
6131
6349
  case "end":
6132
- return _context11.stop();
6350
+ return _context14.stop();
6133
6351
  }
6134
- }, _marked3$2);
6352
+ }, _marked5);
6135
6353
  }
6136
6354
 
6137
- var _marked$5 = /*#__PURE__*/_regeneratorRuntime().mark(fetchServiceSaga),
6138
- _marked2$3 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$4);
6355
+ var _marked$4 = /*#__PURE__*/_regeneratorRuntime().mark(fetchServiceSaga),
6356
+ _marked2$2 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$3);
6139
6357
  function fetchServiceSaga(service) {
6140
6358
  var layers;
6141
6359
  return _regeneratorRuntime().wrap(function fetchServiceSaga$(_context) {
@@ -6160,7 +6378,7 @@ function fetchServiceSaga(service) {
6160
6378
  case "end":
6161
6379
  return _context.stop();
6162
6380
  }
6163
- }, _marked$5, null, [[0, 8]]);
6381
+ }, _marked$4, null, [[0, 8]]);
6164
6382
  }
6165
6383
  function fetchInitialServicesSaga(_ref) {
6166
6384
  var payload = _ref.payload;
@@ -6181,7 +6399,7 @@ function fetchInitialServicesSaga(_ref) {
6181
6399
  }, _callee);
6182
6400
  })();
6183
6401
  }
6184
- function rootSaga$4() {
6402
+ function rootSaga$3() {
6185
6403
  return _regeneratorRuntime().wrap(function rootSaga$(_context3) {
6186
6404
  while (1) switch (_context3.prev = _context3.next) {
6187
6405
  case 0:
@@ -6191,7 +6409,7 @@ function rootSaga$4() {
6191
6409
  case "end":
6192
6410
  return _context3.stop();
6193
6411
  }
6194
- }, _marked2$3);
6412
+ }, _marked2$2);
6195
6413
  }
6196
6414
 
6197
6415
  // TODO: This fixes typecheck errors but maybe there is a better way to do that
@@ -6206,7 +6424,7 @@ var mapStoreReducers = {
6206
6424
  var mapStoreModuleConfig = {
6207
6425
  id: 'webmap-module',
6208
6426
  reducersMap: mapStoreReducers,
6209
- sagas: [rootSaga$5, rootSaga$4]
6427
+ sagas: [rootSaga$4, rootSaga$3]
6210
6428
  };
6211
6429
 
6212
6430
  /* *
@@ -6429,7 +6647,7 @@ var getMapBaseLayerActionsTargets = function getMapBaseLayerActionsTargets(state
6429
6647
  });
6430
6648
  };
6431
6649
 
6432
- var _marked$4 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$3);
6650
+ var _marked$3 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$2);
6433
6651
  var setTimeValidatorRexexp = /^(19|20)\d\d-(0[1-9]|1[012])-([012]\d|3[01])T([01]\d|2[0-3]):([0-5]\d):([0-5]\d)Z$/;
6434
6652
  function setTimeSaga(_ref) {
6435
6653
  var payload = _ref.payload;
@@ -6702,7 +6920,7 @@ function mapBaseLayerActionsSaga(_ref9) {
6702
6920
  }, _callee9);
6703
6921
  })();
6704
6922
  }
6705
- function rootSaga$3() {
6923
+ function rootSaga$2() {
6706
6924
  return _regeneratorRuntime().wrap(function rootSaga$(_context10) {
6707
6925
  while (1) switch (_context10.prev = _context10.next) {
6708
6926
  case 0:
@@ -6748,7 +6966,7 @@ function rootSaga$3() {
6748
6966
  case "end":
6749
6967
  return _context10.stop();
6750
6968
  }
6751
- }, _marked$4);
6969
+ }, _marked$3);
6752
6970
  }
6753
6971
 
6754
6972
  /* *
@@ -6809,8 +7027,8 @@ var utils = /*#__PURE__*/Object.freeze({
6809
7027
  historyDict: historyDict
6810
7028
  });
6811
7029
 
6812
- var _marked$3 = /*#__PURE__*/_regeneratorRuntime().mark(navigateToUrlSaga),
6813
- _marked2$2 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$2);
7030
+ var _marked$2 = /*#__PURE__*/_regeneratorRuntime().mark(navigateToUrlSaga),
7031
+ _marked2$1 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$1);
6814
7032
  function navigateToUrlSaga(action) {
6815
7033
  var payload;
6816
7034
  return _regeneratorRuntime().wrap(function navigateToUrlSaga$(_context) {
@@ -6823,9 +7041,9 @@ function navigateToUrlSaga(action) {
6823
7041
  case "end":
6824
7042
  return _context.stop();
6825
7043
  }
6826
- }, _marked$3);
7044
+ }, _marked$2);
6827
7045
  }
6828
- function rootSaga$2() {
7046
+ function rootSaga$1() {
6829
7047
  return _regeneratorRuntime().wrap(function rootSaga$(_context2) {
6830
7048
  while (1) switch (_context2.prev = _context2.next) {
6831
7049
  case 0:
@@ -6835,7 +7053,7 @@ function rootSaga$2() {
6835
7053
  case "end":
6836
7054
  return _context2.stop();
6837
7055
  }
6838
- }, _marked2$2);
7056
+ }, _marked2$1);
6839
7057
  }
6840
7058
 
6841
7059
  /* *
@@ -6859,7 +7077,7 @@ var routerModuleConfig = {
6859
7077
  reducersMap: {
6860
7078
  router: reducer$2
6861
7079
  },
6862
- sagas: [rootSaga$2]
7080
+ sagas: [rootSaga$1]
6863
7081
  };
6864
7082
 
6865
7083
  /* *
@@ -7153,6 +7371,11 @@ var getGeoJSONIntersectionBoundsLayerId = createSelector(selectDrawToolById, fun
7153
7371
  var getShouldAllowMultipleShapes = createSelector(selectDrawToolById, function (drawingTool) {
7154
7372
  return (drawingTool === null || drawingTool === void 0 ? void 0 : drawingTool.shouldAllowMultipleShapes) || false;
7155
7373
  });
7374
+ var getActiveDrawMode = createSelector(selectDrawToolById, function (drawingTool) {
7375
+ return drawingTool === null || drawingTool === void 0 ? void 0 : drawingTool.drawModes.find(function (mode) {
7376
+ return mode.drawModeId === drawingTool.activeDrawModeId;
7377
+ });
7378
+ });
7156
7379
 
7157
7380
  var selectors = /*#__PURE__*/Object.freeze({
7158
7381
  __proto__: null,
@@ -7165,10 +7388,11 @@ var selectors = /*#__PURE__*/Object.freeze({
7165
7388
  getDrawToolGeoJSONLayerId: getDrawToolGeoJSONLayerId,
7166
7389
  getGeoJSONIntersectionLayerId: getGeoJSONIntersectionLayerId,
7167
7390
  getGeoJSONIntersectionBoundsLayerId: getGeoJSONIntersectionBoundsLayerId,
7168
- getShouldAllowMultipleShapes: getShouldAllowMultipleShapes
7391
+ getShouldAllowMultipleShapes: getShouldAllowMultipleShapes,
7392
+ getActiveDrawMode: getActiveDrawMode
7169
7393
  });
7170
7394
 
7171
- var _marked$2 = /*#__PURE__*/_regeneratorRuntime().mark(drawingSaga);
7395
+ var _marked$1 = /*#__PURE__*/_regeneratorRuntime().mark(drawingSaga);
7172
7396
  var registerOrigin = 'drawings saga:registerDrawToolSaga';
7173
7397
  function registerDrawToolSaga(_ref) {
7174
7398
  var payload = _ref.payload;
@@ -7278,7 +7502,7 @@ function changeDrawToolSaga(_ref2) {
7278
7502
  case 14:
7279
7503
  geoJSONLayer = _context2.sent;
7280
7504
  geoJSON = geoJSONLayer === null || geoJSONLayer === void 0 ? void 0 : geoJSONLayer.geojson;
7281
- lastFeatureIndex = geoJSON !== undefined && getLastEmptyFeatureIndex(geoJSON) || undefined;
7505
+ lastFeatureIndex = geoJSON !== undefined ? getLastEmptyFeatureIndex(geoJSON) : undefined;
7282
7506
  if (!(lastFeatureIndex !== undefined)) {
7283
7507
  _context2.next = 23;
7284
7508
  break;
@@ -7439,7 +7663,7 @@ function drawingSaga() {
7439
7663
  case "end":
7440
7664
  return _context4.stop();
7441
7665
  }
7442
- }, _marked$2);
7666
+ }, _marked$1);
7443
7667
  }
7444
7668
 
7445
7669
  /* *
@@ -7783,9 +8007,9 @@ var storeTestUtils = /*#__PURE__*/Object.freeze({
7783
8007
  mockStateMapWithTimeStepWithoutLayers: mockStateMapWithTimeStepWithoutLayers
7784
8008
  });
7785
8009
 
7786
- var _marked$1 = /*#__PURE__*/_regeneratorRuntime().mark(updateSourceValueWhenLinkingComponentToGroupSaga),
7787
- _marked2$1 = /*#__PURE__*/_regeneratorRuntime().mark(updateViewStateSaga),
7788
- _marked3$1 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga$1);
8010
+ var _marked = /*#__PURE__*/_regeneratorRuntime().mark(updateSourceValueWhenLinkingComponentToGroupSaga),
8011
+ _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(updateViewStateSaga),
8012
+ _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga);
7789
8013
  function updateSourceValueWhenLinkingComponentToGroupSaga(groupId, targetToUpdate) {
7790
8014
  var group;
7791
8015
  return _regeneratorRuntime().wrap(function updateSourceValueWhenLinkingComponentToGroupSaga$(_context) {
@@ -7837,7 +8061,7 @@ function updateSourceValueWhenLinkingComponentToGroupSaga(groupId, targetToUpdat
7837
8061
  case "end":
7838
8062
  return _context.stop();
7839
8063
  }
7840
- }, _marked$1);
8064
+ }, _marked);
7841
8065
  }
7842
8066
  function addGroupTargetSaga(_ref) {
7843
8067
  var payload = _ref.payload;
@@ -7898,9 +8122,9 @@ function updateViewStateSaga() {
7898
8122
  case "end":
7899
8123
  return _context4.stop();
7900
8124
  }
7901
- }, _marked2$1);
8125
+ }, _marked2);
7902
8126
  }
7903
- function rootSaga$1() {
8127
+ function rootSaga() {
7904
8128
  return _regeneratorRuntime().wrap(function rootSaga$(_context5) {
7905
8129
  while (1) switch (_context5.prev = _context5.next) {
7906
8130
  case 0:
@@ -7934,7 +8158,7 @@ function rootSaga$1() {
7934
8158
  case "end":
7935
8159
  return _context5.stop();
7936
8160
  }
7937
- }, _marked3$1);
8161
+ }, _marked3);
7938
8162
  }
7939
8163
 
7940
8164
  var synchronizationGroupConfig = {
@@ -7942,99 +8166,67 @@ var synchronizationGroupConfig = {
7942
8166
  reducersMap: {
7943
8167
  syncronizationGroupStore: reducer$4
7944
8168
  },
7945
- sagas: [rootSaga$3, rootSaga$1]
8169
+ sagas: [rootSaga$2, rootSaga]
7946
8170
  };
7947
8171
 
7948
- var _marked = /*#__PURE__*/_regeneratorRuntime().mark(registerMapUISaga),
7949
- _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(unregisterUIMapSaga),
7950
- _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(rootSaga);
7951
- function registerMapUISaga() {
7952
- var fields, source;
7953
- return _regeneratorRuntime().wrap(function registerMapUISaga$(_context) {
7954
- while (1) switch (_context.prev = _context.next) {
7955
- case 0:
7956
- _context.next = 2;
7957
- return select(getAllMapIds);
7958
- case 2:
7959
- fields = _context.sent;
7960
- if (!(fields.length === 1)) {
7961
- _context.next = 9;
7962
- break;
7963
- }
7964
- _context.next = 6;
7965
- return select(getDialogSource, 'legend');
7966
- case 6:
7967
- source = _context.sent;
7968
- _context.next = 9;
7969
- return put(uiActions.setActiveMapIdForDialog({
7970
- type: 'legend',
7971
- mapId: fields[0],
7972
- setOpen: true,
7973
- source: source
7974
- }));
7975
- case 9:
7976
- case "end":
7977
- return _context.stop();
7978
- }
7979
- }, _marked);
7980
- }
7981
- function unregisterUIMapSaga() {
7982
- var fields, activeUI;
7983
- return _regeneratorRuntime().wrap(function unregisterUIMapSaga$(_context2) {
7984
- while (1) switch (_context2.prev = _context2.next) {
7985
- case 0:
7986
- _context2.next = 2;
7987
- return select(getAllMapIds);
7988
- case 2:
7989
- fields = _context2.sent;
7990
- _context2.next = 5;
7991
- return select(getDialogDetailsByType, 'legend');
7992
- case 5:
7993
- activeUI = _context2.sent;
7994
- if (!(fields.length && activeUI && !fields.includes(activeUI.activeMapId))) {
7995
- _context2.next = 11;
7996
- break;
8172
+ var uiListener = createListenerMiddleware();
8173
+ uiListener.startListening({
8174
+ actionCreator: mapActions.registerMap,
8175
+ effect: function effect(_, listenerApi) {
8176
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8177
+ var fields, source;
8178
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8179
+ while (1) switch (_context.prev = _context.next) {
8180
+ case 0:
8181
+ fields = getAllMapIds(listenerApi.getState());
8182
+ if (fields.length === 1) {
8183
+ source = getDialogSource(listenerApi.getState(), 'legend');
8184
+ listenerApi.dispatch(uiActions.setActiveMapIdForDialog({
8185
+ type: 'legend',
8186
+ mapId: fields[0],
8187
+ setOpen: true,
8188
+ source: source
8189
+ }));
8190
+ }
8191
+ case 2:
8192
+ case "end":
8193
+ return _context.stop();
7997
8194
  }
7998
- _context2.next = 9;
7999
- return put(uiActions.setActiveMapIdForDialog({
8000
- type: 'legend',
8001
- mapId: fields[0],
8002
- setOpen: activeUI.isOpen
8003
- }));
8004
- case 9:
8005
- _context2.next = 14;
8006
- break;
8007
- case 11:
8008
- if (fields.length) {
8009
- _context2.next = 14;
8010
- break;
8195
+ }, _callee);
8196
+ }));
8197
+ }
8198
+ });
8199
+ uiListener.startListening({
8200
+ actionCreator: mapActions.unregisterMap,
8201
+ effect: function effect(_, listenerApi) {
8202
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
8203
+ var fields, activeUI;
8204
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8205
+ while (1) switch (_context2.prev = _context2.next) {
8206
+ case 0:
8207
+ fields = getAllMapIds(listenerApi.getState());
8208
+ activeUI = getDialogDetailsByType(listenerApi.getState(), 'legend');
8209
+ if (fields.length && activeUI && !fields.includes(activeUI.activeMapId)) {
8210
+ listenerApi.dispatch(uiActions.setActiveMapIdForDialog({
8211
+ type: 'legend',
8212
+ mapId: fields[0],
8213
+ setOpen: activeUI.isOpen
8214
+ }));
8215
+ } else if (!fields.length) {
8216
+ // if no more maps, we hide the legend
8217
+ listenerApi.dispatch(uiActions.setToggleOpenDialog({
8218
+ type: 'legend',
8219
+ setOpen: false
8220
+ }));
8221
+ }
8222
+ case 3:
8223
+ case "end":
8224
+ return _context2.stop();
8011
8225
  }
8012
- _context2.next = 14;
8013
- return put(uiActions.setToggleOpenDialog({
8014
- type: 'legend',
8015
- setOpen: false
8016
- }));
8017
- case 14:
8018
- case "end":
8019
- return _context2.stop();
8020
- }
8021
- }, _marked2);
8022
- }
8023
- function rootSaga() {
8024
- return _regeneratorRuntime().wrap(function rootSaga$(_context3) {
8025
- while (1) switch (_context3.prev = _context3.next) {
8026
- case 0:
8027
- _context3.next = 2;
8028
- return takeLatest(mapActions.registerMap.type, registerMapUISaga);
8029
- case 2:
8030
- _context3.next = 4;
8031
- return takeLatest(mapActions.unregisterMap.type, unregisterUIMapSaga);
8032
- case 4:
8033
- case "end":
8034
- return _context3.stop();
8035
- }
8036
- }, _marked3);
8037
- }
8226
+ }, _callee2);
8227
+ }));
8228
+ }
8229
+ });
8038
8230
 
8039
8231
  /* *
8040
8232
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -8057,7 +8249,7 @@ var uiModuleConfig = {
8057
8249
  reducersMap: {
8058
8250
  ui: reducer$6
8059
8251
  },
8060
- sagas: [rootSaga]
8252
+ middlewares: [uiListener.middleware]
8061
8253
  };
8062
8254
 
8063
8255
  /* *
@@ -8099,12 +8291,9 @@ var createStore = function createStore() {
8099
8291
  extensions: [getSagaExtension({})]
8100
8292
  });
8101
8293
  };
8102
- var ThemeWrapperWithModules = withEggs(coreModuleConfig)(function (_ref) {
8103
- var theme = _ref.theme,
8104
- children = _ref.children;
8105
- return /*#__PURE__*/React.createElement(ThemeWrapper, {
8106
- theme: theme
8107
- }, children, " ");
8294
+ var WrapperWithModules = withEggs(coreModuleConfig)(function (_ref) {
8295
+ var children = _ref.children;
8296
+ return children;
8108
8297
  });
8109
8298
  /**
8110
8299
  * A Provider component which provides the GeoWeb theme and store for the core.
@@ -8112,16 +8301,12 @@ var ThemeWrapperWithModules = withEggs(coreModuleConfig)(function (_ref) {
8112
8301
  * @param children
8113
8302
  * @returns
8114
8303
  */
8115
- var ThemeStoreProvider = function ThemeStoreProvider(_ref2) {
8304
+ var StoreProvider = function StoreProvider(_ref2) {
8116
8305
  var children = _ref2.children,
8117
- _ref2$theme = _ref2.theme,
8118
- theme = _ref2$theme === void 0 ? lightTheme : _ref2$theme,
8119
8306
  store = _ref2.store;
8120
8307
  return /*#__PURE__*/React.createElement(Provider, {
8121
8308
  store: store
8122
- }, /*#__PURE__*/React.createElement(ThemeWrapperWithModules, {
8123
- theme: theme
8124
- }, children));
8309
+ }, /*#__PURE__*/React.createElement(WrapperWithModules, null, children));
8125
8310
  };
8126
8311
 
8127
8312
  /* *
@@ -8225,4 +8410,4 @@ var useSetupDialog = function useSetupDialog(dialogType) {
8225
8410
  };
8226
8411
  };
8227
8412
 
8228
- export { ThemeStoreProvider, appActions, appModuleConfig, coreModuleConfig, createStore, drawtoolActions, drawtoolModuleConfig, reducer as drawtoolReducer, selectors as drawtoolSelectors, filterLayers$1 as filterLayers, genericActions, rootSaga$3 as genericSaga, selectors$3 as genericSelectors, types$1 as genericTypes, getSingularDrawtoolDrawLayerId, initialState$4 as initialState, layerActions, reducer$7 as layerReducer, selectors$6 as layerSelectors, types$5 as layerTypes, utils$2 as layerUtils, mapActions, constants$1 as mapConstants, enums as mapEnums, rootSaga$5 as mapSaga, selectors$2 as mapSelectors, mapStoreActions, mapStoreModuleConfig, mapStoreReducers, types$4 as mapTypes, mapUtils, routerActions, routerModuleConfig, utils as routerUtils, selectorMemoizationOptions, serviceActions, selectors$1 as serviceSelectors, types as serviceTypes, storeTestSettings, storeTestUtils, utils$1 as storeUtils, constants as syncConstants, actions as syncGroupsActions, reducer$4 as syncGroupsReducer, selector as syncGroupsSelector, selectors$4 as syncGroupsSelectors, types$2 as syncGroupsTypes, types$2 as types, uiActions, uiModuleConfig, reducer$6 as uiReducer, selectors$5 as uiSelectors, types$3 as uiTypes, useSetupDialog, reducer$5 as webmapReducer };
8413
+ export { StoreProvider, appActions, appModuleConfig, coreModuleConfig, createStore, drawtoolActions, drawtoolModuleConfig, reducer as drawtoolReducer, selectors as drawtoolSelectors, filterLayers$1 as filterLayers, genericActions, rootSaga$2 as genericSaga, selectors$3 as genericSelectors, types$1 as genericTypes, getSingularDrawtoolDrawLayerId, initialState$4 as initialState, layerActions, reducer$7 as layerReducer, selectors$6 as layerSelectors, types$5 as layerTypes, utils$2 as layerUtils, mapActions, constants$1 as mapConstants, enums as mapEnums, rootSaga$4 as mapSaga, selectors$2 as mapSelectors, mapStoreActions, mapStoreModuleConfig, mapStoreReducers, types$4 as mapTypes, mapUtils, routerActions, routerModuleConfig, utils as routerUtils, selectorMemoizationOptions, serviceActions, selectors$1 as serviceSelectors, types as serviceTypes, storeTestSettings, storeTestUtils, utils$1 as storeUtils, constants as syncConstants, actions as syncGroupsActions, reducer$4 as syncGroupsReducer, selector as syncGroupsSelector, selectors$4 as syncGroupsSelectors, types$2 as syncGroupsTypes, types$2 as types, uiActions, uiModuleConfig, reducer$6 as uiReducer, selectors$5 as uiSelectors, types$3 as uiTypes, useSetupDialog, reducer$5 as webmapReducer };