@goodie-forms/core 1.0.0-alpha → 1.1.0-alpha

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 (52) hide show
  1. package/dist/index.js +757 -646
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/form/CustomValidation.d.ts +10 -0
  4. package/dist/src/form/CustomValidation.d.ts.map +1 -0
  5. package/dist/src/form/Field.d.ts +31 -0
  6. package/dist/src/form/Field.d.ts.map +1 -0
  7. package/dist/src/form/FormController.d.ts +68 -0
  8. package/dist/src/form/FormController.d.ts.map +1 -0
  9. package/dist/{form → src/form}/FormField.d.ts +6 -3
  10. package/dist/src/form/FormField.d.ts.map +1 -0
  11. package/dist/src/form/NonullFormField.d.ts +10 -0
  12. package/dist/src/form/NonullFormField.d.ts.map +1 -0
  13. package/dist/src/index.d.ts +6 -0
  14. package/dist/src/index.d.ts.map +1 -0
  15. package/dist/src/types/DeepPartial.d.ts +6 -0
  16. package/dist/src/types/DeepPartial.d.ts.map +1 -0
  17. package/dist/src/types/Mixin.d.ts +2 -0
  18. package/dist/src/types/Mixin.d.ts.map +1 -0
  19. package/dist/src/utils/ensureImmerability.d.ts +2 -0
  20. package/dist/src/utils/ensureImmerability.d.ts.map +1 -0
  21. package/dist/src/utils/getId.d.ts.map +1 -0
  22. package/dist/src/utils/removeBy.d.ts.map +1 -0
  23. package/dist/test/test1.d.ts +2 -0
  24. package/dist/test/test1.d.ts.map +1 -0
  25. package/package.json +27 -27
  26. package/src/form/CustomValidation.ts +52 -0
  27. package/src/form/Field.ts +334 -194
  28. package/src/form/FormController.ts +310 -290
  29. package/src/form/FormField.ts +202 -199
  30. package/src/form/NonullFormField.ts +21 -0
  31. package/src/index.ts +5 -3
  32. package/src/types/DeepPartial.ts +7 -3
  33. package/src/types/Mixin.ts +2 -0
  34. package/src/utils/ensureImmerability.ts +30 -0
  35. package/src/utils/getId.ts +5 -5
  36. package/src/utils/removeBy.ts +11 -11
  37. package/test/test1.ts +52 -0
  38. package/tsconfig.json +7 -7
  39. package/vite.config.ts +18 -18
  40. package/dist/form/Field.d.ts +0 -17
  41. package/dist/form/Field.d.ts.map +0 -1
  42. package/dist/form/FormController.d.ts +0 -62
  43. package/dist/form/FormController.d.ts.map +0 -1
  44. package/dist/form/FormField.d.ts.map +0 -1
  45. package/dist/index.d.ts +0 -4
  46. package/dist/index.d.ts.map +0 -1
  47. package/dist/types/DeepPartial.d.ts +0 -4
  48. package/dist/types/DeepPartial.d.ts.map +0 -1
  49. package/dist/utils/getId.d.ts.map +0 -1
  50. package/dist/utils/removeBy.d.ts.map +0 -1
  51. /package/dist/{utils → src/utils}/getId.d.ts +0 -0
  52. /package/dist/{utils → src/utils}/removeBy.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,92 +1,137 @@
