pocketbase-react 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/README.md +15 -0
  3. package/dist/pocketbase-react.js +492 -0
  4. package/dist/pocketbase-react.min.js +1 -0
  5. package/{dist/esm → es}/context/Pocketbase.d.ts +1 -3
  6. package/es/context/Pocketbase.js +28 -0
  7. package/{dist/cjs → es}/context/client.d.ts +1 -1
  8. package/es/context/client.js +8 -0
  9. package/{dist/cjs → es}/context/content.d.ts +0 -0
  10. package/es/context/content.js +67 -0
  11. package/{dist/cjs → es}/context/index.d.ts +0 -0
  12. package/es/context/index.js +3 -0
  13. package/{dist/cjs → es}/hooks/index.d.ts +0 -0
  14. package/es/hooks/index.js +2 -0
  15. package/{dist/cjs → es}/hooks/useAppContent.d.ts +1 -1
  16. package/es/hooks/useAppContent.js +26 -0
  17. package/es/hooks/useClientContext.d.ts +2 -0
  18. package/es/hooks/useClientContext.js +9 -0
  19. package/{dist/cjs → es}/index.d.ts +0 -0
  20. package/{dist/esm/index.d.ts → es/index.js} +1 -1
  21. package/{dist/cjs → es}/interfaces/Record.d.ts +1 -1
  22. package/es/interfaces/Record.js +1 -0
  23. package/{dist/cjs → es}/interfaces/index.d.ts +0 -0
  24. package/es/interfaces/index.js +1 -0
  25. package/es/store/actions/index.d.ts +2 -0
  26. package/es/store/actions/index.js +2 -0
  27. package/es/store/actions/records.d.ts +9 -0
  28. package/es/store/actions/records.js +39 -0
  29. package/{dist/cjs → es}/store/index.d.ts +0 -0
  30. package/{dist/esm/store/index.d.ts → es/store/index.js} +1 -1
  31. package/{dist/cjs → es}/store/reducers/index.d.ts +2 -2
  32. package/es/store/reducers/index.js +5 -0
  33. package/{dist/cjs → es}/store/reducers/records.d.ts +2 -3
  34. package/es/store/reducers/records.js +71 -0
  35. package/{dist/cjs → es}/store/store.d.ts +1 -1
  36. package/es/store/store.js +46 -0
  37. package/{dist/cjs → es}/store/types/index.d.ts +0 -0
  38. package/es/store/types/index.js +6 -0
  39. package/lib/context/Pocketbase.js +49 -0
  40. package/lib/context/client.js +21 -0
  41. package/lib/context/content.js +83 -0
  42. package/lib/context/index.js +42 -0
  43. package/lib/hooks/index.js +29 -0
  44. package/lib/hooks/useAppContent.js +38 -0
  45. package/lib/hooks/useClientContext.js +15 -0
  46. package/lib/index.js +55 -0
  47. package/lib/interfaces/Record.js +1 -0
  48. package/lib/interfaces/index.js +16 -0
  49. package/lib/store/actions/index.js +12 -0
  50. package/lib/store/actions/records.js +58 -0
  51. package/lib/store/index.js +55 -0
  52. package/lib/store/reducers/index.js +13 -0
  53. package/lib/store/reducers/records.js +85 -0
  54. package/lib/store/store.js +63 -0
  55. package/lib/store/types/index.js +16 -0
  56. package/package.json +94 -35
  57. package/src/context/Pocketbase.tsx +43 -0
  58. package/src/context/client.tsx +14 -0
  59. package/src/context/content.tsx +88 -0
  60. package/{dist/esm/context/index.d.ts → src/context/index.ts} +0 -0
  61. package/src/hooks/index.ts +2 -0
  62. package/src/hooks/useAppContent.ts +28 -0
  63. package/src/hooks/useClientContext.ts +11 -0
  64. package/src/index.ts +4 -0
  65. package/src/interfaces/Record.ts +10 -0
  66. package/src/interfaces/index.ts +1 -0
  67. package/src/store/actions/index.tsx +3 -0
  68. package/src/store/actions/records.tsx +54 -0
  69. package/src/store/index.ts +4 -0
  70. package/src/store/reducers/index.tsx +12 -0
  71. package/src/store/reducers/records.tsx +78 -0
  72. package/src/store/store.tsx +67 -0
  73. package/src/store/types/index.ts +14 -0
  74. package/dist/cjs/EventSource.d.ts +0 -1
  75. package/dist/cjs/context/Pocketbase.d.ts +0 -15
  76. package/dist/cjs/hooks/useClientContext.d.ts +0 -2
  77. package/dist/cjs/index.js +0 -3477
  78. package/dist/cjs/index.js.map +0 -1
  79. package/dist/cjs/store/actions/index.d.ts +0 -2
  80. package/dist/cjs/store/actions/records.d.ts +0 -11
  81. package/dist/esm/EventSource.d.ts +0 -1
  82. package/dist/esm/context/client.d.ts +0 -8
  83. package/dist/esm/context/content.d.ts +0 -16
  84. package/dist/esm/hooks/index.d.ts +0 -2
  85. package/dist/esm/hooks/useAppContent.d.ts +0 -12
  86. package/dist/esm/hooks/useClientContext.d.ts +0 -2
  87. package/dist/esm/index.js +0 -3432
  88. package/dist/esm/index.js.map +0 -1
  89. package/dist/esm/interfaces/Record.d.ts +0 -10
  90. package/dist/esm/interfaces/index.d.ts +0 -1
  91. package/dist/esm/store/actions/index.d.ts +0 -2
  92. package/dist/esm/store/actions/records.d.ts +0 -11
  93. package/dist/esm/store/reducers/index.d.ts +0 -8
  94. package/dist/esm/store/reducers/records.d.ts +0 -12
  95. package/dist/esm/store/store.d.ts +0 -27
  96. package/dist/esm/store/types/index.d.ts +0 -7
  97. package/dist/index.d.ts +0 -128
