UNPKG

58.1 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = function (d, b) {
3 extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6 return extendStatics(d, b);
7 };
8 return function (d, b) {
9 if (typeof b !== "function" && b !== null)
10 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11 extendStatics(d, b);
12 function __() { this.constructor = d; }
13 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14 };
15})();
16var __generator = (this && this.__generator) || function (thisArg, body) {
17 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
18 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
19 function verb(n) { return function (v) { return step([n, v]); }; }
20 function step(op) {
21 if (f) throw new TypeError("Generator is already executing.");
22 while (_) try {
23 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
24 if (y = 0, t) op = [op[0] & 2, t.value];
25 switch (op[0]) {
26 case 0: case 1: t = op; break;
27 case 4: _.label++; return { value: op[1], done: false };
28 case 5: _.label++; y = op[1]; op = [0]; continue;
29 case 7: op = _.ops.pop(); _.trys.pop(); continue;
30 default:
31 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
32 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
33 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
34 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
35 if (t[2]) _.ops.pop();
36 _.trys.pop(); continue;
37 }
38 op = body.call(thisArg, _);
39 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
40 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
41 }
42};
43var __spreadArray = (this && this.__spreadArray) || function (to, from) {
44 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
45 to[j] = from[i];
46 return to;
47};
48var __defProp = Object.defineProperty;
49var __defProps = Object.defineProperties;
50var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
51var __getOwnPropSymbols = Object.getOwnPropertySymbols;
52var __hasOwnProp = Object.prototype.hasOwnProperty;
53var __propIsEnum = Object.prototype.propertyIsEnumerable;
54var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
55var __spreadValues = function (a, b) {
56 for (var prop in b || (b = {}))
57 if (__hasOwnProp.call(b, prop))
58 __defNormalProp(a, prop, b[prop]);
59 if (__getOwnPropSymbols)
60 for (var _i = 0, _b = __getOwnPropSymbols(b); _i < _b.length; _i++) {
61 var prop = _b[_i];
62 if (__propIsEnum.call(b, prop))
63 __defNormalProp(a, prop, b[prop]);
64 }
65 return a;
66};
67var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
68var __async = function (__this, __arguments, generator) {
69 return new Promise(function (resolve, reject) {
70 var fulfilled = function (value) {
71 try {
72 step(generator.next(value));
73 }
74 catch (e) {
75 reject(e);
76 }
77 };
78 var rejected = function (value) {
79 try {
80 step(generator.throw(value));
81 }
82 catch (e) {
83 reject(e);
84 }
85 };
86 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
87 step((generator = generator.apply(__this, __arguments)).next());
88 });
89};
90// src/index.ts
91import { enableES5 } from "immer";
92export * from "redux";
93import { default as default2, current as current2, freeze, original, isDraft as isDraft4 } from "immer";
94import { createSelector as createSelector2 } from "reselect";
95// src/createDraftSafeSelector.ts
96import { current, isDraft } from "immer";
97import { createSelector } from "reselect";
98var createDraftSafeSelector = function () {
99 var args = [];
100 for (var _i = 0; _i < arguments.length; _i++) {
101 args[_i] = arguments[_i];
102 }
103 var selector = createSelector.apply(void 0, args);
104 var wrappedSelector = function (value) {
105 var rest = [];
106 for (var _i = 1; _i < arguments.length; _i++) {
107 rest[_i - 1] = arguments[_i];
108 }
109 return selector.apply(void 0, __spreadArray([isDraft(value) ? current(value) : value], rest));
110 };
111 return wrappedSelector;
112};
113// src/configureStore.ts
114import { createStore, compose as compose2, applyMiddleware, combineReducers } from "redux";
115// src/devtoolsExtension.ts
116import { compose } from "redux";
117var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
118 if (arguments.length === 0)
119 return void 0;
120 if (typeof arguments[0] === "object")
121 return compose;
122 return compose.apply(null, arguments);
123};
124var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
125 return function (noop) {
126 return noop;
127 };
128};
129// src/isPlainObject.ts
130function isPlainObject(value) {
131 if (typeof value !== "object" || value === null)
132 return false;
133 var proto = value;
134 while (Object.getPrototypeOf(proto) !== null) {
135 proto = Object.getPrototypeOf(proto);
136 }
137 return Object.getPrototypeOf(value) === proto;
138}
139// src/getDefaultMiddleware.ts
140import thunkMiddleware from "redux-thunk";
141// src/utils.ts
142function getTimeMeasureUtils(maxDelay, fnName) {
143 var elapsed = 0;
144 return {
145 measureTime: function (fn) {
146 var started = Date.now();
147 try {
148 return fn();
149 }
150 finally {
151 var finished = Date.now();
152 elapsed += finished - started;
153 }
154 },
155 warnIfExceeded: function () {
156 if (elapsed > maxDelay) {
157 console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
158 }
159 }
160 };
161}
162var MiddlewareArray = /** @class */ (function (_super) {
163 __extends(MiddlewareArray, _super);
164 function MiddlewareArray() {
165 var args = [];
166 for (var _i = 0; _i < arguments.length; _i++) {
167 args[_i] = arguments[_i];
168 }
169 var _this = _super.apply(this, args) || this;
170 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
171 return _this;
172 }
173 Object.defineProperty(MiddlewareArray, Symbol.species, {
174 get: function () {
175 return MiddlewareArray;
176 },
177 enumerable: false,
178 configurable: true
179 });
180 MiddlewareArray.prototype.concat = function () {
181 var arr = [];
182 for (var _i = 0; _i < arguments.length; _i++) {
183 arr[_i] = arguments[_i];
184 }
185 return _super.prototype.concat.apply(this, arr);
186 };
187 MiddlewareArray.prototype.prepend = function () {
188 var arr = [];
189 for (var _i = 0; _i < arguments.length; _i++) {
190 arr[_i] = arguments[_i];
191 }
192 if (arr.length === 1 && Array.isArray(arr[0])) {
193 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
194 }
195 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
196 };
197 return MiddlewareArray;
198}(Array));
199// src/immutableStateInvariantMiddleware.ts
200var isProduction = process.env.NODE_ENV === "production";
201var prefix = "Invariant failed";
202function invariant(condition, message) {
203 if (condition) {
204 return;
205 }
206 if (isProduction) {
207 throw new Error(prefix);
208 }
209 throw new Error(prefix + ": " + (message || ""));
210}
211function stringify(obj, serializer, indent, decycler) {
212 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
213}
214function getSerialize(serializer, decycler) {
215 var stack = [], keys = [];
216 if (!decycler)
217 decycler = function (_, value) {
218 if (stack[0] === value)
219 return "[Circular ~]";
220 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
221 };
222 return function (key, value) {
223 if (stack.length > 0) {
224 var thisPos = stack.indexOf(this);
225 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
226 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
227 if (~stack.indexOf(value))
228 value = decycler.call(this, key, value);
229 }
230 else
231 stack.push(value);
232 return serializer == null ? value : serializer.call(this, key, value);
233 };
234}
235function isImmutableDefault(value) {
236 return typeof value !== "object" || value === null || typeof value === "undefined" || Object.isFrozen(value);
237}
238function trackForMutations(isImmutable, ignorePaths, obj) {
239 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
240 return {
241 detectMutations: function () {
242 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
243 }
244 };
245}
246function trackProperties(isImmutable, ignorePaths, obj, path) {
247 if (ignorePaths === void 0) { ignorePaths = []; }
248 if (path === void 0) { path = ""; }
249 var tracked = { value: obj };
250 if (!isImmutable(obj)) {
251 tracked.children = {};
252 for (var key in obj) {
253 var childPath = path ? path + "." + key : key;
254 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
255 continue;
256 }
257 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
258 }
259 }
260 return tracked;
261}
262function detectMutations(isImmutable, ignorePaths, trackedProperty, obj, sameParentRef, path) {
263 if (ignorePaths === void 0) { ignorePaths = []; }
264 if (sameParentRef === void 0) { sameParentRef = false; }
265 if (path === void 0) { path = ""; }
266 var prevObj = trackedProperty ? trackedProperty.value : void 0;
267 var sameRef = prevObj === obj;
268 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
269 return { wasMutated: true, path: path };
270 }
271 if (isImmutable(prevObj) || isImmutable(obj)) {
272 return { wasMutated: false };
273 }
274 var keysToDetect = {};
275 for (var key in trackedProperty.children) {
276 keysToDetect[key] = true;
277 }
278 for (var key in obj) {
279 keysToDetect[key] = true;
280 }
281 for (var key in keysToDetect) {
282 var childPath = path ? path + "." + key : key;
283 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
284 continue;
285 }
286 var result = detectMutations(isImmutable, ignorePaths, trackedProperty.children[key], obj[key], sameRef, childPath);
287 if (result.wasMutated) {
288 return result;
289 }
290 }
291 return { wasMutated: false };
292}
293function createImmutableStateInvariantMiddleware(options) {
294 if (options === void 0) { options = {}; }
295 if (process.env.NODE_ENV === "production") {
296 return function () { return function (next) { return function (action) { return next(action); }; }; };
297 }
298 var _b = options.isImmutable, isImmutable = _b === void 0 ? isImmutableDefault : _b, ignoredPaths = options.ignoredPaths, _c = options.warnAfter, warnAfter = _c === void 0 ? 32 : _c, ignore = options.ignore;
299 ignoredPaths = ignoredPaths || ignore;
300 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
301 return function (_b) {
302 var getState = _b.getState;
303 var state = getState();
304 var tracker = track(state);
305 var result;
306 return function (next) { return function (action) {
307 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
308 measureUtils.measureTime(function () {
309 state = getState();
310 result = tracker.detectMutations();
311 tracker = track(state);
312 invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
313 });
314 var dispatchedAction = next(action);
315 measureUtils.measureTime(function () {
316 state = getState();
317 result = tracker.detectMutations();
318 tracker = track(state);
319 result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
320 });
321 measureUtils.warnIfExceeded();
322 return dispatchedAction;
323 }; };
324 };
325}
326// src/serializableStateInvariantMiddleware.ts
327function isPlain(val) {
328 var type = typeof val;
329 return type === "undefined" || val === null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
330}
331function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths) {
332 if (path === void 0) { path = ""; }
333 if (isSerializable === void 0) { isSerializable = isPlain; }
334 if (ignoredPaths === void 0) { ignoredPaths = []; }
335 var foundNestedSerializable;
336 if (!isSerializable(value)) {
337 return {
338 keyPath: path || "<root>",
339 value: value
340 };
341 }
342 if (typeof value !== "object" || value === null) {
343 return false;
344 }
345 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
346 var hasIgnoredPaths = ignoredPaths.length > 0;
347 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
348 var _b = entries_1[_i], key = _b[0], nestedValue = _b[1];
349 var nestedPath = path ? path + "." + key : key;
350 if (hasIgnoredPaths && ignoredPaths.indexOf(nestedPath) >= 0) {
351 continue;
352 }
353 if (!isSerializable(nestedValue)) {
354 return {
355 keyPath: nestedPath,
356 value: nestedValue
357 };
358 }
359 if (typeof nestedValue === "object") {
360 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths);
361 if (foundNestedSerializable) {
362 return foundNestedSerializable;
363 }
364 }
365 }
366 return false;
367}
368function createSerializableStateInvariantMiddleware(options) {
369 if (options === void 0) { options = {}; }
370 if (process.env.NODE_ENV === "production") {
371 return function () { return function (next) { return function (action) { return next(action); }; }; };
372 }
373 var _b = options.isSerializable, isSerializable = _b === void 0 ? isPlain : _b, getEntries = options.getEntries, _c = options.ignoredActions, ignoredActions = _c === void 0 ? [] : _c, _d = options.ignoredActionPaths, ignoredActionPaths = _d === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _d, _e = options.ignoredPaths, ignoredPaths = _e === void 0 ? [] : _e, _f = options.warnAfter, warnAfter = _f === void 0 ? 32 : _f, _g = options.ignoreState, ignoreState = _g === void 0 ? false : _g;
374 return function (storeAPI) { return function (next) { return function (action) {
375 if (ignoredActions.length && ignoredActions.indexOf(action.type) !== -1) {
376 return next(action);
377 }
378 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
379 measureUtils.measureTime(function () {
380 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths);
381 if (foundActionNonSerializableValue) {
382 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
383 console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\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)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
384 }
385 });
386 var result = next(action);
387 if (!ignoreState) {
388 measureUtils.measureTime(function () {
389 var state = storeAPI.getState();
390 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths);
391 if (foundStateNonSerializableValue) {
392 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
393 console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
394 }
395 });
396 measureUtils.warnIfExceeded();
397 }
398 return result;
399 }; }; };
400}
401// src/getDefaultMiddleware.ts
402function isBoolean(x) {
403 return typeof x === "boolean";
404}
405function curryGetDefaultMiddleware() {
406 return function curriedGetDefaultMiddleware(options) {
407 return getDefaultMiddleware(options);
408 };
409}
410function getDefaultMiddleware(options) {
411 if (options === void 0) { options = {}; }
412 var _b = options.thunk, thunk = _b === void 0 ? true : _b, _c = options.immutableCheck, immutableCheck = _c === void 0 ? true : _c, _d = options.serializableCheck, serializableCheck = _d === void 0 ? true : _d;
413 var middlewareArray = new MiddlewareArray();
414 if (thunk) {
415 if (isBoolean(thunk)) {
416 middlewareArray.push(thunkMiddleware);
417 }
418 else {
419 middlewareArray.push(thunkMiddleware.withExtraArgument(thunk.extraArgument));
420 }
421 }
422 if (process.env.NODE_ENV !== "production") {
423 if (immutableCheck) {
424 var immutableOptions = {};
425 if (!isBoolean(immutableCheck)) {
426 immutableOptions = immutableCheck;
427 }
428 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
429 }
430 if (serializableCheck) {
431 var serializableOptions = {};
432 if (!isBoolean(serializableCheck)) {
433 serializableOptions = serializableCheck;
434 }
435 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
436 }
437 }
438 return middlewareArray;
439}
440// src/configureStore.ts
441var IS_PRODUCTION = process.env.NODE_ENV === "production";
442function configureStore(options) {
443 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
444 var _b = options || {}, _c = _b.reducer, reducer = _c === void 0 ? void 0 : _c, _d = _b.middleware, middleware = _d === void 0 ? curriedGetDefaultMiddleware() : _d, _e = _b.devTools, devTools = _e === void 0 ? true : _e, _f = _b.preloadedState, preloadedState = _f === void 0 ? void 0 : _f, _g = _b.enhancers, enhancers = _g === void 0 ? void 0 : _g;
445 var rootReducer;
446 if (typeof reducer === "function") {
447 rootReducer = reducer;
448 }
449 else if (isPlainObject(reducer)) {
450 rootReducer = combineReducers(reducer);
451 }
452 else {
453 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
454 }
455 var finalMiddleware = middleware;
456 if (typeof finalMiddleware === "function") {
457 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
458 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
459 throw new Error("when using a middleware builder function, an array of middleware must be returned");
460 }
461 }
462 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
463 throw new Error("each middleware provided to configureStore must be a function");
464 }
465 var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
466 var finalCompose = compose2;
467 if (devTools) {
468 finalCompose = composeWithDevTools(__spreadValues({
469 trace: !IS_PRODUCTION
470 }, typeof devTools === "object" && devTools));
471 }
472 var storeEnhancers = [middlewareEnhancer];
473 if (Array.isArray(enhancers)) {
474 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
475 }
476 else if (typeof enhancers === "function") {
477 storeEnhancers = enhancers(storeEnhancers);
478 }
479 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
480 return createStore(rootReducer, preloadedState, composedEnhancer);
481}
482// src/createAction.ts
483function createAction(type, prepareAction) {
484 function actionCreator() {
485 var args = [];
486 for (var _i = 0; _i < arguments.length; _i++) {
487 args[_i] = arguments[_i];
488 }
489 if (prepareAction) {
490 var prepared = prepareAction.apply(void 0, args);
491 if (!prepared) {
492 throw new Error("prepareAction did not return an object");
493 }
494 return __spreadValues(__spreadValues({
495 type: type,
496 payload: prepared.payload
497 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
498 }
499 return { type: type, payload: args[0] };
500 }
501 actionCreator.toString = function () { return "" + type; };
502 actionCreator.type = type;
503 actionCreator.match = function (action) { return action.type === type; };
504 return actionCreator;
505}
506function isFSA(action) {
507 return isPlainObject(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
508}
509function isValidKey(key) {
510 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
511}
512function getType(actionCreator) {
513 return "" + actionCreator;
514}
515// src/createReducer.ts
516import createNextState, { isDraft as isDraft2, isDraftable } from "immer";
517// src/mapBuilders.ts
518function executeReducerBuilderCallback(builderCallback) {
519 var actionsMap = {};
520 var actionMatchers = [];
521 var defaultCaseReducer;
522 var builder = {
523 addCase: function (typeOrActionCreator, reducer) {
524 if (process.env.NODE_ENV !== "production") {
525 if (actionMatchers.length > 0) {
526 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
527 }
528 if (defaultCaseReducer) {
529 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
530 }
531 }
532 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
533 if (type in actionsMap) {
534 throw new Error("addCase cannot be called with two reducers for the same action type");
535 }
536 actionsMap[type] = reducer;
537 return builder;
538 },
539 addMatcher: function (matcher, reducer) {
540 if (process.env.NODE_ENV !== "production") {
541 if (defaultCaseReducer) {
542 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
543 }
544 }
545 actionMatchers.push({ matcher: matcher, reducer: reducer });
546 return builder;
547 },
548 addDefaultCase: function (reducer) {
549 if (process.env.NODE_ENV !== "production") {
550 if (defaultCaseReducer) {
551 throw new Error("`builder.addDefaultCase` can only be called once");
552 }
553 }
554 defaultCaseReducer = reducer;
555 return builder;
556 }
557 };
558 builderCallback(builder);
559 return [actionsMap, actionMatchers, defaultCaseReducer];
560}
561// src/createReducer.ts
562function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
563 if (actionMatchers === void 0) { actionMatchers = []; }
564 var _b = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _b[0], finalActionMatchers = _b[1], finalDefaultCaseReducer = _b[2];
565 var frozenInitialState = createNextState(initialState, function () {
566 });
567 return function (state, action) {
568 if (state === void 0) { state = frozenInitialState; }
569 var caseReducers = __spreadArray([
570 actionsMap[action.type]
571 ], finalActionMatchers.filter(function (_b) {
572 var matcher = _b.matcher;
573 return matcher(action);
574 }).map(function (_b) {
575 var reducer = _b.reducer;
576 return reducer;
577 }));
578 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
579 caseReducers = [finalDefaultCaseReducer];
580 }
581 return caseReducers.reduce(function (previousState, caseReducer) {
582 if (caseReducer) {
583 if (isDraft2(previousState)) {
584 var draft = previousState;
585 var result = caseReducer(draft, action);
586 if (typeof result === "undefined") {
587 return previousState;
588 }
589 return result;
590 }
591 else if (!isDraftable(previousState)) {
592 var result = caseReducer(previousState, action);
593 if (typeof result === "undefined") {
594 if (previousState === null) {
595 return previousState;
596 }
597 throw Error("A case reducer on a non-draftable value must not return undefined");
598 }
599 return result;
600 }
601 else {
602 return createNextState(previousState, function (draft) {
603 return caseReducer(draft, action);
604 });
605 }
606 }
607 return previousState;
608 }, state);
609 };
610}
611// src/createSlice.ts
612function getType2(slice, actionKey) {
613 return slice + "/" + actionKey;
614}
615function createSlice(options) {
616 var name = options.name, initialState = options.initialState;
617 if (!name) {
618 throw new Error("`name` is a required option for createSlice");
619 }
620 var reducers = options.reducers || {};
621 var _b = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers], _c = _b[0], extraReducers = _c === void 0 ? {} : _c, _d = _b[1], actionMatchers = _d === void 0 ? [] : _d, _e = _b[2], defaultCaseReducer = _e === void 0 ? void 0 : _e;
622 var reducerNames = Object.keys(reducers);
623 var sliceCaseReducersByName = {};
624 var sliceCaseReducersByType = {};
625 var actionCreators = {};
626 reducerNames.forEach(function (reducerName) {
627 var maybeReducerWithPrepare = reducers[reducerName];
628 var type = getType2(name, reducerName);
629 var caseReducer;
630 var prepareCallback;
631 if ("reducer" in maybeReducerWithPrepare) {
632 caseReducer = maybeReducerWithPrepare.reducer;
633 prepareCallback = maybeReducerWithPrepare.prepare;
634 }
635 else {
636 caseReducer = maybeReducerWithPrepare;
637 }
638 sliceCaseReducersByName[reducerName] = caseReducer;
639 sliceCaseReducersByType[type] = caseReducer;
640 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
641 });
642 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
643 var reducer = createReducer(initialState, finalCaseReducers, actionMatchers, defaultCaseReducer);
644 return {
645 name: name,
646 reducer: reducer,
647 actions: actionCreators,
648 caseReducers: sliceCaseReducersByName
649 };
650}
651// src/entities/entity_state.ts
652function getInitialEntityState() {
653 return {
654 ids: [],
655 entities: {}
656 };
657}
658function createInitialStateFactory() {
659 function getInitialState(additionalState) {
660 if (additionalState === void 0) { additionalState = {}; }
661 return Object.assign(getInitialEntityState(), additionalState);
662 }
663 return { getInitialState: getInitialState };
664}
665// src/entities/state_selectors.ts
666function createSelectorsFactory() {
667 function getSelectors(selectState) {
668 var selectIds = function (state) { return state.ids; };
669 var selectEntities = function (state) { return state.entities; };
670 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
671 var selectId = function (_, id) { return id; };
672 var selectById = function (entities, id) { return entities[id]; };
673 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
674 if (!selectState) {
675 return {
676 selectIds: selectIds,
677 selectEntities: selectEntities,
678 selectAll: selectAll,
679 selectTotal: selectTotal,
680 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
681 };
682 }
683 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
684 return {
685 selectIds: createDraftSafeSelector(selectState, selectIds),
686 selectEntities: selectGlobalizedEntities,
687 selectAll: createDraftSafeSelector(selectState, selectAll),
688 selectTotal: createDraftSafeSelector(selectState, selectTotal),
689 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
690 };
691 }
692 return { getSelectors: getSelectors };
693}
694// src/entities/state_adapter.ts
695import createNextState2, { isDraft as isDraft3 } from "immer";
696function createSingleArgumentStateOperator(mutator) {
697 var operator = createStateOperator(function (_, state) { return mutator(state); });
698 return function operation(state) {
699 return operator(state, void 0);
700 };
701}
702function createStateOperator(mutator) {
703 return function operation(state, arg) {
704 function isPayloadActionArgument(arg2) {
705 return isFSA(arg2);
706 }
707 var runMutator = function (draft) {
708 if (isPayloadActionArgument(arg)) {
709 mutator(arg.payload, draft);
710 }
711 else {
712 mutator(arg, draft);
713 }
714 };
715 if (isDraft3(state)) {
716 runMutator(state);
717 return state;
718 }
719 else {
720 return createNextState2(state, runMutator);
721 }
722 };
723}
724// src/entities/utils.ts
725function selectIdValue(entity, selectId) {
726 var key = selectId(entity);
727 if (process.env.NODE_ENV !== "production" && key === void 0) {
728 console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
729 }
730 return key;
731}
732function ensureEntitiesArray(entities) {
733 if (!Array.isArray(entities)) {
734 entities = Object.values(entities);
735 }
736 return entities;
737}
738function splitAddedUpdatedEntities(newEntities, selectId, state) {
739 newEntities = ensureEntitiesArray(newEntities);
740 var added = [];
741 var updated = [];
742 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
743 var entity = newEntities_1[_i];
744 var id = selectIdValue(entity, selectId);
745 if (id in state.entities) {
746 updated.push({ id: id, changes: entity });
747 }
748 else {
749 added.push(entity);
750 }
751 }
752 return [added, updated];
753}
754// src/entities/unsorted_state_adapter.ts
755function createUnsortedStateAdapter(selectId) {
756 function addOneMutably(entity, state) {
757 var key = selectIdValue(entity, selectId);
758 if (key in state.entities) {
759 return;
760 }
761 state.ids.push(key);
762 state.entities[key] = entity;
763 }
764 function addManyMutably(newEntities, state) {
765 newEntities = ensureEntitiesArray(newEntities);
766 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
767 var entity = newEntities_2[_i];
768 addOneMutably(entity, state);
769 }
770 }
771 function setOneMutably(entity, state) {
772 var key = selectIdValue(entity, selectId);
773 if (!(key in state.entities)) {
774 state.ids.push(key);
775 }
776 state.entities[key] = entity;
777 }
778 function setManyMutably(newEntities, state) {
779 newEntities = ensureEntitiesArray(newEntities);
780 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
781 var entity = newEntities_3[_i];
782 setOneMutably(entity, state);
783 }
784 }
785 function setAllMutably(newEntities, state) {
786 newEntities = ensureEntitiesArray(newEntities);
787 state.ids = [];
788 state.entities = {};
789 addManyMutably(newEntities, state);
790 }
791 function removeOneMutably(key, state) {
792 return removeManyMutably([key], state);
793 }
794 function removeManyMutably(keys, state) {
795 var didMutate = false;
796 keys.forEach(function (key) {
797 if (key in state.entities) {
798 delete state.entities[key];
799 didMutate = true;
800 }
801 });
802 if (didMutate) {
803 state.ids = state.ids.filter(function (id) { return id in state.entities; });
804 }
805 }
806 function removeAllMutably(state) {
807 Object.assign(state, {
808 ids: [],
809 entities: {}
810 });
811 }
812 function takeNewKey(keys, update, state) {
813 var original2 = state.entities[update.id];
814 var updated = Object.assign({}, original2, update.changes);
815 var newKey = selectIdValue(updated, selectId);
816 var hasNewKey = newKey !== update.id;
817 if (hasNewKey) {
818 keys[update.id] = newKey;
819 delete state.entities[update.id];
820 }
821 state.entities[newKey] = updated;
822 return hasNewKey;
823 }
824 function updateOneMutably(update, state) {
825 return updateManyMutably([update], state);
826 }
827 function updateManyMutably(updates, state) {
828 var newKeys = {};
829 var updatesPerEntity = {};
830 updates.forEach(function (update) {
831 if (update.id in state.entities) {
832 updatesPerEntity[update.id] = {
833 id: update.id,
834 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
835 };
836 }
837 });
838 updates = Object.values(updatesPerEntity);
839 var didMutateEntities = updates.length > 0;
840 if (didMutateEntities) {
841 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
842 if (didMutateIds) {
843 state.ids = state.ids.map(function (id) { return newKeys[id] || id; });
844 }
845 }
846 }
847 function upsertOneMutably(entity, state) {
848 return upsertManyMutably([entity], state);
849 }
850 function upsertManyMutably(newEntities, state) {
851 var _b = splitAddedUpdatedEntities(newEntities, selectId, state), added = _b[0], updated = _b[1];
852 updateManyMutably(updated, state);
853 addManyMutably(added, state);
854 }
855 return {
856 removeAll: createSingleArgumentStateOperator(removeAllMutably),
857 addOne: createStateOperator(addOneMutably),
858 addMany: createStateOperator(addManyMutably),
859 setOne: createStateOperator(setOneMutably),
860 setMany: createStateOperator(setManyMutably),
861 setAll: createStateOperator(setAllMutably),
862 updateOne: createStateOperator(updateOneMutably),
863 updateMany: createStateOperator(updateManyMutably),
864 upsertOne: createStateOperator(upsertOneMutably),
865 upsertMany: createStateOperator(upsertManyMutably),
866 removeOne: createStateOperator(removeOneMutably),
867 removeMany: createStateOperator(removeManyMutably)
868 };
869}
870// src/entities/sorted_state_adapter.ts
871function createSortedStateAdapter(selectId, sort) {
872 var _b = createUnsortedStateAdapter(selectId), removeOne = _b.removeOne, removeMany = _b.removeMany, removeAll = _b.removeAll;
873 function addOneMutably(entity, state) {
874 return addManyMutably([entity], state);
875 }
876 function addManyMutably(newEntities, state) {
877 newEntities = ensureEntitiesArray(newEntities);
878 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
879 if (models.length !== 0) {
880 merge(models, state);
881 }
882 }
883 function setOneMutably(entity, state) {
884 return setManyMutably([entity], state);
885 }
886 function setManyMutably(newEntities, state) {
887 newEntities = ensureEntitiesArray(newEntities);
888 if (newEntities.length !== 0) {
889 merge(newEntities, state);
890 }
891 }
892 function setAllMutably(newEntities, state) {
893 newEntities = ensureEntitiesArray(newEntities);
894 state.entities = {};
895 state.ids = [];
896 addManyMutably(newEntities, state);
897 }
898 function updateOneMutably(update, state) {
899 return updateManyMutably([update], state);
900 }
901 function takeUpdatedModel(models, update, state) {
902 if (!(update.id in state.entities)) {
903 return false;
904 }
905 var original2 = state.entities[update.id];
906 var updated = Object.assign({}, original2, update.changes);
907 var newKey = selectIdValue(updated, selectId);
908 delete state.entities[update.id];
909 models.push(updated);
910 return newKey !== update.id;
911 }
912 function updateManyMutably(updates, state) {
913 var models = [];
914 updates.forEach(function (update) { return takeUpdatedModel(models, update, state); });
915 if (models.length !== 0) {
916 merge(models, state);
917 }
918 }
919 function upsertOneMutably(entity, state) {
920 return upsertManyMutably([entity], state);
921 }
922 function upsertManyMutably(newEntities, state) {
923 var _b = splitAddedUpdatedEntities(newEntities, selectId, state), added = _b[0], updated = _b[1];
924 updateManyMutably(updated, state);
925 addManyMutably(added, state);
926 }
927 function areArraysEqual(a, b) {
928 if (a.length !== b.length) {
929 return false;
930 }
931 for (var i = 0; i < a.length && i < b.length; i++) {
932 if (a[i] === b[i]) {
933 continue;
934 }
935 return false;
936 }
937 return true;
938 }
939 function merge(models, state) {
940 models.forEach(function (model) {
941 state.entities[selectId(model)] = model;
942 });
943 var allEntities = Object.values(state.entities);
944 allEntities.sort(sort);
945 var newSortedIds = allEntities.map(selectId);
946 var ids = state.ids;
947 if (!areArraysEqual(ids, newSortedIds)) {
948 state.ids = newSortedIds;
949 }
950 }
951 return {
952 removeOne: removeOne,
953 removeMany: removeMany,
954 removeAll: removeAll,
955 addOne: createStateOperator(addOneMutably),
956 updateOne: createStateOperator(updateOneMutably),
957 upsertOne: createStateOperator(upsertOneMutably),
958 setOne: createStateOperator(setOneMutably),
959 setMany: createStateOperator(setManyMutably),
960 setAll: createStateOperator(setAllMutably),
961 addMany: createStateOperator(addManyMutably),
962 updateMany: createStateOperator(updateManyMutably),
963 upsertMany: createStateOperator(upsertManyMutably)
964 };
965}
966// src/entities/create_adapter.ts
967function createEntityAdapter(options) {
968 if (options === void 0) { options = {}; }
969 var _b = __spreadValues({
970 sortComparer: false,
971 selectId: function (instance) { return instance.id; }
972 }, options), selectId = _b.selectId, sortComparer = _b.sortComparer;
973 var stateFactory = createInitialStateFactory();
974 var selectorsFactory = createSelectorsFactory();
975 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
976 return __spreadValues(__spreadValues(__spreadValues({
977 selectId: selectId,
978 sortComparer: sortComparer
979 }, stateFactory), selectorsFactory), stateAdapter);
980}
981// src/nanoid.ts
982var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
983var nanoid = function (size) {
984 if (size === void 0) { size = 21; }
985 var id = "";
986 var i = size;
987 while (i--) {
988 id += urlAlphabet[Math.random() * 64 | 0];
989 }
990 return id;
991};
992// src/createAsyncThunk.ts
993var commonProperties = [
994 "name",
995 "message",
996 "stack",
997 "code"
998];
999var RejectWithValue = /** @class */ (function () {
1000 function RejectWithValue(payload, meta) {
1001 this.payload = payload;
1002 this.meta = meta;
1003 }
1004 return RejectWithValue;
1005}());
1006var FulfillWithMeta = /** @class */ (function () {
1007 function FulfillWithMeta(payload, meta) {
1008 this.payload = payload;
1009 this.meta = meta;
1010 }
1011 return FulfillWithMeta;
1012}());
1013var miniSerializeError = function (value) {
1014 if (typeof value === "object" && value !== null) {
1015 var simpleError = {};
1016 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
1017 var property = commonProperties_1[_i];
1018 if (typeof value[property] === "string") {
1019 simpleError[property] = value[property];
1020 }
1021 }
1022 return simpleError;
1023 }
1024 return { message: String(value) };
1025};
1026function createAsyncThunk(typePrefix, payloadCreator, options) {
1027 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
1028 payload: payload,
1029 meta: __spreadProps(__spreadValues({}, meta || {}), {
1030 arg: arg,
1031 requestId: requestId,
1032 requestStatus: "fulfilled"
1033 })
1034 }); });
1035 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
1036 payload: void 0,
1037 meta: __spreadProps(__spreadValues({}, meta || {}), {
1038 arg: arg,
1039 requestId: requestId,
1040 requestStatus: "pending"
1041 })
1042 }); });
1043 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
1044 payload: payload,
1045 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1046 meta: __spreadProps(__spreadValues({}, meta || {}), {
1047 arg: arg,
1048 requestId: requestId,
1049 rejectedWithValue: !!payload,
1050 requestStatus: "rejected",
1051 aborted: (error == null ? void 0 : error.name) === "AbortError",
1052 condition: (error == null ? void 0 : error.name) === "ConditionError"
1053 })
1054 }); });
1055 var displayedWarning = false;
1056 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
1057 function class_1() {
1058 this.signal = {
1059 aborted: false,
1060 addEventListener: function () {
1061 },
1062 dispatchEvent: function () {
1063 return false;
1064 },
1065 onabort: function () {
1066 },
1067 removeEventListener: function () {
1068 }
1069 };
1070 }
1071 class_1.prototype.abort = function () {
1072 if (process.env.NODE_ENV !== "production") {
1073 if (!displayedWarning) {
1074 displayedWarning = true;
1075 console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.");
1076 }
1077 }
1078 };
1079 return class_1;
1080 }());
1081 function actionCreator(arg) {
1082 return function (dispatch, getState, extra) {
1083 var _a;
1084 var requestId = ((_a = options == null ? void 0 : options.idGenerator) != null ? _a : nanoid)();
1085 var abortController = new AC();
1086 var abortReason;
1087 var abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({ name: "AbortError", message: abortReason || "Aborted" }); }); });
1088 var started = false;
1089 function abort(reason) {
1090 if (started) {
1091 abortReason = reason;
1092 abortController.abort();
1093 }
1094 }
1095 var promise = function () {
1096 return __async(this, null, function () {
1097 var _a2, finalAction, err_1, skipDispatch;
1098 return __generator(this, function (_b) {
1099 switch (_b.label) {
1100 case 0:
1101 _b.trys.push([0, 2, , 3]);
1102 if (options && options.condition && options.condition(arg, { getState: getState, extra: extra }) === false) {
1103 throw {
1104 name: "ConditionError",
1105 message: "Aborted due to condition callback returning false."
1106 };
1107 }
1108 started = true;
1109 dispatch(pending(requestId, arg, (_a2 = options == null ? void 0 : options.getPendingMeta) == null ? void 0 : _a2.call(options, { requestId: requestId, arg: arg }, { getState: getState, extra: extra })));
1110 return [4 /*yield*/, Promise.race([
1111 abortedPromise,
1112 Promise.resolve(payloadCreator(arg, {
1113 dispatch: dispatch,
1114 getState: getState,
1115 extra: extra,
1116 requestId: requestId,
1117 signal: abortController.signal,
1118 rejectWithValue: function (value, meta) {
1119 return new RejectWithValue(value, meta);
1120 },
1121 fulfillWithValue: function (value, meta) {
1122 return new FulfillWithMeta(value, meta);
1123 }
1124 })).then(function (result) {
1125 if (result instanceof RejectWithValue) {
1126 throw result;
1127 }
1128 if (result instanceof FulfillWithMeta) {
1129 return fulfilled(result.payload, requestId, arg, result.meta);
1130 }
1131 return fulfilled(result, requestId, arg);
1132 })
1133 ])];
1134 case 1:
1135 finalAction = _b.sent();
1136 return [3 /*break*/, 3];
1137 case 2:
1138 err_1 = _b.sent();
1139 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
1140 return [3 /*break*/, 3];
1141 case 3:
1142 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1143 if (!skipDispatch) {
1144 dispatch(finalAction);
1145 }
1146 return [2 /*return*/, finalAction];
1147 }
1148 });
1149 });
1150 }();
1151 return Object.assign(promise, {
1152 abort: abort,
1153 requestId: requestId,
1154 arg: arg,
1155 unwrap: function () {
1156 return promise.then(unwrapResult);
1157 }
1158 });
1159 };
1160 }
1161 return Object.assign(actionCreator, {
1162 pending: pending,
1163 rejected: rejected,
1164 fulfilled: fulfilled,
1165 typePrefix: typePrefix
1166 });
1167}
1168function unwrapResult(action) {
1169 if (action.meta && action.meta.rejectedWithValue) {
1170 throw action.payload;
1171 }
1172 if (action.error) {
1173 throw action.error;
1174 }
1175 return action.payload;
1176}
1177// src/tsHelpers.ts
1178var hasMatchFunction = function (v) {
1179 return v && typeof v.match === "function";
1180};
1181// src/matchers.ts
1182var matches = function (matcher, action) {
1183 if (hasMatchFunction(matcher)) {
1184 return matcher.match(action);
1185 }
1186 else {
1187 return matcher(action);
1188 }
1189};
1190function isAnyOf() {
1191 var matchers = [];
1192 for (var _i = 0; _i < arguments.length; _i++) {
1193 matchers[_i] = arguments[_i];
1194 }
1195 return function (action) {
1196 return matchers.some(function (matcher) { return matches(matcher, action); });
1197 };
1198}
1199function isAllOf() {
1200 var matchers = [];
1201 for (var _i = 0; _i < arguments.length; _i++) {
1202 matchers[_i] = arguments[_i];
1203 }
1204 return function (action) {
1205 return matchers.every(function (matcher) { return matches(matcher, action); });
1206 };
1207}
1208function hasExpectedRequestMetadata(action, validStatus) {
1209 if (!action || !action.meta)
1210 return false;
1211 var hasValidRequestId = typeof action.meta.requestId === "string";
1212 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
1213 return hasValidRequestId && hasValidRequestStatus;
1214}
1215function isAsyncThunkArray(a) {
1216 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
1217}
1218function isPending() {
1219 var asyncThunks = [];
1220 for (var _i = 0; _i < arguments.length; _i++) {
1221 asyncThunks[_i] = arguments[_i];
1222 }
1223 if (asyncThunks.length === 0) {
1224 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
1225 }
1226 if (!isAsyncThunkArray(asyncThunks)) {
1227 return isPending()(asyncThunks[0]);
1228 }
1229 return function (action) {
1230 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
1231 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1232 return combinedMatcher(action);
1233 };
1234}
1235function isRejected() {
1236 var asyncThunks = [];
1237 for (var _i = 0; _i < arguments.length; _i++) {
1238 asyncThunks[_i] = arguments[_i];
1239 }
1240 if (asyncThunks.length === 0) {
1241 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
1242 }
1243 if (!isAsyncThunkArray(asyncThunks)) {
1244 return isRejected()(asyncThunks[0]);
1245 }
1246 return function (action) {
1247 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
1248 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1249 return combinedMatcher(action);
1250 };
1251}
1252function isRejectedWithValue() {
1253 var asyncThunks = [];
1254 for (var _i = 0; _i < arguments.length; _i++) {
1255 asyncThunks[_i] = arguments[_i];
1256 }
1257 var hasFlag = function (action) {
1258 return action && action.meta && action.meta.rejectedWithValue;
1259 };
1260 if (asyncThunks.length === 0) {
1261 return function (action) {
1262 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
1263 return combinedMatcher(action);
1264 };
1265 }
1266 if (!isAsyncThunkArray(asyncThunks)) {
1267 return isRejectedWithValue()(asyncThunks[0]);
1268 }
1269 return function (action) {
1270 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
1271 return combinedMatcher(action);
1272 };
1273}
1274function isFulfilled() {
1275 var asyncThunks = [];
1276 for (var _i = 0; _i < arguments.length; _i++) {
1277 asyncThunks[_i] = arguments[_i];
1278 }
1279 if (asyncThunks.length === 0) {
1280 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
1281 }
1282 if (!isAsyncThunkArray(asyncThunks)) {
1283 return isFulfilled()(asyncThunks[0]);
1284 }
1285 return function (action) {
1286 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
1287 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1288 return combinedMatcher(action);
1289 };
1290}
1291function isAsyncThunkAction() {
1292 var asyncThunks = [];
1293 for (var _i = 0; _i < arguments.length; _i++) {
1294 asyncThunks[_i] = arguments[_i];
1295 }
1296 if (asyncThunks.length === 0) {
1297 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
1298 }
1299 if (!isAsyncThunkArray(asyncThunks)) {
1300 return isAsyncThunkAction()(asyncThunks[0]);
1301 }
1302 return function (action) {
1303 var matchers = [];
1304 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
1305 var asyncThunk = asyncThunks_1[_i];
1306 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
1307 }
1308 var combinedMatcher = isAnyOf.apply(void 0, matchers);
1309 return combinedMatcher(action);
1310 };
1311}
1312// src/index.ts
1313enableES5();
1314export { MiddlewareArray, configureStore, createAction, createAsyncThunk, createDraftSafeSelector, createEntityAdapter, createImmutableStateInvariantMiddleware, default2 as createNextState, createReducer, createSelector2 as createSelector, createSerializableStateInvariantMiddleware, createSlice, current2 as current, findNonSerializableValue, freeze, getDefaultMiddleware, getType, isAllOf, isAnyOf, isAsyncThunkAction, isDraft4 as isDraft, isFulfilled, isImmutableDefault, isPending, isPlain, isPlainObject, isRejected, isRejectedWithValue, miniSerializeError, nanoid, original, unwrapResult };
1315//# sourceMappingURL=redux-toolkit.esm.js.map
\No newline at end of file