1
- var S;
1
+ var m;
2
2
  ((t) => {
3
- function e(u, a) {
4
- if (u == null) return;
5
- const r = a.split(".");
6
- let s = u;
7
- for (const f of r) {
8
- if (s == null) return;
9
- s = s[f];
10
- }
11
- return s;
12
- }
13
- t.getValue = e;
14
- function i(u, a, r) {
15
- if (u === a) return !0;
16
- if (u === null || a === null || typeof u != "object" || typeof a != "object") return !1;
17
- if (Array.isArray(u)) {
18
- if (!Array.isArray(a) || u.length !== a.length) return !1;
19
- for (let h = 0; h < u.length; h++)
20
- if (!i(u[h], a[h])) return !1;
3
+ function e(r, c, l) {
4
+ if (r === c) return !0;
5
+ if (r === null || c === null || typeof r != "object" || typeof c != "object") return !1;
6
+ if (Array.isArray(r)) {
7
+ if (!Array.isArray(c) || r.length !== c.length) return !1;
8
+ for (let y = 0; y < r.length; y++)
9
+ if (!e(r[y], c[y])) return !1;
21
10
  return !0;
22
11
  }
23
- if (r != null) {
24
- const h = r(u, a);
25
- if (h !== void 0) return h;
12
+ if (l != null) {
13
+ const y = l(r, c);
14
+ if (y !== void 0) return y;
26
15
  }
27
- if (u instanceof Date && a instanceof Date)
28
- return u.getTime() === a.getTime();
29
- if (u instanceof RegExp && a instanceof RegExp)
30
- return u.source === a.source && u.flags === a.flags;
31
- if (u instanceof Map && a instanceof Map) {
32
- if (u.size !== a.size) return !1;
33
- for (const [h, v] of u)
34
- if (!a.has(h) || !i(v, a.get(h))) return !1;
16
+ if (r instanceof Date && c instanceof Date)
17
+ return r.getTime() === c.getTime();
18
+ if (r instanceof RegExp && c instanceof RegExp)
19
+ return r.source === c.source && r.flags === c.flags;
20
+ if (r instanceof Map && c instanceof Map) {
21
+ if (r.size !== c.size) return !1;
22
+ for (const [y, V] of r)
23
+ if (!c.has(y) || !e(V, c.get(y))) return !1;
35
24
  return !0;
36
25
  }
37
- if (u instanceof Set && a instanceof Set) {
38
- if (u.size !== a.size) return !1;
39
- for (const h of u)
40
- if (!a.has(h)) return !1;
26
+ if (r instanceof Set && c instanceof Set) {
27
+ if (r.size !== c.size) return !1;
28
+ for (const y of r)
29
+ if (!c.has(y)) return !1;
41
30
  return !0;
42
31
  }
43
- if (Object.getPrototypeOf(u) !== Object.getPrototypeOf(a))
32
+ if (Object.getPrototypeOf(r) !== Object.getPrototypeOf(c))
44
33
  return !1;
45
- const s = Object.keys(u), f = Object.keys(a);
46
- if (s.length !== f.length) return !1;
47
- for (const h of s)
48
- if (!Object.prototype.hasOwnProperty.call(a, h) || !i(u[h], a[h])) return !1;
34
+ const _ = Object.keys(r), g = Object.keys(c);
35
+ if (_.length !== g.length) return !1;
36
+ for (const y of _)
37
+ if (!Object.prototype.hasOwnProperty.call(c, y) || !e(r[y], c[y])) return !1;
49
38
  return !0;
50
39
  }
51
- t.deepEqual = i;
52
- function n(u, a, r, s) {
53
- const f = [], h = [], v = [];
54
- for (const g of a)
55
- u.some((I) => r(I, g)) ? (s?.(g) ?? !0) && v.push(g) : (s?.(g) ?? !0) && f.push(g);
56
- for (const g of u)
57
- a.some((I) => r(g, I)) || (s?.(g) ?? !0) && h.push(g);
58
- return { added: f, removed: h, unchanged: v };
40
+ t.deepEqual = e;
41
+ function n(r, c, l, _) {
42
+ const g = [], y = [], V = [];
43
+ for (const D of c)
44
+ r.some((O) => l(O, D)) ? (_?.(D) ?? !0) && V.push(D) : (_?.(D) ?? !0) && g.push(D);
45
+ for (const D of r)
46
+ c.some((O) => l(D, O)) || (_?.(D) ?? !0) && y.push(D);
47
+ return { added: g, removed: y, unchanged: V };
59
48
  }
60
49
  t.diff = n;
61
- function o(u, a, r) {
62
- return c(u, a, () => r);
63
- }
64
- t.setValue = o;
65
- function c(u, a, r) {
66
- const s = a.split(".");
67
- let f = u;
68
- for (let g = 0; g < s.length - 1; g++) {
69
- const I = s[g];
70
- f[I] == null && (f[I] = {}), f = f[I];
50
+ function i(r) {
51
+ const c = [];
52
+ let l = 0;
53
+ for (; l < r.length; ) {
54
+ const _ = r[l];
55
+ if (_ === ".") {
56
+ l++;
57
+ continue;
58
+ }
59
+ if (_ === "[") {
60
+ l++;
61
+ let y = "";
62
+ for (; l < r.length && r[l] !== "]"; )
63
+ y += r[l], l++;
64
+ if (l++, !y || !/^\d+$/.test(y))
65
+ throw new Error(`Invalid array index in path: ${r}`);
66
+ c.push(Number(y));
67
+ continue;
68
+ }
69
+ let g = "";
70
+ for (; l < r.length && /[^\.\[]/.test(r[l]); )
71
+ g += r[l], l++;
72
+ g && c.push(g);
71
73
  }
72
- const h = f[s[s.length - 1]], v = r(h);
73
- v !== void 0 && (f[s[s.length - 1]] = v);
74
- }
75
- t.modifyValue = c;
76
- function l(u, a) {
77
- const r = a.split(".");
78
- let s = u;
79
- for (let f = 0; f < r.length - 1; f++) {
80
- const h = r[f];
81
- if (s[h] == null)
82
- return;
83
- s = s[h];
74
+ return c;
75
+ }
76
+ t.parsePathFragments = i;
77
+ function o(r) {
78
+ let c = "";
79
+ for (const l of r) {
80
+ const _ = typeof l == "object" && "key" in l ? l.key : l;
81
+ typeof _ == "number" ? c += `[${_}]` : (c.length > 0 && (c += "."), c += _.toString());
82
+ }
83
+ return c;
84
+ }
85
+ t.parsePath = o;
86
+ function a(r, c) {
87
+ const l = i(r), _ = i(c);
88
+ if (l.length >= _.length) return !1;
89
+ for (let g = 0; g < l.length; g++)
90
+ if (l[g] !== _[g])
91
+ return !1;
92
+ return !0;
93
+ }
94
+ t.isDescendant = a;
95
+ function u(r, c) {
96
+ if (r == null) return;
97
+ const l = i(c);
98
+ let _ = r;
99
+ for (const g of l) {
100
+ if (_ == null) return;
101
+ _ = _[g];
102
+ }
103
+ return _;
104
+ }
105
+ t.getValue = u;
106
+ function h(r, c, l) {
107
+ return d(r, c, () => l);
108
+ }
109
+ t.setValue = h;
110
+ function d(r, c, l) {
111
+ const _ = i(c);
112
+ let g = r;
113
+ for (let O = 0; O < _.length - 1; O++) {
114
+ const f = _[O], S = _[O + 1];
115
+ g[f] == null && (g[f] = typeof S == "number" ? [] : {}), g = g[f];
116
+ }
117
+ const y = _[_.length - 1], V = g[y], D = l(V);
118
+ D !== void 0 && (g[y] = D);
119
+ }
120
+ t.modifyValue = d;
121
+ function s(r, c) {
122
+ const l = i(c);
123
+ let _ = r;
124
+ for (let y = 0; y < l.length - 1; y++) {
125
+ const V = l[y];
126
+ if (_[V] == null) return;
127
+ _ = _[V];
84
128
  }
85
- delete s[r[r.length - 1]];
129
+ const g = l[l.length - 1];
130
+ delete _[g];
86
131
  }
87
- t.deleteValue = l;
88
- })(S || (S = {}));
89
- var zt = /* @__PURE__ */ Symbol.for("immer-nothing"), $ = /* @__PURE__ */ Symbol.for("immer-draftable"), _ = /* @__PURE__ */ Symbol.for("immer-state"), jt = process.env.NODE_ENV !== "production" ? [
132
+ t.deleteValue = s;
133
+ })(m || (m = {}));
134
+ var zt = /* @__PURE__ */ Symbol.for("immer-nothing"), J = /* @__PURE__ */ Symbol.for("immer-draftable"), p = /* @__PURE__ */ Symbol.for("immer-state"), jt = process.env.NODE_ENV !== "production" ? [
90
135
  // All error codes, starting by 0:
91
136
  function(t) {
92
137
  return `The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`;
@@ -117,125 +162,125 @@ var zt = /* @__PURE__ */ Symbol.for("immer-nothing"), $ = /* @__PURE__ */ Symbol
117
162
  // Note: if more errors are added, the errorOffset in Patches.ts should be increased
118
163
  // See Patches.ts for additional errors
119
164
  ] : [];
120
- function M(t, ...e) {
165
+ function E(t, ...e) {
121
166
  if (process.env.NODE_ENV !== "production") {
122
- const i = jt[t], n = C(i) ? i.apply(null, e) : i;
123
- throw new Error(`[Immer] ${n}`);
167
+ const n = jt[t], i = k(n) ? n.apply(null, e) : n;
168
+ throw new Error(`[Immer] ${i}`);
124
169
  }
125
170
  throw new Error(
126
171
  `[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`
127
172
  );
128
173
  }
129
- var D = Object, k = D.getPrototypeOf, K = "constructor", et = "prototype", dt = "configurable", Y = "enumerable", W = "writable", R = "value", V = (t) => !!t && !!t[_];
130
- function E(t) {
131
- return t ? Tt(t) || it(t) || !!t[$] || !!t[K]?.[$] || nt(t) || rt(t) : !1;
174
+ var F = Object, x = F.getPrototypeOf, Q = "constructor", rt = "prototype", pt = "configurable", X = "enumerable", K = "writable", j = "value", C = (t) => !!t && !!t[p];
175
+ function b(t) {
176
+ return t ? At(t) || st(t) || !!t[J] || !!t[Q]?.[J] || ot(t) || at(t) : !1;
132
177
  }
133
- var Lt = D[et][K].toString(), Mt = /* @__PURE__ */ new WeakMap();
134
- function Tt(t) {
135
- if (!t || !st(t))
178
+ var Lt = F[rt][Q].toString(), Ft = /* @__PURE__ */ new WeakMap();
179
+ function At(t) {
180
+ if (!t || !ct(t))
136
181
  return !1;
137
- const e = k(t);
138
- if (e === null || e === D[et])
182
+ const e = x(t);
183
+ if (e === null || e === F[rt])
139
184
  return !0;
140
- const i = D.hasOwnProperty.call(e, K) && e[K];
141
- if (i === Object)
185
+ const n = F.hasOwnProperty.call(e, Q) && e[Q];
186
+ if (n === Object)
142
187
  return !0;
143
- if (!C(i))
188
+ if (!k(n))
144
189
  return !1;
145
- let n = Mt.get(i);
146
- return n === void 0 && (n = Function.toString.call(i), Mt.set(i, n)), n === Lt;
190
+ let i = Ft.get(n);
191
+ return i === void 0 && (i = Function.toString.call(n), Ft.set(n, i)), i === Lt;
147
192
  }
148
- function H(t, e, i = !0) {
149
- q(t) === 0 ? (i ? Reflect.ownKeys(t) : D.keys(t)).forEach((o) => {
193
+ function q(t, e, n = !0) {
194
+ G(t) === 0 ? (n ? Reflect.ownKeys(t) : F.keys(t)).forEach((o) => {
150
195
  e(o, t[o], t);
151
- }) : t.forEach((n, o) => e(o, n, t));
196
+ }) : t.forEach((i, o) => e(o, i, t));
152
197
  }
153
- function q(t) {
154
- const e = t[_];
155
- return e ? e.type_ : it(t) ? 1 : nt(t) ? 2 : rt(t) ? 3 : 0;
198
+ function G(t) {
199
+ const e = t[p];
200
+ return e ? e.type_ : st(t) ? 1 : ot(t) ? 2 : at(t) ? 3 : 0;
156
201
  }
157
- var Dt = (t, e, i = q(t)) => i === 2 ? t.has(e) : D[et].hasOwnProperty.call(t, e), ht = (t, e, i = q(t)) => (
202
+ var Mt = (t, e, n = G(t)) => n === 2 ? t.has(e) : F[rt].hasOwnProperty.call(t, e), yt = (t, e, n = G(t)) => (
158
203
  // @ts-ignore
159
- i === 2 ? t.get(e) : t[e]
160
- ), J = (t, e, i, n = q(t)) => {
161
- n === 2 ? t.set(e, i) : n === 3 ? t.add(i) : t[e] = i;
204
+ n === 2 ? t.get(e) : t[e]
205
+ ), Z = (t, e, n, i = G(t)) => {
206
+ i === 2 ? t.set(e, n) : i === 3 ? t.add(n) : t[e] = n;
162
207
  };
163
208
  function Bt(t, e) {
164
209
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
165
210
  }
166
- var it = Array.isArray, nt = (t) => t instanceof Map, rt = (t) => t instanceof Set, st = (t) => typeof t == "object", C = (t) => typeof t == "function", lt = (t) => typeof t == "boolean";
211
+ var st = Array.isArray, ot = (t) => t instanceof Map, at = (t) => t instanceof Set, ct = (t) => typeof t == "object", k = (t) => typeof t == "function", ht = (t) => typeof t == "boolean";
167
212
  function Ht(t) {
168
213
  const e = +t;
169
214
  return Number.isInteger(e) && String(e) === t;
170
215
  }
171
- var qt = (t) => st(t) ? t?.[_] : null, p = (t) => t.copy_ || t.base_, Gt = (t) => {
172
- const e = qt(t);
216
+ var $t = (t) => ct(t) ? t?.[p] : null, v = (t) => t.copy_ || t.base_, qt = (t) => {
217
+ const e = $t(t);
173
218
  return e ? e.copy_ ?? e.base_ : t;
174
- }, vt = (t) => t.modified_ ? t.copy_ : t.base_;
175
- function _t(t, e) {
176
- if (nt(t))
219
+ }, wt = (t) => t.modified_ ? t.copy_ : t.base_;
220
+ function gt(t, e) {
221
+ if (ot(t))
177
222
  return new Map(t);
178
- if (rt(t))
223
+ if (at(t))
179
224
  return new Set(t);
180
- if (it(t))
181
- return Array[et].slice.call(t);
182
- const i = Tt(t);
183
- if (e === !0 || e === "class_only" && !i) {
184
- const n = D.getOwnPropertyDescriptors(t);
185
- delete n[_];
186
- let o = Reflect.ownKeys(n);
187
- for (let c = 0; c < o.length; c++) {
188
- const l = o[c], u = n[l];
189
- u[W] === !1 && (u[W] = !0, u[dt] = !0), (u.get || u.set) && (n[l] = {
190
- [dt]: !0,
191
- [W]: !0,
225
+ if (st(t))
226
+ return Array[rt].slice.call(t);
227
+ const n = At(t);
228
+ if (e === !0 || e === "class_only" && !n) {
229
+ const i = F.getOwnPropertyDescriptors(t);
230
+ delete i[p];
231
+ let o = Reflect.ownKeys(i);
232
+ for (let a = 0; a < o.length; a++) {
233
+ const u = o[a], h = i[u];
234
+ h[K] === !1 && (h[K] = !0, h[pt] = !0), (h.get || h.set) && (i[u] = {
235
+ [pt]: !0,
236
+ [K]: !0,
192
237
  // could live with !!desc.set as well here...
193
- [Y]: u[Y],
194
- [R]: t[l]
238
+ [X]: h[X],
239
+ [j]: t[u]
195
240
  });
196
241
  }
197
- return D.create(k(t), n);
242
+ return F.create(x(t), i);
198
243
  } else {
199
- const n = k(t);
200
- if (n !== null && i)
244
+ const i = x(t);
245
+ if (i !== null && n)
201
246
  return { ...t };
202
- const o = D.create(n);
203
- return D.assign(o, t);
247
+ const o = F.create(i);
248
+ return F.assign(o, t);
204
249
  }
205
250
  }
206
- function Pt(t, e = !1) {
207
- return ot(t) || V(t) || !E(t) || (q(t) > 1 && D.defineProperties(t, {
208
- set: G,
209
- add: G,
210
- clear: G,
211
- delete: G
212
- }), D.freeze(t), e && H(
251
+ function Et(t, e = !1) {
252
+ return lt(t) || C(t) || !b(t) || (G(t) > 1 && F.defineProperties(t, {
253
+ set: W,
254
+ add: W,
255
+ clear: W,
256
+ delete: W
257
+ }), F.freeze(t), e && q(
213
258
  t,
214
- (i, n) => {
215
- Pt(n, !0);
259
+ (n, i) => {
260
+ Et(i, !0);
216
261
  },
217
262
  !1
218
263
  )), t;
219
264
  }
220
- function Wt() {
221
- M(2);
265
+ function Gt() {
266
+ E(2);
222
267
  }
223
- var G = {
224
- [R]: Wt
268
+ var W = {
269
+ [j]: Gt
225
270
  };
226
- function ot(t) {
227
- return t === null || !st(t) ? !0 : D.isFrozen(t);
271
+ function lt(t) {
272
+ return t === null || !ct(t) ? !0 : F.isFrozen(t);
228
273
  }
229
- var U = "MapSet", pt = "Patches", yt = "ArrayMethods", Q = {};
230
- function A(t) {
231
- const e = Q[t];
232
- return e || M(0, t), e;
274
+ var L = "MapSet", mt = "Patches", St = "ArrayMethods", tt = {};
275
+ function N(t) {
276
+ const e = tt[t];
277
+ return e || E(0, t), e;
233
278
  }
234
- var wt = (t) => !!Q[t];
235
- function Vt(t, e) {
236
- Q[t] || (Q[t] = e);
279
+ var Vt = (t) => !!tt[t];
280
+ function Ct(t, e) {
281
+ tt[t] || (tt[t] = e);
237
282
  }
238
- var j, X = () => j, $t = (t, e) => ({
283
+ var B, et = () => B, Wt = (t, e) => ({
239
284
  drafts_: [],
240
285
  parent_: t,
241
286
  immer_: e,
@@ -245,137 +290,137 @@ var j, X = () => j, $t = (t, e) => ({
245
290
  unfinalizedDrafts_: 0,
246
291
  handledSet_: /* @__PURE__ */ new Set(),
247
292
  processedForPatches_: /* @__PURE__ */ new Set(),
248
- mapSetPlugin_: wt(U) ? A(U) : void 0,
249
- arrayMethodsPlugin_: wt(yt) ? A(yt) : void 0
293
+ mapSetPlugin_: Vt(L) ? N(L) : void 0,
294
+ arrayMethodsPlugin_: Vt(St) ? N(St) : void 0
250
295
  });
251
- function Et(t, e) {
252
- e && (t.patchPlugin_ = A(pt), t.patches_ = [], t.inversePatches_ = [], t.patchListener_ = e);
296
+ function bt(t, e) {
297
+ e && (t.patchPlugin_ = N(mt), t.patches_ = [], t.inversePatches_ = [], t.patchListener_ = e);
253
298
  }
254
- function mt(t) {
255
- gt(t), t.drafts_.forEach(Kt), t.drafts_ = null;
299
+ function vt(t) {
300
+ Pt(t), t.drafts_.forEach(Kt), t.drafts_ = null;
256
301
  }
257
- function gt(t) {
258
- t === j && (j = t.parent_);
302
+ function Pt(t) {
303
+ t === B && (B = t.parent_);
259
304
  }
260
- var Ot = (t) => j = $t(j, t);
305
+ var Ot = (t) => B = Wt(B, t);
261
306
  function Kt(t) {
262
- const e = t[_];
307
+ const e = t[p];
263
308
  e.type_ === 0 || e.type_ === 1 ? e.revoke_() : e.revoked_ = !0;
264
309
  }
265
310
  function It(t, e) {
266
311
  e.unfinalizedDrafts_ = e.drafts_.length;
267
- const i = e.drafts_[0];
268
- if (t !== void 0 && t !== i) {
269
- i[_].modified_ && (mt(e), M(4)), E(t) && (t = bt(e, t));
312
+ const n = e.drafts_[0];
313
+ if (t !== void 0 && t !== n) {
314
+ n[p].modified_ && (vt(e), E(4)), b(t) && (t = Tt(e, t));
270
315
  const { patchPlugin_: o } = e;
271
316
  o && o.generateReplacementPatches_(
272
- i[_].base_,
317
+ n[p].base_,
273
318
  t,
274
319
  e
275
320
  );
276
321
  } else
277
- t = bt(e, i);
278
- return Yt(e, t, !0), mt(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== zt ? t : void 0;
322
+ t = Tt(e, n);
323
+ return Yt(e, t, !0), vt(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== zt ? t : void 0;
279
324
  }
280
- function bt(t, e) {
281
- if (ot(e))
325
+ function Tt(t, e) {
326
+ if (lt(e))
282
327
  return e;
283
- const i = e[_];
284
- if (!i)
285
- return Z(e, t.handledSet_, t);
286
- if (!at(i, t))
328
+ const n = e[p];
329
+ if (!n)
330
+ return nt(e, t.handledSet_, t);
331
+ if (!ut(n, t))
287
332
  return e;
288
- if (!i.modified_)
289
- return i.base_;
290
- if (!i.finalized_) {
291
- const { callbacks_: n } = i;
292
- if (n)
293
- for (; n.length > 0; )
294
- n.pop()(t);
295
- kt(i, t);
296
- }
297
- return i.copy_;
333
+ if (!n.modified_)
334
+ return n.base_;
335
+ if (!n.finalized_) {
336
+ const { callbacks_: i } = n;
337
+ if (i)
338
+ for (; i.length > 0; )
339
+ i.pop()(t);
340
+ xt(n, t);
341
+ }
342
+ return n.copy_;
298
343
  }
299
- function Yt(t, e, i = !1) {
300
- !t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && Pt(e, i);
344
+ function Yt(t, e, n = !1) {
345
+ !t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && Et(e, n);
301
346
  }
302
- function Ct(t) {
347
+ function kt(t) {
303
348
  t.finalized_ = !0, t.scope_.unfinalizedDrafts_--;
304
349
  }
305
- var at = (t, e) => t.scope_ === e, Jt = [];
306
- function At(t, e, i, n) {
307
- const o = p(t), c = t.type_;
308
- if (n !== void 0 && ht(o, n, c) === e) {
309
- J(o, n, i, c);
350
+ var ut = (t, e) => t.scope_ === e, Jt = [];
351
+ function Nt(t, e, n, i) {
352
+ const o = v(t), a = t.type_;
353
+ if (i !== void 0 && yt(o, i, a) === e) {
354
+ Z(o, i, n, a);
310
355
  return;
311
356
  }
312
357
  if (!t.draftLocations_) {
313
- const u = t.draftLocations_ = /* @__PURE__ */ new Map();
314
- H(o, (a, r) => {
315
- if (V(r)) {
316
- const s = u.get(r) || [];
317
- s.push(a), u.set(r, s);
358
+ const h = t.draftLocations_ = /* @__PURE__ */ new Map();
359
+ q(o, (d, s) => {
360
+ if (C(s)) {
361
+ const r = h.get(s) || [];
362
+ r.push(d), h.set(s, r);
318
363
  }
319
364
  });
320
365
  }
321
- const l = t.draftLocations_.get(e) ?? Jt;
322
- for (const u of l)
323
- J(o, u, i, c);
366
+ const u = t.draftLocations_.get(e) ?? Jt;
367
+ for (const h of u)
368
+ Z(o, h, n, a);
324
369
  }
325
- function Qt(t, e, i) {
370
+ function Qt(t, e, n) {
326
371
  t.callbacks_.push(function(o) {
327
- const c = e;
328
- if (!c || !at(c, o))
372
+ const a = e;
373
+ if (!a || !ut(a, o))
329
374
  return;
330
- o.mapSetPlugin_?.fixSetContents(c);
331
- const l = vt(c);
332
- At(t, c.draft_ ?? c, l, i), kt(c, o);
375
+ o.mapSetPlugin_?.fixSetContents(a);
376
+ const u = wt(a);
377
+ Nt(t, a.draft_ ?? a, u, n), xt(a, o);
333
378
  });
334
379
  }
335
- function kt(t, e) {
380
+ function xt(t, e) {
336
381
  if (t.modified_ && !t.finalized_ && (t.type_ === 3 || t.type_ === 1 && t.allIndicesReassigned_ || (t.assigned_?.size ?? 0) > 0)) {
337
- const { patchPlugin_: n } = e;
338
- if (n) {
339
- const o = n.getPath(t);
340
- o && n.generatePatches_(t, o, e);
382
+ const { patchPlugin_: i } = e;
383
+ if (i) {
384
+ const o = i.getPath(t);
385
+ o && i.generatePatches_(t, o, e);
341
386
  }
342
- Ct(t);
387
+ kt(t);
343
388
  }
344
389
  }
345
- function St(t, e, i) {
346
- const { scope_: n } = t;
347
- if (V(i)) {
348
- const o = i[_];
349
- at(o, n) && o.callbacks_.push(function() {
350
- N(t);
351
- const l = vt(o);
352
- At(t, i, l, e);
390
+ function Dt(t, e, n) {
391
+ const { scope_: i } = t;
392
+ if (C(n)) {
393
+ const o = n[p];
394
+ ut(o, i) && o.callbacks_.push(function() {
395
+ U(t);
396
+ const u = wt(o);
397
+ Nt(t, n, u, e);
353
398
  });
354
- } else E(i) && t.callbacks_.push(function() {
355
- const c = p(t);
356
- t.type_ === 3 ? c.has(i) && Z(i, n.handledSet_, n) : ht(c, e, t.type_) === i && n.drafts_.length > 1 && (t.assigned_.get(e) ?? !1) === !0 && t.copy_ && Z(
357
- ht(t.copy_, e, t.type_),
358
- n.handledSet_,
359
- n
399
+ } else b(n) && t.callbacks_.push(function() {
400
+ const a = v(t);
401
+ t.type_ === 3 ? a.has(n) && nt(n, i.handledSet_, i) : yt(a, e, t.type_) === n && i.drafts_.length > 1 && (t.assigned_.get(e) ?? !1) === !0 && t.copy_ && nt(
402
+ yt(t.copy_, e, t.type_),
403
+ i.handledSet_,
404
+ i
360
405
  );
361
406
  });
362
407
  }
363
- function Z(t, e, i) {
364
- return !i.immer_.autoFreeze_ && i.unfinalizedDrafts_ < 1 || V(t) || e.has(t) || !E(t) || ot(t) || (e.add(t), H(t, (n, o) => {
365
- if (V(o)) {
366
- const c = o[_];
367
- if (at(c, i)) {
368
- const l = vt(c);
369
- J(t, n, l, t.type_), Ct(c);
408
+ function nt(t, e, n) {
409
+ return !n.immer_.autoFreeze_ && n.unfinalizedDrafts_ < 1 || C(t) || e.has(t) || !b(t) || lt(t) || (e.add(t), q(t, (i, o) => {
410
+ if (C(o)) {
411
+ const a = o[p];
412
+ if (ut(a, n)) {
413
+ const u = wt(a);
414
+ Z(t, i, u, t.type_), kt(a);
370
415
  }
371
- } else E(o) && Z(o, e, i);
416
+ } else b(o) && nt(o, e, n);
372
417
  })), t;
373
418
  }
374
419
  function Xt(t, e) {
375
- const i = it(t), n = {
376
- type_: i ? 1 : 0,
420
+ const n = st(t), i = {
421
+ type_: n ? 1 : 0,
377
422
  // Track which produce call this is associated with.
378
- scope_: e ? e.scope_ : X(),
423
+ scope_: e ? e.scope_ : et(),
379
424
  // True for both shallow and deep changes.
380
425
  modified_: !1,
381
426
  // Used during finalization.
@@ -398,177 +443,177 @@ function Xt(t, e) {
398
443
  // `callbacks` actually gets assigned in `createProxy`
399
444
  callbacks_: void 0
400
445
  };
401
- let o = n, c = tt;
402
- i && (o = [n], c = L);
403
- const { revoke: l, proxy: u } = Proxy.revocable(o, c);
404
- return n.draft_ = u, n.revoke_ = l, [u, n];
446
+ let o = i, a = it;
447
+ n && (o = [i], a = H);
448
+ const { revoke: u, proxy: h } = Proxy.revocable(o, a);
449
+ return i.draft_ = h, i.revoke_ = u, [h, i];
405
450
  }
406
- var tt = {
451
+ var it = {
407
452
  get(t, e) {
408
- if (e === _)
453
+ if (e === p)
409
454
  return t;
410
- let i = t.scope_.arrayMethodsPlugin_;
411
- const n = t.type_ === 1 && typeof e == "string";
412
- if (n && i?.isArrayOperationMethod(e))
413
- return i.createMethodInterceptor(t, e);
414
- const o = p(t);
415
- if (!Dt(o, e, t.type_))
455
+ let n = t.scope_.arrayMethodsPlugin_;
456
+ const i = t.type_ === 1 && typeof e == "string";
457
+ if (i && n?.isArrayOperationMethod(e))
458
+ return n.createMethodInterceptor(t, e);
459
+ const o = v(t);
460
+ if (!Mt(o, e, t.type_))
416
461
  return Zt(t, o, e);
417
- const c = o[e];
418
- if (t.finalized_ || !E(c) || n && t.operationMethod && i?.isMutatingArrayMethod(
462
+ const a = o[e];
463
+ if (t.finalized_ || !b(a) || i && t.operationMethod && n?.isMutatingArrayMethod(
419
464
  t.operationMethod
420
465
  ) && Ht(e))
421
- return c;
422
- if (c === ft(t.base_, e)) {
423
- N(t);
424
- const l = t.type_ === 1 ? +e : e, u = B(t.scope_, c, t, l);
425
- return t.copy_[l] = u;
466
+ return a;
467
+ if (a === _t(t.base_, e)) {
468
+ U(t);
469
+ const u = t.type_ === 1 ? +e : e, h = $(t.scope_, a, t, u);
470
+ return t.copy_[u] = h;
426
471
  }
427
- return c;
472
+ return a;
428
473
  },
429
474
  has(t, e) {
430
- return e in p(t);
475
+ return e in v(t);
431
476
  },
432
477
  ownKeys(t) {
433
- return Reflect.ownKeys(p(t));
478
+ return Reflect.ownKeys(v(t));
434
479
  },
435
- set(t, e, i) {
436
- const n = Ft(p(t), e);
437
- if (n?.set)
438
- return n.set.call(t.draft_, i), !0;
480
+ set(t, e, n) {
481
+ const i = Rt(v(t), e);
482
+ if (i?.set)
483
+ return i.set.call(t.draft_, n), !0;
439
484
  if (!t.modified_) {
440
- const o = ft(p(t), e), c = o?.[_];
441
- if (c && c.base_ === i)
442
- return t.copy_[e] = i, t.assigned_.set(e, !1), !0;
443
- if (Bt(i, o) && (i !== void 0 || Dt(t.base_, e, t.type_)))
485
+ const o = _t(v(t), e), a = o?.[p];
486
+ if (a && a.base_ === n)
487
+ return t.copy_[e] = n, t.assigned_.set(e, !1), !0;
488
+ if (Bt(n, o) && (n !== void 0 || Mt(t.base_, e, t.type_)))
444
489
  return !0;
445
- N(t), O(t);
490
+ U(t), I(t);
446
491
  }
447
- return t.copy_[e] === i && // special case: handle new props with value 'undefined'
448
- (i !== void 0 || e in t.copy_) || // special case: NaN
449
- Number.isNaN(i) && Number.isNaN(t.copy_[e]) || (t.copy_[e] = i, t.assigned_.set(e, !0), St(t, e, i)), !0;
492
+ return t.copy_[e] === n && // special case: handle new props with value 'undefined'
493
+ (n !== void 0 || e in t.copy_) || // special case: NaN
494
+ Number.isNaN(n) && Number.isNaN(t.copy_[e]) || (t.copy_[e] = n, t.assigned_.set(e, !0), Dt(t, e, n)), !0;
450
495
  },
451
496
  deleteProperty(t, e) {
452
- return N(t), ft(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_.set(e, !1), O(t)) : t.assigned_.delete(e), t.copy_ && delete t.copy_[e], !0;
497
+ return U(t), _t(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_.set(e, !1), I(t)) : t.assigned_.delete(e), t.copy_ && delete t.copy_[e], !0;
453
498
  },
454
499
  // Note: We never coerce `desc.value` into an Immer draft, because we can't make
455
500
  // the same guarantee in ES5 mode.
456
501
  getOwnPropertyDescriptor(t, e) {
457
- const i = p(t), n = Reflect.getOwnPropertyDescriptor(i, e);
458
- return n && {
459
- [W]: !0,
460
- [dt]: t.type_ !== 1 || e !== "length",
461
- [Y]: n[Y],
462
- [R]: i[e]
502
+ const n = v(t), i = Reflect.getOwnPropertyDescriptor(n, e);
503
+ return i && {
504
+ [K]: !0,
505
+ [pt]: t.type_ !== 1 || e !== "length",
506
+ [X]: i[X],
507
+ [j]: n[e]
463
508
  };
464
509
  },
465
510
  defineProperty() {
466
- M(11);
511
+ E(11);
467
512
  },
468
513
  getPrototypeOf(t) {
469
- return k(t.base_);
514
+ return x(t.base_);
470
515
  },
471
516
  setPrototypeOf() {
472
- M(12);
473
- }
474
- }, L = {};
475
- for (let t in tt) {
476
- let e = tt[t];
477
- L[t] = function() {
478
- const i = arguments;
479
- return i[0] = i[0][0], e.apply(this, i);
517
+ E(12);
518
+ }
519
+ }, H = {};
520
+ for (let t in it) {
521
+ let e = it[t];
522
+ H[t] = function() {
523
+ const n = arguments;
524
+ return n[0] = n[0][0], e.apply(this, n);
480
525
  };
481
526
  }
482
- L.deleteProperty = function(t, e) {
483
- return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && M(13), L.set.call(this, t, e, void 0);
527
+ H.deleteProperty = function(t, e) {
528
+ return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && E(13), H.set.call(this, t, e, void 0);
484
529
  };
485
- L.set = function(t, e, i) {
486
- return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) && M(14), tt.set.call(this, t[0], e, i, t[0]);
530
+ H.set = function(t, e, n) {
531
+ return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) && E(14), it.set.call(this, t[0], e, n, t[0]);
487
532
  };
488
- function ft(t, e) {
489
- const i = t[_];
490
- return (i ? p(i) : t)[e];
533
+ function _t(t, e) {
534
+ const n = t[p];
535
+ return (n ? v(n) : t)[e];
491
536
  }
492
- function Zt(t, e, i) {
493
- const n = Ft(e, i);
494
- return n ? R in n ? n[R] : (
537
+ function Zt(t, e, n) {
538
+ const i = Rt(e, n);
539
+ return i ? j in i ? i[j] : (
495
540
  // This is a very special case, if the prop is a getter defined by the
496
541
  // prototype, we should invoke it with the draft as context!
497
- n.get?.call(t.draft_)
542
+ i.get?.call(t.draft_)
498
543
  ) : void 0;
499
544
  }
500
- function Ft(t, e) {
545
+ function Rt(t, e) {
501
546
  if (!(e in t))
502
547
  return;
503
- let i = k(t);
504
- for (; i; ) {
505
- const n = Object.getOwnPropertyDescriptor(i, e);
506
- if (n)
507
- return n;
508
- i = k(i);
548
+ let n = x(t);
549
+ for (; n; ) {
550
+ const i = Object.getOwnPropertyDescriptor(n, e);
551
+ if (i)
552
+ return i;
553
+ n = x(n);
509
554
  }
510
555
  }
511
- function O(t) {
512
- t.modified_ || (t.modified_ = !0, t.parent_ && O(t.parent_));
556
+ function I(t) {
557
+ t.modified_ || (t.modified_ = !0, t.parent_ && I(t.parent_));
513
558
  }
514
- function N(t) {
515
- t.copy_ || (t.assigned_ = /* @__PURE__ */ new Map(), t.copy_ = _t(
559
+ function U(t) {
560
+ t.copy_ || (t.assigned_ = /* @__PURE__ */ new Map(), t.copy_ = gt(
516
561
  t.base_,
517
562
  t.scope_.immer_.useStrictShallowCopy_
518
563
  ));
519
564
  }
520
565
  var te = class {
521
566
  constructor(t) {
522
- this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1, this.produce = (e, i, n) => {
523
- if (C(e) && !C(i)) {
524
- const c = i;
525
- i = e;
526
- const l = this;
527
- return function(a = c, ...r) {
528
- return l.produce(a, (s) => i.call(this, s, ...r));
567
+ this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !1, this.produce = (e, n, i) => {
568
+ if (k(e) && !k(n)) {
569
+ const a = n;
570
+ n = e;
571
+ const u = this;
572
+ return function(d = a, ...s) {
573
+ return u.produce(d, (r) => n.call(this, r, ...s));
529
574
  };
530
575
  }
531
- C(i) || M(6), n !== void 0 && !C(n) && M(7);
576
+ k(n) || E(6), i !== void 0 && !k(i) && E(7);
532
577
  let o;
533
- if (E(e)) {
534
- const c = Ot(this), l = B(c, e, void 0);
535
- let u = !0;
578
+ if (b(e)) {
579
+ const a = Ot(this), u = $(a, e, void 0);
580
+ let h = !0;
536
581
  try {
537
- o = i(l), u = !1;
582
+ o = n(u), h = !1;
538
583
  } finally {
539
- u ? mt(c) : gt(c);
584
+ h ? vt(a) : Pt(a);
540
585
  }
541
- return Et(c, n), It(o, c);
542
- } else if (!e || !st(e)) {
543
- if (o = i(e), o === void 0 && (o = e), o === zt && (o = void 0), this.autoFreeze_ && Pt(o, !0), n) {
544
- const c = [], l = [];
545
- A(pt).generateReplacementPatches_(e, o, {
546
- patches_: c,
547
- inversePatches_: l
548
- }), n(c, l);
586
+ return bt(a, i), It(o, a);
587
+ } else if (!e || !ct(e)) {
588
+ if (o = n(e), o === void 0 && (o = e), o === zt && (o = void 0), this.autoFreeze_ && Et(o, !0), i) {
589
+ const a = [], u = [];
590
+ N(mt).generateReplacementPatches_(e, o, {
591
+ patches_: a,
592
+ inversePatches_: u
593
+ }), i(a, u);
549
594
  }
550
595
  return o;
551
596
  } else
552
- M(1, e);
553
- }, this.produceWithPatches = (e, i) => {
554
- if (C(e))
555
- return (l, ...u) => this.produceWithPatches(l, (a) => e(a, ...u));
556
- let n, o;
557
- return [this.produce(e, i, (l, u) => {
558
- n = l, o = u;
559
- }), n, o];
560
- }, lt(t?.autoFreeze) && this.setAutoFreeze(t.autoFreeze), lt(t?.useStrictShallowCopy) && this.setUseStrictShallowCopy(t.useStrictShallowCopy), lt(t?.useStrictIteration) && this.setUseStrictIteration(t.useStrictIteration);
597
+ E(1, e);
598
+ }, this.produceWithPatches = (e, n) => {
599
+ if (k(e))
600
+ return (u, ...h) => this.produceWithPatches(u, (d) => e(d, ...h));
601
+ let i, o;
602
+ return [this.produce(e, n, (u, h) => {
603
+ i = u, o = h;
604
+ }), i, o];
605
+ }, ht(t?.autoFreeze) && this.setAutoFreeze(t.autoFreeze), ht(t?.useStrictShallowCopy) && this.setUseStrictShallowCopy(t.useStrictShallowCopy), ht(t?.useStrictIteration) && this.setUseStrictIteration(t.useStrictIteration);
561
606
  }
562
607
  createDraft(t) {
563
- E(t) || M(8), V(t) && (t = ee(t));
564
- const e = Ot(this), i = B(e, t, void 0);
565
- return i[_].isManual_ = !0, gt(e), i;
608
+ b(t) || E(8), C(t) && (t = ee(t));
609
+ const e = Ot(this), n = $(e, t, void 0);
610
+ return n[p].isManual_ = !0, Pt(e), n;
566
611
  }
567
612
  finishDraft(t, e) {
568
- const i = t && t[_];
569
- (!i || !i.isManual_) && M(9);
570
- const { scope_: n } = i;
571
- return Et(n, e), It(void 0, n);
613
+ const n = t && t[p];
614
+ (!n || !n.isManual_) && E(9);
615
+ const { scope_: i } = n;
616
+ return bt(i, e), It(void 0, i);
572
617
  }
573
618
  /**
574
619
  * Pass true to automatically freeze all copies created by Immer.
@@ -599,64 +644,64 @@ var te = class {
599
644
  return this.useStrictIteration_;
600
645
  }
601
646
  applyPatches(t, e) {
602
- let i;
603
- for (i = e.length - 1; i >= 0; i--) {
604
- const o = e[i];
647
+ let n;
648
+ for (n = e.length - 1; n >= 0; n--) {
649
+ const o = e[n];
605
650
  if (o.path.length === 0 && o.op === "replace") {
606
651
  t = o.value;
607
652
  break;
608
653
  }
609
654
  }
610
- i > -1 && (e = e.slice(i + 1));
611
- const n = A(pt).applyPatches_;
612
- return V(t) ? n(t, e) : this.produce(
655
+ n > -1 && (e = e.slice(n + 1));
656
+ const i = N(mt).applyPatches_;
657
+ return C(t) ? i(t, e) : this.produce(
613
658
  t,
614
- (o) => n(o, e)
659
+ (o) => i(o, e)
615
660
  );
616
661
  }
617
662
  };
618
- function B(t, e, i, n) {
619
- const [o, c] = nt(e) ? A(U).proxyMap_(e, i) : rt(e) ? A(U).proxySet_(e, i) : Xt(e, i);
620
- return (i?.scope_ ?? X()).drafts_.push(o), c.callbacks_ = i?.callbacks_ ?? [], c.key_ = n, i && n !== void 0 ? Qt(i, c, n) : c.callbacks_.push(function(a) {
621
- a.mapSetPlugin_?.fixSetContents(c);
622
- const { patchPlugin_: r } = a;
623
- c.modified_ && r && r.generatePatches_(c, [], a);
663
+ function $(t, e, n, i) {
664
+ const [o, a] = ot(e) ? N(L).proxyMap_(e, n) : at(e) ? N(L).proxySet_(e, n) : Xt(e, n);
665
+ return (n?.scope_ ?? et()).drafts_.push(o), a.callbacks_ = n?.callbacks_ ?? [], a.key_ = i, n && i !== void 0 ? Qt(n, a, i) : a.callbacks_.push(function(d) {
666
+ d.mapSetPlugin_?.fixSetContents(a);
667
+ const { patchPlugin_: s } = d;
668
+ a.modified_ && s && s.generatePatches_(a, [], d);
624
669
  }), o;
625
670
  }
626
671
  function ee(t) {
627
- return V(t) || M(10, t), Nt(t);
672
+ return C(t) || E(10, t), Ut(t);
628
673
  }
629
- function Nt(t) {
630
- if (!E(t) || ot(t))
674
+ function Ut(t) {
675
+ if (!b(t) || lt(t))
631
676
  return t;
632
- const e = t[_];
633
- let i, n = !0;
677
+ const e = t[p];
678
+ let n, i = !0;
634
679
  if (e) {
635
680
  if (!e.modified_)
636
681
  return e.base_;
637
- e.finalized_ = !0, i = _t(t, e.scope_.immer_.useStrictShallowCopy_), n = e.scope_.immer_.shouldUseStrictIteration();
682
+ e.finalized_ = !0, n = gt(t, e.scope_.immer_.useStrictShallowCopy_), i = e.scope_.immer_.shouldUseStrictIteration();
638
683
  } else
639
- i = _t(t, !0);
640
- return H(
641
- i,
642
- (o, c) => {
643
- J(i, o, Nt(c));
684
+ n = gt(t, !0);
685
+ return q(
686
+ n,
687
+ (o, a) => {
688
+ Z(n, o, Ut(a));
644
689
  },
645
- n
646
- ), e && (e.finalized_ = !1), i;
690
+ i
691
+ ), e && (e.finalized_ = !1), n;
647
692
  }
648
- function ie() {
693
+ function ne() {
649
694
  class t extends Map {
650
- constructor(r, s) {
651
- super(), this[_] = {
695
+ constructor(s, r) {
696
+ super(), this[p] = {
652
697
  type_: 2,
653
- parent_: s,
654
- scope_: s ? s.scope_ : X(),
698
+ parent_: r,
699
+ scope_: r ? r.scope_ : et(),
655
700
  modified_: !1,
656
701
  finalized_: !1,
657
702
  copy_: void 0,
658
703
  assigned_: void 0,
659
- base_: r,
704
+ base_: s,
660
705
  draft_: this,
661
706
  isManual_: !1,
662
707
  revoked_: !1,
@@ -664,70 +709,70 @@ function ie() {
664
709
  };
665
710
  }
666
711
  get size() {
667
- return p(this[_]).size;
712
+ return v(this[p]).size;
668
713
  }
669
- has(r) {
670
- return p(this[_]).has(r);
714
+ has(s) {
715
+ return v(this[p]).has(s);
671
716
  }
672
- set(r, s) {
673
- const f = this[_];
674
- return l(f), (!p(f).has(r) || p(f).get(r) !== s) && (i(f), O(f), f.assigned_.set(r, !0), f.copy_.set(r, s), f.assigned_.set(r, !0), St(f, r, s)), this;
717
+ set(s, r) {
718
+ const c = this[p];
719
+ return u(c), (!v(c).has(s) || v(c).get(s) !== r) && (n(c), I(c), c.assigned_.set(s, !0), c.copy_.set(s, r), c.assigned_.set(s, !0), Dt(c, s, r)), this;
675
720
  }
676
- delete(r) {
677
- if (!this.has(r))
721
+ delete(s) {
722
+ if (!this.has(s))
678
723
  return !1;
679
- const s = this[_];
680
- return l(s), i(s), O(s), s.base_.has(r) ? s.assigned_.set(r, !1) : s.assigned_.delete(r), s.copy_.delete(r), !0;
724
+ const r = this[p];
725
+ return u(r), n(r), I(r), r.base_.has(s) ? r.assigned_.set(s, !1) : r.assigned_.delete(s), r.copy_.delete(s), !0;
681
726
  }
682
727
  clear() {
683
- const r = this[_];
684
- l(r), p(r).size && (i(r), O(r), r.assigned_ = /* @__PURE__ */ new Map(), H(r.base_, (s) => {
685
- r.assigned_.set(s, !1);
686
- }), r.copy_.clear());
728
+ const s = this[p];
729
+ u(s), v(s).size && (n(s), I(s), s.assigned_ = /* @__PURE__ */ new Map(), q(s.base_, (r) => {
730
+ s.assigned_.set(r, !1);
731
+ }), s.copy_.clear());
687
732
  }
688
- forEach(r, s) {
689
- const f = this[_];
690
- p(f).forEach((h, v, g) => {
691
- r.call(s, this.get(v), v, this);
733
+ forEach(s, r) {
734
+ const c = this[p];
735
+ v(c).forEach((l, _, g) => {
736
+ s.call(r, this.get(_), _, this);
692
737
  });
693
738
  }
694
- get(r) {
695
- const s = this[_];
696
- l(s);
697
- const f = p(s).get(r);
698
- if (s.finalized_ || !E(f) || f !== s.base_.get(r))
699
- return f;
700
- const h = B(s.scope_, f, s, r);
701
- return i(s), s.copy_.set(r, h), h;
739
+ get(s) {
740
+ const r = this[p];
741
+ u(r);
742
+ const c = v(r).get(s);
743
+ if (r.finalized_ || !b(c) || c !== r.base_.get(s))
744
+ return c;
745
+ const l = $(r.scope_, c, r, s);
746
+ return n(r), r.copy_.set(s, l), l;
702
747
  }
703
748
  keys() {
704
- return p(this[_]).keys();
749
+ return v(this[p]).keys();
705
750
  }
706
751
  values() {
707
- const r = this.keys();
752
+ const s = this.keys();
708
753
  return {
709
754
  [Symbol.iterator]: () => this.values(),
710
755
  next: () => {
711
- const s = r.next();
712
- return s.done ? s : {
756
+ const r = s.next();
757
+ return r.done ? r : {
713
758
  done: !1,
714
- value: this.get(s.value)
759
+ value: this.get(r.value)
715
760
  };
716
761
  }
717
762
  };
718
763
  }
719
764
  entries() {
720
- const r = this.keys();
765
+ const s = this.keys();
721
766
  return {
722
767
  [Symbol.iterator]: () => this.entries(),
723
768
  next: () => {
724
- const s = r.next();
725
- if (s.done)
726
- return s;
727
- const f = this.get(s.value);
769
+ const r = s.next();
770
+ if (r.done)
771
+ return r;
772
+ const c = this.get(r.value);
728
773
  return {
729
774
  done: !1,
730
- value: [s.value, f]
775
+ value: [r.value, c]
731
776
  };
732
777
  }
733
778
  };
@@ -736,23 +781,23 @@ function ie() {
736
781
  return this.entries();
737
782
  }
738
783
  }
739
- function e(a, r) {
740
- const s = new t(a, r);
741
- return [s, s[_]];
784
+ function e(d, s) {
785
+ const r = new t(d, s);
786
+ return [r, r[p]];
742
787
  }
743
- function i(a) {
744
- a.copy_ || (a.assigned_ = /* @__PURE__ */ new Map(), a.copy_ = new Map(a.base_));
788
+ function n(d) {
789
+ d.copy_ || (d.assigned_ = /* @__PURE__ */ new Map(), d.copy_ = new Map(d.base_));
745
790
  }
746
- class n extends Set {
747
- constructor(r, s) {
748
- super(), this[_] = {
791
+ class i extends Set {
792
+ constructor(s, r) {
793
+ super(), this[p] = {
749
794
  type_: 3,
750
- parent_: s,
751
- scope_: s ? s.scope_ : X(),
795
+ parent_: r,
796
+ scope_: r ? r.scope_ : et(),
752
797
  modified_: !1,
753
798
  finalized_: !1,
754
799
  copy_: void 0,
755
- base_: r,
800
+ base_: s,
756
801
  draft_: this,
757
802
  drafts_: /* @__PURE__ */ new Map(),
758
803
  revoked_: !1,
@@ -762,36 +807,36 @@ function ie() {
762
807
  };
763
808
  }
764
809
  get size() {
765
- return p(this[_]).size;
810
+ return v(this[p]).size;
766
811
  }
767
- has(r) {
768
- const s = this[_];
769
- return l(s), s.copy_ ? !!(s.copy_.has(r) || s.drafts_.has(r) && s.copy_.has(s.drafts_.get(r))) : s.base_.has(r);
812
+ has(s) {
813
+ const r = this[p];
814
+ return u(r), r.copy_ ? !!(r.copy_.has(s) || r.drafts_.has(s) && r.copy_.has(r.drafts_.get(s))) : r.base_.has(s);
770
815
  }
771
- add(r) {
772
- const s = this[_];
773
- return l(s), this.has(r) || (c(s), O(s), s.copy_.add(r), St(s, r, r)), this;
816
+ add(s) {
817
+ const r = this[p];
818
+ return u(r), this.has(s) || (a(r), I(r), r.copy_.add(s), Dt(r, s, s)), this;
774
819
  }
775
- delete(r) {
776
- if (!this.has(r))
820
+ delete(s) {
821
+ if (!this.has(s))
777
822
  return !1;
778
- const s = this[_];
779
- return l(s), c(s), O(s), s.copy_.delete(r) || (s.drafts_.has(r) ? s.copy_.delete(s.drafts_.get(r)) : (
823
+ const r = this[p];
824
+ return u(r), a(r), I(r), r.copy_.delete(s) || (r.drafts_.has(s) ? r.copy_.delete(r.drafts_.get(s)) : (
780
825
  /* istanbul ignore next */
781
826
  !1
782
827
  ));
783
828
  }
784
829
  clear() {
785
- const r = this[_];
786
- l(r), p(r).size && (c(r), O(r), r.copy_.clear());
830
+ const s = this[p];
831
+ u(s), v(s).size && (a(s), I(s), s.copy_.clear());
787
832
  }
788
833
  values() {
789
- const r = this[_];
790
- return l(r), c(r), r.copy_.values();
834
+ const s = this[p];
835
+ return u(s), a(s), s.copy_.values();
791
836
  }
792
837
  entries() {
793
- const r = this[_];
794
- return l(r), c(r), r.copy_.entries();
838
+ const s = this[p];
839
+ return u(s), a(s), s.copy_.entries();
795
840
  }
796
841
  keys() {
797
842
  return this.values();
@@ -799,53 +844,53 @@ function ie() {
799
844
  [Symbol.iterator]() {
800
845
  return this.values();
801
846
  }
802
- forEach(r, s) {
803
- const f = this.values();
804
- let h = f.next();
805
- for (; !h.done; )
806
- r.call(s, h.value, h.value, this), h = f.next();
847
+ forEach(s, r) {
848
+ const c = this.values();
849
+ let l = c.next();
850
+ for (; !l.done; )
851
+ s.call(r, l.value, l.value, this), l = c.next();
807
852
  }
808
853
  }
809
- function o(a, r) {
810
- const s = new n(a, r);
811
- return [s, s[_]];
854
+ function o(d, s) {
855
+ const r = new i(d, s);
856
+ return [r, r[p]];
812
857
  }
813
- function c(a) {
814
- a.copy_ || (a.copy_ = /* @__PURE__ */ new Set(), a.base_.forEach((r) => {
815
- if (E(r)) {
816
- const s = B(a.scope_, r, a, r);
817
- a.drafts_.set(r, s), a.copy_.add(s);
858
+ function a(d) {
859
+ d.copy_ || (d.copy_ = /* @__PURE__ */ new Set(), d.base_.forEach((s) => {
860
+ if (b(s)) {
861
+ const r = $(d.scope_, s, d, s);
862
+ d.drafts_.set(s, r), d.copy_.add(r);
818
863
  } else
819
- a.copy_.add(r);
864
+ d.copy_.add(s);
820
865
  }));
821
866
  }
822
- function l(a) {
823
- a.revoked_ && M(3, JSON.stringify(p(a)));
867
+ function u(d) {
868
+ d.revoked_ && E(3, JSON.stringify(v(d)));
824
869
  }
825
- function u(a) {
826
- if (a.type_ === 3 && a.copy_) {
827
- const r = new Set(a.copy_);
828
- a.copy_.clear(), r.forEach((s) => {
829
- a.copy_.add(Gt(s));
870
+ function h(d) {
871
+ if (d.type_ === 3 && d.copy_) {
872
+ const s = new Set(d.copy_);
873
+ d.copy_.clear(), s.forEach((r) => {
874
+ d.copy_.add(qt(r));
830
875
  });
831
876
  }
832
877
  }
833
- Vt(U, { proxyMap_: e, proxySet_: o, fixSetContents: u });
878
+ Ct(L, { proxyMap_: e, proxySet_: o, fixSetContents: h });
834
879
  }
835
- function ne() {
836
- const t = /* @__PURE__ */ new Set(["shift", "unshift"]), e = /* @__PURE__ */ new Set(["push", "pop"]), i = /* @__PURE__ */ new Set([
880
+ function ie() {
881
+ const t = /* @__PURE__ */ new Set(["shift", "unshift"]), e = /* @__PURE__ */ new Set(["push", "pop"]), n = /* @__PURE__ */ new Set([
837
882
  ...e,
838
883
  ...t
839
- ]), n = /* @__PURE__ */ new Set(["reverse", "sort"]), o = /* @__PURE__ */ new Set([
840
- ...i,
884
+ ]), i = /* @__PURE__ */ new Set(["reverse", "sort"]), o = /* @__PURE__ */ new Set([
841
885
  ...n,
886
+ ...i,
842
887
  "splice"
843
- ]), c = /* @__PURE__ */ new Set(["find", "findLast"]), l = /* @__PURE__ */ new Set([
888
+ ]), a = /* @__PURE__ */ new Set(["find", "findLast"]), u = /* @__PURE__ */ new Set([
844
889
  "filter",
845
890
  "slice",
846
891
  "concat",
847
892
  "flat",
848
- ...c,
893
+ ...a,
849
894
  "findIndex",
850
895
  "findLastIndex",
851
896
  "some",
@@ -857,119 +902,132 @@ function ne() {
857
902
  "toString",
858
903
  "toLocaleString"
859
904
  ]);
860
- function u(d) {
861
- return o.has(d);
905
+ function h(f) {
906
+ return o.has(f);
862
907
  }
863
- function a(d) {
864
- return l.has(d);
908
+ function d(f) {
909
+ return u.has(f);
865
910
  }
866
- function r(d) {
867
- return u(d) || a(d);
911
+ function s(f) {
912
+ return h(f) || d(f);
868
913
  }
869
- function s(d, y) {
870
- d.operationMethod = y;
914
+ function r(f, S) {
915
+ f.operationMethod = S;
871
916
  }
872
- function f(d) {
873
- d.operationMethod = void 0;
917
+ function c(f) {
918
+ f.operationMethod = void 0;
874
919
  }
875
- function h(d, y, w = !0) {
876
- N(d);
877
- const m = y();
878
- return O(d), w && d.assigned_.set("length", !0), m;
920
+ function l(f, S, M = !0) {
921
+ U(f);
922
+ const P = S();
923
+ return I(f), M && f.assigned_.set("length", !0), P;
879
924
  }
880
- function v(d) {
881
- d.allIndicesReassigned_ = !0;
925
+ function _(f) {
926
+ f.allIndicesReassigned_ = !0;
882
927
  }
883
- function g(d, y) {
884
- return d < 0 ? Math.max(y + d, 0) : Math.min(d, y);
928
+ function g(f, S) {
929
+ return f < 0 ? Math.max(S + f, 0) : Math.min(f, S);
885
930
  }
886
- function I(d, y, w) {
887
- return h(d, () => {
888
- const m = d.copy_[y](...w);
889
- return t.has(y) && v(d), i.has(y) ? m : d.draft_;
931
+ function y(f, S, M) {
932
+ return l(f, () => {
933
+ const P = f.copy_[S](...M);
934
+ return t.has(S) && _(f), n.has(S) ? P : f.draft_;
890
935
  });
891
936
  }
892
- function xt(d, y, w) {
893
- return h(
894
- d,
895
- () => (d.copy_[y](...w), v(d), d.draft_),
937
+ function V(f, S, M) {
938
+ return l(
939
+ f,
940
+ () => (f.copy_[S](...M), _(f), f.draft_),
896
941
  !1
897
942
  );
898
943
  }
899
- function Rt(d, y) {
900
- return function(...m) {
901
- const P = y;
902
- s(d, P);
944
+ function D(f, S) {
945
+ return function(...P) {
946
+ const w = S;
947
+ r(f, w);
903
948
  try {
904
- if (u(P)) {
905
- if (i.has(P))
906
- return I(d, P, m);
907
- if (n.has(P))
908
- return xt(d, P, m);
909
- if (P === "splice") {
910
- const b = h(
911
- d,
912
- () => d.copy_.splice(...m)
949
+ if (h(w)) {
950
+ if (n.has(w))
951
+ return y(f, w, P);
952
+ if (i.has(w))
953
+ return V(f, w, P);
954
+ if (w === "splice") {
955
+ const T = l(
956
+ f,
957
+ () => f.copy_.splice(...P)
913
958
  );
914
- return v(d), b;
959
+ return _(f), T;
915
960
  }
916
961
  } else
917
- return Ut(d, P, m);
962
+ return O(f, w, P);
918
963
  } finally {
919
- f(d);
964
+ c(f);
920
965
  }
921
966
  };
922
967
  }
923
- function Ut(d, y, w) {
924
- const m = p(d);
925
- if (y === "filter") {
926
- const P = w[0], b = [];
927
- for (let z = 0; z < m.length; z++)
928
- P(m[z], z, m) && b.push(d.draft_[z]);
929
- return b;
968
+ function O(f, S, M) {
969
+ const P = v(f);
970
+ if (S === "filter") {
971
+ const w = M[0], T = [];
972
+ for (let z = 0; z < P.length; z++)
973
+ w(P[z], z, P) && T.push(f.draft_[z]);
974
+ return T;
930
975
  }
931
- if (c.has(y)) {
932
- const P = w[0], b = y === "find", z = b ? 1 : -1, ct = b ? 0 : m.length - 1;
933
- for (let T = ct; T >= 0 && T < m.length; T += z)
934
- if (P(m[T], T, m))
935
- return d.draft_[T];
976
+ if (a.has(S)) {
977
+ const w = M[0], T = S === "find", z = T ? 1 : -1, ft = T ? 0 : P.length - 1;
978
+ for (let A = ft; A >= 0 && A < P.length; A += z)
979
+ if (w(P[A], A, P))
980
+ return f.draft_[A];
936
981
  return;
937
982
  }
938
- if (y === "slice") {
939
- const P = w[0] ?? 0, b = w[1] ?? m.length, z = g(P, m.length), ct = g(b, m.length), T = [];
940
- for (let ut = z; ut < ct; ut++)
941
- T.push(d.draft_[ut]);
942
- return T;
983
+ if (S === "slice") {
984
+ const w = M[0] ?? 0, T = M[1] ?? P.length, z = g(w, P.length), ft = g(T, P.length), A = [];
985
+ for (let dt = z; dt < ft; dt++)
986
+ A.push(f.draft_[dt]);
987
+ return A;
943
988
  }
944
- return m[y](...w);
989
+ return P[S](...M);
945
990
  }
946
- Vt(yt, {
947
- createMethodInterceptor: Rt,
948
- isArrayOperationMethod: r,
949
- isMutatingArrayMethod: u
991
+ Ct(St, {
992
+ createMethodInterceptor: D,
993
+ isArrayOperationMethod: s,
994
+ isMutatingArrayMethod: h
950
995
  });
951
996
  }
952
- var re = new te(), F = re.produce;
997
+ var re = new te(), R = re.produce;
998
+ function Y(t) {
999
+ if (typeof t != "object" || t === null) return;
1000
+ const e = Object.getPrototypeOf(t);
1001
+ if (e === Object.prototype || e === null) return;
1002
+ const n = e.constructor;
1003
+ typeof n == "function" && (t instanceof Date || t instanceof RegExp || t instanceof Map || t instanceof Set || t instanceof WeakMap || t instanceof WeakSet || ArrayBuffer.isView(t) || n[J] !== !0 && (n[J] = !0));
1004
+ }
953
1005
  let se = 0;
954
1006
  function oe() {
955
1007
  return se++;
956
1008
  }
957
- class x {
958
- constructor(e, i) {
959
- this.controller = e, this.path = i, this.id = oe(), this._isTouched = !1, this._isDirty = !1;
1009
+ class ae {
1010
+ constructor(e, n, i) {
1011
+ this.controller = e, this.path = n, this.id = oe(), this._isTouched = !1, this._isDirty = !1, i?.isTouched && this._setTouched(!0), i?.isDirty && this._setDirty(!0);
960
1012
  }
961
1013
  get value() {
962
- return S.getValue(
1014
+ return m.getValue(
963
1015
  this.controller._data,
964
1016
  this.path
965
1017
  );
966
1018
  }
1019
+ get initialValue() {
1020
+ return m.getValue(
1021
+ this.controller._initialData,
1022
+ this.path
1023
+ );
1024
+ }
967
1025
  get boundElement() {
968
1026
  return this.target;
969
1027
  }
970
1028
  get issues() {
971
1029
  return this.controller._issues.filter(
972
- (e) => e.path?.join(".") === this.path
1030
+ (e) => m.parsePath(e.path ?? []) === this.path
973
1031
  );
974
1032
  }
975
1033
  get isTouched() {
@@ -982,61 +1040,68 @@ class x {
982
1040
  return this.issues.length === 0;
983
1041
  }
984
1042
  _setTouched(e) {
985
- const i = this._isTouched !== e;
986
- this._isTouched = e, i && this.controller.events.emit("fieldTouchUpdated", this.path);
1043
+ const n = this._isTouched !== e;
1044
+ if (this._isTouched = e, n) {
1045
+ const i = this.controller.getAscendantFields(this.path);
1046
+ for (let o = i.length - 1; o >= 0; o--) {
1047
+ const a = i[o];
1048
+ a != null && this.controller.events.emit("fieldTouchUpdated", a.path);
1049
+ }
1050
+ }
987
1051
  }
988
1052
  _setDirty(e) {
989
- const i = this._isDirty !== e;
990
- this._isDirty = e, i && this.controller.events.emit("fieldDirtyUpdated", this.path);
1053
+ const n = this._isDirty !== e;
1054
+ if (this._isDirty = e, n) {
1055
+ const i = this.controller.getAscendantFields(this.path);
1056
+ for (let o = i.length - 1; o >= 0; o--) {
1057
+ const a = i[o];
1058
+ a != null && this.controller.events.emit("fieldDirtyUpdated", a.path);
1059
+ }
1060
+ }
991
1061
  }
992
1062
  bindElement(e) {
993
1063
  e != null ? this.controller.events.emit("elementBound", this.path, e) : this.controller.events.emit("elementUnbound", this.path), this.target = e;
994
1064
  }
995
- static ensureImmerability(e) {
996
- if (typeof e != "object" || e === null) return;
997
- const i = Object.getPrototypeOf(e);
998
- if (i === Object.prototype || i === null) return;
999
- const n = i.constructor;
1000
- typeof n == "function" && (e instanceof Date || e instanceof RegExp || e instanceof Map || e instanceof Set || e instanceof WeakMap || e instanceof WeakSet || ArrayBuffer.isView(e) || n[$] !== !0 && (n[$] = !0));
1001
- }
1002
- setValue(e, i) {
1003
- return this.modifyValue(() => e, i);
1065
+ setValue(e, n) {
1066
+ return this.modifyValue(() => e, n);
1004
1067
  }
1005
- modifyValue(e, i) {
1006
- (i?.shouldTouch == null || i?.shouldTouch) && this.touch();
1007
- const n = S.getValue(
1008
- this.controller._initialData,
1009
- this.path
1010
- ), o = S.getValue(
1011
- this.controller._data,
1012
- this.path
1013
- );
1014
- x.ensureImmerability(n), x.ensureImmerability(o), this.controller._data = F(this.controller._data, (a) => {
1015
- S.modifyValue(
1016
- a,
1017
- this.path,
1018
- (r) => e(r, this)
1019
- );
1068
+ modifyValue(e, n) {
1069
+ (n?.shouldTouch == null || n?.shouldTouch) && this.touch();
1070
+ const i = this.controller.getAscendantFields(this.path), o = i.map((s) => s?.initialValue);
1071
+ o.forEach((s) => Y(s));
1072
+ const a = i.map((s) => s?.value);
1073
+ a.forEach((s) => Y(s)), this.controller._data = R(this.controller._data, (s) => {
1074
+ m.modifyValue(s, this.path, (r) => e(r));
1020
1075
  });
1021
- const c = S.getValue(
1022
- this.controller._data,
1023
- this.path
1024
- );
1025
- x.ensureImmerability(c);
1026
- const l = (a, r) => {
1027
- if (typeof a != "object" || typeof r != "object") return;
1028
- const s = a.constructor, f = r.constructor;
1029
- if (s === f)
1030
- return this.controller.equalityComparators?.[s]?.(a, r);
1076
+ const u = i.map((s) => s?.value);
1077
+ u.forEach((s) => Y(s));
1078
+ const h = (s, r) => {
1079
+ if (typeof s != "object" || typeof r != "object") return;
1080
+ const c = s.constructor, l = r.constructor;
1081
+ if (c === l)
1082
+ return this.controller.equalityComparators?.[c]?.(s, r);
1031
1083
  };
1032
- if (!S.deepEqual(o, c, l) && this.controller.events.emit(
1033
- "valueChanged",
1034
- this.path,
1035
- c,
1036
- o
1037
- ), i?.shouldMarkDirty == null || i?.shouldMarkDirty) {
1038
- const a = !S.deepEqual(n, c, l);
1039
- this._setDirty(a);
1084
+ if (!m.deepEqual(
1085
+ a[a.length - 1],
1086
+ u[u.length - 1],
1087
+ h
1088
+ ))
1089
+ for (let s = i.length - 1; s >= 0; s--) {
1090
+ const r = i[s];
1091
+ this.controller.events.emit(
1092
+ "valueChanged",
1093
+ r.path,
1094
+ u[s],
1095
+ a[s]
1096
+ );
1097
+ }
1098
+ if (n?.shouldMarkDirty == null || n?.shouldMarkDirty) {
1099
+ const s = !m.deepEqual(
1100
+ o[o.length - 1],
1101
+ u[u.length - 1],
1102
+ h
1103
+ );
1104
+ this._setDirty(s);
1040
1105
  }
1041
1106
  }
1042
1107
  reset() {
@@ -1057,29 +1122,29 @@ class x {
1057
1122
  }), this.target?.scrollIntoView(), this.target?.focus();
1058
1123
  }
1059
1124
  }
1060
- let ae = () => ({
1125
+ let ce = () => ({
1061
1126
  emit(t, ...e) {
1062
- for (let i = this.events[t] || [], n = 0, o = i.length; n < o; n++)
1063
- i[n](...e);
1127
+ for (let n = this.events[t] || [], i = 0, o = n.length; i < o; i++)
1128
+ n[i](...e);
1064
1129
  },
1065
1130
  events: {},
1066
1131
  on(t, e) {
1067
1132
  return (this.events[t] ||= []).push(e), () => {
1068
- this.events[t] = this.events[t]?.filter((i) => e !== i);
1133
+ this.events[t] = this.events[t]?.filter((n) => e !== n);
1069
1134
  };
1070
1135
  }
1071
1136
  });
1072
- function ce(t, e) {
1073
- let i = [];
1074
- for (let n = t.length - 1; n >= 0; n--)
1075
- e(t[n]) && i.push(n);
1076
- i.forEach((n) => t.splice(n, 1));
1137
+ function le(t, e) {
1138
+ let n = [];
1139
+ for (let i = t.length - 1; i >= 0; i--)
1140
+ e(t[i]) && n.push(i);
1141
+ n.forEach((i) => t.splice(i, 1));
1077
1142
  }
1078
- ie();
1079
1143
  ne();
1144
+ ie();
1080
1145
  class ue {
1081
1146
  constructor(e) {
1082
- this._status = "idle", this._fields = /* @__PURE__ */ new Map(), this._issues = [], this.events = ae(), this.validationSchema = e.validationSchema, this.equalityComparators = e.equalityComparators, this._initialData = e.initialData ?? {}, this._data = F(this._initialData, () => {
1147
+ this._isValidating = !1, this._isSubmitting = !1, this._fields = /* @__PURE__ */ new Map(), this._issues = [], this.events = ce(), this.validationSchema = e.validationSchema, this.equalityComparators = e.equalityComparators, this._initialData = e.initialData ?? {}, this._data = R(this._initialData, () => {
1083
1148
  });
1084
1149
  }
1085
1150
  get isDirty() {
@@ -1090,95 +1155,141 @@ class ue {
1090
1155
  get isValid() {
1091
1156
  return this._issues.length === 0;
1092
1157
  }
1158
+ get isValidating() {
1159
+ return this._isValidating;
1160
+ }
1093
1161
  get isSubmitting() {
1094
- return this._status === "submitting";
1095
- }
1096
- setStatus(e) {
1097
- if (e === this._status) return;
1098
- const i = this._status;
1099
- this._status = e, this.events.emit("statusChanged", e, i);
1100
- }
1101
- _unsafeSetFieldValue(e, i, n) {
1102
- n?.updateInitialValue && (this._initialData = F(this._initialData, (o) => {
1103
- S.setValue(o, e, i);
1104
- })), this._data = F(this._data, (o) => {
1105
- S.setValue(o, e, i);
1162
+ return this._isSubmitting;
1163
+ }
1164
+ setValidating(e) {
1165
+ this._isValidating !== e && (this._isValidating = e, this.events.emit("validationStatusChange", e));
1166
+ }
1167
+ setSubmitting(e) {
1168
+ this._isSubmitting !== e && (this._isSubmitting = e, this.events.emit("submissionStatusChange", e));
1169
+ }
1170
+ _unsafeSetFieldValue(e, n, i) {
1171
+ Y(n), i?.updateInitialValue === !0 && (this._initialData = R(this._initialData, (o) => {
1172
+ m.setValue(o, e, n);
1173
+ })), this._data = R(this._data, (o) => {
1174
+ m.setValue(o, e, n);
1106
1175
  });
1107
1176
  }
1108
- bindField(e, i) {
1109
- const n = new x(this, e);
1110
- return console.log("Binding", e, i?.defaultValue, n.id), this._fields.set(e, n), this.events.emit("fieldBound", e), i?.defaultValue != null && this._unsafeSetFieldValue(e, i.defaultValue, {
1111
- updateInitialValue: !0
1112
- }), i?.domElement != null && n.bindElement(i.domElement), n;
1177
+ // TODO: Rename to "register" ??
1178
+ bindField(e, n) {
1179
+ let i = m.getValue(this._data, e);
1180
+ i == null && n?.defaultValue != null && (this._unsafeSetFieldValue(e, n.defaultValue, {
1181
+ updateInitialValue: n.overrideInitialValue
1182
+ }), i = m.getValue(this._data, e));
1183
+ const o = m.getValue(this._initialData, e), a = new ae(this, e, {
1184
+ isDirty: !m.deepEqual(i, o)
1185
+ });
1186
+ return n?.domElement != null && a.bindElement(n.domElement), this._fields.set(e, a), this.events.emit("fieldBound", e), a;
1113
1187
  }
1114
1188
  unbindField(e) {
1115
1189
  this._fields.delete(e), this.events.emit("fieldUnbound", e);
1116
1190
  }
1117
1191
  // TODO: Add an option to keep dirty/touched fields as they are
1118
1192
  reset(e) {
1119
- this.setStatus("idle"), this._data = this._initialData, this._issues = [];
1120
- for (const i of this._fields.values())
1121
- i.reset();
1122
- e != null && (this._initialData = e, this._data = F(this._initialData, () => {
1193
+ this._data = this._initialData, this._issues = [];
1194
+ for (const n of this._fields.values())
1195
+ n.reset();
1196
+ e != null && (this._initialData = e, this._data = R(this._initialData, () => {
1123
1197
  }));
1124
1198
  }
1125
- getField(e, i) {
1126
- let n = this._fields.get(e);
1127
- return n == null && i?.bindIfMissing && (n = this.bindField(e)), n;
1199
+ getAscendantFields(e) {
1200
+ const n = m.parsePathFragments(e);
1201
+ return n.map((o, a) => m.parsePath(
1202
+ n.slice(0, a + 1)
1203
+ )).map((o) => this.getField(o)).filter((o) => !!o);
1204
+ }
1205
+ getField(e) {
1206
+ return this._fields.get(e);
1128
1207
  }
1129
1208
  clearFieldIssues(e) {
1130
- this._issues = this._issues.filter((i) => i.path == null ? !0 : i.path.join(".") !== e);
1209
+ this._issues = this._issues.filter((n) => n.path == null ? !0 : m.parsePath(n.path) !== e);
1131
1210
  }
1132
- async applyValidation(e, i) {
1133
- const n = S.diff(
1211
+ async applyValidation(e, n) {
1212
+ const i = m.diff(
1134
1213
  this._issues,
1135
1214
  e.issues ?? [],
1136
- S.deepEqual,
1137
- (o) => o.path == null ? !1 : o.path.join(".") === i
1215
+ m.deepEqual,
1216
+ (o) => {
1217
+ if (o.path == null) return !1;
1218
+ const a = m.parsePath(o.path);
1219
+ return a === n || m.isDescendant(n, a);
1220
+ }
1138
1221
  );
1139
- ce(this._issues, (o) => n.removed.includes(o)), n.added.forEach((o) => this._issues.push(o)), (n.added.length !== 0 || n.removed.length !== 0) && this.events.emit("validationIssuesUpdated", i);
1222
+ le(this._issues, (o) => i.removed.includes(o)), i.added.forEach((o) => this._issues.push(o)), (i.added.length !== 0 || i.removed.length !== 0) && this.events.emit("fieldIssuesUpdated", n);
1140
1223
  }
1141
1224
  async validateField(e) {
1142
- if (this._status !== "idle" || this.validationSchema == null) return;
1143
- this.setStatus("validating"), this.getField(e, { bindIfMissing: !0 });
1144
- const i = await this.validationSchema["~standard"].validate(
1225
+ if (this._isValidating || this.validationSchema == null) return;
1226
+ this.setValidating(!0), this.getField(e) == null && this.bindField(e);
1227
+ const n = await this.validationSchema["~standard"].validate(
1145
1228
  this._data
1146
1229
  );
1147
- this.events.emit("validationTriggered", e), this.applyValidation(i, e), this.setStatus("idle");
1230
+ this.events.emit("validationTriggered", e), this.applyValidation(n, e), this.setValidating(!1);
1148
1231
  }
1149
1232
  async validateForm() {
1150
- if (this._status !== "idle" || this.validationSchema == null) return;
1151
- this.setStatus("validating");
1233
+ if (this._isValidating || this.validationSchema == null) return;
1234
+ this.setValidating(!0);
1152
1235
  const e = await this.validationSchema["~standard"].validate(
1153
1236
  this._data
1154
1237
  );
1155
- for (const n of this._fields.keys())
1156
- this.events.emit("validationTriggered", n), this.applyValidation(e, n);
1157
- S.diff(this._issues, e.issues ?? [], S.deepEqual).added.forEach((n) => this._issues.push(n)), this.setStatus("idle");
1238
+ for (const i of this._fields.keys())
1239
+ this.events.emit("validationTriggered", i), this.applyValidation(e, i);
1240
+ m.diff(this._issues, e.issues ?? [], m.deepEqual).added.forEach((i) => this._issues.push(i)), this.setValidating(!1);
1158
1241
  }
1159
- createSubmitHandler(e, i) {
1160
- return async (n) => {
1161
- if (n?.preventDefault(), this._status !== "idle") return;
1242
+ createSubmitHandler(e, n) {
1243
+ return async (i) => {
1244
+ if (i?.preventDefault(), this._isValidating || this._isSubmitting) return;
1162
1245
  const o = new AbortController();
1163
1246
  if (await this.validateForm(), this._issues.length === 0) {
1164
- this.setStatus("submitting"), await e?.(this._data, n, o.signal), this.setStatus("idle");
1247
+ this.setSubmitting(!0), await e?.(this._data, i, o.signal), this.setSubmitting(!1);
1165
1248
  return;
1166
1249
  }
1167
- for (const c of this._issues) {
1168
- if (c.path == null) continue;
1169
- const l = c.path.join("."), u = this.getField(l);
1170
- if (u != null && u.boundElement != null) {
1171
- u.focus();
1250
+ for (const a of this._issues) {
1251
+ if (a.path == null) continue;
1252
+ const u = m.parsePath(a.path), h = this.getField(u);
1253
+ if (h != null && h.boundElement != null) {
1254
+ h.focus();
1172
1255
  break;
1173
1256
  }
1174
1257
  }
1175
- await i?.(this._issues, n, o.signal), this.setStatus("idle");
1258
+ await n?.(this._issues, i, o.signal), this.setSubmitting(!1);
1176
1259
  };
1177
1260
  }
1178
1261
  }
1262
+ function fe(t) {
1263
+ return {
1264
+ "~standard": {
1265
+ version: 1,
1266
+ vendor: "goodie-forms/custom",
1267
+ validate: async (e) => {
1268
+ try {
1269
+ const n = await t(e);
1270
+ return n == null ? { value: e } : {
1271
+ issues: n.map((i) => ({
1272
+ path: m.parsePathFragments(i.path),
1273
+ message: i.message
1274
+ }))
1275
+ };
1276
+ } catch (n) {
1277
+ return {
1278
+ issues: [
1279
+ {
1280
+ message: n instanceof Error ? n.message : "Unknown error"
1281
+ }
1282
+ ]
1283
+ };
1284
+ }
1285
+ }
1286
+ }
1287
+ };
1288
+ }
1179
1289
  export {
1180
- S as Field,
1290
+ m as Field,
1181
1291
  ue as FormController,
1182
- x as FormField
1292
+ ae as FormField,
1293
+ fe as customValidation
1183
1294
  };
1184
1295
  //# sourceMappingURL=index.js.map