remix-validated-form 4.3.1-beta.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/browser/ValidatedForm.js +16 -30
  3. package/browser/hooks.d.ts +1 -1
  4. package/browser/hooks.js +10 -9
  5. package/browser/internal/hooks.d.ts +20 -9
  6. package/browser/internal/hooks.js +32 -23
  7. package/browser/internal/logic/getRadioChecked.js +1 -1
  8. package/browser/internal/state/cleanup.d.ts +2 -0
  9. package/browser/internal/state/cleanup.js +6 -0
  10. package/browser/internal/state/controlledFieldStore.d.ts +24 -0
  11. package/browser/internal/state/controlledFieldStore.js +57 -0
  12. package/browser/internal/state/controlledFields.d.ts +3 -116
  13. package/browser/internal/state/controlledFields.js +25 -68
  14. package/browser/internal/state/createFormStore.d.ts +40 -0
  15. package/browser/internal/state/createFormStore.js +83 -0
  16. package/browser/internal/state/storeFamily.d.ts +9 -0
  17. package/browser/internal/state/storeFamily.js +18 -0
  18. package/browser/internal/state/storeHooks.d.ts +5 -0
  19. package/browser/internal/state/storeHooks.js +10 -0
  20. package/browser/unreleased/formStateHooks.d.ts +15 -0
  21. package/browser/unreleased/formStateHooks.js +23 -14
  22. package/browser/userFacingFormContext.d.ts +8 -0
  23. package/browser/userFacingFormContext.js +5 -4
  24. package/dist/remix-validated-form.cjs.js +17 -1
  25. package/dist/remix-validated-form.es.js +1033 -1724
  26. package/dist/remix-validated-form.umd.js +17 -1
  27. package/dist/types/hooks.d.ts +1 -1
  28. package/dist/types/internal/hooks.d.ts +20 -9
  29. package/dist/types/internal/state/cleanup.d.ts +2 -0
  30. package/dist/types/internal/state/controlledFieldStore.d.ts +24 -0
  31. package/dist/types/internal/state/controlledFields.d.ts +3 -116
  32. package/dist/types/internal/state/createFormStore.d.ts +40 -0
  33. package/dist/types/internal/state/storeFamily.d.ts +9 -0
  34. package/dist/types/internal/state/storeHooks.d.ts +5 -0
  35. package/dist/types/unreleased/formStateHooks.d.ts +15 -0
  36. package/dist/types/userFacingFormContext.d.ts +8 -0
  37. package/package.json +4 -3
  38. package/src/ValidatedForm.tsx +25 -47
  39. package/src/hooks.ts +15 -18
  40. package/src/internal/hooks.ts +69 -45
  41. package/src/internal/logic/getRadioChecked.ts +1 -1
  42. package/src/internal/state/cleanup.ts +8 -0
  43. package/src/internal/state/controlledFieldStore.ts +91 -0
  44. package/src/internal/state/controlledFields.ts +31 -123
  45. package/src/internal/state/createFormStore.ts +152 -0
  46. package/src/internal/state/storeFamily.ts +24 -0
  47. package/src/internal/state/storeHooks.ts +22 -0
  48. package/src/unreleased/formStateHooks.ts +50 -27
  49. package/src/userFacingFormContext.ts +17 -5
  50. package/dist/types/internal/reset.d.ts +0 -28
  51. package/dist/types/internal/state/atomUtils.d.ts +0 -38
  52. package/dist/types/internal/state.d.ts +0 -343
  53. package/src/internal/reset.ts +0 -26
  54. package/src/internal/state/atomUtils.ts +0 -13
  55. package/src/internal/state.ts +0 -124
