@opengeoweb/shared 9.4.1 → 9.6.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.
package/index.esm.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useRef } from 'react';
3
3
  import { Box, Typography, Tooltip, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, Alert, AlertTitle, useTheme, Drawer, Link, Avatar as Avatar$1, Paper, ClickAwayListener, MenuList, MenuItem, Grid, RadioGroup, FormControlLabel, Radio, List, ListItem, Tabs, Tab, Backdrop, Slider, ToggleButton, Menu, ListSubheader, ListItemText, ListItemIcon, Select, Accordion, AccordionSummary, AccordionDetails, FormLabel, Switch, TextField, InputAdornment } from '@mui/material';
4
- import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, HamburgerMenu, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, ChevronDown, Search, Clear } from '@opengeoweb/theme';
4
+ import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, HamburgerMenu, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, ChevronDown, Search, Clear, Cached } from '@opengeoweb/theme';
5
5
  import { throttle, escapeRegExp, debounce } from 'lodash';
6
6
  import Draggable from 'react-draggable';
7
7
  import { Resizable } from 're-resizable';
8
8
  import { useStore } from 'react-redux';
9
- import { parseISO, parse, format, isEqual, add as add$1, sub as sub$1, differenceInMinutes as differenceInMinutes$1, differenceInHours as differenceInHours$1, isBefore as isBefore$1, isAfter as isAfter$1, isValid as isValid$1, getUnixTime, set as set$1 } from 'date-fns';
9
+ import { parseISO, parse, format, isEqual, add as add$1, sub as sub$1, differenceInMinutes as differenceInMinutes$1, differenceInHours as differenceInHours$1, isBefore as isBefore$1, isAfter as isAfter$1, isValid as isValid$1, getUnixTime, fromUnixTime, set as set$1 } from 'date-fns';
10
+ import configureStore from 'redux-mock-store';
10
11
  import { configureStore as configureStore$1 } from '@reduxjs/toolkit';
11
12
 
