remix-validated-form 5.1.0 → 5.1.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -23,6 +26,351 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
26
  ));
24
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
28
 
29
+ // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js
30
+ var require_use_sync_external_store_shim_production_min = __commonJS({
31
+ "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js"(exports) {
32
+ "use strict";
33
+ var e = require("react");
34
+ function h2(a2, b2) {
35
+ return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
36
+ }
37
+ var k2 = "function" === typeof Object.is ? Object.is : h2;
38
+ var l2 = e.useState;
39
+ var m = e.useEffect;
40
+ var n2 = e.useLayoutEffect;
41
+ var p2 = e.useDebugValue;
42
+ function q2(a2, b2) {
43
+ var d2 = b2(), f2 = l2({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
44
+ n2(function() {
45
+ c2.value = d2;
46
+ c2.getSnapshot = b2;
47
+ r2(c2) && g2({ inst: c2 });
48
+ }, [a2, d2, b2]);
49
+ m(function() {
50
+ r2(c2) && g2({ inst: c2 });
51
+ return a2(function() {
52
+ r2(c2) && g2({ inst: c2 });
53
+ });
54
+ }, [a2]);
55
+ p2(d2);
56
+ return d2;
57
+ }
58
+ function r2(a2) {
59
+ var b2 = a2.getSnapshot;
60
+ a2 = a2.value;
61
+ try {
62
+ var d2 = b2();
63
+ return !k2(a2, d2);
64
+ } catch (f2) {
65
+ return true;
66
+ }
67
+ }
68
+ function t2(a2, b2) {
69
+ return b2();
70
+ }
71
+ var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2;
72
+ exports.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u2;
73
+ }
74
+ });
75
+
76
+ // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
77
+ var require_use_sync_external_store_shim_development = __commonJS({
78
+ "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
79
+ "use strict";
80
+ if (process.env.NODE_ENV !== "production") {
81
+ (function() {
82
+ "use strict";
83
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
84
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
85
+ }
86
+ var React3 = require("react");
87
+ var ReactSharedInternals = React3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
88
+ function error(format) {
89
+ {
90
+ {
91
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
92
+ args[_key2 - 1] = arguments[_key2];
93
+ }
94
+ printWarning("error", format, args);
95
+ }
96
+ }
97
+ }
98
+ function printWarning(level, format, args) {
99
+ {
100
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
101
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
102
+ if (stack !== "") {
103
+ format += "%s";
104
+ args = args.concat([stack]);
105
+ }
106
+ var argsWithFormat = args.map(function(item) {
107
+ return String(item);
108
+ });
109
+ argsWithFormat.unshift("Warning: " + format);
110
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
111
+ }
112
+ }
113
+ function is(x2, y2) {
114
+ return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
115
+ }
116
+ var objectIs = typeof Object.is === "function" ? Object.is : is;
117
+ var useState3 = React3.useState, useEffect6 = React3.useEffect, useLayoutEffect2 = React3.useLayoutEffect, useDebugValue2 = React3.useDebugValue;
118
+ var didWarnOld18Alpha = false;
119
+ var didWarnUncachedGetSnapshot = false;
120
+ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
121
+ {
122
+ if (!didWarnOld18Alpha) {
123
+ if (React3.startTransition !== void 0) {
124
+ didWarnOld18Alpha = true;
125
+ error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
126
+ }
127
+ }
128
+ }
129
+ var value = getSnapshot();
130
+ {
131
+ if (!didWarnUncachedGetSnapshot) {
132
+ var cachedValue = getSnapshot();
133
+ if (!objectIs(value, cachedValue)) {
134
+ error("The result of getSnapshot should be cached to avoid an infinite loop");
135
+ didWarnUncachedGetSnapshot = true;
136
+ }
137
+ }
138
+ }
139
+ var _useState = useState3({
140
+ inst: {
141
+ value,
142
+ getSnapshot
143
+ }
144
+ }), inst = _useState[0].inst, forceUpdate = _useState[1];
145
+ useLayoutEffect2(function() {
146
+ inst.value = value;
147
+ inst.getSnapshot = getSnapshot;
148
+ if (checkIfSnapshotChanged(inst)) {
149
+ forceUpdate({
150
+ inst
151
+ });
152
+ }
153
+ }, [subscribe, value, getSnapshot]);
154
+ useEffect6(function() {
155
+ if (checkIfSnapshotChanged(inst)) {
156
+ forceUpdate({
157
+ inst
158
+ });
159
+ }
160
+ var handleStoreChange = function() {
161
+ if (checkIfSnapshotChanged(inst)) {
162
+ forceUpdate({
163
+ inst
164
+ });
165
+ }
166
+ };
167
+ return subscribe(handleStoreChange);
168
+ }, [subscribe]);
169
+ useDebugValue2(value);
170
+ return value;
171
+ }
172
+ function checkIfSnapshotChanged(inst) {
173
+ var latestGetSnapshot = inst.getSnapshot;
174
+ var prevValue = inst.value;
175
+ try {
176
+ var nextValue = latestGetSnapshot();
177
+ return !objectIs(prevValue, nextValue);
178
+ } catch (error2) {
179
+ return true;
180
+ }
181
+ }
182
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
183
+ return getSnapshot();
184
+ }
185
+ var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
186
+ var isServerEnvironment = !canUseDOM;
187
+ var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
188
+ var useSyncExternalStore$2 = React3.useSyncExternalStore !== void 0 ? React3.useSyncExternalStore : shim;
189
+ exports.useSyncExternalStore = useSyncExternalStore$2;
190
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
191
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
192
+ }
193
+ })();
194
+ }
195
+ }
196
+ });
197
+
198
+ // ../../node_modules/use-sync-external-store/shim/index.js
199
+ var require_shim = __commonJS({
200
+ "../../node_modules/use-sync-external-store/shim/index.js"(exports, module2) {
201
+ "use strict";
202
+ if (process.env.NODE_ENV === "production") {
203
+ module2.exports = require_use_sync_external_store_shim_production_min();
204
+ } else {
205
+ module2.exports = require_use_sync_external_store_shim_development();
206
+ }
207
+ }
208
+ });
209
+
210
+ // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js
211
+ var require_with_selector_production_min = __commonJS({
212
+ "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js"(exports) {
213
+ "use strict";
214
+ var h2 = require("react");
215
+ var n2 = require_shim();
216
+ function p2(a2, b2) {
217
+ return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
218
+ }
219
+ var q2 = "function" === typeof Object.is ? Object.is : p2;
220
+ var r2 = n2.useSyncExternalStore;
221
+ var t2 = h2.useRef;
222
+ var u2 = h2.useEffect;
223
+ var v2 = h2.useMemo;
224
+ var w2 = h2.useDebugValue;
225
+ exports.useSyncExternalStoreWithSelector = function(a2, b2, e, l2, g2) {
226
+ var c2 = t2(null);
227
+ if (null === c2.current) {
228
+ var f2 = { hasValue: false, value: null };
229
+ c2.current = f2;
230
+ } else
231
+ f2 = c2.current;
232
+ c2 = v2(function() {
233
+ function a3(a4) {
234
+ if (!c3) {
235
+ c3 = true;
236
+ d3 = a4;
237
+ a4 = l2(a4);
238
+ if (void 0 !== g2 && f2.hasValue) {
239
+ var b3 = f2.value;
240
+ if (g2(b3, a4))
241
+ return k2 = b3;
242
+ }
243
+ return k2 = a4;
244
+ }
245
+ b3 = k2;
246
+ if (q2(d3, a4))
247
+ return b3;
248
+ var e2 = l2(a4);
249
+ if (void 0 !== g2 && g2(b3, e2))
250
+ return b3;
251
+ d3 = a4;
252
+ return k2 = e2;
253
+ }
254
+ var c3 = false, d3, k2, m = void 0 === e ? null : e;
255
+ return [function() {
256
+ return a3(b2());
257
+ }, null === m ? void 0 : function() {
258
+ return a3(m());
259
+ }];
260
+ }, [b2, e, l2, g2]);
261
+ var d2 = r2(a2, c2[0], c2[1]);
262
+ u2(function() {
263
+ f2.hasValue = true;
264
+ f2.value = d2;
265
+ }, [d2]);
266
+ w2(d2);
267
+ return d2;
268
+ };
269
+ }
270
+ });
271
+
272
+ // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
273
+ var require_with_selector_development = __commonJS({
274
+ "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
275
+ "use strict";
276
+ if (process.env.NODE_ENV !== "production") {
277
+ (function() {
278
+ "use strict";
279
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
280
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
281
+ }
282
+ var React3 = require("react");
283
+ var shim = require_shim();
284
+ function is(x2, y2) {
285
+ return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
286
+ }
287
+ var objectIs = typeof Object.is === "function" ? Object.is : is;
288
+ var useSyncExternalStore = shim.useSyncExternalStore;
289
+ var useRef6 = React3.useRef, useEffect6 = React3.useEffect, useMemo6 = React3.useMemo, useDebugValue2 = React3.useDebugValue;
290
+ function useSyncExternalStoreWithSelector2(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
291
+ var instRef = useRef6(null);
292
+ var inst;
293
+ if (instRef.current === null) {
294
+ inst = {
295
+ hasValue: false,
296
+ value: null
297
+ };
298
+ instRef.current = inst;
299
+ } else {
300
+ inst = instRef.current;
301
+ }
302
+ var _useMemo = useMemo6(function() {
303
+ var hasMemo = false;
304
+ var memoizedSnapshot;
305
+ var memoizedSelection;
306
+ var memoizedSelector = function(nextSnapshot) {
307
+ if (!hasMemo) {
308
+ hasMemo = true;
309
+ memoizedSnapshot = nextSnapshot;
310
+ var _nextSelection = selector(nextSnapshot);
311
+ if (isEqual !== void 0) {
312
+ if (inst.hasValue) {
313
+ var currentSelection = inst.value;
314
+ if (isEqual(currentSelection, _nextSelection)) {
315
+ memoizedSelection = currentSelection;
316
+ return currentSelection;
317
+ }
318
+ }
319
+ }
320
+ memoizedSelection = _nextSelection;
321
+ return _nextSelection;
322
+ }
323
+ var prevSnapshot = memoizedSnapshot;
324
+ var prevSelection = memoizedSelection;
325
+ if (objectIs(prevSnapshot, nextSnapshot)) {
326
+ return prevSelection;
327
+ }
328
+ var nextSelection = selector(nextSnapshot);
329
+ if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
330
+ return prevSelection;
331
+ }
332
+ memoizedSnapshot = nextSnapshot;
333
+ memoizedSelection = nextSelection;
334
+ return nextSelection;
335
+ };
336
+ var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
337
+ var getSnapshotWithSelector = function() {
338
+ return memoizedSelector(getSnapshot());
339
+ };
340
+ var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
341
+ return memoizedSelector(maybeGetServerSnapshot());
342
+ };
343
+ return [getSnapshotWithSelector, getServerSnapshotWithSelector];
344
+ }, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
345
+ var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
346
+ useEffect6(function() {
347
+ inst.hasValue = true;
348
+ inst.value = value;
349
+ }, [value]);
350
+ useDebugValue2(value);
351
+ return value;
352
+ }
353
+ exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector2;
354
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
355
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
356
+ }
357
+ })();
358
+ }
359
+ }
360
+ });
361
+
362
+ // ../../node_modules/use-sync-external-store/shim/with-selector.js
363
+ var require_with_selector = __commonJS({
364
+ "../../node_modules/use-sync-external-store/shim/with-selector.js"(exports, module2) {
365
+ "use strict";
366
+ if (process.env.NODE_ENV === "production") {
367
+ module2.exports = require_with_selector_production_min();
368
+ } else {
369
+ module2.exports = require_with_selector_development();
370
+ }
371
+ }
372
+ });
373
+
26
374
  // src/index.ts