@@ -5,18 +5,18 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
8
+ var __spreadValues = (a2, b2) => {
9
+ for (var prop in b2 || (b2 = {}))
10
+ if (__hasOwnProp.call(b2, prop))
11
+ __defNormalProp(a2, prop, b2[prop]);
12
12
  if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
13
+ for (var prop of __getOwnPropSymbols(b2)) {
14
+ if (__propIsEnum.call(b2, prop))
15
+ __defNormalProp(a2, prop, b2[prop]);
16
16
  }
17
- return a;
17
+ return a2;
18
18
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
19
+ var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
20
20
  var __objRest = (source, exclude) => {
21
21
  var target = {};
22
22
  for (var prop in source)
@@ -29,7 +29,7 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import React, { useContext, useCallback, useReducer, useEffect, useDebugValue, createContext, useMemo, useRef, useLayoutEffect, useState } from "react";
32
+ import React, { createContext, useDebugValue, useContext, useCallback, useEffect, useMemo, useRef, useLayoutEffect, useState } from "react";
33
33
  import { useActionData, useMatches, useTransition, Form, useSubmit } from "@remix-run/react";
34
34
  import { json } from "@remix-run/server-runtime";
35
35
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -136,19 +136,19 @@ var freeSelf = typeof self == "object" && self && self.Object === Object && self
136
136
  var root$8 = freeGlobal || freeSelf || Function("return this")();
137
137
  var _root = root$8;
138
138
  var root$7 = _root;
139
- var Symbol$7 = root$7.Symbol;
140
- var _Symbol = Symbol$7;
141
- var Symbol$6 = _Symbol;
142
- var objectProto$f = Object.prototype;
143
- var hasOwnProperty$c = objectProto$f.hasOwnProperty;
144
- var nativeObjectToString$1 = objectProto$f.toString;
145
- var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
139
+ var Symbol$5 = root$7.Symbol;
140
+ var _Symbol = Symbol$5;
141
+ var Symbol$4 = _Symbol;
142
+ var objectProto$d = Object.prototype;
143
+ var hasOwnProperty$a = objectProto$d.hasOwnProperty;
144
+ var nativeObjectToString$1 = objectProto$d.toString;
145
+ var symToStringTag$1 = Symbol$4 ? Symbol$4.toStringTag : void 0;
146
146
  function getRawTag$1(value) {
147
- var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
147
+ var isOwn = hasOwnProperty$a.call(value, symToStringTag$1), tag = value[symToStringTag$1];
148
148
  try {
149
149
  value[symToStringTag$1] = void 0;
150
150
  var unmasked = true;
151
- } catch (e) {
151
+ } catch (e2) {
152
152
  }
153
153
  var result = nativeObjectToString$1.call(value);
154
154
  if (unmasked) {
@@ -161,35 +161,35 @@ function getRawTag$1(value) {
161
161
  return result;
162
162
  }
163
163
  var _getRawTag = getRawTag$1;
164
- var objectProto$e = Object.prototype;
165
- var nativeObjectToString = objectProto$e.toString;
164
+ var objectProto$c = Object.prototype;
165
+ var nativeObjectToString = objectProto$c.toString;
166
166
  function objectToString$1(value) {
167
167
  return nativeObjectToString.call(value);
168
168
  }
169
169
  var _objectToString = objectToString$1;
170
- var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
170
+ var Symbol$3 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
171
171
  var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
172
- var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
173
- function baseGetTag$6(value) {
172
+ var symToStringTag = Symbol$3 ? Symbol$3.toStringTag : void 0;
173
+ function baseGetTag$5(value) {
174
174
  if (value == null) {
175
175
  return value === void 0 ? undefinedTag : nullTag;
176
176
  }
177
177
  return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
178
178
  }
179
- var _baseGetTag = baseGetTag$6;
180
- function isObject$7(value) {
179
+ var _baseGetTag = baseGetTag$5;
180
+ function isObject$5(value) {
181
181
  var type = typeof value;
182
182
  return value != null && (type == "object" || type == "function");
183
183
  }
184
- var isObject_1 = isObject$7;
185
- var baseGetTag$5 = _baseGetTag, isObject$6 = isObject_1;
186
- var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
184
+ var isObject_1 = isObject$5;
185
+ var baseGetTag$4 = _baseGetTag, isObject$4 = isObject_1;
186
+ var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
187
187
  function isFunction$2(value) {
188
- if (!isObject$6(value)) {
188
+ if (!isObject$4(value)) {
189
189
  return false;
190
190
  }
191
- var tag = baseGetTag$5(value);
192
- return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
191
+ var tag = baseGetTag$4(value);
192
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
193
193
  }
194
194
  var isFunction_1 = isFunction$2;
195
195
  var root$6 = _root;
@@ -204,31 +204,31 @@ function isMasked$1(func) {
204
204
  return !!maskSrcKey && maskSrcKey in func;
205
205
  }
206
206
  var _isMasked = isMasked$1;
207
- var funcProto$2 = Function.prototype;
208
- var funcToString$2 = funcProto$2.toString;
207
+ var funcProto$1 = Function.prototype;
208
+ var funcToString$1 = funcProto$1.toString;
209
209
  function toSource$2(func) {
210
210
  if (func != null) {
211
211
  try {
212
- return funcToString$2.call(func);
213
- } catch (e) {
212
+ return funcToString$1.call(func);
213
+ } catch (e2) {
214
214
  }
215
215
  try {
216
216
  return func + "";
217
- } catch (e) {
217
+ } catch (e2) {
218
218
  }
219
219
  }
220
220
  return "";
221
221
  }
222
222
  var _toSource = toSource$2;
223
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$5 = isObject_1, toSource$1 = _toSource;
223
+ var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$3 = isObject_1, toSource$1 = _toSource;
224
224
  var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
225
225
  var reIsHostCtor = /^\[object .+?Constructor\]$/;
226
- var funcProto$1 = Function.prototype, objectProto$d = Object.prototype;
227
- var funcToString$1 = funcProto$1.toString;
228
- var hasOwnProperty$b = objectProto$d.hasOwnProperty;
229
- var reIsNative = RegExp("^" + funcToString$1.call(hasOwnProperty$b).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
226
+ var funcProto = Function.prototype, objectProto$b = Object.prototype;
227
+ var funcToString = funcProto.toString;
228
+ var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
229
+ var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty$9).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
230
230
  function baseIsNative$1(value) {
231
- if (!isObject$5(value) || isMasked(value)) {
231
+ if (!isObject$3(value) || isMasked(value)) {
232
232
  return false;
233
233
  }
234
234
  var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
@@ -265,23 +265,23 @@ function hashDelete$1(key) {
265
265
  var _hashDelete = hashDelete$1;
266
266
  var nativeCreate$2 = _nativeCreate;
267
267
  var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
268
- var objectProto$c = Object.prototype;
269
- var hasOwnProperty$a = objectProto$c.hasOwnProperty;
268
+ var objectProto$a = Object.prototype;
269
+ var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
270
270
  function hashGet$1(key) {
271
271
  var data = this.__data__;
272
272
  if (nativeCreate$2) {
273
273
  var result = data[key];
274
274
  return result === HASH_UNDEFINED$2 ? void 0 : result;
275
275
  }
276
- return hasOwnProperty$a.call(data, key) ? data[key] : void 0;
276
+ return hasOwnProperty$8.call(data, key) ? data[key] : void 0;
277
277
  }
278
278
  var _hashGet = hashGet$1;
279
279
  var nativeCreate$1 = _nativeCreate;
280
- var objectProto$b = Object.prototype;
281
- var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
280
+ var objectProto$9 = Object.prototype;
281
+ var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
282
282
  function hashHas$1(key) {
283
283
  var data = this.__data__;
284
- return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$9.call(data, key);
284
+ return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$7.call(data, key);
285
285
  }
286
286
  var _hashHas = hashHas$1;
287
287
  var nativeCreate = _nativeCreate;
@@ -388,16 +388,16 @@ function stackSet$1(key, value) {
388
388
  }
389
389
  var _stackSet = stackSet$1;
390
390
  var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
391
- function Stack$3(entries) {
391
+ function Stack$2(entries) {
392
392
  var data = this.__data__ = new ListCache(entries);
393
393
  this.size = data.size;
394
394
  }
395
- Stack$3.prototype.clear = stackClear;
396
- Stack$3.prototype["delete"] = stackDelete;
397
- Stack$3.prototype.get = stackGet;
398
- Stack$3.prototype.has = stackHas;
399
- Stack$3.prototype.set = stackSet;
400
- var _Stack = Stack$3;
395
+ Stack$2.prototype.clear = stackClear;
396
+ Stack$2.prototype["delete"] = stackDelete;
397
+ Stack$2.prototype.get = stackGet;
398
+ Stack$2.prototype.has = stackHas;
399
+ Stack$2.prototype.set = stackSet;
400
+ var _Stack = Stack$2;
401
401
  var HASH_UNDEFINED = "__lodash_hash_undefined__";
402
402
  function setCacheAdd$1(value) {
403
403
  this.__data__.set(value, HASH_UNDEFINED);
@@ -480,8 +480,8 @@ function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
480
480
  }
481
481
  var _equalArrays = equalArrays$2;
482
482
  var root$4 = _root;
483
- var Uint8Array$2 = root$4.Uint8Array;
484
- var _Uint8Array = Uint8Array$2;
483
+ var Uint8Array$1 = root$4.Uint8Array;
484
+ var _Uint8Array = Uint8Array$1;
485
485
  function mapToArray$1(map) {
486
486
  var index = -1, result = Array(map.size);
487
487
  map.forEach(function(value, key) {
@@ -498,36 +498,36 @@ function setToArray$3(set2) {
498
498
  return result;
499
499
  }
500
500
  var _setToArray = setToArray$3;
501
- var Symbol$4 = _Symbol, Uint8Array$1 = _Uint8Array, eq$1 = eq_1, equalArrays$1 = _equalArrays, mapToArray = _mapToArray, setToArray$2 = _setToArray;
501
+ var Symbol$2 = _Symbol, Uint8Array2 = _Uint8Array, eq$1 = eq_1, equalArrays$1 = _equalArrays, mapToArray = _mapToArray, setToArray$2 = _setToArray;
502
502
  var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
503
- var boolTag$3 = "[object Boolean]", dateTag$3 = "[object Date]", errorTag$2 = "[object Error]", mapTag$5 = "[object Map]", numberTag$3 = "[object Number]", regexpTag$3 = "[object RegExp]", setTag$5 = "[object Set]", stringTag$3 = "[object String]", symbolTag$3 = "[object Symbol]";
504
- var arrayBufferTag$3 = "[object ArrayBuffer]", dataViewTag$4 = "[object DataView]";
505
- var symbolProto$2 = Symbol$4 ? Symbol$4.prototype : void 0, symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : void 0;
503
+ var boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]";
504
+ var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]";
505
+ var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : void 0, symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : void 0;
506
506
  function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
507
507
  switch (tag) {
508
- case dataViewTag$4:
508
+ case dataViewTag$2:
509
509
  if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
510
510
  return false;
511
511
  }
512
512
  object = object.buffer;
513
513
  other = other.buffer;
514
- case arrayBufferTag$3:
515
- if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) {
514
+ case arrayBufferTag$1:
515
+ if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
516
516
  return false;
517
517
  }
518
518
  return true;
519
- case boolTag$3:
520
- case dateTag$3:
521
- case numberTag$3:
519
+ case boolTag$1:
520
+ case dateTag$1:
521
+ case numberTag$1:
522
522
  return eq$1(+object, +other);
523
- case errorTag$2:
523
+ case errorTag$1:
524
524
  return object.name == other.name && object.message == other.message;
525
- case regexpTag$3:
526
- case stringTag$3:
525
+ case regexpTag$1:
526
+ case stringTag$1:
527
527
  return object == other + "";
528
- case mapTag$5:
528
+ case mapTag$2:
529
529
  var convert = mapToArray;
530
- case setTag$5:
530
+ case setTag$2:
531
531
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
532
532
  convert || (convert = setToArray$2);
533
533
  if (object.size != other.size && !isPartial) {
@@ -542,28 +542,28 @@ function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack)
542
542
  var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
543
543
  stack["delete"](object);
544
544
  return result;
545
- case symbolTag$3:
546
- if (symbolValueOf$1) {
547
- return symbolValueOf$1.call(object) == symbolValueOf$1.call(other);
545
+ case symbolTag$1:
546
+ if (symbolValueOf) {
547
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
548
548
  }
549
549
  }
550
550
  return false;
551
551
  }
552
552
  var _equalByTag = equalByTag$1;
553
- function arrayPush$3(array, values) {
553
+ function arrayPush$2(array, values) {
554
554
  var index = -1, length = values.length, offset = array.length;
555
555
  while (++index < length) {
556
556
  array[offset + index] = values[index];
557
557
  }
558
558
  return array;
559
559
  }
560
- var _arrayPush = arrayPush$3;
561
- var isArray$a = Array.isArray;
562
- var isArray_1 = isArray$a;
563
- var arrayPush$2 = _arrayPush, isArray$9 = isArray_1;
560
+ var _arrayPush = arrayPush$2;
561
+ var isArray$8 = Array.isArray;
562
+ var isArray_1 = isArray$8;
563
+ var arrayPush$1 = _arrayPush, isArray$7 = isArray_1;
564
564
  function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
565
565
  var result = keysFunc(object);
566
- return isArray$9(object) ? result : arrayPush$2(result, symbolsFunc(object));
566
+ return isArray$7(object) ? result : arrayPush$1(result, symbolsFunc(object));
567
567
  }
568
568
  var _baseGetAllKeys = baseGetAllKeys$2;
569
569
  function arrayFilter$1(array, predicate) {
@@ -582,10 +582,10 @@ function stubArray$2() {
582
582
  }
583
583
  var stubArray_1 = stubArray$2;
584
584
  var arrayFilter = _arrayFilter, stubArray$1 = stubArray_1;
585
- var objectProto$a = Object.prototype;
586
- var propertyIsEnumerable$1 = objectProto$a.propertyIsEnumerable;
585
+ var objectProto$8 = Object.prototype;
586
+ var propertyIsEnumerable$1 = objectProto$8.propertyIsEnumerable;
587
587
  var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
588
- var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
588
+ var getSymbols$2 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
589
589
  if (object == null) {
590
590
  return [];
591
591
  }
@@ -594,36 +594,36 @@ var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
594
594
  return propertyIsEnumerable$1.call(object, symbol);
595
595
  });
596
596
  };
597
- var _getSymbols = getSymbols$3;
598
- function baseTimes$1(n, iteratee) {
599
- var index = -1, result = Array(n);
600
- while (++index < n) {
597
+ var _getSymbols = getSymbols$2;
598
+ function baseTimes$1(n2, iteratee) {
599
+ var index = -1, result = Array(n2);
600
+ while (++index < n2) {
601
601
  result[index] = iteratee(index);
602
602
  }
603
603
  return result;
604
604
  }
605
605
  var _baseTimes = baseTimes$1;
606
- function isObjectLike$8(value) {
606
+ function isObjectLike$5(value) {
607
607
  return value != null && typeof value == "object";
608
608
  }
609
- var isObjectLike_1 = isObjectLike$8;
610
- var baseGetTag$4 = _baseGetTag, isObjectLike$7 = isObjectLike_1;
611
- var argsTag$3 = "[object Arguments]";
609
+ var isObjectLike_1 = isObjectLike$5;
610
+ var baseGetTag$3 = _baseGetTag, isObjectLike$4 = isObjectLike_1;
611
+ var argsTag$2 = "[object Arguments]";
612
612
  function baseIsArguments$1(value) {
613
- return isObjectLike$7(value) && baseGetTag$4(value) == argsTag$3;
613
+ return isObjectLike$4(value) && baseGetTag$3(value) == argsTag$2;
614
614
  }
615
615
  var _baseIsArguments = baseIsArguments$1;
616
- var baseIsArguments = _baseIsArguments, isObjectLike$6 = isObjectLike_1;
617
- var objectProto$9 = Object.prototype;
618
- var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
619
- var propertyIsEnumerable = objectProto$9.propertyIsEnumerable;
620
- var isArguments$3 = baseIsArguments(function() {
616
+ var baseIsArguments = _baseIsArguments, isObjectLike$3 = isObjectLike_1;
617
+ var objectProto$7 = Object.prototype;
618
+ var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
619
+ var propertyIsEnumerable = objectProto$7.propertyIsEnumerable;
620
+ var isArguments$2 = baseIsArguments(function() {
621
621
  return arguments;
622
622
  }()) ? baseIsArguments : function(value) {
623
- return isObjectLike$6(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
623
+ return isObjectLike$3(value) && hasOwnProperty$6.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
624
624
  };
625
- var isArguments_1 = isArguments$3;
626
- var isBuffer$3 = { exports: {} };
625
+ var isArguments_1 = isArguments$2;
626
+ var isBuffer$2 = { exports: {} };
627
627
  function stubFalse() {
628
628
  return false;
629
629
  }
@@ -637,7 +637,7 @@ var stubFalse_1 = stubFalse;
637
637
  var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
638
638
  var isBuffer2 = nativeIsBuffer || stubFalse2;
639
639
  module.exports = isBuffer2;
640
- })(isBuffer$3, isBuffer$3.exports);
640
+ })(isBuffer$2, isBuffer$2.exports);
641
641
  var MAX_SAFE_INTEGER$1 = 9007199254740991;
642
642
  var reIsUint = /^(?:0|[1-9]\d*)$/;
643
643
  function isIndex$3(value, length) {
@@ -651,22 +651,22 @@ function isLength$3(value) {
651
651
  return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
652
652
  }
653
653
  var isLength_1 = isLength$3;
654
- var baseGetTag$3 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$5 = isObjectLike_1;
655
- var argsTag$2 = "[object Arguments]", arrayTag$2 = "[object Array]", boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", errorTag$1 = "[object Error]", funcTag$1 = "[object Function]", mapTag$4 = "[object Map]", numberTag$2 = "[object Number]", objectTag$4 = "[object Object]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", weakMapTag$2 = "[object WeakMap]";
656
- var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$3 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
654
+ var baseGetTag$2 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$2 = isObjectLike_1;
655
+ var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag$1 = "[object Map]", numberTag = "[object Number]", objectTag$2 = "[object Object]", regexpTag = "[object RegExp]", setTag$1 = "[object Set]", stringTag = "[object String]", weakMapTag$1 = "[object WeakMap]";
656
+ var arrayBufferTag = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
657
657
  var typedArrayTags = {};
658
- typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
659
- typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] = typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] = typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] = typedArrayTags[objectTag$4] = typedArrayTags[regexpTag$2] = typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] = typedArrayTags[weakMapTag$2] = false;
658
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
659
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag] = typedArrayTags[setTag$1] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag$1] = false;
660
660
  function baseIsTypedArray$1(value) {
661
- return isObjectLike$5(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$3(value)];
661
+ return isObjectLike$2(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$2(value)];
662
662
  }
663
663
  var _baseIsTypedArray = baseIsTypedArray$1;
664
- function baseUnary$3(func) {
664
+ function baseUnary$1(func) {
665
665
  return function(value) {
666
666
  return func(value);
667
667
  };
668
668
  }
669
- var _baseUnary = baseUnary$3;
669
+ var _baseUnary = baseUnary$1;
670
670
  var _nodeUtil = { exports: {} };
671
671
  (function(module, exports) {
672
672
  var freeGlobal2 = _freeGlobal;
@@ -681,34 +681,34 @@ var _nodeUtil = { exports: {} };
681
681
  return types;
682
682
  }
683
683
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
684
- } catch (e) {
684
+ } catch (e2) {
685
685
  }
686
686
  }();
687
687
  module.exports = nodeUtil2;
688
688
  })(_nodeUtil, _nodeUtil.exports);
689
- var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtil.exports;
690
- var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
691
- var isTypedArray$2 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
689
+ var baseIsTypedArray = _baseIsTypedArray, baseUnary = _baseUnary, nodeUtil = _nodeUtil.exports;
690
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
691
+ var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
692
692
  var isTypedArray_1 = isTypedArray$2;
693
- var baseTimes = _baseTimes, isArguments$2 = isArguments_1, isArray$8 = isArray_1, isBuffer$2 = isBuffer$3.exports, isIndex$2 = _isIndex, isTypedArray$1 = isTypedArray_1;
694
- var objectProto$8 = Object.prototype;
695
- var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
693
+ var baseTimes = _baseTimes, isArguments$1 = isArguments_1, isArray$6 = isArray_1, isBuffer$1 = isBuffer$2.exports, isIndex$2 = _isIndex, isTypedArray$1 = isTypedArray_1;
694
+ var objectProto$6 = Object.prototype;
695
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
696
696
  function arrayLikeKeys$2(value, inherited) {
697
- var isArr = isArray$8(value), isArg = !isArr && isArguments$2(value), isBuff = !isArr && !isArg && isBuffer$2(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
697
+ var isArr = isArray$6(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
698
698
  for (var key in value) {
699
- if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex$2(key, length)))) {
699
+ if ((inherited || hasOwnProperty$5.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex$2(key, length)))) {
700
700
  result.push(key);
701
701
  }
702
702
  }
703
703
  return result;
704
704
  }
705
705
  var _arrayLikeKeys = arrayLikeKeys$2;
706
- var objectProto$7 = Object.prototype;
707
- function isPrototype$3(value) {
708
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$7;
706
+ var objectProto$5 = Object.prototype;
707
+ function isPrototype$2(value) {
708
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$5;
709
709
  return value === proto;
710
710
  }
711
- var _isPrototype = isPrototype$3;
711
+ var _isPrototype = isPrototype$2;
712
712
  function overArg$2(func, transform) {
713
713
  return function(arg) {
714
714
  return func(transform(arg));
@@ -718,16 +718,16 @@ var _overArg = overArg$2;
718
718
  var overArg$1 = _overArg;
719
719
  var nativeKeys$1 = overArg$1(Object.keys, Object);
720
720
  var _nativeKeys = nativeKeys$1;
721
- var isPrototype$2 = _isPrototype, nativeKeys = _nativeKeys;
722
- var objectProto$6 = Object.prototype;
723
- var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
721
+ var isPrototype$1 = _isPrototype, nativeKeys = _nativeKeys;
722
+ var objectProto$4 = Object.prototype;
723
+ var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
724
724
  function baseKeys$1(object) {
725
- if (!isPrototype$2(object)) {
725
+ if (!isPrototype$1(object)) {
726
726
  return nativeKeys(object);
727
727
  }
728
728
  var result = [];
729
729
  for (var key in Object(object)) {
730
- if (hasOwnProperty$6.call(object, key) && key != "constructor") {
730
+ if (hasOwnProperty$4.call(object, key) && key != "constructor") {
731
731
  result.push(key);
732
732
  }
733
733
  }
@@ -740,28 +740,28 @@ function isArrayLike$2(value) {
740
740
  }
741
741
  var isArrayLike_1 = isArrayLike$2;
742
742
  var arrayLikeKeys$1 = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike$1 = isArrayLike_1;
743
- function keys$4(object) {
743
+ function keys$2(object) {
744
744
  return isArrayLike$1(object) ? arrayLikeKeys$1(object) : baseKeys(object);
745
745
  }
746
- var keys_1 = keys$4;
747
- var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols$2 = _getSymbols, keys$3 = keys_1;
748
- function getAllKeys$2(object) {
749
- return baseGetAllKeys$1(object, keys$3, getSymbols$2);
746
+ var keys_1 = keys$2;
747
+ var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols$1 = _getSymbols, keys$1 = keys_1;
748
+ function getAllKeys$1(object) {
749
+ return baseGetAllKeys$1(object, keys$1, getSymbols$1);
750
750
  }
751
- var _getAllKeys = getAllKeys$2;
752
- var getAllKeys$1 = _getAllKeys;
751
+ var _getAllKeys = getAllKeys$1;
752
+ var getAllKeys = _getAllKeys;
753
753
  var COMPARE_PARTIAL_FLAG$3 = 1;
754
- var objectProto$5 = Object.prototype;
755
- var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
754
+ var objectProto$3 = Object.prototype;
755
+ var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
756
756
  function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
757
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys$1(object), objLength = objProps.length, othProps = getAllKeys$1(other), othLength = othProps.length;
757
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
758
758
  if (objLength != othLength && !isPartial) {
759
759
  return false;
760
760
  }
761
761
  var index = objLength;
762
762
  while (index--) {
763
763
  var key = objProps[index];
764
- if (!(isPartial ? key in other : hasOwnProperty$5.call(other, key))) {
764
+ if (!(isPartial ? key in other : hasOwnProperty$3.call(other, key))) {
765
765
  return false;
766
766
  }
767
767
  }
@@ -807,82 +807,82 @@ var getNative$2 = _getNative, root$1 = _root;
807
807
  var Set$3 = getNative$2(root$1, "Set");
808
808
  var _Set = Set$3;
809
809
  var getNative$1 = _getNative, root = _root;
810
- var WeakMap$2 = getNative$1(root, "WeakMap");
811
- var _WeakMap = WeakMap$2;
812
- var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$2 = _Set, WeakMap$1 = _WeakMap, baseGetTag$2 = _baseGetTag, toSource = _toSource;
813
- var mapTag$3 = "[object Map]", objectTag$3 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
814
- var dataViewTag$2 = "[object DataView]";
815
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$2), weakMapCtorString = toSource(WeakMap$1);
816
- var getTag$4 = baseGetTag$2;
817
- if (DataView && getTag$4(new DataView(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag$4(new Map$1()) != mapTag$3 || Promise$1 && getTag$4(Promise$1.resolve()) != promiseTag || Set$2 && getTag$4(new Set$2()) != setTag$3 || WeakMap$1 && getTag$4(new WeakMap$1()) != weakMapTag$1) {
818
- getTag$4 = function(value) {
819
- var result = baseGetTag$2(value), Ctor = result == objectTag$3 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
810
+ var WeakMap$1 = getNative$1(root, "WeakMap");
811
+ var _WeakMap = WeakMap$1;
812
+ var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$2 = _Set, WeakMap = _WeakMap, baseGetTag$1 = _baseGetTag, toSource = _toSource;
813
+ var mapTag = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag = "[object Set]", weakMapTag = "[object WeakMap]";
814
+ var dataViewTag = "[object DataView]";
815
+ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$2), weakMapCtorString = toSource(WeakMap);
816
+ var getTag$1 = baseGetTag$1;
817
+ if (DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag$1(new Map$1()) != mapTag || Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag || Set$2 && getTag$1(new Set$2()) != setTag || WeakMap && getTag$1(new WeakMap()) != weakMapTag) {
818
+ getTag$1 = function(value) {
819
+ var result = baseGetTag$1(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
820
820
  if (ctorString) {
821
821
  switch (ctorString) {
822
822
  case dataViewCtorString:
823
- return dataViewTag$2;
823
+ return dataViewTag;
824
824
  case mapCtorString:
825
- return mapTag$3;
825
+ return mapTag;
826
826
  case promiseCtorString:
827
827
  return promiseTag;
828
828
  case setCtorString:
829
- return setTag$3;
829
+ return setTag;
830
830
  case weakMapCtorString:
831
- return weakMapTag$1;
831
+ return weakMapTag;
832
832
  }
833
833
  }
834
834
  return result;
835
835
  };
836
836
  }
837
- var _getTag = getTag$4;
838
- var Stack$2 = _Stack, equalArrays = _equalArrays, equalByTag = _equalByTag, equalObjects = _equalObjects, getTag$3 = _getTag, isArray$7 = isArray_1, isBuffer$1 = isBuffer$3.exports, isTypedArray = isTypedArray_1;
837
+ var _getTag = getTag$1;
838
+ var Stack$1 = _Stack, equalArrays = _equalArrays, equalByTag = _equalByTag, equalObjects = _equalObjects, getTag = _getTag, isArray$5 = isArray_1, isBuffer = isBuffer$2.exports, isTypedArray = isTypedArray_1;
839
839
  var COMPARE_PARTIAL_FLAG$2 = 1;
840
- var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", objectTag$2 = "[object Object]";
841
- var objectProto$4 = Object.prototype;
842
- var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
840
+ var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
841
+ var objectProto$2 = Object.prototype;
842
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
843
843
  function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
844
- var objIsArr = isArray$7(object), othIsArr = isArray$7(other), objTag = objIsArr ? arrayTag$1 : getTag$3(object), othTag = othIsArr ? arrayTag$1 : getTag$3(other);
845
- objTag = objTag == argsTag$1 ? objectTag$2 : objTag;
846
- othTag = othTag == argsTag$1 ? objectTag$2 : othTag;
847
- var objIsObj = objTag == objectTag$2, othIsObj = othTag == objectTag$2, isSameTag = objTag == othTag;
848
- if (isSameTag && isBuffer$1(object)) {
849
- if (!isBuffer$1(other)) {
844
+ var objIsArr = isArray$5(object), othIsArr = isArray$5(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
845
+ objTag = objTag == argsTag ? objectTag : objTag;
846
+ othTag = othTag == argsTag ? objectTag : othTag;
847
+ var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
848
+ if (isSameTag && isBuffer(object)) {
849
+ if (!isBuffer(other)) {
850
850
  return false;
851
851
  }
852
852
  objIsArr = true;
853
853
  objIsObj = false;
854
854
  }
855
855
  if (isSameTag && !objIsObj) {
856
- stack || (stack = new Stack$2());
856
+ stack || (stack = new Stack$1());
857
857
  return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
858
858
  }
859
859
  if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
860
- var objIsWrapped = objIsObj && hasOwnProperty$4.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$4.call(other, "__wrapped__");
860
+ var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$2.call(other, "__wrapped__");
861
861
  if (objIsWrapped || othIsWrapped) {
862
862
  var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
863
- stack || (stack = new Stack$2());
863
+ stack || (stack = new Stack$1());
864
864
  return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
865
865
  }
866
866
  }
867
867
  if (!isSameTag) {
868
868
  return false;
869
869
  }
870
- stack || (stack = new Stack$2());
870
+ stack || (stack = new Stack$1());
871
871
  return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
872
872
  }
873
873
  var _baseIsEqualDeep = baseIsEqualDeep$1;
874
- var baseIsEqualDeep = _baseIsEqualDeep, isObjectLike$4 = isObjectLike_1;
874
+ var baseIsEqualDeep = _baseIsEqualDeep, isObjectLike$1 = isObjectLike_1;
875
875
  function baseIsEqual$3(value, other, bitmask, customizer, stack) {
876
876
  if (value === other) {
877
877
  return true;
878
878
  }
879
- if (value == null || other == null || !isObjectLike$4(value) && !isObjectLike$4(other)) {
879
+ if (value == null || other == null || !isObjectLike$1(value) && !isObjectLike$1(other)) {
880
880
  return value !== value && other !== other;
881
881
  }
882
882
  return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$3, stack);
883
883
  }
884
884
  var _baseIsEqual = baseIsEqual$3;
885
- var Stack$1 = _Stack, baseIsEqual$2 = _baseIsEqual;
885
+ var Stack = _Stack, baseIsEqual$2 = _baseIsEqual;
886
886
  var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
887
887
  function baseIsMatch$1(object, source, matchData, customizer) {
888
888
  var index = matchData.length, length = index, noCustomizer = !customizer;
@@ -904,7 +904,7 @@ function baseIsMatch$1(object, source, matchData, customizer) {
904
904
  return false;
905
905
  }
906
906
  } else {
907
- var stack = new Stack$1();
907
+ var stack = new Stack();
908
908
  if (customizer) {
909
909
  var result = customizer(objValue, srcValue, key, object, source, stack);
910
910
  }
@@ -916,14 +916,14 @@ function baseIsMatch$1(object, source, matchData, customizer) {
916
916
  return true;
917
917
  }
918
918
  var _baseIsMatch = baseIsMatch$1;
919
- var isObject$4 = isObject_1;
919
+ var isObject$2 = isObject_1;
920
920
  function isStrictComparable$2(value) {
921
- return value === value && !isObject$4(value);
921
+ return value === value && !isObject$2(value);
922
922
  }
923
923
  var _isStrictComparable = isStrictComparable$2;
924
- var isStrictComparable$1 = _isStrictComparable, keys$2 = keys_1;
924
+ var isStrictComparable$1 = _isStrictComparable, keys = keys_1;
925
925
  function getMatchData$1(object) {
926
- var result = keys$2(object), length = result.length;
926
+ var result = keys(object), length = result.length;
927
927
  while (length--) {
928
928
  var key = result[length], value = object[key];
929
929
  result[length] = [key, value, isStrictComparable$1(value)];
@@ -951,16 +951,16 @@ function baseMatches$1(source) {
951
951
  };
952
952
  }
953
953
  var _baseMatches = baseMatches$1;
954
- var baseGetTag$1 = _baseGetTag, isObjectLike$3 = isObjectLike_1;
955
- var symbolTag$2 = "[object Symbol]";
954
+ var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
955
+ var symbolTag = "[object Symbol]";
956
956
  function isSymbol$3(value) {
957
- return typeof value == "symbol" || isObjectLike$3(value) && baseGetTag$1(value) == symbolTag$2;
957
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
958
958
  }
959
959
  var isSymbol_1 = isSymbol$3;
960
- var isArray$6 = isArray_1, isSymbol$2 = isSymbol_1;
960
+ var isArray$4 = isArray_1, isSymbol$2 = isSymbol_1;
961
961
  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
962
962
  function isKey$3(value, object) {
963
- if (isArray$6(value)) {
963
+ if (isArray$4(value)) {
964
964
  return false;
965
965
  }
966
966
  var type = typeof value;
@@ -1017,23 +1017,23 @@ var stringToPath$1 = memoizeCapped(function(string) {
1017
1017
  return result;
1018
1018
  });
1019
1019
  var _stringToPath = stringToPath$1;
1020
- function arrayMap$3(array, iteratee) {
1020
+ function arrayMap$2(array, iteratee) {
1021
1021
  var index = -1, length = array == null ? 0 : array.length, result = Array(length);
1022
1022
  while (++index < length) {
1023
1023
  result[index] = iteratee(array[index], index, array);
1024
1024
  }
1025
1025
  return result;
1026
1026
  }
1027
- var _arrayMap = arrayMap$3;
1028
- var Symbol$3 = _Symbol, arrayMap$2 = _arrayMap, isArray$5 = isArray_1, isSymbol$1 = isSymbol_1;
1027
+ var _arrayMap = arrayMap$2;
1028
+ var Symbol$1 = _Symbol, arrayMap$1 = _arrayMap, isArray$3 = isArray_1, isSymbol$1 = isSymbol_1;
1029
1029
  var INFINITY$2 = 1 / 0;
1030
- var symbolProto$1 = Symbol$3 ? Symbol$3.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
1030
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
1031
1031
  function baseToString$1(value) {
1032
1032
  if (typeof value == "string") {
1033
1033
  return value;
1034
1034
  }
1035
- if (isArray$5(value)) {
1036
- return arrayMap$2(value, baseToString$1) + "";
1035
+ if (isArray$3(value)) {
1036
+ return arrayMap$1(value, baseToString$1) + "";
1037
1037
  }
1038
1038
  if (isSymbol$1(value)) {
1039
1039
  return symbolToString ? symbolToString.call(value) : "";
@@ -1047,37 +1047,37 @@ function toString$1(value) {
1047
1047
  return value == null ? "" : baseToString(value);
1048
1048
  }
1049
1049
  var toString_1 = toString$1;
1050
- var isArray$4 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString = toString_1;
1051
- function castPath$6(value, object) {
1052
- if (isArray$4(value)) {
1050
+ var isArray$2 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString = toString_1;
1051
+ function castPath$4(value, object) {
1052
+ if (isArray$2(value)) {
1053
1053
  return value;
1054
1054
  }
1055
1055
  return isKey$2(value, object) ? [value] : stringToPath(toString(value));
1056
1056
  }
1057
- var _castPath = castPath$6;
1057
+ var _castPath = castPath$4;
1058
1058
  var isSymbol = isSymbol_1;
1059
1059
  var INFINITY$1 = 1 / 0;
1060
- function toKey$6(value) {
1060
+ function toKey$5(value) {
1061
1061
  if (typeof value == "string" || isSymbol(value)) {
1062
1062
  return value;
1063
1063
  }
1064
1064
  var result = value + "";
1065
1065
  return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
1066
1066
  }
1067
- var _toKey = toKey$6;
1068
- var castPath$5 = _castPath, toKey$5 = _toKey;
1069
- function baseGet$4(object, path) {
1070
- path = castPath$5(path, object);
1067
+ var _toKey = toKey$5;
1068
+ var castPath$3 = _castPath, toKey$4 = _toKey;
1069
+ function baseGet$3(object, path) {
1070
+ path = castPath$3(path, object);
1071
1071
  var index = 0, length = path.length;
1072
1072
  while (object != null && index < length) {
1073
- object = object[toKey$5(path[index++])];
1073
+ object = object[toKey$4(path[index++])];
1074
1074
  }
1075
1075
  return index && index == length ? object : void 0;
1076
1076
  }
1077
- var _baseGet = baseGet$4;
1078
- var baseGet$3 = _baseGet;
1077
+ var _baseGet = baseGet$3;
1078
+ var baseGet$2 = _baseGet;
1079
1079
  function get$1(object, path, defaultValue) {
1080
- var result = object == null ? void 0 : baseGet$3(object, path);
1080
+ var result = object == null ? void 0 : baseGet$2(object, path);
1081
1081
  return result === void 0 ? defaultValue : result;
1082
1082
  }
1083
1083
  var get_1 = get$1;
@@ -1085,12 +1085,12 @@ function baseHasIn$1(object, key) {
1085
1085
  return object != null && key in Object(object);
1086
1086
  }
1087
1087
  var _baseHasIn = baseHasIn$1;
1088
- var castPath$4 = _castPath, isArguments$1 = isArguments_1, isArray$3 = isArray_1, isIndex$1 = _isIndex, isLength = isLength_1, toKey$4 = _toKey;
1088
+ var castPath$2 = _castPath, isArguments = isArguments_1, isArray$1 = isArray_1, isIndex$1 = _isIndex, isLength = isLength_1, toKey$3 = _toKey;
1089
1089
  function hasPath$1(object, path, hasFunc) {
1090
- path = castPath$4(path, object);
1090
+ path = castPath$2(path, object);
1091
1091
  var index = -1, length = path.length, result = false;
1092
1092
  while (++index < length) {
1093
- var key = toKey$4(path[index]);
1093
+ var key = toKey$3(path[index]);
1094
1094
  if (!(result = object != null && hasFunc(object, key))) {
1095
1095
  break;
1096
1096
  }
@@ -1100,7 +1100,7 @@ function hasPath$1(object, path, hasFunc) {
1100
1100
  return result;
1101
1101
  }
1102
1102
  length = object == null ? 0 : object.length;
1103
- return !!length && isLength(length) && isIndex$1(key, length) && (isArray$3(object) || isArguments$1(object));
1103
+ return !!length && isLength(length) && isIndex$1(key, length) && (isArray$1(object) || isArguments(object));
1104
1104
  }
1105
1105
  var _hasPath = hasPath$1;
1106
1106
  var baseHasIn = _baseHasIn, hasPath = _hasPath;
@@ -1108,11 +1108,11 @@ function hasIn$1(object, path) {
1108
1108
  return object != null && hasPath(object, path, baseHasIn);
1109
1109
  }
1110
1110
  var hasIn_1 = hasIn$1;
1111
- var baseIsEqual$1 = _baseIsEqual, get = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$3 = _toKey;
1111
+ var baseIsEqual$1 = _baseIsEqual, get = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$2 = _toKey;
1112
1112
  var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
1113
1113
  function baseMatchesProperty$1(path, srcValue) {
1114
1114
  if (isKey$1(path) && isStrictComparable(srcValue)) {
1115
- return matchesStrictComparable(toKey$3(path), srcValue);
1115
+ return matchesStrictComparable(toKey$2(path), srcValue);
1116
1116
  }
1117
1117
  return function(object) {
1118
1118
  var objValue = get(object, path);
@@ -1120,38 +1120,38 @@ function baseMatchesProperty$1(path, srcValue) {
1120
1120
  };
1121
1121
  }
1122
1122
  var _baseMatchesProperty = baseMatchesProperty$1;
1123
- function identity$2(value) {
1123
+ function identity$1(value) {
1124
1124
  return value;
1125
1125
  }
1126
- var identity_1 = identity$2;
1126
+ var identity_1 = identity$1;
1127
1127
  function baseProperty$1(key) {
1128
1128
  return function(object) {
1129
1129
  return object == null ? void 0 : object[key];
1130
1130
  };
1131
1131
  }
1132
1132
  var _baseProperty = baseProperty$1;
1133
- var baseGet$2 = _baseGet;
1133
+ var baseGet$1 = _baseGet;
1134
1134
  function basePropertyDeep$1(path) {
1135
1135
  return function(object) {
1136
- return baseGet$2(object, path);
1136
+ return baseGet$1(object, path);
1137
1137
  };
1138
1138
  }
1139
1139
  var _basePropertyDeep = basePropertyDeep$1;
1140
- var baseProperty = _baseProperty, basePropertyDeep = _basePropertyDeep, isKey = _isKey, toKey$2 = _toKey;
1140
+ var baseProperty = _baseProperty, basePropertyDeep = _basePropertyDeep, isKey = _isKey, toKey$1 = _toKey;
1141
1141
  function property$1(path) {
1142
- return isKey(path) ? baseProperty(toKey$2(path)) : basePropertyDeep(path);
1142
+ return isKey(path) ? baseProperty(toKey$1(path)) : basePropertyDeep(path);
1143
1143
  }
1144
1144
  var property_1 = property$1;
1145
- var baseMatches = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity$1 = identity_1, isArray$2 = isArray_1, property = property_1;
1145
+ var baseMatches = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity = identity_1, isArray = isArray_1, property = property_1;
1146
1146
  function baseIteratee$2(value) {
1147
1147
  if (typeof value == "function") {
1148
1148
  return value;
1149
1149
  }
1150
1150
  if (value == null) {
1151
- return identity$1;
1151
+ return identity;
1152
1152
  }
1153
1153
  if (typeof value == "object") {
1154
- return isArray$2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
1154
+ return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
1155
1155
  }
1156
1156
  return property(value);
1157
1157
  }
@@ -1178,19 +1178,19 @@ function negate$1(predicate) {
1178
1178
  }
1179
1179
  var negate_1 = negate$1;
1180
1180
  var getNative = _getNative;
1181
- var defineProperty$2 = function() {
1181
+ var defineProperty$1 = function() {
1182
1182
  try {
1183
1183
  var func = getNative(Object, "defineProperty");
1184
1184
  func({}, "", {});
1185
1185
  return func;
1186
- } catch (e) {
1186
+ } catch (e2) {
1187
1187
  }
1188
1188
  }();
1189
- var _defineProperty = defineProperty$2;
1190
- var defineProperty$1 = _defineProperty;
1191
- function baseAssignValue$2(object, key, value) {
1192
- if (key == "__proto__" && defineProperty$1) {
1193
- defineProperty$1(object, key, {
1189
+ var _defineProperty = defineProperty$1;
1190
+ var defineProperty = _defineProperty;
1191
+ function baseAssignValue$1(object, key, value) {
1192
+ if (key == "__proto__" && defineProperty) {
1193
+ defineProperty(object, key, {
1194
1194
  "configurable": true,
1195
1195
  "enumerable": true,
1196
1196
  "value": value,
@@ -1200,26 +1200,26 @@ function baseAssignValue$2(object, key, value) {
1200
1200
  object[key] = value;
1201
1201
  }
1202
1202
  }
1203
- var _baseAssignValue = baseAssignValue$2;
1204
- var baseAssignValue$1 = _baseAssignValue, eq = eq_1;
1205
- var objectProto$3 = Object.prototype;
1206
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
1207
- function assignValue$3(object, key, value) {
1203
+ var _baseAssignValue = baseAssignValue$1;
1204
+ var baseAssignValue = _baseAssignValue, eq = eq_1;
1205
+ var objectProto$1 = Object.prototype;
1206
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1207
+ function assignValue$1(object, key, value) {
1208
1208
  var objValue = object[key];
1209
- if (!(hasOwnProperty$3.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
1210
- baseAssignValue$1(object, key, value);
1209
+ if (!(hasOwnProperty$1.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
1210
+ baseAssignValue(object, key, value);
1211
1211
  }
1212
1212
  }
1213
- var _assignValue = assignValue$3;
1214
- var assignValue$2 = _assignValue, castPath$3 = _castPath, isIndex = _isIndex, isObject$3 = isObject_1, toKey$1 = _toKey;
1213
+ var _assignValue = assignValue$1;
1214
+ var assignValue = _assignValue, castPath$1 = _castPath, isIndex = _isIndex, isObject$1 = isObject_1, toKey = _toKey;
1215
1215
  function baseSet$2(object, path, value, customizer) {
1216
- if (!isObject$3(object)) {
1216
+ if (!isObject$1(object)) {
1217
1217
  return object;
1218
1218
  }
1219
- path = castPath$3(path, object);
1219
+ path = castPath$1(path, object);
1220
1220
  var index = -1, length = path.length, lastIndex = length - 1, nested = object;
1221
1221
  while (nested != null && ++index < length) {
1222
- var key = toKey$1(path[index]), newValue = value;
1222
+ var key = toKey(path[index]), newValue = value;
1223
1223
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
1224
1224
  return object;
1225
1225
  }
@@ -1227,41 +1227,41 @@ function baseSet$2(object, path, value, customizer) {
1227
1227
  var objValue = nested[key];
1228
1228
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
1229
1229
  if (newValue === void 0) {
1230
- newValue = isObject$3(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
1230
+ newValue = isObject$1(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
1231
1231
  }
1232
1232
  }
1233
- assignValue$2(nested, key, newValue);
1233
+ assignValue(nested, key, newValue);
1234
1234
  nested = nested[key];
1235
1235
  }
1236
1236
  return object;
1237
1237
  }
1238
1238
  var _baseSet = baseSet$2;
1239
- var baseGet$1 = _baseGet, baseSet$1 = _baseSet, castPath$2 = _castPath;
1239
+ var baseGet = _baseGet, baseSet$1 = _baseSet, castPath = _castPath;
1240
1240
  function basePickBy$1(object, paths, predicate) {
1241
1241
  var index = -1, length = paths.length, result = {};
1242
1242
  while (++index < length) {
1243
- var path = paths[index], value = baseGet$1(object, path);
1243
+ var path = paths[index], value = baseGet(object, path);
1244
1244
  if (predicate(value, path)) {
1245
- baseSet$1(result, castPath$2(path, object), value);
1245
+ baseSet$1(result, castPath(path, object), value);
1246
1246
  }
1247
1247
  }
1248
1248
  return result;
1249
1249
  }
1250
1250
  var _basePickBy = basePickBy$1;
1251
1251
  var overArg = _overArg;
1252
- var getPrototype$3 = overArg(Object.getPrototypeOf, Object);
1253
- var _getPrototype = getPrototype$3;
1254
- var arrayPush$1 = _arrayPush, getPrototype$2 = _getPrototype, getSymbols$1 = _getSymbols, stubArray = stubArray_1;
1252
+ var getPrototype$1 = overArg(Object.getPrototypeOf, Object);
1253
+ var _getPrototype = getPrototype$1;
1254
+ var arrayPush = _arrayPush, getPrototype = _getPrototype, getSymbols = _getSymbols, stubArray = stubArray_1;
1255
1255
  var nativeGetSymbols = Object.getOwnPropertySymbols;
1256
- var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
1256
+ var getSymbolsIn$1 = !nativeGetSymbols ? stubArray : function(object) {
1257
1257
  var result = [];
1258
1258
  while (object) {
1259
- arrayPush$1(result, getSymbols$1(object));
1260
- object = getPrototype$2(object);
1259
+ arrayPush(result, getSymbols(object));
1260
+ object = getPrototype(object);
1261
1261
  }
1262
1262
  return result;
1263
1263
  };
1264
- var _getSymbolsIn = getSymbolsIn$2;
1264
+ var _getSymbolsIn = getSymbolsIn$1;
1265
1265
  function nativeKeysIn$1(object) {
1266
1266
  var result = [];
1267
1267
  if (object != null) {
@@ -1272,16 +1272,16 @@ function nativeKeysIn$1(object) {
1272
1272
  return result;
1273
1273
  }
1274
1274
  var _nativeKeysIn = nativeKeysIn$1;
1275
- var isObject$2 = isObject_1, isPrototype$1 = _isPrototype, nativeKeysIn = _nativeKeysIn;
1276
- var objectProto$2 = Object.prototype;
1277
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
1275
+ var isObject = isObject_1, isPrototype = _isPrototype, nativeKeysIn = _nativeKeysIn;
1276
+ var objectProto = Object.prototype;
1277
+ var hasOwnProperty = objectProto.hasOwnProperty;
1278
1278
  function baseKeysIn$1(object) {
1279
- if (!isObject$2(object)) {
1279
+ if (!isObject(object)) {
1280
1280
  return nativeKeysIn(object);
1281
1281
  }
1282
- var isProto = isPrototype$1(object), result = [];
1282
+ var isProto = isPrototype(object), result = [];
1283
1283
  for (var key in object) {
1284
- if (!(key == "constructor" && (isProto || !hasOwnProperty$2.call(object, key)))) {
1284
+ if (!(key == "constructor" && (isProto || !hasOwnProperty.call(object, key)))) {
1285
1285
  result.push(key);
1286
1286
  }
1287
1287
  }
@@ -1289,21 +1289,21 @@ function baseKeysIn$1(object) {
1289
1289
  }
1290
1290
  var _baseKeysIn = baseKeysIn$1;
1291
1291
  var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike = isArrayLike_1;
1292
- function keysIn$3(object) {
1292
+ function keysIn$1(object) {
1293
1293
  return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
1294
1294
  }
1295
- var keysIn_1 = keysIn$3;
1296
- var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn$1 = _getSymbolsIn, keysIn$2 = keysIn_1;
1297
- function getAllKeysIn$3(object) {
1298
- return baseGetAllKeys(object, keysIn$2, getSymbolsIn$1);
1295
+ var keysIn_1 = keysIn$1;
1296
+ var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn = keysIn_1;
1297
+ function getAllKeysIn$1(object) {
1298
+ return baseGetAllKeys(object, keysIn, getSymbolsIn);
1299
1299
  }
1300
- var _getAllKeysIn = getAllKeysIn$3;
1301
- var arrayMap$1 = _arrayMap, baseIteratee$1 = _baseIteratee, basePickBy = _basePickBy, getAllKeysIn$2 = _getAllKeysIn;
1300
+ var _getAllKeysIn = getAllKeysIn$1;
1301
+ var arrayMap = _arrayMap, baseIteratee$1 = _baseIteratee, basePickBy = _basePickBy, getAllKeysIn = _getAllKeysIn;
1302
1302
  function pickBy$1(object, predicate) {
1303
1303
  if (object == null) {
1304
1304
  return {};
1305
1305
  }
1306
- var props = arrayMap$1(getAllKeysIn$2(object), function(prop) {
1306
+ var props = arrayMap(getAllKeysIn(object), function(prop) {
1307
1307
  return [prop];
1308
1308
  });
1309
1309
  predicate = baseIteratee$1(predicate);
@@ -1377,821 +1377,6 @@ const createGetInputProps = ({
1377
1377
  return omitBy_1(inputProps, (value) => value === void 0);
1378
1378
  };
1379
1379
  };
1380
- const SUSPENSE_PROMISE = Symbol();
1381
- const isSuspensePromise = (promise) => !!promise[SUSPENSE_PROMISE];
1382
- const isSuspensePromiseAlreadyCancelled = (suspensePromise) => !suspensePromise[SUSPENSE_PROMISE].c;
1383
- const cancelSuspensePromise = (suspensePromise) => {
1384
- var _a, _b;
1385
- (_b = (_a = suspensePromise[SUSPENSE_PROMISE]).c) == null ? void 0 : _b.call(_a);
1386
- };
1387
- const isEqualSuspensePromise = (oldSuspensePromise, newSuspensePromise) => {
1388
- const oldOriginalPromise = oldSuspensePromise[SUSPENSE_PROMISE].o;
1389
- const newOriginalPromise = newSuspensePromise[SUSPENSE_PROMISE].o;
1390
- return oldOriginalPromise === newOriginalPromise || oldSuspensePromise === newOriginalPromise || isSuspensePromise(oldOriginalPromise) && isEqualSuspensePromise(oldOriginalPromise, newSuspensePromise);
1391
- };
1392
- const createSuspensePromise = (promise) => {
1393
- const objectToAttach = {
1394
- o: promise,
1395
- c: null
1396
- };
1397
- const suspensePromise = new Promise((resolve) => {
1398
- objectToAttach.c = () => {
1399
- objectToAttach.c = null;
1400
- resolve();
1401
- };
1402
- promise.then(objectToAttach.c, objectToAttach.c);
1403
- });
1404
- suspensePromise[SUSPENSE_PROMISE] = objectToAttach;
1405
- return suspensePromise;
1406
- };
1407
- var __defProp$1 = Object.defineProperty;
1408
- var __defProps$1 = Object.defineProperties;
1409
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1410
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1411
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1412
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1413
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1414
- var __spreadValues$1 = (a, b) => {
1415
- for (var prop in b || (b = {}))
1416
- if (__hasOwnProp$1.call(b, prop))
1417
- __defNormalProp$1(a, prop, b[prop]);
1418
- if (__getOwnPropSymbols$1)
1419
- for (var prop of __getOwnPropSymbols$1(b)) {
1420
- if (__propIsEnum$1.call(b, prop))
1421
- __defNormalProp$1(a, prop, b[prop]);
1422
- }
1423
- return a;
1424
- };
1425
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1426
- const hasInitialValue = (atom2) => "init" in atom2;
1427
- const READ_ATOM = "r";
1428
- const WRITE_ATOM$1 = "w";
1429
- const COMMIT_ATOM = "c";
1430
- const SUBSCRIBE_ATOM = "s";
1431
- const RESTORE_ATOMS = "h";
1432
- const DEV_SUBSCRIBE_STATE = "n";
1433
- const DEV_GET_MOUNTED_ATOMS = "l";
1434
- const DEV_GET_ATOM_STATE = "a";
1435
- const DEV_GET_MOUNTED = "m";
1436
- const createStore = (initialValues) => {
1437
- const committedAtomStateMap = /* @__PURE__ */ new WeakMap();
1438
- const mountedMap = /* @__PURE__ */ new WeakMap();
1439
- const pendingMap = /* @__PURE__ */ new Map();
1440
- let stateListeners;
1441
- let mountedAtoms;
1442
- if (typeof process === "object" && false) {
1443
- stateListeners = /* @__PURE__ */ new Set();
1444
- mountedAtoms = /* @__PURE__ */ new Set();
1445
- }
1446
- if (initialValues) {
1447
- for (const [atom2, value] of initialValues) {
1448
- const atomState = { v: value, r: 0, d: /* @__PURE__ */ new Map() };
1449
- if (typeof process === "object" && false) {
1450
- Object.freeze(atomState);
1451
- if (!hasInitialValue(atom2)) {
1452
- console.warn("Found initial value for derived atom which can cause unexpected behavior", atom2);
1453
- }
1454
- }
1455
- committedAtomStateMap.set(atom2, atomState);
1456
- }
1457
- }
1458
- const suspensePromiseCacheMap = /* @__PURE__ */ new WeakMap();
1459
- const addSuspensePromiseToCache = (version, atom2, suspensePromise) => {
1460
- let cache = suspensePromiseCacheMap.get(atom2);
1461
- if (!cache) {
1462
- cache = /* @__PURE__ */ new Map();
1463
- suspensePromiseCacheMap.set(atom2, cache);
1464
- }
1465
- suspensePromise.then(() => {
1466
- if (cache.get(version) === suspensePromise) {
1467
- cache.delete(version);
1468
- if (!cache.size) {
1469
- suspensePromiseCacheMap.delete(atom2);
1470
- }
1471
- }
1472
- });
1473
- cache.set(version, suspensePromise);
1474
- };
1475
- const cancelAllSuspensePromiseInCache = (atom2) => {
1476
- const versionSet = /* @__PURE__ */ new Set();
1477
- const cache = suspensePromiseCacheMap.get(atom2);
1478
- if (cache) {
1479
- suspensePromiseCacheMap.delete(atom2);
1480
- cache.forEach((suspensePromise, version) => {
1481
- cancelSuspensePromise(suspensePromise);
1482
- versionSet.add(version);
1483
- });
1484
- }
1485
- return versionSet;
1486
- };
1487
- const versionedAtomStateMapMap = /* @__PURE__ */ new WeakMap();
1488
- const getVersionedAtomStateMap = (version) => {
1489
- let versionedAtomStateMap = versionedAtomStateMapMap.get(version);
1490
- if (!versionedAtomStateMap) {
1491
- versionedAtomStateMap = /* @__PURE__ */ new Map();
1492
- versionedAtomStateMapMap.set(version, versionedAtomStateMap);
1493
- }
1494
- return versionedAtomStateMap;
1495
- };
1496
- const getAtomState = (version, atom2) => {
1497
- if (version) {
1498
- const versionedAtomStateMap = getVersionedAtomStateMap(version);
1499
- let atomState = versionedAtomStateMap.get(atom2);
1500
- if (!atomState) {
1501
- atomState = getAtomState(version.p, atom2);
1502
- if (atomState) {
1503
- if ("p" in atomState) {
1504
- atomState.p.then(() => versionedAtomStateMap.delete(atom2));
1505
- }
1506
- versionedAtomStateMap.set(atom2, atomState);
1507
- }
1508
- }
1509
- return atomState;
1510
- }
1511
- return committedAtomStateMap.get(atom2);
1512
- };
1513
- const setAtomState = (version, atom2, atomState) => {
1514
- if (typeof process === "object" && false) {
1515
- Object.freeze(atomState);
1516
- }
1517
- if (version) {
1518
- const versionedAtomStateMap = getVersionedAtomStateMap(version);
1519
- versionedAtomStateMap.set(atom2, atomState);
1520
- } else {
1521
- const prevAtomState = committedAtomStateMap.get(atom2);
1522
- committedAtomStateMap.set(atom2, atomState);
1523
- if (!pendingMap.has(atom2)) {
1524
- pendingMap.set(atom2, prevAtomState);
1525
- }
1526
- }
1527
- };
1528
- const createReadDependencies = (version, prevReadDependencies = /* @__PURE__ */ new Map(), dependencies) => {
1529
- if (!dependencies) {
1530
- return prevReadDependencies;
1531
- }
1532
- const readDependencies = /* @__PURE__ */ new Map();
1533
- let changed = false;
1534
- dependencies.forEach((atom2) => {
1535
- var _a;
1536
- const revision = ((_a = getAtomState(version, atom2)) == null ? void 0 : _a.r) || 0;
1537
- readDependencies.set(atom2, revision);
1538
- if (prevReadDependencies.get(atom2) !== revision) {
1539
- changed = true;
1540
- }
1541
- });
1542
- if (prevReadDependencies.size === readDependencies.size && !changed) {
1543
- return prevReadDependencies;
1544
- }
1545
- return readDependencies;
1546
- };
1547
- const setAtomValue = (version, atom2, value, dependencies, suspensePromise) => {
1548
- const atomState = getAtomState(version, atom2);
1549
- if (atomState) {
1550
- if (suspensePromise && (!("p" in atomState) || !isEqualSuspensePromise(atomState.p, suspensePromise))) {
1551
- return atomState;
1552
- }
1553
- if ("p" in atomState) {
1554
- cancelSuspensePromise(atomState.p);
1555
- }
1556
- }
1557
- const nextAtomState = {
1558
- v: value,
1559
- r: (atomState == null ? void 0 : atomState.r) || 0,
1560
- d: createReadDependencies(version, atomState == null ? void 0 : atomState.d, dependencies)
1561
- };
1562
- if (!atomState || !("v" in atomState) || !Object.is(atomState.v, value)) {
1563
- ++nextAtomState.r;
1564
- if (nextAtomState.d.has(atom2)) {
1565
- nextAtomState.d = new Map(nextAtomState.d).set(atom2, nextAtomState.r);
1566
- }
1567
- } else if (nextAtomState.d !== atomState.d && (nextAtomState.d.size !== atomState.d.size || !Array.from(nextAtomState.d.keys()).every((a) => atomState.d.has(a)))) {
1568
- Promise.resolve().then(() => {
1569
- flushPending(version);
1570
- });
1571
- }
1572
- setAtomState(version, atom2, nextAtomState);
1573
- return nextAtomState;
1574
- };
1575
- const setAtomReadError = (version, atom2, error, dependencies, suspensePromise) => {
1576
- const atomState = getAtomState(version, atom2);
1577
- if (atomState) {
1578
- if (suspensePromise && (!("p" in atomState) || !isEqualSuspensePromise(atomState.p, suspensePromise))) {
1579
- return atomState;
1580
- }
1581
- if ("p" in atomState) {
1582
- cancelSuspensePromise(atomState.p);
1583
- }
1584
- }
1585
- const nextAtomState = {
1586
- e: error,
1587
- r: (atomState == null ? void 0 : atomState.r) || 0,
1588
- d: createReadDependencies(version, atomState == null ? void 0 : atomState.d, dependencies)
1589
- };
1590
- setAtomState(version, atom2, nextAtomState);
1591
- return nextAtomState;
1592
- };
1593
- const setAtomSuspensePromise = (version, atom2, suspensePromise, dependencies) => {
1594
- const atomState = getAtomState(version, atom2);
1595
- if (atomState && "p" in atomState) {
1596
- if (isEqualSuspensePromise(atomState.p, suspensePromise)) {
1597
- return atomState;
1598
- }
1599
- cancelSuspensePromise(atomState.p);
1600
- }
1601
- addSuspensePromiseToCache(version, atom2, suspensePromise);
1602
- const nextAtomState = {
1603
- p: suspensePromise,
1604
- r: (atomState == null ? void 0 : atomState.r) || 0,
1605
- d: createReadDependencies(version, atomState == null ? void 0 : atomState.d, dependencies)
1606
- };
1607
- setAtomState(version, atom2, nextAtomState);
1608
- return nextAtomState;
1609
- };
1610
- const setAtomPromiseOrValue = (version, atom2, promiseOrValue, dependencies) => {
1611
- if (promiseOrValue instanceof Promise) {
1612
- const suspensePromise = createSuspensePromise(promiseOrValue.then((value) => {
1613
- setAtomValue(version, atom2, value, dependencies, suspensePromise);
1614
- flushPending(version);
1615
- }).catch((e) => {
1616
- if (e instanceof Promise) {
1617
- if (isSuspensePromise(e)) {
1618
- return e.then(() => {
1619
- readAtomState(version, atom2, true);
1620
- });
1621
- }
1622
- return e;
1623
- }
1624
- setAtomReadError(version, atom2, e, dependencies, suspensePromise);
1625
- flushPending(version);
1626
- }));
1627
- return setAtomSuspensePromise(version, atom2, suspensePromise, dependencies);
1628
- }
1629
- return setAtomValue(version, atom2, promiseOrValue, dependencies);
1630
- };
1631
- const setAtomInvalidated = (version, atom2) => {
1632
- const atomState = getAtomState(version, atom2);
1633
- if (atomState) {
1634
- const nextAtomState = __spreadProps$1(__spreadValues$1({}, atomState), {
1635
- i: atomState.r
1636
- });
1637
- setAtomState(version, atom2, nextAtomState);
1638
- } else if (typeof process === "object" && false) {
1639
- console.warn("[Bug] could not invalidate non existing atom", atom2);
1640
- }
1641
- };
1642
- const readAtomState = (version, atom2, force) => {
1643
- if (!force) {
1644
- const atomState = getAtomState(version, atom2);
1645
- if (atomState) {
1646
- if (atomState.r !== atomState.i && "p" in atomState && !isSuspensePromiseAlreadyCancelled(atomState.p)) {
1647
- return atomState;
1648
- }
1649
- atomState.d.forEach((_, a) => {
1650
- if (a !== atom2) {
1651
- if (!mountedMap.has(a)) {
1652
- readAtomState(version, a);
1653
- } else {
1654
- const aState = getAtomState(version, a);
1655
- if (aState && aState.r === aState.i) {
1656
- readAtomState(version, a);
1657
- }
1658
- }
1659
- }
1660
- });
1661
- if (Array.from(atomState.d).every(([a, r]) => {
1662
- const aState = getAtomState(version, a);
1663
- return aState && "v" in aState && aState.r === r;
1664
- })) {
1665
- return atomState;
1666
- }
1667
- }
1668
- }
1669
- const dependencies = /* @__PURE__ */ new Set();
1670
- try {
1671
- const promiseOrValue = atom2.read((a) => {
1672
- dependencies.add(a);
1673
- const aState = a === atom2 ? getAtomState(version, a) : readAtomState(version, a);
1674
- if (aState) {
1675
- if ("e" in aState) {
1676
- throw aState.e;
1677
- }
1678
- if ("p" in aState) {
1679
- throw aState.p;
1680
- }
1681
- return aState.v;
1682
- }
1683
- if (hasInitialValue(a)) {
1684
- return a.init;
1685
- }
1686
- throw new Error("no atom init");
1687
- });
1688
- return setAtomPromiseOrValue(version, atom2, promiseOrValue, dependencies);
1689
- } catch (errorOrPromise) {
1690
- if (errorOrPromise instanceof Promise) {
1691
- const suspensePromise = createSuspensePromise(errorOrPromise);
1692
- return setAtomSuspensePromise(version, atom2, suspensePromise, dependencies);
1693
- }
1694
- return setAtomReadError(version, atom2, errorOrPromise, dependencies);
1695
- }
1696
- };
1697
- const readAtom = (readingAtom, version) => {
1698
- const atomState = readAtomState(version, readingAtom);
1699
- return atomState;
1700
- };
1701
- const addAtom = (addingAtom) => {
1702
- let mounted = mountedMap.get(addingAtom);
1703
- if (!mounted) {
1704
- mounted = mountAtom(addingAtom);
1705
- }
1706
- return mounted;
1707
- };
1708
- const canUnmountAtom = (atom2, mounted) => !mounted.l.size && (!mounted.t.size || mounted.t.size === 1 && mounted.t.has(atom2));
1709
- const delAtom = (deletingAtom) => {
1710
- const mounted = mountedMap.get(deletingAtom);
1711
- if (mounted && canUnmountAtom(deletingAtom, mounted)) {
1712
- unmountAtom(deletingAtom);
1713
- }
1714
- };
1715
- const invalidateDependents = (version, atom2) => {
1716
- const mounted = mountedMap.get(atom2);
1717
- mounted == null ? void 0 : mounted.t.forEach((dependent) => {
1718
- if (dependent !== atom2) {
1719
- setAtomInvalidated(version, dependent);
1720
- invalidateDependents(version, dependent);
1721
- }
1722
- });
1723
- };
1724
- const writeAtomState = (version, atom2, update) => {
1725
- let isSync = true;
1726
- const writeGetter = (a, options) => {
1727
- if (typeof options === "boolean") {
1728
- console.warn("[DEPRECATED] Please use { unstable_promise: true }");
1729
- options = { unstable_promise: options };
1730
- }
1731
- const aState = readAtomState(version, a);
1732
- if ("e" in aState) {
1733
- throw aState.e;
1734
- }
1735
- if ("p" in aState) {
1736
- if (options == null ? void 0 : options.unstable_promise) {
1737
- return aState.p.then(() => writeGetter(a, options));
1738
- }
1739
- if (typeof process === "object" && false) {
1740
- console.info("Reading pending atom state in write operation. We throw a promise for now.", a);
1741
- }
1742
- throw aState.p;
1743
- }
1744
- if ("v" in aState) {
1745
- return aState.v;
1746
- }
1747
- if (typeof process === "object" && false) {
1748
- console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.", a);
1749
- }
1750
- throw new Error("no value found");
1751
- };
1752
- const setter = (a, v) => {
1753
- let promiseOrVoid2;
1754
- if (a === atom2) {
1755
- if (!hasInitialValue(a)) {
1756
- throw new Error("atom not writable");
1757
- }
1758
- const versionSet = cancelAllSuspensePromiseInCache(a);
1759
- versionSet.forEach((cancelledVersion) => {
1760
- if (cancelledVersion !== version) {
1761
- setAtomPromiseOrValue(cancelledVersion, a, v);
1762
- }
1763
- });
1764
- setAtomPromiseOrValue(version, a, v);
1765
- invalidateDependents(version, a);
1766
- } else {
1767
- promiseOrVoid2 = writeAtomState(version, a, v);
1768
- }
1769
- if (!isSync) {
1770
- flushPending(version);
1771
- }
1772
- return promiseOrVoid2;
1773
- };
1774
- const promiseOrVoid = atom2.write(writeGetter, setter, update);
1775
- isSync = false;
1776
- version = void 0;
1777
- return promiseOrVoid;
1778
- };
1779
- const writeAtom = (writingAtom, update, version) => {
1780
- const promiseOrVoid = writeAtomState(version, writingAtom, update);
1781
- flushPending(version);
1782
- return promiseOrVoid;
1783
- };
1784
- const isActuallyWritableAtom = (atom2) => !!atom2.write;
1785
- const mountAtom = (atom2, initialDependent) => {
1786
- const mounted = {
1787
- t: new Set(initialDependent && [initialDependent]),
1788
- l: /* @__PURE__ */ new Set()
1789
- };
1790
- mountedMap.set(atom2, mounted);
1791
- if (typeof process === "object" && false) {
1792
- mountedAtoms.add(atom2);
1793
- }
1794
- const atomState = readAtomState(void 0, atom2);
1795
- atomState.d.forEach((_, a) => {
1796
- const aMounted = mountedMap.get(a);
1797
- if (aMounted) {
1798
- aMounted.t.add(atom2);
1799
- } else {
1800
- if (a !== atom2) {
1801
- mountAtom(a, atom2);
1802
- }
1803
- }
1804
- });
1805
- if (isActuallyWritableAtom(atom2) && atom2.onMount) {
1806
- const setAtom = (update) => writeAtom(atom2, update);
1807
- const onUnmount = atom2.onMount(setAtom);
1808
- if (onUnmount) {
1809
- mounted.u = onUnmount;
1810
- }
1811
- }
1812
- return mounted;
1813
- };
1814
- const unmountAtom = (atom2) => {
1815
- var _a;
1816
- const onUnmount = (_a = mountedMap.get(atom2)) == null ? void 0 : _a.u;
1817
- if (onUnmount) {
1818
- onUnmount();
1819
- }
1820
- mountedMap.delete(atom2);
1821
- if (typeof process === "object" && false) {
1822
- mountedAtoms.delete(atom2);
1823
- }
1824
- const atomState = getAtomState(void 0, atom2);
1825
- if (atomState) {
1826
- atomState.d.forEach((_, a) => {
1827
- if (a !== atom2) {
1828
- const mounted = mountedMap.get(a);
1829
- if (mounted) {
1830
- mounted.t.delete(atom2);
1831
- if (canUnmountAtom(a, mounted)) {
1832
- unmountAtom(a);
1833
- }
1834
- }
1835
- }
1836
- });
1837
- } else if (typeof process === "object" && false) {
1838
- console.warn("[Bug] could not find atom state to unmount", atom2);
1839
- }
1840
- };
1841
- const mountDependencies = (atom2, atomState, prevReadDependencies) => {
1842
- const dependencies = new Set(atomState.d.keys());
1843
- prevReadDependencies == null ? void 0 : prevReadDependencies.forEach((_, a) => {
1844
- if (dependencies.has(a)) {
1845
- dependencies.delete(a);
1846
- return;
1847
- }
1848
- const mounted = mountedMap.get(a);
1849
- if (mounted) {
1850
- mounted.t.delete(atom2);
1851
- if (canUnmountAtom(a, mounted)) {
1852
- unmountAtom(a);
1853
- }
1854
- }
1855
- });
1856
- dependencies.forEach((a) => {
1857
- const mounted = mountedMap.get(a);
1858
- if (mounted) {
1859
- mounted.t.add(atom2);
1860
- } else if (mountedMap.has(atom2)) {
1861
- mountAtom(a, atom2);
1862
- }
1863
- });
1864
- };
1865
- const flushPending = (version) => {
1866
- if (version) {
1867
- const versionedAtomStateMap = getVersionedAtomStateMap(version);
1868
- versionedAtomStateMap.forEach((atomState, atom2) => {
1869
- if (atomState !== committedAtomStateMap.get(atom2)) {
1870
- const mounted = mountedMap.get(atom2);
1871
- mounted == null ? void 0 : mounted.l.forEach((listener) => listener(version));
1872
- }
1873
- });
1874
- return;
1875
- }
1876
- while (pendingMap.size) {
1877
- const pending = Array.from(pendingMap);
1878
- pendingMap.clear();
1879
- pending.forEach(([atom2, prevAtomState]) => {
1880
- const atomState = getAtomState(void 0, atom2);
1881
- if (atomState && atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {
1882
- mountDependencies(atom2, atomState, prevAtomState == null ? void 0 : prevAtomState.d);
1883
- }
1884
- const mounted = mountedMap.get(atom2);
1885
- mounted == null ? void 0 : mounted.l.forEach((listener) => listener());
1886
- });
1887
- }
1888
- if (typeof process === "object" && false) {
1889
- stateListeners.forEach((l) => l());
1890
- }
1891
- };
1892
- const commitVersionedAtomStateMap = (version) => {
1893
- const versionedAtomStateMap = getVersionedAtomStateMap(version);
1894
- versionedAtomStateMap.forEach((atomState, atom2) => {
1895
- const prevAtomState = committedAtomStateMap.get(atom2);
1896
- if (atomState.r > ((prevAtomState == null ? void 0 : prevAtomState.r) || 0) || "v" in atomState && atomState.r === (prevAtomState == null ? void 0 : prevAtomState.r) && atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {
1897
- committedAtomStateMap.set(atom2, atomState);
1898
- if (atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {
1899
- mountDependencies(atom2, atomState, prevAtomState == null ? void 0 : prevAtomState.d);
1900
- }
1901
- }
1902
- });
1903
- };
1904
- const commitAtom = (_atom, version) => {
1905
- if (version) {
1906
- commitVersionedAtomStateMap(version);
1907
- }
1908
- flushPending(void 0);
1909
- };
1910
- const subscribeAtom = (atom2, callback) => {
1911
- const mounted = addAtom(atom2);
1912
- const listeners = mounted.l;
1913
- listeners.add(callback);
1914
- return () => {
1915
- listeners.delete(callback);
1916
- delAtom(atom2);
1917
- };
1918
- };
1919
- const restoreAtoms = (values, version) => {
1920
- for (const [atom2, value] of values) {
1921
- if (hasInitialValue(atom2)) {
1922
- setAtomPromiseOrValue(version, atom2, value);
1923
- invalidateDependents(version, atom2);
1924
- }
1925
- }
1926
- flushPending(version);
1927
- };
1928
- if (typeof process === "object" && false) {
1929
- return {
1930
- [READ_ATOM]: readAtom,
1931
- [WRITE_ATOM$1]: writeAtom,
1932
- [COMMIT_ATOM]: commitAtom,
1933
- [SUBSCRIBE_ATOM]: subscribeAtom,
1934
- [RESTORE_ATOMS]: restoreAtoms,
1935
- [DEV_SUBSCRIBE_STATE]: (l) => {
1936
- stateListeners.add(l);
1937
- return () => {
1938
- stateListeners.delete(l);
1939
- };
1940
- },
1941
- [DEV_GET_MOUNTED_ATOMS]: () => mountedAtoms.values(),
1942
- [DEV_GET_ATOM_STATE]: (a) => committedAtomStateMap.get(a),
1943
- [DEV_GET_MOUNTED]: (a) => mountedMap.get(a)
1944
- };
1945
- }
1946
- return {
1947
- [READ_ATOM]: readAtom,
1948
- [WRITE_ATOM$1]: writeAtom,
1949
- [COMMIT_ATOM]: commitAtom,
1950
- [SUBSCRIBE_ATOM]: subscribeAtom,
1951
- [RESTORE_ATOMS]: restoreAtoms
1952
- };
1953
- };
1954
- const createScopeContainer = (initialValues) => {
1955
- const store = createStore(initialValues);
1956
- return { s: store };
1957
- };
1958
- const ScopeContextMap = /* @__PURE__ */ new Map();
1959
- const getScopeContext = (scope) => {
1960
- if (!ScopeContextMap.has(scope)) {
1961
- ScopeContextMap.set(scope, createContext(createScopeContainer()));
1962
- }
1963
- return ScopeContextMap.get(scope);
1964
- };
1965
- let keyCount = 0;
1966
- function atom(read, write) {
1967
- const key = `atom${++keyCount}`;
1968
- const config = {
1969
- toString: () => key
1970
- };
1971
- if (typeof read === "function") {
1972
- config.read = read;
1973
- } else {
1974
- config.init = read;
1975
- config.read = (get2) => get2(config);
1976
- config.write = (get2, set2, update) => set2(config, typeof update === "function" ? update(get2(config)) : update);
1977
- }
1978
- if (write) {
1979
- config.write = write;
1980
- }
1981
- return config;
1982
- }
1983
- const isWritable = (atom2) => !!atom2.write;
1984
- function useAtom(atom2, scope) {
1985
- if ("scope" in atom2) {
1986
- console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead.");
1987
- scope = atom2.scope;
1988
- }
1989
- const ScopeContext = getScopeContext(scope);
1990
- const { s: store, w: versionedWrite } = useContext(ScopeContext);
1991
- const getAtomValue = useCallback((version2) => {
1992
- const atomState = store[READ_ATOM](atom2, version2);
1993
- if ("e" in atomState) {
1994
- throw atomState.e;
1995
- }
1996
- if ("p" in atomState) {
1997
- throw atomState.p;
1998
- }
1999
- if ("v" in atomState) {
2000
- return atomState.v;
2001
- }
2002
- throw new Error("no atom value");
2003
- }, [store, atom2]);
2004
- const [[version, value, atomFromUseReducer], rerenderIfChanged] = useReducer(useCallback((prev, nextVersion) => {
2005
- const nextValue = getAtomValue(nextVersion);
2006
- if (Object.is(prev[1], nextValue) && prev[2] === atom2) {
2007
- return prev;
2008
- }
2009
- return [nextVersion, nextValue, atom2];
2010
- }, [getAtomValue, atom2]), void 0, () => {
2011
- const initialVersion = void 0;
2012
- const initialValue = getAtomValue(initialVersion);
2013
- return [initialVersion, initialValue, atom2];
2014
- });
2015
- if (atomFromUseReducer !== atom2) {
2016
- rerenderIfChanged(void 0);
2017
- }
2018
- useEffect(() => {
2019
- const unsubscribe = store[SUBSCRIBE_ATOM](atom2, rerenderIfChanged);
2020
- rerenderIfChanged(void 0);
2021
- return unsubscribe;
2022
- }, [store, atom2]);
2023
- useEffect(() => {
2024
- store[COMMIT_ATOM](atom2, version);
2025
- });
2026
- const setAtom = useCallback((update) => {
2027
- if (isWritable(atom2)) {
2028
- const write = (version2) => store[WRITE_ATOM$1](atom2, update, version2);
2029
- return versionedWrite ? versionedWrite(write) : write();
2030
- } else {
2031
- throw new Error("not writable atom");
2032
- }
2033
- }, [store, versionedWrite, atom2]);
2034
- useDebugValue(value);
2035
- return [value, setAtom];
2036
- }
2037
- const WRITE_ATOM = "w";
2038
- function useUpdateAtom(anAtom, scope) {
2039
- const ScopeContext = getScopeContext(scope);
2040
- const { s: store, w: versionedWrite } = useContext(ScopeContext);
2041
- const setAtom = useCallback((update) => {
2042
- const write = (version) => store[WRITE_ATOM](anAtom, update, version);
2043
- return versionedWrite ? versionedWrite(write) : write();
2044
- }, [store, versionedWrite, anAtom]);
2045
- return setAtom;
2046
- }
2047
- function useAtomValue(anAtom, scope) {
2048
- return useAtom(anAtom, scope)[0];
2049
- }
2050
- function atomFamily(initializeAtom, areEqual) {
2051
- let shouldRemove = null;
2052
- const atoms = /* @__PURE__ */ new Map();
2053
- const createAtom = (param) => {
2054
- let item;
2055
- if (areEqual === void 0) {
2056
- item = atoms.get(param);
2057
- } else {
2058
- for (const [key, value] of atoms) {
2059
- if (areEqual(key, param)) {
2060
- item = value;
2061
- break;
2062
- }
2063
- }
2064
- }
2065
- if (item !== void 0) {
2066
- if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) {
2067
- atoms.delete(param);
2068
- } else {
2069
- return item[0];
2070
- }
2071
- }
2072
- const newAtom = initializeAtom(param);
2073
- atoms.set(param, [newAtom, Date.now()]);
2074
- return newAtom;
2075
- };
2076
- createAtom.remove = (param) => {
2077
- if (areEqual === void 0) {
2078
- atoms.delete(param);
2079
- } else {
2080
- for (const [key] of atoms) {
2081
- if (areEqual(key, param)) {
2082
- atoms.delete(key);
2083
- break;
2084
- }
2085
- }
2086
- }
2087
- };
2088
- createAtom.setShouldRemove = (fn) => {
2089
- shouldRemove = fn;
2090
- if (!shouldRemove)
2091
- return;
2092
- for (const [key, value] of atoms) {
2093
- if (shouldRemove(value[1], key)) {
2094
- atoms.delete(key);
2095
- }
2096
- }
2097
- };
2098
- return createAtom;
2099
- }
2100
- const getWeakCacheItem = (cache, deps) => {
2101
- do {
2102
- const [dep, ...rest] = deps;
2103
- const entry = cache.get(dep);
2104
- if (!entry) {
2105
- return;
2106
- }
2107
- if (!rest.length) {
2108
- return entry[1];
2109
- }
2110
- cache = entry[0];
2111
- deps = rest;
2112
- } while (deps.length);
2113
- };
2114
- const setWeakCacheItem = (cache, deps, item) => {
2115
- do {
2116
- const [dep, ...rest] = deps;
2117
- let entry = cache.get(dep);
2118
- if (!entry) {
2119
- entry = [/* @__PURE__ */ new WeakMap()];
2120
- cache.set(dep, entry);
2121
- }
2122
- if (!rest.length) {
2123
- entry[1] = item;
2124
- return;
2125
- }
2126
- cache = entry[0];
2127
- deps = rest;
2128
- } while (deps.length);
2129
- };
2130
- const createMemoizeAtom = () => {
2131
- const cache = /* @__PURE__ */ new WeakMap();
2132
- const memoizeAtom = (createAtom, deps) => {
2133
- const cachedAtom = getWeakCacheItem(cache, deps);
2134
- if (cachedAtom) {
2135
- return cachedAtom;
2136
- }
2137
- const createdAtom = createAtom();
2138
- setWeakCacheItem(cache, deps, createdAtom);
2139
- return createdAtom;
2140
- };
2141
- return memoizeAtom;
2142
- };
2143
- const memoizeAtom$4 = createMemoizeAtom();
2144
- function selectAtom(anAtom, selector, equalityFn = Object.is) {
2145
- return memoizeAtom$4(() => {
2146
- const refAtom = atom(() => ({}));
2147
- const derivedAtom = atom((get2) => {
2148
- const slice = selector(get2(anAtom));
2149
- const ref = get2(refAtom);
2150
- if ("prev" in ref && equalityFn(ref.prev, slice)) {
2151
- return ref.prev;
2152
- }
2153
- ref.prev = slice;
2154
- return slice;
2155
- });
2156
- return derivedAtom;
2157
- }, [anAtom, selector, equalityFn]);
2158
- }
2159
- function useAtomCallback(callback, scope) {
2160
- const anAtom = useMemo(() => atom(null, (get2, set2, [arg, resolve, reject]) => {
2161
- try {
2162
- resolve(callback(get2, set2, arg));
2163
- } catch (e) {
2164
- reject(e);
2165
- }
2166
- }), [callback]);
2167
- const invoke = useUpdateAtom(anAtom, scope);
2168
- return useCallback((arg) => new Promise((resolve, reject) => {
2169
- invoke([arg, resolve, reject]);
2170
- }), [invoke]);
2171
- }
2172
- function createJSONStorage(getStringStorage) {
2173
- try {
2174
- if (!getStringStorage().removeItem) {
2175
- console.warn("Missing removeItem. In the next version, it will be required.");
2176
- }
2177
- } catch {
2178
- }
2179
- return {
2180
- getItem: (key) => {
2181
- const value = getStringStorage().getItem(key);
2182
- if (value instanceof Promise) {
2183
- return value.then((v) => JSON.parse(v || ""));
2184
- }
2185
- return JSON.parse(value || "");
2186
- },
2187
- setItem: (key, newValue) => getStringStorage().setItem(key, JSON.stringify(newValue)),
2188
- removeItem: (key) => {
2189
- var _a, _b;
2190
- return (_b = (_a = getStringStorage()).removeItem) == null ? void 0 : _b.call(_a, key);
2191
- }
2192
- };
2193
- }
2194
- createJSONStorage(() => localStorage);
2195
1380
  var prefix = "Invariant failed";
2196
1381
  function invariant(condition, message) {
2197
1382
  if (condition) {
@@ -2207,7 +1392,7 @@ const formDefaultValuesKey = (formId) => `${FORM_DEFAULTS_FIELD}_${formId}`;
2207
1392
  const InternalFormContext = createContext(null);
2208
1393
  const serverData = (data) => ({
2209
1394
  hydrateTo: () => data,
2210
- map: (fn) => serverData(fn(data))
1395
+ map: (fn2) => serverData(fn2(data))
2211
1396
  });
2212
1397
  const hydratedData = () => ({
2213
1398
  hydrateTo: (hydratedData2) => hydratedData2,
@@ -2219,530 +1404,656 @@ const hydratable = {
2219
1404
  hydratedData,
2220
1405
  from
2221
1406
  };
2222
- function arrayEach$1(array, iteratee) {
2223
- var index = -1, length = array == null ? 0 : array.length;
2224
- while (++index < length) {
2225
- if (iteratee(array[index], index, array) === false) {
2226
- break;
2227
- }
2228
- }
2229
- return array;
2230
- }
2231
- var _arrayEach = arrayEach$1;
2232
- var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
2233
- function copyObject$5(source, props, object, customizer) {
2234
- var isNew = !object;
2235
- object || (object = {});
2236
- var index = -1, length = props.length;
2237
- while (++index < length) {
2238
- var key = props[index];
2239
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
2240
- if (newValue === void 0) {
2241
- newValue = source[key];
2242
- }
2243
- if (isNew) {
2244
- baseAssignValue(object, key, newValue);
2245
- } else {
2246
- assignValue$1(object, key, newValue);
2247
- }
2248
- }
2249
- return object;
2250
- }
2251
- var _copyObject = copyObject$5;
2252
- var copyObject$4 = _copyObject, keys$1 = keys_1;
2253
- function baseAssign$1(object, source) {
2254
- return object && copyObject$4(source, keys$1(source), object);
2255
- }
2256
- var _baseAssign = baseAssign$1;
2257
- var copyObject$3 = _copyObject, keysIn$1 = keysIn_1;
2258
- function baseAssignIn$1(object, source) {
2259
- return object && copyObject$3(source, keysIn$1(source), object);
2260
- }
2261
- var _baseAssignIn = baseAssignIn$1;
2262
- var _cloneBuffer = { exports: {} };
2263
- (function(module, exports) {
2264
- var root2 = _root;
2265
- var freeExports = exports && !exports.nodeType && exports;
2266
- var freeModule = freeExports && true && module && !module.nodeType && module;
2267
- var moduleExports = freeModule && freeModule.exports === freeExports;
2268
- var Buffer2 = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
2269
- function cloneBuffer2(buffer, isDeep) {
2270
- if (isDeep) {
2271
- return buffer.slice();
1407
+ const createStoreImpl = (createState) => {
1408
+ let state;
1409
+ const listeners = /* @__PURE__ */ new Set();
1410
+ const setState = (partial, replace) => {
1411
+ const nextState = typeof partial === "function" ? partial(state) : partial;
1412
+ if (nextState !== state) {
1413
+ const previousState = state;
1414
+ state = replace ? nextState : Object.assign({}, state, nextState);
1415
+ listeners.forEach((listener) => listener(state, previousState));
2272
1416
  }
2273
- var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2274
- buffer.copy(result);
2275
- return result;
2276
- }
2277
- module.exports = cloneBuffer2;
2278
- })(_cloneBuffer, _cloneBuffer.exports);
2279
- function copyArray$1(source, array) {
2280
- var index = -1, length = source.length;
2281
- array || (array = Array(length));
2282
- while (++index < length) {
2283
- array[index] = source[index];
2284
- }
2285
- return array;
2286
- }
2287
- var _copyArray = copyArray$1;
2288
- var copyObject$2 = _copyObject, getSymbols = _getSymbols;
2289
- function copySymbols$1(source, object) {
2290
- return copyObject$2(source, getSymbols(source), object);
2291
- }
2292
- var _copySymbols = copySymbols$1;
2293
- var copyObject$1 = _copyObject, getSymbolsIn = _getSymbolsIn;
2294
- function copySymbolsIn$1(source, object) {
2295
- return copyObject$1(source, getSymbolsIn(source), object);
2296
- }
2297
- var _copySymbolsIn = copySymbolsIn$1;
2298
- var objectProto$1 = Object.prototype;
2299
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2300
- function initCloneArray$1(array) {
2301
- var length = array.length, result = new array.constructor(length);
2302
- if (length && typeof array[0] == "string" && hasOwnProperty$1.call(array, "index")) {
2303
- result.index = array.index;
2304
- result.input = array.input;
2305
- }
2306
- return result;
2307
- }
2308
- var _initCloneArray = initCloneArray$1;
2309
- var Uint8Array2 = _Uint8Array;
2310
- function cloneArrayBuffer$3(arrayBuffer) {
2311
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2312
- new Uint8Array2(result).set(new Uint8Array2(arrayBuffer));
2313
- return result;
2314
- }
2315
- var _cloneArrayBuffer = cloneArrayBuffer$3;
2316
- var cloneArrayBuffer$2 = _cloneArrayBuffer;
2317
- function cloneDataView$1(dataView, isDeep) {
2318
- var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
2319
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2320
- }
2321
- var _cloneDataView = cloneDataView$1;
2322
- var reFlags = /\w*$/;
2323
- function cloneRegExp$1(regexp) {
2324
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2325
- result.lastIndex = regexp.lastIndex;
2326
- return result;
2327
- }
2328
- var _cloneRegExp = cloneRegExp$1;
2329
- var Symbol$2 = _Symbol;
2330
- var symbolProto = Symbol$2 ? Symbol$2.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2331
- function cloneSymbol$1(symbol) {
2332
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2333
- }
2334
- var _cloneSymbol = cloneSymbol$1;
2335
- var cloneArrayBuffer$1 = _cloneArrayBuffer;
2336
- function cloneTypedArray$1(typedArray, isDeep) {
2337
- var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
2338
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2339
- }
2340
- var _cloneTypedArray = cloneTypedArray$1;
2341
- var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
2342
- var boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]";
2343
- var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
2344
- function initCloneByTag$1(object, tag, isDeep) {
2345
- var Ctor = object.constructor;
2346
- switch (tag) {
2347
- case arrayBufferTag$1:
2348
- return cloneArrayBuffer(object);
2349
- case boolTag$1:
2350
- case dateTag$1:
2351
- return new Ctor(+object);
2352
- case dataViewTag$1:
2353
- return cloneDataView(object, isDeep);
2354
- case float32Tag$1:
2355
- case float64Tag$1:
2356
- case int8Tag$1:
2357
- case int16Tag$1:
2358
- case int32Tag$1:
2359
- case uint8Tag$1:
2360
- case uint8ClampedTag$1:
2361
- case uint16Tag$1:
2362
- case uint32Tag$1:
2363
- return cloneTypedArray(object, isDeep);
2364
- case mapTag$2:
2365
- return new Ctor();
2366
- case numberTag$1:
2367
- case stringTag$1:
2368
- return new Ctor(object);
2369
- case regexpTag$1:
2370
- return cloneRegExp(object);
2371
- case setTag$2:
2372
- return new Ctor();
2373
- case symbolTag$1:
2374
- return cloneSymbol(object);
2375
- }
2376
- }
2377
- var _initCloneByTag = initCloneByTag$1;
2378
- var isObject$1 = isObject_1;
2379
- var objectCreate = Object.create;
2380
- var baseCreate$1 = function() {
2381
- function object() {
2382
- }
2383
- return function(proto) {
2384
- if (!isObject$1(proto)) {
2385
- return {};
2386
- }
2387
- if (objectCreate) {
2388
- return objectCreate(proto);
2389
- }
2390
- object.prototype = proto;
2391
- var result = new object();
2392
- object.prototype = void 0;
2393
- return result;
2394
1417
  };
2395
- }();
2396
- var _baseCreate = baseCreate$1;
2397
- var baseCreate = _baseCreate, getPrototype$1 = _getPrototype, isPrototype = _isPrototype;
2398
- function initCloneObject$1(object) {
2399
- return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype$1(object)) : {};
2400
- }
2401
- var _initCloneObject = initCloneObject$1;
2402
- var getTag$2 = _getTag, isObjectLike$2 = isObjectLike_1;
2403
- var mapTag$1 = "[object Map]";
2404
- function baseIsMap$1(value) {
2405
- return isObjectLike$2(value) && getTag$2(value) == mapTag$1;
2406
- }
2407
- var _baseIsMap = baseIsMap$1;
2408
- var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtil.exports;
2409
- var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
2410
- var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
2411
- var isMap_1 = isMap$1;
2412
- var getTag$1 = _getTag, isObjectLike$1 = isObjectLike_1;
2413
- var setTag$1 = "[object Set]";
2414
- function baseIsSet$1(value) {
2415
- return isObjectLike$1(value) && getTag$1(value) == setTag$1;
2416
- }
2417
- var _baseIsSet = baseIsSet$1;
2418
- var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtil.exports;
2419
- var nodeIsSet = nodeUtil && nodeUtil.isSet;
2420
- var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
2421
- var isSet_1 = isSet$1;
2422
- var Stack = _Stack, arrayEach = _arrayEach, assignValue = _assignValue, baseAssign = _baseAssign, baseAssignIn = _baseAssignIn, cloneBuffer = _cloneBuffer.exports, copyArray = _copyArray, copySymbols = _copySymbols, copySymbolsIn = _copySymbolsIn, getAllKeys = _getAllKeys, getAllKeysIn$1 = _getAllKeysIn, getTag = _getTag, initCloneArray = _initCloneArray, initCloneByTag = _initCloneByTag, initCloneObject = _initCloneObject, isArray$1 = isArray_1, isBuffer = isBuffer$3.exports, isMap = isMap_1, isObject = isObject_1, isSet = isSet_1, keys = keys_1, keysIn = keysIn_1;
2423
- var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG$1 = 2, CLONE_SYMBOLS_FLAG$1 = 4;
2424
- var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag$1 = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
2425
- var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
2426
- var cloneableTags = {};
2427
- cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag$1] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
2428
- cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
2429
- function baseClone$1(value, bitmask, customizer, key, object, stack) {
2430
- var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG$1, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
2431
- if (customizer) {
2432
- result = object ? customizer(value, key, object, stack) : customizer(value);
2433
- }
2434
- if (result !== void 0) {
2435
- return result;
2436
- }
2437
- if (!isObject(value)) {
2438
- return value;
2439
- }
2440
- var isArr = isArray$1(value);
2441
- if (isArr) {
2442
- result = initCloneArray(value);
2443
- if (!isDeep) {
2444
- return copyArray(value, result);
2445
- }
2446
- } else {
2447
- var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
2448
- if (isBuffer(value)) {
2449
- return cloneBuffer(value, isDeep);
2450
- }
2451
- if (tag == objectTag$1 || tag == argsTag || isFunc && !object) {
2452
- result = isFlat || isFunc ? {} : initCloneObject(value);
2453
- if (!isDeep) {
2454
- return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
2455
- }
2456
- } else {
2457
- if (!cloneableTags[tag]) {
2458
- return object ? value : {};
2459
- }
2460
- result = initCloneByTag(value, tag, isDeep);
2461
- }
2462
- }
2463
- stack || (stack = new Stack());
2464
- var stacked = stack.get(value);
2465
- if (stacked) {
2466
- return stacked;
2467
- }
2468
- stack.set(value, result);
2469
- if (isSet(value)) {
2470
- value.forEach(function(subValue) {
2471
- result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
2472
- });
2473
- } else if (isMap(value)) {
2474
- value.forEach(function(subValue, key2) {
2475
- result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
1418
+ const getState = () => state;
1419
+ const subscribe = (listener) => {
1420
+ listeners.add(listener);
1421
+ return () => listeners.delete(listener);
1422
+ };
1423
+ const destroy = () => listeners.clear();
1424
+ const api = { setState, getState, subscribe, destroy };
1425
+ state = createState(setState, getState, api);
1426
+ return api;
1427
+ };
1428
+ const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1429
+ var withSelector = { exports: {} };
1430
+ var withSelector_production_min = {};
1431
+ var shim = { exports: {} };
1432
+ var useSyncExternalStoreShim_production_min = {};
1433
+ /**
1434
+ * @license React
1435
+ * use-sync-external-store-shim.production.min.js
1436
+ *
1437
+ * Copyright (c) Facebook, Inc. and its affiliates.
1438
+ *
1439
+ * This source code is licensed under the MIT license found in the
1440
+ * LICENSE file in the root directory of this source tree.
1441
+ */
1442
+ var e = React;
1443
+ function h$2(a2, b2) {
1444
+ return a2 === b2 && (a2 !== 0 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
1445
+ }
1446
+ var k$1 = typeof Object.is === "function" ? Object.is : h$2, l$1 = e.useState, m = e.useEffect, n$2 = e.useLayoutEffect, p$2 = e.useDebugValue;
1447
+ function q$2(a2, b2) {
1448
+ var d2 = b2(), f2 = l$1({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
1449
+ n$2(function() {
1450
+ c2.value = d2;
1451
+ c2.getSnapshot = b2;
1452
+ r$2(c2) && g2({ inst: c2 });
1453
+ }, [a2, d2, b2]);
1454
+ m(function() {
1455
+ r$2(c2) && g2({ inst: c2 });
1456
+ return a2(function() {
1457
+ r$2(c2) && g2({ inst: c2 });
2476
1458
  });
2477
- }
2478
- var keysFunc = isFull ? isFlat ? getAllKeysIn$1 : getAllKeys : isFlat ? keysIn : keys;
2479
- var props = isArr ? void 0 : keysFunc(value);
2480
- arrayEach(props || value, function(subValue, key2) {
2481
- if (props) {
2482
- key2 = subValue;
2483
- subValue = value[key2];
2484
- }
2485
- assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
2486
- });
2487
- return result;
2488
- }
2489
- var _baseClone = baseClone$1;
2490
- function last$1(array) {
2491
- var length = array == null ? 0 : array.length;
2492
- return length ? array[length - 1] : void 0;
1459
+ }, [a2]);
1460
+ p$2(d2);
1461
+ return d2;
2493
1462
  }
2494
- var last_1 = last$1;
2495
- function baseSlice$1(array, start, end) {
2496
- var index = -1, length = array.length;
2497
- if (start < 0) {
2498
- start = -start > length ? 0 : length + start;
2499
- }
2500
- end = end > length ? length : end;
2501
- if (end < 0) {
2502
- end += length;
2503
- }
2504
- length = start > end ? 0 : end - start >>> 0;
2505
- start >>>= 0;
2506
- var result = Array(length);
2507
- while (++index < length) {
2508
- result[index] = array[index + start];
2509
- }
2510
- return result;
2511
- }
2512
- var _baseSlice = baseSlice$1;
2513
- var baseGet = _baseGet, baseSlice = _baseSlice;
2514
- function parent$1(object, path) {
2515
- return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
2516
- }
2517
- var _parent = parent$1;
2518
- var castPath$1 = _castPath, last = last_1, parent = _parent, toKey = _toKey;
2519
- function baseUnset$1(object, path) {
2520
- path = castPath$1(path, object);
2521
- object = parent(object, path);
2522
- return object == null || delete object[toKey(last(path))];
2523
- }
2524
- var _baseUnset = baseUnset$1;
2525
- var baseGetTag = _baseGetTag, getPrototype = _getPrototype, isObjectLike = isObjectLike_1;
2526
- var objectTag = "[object Object]";
2527
- var funcProto = Function.prototype, objectProto = Object.prototype;
2528
- var funcToString = funcProto.toString;
2529
- var hasOwnProperty = objectProto.hasOwnProperty;
2530
- var objectCtorString = funcToString.call(Object);
2531
- function isPlainObject$1(value) {
2532
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
2533
- return false;
2534
- }
2535
- var proto = getPrototype(value);
2536
- if (proto === null) {
1463
+ function r$2(a2) {
1464
+ var b2 = a2.getSnapshot;
1465
+ a2 = a2.value;
1466
+ try {
1467
+ var d2 = b2();
1468
+ return !k$1(a2, d2);
1469
+ } catch (f2) {
2537
1470
  return true;
2538
1471
  }
2539
- var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
2540
- return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
2541
- }
2542
- var isPlainObject_1 = isPlainObject$1;
2543
- var isPlainObject = isPlainObject_1;
2544
- function customOmitClone$1(value) {
2545
- return isPlainObject(value) ? void 0 : value;
2546
- }
2547
- var _customOmitClone = customOmitClone$1;
2548
- var Symbol$1 = _Symbol, isArguments = isArguments_1, isArray = isArray_1;
2549
- var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : void 0;
2550
- function isFlattenable$1(value) {
2551
- return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
2552
- }
2553
- var _isFlattenable = isFlattenable$1;
2554
- var arrayPush = _arrayPush, isFlattenable = _isFlattenable;
2555
- function baseFlatten$1(array, depth, predicate, isStrict, result) {
2556
- var index = -1, length = array.length;
2557
- predicate || (predicate = isFlattenable);
2558
- result || (result = []);
2559
- while (++index < length) {
2560
- var value = array[index];
2561
- if (depth > 0 && predicate(value)) {
2562
- if (depth > 1) {
2563
- baseFlatten$1(value, depth - 1, predicate, isStrict, result);
2564
- } else {
2565
- arrayPush(result, value);
1472
+ }
1473
+ function t$2(a2, b2) {
1474
+ return b2();
1475
+ }
1476
+ var u$2 = typeof window === "undefined" || typeof window.document === "undefined" || typeof window.document.createElement === "undefined" ? t$2 : q$2;
1477
+ useSyncExternalStoreShim_production_min.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : u$2;
1478
+ {
1479
+ shim.exports = useSyncExternalStoreShim_production_min;
1480
+ }
1481
+ /**
1482
+ * @license React
1483
+ * use-sync-external-store-shim/with-selector.production.min.js
1484
+ *
1485
+ * Copyright (c) Facebook, Inc. and its affiliates.
1486
+ *
1487
+ * This source code is licensed under the MIT license found in the
1488
+ * LICENSE file in the root directory of this source tree.
1489
+ */
1490
+ var h$1 = React, n$1 = shim.exports;
1491
+ function p$1(a2, b2) {
1492
+ return a2 === b2 && (a2 !== 0 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
1493
+ }
1494
+ var q$1 = typeof Object.is === "function" ? Object.is : p$1, r$1 = n$1.useSyncExternalStore, t$1 = h$1.useRef, u$1 = h$1.useEffect, v$1 = h$1.useMemo, w$1 = h$1.useDebugValue;
1495
+ withSelector_production_min.useSyncExternalStoreWithSelector = function(a2, b2, e2, l2, g2) {
1496
+ var c2 = t$1(null);
1497
+ if (c2.current === null) {
1498
+ var f2 = { hasValue: false, value: null };
1499
+ c2.current = f2;
1500
+ } else
1501
+ f2 = c2.current;
1502
+ c2 = v$1(function() {
1503
+ function a3(a4) {
1504
+ if (!c3) {
1505
+ c3 = true;
1506
+ d3 = a4;
1507
+ a4 = l2(a4);
1508
+ if (g2 !== void 0 && f2.hasValue) {
1509
+ var b3 = f2.value;
1510
+ if (g2(b3, a4))
1511
+ return k2 = b3;
1512
+ }
1513
+ return k2 = a4;
2566
1514
  }
2567
- } else if (!isStrict) {
2568
- result[result.length] = value;
2569
- }
2570
- }
2571
- return result;
1515
+ b3 = k2;
1516
+ if (q$1(d3, a4))
1517
+ return b3;
1518
+ var e3 = l2(a4);
1519
+ if (g2 !== void 0 && g2(b3, e3))
1520
+ return b3;
1521
+ d3 = a4;
1522
+ return k2 = e3;
1523
+ }
1524
+ var c3 = false, d3, k2, m2 = e2 === void 0 ? null : e2;
1525
+ return [function() {
1526
+ return a3(b2());
1527
+ }, m2 === null ? void 0 : function() {
1528
+ return a3(m2());
1529
+ }];
1530
+ }, [b2, e2, l2, g2]);
1531
+ var d2 = r$1(a2, c2[0], c2[1]);
1532
+ u$1(function() {
1533
+ f2.hasValue = true;
1534
+ f2.value = d2;
1535
+ }, [d2]);
1536
+ w$1(d2);
1537
+ return d2;
1538
+ };
1539
+ {
1540
+ withSelector.exports = withSelector_production_min;
1541
+ }
1542
+ function useStore(api, selector = api.getState, equalityFn) {
1543
+ const slice = withSelector.exports.useSyncExternalStoreWithSelector(api.subscribe, api.getState, api.getServerState || api.getState, selector, equalityFn);
1544
+ useDebugValue(slice);
1545
+ return slice;
1546
+ }
1547
+ const createImpl = (createState) => {
1548
+ const api = typeof createState === "function" ? createStore(createState) : createState;
1549
+ const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
1550
+ Object.assign(useBoundStore, api);
1551
+ return useBoundStore;
1552
+ };
1553
+ const create = (createState) => createState ? createImpl(createState) : createImpl;
1554
+ var create$1 = create;
1555
+ function n(n2) {
1556
+ for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e2 = 1; e2 < r2; e2++)
1557
+ t2[e2 - 1] = arguments[e2];
1558
+ throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) {
1559
+ return "'" + n3 + "'";
1560
+ }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
1561
+ }
1562
+ function r(n2) {
1563
+ return !!n2 && !!n2[Q];
1564
+ }
1565
+ function t(n2) {
1566
+ return !!n2 && (function(n3) {
1567
+ if (!n3 || typeof n3 != "object")
1568
+ return false;
1569
+ var r2 = Object.getPrototypeOf(n3);
1570
+ if (r2 === null)
1571
+ return true;
1572
+ var t2 = Object.hasOwnProperty.call(r2, "constructor") && r2.constructor;
1573
+ return t2 === Object || typeof t2 == "function" && Function.toString.call(t2) === Z;
1574
+ }(n2) || Array.isArray(n2) || !!n2[L] || !!n2.constructor[L] || s(n2) || v(n2));
1575
+ }
1576
+ function i(n2, r2, t2) {
1577
+ t2 === void 0 && (t2 = false), o(n2) === 0 ? (t2 ? Object.keys : nn)(n2).forEach(function(e2) {
1578
+ t2 && typeof e2 == "symbol" || r2(e2, n2[e2], n2);
1579
+ }) : n2.forEach(function(t3, e2) {
1580
+ return r2(e2, t3, n2);
1581
+ });
2572
1582
  }
2573
- var _baseFlatten = baseFlatten$1;
2574
- var baseFlatten = _baseFlatten;
2575
- function flatten$1(array) {
2576
- var length = array == null ? 0 : array.length;
2577
- return length ? baseFlatten(array, 1) : [];
2578
- }
2579
- var flatten_1 = flatten$1;
2580
- function apply$1(func, thisArg, args) {
2581
- switch (args.length) {
2582
- case 0:
2583
- return func.call(thisArg);
2584
- case 1:
2585
- return func.call(thisArg, args[0]);
1583
+ function o(n2) {
1584
+ var r2 = n2[Q];
1585
+ return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v(n2) ? 3 : 0;
1586
+ }
1587
+ function u(n2, r2) {
1588
+ return o(n2) === 2 ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2);
1589
+ }
1590
+ function a(n2, r2) {
1591
+ return o(n2) === 2 ? n2.get(r2) : n2[r2];
1592
+ }
1593
+ function f(n2, r2, t2) {
1594
+ var e2 = o(n2);
1595
+ e2 === 2 ? n2.set(r2, t2) : e2 === 3 ? (n2.delete(r2), n2.add(t2)) : n2[r2] = t2;
1596
+ }
1597
+ function c(n2, r2) {
1598
+ return n2 === r2 ? n2 !== 0 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2;
1599
+ }
1600
+ function s(n2) {
1601
+ return X && n2 instanceof Map;
1602
+ }
1603
+ function v(n2) {
1604
+ return q && n2 instanceof Set;
1605
+ }
1606
+ function p(n2) {
1607
+ return n2.o || n2.t;
1608
+ }
1609
+ function l(n2) {
1610
+ if (Array.isArray(n2))
1611
+ return Array.prototype.slice.call(n2);
1612
+ var r2 = rn(n2);
1613
+ delete r2[Q];
1614
+ for (var t2 = nn(r2), e2 = 0; e2 < t2.length; e2++) {
1615
+ var i2 = t2[e2], o2 = r2[i2];
1616
+ o2.writable === false && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] });
1617
+ }
1618
+ return Object.create(Object.getPrototypeOf(n2), r2);
1619
+ }
1620
+ function d(n2, e2) {
1621
+ return e2 === void 0 && (e2 = false), y(n2) || r(n2) || !t(n2) ? n2 : (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h), Object.freeze(n2), e2 && i(n2, function(n3, r2) {
1622
+ return d(r2, true);
1623
+ }, true), n2);
1624
+ }
1625
+ function h() {
1626
+ n(2);
1627
+ }
1628
+ function y(n2) {
1629
+ return n2 == null || typeof n2 != "object" || Object.isFrozen(n2);
1630
+ }
1631
+ function b(r2) {
1632
+ var t2 = tn[r2];
1633
+ return t2 || n(18, r2), t2;
1634
+ }
1635
+ function _() {
1636
+ return U;
1637
+ }
1638
+ function j(n2, r2) {
1639
+ r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2);
1640
+ }
1641
+ function O(n2) {
1642
+ g(n2), n2.p.forEach(S), n2.p = null;
1643
+ }
1644
+ function g(n2) {
1645
+ n2 === U && (U = n2.l);
1646
+ }
1647
+ function w(n2) {
1648
+ return U = { p: [], l: U, h: n2, m: true, _: 0 };
1649
+ }
1650
+ function S(n2) {
1651
+ var r2 = n2[Q];
1652
+ r2.i === 0 || r2.i === 1 ? r2.j() : r2.O = true;
1653
+ }
1654
+ function P(r2, e2) {
1655
+ e2._ = e2.p.length;
1656
+ var i2 = e2.p[0], o2 = r2 !== void 0 && r2 !== i2;
1657
+ return e2.h.g || b("ES5").S(e2, r2, o2), o2 ? (i2[Q].P && (O(e2), n(4)), t(r2) && (r2 = M(e2, r2), e2.l || x(e2, r2)), e2.u && b("Patches").M(i2[Q].t, r2, e2.u, e2.s)) : r2 = M(e2, i2, []), O(e2), e2.u && e2.v(e2.u, e2.s), r2 !== H ? r2 : void 0;
1658
+ }
1659
+ function M(n2, r2, t2) {
1660
+ if (y(r2))
1661
+ return r2;
1662
+ var e2 = r2[Q];
1663
+ if (!e2)
1664
+ return i(r2, function(i2, o3) {
1665
+ return A(n2, e2, r2, i2, o3, t2);
1666
+ }, true), r2;
1667
+ if (e2.A !== n2)
1668
+ return r2;
1669
+ if (!e2.P)
1670
+ return x(n2, e2.t, true), e2.t;
1671
+ if (!e2.I) {
1672
+ e2.I = true, e2.A._--;
1673
+ var o2 = e2.i === 4 || e2.i === 5 ? e2.o = l(e2.k) : e2.o;
1674
+ i(e2.i === 3 ? new Set(o2) : o2, function(r3, i2) {
1675
+ return A(n2, e2, o2, r3, i2, t2);
1676
+ }), x(n2, o2, false), t2 && n2.u && b("Patches").R(e2, t2, n2.u, n2.s);
1677
+ }
1678
+ return e2.o;
1679
+ }
1680
+ function A(e2, i2, o2, a2, c2, s2) {
1681
+ if (r(c2)) {
1682
+ var v2 = M(e2, c2, s2 && i2 && i2.i !== 3 && !u(i2.D, a2) ? s2.concat(a2) : void 0);
1683
+ if (f(o2, a2, v2), !r(v2))
1684
+ return;
1685
+ e2.m = false;
1686
+ }
1687
+ if (t(c2) && !y(c2)) {
1688
+ if (!e2.h.F && e2._ < 1)
1689
+ return;
1690
+ M(e2, c2), i2 && i2.A.l || x(e2, c2);
1691
+ }
1692
+ }
1693
+ function x(n2, r2, t2) {
1694
+ t2 === void 0 && (t2 = false), n2.h.F && n2.m && d(r2, t2);
1695
+ }
1696
+ function z(n2, r2) {
1697
+ var t2 = n2[Q];
1698
+ return (t2 ? p(t2) : n2)[r2];
1699
+ }
1700
+ function I(n2, r2) {
1701
+ if (r2 in n2)
1702
+ for (var t2 = Object.getPrototypeOf(n2); t2; ) {
1703
+ var e2 = Object.getOwnPropertyDescriptor(t2, r2);
1704
+ if (e2)
1705
+ return e2;
1706
+ t2 = Object.getPrototypeOf(t2);
1707
+ }
1708
+ }
1709
+ function k(n2) {
1710
+ n2.P || (n2.P = true, n2.l && k(n2.l));
1711
+ }
1712
+ function E(n2) {
1713
+ n2.o || (n2.o = l(n2.t));
1714
+ }
1715
+ function R(n2, r2, t2) {
1716
+ var e2 = s(r2) ? b("MapSet").N(r2, t2) : v(r2) ? b("MapSet").T(r2, t2) : n2.g ? function(n3, r3) {
1717
+ var t3 = Array.isArray(n3), e3 = { i: t3 ? 1 : 0, A: r3 ? r3.A : _(), P: false, I: false, D: {}, l: r3, t: n3, k: null, o: null, j: null, C: false }, i2 = e3, o2 = en;
1718
+ t3 && (i2 = [e3], o2 = on);
1719
+ var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy;
1720
+ return e3.k = f2, e3.j = a2, f2;
1721
+ }(r2, t2) : b("ES5").J(r2, t2);
1722
+ return (t2 ? t2.A : _()).p.push(e2), e2;
1723
+ }
1724
+ function D(e2) {
1725
+ return r(e2) || n(22, e2), function n2(r2) {
1726
+ if (!t(r2))
1727
+ return r2;
1728
+ var e3, u2 = r2[Q], c2 = o(r2);
1729
+ if (u2) {
1730
+ if (!u2.P && (u2.i < 4 || !b("ES5").K(u2)))
1731
+ return u2.t;
1732
+ u2.I = true, e3 = F(r2, c2), u2.I = false;
1733
+ } else
1734
+ e3 = F(r2, c2);
1735
+ return i(e3, function(r3, t2) {
1736
+ u2 && a(u2.t, r3) === t2 || f(e3, r3, n2(t2));
1737
+ }), c2 === 3 ? new Set(e3) : e3;
1738
+ }(e2);
1739
+ }
1740
+ function F(n2, r2) {
1741
+ switch (r2) {
2586
1742
  case 2:
2587
- return func.call(thisArg, args[0], args[1]);
1743
+ return new Map(n2);
2588
1744
  case 3:
2589
- return func.call(thisArg, args[0], args[1], args[2]);
2590
- }
2591
- return func.apply(thisArg, args);
2592
- }
2593
- var _apply = apply$1;
2594
- var apply = _apply;
2595
- var nativeMax = Math.max;
2596
- function overRest$1(func, start, transform) {
2597
- start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
2598
- return function() {
2599
- var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
2600
- while (++index < length) {
2601
- array[index] = args[start + index];
2602
- }
2603
- index = -1;
2604
- var otherArgs = Array(start + 1);
2605
- while (++index < start) {
2606
- otherArgs[index] = args[index];
1745
+ return Array.from(n2);
1746
+ }
1747
+ return l(n2);
1748
+ }
1749
+ var G, U, W = typeof Symbol != "undefined" && typeof Symbol("x") == "symbol", X = typeof Map != "undefined", q = typeof Set != "undefined", B = typeof Proxy != "undefined" && Proxy.revocable !== void 0 && typeof Reflect != "undefined", H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G), L = W ? Symbol.for("immer-draftable") : "__$immer_draftable", Q = W ? Symbol.for("immer-state") : "__$immer_state", Z = "" + Object.prototype.constructor, nn = typeof Reflect != "undefined" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(n2) {
1750
+ return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2));
1751
+ } : Object.getOwnPropertyNames, rn = Object.getOwnPropertyDescriptors || function(n2) {
1752
+ var r2 = {};
1753
+ return nn(n2).forEach(function(t2) {
1754
+ r2[t2] = Object.getOwnPropertyDescriptor(n2, t2);
1755
+ }), r2;
1756
+ }, tn = {}, en = { get: function(n2, r2) {
1757
+ if (r2 === Q)
1758
+ return n2;
1759
+ var e2 = p(n2);
1760
+ if (!u(e2, r2))
1761
+ return function(n3, r3, t2) {
1762
+ var e3, i3 = I(r3, t2);
1763
+ return i3 ? "value" in i3 ? i3.value : (e3 = i3.get) === null || e3 === void 0 ? void 0 : e3.call(n3.k) : void 0;
1764
+ }(n2, e2, r2);
1765
+ var i2 = e2[r2];
1766
+ return n2.I || !t(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = R(n2.A.h, i2, n2)) : i2;
1767
+ }, has: function(n2, r2) {
1768
+ return r2 in p(n2);
1769
+ }, ownKeys: function(n2) {
1770
+ return Reflect.ownKeys(p(n2));
1771
+ }, set: function(n2, r2, t2) {
1772
+ var e2 = I(p(n2), r2);
1773
+ if (e2 == null ? void 0 : e2.set)
1774
+ return e2.set.call(n2.k, t2), true;
1775
+ if (!n2.P) {
1776
+ var i2 = z(p(n2), r2), o2 = i2 == null ? void 0 : i2[Q];
1777
+ if (o2 && o2.t === t2)
1778
+ return n2.o[r2] = t2, n2.D[r2] = false, true;
1779
+ if (c(t2, i2) && (t2 !== void 0 || u(n2.t, r2)))
1780
+ return true;
1781
+ E(n2), k(n2);
1782
+ }
1783
+ return n2.o[r2] === t2 && typeof t2 != "number" && (t2 !== void 0 || r2 in n2.o) || (n2.o[r2] = t2, n2.D[r2] = true, true);
1784
+ }, deleteProperty: function(n2, r2) {
1785
+ return z(n2.t, r2) !== void 0 || r2 in n2.t ? (n2.D[r2] = false, E(n2), k(n2)) : delete n2.D[r2], n2.o && delete n2.o[r2], true;
1786
+ }, getOwnPropertyDescriptor: function(n2, r2) {
1787
+ var t2 = p(n2), e2 = Reflect.getOwnPropertyDescriptor(t2, r2);
1788
+ return e2 ? { writable: true, configurable: n2.i !== 1 || r2 !== "length", enumerable: e2.enumerable, value: t2[r2] } : e2;
1789
+ }, defineProperty: function() {
1790
+ n(11);
1791
+ }, getPrototypeOf: function(n2) {
1792
+ return Object.getPrototypeOf(n2.t);
1793
+ }, setPrototypeOf: function() {
1794
+ n(12);
1795
+ } }, on = {};
1796
+ i(en, function(n2, r2) {
1797
+ on[n2] = function() {
1798
+ return arguments[0] = arguments[0][0], r2.apply(this, arguments);
1799
+ };
1800
+ }), on.deleteProperty = function(r2, t2) {
1801
+ return on.set.call(this, r2, t2, void 0);
1802
+ }, on.set = function(r2, t2, e2) {
1803
+ return en.set.call(this, r2[0], t2, e2, r2[0]);
1804
+ };
1805
+ var un = function() {
1806
+ function e2(r2) {
1807
+ var e3 = this;
1808
+ this.g = B, this.F = true, this.produce = function(r3, i3, o2) {
1809
+ if (typeof r3 == "function" && typeof i3 != "function") {
1810
+ var u2 = i3;
1811
+ i3 = r3;
1812
+ var a2 = e3;
1813
+ return function(n2) {
1814
+ var r4 = this;
1815
+ n2 === void 0 && (n2 = u2);
1816
+ for (var t2 = arguments.length, e4 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++)
1817
+ e4[o3 - 1] = arguments[o3];
1818
+ return a2.produce(n2, function(n3) {
1819
+ var t3;
1820
+ return (t3 = i3).call.apply(t3, [r4, n3].concat(e4));
1821
+ });
1822
+ };
1823
+ }
1824
+ var f2;
1825
+ if (typeof i3 != "function" && n(6), o2 !== void 0 && typeof o2 != "function" && n(7), t(r3)) {
1826
+ var c2 = w(e3), s2 = R(e3, r3, void 0), v2 = true;
1827
+ try {
1828
+ f2 = i3(s2), v2 = false;
1829
+ } finally {
1830
+ v2 ? O(c2) : g(c2);
1831
+ }
1832
+ return typeof Promise != "undefined" && f2 instanceof Promise ? f2.then(function(n2) {
1833
+ return j(c2, o2), P(n2, c2);
1834
+ }, function(n2) {
1835
+ throw O(c2), n2;
1836
+ }) : (j(c2, o2), P(f2, c2));
1837
+ }
1838
+ if (!r3 || typeof r3 != "object") {
1839
+ if ((f2 = i3(r3)) === void 0 && (f2 = r3), f2 === H && (f2 = void 0), e3.F && d(f2, true), o2) {
1840
+ var p2 = [], l2 = [];
1841
+ b("Patches").M(r3, f2, p2, l2), o2(p2, l2);
1842
+ }
1843
+ return f2;
1844
+ }
1845
+ n(21, r3);
1846
+ }, this.produceWithPatches = function(n2, r3) {
1847
+ if (typeof n2 == "function")
1848
+ return function(r4) {
1849
+ for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++)
1850
+ i4[o3 - 1] = arguments[o3];
1851
+ return e3.produceWithPatches(r4, function(r5) {
1852
+ return n2.apply(void 0, [r5].concat(i4));
1853
+ });
1854
+ };
1855
+ var t2, i3, o2 = e3.produce(n2, r3, function(n3, r4) {
1856
+ t2 = n3, i3 = r4;
1857
+ });
1858
+ return typeof Promise != "undefined" && o2 instanceof Promise ? o2.then(function(n3) {
1859
+ return [n3, t2, i3];
1860
+ }) : [o2, t2, i3];
1861
+ }, typeof (r2 == null ? void 0 : r2.useProxies) == "boolean" && this.setUseProxies(r2.useProxies), typeof (r2 == null ? void 0 : r2.autoFreeze) == "boolean" && this.setAutoFreeze(r2.autoFreeze);
1862
+ }
1863
+ var i2 = e2.prototype;
1864
+ return i2.createDraft = function(e3) {
1865
+ t(e3) || n(8), r(e3) && (e3 = D(e3));
1866
+ var i3 = w(this), o2 = R(this, e3, void 0);
1867
+ return o2[Q].C = true, g(i3), o2;
1868
+ }, i2.finishDraft = function(r2, t2) {
1869
+ var e3 = r2 && r2[Q];
1870
+ var i3 = e3.A;
1871
+ return j(i3, t2), P(void 0, i3);
1872
+ }, i2.setAutoFreeze = function(n2) {
1873
+ this.F = n2;
1874
+ }, i2.setUseProxies = function(r2) {
1875
+ r2 && !B && n(20), this.g = r2;
1876
+ }, i2.applyPatches = function(n2, t2) {
1877
+ var e3;
1878
+ for (e3 = t2.length - 1; e3 >= 0; e3--) {
1879
+ var i3 = t2[e3];
1880
+ if (i3.path.length === 0 && i3.op === "replace") {
1881
+ n2 = i3.value;
1882
+ break;
1883
+ }
2607
1884
  }
2608
- otherArgs[start] = transform(array);
2609
- return apply(func, this, otherArgs);
1885
+ e3 > -1 && (t2 = t2.slice(e3 + 1));
1886
+ var o2 = b("Patches").$;
1887
+ return r(n2) ? o2(n2, t2) : this.produce(n2, function(n3) {
1888
+ return o2(n3, t2);
1889
+ });
1890
+ }, e2;
1891
+ }(), an = new un(), fn = an.produce;
1892
+ an.produceWithPatches.bind(an);
1893
+ an.setAutoFreeze.bind(an);
1894
+ an.setUseProxies.bind(an);
1895
+ an.applyPatches.bind(an);
1896
+ an.createDraft.bind(an);
1897
+ an.finishDraft.bind(an);
1898
+ const immerImpl = (initializer) => (set2, get2, store) => {
1899
+ store.setState = (updater, replace, ...a2) => {
1900
+ const nextState = typeof updater === "function" ? fn(updater) : updater;
1901
+ return set2(nextState, replace, ...a2);
2610
1902
  };
2611
- }
2612
- var _overRest = overRest$1;
2613
- function constant$1(value) {
2614
- return function() {
2615
- return value;
1903
+ return initializer(store.setState, get2, store);
1904
+ };
1905
+ const immer = immerImpl;
1906
+ const storeFamily = (create2) => {
1907
+ const stores = /* @__PURE__ */ new Map();
1908
+ const family = (formId) => {
1909
+ if (stores.has(formId))
1910
+ return stores.get(formId);
1911
+ const store = create2(formId);
1912
+ stores.set(formId, store);
1913
+ return store;
2616
1914
  };
2617
- }
2618
- var constant_1 = constant$1;
2619
- var constant = constant_1, defineProperty = _defineProperty, identity = identity_1;
2620
- var baseSetToString$1 = !defineProperty ? identity : function(func, string) {
2621
- return defineProperty(func, "toString", {
2622
- "configurable": true,
2623
- "enumerable": false,
2624
- "value": constant(string),
2625
- "writable": true
2626
- });
1915
+ family.remove = (formId) => {
1916
+ stores.delete(formId);
1917
+ };
1918
+ return family;
2627
1919
  };
2628
- var _baseSetToString = baseSetToString$1;
2629
- var HOT_COUNT = 800, HOT_SPAN = 16;
2630
- var nativeNow = Date.now;
2631
- function shortOut$1(func) {
2632
- var count = 0, lastCalled = 0;
2633
- return function() {
2634
- var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
2635
- lastCalled = stamp;
2636
- if (remaining > 0) {
2637
- if (++count >= HOT_COUNT) {
2638
- return arguments[0];
2639
- }
1920
+ const controlledFieldStore = storeFamily(() => create$1()(immer((set2, get2, api) => ({
1921
+ fields: {},
1922
+ register: (field) => set2((state) => {
1923
+ if (state.fields[field]) {
1924
+ state.fields[field].refCount++;
2640
1925
  } else {
2641
- count = 0;
1926
+ state.fields[field] = {
1927
+ refCount: 1,
1928
+ value: void 0,
1929
+ hydrated: false,
1930
+ valueUpdatePromise: void 0,
1931
+ resolveValueUpdate: void 0
1932
+ };
2642
1933
  }
2643
- return func.apply(void 0, arguments);
2644
- };
2645
- }
2646
- var _shortOut = shortOut$1;
2647
- var baseSetToString = _baseSetToString, shortOut = _shortOut;
2648
- var setToString$1 = shortOut(baseSetToString);
2649
- var _setToString = setToString$1;
2650
- var flatten = flatten_1, overRest = _overRest, setToString = _setToString;
2651
- function flatRest$1(func) {
2652
- return setToString(overRest(func, void 0, flatten), func + "");
2653
- }
2654
- var _flatRest = flatRest$1;
2655
- var arrayMap = _arrayMap, baseClone = _baseClone, baseUnset = _baseUnset, castPath = _castPath, copyObject = _copyObject, customOmitClone = _customOmitClone, flatRest = _flatRest, getAllKeysIn = _getAllKeysIn;
2656
- var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
2657
- var omit = flatRest(function(object, paths) {
2658
- var result = {};
2659
- if (object == null) {
2660
- return result;
2661
- }
2662
- var isDeep = false;
2663
- paths = arrayMap(paths, function(path) {
2664
- path = castPath(path, object);
2665
- isDeep || (isDeep = path.length > 1);
2666
- return path;
2667
- });
2668
- copyObject(object, getAllKeysIn(object), result);
2669
- if (isDeep) {
2670
- result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
2671
- }
2672
- var length = paths.length;
2673
- while (length--) {
2674
- baseUnset(result, paths[length]);
2675
- }
2676
- return result;
2677
- });
2678
- var omit_1 = omit;
2679
- var baseIsEqual = _baseIsEqual;
2680
- function isEqual(value, other) {
2681
- return baseIsEqual(value, other);
2682
- }
2683
- var isEqual_1 = isEqual;
2684
- const formAtomFamily = (data) => atomFamily((_) => atom(data));
2685
- const fieldAtomFamily = (func) => atomFamily(func, isEqual_1);
2686
- const ATOM_SCOPE = Symbol("remix-validated-form-scope");
2687
- const isHydratedAtom = formAtomFamily(false);
2688
- const isSubmittingAtom = formAtomFamily(false);
2689
- const hasBeenSubmittedAtom = formAtomFamily(false);
2690
- const fieldErrorsAtom = formAtomFamily({});
2691
- const touchedFieldsAtom = formAtomFamily({});
2692
- const formPropsAtom = formAtomFamily({
2693
- validateField: () => Promise.resolve(null),
2694
- registerReceiveFocus: () => () => {
1934
+ }),
1935
+ unregister: (field) => set2((state) => {
1936
+ const fieldState = state.fields[field];
1937
+ if (!fieldState)
1938
+ return;
1939
+ fieldState.refCount--;
1940
+ if (fieldState.refCount === 0)
1941
+ delete state.fields[field];
1942
+ }),
1943
+ setValue: (field, value) => set2((state) => {
1944
+ const fieldState = state.fields[field];
1945
+ if (!fieldState)
1946
+ return;
1947
+ fieldState.value = value;
1948
+ const promise = new Promise((resolve) => {
1949
+ fieldState.resolveValueUpdate = resolve;
1950
+ });
1951
+ fieldState.valueUpdatePromise = promise;
1952
+ }),
1953
+ hydrateWithDefault: (field, defaultValue) => set2((state) => {
1954
+ const fieldState = state.fields[field];
1955
+ if (!fieldState)
1956
+ return;
1957
+ fieldState.value = defaultValue;
1958
+ fieldState.defaultValue = defaultValue;
1959
+ fieldState.hydrated = true;
1960
+ }),
1961
+ awaitValueUpdate: async (field) => {
1962
+ var _a;
1963
+ await ((_a = get2().fields[field]) == null ? void 0 : _a.valueUpdatePromise);
2695
1964
  },
2696
- defaultValues: {}
2697
- });
2698
- const formElementAtom = formAtomFamily(null);
2699
- const cleanupFormState = (formId) => {
2700
- [
2701
- isHydratedAtom,
2702
- isSubmittingAtom,
2703
- hasBeenSubmittedAtom,
2704
- fieldErrorsAtom,
2705
- touchedFieldsAtom,
2706
- formPropsAtom
2707
- ].forEach((formAtom) => formAtom.remove(formId));
2708
- };
2709
- const isValidAtom = atomFamily((formId) => atom((get2) => Object.keys(get2(fieldErrorsAtom(formId))).length === 0));
2710
- const startSubmitAtom = atomFamily((formId) => atom(null, (_get, set2) => {
2711
- set2(isSubmittingAtom(formId), true);
2712
- set2(hasBeenSubmittedAtom(formId), true);
2713
- }));
2714
- const endSubmitAtom = atomFamily((formId) => atom(null, (_get, set2) => {
2715
- set2(isSubmittingAtom(formId), false);
2716
- }));
2717
- const setTouchedAtom = atomFamily((formId) => atom(null, (get2, set2, { field, touched }) => {
2718
- const prev = get2(touchedFieldsAtom(formId));
2719
- if (prev[field] !== touched) {
2720
- set2(touchedFieldsAtom(formId), __spreadProps(__spreadValues({}, prev), {
2721
- [field]: touched
2722
- }));
2723
- }
2724
- }));
2725
- const setFieldErrorAtom = atomFamily((formId) => atom(null, (get2, set2, { field, error }) => {
2726
- const prev = get2(fieldErrorsAtom(formId));
2727
- if (error === void 0 && field in prev) {
2728
- set2(fieldErrorsAtom(formId), omit_1(prev, field));
2729
- }
2730
- if (error !== void 0 && prev[field] !== error) {
2731
- set2(fieldErrorsAtom(formId), __spreadProps(__spreadValues({}, get2(fieldErrorsAtom(formId))), {
2732
- [field]: error
2733
- }));
1965
+ reset: () => set2((state) => {
1966
+ Object.values(state.fields).forEach((field) => {
1967
+ if (!field)
1968
+ return;
1969
+ field.value = field.defaultValue;
1970
+ });
1971
+ })
1972
+ }))));
1973
+ const formStore = storeFamily((formId) => create$1()(immer((set2, get2, api) => ({
1974
+ isHydrated: false,
1975
+ isSubmitting: false,
1976
+ hasBeenSubmitted: false,
1977
+ touchedFields: {},
1978
+ fieldErrors: {},
1979
+ formElement: null,
1980
+ isValid: () => Object.keys(get2().fieldErrors).length === 0,
1981
+ startSubmit: () => set2((state) => {
1982
+ state.isSubmitting = true;
1983
+ state.hasBeenSubmitted = true;
1984
+ }),
1985
+ endSubmit: () => set2((state) => {
1986
+ state.isSubmitting = false;
1987
+ }),
1988
+ setTouched: (fieldName, touched) => set2((state) => {
1989
+ state.touchedFields[fieldName] = touched;
1990
+ }),
1991
+ setFieldError: (fieldName, error) => set2((state) => {
1992
+ state.fieldErrors[fieldName] = error;
1993
+ }),
1994
+ setFieldErrors: (errors) => set2((state) => {
1995
+ state.fieldErrors = errors;
1996
+ }),
1997
+ clearFieldError: (fieldName) => set2((state) => {
1998
+ delete state.fieldErrors[fieldName];
1999
+ }),
2000
+ reset: () => set2((state) => {
2001
+ state.fieldErrors = {};
2002
+ state.touchedFields = {};
2003
+ state.hasBeenSubmitted = false;
2004
+ }),
2005
+ syncFormProps: (props) => set2((state) => {
2006
+ state.formProps = props;
2007
+ }),
2008
+ setHydrated: () => set2((state) => {
2009
+ state.isHydrated = true;
2010
+ }),
2011
+ setFormElement: (formElement) => {
2012
+ if (get2().formElement === formElement)
2013
+ return;
2014
+ set2((state) => {
2015
+ state.formElement = formElement;
2016
+ });
2017
+ },
2018
+ validateField: async (field) => {
2019
+ var _a, _b, _c;
2020
+ const formElement = get2().formElement;
2021
+ invariant(formElement);
2022
+ const validator = (_a = get2().formProps) == null ? void 0 : _a.validator;
2023
+ invariant(validator);
2024
+ await ((_c = (_b = controlledFieldStore(formId).getState()).awaitValueUpdate) == null ? void 0 : _c.call(_b, field));
2025
+ const { error } = await validator.validateField(new FormData(formElement), field);
2026
+ if (error) {
2027
+ get2().setFieldError(field, error);
2028
+ return error;
2029
+ } else {
2030
+ get2().clearFieldError(field);
2031
+ return null;
2032
+ }
2033
+ },
2034
+ validate: async () => {
2035
+ var _a;
2036
+ const formElement = get2().formElement;
2037
+ invariant(formElement);
2038
+ const validator = (_a = get2().formProps) == null ? void 0 : _a.validator;
2039
+ invariant(validator);
2040
+ const { error } = await validator.validate(new FormData(formElement));
2041
+ if (error)
2042
+ get2().setFieldErrors(error.fieldErrors);
2043
+ },
2044
+ resetFormElement: () => {
2045
+ var _a;
2046
+ return (_a = get2().formElement) == null ? void 0 : _a.reset();
2734
2047
  }
2735
- }));
2736
- const fieldTouchedAtom = fieldAtomFamily(({ formId, field }) => atom((get2) => get2(touchedFieldsAtom(formId))[field], (_get, set2, touched) => {
2737
- set2(setTouchedAtom(formId), { field, touched });
2738
- }));
2739
- const fieldErrorAtom = fieldAtomFamily(({ formId, field }) => atom((get2) => get2(fieldErrorsAtom(formId))[field], (_get, set2, error) => {
2740
- set2(setFieldErrorAtom(formId), { field, error });
2741
- }));
2742
- fieldAtomFamily(({ formId, field }) => selectAtom(formPropsAtom(formId), (state) => state.defaultValues[field]));
2743
- const useFormUpdateAtom = (atom2) => useUpdateAtom(atom2, ATOM_SCOPE);
2744
- const useFormAtom = (anAtom) => useAtom(anAtom, ATOM_SCOPE);
2745
- const useFormAtomValue = (anAtom) => useAtomValue(anAtom, ATOM_SCOPE);
2048
+ }))));
2049
+ const useFormStore = (formId, selector) => {
2050
+ const useStore2 = formStore(formId);
2051
+ return useStore2(selector);
2052
+ };
2053
+ const useControlledFieldStore = (formId, selector) => {
2054
+ const useStore2 = controlledFieldStore(formId);
2055
+ return useStore2(selector);
2056
+ };
2746
2057
  const useInternalFormContext = (formId, hookName) => {
2747
2058
  const formContext = useContext(InternalFormContext);
2748
2059
  if (formId)
@@ -2773,7 +2084,7 @@ function useErrorResponseForForm({
2773
2084
  }
2774
2085
  const useFieldErrorsForForm = (context) => {
2775
2086
  const response = useErrorResponseForForm(context);
2776
- const hydrated = useFormAtomValue(isHydratedAtom(context.formId));
2087
+ const hydrated = useFormStore(context.formId, (state) => state.isHydrated);
2777
2088
  return hydratable.from(response == null ? void 0 : response.fieldErrors, hydrated);
2778
2089
  };
2779
2090
  const useDefaultValuesFromLoader = ({
@@ -2789,7 +2100,7 @@ const useDefaultValuesFromLoader = ({
2789
2100
  };
2790
2101
  const useDefaultValuesForForm = (context) => {
2791
2102
  const { formId, defaultValuesProp } = context;
2792
- const hydrated = useFormAtomValue(isHydratedAtom(formId));
2103
+ const hydrated = useFormStore(formId, (state) => state.isHydrated);
2793
2104
  const errorResponse = useErrorResponseForForm(context);
2794
2105
  const defaultValuesFromLoader = useDefaultValuesFromLoader(context);
2795
2106
  if (hydrated)
@@ -2809,131 +2120,124 @@ const useHasActiveFormSubmit = ({
2809
2120
  const hasActiveSubmission = fetcher ? fetcher.state === "submitting" : !!transition.submission;
2810
2121
  return hasActiveSubmission;
2811
2122
  };
2812
- const useFieldTouched = (field, { formId }) => useFormAtom(fieldTouchedAtom({ formId, field }));
2123
+ const useFieldTouched = (field, { formId }) => {
2124
+ const touched = useFormStore(formId, (state) => state.touchedFields[field]);
2125
+ const setFieldTouched = useFormStore(formId, (state) => state.setTouched);
2126
+ const setTouched = useCallback((touched2) => setFieldTouched(field, touched2), [field, setFieldTouched]);
2127
+ return [touched, setTouched];
2128
+ };
2813
2129
  const useFieldError = (name, context) => {
2814
2130
  const fieldErrors = useFieldErrorsForForm(context);
2815
- const [state, set2] = useFormAtom(fieldErrorAtom({ formId: context.formId, field: name }));
2816
- return [
2817
- fieldErrors.map((fieldErrors2) => fieldErrors2 == null ? void 0 : fieldErrors2[name]).hydrateTo(state),
2818
- set2
2819
- ];
2131
+ const state = useFormStore(context.formId, (state2) => state2.fieldErrors[name]);
2132
+ return fieldErrors.map((fieldErrors2) => fieldErrors2 == null ? void 0 : fieldErrors2[name]).hydrateTo(state);
2133
+ };
2134
+ const useClearError = (context) => {
2135
+ const { formId } = context;
2136
+ return useFormStore(formId, (state) => state.clearFieldError);
2820
2137
  };
2821
2138
  const useFieldDefaultValue = (name, context) => {
2822
2139
  const defaultValues = useDefaultValuesForForm(context);
2823
- const { defaultValues: state } = useFormAtomValue(formPropsAtom(context.formId));
2140
+ const state = useSyncedDefaultValues(context.formId);
2824
2141
  return defaultValues.map((val) => get_1(val, name)).hydrateTo(get_1(state, name));
2825
2142
  };
2826
- const useClearError = ({ formId }) => {
2827
- const updateError = useFormUpdateAtom(setFieldErrorAtom(formId));
2828
- return useCallback((name) => updateError({ field: name, error: void 0 }), [updateError]);
2143
+ const useInternalIsSubmitting = (formId) => useFormStore(formId, (state) => state.isSubmitting);
2144
+ const useInternalIsValid = (formId) => useFormStore(formId, (state) => state.isValid());
2145
+ const useInternalHasBeenSubmitted = (formId) => useFormStore(formId, (state) => state.hasBeenSubmitted);
2146
+ const useValidateField = (formId) => useFormStore(formId, (state) => state.validateField);
2147
+ const useValidate = (formId) => useFormStore(formId, (state) => state.validate);
2148
+ const noOpReceiver = () => () => {
2829
2149
  };
2830
- const useSetTouched = ({ formId }) => {
2831
- const setTouched = useFormUpdateAtom(setTouchedAtom(formId));
2832
- return useCallback((name, touched) => setTouched({ field: name, touched }), [setTouched]);
2833
- };
2834
- const controlledFieldsAtom = formAtomFamily({});
2835
- const refCountAtom = fieldAtomFamily(() => atom(0));
2836
- const fieldValueAtom = fieldAtomFamily(() => atom(void 0));
2837
- const fieldValueHydratedAtom = fieldAtomFamily(() => atom(false));
2838
- const valueUpdatePromiseAtom = fieldAtomFamily(() => atom(void 0));
2839
- const resolveValueUpdateAtom = fieldAtomFamily(() => atom(void 0));
2840
- const registerAtom = atom(null, (get2, set2, { formId, field }) => {
2841
- set2(refCountAtom({ formId, field }), (prev) => prev + 1);
2842
- const newRefCount = get2(refCountAtom({ formId, field }));
2843
- if (newRefCount === 1) {
2844
- set2(controlledFieldsAtom(formId), (prev) => __spreadProps(__spreadValues({}, prev), {
2845
- [field]: fieldValueAtom({ formId, field })
2846
- }));
2847
- }
2150
+ const useRegisterReceiveFocus = (formId) => useFormStore(formId, (state) => {
2151
+ var _a, _b;
2152
+ return (_b = (_a = state.formProps) == null ? void 0 : _a.registerReceiveFocus) != null ? _b : noOpReceiver;
2848
2153
  });
2849
- const unregisterAtom = atom(null, (get2, set2, { formId, field }) => {
2850
- set2(refCountAtom({ formId, field }), (prev) => prev - 1);
2851
- const newRefCount = get2(refCountAtom({ formId, field }));
2852
- if (newRefCount === 0) {
2853
- set2(controlledFieldsAtom(formId), (prev) => omit_1(prev, field));
2854
- fieldValueAtom.remove({ formId, field });
2855
- resolveValueUpdateAtom.remove({ formId, field });
2856
- fieldValueHydratedAtom.remove({ formId, field });
2857
- }
2154
+ const defaultDefaultValues = {};
2155
+ const useSyncedDefaultValues = (formId) => useFormStore(formId, (state) => {
2156
+ var _a, _b;
2157
+ return (_b = (_a = state.formProps) == null ? void 0 : _a.defaultValues) != null ? _b : defaultDefaultValues;
2858
2158
  });
2859
- const setControlledFieldValueAtom = atom(null, (_get, set2, {
2860
- formId,
2861
- field,
2862
- value
2863
- }) => {
2864
- set2(fieldValueAtom({ formId, field }), value);
2865
- const resolveAtom = resolveValueUpdateAtom({ formId, field });
2866
- const promiseAtom = valueUpdatePromiseAtom({ formId, field });
2867
- const promise = new Promise((resolve) => set2(resolveAtom, () => {
2868
- resolve();
2869
- set2(resolveAtom, void 0);
2870
- set2(promiseAtom, void 0);
2871
- }));
2872
- set2(promiseAtom, promise);
2159
+ const useSetTouched = ({ formId }) => useFormStore(formId, (state) => state.setTouched);
2160
+ const useTouchedFields = (formId) => useFormStore(formId, (state) => state.touchedFields);
2161
+ const useFieldErrors = (formId) => useFormStore(formId, (state) => state.fieldErrors);
2162
+ const useSetFieldErrors = (formId) => useFormStore(formId, (state) => state.setFieldErrors);
2163
+ const useResetFormElement = (formId) => useFormStore(formId, (state) => state.resetFormElement);
2164
+ const useFormActionProp = (formId) => useFormStore(formId, (state) => {
2165
+ var _a;
2166
+ return (_a = state.formProps) == null ? void 0 : _a.action;
2167
+ });
2168
+ const useFormSubactionProp = (formId) => useFormStore(formId, (state) => {
2169
+ var _a;
2170
+ return (_a = state.formProps) == null ? void 0 : _a.subaction;
2873
2171
  });
2874
2172
  const useControlledFieldValue = (context, field) => {
2875
- const fieldAtom = fieldValueAtom({ formId: context.formId, field });
2876
- const [value, setValue] = useFormAtom(fieldAtom);
2173
+ const useValueStore = controlledFieldStore(context.formId);
2174
+ const value = useValueStore((state) => {
2175
+ var _a;
2176
+ return (_a = state.fields[field]) == null ? void 0 : _a.value;
2177
+ });
2178
+ const useFormStore2 = formStore(context.formId);
2179
+ const isFormHydrated = useFormStore2((state) => state.isHydrated);
2877
2180
  const defaultValue = useFieldDefaultValue(field, context);
2878
- const isHydrated = useFormAtomValue(isHydratedAtom(context.formId));
2879
- const [isFieldHydrated, setIsFieldHydrated] = useFormAtom(fieldValueHydratedAtom({ formId: context.formId, field }));
2181
+ const isFieldHydrated = useValueStore((state) => {
2182
+ var _a, _b;
2183
+ return (_b = (_a = state.fields[field]) == null ? void 0 : _a.hydrated) != null ? _b : false;
2184
+ });
2185
+ const hydrateWithDefault = useValueStore((state) => state.hydrateWithDefault);
2880
2186
  useEffect(() => {
2881
- if (isHydrated && !isFieldHydrated) {
2882
- setValue(defaultValue);
2883
- setIsFieldHydrated(true);
2187
+ if (isFormHydrated && !isFieldHydrated) {
2188
+ hydrateWithDefault(field, defaultValue);
2884
2189
  }
2885
2190
  }, [
2886
2191
  defaultValue,
2887
2192
  field,
2888
- context.formId,
2193
+ hydrateWithDefault,
2889
2194
  isFieldHydrated,
2890
- isHydrated,
2891
- setIsFieldHydrated,
2892
- setValue
2195
+ isFormHydrated
2893
2196
  ]);
2894
2197
  return isFieldHydrated ? value : defaultValue;
2895
2198
  };
2896
2199
  const useControllableValue = (context, field) => {
2897
- const resolveUpdate = useFormAtomValue(resolveValueUpdateAtom({ formId: context.formId, field }));
2200
+ const useValueStore = controlledFieldStore(context.formId);
2201
+ const resolveUpdate = useValueStore((state) => {
2202
+ var _a;
2203
+ return (_a = state.fields[field]) == null ? void 0 : _a.resolveValueUpdate;
2204
+ });
2898
2205
  useEffect(() => {
2899
2206
  resolveUpdate == null ? void 0 : resolveUpdate();
2900
2207
  }, [resolveUpdate]);
2901
- const register = useFormUpdateAtom(registerAtom);
2902
- const unregister = useFormUpdateAtom(unregisterAtom);
2208
+ const register = useValueStore((state) => state.register);
2209
+ const unregister = useValueStore((state) => state.unregister);
2903
2210
  useEffect(() => {
2904
- register({ formId: context.formId, field });
2905
- return () => unregister({ formId: context.formId, field });
2211
+ register(field);
2212
+ return () => unregister(field);
2906
2213
  }, [context.formId, field, register, unregister]);
2907
- const setControlledFieldValue = useFormUpdateAtom(setControlledFieldValueAtom);
2908
- const setValue = useCallback((value2) => setControlledFieldValue({ formId: context.formId, field, value: value2 }), [field, context.formId, setControlledFieldValue]);
2214
+ const setControlledFieldValue = useValueStore((state) => state.setValue);
2215
+ const setValue = useCallback((value2) => setControlledFieldValue(field, value2), [field, setControlledFieldValue]);
2909
2216
  const value = useControlledFieldValue(context, field);
2910
2217
  return [value, setValue];
2911
2218
  };
2912
2219
  const useUpdateControllableValue = (formId) => {
2913
- const setControlledFieldValue = useFormUpdateAtom(setControlledFieldValueAtom);
2914
- return useCallback((field, value) => setControlledFieldValue({ formId, field, value }), [formId, setControlledFieldValue]);
2915
- };
2916
- const useAwaitValue = (formId) => {
2917
- return useAtomCallback(useCallback(async (get2, _set, field) => {
2918
- await get2(valueUpdatePromiseAtom({ formId, field }));
2919
- }, [formId]));
2220
+ const useValueStore = controlledFieldStore(formId);
2221
+ return useValueStore((state) => state.setValue);
2920
2222
  };
2921
2223
  const useIsSubmitting = (formId) => {
2922
2224
  const formContext = useInternalFormContext(formId, "useIsSubmitting");
2923
- return useFormAtomValue(isSubmittingAtom(formContext.formId));
2225
+ return useInternalIsSubmitting(formContext.formId);
2924
2226
  };
2925
2227
  const useIsValid = (formId) => {
2926
2228
  const formContext = useInternalFormContext(formId, "useIsValid");
2927
- return useFormAtomValue(isValidAtom(formContext.formId));
2229
+ return useInternalIsValid(formContext.formId);
2928
2230
  };
2929
2231
  const useField = (name, options) => {
2930
2232
  const { formId: providedFormId, handleReceiveFocus } = options != null ? options : {};
2931
2233
  const formContext = useInternalFormContext(providedFormId, "useField");
2932
2234
  const defaultValue = useFieldDefaultValue(name, formContext);
2933
2235
  const [touched, setTouched] = useFieldTouched(name, formContext);
2934
- const [error, setError] = useFieldError(name, formContext);
2935
- const hasBeenSubmitted = useFormAtomValue(hasBeenSubmittedAtom(formContext.formId));
2936
- const { validateField, registerReceiveFocus } = useFormAtomValue(formPropsAtom(formContext.formId));
2236
+ const error = useFieldError(name, formContext);
2237
+ const clearError = useClearError(formContext);
2238
+ const hasBeenSubmitted = useInternalHasBeenSubmitted(formContext.formId);
2239
+ const validateField = useValidateField(formContext.formId);
2240
+ const registerReceiveFocus = useRegisterReceiveFocus(formContext.formId);
2937
2241
  useEffect(() => {
2938
2242
  if (handleReceiveFocus)
2939
2243
  return registerReceiveFocus(name, handleReceiveFocus);
@@ -2941,7 +2245,7 @@ const useField = (name, options) => {
2941
2245
  const field = useMemo(() => {
2942
2246
  const helpers = {
2943
2247
  error,
2944
- clearError: () => setError(void 0),
2248
+ clearError: () => clearError(name),
2945
2249
  validate: () => {
2946
2250
  validateField(name);
2947
2251
  },
@@ -2959,13 +2263,13 @@ const useField = (name, options) => {
2959
2263
  });
2960
2264
  }, [
2961
2265
  error,
2266
+ clearError,
2962
2267
  defaultValue,
2963
2268
  touched,
2964
2269
  setTouched,
2965
2270
  name,
2966
2271
  hasBeenSubmitted,
2967
2272
  options == null ? void 0 : options.validationBehavior,
2968
- setError,
2969
2273
  validateField
2970
2274
  ]);
2971
2275
  return field;
@@ -3133,14 +2437,10 @@ const useMultiValueMap = () => {
3133
2437
  return ref.current;
3134
2438
  }, []);
3135
2439
  };
3136
- const resetAtom = atomFamily((formId) => atom(null, (get2, set2) => {
3137
- set2(fieldErrorsAtom(formId), {});
3138
- set2(touchedFieldsAtom(formId), {});
3139
- set2(hasBeenSubmittedAtom(formId), false);
3140
- const { defaultValues } = get2(formPropsAtom(formId));
3141
- const controlledFields = get2(controlledFieldsAtom(formId));
3142
- Object.entries(controlledFields).forEach(([name, atom2]) => set2(atom2, get_1(defaultValues, name)));
3143
- }));
2440
+ const cleanupFormState = (formId) => {
2441
+ formStore.remove(formId);
2442
+ controlledFieldStore.remove(formId);
2443
+ };
3144
2444
  function useSubmitComplete(isSubmitting, callback) {
3145
2445
  const isPending = useRef(false);
3146
2446
  useEffect(() => {
@@ -3153,6 +2453,11 @@ function useSubmitComplete(isSubmitting, callback) {
3153
2453
  }
3154
2454
  });
3155
2455
  }
2456
+ var baseIsEqual = _baseIsEqual;
2457
+ function isEqual(value, other) {
2458
+ return baseIsEqual(value, other);
2459
+ }
2460
+ var isEqual_1 = isEqual;
3156
2461
  const mergeRefs = (refs) => {
3157
2462
  return (value) => {
3158
2463
  refs.filter(Boolean).forEach((ref) => {
@@ -3296,31 +2601,19 @@ function ValidatedForm(_a) {
3296
2601
  const formRef = useRef(null);
3297
2602
  const Form$1 = (_a2 = fetcher == null ? void 0 : fetcher.Form) != null ? _a2 : Form;
3298
2603
  const submit = useSubmit();
3299
- const setFieldErrors = useFormUpdateAtom(fieldErrorsAtom(formId));
3300
- const setFieldError = useFormUpdateAtom(setFieldErrorAtom(formId));
3301
- const reset = useFormUpdateAtom(resetAtom(formId));
3302
- const startSubmit = useFormUpdateAtom(startSubmitAtom(formId));
3303
- const endSubmit = useFormUpdateAtom(endSubmitAtom(formId));
3304
- const syncFormProps = useFormUpdateAtom(formPropsAtom(formId));
3305
- const setHydrated = useFormUpdateAtom(isHydratedAtom(formId));
3306
- const setFormElementInState = useFormUpdateAtom(formElementAtom(formId));
2604
+ const setFieldErrors = useSetFieldErrors(formId);
2605
+ const setFieldError = useFormStore(formId, (state) => state.setFieldError);
2606
+ const reset = useFormStore(formId, (state) => state.reset);
2607
+ const resetControlledFields = useControlledFieldStore(formId, (state) => state.reset);
2608
+ const startSubmit = useFormStore(formId, (state) => state.startSubmit);
2609
+ const endSubmit = useFormStore(formId, (state) => state.endSubmit);
2610
+ const syncFormProps = useFormStore(formId, (state) => state.syncFormProps);
2611
+ const setHydrated = useFormStore(formId, (state) => state.setHydrated);
2612
+ const setFormElementInState = useFormStore(formId, (state) => state.setFormElement);
3307
2613
  useEffect(() => {
3308
- setHydrated(true);
2614
+ setHydrated();
3309
2615
  return () => cleanupFormState(formId);
3310
2616
  }, [formId, setHydrated]);
3311
- const awaitValue = useAwaitValue(formId);
3312
- const validateField = useCallback(async (field) => {
3313
- invariant(formRef.current);
3314
- await awaitValue(field);
3315
- const { error } = await validator.validateField(getDataFromForm(formRef.current), field);
3316
- if (error) {
3317
- setFieldError({ field, error });
3318
- return error;
3319
- } else {
3320
- setFieldError({ field, error: void 0 });
3321
- return null;
3322
- }
3323
- }, [awaitValue, setFieldError, validator]);
3324
2617
  const customFocusHandlers = useMultiValueMap();
3325
2618
  const registerReceiveFocus = useCallback((fieldName, handler) => {
3326
2619
  customFocusHandlers().add(fieldName, handler);
@@ -3334,8 +2627,8 @@ function ValidatedForm(_a) {
3334
2627
  action,
3335
2628
  defaultValues: (_a3 = providedDefaultValues != null ? providedDefaultValues : backendDefaultValues) != null ? _a3 : {},
3336
2629
  subaction,
3337
- validateField,
3338
- registerReceiveFocus
2630
+ registerReceiveFocus,
2631
+ validator
3339
2632
  });
3340
2633
  }, [
3341
2634
  action,
@@ -3343,8 +2636,8 @@ function ValidatedForm(_a) {
3343
2636
  registerReceiveFocus,
3344
2637
  subaction,
3345
2638
  syncFormProps,
3346
- validateField,
3347
- backendDefaultValues
2639
+ backendDefaultValues,
2640
+ validator
3348
2641
  ]);
3349
2642
  useEffect(() => {
3350
2643
  var _a3;
@@ -3371,9 +2664,9 @@ function ValidatedForm(_a) {
3371
2664
  window.removeEventListener("click", handleClick, { capture: true });
3372
2665
  };
3373
2666
  }, []);
3374
- const handleSubmit = async (e) => {
2667
+ const handleSubmit = async (e2) => {
3375
2668
  startSubmit();
3376
- const result = await validator.validate(getDataFromForm(e.currentTarget));
2669
+ const result = await validator.validate(getDataFromForm(e2.currentTarget));
3377
2670
  if (result.error) {
3378
2671
  endSubmit();
3379
2672
  setFieldErrors(result.error.fieldErrors);
@@ -3381,7 +2674,7 @@ function ValidatedForm(_a) {
3381
2674
  focusFirstInvalidInput(result.error.fieldErrors, customFocusHandlers(), formRef.current);
3382
2675
  }
3383
2676
  } else {
3384
- const eventProxy = formEventProxy(e);
2677
+ const eventProxy = formEventProxy(e2);
3385
2678
  await (onSubmit == null ? void 0 : onSubmit(result.data, eventProxy));
3386
2679
  if (eventProxy.defaultPrevented) {
3387
2680
  endSubmit();
@@ -3404,15 +2697,16 @@ function ValidatedForm(_a) {
3404
2697
  action,
3405
2698
  method,
3406
2699
  replace,
3407
- onSubmit: (e) => {
3408
- e.preventDefault();
3409
- handleSubmit(e);
2700
+ onSubmit: (e2) => {
2701
+ e2.preventDefault();
2702
+ handleSubmit(e2);
3410
2703
  },
3411
2704
  onReset: (event) => {
3412
2705
  onReset == null ? void 0 : onReset(event);
3413
2706
  if (event.defaultPrevented)
3414
2707
  return;
3415
2708
  reset();
2709
+ resetControlledFields();
3416
2710
  }
3417
2711
  }), /* @__PURE__ */ React.createElement(InternalFormContext.Provider, {
3418
2712
  value: contextValue
@@ -3472,18 +2766,22 @@ function createValidator(validator) {
3472
2766
  };
3473
2767
  }
3474
2768
  const useFormState = (formId) => {
3475
- const formContext = useInternalFormContext(formId, "useIsValid");
3476
- const formProps = useFormAtomValue(formPropsAtom(formContext.formId));
3477
- const isSubmitting = useFormAtomValue(isSubmittingAtom(formContext.formId));
3478
- const hasBeenSubmitted = useFormAtomValue(hasBeenSubmittedAtom(formContext.formId));
3479
- const touchedFields = useFormAtomValue(touchedFieldsAtom(formContext.formId));
3480
- const isValid = useFormAtomValue(isValidAtom(formContext.formId));
2769
+ const formContext = useInternalFormContext(formId, "useFormState");
2770
+ const isSubmitting = useInternalIsSubmitting(formContext.formId);
2771
+ const hasBeenSubmitted = useInternalHasBeenSubmitted(formContext.formId);
2772
+ const touchedFields = useTouchedFields(formContext.formId);
2773
+ const isValid = useInternalIsValid(formContext.formId);
2774
+ const action = useFormActionProp(formContext.formId);
2775
+ const subaction = useFormSubactionProp(formContext.formId);
2776
+ const syncedDefaultValues = useSyncedDefaultValues(formContext.formId);
3481
2777
  const defaultValuesToUse = useDefaultValuesForForm(formContext);
3482
- const hydratedDefaultValues = defaultValuesToUse.hydrateTo(formProps.defaultValues);
3483
- const fieldErrorsFromState = useFormAtomValue(fieldErrorsAtom(formContext.formId));
2778
+ const hydratedDefaultValues = defaultValuesToUse.hydrateTo(syncedDefaultValues);
2779
+ const fieldErrorsFromState = useFieldErrors(formContext.formId);
3484
2780
  const fieldErrorsToUse = useFieldErrorsForForm(formContext);
3485
2781
  const hydratedFieldErrors = fieldErrorsToUse.hydrateTo(fieldErrorsFromState);
3486
- return useMemo(() => __spreadProps(__spreadValues({}, formProps), {
2782
+ return useMemo(() => ({
2783
+ action,
2784
+ subaction,
3487
2785
  defaultValues: hydratedDefaultValues,
3488
2786
  fieldErrors: hydratedFieldErrors != null ? hydratedFieldErrors : {},
3489
2787
  hasBeenSubmitted,
@@ -3491,25 +2789,32 @@ const useFormState = (formId) => {
3491
2789
  touchedFields,
3492
2790
  isValid
3493
2791
  }), [
3494
- formProps,
2792
+ action,
3495
2793
  hasBeenSubmitted,
3496
2794
  hydratedDefaultValues,
3497
2795
  hydratedFieldErrors,
3498
2796
  isSubmitting,
3499
2797
  isValid,
2798
+ subaction,
3500
2799
  touchedFields
3501
2800
  ]);
3502
2801
  };
3503
2802
  const useFormHelpers = (formId) => {
3504
2803
  const formContext = useInternalFormContext(formId, "useFormHelpers");
3505
2804
  const setTouched = useSetTouched(formContext);
3506
- const { validateField } = useFormAtomValue(formPropsAtom(formContext.formId));
2805
+ const validateField = useValidateField(formContext.formId);
2806
+ const validate = useValidate(formContext.formId);
3507
2807
  const clearError = useClearError(formContext);
2808
+ const setFieldErrors = useSetFieldErrors(formContext.formId);
2809
+ const reset = useResetFormElement(formContext.formId);
3508
2810
  return useMemo(() => ({
3509
2811
  setTouched,
3510
2812
  validateField,
3511
- clearError
3512
- }), [clearError, setTouched, validateField]);
2813
+ clearError,
2814
+ validate,
2815
+ clearAllErrors: () => setFieldErrors({}),
2816
+ reset
2817
+ }), [clearError, reset, setFieldErrors, setTouched, validate, validateField]);
3513
2818
  };
3514
2819
  const useFormContext = (formId) => {
3515
2820
  const context = useInternalFormContext(formId, "useFormContext");
@@ -3517,9 +2822,11 @@ const useFormContext = (formId) => {
3517
2822
  const {
3518
2823
  clearError: internalClearError,
3519
2824
  setTouched,
3520
- validateField
2825
+ validateField,
2826
+ clearAllErrors,
2827
+ validate
3521
2828
  } = useFormHelpers(formId);
3522
- const { registerReceiveFocus } = useFormAtomValue(formPropsAtom(context.formId));
2829
+ const registerReceiveFocus = useRegisterReceiveFocus(context.formId);
3523
2830
  const clearError = useCallback((...names) => {
3524
2831
  names.forEach((name) => {
3525
2832
  internalClearError(name);
@@ -3529,7 +2836,9 @@ const useFormContext = (formId) => {
3529
2836
  setFieldTouched: setTouched,
3530
2837
  validateField,
3531
2838
  clearError,
3532
- registerReceiveFocus
2839
+ registerReceiveFocus,
2840
+ clearAllErrors,
2841
+ validate
3533
2842
  });
3534
2843
  };
3535
2844
  export { ValidatedForm, createValidator, setFormDefaults, useControlField, useField, useFormContext, useIsSubmitting, useIsValid, useUpdateControlledField, validationError };