12
13
  /******************************************************************************
@@ -153,7 +154,7 @@ function _createClass(Constructor, protoProps, staticProps) {
153
154
  });
154
155
  return Constructor;
155
156
  }
156
- function _defineProperty$1(obj, key, value) {
157
+ function _defineProperty(obj, key, value) {
157
158
  key = _toPropertyKey(key);
158
159
  if (key in obj) {
159
160
  Object.defineProperty(obj, key, {
@@ -241,7 +242,7 @@ function _slicedToArray(arr, i) {
241
242
  function _toArray(arr) {
242
243
  return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
243
244
  }
244
- function _toConsumableArray$1(arr) {
245
+ function _toConsumableArray(arr) {
245
246
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
246
247
  }
247
248
  function _arrayWithoutHoles(arr) {
@@ -320,7 +321,7 @@ var CustomIconButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
320
321
  className = _a.className,
321
322
  defaultTooltipProps = _a.tooltipProps,
322
323
  props = __rest(_a, ["tooltipTitle", "variant", "isSelected", "shouldShowAsDisabled", "size", "children", "className", "tooltipProps"]);
323
- var classNames = [].concat(_toConsumableArray$1(className ? [className] : []), _toConsumableArray$1(isSelected ? ['Mui-selected'] : []), [variant]).join(' ');
324
+ var classNames = [].concat(_toConsumableArray(className ? [className] : []), _toConsumableArray(isSelected ? ['Mui-selected'] : []), [variant]).join(' ');
324
325
  var tooltipTitle = (defaultTooltipProps === null || defaultTooltipProps === void 0 ? void 0 : defaultTooltipProps.title) || defaultTooltipTitle;
325
326
  var tooltipProps = Object.assign(Object.assign({}, defaultTooltipProps), {
326
327
  title: tooltipTitle,
@@ -997,7 +998,7 @@ var AppHeader = function AppHeader(_ref) {
997
998
  return /*#__PURE__*/React__default.createElement(Box, {
998
999
  component: "header",
999
1000
  role: "heading",
1000
- sx: _defineProperty$1(_defineProperty$1({
1001
+ sx: _defineProperty(_defineProperty({
1001
1002
  height: 40,
1002
1003
  backgroundColor: theme.palette.geowebColors.brand.brand,
1003
1004
  color: theme.palette.common.white,
@@ -3062,7 +3063,7 @@ var SearchHighlight = function SearchHighlight(_ref) {
3062
3063
  return /*#__PURE__*/React__default.createElement("span", null, text);
3063
3064
  }
3064
3065
  var searchWords = search.split(' ').reduce(function (words, word) {
3065
- return word ? [].concat(_toConsumableArray$1(words), [word.toLocaleLowerCase()]) : words;
3066
+ return word ? [].concat(_toConsumableArray(words), [word.toLocaleLowerCase()]) : words;
3066
3067
  }, []);
3067
3068
  var searchRegex = searchWords.map(function (word) {
3068
3069
  return escapeRegExp(word);
@@ -3268,6 +3269,61 @@ var SearchField = function SearchField(_ref) {
3268
3269
  });
3269
3270
  };
3270
3271
 
3272
+ /* *
3273
+ * Licensed under the Apache License, Version 2.0 (the "License");
3274
+ * you may not use this file except in compliance with the License.
3275
+ * You may obtain a copy of the License at
3276
+ *
3277
+ * http://www.apache.org/licenses/LICENSE-2.0
3278
+ *
3279
+ * Unless required by applicable law or agreed to in writing, software
3280
+ * distributed under the License is distributed on an "AS IS" BASIS,
3281
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3282
+ * See the License for the specific language governing permissions and
3283
+ * limitations under the License.
3284
+ *
3285
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3286
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
3287
+ * */
3288
+ var BUTTON_TITLE = 'Click to refresh';
3289
+ var getLastUpdateTitle = function getLastUpdateTitle(time) {
3290
+ return "Last updated ".concat(time);
3291
+ };
3292
+ var LastUpdateTime = function LastUpdateTime(_ref) {
3293
+ var _ref$onPressRefresh = _ref.onPressRefresh,
3294
+ onPressRefresh = _ref$onPressRefresh === void 0 ? function () {} : _ref$onPressRefresh,
3295
+ lastUpdateTime = _ref.lastUpdateTime,
3296
+ dataTestId = _ref.dataTestId;
3297
+ return /*#__PURE__*/React__default.createElement(Box, {
3298
+ sx: {
3299
+ display: 'flex',
3300
+ alignItems: 'center',
3301
+ height: '100%',
3302
+ justifyContent: 'flex-end'
3303
+ }
3304
+ }, /*#__PURE__*/React__default.createElement(Typography, {
3305
+ sx: {
3306
+ color: 'geowebColors.captions.captionStatus.rgba',
3307
+ fontSize: '10px',
3308
+ lineHeight: '1.6',
3309
+ letterSpacing: '0.33px'
3310
+ },
3311
+ "data-testid": dataTestId
3312
+ }, getLastUpdateTitle(lastUpdateTime)), /*#__PURE__*/React__default.createElement(CustomIconButton, {
3313
+ "data-testid": "refresh-button",
3314
+ onClick: onPressRefresh,
3315
+ sx: {
3316
+ marginRight: {
3317
+ xs: 2,
3318
+ sm: 1
3319
+ },
3320
+ marginLeft: 1
3321
+ },
3322
+ tooltipTitle: BUTTON_TITLE,
3323
+ variant: "tool"
3324
+ }, /*#__PURE__*/React__default.createElement(Cached, null)));
3325
+ };
3326
+
3271
3327
  /* *
3272
3328
  * Licensed under the Apache License, Version 2.0 (the "License");
3273
3329
  * you may not use this file except in compliance with the License.
@@ -3554,8 +3610,10 @@ var differenceInMinutes = function differenceInMinutes(dateLeft, dateRight) {
3554
3610
  * @param dateRight - the earlier date
3555
3611
  * @returns {number} the number of hours
3556
3612
  */
3557
- var differenceInHours = function differenceInHours(dateLeft, dateRight) {
3558
- return differenceInHours$1(dateLeft, dateRight);
3613
+ var differenceInHours = function differenceInHours(dateLeft, dateRight, roundingMethod) {
3614
+ return roundingMethod ? differenceInHours$1(dateLeft, dateRight, {
3615
+ roundingMethod: roundingMethod
3616
+ }) : differenceInHours$1(dateLeft, dateRight);
3559
3617
  };
3560
3618
  /**
3561
3619
  *
@@ -3617,13 +3675,48 @@ var unix = function unix(date) {
3617
3675
  return getUnixTime(date);
3618
3676
  };
3619
3677
  /**
3620
- * Set date values to a given date.
3678
+ * Return the Date object for a given timestamp
3679
+ * @param {number} unixTime - timestamp
3680
+ * @returns the timestamp
3681
+ */
3682
+ var fromUnix = function fromUnix(unixTime) {
3683
+ return fromUnixTime(unixTime);
3684
+ };
3685
+ /**
3686
+ * Set date values to a given date (by default it is assumed you are passing the new values in UTC).
3621
3687
  * @param date - the dater to be changed
3622
3688
  * @param values - an object with options
3689
+ * @param useLocalTimeZone - boolean true if you are passing the values in local timezone
3623
3690
  * @returns the new date with options set
3624
3691
  */
3625
3692
  var set = function set(date, values) {
3626
- return set$1(date, values);
3693
+ var useLocalTimeZone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3694
+ if (useLocalTimeZone) {
3695
+ return set$1(date, values);
3696
+ }
3697
+ var newDate = new Date(date);
3698
+ if (values.year != null) {
3699
+ newDate.setUTCFullYear(values.year);
3700
+ }
3701
+ if (values.month != null) {
3702
+ newDate.setUTCMonth(values.month);
3703
+ }
3704
+ if (values.date != null) {
3705
+ newDate.setUTCDate(values.date);
3706
+ }
3707
+ if (values.hours != null) {
3708
+ newDate.setUTCHours(values.hours);
3709
+ }
3710
+ if (values.minutes != null) {
3711
+ newDate.setUTCMinutes(values.minutes);
3712
+ }
3713
+ if (values.seconds != null) {
3714
+ newDate.setUTCSeconds(values.seconds);
3715
+ }
3716
+ if (values.milliseconds != null) {
3717
+ newDate.setUTCMilliseconds(values.milliseconds);
3718
+ }
3719
+ return newDate;
3627
3720
  };
3628
3721
 
3629
3722
  /* *
@@ -3660,1030 +3753,11 @@ var index = /*#__PURE__*/Object.freeze({
3660
3753
  utc: utc,
3661
3754
  isValid: isValid,
3662
3755
  unix: unix,
3663
- set: set
3756
+ fromUnix: fromUnix,
3757
+ set: set,
3758
+ isEqual: isEqual
3664
3759
  });
3665
3760
 
3666
- function getAugmentedNamespace(n) {
3667
- if (n.__esModule) return n;
3668
- var a = Object.defineProperty({}, '__esModule', {value: true});
3669
- Object.keys(n).forEach(function (k) {
3670
- var d = Object.getOwnPropertyDescriptor(n, k);
3671
- Object.defineProperty(a, k, d.get ? d : {
3672
- enumerable: true,
3673
- get: function () {
3674
- return n[k];
3675
- }
3676
- });
3677
- });
3678
- return a;
3679
- }
3680
-
3681
- var lib = {};
3682
-
3683
- function _typeof(o) {
3684
- "@babel/helpers - typeof";
3685
-
3686
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
3687
- return typeof o;
3688
- } : function (o) {
3689
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
3690
- }, _typeof(o);
3691
- }
3692
-
3693
- function toPrimitive(t, r) {
3694
- if ("object" != _typeof(t) || !t) return t;
3695
- var e = t[Symbol.toPrimitive];
3696
- if (void 0 !== e) {
3697
- var i = e.call(t, r || "default");
3698
- if ("object" != _typeof(i)) return i;
3699
- throw new TypeError("@@toPrimitive must return a primitive value.");
3700
- }
3701
- return ("string" === r ? String : Number)(t);
3702
- }
3703
-
3704
- function toPropertyKey(t) {
3705
- var i = toPrimitive(t, "string");
3706
- return "symbol" == _typeof(i) ? i : String(i);
3707
- }
3708
-
3709
- function _defineProperty(obj, key, value) {
3710
- key = toPropertyKey(key);
3711
- if (key in obj) {
3712
- Object.defineProperty(obj, key, {
3713
- value: value,
3714
- enumerable: true,
3715
- configurable: true,
3716
- writable: true
3717
- });
3718
- } else {
3719
- obj[key] = value;
3720
- }
3721
- return obj;
3722
- }
3723
-
3724
- function ownKeys(e, r) {
3725
- var t = Object.keys(e);
3726
- if (Object.getOwnPropertySymbols) {
3727
- var o = Object.getOwnPropertySymbols(e);
3728
- r && (o = o.filter(function (r) {
3729
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
3730
- })), t.push.apply(t, o);
3731
- }
3732
- return t;
3733
- }
3734
- function _objectSpread2(e) {
3735
- for (var r = 1; r < arguments.length; r++) {
3736
- var t = null != arguments[r] ? arguments[r] : {};
3737
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
3738
- _defineProperty(e, r, t[r]);
3739
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
3740
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3741
- });
3742
- }
3743
- return e;
3744
- }
3745
-
3746
- /**
3747
- * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
3748
- *
3749
- * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
3750
- * during build.
3751
- * @param {number} code
3752
- */
3753
- function formatProdErrorMessage(code) {
3754
- return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
3755
- }
3756
-
3757
- // Inlined version of the `symbol-observable` polyfill
3758
- var $$observable = (function () {
3759
- return typeof Symbol === 'function' && Symbol.observable || '@@observable';
3760
- })();
3761
-
3762
- /**
3763
- * These are private action types reserved by Redux.
3764
- * For any unknown actions, you must return the current state.
3765
- * If the current state is undefined, you must return the initial state.
3766
- * Do not reference these action types directly in your code.
3767
- */
3768
- var randomString = function randomString() {
3769
- return Math.random().toString(36).substring(7).split('').join('.');
3770
- };
3771
-
3772
- var ActionTypes = {
3773
- INIT: "@@redux/INIT" + randomString(),
3774
- REPLACE: "@@redux/REPLACE" + randomString(),
3775
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
3776
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
3777
- }
3778
- };
3779
-
3780
- /**
3781
- * @param {any} obj The object to inspect.
3782
- * @returns {boolean} True if the argument appears to be a plain object.
3783
- */
3784
- function isPlainObject$1(obj) {
3785
- if (typeof obj !== 'object' || obj === null) return false;
3786
- var proto = obj;
3787
-
3788
- while (Object.getPrototypeOf(proto) !== null) {
3789
- proto = Object.getPrototypeOf(proto);
3790
- }
3791
-
3792
- return Object.getPrototypeOf(obj) === proto;
3793
- }
3794
-
3795
- // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
3796
- function miniKindOf(val) {
3797
- if (val === void 0) return 'undefined';
3798
- if (val === null) return 'null';
3799
- var type = typeof val;
3800
-
3801
- switch (type) {
3802
- case 'boolean':
3803
- case 'string':
3804
- case 'number':
3805
- case 'symbol':
3806
- case 'function':
3807
- {
3808
- return type;
3809
- }
3810
- }
3811
-
3812
- if (Array.isArray(val)) return 'array';
3813
- if (isDate(val)) return 'date';
3814
- if (isError(val)) return 'error';
3815
- var constructorName = ctorName(val);
3816
-
3817
- switch (constructorName) {
3818
- case 'Symbol':
3819
- case 'Promise':
3820
- case 'WeakMap':
3821
- case 'WeakSet':
3822
- case 'Map':
3823
- case 'Set':
3824
- return constructorName;
3825
- } // other
3826
-
3827
-
3828
- return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
3829
- }
3830
-
3831
- function ctorName(val) {
3832
- return typeof val.constructor === 'function' ? val.constructor.name : null;
3833
- }
3834
-
3835
- function isError(val) {
3836
- return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
3837
- }
3838
-
3839
- function isDate(val) {
3840
- if (val instanceof Date) return true;
3841
- return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
3842
- }
3843
-
3844
- function kindOf(val) {
3845
- var typeOfVal = typeof val;
3846
-
3847
- if (process.env.NODE_ENV !== 'production') {
3848
- typeOfVal = miniKindOf(val);
3849
- }
3850
-
3851
- return typeOfVal;
3852
- }
3853
-
3854
- /**
3855
- * @deprecated
3856
- *
3857
- * **We recommend using the `configureStore` method
3858
- * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
3859
- *
3860
- * Redux Toolkit is our recommended approach for writing Redux logic today,
3861
- * including store setup, reducers, data fetching, and more.
3862
- *
3863
- * **For more details, please read this Redux docs page:**
3864
- * **https://redux.js.org/introduction/why-rtk-is-redux-today**
3865
- *
3866
- * `configureStore` from Redux Toolkit is an improved version of `createStore` that
3867
- * simplifies setup and helps avoid common bugs.
3868
- *
3869
- * You should not be using the `redux` core package by itself today, except for learning purposes.
3870
- * The `createStore` method from the core `redux` package will not be removed, but we encourage
3871
- * all users to migrate to using Redux Toolkit for all Redux code.
3872
- *
3873
- * If you want to use `createStore` without this visual deprecation warning, use
3874
- * the `legacy_createStore` import instead:
3875
- *
3876
- * `import { legacy_createStore as createStore} from 'redux'`
3877
- *
3878
- */
3879
-
3880
- function createStore(reducer, preloadedState, enhancer) {
3881
- var _ref2;
3882
-
3883
- if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
3884
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
3885
- }
3886
-
3887
- if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
3888
- enhancer = preloadedState;
3889
- preloadedState = undefined;
3890
- }
3891
-
3892
- if (typeof enhancer !== 'undefined') {
3893
- if (typeof enhancer !== 'function') {
3894
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
3895
- }
3896
-
3897
- return enhancer(createStore)(reducer, preloadedState);
3898
- }
3899
-
3900
- if (typeof reducer !== 'function') {
3901
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
3902
- }
3903
-
3904
- var currentReducer = reducer;
3905
- var currentState = preloadedState;
3906
- var currentListeners = [];
3907
- var nextListeners = currentListeners;
3908
- var isDispatching = false;
3909
- /**
3910
- * This makes a shallow copy of currentListeners so we can use
3911
- * nextListeners as a temporary list while dispatching.
3912
- *
3913
- * This prevents any bugs around consumers calling
3914
- * subscribe/unsubscribe in the middle of a dispatch.
3915
- */
3916
-
3917
- function ensureCanMutateNextListeners() {
3918
- if (nextListeners === currentListeners) {
3919
- nextListeners = currentListeners.slice();
3920
- }
3921
- }
3922
- /**
3923
- * Reads the state tree managed by the store.
3924
- *
3925
- * @returns {any} The current state tree of your application.
3926
- */
3927
-
3928
-
3929
- function getState() {
3930
- if (isDispatching) {
3931
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
3932
- }
3933
-
3934
- return currentState;
3935
- }
3936
- /**
3937
- * Adds a change listener. It will be called any time an action is dispatched,
3938
- * and some part of the state tree may potentially have changed. You may then
3939
- * call `getState()` to read the current state tree inside the callback.
3940
- *
3941
- * You may call `dispatch()` from a change listener, with the following
3942
- * caveats:
3943
- *
3944
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
3945
- * If you subscribe or unsubscribe while the listeners are being invoked, this
3946
- * will not have any effect on the `dispatch()` that is currently in progress.
3947
- * However, the next `dispatch()` call, whether nested or not, will use a more
3948
- * recent snapshot of the subscription list.
3949
- *
3950
- * 2. The listener should not expect to see all state changes, as the state
3951
- * might have been updated multiple times during a nested `dispatch()` before
3952
- * the listener is called. It is, however, guaranteed that all subscribers
3953
- * registered before the `dispatch()` started will be called with the latest
3954
- * state by the time it exits.
3955
- *
3956
- * @param {Function} listener A callback to be invoked on every dispatch.
3957
- * @returns {Function} A function to remove this change listener.
3958
- */
3959
-
3960
-
3961
- function subscribe(listener) {
3962
- if (typeof listener !== 'function') {
3963
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
3964
- }
3965
-
3966
- if (isDispatching) {
3967
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
3968
- }
3969
-
3970
- var isSubscribed = true;
3971
- ensureCanMutateNextListeners();
3972
- nextListeners.push(listener);
3973
- return function unsubscribe() {
3974
- if (!isSubscribed) {
3975
- return;
3976
- }
3977
-
3978
- if (isDispatching) {
3979
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
3980
- }
3981
-
3982
- isSubscribed = false;
3983
- ensureCanMutateNextListeners();
3984
- var index = nextListeners.indexOf(listener);
3985
- nextListeners.splice(index, 1);
3986
- currentListeners = null;
3987
- };
3988
- }
3989
- /**
3990
- * Dispatches an action. It is the only way to trigger a state change.
3991
- *
3992
- * The `reducer` function, used to create the store, will be called with the
3993
- * current state tree and the given `action`. Its return value will
3994
- * be considered the **next** state of the tree, and the change listeners
3995
- * will be notified.
3996
- *
3997
- * The base implementation only supports plain object actions. If you want to
3998
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
3999
- * wrap your store creating function into the corresponding middleware. For
4000
- * example, see the documentation for the `redux-thunk` package. Even the
4001
- * middleware will eventually dispatch plain object actions using this method.
4002
- *
4003
- * @param {Object} action A plain object representing “what changed”. It is
4004
- * a good idea to keep actions serializable so you can record and replay user
4005
- * sessions, or use the time travelling `redux-devtools`. An action must have
4006
- * a `type` property which may not be `undefined`. It is a good idea to use
4007
- * string constants for action types.
4008
- *
4009
- * @returns {Object} For convenience, the same action object you dispatched.
4010
- *
4011
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
4012
- * return something else (for example, a Promise you can await).
4013
- */
4014
-
4015
-
4016
- function dispatch(action) {
4017
- if (!isPlainObject$1(action)) {
4018
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
4019
- }
4020
-
4021
- if (typeof action.type === 'undefined') {
4022
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
4023
- }
4024
-
4025
- if (isDispatching) {
4026
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
4027
- }
4028
-
4029
- try {
4030
- isDispatching = true;
4031
- currentState = currentReducer(currentState, action);
4032
- } finally {
4033
- isDispatching = false;
4034
- }
4035
-
4036
- var listeners = currentListeners = nextListeners;
4037
-
4038
- for (var i = 0; i < listeners.length; i++) {
4039
- var listener = listeners[i];
4040
- listener();
4041
- }
4042
-
4043
- return action;
4044
- }
4045
- /**
4046
- * Replaces the reducer currently used by the store to calculate the state.
4047
- *
4048
- * You might need this if your app implements code splitting and you want to
4049
- * load some of the reducers dynamically. You might also need this if you
4050
- * implement a hot reloading mechanism for Redux.
4051
- *
4052
- * @param {Function} nextReducer The reducer for the store to use instead.
4053
- * @returns {void}
4054
- */
4055
-
4056
-
4057
- function replaceReducer(nextReducer) {
4058
- if (typeof nextReducer !== 'function') {
4059
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
4060
- }
4061
-
4062
- currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
4063
- // Any reducers that existed in both the new and old rootReducer
4064
- // will receive the previous state. This effectively populates
4065
- // the new state tree with any relevant data from the old one.
4066
-
4067
- dispatch({
4068
- type: ActionTypes.REPLACE
4069
- });
4070
- }
4071
- /**
4072
- * Interoperability point for observable/reactive libraries.
4073
- * @returns {observable} A minimal observable of state changes.
4074
- * For more information, see the observable proposal:
4075
- * https://github.com/tc39/proposal-observable
4076
- */
4077
-
4078
-
4079
- function observable() {
4080
- var _ref;
4081
-
4082
- var outerSubscribe = subscribe;
4083
- return _ref = {
4084
- /**
4085
- * The minimal observable subscription method.
4086
- * @param {Object} observer Any object that can be used as an observer.
4087
- * The observer object should have a `next` method.
4088
- * @returns {subscription} An object with an `unsubscribe` method that can
4089
- * be used to unsubscribe the observable from the store, and prevent further
4090
- * emission of values from the observable.
4091
- */
4092
- subscribe: function subscribe(observer) {
4093
- if (typeof observer !== 'object' || observer === null) {
4094
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
4095
- }
4096
-
4097
- function observeState() {
4098
- if (observer.next) {
4099
- observer.next(getState());
4100
- }
4101
- }
4102
-
4103
- observeState();
4104
- var unsubscribe = outerSubscribe(observeState);
4105
- return {
4106
- unsubscribe: unsubscribe
4107
- };
4108
- }
4109
- }, _ref[$$observable] = function () {
4110
- return this;
4111
- }, _ref;
4112
- } // When a store is created, an "INIT" action is dispatched so that every
4113
- // reducer returns their initial state. This effectively populates
4114
- // the initial state tree.
4115
-
4116
-
4117
- dispatch({
4118
- type: ActionTypes.INIT
4119
- });
4120
- return _ref2 = {
4121
- dispatch: dispatch,
4122
- subscribe: subscribe,
4123
- getState: getState,
4124
- replaceReducer: replaceReducer
4125
- }, _ref2[$$observable] = observable, _ref2;
4126
- }
4127
- /**
4128
- * Creates a Redux store that holds the state tree.
4129
- *
4130
- * **We recommend using `configureStore` from the
4131
- * `@reduxjs/toolkit` package**, which replaces `createStore`:
4132
- * **https://redux.js.org/introduction/why-rtk-is-redux-today**
4133
- *
4134
- * The only way to change the data in the store is to call `dispatch()` on it.
4135
- *
4136
- * There should only be a single store in your app. To specify how different
4137
- * parts of the state tree respond to actions, you may combine several reducers
4138
- * into a single reducer function by using `combineReducers`.
4139
- *
4140
- * @param {Function} reducer A function that returns the next state tree, given
4141
- * the current state tree and the action to handle.
4142
- *
4143
- * @param {any} [preloadedState] The initial state. You may optionally specify it
4144
- * to hydrate the state from the server in universal apps, or to restore a
4145
- * previously serialized user session.
4146
- * If you use `combineReducers` to produce the root reducer function, this must be
4147
- * an object with the same shape as `combineReducers` keys.
4148
- *
4149
- * @param {Function} [enhancer] The store enhancer. You may optionally specify it
4150
- * to enhance the store with third-party capabilities such as middleware,
4151
- * time travel, persistence, etc. The only store enhancer that ships with Redux
4152
- * is `applyMiddleware()`.
4153
- *
4154
- * @returns {Store} A Redux store that lets you read the state, dispatch actions
4155
- * and subscribe to changes.
4156
- */
4157
-
4158
- var legacy_createStore = createStore;
4159
-
4160
- /**
4161
- * Prints a warning in the console if it exists.
4162
- *
4163
- * @param {String} message The warning message.
4164
- * @returns {void}
4165
- */
4166
- function warning(message) {
4167
- /* eslint-disable no-console */
4168
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
4169
- console.error(message);
4170
- }
4171
- /* eslint-enable no-console */
4172
-
4173
-
4174
- try {
4175
- // This error was thrown as a convenience so that if you enable
4176
- // "break on all exceptions" in your console,
4177
- // it would pause the execution at this line.
4178
- throw new Error(message);
4179
- } catch (e) {} // eslint-disable-line no-empty
4180
-
4181
- }
4182
-
4183
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
4184
- var reducerKeys = Object.keys(reducers);
4185
- var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
4186
-
4187
- if (reducerKeys.length === 0) {
4188
- return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
4189
- }
4190
-
4191
- if (!isPlainObject$1(inputState)) {
4192
- return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
4193
- }
4194
-
4195
- var unexpectedKeys = Object.keys(inputState).filter(function (key) {
4196
- return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
4197
- });
4198
- unexpectedKeys.forEach(function (key) {
4199
- unexpectedKeyCache[key] = true;
4200
- });
4201
- if (action && action.type === ActionTypes.REPLACE) return;
4202
-
4203
- if (unexpectedKeys.length > 0) {
4204
- return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
4205
- }
4206
- }
4207
-
4208
- function assertReducerShape(reducers) {
4209
- Object.keys(reducers).forEach(function (key) {
4210
- var reducer = reducers[key];
4211
- var initialState = reducer(undefined, {
4212
- type: ActionTypes.INIT
4213
- });
4214
-
4215
- if (typeof initialState === 'undefined') {
4216
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
4217
- }
4218
-
4219
- if (typeof reducer(undefined, {
4220
- type: ActionTypes.PROBE_UNKNOWN_ACTION()
4221
- }) === 'undefined') {
4222
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
4223
- }
4224
- });
4225
- }
4226
- /**
4227
- * Turns an object whose values are different reducer functions, into a single
4228
- * reducer function. It will call every child reducer, and gather their results
4229
- * into a single state object, whose keys correspond to the keys of the passed
4230
- * reducer functions.
4231
- *
4232
- * @param {Object} reducers An object whose values correspond to different
4233
- * reducer functions that need to be combined into one. One handy way to obtain
4234
- * it is to use ES6 `import * as reducers` syntax. The reducers may never return
4235
- * undefined for any action. Instead, they should return their initial state
4236
- * if the state passed to them was undefined, and the current state for any
4237
- * unrecognized action.
4238
- *
4239
- * @returns {Function} A reducer function that invokes every reducer inside the
4240
- * passed object, and builds a state object with the same shape.
4241
- */
4242
-
4243
-
4244
- function combineReducers(reducers) {
4245
- var reducerKeys = Object.keys(reducers);
4246
- var finalReducers = {};
4247
-
4248
- for (var i = 0; i < reducerKeys.length; i++) {
4249
- var key = reducerKeys[i];
4250
-
4251
- if (process.env.NODE_ENV !== 'production') {
4252
- if (typeof reducers[key] === 'undefined') {
4253
- warning("No reducer provided for key \"" + key + "\"");
4254
- }
4255
- }
4256
-
4257
- if (typeof reducers[key] === 'function') {
4258
- finalReducers[key] = reducers[key];
4259
- }
4260
- }
4261
-
4262
- var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
4263
- // keys multiple times.
4264
-
4265
- var unexpectedKeyCache;
4266
-
4267
- if (process.env.NODE_ENV !== 'production') {
4268
- unexpectedKeyCache = {};
4269
- }
4270
-
4271
- var shapeAssertionError;
4272
-
4273
- try {
4274
- assertReducerShape(finalReducers);
4275
- } catch (e) {
4276
- shapeAssertionError = e;
4277
- }
4278
-
4279
- return function combination(state, action) {
4280
- if (state === void 0) {
4281
- state = {};
4282
- }
4283
-
4284
- if (shapeAssertionError) {
4285
- throw shapeAssertionError;
4286
- }
4287
-
4288
- if (process.env.NODE_ENV !== 'production') {
4289
- var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
4290
-
4291
- if (warningMessage) {
4292
- warning(warningMessage);
4293
- }
4294
- }
4295
-
4296
- var hasChanged = false;
4297
- var nextState = {};
4298
-
4299
- for (var _i = 0; _i < finalReducerKeys.length; _i++) {
4300
- var _key = finalReducerKeys[_i];
4301
- var reducer = finalReducers[_key];
4302
- var previousStateForKey = state[_key];
4303
- var nextStateForKey = reducer(previousStateForKey, action);
4304
-
4305
- if (typeof nextStateForKey === 'undefined') {
4306
- var actionType = action && action.type;
4307
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
4308
- }
4309
-
4310
- nextState[_key] = nextStateForKey;
4311
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
4312
- }
4313
-
4314
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
4315
- return hasChanged ? nextState : state;
4316
- };
4317
- }
4318
-
4319
- function bindActionCreator(actionCreator, dispatch) {
4320
- return function () {
4321
- return dispatch(actionCreator.apply(this, arguments));
4322
- };
4323
- }
4324
- /**
4325
- * Turns an object whose values are action creators, into an object with the
4326
- * same keys, but with every function wrapped into a `dispatch` call so they
4327
- * may be invoked directly. This is just a convenience method, as you can call
4328
- * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
4329
- *
4330
- * For convenience, you can also pass an action creator as the first argument,
4331
- * and get a dispatch wrapped function in return.
4332
- *
4333
- * @param {Function|Object} actionCreators An object whose values are action
4334
- * creator functions. One handy way to obtain it is to use ES6 `import * as`
4335
- * syntax. You may also pass a single function.
4336
- *
4337
- * @param {Function} dispatch The `dispatch` function available on your Redux
4338
- * store.
4339
- *
4340
- * @returns {Function|Object} The object mimicking the original object, but with
4341
- * every action creator wrapped into the `dispatch` call. If you passed a
4342
- * function as `actionCreators`, the return value will also be a single
4343
- * function.
4344
- */
4345
-
4346
-
4347
- function bindActionCreators(actionCreators, dispatch) {
4348
- if (typeof actionCreators === 'function') {
4349
- return bindActionCreator(actionCreators, dispatch);
4350
- }
4351
-
4352
- if (typeof actionCreators !== 'object' || actionCreators === null) {
4353
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
4354
- }
4355
-
4356
- var boundActionCreators = {};
4357
-
4358
- for (var key in actionCreators) {
4359
- var actionCreator = actionCreators[key];
4360
-
4361
- if (typeof actionCreator === 'function') {
4362
- boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
4363
- }
4364
- }
4365
-
4366
- return boundActionCreators;
4367
- }
4368
-
4369
- /**
4370
- * Composes single-argument functions from right to left. The rightmost
4371
- * function can take multiple arguments as it provides the signature for
4372
- * the resulting composite function.
4373
- *
4374
- * @param {...Function} funcs The functions to compose.
4375
- * @returns {Function} A function obtained by composing the argument functions
4376
- * from right to left. For example, compose(f, g, h) is identical to doing
4377
- * (...args) => f(g(h(...args))).
4378
- */
4379
- function compose() {
4380
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
4381
- funcs[_key] = arguments[_key];
4382
- }
4383
-
4384
- if (funcs.length === 0) {
4385
- return function (arg) {
4386
- return arg;
4387
- };
4388
- }
4389
-
4390
- if (funcs.length === 1) {
4391
- return funcs[0];
4392
- }
4393
-
4394
- return funcs.reduce(function (a, b) {
4395
- return function () {
4396
- return a(b.apply(void 0, arguments));
4397
- };
4398
- });
4399
- }
4400
-
4401
- /**
4402
- * Creates a store enhancer that applies middleware to the dispatch method
4403
- * of the Redux store. This is handy for a variety of tasks, such as expressing
4404
- * asynchronous actions in a concise manner, or logging every action payload.
4405
- *
4406
- * See `redux-thunk` package as an example of the Redux middleware.
4407
- *
4408
- * Because middleware is potentially asynchronous, this should be the first
4409
- * store enhancer in the composition chain.
4410
- *
4411
- * Note that each middleware will be given the `dispatch` and `getState` functions
4412
- * as named arguments.
4413
- *
4414
- * @param {...Function} middlewares The middleware chain to be applied.
4415
- * @returns {Function} A store enhancer applying the middleware.
4416
- */
4417
-
4418
- function applyMiddleware() {
4419
- for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
4420
- middlewares[_key] = arguments[_key];
4421
- }
4422
-
4423
- return function (createStore) {
4424
- return function () {
4425
- var store = createStore.apply(void 0, arguments);
4426
-
4427
- var _dispatch = function dispatch() {
4428
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
4429
- };
4430
-
4431
- var middlewareAPI = {
4432
- getState: store.getState,
4433
- dispatch: function dispatch() {
4434
- return _dispatch.apply(void 0, arguments);
4435
- }
4436
- };
4437
- var chain = middlewares.map(function (middleware) {
4438
- return middleware(middlewareAPI);
4439
- });
4440
- _dispatch = compose.apply(void 0, chain)(store.dispatch);
4441
- return _objectSpread2(_objectSpread2({}, store), {}, {
4442
- dispatch: _dispatch
4443
- });
4444
- };
4445
- };
4446
- }
4447
-
4448
- var redux = /*#__PURE__*/Object.freeze({
4449
- __proto__: null,
4450
- __DO_NOT_USE__ActionTypes: ActionTypes,
4451
- applyMiddleware: applyMiddleware,
4452
- bindActionCreators: bindActionCreators,
4453
- combineReducers: combineReducers,
4454
- compose: compose,
4455
- createStore: createStore,
4456
- legacy_createStore: legacy_createStore
4457
- });
4458
-
4459
- var require$$0 = /*@__PURE__*/getAugmentedNamespace(redux);
4460
-
4461
- /**
4462
- * lodash (Custom Build) <https://lodash.com/>
4463
- * Build: `lodash modularize exports="npm" -o ./`
4464
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
4465
- * Released under MIT license <https://lodash.com/license>
4466
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
4467
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4468
- */
4469
-
4470
- /** `Object#toString` result references. */
4471
- var objectTag = '[object Object]';
4472
-
4473
- /**
4474
- * Checks if `value` is a host object in IE < 9.
4475
- *
4476
- * @private
4477
- * @param {*} value The value to check.
4478
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
4479
- */
4480
- function isHostObject(value) {
4481
- // Many host objects are `Object` objects that can coerce to strings
4482
- // despite having improperly defined `toString` methods.
4483
- var result = false;
4484
- if (value != null && typeof value.toString != 'function') {
4485
- try {
4486
- result = !!(value + '');
4487
- } catch (e) {}
4488
- }
4489
- return result;
4490
- }
4491
-
4492
- /**
4493
- * Creates a unary function that invokes `func` with its argument transformed.
4494
- *
4495
- * @private
4496
- * @param {Function} func The function to wrap.
4497
- * @param {Function} transform The argument transform.
4498
- * @returns {Function} Returns the new function.
4499
- */
4500
- function overArg(func, transform) {
4501
- return function(arg) {
4502
- return func(transform(arg));
4503
- };
4504
- }
4505
-
4506
- /** Used for built-in method references. */
4507
- var funcProto = Function.prototype,
4508
- objectProto = Object.prototype;
4509
-
4510
- /** Used to resolve the decompiled source of functions. */
4511
- var funcToString = funcProto.toString;
4512
-
4513
- /** Used to check objects for own properties. */
4514
- var hasOwnProperty = objectProto.hasOwnProperty;
4515
-
4516
- /** Used to infer the `Object` constructor. */
4517
- var objectCtorString = funcToString.call(Object);
4518
-
4519
- /**
4520
- * Used to resolve the
4521
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
4522
- * of values.
4523
- */
4524
- var objectToString = objectProto.toString;
4525
-
4526
- /** Built-in value references. */
4527
- var getPrototype = overArg(Object.getPrototypeOf, Object);
4528
-
4529
- /**
4530
- * Checks if `value` is object-like. A value is object-like if it's not `null`
4531
- * and has a `typeof` result of "object".
4532
- *
4533
- * @static
4534
- * @memberOf _
4535
- * @since 4.0.0
4536
- * @category Lang
4537
- * @param {*} value The value to check.
4538
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
4539
- * @example
4540
- *
4541
- * _.isObjectLike({});
4542
- * // => true
4543
- *
4544
- * _.isObjectLike([1, 2, 3]);
4545
- * // => true
4546
- *
4547
- * _.isObjectLike(_.noop);
4548
- * // => false
4549
- *
4550
- * _.isObjectLike(null);
4551
- * // => false
4552
- */
4553
- function isObjectLike(value) {
4554
- return !!value && typeof value == 'object';
4555
- }
4556
-
4557
- /**
4558
- * Checks if `value` is a plain object, that is, an object created by the
4559
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
4560
- *
4561
- * @static
4562
- * @memberOf _
4563
- * @since 0.8.0
4564
- * @category Lang
4565
- * @param {*} value The value to check.
4566
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
4567
- * @example
4568
- *
4569
- * function Foo() {
4570
- * this.a = 1;
4571
- * }
4572
- *
4573
- * _.isPlainObject(new Foo);
4574
- * // => false
4575
- *
4576
- * _.isPlainObject([1, 2, 3]);
4577
- * // => false
4578
- *
4579
- * _.isPlainObject({ 'x': 0, 'y': 0 });
4580
- * // => true
4581
- *
4582
- * _.isPlainObject(Object.create(null));
4583
- * // => true
4584
- */
4585
- function isPlainObject(value) {
4586
- if (!isObjectLike(value) ||
4587
- objectToString.call(value) != objectTag || isHostObject(value)) {
4588
- return false;
4589
- }
4590
- var proto = getPrototype(value);
4591
- if (proto === null) {
4592
- return true;
4593
- }
4594
- var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
4595
- return (typeof Ctor == 'function' &&
4596
- Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
4597
- }
4598
-
4599
- var lodash_isplainobject = isPlainObject;
4600
-
4601
- Object.defineProperty(lib, "__esModule", {
4602
- value: true
4603
- });
4604
- var _default = lib.default = configureStore;
4605
-
4606
- var _redux = require$$0;
4607
-
4608
- var _lodash = lodash_isplainobject;
4609
-
4610
- var _lodash2 = _interopRequireDefault(_lodash);
4611
-
4612
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4613
-
4614
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
4615
-
4616
- var isFunction = function isFunction(arg) {
4617
- return typeof arg === 'function';
4618
- };
4619
-
4620
- function configureStore() {
4621
- var middlewares = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
4622
-
4623
- return function mockStore() {
4624
- var _getState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4625
-
4626
- function mockStoreWithoutMiddleware() {
4627
- var actions = [];
4628
- var listeners = [];
4629
-
4630
- var self = {
4631
- getState: function getState() {
4632
- return isFunction(_getState) ? _getState(actions) : _getState;
4633
- },
4634
- getActions: function getActions() {
4635
- return actions;
4636
- },
4637
- dispatch: function dispatch(action) {
4638
- if (!(0, _lodash2.default)(action)) {
4639
- throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
4640
- }
4641
-
4642
- if (typeof action.type === 'undefined') {
4643
- throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant? ' + 'Action: ' + JSON.stringify(action));
4644
- }
4645
-
4646
- actions.push(action);
4647
-
4648
- for (var i = 0; i < listeners.length; i++) {
4649
- listeners[i]();
4650
- }
4651
-
4652
- return action;
4653
- },
4654
- clearActions: function clearActions() {
4655
- actions = [];
4656
- },
4657
- subscribe: function subscribe(cb) {
4658
- if (isFunction(cb)) {
4659
- listeners.push(cb);
4660
- }
4661
-
4662
- return function () {
4663
- var index = listeners.indexOf(cb);
4664
-
4665
- if (index < 0) {
4666
- return;
4667
- }
4668
- listeners.splice(index, 1);
4669
- };
4670
- },
4671
- replaceReducer: function replaceReducer(nextReducer) {
4672
- if (!isFunction(nextReducer)) {
4673
- throw new Error('Expected the nextReducer to be a function.');
4674
- }
4675
- }
4676
- };
4677
-
4678
- return self;
4679
- }
4680
-
4681
- var mockStoreWithMiddleware = _redux.applyMiddleware.apply(undefined, _toConsumableArray(middlewares))(mockStoreWithoutMiddleware);
4682
-
4683
- return mockStoreWithMiddleware();
4684
- };
4685
- }
4686
-
4687
3761
  /* *
4688
3762
  * Licensed under the Apache License, Version 2.0 (the "License");
4689
3763
  * you may not use this file except in compliance with the License.
@@ -4701,7 +3775,7 @@ function configureStore() {
4701
3775
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
4702
3776
  * */
4703
3777
  var createMockStoreWithEggs = function createMockStoreWithEggs(mockState) {
4704
- var mockStore = _default();
3778
+ var mockStore = configureStore();
4705
3779
  var store = mockStore(mockState);
4706
3780
  store.addEggs = typeof jest !== 'undefined' ? jest.fn() : function () {}; // mocking the dynamic module loader
4707
3781
  return store;
@@ -4709,7 +3783,7 @@ var createMockStoreWithEggs = function createMockStoreWithEggs(mockState) {
4709
3783
  var createMockStoreWithEggsAndMiddleware = function createMockStoreWithEggsAndMiddleware(mockState,
4710
3784
  // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
4711
3785
  middleware) {
4712
- var mockStore = _default([middleware]);
3786
+ var mockStore = configureStore([middleware]);
4713
3787
  var store = mockStore(mockState);
4714
3788
  store.addEggs = typeof jest !== 'undefined' ? jest.fn() : function () {}; // mocking the dynamic module loader
4715
3789
  return store;
@@ -4752,4 +3826,62 @@ var getHeight = function getHeight(element) {
4752
3826
  return element.offsetHeight + marginTop + marginBottom;
4753
3827
  };
4754
3828
 
4755
- export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, ResizeComponent as Resizable, SearchField, SearchFieldButton, SearchHighlight, StatusTag, SwitchButton, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, calculateStartSize, createMockStoreWithEggs, createMockStoreWithEggsAndMiddleware, createToolkitMockStoreWithEggs, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getHeight, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
3829
+ /* *
3830
+ * Licensed under the Apache License, Version 2.0 (the "License");
3831
+ * you may not use this file except in compliance with the License.
3832
+ * You may obtain a copy of the License at
3833
+ *
3834
+ * http://www.apache.org/licenses/LICENSE-2.0
3835
+ *
3836
+ * Unless required by applicable law or agreed to in writing, software
3837
+ * distributed under the License is distributed on an "AS IS" BASIS,
3838
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3839
+ * See the License for the specific language governing permissions and
3840
+ * limitations under the License.
3841
+ *
3842
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3843
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
3844
+ * */
3845
+ /**
3846
+ * Utility function to keep track of number of renders by a react component
3847
+ *
3848
+ * Usage:
3849
+ * 1) reset all counters to zero by:
3850
+ * renderCounter.reset()
3851
+ * 2) in the render function of the functional component do:
3852
+ * renderCounter.count(<your react functional component>.name);
3853
+ * 3) in the test do:
3854
+ * expect(renderCounter.get(<your react functional component>.name)).toBe(1);
3855
+ *
3856
+ */
3857
+ var RenderCounter = /*#__PURE__*/function () {
3858
+ function RenderCounter() {
3859
+ _classCallCheck(this, RenderCounter);
3860
+ this.numRenders = new Map();
3861
+ }
3862
+ _createClass(RenderCounter, [{
3863
+ key: "reset",
3864
+ value: function reset() {
3865
+ var _this = this;
3866
+ this.numRenders.forEach(function (_value, key) {
3867
+ _this.numRenders.set(key, 0);
3868
+ });
3869
+ }
3870
+ }, {
3871
+ key: "count",
3872
+ value: function count(id) {
3873
+ this.numRenders.set(id, this.get(id) + 1);
3874
+ // Enable next line (for debugging) to track the number of renders per component in the developer console
3875
+ // console.log('numRenders', id, this.get(id));
3876
+ }
3877
+ }, {
3878
+ key: "get",
3879
+ value: function get(id) {
3880
+ return this.numRenders.get(id) || 0;
3881
+ }
3882
+ }]);
3883
+ return RenderCounter;
3884
+ }();
3885
+ var renderCounter = new RenderCounter();
3886
+
3887
+ export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, BUTTON_TITLE, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, ErrorBoundary, LastUpdateTime, ResizeComponent as Resizable, SearchField, SearchFieldButton, SearchHighlight, StatusTag, SwitchButton, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, calculateStartSize, createMockStoreWithEggs, createMockStoreWithEggsAndMiddleware, createToolkitMockStoreWithEggs, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getHeight, getInitials, getLastUpdateTitle, getPosition, getWarningMessage, isAxiosError, renderCounter, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };