redux-starter-kit
Advanced tools
Comparing version 0.7.0 to 0.8.0
import { Action } from 'redux'; | ||
import { IsUnknownOrNonInferrable } from './tsHelpers'; | ||
/** | ||
@@ -10,3 +11,3 @@ * An action with a string type and an associated payload. This is the | ||
*/ | ||
export declare type PayloadAction<P = any, T extends string = string, M = void> = WithOptionalMeta<M, WithPayload<P, Action<T>>>; | ||
export declare type PayloadAction<P = void, T extends string = string, M = void> = WithOptionalMeta<M, WithPayload<P, Action<T>>>; | ||
export declare type PrepareAction<P> = ((...args: any[]) => { | ||
@@ -24,7 +25,7 @@ payload: P; | ||
export declare type ActionCreatorWithoutPayload<T extends string = string> = WithTypeProperty<T, () => PayloadAction<undefined, T>>; | ||
export declare type ActionCreatorWithPayload<P, T extends string = string> = WithTypeProperty<T, <PT extends P>(payload: PT) => PayloadAction<PT, T>>; | ||
export declare type ActionCreatorWithPayload<P, T extends string = string> = WithTypeProperty<T, IsUnknownOrNonInferrable<P, <PT extends unknown>(payload: PT) => PayloadAction<PT, T>, <PT extends P>(payload: PT) => PayloadAction<PT, T>>>; | ||
/** | ||
* An action creator that produces actions with a `payload` attribute. | ||
*/ | ||
export declare type PayloadActionCreator<P = any, T extends string = string, PA extends PrepareAction<P> | void = void> = IfPrepareActionMethodProvided<PA, ActionCreatorWithPreparedPayload<PA, T>, IfMaybeUndefined<P, ActionCreatorWithOptionalPayload<P, T>, IfVoid<P, ActionCreatorWithoutPayload<T>, ActionCreatorWithPayload<P, T>>>>; | ||
export declare type PayloadActionCreator<P = void, T extends string = string, PA extends PrepareAction<P> | void = void> = IfPrepareActionMethodProvided<PA, ActionCreatorWithPreparedPayload<PA, T>, IfMaybeUndefined<P, ActionCreatorWithOptionalPayload<P, T>, IfVoid<P, ActionCreatorWithoutPayload<T>, ActionCreatorWithPayload<P, T>>>>; | ||
/** | ||
@@ -41,3 +42,3 @@ * A utility function to create an action creator for the given action type | ||
*/ | ||
export declare function createAction<P = any, T extends string = string>(type: T): PayloadActionCreator<P, T>; | ||
export declare function createAction<P = void, T extends string = string>(type: T): PayloadActionCreator<P, T>; | ||
export declare function createAction<PA extends PrepareAction<any>, T extends string = string>(type: T, prepareAction: PA): PayloadActionCreator<ReturnType<PA>['payload'], T, PA>; | ||
@@ -44,0 +45,0 @@ /** |
@@ -10,6 +10,4 @@ import { Reducer } from 'redux'; | ||
export declare type SliceActionCreator<P> = PayloadActionCreator<P>; | ||
export interface Slice<State = any, ActionCreators extends { | ||
export interface Slice<State = any, CaseReducers extends SliceCaseReducerDefinitions<State, PayloadActions> = { | ||
[key: string]: any; | ||
} = { | ||
[key: string]: any; | ||
}> { | ||
@@ -19,3 +17,3 @@ /** | ||
*/ | ||
slice: string; | ||
name: string; | ||
/** | ||
@@ -29,3 +27,4 @@ * The slice's reducer. | ||
*/ | ||
actions: ActionCreators; | ||
actions: CaseReducerActions<CaseReducers>; | ||
caseReducers: SliceDefinedCaseReducers<CaseReducers, State>; | ||
} | ||
@@ -35,7 +34,7 @@ /** | ||
*/ | ||
export interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<State, any> = SliceCaseReducers<State, any>> { | ||
export interface CreateSliceOptions<State = any, CR extends SliceCaseReducerDefinitions<State, any> = SliceCaseReducerDefinitions<State, any>> { | ||
/** | ||
* The slice's name. Used to namespace the generated action types. | ||
*/ | ||
slice?: string; | ||
name: string; | ||
/** | ||
@@ -59,11 +58,11 @@ * The initial state to be returned by the slice reducer. | ||
declare type PayloadActions<Types extends keyof any = string> = Record<Types, PayloadAction>; | ||
declare type EnhancedCaseReducer<State, Action extends PayloadAction> = { | ||
declare type CaseReducerWithPrepare<State, Action extends PayloadAction> = { | ||
reducer: CaseReducer<State, Action>; | ||
prepare: PrepareAction<Action['payload']>; | ||
}; | ||
declare type SliceCaseReducers<State, PA extends PayloadActions> = { | ||
[ActionType in keyof PA]: CaseReducer<State, PA[ActionType]> | EnhancedCaseReducer<State, PA[ActionType]>; | ||
declare type SliceCaseReducerDefinitions<State, PA extends PayloadActions> = { | ||
[ActionType in keyof PA]: CaseReducer<State, PA[ActionType]> | CaseReducerWithPrepare<State, PA[ActionType]>; | ||
}; | ||
declare type IfIsReducerFunctionWithoutAction<R, True, False = never> = R extends (state: any) => any ? True : False; | ||
declare type IfIsEnhancedReducer<R, True, False = never> = R extends { | ||
declare type IfIsCaseReducerWithPrepare<R, True, False = never> = R extends { | ||
prepare: Function; | ||
@@ -75,5 +74,11 @@ } ? True : False; | ||
} ? Prepare : never; | ||
declare type CaseReducerActions<CaseReducers extends SliceCaseReducers<any, any>> = { | ||
[Type in keyof CaseReducers]: IfIsEnhancedReducer<CaseReducers[Type], ActionCreatorWithPreparedPayload<PrepareActionForReducer<CaseReducers[Type]>>, IfIsReducerFunctionWithoutAction<CaseReducers[Type], ActionCreatorWithoutPayload, PayloadActionCreator<PayloadForReducer<CaseReducers[Type]>>>>; | ||
declare type ActionForReducer<R, S> = R extends (state: S, action: PayloadAction<infer P>) => S ? PayloadAction<P> : R extends { | ||
reducer(state: any, action: PayloadAction<infer P>): any; | ||
} ? PayloadAction<P> : unknown; | ||
declare type CaseReducerActions<CaseReducers extends SliceCaseReducerDefinitions<any, any>> = { | ||
[Type in keyof CaseReducers]: IfIsCaseReducerWithPrepare<CaseReducers[Type], ActionCreatorWithPreparedPayload<PrepareActionForReducer<CaseReducers[Type]>>, IfIsReducerFunctionWithoutAction<CaseReducers[Type], ActionCreatorWithoutPayload, PayloadActionCreator<PayloadForReducer<CaseReducers[Type]>>>>; | ||
}; | ||
declare type SliceDefinedCaseReducers<CaseReducers extends SliceCaseReducerDefinitions<any, any>, State = any> = { | ||
[Type in keyof CaseReducers]: CaseReducer<State, ActionForReducer<CaseReducers[Type], State>>; | ||
}; | ||
declare type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
@@ -91,3 +96,3 @@ declare type SliceCaseReducersCheck<S, ACR> = { | ||
}; | ||
declare type RestrictEnhancedReducersToMatchReducerAndPrepare<S, CR extends SliceCaseReducers<S, any>> = { | ||
declare type RestrictCaseReducerDefinitionsToMatchReducerAndPrepare<S, CR extends SliceCaseReducerDefinitions<S, any>> = { | ||
reducers: SliceCaseReducersCheck<S, NoInfer<CR>>; | ||
@@ -97,3 +102,3 @@ }; | ||
* A function that accepts an initial state, an object full of reducer | ||
* functions, and optionally a "slice name", and automatically generates | ||
* functions, and a "slice name", and automatically generates | ||
* action creators and action types that correspond to the | ||
@@ -104,3 +109,3 @@ * reducers and state. | ||
*/ | ||
export declare function createSlice<State, CaseReducers extends SliceCaseReducers<State, any>>(options: CreateSliceOptions<State, CaseReducers> & RestrictEnhancedReducersToMatchReducerAndPrepare<State, CaseReducers>): Slice<State, CaseReducerActions<CaseReducers>>; | ||
export declare function createSlice<State, CaseReducers extends SliceCaseReducerDefinitions<State, any>>(options: CreateSliceOptions<State, CaseReducers> & RestrictCaseReducerDefinitionsToMatchReducerAndPrepare<State, CaseReducers>): Slice<State, CaseReducers>; | ||
export {}; |
@@ -348,3 +348,3 @@ 'use strict'; | ||
} else { | ||
throw new Error('Reducer argument must be a function or an object of functions that can be passed to combineReducers'); | ||
throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'); | ||
} | ||
@@ -480,7 +480,7 @@ | ||
function getType$1(slice, actionKey) { | ||
return slice ? "".concat(slice, "/").concat(actionKey) : actionKey; | ||
return "".concat(slice, "/").concat(actionKey); | ||
} | ||
/** | ||
* A function that accepts an initial state, an object full of reducer | ||
* functions, and optionally a "slice name", and automatically generates | ||
* functions, and a "slice name", and automatically generates | ||
* action creators and action types that correspond to the | ||
@@ -495,24 +495,41 @@ * reducers and state. | ||
function createSlice(options) { | ||
var _options$slice = options.slice, | ||
slice = _options$slice === void 0 ? '' : _options$slice, | ||
var name = options.name, | ||
initialState = options.initialState; | ||
if (!name) { | ||
throw new Error('`name` is a required option for createSlice'); | ||
} | ||
var reducers = options.reducers || {}; | ||
var extraReducers = options.extraReducers || {}; | ||
var actionKeys = Object.keys(reducers); | ||
var reducerMap = actionKeys.reduce(function (map, actionKey) { | ||
var maybeEnhancedReducer = reducers[actionKey]; | ||
map[getType$1(slice, actionKey)] = typeof maybeEnhancedReducer === 'function' ? maybeEnhancedReducer : maybeEnhancedReducer.reducer; | ||
return map; | ||
}, extraReducers); | ||
var reducer = createReducer(initialState, reducerMap); | ||
var actionMap = actionKeys.reduce(function (map, action) { | ||
var maybeEnhancedReducer = reducers[action]; | ||
var type = getType$1(slice, action); | ||
map[action] = typeof maybeEnhancedReducer === 'function' ? createAction(type) : createAction(type, maybeEnhancedReducer.prepare); | ||
return map; | ||
}, {}); | ||
var reducerNames = Object.keys(reducers); | ||
var sliceCaseReducersByName = {}; | ||
var sliceCaseReducersByType = {}; | ||
var actionCreators = {}; | ||
reducerNames.forEach(function (reducerName) { | ||
var maybeReducerWithPrepare = reducers[reducerName]; | ||
var type = getType$1(name, reducerName); | ||
var caseReducer; | ||
var prepareCallback; | ||
if (typeof maybeReducerWithPrepare === 'function') { | ||
caseReducer = maybeReducerWithPrepare; | ||
} else { | ||
caseReducer = maybeReducerWithPrepare.reducer; | ||
prepareCallback = maybeReducerWithPrepare.prepare; | ||
} | ||
sliceCaseReducersByName[reducerName] = caseReducer; | ||
sliceCaseReducersByType[type] = caseReducer; | ||
actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type); | ||
}); | ||
var finalCaseReducers = _objectSpread({}, extraReducers, sliceCaseReducersByType); | ||
var reducer = createReducer(initialState, finalCaseReducers); | ||
return { | ||
slice: slice, | ||
name: name, | ||
reducer: reducer, | ||
actions: actionMap | ||
actions: actionCreators, | ||
caseReducers: sliceCaseReducersByName | ||
}; | ||
@@ -519,0 +536,0 @@ } |
@@ -344,3 +344,3 @@ import { combineReducers, applyMiddleware, createStore, compose } from 'redux'; | ||
} else { | ||
throw new Error('Reducer argument must be a function or an object of functions that can be passed to combineReducers'); | ||
throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'); | ||
} | ||
@@ -476,7 +476,7 @@ | ||
function getType$1(slice, actionKey) { | ||
return slice ? "".concat(slice, "/").concat(actionKey) : actionKey; | ||
return "".concat(slice, "/").concat(actionKey); | ||
} | ||
/** | ||
* A function that accepts an initial state, an object full of reducer | ||
* functions, and optionally a "slice name", and automatically generates | ||
* functions, and a "slice name", and automatically generates | ||
* action creators and action types that correspond to the | ||
@@ -491,24 +491,41 @@ * reducers and state. | ||
function createSlice(options) { | ||
var _options$slice = options.slice, | ||
slice = _options$slice === void 0 ? '' : _options$slice, | ||
var name = options.name, | ||
initialState = options.initialState; | ||
if (!name) { | ||
throw new Error('`name` is a required option for createSlice'); | ||
} | ||
var reducers = options.reducers || {}; | ||
var extraReducers = options.extraReducers || {}; | ||
var actionKeys = Object.keys(reducers); | ||
var reducerMap = actionKeys.reduce(function (map, actionKey) { | ||
var maybeEnhancedReducer = reducers[actionKey]; | ||
map[getType$1(slice, actionKey)] = typeof maybeEnhancedReducer === 'function' ? maybeEnhancedReducer : maybeEnhancedReducer.reducer; | ||
return map; | ||
}, extraReducers); | ||
var reducer = createReducer(initialState, reducerMap); | ||
var actionMap = actionKeys.reduce(function (map, action) { | ||
var maybeEnhancedReducer = reducers[action]; | ||
var type = getType$1(slice, action); | ||
map[action] = typeof maybeEnhancedReducer === 'function' ? createAction(type) : createAction(type, maybeEnhancedReducer.prepare); | ||
return map; | ||
}, {}); | ||
var reducerNames = Object.keys(reducers); | ||
var sliceCaseReducersByName = {}; | ||
var sliceCaseReducersByType = {}; | ||
var actionCreators = {}; | ||
reducerNames.forEach(function (reducerName) { | ||
var maybeReducerWithPrepare = reducers[reducerName]; | ||
var type = getType$1(name, reducerName); | ||
var caseReducer; | ||
var prepareCallback; | ||
if (typeof maybeReducerWithPrepare === 'function') { | ||
caseReducer = maybeReducerWithPrepare; | ||
} else { | ||
caseReducer = maybeReducerWithPrepare.reducer; | ||
prepareCallback = maybeReducerWithPrepare.prepare; | ||
} | ||
sliceCaseReducersByName[reducerName] = caseReducer; | ||
sliceCaseReducersByType[type] = caseReducer; | ||
actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type); | ||
}); | ||
var finalCaseReducers = _objectSpread({}, extraReducers, sliceCaseReducersByType); | ||
var reducer = createReducer(initialState, finalCaseReducers); | ||
return { | ||
slice: slice, | ||
name: name, | ||
reducer: reducer, | ||
actions: actionMap | ||
actions: actionCreators, | ||
caseReducers: sliceCaseReducersByName | ||
}; | ||
@@ -515,0 +532,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RSK={})}(this,function(e){"use strict";var t=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),r=function(){return Math.random().toString(36).substring(7).split("").join(".")},n={INIT:"@@redux/INIT"+r(),REPLACE:"@@redux/REPLACE"+r(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+r()}};function o(e,r,i){var a;if("function"==typeof r&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof r&&void 0===i&&(i=r,r=void 0),void 0!==i){if("function"!=typeof i)throw Error("Expected the enhancer to be a function.");return i(o)(e,r)}if("function"!=typeof e)throw Error("Expected the reducer to be a function.");var u=e,c=r,f=[],s=f,l=!1;function p(){s===f&&(s=f.slice())}function d(){if(l)throw Error("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.");return c}function y(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(l)throw Error("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-reference/store#subscribe(listener) for more details.");var t=!0;return p(),s.push(e),function(){if(t){if(l)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,p();var r=s.indexOf(e);s.splice(r,1)}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=f=s,r=0;t.length>r;r++){(0,t[r])()}return e}return h({type:n.INIT}),(a={dispatch:h,subscribe:y,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");u=e,h({type:n.REPLACE})}})[t]=function(){var e,r=y;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(d())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},a}function i(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+r+'"'||"an action")+', reducer "'+e+'" 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.'}function a(e){for(var t=Object.keys(e),r={},o=0;t.length>o;o++){var a=t[o];"function"==typeof e[a]&&(r[a]=e[a])}var u,c=Object.keys(r);try{!function(e){Object.keys(e).forEach(function(t){var r=e[t];if(void 0===r(void 0,{type:n.INIT}))throw Error('Reducer "'+t+"\" 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.");if(void 0===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.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.')})}(r)}catch(e){u=e}return function(e,t){if(void 0===e&&(e={}),u)throw u;for(var n=!1,o={},a=0;c.length>a;a++){var f=c[a],s=e[f],l=(0,r[f])(s,t);if(void 0===l){var p=i(f,t);throw Error(p)}o[f]=l,n=n||l!==s}return n?o:e}}function u(e,t){return function(){return t(e.apply(this,arguments))}}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){c(e,t,r[t])})}return e}function s(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}function l(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return f({},r,{dispatch:n=s.apply(void 0,i)(r.dispatch)})}}}var p,d=Object.freeze({createStore:o,combineReducers:a,bindActionCreators:function(e,t){if("function"==typeof e)return u(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;r.length>o;o++){var i=r[o],a=e[i];"function"==typeof a&&(n[i]=u(a,t))}return n},applyMiddleware:l,compose:s,__DO_NOT_USE__ActionTypes:n}),y="undefined"!=typeof Symbol?Symbol("immer-nothing"):((p={})["immer-nothing"]=!0,p),h="undefined"!=typeof Symbol?Symbol.for("immer-draftable"):"__$immer_draftable",v="undefined"!=typeof Symbol?Symbol.for("immer-state"):"__$immer_state";function b(e){return!!e&&!!e[v]}function g(e){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e))return!0;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype||(!!e[h]||!!e.constructor[h])}var m=Object.assign||function(e,t){for(var r in t)P(t,r)&&(e[r]=t[r]);return e},w="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function O(e,t){if(void 0===t&&(t=!1),Array.isArray(e))return e.slice();var r=Object.create(Object.getPrototypeOf(e));return w(e).forEach(function(n){if(n!==v){var o=Object.getOwnPropertyDescriptor(e,n),i=o.value;if(o.get){if(!t)throw Error("Immer drafts cannot have computed properties");i=o.get.call(e)}o.enumerable?r[n]=i:Object.defineProperty(r,n,{value:i,writable:!0,configurable:!0})}}),r}function j(e,t){if(Array.isArray(e))for(var r=0;e.length>r;r++)t(r,e[r],e);else w(e).forEach(function(r){return t(r,e[r],e)})}function E(e,t){return Object.getOwnPropertyDescriptor(e,t).enumerable}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function A(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}var S=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function x(e){e[v].revoke()}S.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},S.prototype.revoke=function(){this.leave(),this.drafts.forEach(x),this.drafts=null},S.prototype.leave=function(){this===S.current&&(S.current=this.parent)},S.current=null,S.enter=function(){return this.current=new S(this.current)};var _={};function z(e,t){var r=Array.isArray(e),n=R(e);j(n,function(t){!function(e,t,r){var n=_[t];n?n.enumerable=r:_[t]=n={configurable:!0,enumerable:r,get:function(){return function(e,t){C(e);var r=D(T(e),t);if(e.finalizing)return r;if(r===D(e.base,t)&&g(r))return N(e),e.copy[t]=z(r,e);return r}(this[v],t)},set:function(e){!function(e,t,r){if(C(e),e.assigned[t]=!0,!e.modified){if(A(r,D(T(e),t)))return;I(e),N(e)}e.copy[t]=r}(this[v],t,e)}};Object.defineProperty(e,t,n)}(n,t,r||E(e,t))});var o=t?t.scope:S.current;return Object.defineProperty(n,v,{value:{scope:o,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:t,base:e,draft:n,copy:null,revoke:k,revoked:!1},enumerable:!1,writable:!0}),o.drafts.push(n),n}function k(){this.revoked=!0}function T(e){return e.copy||e.base}function D(e,t){var r=e[v];if(r&&!r.finalizing){r.finalizing=!0;var n=e[t];return r.finalizing=!1,n}return e[t]}function I(e){e.modified||(e.modified=!0,e.parent&&I(e.parent))}function N(e){e.copy||(e.copy=R(e.base))}function R(e){var t=e&&e[v];if(t){t.finalizing=!0;var r=O(t.draft,!0);return t.finalizing=!1,r}return O(e)}function C(e){if(!0===e.revoked)throw Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(T(e)))}function F(e){for(var t=e.length-1;t>=0;t--){var r=e[t][v];r.modified||(Array.isArray(r.base)?M(r)&&I(r):U(r)&&I(r))}}function U(e){for(var t=e.base,r=e.draft,n=Object.keys(r),o=n.length-1;o>=0;o--){var i=n[o],a=t[i];if(void 0===a&&!P(t,i))return!0;var u=r[i],c=u&&u[v];if(c?c.base!==a:!A(u,a))return!0}return n.length!==Object.keys(t).length}function M(e){var t=e.draft;if(t.length!==e.base.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var L=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach(function(e){e[v].finalizing=!0}),r?b(t)&&t[v].scope===e&&F(e.drafts):(e.patches&&function e(t){if(t&&"object"==typeof t){var r=t[v];if(r){var n=r.base,o=r.draft,i=r.assigned;if(Array.isArray(t)){if(M(r)){if(I(r),i.length=!0,n.length>o.length)for(var a=o.length;n.length>a;a++)i[a]=!1;else for(var u=n.length;o.length>u;u++)i[u]=!0;for(var c=0;o.length>c;c++)void 0===i[c]&&e(o[c])}}else Object.keys(o).forEach(function(t){void 0!==n[t]||P(n,t)?i[t]||e(o[t]):(i[t]=!0,I(r))}),Object.keys(n).forEach(function(e){void 0!==o[e]||P(o,e)||(i[e]=!1,I(r))})}}}(e.drafts[0]),F(e.drafts))},createProxy:z});function K(e,t){var r=t?t.scope:S.current,n={scope:r,modified:!1,finalized:!1,assigned:{},parent:t,base:e,draft:null,drafts:{},copy:null,revoke:null},o=Array.isArray(e)?Proxy.revocable([n],V):Proxy.revocable(n,X),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var X={get:function(e,t){if(t===v)return e;var r=e.drafts;if(!e.modified&&P(r,t))return r[t];var n=W(e)[t];if(e.finalized||!g(n))return n;if(e.modified){if(n!==B(e.base,t))return n;r=e.copy}return r[t]=K(n,e)},has:function(e,t){return t in W(e)},ownKeys:function(e){return Reflect.ownKeys(W(e))},set:function(e,t,r){if(!e.modified){var n=B(e.base,t),o=r?A(n,r)||r===e.drafts[t]:A(n,r)&&t in e.base;if(o)return!0;Y(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){(void 0!==B(e.base,t)||t in e.base)&&(e.assigned[t]=!1,Y(e));e.copy&&delete e.copy[t];return!0},getOwnPropertyDescriptor:function(e,t){var r=W(e),n=Reflect.getOwnPropertyDescriptor(r,t);n&&(n.writable=!0,n.configurable=!Array.isArray(r)||"length"!==t);return n},defineProperty:function(){throw Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},V={};function W(e){return e.copy||e.base}function B(e,t){var r=e[v],n=Reflect.getOwnPropertyDescriptor(r?W(r):e,t);return n&&n.value}function Y(e){e.modified||(e.modified=!0,e.copy=m(O(e.base),e.drafts),e.drafts=null,e.parent&&Y(e.parent))}j(X,function(e,t){V[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),V.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw Error("Immer only supports deleting array indices");return X.deleteProperty.call(this,e[0],t)},V.set=function(e,t,r){if("length"!==t&&isNaN(parseInt(t)))throw Error("Immer only supports setting array indices and the 'length' property");return X.set.call(this,e[0],t,r)};var q=Object.freeze({willFinalize:function(){},createProxy:K});function $(e,t,r,n){Array.isArray(e.base)?function(e,t,r,n){var o,i,a=e.base,u=e.copy,c=e.assigned;a.length>u.length&&(a=(o=[u,a])[0],u=o[1],r=(i=[n,r])[0],n=i[1]);var f=u.length-a.length,s=0;for(;a[s]===u[s]&&a.length>s;)++s;var l=a.length;for(;l>s&&a[l-1]===u[l+f-1];)--l;for(var p=s;l>p;++p)if(c[p]&&u[p]!==a[p]){var d=t.concat([p]);r.push({op:"replace",path:d,value:u[p]}),n.push({op:"replace",path:d,value:a[p]})}for(var y=l!=a.length,h=r.length,v=l+f-1;v>=l;--v){var b=t.concat([v]);r[h+v-l]={op:"add",path:b,value:u[v]},y&&n.push({op:"remove",path:b})}y||n.push({op:"replace",path:t.concat(["length"]),value:a.length})}(e,t,r,n):function(e,t,r,n){var o=e.base,i=e.copy;j(e.assigned,function(e,a){var u=o[e],c=i[e],f=a?e in o?"replace":"add":"remove";if(u!==c||"replace"!==f){var s=t.concat(e);r.push("remove"===f?{op:f,path:s}:{op:f,path:s,value:c}),n.push("add"===f?{op:"remove",path:s}:"remove"===f?{op:"add",path:s,value:u}:{op:"replace",path:s,value:u})}})}(e,t,r,n)}function G(e,t){for(var r=0;t.length>r;r++){var n=t[r],o=n.path;if(0===o.length&&"replace"===n.op)e=n.value;else{for(var i=e,a=0;o.length-1>a;a++)if(!(i=i[o[a]])||"object"!=typeof i)throw Error("Cannot apply patch, path doesn't resolve: "+o.join("/"));var u=o[o.length-1];switch(n.op){case"replace":i[u]=n.value;break;case"add":Array.isArray(i)?i.splice(u,0,n.value):i[u]=n.value;break;case"remove":Array.isArray(i)?i.splice(u,1):delete i[u];break;default:throw Error("Unsupported patch operation: "+n.op)}}}return e}var H={useProxies:"undefined"!=typeof Proxy&&"undefined"!=typeof Reflect,autoFreeze:!1,onAssign:null,onDelete:null,onCopy:null},J=function(e){m(this,H,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};J.prototype.produce=function(e,t,r){var n,o=this;if("function"==typeof e&&"function"!=typeof t){var i=t;return t=e,function(e){void 0===e&&(e=i);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return o.produce(e,function(e){return t.call.apply(t,[e,e].concat(r))})}}if("function"!=typeof t)throw Error("The first or second argument to `produce` must be a function");if(void 0!==r&&"function"!=typeof r)throw Error("The third argument to `produce` must be a function or undefined");if(g(e)){var a=S.enter(),u=this.createProxy(e),c=!0;try{n=t.call(u,u),c=!1}finally{c?a.revoke():a.leave()}return n instanceof Promise?n.then(function(e){return a.usePatches(r),o.processResult(e,a)},function(e){throw a.revoke(),e}):(a.usePatches(r),this.processResult(n,a))}return void 0===(n=t(e))?e:n!==y?n:void 0},J.prototype.createDraft=function(e){if(!g(e))throw Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var t=S.enter(),r=this.createProxy(e);return r[v].isManual=!0,t.leave(),r},J.prototype.finishDraft=function(e,t){var r=e&&e[v];if(!r||!r.isManual)throw Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(r.finalized)throw Error("The given draft is already finalized");var n=r.scope;return n.usePatches(t),this.processResult(void 0,n)},J.prototype.setAutoFreeze=function(e){this.autoFreeze=e},J.prototype.setUseProxies=function(e){this.useProxies=e,m(this,e?q:L)},J.prototype.applyPatches=function(e,t){return b(e)?G(e,t):this.produce(e,function(e){return G(e,t)})},J.prototype.processResult=function(e,t){var r=t.drafts[0],n=void 0!==e&&e!==r;if(this.willFinalize(t,e,n),n){if(r[v].modified)throw t.revoke(),Error("An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.");g(e)&&(e=this.finalize(e,null,t)),t.patches&&(t.patches.push({op:"replace",path:[],value:e}),t.inversePatches.push({op:"replace",path:[],value:r[v].base}))}else e=this.finalize(r,[],t);return t.revoke(),t.patches&&t.patchListener(t.patches,t.inversePatches),e!==y?e:void 0},J.prototype.finalize=function(e,t,r){var n=this,o=e[v];if(!o)return Object.isFrozen(e)?e:this.finalizeTree(e,null,r);if(o.scope!==r)return e;if(!o.modified)return o.base;if(!o.finalized){if(o.finalized=!0,this.finalizeTree(o.draft,t,r),this.onDelete)if(this.useProxies){var i=o.assigned;for(var a in i)i[a]||this.onDelete(o,a)}else{var u=o.copy;j(o.base,function(e){P(u,e)||n.onDelete(o,e)})}this.onCopy&&this.onCopy(o),this.autoFreeze&&r.canAutoFreeze&&Object.freeze(o.copy),t&&r.patches&&$(o,t,r.patches,r.inversePatches)}return o.copy},J.prototype.finalizeTree=function(e,t,r){var n=this,o=e[v];o&&(this.useProxies||(o.copy=O(o.draft,!0)),e=o.copy);var i=!!t&&!!r.patches,a=function(u,c,f){if(c===f)throw Error("Immer forbids circular references");var s=!!o&&f===e;if(b(c)){var l=s&&i&&!o.assigned[u]?t.concat(u):null;if(b(c=n.finalize(c,l,r))&&(r.canAutoFreeze=!1),Array.isArray(f)||E(f,u)?f[u]=c:Object.defineProperty(f,u,{value:c}),s&&c===o.base[u])return}else{if(s&&A(c,o.base[u]))return;g(c)&&!Object.isFrozen(c)&&j(c,a)}s&&n.onAssign&&n.onAssign(o,u,c)};return j(e,a),e};var Q=new J,Z=Q.produce;Q.setAutoFreeze.bind(Q),Q.setUseProxies.bind(Q),Q.applyPatches.bind(Q),Q.createDraft.bind(Q),Q.finishDraft.bind(Q);function ee(e,t){return e===t}function te(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;n>o;o++)if(!e(t[o],r[o]))return!1;return!0}function re(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every(function(e){return"function"==typeof e})){var r=t.map(function(e){return typeof e}).join(", ");throw Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}var ne=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;t>o;o++)n[o]=arguments[o];var i=0,a=n.pop(),u=re(n),c=e.apply(void 0,[function(){return i++,a.apply(null,arguments)}].concat(r)),f=e(function(){for(var e=[],t=u.length,r=0;t>r;r++)e.push(u[r].apply(null,arguments));return c.apply(null,e)});return f.resultFunc=a,f.dependencies=u,f.recomputations=function(){return i},f.resetRecomputations=function(){return i=0},f}}(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ee,r=null,n=null;return function(){return te(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}});function oe(e){return(oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ae(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function ue(e){return function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);e.length>t;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var ce,fe=function(e,t){return e(t={exports:{}},t.exports),t.exports}(function(e,t){var r=d.compose;t.__esModule=!0,t.composeWithDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?r:r.apply(null,arguments)},t.devToolsEnhancer="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}}});(ce=fe)&&ce.__esModule&&Object.prototype.hasOwnProperty.call(ce,"default");var se=fe.composeWithDevTools;function le(e){if("object"!==oe(e)||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function pe(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var de=pe();function ye(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||le(e)}de.withExtraArgument=pe;var he="A non-serializable value was detected in the state, in the path: `%s`. Value: %o\nTake a look at the reducer(s) handling this action type: %s.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)",ve="A non-serializable value was detected in an action, in the path: `%s`. Value: %o\nTake a look at the logic that dispatched this action: %o.\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)";function be(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ye,o=arguments.length>3?arguments[3]:void 0;if(!n(e))return{keyPath:r.join(".")||"<root>",value:e};if("object"!==oe(e)||null===e)return!1;var i=null!=o?o(e):Object.entries(e),a=!0,u=!1,c=void 0;try{for(var f,s=i[Symbol.iterator]();!(a=(f=s.next()).done);a=!0){var l=ae(f.value,2),p=l[1],d=r.concat(l[0]);if(!n(p))return{keyPath:d.join("."),value:p};if("object"===oe(p)&&(t=be(p,d,n,o)))return t}}catch(e){u=!0,c=e}finally{try{a||null==s.return||s.return()}finally{if(u)throw c}}return!1}function ge(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.thunk,r=void 0===t||t,n=[];return r&&(!function(e){return"boolean"==typeof e}(r)?n.push(de.withExtraArgument(r.extraArgument)):n.push(de)),n}var me=!0;function we(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw Error("prepareAction did not return an object");return"meta"in r?{type:e,payload:r.payload,meta:r.meta}:{type:e,payload:r.payload}}return{type:e,payload:arguments.length>0?arguments[0]:void 0}}return r.toString=function(){return"".concat(e)},r.type=e,r}function Oe(e,t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;return Z(r,function(e){var r=t[n.type];return r?r(e,n):void 0})}}function je(e,t){return e?"".concat(e,"/").concat(t):t}e.combineReducers=a,e.compose=s,e.configureStore=function(e){var t,r=e||{},n=r.reducer,i=void 0===n?void 0:n,u=r.middleware,c=void 0===u?ge():u,f=r.devTools,p=void 0===f||f,d=r.preloadedState,y=void 0===d?void 0:d,h=r.enhancers,v=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!le(i))throw Error("Reducer argument must be a function or an object of functions that can be passed to combineReducers");t=a(i)}var b=l.apply(void 0,ue(c)),g=s;p&&(g=se(function(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){ie(e,t,r[t])})}return e}({trace:!me},"object"===oe(p)&&p)));var m=[b];return Array.isArray(v)?m=[b].concat(ue(v)):"function"==typeof v&&(m=v(m)),o(t,y,g.apply(void 0,ue(m)))},e.createAction=we,e.createNextState=Z,e.createReducer=Oe,e.createSelector=ne,e.createSerializableStateInvariantMiddleware=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isSerializable,r=void 0===t?ye:t,n=e.getEntries,o=e.ignoredActions,i=void 0===o?[]:o;return function(e){return function(t){return function(o){if(i.length&&-1!==i.indexOf(o.type))return t(o);var a=be(o,[],r,n);a&&console.error(ve,a.keyPath,a.value,o);var u=t(o),c=be(e.getState(),[],r,n);return c&&console.error(he,c.keyPath,c.value,o.type),u}}}},e.createSlice=function(e){var t=e.slice,r=void 0===t?"":t,n=e.initialState,o=e.reducers||{},i=e.extraReducers||{},a=Object.keys(o),u=Oe(n,a.reduce(function(e,t){var n=o[t];return e[je(r,t)]="function"==typeof n?n:n.reducer,e},i)),c=a.reduce(function(e,t){var n=o[t],i=je(r,t);return e[t]="function"==typeof n?we(i):we(i,n.prepare),e},{});return{slice:r,reducer:u,actions:c}},e.findNonSerializableValue=be,e.getDefaultMiddleware=ge,e.getType=function(e){return"".concat(e)},e.isPlain=ye,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RSK={})}(this,function(e){"use strict";var t=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),r=function(){return Math.random().toString(36).substring(7).split("").join(".")},n={INIT:"@@redux/INIT"+r(),REPLACE:"@@redux/REPLACE"+r(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+r()}};function o(e,r,i){var a;if("function"==typeof r&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof r&&void 0===i&&(i=r,r=void 0),void 0!==i){if("function"!=typeof i)throw Error("Expected the enhancer to be a function.");return i(o)(e,r)}if("function"!=typeof e)throw Error("Expected the reducer to be a function.");var u=e,c=r,f=[],s=f,l=!1;function p(){s===f&&(s=f.slice())}function d(){if(l)throw Error("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.");return c}function y(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(l)throw Error("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-reference/store#subscribe(listener) for more details.");var t=!0;return p(),s.push(e),function(){if(t){if(l)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,p();var r=s.indexOf(e);s.splice(r,1)}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=f=s,r=0;t.length>r;r++){(0,t[r])()}return e}return h({type:n.INIT}),(a={dispatch:h,subscribe:y,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");u=e,h({type:n.REPLACE})}})[t]=function(){var e,r=y;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(d())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},a}function i(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+r+'"'||"an action")+', reducer "'+e+'" 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.'}function a(e){for(var t=Object.keys(e),r={},o=0;t.length>o;o++){var a=t[o];"function"==typeof e[a]&&(r[a]=e[a])}var u,c=Object.keys(r);try{!function(e){Object.keys(e).forEach(function(t){var r=e[t];if(void 0===r(void 0,{type:n.INIT}))throw Error('Reducer "'+t+"\" 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.");if(void 0===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.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.')})}(r)}catch(e){u=e}return function(e,t){if(void 0===e&&(e={}),u)throw u;for(var n=!1,o={},a=0;c.length>a;a++){var f=c[a],s=e[f],l=(0,r[f])(s,t);if(void 0===l){var p=i(f,t);throw Error(p)}o[f]=l,n=n||l!==s}return n?o:e}}function u(e,t){return function(){return t(e.apply(this,arguments))}}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){c(e,t,r[t])})}return e}function s(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}function l(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return f({},r,{dispatch:n=s.apply(void 0,i)(r.dispatch)})}}}var p,d=Object.freeze({createStore:o,combineReducers:a,bindActionCreators:function(e,t){if("function"==typeof e)return u(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;r.length>o;o++){var i=r[o],a=e[i];"function"==typeof a&&(n[i]=u(a,t))}return n},applyMiddleware:l,compose:s,__DO_NOT_USE__ActionTypes:n}),y="undefined"!=typeof Symbol?Symbol("immer-nothing"):((p={})["immer-nothing"]=!0,p),h="undefined"!=typeof Symbol?Symbol.for("immer-draftable"):"__$immer_draftable",v="undefined"!=typeof Symbol?Symbol.for("immer-state"):"__$immer_state";function b(e){return!!e&&!!e[v]}function g(e){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e))return!0;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype||(!!e[h]||!!e.constructor[h])}var m=Object.assign||function(e,t){for(var r in t)P(t,r)&&(e[r]=t[r]);return e},w="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function O(e,t){if(void 0===t&&(t=!1),Array.isArray(e))return e.slice();var r=Object.create(Object.getPrototypeOf(e));return w(e).forEach(function(n){if(n!==v){var o=Object.getOwnPropertyDescriptor(e,n),i=o.value;if(o.get){if(!t)throw Error("Immer drafts cannot have computed properties");i=o.get.call(e)}o.enumerable?r[n]=i:Object.defineProperty(r,n,{value:i,writable:!0,configurable:!0})}}),r}function j(e,t){if(Array.isArray(e))for(var r=0;e.length>r;r++)t(r,e[r],e);else w(e).forEach(function(r){return t(r,e[r],e)})}function E(e,t){return Object.getOwnPropertyDescriptor(e,t).enumerable}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function A(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}var S=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function x(e){e[v].revoke()}S.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},S.prototype.revoke=function(){this.leave(),this.drafts.forEach(x),this.drafts=null},S.prototype.leave=function(){this===S.current&&(S.current=this.parent)},S.current=null,S.enter=function(){return this.current=new S(this.current)};var _={};function z(e,t){var r=Array.isArray(e),n=R(e);j(n,function(t){!function(e,t,r){var n=_[t];n?n.enumerable=r:_[t]=n={configurable:!0,enumerable:r,get:function(){return function(e,t){C(e);var r=D(T(e),t);if(e.finalizing)return r;if(r===D(e.base,t)&&g(r))return N(e),e.copy[t]=z(r,e);return r}(this[v],t)},set:function(e){!function(e,t,r){if(C(e),e.assigned[t]=!0,!e.modified){if(A(r,D(T(e),t)))return;I(e),N(e)}e.copy[t]=r}(this[v],t,e)}};Object.defineProperty(e,t,n)}(n,t,r||E(e,t))});var o=t?t.scope:S.current;return Object.defineProperty(n,v,{value:{scope:o,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:t,base:e,draft:n,copy:null,revoke:k,revoked:!1},enumerable:!1,writable:!0}),o.drafts.push(n),n}function k(){this.revoked=!0}function T(e){return e.copy||e.base}function D(e,t){var r=e[v];if(r&&!r.finalizing){r.finalizing=!0;var n=e[t];return r.finalizing=!1,n}return e[t]}function I(e){e.modified||(e.modified=!0,e.parent&&I(e.parent))}function N(e){e.copy||(e.copy=R(e.base))}function R(e){var t=e&&e[v];if(t){t.finalizing=!0;var r=O(t.draft,!0);return t.finalizing=!1,r}return O(e)}function C(e){if(!0===e.revoked)throw Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(T(e)))}function F(e){for(var t=e.length-1;t>=0;t--){var r=e[t][v];r.modified||(Array.isArray(r.base)?M(r)&&I(r):U(r)&&I(r))}}function U(e){for(var t=e.base,r=e.draft,n=Object.keys(r),o=n.length-1;o>=0;o--){var i=n[o],a=t[i];if(void 0===a&&!P(t,i))return!0;var u=r[i],c=u&&u[v];if(c?c.base!==a:!A(u,a))return!0}return n.length!==Object.keys(t).length}function M(e){var t=e.draft;if(t.length!==e.base.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var L=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach(function(e){e[v].finalizing=!0}),r?b(t)&&t[v].scope===e&&F(e.drafts):(e.patches&&function e(t){if(t&&"object"==typeof t){var r=t[v];if(r){var n=r.base,o=r.draft,i=r.assigned;if(Array.isArray(t)){if(M(r)){if(I(r),i.length=!0,n.length>o.length)for(var a=o.length;n.length>a;a++)i[a]=!1;else for(var u=n.length;o.length>u;u++)i[u]=!0;for(var c=0;o.length>c;c++)void 0===i[c]&&e(o[c])}}else Object.keys(o).forEach(function(t){void 0!==n[t]||P(n,t)?i[t]||e(o[t]):(i[t]=!0,I(r))}),Object.keys(n).forEach(function(e){void 0!==o[e]||P(o,e)||(i[e]=!1,I(r))})}}}(e.drafts[0]),F(e.drafts))},createProxy:z});function K(e,t){var r=t?t.scope:S.current,n={scope:r,modified:!1,finalized:!1,assigned:{},parent:t,base:e,draft:null,drafts:{},copy:null,revoke:null},o=Array.isArray(e)?Proxy.revocable([n],V):Proxy.revocable(n,X),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var X={get:function(e,t){if(t===v)return e;var r=e.drafts;if(!e.modified&&P(r,t))return r[t];var n=W(e)[t];if(e.finalized||!g(n))return n;if(e.modified){if(n!==q(e.base,t))return n;r=e.copy}return r[t]=K(n,e)},has:function(e,t){return t in W(e)},ownKeys:function(e){return Reflect.ownKeys(W(e))},set:function(e,t,r){if(!e.modified){var n=q(e.base,t),o=r?A(n,r)||r===e.drafts[t]:A(n,r)&&t in e.base;if(o)return!0;B(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){(void 0!==q(e.base,t)||t in e.base)&&(e.assigned[t]=!1,B(e));e.copy&&delete e.copy[t];return!0},getOwnPropertyDescriptor:function(e,t){var r=W(e),n=Reflect.getOwnPropertyDescriptor(r,t);n&&(n.writable=!0,n.configurable=!Array.isArray(r)||"length"!==t);return n},defineProperty:function(){throw Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},V={};function W(e){return e.copy||e.base}function q(e,t){var r=e[v],n=Reflect.getOwnPropertyDescriptor(r?W(r):e,t);return n&&n.value}function B(e){e.modified||(e.modified=!0,e.copy=m(O(e.base),e.drafts),e.drafts=null,e.parent&&B(e.parent))}j(X,function(e,t){V[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),V.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw Error("Immer only supports deleting array indices");return X.deleteProperty.call(this,e[0],t)},V.set=function(e,t,r){if("length"!==t&&isNaN(parseInt(t)))throw Error("Immer only supports setting array indices and the 'length' property");return X.set.call(this,e[0],t,r)};var Y=Object.freeze({willFinalize:function(){},createProxy:K});function $(e,t,r,n){Array.isArray(e.base)?function(e,t,r,n){var o,i,a=e.base,u=e.copy,c=e.assigned;a.length>u.length&&(a=(o=[u,a])[0],u=o[1],r=(i=[n,r])[0],n=i[1]);var f=u.length-a.length,s=0;for(;a[s]===u[s]&&a.length>s;)++s;var l=a.length;for(;l>s&&a[l-1]===u[l+f-1];)--l;for(var p=s;l>p;++p)if(c[p]&&u[p]!==a[p]){var d=t.concat([p]);r.push({op:"replace",path:d,value:u[p]}),n.push({op:"replace",path:d,value:a[p]})}for(var y=l!=a.length,h=r.length,v=l+f-1;v>=l;--v){var b=t.concat([v]);r[h+v-l]={op:"add",path:b,value:u[v]},y&&n.push({op:"remove",path:b})}y||n.push({op:"replace",path:t.concat(["length"]),value:a.length})}(e,t,r,n):function(e,t,r,n){var o=e.base,i=e.copy;j(e.assigned,function(e,a){var u=o[e],c=i[e],f=a?e in o?"replace":"add":"remove";if(u!==c||"replace"!==f){var s=t.concat(e);r.push("remove"===f?{op:f,path:s}:{op:f,path:s,value:c}),n.push("add"===f?{op:"remove",path:s}:"remove"===f?{op:"add",path:s,value:u}:{op:"replace",path:s,value:u})}})}(e,t,r,n)}function G(e,t){for(var r=0;t.length>r;r++){var n=t[r],o=n.path;if(0===o.length&&"replace"===n.op)e=n.value;else{for(var i=e,a=0;o.length-1>a;a++)if(!(i=i[o[a]])||"object"!=typeof i)throw Error("Cannot apply patch, path doesn't resolve: "+o.join("/"));var u=o[o.length-1];switch(n.op){case"replace":i[u]=n.value;break;case"add":Array.isArray(i)?i.splice(u,0,n.value):i[u]=n.value;break;case"remove":Array.isArray(i)?i.splice(u,1):delete i[u];break;default:throw Error("Unsupported patch operation: "+n.op)}}}return e}var H={useProxies:"undefined"!=typeof Proxy&&"undefined"!=typeof Reflect,autoFreeze:!1,onAssign:null,onDelete:null,onCopy:null},J=function(e){m(this,H,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};J.prototype.produce=function(e,t,r){var n,o=this;if("function"==typeof e&&"function"!=typeof t){var i=t;return t=e,function(e){void 0===e&&(e=i);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return o.produce(e,function(e){return t.call.apply(t,[e,e].concat(r))})}}if("function"!=typeof t)throw Error("The first or second argument to `produce` must be a function");if(void 0!==r&&"function"!=typeof r)throw Error("The third argument to `produce` must be a function or undefined");if(g(e)){var a=S.enter(),u=this.createProxy(e),c=!0;try{n=t.call(u,u),c=!1}finally{c?a.revoke():a.leave()}return n instanceof Promise?n.then(function(e){return a.usePatches(r),o.processResult(e,a)},function(e){throw a.revoke(),e}):(a.usePatches(r),this.processResult(n,a))}return void 0===(n=t(e))?e:n!==y?n:void 0},J.prototype.createDraft=function(e){if(!g(e))throw Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var t=S.enter(),r=this.createProxy(e);return r[v].isManual=!0,t.leave(),r},J.prototype.finishDraft=function(e,t){var r=e&&e[v];if(!r||!r.isManual)throw Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(r.finalized)throw Error("The given draft is already finalized");var n=r.scope;return n.usePatches(t),this.processResult(void 0,n)},J.prototype.setAutoFreeze=function(e){this.autoFreeze=e},J.prototype.setUseProxies=function(e){this.useProxies=e,m(this,e?Y:L)},J.prototype.applyPatches=function(e,t){return b(e)?G(e,t):this.produce(e,function(e){return G(e,t)})},J.prototype.processResult=function(e,t){var r=t.drafts[0],n=void 0!==e&&e!==r;if(this.willFinalize(t,e,n),n){if(r[v].modified)throw t.revoke(),Error("An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.");g(e)&&(e=this.finalize(e,null,t)),t.patches&&(t.patches.push({op:"replace",path:[],value:e}),t.inversePatches.push({op:"replace",path:[],value:r[v].base}))}else e=this.finalize(r,[],t);return t.revoke(),t.patches&&t.patchListener(t.patches,t.inversePatches),e!==y?e:void 0},J.prototype.finalize=function(e,t,r){var n=this,o=e[v];if(!o)return Object.isFrozen(e)?e:this.finalizeTree(e,null,r);if(o.scope!==r)return e;if(!o.modified)return o.base;if(!o.finalized){if(o.finalized=!0,this.finalizeTree(o.draft,t,r),this.onDelete)if(this.useProxies){var i=o.assigned;for(var a in i)i[a]||this.onDelete(o,a)}else{var u=o.copy;j(o.base,function(e){P(u,e)||n.onDelete(o,e)})}this.onCopy&&this.onCopy(o),this.autoFreeze&&r.canAutoFreeze&&Object.freeze(o.copy),t&&r.patches&&$(o,t,r.patches,r.inversePatches)}return o.copy},J.prototype.finalizeTree=function(e,t,r){var n=this,o=e[v];o&&(this.useProxies||(o.copy=O(o.draft,!0)),e=o.copy);var i=!!t&&!!r.patches,a=function(u,c,f){if(c===f)throw Error("Immer forbids circular references");var s=!!o&&f===e;if(b(c)){var l=s&&i&&!o.assigned[u]?t.concat(u):null;if(b(c=n.finalize(c,l,r))&&(r.canAutoFreeze=!1),Array.isArray(f)||E(f,u)?f[u]=c:Object.defineProperty(f,u,{value:c}),s&&c===o.base[u])return}else{if(s&&A(c,o.base[u]))return;g(c)&&!Object.isFrozen(c)&&j(c,a)}s&&n.onAssign&&n.onAssign(o,u,c)};return j(e,a),e};var Q=new J,Z=Q.produce;Q.setAutoFreeze.bind(Q),Q.setUseProxies.bind(Q),Q.applyPatches.bind(Q),Q.createDraft.bind(Q),Q.finishDraft.bind(Q);function ee(e,t){return e===t}function te(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;n>o;o++)if(!e(t[o],r[o]))return!1;return!0}function re(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every(function(e){return"function"==typeof e})){var r=t.map(function(e){return typeof e}).join(", ");throw Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}var ne=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;t>o;o++)n[o]=arguments[o];var i=0,a=n.pop(),u=re(n),c=e.apply(void 0,[function(){return i++,a.apply(null,arguments)}].concat(r)),f=e(function(){for(var e=[],t=u.length,r=0;t>r;r++)e.push(u[r].apply(null,arguments));return c.apply(null,e)});return f.resultFunc=a,f.dependencies=u,f.recomputations=function(){return i},f.resetRecomputations=function(){return i=0},f}}(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ee,r=null,n=null;return function(){return te(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}});function oe(e){return(oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ae(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){ie(e,t,r[t])})}return e}function ue(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function ce(e){return function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);e.length>t;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var fe,se=function(e,t){return e(t={exports:{}},t.exports),t.exports}(function(e,t){var r=d.compose;t.__esModule=!0,t.composeWithDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?r:r.apply(null,arguments)},t.devToolsEnhancer="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}}});(fe=se)&&fe.__esModule&&Object.prototype.hasOwnProperty.call(fe,"default");var le=se.composeWithDevTools;function pe(e){if("object"!==oe(e)||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function de(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var ye=de();function he(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||pe(e)}ye.withExtraArgument=de;var ve="A non-serializable value was detected in the state, in the path: `%s`. Value: %o\nTake a look at the reducer(s) handling this action type: %s.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)",be="A non-serializable value was detected in an action, in the path: `%s`. Value: %o\nTake a look at the logic that dispatched this action: %o.\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)";function ge(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:he,o=arguments.length>3?arguments[3]:void 0;if(!n(e))return{keyPath:r.join(".")||"<root>",value:e};if("object"!==oe(e)||null===e)return!1;var i=null!=o?o(e):Object.entries(e),a=!0,u=!1,c=void 0;try{for(var f,s=i[Symbol.iterator]();!(a=(f=s.next()).done);a=!0){var l=ue(f.value,2),p=l[1],d=r.concat(l[0]);if(!n(p))return{keyPath:d.join("."),value:p};if("object"===oe(p)&&(t=ge(p,d,n,o)))return t}}catch(e){u=!0,c=e}finally{try{a||null==s.return||s.return()}finally{if(u)throw c}}return!1}function me(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.thunk,r=void 0===t||t,n=[];return r&&(!function(e){return"boolean"==typeof e}(r)?n.push(ye.withExtraArgument(r.extraArgument)):n.push(ye)),n}var we=!0;function Oe(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw Error("prepareAction did not return an object");return"meta"in r?{type:e,payload:r.payload,meta:r.meta}:{type:e,payload:r.payload}}return{type:e,payload:arguments.length>0?arguments[0]:void 0}}return r.toString=function(){return"".concat(e)},r.type=e,r}function je(e,t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;return Z(r,function(e){var r=t[n.type];return r?r(e,n):void 0})}}e.combineReducers=a,e.compose=s,e.configureStore=function(e){var t,r=e||{},n=r.reducer,i=void 0===n?void 0:n,u=r.middleware,c=void 0===u?me():u,f=r.devTools,p=void 0===f||f,d=r.preloadedState,y=void 0===d?void 0:d,h=r.enhancers,v=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!pe(i))throw Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=a(i)}var b=l.apply(void 0,ce(c)),g=s;p&&(g=le(ae({trace:!we},"object"===oe(p)&&p)));var m=[b];return Array.isArray(v)?m=[b].concat(ce(v)):"function"==typeof v&&(m=v(m)),o(t,y,g.apply(void 0,ce(m)))},e.createAction=Oe,e.createNextState=Z,e.createReducer=je,e.createSelector=ne,e.createSerializableStateInvariantMiddleware=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isSerializable,r=void 0===t?he:t,n=e.getEntries,o=e.ignoredActions,i=void 0===o?[]:o;return function(e){return function(t){return function(o){if(i.length&&-1!==i.indexOf(o.type))return t(o);var a=ge(o,[],r,n);a&&console.error(be,a.keyPath,a.value,o);var u=t(o),c=ge(e.getState(),[],r,n);return c&&console.error(ve,c.keyPath,c.value,o.type),u}}}},e.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw Error("`name` is a required option for createSlice");var n=e.reducers||{},o=e.extraReducers||{},i={},a={},u={};Object.keys(n).forEach(function(e){var r,o,c,f=n[e],s=(r=e,"".concat(t,"/").concat(r));"function"==typeof f?o=f:(o=f.reducer,c=f.prepare),i[e]=o,a[s]=o,u[e]=c?Oe(s,c):Oe(s)});var c=je(r,ae({},o,a));return{name:t,reducer:c,actions:u,caseReducers:i}},e.findNonSerializableValue=ge,e.getDefaultMiddleware=me,e.getType=function(e){return"".concat(e)},e.isPlain=he,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "redux-starter-kit", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "A simple set of tools to make using Redux easier", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/reduxjs/redux-starter-kit", |
@@ -35,3 +35,3 @@ # Redux Starter Kit | ||
- A `createSlice()` function that accepts a set of reducer functions, a slice name, and an initial state value, and automatically generates corresponding action creators, types, and simple selector functions. | ||
- An improved version of the widely used `createSelector` utility for creating memoized selector functions, which can accept string keypaths as "input selectors" (re-exported from the [`selectorator` library](https://github.com/planttheidea/selectorator)). | ||
- The `createSelector` utility from the [Reselect](https://github.com/reduxjs/reselect) library, re-exported for ease of use. | ||
@@ -38,0 +38,0 @@ ## Documentation |
@@ -53,3 +53,3 @@ import { configureStore } from './configureStore' | ||
expect(configureStore).toThrow( | ||
'Reducer argument must be a function or an object of functions that can be passed to combineReducers' | ||
'"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers' | ||
) | ||
@@ -56,0 +56,0 @@ }) |
@@ -112,3 +112,3 @@ import { | ||
throw new Error( | ||
'Reducer argument must be a function or an object of functions that can be passed to combineReducers' | ||
'"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers' | ||
) | ||
@@ -115,0 +115,0 @@ } |
import { Action } from 'redux' | ||
import { IsUnknownOrNonInferrable } from './tsHelpers' | ||
@@ -12,3 +13,3 @@ /** | ||
export type PayloadAction< | ||
P = any, | ||
P = void, | ||
T extends string = string, | ||
@@ -50,3 +51,12 @@ M = void | ||
T extends string = string | ||
> = WithTypeProperty<T, <PT extends P>(payload: PT) => PayloadAction<PT, T>> | ||
> = WithTypeProperty< | ||
T, | ||
IsUnknownOrNonInferrable< | ||
P, | ||
// TS < 3.5 infers non-inferrable types to {}, which does not take `null`. This enforces `undefined` instead. | ||
<PT extends unknown>(payload: PT) => PayloadAction<PT, T>, | ||
// default behaviour | ||
<PT extends P>(payload: PT) => PayloadAction<PT, T> | ||
> | ||
> | ||
@@ -57,3 +67,3 @@ /** | ||
export type PayloadActionCreator< | ||
P = any, | ||
P = void, | ||
T extends string = string, | ||
@@ -90,3 +100,3 @@ PA extends PrepareAction<P> | void = void | ||
export function createAction<P = any, T extends string = string>( | ||
export function createAction<P = void, T extends string = string>( | ||
type: T | ||
@@ -93,0 +103,0 @@ ): PayloadActionCreator<P, T> |
@@ -5,47 +5,36 @@ import { createSlice } from './createSlice' | ||
describe('createSlice', () => { | ||
describe('when slice is empty', () => { | ||
const { actions, reducer } = createSlice({ | ||
reducers: { | ||
increment: state => state + 1, | ||
multiply: (state, action: PayloadAction<number>) => | ||
state * action.payload | ||
}, | ||
initialState: 0 | ||
describe('when slice is undefined', () => { | ||
it('should throw an error', () => { | ||
expect(() => | ||
// @ts-ignore | ||
createSlice({ | ||
reducers: { | ||
increment: state => state + 1, | ||
multiply: (state, action: PayloadAction<number>) => | ||
state * action.payload | ||
}, | ||
initialState: 0 | ||
}) | ||
).toThrowError() | ||
}) | ||
}) | ||
it('should create increment action', () => { | ||
expect(actions.hasOwnProperty('increment')).toBe(true) | ||
describe('when slice is an empty string', () => { | ||
it('should throw an error', () => { | ||
expect(() => | ||
createSlice({ | ||
name: '', | ||
reducers: { | ||
increment: state => state + 1, | ||
multiply: (state, action: PayloadAction<number>) => | ||
state * action.payload | ||
}, | ||
initialState: 0 | ||
}) | ||
).toThrowError() | ||
}) | ||
it('should create multiply action', () => { | ||
expect(actions.hasOwnProperty('multiply')).toBe(true) | ||
}) | ||
it('should have the correct action for increment', () => { | ||
expect(actions.increment()).toEqual({ | ||
type: 'increment', | ||
payload: undefined | ||
}) | ||
}) | ||
it('should have the correct action for multiply', () => { | ||
expect(actions.multiply(3)).toEqual({ | ||
type: 'multiply', | ||
payload: 3 | ||
}) | ||
}) | ||
describe('when using reducer', () => { | ||
it('should return the correct value from reducer with increment', () => { | ||
expect(reducer(undefined, actions.increment())).toEqual(1) | ||
}) | ||
it('should return the correct value from reducer with multiply', () => { | ||
expect(reducer(2, actions.multiply(3))).toEqual(6) | ||
}) | ||
}) | ||
}) | ||
describe('when passing slice', () => { | ||
const { actions, reducer } = createSlice({ | ||
const { actions, reducer, caseReducers } = createSlice({ | ||
reducers: { | ||
@@ -55,3 +44,3 @@ increment: state => state + 1 | ||
initialState: 0, | ||
slice: 'cool' | ||
name: 'cool' | ||
}) | ||
@@ -73,2 +62,8 @@ | ||
}) | ||
it('should include the generated case reducers', () => { | ||
expect(caseReducers).toBeTruthy() | ||
expect(caseReducers.increment).toBeTruthy() | ||
expect(typeof caseReducers.increment).toBe('function') | ||
}) | ||
}) | ||
@@ -86,3 +81,3 @@ | ||
initialState, | ||
slice: 'user' | ||
name: 'user' | ||
}) | ||
@@ -101,2 +96,3 @@ | ||
const { reducer } = createSlice({ | ||
name: 'test', | ||
reducers: { | ||
@@ -124,3 +120,3 @@ increment: state => state + 1, | ||
const testSlice = createSlice({ | ||
slice: 'test', | ||
name: 'test', | ||
initialState: 0, | ||
@@ -146,3 +142,3 @@ reducers: { | ||
const testSlice = createSlice({ | ||
slice: 'test', | ||
name: 'test', | ||
initialState: 0, | ||
@@ -149,0 +145,0 @@ reducers: { |
@@ -21,3 +21,5 @@ import { Reducer } from 'redux' | ||
State = any, | ||
ActionCreators extends { [key: string]: any } = { [key: string]: any } | ||
CaseReducers extends SliceCaseReducerDefinitions<State, PayloadActions> = { | ||
[key: string]: any | ||
} | ||
> { | ||
@@ -27,3 +29,3 @@ /** | ||
*/ | ||
slice: string | ||
name: string | ||
@@ -39,3 +41,5 @@ /** | ||
*/ | ||
actions: ActionCreators | ||
actions: CaseReducerActions<CaseReducers> | ||
caseReducers: SliceDefinedCaseReducers<CaseReducers, State> | ||
} | ||
@@ -48,3 +52,6 @@ | ||
State = any, | ||
CR extends SliceCaseReducers<State, any> = SliceCaseReducers<State, any> | ||
CR extends SliceCaseReducerDefinitions< | ||
State, | ||
any | ||
> = SliceCaseReducerDefinitions<State, any> | ||
> { | ||
@@ -54,3 +61,3 @@ /** | ||
*/ | ||
slice?: string | ||
name: string | ||
@@ -82,3 +89,3 @@ /** | ||
type EnhancedCaseReducer<State, Action extends PayloadAction> = { | ||
type CaseReducerWithPrepare<State, Action extends PayloadAction> = { | ||
reducer: CaseReducer<State, Action> | ||
@@ -88,6 +95,6 @@ prepare: PrepareAction<Action['payload']> | ||
type SliceCaseReducers<State, PA extends PayloadActions> = { | ||
type SliceCaseReducerDefinitions<State, PA extends PayloadActions> = { | ||
[ActionType in keyof PA]: | ||
| CaseReducer<State, PA[ActionType]> | ||
| EnhancedCaseReducer<State, PA[ActionType]> | ||
| CaseReducerWithPrepare<State, PA[ActionType]> | ||
} | ||
@@ -100,3 +107,3 @@ | ||
: False | ||
type IfIsEnhancedReducer<R, True, False = never> = R extends { | ||
type IfIsCaseReducerWithPrepare<R, True, False = never> = R extends { | ||
prepare: Function | ||
@@ -117,4 +124,17 @@ } | ||
type CaseReducerActions<CaseReducers extends SliceCaseReducers<any, any>> = { | ||
[Type in keyof CaseReducers]: IfIsEnhancedReducer< | ||
type ActionForReducer<R, S> = R extends ( | ||
state: S, | ||
action: PayloadAction<infer P> | ||
) => S | ||
? PayloadAction<P> | ||
: R extends { | ||
reducer(state: any, action: PayloadAction<infer P>): any | ||
} | ||
? PayloadAction<P> | ||
: unknown | ||
type CaseReducerActions< | ||
CaseReducers extends SliceCaseReducerDefinitions<any, any> | ||
> = { | ||
[Type in keyof CaseReducers]: IfIsCaseReducerWithPrepare< | ||
CaseReducers[Type], | ||
@@ -134,2 +154,12 @@ ActionCreatorWithPreparedPayload< | ||
type SliceDefinedCaseReducers< | ||
CaseReducers extends SliceCaseReducerDefinitions<any, any>, | ||
State = any | ||
> = { | ||
[Type in keyof CaseReducers]: CaseReducer< | ||
State, | ||
ActionForReducer<CaseReducers[Type], State> | ||
> | ||
} | ||
type NoInfer<T> = [T][T extends any ? 0 : never] | ||
@@ -147,9 +177,9 @@ | ||
type RestrictEnhancedReducersToMatchReducerAndPrepare< | ||
type RestrictCaseReducerDefinitionsToMatchReducerAndPrepare< | ||
S, | ||
CR extends SliceCaseReducers<S, any> | ||
CR extends SliceCaseReducerDefinitions<S, any> | ||
> = { reducers: SliceCaseReducersCheck<S, NoInfer<CR>> } | ||
function getType(slice: string, actionKey: string): string { | ||
return slice ? `${slice}/${actionKey}` : actionKey | ||
return `${slice}/${actionKey}` | ||
} | ||
@@ -159,3 +189,3 @@ | ||
* A function that accepts an initial state, an object full of reducer | ||
* functions, and optionally a "slice name", and automatically generates | ||
* functions, and a "slice name", and automatically generates | ||
* action creators and action types that correspond to the | ||
@@ -168,7 +198,7 @@ * reducers and state. | ||
State, | ||
CaseReducers extends SliceCaseReducers<State, any> | ||
CaseReducers extends SliceCaseReducerDefinitions<State, any> | ||
>( | ||
options: CreateSliceOptions<State, CaseReducers> & | ||
RestrictEnhancedReducersToMatchReducerAndPrepare<State, CaseReducers> | ||
): Slice<State, CaseReducerActions<CaseReducers>> | ||
RestrictCaseReducerDefinitionsToMatchReducerAndPrepare<State, CaseReducers> | ||
): Slice<State, CaseReducers> | ||
@@ -178,40 +208,48 @@ // internal definition is a little less restrictive | ||
State, | ||
CaseReducers extends SliceCaseReducers<State, any> | ||
CaseReducers extends SliceCaseReducerDefinitions<State, any> | ||
>( | ||
options: CreateSliceOptions<State, CaseReducers> | ||
): Slice<State, CaseReducerActions<CaseReducers>> { | ||
const { slice = '', initialState } = options | ||
): Slice<State, CaseReducers> { | ||
const { name, initialState } = options | ||
if (!name) { | ||
throw new Error('`name` is a required option for createSlice') | ||
} | ||
const reducers = options.reducers || {} | ||
const extraReducers = options.extraReducers || {} | ||
const actionKeys = Object.keys(reducers) | ||
const reducerNames = Object.keys(reducers) | ||
const reducerMap = actionKeys.reduce((map, actionKey) => { | ||
let maybeEnhancedReducer = reducers[actionKey] | ||
map[getType(slice, actionKey)] = | ||
typeof maybeEnhancedReducer === 'function' | ||
? maybeEnhancedReducer | ||
: maybeEnhancedReducer.reducer | ||
return map | ||
}, extraReducers) | ||
const sliceCaseReducersByName: Record<string, CaseReducer> = {} | ||
const sliceCaseReducersByType: Record<string, CaseReducer> = {} | ||
const actionCreators: Record<string, PayloadActionCreator> = {} | ||
const reducer = createReducer(initialState, reducerMap) | ||
reducerNames.forEach(reducerName => { | ||
const maybeReducerWithPrepare = reducers[reducerName] | ||
const type = getType(name, reducerName) | ||
const actionMap = actionKeys.reduce( | ||
(map, action) => { | ||
let maybeEnhancedReducer = reducers[action] | ||
const type = getType(slice, action) | ||
map[action] = | ||
typeof maybeEnhancedReducer === 'function' | ||
? createAction(type) | ||
: createAction(type, maybeEnhancedReducer.prepare) | ||
return map | ||
}, | ||
{} as any | ||
) | ||
let caseReducer: CaseReducer<State, any> | ||
let prepareCallback: PrepareAction<any> | undefined | ||
if (typeof maybeReducerWithPrepare === 'function') { | ||
caseReducer = maybeReducerWithPrepare | ||
} else { | ||
caseReducer = maybeReducerWithPrepare.reducer | ||
prepareCallback = maybeReducerWithPrepare.prepare | ||
} | ||
sliceCaseReducersByName[reducerName] = caseReducer | ||
sliceCaseReducersByType[type] = caseReducer | ||
actionCreators[reducerName] = prepareCallback | ||
? createAction(type, prepareCallback) | ||
: createAction(type) | ||
}) | ||
const finalCaseReducers = { ...extraReducers, ...sliceCaseReducersByType } | ||
const reducer = createReducer(initialState, finalCaseReducers) | ||
return { | ||
slice, | ||
name, | ||
reducer, | ||
actions: actionMap | ||
actions: actionCreators as any, | ||
caseReducers: sliceCaseReducersByName as any | ||
} | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222178
34
5150