27
375
  var src_exports = {};
28
376
  __export(src_exports, {
@@ -42,7 +390,7 @@ __export(src_exports, {
42
390
  module.exports = __toCommonJS(src_exports);
43
391
 
44
392
  // src/hooks.ts
45
- var import_react5 = require("react");
393
+ var import_react6 = require("react");
46
394
 
47
395
  // src/internal/getInputProps.ts
48
396
  var R = __toESM(require("remeda"));
@@ -128,8 +476,8 @@ var createGetInputProps = ({
128
476
  };
129
477
 
130
478
  // src/internal/hooks.ts
131
- var import_react2 = require("@remix-run/react");
132
- var import_react3 = require("react");
479
+ var import_react3 = require("@remix-run/react");
480
+ var import_react4 = require("react");
133
481
 
134
482
  // ../set-get/src/stringToPathArray.ts
135
483
  var stringToPathArray = (path) => {
@@ -137,7 +485,7 @@ var stringToPathArray = (path) => {
137
485
  return [];
138
486
  const match = path.match(/^\[(.+?)\](.*)$/) || path.match(/^\.?([^\.\[\]]+)(.*)$/);
139
487
  if (match) {
140
- const [_, key, rest] = match;
488
+ const [_2, key, rest] = match;
141
489
  return [/^\d+$/.test(key) ? Number(key) : key, ...stringToPathArray(rest)];
142
490
  }
143
491
  return [path];
@@ -152,10 +500,10 @@ function _setPathNormalized(object, path, value) {
152
500
  const leadingSegments = path.slice(0, -1);
153
501
  const lastSegment = path[path.length - 1];
154
502
  let obj = object;
155
- for (let i = 0; i < leadingSegments.length; i++) {
156
- const segment = leadingSegments[i];
503
+ for (let i2 = 0; i2 < leadingSegments.length; i2++) {
504
+ const segment = leadingSegments[i2];
157
505
  if (obj[segment] === void 0) {
158
- const nextSegment = (_a = leadingSegments[i + 1]) != null ? _a : lastSegment;
506
+ const nextSegment = (_a = leadingSegments[i2 + 1]) != null ? _a : lastSegment;
159
507
  obj[segment] = typeof nextSegment === "number" ? [] : {};
160
508
  }
161
509
  obj = obj[segment];
@@ -185,7 +533,7 @@ var InternalFormContext = (0, import_react.createContext)(null);
185
533
  // src/internal/hydratable.ts
186
534
  var serverData = (data) => ({
187
535
  hydrateTo: () => data,
188
- map: (fn) => serverData(fn(data))
536
+ map: (fn2) => serverData(fn2(data))
189
537
  });
190
538
  var hydratedData = () => ({
191
539
  hydrateTo: (hydratedData2) => hydratedData2,
@@ -200,8 +548,459 @@ var hydratable = {
200
548
 
201
549
  // src/internal/state/createFormStore.ts
202
550
  var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
203
- var import_zustand = require("zustand");
204
- var import_immer = require("zustand/middleware/immer");
551
+
552
+ // ../../node_modules/zustand/esm/vanilla.mjs
553
+ var import_meta = {};
554
+ var createStoreImpl = (createState) => {
555
+ let state;
556
+ const listeners = /* @__PURE__ */ new Set();
557
+ const setState = (partial, replace2) => {
558
+ const nextState = typeof partial === "function" ? partial(state) : partial;
559
+ if (!Object.is(nextState, state)) {
560
+ const previousState = state;
561
+ state = (replace2 != null ? replace2 : typeof nextState !== "object") ? nextState : Object.assign({}, state, nextState);
562
+ listeners.forEach((listener) => listener(state, previousState));
563
+ }
564
+ };
565
+ const getState = () => state;
566
+ const subscribe = (listener) => {
567
+ listeners.add(listener);
568
+ return () => listeners.delete(listener);
569
+ };
570
+ const destroy = () => {
571
+ if ((import_meta.env && import_meta.env.MODE) !== "production") {
572
+ console.warn(
573
+ "[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected."
574
+ );
575
+ }
576
+ listeners.clear();
577
+ };
578
+ const api = { setState, getState, subscribe, destroy };
579
+ state = createState(setState, getState, api);
580
+ return api;
581
+ };
582
+ var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
583
+
584
+ // ../../node_modules/zustand/esm/index.mjs
585
+ var import_react2 = require("react");
586
+ var import_with_selector = __toESM(require_with_selector(), 1);
587
+ var import_meta2 = {};
588
+ var { useSyncExternalStoreWithSelector } = import_with_selector.default;
589
+ function useStore(api, selector = api.getState, equalityFn) {
590
+ const slice = useSyncExternalStoreWithSelector(
591
+ api.subscribe,
592
+ api.getState,
593
+ api.getServerState || api.getState,
594
+ selector,
595
+ equalityFn
596
+ );
597
+ (0, import_react2.useDebugValue)(slice);
598
+ return slice;
599
+ }
600
+ var createImpl = (createState) => {
601
+ if ((import_meta2.env && import_meta2.env.MODE) !== "production" && typeof createState !== "function") {
602
+ console.warn(
603
+ '[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.'
604
+ );
605
+ }
606
+ const api = typeof createState === "function" ? createStore(createState) : createState;
607
+ const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
608
+ Object.assign(useBoundStore, api);
609
+ return useBoundStore;
610
+ };
611
+ var create = (createState) => createState ? createImpl(createState) : createImpl;
612
+
613
+ // ../../node_modules/immer/dist/immer.esm.mjs
614
+ function n(n2) {
615
+ for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e = 1; e < r2; e++)
616
+ t2[e - 1] = arguments[e];
617
+ if ("production" !== process.env.NODE_ENV) {
618
+ var i2 = Y[n2], o2 = i2 ? "function" == typeof i2 ? i2.apply(null, t2) : i2 : "unknown error nr: " + n2;
619
+ throw Error("[Immer] " + o2);
620
+ }
621
+ throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) {
622
+ return "'" + n3 + "'";
623
+ }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
624
+ }
625
+ function r(n2) {
626
+ return !!n2 && !!n2[Q];
627
+ }
628
+ function t(n2) {
629
+ var r2;
630
+ return !!n2 && (function(n3) {
631
+ if (!n3 || "object" != typeof n3)
632
+ return false;
633
+ var r3 = Object.getPrototypeOf(n3);
634
+ if (null === r3)
635
+ return true;
636
+ var t2 = Object.hasOwnProperty.call(r3, "constructor") && r3.constructor;
637
+ return t2 === Object || "function" == typeof t2 && Function.toString.call(t2) === Z;
638
+ }(n2) || Array.isArray(n2) || !!n2[L] || !!(null === (r2 = n2.constructor) || void 0 === r2 ? void 0 : r2[L]) || s(n2) || v(n2));
639
+ }
640
+ function i(n2, r2, t2) {
641
+ void 0 === t2 && (t2 = false), 0 === o(n2) ? (t2 ? Object.keys : nn)(n2).forEach(function(e) {
642
+ t2 && "symbol" == typeof e || r2(e, n2[e], n2);
643
+ }) : n2.forEach(function(t3, e) {
644
+ return r2(e, t3, n2);
645
+ });
646
+ }
647
+ function o(n2) {
648
+ var r2 = n2[Q];
649
+ return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v(n2) ? 3 : 0;
650
+ }
651
+ function u(n2, r2) {
652
+ return 2 === o(n2) ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2);
653
+ }
654
+ function a(n2, r2) {
655
+ return 2 === o(n2) ? n2.get(r2) : n2[r2];
656
+ }
657
+ function f(n2, r2, t2) {
658
+ var e = o(n2);
659
+ 2 === e ? n2.set(r2, t2) : 3 === e ? (n2.delete(r2), n2.add(t2)) : n2[r2] = t2;
660
+ }
661
+ function c(n2, r2) {
662
+ return n2 === r2 ? 0 !== n2 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2;
663
+ }
664
+ function s(n2) {
665
+ return X && n2 instanceof Map;
666
+ }
667
+ function v(n2) {
668
+ return q && n2 instanceof Set;
669
+ }
670
+ function p(n2) {
671
+ return n2.o || n2.t;
672
+ }
673
+ function l(n2) {
674
+ if (Array.isArray(n2))
675
+ return Array.prototype.slice.call(n2);
676
+ var r2 = rn(n2);
677
+ delete r2[Q];
678
+ for (var t2 = nn(r2), e = 0; e < t2.length; e++) {
679
+ var i2 = t2[e], o2 = r2[i2];
680
+ false === o2.writable && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] });
681
+ }
682
+ return Object.create(Object.getPrototypeOf(n2), r2);
683
+ }
684
+ function d(n2, e) {
685
+ return void 0 === e && (e = false), y(n2) || r(n2) || !t(n2) ? n2 : (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h), Object.freeze(n2), e && i(n2, function(n3, r2) {
686
+ return d(r2, true);
687
+ }, true), n2);
688
+ }
689
+ function h() {
690
+ n(2);
691
+ }
692
+ function y(n2) {
693
+ return null == n2 || "object" != typeof n2 || Object.isFrozen(n2);
694
+ }
695
+ function b(r2) {
696
+ var t2 = tn[r2];
697
+ return t2 || n(18, r2), t2;
698
+ }
699
+ function _() {
700
+ return "production" === process.env.NODE_ENV || U || n(0), U;
701
+ }
702
+ function j(n2, r2) {
703
+ r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2);
704
+ }
705
+ function O(n2) {
706
+ g(n2), n2.p.forEach(S), n2.p = null;
707
+ }
708
+ function g(n2) {
709
+ n2 === U && (U = n2.l);
710
+ }
711
+ function w(n2) {
712
+ return U = { p: [], l: U, h: n2, m: true, _: 0 };
713
+ }
714
+ function S(n2) {
715
+ var r2 = n2[Q];
716
+ 0 === r2.i || 1 === r2.i ? r2.j() : r2.O = true;
717
+ }
718
+ function P(r2, e) {
719
+ e._ = e.p.length;
720
+ var i2 = e.p[0], o2 = void 0 !== r2 && r2 !== i2;
721
+ return e.h.g || b("ES5").S(e, r2, o2), o2 ? (i2[Q].P && (O(e), n(4)), t(r2) && (r2 = M(e, r2), e.l || x(e, r2)), e.u && b("Patches").M(i2[Q].t, r2, e.u, e.s)) : r2 = M(e, i2, []), O(e), e.u && e.v(e.u, e.s), r2 !== H ? r2 : void 0;
722
+ }
723
+ function M(n2, r2, t2) {
724
+ if (y(r2))
725
+ return r2;
726
+ var e = r2[Q];
727
+ if (!e)
728
+ return i(r2, function(i2, o3) {
729
+ return A(n2, e, r2, i2, o3, t2);
730
+ }, true), r2;
731
+ if (e.A !== n2)
732
+ return r2;
733
+ if (!e.P)
734
+ return x(n2, e.t, true), e.t;
735
+ if (!e.I) {
736
+ e.I = true, e.A._--;
737
+ var o2 = 4 === e.i || 5 === e.i ? e.o = l(e.k) : e.o;
738
+ i(3 === e.i ? new Set(o2) : o2, function(r3, i2) {
739
+ return A(n2, e, o2, r3, i2, t2);
740
+ }), x(n2, o2, false), t2 && n2.u && b("Patches").R(e, t2, n2.u, n2.s);
741
+ }
742
+ return e.o;
743
+ }
744
+ function A(e, i2, o2, a2, c2, s2) {
745
+ if ("production" !== process.env.NODE_ENV && c2 === o2 && n(5), r(c2)) {
746
+ var v2 = M(e, c2, s2 && i2 && 3 !== i2.i && !u(i2.D, a2) ? s2.concat(a2) : void 0);
747
+ if (f(o2, a2, v2), !r(v2))
748
+ return;
749
+ e.m = false;
750
+ }
751
+ if (t(c2) && !y(c2)) {
752
+ if (!e.h.F && e._ < 1)
753
+ return;
754
+ M(e, c2), i2 && i2.A.l || x(e, c2);
755
+ }
756
+ }
757
+ function x(n2, r2, t2) {
758
+ void 0 === t2 && (t2 = false), n2.h.F && n2.m && d(r2, t2);
759
+ }
760
+ function z(n2, r2) {
761
+ var t2 = n2[Q];
762
+ return (t2 ? p(t2) : n2)[r2];
763
+ }
764
+ function I(n2, r2) {
765
+ if (r2 in n2)
766
+ for (var t2 = Object.getPrototypeOf(n2); t2; ) {
767
+ var e = Object.getOwnPropertyDescriptor(t2, r2);
768
+ if (e)
769
+ return e;
770
+ t2 = Object.getPrototypeOf(t2);
771
+ }
772
+ }
773
+ function k(n2) {
774
+ n2.P || (n2.P = true, n2.l && k(n2.l));
775
+ }
776
+ function E(n2) {
777
+ n2.o || (n2.o = l(n2.t));
778
+ }
779
+ function R2(n2, r2, t2) {
780
+ var e = s(r2) ? b("MapSet").N(r2, t2) : v(r2) ? b("MapSet").T(r2, t2) : n2.g ? function(n3, r3) {
781
+ var t3 = Array.isArray(n3), e2 = { 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 = e2, o2 = en;
782
+ t3 && (i2 = [e2], o2 = on);
783
+ var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy;
784
+ return e2.k = f2, e2.j = a2, f2;
785
+ }(r2, t2) : b("ES5").J(r2, t2);
786
+ return (t2 ? t2.A : _()).p.push(e), e;
787
+ }
788
+ function D(e) {
789
+ return r(e) || n(22, e), function n2(r2) {
790
+ if (!t(r2))
791
+ return r2;
792
+ var e2, u2 = r2[Q], c2 = o(r2);
793
+ if (u2) {
794
+ if (!u2.P && (u2.i < 4 || !b("ES5").K(u2)))
795
+ return u2.t;
796
+ u2.I = true, e2 = F(r2, c2), u2.I = false;
797
+ } else
798
+ e2 = F(r2, c2);
799
+ return i(e2, function(r3, t2) {
800
+ u2 && a(u2.t, r3) === t2 || f(e2, r3, n2(t2));
801
+ }), 3 === c2 ? new Set(e2) : e2;
802
+ }(e);
803
+ }
804
+ function F(n2, r2) {
805
+ switch (r2) {
806
+ case 2:
807
+ return new Map(n2);
808
+ case 3:
809
+ return Array.from(n2);
810
+ }
811
+ return l(n2);
812
+ }
813
+ var G;
814
+ var U;
815
+ var W = "undefined" != typeof Symbol && "symbol" == typeof Symbol("x");
816
+ var X = "undefined" != typeof Map;
817
+ var q = "undefined" != typeof Set;
818
+ var B = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect;
819
+ var H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G);
820
+ var L = W ? Symbol.for("immer-draftable") : "__$immer_draftable";
821
+ var Q = W ? Symbol.for("immer-state") : "__$immer_state";
822
+ var Y = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(n2) {
823
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n2;
824
+ }, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(n2) {
825
+ return "Cannot apply patch, path doesn't resolve: " + n2;
826
+ }, 16: 'Sets cannot have "replace" patches.', 17: function(n2) {
827
+ return "Unsupported patch operation: " + n2;
828
+ }, 18: function(n2) {
829
+ return "The plugin for '" + n2 + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n2 + "()` when initializing your application.";
830
+ }, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(n2) {
831
+ return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + n2 + "'";
832
+ }, 22: function(n2) {
833
+ return "'current' expects a draft, got: " + n2;
834
+ }, 23: function(n2) {
835
+ return "'original' expects a draft, got: " + n2;
836
+ }, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" };
837
+ var Z = "" + Object.prototype.constructor;
838
+ var nn = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function(n2) {
839
+ return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2));
840
+ } : Object.getOwnPropertyNames;
841
+ var rn = Object.getOwnPropertyDescriptors || function(n2) {
842
+ var r2 = {};
843
+ return nn(n2).forEach(function(t2) {
844
+ r2[t2] = Object.getOwnPropertyDescriptor(n2, t2);
845
+ }), r2;
846
+ };
847
+ var tn = {};
848
+ var en = { get: function(n2, r2) {
849
+ if (r2 === Q)
850
+ return n2;
851
+ var e = p(n2);
852
+ if (!u(e, r2))
853
+ return function(n3, r3, t2) {
854
+ var e2, i3 = I(r3, t2);
855
+ return i3 ? "value" in i3 ? i3.value : null === (e2 = i3.get) || void 0 === e2 ? void 0 : e2.call(n3.k) : void 0;
856
+ }(n2, e, r2);
857
+ var i2 = e[r2];
858
+ return n2.I || !t(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = R2(n2.A.h, i2, n2)) : i2;
859
+ }, has: function(n2, r2) {
860
+ return r2 in p(n2);
861
+ }, ownKeys: function(n2) {
862
+ return Reflect.ownKeys(p(n2));
863
+ }, set: function(n2, r2, t2) {
864
+ var e = I(p(n2), r2);
865
+ if (null == e ? void 0 : e.set)
866
+ return e.set.call(n2.k, t2), true;
867
+ if (!n2.P) {
868
+ var i2 = z(p(n2), r2), o2 = null == i2 ? void 0 : i2[Q];
869
+ if (o2 && o2.t === t2)
870
+ return n2.o[r2] = t2, n2.D[r2] = false, true;
871
+ if (c(t2, i2) && (void 0 !== t2 || u(n2.t, r2)))
872
+ return true;
873
+ E(n2), k(n2);
874
+ }
875
+ return n2.o[r2] === t2 && "number" != typeof t2 && (void 0 !== t2 || r2 in n2.o) || (n2.o[r2] = t2, n2.D[r2] = true, true);
876
+ }, deleteProperty: function(n2, r2) {
877
+ return void 0 !== z(n2.t, r2) || r2 in n2.t ? (n2.D[r2] = false, E(n2), k(n2)) : delete n2.D[r2], n2.o && delete n2.o[r2], true;
878
+ }, getOwnPropertyDescriptor: function(n2, r2) {
879
+ var t2 = p(n2), e = Reflect.getOwnPropertyDescriptor(t2, r2);
880
+ return e ? { writable: true, configurable: 1 !== n2.i || "length" !== r2, enumerable: e.enumerable, value: t2[r2] } : e;
881
+ }, defineProperty: function() {
882
+ n(11);
883
+ }, getPrototypeOf: function(n2) {
884
+ return Object.getPrototypeOf(n2.t);
885
+ }, setPrototypeOf: function() {
886
+ n(12);
887
+ } };
888
+ var on = {};
889
+ i(en, function(n2, r2) {
890
+ on[n2] = function() {
891
+ return arguments[0] = arguments[0][0], r2.apply(this, arguments);
892
+ };
893
+ }), on.deleteProperty = function(r2, t2) {
894
+ return "production" !== process.env.NODE_ENV && isNaN(parseInt(t2)) && n(13), on.set.call(this, r2, t2, void 0);
895
+ }, on.set = function(r2, t2, e) {
896
+ return "production" !== process.env.NODE_ENV && "length" !== t2 && isNaN(parseInt(t2)) && n(14), en.set.call(this, r2[0], t2, e, r2[0]);
897
+ };
898
+ var un = function() {
899
+ function e(r2) {
900
+ var e2 = this;
901
+ this.g = B, this.F = true, this.produce = function(r3, i3, o2) {
902
+ if ("function" == typeof r3 && "function" != typeof i3) {
903
+ var u2 = i3;
904
+ i3 = r3;
905
+ var a2 = e2;
906
+ return function(n2) {
907
+ var r4 = this;
908
+ void 0 === n2 && (n2 = u2);
909
+ for (var t2 = arguments.length, e3 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++)
910
+ e3[o3 - 1] = arguments[o3];
911
+ return a2.produce(n2, function(n3) {
912
+ var t3;
913
+ return (t3 = i3).call.apply(t3, [r4, n3].concat(e3));
914
+ });
915
+ };
916
+ }
917
+ var f2;
918
+ if ("function" != typeof i3 && n(6), void 0 !== o2 && "function" != typeof o2 && n(7), t(r3)) {
919
+ var c2 = w(e2), s2 = R2(e2, r3, void 0), v2 = true;
920
+ try {
921
+ f2 = i3(s2), v2 = false;
922
+ } finally {
923
+ v2 ? O(c2) : g(c2);
924
+ }
925
+ return "undefined" != typeof Promise && f2 instanceof Promise ? f2.then(function(n2) {
926
+ return j(c2, o2), P(n2, c2);
927
+ }, function(n2) {
928
+ throw O(c2), n2;
929
+ }) : (j(c2, o2), P(f2, c2));
930
+ }
931
+ if (!r3 || "object" != typeof r3) {
932
+ if (void 0 === (f2 = i3(r3)) && (f2 = r3), f2 === H && (f2 = void 0), e2.F && d(f2, true), o2) {
933
+ var p2 = [], l2 = [];
934
+ b("Patches").M(r3, f2, p2, l2), o2(p2, l2);
935
+ }
936
+ return f2;
937
+ }
938
+ n(21, r3);
939
+ }, this.produceWithPatches = function(n2, r3) {
940
+ if ("function" == typeof n2)
941
+ return function(r4) {
942
+ for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++)
943
+ i4[o3 - 1] = arguments[o3];
944
+ return e2.produceWithPatches(r4, function(r5) {
945
+ return n2.apply(void 0, [r5].concat(i4));
946
+ });
947
+ };
948
+ var t2, i3, o2 = e2.produce(n2, r3, function(n3, r4) {
949
+ t2 = n3, i3 = r4;
950
+ });
951
+ return "undefined" != typeof Promise && o2 instanceof Promise ? o2.then(function(n3) {
952
+ return [n3, t2, i3];
953
+ }) : [o2, t2, i3];
954
+ }, "boolean" == typeof (null == r2 ? void 0 : r2.useProxies) && this.setUseProxies(r2.useProxies), "boolean" == typeof (null == r2 ? void 0 : r2.autoFreeze) && this.setAutoFreeze(r2.autoFreeze);
955
+ }
956
+ var i2 = e.prototype;
957
+ return i2.createDraft = function(e2) {
958
+ t(e2) || n(8), r(e2) && (e2 = D(e2));
959
+ var i3 = w(this), o2 = R2(this, e2, void 0);
960
+ return o2[Q].C = true, g(i3), o2;
961
+ }, i2.finishDraft = function(r2, t2) {
962
+ var e2 = r2 && r2[Q];
963
+ "production" !== process.env.NODE_ENV && (e2 && e2.C || n(9), e2.I && n(10));
964
+ var i3 = e2.A;
965
+ return j(i3, t2), P(void 0, i3);
966
+ }, i2.setAutoFreeze = function(n2) {
967
+ this.F = n2;
968
+ }, i2.setUseProxies = function(r2) {
969
+ r2 && !B && n(20), this.g = r2;
970
+ }, i2.applyPatches = function(n2, t2) {
971
+ var e2;
972
+ for (e2 = t2.length - 1; e2 >= 0; e2--) {
973
+ var i3 = t2[e2];
974
+ if (0 === i3.path.length && "replace" === i3.op) {
975
+ n2 = i3.value;
976
+ break;
977
+ }
978
+ }
979
+ e2 > -1 && (t2 = t2.slice(e2 + 1));
980
+ var o2 = b("Patches").$;
981
+ return r(n2) ? o2(n2, t2) : this.produce(n2, function(n3) {
982
+ return o2(n3, t2);
983
+ });
984
+ }, e;
985
+ }();
986
+ var an = new un();
987
+ var fn = an.produce;
988
+ var cn = an.produceWithPatches.bind(an);
989
+ var sn = an.setAutoFreeze.bind(an);
990
+ var vn = an.setUseProxies.bind(an);
991
+ var pn = an.applyPatches.bind(an);
992
+ var ln = an.createDraft.bind(an);
993
+ var dn = an.finishDraft.bind(an);
994
+
995
+ // ../../node_modules/zustand/esm/middleware/immer.mjs
996
+ var immerImpl = (initializer) => (set, get2, store) => {
997
+ store.setState = (updater, replace2, ...a2) => {
998
+ const nextState = typeof updater === "function" ? fn(updater) : updater;
999
+ return set(nextState, replace2, ...a2);
1000
+ };
1001
+ return initializer(store.setState, get2, store);
1002
+ };
1003
+ var immer = immerImpl;
205
1004
 
206
1005
  // src/internal/logic/requestSubmit.ts
207
1006
  var requestSubmit = (element, submitter) => {
@@ -322,8 +1121,8 @@ var insert = (array, index, value) => {
322
1121
  };
323
1122
  var insertEmpty = (array, index) => {
324
1123
  const tail = sparseSplice(array, index);
325
- tail.forEach((item, i) => {
326
- sparseSplice(array, index + i + 1, 0, item);
1124
+ tail.forEach((item, i2) => {
1125
+ sparseSplice(array, index + i2 + 1, 0, item);
327
1126
  });
328
1127
  };
329
1128
  var remove = (array, index) => {
@@ -1089,8 +1888,8 @@ var createFormState = (set, get2) => ({
1089
1888
  }
1090
1889
  }
1091
1890
  });
1092
- var useRootFormStore = (0, import_zustand.create)()(
1093
- (0, import_immer.immer)((set, get2) => ({
1891
+ var useRootFormStore = create()(
1892
+ immer((set, get2) => ({
1094
1893
  forms: {},
1095
1894
  form: (formId) => {
1096
1895
  var _a;
@@ -1121,7 +1920,7 @@ var useFormStore = (formId, selector) => {
1121
1920
 
1122
1921
  // src/internal/hooks.ts
1123
1922
  var useInternalFormContext = (formId, hookName) => {
1124
- const formContext = (0, import_react3.useContext)(InternalFormContext);
1923
+ const formContext = (0, import_react4.useContext)(InternalFormContext);
1125
1924
  if (formId)
1126
1925
  return { formId };
1127
1926
  if (formContext)
@@ -1136,7 +1935,7 @@ function useErrorResponseForForm({
1136
1935
  formId
1137
1936
  }) {
1138
1937
  var _a;
1139
- const actionData = (0, import_react2.useActionData)();
1938
+ const actionData = (0, import_react3.useActionData)();
1140
1939
  if (fetcher) {
1141
1940
  if ((_a = fetcher.data) == null ? void 0 : _a.fieldErrors)
1142
1941
  return fetcher.data;
@@ -1158,7 +1957,7 @@ var useFieldErrorsForForm = (context) => {
1158
1957
  var useDefaultValuesFromLoader = ({
1159
1958
  formId
1160
1959
  }) => {
1161
- const matches = (0, import_react2.useMatches)();
1960
+ const matches = (0, import_react3.useMatches)();
1162
1961
  if (typeof formId === "string") {
1163
1962
  const dataKey = formDefaultValuesKey(formId);
1164
1963
  const match = matches.reverse().find(
@@ -1189,14 +1988,14 @@ var useDefaultValuesForForm = (context) => {
1189
1988
  var useHasActiveFormSubmit = ({
1190
1989
  fetcher
1191
1990
  }) => {
1192
- let navigation = (0, import_react2.useNavigation)();
1991
+ let navigation = (0, import_react3.useNavigation)();
1193
1992
  const hasActiveSubmission = fetcher ? fetcher.state === "submitting" : navigation.state === "submitting" || navigation.state === "loading";
1194
1993
  return hasActiveSubmission;
1195
1994
  };
1196
1995
  var useFieldTouched = (field, { formId }) => {
1197
1996
  const touched = useFormStore(formId, (state) => state.touchedFields[field]);
1198
1997
  const setFieldTouched = useFormStore(formId, (state) => state.setTouched);
1199
- const setTouched = (0, import_react3.useCallback)(
1998
+ const setTouched = (0, import_react4.useCallback)(
1200
1999
  (touched2) => setFieldTouched(field, touched2),
1201
2000
  [field, setFieldTouched]
1202
2001
  );
@@ -1259,7 +2058,7 @@ var useFormSubactionProp = (formId) => useFormStore(formId, (state) => {
1259
2058
  var useFormValues = (formId) => useFormStore(formId, (state) => state.getValues);
1260
2059
 
1261
2060
  // src/internal/state/controlledFields.ts
1262
- var import_react4 = require("react");
2061
+ var import_react5 = require("react");
1263
2062
  var useControlledFieldValue = (context, field) => {
1264
2063
  const value = useFormStore(
1265
2064
  context.formId,
@@ -1277,7 +2076,7 @@ var useRegisterControlledField = (context, field) => {
1277
2076
  context.formId,
1278
2077
  (state) => state.controlledFields.valueUpdateResolvers[field]
1279
2078
  );
1280
- (0, import_react4.useEffect)(() => {
2079
+ (0, import_react5.useEffect)(() => {
1281
2080
  resolveUpdate == null ? void 0 : resolveUpdate();
1282
2081
  }, [resolveUpdate]);
1283
2082
  const register = useFormStore(
@@ -1288,7 +2087,7 @@ var useRegisterControlledField = (context, field) => {
1288
2087
  context.formId,
1289
2088
  (state) => state.controlledFields.unregister
1290
2089
  );
1291
- (0, import_react4.useEffect)(() => {
2090
+ (0, import_react5.useEffect)(() => {
1292
2091
  register(field);
1293
2092
  return () => unregister(field);
1294
2093
  }, [context.formId, field, register, unregister]);
@@ -1299,7 +2098,7 @@ var useControllableValue = (context, field) => {
1299
2098
  context.formId,
1300
2099
  (state) => state.controlledFields.setValue
1301
2100
  );
1302
- const setValue = (0, import_react4.useCallback)(
2101
+ const setValue = (0, import_react5.useCallback)(
1303
2102
  (value2) => setControlledFieldValue(field, value2),
1304
2103
  [field, setControlledFieldValue]
1305
2104
  );
@@ -1311,7 +2110,7 @@ var useUpdateControllableValue = (formId) => {
1311
2110
  formId,
1312
2111
  (state) => state.controlledFields.setValue
1313
2112
  );
1314
- return (0, import_react4.useCallback)(
2113
+ return (0, import_react5.useCallback)(
1315
2114
  (field, value) => setValue(field, value),
1316
2115
  [setValue]
1317
2116
  );
@@ -1336,11 +2135,11 @@ var useField = (name, options) => {
1336
2135
  const hasBeenSubmitted = useInternalHasBeenSubmitted(formContext.formId);
1337
2136
  const smartValidate = useSmartValidate(formContext.formId);
1338
2137
  const registerReceiveFocus = useRegisterReceiveFocus(formContext.formId);
1339
- (0, import_react5.useEffect)(() => {
2138
+ (0, import_react6.useEffect)(() => {
1340
2139
  if (handleReceiveFocus)
1341
2140
  return registerReceiveFocus(name, handleReceiveFocus);
1342
2141
  }, [handleReceiveFocus, name, registerReceiveFocus]);
1343
- const field = (0, import_react5.useMemo)(() => {
2142
+ const field = (0, import_react6.useMemo)(() => {
1344
2143
  const helpers = {
1345
2144
  error,
1346
2145
  clearError: () => clearError(name),
@@ -1400,12 +2199,12 @@ var setFormDefaults = (formId, defaultValues) => ({
1400
2199
  });
1401
2200
 
1402
2201
  // src/ValidatedForm.tsx
1403
- var import_react9 = require("@remix-run/react");
1404
- var import_react10 = require("react");
1405
- var R3 = __toESM(require("remeda"));
2202
+ var import_react10 = require("@remix-run/react");
2203
+ var import_react11 = require("react");
2204
+ var R4 = __toESM(require("remeda"));
1406
2205
 
1407
2206
  // src/internal/MultiValueMap.ts
1408
- var import_react6 = require("react");
2207
+ var import_react7 = require("react");
1409
2208
  var MultiValueMap = class {
1410
2209
  constructor() {
1411
2210
  this.dict = /* @__PURE__ */ new Map();
@@ -1439,8 +2238,8 @@ var MultiValueMap = class {
1439
2238
  }
1440
2239
  };
1441
2240
  var useMultiValueMap = () => {
1442
- const ref = (0, import_react6.useRef)(null);
1443
- return (0, import_react6.useCallback)(() => {
2241
+ const ref = (0, import_react7.useRef)(null);
2242
+ return (0, import_react7.useCallback)(() => {
1444
2243
  if (ref.current)
1445
2244
  return ref.current;
1446
2245
  ref.current = new MultiValueMap();
@@ -1449,10 +2248,10 @@ var useMultiValueMap = () => {
1449
2248
  };
1450
2249
 
1451
2250
  // src/internal/submissionCallbacks.ts
1452
- var import_react7 = require("react");
2251
+ var import_react8 = require("react");
1453
2252
  function useSubmitComplete(isSubmitting, callback) {
1454
- const isPending = (0, import_react7.useRef)(false);
1455
- (0, import_react7.useEffect)(() => {
2253
+ const isPending = (0, import_react8.useRef)(false);
2254
+ (0, import_react8.useEffect)(() => {
1456
2255
  if (isSubmitting) {
1457
2256
  isPending.current = true;
1458
2257
  }
@@ -1464,8 +2263,8 @@ function useSubmitComplete(isSubmitting, callback) {
1464
2263
  }
1465
2264
 
1466
2265
  // src/internal/util.ts
1467
- var import_react8 = require("react");
1468
- var R2 = __toESM(require("remeda"));
2266
+ var import_react9 = require("react");
2267
+ var R3 = __toESM(require("remeda"));
1469
2268
  var mergeRefs = (refs) => {
1470
2269
  return (value) => {
1471
2270
  refs.filter(Boolean).forEach((ref) => {
@@ -1477,11 +2276,11 @@ var mergeRefs = (refs) => {
1477
2276
  });
1478
2277
  };
1479
2278
  };
1480
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react8.useLayoutEffect : import_react8.useEffect;
2279
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react9.useLayoutEffect : import_react9.useEffect;
1481
2280
  var useDeepEqualsMemo = (item) => {
1482
- const ref = (0, import_react8.useRef)(item);
1483
- const areEqual = ref.current === item || R2.equals(ref.current, item);
1484
- (0, import_react8.useEffect)(() => {
2281
+ const ref = (0, import_react9.useRef)(item);
2282
+ const areEqual = ref.current === item || R3.equals(ref.current, item);
2283
+ (0, import_react9.useEffect)(() => {
1485
2284
  if (!areEqual) {
1486
2285
  ref.current = item;
1487
2286
  }
@@ -1503,7 +2302,7 @@ var focusFirstInvalidInput = (fieldErrors, customFocusHandlers, formElement) =>
1503
2302
  return input.name;
1504
2303
  return null;
1505
2304
  }).filter(nonNull).filter((name) => name in fieldErrors);
1506
- const uniqueNamesInOrder = R3.uniq(namesInOrder);
2305
+ const uniqueNamesInOrder = R4.uniq(namesInOrder);
1507
2306
  for (const fieldName of uniqueNamesInOrder) {
1508
2307
  if (customFocusHandlers.has(fieldName)) {
1509
2308
  customFocusHandlers.getAll(fieldName).forEach((handler) => {
@@ -1533,7 +2332,7 @@ var focusFirstInvalidInput = (fieldErrors, customFocusHandlers, formElement) =>
1533
2332
  }
1534
2333
  };
1535
2334
  var useFormId = (providedId) => {
1536
- const [symbolId] = (0, import_react10.useState)(() => Symbol("remix-validated-form-id"));
2335
+ const [symbolId] = (0, import_react11.useState)(() => Symbol("remix-validated-form-id"));
1537
2336
  return providedId != null ? providedId : symbolId;
1538
2337
  };
1539
2338
  var FormResetter = ({
@@ -1589,7 +2388,7 @@ function ValidatedForm({
1589
2388
  var _a;
1590
2389
  const formId = useFormId(id);
1591
2390
  const providedDefaultValues = useDeepEqualsMemo(unMemoizedDefaults);
1592
- const contextValue = (0, import_react10.useMemo)(
2391
+ const contextValue = (0, import_react11.useMemo)(
1593
2392
  () => ({
1594
2393
  formId,
1595
2394
  action,
@@ -1602,9 +2401,9 @@ function ValidatedForm({
1602
2401
  const backendError = useErrorResponseForForm(contextValue);
1603
2402
  const backendDefaultValues = useDefaultValuesFromLoader(contextValue);
1604
2403
  const hasActiveSubmission = useHasActiveFormSubmit(contextValue);
1605
- const formRef = (0, import_react10.useRef)(null);
1606
- const Form = (_a = fetcher == null ? void 0 : fetcher.Form) != null ? _a : import_react9.Form;
1607
- const submit = (0, import_react9.useSubmit)();
2404
+ const formRef = (0, import_react11.useRef)(null);
2405
+ const Form = (_a = fetcher == null ? void 0 : fetcher.Form) != null ? _a : import_react10.Form;
2406
+ const submit = (0, import_react10.useSubmit)();
1608
2407
  const setFieldErrors = useSetFieldErrors(formId);
1609
2408
  const setFieldError = useFormStore(formId, (state) => state.setFieldError);
1610
2409
  const reset = useFormStore(formId, (state) => state.reset);
@@ -1618,7 +2417,7 @@ function ValidatedForm({
1618
2417
  const cleanupForm = useRootFormStore((state) => state.cleanupForm);
1619
2418
  const registerForm = useRootFormStore((state) => state.registerForm);
1620
2419
  const customFocusHandlers = useMultiValueMap();
1621
- const registerReceiveFocus = (0, import_react10.useCallback)(
2420
+ const registerReceiveFocus = (0, import_react11.useCallback)(
1622
2421
  (fieldName, handler) => {
1623
2422
  customFocusHandlers().add(fieldName, handler);
1624
2423
  return () => {
@@ -1652,7 +2451,7 @@ function ValidatedForm({
1652
2451
  useIsomorphicLayoutEffect(() => {
1653
2452
  setFormElementInState(formRef.current);
1654
2453
  }, [setFormElementInState]);
1655
- (0, import_react10.useEffect)(() => {
2454
+ (0, import_react11.useEffect)(() => {
1656
2455
  var _a2;
1657
2456
  setFieldErrors((_a2 = backendError == null ? void 0 : backendError.fieldErrors) != null ? _a2 : {});
1658
2457
  if (!disableFocusOnError && (backendError == null ? void 0 : backendError.fieldErrors)) {
@@ -1750,7 +2549,7 @@ function ValidatedForm({
1750
2549
  }
1751
2550
 
1752
2551
  // src/validation/createValidator.ts
1753
- var R4 = __toESM(require("remeda"));
2552
+ var R5 = __toESM(require("remeda"));
1754
2553
 
1755
2554
  // src/internal/flatten.ts
1756
2555
  var objectFromPathEntries = (entries) => {
@@ -1768,7 +2567,7 @@ var preprocessFormData = (data) => {
1768
2567
  return objectFromPathEntries([...data.entries()]);
1769
2568
  return objectFromPathEntries(Object.entries(data));
1770
2569
  };
1771
- var omitInternalFields = (data) => R4.omit(data, [FORM_ID_FIELD]);
2570
+ var omitInternalFields = (data) => R5.omit(data, [FORM_ID_FIELD]);
1772
2571
  function createValidator(validator) {
1773
2572
  return {
1774
2573
  validate: async (value) => {
@@ -1798,10 +2597,10 @@ function createValidator(validator) {
1798
2597
  }
1799
2598
 
1800
2599
  // src/userFacingFormContext.ts
1801
- var import_react12 = require("react");
2600
+ var import_react13 = require("react");
1802
2601
 
1803
2602
  // src/unreleased/formStateHooks.ts
1804
- var import_react11 = require("react");
2603
+ var import_react12 = require("react");
1805
2604
  var useFormState = (formId) => {
1806
2605
  const formContext = useInternalFormContext(formId, "useFormState");
1807
2606
  const isSubmitting = useInternalIsSubmitting(formContext.formId);
@@ -1816,7 +2615,7 @@ var useFormState = (formId) => {
1816
2615
  const fieldErrorsFromState = useFieldErrors(formContext.formId);
1817
2616
  const fieldErrorsToUse = useFieldErrorsForForm(formContext);
1818
2617
  const hydratedFieldErrors = fieldErrorsToUse.hydrateTo(fieldErrorsFromState);
1819
- return (0, import_react11.useMemo)(
2618
+ return (0, import_react12.useMemo)(
1820
2619
  () => ({
1821
2620
  action,
1822
2621
  subaction,
@@ -1849,7 +2648,7 @@ var useFormHelpers = (formId) => {
1849
2648
  const reset = useResetFormElement(formContext.formId);
1850
2649
  const submit = useSubmitForm(formContext.formId);
1851
2650
  const getValues = useFormValues(formContext.formId);
1852
- return (0, import_react11.useMemo)(
2651
+ return (0, import_react12.useMemo)(
1853
2652
  () => ({
1854
2653
  setTouched,
1855
2654
  validateField: async (fieldName) => {
@@ -1894,7 +2693,7 @@ var useFormContext = (formId) => {
1894
2693
  getValues
1895
2694
  } = useFormHelpers(formId);
1896
2695
  const registerReceiveFocus = useRegisterReceiveFocus(context.formId);
1897
- const clearError = (0, import_react12.useCallback)(
2696
+ const clearError = (0, import_react13.useCallback)(
1898
2697
  (...names) => {
1899
2698
  names.forEach((name) => {
1900
2699
  internalClearError(name);
@@ -1902,7 +2701,7 @@ var useFormContext = (formId) => {
1902
2701
  },
1903
2702
  [internalClearError]
1904
2703
  );
1905
- return (0, import_react12.useMemo)(
2704
+ return (0, import_react13.useMemo)(
1906
2705
  () => ({
1907
2706
  ...state,
1908
2707
  setFieldTouched: setTouched,
@@ -1932,8 +2731,8 @@ var useFormContext = (formId) => {
1932
2731
 
1933
2732
  // src/internal/state/fieldArray.tsx
1934
2733
  var import_nanoid = require("nanoid");
1935
- var import_react13 = require("react");
1936
2734
  var import_react14 = require("react");
2735
+ var import_react15 = require("react");
1937
2736
  var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
1938
2737
  var import_jsx_runtime2 = require("react/jsx-runtime");
1939
2738
  var useInternalFieldArray = (context, field, validationBehavior) => {
@@ -1948,7 +2747,7 @@ var useInternalFieldArray = (context, field, validationBehavior) => {
1948
2747
  ...validationBehavior
1949
2748
  };
1950
2749
  const behavior = hasBeenSubmitted ? resolvedValidationBehavior.whenSubmitted : resolvedValidationBehavior.initial;
1951
- const maybeValidate = (0, import_react14.useCallback)(() => {
2750
+ const maybeValidate = (0, import_react15.useCallback)(() => {
1952
2751
  if (behavior === "onChange") {
1953
2752
  validateField({ alwaysIncludeErrorsFromFields: [field] });
1954
2753
  }
@@ -1961,12 +2760,12 @@ var useInternalFieldArray = (context, field, validationBehavior) => {
1961
2760
  context.formId,
1962
2761
  (state) => state.controlledFields.array
1963
2762
  );
1964
- const arrayValue = (0, import_react13.useMemo)(() => value != null ? value : [], [value]);
1965
- const keyRef = (0, import_react13.useRef)([]);
2763
+ const arrayValue = (0, import_react14.useMemo)(() => value != null ? value : [], [value]);
2764
+ const keyRef = (0, import_react14.useRef)([]);
1966
2765
  if (keyRef.current.length !== arrayValue.length) {
1967
2766
  keyRef.current = arrayValue.map(() => (0, import_nanoid.nanoid)());
1968
2767
  }
1969
- const helpers = (0, import_react13.useMemo)(
2768
+ const helpers = (0, import_react14.useMemo)(
1970
2769
  () => ({
1971
2770
  push: (item) => {
1972
2771
  arr.push(field, item);
@@ -2011,7 +2810,7 @@ var useInternalFieldArray = (context, field, validationBehavior) => {
2011
2810
  }),
2012
2811
  [arr, field, maybeValidate]
2013
2812
  );
2014
- const valueWithKeys = (0, import_react13.useMemo)(() => {
2813
+ const valueWithKeys = (0, import_react14.useMemo)(() => {
2015
2814
  const result = [];
2016
2815
  arrayValue.forEach((item, index) => {
2017
2816
  result[index] = {
@@ -2056,4 +2855,40 @@ function FieldArray({
2056
2855
  useUpdateControlledField,
2057
2856
  validationError
2058
2857
  });
2858
+ /**
2859
+ * @license React
2860
+ * use-sync-external-store-shim.development.js
2861
+ *
2862
+ * Copyright (c) Facebook, Inc. and its affiliates.
2863
+ *
2864
+ * This source code is licensed under the MIT license found in the
2865
+ * LICENSE file in the root directory of this source tree.
2866
+ */
2867
+ /**
2868
+ * @license React
2869
+ * use-sync-external-store-shim.production.min.js
2870
+ *
2871
+ * Copyright (c) Facebook, Inc. and its affiliates.
2872
+ *
2873
+ * This source code is licensed under the MIT license found in the
2874
+ * LICENSE file in the root directory of this source tree.
2875
+ */
2876
+ /**
2877
+ * @license React
2878
+ * use-sync-external-store-shim/with-selector.development.js
2879
+ *
2880
+ * Copyright (c) Facebook, Inc. and its affiliates.
2881
+ *
2882
+ * This source code is licensed under the MIT license found in the
2883
+ * LICENSE file in the root directory of this source tree.
2884
+ */
2885
+ /**
2886
+ * @license React
2887
+ * use-sync-external-store-shim/with-selector.production.min.js
2888
+ *
2889
+ * Copyright (c) Facebook, Inc. and its affiliates.
2890
+ *
2891
+ * This source code is licensed under the MIT license found in the
2892
+ * LICENSE file in the root directory of this source tree.
2893
+ */
2059
2894
  //# sourceMappingURL=index.cjs.js.map