package/dist/cjs/index.js DELETED
@@ -1,3477 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var reactDom = require('react-dom');
7
- var PocketBase = require('pocketbase/dist/pocketbase.cjs');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n["default"] = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
31
- var PocketBase__default = /*#__PURE__*/_interopDefaultLegacy(PocketBase);
32
-
33
- /******************************************************************************
34
- Copyright (c) Microsoft Corporation.
35
-
36
- Permission to use, copy, modify, and/or distribute this software for any
37
- purpose with or without fee is hereby granted.
38
-
39
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
40
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
41
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
42
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
43
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
44
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45
- PERFORMANCE OF THIS SOFTWARE.
46
- ***************************************************************************** */
47
-
48
- var __assign = function() {
49
- __assign = Object.assign || function __assign(t) {
50
- for (var s, i = 1, n = arguments.length; i < n; i++) {
51
- s = arguments[i];
52
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
53
- }
54
- return t;
55
- };
56
- return __assign.apply(this, arguments);
57
- };
58
-
59
- function __awaiter(thisArg, _arguments, P, generator) {
60
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
61
- return new (P || (P = Promise))(function (resolve, reject) {
62
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
63
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
64
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
65
- step((generator = generator.apply(thisArg, _arguments || [])).next());
66
- });
67
- }
68
-
69
- function __generator(thisArg, body) {
70
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
71
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
72
- function verb(n) { return function (v) { return step([n, v]); }; }
73
- function step(op) {
74
- if (f) throw new TypeError("Generator is already executing.");
75
- while (_) try {
76
- 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;
77
- if (y = 0, t) op = [op[0] & 2, t.value];
78
- switch (op[0]) {
79
- case 0: case 1: t = op; break;
80
- case 4: _.label++; return { value: op[1], done: false };
81
- case 5: _.label++; y = op[1]; op = [0]; continue;
82
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
83
- default:
84
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
85
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
86
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
87
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
88
- if (t[2]) _.ops.pop();
89
- _.trys.pop(); continue;
90
- }
91
- op = body.call(thisArg, _);
92
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
93
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
94
- }
95
- }
96
-
97
- function __spreadArray$1(to, from, pack) {
98
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
99
- if (ar || !(i in from)) {
100
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
101
- ar[i] = from[i];
102
- }
103
- }
104
- return to.concat(ar || Array.prototype.slice.call(from));
105
- }
106
-
107
- var SET_RECORDS = 'SET_RECORDS';
108
- var ADD_RECORD = 'ADD_RECORD';
109
- var ADD_RECORDS = 'ADD_RECORDS';
110
- var UPDATE_RECORD = 'UPDATE_RECORD';
111
- var DELETE_RECORD = 'DELETE_RECORD';
112
- var DELETE_RECORDS = 'DELETE_RECORDS';
113
-
114
- var setRecords = function (key, payload) {
115
- return ({
116
- type: SET_RECORDS,
117
- key: key,
118
- payload: payload,
119
- });
120
- };
121
- var addRecord = function (key, payload) {
122
- return ({
123
- type: ADD_RECORD,
124
- key: key,
125
- payload: payload,
126
- });
127
- };
128
- var addRecords = function (key, payload) {
129
- return ({
130
- type: ADD_RECORDS,
131
- key: key,
132
- payload: payload,
133
- });
134
- };
135
- var deleteRecord$1 = function (key, payload) {
136
- return ({
137
- type: DELETE_RECORD,
138
- key: key,
139
- payload: payload,
140
- });
141
- };
142
- var deleteRecords$1 = function (key, payload) {
143
- return ({
144
- type: DELETE_RECORDS,
145
- key: key,
146
- payload: payload,
147
- });
148
- };
149
- var updateRecord$1 = function (key, payload) {
150
- return ({
151
- type: UPDATE_RECORD,
152
- key: key,
153
- payload: payload,
154
- });
155
- };
156
- var recordsAction = {
157
- setRecords: setRecords,
158
- addRecord: addRecord,
159
- addRecords: addRecords,
160
- deleteRecord: deleteRecord$1,
161
- deleteRecords: deleteRecords$1,
162
- updateRecord: updateRecord$1,
163
- };
164
-
165
- function _defineProperty$4(obj, key, value) {
166
- if (key in obj) {
167
- Object.defineProperty(obj, key, {
168
- value: value,
169
- enumerable: true,
170
- configurable: true,
171
- writable: true
172
- });
173
- } else {
174
- obj[key] = value;
175
- }
176
-
177
- return obj;
178
- }
179
-
180
- function ownKeys$3(object, enumerableOnly) {
181
- var keys = Object.keys(object);
182
-
183
- if (Object.getOwnPropertySymbols) {
184
- var symbols = Object.getOwnPropertySymbols(object);
185
- enumerableOnly && (symbols = symbols.filter(function (sym) {
186
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
187
- })), keys.push.apply(keys, symbols);
188
- }
189
-
190
- return keys;
191
- }
192
-
193
- function _objectSpread2(target) {
194
- for (var i = 1; i < arguments.length; i++) {
195
- var source = null != arguments[i] ? arguments[i] : {};
196
- i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) {
197
- _defineProperty$4(target, key, source[key]);
198
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) {
199
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
200
- });
201
- }
202
-
203
- return target;
204
- }
205
-
206
- /**
207
- * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
208
- *
209
- * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
210
- * during build.
211
- * @param {number} code
212
- */
213
- function formatProdErrorMessage(code) {
214
- return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
215
- }
216
-
217
- // Inlined version of the `symbol-observable` polyfill
218
- var $$observable = (function () {
219
- return typeof Symbol === 'function' && Symbol.observable || '@@observable';
220
- })();
221
-
222
- /**
223
- * These are private action types reserved by Redux.
224
- * For any unknown actions, you must return the current state.
225
- * If the current state is undefined, you must return the initial state.
226
- * Do not reference these action types directly in your code.
227
- */
228
- var randomString = function randomString() {
229
- return Math.random().toString(36).substring(7).split('').join('.');
230
- };
231
-
232
- var ActionTypes = {
233
- INIT: "@@redux/INIT" + randomString(),
234
- REPLACE: "@@redux/REPLACE" + randomString(),
235
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
236
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
237
- }
238
- };
239
-
240
- /**
241
- * @param {any} obj The object to inspect.
242
- * @returns {boolean} True if the argument appears to be a plain object.
243
- */
244
- function isPlainObject$1(obj) {
245
- if (typeof obj !== 'object' || obj === null) return false;
246
- var proto = obj;
247
-
248
- while (Object.getPrototypeOf(proto) !== null) {
249
- proto = Object.getPrototypeOf(proto);
250
- }
251
-
252
- return Object.getPrototypeOf(obj) === proto;
253
- }
254
-
255
- // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
256
- function miniKindOf(val) {
257
- if (val === void 0) return 'undefined';
258
- if (val === null) return 'null';
259
- var type = typeof val;
260
-
261
- switch (type) {
262
- case 'boolean':
263
- case 'string':
264
- case 'number':
265
- case 'symbol':
266
- case 'function':
267
- {
268
- return type;
269
- }
270
- }
271
-
272
- if (Array.isArray(val)) return 'array';
273
- if (isDate(val)) return 'date';
274
- if (isError(val)) return 'error';
275
- var constructorName = ctorName(val);
276
-
277
- switch (constructorName) {
278
- case 'Symbol':
279
- case 'Promise':
280
- case 'WeakMap':
281
- case 'WeakSet':
282
- case 'Map':
283
- case 'Set':
284
- return constructorName;
285
- } // other
286
-
287
-
288
- return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
289
- }
290
-
291
- function ctorName(val) {
292
- return typeof val.constructor === 'function' ? val.constructor.name : null;
293
- }
294
-
295
- function isError(val) {
296
- return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
297
- }
298
-
299
- function isDate(val) {
300
- if (val instanceof Date) return true;
301
- return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
302
- }
303
-
304
- function kindOf(val) {
305
- var typeOfVal = typeof val;
306
-
307
- if (process.env.NODE_ENV !== 'production') {
308
- typeOfVal = miniKindOf(val);
309
- }
310
-
311
- return typeOfVal;
312
- }
313
-
314
- /**
315
- * @deprecated
316
- *
317
- * **We recommend using the `configureStore` method
318
- * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
319
- *
320
- * Redux Toolkit is our recommended approach for writing Redux logic today,
321
- * including store setup, reducers, data fetching, and more.
322
- *
323
- * **For more details, please read this Redux docs page:**
324
- * **https://redux.js.org/introduction/why-rtk-is-redux-today**
325
- *
326
- * `configureStore` from Redux Toolkit is an improved version of `createStore` that
327
- * simplifies setup and helps avoid common bugs.
328
- *
329
- * You should not be using the `redux` core package by itself today, except for learning purposes.
330
- * The `createStore` method from the core `redux` package will not be removed, but we encourage
331
- * all users to migrate to using Redux Toolkit for all Redux code.
332
- *
333
- * If you want to use `createStore` without this visual deprecation warning, use
334
- * the `legacy_createStore` import instead:
335
- *
336
- * `import { legacy_createStore as createStore} from 'redux'`
337
- *
338
- */
339
-
340
- function createStore(reducer, preloadedState, enhancer) {
341
- var _ref2;
342
-
343
- if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
344
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
345
- }
346
-
347
- if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
348
- enhancer = preloadedState;
349
- preloadedState = undefined;
350
- }
351
-
352
- if (typeof enhancer !== 'undefined') {
353
- if (typeof enhancer !== 'function') {
354
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
355
- }
356
-
357
- return enhancer(createStore)(reducer, preloadedState);
358
- }
359
-
360
- if (typeof reducer !== 'function') {
361
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
362
- }
363
-
364
- var currentReducer = reducer;
365
- var currentState = preloadedState;
366
- var currentListeners = [];
367
- var nextListeners = currentListeners;
368
- var isDispatching = false;
369
- /**
370
- * This makes a shallow copy of currentListeners so we can use
371
- * nextListeners as a temporary list while dispatching.
372
- *
373
- * This prevents any bugs around consumers calling
374
- * subscribe/unsubscribe in the middle of a dispatch.
375
- */
376
-
377
- function ensureCanMutateNextListeners() {
378
- if (nextListeners === currentListeners) {
379
- nextListeners = currentListeners.slice();
380
- }
381
- }
382
- /**
383
- * Reads the state tree managed by the store.
384
- *
385
- * @returns {any} The current state tree of your application.
386
- */
387
-
388
-
389
- function getState() {
390
- if (isDispatching) {
391
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
392
- }
393
-
394
- return currentState;
395
- }
396
- /**
397
- * Adds a change listener. It will be called any time an action is dispatched,
398
- * and some part of the state tree may potentially have changed. You may then
399
- * call `getState()` to read the current state tree inside the callback.
400
- *
401
- * You may call `dispatch()` from a change listener, with the following
402
- * caveats:
403
- *
404
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
405
- * If you subscribe or unsubscribe while the listeners are being invoked, this
406
- * will not have any effect on the `dispatch()` that is currently in progress.
407
- * However, the next `dispatch()` call, whether nested or not, will use a more
408
- * recent snapshot of the subscription list.
409
- *
410
- * 2. The listener should not expect to see all state changes, as the state
411
- * might have been updated multiple times during a nested `dispatch()` before
412
- * the listener is called. It is, however, guaranteed that all subscribers
413
- * registered before the `dispatch()` started will be called with the latest
414
- * state by the time it exits.
415
- *
416
- * @param {Function} listener A callback to be invoked on every dispatch.
417
- * @returns {Function} A function to remove this change listener.
418
- */
419
-
420
-
421
- function subscribe(listener) {
422
- if (typeof listener !== 'function') {
423
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
424
- }
425
-
426
- if (isDispatching) {
427
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
428
- }
429
-
430
- var isSubscribed = true;
431
- ensureCanMutateNextListeners();
432
- nextListeners.push(listener);
433
- return function unsubscribe() {
434
- if (!isSubscribed) {
435
- return;
436
- }
437
-
438
- if (isDispatching) {
439
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
440
- }
441
-
442
- isSubscribed = false;
443
- ensureCanMutateNextListeners();
444
- var index = nextListeners.indexOf(listener);
445
- nextListeners.splice(index, 1);
446
- currentListeners = null;
447
- };
448
- }
449
- /**
450
- * Dispatches an action. It is the only way to trigger a state change.
451
- *
452
- * The `reducer` function, used to create the store, will be called with the
453
- * current state tree and the given `action`. Its return value will
454
- * be considered the **next** state of the tree, and the change listeners
455
- * will be notified.
456
- *
457
- * The base implementation only supports plain object actions. If you want to
458
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
459
- * wrap your store creating function into the corresponding middleware. For
460
- * example, see the documentation for the `redux-thunk` package. Even the
461
- * middleware will eventually dispatch plain object actions using this method.
462
- *
463
- * @param {Object} action A plain object representing “what changed”. It is
464
- * a good idea to keep actions serializable so you can record and replay user
465
- * sessions, or use the time travelling `redux-devtools`. An action must have
466
- * a `type` property which may not be `undefined`. It is a good idea to use
467
- * string constants for action types.
468
- *
469
- * @returns {Object} For convenience, the same action object you dispatched.
470
- *
471
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
472
- * return something else (for example, a Promise you can await).
473
- */
474
-
475
-
476
- function dispatch(action) {
477
- if (!isPlainObject$1(action)) {
478
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
479
- }
480
-
481
- if (typeof action.type === 'undefined') {
482
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
483
- }
484
-
485
- if (isDispatching) {
486
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
487
- }
488
-
489
- try {
490
- isDispatching = true;
491
- currentState = currentReducer(currentState, action);
492
- } finally {
493
- isDispatching = false;
494
- }
495
-
496
- var listeners = currentListeners = nextListeners;
497
-
498
- for (var i = 0; i < listeners.length; i++) {
499
- var listener = listeners[i];
500
- listener();
501
- }
502
-
503
- return action;
504
- }
505
- /**
506
- * Replaces the reducer currently used by the store to calculate the state.
507
- *
508
- * You might need this if your app implements code splitting and you want to
509
- * load some of the reducers dynamically. You might also need this if you
510
- * implement a hot reloading mechanism for Redux.
511
- *
512
- * @param {Function} nextReducer The reducer for the store to use instead.
513
- * @returns {void}
514
- */
515
-
516
-
517
- function replaceReducer(nextReducer) {
518
- if (typeof nextReducer !== 'function') {
519
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
520
- }
521
-
522
- currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
523
- // Any reducers that existed in both the new and old rootReducer
524
- // will receive the previous state. This effectively populates
525
- // the new state tree with any relevant data from the old one.
526
-
527
- dispatch({
528
- type: ActionTypes.REPLACE
529
- });
530
- }
531
- /**
532
- * Interoperability point for observable/reactive libraries.
533
- * @returns {observable} A minimal observable of state changes.
534
- * For more information, see the observable proposal:
535
- * https://github.com/tc39/proposal-observable
536
- */
537
-
538
-
539
- function observable() {
540
- var _ref;
541
-
542
- var outerSubscribe = subscribe;
543
- return _ref = {
544
- /**
545
- * The minimal observable subscription method.
546
- * @param {Object} observer Any object that can be used as an observer.
547
- * The observer object should have a `next` method.
548
- * @returns {subscription} An object with an `unsubscribe` method that can
549
- * be used to unsubscribe the observable from the store, and prevent further
550
- * emission of values from the observable.
551
- */
552
- subscribe: function subscribe(observer) {
553
- if (typeof observer !== 'object' || observer === null) {
554
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
555
- }
556
-
557
- function observeState() {
558
- if (observer.next) {
559
- observer.next(getState());
560
- }
561
- }
562
-
563
- observeState();
564
- var unsubscribe = outerSubscribe(observeState);
565
- return {
566
- unsubscribe: unsubscribe
567
- };
568
- }
569
- }, _ref[$$observable] = function () {
570
- return this;
571
- }, _ref;
572
- } // When a store is created, an "INIT" action is dispatched so that every
573
- // reducer returns their initial state. This effectively populates
574
- // the initial state tree.
575
-
576
-
577
- dispatch({
578
- type: ActionTypes.INIT
579
- });
580
- return _ref2 = {
581
- dispatch: dispatch,
582
- subscribe: subscribe,
583
- getState: getState,
584
- replaceReducer: replaceReducer
585
- }, _ref2[$$observable] = observable, _ref2;
586
- }
587
-
588
- /**
589
- * Prints a warning in the console if it exists.
590
- *
591
- * @param {String} message The warning message.
592
- * @returns {void}
593
- */
594
- function warning(message) {
595
- /* eslint-disable no-console */
596
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
597
- console.error(message);
598
- }
599
- /* eslint-enable no-console */
600
-
601
-
602
- try {
603
- // This error was thrown as a convenience so that if you enable
604
- // "break on all exceptions" in your console,
605
- // it would pause the execution at this line.
606
- throw new Error(message);
607
- } catch (e) {} // eslint-disable-line no-empty
608
-
609
- }
610
-
611
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
612
- var reducerKeys = Object.keys(reducers);
613
- var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
614
-
615
- if (reducerKeys.length === 0) {
616
- return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
617
- }
618
-
619
- if (!isPlainObject$1(inputState)) {
620
- return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
621
- }
622
-
623
- var unexpectedKeys = Object.keys(inputState).filter(function (key) {
624
- return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
625
- });
626
- unexpectedKeys.forEach(function (key) {
627
- unexpectedKeyCache[key] = true;
628
- });
629
- if (action && action.type === ActionTypes.REPLACE) return;
630
-
631
- if (unexpectedKeys.length > 0) {
632
- return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
633
- }
634
- }
635
-
636
- function assertReducerShape(reducers) {
637
- Object.keys(reducers).forEach(function (key) {
638
- var reducer = reducers[key];
639
- var initialState = reducer(undefined, {
640
- type: ActionTypes.INIT
641
- });
642
-
643
- if (typeof initialState === 'undefined') {
644
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
645
- }
646
-
647
- if (typeof reducer(undefined, {
648
- type: ActionTypes.PROBE_UNKNOWN_ACTION()
649
- }) === 'undefined') {
650
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
651
- }
652
- });
653
- }
654
- /**
655
- * Turns an object whose values are different reducer functions, into a single
656
- * reducer function. It will call every child reducer, and gather their results
657
- * into a single state object, whose keys correspond to the keys of the passed
658
- * reducer functions.
659
- *
660
- * @param {Object} reducers An object whose values correspond to different
661
- * reducer functions that need to be combined into one. One handy way to obtain
662
- * it is to use ES6 `import * as reducers` syntax. The reducers may never return
663
- * undefined for any action. Instead, they should return their initial state
664
- * if the state passed to them was undefined, and the current state for any
665
- * unrecognized action.
666
- *
667
- * @returns {Function} A reducer function that invokes every reducer inside the
668
- * passed object, and builds a state object with the same shape.
669
- */
670
-
671
-
672
- function combineReducers(reducers) {
673
- var reducerKeys = Object.keys(reducers);
674
- var finalReducers = {};
675
-
676
- for (var i = 0; i < reducerKeys.length; i++) {
677
- var key = reducerKeys[i];
678
-
679
- if (process.env.NODE_ENV !== 'production') {
680
- if (typeof reducers[key] === 'undefined') {
681
- warning("No reducer provided for key \"" + key + "\"");
682
- }
683
- }
684
-
685
- if (typeof reducers[key] === 'function') {
686
- finalReducers[key] = reducers[key];
687
- }
688
- }
689
-
690
- var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
691
- // keys multiple times.
692
-
693
- var unexpectedKeyCache;
694
-
695
- if (process.env.NODE_ENV !== 'production') {
696
- unexpectedKeyCache = {};
697
- }
698
-
699
- var shapeAssertionError;
700
-
701
- try {
702
- assertReducerShape(finalReducers);
703
- } catch (e) {
704
- shapeAssertionError = e;
705
- }
706
-
707
- return function combination(state, action) {
708
- if (state === void 0) {
709
- state = {};
710
- }
711
-
712
- if (shapeAssertionError) {
713
- throw shapeAssertionError;
714
- }
715
-
716
- if (process.env.NODE_ENV !== 'production') {
717
- var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
718
-
719
- if (warningMessage) {
720
- warning(warningMessage);
721
- }
722
- }
723
-
724
- var hasChanged = false;
725
- var nextState = {};
726
-
727
- for (var _i = 0; _i < finalReducerKeys.length; _i++) {
728
- var _key = finalReducerKeys[_i];
729
- var reducer = finalReducers[_key];
730
- var previousStateForKey = state[_key];
731
- var nextStateForKey = reducer(previousStateForKey, action);
732
-
733
- if (typeof nextStateForKey === 'undefined') {
734
- var actionType = action && action.type;
735
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
736
- }
737
-
738
- nextState[_key] = nextStateForKey;
739
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
740
- }
741
-
742
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
743
- return hasChanged ? nextState : state;
744
- };
745
- }
746
-
747
- /**
748
- * Composes single-argument functions from right to left. The rightmost
749
- * function can take multiple arguments as it provides the signature for
750
- * the resulting composite function.
751
- *
752
- * @param {...Function} funcs The functions to compose.
753
- * @returns {Function} A function obtained by composing the argument functions
754
- * from right to left. For example, compose(f, g, h) is identical to doing
755
- * (...args) => f(g(h(...args))).
756
- */
757
- function compose() {
758
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
759
- funcs[_key] = arguments[_key];
760
- }
761
-
762
- if (funcs.length === 0) {
763
- return function (arg) {
764
- return arg;
765
- };
766
- }
767
-
768
- if (funcs.length === 1) {
769
- return funcs[0];
770
- }
771
-
772
- return funcs.reduce(function (a, b) {
773
- return function () {
774
- return a(b.apply(void 0, arguments));
775
- };
776
- });
777
- }
778
-
779
- /**
780
- * Creates a store enhancer that applies middleware to the dispatch method
781
- * of the Redux store. This is handy for a variety of tasks, such as expressing
782
- * asynchronous actions in a concise manner, or logging every action payload.
783
- *
784
- * See `redux-thunk` package as an example of the Redux middleware.
785
- *
786
- * Because middleware is potentially asynchronous, this should be the first
787
- * store enhancer in the composition chain.
788
- *
789
- * Note that each middleware will be given the `dispatch` and `getState` functions
790
- * as named arguments.
791
- *
792
- * @param {...Function} middlewares The middleware chain to be applied.
793
- * @returns {Function} A store enhancer applying the middleware.
794
- */
795
-
796
- function applyMiddleware() {
797
- for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
798
- middlewares[_key] = arguments[_key];
799
- }
800
-
801
- return function (createStore) {
802
- return function () {
803
- var store = createStore.apply(void 0, arguments);
804
-
805
- var _dispatch = function dispatch() {
806
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
807
- };
808
-
809
- var middlewareAPI = {
810
- getState: store.getState,
811
- dispatch: function dispatch() {
812
- return _dispatch.apply(void 0, arguments);
813
- }
814
- };
815
- var chain = middlewares.map(function (middleware) {
816
- return middleware(middlewareAPI);
817
- });
818
- _dispatch = compose.apply(void 0, chain)(store.dispatch);
819
- return _objectSpread2(_objectSpread2({}, store), {}, {
820
- dispatch: _dispatch
821
- });
822
- };
823
- };
824
- }
825
-
826
- /*
827
- * This is a dummy function to check if the function name has been altered by minification.
828
- * If the function has been minified and NODE_ENV !== 'production', warn the user.
829
- */
830
-
831
- function isCrushed() {}
832
-
833
- if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
834
- warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
835
- }
836
-
837
- function appendRecord(record, records) {
838
- return __spreadArray$1(__spreadArray$1([], records, true), [record], false);
839
- }
840
- function appendRecords(recordsToAppend, records) {
841
- return __spreadArray$1(__spreadArray$1([], records, true), recordsToAppend, true);
842
- }
843
- function updateRecord(record, records) {
844
- return records.map(function (r) {
845
- if (r.id === record.id) {
846
- return record;
847
- }
848
- return r;
849
- });
850
- }
851
- function deleteRecord(record, records) {
852
- return records.filter(function (r) { return r.id !== record.id; });
853
- }
854
- function deleteRecords(recordsToDelete, records) {
855
- return records.filter(function (r) { return !recordsToDelete.includes(r); });
856
- }
857
- var records = (function (state, action) {
858
- var _a, _b, _c, _d, _e, _f;
859
- var _g;
860
- if (state === void 0) { state = {}; }
861
- var list = (_g = state[action.key]) !== null && _g !== void 0 ? _g : [];
862
- switch (action.type) {
863
- case SET_RECORDS:
864
- if (Array.isArray(action.payload)) {
865
- return __assign(__assign({}, state), (_a = {}, _a[action.key] = action.payload, _a));
866
- }
867
- case ADD_RECORD:
868
- return __assign(__assign({}, state), (_b = {}, _b[action.key] = appendRecord(action.payload, list), _b));
869
- case ADD_RECORDS:
870
- return __assign(__assign({}, state), (_c = {}, _c[action.key] = appendRecords(action.payload, list), _c));
871
- case DELETE_RECORD:
872
- return __assign(__assign({}, state), (_d = {}, _d[action.key] = deleteRecord(action.payload, list), _d));
873
- case DELETE_RECORDS:
874
- return __assign(__assign({}, state), (_e = {}, _e[action.key] = deleteRecords(action.payload, list), _e));
875
- case UPDATE_RECORD:
876
- return __assign(__assign({}, state), (_f = {}, _f[action.key] = updateRecord(action.payload, list), _f));
877
- default:
878
- return state;
879
- }
880
- });
881
-
882
- var appReducer = combineReducers({
883
- records: records,
884
- });
885
-
886
- function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!n.constructor[L]||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?(n.delete(r),n.add(t)):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)?n:(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0),n)}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function m(n,r){tn[n]||(tn[n]=r);}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function O(n){g(n),n.p.forEach(S),n.p=null;}function g(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.O=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.g||b("ES5").S(e,r,o),o?(i[Q].P&&(O(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),O(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o;i(3===e.i?new Set(o):o,(function(r,i){return A(n,e,o,r,i,t)})),x(n,o,!1),t&&n.u&&b("Patches").R(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var v=M(e,c,s&&i&&3!==i.i&&!u(i.D,a)?s.concat(a):void 0);if(f(o,a,v),!r(v))return;e.m=!1;}if(t(c)&&!y(c)){if(!e.h.F&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),n.h.F&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function R(n,r,t){var e=s(r)?b("MapSet").N(r,t):v(r)?b("MapSet").T(r,t):n.g?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,D:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function D(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=F(r,c),u.I=!1;}else e=F(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function F(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function N(){function t(n,r){var t=s[n];return t?t.enumerable=r:s[n]=t={configurable:!0,enumerable:r,get:function(){var r=this[Q];return "production"!==process.env.NODE_ENV&&f(r),en.get(r,n)},set:function(r){var t=this[Q];"production"!==process.env.NODE_ENV&&f(t),en.set(t,n,r);}},t}function e(n){for(var r=n.length-1;r>=0;r--){var t=n[r][Q];if(!t.P)switch(t.i){case 5:a(t)&&k(t);break;case 4:o(t)&&k(t);}}}function o(n){for(var r=n.t,t=n.k,e=nn(t),i=e.length-1;i>=0;i--){var o=e[i];if(o!==Q){var a=r[o];if(void 0===a&&!u(r,o))return !0;var f=t[o],s=f&&f[Q];if(s?s.t!==a:!c(f,a))return !0}}var v=!!r[Q];return e.length!==nn(r).length+(v?0:1)}function a(n){var r=n.k;if(r.length!==n.t.length)return !0;var t=Object.getOwnPropertyDescriptor(r,r.length-1);if(t&&!t.get)return !0;for(var e=0;e<r.length;e++)if(!r.hasOwnProperty(e))return !0;return !1}function f(r){r.O&&n(3,JSON.stringify(p(r)));}var s={};m("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var o=rn(r);delete o[Q];for(var u=nn(o),a=0;a<u.length;a++){var f=u[a];o[f]=t(f,n||!!o[f].enumerable);}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:_(),P:!1,I:!1,D:{},l:r,t:n,k:i,o:null,O:!1,C:!1};return Object.defineProperty(i,Q,{value:o,writable:!0}),i},S:function(n,t,o){o?r(t)&&t[Q].A===n&&e(n.p):(n.u&&function n(r){if(r&&"object"==typeof r){var t=r[Q];if(t){var e=t.t,o=t.k,f=t.D,c=t.i;if(4===c)i(o,(function(r){r!==Q&&(void 0!==e[r]||u(e,r)?f[r]||n(o[r]):(f[r]=!0,k(t)));})),i(e,(function(n){void 0!==o[n]||u(o,n)||(f[n]=!1,k(t));}));else if(5===c){if(a(t)&&(k(t),f.length=!0),o.length<e.length)for(var s=o.length;s<e.length;s++)f[s]=!1;else for(var v=e.length;v<o.length;v++)f[v]=!0;for(var p=Math.min(o.length,e.length),l=0;l<p;l++)o.hasOwnProperty(l)||(f[l]=!0),void 0===f[l]&&n(o[l]);}}}}(n.p[0]),e(n.p));},K:function(n){return 4===n.i?o(n):a(n)}});}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=R(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.D[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&"number"!=typeof t&&(void 0!==t||r in n.o)||(n.o[r]=t,n.D[r]=!0,!0)},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.D[r]=!1,E(n),k(n)):delete n.D[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.g=B,this.F=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=R(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?O(c):g(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw O(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.F&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=D(e));var i=w(this),o=R(this,e,void 0);return o[Q].C=!0,g(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.F=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.g=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un;an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
887
-
888
- /** A function that accepts a potential "extra argument" value to be injected later,
889
- * and returns an instance of the thunk middleware that uses that value
890
- */
891
- function createThunkMiddleware(extraArgument) {
892
- // Standard Redux middleware definition pattern:
893
- // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
894
- var middleware = function middleware(_ref) {
895
- var dispatch = _ref.dispatch,
896
- getState = _ref.getState;
897
- return function (next) {
898
- return function (action) {
899
- // The thunk middleware looks for any functions that were passed to `store.dispatch`.
900
- // If this "action" is really a function, call it and return the result.
901
- if (typeof action === 'function') {
902
- // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
903
- return action(dispatch, getState, extraArgument);
904
- } // Otherwise, pass the action down the middleware chain as usual
905
-
906
-
907
- return next(action);
908
- };
909
- };
910
- };
911
-
912
- return middleware;
913
- }
914
-
915
- var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
916
- // with whatever "extra arg" they want to inject into their thunks
917
-
918
- thunk.withExtraArgument = createThunkMiddleware;
919
- var thunk$1 = thunk;
920
-
921
- var __extends = (undefined && undefined.__extends) || (function () {
922
- var extendStatics = function (d, b) {
923
- extendStatics = Object.setPrototypeOf ||
924
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
925
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
926
- return extendStatics(d, b);
927
- };
928
- return function (d, b) {
929
- if (typeof b !== "function" && b !== null)
930
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
931
- extendStatics(d, b);
932
- function __() { this.constructor = d; }
933
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
934
- };
935
- })();
936
- (undefined && undefined.__generator) || function (thisArg, body) {
937
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
938
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
939
- function verb(n) { return function (v) { return step([n, v]); }; }
940
- function step(op) {
941
- if (f) throw new TypeError("Generator is already executing.");
942
- while (_) try {
943
- 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;
944
- if (y = 0, t) op = [op[0] & 2, t.value];
945
- switch (op[0]) {
946
- case 0: case 1: t = op; break;
947
- case 4: _.label++; return { value: op[1], done: false };
948
- case 5: _.label++; y = op[1]; op = [0]; continue;
949
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
950
- default:
951
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
952
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
953
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
954
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
955
- if (t[2]) _.ops.pop();
956
- _.trys.pop(); continue;
957
- }
958
- op = body.call(thisArg, _);
959
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
960
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
961
- }
962
- };
963
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
964
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
965
- to[j] = from[i];
966
- return to;
967
- };
968
- var __defProp = Object.defineProperty;
969
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
970
- var __hasOwnProp = Object.prototype.hasOwnProperty;
971
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
972
- var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
973
- var __spreadValues = function (a, b) {
974
- for (var prop in b || (b = {}))
975
- if (__hasOwnProp.call(b, prop))
976
- __defNormalProp(a, prop, b[prop]);
977
- if (__getOwnPropSymbols)
978
- for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
979
- var prop = _c[_i];
980
- if (__propIsEnum.call(b, prop))
981
- __defNormalProp(a, prop, b[prop]);
982
- }
983
- return a;
984
- };
985
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
986
- if (arguments.length === 0)
987
- return void 0;
988
- if (typeof arguments[0] === "object")
989
- return compose;
990
- return compose.apply(null, arguments);
991
- };
992
- // src/isPlainObject.ts
993
- function isPlainObject(value) {
994
- if (typeof value !== "object" || value === null)
995
- return false;
996
- var proto = Object.getPrototypeOf(value);
997
- if (proto === null)
998
- return true;
999
- var baseProto = proto;
1000
- while (Object.getPrototypeOf(baseProto) !== null) {
1001
- baseProto = Object.getPrototypeOf(baseProto);
1002
- }
1003
- return proto === baseProto;
1004
- }
1005
- function getTimeMeasureUtils(maxDelay, fnName) {
1006
- var elapsed = 0;
1007
- return {
1008
- measureTime: function (fn) {
1009
- var started = Date.now();
1010
- try {
1011
- return fn();
1012
- }
1013
- finally {
1014
- var finished = Date.now();
1015
- elapsed += finished - started;
1016
- }
1017
- },
1018
- warnIfExceeded: function () {
1019
- if (elapsed > maxDelay) {
1020
- 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.");
1021
- }
1022
- }
1023
- };
1024
- }
1025
- var MiddlewareArray = /** @class */ (function (_super) {
1026
- __extends(MiddlewareArray, _super);
1027
- function MiddlewareArray() {
1028
- var args = [];
1029
- for (var _i = 0; _i < arguments.length; _i++) {
1030
- args[_i] = arguments[_i];
1031
- }
1032
- var _this = _super.apply(this, args) || this;
1033
- Object.setPrototypeOf(_this, MiddlewareArray.prototype);
1034
- return _this;
1035
- }
1036
- Object.defineProperty(MiddlewareArray, Symbol.species, {
1037
- get: function () {
1038
- return MiddlewareArray;
1039
- },
1040
- enumerable: false,
1041
- configurable: true
1042
- });
1043
- MiddlewareArray.prototype.concat = function () {
1044
- var arr = [];
1045
- for (var _i = 0; _i < arguments.length; _i++) {
1046
- arr[_i] = arguments[_i];
1047
- }
1048
- return _super.prototype.concat.apply(this, arr);
1049
- };
1050
- MiddlewareArray.prototype.prepend = function () {
1051
- var arr = [];
1052
- for (var _i = 0; _i < arguments.length; _i++) {
1053
- arr[_i] = arguments[_i];
1054
- }
1055
- if (arr.length === 1 && Array.isArray(arr[0])) {
1056
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
1057
- }
1058
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
1059
- };
1060
- return MiddlewareArray;
1061
- }(Array));
1062
- // src/immutableStateInvariantMiddleware.ts
1063
- var isProduction = process.env.NODE_ENV === "production";
1064
- var prefix = "Invariant failed";
1065
- function invariant(condition, message) {
1066
- if (condition) {
1067
- return;
1068
- }
1069
- if (isProduction) {
1070
- throw new Error(prefix);
1071
- }
1072
- throw new Error(prefix + ": " + (message || ""));
1073
- }
1074
- function stringify(obj, serializer, indent, decycler) {
1075
- return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
1076
- }
1077
- function getSerialize(serializer, decycler) {
1078
- var stack = [], keys = [];
1079
- if (!decycler)
1080
- decycler = function (_, value) {
1081
- if (stack[0] === value)
1082
- return "[Circular ~]";
1083
- return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
1084
- };
1085
- return function (key, value) {
1086
- if (stack.length > 0) {
1087
- var thisPos = stack.indexOf(this);
1088
- ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
1089
- ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
1090
- if (~stack.indexOf(value))
1091
- value = decycler.call(this, key, value);
1092
- }
1093
- else
1094
- stack.push(value);
1095
- return serializer == null ? value : serializer.call(this, key, value);
1096
- };
1097
- }
1098
- function isImmutableDefault(value) {
1099
- return typeof value !== "object" || value == null || Object.isFrozen(value);
1100
- }
1101
- function trackForMutations(isImmutable, ignorePaths, obj) {
1102
- var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
1103
- return {
1104
- detectMutations: function () {
1105
- return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
1106
- }
1107
- };
1108
- }
1109
- function trackProperties(isImmutable, ignorePaths, obj, path) {
1110
- if (ignorePaths === void 0) { ignorePaths = []; }
1111
- if (path === void 0) { path = ""; }
1112
- var tracked = { value: obj };
1113
- if (!isImmutable(obj)) {
1114
- tracked.children = {};
1115
- for (var key in obj) {
1116
- var childPath = path ? path + "." + key : key;
1117
- if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
1118
- continue;
1119
- }
1120
- tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
1121
- }
1122
- }
1123
- return tracked;
1124
- }
1125
- function detectMutations(isImmutable, ignorePaths, trackedProperty, obj, sameParentRef, path) {
1126
- if (ignorePaths === void 0) { ignorePaths = []; }
1127
- if (sameParentRef === void 0) { sameParentRef = false; }
1128
- if (path === void 0) { path = ""; }
1129
- var prevObj = trackedProperty ? trackedProperty.value : void 0;
1130
- var sameRef = prevObj === obj;
1131
- if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
1132
- return { wasMutated: true, path: path };
1133
- }
1134
- if (isImmutable(prevObj) || isImmutable(obj)) {
1135
- return { wasMutated: false };
1136
- }
1137
- var keysToDetect = {};
1138
- for (var key in trackedProperty.children) {
1139
- keysToDetect[key] = true;
1140
- }
1141
- for (var key in obj) {
1142
- keysToDetect[key] = true;
1143
- }
1144
- for (var key in keysToDetect) {
1145
- var childPath = path ? path + "." + key : key;
1146
- if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
1147
- continue;
1148
- }
1149
- var result = detectMutations(isImmutable, ignorePaths, trackedProperty.children[key], obj[key], sameRef, childPath);
1150
- if (result.wasMutated) {
1151
- return result;
1152
- }
1153
- }
1154
- return { wasMutated: false };
1155
- }
1156
- function createImmutableStateInvariantMiddleware(options) {
1157
- if (options === void 0) { options = {}; }
1158
- if (process.env.NODE_ENV === "production") {
1159
- return function () { return function (next) { return function (action) { return next(action); }; }; };
1160
- }
1161
- var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
1162
- ignoredPaths = ignoredPaths || ignore;
1163
- var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
1164
- return function (_c) {
1165
- var getState = _c.getState;
1166
- var state = getState();
1167
- var tracker = track(state);
1168
- var result;
1169
- return function (next) { return function (action) {
1170
- var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
1171
- measureUtils.measureTime(function () {
1172
- state = getState();
1173
- result = tracker.detectMutations();
1174
- tracker = track(state);
1175
- 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)");
1176
- });
1177
- var dispatchedAction = next(action);
1178
- measureUtils.measureTime(function () {
1179
- state = getState();
1180
- result = tracker.detectMutations();
1181
- tracker = track(state);
1182
- 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)");
1183
- });
1184
- measureUtils.warnIfExceeded();
1185
- return dispatchedAction;
1186
- }; };
1187
- };
1188
- }
1189
- // src/serializableStateInvariantMiddleware.ts
1190
- function isPlain(val) {
1191
- var type = typeof val;
1192
- return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
1193
- }
1194
- function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths) {
1195
- if (path === void 0) { path = ""; }
1196
- if (isSerializable === void 0) { isSerializable = isPlain; }
1197
- if (ignoredPaths === void 0) { ignoredPaths = []; }
1198
- var foundNestedSerializable;
1199
- if (!isSerializable(value)) {
1200
- return {
1201
- keyPath: path || "<root>",
1202
- value: value
1203
- };
1204
- }
1205
- if (typeof value !== "object" || value === null) {
1206
- return false;
1207
- }
1208
- var entries = getEntries != null ? getEntries(value) : Object.entries(value);
1209
- var hasIgnoredPaths = ignoredPaths.length > 0;
1210
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1211
- var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
1212
- var nestedPath = path ? path + "." + key : key;
1213
- if (hasIgnoredPaths && ignoredPaths.indexOf(nestedPath) >= 0) {
1214
- continue;
1215
- }
1216
- if (!isSerializable(nestedValue)) {
1217
- return {
1218
- keyPath: nestedPath,
1219
- value: nestedValue
1220
- };
1221
- }
1222
- if (typeof nestedValue === "object") {
1223
- foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths);
1224
- if (foundNestedSerializable) {
1225
- return foundNestedSerializable;
1226
- }
1227
- }
1228
- }
1229
- return false;
1230
- }
1231
- function createSerializableStateInvariantMiddleware(options) {
1232
- if (options === void 0) { options = {}; }
1233
- if (process.env.NODE_ENV === "production") {
1234
- return function () { return function (next) { return function (action) { return next(action); }; }; };
1235
- }
1236
- var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j;
1237
- return function (storeAPI) { return function (next) { return function (action) {
1238
- var result = next(action);
1239
- var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
1240
- if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
1241
- measureUtils.measureTime(function () {
1242
- var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths);
1243
- if (foundActionNonSerializableValue) {
1244
- var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
1245
- 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)");
1246
- }
1247
- });
1248
- }
1249
- if (!ignoreState) {
1250
- measureUtils.measureTime(function () {
1251
- var state = storeAPI.getState();
1252
- var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths);
1253
- if (foundStateNonSerializableValue) {
1254
- var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
1255
- 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)");
1256
- }
1257
- });
1258
- measureUtils.warnIfExceeded();
1259
- }
1260
- return result;
1261
- }; }; };
1262
- }
1263
- // src/getDefaultMiddleware.ts
1264
- function isBoolean(x) {
1265
- return typeof x === "boolean";
1266
- }
1267
- function curryGetDefaultMiddleware() {
1268
- return function curriedGetDefaultMiddleware(options) {
1269
- return getDefaultMiddleware(options);
1270
- };
1271
- }
1272
- function getDefaultMiddleware(options) {
1273
- if (options === void 0) { options = {}; }
1274
- var _c = options.thunk, thunk = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e;
1275
- var middlewareArray = new MiddlewareArray();
1276
- if (thunk) {
1277
- if (isBoolean(thunk)) {
1278
- middlewareArray.push(thunk$1);
1279
- }
1280
- else {
1281
- middlewareArray.push(thunk$1.withExtraArgument(thunk.extraArgument));
1282
- }
1283
- }
1284
- if (process.env.NODE_ENV !== "production") {
1285
- if (immutableCheck) {
1286
- var immutableOptions = {};
1287
- if (!isBoolean(immutableCheck)) {
1288
- immutableOptions = immutableCheck;
1289
- }
1290
- middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
1291
- }
1292
- if (serializableCheck) {
1293
- var serializableOptions = {};
1294
- if (!isBoolean(serializableCheck)) {
1295
- serializableOptions = serializableCheck;
1296
- }
1297
- middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
1298
- }
1299
- }
1300
- return middlewareArray;
1301
- }
1302
- // src/configureStore.ts
1303
- var IS_PRODUCTION = process.env.NODE_ENV === "production";
1304
- function configureStore(options) {
1305
- var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
1306
- var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
1307
- var rootReducer;
1308
- if (typeof reducer === "function") {
1309
- rootReducer = reducer;
1310
- }
1311
- else if (isPlainObject(reducer)) {
1312
- rootReducer = combineReducers(reducer);
1313
- }
1314
- else {
1315
- throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
1316
- }
1317
- var finalMiddleware = middleware;
1318
- if (typeof finalMiddleware === "function") {
1319
- finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
1320
- if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
1321
- throw new Error("when using a middleware builder function, an array of middleware must be returned");
1322
- }
1323
- }
1324
- if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
1325
- throw new Error("each middleware provided to configureStore must be a function");
1326
- }
1327
- var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
1328
- var finalCompose = compose;
1329
- if (devTools) {
1330
- finalCompose = composeWithDevTools(__spreadValues({
1331
- trace: !IS_PRODUCTION
1332
- }, typeof devTools === "object" && devTools));
1333
- }
1334
- var storeEnhancers = [middlewareEnhancer];
1335
- if (Array.isArray(enhancers)) {
1336
- storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
1337
- }
1338
- else if (typeof enhancers === "function") {
1339
- storeEnhancers = enhancers(storeEnhancers);
1340
- }
1341
- var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
1342
- return createStore(rootReducer, preloadedState, composedEnhancer);
1343
- }
1344
- // src/index.ts
1345
- N();
1346
-
1347
- var KEY_PREFIX = 'persist:';
1348
- var FLUSH = 'persist/FLUSH';
1349
- var REHYDRATE = 'persist/REHYDRATE';
1350
- var PAUSE = 'persist/PAUSE';
1351
- var PERSIST = 'persist/PERSIST';
1352
- var PURGE = 'persist/PURGE';
1353
- var REGISTER = 'persist/REGISTER';
1354
- var DEFAULT_VERSION = -1;
1355
-
1356
- function _typeof$1(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
1357
-
1358
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1359
-
1360
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty$3(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1361
-
1362
- function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1363
-
1364
- /*
1365
- autoMergeLevel1:
1366
- - merges 1 level of substate
1367
- - skips substate if already modified
1368
- */
1369
- function autoMergeLevel1(inboundState, originalState, reducedState, _ref) {
1370
- var debug = _ref.debug;
1371
-
1372
- var newState = _objectSpread$2({}, reducedState); // only rehydrate if inboundState exists and is an object
1373
-
1374
-
1375
- if (inboundState && _typeof$1(inboundState) === 'object') {
1376
- Object.keys(inboundState).forEach(function (key) {
1377
- // ignore _persist data
1378
- if (key === '_persist') return; // if reducer modifies substate, skip auto rehydration
1379
-
1380
- if (originalState[key] !== reducedState[key]) {
1381
- if (process.env.NODE_ENV !== 'production' && debug) console.log('redux-persist/stateReconciler: sub state for key `%s` modified, skipping.', key);
1382
- return;
1383
- } // otherwise hard set the new value
1384
-
1385
-
1386
- newState[key] = inboundState[key];
1387
- });
1388
- }
1389
-
1390
- if (process.env.NODE_ENV !== 'production' && debug && inboundState && _typeof$1(inboundState) === 'object') console.log("redux-persist/stateReconciler: rehydrated keys '".concat(Object.keys(inboundState).join(', '), "'"));
1391
- return newState;
1392
- }
1393
-
1394
- // @TODO remove once flow < 0.63 support is no longer required.
1395
- function createPersistoid(config) {
1396
- // defaults
1397
- var blacklist = config.blacklist || null;
1398
- var whitelist = config.whitelist || null;
1399
- var transforms = config.transforms || [];
1400
- var throttle = config.throttle || 0;
1401
- var storageKey = "".concat(config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX).concat(config.key);
1402
- var storage = config.storage;
1403
- var serialize;
1404
-
1405
- if (config.serialize === false) {
1406
- serialize = function serialize(x) {
1407
- return x;
1408
- };
1409
- } else if (typeof config.serialize === 'function') {
1410
- serialize = config.serialize;
1411
- } else {
1412
- serialize = defaultSerialize;
1413
- }
1414
-
1415
- var writeFailHandler = config.writeFailHandler || null; // initialize stateful values
1416
-
1417
- var lastState = {};
1418
- var stagedState = {};
1419
- var keysToProcess = [];
1420
- var timeIterator = null;
1421
- var writePromise = null;
1422
-
1423
- var update = function update(state) {
1424
- // add any changed keys to the queue
1425
- Object.keys(state).forEach(function (key) {
1426
- if (!passWhitelistBlacklist(key)) return; // is keyspace ignored? noop
1427
-
1428
- if (lastState[key] === state[key]) return; // value unchanged? noop
1429
-
1430
- if (keysToProcess.indexOf(key) !== -1) return; // is key already queued? noop
1431
-
1432
- keysToProcess.push(key); // add key to queue
1433
- }); //if any key is missing in the new state which was present in the lastState,
1434
- //add it for processing too
1435
-
1436
- Object.keys(lastState).forEach(function (key) {
1437
- if (state[key] === undefined && passWhitelistBlacklist(key) && keysToProcess.indexOf(key) === -1 && lastState[key] !== undefined) {
1438
- keysToProcess.push(key);
1439
- }
1440
- }); // start the time iterator if not running (read: throttle)
1441
-
1442
- if (timeIterator === null) {
1443
- timeIterator = setInterval(processNextKey, throttle);
1444
- }
1445
-
1446
- lastState = state;
1447
- };
1448
-
1449
- function processNextKey() {
1450
- if (keysToProcess.length === 0) {
1451
- if (timeIterator) clearInterval(timeIterator);
1452
- timeIterator = null;
1453
- return;
1454
- }
1455
-
1456
- var key = keysToProcess.shift();
1457
- var endState = transforms.reduce(function (subState, transformer) {
1458
- return transformer.in(subState, key, lastState);
1459
- }, lastState[key]);
1460
-
1461
- if (endState !== undefined) {
1462
- try {
1463
- stagedState[key] = serialize(endState);
1464
- } catch (err) {
1465
- console.error('redux-persist/createPersistoid: error serializing state', err);
1466
- }
1467
- } else {
1468
- //if the endState is undefined, no need to persist the existing serialized content
1469
- delete stagedState[key];
1470
- }
1471
-
1472
- if (keysToProcess.length === 0) {
1473
- writeStagedState();
1474
- }
1475
- }
1476
-
1477
- function writeStagedState() {
1478
- // cleanup any removed keys just before write.
1479
- Object.keys(stagedState).forEach(function (key) {
1480
- if (lastState[key] === undefined) {
1481
- delete stagedState[key];
1482
- }
1483
- });
1484
- writePromise = storage.setItem(storageKey, serialize(stagedState)).catch(onWriteFail);
1485
- }
1486
-
1487
- function passWhitelistBlacklist(key) {
1488
- if (whitelist && whitelist.indexOf(key) === -1 && key !== '_persist') return false;
1489
- if (blacklist && blacklist.indexOf(key) !== -1) return false;
1490
- return true;
1491
- }
1492
-
1493
- function onWriteFail(err) {
1494
- // @TODO add fail handlers (typically storage full)
1495
- if (writeFailHandler) writeFailHandler(err);
1496
-
1497
- if (err && process.env.NODE_ENV !== 'production') {
1498
- console.error('Error storing data', err);
1499
- }
1500
- }
1501
-
1502
- var flush = function flush() {
1503
- while (keysToProcess.length !== 0) {
1504
- processNextKey();
1505
- }
1506
-
1507
- return writePromise || Promise.resolve();
1508
- }; // return `persistoid`
1509
-
1510
-
1511
- return {
1512
- update: update,
1513
- flush: flush
1514
- };
1515
- } // @NOTE in the future this may be exposed via config
1516
-
1517
- function defaultSerialize(data) {
1518
- return JSON.stringify(data);
1519
- }
1520
-
1521
- function getStoredState(config) {
1522
- var transforms = config.transforms || [];
1523
- var storageKey = "".concat(config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX).concat(config.key);
1524
- var storage = config.storage;
1525
- var debug = config.debug;
1526
- var deserialize;
1527
-
1528
- if (config.deserialize === false) {
1529
- deserialize = function deserialize(x) {
1530
- return x;
1531
- };
1532
- } else if (typeof config.deserialize === 'function') {
1533
- deserialize = config.deserialize;
1534
- } else {
1535
- deserialize = defaultDeserialize;
1536
- }
1537
-
1538
- return storage.getItem(storageKey).then(function (serialized) {
1539
- if (!serialized) return undefined;else {
1540
- try {
1541
- var state = {};
1542
- var rawState = deserialize(serialized);
1543
- Object.keys(rawState).forEach(function (key) {
1544
- state[key] = transforms.reduceRight(function (subState, transformer) {
1545
- return transformer.out(subState, key, rawState);
1546
- }, deserialize(rawState[key]));
1547
- });
1548
- return state;
1549
- } catch (err) {
1550
- if (process.env.NODE_ENV !== 'production' && debug) console.log("redux-persist/getStoredState: Error restoring data ".concat(serialized), err);
1551
- throw err;
1552
- }
1553
- }
1554
- });
1555
- }
1556
-
1557
- function defaultDeserialize(serial) {
1558
- return JSON.parse(serial);
1559
- }
1560
-
1561
- function purgeStoredState(config) {
1562
- var storage = config.storage;
1563
- var storageKey = "".concat(config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX).concat(config.key);
1564
- return storage.removeItem(storageKey, warnIfRemoveError);
1565
- }
1566
-
1567
- function warnIfRemoveError(err) {
1568
- if (err && process.env.NODE_ENV !== 'production') {
1569
- console.error('redux-persist/purgeStoredState: Error purging data stored state', err);
1570
- }
1571
- }
1572
-
1573
- function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1574
-
1575
- function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1576
-
1577
- function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1578
-
1579
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
1580
-
1581
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1582
- var DEFAULT_TIMEOUT = 5000;
1583
- /*
1584
- @TODO add validation / handling for:
1585
- - persisting a reducer which has nested _persist
1586
- - handling actions that fire before reydrate is called
1587
- */
1588
-
1589
- function persistReducer(config, baseReducer) {
1590
- if (process.env.NODE_ENV !== 'production') {
1591
- if (!config) throw new Error('config is required for persistReducer');
1592
- if (!config.key) throw new Error('key is required in persistor config');
1593
- if (!config.storage) throw new Error("redux-persist: config.storage is required. Try using one of the provided storage engines `import storage from 'redux-persist/lib/storage'`");
1594
- }
1595
-
1596
- var version = config.version !== undefined ? config.version : DEFAULT_VERSION;
1597
- config.debug || false;
1598
- var stateReconciler = config.stateReconciler === undefined ? autoMergeLevel1 : config.stateReconciler;
1599
- var getStoredState$1 = config.getStoredState || getStoredState;
1600
- var timeout = config.timeout !== undefined ? config.timeout : DEFAULT_TIMEOUT;
1601
- var _persistoid = null;
1602
- var _purge = false;
1603
- var _paused = true;
1604
-
1605
- var conditionalUpdate = function conditionalUpdate(state) {
1606
- // update the persistoid only if we are rehydrated and not paused
1607
- state._persist.rehydrated && _persistoid && !_paused && _persistoid.update(state);
1608
- return state;
1609
- };
1610
-
1611
- return function (state, action) {
1612
- var _ref = state || {},
1613
- _persist = _ref._persist,
1614
- rest = _objectWithoutProperties(_ref, ["_persist"]); // $FlowIgnore need to update State type
1615
-
1616
-
1617
- var restState = rest;
1618
-
1619
- if (action.type === PERSIST) {
1620
- var _sealed = false;
1621
-
1622
- var _rehydrate = function _rehydrate(payload, err) {
1623
- // dev warning if we are already sealed
1624
- if (process.env.NODE_ENV !== 'production' && _sealed) console.error("redux-persist: rehydrate for \"".concat(config.key, "\" called after timeout."), payload, err); // only rehydrate if we are not already sealed
1625
-
1626
- if (!_sealed) {
1627
- action.rehydrate(config.key, payload, err);
1628
- _sealed = true;
1629
- }
1630
- };
1631
-
1632
- timeout && setTimeout(function () {
1633
- !_sealed && _rehydrate(undefined, new Error("redux-persist: persist timed out for persist key \"".concat(config.key, "\"")));
1634
- }, timeout); // @NOTE PERSIST resumes if paused.
1635
-
1636
- _paused = false; // @NOTE only ever create persistoid once, ensure we call it at least once, even if _persist has already been set
1637
-
1638
- if (!_persistoid) _persistoid = createPersistoid(config); // @NOTE PERSIST can be called multiple times, noop after the first
1639
-
1640
- if (_persist) {
1641
- // We still need to call the base reducer because there might be nested
1642
- // uses of persistReducer which need to be aware of the PERSIST action
1643
- return _objectSpread$1({}, baseReducer(restState, action), {
1644
- _persist: _persist
1645
- });
1646
- }
1647
-
1648
- if (typeof action.rehydrate !== 'function' || typeof action.register !== 'function') throw new Error('redux-persist: either rehydrate or register is not a function on the PERSIST action. This can happen if the action is being replayed. This is an unexplored use case, please open an issue and we will figure out a resolution.');
1649
- action.register(config.key);
1650
- getStoredState$1(config).then(function (restoredState) {
1651
- var migrate = config.migrate || function (s, v) {
1652
- return Promise.resolve(s);
1653
- };
1654
-
1655
- migrate(restoredState, version).then(function (migratedState) {
1656
- _rehydrate(migratedState);
1657
- }, function (migrateErr) {
1658
- if (process.env.NODE_ENV !== 'production' && migrateErr) console.error('redux-persist: migration error', migrateErr);
1659
-
1660
- _rehydrate(undefined, migrateErr);
1661
- });
1662
- }, function (err) {
1663
- _rehydrate(undefined, err);
1664
- });
1665
- return _objectSpread$1({}, baseReducer(restState, action), {
1666
- _persist: {
1667
- version: version,
1668
- rehydrated: false
1669
- }
1670
- });
1671
- } else if (action.type === PURGE) {
1672
- _purge = true;
1673
- action.result(purgeStoredState(config));
1674
- return _objectSpread$1({}, baseReducer(restState, action), {
1675
- _persist: _persist
1676
- });
1677
- } else if (action.type === FLUSH) {
1678
- action.result(_persistoid && _persistoid.flush());
1679
- return _objectSpread$1({}, baseReducer(restState, action), {
1680
- _persist: _persist
1681
- });
1682
- } else if (action.type === PAUSE) {
1683
- _paused = true;
1684
- } else if (action.type === REHYDRATE) {
1685
- // noop on restState if purging
1686
- if (_purge) return _objectSpread$1({}, restState, {
1687
- _persist: _objectSpread$1({}, _persist, {
1688
- rehydrated: true
1689
- }) // @NOTE if key does not match, will continue to default else below
1690
-
1691
- });
1692
-
1693
- if (action.key === config.key) {
1694
- var reducedState = baseReducer(restState, action);
1695
- var inboundState = action.payload; // only reconcile state if stateReconciler and inboundState are both defined
1696
-
1697
- var reconciledRest = stateReconciler !== false && inboundState !== undefined ? stateReconciler(inboundState, state, reducedState, config) : reducedState;
1698
-
1699
- var _newState = _objectSpread$1({}, reconciledRest, {
1700
- _persist: _objectSpread$1({}, _persist, {
1701
- rehydrated: true
1702
- })
1703
- });
1704
-
1705
- return conditionalUpdate(_newState);
1706
- }
1707
- } // if we have not already handled PERSIST, straight passthrough
1708
-
1709
-
1710
- if (!_persist) return baseReducer(state, action); // run base reducer:
1711
- // is state modified ? return original : return updated
1712
-
1713
- var newState = baseReducer(restState, action);
1714
- if (newState === restState) return state;
1715
- return conditionalUpdate(_objectSpread$1({}, newState, {
1716
- _persist: _persist
1717
- }));
1718
- };
1719
- }
1720
-
1721
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1722
-
1723
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
1724
-
1725
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
1726
-
1727
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
1728
-
1729
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1730
-
1731
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1732
-
1733
- function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1734
- var initialState = {
1735
- registry: [],
1736
- bootstrapped: false
1737
- };
1738
-
1739
- var persistorReducer = function persistorReducer() {
1740
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
1741
- var action = arguments.length > 1 ? arguments[1] : undefined;
1742
-
1743
- switch (action.type) {
1744
- case REGISTER:
1745
- return _objectSpread({}, state, {
1746
- registry: [].concat(_toConsumableArray(state.registry), [action.key])
1747
- });
1748
-
1749
- case REHYDRATE:
1750
- var firstIndex = state.registry.indexOf(action.key);
1751
-
1752
- var registry = _toConsumableArray(state.registry);
1753
-
1754
- registry.splice(firstIndex, 1);
1755
- return _objectSpread({}, state, {
1756
- registry: registry,
1757
- bootstrapped: registry.length === 0
1758
- });
1759
-
1760
- default:
1761
- return state;
1762
- }
1763
- };
1764
-
1765
- function persistStore(store, options, cb) {
1766
- // help catch incorrect usage of passing PersistConfig in as PersistorOptions
1767
- if (process.env.NODE_ENV !== 'production') {
1768
- var optionsToTest = options || {};
1769
- var bannedKeys = ['blacklist', 'whitelist', 'transforms', 'storage', 'keyPrefix', 'migrate'];
1770
- bannedKeys.forEach(function (k) {
1771
- if (!!optionsToTest[k]) console.error("redux-persist: invalid option passed to persistStore: \"".concat(k, "\". You may be incorrectly passing persistConfig into persistStore, whereas it should be passed into persistReducer."));
1772
- });
1773
- }
1774
-
1775
- var boostrappedCb = cb || false;
1776
-
1777
- var _pStore = createStore(persistorReducer, initialState, options && options.enhancer ? options.enhancer : undefined);
1778
-
1779
- var register = function register(key) {
1780
- _pStore.dispatch({
1781
- type: REGISTER,
1782
- key: key
1783
- });
1784
- };
1785
-
1786
- var rehydrate = function rehydrate(key, payload, err) {
1787
- var rehydrateAction = {
1788
- type: REHYDRATE,
1789
- payload: payload,
1790
- err: err,
1791
- key: key // dispatch to `store` to rehydrate and `persistor` to track result
1792
-
1793
- };
1794
- store.dispatch(rehydrateAction);
1795
-
1796
- _pStore.dispatch(rehydrateAction);
1797
-
1798
- if (boostrappedCb && persistor.getState().bootstrapped) {
1799
- boostrappedCb();
1800
- boostrappedCb = false;
1801
- }
1802
- };
1803
-
1804
- var persistor = _objectSpread({}, _pStore, {
1805
- purge: function purge() {
1806
- var results = [];
1807
- store.dispatch({
1808
- type: PURGE,
1809
- result: function result(purgeResult) {
1810
- results.push(purgeResult);
1811
- }
1812
- });
1813
- return Promise.all(results);
1814
- },
1815
- flush: function flush() {
1816
- var results = [];
1817
- store.dispatch({
1818
- type: FLUSH,
1819
- result: function result(flushResult) {
1820
- results.push(flushResult);
1821
- }
1822
- });
1823
- return Promise.all(results);
1824
- },
1825
- pause: function pause() {
1826
- store.dispatch({
1827
- type: PAUSE
1828
- });
1829
- },
1830
- persist: function persist() {
1831
- store.dispatch({
1832
- type: PERSIST,
1833
- register: register,
1834
- rehydrate: rehydrate
1835
- });
1836
- }
1837
- });
1838
-
1839
- if (!(options && options.manualPersist)) {
1840
- persistor.persist();
1841
- }
1842
-
1843
- return persistor;
1844
- }
1845
-
1846
- var shim = {exports: {}};
1847
-
1848
- var useSyncExternalStoreShim_production_min = {};
1849
-
1850
- /**
1851
- * @license React
1852
- * use-sync-external-store-shim.production.min.js
1853
- *
1854
- * Copyright (c) Facebook, Inc. and its affiliates.
1855
- *
1856
- * This source code is licensed under the MIT license found in the
1857
- * LICENSE file in the root directory of this source tree.
1858
- */
1859
-
1860
- var hasRequiredUseSyncExternalStoreShim_production_min;
1861
-
1862
- function requireUseSyncExternalStoreShim_production_min () {
1863
- if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
1864
- hasRequiredUseSyncExternalStoreShim_production_min = 1;
1865
- var e=React__default["default"];function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
1866
- function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
1867
- return useSyncExternalStoreShim_production_min;
1868
- }
1869
-
1870
- var useSyncExternalStoreShim_development = {};
1871
-
1872
- /**
1873
- * @license React
1874
- * use-sync-external-store-shim.development.js
1875
- *
1876
- * Copyright (c) Facebook, Inc. and its affiliates.
1877
- *
1878
- * This source code is licensed under the MIT license found in the
1879
- * LICENSE file in the root directory of this source tree.
1880
- */
1881
-
1882
- var hasRequiredUseSyncExternalStoreShim_development;
1883
-
1884
- function requireUseSyncExternalStoreShim_development () {
1885
- if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
1886
- hasRequiredUseSyncExternalStoreShim_development = 1;
1887
-
1888
- if (process.env.NODE_ENV !== "production") {
1889
- (function() {
1890
-
1891
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
1892
- if (
1893
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
1894
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
1895
- 'function'
1896
- ) {
1897
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
1898
- }
1899
- var React = React__default["default"];
1900
-
1901
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1902
-
1903
- function error(format) {
1904
- {
1905
- {
1906
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1907
- args[_key2 - 1] = arguments[_key2];
1908
- }
1909
-
1910
- printWarning('error', format, args);
1911
- }
1912
- }
1913
- }
1914
-
1915
- function printWarning(level, format, args) {
1916
- // When changing this logic, you might want to also
1917
- // update consoleWithStackDev.www.js as well.
1918
- {
1919
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1920
- var stack = ReactDebugCurrentFrame.getStackAddendum();
1921
-
1922
- if (stack !== '') {
1923
- format += '%s';
1924
- args = args.concat([stack]);
1925
- } // eslint-disable-next-line react-internal/safe-string-coercion
1926
-
1927
-
1928
- var argsWithFormat = args.map(function (item) {
1929
- return String(item);
1930
- }); // Careful: RN currently depends on this prefix
1931
-
1932
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
1933
- // breaks IE9: https://github.com/facebook/react/issues/13610
1934
- // eslint-disable-next-line react-internal/no-production-logging
1935
-
1936
- Function.prototype.apply.call(console[level], console, argsWithFormat);
1937
- }
1938
- }
1939
-
1940
- /**
1941
- * inlined Object.is polyfill to avoid requiring consumers ship their own
1942
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1943
- */
1944
- function is(x, y) {
1945
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
1946
- ;
1947
- }
1948
-
1949
- var objectIs = typeof Object.is === 'function' ? Object.is : is;
1950
-
1951
- // dispatch for CommonJS interop named imports.
1952
-
1953
- var useState = React.useState,
1954
- useEffect = React.useEffect,
1955
- useLayoutEffect = React.useLayoutEffect,
1956
- useDebugValue = React.useDebugValue;
1957
- var didWarnOld18Alpha = false;
1958
- var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
1959
- // because of a very particular set of implementation details and assumptions
1960
- // -- change any one of them and it will break. The most important assumption
1961
- // is that updates are always synchronous, because concurrent rendering is
1962
- // only available in versions of React that also have a built-in
1963
- // useSyncExternalStore API. And we only use this shim when the built-in API
1964
- // does not exist.
1965
- //
1966
- // Do not assume that the clever hacks used by this hook also work in general.
1967
- // The point of this shim is to replace the need for hacks by other libraries.
1968
-
1969
- function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
1970
- // React do not expose a way to check if we're hydrating. So users of the shim
1971
- // will need to track that themselves and return the correct value
1972
- // from `getSnapshot`.
1973
- getServerSnapshot) {
1974
- {
1975
- if (!didWarnOld18Alpha) {
1976
- if (React.startTransition !== undefined) {
1977
- didWarnOld18Alpha = true;
1978
-
1979
- error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
1980
- }
1981
- }
1982
- } // Read the current snapshot from the store on every render. Again, this
1983
- // breaks the rules of React, and only works here because of specific
1984
- // implementation details, most importantly that updates are
1985
- // always synchronous.
1986
-
1987
-
1988
- var value = getSnapshot();
1989
-
1990
- {
1991
- if (!didWarnUncachedGetSnapshot) {
1992
- var cachedValue = getSnapshot();
1993
-
1994
- if (!objectIs(value, cachedValue)) {
1995
- error('The result of getSnapshot should be cached to avoid an infinite loop');
1996
-
1997
- didWarnUncachedGetSnapshot = true;
1998
- }
1999
- }
2000
- } // Because updates are synchronous, we don't queue them. Instead we force a
2001
- // re-render whenever the subscribed state changes by updating an some
2002
- // arbitrary useState hook. Then, during render, we call getSnapshot to read
2003
- // the current value.
2004
- //
2005
- // Because we don't actually use the state returned by the useState hook, we
2006
- // can save a bit of memory by storing other stuff in that slot.
2007
- //
2008
- // To implement the early bailout, we need to track some things on a mutable
2009
- // object. Usually, we would put that in a useRef hook, but we can stash it in
2010
- // our useState hook instead.
2011
- //
2012
- // To force a re-render, we call forceUpdate({inst}). That works because the
2013
- // new object always fails an equality check.
2014
-
2015
-
2016
- var _useState = useState({
2017
- inst: {
2018
- value: value,
2019
- getSnapshot: getSnapshot
2020
- }
2021
- }),
2022
- inst = _useState[0].inst,
2023
- forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
2024
- // in the layout phase so we can access it during the tearing check that
2025
- // happens on subscribe.
2026
-
2027
-
2028
- useLayoutEffect(function () {
2029
- inst.value = value;
2030
- inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
2031
- // commit phase if there was an interleaved mutation. In concurrent mode
2032
- // this can happen all the time, but even in synchronous mode, an earlier
2033
- // effect may have mutated the store.
2034
-
2035
- if (checkIfSnapshotChanged(inst)) {
2036
- // Force a re-render.
2037
- forceUpdate({
2038
- inst: inst
2039
- });
2040
- }
2041
- }, [subscribe, value, getSnapshot]);
2042
- useEffect(function () {
2043
- // Check for changes right before subscribing. Subsequent changes will be
2044
- // detected in the subscription handler.
2045
- if (checkIfSnapshotChanged(inst)) {
2046
- // Force a re-render.
2047
- forceUpdate({
2048
- inst: inst
2049
- });
2050
- }
2051
-
2052
- var handleStoreChange = function () {
2053
- // TODO: Because there is no cross-renderer API for batching updates, it's
2054
- // up to the consumer of this library to wrap their subscription event
2055
- // with unstable_batchedUpdates. Should we try to detect when this isn't
2056
- // the case and print a warning in development?
2057
- // The store changed. Check if the snapshot changed since the last time we
2058
- // read from the store.
2059
- if (checkIfSnapshotChanged(inst)) {
2060
- // Force a re-render.
2061
- forceUpdate({
2062
- inst: inst
2063
- });
2064
- }
2065
- }; // Subscribe to the store and return a clean-up function.
2066
-
2067
-
2068
- return subscribe(handleStoreChange);
2069
- }, [subscribe]);
2070
- useDebugValue(value);
2071
- return value;
2072
- }
2073
-
2074
- function checkIfSnapshotChanged(inst) {
2075
- var latestGetSnapshot = inst.getSnapshot;
2076
- var prevValue = inst.value;
2077
-
2078
- try {
2079
- var nextValue = latestGetSnapshot();
2080
- return !objectIs(prevValue, nextValue);
2081
- } catch (error) {
2082
- return true;
2083
- }
2084
- }
2085
-
2086
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
2087
- // Note: The shim does not use getServerSnapshot, because pre-18 versions of
2088
- // React do not expose a way to check if we're hydrating. So users of the shim
2089
- // will need to track that themselves and return the correct value
2090
- // from `getSnapshot`.
2091
- return getSnapshot();
2092
- }
2093
-
2094
- var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
2095
-
2096
- var isServerEnvironment = !canUseDOM;
2097
-
2098
- var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
2099
- var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
2100
-
2101
- useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
2102
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
2103
- if (
2104
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
2105
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
2106
- 'function'
2107
- ) {
2108
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
2109
- }
2110
-
2111
- })();
2112
- }
2113
- return useSyncExternalStoreShim_development;
2114
- }
2115
-
2116
- (function (module) {
2117
-
2118
- if (process.env.NODE_ENV === 'production') {
2119
- module.exports = requireUseSyncExternalStoreShim_production_min();
2120
- } else {
2121
- module.exports = requireUseSyncExternalStoreShim_development();
2122
- }
2123
- } (shim));
2124
-
2125
- var withSelector = {exports: {}};
2126
-
2127
- var withSelector_production_min = {};
2128
-
2129
- /**
2130
- * @license React
2131
- * use-sync-external-store-shim/with-selector.production.min.js
2132
- *
2133
- * Copyright (c) Facebook, Inc. and its affiliates.
2134
- *
2135
- * This source code is licensed under the MIT license found in the
2136
- * LICENSE file in the root directory of this source tree.
2137
- */
2138
-
2139
- var hasRequiredWithSelector_production_min;
2140
-
2141
- function requireWithSelector_production_min () {
2142
- if (hasRequiredWithSelector_production_min) return withSelector_production_min;
2143
- hasRequiredWithSelector_production_min = 1;
2144
- var h=React__default["default"],n=shim.exports;function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
2145
- withSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
2146
- u(function(){f.hasValue=!0;f.value=d;},[d]);w(d);return d};
2147
- return withSelector_production_min;
2148
- }
2149
-
2150
- var withSelector_development = {};
2151
-
2152
- /**
2153
- * @license React
2154
- * use-sync-external-store-shim/with-selector.development.js
2155
- *
2156
- * Copyright (c) Facebook, Inc. and its affiliates.
2157
- *
2158
- * This source code is licensed under the MIT license found in the
2159
- * LICENSE file in the root directory of this source tree.
2160
- */
2161
-
2162
- var hasRequiredWithSelector_development;
2163
-
2164
- function requireWithSelector_development () {
2165
- if (hasRequiredWithSelector_development) return withSelector_development;
2166
- hasRequiredWithSelector_development = 1;
2167
-
2168
- if (process.env.NODE_ENV !== "production") {
2169
- (function() {
2170
-
2171
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
2172
- if (
2173
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
2174
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
2175
- 'function'
2176
- ) {
2177
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2178
- }
2179
- var React = React__default["default"];
2180
- var shim$1 = shim.exports;
2181
-
2182
- /**
2183
- * inlined Object.is polyfill to avoid requiring consumers ship their own
2184
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
2185
- */
2186
- function is(x, y) {
2187
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
2188
- ;
2189
- }
2190
-
2191
- var objectIs = typeof Object.is === 'function' ? Object.is : is;
2192
-
2193
- var useSyncExternalStore = shim$1.useSyncExternalStore;
2194
-
2195
- // for CommonJS interop.
2196
-
2197
- var useRef = React.useRef,
2198
- useEffect = React.useEffect,
2199
- useMemo = React.useMemo,
2200
- useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
2201
-
2202
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
2203
- // Use this to track the rendered snapshot.
2204
- var instRef = useRef(null);
2205
- var inst;
2206
-
2207
- if (instRef.current === null) {
2208
- inst = {
2209
- hasValue: false,
2210
- value: null
2211
- };
2212
- instRef.current = inst;
2213
- } else {
2214
- inst = instRef.current;
2215
- }
2216
-
2217
- var _useMemo = useMemo(function () {
2218
- // Track the memoized state using closure variables that are local to this
2219
- // memoized instance of a getSnapshot function. Intentionally not using a
2220
- // useRef hook, because that state would be shared across all concurrent
2221
- // copies of the hook/component.
2222
- var hasMemo = false;
2223
- var memoizedSnapshot;
2224
- var memoizedSelection;
2225
-
2226
- var memoizedSelector = function (nextSnapshot) {
2227
- if (!hasMemo) {
2228
- // The first time the hook is called, there is no memoized result.
2229
- hasMemo = true;
2230
- memoizedSnapshot = nextSnapshot;
2231
-
2232
- var _nextSelection = selector(nextSnapshot);
2233
-
2234
- if (isEqual !== undefined) {
2235
- // Even if the selector has changed, the currently rendered selection
2236
- // may be equal to the new selection. We should attempt to reuse the
2237
- // current value if possible, to preserve downstream memoizations.
2238
- if (inst.hasValue) {
2239
- var currentSelection = inst.value;
2240
-
2241
- if (isEqual(currentSelection, _nextSelection)) {
2242
- memoizedSelection = currentSelection;
2243
- return currentSelection;
2244
- }
2245
- }
2246
- }
2247
-
2248
- memoizedSelection = _nextSelection;
2249
- return _nextSelection;
2250
- } // We may be able to reuse the previous invocation's result.
2251
-
2252
-
2253
- // We may be able to reuse the previous invocation's result.
2254
- var prevSnapshot = memoizedSnapshot;
2255
- var prevSelection = memoizedSelection;
2256
-
2257
- if (objectIs(prevSnapshot, nextSnapshot)) {
2258
- // The snapshot is the same as last time. Reuse the previous selection.
2259
- return prevSelection;
2260
- } // The snapshot has changed, so we need to compute a new selection.
2261
-
2262
-
2263
- // The snapshot has changed, so we need to compute a new selection.
2264
- var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
2265
- // has changed. If it hasn't, return the previous selection. That signals
2266
- // to React that the selections are conceptually equal, and we can bail
2267
- // out of rendering.
2268
-
2269
- // If a custom isEqual function is provided, use that to check if the data
2270
- // has changed. If it hasn't, return the previous selection. That signals
2271
- // to React that the selections are conceptually equal, and we can bail
2272
- // out of rendering.
2273
- if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
2274
- return prevSelection;
2275
- }
2276
-
2277
- memoizedSnapshot = nextSnapshot;
2278
- memoizedSelection = nextSelection;
2279
- return nextSelection;
2280
- }; // Assigning this to a constant so that Flow knows it can't change.
2281
-
2282
-
2283
- // Assigning this to a constant so that Flow knows it can't change.
2284
- var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
2285
-
2286
- var getSnapshotWithSelector = function () {
2287
- return memoizedSelector(getSnapshot());
2288
- };
2289
-
2290
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
2291
- return memoizedSelector(maybeGetServerSnapshot());
2292
- };
2293
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
2294
- }, [getSnapshot, getServerSnapshot, selector, isEqual]),
2295
- getSelection = _useMemo[0],
2296
- getServerSelection = _useMemo[1];
2297
-
2298
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
2299
- useEffect(function () {
2300
- inst.hasValue = true;
2301
- inst.value = value;
2302
- }, [value]);
2303
- useDebugValue(value);
2304
- return value;
2305
- }
2306
-
2307
- withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
2308
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
2309
- if (
2310
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
2311
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
2312
- 'function'
2313
- ) {
2314
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
2315
- }
2316
-
2317
- })();
2318
- }
2319
- return withSelector_development;
2320
- }
2321
-
2322
- (function (module) {
2323
-
2324
- if (process.env.NODE_ENV === 'production') {
2325
- module.exports = requireWithSelector_production_min();
2326
- } else {
2327
- module.exports = requireWithSelector_development();
2328
- }
2329
- } (withSelector));
2330
-
2331
- // Default to a dummy "batch" implementation that just runs the callback
2332
- function defaultNoopBatch(callback) {
2333
- callback();
2334
- }
2335
-
2336
- let batch = defaultNoopBatch; // Allow injecting another batching function later
2337
-
2338
- const setBatch = newBatch => batch = newBatch; // Supply a getter just to skip dealing with ESM bindings
2339
-
2340
- const getBatch = () => batch;
2341
-
2342
- const ReactReduxContext = /*#__PURE__*/React.createContext(null);
2343
-
2344
- if (process.env.NODE_ENV !== 'production') {
2345
- ReactReduxContext.displayName = 'ReactRedux';
2346
- }
2347
-
2348
- /**
2349
- * A hook to access the value of the `ReactReduxContext`. This is a low-level
2350
- * hook that you should usually not need to call directly.
2351
- *
2352
- * @returns {any} the value of the `ReactReduxContext`
2353
- *
2354
- * @example
2355
- *
2356
- * import React from 'react'
2357
- * import { useReduxContext } from 'react-redux'
2358
- *
2359
- * export const CounterComponent = () => {
2360
- * const { store } = useReduxContext()
2361
- * return <div>{store.getState()}</div>
2362
- * }
2363
- */
2364
- function useReduxContext() {
2365
- const contextValue = React.useContext(ReactReduxContext);
2366
-
2367
- if (process.env.NODE_ENV !== 'production' && !contextValue) {
2368
- throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
2369
- }
2370
-
2371
- return contextValue;
2372
- }
2373
-
2374
- const notInitialized = () => {
2375
- throw new Error('uSES not initialized!');
2376
- };
2377
-
2378
- let useSyncExternalStoreWithSelector = notInitialized;
2379
- const initializeUseSelector = fn => {
2380
- useSyncExternalStoreWithSelector = fn;
2381
- };
2382
-
2383
- const refEquality = (a, b) => a === b;
2384
- /**
2385
- * Hook factory, which creates a `useSelector` hook bound to a given context.
2386
- *
2387
- * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
2388
- * @returns {Function} A `useSelector` hook bound to the specified context.
2389
- */
2390
-
2391
-
2392
- function createSelectorHook(context = ReactReduxContext) {
2393
- const useReduxContext$1 = context === ReactReduxContext ? useReduxContext : () => React.useContext(context);
2394
- return function useSelector(selector, equalityFn = refEquality) {
2395
- if (process.env.NODE_ENV !== 'production') {
2396
- if (!selector) {
2397
- throw new Error(`You must pass a selector to useSelector`);
2398
- }
2399
-
2400
- if (typeof selector !== 'function') {
2401
- throw new Error(`You must pass a function as a selector to useSelector`);
2402
- }
2403
-
2404
- if (typeof equalityFn !== 'function') {
2405
- throw new Error(`You must pass a function as an equality function to useSelector`);
2406
- }
2407
- }
2408
-
2409
- const {
2410
- store,
2411
- subscription,
2412
- getServerState
2413
- } = useReduxContext$1();
2414
- const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, selector, equalityFn);
2415
- React.useDebugValue(selectedState);
2416
- return selectedState;
2417
- };
2418
- }
2419
- /**
2420
- * A hook to access the redux store's state. This hook takes a selector function
2421
- * as an argument. The selector is called with the store state.
2422
- *
2423
- * This hook takes an optional equality comparison function as the second parameter
2424
- * that allows you to customize the way the selected state is compared to determine
2425
- * whether the component needs to be re-rendered.
2426
- *
2427
- * @param {Function} selector the selector function
2428
- * @param {Function=} equalityFn the function that will be used to determine equality
2429
- *
2430
- * @returns {any} the selected state
2431
- *
2432
- * @example
2433
- *
2434
- * import React from 'react'
2435
- * import { useSelector } from 'react-redux'
2436
- *
2437
- * export const CounterComponent = () => {
2438
- * const counter = useSelector(state => state.counter)
2439
- * return <div>{counter}</div>
2440
- * }
2441
- */
2442
-
2443
- const useSelector = /*#__PURE__*/createSelectorHook();
2444
-
2445
- var reactIs$2 = {exports: {}};
2446
-
2447
- var reactIs_production_min$1 = {};
2448
-
2449
- /** @license React v16.13.1
2450
- * react-is.production.min.js
2451
- *
2452
- * Copyright (c) Facebook, Inc. and its affiliates.
2453
- *
2454
- * This source code is licensed under the MIT license found in the
2455
- * LICENSE file in the root directory of this source tree.
2456
- */
2457
-
2458
- var hasRequiredReactIs_production_min$1;
2459
-
2460
- function requireReactIs_production_min$1 () {
2461
- if (hasRequiredReactIs_production_min$1) return reactIs_production_min$1;
2462
- hasRequiredReactIs_production_min$1 = 1;
2463
- var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
2464
- Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
2465
- function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min$1.AsyncMode=l;reactIs_production_min$1.ConcurrentMode=m;reactIs_production_min$1.ContextConsumer=k;reactIs_production_min$1.ContextProvider=h;reactIs_production_min$1.Element=c;reactIs_production_min$1.ForwardRef=n;reactIs_production_min$1.Fragment=e;reactIs_production_min$1.Lazy=t;reactIs_production_min$1.Memo=r;reactIs_production_min$1.Portal=d;
2466
- reactIs_production_min$1.Profiler=g;reactIs_production_min$1.StrictMode=f;reactIs_production_min$1.Suspense=p;reactIs_production_min$1.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min$1.isConcurrentMode=A;reactIs_production_min$1.isContextConsumer=function(a){return z(a)===k};reactIs_production_min$1.isContextProvider=function(a){return z(a)===h};reactIs_production_min$1.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min$1.isForwardRef=function(a){return z(a)===n};reactIs_production_min$1.isFragment=function(a){return z(a)===e};reactIs_production_min$1.isLazy=function(a){return z(a)===t};
2467
- reactIs_production_min$1.isMemo=function(a){return z(a)===r};reactIs_production_min$1.isPortal=function(a){return z(a)===d};reactIs_production_min$1.isProfiler=function(a){return z(a)===g};reactIs_production_min$1.isStrictMode=function(a){return z(a)===f};reactIs_production_min$1.isSuspense=function(a){return z(a)===p};
2468
- reactIs_production_min$1.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min$1.typeOf=z;
2469
- return reactIs_production_min$1;
2470
- }
2471
-
2472
- var reactIs_development$1 = {};
2473
-
2474
- /** @license React v16.13.1
2475
- * react-is.development.js
2476
- *
2477
- * Copyright (c) Facebook, Inc. and its affiliates.
2478
- *
2479
- * This source code is licensed under the MIT license found in the
2480
- * LICENSE file in the root directory of this source tree.
2481
- */
2482
-
2483
- var hasRequiredReactIs_development$1;
2484
-
2485
- function requireReactIs_development$1 () {
2486
- if (hasRequiredReactIs_development$1) return reactIs_development$1;
2487
- hasRequiredReactIs_development$1 = 1;
2488
-
2489
-
2490
-
2491
- if (process.env.NODE_ENV !== "production") {
2492
- (function() {
2493
-
2494
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
2495
- // nor polyfill, then a plain number is used for performance.
2496
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
2497
- var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
2498
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
2499
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
2500
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
2501
- var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
2502
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
2503
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
2504
- // (unstable) APIs that have been removed. Can we remove the symbols?
2505
-
2506
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
2507
- var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
2508
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
2509
- var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
2510
- var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
2511
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
2512
- var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
2513
- var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
2514
- var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
2515
- var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
2516
- var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
2517
-
2518
- function isValidElementType(type) {
2519
- return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2520
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
2521
- }
2522
-
2523
- function typeOf(object) {
2524
- if (typeof object === 'object' && object !== null) {
2525
- var $$typeof = object.$$typeof;
2526
-
2527
- switch ($$typeof) {
2528
- case REACT_ELEMENT_TYPE:
2529
- var type = object.type;
2530
-
2531
- switch (type) {
2532
- case REACT_ASYNC_MODE_TYPE:
2533
- case REACT_CONCURRENT_MODE_TYPE:
2534
- case REACT_FRAGMENT_TYPE:
2535
- case REACT_PROFILER_TYPE:
2536
- case REACT_STRICT_MODE_TYPE:
2537
- case REACT_SUSPENSE_TYPE:
2538
- return type;
2539
-
2540
- default:
2541
- var $$typeofType = type && type.$$typeof;
2542
-
2543
- switch ($$typeofType) {
2544
- case REACT_CONTEXT_TYPE:
2545
- case REACT_FORWARD_REF_TYPE:
2546
- case REACT_LAZY_TYPE:
2547
- case REACT_MEMO_TYPE:
2548
- case REACT_PROVIDER_TYPE:
2549
- return $$typeofType;
2550
-
2551
- default:
2552
- return $$typeof;
2553
- }
2554
-
2555
- }
2556
-
2557
- case REACT_PORTAL_TYPE:
2558
- return $$typeof;
2559
- }
2560
- }
2561
-
2562
- return undefined;
2563
- } // AsyncMode is deprecated along with isAsyncMode
2564
-
2565
- var AsyncMode = REACT_ASYNC_MODE_TYPE;
2566
- var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
2567
- var ContextConsumer = REACT_CONTEXT_TYPE;
2568
- var ContextProvider = REACT_PROVIDER_TYPE;
2569
- var Element = REACT_ELEMENT_TYPE;
2570
- var ForwardRef = REACT_FORWARD_REF_TYPE;
2571
- var Fragment = REACT_FRAGMENT_TYPE;
2572
- var Lazy = REACT_LAZY_TYPE;
2573
- var Memo = REACT_MEMO_TYPE;
2574
- var Portal = REACT_PORTAL_TYPE;
2575
- var Profiler = REACT_PROFILER_TYPE;
2576
- var StrictMode = REACT_STRICT_MODE_TYPE;
2577
- var Suspense = REACT_SUSPENSE_TYPE;
2578
- var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
2579
-
2580
- function isAsyncMode(object) {
2581
- {
2582
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
2583
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
2584
-
2585
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
2586
- }
2587
- }
2588
-
2589
- return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
2590
- }
2591
- function isConcurrentMode(object) {
2592
- return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
2593
- }
2594
- function isContextConsumer(object) {
2595
- return typeOf(object) === REACT_CONTEXT_TYPE;
2596
- }
2597
- function isContextProvider(object) {
2598
- return typeOf(object) === REACT_PROVIDER_TYPE;
2599
- }
2600
- function isElement(object) {
2601
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2602
- }
2603
- function isForwardRef(object) {
2604
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
2605
- }
2606
- function isFragment(object) {
2607
- return typeOf(object) === REACT_FRAGMENT_TYPE;
2608
- }
2609
- function isLazy(object) {
2610
- return typeOf(object) === REACT_LAZY_TYPE;
2611
- }
2612
- function isMemo(object) {
2613
- return typeOf(object) === REACT_MEMO_TYPE;
2614
- }
2615
- function isPortal(object) {
2616
- return typeOf(object) === REACT_PORTAL_TYPE;
2617
- }
2618
- function isProfiler(object) {
2619
- return typeOf(object) === REACT_PROFILER_TYPE;
2620
- }
2621
- function isStrictMode(object) {
2622
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
2623
- }
2624
- function isSuspense(object) {
2625
- return typeOf(object) === REACT_SUSPENSE_TYPE;
2626
- }
2627
-
2628
- reactIs_development$1.AsyncMode = AsyncMode;
2629
- reactIs_development$1.ConcurrentMode = ConcurrentMode;
2630
- reactIs_development$1.ContextConsumer = ContextConsumer;
2631
- reactIs_development$1.ContextProvider = ContextProvider;
2632
- reactIs_development$1.Element = Element;
2633
- reactIs_development$1.ForwardRef = ForwardRef;
2634
- reactIs_development$1.Fragment = Fragment;
2635
- reactIs_development$1.Lazy = Lazy;
2636
- reactIs_development$1.Memo = Memo;
2637
- reactIs_development$1.Portal = Portal;
2638
- reactIs_development$1.Profiler = Profiler;
2639
- reactIs_development$1.StrictMode = StrictMode;
2640
- reactIs_development$1.Suspense = Suspense;
2641
- reactIs_development$1.isAsyncMode = isAsyncMode;
2642
- reactIs_development$1.isConcurrentMode = isConcurrentMode;
2643
- reactIs_development$1.isContextConsumer = isContextConsumer;
2644
- reactIs_development$1.isContextProvider = isContextProvider;
2645
- reactIs_development$1.isElement = isElement;
2646
- reactIs_development$1.isForwardRef = isForwardRef;
2647
- reactIs_development$1.isFragment = isFragment;
2648
- reactIs_development$1.isLazy = isLazy;
2649
- reactIs_development$1.isMemo = isMemo;
2650
- reactIs_development$1.isPortal = isPortal;
2651
- reactIs_development$1.isProfiler = isProfiler;
2652
- reactIs_development$1.isStrictMode = isStrictMode;
2653
- reactIs_development$1.isSuspense = isSuspense;
2654
- reactIs_development$1.isValidElementType = isValidElementType;
2655
- reactIs_development$1.typeOf = typeOf;
2656
- })();
2657
- }
2658
- return reactIs_development$1;
2659
- }
2660
-
2661
- (function (module) {
2662
-
2663
- if (process.env.NODE_ENV === 'production') {
2664
- module.exports = requireReactIs_production_min$1();
2665
- } else {
2666
- module.exports = requireReactIs_development$1();
2667
- }
2668
- } (reactIs$2));
2669
-
2670
- var reactIs$1 = reactIs$2.exports;
2671
- var FORWARD_REF_STATICS = {
2672
- '$$typeof': true,
2673
- render: true,
2674
- defaultProps: true,
2675
- displayName: true,
2676
- propTypes: true
2677
- };
2678
- var MEMO_STATICS = {
2679
- '$$typeof': true,
2680
- compare: true,
2681
- defaultProps: true,
2682
- displayName: true,
2683
- propTypes: true,
2684
- type: true
2685
- };
2686
- var TYPE_STATICS = {};
2687
- TYPE_STATICS[reactIs$1.ForwardRef] = FORWARD_REF_STATICS;
2688
- TYPE_STATICS[reactIs$1.Memo] = MEMO_STATICS;
2689
-
2690
- var reactIs = {exports: {}};
2691
-
2692
- var reactIs_production_min = {};
2693
-
2694
- /**
2695
- * @license React
2696
- * react-is.production.min.js
2697
- *
2698
- * Copyright (c) Facebook, Inc. and its affiliates.
2699
- *
2700
- * This source code is licensed under the MIT license found in the
2701
- * LICENSE file in the root directory of this source tree.
2702
- */
2703
-
2704
- var hasRequiredReactIs_production_min;
2705
-
2706
- function requireReactIs_production_min () {
2707
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
2708
- hasRequiredReactIs_production_min = 1;
2709
- var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");
2710
- function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=g;reactIs_production_min.Element=b;reactIs_production_min.ForwardRef=l;reactIs_production_min.Fragment=d;reactIs_production_min.Lazy=q;reactIs_production_min.Memo=p;reactIs_production_min.Portal=c;reactIs_production_min.Profiler=f;reactIs_production_min.StrictMode=e;reactIs_production_min.Suspense=m;
2711
- reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return v(a)===h};reactIs_production_min.isContextProvider=function(a){return v(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return v(a)===l};reactIs_production_min.isFragment=function(a){return v(a)===d};reactIs_production_min.isLazy=function(a){return v(a)===q};reactIs_production_min.isMemo=function(a){return v(a)===p};
2712
- reactIs_production_min.isPortal=function(a){return v(a)===c};reactIs_production_min.isProfiler=function(a){return v(a)===f};reactIs_production_min.isStrictMode=function(a){return v(a)===e};reactIs_production_min.isSuspense=function(a){return v(a)===m};reactIs_production_min.isSuspenseList=function(a){return v(a)===n};
2713
- reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};reactIs_production_min.typeOf=v;
2714
- return reactIs_production_min;
2715
- }
2716
-
2717
- var reactIs_development = {};
2718
-
2719
- /**
2720
- * @license React
2721
- * react-is.development.js
2722
- *
2723
- * Copyright (c) Facebook, Inc. and its affiliates.
2724
- *
2725
- * This source code is licensed under the MIT license found in the
2726
- * LICENSE file in the root directory of this source tree.
2727
- */
2728
-
2729
- var hasRequiredReactIs_development;
2730
-
2731
- function requireReactIs_development () {
2732
- if (hasRequiredReactIs_development) return reactIs_development;
2733
- hasRequiredReactIs_development = 1;
2734
-
2735
- if (process.env.NODE_ENV !== "production") {
2736
- (function() {
2737
-
2738
- // ATTENTION
2739
- // When adding new symbols to this file,
2740
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
2741
- // The Symbol used to tag the ReactElement-like types.
2742
- var REACT_ELEMENT_TYPE = Symbol.for('react.element');
2743
- var REACT_PORTAL_TYPE = Symbol.for('react.portal');
2744
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
2745
- var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
2746
- var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
2747
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
2748
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
2749
- var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
2750
- var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
2751
- var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
2752
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
2753
- var REACT_MEMO_TYPE = Symbol.for('react.memo');
2754
- var REACT_LAZY_TYPE = Symbol.for('react.lazy');
2755
- var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
2756
-
2757
- // -----------------------------------------------------------------------------
2758
-
2759
- var enableScopeAPI = false; // Experimental Create Event Handle API.
2760
- var enableCacheElement = false;
2761
- var enableTransitionTracing = false; // No known bugs, but needs performance testing
2762
-
2763
- var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
2764
- // stuff. Intended to enable React core members to more easily debug scheduling
2765
- // issues in DEV builds.
2766
-
2767
- var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
2768
-
2769
- var REACT_MODULE_REFERENCE;
2770
-
2771
- {
2772
- REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
2773
- }
2774
-
2775
- function isValidElementType(type) {
2776
- if (typeof type === 'string' || typeof type === 'function') {
2777
- return true;
2778
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
2779
-
2780
-
2781
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
2782
- return true;
2783
- }
2784
-
2785
- if (typeof type === 'object' && type !== null) {
2786
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
2787
- // types supported by any Flight configuration anywhere since
2788
- // we don't know which Flight build this will end up being used
2789
- // with.
2790
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
2791
- return true;
2792
- }
2793
- }
2794
-
2795
- return false;
2796
- }
2797
-
2798
- function typeOf(object) {
2799
- if (typeof object === 'object' && object !== null) {
2800
- var $$typeof = object.$$typeof;
2801
-
2802
- switch ($$typeof) {
2803
- case REACT_ELEMENT_TYPE:
2804
- var type = object.type;
2805
-
2806
- switch (type) {
2807
- case REACT_FRAGMENT_TYPE:
2808
- case REACT_PROFILER_TYPE:
2809
- case REACT_STRICT_MODE_TYPE:
2810
- case REACT_SUSPENSE_TYPE:
2811
- case REACT_SUSPENSE_LIST_TYPE:
2812
- return type;
2813
-
2814
- default:
2815
- var $$typeofType = type && type.$$typeof;
2816
-
2817
- switch ($$typeofType) {
2818
- case REACT_SERVER_CONTEXT_TYPE:
2819
- case REACT_CONTEXT_TYPE:
2820
- case REACT_FORWARD_REF_TYPE:
2821
- case REACT_LAZY_TYPE:
2822
- case REACT_MEMO_TYPE:
2823
- case REACT_PROVIDER_TYPE:
2824
- return $$typeofType;
2825
-
2826
- default:
2827
- return $$typeof;
2828
- }
2829
-
2830
- }
2831
-
2832
- case REACT_PORTAL_TYPE:
2833
- return $$typeof;
2834
- }
2835
- }
2836
-
2837
- return undefined;
2838
- }
2839
- var ContextConsumer = REACT_CONTEXT_TYPE;
2840
- var ContextProvider = REACT_PROVIDER_TYPE;
2841
- var Element = REACT_ELEMENT_TYPE;
2842
- var ForwardRef = REACT_FORWARD_REF_TYPE;
2843
- var Fragment = REACT_FRAGMENT_TYPE;
2844
- var Lazy = REACT_LAZY_TYPE;
2845
- var Memo = REACT_MEMO_TYPE;
2846
- var Portal = REACT_PORTAL_TYPE;
2847
- var Profiler = REACT_PROFILER_TYPE;
2848
- var StrictMode = REACT_STRICT_MODE_TYPE;
2849
- var Suspense = REACT_SUSPENSE_TYPE;
2850
- var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
2851
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
2852
- var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
2853
-
2854
- function isAsyncMode(object) {
2855
- {
2856
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
2857
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
2858
-
2859
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
2860
- }
2861
- }
2862
-
2863
- return false;
2864
- }
2865
- function isConcurrentMode(object) {
2866
- {
2867
- if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
2868
- hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
2869
-
2870
- console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
2871
- }
2872
- }
2873
-
2874
- return false;
2875
- }
2876
- function isContextConsumer(object) {
2877
- return typeOf(object) === REACT_CONTEXT_TYPE;
2878
- }
2879
- function isContextProvider(object) {
2880
- return typeOf(object) === REACT_PROVIDER_TYPE;
2881
- }
2882
- function isElement(object) {
2883
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2884
- }
2885
- function isForwardRef(object) {
2886
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
2887
- }
2888
- function isFragment(object) {
2889
- return typeOf(object) === REACT_FRAGMENT_TYPE;
2890
- }
2891
- function isLazy(object) {
2892
- return typeOf(object) === REACT_LAZY_TYPE;
2893
- }
2894
- function isMemo(object) {
2895
- return typeOf(object) === REACT_MEMO_TYPE;
2896
- }
2897
- function isPortal(object) {
2898
- return typeOf(object) === REACT_PORTAL_TYPE;
2899
- }
2900
- function isProfiler(object) {
2901
- return typeOf(object) === REACT_PROFILER_TYPE;
2902
- }
2903
- function isStrictMode(object) {
2904
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
2905
- }
2906
- function isSuspense(object) {
2907
- return typeOf(object) === REACT_SUSPENSE_TYPE;
2908
- }
2909
- function isSuspenseList(object) {
2910
- return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
2911
- }
2912
-
2913
- reactIs_development.ContextConsumer = ContextConsumer;
2914
- reactIs_development.ContextProvider = ContextProvider;
2915
- reactIs_development.Element = Element;
2916
- reactIs_development.ForwardRef = ForwardRef;
2917
- reactIs_development.Fragment = Fragment;
2918
- reactIs_development.Lazy = Lazy;
2919
- reactIs_development.Memo = Memo;
2920
- reactIs_development.Portal = Portal;
2921
- reactIs_development.Profiler = Profiler;
2922
- reactIs_development.StrictMode = StrictMode;
2923
- reactIs_development.Suspense = Suspense;
2924
- reactIs_development.SuspenseList = SuspenseList;
2925
- reactIs_development.isAsyncMode = isAsyncMode;
2926
- reactIs_development.isConcurrentMode = isConcurrentMode;
2927
- reactIs_development.isContextConsumer = isContextConsumer;
2928
- reactIs_development.isContextProvider = isContextProvider;
2929
- reactIs_development.isElement = isElement;
2930
- reactIs_development.isForwardRef = isForwardRef;
2931
- reactIs_development.isFragment = isFragment;
2932
- reactIs_development.isLazy = isLazy;
2933
- reactIs_development.isMemo = isMemo;
2934
- reactIs_development.isPortal = isPortal;
2935
- reactIs_development.isProfiler = isProfiler;
2936
- reactIs_development.isStrictMode = isStrictMode;
2937
- reactIs_development.isSuspense = isSuspense;
2938
- reactIs_development.isSuspenseList = isSuspenseList;
2939
- reactIs_development.isValidElementType = isValidElementType;
2940
- reactIs_development.typeOf = typeOf;
2941
- })();
2942
- }
2943
- return reactIs_development;
2944
- }
2945
-
2946
- (function (module) {
2947
-
2948
- if (process.env.NODE_ENV === 'production') {
2949
- module.exports = requireReactIs_production_min();
2950
- } else {
2951
- module.exports = requireReactIs_development();
2952
- }
2953
- } (reactIs));
2954
-
2955
- // well as nesting subscriptions of descendant components, so that we can ensure the
2956
- // ancestor components re-render before descendants
2957
-
2958
- function createListenerCollection() {
2959
- const batch = getBatch();
2960
- let first = null;
2961
- let last = null;
2962
- return {
2963
- clear() {
2964
- first = null;
2965
- last = null;
2966
- },
2967
-
2968
- notify() {
2969
- batch(() => {
2970
- let listener = first;
2971
-
2972
- while (listener) {
2973
- listener.callback();
2974
- listener = listener.next;
2975
- }
2976
- });
2977
- },
2978
-
2979
- get() {
2980
- let listeners = [];
2981
- let listener = first;
2982
-
2983
- while (listener) {
2984
- listeners.push(listener);
2985
- listener = listener.next;
2986
- }
2987
-
2988
- return listeners;
2989
- },
2990
-
2991
- subscribe(callback) {
2992
- let isSubscribed = true;
2993
- let listener = last = {
2994
- callback,
2995
- next: null,
2996
- prev: last
2997
- };
2998
-
2999
- if (listener.prev) {
3000
- listener.prev.next = listener;
3001
- } else {
3002
- first = listener;
3003
- }
3004
-
3005
- return function unsubscribe() {
3006
- if (!isSubscribed || first === null) return;
3007
- isSubscribed = false;
3008
-
3009
- if (listener.next) {
3010
- listener.next.prev = listener.prev;
3011
- } else {
3012
- last = listener.prev;
3013
- }
3014
-
3015
- if (listener.prev) {
3016
- listener.prev.next = listener.next;
3017
- } else {
3018
- first = listener.next;
3019
- }
3020
- };
3021
- }
3022
-
3023
- };
3024
- }
3025
-
3026
- const nullListeners = {
3027
- notify() {},
3028
-
3029
- get: () => []
3030
- };
3031
- function createSubscription(store, parentSub) {
3032
- let unsubscribe;
3033
- let listeners = nullListeners;
3034
-
3035
- function addNestedSub(listener) {
3036
- trySubscribe();
3037
- return listeners.subscribe(listener);
3038
- }
3039
-
3040
- function notifyNestedSubs() {
3041
- listeners.notify();
3042
- }
3043
-
3044
- function handleChangeWrapper() {
3045
- if (subscription.onStateChange) {
3046
- subscription.onStateChange();
3047
- }
3048
- }
3049
-
3050
- function isSubscribed() {
3051
- return Boolean(unsubscribe);
3052
- }
3053
-
3054
- function trySubscribe() {
3055
- if (!unsubscribe) {
3056
- unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
3057
- listeners = createListenerCollection();
3058
- }
3059
- }
3060
-
3061
- function tryUnsubscribe() {
3062
- if (unsubscribe) {
3063
- unsubscribe();
3064
- unsubscribe = undefined;
3065
- listeners.clear();
3066
- listeners = nullListeners;
3067
- }
3068
- }
3069
-
3070
- const subscription = {
3071
- addNestedSub,
3072
- notifyNestedSubs,
3073
- handleChangeWrapper,
3074
- isSubscribed,
3075
- trySubscribe,
3076
- tryUnsubscribe,
3077
- getListeners: () => listeners
3078
- };
3079
- return subscription;
3080
- }
3081
-
3082
- // To get around it, we can conditionally useEffect on the server (no-op) and
3083
- // useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
3084
- // subscription callback always has the selector from the latest render commit
3085
- // available, otherwise a store update may happen between render and the effect,
3086
- // which may cause missed updates; we also must ensure the store subscription
3087
- // is created synchronously, otherwise a store update may occur before the
3088
- // subscription is created and an inconsistent state may be observed
3089
- // Matches logic in React's `shared/ExecutionEnvironment` file
3090
-
3091
- const canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
3092
- const useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;
3093
-
3094
- function Provider({
3095
- store,
3096
- context,
3097
- children,
3098
- serverState
3099
- }) {
3100
- const contextValue = React.useMemo(() => {
3101
- const subscription = createSubscription(store);
3102
- return {
3103
- store,
3104
- subscription,
3105
- getServerState: serverState ? () => serverState : undefined
3106
- };
3107
- }, [store, serverState]);
3108
- const previousState = React.useMemo(() => store.getState(), [store]);
3109
- useIsomorphicLayoutEffect(() => {
3110
- const {
3111
- subscription
3112
- } = contextValue;
3113
- subscription.onStateChange = subscription.notifyNestedSubs;
3114
- subscription.trySubscribe();
3115
-
3116
- if (previousState !== store.getState()) {
3117
- subscription.notifyNestedSubs();
3118
- }
3119
-
3120
- return () => {
3121
- subscription.tryUnsubscribe();
3122
- subscription.onStateChange = undefined;
3123
- };
3124
- }, [contextValue, previousState]);
3125
- const Context = context || ReactReduxContext; // @ts-ignore 'AnyAction' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype
3126
-
3127
- return /*#__PURE__*/React__default["default"].createElement(Context.Provider, {
3128
- value: contextValue
3129
- }, children);
3130
- }
3131
-
3132
- // The primary entry point assumes we're working with standard ReactDOM/RN, but
3133
- initializeUseSelector(withSelector.exports.useSyncExternalStoreWithSelector);
3134
- // with standard React renderers (ReactDOM, React Native)
3135
-
3136
- setBatch(reactDom.unstable_batchedUpdates);
3137
-
3138
- var CustomStorage = {
3139
- getItem: function (_key) {
3140
- return __awaiter(void 0, void 0, void 0, function () {
3141
- return __generator(this, function (_a) {
3142
- return [2 /*return*/, {}];
3143
- });
3144
- });
3145
- },
3146
- setItem: function (_key, _value) {
3147
- return __awaiter(void 0, void 0, void 0, function () {
3148
- return __generator(this, function (_a) {
3149
- return [2 /*return*/, {}];
3150
- });
3151
- });
3152
- },
3153
- removeItem: function (_key) {
3154
- return __awaiter(void 0, void 0, void 0, function () {
3155
- return __generator(this, function (_a) {
3156
- return [2 /*return*/, {}];
3157
- });
3158
- });
3159
- },
3160
- };
3161
- var persistConfig = {
3162
- key: 'root',
3163
- storage: CustomStorage
3164
- };
3165
- var reducer = combineReducers({
3166
- reducer: persistReducer(persistConfig, appReducer),
3167
- });
3168
- var store = configureStore({
3169
- reducer: reducer,
3170
- middleware: [thunk$1],
3171
- });
3172
- var useAppDispatch = store.dispatch;
3173
- var useAppSelector = useSelector;
3174
- var persistor = persistStore(store);
3175
-
3176
- var useClientContext = (function () {
3177
- var context = React.useContext(ClientContext);
3178
- return context;
3179
- });
3180
-
3181
- var ContentContext = React.createContext(null);
3182
- var ContentProvider = function (props) {
3183
- var client = useClientContext();
3184
- var dispatch = useAppDispatch;
3185
- var _a = React__namespace.useState(props.collections || []), collections = _a[0]; _a[1];
3186
- var actions = {
3187
- subscribe: function (collectionName) { return __awaiter(void 0, void 0, void 0, function () {
3188
- return __generator(this, function (_a) {
3189
- switch (_a.label) {
3190
- case 0:
3191
- // save local that collectionName should be subscribed
3192
- return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.realtime.subscribe(collectionName, function (event) {
3193
- switch (event.action) {
3194
- case 'create':
3195
- dispatch(recordsAction.addRecord(collectionName, event.record));
3196
- break;
3197
- case 'update':
3198
- dispatch(recordsAction.updateRecord(collectionName, event.record));
3199
- break;
3200
- case 'delete':
3201
- dispatch(recordsAction.deleteRecord(collectionName, event.record));
3202
- break;
3203
- }
3204
- }))];
3205
- case 1:
3206
- // save local that collectionName should be subscribed
3207
- _a.sent();
3208
- return [2 /*return*/];
3209
- }
3210
- });
3211
- }); },
3212
- unsubscribe: function (collectionName) {
3213
- if (collectionName) {
3214
- client === null || client === void 0 ? void 0 : client.realtime.unsubscribe(collectionName);
3215
- }
3216
- else {
3217
- client === null || client === void 0 ? void 0 : client.realtime.unsubscribe();
3218
- }
3219
- },
3220
- fetch: function (collectionName) { return __awaiter(void 0, void 0, void 0, function () {
3221
- var records;
3222
- return __generator(this, function (_a) {
3223
- switch (_a.label) {
3224
- case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.getFullList(collectionName, 200))];
3225
- case 1:
3226
- records = _a.sent();
3227
- dispatch(recordsAction.setRecords(collectionName, records));
3228
- return [2 /*return*/];
3229
- }
3230
- });
3231
- }); },
3232
- create: function (collectionName, record) { return __awaiter(void 0, void 0, void 0, function () {
3233
- return __generator(this, function (_a) {
3234
- switch (_a.label) {
3235
- case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.create(collectionName, record))];
3236
- case 1:
3237
- _a.sent();
3238
- return [2 /*return*/];
3239
- }
3240
- });
3241
- }); },
3242
- update: function (collectionName, recordId, record) { return __awaiter(void 0, void 0, void 0, function () {
3243
- return __generator(this, function (_a) {
3244
- switch (_a.label) {
3245
- case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.update(collectionName, recordId, record))];
3246
- case 1:
3247
- _a.sent();
3248
- return [2 /*return*/];
3249
- }
3250
- });
3251
- }); },
3252
- delete: function (collectionName, recordId) { return __awaiter(void 0, void 0, void 0, function () {
3253
- return __generator(this, function (_a) {
3254
- switch (_a.label) {
3255
- case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.delete(collectionName, recordId))];
3256
- case 1:
3257
- _a.sent();
3258
- return [2 /*return*/];
3259
- }
3260
- });
3261
- }); },
3262
- };
3263
- React.useEffect(function () {
3264
- if (collections) {
3265
- collections.forEach(function (collectionName) {
3266
- actions.fetch(collectionName);
3267
- });
3268
- }
3269
- return function () { return actions.unsubscribe(); };
3270
- }, [collections]);
3271
- return (React__namespace.createElement(ContentContext.Provider, { value: actions }, props.children));
3272
- };
3273
-
3274
- var ClientContext = React.createContext(null);
3275
- var ClientProvider = function (props) {
3276
- return React__namespace.createElement(ClientContext.Provider, { value: props.client }, props.children);
3277
- };
3278
-
3279
- var PersistGate_1 = void 0;
3280
-
3281
- var _react = _interopRequireWildcard(React__default["default"]);
3282
-
3283
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
3284
-
3285
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3286
-
3287
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3288
-
3289
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3290
-
3291
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
3292
-
3293
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
3294
-
3295
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
3296
-
3297
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
3298
-
3299
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
3300
-
3301
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3302
-
3303
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3304
-
3305
- var PersistGate =
3306
- /*#__PURE__*/
3307
- function (_PureComponent) {
3308
- _inherits(PersistGate, _PureComponent);
3309
-
3310
- function PersistGate() {
3311
- var _getPrototypeOf2;
3312
-
3313
- var _this;
3314
-
3315
- _classCallCheck(this, PersistGate);
3316
-
3317
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3318
- args[_key] = arguments[_key];
3319
- }
3320
-
3321
- _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(PersistGate)).call.apply(_getPrototypeOf2, [this].concat(args)));
3322
-
3323
- _defineProperty(_assertThisInitialized(_this), "state", {
3324
- bootstrapped: false
3325
- });
3326
-
3327
- _defineProperty(_assertThisInitialized(_this), "_unsubscribe", void 0);
3328
-
3329
- _defineProperty(_assertThisInitialized(_this), "handlePersistorState", function () {
3330
- var persistor = _this.props.persistor;
3331
-
3332
- var _persistor$getState = persistor.getState(),
3333
- bootstrapped = _persistor$getState.bootstrapped;
3334
-
3335
- if (bootstrapped) {
3336
- if (_this.props.onBeforeLift) {
3337
- Promise.resolve(_this.props.onBeforeLift()).finally(function () {
3338
- return _this.setState({
3339
- bootstrapped: true
3340
- });
3341
- });
3342
- } else {
3343
- _this.setState({
3344
- bootstrapped: true
3345
- });
3346
- }
3347
-
3348
- _this._unsubscribe && _this._unsubscribe();
3349
- }
3350
- });
3351
-
3352
- return _this;
3353
- }
3354
-
3355
- _createClass(PersistGate, [{
3356
- key: "componentDidMount",
3357
- value: function componentDidMount() {
3358
- this._unsubscribe = this.props.persistor.subscribe(this.handlePersistorState);
3359
- this.handlePersistorState();
3360
- }
3361
- }, {
3362
- key: "componentWillUnmount",
3363
- value: function componentWillUnmount() {
3364
- this._unsubscribe && this._unsubscribe();
3365
- }
3366
- }, {
3367
- key: "render",
3368
- value: function render() {
3369
- if (process.env.NODE_ENV !== 'production') {
3370
- if (typeof this.props.children === 'function' && this.props.loading) console.error('redux-persist: PersistGate expects either a function child or loading prop, but not both. The loading prop will be ignored.');
3371
- }
3372
-
3373
- if (typeof this.props.children === 'function') {
3374
- return this.props.children(this.state.bootstrapped);
3375
- }
3376
-
3377
- return this.state.bootstrapped ? this.props.children : this.props.loading;
3378
- }
3379
- }]);
3380
-
3381
- return PersistGate;
3382
- }(_react.PureComponent);
3383
-
3384
- PersistGate_1 = PersistGate;
3385
-
3386
- _defineProperty(PersistGate, "defaultProps", {
3387
- children: null,
3388
- loading: null
3389
- });
3390
-
3391
- var PocketbaseContext = React.createContext(null);
3392
- var Pocketbase = function (props) {
3393
- var _a = React__namespace.useState(null), client = _a[0], setClient = _a[1];
3394
- React.useEffect(function () {
3395
- var reducer = combineReducers({
3396
- reducer: persistReducer(__assign(__assign({}, persistConfig), { storage: props.storage }), appReducer),
3397
- });
3398
- store.replaceReducer(reducer);
3399
- var client = new PocketBase__default["default"](props.serverURL);
3400
- client.admins.authViaEmail(props.credentials.username, props.credentials.password).then(function () {
3401
- setClient(client);
3402
- console.log('Pocketbase client initialized');
3403
- });
3404
- }, [props.serverURL]);
3405
- return client ? (React__namespace.createElement(ClientProvider, { client: client },
3406
- React__namespace.createElement(Provider, { store: store },
3407
- React__namespace.createElement(PersistGate_1, { persistor: persistor },
3408
- React__namespace.createElement(ContentProvider, { collections: props.initialCollections }, props.children))))) : null;
3409
- };
3410
-
3411
- function useAppContent(collectionName, initialFetch) {
3412
- var _this = this;
3413
- var _a;
3414
- if (initialFetch === void 0) { initialFetch = false; }
3415
- var records = ((_a = useAppSelector(function (state) { return state.reducer.records[collectionName]; })) !== null && _a !== void 0 ? _a : []);
3416
- var context = React.useContext(ContentContext);
3417
- React.useEffect(function () {
3418
- if (initialFetch) {
3419
- context === null || context === void 0 ? void 0 : context.fetch(collectionName);
3420
- }
3421
- }, [collectionName, initialFetch]);
3422
- var actions = {
3423
- subscribe: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
3424
- switch (_a.label) {
3425
- case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.subscribe(collectionName))];
3426
- case 1: return [2 /*return*/, _a.sent()];
3427
- }
3428
- }); }); },
3429
- unsubscribe: function () { return context === null || context === void 0 ? void 0 : context.unsubscribe(collectionName); },
3430
- refetch: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
3431
- switch (_a.label) {
3432
- case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.fetch(collectionName))];
3433
- case 1: return [2 /*return*/, _a.sent()];
3434
- }
3435
- }); }); },
3436
- create: function (record) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
3437
- switch (_a.label) {
3438
- case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.create(collectionName, record))];
3439
- case 1: return [2 /*return*/, _a.sent()];
3440
- }
3441
- }); }); },
3442
- update: function (id, record) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
3443
- switch (_a.label) {
3444
- case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.update(collectionName, id, record))];
3445
- case 1: return [2 /*return*/, _a.sent()];
3446
- }
3447
- }); }); },
3448
- delete: function (id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
3449
- switch (_a.label) {
3450
- case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.delete(collectionName, id))];
3451
- case 1: return [2 /*return*/, _a.sent()];
3452
- }
3453
- }); }); },
3454
- };
3455
- return { records: records, actions: actions };
3456
- }
3457
-
3458
- exports.ADD_RECORD = ADD_RECORD;
3459
- exports.ADD_RECORDS = ADD_RECORDS;
3460
- exports.ClientContext = ClientContext;
3461
- exports.ClientProvider = ClientProvider;
3462
- exports.ContentContext = ContentContext;
3463
- exports.ContentProvider = ContentProvider;
3464
- exports.DELETE_RECORD = DELETE_RECORD;
3465
- exports.DELETE_RECORDS = DELETE_RECORDS;
3466
- exports.Pocketbase = Pocketbase;
3467
- exports.PocketbaseContext = PocketbaseContext;
3468
- exports.SET_RECORDS = SET_RECORDS;
3469
- exports.UPDATE_RECORD = UPDATE_RECORD;
3470
- exports.persistConfig = persistConfig;
3471
- exports.persistor = persistor;
3472
- exports.recordsAction = recordsAction;
3473
- exports.store = store;
3474
- exports.useAppContent = useAppContent;
3475
- exports.useAppDispatch = useAppDispatch;
3476
- exports.useAppSelector = useAppSelector;
3477
- //# sourceMappingURL=index.js.map