@hot-updater/console 0.28.0 → 0.29.1

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 (93) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/apple-touch-icon.png +0 -0
  3. package/.output/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  4. package/.output/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  5. package/.output/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  6. package/.output/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  7. package/.output/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  8. package/.output/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  9. package/.output/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  10. package/.output/public/assets/main-Dlx8-qN-.js +61 -0
  11. package/.output/public/assets/routes-DB0tWmiJ.js +10 -0
  12. package/.output/public/assets/styles-Bfxg4M1x.css +2 -0
  13. package/.output/public/favicon-16x16.png +0 -0
  14. package/.output/public/favicon-32x32.png +0 -0
  15. package/.output/public/favicon.ico +0 -0
  16. package/.output/public/logo.svg +1 -0
  17. package/.output/public/manifest.json +30 -0
  18. package/.output/public/robots.txt +3 -0
  19. package/.output/server/_chunks/ssr-renderer.mjs +15 -0
  20. package/.output/server/_libs/@floating-ui/core+[...].mjs +698 -0
  21. package/.output/server/_libs/@floating-ui/dom+[...].mjs +644 -0
  22. package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +839 -0
  23. package/.output/server/_libs/@radix-ui/react-alert-dialog+[...].mjs +2093 -0
  24. package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +287 -0
  25. package/.output/server/_libs/@radix-ui/react-select+[...].mjs +1003 -0
  26. package/.output/server/_libs/@tanstack/devtools-event-client+[...].mjs +196 -0
  27. package/.output/server/_libs/@tanstack/form-core+[...].mjs +2396 -0
  28. package/.output/server/_libs/@tanstack/react-form+[...].mjs +298 -0
  29. package/.output/server/_libs/@tanstack/react-router+[...].mjs +13068 -0
  30. package/.output/server/_libs/@tanstack/react-table+[...].mjs +2372 -0
  31. package/.output/server/_libs/chownr.mjs +60 -0
  32. package/.output/server/_libs/class-variance-authority+clsx.mjs +69 -0
  33. package/.output/server/_libs/core-util-is.mjs +67 -0
  34. package/.output/server/_libs/dayjs.mjs +408 -0
  35. package/.output/server/_libs/h3+rou3+srvx.mjs +1158 -0
  36. package/.output/server/_libs/hookable.mjs +41 -0
  37. package/.output/server/_libs/immediate.mjs +57 -0
  38. package/.output/server/_libs/inherits.mjs +39 -0
  39. package/.output/server/_libs/isaacs__fs-minipass+minipass.mjs +1120 -0
  40. package/.output/server/_libs/isarray.mjs +10 -0
  41. package/.output/server/_libs/jszip+[...].mjs +8311 -0
  42. package/.output/server/_libs/lucide-react.mjs +371 -0
  43. package/.output/server/_libs/minizlib.mjs +345 -0
  44. package/.output/server/_libs/next-themes.mjs +49 -0
  45. package/.output/server/_libs/radix-ui__number.mjs +6 -0
  46. package/.output/server/_libs/radix-ui__primitive.mjs +9 -0
  47. package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
  48. package/.output/server/_libs/radix-ui__react-collection.mjs +78 -0
  49. package/.output/server/_libs/radix-ui__react-direction.mjs +11 -0
  50. package/.output/server/_libs/radix-ui__react-label.mjs +22 -0
  51. package/.output/server/_libs/radix-ui__react-separator.mjs +31 -0
  52. package/.output/server/_libs/radix-ui__react-slider.mjs +451 -0
  53. package/.output/server/_libs/radix-ui__react-switch.mjs +118 -0
  54. package/.output/server/_libs/radix-ui__react-tooltip.mjs +491 -0
  55. package/.output/server/_libs/semver.mjs +1339 -0
  56. package/.output/server/_libs/sonner.mjs +908 -0
  57. package/.output/server/_libs/tailwind-merge.mjs +1962 -0
  58. package/.output/server/_libs/tanstack__history.mjs +322 -0
  59. package/.output/server/_libs/tanstack__query-core.mjs +2073 -0
  60. package/.output/server/_libs/tanstack__react-query.mjs +146 -0
  61. package/.output/server/_libs/tanstack__router-core.mjs +6 -0
  62. package/.output/server/_libs/tar.mjs +1996 -0
  63. package/.output/server/_libs/ufo.mjs +64 -0
  64. package/.output/server/_runtime.mjs +26 -0
  65. package/.output/server/_ssr/api-rpc-D3ZehMIN.mjs +217 -0
  66. package/.output/server/_ssr/config.server-JUYQ7UbI.mjs +26 -0
  67. package/.output/server/_ssr/deleteBundle-DWUxu9-K.mjs +22 -0
  68. package/.output/server/_ssr/extract-timestamp-from-uuidv7-B90UBADU.mjs +24 -0
  69. package/.output/server/_ssr/promoteBundle-DtMHuubR.mjs +1571 -0
  70. package/.output/server/_ssr/router-pgc7NX76.mjs +250 -0
  71. package/.output/server/_ssr/routes-PqTTQSoI.mjs +1833 -0
  72. package/.output/server/_ssr/sidebar-DXng0IOP.mjs +439 -0
  73. package/.output/server/_ssr/ssr.mjs +5050 -0
  74. package/.output/server/_ssr/start-DQK0r85G.mjs +4 -0
  75. package/.output/server/_tanstack-start-manifest_v-DTbQVOpU.mjs +17 -0
  76. package/.output/server/index.mjs +417 -0
  77. package/.output/server/node_modules/tslib/modules/index.js +70 -0
  78. package/.output/server/node_modules/tslib/modules/package.json +3 -0
  79. package/.output/server/node_modules/tslib/package.json +47 -0
  80. package/.output/server/node_modules/tslib/tslib.js +484 -0
  81. package/.output/server/package.json +9 -0
  82. package/README.md +191 -2
  83. package/package.json +77 -50
  84. package/dist/.gitkeep +0 -0
  85. package/dist/assets/favicon-BkwcEHsj.ico +0 -0
  86. package/dist/assets/index-DUlKsori.css +0 -1
  87. package/dist/assets/index-ijmIcyn1.js +0 -27
  88. package/dist/assets/logo-BYNFyja1.png +0 -0
  89. package/dist/index.cjs +0 -2129
  90. package/dist/index.d.cts +0 -218
  91. package/dist/index.d.ts +0 -218
  92. package/dist/index.html +0 -14
  93. package/dist/index.js +0 -2125
@@ -0,0 +1,2396 @@
1
+ import { t as EventClient } from "./devtools-event-client+[...].mjs";
2
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/alien.js
3
+ var ReactiveFlags = /* @__PURE__ */ ((ReactiveFlags2) => {
4
+ ReactiveFlags2[ReactiveFlags2["None"] = 0] = "None";
5
+ ReactiveFlags2[ReactiveFlags2["Mutable"] = 1] = "Mutable";
6
+ ReactiveFlags2[ReactiveFlags2["Watching"] = 2] = "Watching";
7
+ ReactiveFlags2[ReactiveFlags2["RecursedCheck"] = 4] = "RecursedCheck";
8
+ ReactiveFlags2[ReactiveFlags2["Recursed"] = 8] = "Recursed";
9
+ ReactiveFlags2[ReactiveFlags2["Dirty"] = 16] = "Dirty";
10
+ ReactiveFlags2[ReactiveFlags2["Pending"] = 32] = "Pending";
11
+ return ReactiveFlags2;
12
+ })(ReactiveFlags || {});
13
+ function createReactiveSystem({ update, notify, unwatched }) {
14
+ return {
15
+ link: link2,
16
+ unlink: unlink2,
17
+ propagate: propagate2,
18
+ checkDirty: checkDirty2,
19
+ shallowPropagate: shallowPropagate2
20
+ };
21
+ function link2(dep, sub, version) {
22
+ const prevDep = sub.depsTail;
23
+ if (prevDep !== void 0 && prevDep.dep === dep) return;
24
+ const nextDep = prevDep !== void 0 ? prevDep.nextDep : sub.deps;
25
+ if (nextDep !== void 0 && nextDep.dep === dep) {
26
+ nextDep.version = version;
27
+ sub.depsTail = nextDep;
28
+ return;
29
+ }
30
+ const prevSub = dep.subsTail;
31
+ if (prevSub !== void 0 && prevSub.version === version && prevSub.sub === sub) return;
32
+ const newLink = sub.depsTail = dep.subsTail = {
33
+ version,
34
+ dep,
35
+ sub,
36
+ prevDep,
37
+ nextDep,
38
+ prevSub,
39
+ nextSub: void 0
40
+ };
41
+ if (nextDep !== void 0) nextDep.prevDep = newLink;
42
+ if (prevDep !== void 0) prevDep.nextDep = newLink;
43
+ else sub.deps = newLink;
44
+ if (prevSub !== void 0) prevSub.nextSub = newLink;
45
+ else dep.subs = newLink;
46
+ }
47
+ function unlink2(link3, sub = link3.sub) {
48
+ const dep = link3.dep;
49
+ const prevDep = link3.prevDep;
50
+ const nextDep = link3.nextDep;
51
+ const nextSub = link3.nextSub;
52
+ const prevSub = link3.prevSub;
53
+ if (nextDep !== void 0) nextDep.prevDep = prevDep;
54
+ else sub.depsTail = prevDep;
55
+ if (prevDep !== void 0) prevDep.nextDep = nextDep;
56
+ else sub.deps = nextDep;
57
+ if (nextSub !== void 0) nextSub.prevSub = prevSub;
58
+ else dep.subsTail = prevSub;
59
+ if (prevSub !== void 0) prevSub.nextSub = nextSub;
60
+ else if ((dep.subs = nextSub) === void 0) unwatched(dep);
61
+ return nextDep;
62
+ }
63
+ function propagate2(link3) {
64
+ let next = link3.nextSub;
65
+ let stack;
66
+ top: do {
67
+ const sub = link3.sub;
68
+ let flags = sub.flags;
69
+ if (!(flags & 60)) sub.flags = flags | 32;
70
+ else if (!(flags & 12)) flags = 0;
71
+ else if (!(flags & 4)) sub.flags = flags & -9 | 32;
72
+ else if (!(flags & 48) && isValidLink(link3, sub)) {
73
+ sub.flags = flags | 40;
74
+ flags &= 1;
75
+ } else flags = 0;
76
+ if (flags & 2) notify(sub);
77
+ if (flags & 1) {
78
+ const subSubs = sub.subs;
79
+ if (subSubs !== void 0) {
80
+ const nextSub = (link3 = subSubs).nextSub;
81
+ if (nextSub !== void 0) {
82
+ stack = {
83
+ value: next,
84
+ prev: stack
85
+ };
86
+ next = nextSub;
87
+ }
88
+ continue;
89
+ }
90
+ }
91
+ if ((link3 = next) !== void 0) {
92
+ next = link3.nextSub;
93
+ continue;
94
+ }
95
+ while (stack !== void 0) {
96
+ link3 = stack.value;
97
+ stack = stack.prev;
98
+ if (link3 !== void 0) {
99
+ next = link3.nextSub;
100
+ continue top;
101
+ }
102
+ }
103
+ break;
104
+ } while (true);
105
+ }
106
+ function checkDirty2(link3, sub) {
107
+ let stack;
108
+ let checkDepth = 0;
109
+ let dirty = false;
110
+ top: do {
111
+ const dep = link3.dep;
112
+ const flags = dep.flags;
113
+ if (sub.flags & 16) dirty = true;
114
+ else if ((flags & 17) === 17) {
115
+ if (update(dep)) {
116
+ const subs = dep.subs;
117
+ if (subs.nextSub !== void 0) shallowPropagate2(subs);
118
+ dirty = true;
119
+ }
120
+ } else if ((flags & 33) === 33) {
121
+ if (link3.nextSub !== void 0 || link3.prevSub !== void 0) stack = {
122
+ value: link3,
123
+ prev: stack
124
+ };
125
+ link3 = dep.deps;
126
+ sub = dep;
127
+ ++checkDepth;
128
+ continue;
129
+ }
130
+ if (!dirty) {
131
+ const nextDep = link3.nextDep;
132
+ if (nextDep !== void 0) {
133
+ link3 = nextDep;
134
+ continue;
135
+ }
136
+ }
137
+ while (checkDepth--) {
138
+ const firstSub = sub.subs;
139
+ const hasMultipleSubs = firstSub.nextSub !== void 0;
140
+ if (hasMultipleSubs) {
141
+ link3 = stack.value;
142
+ stack = stack.prev;
143
+ } else link3 = firstSub;
144
+ if (dirty) {
145
+ if (update(sub)) {
146
+ if (hasMultipleSubs) shallowPropagate2(firstSub);
147
+ sub = link3.sub;
148
+ continue;
149
+ }
150
+ dirty = false;
151
+ } else sub.flags &= -33;
152
+ sub = link3.sub;
153
+ const nextDep = link3.nextDep;
154
+ if (nextDep !== void 0) {
155
+ link3 = nextDep;
156
+ continue top;
157
+ }
158
+ }
159
+ return dirty;
160
+ } while (true);
161
+ }
162
+ function shallowPropagate2(link3) {
163
+ do {
164
+ const sub = link3.sub;
165
+ const flags = sub.flags;
166
+ if ((flags & 48) === 32) {
167
+ sub.flags = flags | 16;
168
+ if ((flags & 6) === 2) notify(sub);
169
+ }
170
+ } while ((link3 = link3.nextSub) !== void 0);
171
+ }
172
+ function isValidLink(checkLink, sub) {
173
+ let link3 = sub.depsTail;
174
+ while (link3 !== void 0) {
175
+ if (link3 === checkLink) return true;
176
+ link3 = link3.prevDep;
177
+ }
178
+ return false;
179
+ }
180
+ }
181
+ var batchDepth = 0;
182
+ var notifyIndex$1 = 0;
183
+ var queuedLength = 0;
184
+ var queued = [];
185
+ var { link: link$1, unlink: unlink$1, propagate: propagate$1, checkDirty: checkDirty$1, shallowPropagate: shallowPropagate$1 } = createReactiveSystem({
186
+ update(node) {
187
+ if (node.depsTail !== void 0) return updateComputed(node);
188
+ else return updateSignal(node);
189
+ },
190
+ notify(effect2) {
191
+ let insertIndex = queuedLength;
192
+ let firstInsertedIndex = insertIndex;
193
+ do {
194
+ queued[insertIndex++] = effect2;
195
+ effect2.flags &= -3;
196
+ effect2 = effect2.subs?.sub;
197
+ if (effect2 === void 0 || !(effect2.flags & 2)) break;
198
+ } while (true);
199
+ queuedLength = insertIndex;
200
+ while (firstInsertedIndex < --insertIndex) {
201
+ const left = queued[firstInsertedIndex];
202
+ queued[firstInsertedIndex++] = queued[insertIndex];
203
+ queued[insertIndex] = left;
204
+ }
205
+ },
206
+ unwatched(node) {
207
+ if (!(node.flags & 1)) effectScopeOper.call(node);
208
+ else if (node.depsTail !== void 0) {
209
+ node.depsTail = void 0;
210
+ node.flags = 17;
211
+ purgeDeps$1(node);
212
+ }
213
+ }
214
+ });
215
+ function getBatchDepth() {
216
+ return batchDepth;
217
+ }
218
+ function startBatch() {
219
+ ++batchDepth;
220
+ }
221
+ function endBatch() {
222
+ if (!--batchDepth) flush$1();
223
+ }
224
+ function updateComputed(c) {
225
+ c.depsTail = void 0;
226
+ c.flags = 5;
227
+ try {
228
+ const oldValue = c.value;
229
+ return oldValue !== (c.value = c.getter(oldValue));
230
+ } finally {
231
+ c.flags &= -5;
232
+ purgeDeps$1(c);
233
+ }
234
+ }
235
+ function updateSignal(s) {
236
+ s.flags = 1;
237
+ return s.currentValue !== (s.currentValue = s.pendingValue);
238
+ }
239
+ function run(e) {
240
+ const flags = e.flags;
241
+ if (flags & 16 || flags & 32 && checkDirty$1(e.deps, e)) {
242
+ e.depsTail = void 0;
243
+ e.flags = 6;
244
+ try {
245
+ e.fn();
246
+ } finally {
247
+ e.flags &= -5;
248
+ purgeDeps$1(e);
249
+ }
250
+ } else e.flags = 2;
251
+ }
252
+ function flush$1() {
253
+ try {
254
+ while (notifyIndex$1 < queuedLength) {
255
+ const effect2 = queued[notifyIndex$1];
256
+ queued[notifyIndex$1++] = void 0;
257
+ run(effect2);
258
+ }
259
+ } finally {
260
+ while (notifyIndex$1 < queuedLength) {
261
+ const effect2 = queued[notifyIndex$1];
262
+ queued[notifyIndex$1++] = void 0;
263
+ effect2.flags |= 10;
264
+ }
265
+ notifyIndex$1 = 0;
266
+ queuedLength = 0;
267
+ }
268
+ }
269
+ function effectScopeOper() {
270
+ this.depsTail = void 0;
271
+ this.flags = 0;
272
+ purgeDeps$1(this);
273
+ const sub = this.subs;
274
+ if (sub !== void 0) unlink$1(sub);
275
+ }
276
+ function purgeDeps$1(sub) {
277
+ const depsTail = sub.depsTail;
278
+ let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
279
+ while (dep !== void 0) dep = unlink$1(dep, sub);
280
+ }
281
+ //#endregion
282
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/atom.js
283
+ function toObserver(nextHandler, errorHandler, completionHandler) {
284
+ const isObserver = typeof nextHandler === "object";
285
+ const self = isObserver ? nextHandler : void 0;
286
+ return {
287
+ next: (isObserver ? nextHandler.next : nextHandler)?.bind(self),
288
+ error: (isObserver ? nextHandler.error : errorHandler)?.bind(self),
289
+ complete: (isObserver ? nextHandler.complete : completionHandler)?.bind(self)
290
+ };
291
+ }
292
+ var queuedEffects = [];
293
+ var cycle = 0;
294
+ var { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSystem({
295
+ update(atom) {
296
+ return atom._update();
297
+ },
298
+ notify(effect2) {
299
+ queuedEffects[queuedEffectsLength++] = effect2;
300
+ effect2.flags &= ~ReactiveFlags.Watching;
301
+ },
302
+ unwatched(atom) {
303
+ if (atom.depsTail !== void 0) {
304
+ atom.depsTail = void 0;
305
+ atom.flags = ReactiveFlags.Mutable | ReactiveFlags.Dirty;
306
+ purgeDeps(atom);
307
+ }
308
+ }
309
+ });
310
+ var notifyIndex = 0;
311
+ var queuedEffectsLength = 0;
312
+ var activeSub;
313
+ function purgeDeps(sub) {
314
+ const depsTail = sub.depsTail;
315
+ let dep = depsTail !== void 0 ? depsTail.nextDep : sub.deps;
316
+ while (dep !== void 0) dep = unlink(dep, sub);
317
+ }
318
+ function flush() {
319
+ if (getBatchDepth() > 0) return;
320
+ while (notifyIndex < queuedEffectsLength) {
321
+ const effect2 = queuedEffects[notifyIndex];
322
+ queuedEffects[notifyIndex++] = void 0;
323
+ effect2.notify();
324
+ }
325
+ notifyIndex = 0;
326
+ queuedEffectsLength = 0;
327
+ }
328
+ function createAtom(valueOrFn, options) {
329
+ const isComputed = typeof valueOrFn === "function";
330
+ const getter = valueOrFn;
331
+ const atom = {
332
+ _snapshot: isComputed ? void 0 : valueOrFn,
333
+ subs: void 0,
334
+ subsTail: void 0,
335
+ deps: void 0,
336
+ depsTail: void 0,
337
+ flags: isComputed ? ReactiveFlags.None : ReactiveFlags.Mutable,
338
+ get() {
339
+ if (activeSub !== void 0) link(atom, activeSub, cycle);
340
+ return atom._snapshot;
341
+ },
342
+ subscribe(observerOrFn) {
343
+ const obs = toObserver(observerOrFn);
344
+ const observed = { current: false };
345
+ const e = effect(() => {
346
+ atom.get();
347
+ if (!observed.current) observed.current = true;
348
+ else obs.next?.(atom._snapshot);
349
+ });
350
+ return { unsubscribe: () => {
351
+ e.stop();
352
+ } };
353
+ },
354
+ _update(getValue) {
355
+ const prevSub = activeSub;
356
+ const compare = options?.compare ?? Object.is;
357
+ if (isComputed) {
358
+ activeSub = atom;
359
+ ++cycle;
360
+ atom.depsTail = void 0;
361
+ } else if (getValue === void 0) return false;
362
+ if (isComputed) atom.flags = ReactiveFlags.Mutable | ReactiveFlags.RecursedCheck;
363
+ try {
364
+ const oldValue = atom._snapshot;
365
+ const newValue = typeof getValue === "function" ? getValue(oldValue) : getValue === void 0 && isComputed ? getter(oldValue) : getValue;
366
+ if (oldValue === void 0 || !compare(oldValue, newValue)) {
367
+ atom._snapshot = newValue;
368
+ return true;
369
+ }
370
+ return false;
371
+ } finally {
372
+ activeSub = prevSub;
373
+ if (isComputed) atom.flags &= ~ReactiveFlags.RecursedCheck;
374
+ purgeDeps(atom);
375
+ }
376
+ }
377
+ };
378
+ if (isComputed) {
379
+ atom.flags = ReactiveFlags.Mutable | ReactiveFlags.Dirty;
380
+ atom.get = function() {
381
+ const flags = atom.flags;
382
+ if (flags & ReactiveFlags.Dirty || flags & ReactiveFlags.Pending && checkDirty(atom.deps, atom)) {
383
+ if (atom._update()) {
384
+ const subs = atom.subs;
385
+ if (subs !== void 0) shallowPropagate(subs);
386
+ }
387
+ } else if (flags & ReactiveFlags.Pending) atom.flags = flags & ~ReactiveFlags.Pending;
388
+ if (activeSub !== void 0) link(atom, activeSub, cycle);
389
+ return atom._snapshot;
390
+ };
391
+ } else atom.set = function(valueOrFn2) {
392
+ if (atom._update(valueOrFn2)) {
393
+ const subs = atom.subs;
394
+ if (subs !== void 0) {
395
+ propagate(subs);
396
+ shallowPropagate(subs);
397
+ flush();
398
+ }
399
+ }
400
+ };
401
+ return atom;
402
+ }
403
+ function effect(fn) {
404
+ const run = () => {
405
+ const prevSub = activeSub;
406
+ activeSub = effectObj;
407
+ ++cycle;
408
+ effectObj.depsTail = void 0;
409
+ effectObj.flags = ReactiveFlags.Watching | ReactiveFlags.RecursedCheck;
410
+ try {
411
+ return fn();
412
+ } finally {
413
+ activeSub = prevSub;
414
+ effectObj.flags &= ~ReactiveFlags.RecursedCheck;
415
+ purgeDeps(effectObj);
416
+ }
417
+ };
418
+ const effectObj = {
419
+ deps: void 0,
420
+ depsTail: void 0,
421
+ subs: void 0,
422
+ subsTail: void 0,
423
+ flags: ReactiveFlags.Watching | ReactiveFlags.RecursedCheck,
424
+ notify() {
425
+ const flags = this.flags;
426
+ if (flags & ReactiveFlags.Dirty || flags & ReactiveFlags.Pending && checkDirty(this.deps, this)) run();
427
+ else this.flags = ReactiveFlags.Watching;
428
+ },
429
+ stop() {
430
+ this.flags = ReactiveFlags.None;
431
+ this.depsTail = void 0;
432
+ purgeDeps(this);
433
+ }
434
+ };
435
+ run();
436
+ return effectObj;
437
+ }
438
+ //#endregion
439
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/store.js
440
+ var Store = class {
441
+ constructor(valueOrFn) {
442
+ this.atom = createAtom(valueOrFn);
443
+ }
444
+ setState(updater) {
445
+ this.atom.set(updater);
446
+ }
447
+ get state() {
448
+ return this.atom.get();
449
+ }
450
+ get() {
451
+ return this.state;
452
+ }
453
+ subscribe(observerOrFn) {
454
+ return this.atom.subscribe(toObserver(observerOrFn));
455
+ }
456
+ };
457
+ var ReadonlyStore = class {
458
+ constructor(valueOrFn) {
459
+ this.atom = createAtom(valueOrFn);
460
+ }
461
+ get state() {
462
+ return this.atom.get();
463
+ }
464
+ get() {
465
+ return this.state;
466
+ }
467
+ subscribe(observerOrFn) {
468
+ return this.atom.subscribe(toObserver(observerOrFn));
469
+ }
470
+ };
471
+ function createStore(valueOrFn) {
472
+ if (typeof valueOrFn === "function") return new ReadonlyStore(valueOrFn);
473
+ return new Store(valueOrFn);
474
+ }
475
+ //#endregion
476
+ //#region ../../node_modules/.pnpm/@tanstack+store@0.9.2/node_modules/@tanstack/store/dist/esm/batch.js
477
+ function batch(fn) {
478
+ try {
479
+ startBatch();
480
+ fn();
481
+ } finally {
482
+ endBatch();
483
+ flush();
484
+ }
485
+ }
486
+ //#endregion
487
+ //#region ../../node_modules/.pnpm/@tanstack+pacer-lite@0.1.1/node_modules/@tanstack/pacer-lite/dist/lite-throttler.js
488
+ /**
489
+ * A lightweight class that creates a throttled function.
490
+ *
491
+ * This is an alternative to the Throttler in the core @tanstack/pacer package, but is more
492
+ * suitable for libraries and npm packages that need minimal overhead. Unlike the core Throttler,
493
+ * this version does not use TanStack Store for state management, has no devtools integration,
494
+ * and provides only essential throttling functionality.
495
+ *
496
+ * Throttling ensures a function is called at most once within a specified time window.
497
+ * Unlike debouncing which waits for a pause in calls, throttling guarantees consistent
498
+ * execution timing regardless of call frequency.
499
+ *
500
+ * Supports both leading and trailing edge execution:
501
+ * - Leading: Execute immediately on first call (default: true)
502
+ * - Trailing: Execute after wait period if called during throttle (default: true)
503
+ *
504
+ * Features:
505
+ * - Zero dependencies - no external libraries required
506
+ * - Minimal API surface - only essential methods (maybeExecute, flush, cancel)
507
+ * - Simple state management - uses basic private properties instead of reactive stores
508
+ * - Callback support for monitoring execution events
509
+ * - Lightweight - designed for use in npm packages where bundle size matters
510
+ *
511
+ * @example
512
+ * ```ts
513
+ * const throttler = new LiteThrottler((scrollY: number) => {
514
+ * updateScrollPosition(scrollY);
515
+ * }, {
516
+ * wait: 100,
517
+ * onExecute: (args, throttler) => {
518
+ * console.log('Updated scroll position:', args[0]);
519
+ * }
520
+ * });
521
+ *
522
+ * // Will execute at most once per 100ms
523
+ * window.addEventListener('scroll', () => {
524
+ * throttler.maybeExecute(window.scrollY);
525
+ * });
526
+ * ```
527
+ */
528
+ var LiteThrottler = class {
529
+ constructor(fn, options) {
530
+ this.fn = fn;
531
+ this.options = options;
532
+ this.lastExecutionTime = 0;
533
+ this.isPending = false;
534
+ this.maybeExecute = (...args) => {
535
+ const timeSinceLastExecution = Date.now() - this.lastExecutionTime;
536
+ if (this.options.leading && timeSinceLastExecution >= this.options.wait) this.execute(...args);
537
+ else {
538
+ this.lastArgs = args;
539
+ if (!this.timeoutId && this.options.trailing) {
540
+ const timeoutDuration = this.options.wait - timeSinceLastExecution;
541
+ this.isPending = true;
542
+ this.timeoutId = setTimeout(() => {
543
+ if (this.lastArgs !== void 0) this.execute(...this.lastArgs);
544
+ }, timeoutDuration);
545
+ }
546
+ }
547
+ };
548
+ this.execute = (...args) => {
549
+ this.fn(...args);
550
+ this.options.onExecute?.(args, this);
551
+ this.lastExecutionTime = Date.now();
552
+ this.clearTimeout();
553
+ this.lastArgs = void 0;
554
+ this.isPending = false;
555
+ };
556
+ this.flush = () => {
557
+ if (this.isPending && this.lastArgs) this.execute(...this.lastArgs);
558
+ };
559
+ this.cancel = () => {
560
+ this.clearTimeout();
561
+ this.lastArgs = void 0;
562
+ this.isPending = false;
563
+ };
564
+ this.clearTimeout = () => {
565
+ if (this.timeoutId) {
566
+ clearTimeout(this.timeoutId);
567
+ this.timeoutId = void 0;
568
+ }
569
+ };
570
+ if (this.options.leading === void 0 && this.options.trailing === void 0) {
571
+ this.options.leading = true;
572
+ this.options.trailing = true;
573
+ }
574
+ }
575
+ };
576
+ /**
577
+ * Creates a lightweight throttled function that limits how often the provided function can execute.
578
+ *
579
+ * This is an alternative to the throttle function in the core @tanstack/pacer package, but is more
580
+ * suitable for libraries and npm packages that need minimal overhead. Unlike the core version,
581
+ * this function creates a throttler with no external dependencies, devtools integration, or reactive state.
582
+ *
583
+ * Throttling ensures a function executes at most once within a specified time window,
584
+ * regardless of how many times it is called. This is useful for rate-limiting
585
+ * expensive operations or UI updates.
586
+ *
587
+ * @example
588
+ * ```ts
589
+ * const throttledScroll = liteThrottle(() => {
590
+ * updateScrollIndicator();
591
+ * }, { wait: 100 });
592
+ *
593
+ * // Will execute at most once per 100ms
594
+ * window.addEventListener('scroll', throttledScroll);
595
+ * ```
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * // Leading edge execution - fires immediately then throttles
600
+ * const throttledResize = liteThrottle(() => {
601
+ * recalculateLayout();
602
+ * }, { wait: 250, leading: true, trailing: false });
603
+ * ```
604
+ */
605
+ function liteThrottle(fn, options) {
606
+ return new LiteThrottler(fn, options).maybeExecute;
607
+ }
608
+ //#endregion
609
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/EventClient.js
610
+ var FormEventClient = class extends EventClient {
611
+ constructor() {
612
+ super({
613
+ pluginId: "form-devtools",
614
+ reconnectEveryMs: 1e3
615
+ });
616
+ }
617
+ };
618
+ var formEventClient = new FormEventClient();
619
+ //#endregion
620
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/utils.js
621
+ function functionalUpdate(updater, input) {
622
+ return typeof updater === "function" ? updater(input) : updater;
623
+ }
624
+ function getBy(obj, path) {
625
+ return makePathArray(path).reduce((current, pathPart) => {
626
+ if (current === null) return null;
627
+ if (typeof current !== "undefined") return current[pathPart];
628
+ }, obj);
629
+ }
630
+ function setBy(obj, _path, updater) {
631
+ const path = makePathArray(_path);
632
+ function doSet(parent) {
633
+ if (!path.length) return functionalUpdate(updater, parent);
634
+ const key = path.shift();
635
+ if (typeof key === "string" || typeof key === "number" && !Array.isArray(parent)) {
636
+ if (typeof parent === "object") {
637
+ if (parent === null) parent = {};
638
+ return {
639
+ ...parent,
640
+ [key]: doSet(parent[key])
641
+ };
642
+ }
643
+ return { [key]: doSet() };
644
+ }
645
+ if (Array.isArray(parent) && typeof key === "number") {
646
+ const prefix = parent.slice(0, key);
647
+ return [
648
+ ...prefix.length ? prefix : new Array(key),
649
+ doSet(parent[key]),
650
+ ...parent.slice(key + 1)
651
+ ];
652
+ }
653
+ return [...new Array(key), doSet()];
654
+ }
655
+ return doSet(obj);
656
+ }
657
+ function deleteBy(obj, _path) {
658
+ const path = makePathArray(_path);
659
+ function doDelete(parent) {
660
+ if (!parent) return;
661
+ if (path.length === 1) {
662
+ const finalPath = path[0];
663
+ if (Array.isArray(parent) && typeof finalPath === "number") return parent.filter((_, i) => i !== finalPath);
664
+ const { [finalPath]: remove, ...rest } = parent;
665
+ return rest;
666
+ }
667
+ const key = path.shift();
668
+ if (typeof key === "string" || typeof key === "number" && !Array.isArray(parent)) {
669
+ if (typeof parent === "object") return {
670
+ ...parent,
671
+ [key]: doDelete(parent[key])
672
+ };
673
+ }
674
+ if (typeof key === "number") {
675
+ if (Array.isArray(parent)) {
676
+ if (key >= parent.length) return parent;
677
+ const prefix = parent.slice(0, key);
678
+ return [
679
+ ...prefix.length ? prefix : new Array(key),
680
+ doDelete(parent[key]),
681
+ ...parent.slice(key + 1)
682
+ ];
683
+ }
684
+ }
685
+ throw new Error("It seems we have created an infinite loop in deleteBy. ");
686
+ }
687
+ return doDelete(obj);
688
+ }
689
+ var reLineOfOnlyDigits = /^(\d+)$/gm;
690
+ var reDigitsBetweenDots = /\.(\d+)(?=\.)/gm;
691
+ var reStartWithDigitThenDot = /^(\d+)\./gm;
692
+ var reDotWithDigitsToEnd = /\.(\d+$)/gm;
693
+ var reMultipleDots = /\.{2,}/gm;
694
+ var intPrefix = "__int__";
695
+ var intReplace = `${intPrefix}$1`;
696
+ function makePathArray(str) {
697
+ if (Array.isArray(str)) return [...str];
698
+ if (typeof str !== "string") throw new Error("Path must be a string.");
699
+ return str.replace(/(^\[)|]/gm, "").replace(/\[/g, ".").replace(reLineOfOnlyDigits, intReplace).replace(reDigitsBetweenDots, `.${intReplace}.`).replace(reStartWithDigitThenDot, `${intReplace}.`).replace(reDotWithDigitsToEnd, `.${intReplace}`).replace(reMultipleDots, ".").split(".").map((d) => {
700
+ if (d.startsWith(intPrefix)) {
701
+ const numStr = d.substring(7);
702
+ const num = parseInt(numStr, 10);
703
+ if (String(num) === numStr) return num;
704
+ return numStr;
705
+ }
706
+ return d;
707
+ });
708
+ }
709
+ function isNonEmptyArray(obj) {
710
+ return !(Array.isArray(obj) && obj.length === 0);
711
+ }
712
+ function getSyncValidatorArray(cause, options) {
713
+ const runValidation = (props) => {
714
+ return props.validators.filter(Boolean).map((validator) => {
715
+ return {
716
+ cause: validator.cause,
717
+ validate: validator.fn
718
+ };
719
+ });
720
+ };
721
+ return options.validationLogic({
722
+ form: options.form,
723
+ validators: options.validators,
724
+ event: {
725
+ type: cause,
726
+ async: false
727
+ },
728
+ runValidation
729
+ });
730
+ }
731
+ function getAsyncValidatorArray(cause, options) {
732
+ const { asyncDebounceMs } = options;
733
+ const { onBlurAsyncDebounceMs, onChangeAsyncDebounceMs, onDynamicAsyncDebounceMs } = options.validators || {};
734
+ const defaultDebounceMs = asyncDebounceMs ?? 0;
735
+ const runValidation = (props) => {
736
+ return props.validators.filter(Boolean).map((validator) => {
737
+ const validatorCause = validator?.cause || cause;
738
+ let debounceMs = defaultDebounceMs;
739
+ switch (validatorCause) {
740
+ case "change":
741
+ debounceMs = onChangeAsyncDebounceMs ?? defaultDebounceMs;
742
+ break;
743
+ case "blur":
744
+ debounceMs = onBlurAsyncDebounceMs ?? defaultDebounceMs;
745
+ break;
746
+ case "dynamic":
747
+ debounceMs = onDynamicAsyncDebounceMs ?? defaultDebounceMs;
748
+ break;
749
+ case "submit":
750
+ debounceMs = 0;
751
+ break;
752
+ }
753
+ if (cause === "submit") debounceMs = 0;
754
+ return {
755
+ cause: validatorCause,
756
+ validate: validator.fn,
757
+ debounceMs
758
+ };
759
+ });
760
+ };
761
+ return options.validationLogic({
762
+ form: options.form,
763
+ validators: options.validators,
764
+ event: {
765
+ type: cause,
766
+ async: true
767
+ },
768
+ runValidation
769
+ });
770
+ }
771
+ var isGlobalFormValidationError = (error) => {
772
+ return !!error && typeof error === "object" && "fields" in error;
773
+ };
774
+ function evaluate(objA, objB) {
775
+ if (Object.is(objA, objB)) return true;
776
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) return false;
777
+ if (objA instanceof Date && objB instanceof Date) return objA.getTime() === objB.getTime();
778
+ if (objA instanceof Map && objB instanceof Map) {
779
+ if (objA.size !== objB.size) return false;
780
+ for (const [k, v] of objA) if (!objB.has(k) || !Object.is(v, objB.get(k))) return false;
781
+ return true;
782
+ }
783
+ if (objA instanceof Set && objB instanceof Set) {
784
+ if (objA.size !== objB.size) return false;
785
+ for (const v of objA) if (!objB.has(v)) return false;
786
+ return true;
787
+ }
788
+ const keysA = Object.keys(objA);
789
+ const keysB = Object.keys(objB);
790
+ if (keysA.length !== keysB.length) return false;
791
+ for (const key of keysA) if (!keysB.includes(key) || !evaluate(objA[key], objB[key])) return false;
792
+ return true;
793
+ }
794
+ var determineFormLevelErrorSourceAndValue = ({ newFormValidatorError, isPreviousErrorFromFormValidator, previousErrorValue }) => {
795
+ if (newFormValidatorError) return {
796
+ newErrorValue: newFormValidatorError,
797
+ newSource: "form"
798
+ };
799
+ if (isPreviousErrorFromFormValidator) return {
800
+ newErrorValue: void 0,
801
+ newSource: void 0
802
+ };
803
+ if (previousErrorValue) return {
804
+ newErrorValue: previousErrorValue,
805
+ newSource: "field"
806
+ };
807
+ return {
808
+ newErrorValue: void 0,
809
+ newSource: void 0
810
+ };
811
+ };
812
+ var determineFieldLevelErrorSourceAndValue = ({ formLevelError, fieldLevelError }) => {
813
+ if (fieldLevelError) return {
814
+ newErrorValue: fieldLevelError,
815
+ newSource: "field"
816
+ };
817
+ if (formLevelError) return {
818
+ newErrorValue: formLevelError,
819
+ newSource: "form"
820
+ };
821
+ return {
822
+ newErrorValue: void 0,
823
+ newSource: void 0
824
+ };
825
+ };
826
+ function mergeOpts(originalOpts, overrides) {
827
+ if (originalOpts === void 0 || originalOpts === null) return overrides;
828
+ return {
829
+ ...originalOpts,
830
+ ...overrides
831
+ };
832
+ }
833
+ var IDX = 256;
834
+ var HEX = [];
835
+ var BUFFER;
836
+ while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
837
+ function uuid() {
838
+ let i = 0;
839
+ let num;
840
+ let out = "";
841
+ if (!BUFFER || IDX + 16 > 256) {
842
+ BUFFER = new Array(256);
843
+ i = 256;
844
+ while (i--) BUFFER[i] = 256 * Math.random() | 0;
845
+ i = 0;
846
+ IDX = 0;
847
+ }
848
+ for (; i < 16; i++) {
849
+ num = BUFFER[IDX + i];
850
+ if (i === 6) out += HEX[num & 15 | 64];
851
+ else if (i === 8) out += HEX[num & 63 | 128];
852
+ else out += HEX[num];
853
+ if (i & 1 && i > 1 && i < 11) out += "-";
854
+ }
855
+ IDX++;
856
+ return out;
857
+ }
858
+ var throttleFormState = liteThrottle((form) => formEventClient.emit("form-state", {
859
+ id: form.formId,
860
+ state: form.store.state
861
+ }), { wait: 300 });
862
+ function deepCopy(obj) {
863
+ if (obj === null || typeof obj !== "object") return obj;
864
+ if (obj instanceof Date) return new Date(obj.getTime());
865
+ if (Array.isArray(obj)) {
866
+ const arrCopy = [];
867
+ for (let i = 0; i < obj.length; i++) arrCopy[i] = deepCopy(obj[i]);
868
+ return arrCopy;
869
+ }
870
+ if (obj instanceof Map) {
871
+ const mapCopy = /* @__PURE__ */ new Map();
872
+ obj.forEach((value, key) => {
873
+ mapCopy.set(key, deepCopy(value));
874
+ });
875
+ return mapCopy;
876
+ }
877
+ if (obj instanceof Set) {
878
+ const setCopy = /* @__PURE__ */ new Set();
879
+ obj.forEach((value) => {
880
+ setCopy.add(deepCopy(value));
881
+ });
882
+ return setCopy;
883
+ }
884
+ const copy = {};
885
+ for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) copy[key] = deepCopy(obj[key]);
886
+ return copy;
887
+ }
888
+ //#endregion
889
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/ValidationLogic.js
890
+ var defaultValidationLogic = (props) => {
891
+ if (!props.validators) return props.runValidation({
892
+ validators: [],
893
+ form: props.form
894
+ });
895
+ const isAsync = props.event.async;
896
+ const onMountValidator = isAsync ? void 0 : {
897
+ fn: props.validators.onMount,
898
+ cause: "mount"
899
+ };
900
+ const onChangeValidator = {
901
+ fn: isAsync ? props.validators.onChangeAsync : props.validators.onChange,
902
+ cause: "change"
903
+ };
904
+ const onBlurValidator = {
905
+ fn: isAsync ? props.validators.onBlurAsync : props.validators.onBlur,
906
+ cause: "blur"
907
+ };
908
+ const onSubmitValidator = {
909
+ fn: isAsync ? props.validators.onSubmitAsync : props.validators.onSubmit,
910
+ cause: "submit"
911
+ };
912
+ const onServerValidator = isAsync ? void 0 : {
913
+ fn: () => void 0,
914
+ cause: "server"
915
+ };
916
+ switch (props.event.type) {
917
+ case "mount": return props.runValidation({
918
+ validators: [onMountValidator],
919
+ form: props.form
920
+ });
921
+ case "submit": return props.runValidation({
922
+ validators: [
923
+ onChangeValidator,
924
+ onBlurValidator,
925
+ onSubmitValidator,
926
+ onServerValidator
927
+ ],
928
+ form: props.form
929
+ });
930
+ case "server": return props.runValidation({
931
+ validators: [],
932
+ form: props.form
933
+ });
934
+ case "blur": return props.runValidation({
935
+ validators: [onBlurValidator, onServerValidator],
936
+ form: props.form
937
+ });
938
+ case "change": return props.runValidation({
939
+ validators: [onChangeValidator, onServerValidator],
940
+ form: props.form
941
+ });
942
+ default: throw new Error(`Unknown validation event type: ${props.event.type}`);
943
+ }
944
+ };
945
+ //#endregion
946
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/standardSchemaValidator.js
947
+ function prefixSchemaToErrors(issues, formValue) {
948
+ const schema = /* @__PURE__ */ new Map();
949
+ for (const issue of issues) {
950
+ const issuePath = issue.path ?? [];
951
+ let currentFormValue = formValue;
952
+ let path = "";
953
+ for (let i = 0; i < issuePath.length; i++) {
954
+ const pathSegment = issuePath[i];
955
+ if (pathSegment === void 0) continue;
956
+ const segment = typeof pathSegment === "object" ? pathSegment.key : pathSegment;
957
+ const segmentAsNumber = Number(segment);
958
+ if (Array.isArray(currentFormValue) && !Number.isNaN(segmentAsNumber)) path += `[${segmentAsNumber}]`;
959
+ else path += (i > 0 ? "." : "") + String(segment);
960
+ if (typeof currentFormValue === "object" && currentFormValue !== null) currentFormValue = currentFormValue[segment];
961
+ else currentFormValue = void 0;
962
+ }
963
+ schema.set(path, (schema.get(path) ?? []).concat(issue));
964
+ }
965
+ return Object.fromEntries(schema);
966
+ }
967
+ var transformFormIssues = (issues, formValue) => {
968
+ const schemaErrors = prefixSchemaToErrors(issues, formValue);
969
+ return {
970
+ form: schemaErrors,
971
+ fields: schemaErrors
972
+ };
973
+ };
974
+ var standardSchemaValidators = {
975
+ validate({ value, validationSource }, schema) {
976
+ const result = schema["~standard"].validate(value);
977
+ if (result instanceof Promise) throw new Error("async function passed to sync validator");
978
+ if (!result.issues) return;
979
+ if (validationSource === "field") return result.issues;
980
+ return transformFormIssues(result.issues, value);
981
+ },
982
+ async validateAsync({ value, validationSource }, schema) {
983
+ const result = await schema["~standard"].validate(value);
984
+ if (!result.issues) return;
985
+ if (validationSource === "field") return result.issues;
986
+ return transformFormIssues(result.issues, value);
987
+ }
988
+ };
989
+ var isStandardSchemaValidator = (validator) => !!validator && "~standard" in validator;
990
+ //#endregion
991
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/metaHelper.js
992
+ var defaultFieldMeta = {
993
+ isValidating: false,
994
+ isTouched: false,
995
+ isBlurred: false,
996
+ isDirty: false,
997
+ isPristine: true,
998
+ isValid: true,
999
+ isDefaultValue: true,
1000
+ errors: [],
1001
+ errorMap: {},
1002
+ errorSourceMap: {}
1003
+ };
1004
+ function metaHelper(formApi) {
1005
+ function handleArrayMove(field, fromIndex, toIndex) {
1006
+ const affectedFields = getAffectedFields(field, fromIndex, "move", toIndex);
1007
+ const startIndex = Math.min(fromIndex, toIndex);
1008
+ const endIndex = Math.max(fromIndex, toIndex);
1009
+ for (let i = startIndex; i <= endIndex; i++) affectedFields.push(getFieldPath(field, i));
1010
+ const fromFields = Object.keys(formApi.fieldInfo).reduce((fieldMap, fieldKey) => {
1011
+ if (fieldKey.startsWith(getFieldPath(field, fromIndex))) fieldMap.set(fieldKey, formApi.getFieldMeta(fieldKey));
1012
+ return fieldMap;
1013
+ }, /* @__PURE__ */ new Map());
1014
+ shiftMeta(affectedFields, fromIndex < toIndex ? "up" : "down");
1015
+ Object.keys(formApi.fieldInfo).filter((fieldKey) => fieldKey.startsWith(getFieldPath(field, toIndex))).forEach((fieldKey) => {
1016
+ const fromKey = fieldKey.replace(getFieldPath(field, toIndex), getFieldPath(field, fromIndex));
1017
+ const fromMeta = fromFields.get(fromKey);
1018
+ if (fromMeta) formApi.setFieldMeta(fieldKey, fromMeta);
1019
+ });
1020
+ }
1021
+ function handleArrayRemove(field, index) {
1022
+ shiftMeta(getAffectedFields(field, index, "remove"), "up");
1023
+ }
1024
+ function handleArraySwap(field, index, secondIndex) {
1025
+ getAffectedFields(field, index, "swap", secondIndex).forEach((fieldKey) => {
1026
+ if (!fieldKey.toString().startsWith(getFieldPath(field, index))) return;
1027
+ const swappedKey = fieldKey.toString().replace(getFieldPath(field, index), getFieldPath(field, secondIndex));
1028
+ const [meta1, meta2] = [formApi.getFieldMeta(fieldKey), formApi.getFieldMeta(swappedKey)];
1029
+ if (meta1) formApi.setFieldMeta(swappedKey, meta1);
1030
+ if (meta2) formApi.setFieldMeta(fieldKey, meta2);
1031
+ });
1032
+ }
1033
+ function handleArrayInsert(field, insertIndex) {
1034
+ const affectedFields = getAffectedFields(field, insertIndex, "insert");
1035
+ shiftMeta(affectedFields, "down");
1036
+ affectedFields.forEach((fieldKey) => {
1037
+ if (fieldKey.toString().startsWith(getFieldPath(field, insertIndex))) formApi.setFieldMeta(fieldKey, getEmptyFieldMeta());
1038
+ });
1039
+ }
1040
+ function getFieldPath(field, index) {
1041
+ return `${field}[${index}]`;
1042
+ }
1043
+ function getAffectedFields(field, index, mode, secondIndex) {
1044
+ const affectedFieldKeys = [getFieldPath(field, index)];
1045
+ switch (mode) {
1046
+ case "swap":
1047
+ affectedFieldKeys.push(getFieldPath(field, secondIndex));
1048
+ break;
1049
+ case "move": {
1050
+ const [startIndex, endIndex] = [Math.min(index, secondIndex), Math.max(index, secondIndex)];
1051
+ for (let i = startIndex; i <= endIndex; i++) affectedFieldKeys.push(getFieldPath(field, i));
1052
+ break;
1053
+ }
1054
+ default: {
1055
+ const currentValue = formApi.getFieldValue(field);
1056
+ const fieldItems = Array.isArray(currentValue) ? currentValue.length : 0;
1057
+ for (let i = index + 1; i < fieldItems; i++) affectedFieldKeys.push(getFieldPath(field, i));
1058
+ break;
1059
+ }
1060
+ }
1061
+ return Object.keys(formApi.fieldInfo).filter((fieldKey) => affectedFieldKeys.some((key) => fieldKey.startsWith(key)));
1062
+ }
1063
+ function updateIndex(fieldKey, direction) {
1064
+ return fieldKey.replace(/\[(\d+)\]/, (_, num) => {
1065
+ const currIndex = parseInt(num, 10);
1066
+ return `[${direction === "up" ? currIndex + 1 : Math.max(0, currIndex - 1)}]`;
1067
+ });
1068
+ }
1069
+ function shiftMeta(fields, direction) {
1070
+ (direction === "up" ? fields : [...fields].reverse()).forEach((fieldKey) => {
1071
+ const nextFieldKey = updateIndex(fieldKey.toString(), direction);
1072
+ const nextFieldMeta = formApi.getFieldMeta(nextFieldKey);
1073
+ if (nextFieldMeta) formApi.setFieldMeta(fieldKey, nextFieldMeta);
1074
+ else formApi.setFieldMeta(fieldKey, getEmptyFieldMeta());
1075
+ });
1076
+ }
1077
+ const getEmptyFieldMeta = () => defaultFieldMeta;
1078
+ return {
1079
+ handleArrayMove,
1080
+ handleArrayRemove,
1081
+ handleArraySwap,
1082
+ handleArrayInsert
1083
+ };
1084
+ }
1085
+ //#endregion
1086
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/FormApi.js
1087
+ function getDefaultFormState(defaultState) {
1088
+ return {
1089
+ values: defaultState.values ?? {},
1090
+ errorMap: defaultState.errorMap ?? {},
1091
+ fieldMetaBase: defaultState.fieldMetaBase ?? {},
1092
+ isSubmitted: defaultState.isSubmitted ?? false,
1093
+ isSubmitting: defaultState.isSubmitting ?? false,
1094
+ isValidating: defaultState.isValidating ?? false,
1095
+ submissionAttempts: defaultState.submissionAttempts ?? 0,
1096
+ isSubmitSuccessful: defaultState.isSubmitSuccessful ?? false,
1097
+ validationMetaMap: defaultState.validationMetaMap ?? {
1098
+ onChange: void 0,
1099
+ onBlur: void 0,
1100
+ onSubmit: void 0,
1101
+ onMount: void 0,
1102
+ onServer: void 0,
1103
+ onDynamic: void 0
1104
+ }
1105
+ };
1106
+ }
1107
+ var FormApi = class {
1108
+ /**
1109
+ * Constructs a new `FormApi` instance with the given form options.
1110
+ */
1111
+ constructor(opts) {
1112
+ this.options = {};
1113
+ this.fieldInfo = {};
1114
+ this.mount = () => {
1115
+ const cleanupDevtoolBroadcast = this.store.subscribe(() => {
1116
+ throttleFormState(this);
1117
+ });
1118
+ const cleanupFormStateListener = formEventClient.on("request-form-state", (e) => {
1119
+ if (e.payload.id === this._formId) formEventClient.emit("form-api", {
1120
+ id: this._formId,
1121
+ state: this.store.state,
1122
+ options: this.options
1123
+ });
1124
+ });
1125
+ const cleanupFormResetListener = formEventClient.on("request-form-reset", (e) => {
1126
+ if (e.payload.id === this._formId) this.reset();
1127
+ });
1128
+ const cleanupFormForceSubmitListener = formEventClient.on("request-form-force-submit", (e) => {
1129
+ if (e.payload.id === this._formId) {
1130
+ this._devtoolsSubmissionOverride = true;
1131
+ this.handleSubmit();
1132
+ this._devtoolsSubmissionOverride = false;
1133
+ }
1134
+ });
1135
+ const cleanup = () => {
1136
+ cleanupFormForceSubmitListener();
1137
+ cleanupFormResetListener();
1138
+ cleanupFormStateListener();
1139
+ cleanupDevtoolBroadcast.unsubscribe();
1140
+ formEventClient.emit("form-unmounted", { id: this._formId });
1141
+ };
1142
+ this.options.listeners?.onMount?.({ formApi: this });
1143
+ const { onMount } = this.options.validators || {};
1144
+ formEventClient.emit("form-api", {
1145
+ id: this._formId,
1146
+ state: this.store.state,
1147
+ options: this.options
1148
+ });
1149
+ if (!onMount) return cleanup;
1150
+ this.validateSync("mount");
1151
+ return cleanup;
1152
+ };
1153
+ this.update = (options) => {
1154
+ if (!options) return;
1155
+ const oldOptions = this.options;
1156
+ this.options = options;
1157
+ const shouldUpdateValues = options.defaultValues && !evaluate(options.defaultValues, oldOptions.defaultValues) && !this.state.isTouched;
1158
+ const shouldUpdateState = !evaluate(options.defaultState, oldOptions.defaultState) && !this.state.isTouched;
1159
+ if (!shouldUpdateValues && !shouldUpdateState) return;
1160
+ batch(() => {
1161
+ this.baseStore.setState(() => getDefaultFormState(Object.assign({}, this.state, shouldUpdateState ? options.defaultState : {}, shouldUpdateValues ? { values: options.defaultValues } : {})));
1162
+ });
1163
+ formEventClient.emit("form-api", {
1164
+ id: this._formId,
1165
+ state: this.store.state,
1166
+ options: this.options
1167
+ });
1168
+ };
1169
+ this.reset = (values, opts2) => {
1170
+ const { fieldMeta: currentFieldMeta } = this.state;
1171
+ const fieldMetaBase = this.resetFieldMeta(currentFieldMeta);
1172
+ if (values && !opts2?.keepDefaultValues) this.options = {
1173
+ ...this.options,
1174
+ defaultValues: values
1175
+ };
1176
+ this.baseStore.setState(() => getDefaultFormState({
1177
+ ...this.options.defaultState,
1178
+ values: values ?? this.options.defaultValues ?? this.options.defaultState?.values,
1179
+ fieldMetaBase
1180
+ }));
1181
+ };
1182
+ this.validateAllFields = async (cause) => {
1183
+ const fieldValidationPromises = [];
1184
+ batch(() => {
1185
+ Object.values(this.fieldInfo).forEach((field) => {
1186
+ if (!field.instance) return;
1187
+ const fieldInstance = field.instance;
1188
+ fieldValidationPromises.push(Promise.resolve().then(() => fieldInstance.validate(cause, { skipFormValidation: true })));
1189
+ if (!field.instance.state.meta.isTouched) field.instance.setMeta((prev) => ({
1190
+ ...prev,
1191
+ isTouched: true
1192
+ }));
1193
+ });
1194
+ });
1195
+ return (await Promise.all(fieldValidationPromises)).flat();
1196
+ };
1197
+ this.validateArrayFieldsStartingFrom = async (field, index, cause) => {
1198
+ const currentValue = this.getFieldValue(field);
1199
+ const lastIndex = Array.isArray(currentValue) ? Math.max(currentValue.length - 1, 0) : null;
1200
+ const fieldKeysToValidate = [`${field}[${index}]`];
1201
+ for (let i = index + 1; i <= (lastIndex ?? 0); i++) fieldKeysToValidate.push(`${field}[${i}]`);
1202
+ const fieldsToValidate = Object.keys(this.fieldInfo).filter((fieldKey) => fieldKeysToValidate.some((key) => fieldKey.startsWith(key)));
1203
+ const fieldValidationPromises = [];
1204
+ batch(() => {
1205
+ fieldsToValidate.forEach((nestedField) => {
1206
+ fieldValidationPromises.push(Promise.resolve().then(() => this.validateField(nestedField, cause)));
1207
+ });
1208
+ });
1209
+ return (await Promise.all(fieldValidationPromises)).flat();
1210
+ };
1211
+ this.validateField = (field, cause) => {
1212
+ const fieldInstance = this.fieldInfo[field]?.instance;
1213
+ if (!fieldInstance) {
1214
+ const { hasErrored } = this.validateSync(cause);
1215
+ if (hasErrored && !this.options.asyncAlways) return this.getFieldMeta(field)?.errors ?? [];
1216
+ return this.validateAsync(cause).then(() => {
1217
+ return this.getFieldMeta(field)?.errors ?? [];
1218
+ });
1219
+ }
1220
+ if (!fieldInstance.state.meta.isTouched) fieldInstance.setMeta((prev) => ({
1221
+ ...prev,
1222
+ isTouched: true
1223
+ }));
1224
+ return fieldInstance.validate(cause);
1225
+ };
1226
+ this.validateSync = (cause) => {
1227
+ const validates = getSyncValidatorArray(cause, {
1228
+ ...this.options,
1229
+ form: this,
1230
+ validationLogic: this.options.validationLogic || defaultValidationLogic
1231
+ });
1232
+ let hasErrored = false;
1233
+ const currentValidationErrorMap = {};
1234
+ batch(() => {
1235
+ for (const validateObj of validates) {
1236
+ if (!validateObj.validate) continue;
1237
+ const { formError, fieldErrors } = normalizeError$1(this.runValidator({
1238
+ validate: validateObj.validate,
1239
+ value: {
1240
+ value: this.state.values,
1241
+ formApi: this,
1242
+ validationSource: "form"
1243
+ },
1244
+ type: "validate"
1245
+ }));
1246
+ const errorMapKey = getErrorMapKey$1(validateObj.cause);
1247
+ const allFieldsToProcess = /* @__PURE__ */ new Set([...Object.keys(this.state.fieldMeta), ...Object.keys(fieldErrors || {})]);
1248
+ for (const field of allFieldsToProcess) {
1249
+ if (this.baseStore.state.fieldMetaBase[field] === void 0 && !fieldErrors?.[field]) continue;
1250
+ const { errorMap: currentErrorMap, errorSourceMap: currentErrorMapSource } = this.getFieldMeta(field) ?? defaultFieldMeta;
1251
+ const newFormValidatorError = fieldErrors?.[field];
1252
+ const { newErrorValue, newSource } = determineFormLevelErrorSourceAndValue({
1253
+ newFormValidatorError,
1254
+ isPreviousErrorFromFormValidator: currentErrorMapSource?.[errorMapKey] === "form",
1255
+ previousErrorValue: currentErrorMap?.[errorMapKey]
1256
+ });
1257
+ if (newSource === "form") currentValidationErrorMap[field] = {
1258
+ ...currentValidationErrorMap[field],
1259
+ [errorMapKey]: newFormValidatorError
1260
+ };
1261
+ if (currentErrorMap?.[errorMapKey] !== newErrorValue) this.setFieldMeta(field, (prev = defaultFieldMeta) => ({
1262
+ ...prev,
1263
+ errorMap: {
1264
+ ...prev.errorMap,
1265
+ [errorMapKey]: newErrorValue
1266
+ },
1267
+ errorSourceMap: {
1268
+ ...prev.errorSourceMap,
1269
+ [errorMapKey]: newSource
1270
+ }
1271
+ }));
1272
+ }
1273
+ if (this.state.errorMap?.[errorMapKey] !== formError) this.baseStore.setState((prev) => ({
1274
+ ...prev,
1275
+ errorMap: {
1276
+ ...prev.errorMap,
1277
+ [errorMapKey]: formError
1278
+ }
1279
+ }));
1280
+ if (formError || fieldErrors) hasErrored = true;
1281
+ }
1282
+ const submitErrKey = getErrorMapKey$1("submit");
1283
+ if (this.state.errorMap?.[submitErrKey] && cause !== "submit" && !hasErrored) this.baseStore.setState((prev) => ({
1284
+ ...prev,
1285
+ errorMap: {
1286
+ ...prev.errorMap,
1287
+ [submitErrKey]: void 0
1288
+ }
1289
+ }));
1290
+ const serverErrKey = getErrorMapKey$1("server");
1291
+ if (this.state.errorMap?.[serverErrKey] && cause !== "server" && !hasErrored) this.baseStore.setState((prev) => ({
1292
+ ...prev,
1293
+ errorMap: {
1294
+ ...prev.errorMap,
1295
+ [serverErrKey]: void 0
1296
+ }
1297
+ }));
1298
+ });
1299
+ return {
1300
+ hasErrored,
1301
+ fieldsErrorMap: currentValidationErrorMap
1302
+ };
1303
+ };
1304
+ this.validateAsync = async (cause) => {
1305
+ const validates = getAsyncValidatorArray(cause, {
1306
+ ...this.options,
1307
+ form: this,
1308
+ validationLogic: this.options.validationLogic || defaultValidationLogic
1309
+ });
1310
+ if (!this.state.isFormValidating) this.baseStore.setState((prev) => ({
1311
+ ...prev,
1312
+ isFormValidating: true
1313
+ }));
1314
+ const promises = [];
1315
+ let fieldErrorsFromFormValidators;
1316
+ for (const validateObj of validates) {
1317
+ if (!validateObj.validate) continue;
1318
+ const key = getErrorMapKey$1(validateObj.cause);
1319
+ this.state.validationMetaMap[key]?.lastAbortController.abort();
1320
+ const controller = new AbortController();
1321
+ this.state.validationMetaMap[key] = { lastAbortController: controller };
1322
+ promises.push(new Promise(async (resolve) => {
1323
+ let rawError;
1324
+ try {
1325
+ rawError = await new Promise((rawResolve, rawReject) => {
1326
+ setTimeout(async () => {
1327
+ if (controller.signal.aborted) return rawResolve(void 0);
1328
+ try {
1329
+ rawResolve(await this.runValidator({
1330
+ validate: validateObj.validate,
1331
+ value: {
1332
+ value: this.state.values,
1333
+ formApi: this,
1334
+ validationSource: "form",
1335
+ signal: controller.signal
1336
+ },
1337
+ type: "validateAsync"
1338
+ }));
1339
+ } catch (e) {
1340
+ rawReject(e);
1341
+ }
1342
+ }, validateObj.debounceMs);
1343
+ });
1344
+ } catch (e) {
1345
+ rawError = e;
1346
+ }
1347
+ const { formError, fieldErrors: fieldErrorsFromNormalizeError } = normalizeError$1(rawError);
1348
+ if (fieldErrorsFromNormalizeError) fieldErrorsFromFormValidators = fieldErrorsFromFormValidators ? {
1349
+ ...fieldErrorsFromFormValidators,
1350
+ ...fieldErrorsFromNormalizeError
1351
+ } : fieldErrorsFromNormalizeError;
1352
+ const errorMapKey = getErrorMapKey$1(validateObj.cause);
1353
+ for (const field of Object.keys(this.state.fieldMeta)) {
1354
+ if (this.baseStore.state.fieldMetaBase[field] === void 0) continue;
1355
+ const fieldMeta = this.getFieldMeta(field);
1356
+ if (!fieldMeta) continue;
1357
+ const { errorMap: currentErrorMap, errorSourceMap: currentErrorMapSource } = fieldMeta;
1358
+ const newFormValidatorError = fieldErrorsFromFormValidators?.[field];
1359
+ const { newErrorValue, newSource } = determineFormLevelErrorSourceAndValue({
1360
+ newFormValidatorError,
1361
+ isPreviousErrorFromFormValidator: currentErrorMapSource?.[errorMapKey] === "form",
1362
+ previousErrorValue: currentErrorMap?.[errorMapKey]
1363
+ });
1364
+ if (currentErrorMap?.[errorMapKey] !== newErrorValue) this.setFieldMeta(field, (prev) => ({
1365
+ ...prev,
1366
+ errorMap: {
1367
+ ...prev.errorMap,
1368
+ [errorMapKey]: newErrorValue
1369
+ },
1370
+ errorSourceMap: {
1371
+ ...prev.errorSourceMap,
1372
+ [errorMapKey]: newSource
1373
+ }
1374
+ }));
1375
+ }
1376
+ this.baseStore.setState((prev) => ({
1377
+ ...prev,
1378
+ errorMap: {
1379
+ ...prev.errorMap,
1380
+ [errorMapKey]: formError
1381
+ }
1382
+ }));
1383
+ resolve(fieldErrorsFromFormValidators ? {
1384
+ fieldErrors: fieldErrorsFromFormValidators,
1385
+ errorMapKey
1386
+ } : void 0);
1387
+ }));
1388
+ }
1389
+ let results = [];
1390
+ const fieldsErrorMap = {};
1391
+ if (promises.length) {
1392
+ results = await Promise.all(promises);
1393
+ for (const fieldValidationResult of results) if (fieldValidationResult?.fieldErrors) {
1394
+ const { errorMapKey } = fieldValidationResult;
1395
+ for (const [field, fieldError] of Object.entries(fieldValidationResult.fieldErrors)) fieldsErrorMap[field] = {
1396
+ ...fieldsErrorMap[field] || {},
1397
+ [errorMapKey]: fieldError
1398
+ };
1399
+ }
1400
+ }
1401
+ this.baseStore.setState((prev) => ({
1402
+ ...prev,
1403
+ isFormValidating: false
1404
+ }));
1405
+ return fieldsErrorMap;
1406
+ };
1407
+ this.validate = (cause) => {
1408
+ const { hasErrored, fieldsErrorMap } = this.validateSync(cause);
1409
+ if (hasErrored && !this.options.asyncAlways) return fieldsErrorMap;
1410
+ return this.validateAsync(cause);
1411
+ };
1412
+ this._handleSubmit = async (submitMeta) => {
1413
+ this.baseStore.setState((old) => ({
1414
+ ...old,
1415
+ isSubmitted: false,
1416
+ submissionAttempts: old.submissionAttempts + 1,
1417
+ isSubmitSuccessful: false
1418
+ }));
1419
+ batch(() => {
1420
+ Object.values(this.fieldInfo).forEach((field) => {
1421
+ if (!field.instance) return;
1422
+ if (!field.instance.state.meta.isTouched) field.instance.setMeta((prev) => ({
1423
+ ...prev,
1424
+ isTouched: true
1425
+ }));
1426
+ });
1427
+ });
1428
+ const submitMetaArg = submitMeta ?? this.options.onSubmitMeta;
1429
+ if (!this.state.canSubmit && !this._devtoolsSubmissionOverride) {
1430
+ this.options.onSubmitInvalid?.({
1431
+ value: this.state.values,
1432
+ formApi: this,
1433
+ meta: submitMetaArg
1434
+ });
1435
+ return;
1436
+ }
1437
+ this.baseStore.setState((d) => ({
1438
+ ...d,
1439
+ isSubmitting: true
1440
+ }));
1441
+ const done = () => {
1442
+ this.baseStore.setState((prev) => ({
1443
+ ...prev,
1444
+ isSubmitting: false
1445
+ }));
1446
+ };
1447
+ await this.validateAllFields("submit");
1448
+ if (!this.state.isFieldsValid) {
1449
+ done();
1450
+ this.options.onSubmitInvalid?.({
1451
+ value: this.state.values,
1452
+ formApi: this,
1453
+ meta: submitMetaArg
1454
+ });
1455
+ formEventClient.emit("form-submission", {
1456
+ id: this._formId,
1457
+ submissionAttempt: this.state.submissionAttempts,
1458
+ successful: false,
1459
+ stage: "validateAllFields",
1460
+ errors: Object.values(this.state.fieldMeta).map((meta) => meta.errors).flat()
1461
+ });
1462
+ return;
1463
+ }
1464
+ await this.validate("submit");
1465
+ if (!this.state.isValid) {
1466
+ done();
1467
+ this.options.onSubmitInvalid?.({
1468
+ value: this.state.values,
1469
+ formApi: this,
1470
+ meta: submitMetaArg
1471
+ });
1472
+ formEventClient.emit("form-submission", {
1473
+ id: this._formId,
1474
+ submissionAttempt: this.state.submissionAttempts,
1475
+ successful: false,
1476
+ stage: "validate",
1477
+ errors: this.state.errors
1478
+ });
1479
+ return;
1480
+ }
1481
+ batch(() => {
1482
+ Object.values(this.fieldInfo).forEach((field) => {
1483
+ field.instance?.options.listeners?.onSubmit?.({
1484
+ value: field.instance.state.value,
1485
+ fieldApi: field.instance
1486
+ });
1487
+ });
1488
+ });
1489
+ this.options.listeners?.onSubmit?.({
1490
+ formApi: this,
1491
+ meta: submitMetaArg
1492
+ });
1493
+ try {
1494
+ await this.options.onSubmit?.({
1495
+ value: this.state.values,
1496
+ formApi: this,
1497
+ meta: submitMetaArg
1498
+ });
1499
+ batch(() => {
1500
+ this.baseStore.setState((prev) => ({
1501
+ ...prev,
1502
+ isSubmitted: true,
1503
+ isSubmitSuccessful: true
1504
+ }));
1505
+ formEventClient.emit("form-submission", {
1506
+ id: this._formId,
1507
+ submissionAttempt: this.state.submissionAttempts,
1508
+ successful: true
1509
+ });
1510
+ done();
1511
+ });
1512
+ } catch (err) {
1513
+ this.baseStore.setState((prev) => ({
1514
+ ...prev,
1515
+ isSubmitSuccessful: false
1516
+ }));
1517
+ formEventClient.emit("form-submission", {
1518
+ id: this._formId,
1519
+ submissionAttempt: this.state.submissionAttempts,
1520
+ successful: false,
1521
+ stage: "inflight",
1522
+ onError: err
1523
+ });
1524
+ done();
1525
+ throw err;
1526
+ }
1527
+ };
1528
+ this.getFieldValue = (field) => getBy(this.state.values, field);
1529
+ this.getFieldMeta = (field) => {
1530
+ return this.state.fieldMeta[field];
1531
+ };
1532
+ this.getFieldInfo = (field) => {
1533
+ return this.fieldInfo[field] ||= {
1534
+ instance: null,
1535
+ validationMetaMap: {
1536
+ onChange: void 0,
1537
+ onBlur: void 0,
1538
+ onSubmit: void 0,
1539
+ onMount: void 0,
1540
+ onServer: void 0,
1541
+ onDynamic: void 0
1542
+ }
1543
+ };
1544
+ };
1545
+ this.setFieldMeta = (field, updater) => {
1546
+ this.baseStore.setState((prev) => {
1547
+ return {
1548
+ ...prev,
1549
+ fieldMetaBase: {
1550
+ ...prev.fieldMetaBase,
1551
+ [field]: functionalUpdate(updater, prev.fieldMetaBase[field])
1552
+ }
1553
+ };
1554
+ });
1555
+ };
1556
+ this.resetFieldMeta = (fieldMeta) => {
1557
+ return Object.keys(fieldMeta).reduce((acc, key) => {
1558
+ const fieldKey = key;
1559
+ acc[fieldKey] = defaultFieldMeta;
1560
+ return acc;
1561
+ }, {});
1562
+ };
1563
+ this.setFieldValue = (field, updater, opts2) => {
1564
+ const dontUpdateMeta = opts2?.dontUpdateMeta ?? false;
1565
+ const dontRunListeners = opts2?.dontRunListeners ?? false;
1566
+ const dontValidate = opts2?.dontValidate ?? false;
1567
+ batch(() => {
1568
+ if (!dontUpdateMeta) this.setFieldMeta(field, (prev) => ({
1569
+ ...prev,
1570
+ isTouched: true,
1571
+ isDirty: true,
1572
+ errorMap: {
1573
+ ...prev?.errorMap,
1574
+ onMount: void 0
1575
+ }
1576
+ }));
1577
+ this.baseStore.setState((prev) => {
1578
+ return {
1579
+ ...prev,
1580
+ values: setBy(prev.values, field, updater)
1581
+ };
1582
+ });
1583
+ });
1584
+ if (!dontRunListeners) this.getFieldInfo(field).instance?.triggerOnChangeListener();
1585
+ if (!dontValidate) this.validateField(field, "change");
1586
+ };
1587
+ this.deleteField = (field) => {
1588
+ const fieldsToDelete = [...Object.keys(this.fieldInfo).filter((f) => {
1589
+ const fieldStr = field.toString();
1590
+ return f !== fieldStr && f.startsWith(fieldStr);
1591
+ }), field];
1592
+ this.baseStore.setState((prev) => {
1593
+ const newState = { ...prev };
1594
+ fieldsToDelete.forEach((f) => {
1595
+ newState.values = deleteBy(newState.values, f);
1596
+ delete this.fieldInfo[f];
1597
+ delete newState.fieldMetaBase[f];
1598
+ });
1599
+ return newState;
1600
+ });
1601
+ };
1602
+ this.pushFieldValue = (field, value, options) => {
1603
+ this.setFieldValue(field, (prev) => [...Array.isArray(prev) ? prev : [], value], options);
1604
+ };
1605
+ this.insertFieldValue = async (field, index, value, options) => {
1606
+ this.setFieldValue(field, (prev) => {
1607
+ return [
1608
+ ...prev.slice(0, index),
1609
+ value,
1610
+ ...prev.slice(index)
1611
+ ];
1612
+ }, mergeOpts(options, { dontValidate: true }));
1613
+ const dontValidate = options?.dontValidate ?? false;
1614
+ if (!dontValidate) await this.validateField(field, "change");
1615
+ metaHelper(this).handleArrayInsert(field, index);
1616
+ if (!dontValidate) await this.validateArrayFieldsStartingFrom(field, index, "change");
1617
+ };
1618
+ this.replaceFieldValue = async (field, index, value, options) => {
1619
+ this.setFieldValue(field, (prev) => {
1620
+ return prev.map((d, i) => i === index ? value : d);
1621
+ }, mergeOpts(options, { dontValidate: true }));
1622
+ if (!(options?.dontValidate ?? false)) {
1623
+ await this.validateField(field, "change");
1624
+ await this.validateArrayFieldsStartingFrom(field, index, "change");
1625
+ }
1626
+ };
1627
+ this.removeFieldValue = async (field, index, options) => {
1628
+ const fieldValue = this.getFieldValue(field);
1629
+ const lastIndex = Array.isArray(fieldValue) ? Math.max(fieldValue.length - 1, 0) : null;
1630
+ this.setFieldValue(field, (prev) => {
1631
+ return prev.filter((_d, i) => i !== index);
1632
+ }, mergeOpts(options, { dontValidate: true }));
1633
+ metaHelper(this).handleArrayRemove(field, index);
1634
+ if (lastIndex !== null) {
1635
+ const start = `${field}[${lastIndex}]`;
1636
+ this.deleteField(start);
1637
+ }
1638
+ if (!(options?.dontValidate ?? false)) {
1639
+ await this.validateField(field, "change");
1640
+ await this.validateArrayFieldsStartingFrom(field, index, "change");
1641
+ }
1642
+ };
1643
+ this.swapFieldValues = (field, index1, index2, options) => {
1644
+ this.setFieldValue(field, (prev) => {
1645
+ const prev1 = prev[index1];
1646
+ const prev2 = prev[index2];
1647
+ return setBy(setBy(prev, `${index1}`, prev2), `${index2}`, prev1);
1648
+ }, mergeOpts(options, { dontValidate: true }));
1649
+ metaHelper(this).handleArraySwap(field, index1, index2);
1650
+ if (!(options?.dontValidate ?? false)) {
1651
+ this.validateField(field, "change");
1652
+ this.validateField(`${field}[${index1}]`, "change");
1653
+ this.validateField(`${field}[${index2}]`, "change");
1654
+ }
1655
+ };
1656
+ this.moveFieldValues = (field, index1, index2, options) => {
1657
+ this.setFieldValue(field, (prev) => {
1658
+ const next = [...prev];
1659
+ next.splice(index2, 0, next.splice(index1, 1)[0]);
1660
+ return next;
1661
+ }, mergeOpts(options, { dontValidate: true }));
1662
+ metaHelper(this).handleArrayMove(field, index1, index2);
1663
+ if (!(options?.dontValidate ?? false)) {
1664
+ this.validateField(field, "change");
1665
+ this.validateField(`${field}[${index1}]`, "change");
1666
+ this.validateField(`${field}[${index2}]`, "change");
1667
+ }
1668
+ };
1669
+ this.clearFieldValues = (field, options) => {
1670
+ const fieldValue = this.getFieldValue(field);
1671
+ const lastIndex = Array.isArray(fieldValue) ? Math.max(fieldValue.length - 1, 0) : null;
1672
+ this.setFieldValue(field, [], mergeOpts(options, { dontValidate: true }));
1673
+ if (lastIndex !== null) for (let i = 0; i <= lastIndex; i++) {
1674
+ const fieldKey = `${field}[${i}]`;
1675
+ this.deleteField(fieldKey);
1676
+ }
1677
+ if (!(options?.dontValidate ?? false)) this.validateField(field, "change");
1678
+ };
1679
+ this.resetField = (field) => {
1680
+ this.baseStore.setState((prev) => {
1681
+ return {
1682
+ ...prev,
1683
+ fieldMetaBase: {
1684
+ ...prev.fieldMetaBase,
1685
+ [field]: defaultFieldMeta
1686
+ },
1687
+ values: this.options.defaultValues ? setBy(prev.values, field, getBy(this.options.defaultValues, field)) : prev.values
1688
+ };
1689
+ });
1690
+ };
1691
+ this.setErrorMap = (errorMap) => {
1692
+ batch(() => {
1693
+ Object.entries(errorMap).forEach(([key, value]) => {
1694
+ const errorMapKey = key;
1695
+ if (isGlobalFormValidationError(value)) {
1696
+ const { formError, fieldErrors } = normalizeError$1(value);
1697
+ for (const fieldName of Object.keys(this.fieldInfo)) {
1698
+ if (!this.getFieldMeta(fieldName)) continue;
1699
+ this.setFieldMeta(fieldName, (prev) => ({
1700
+ ...prev,
1701
+ errorMap: {
1702
+ ...prev.errorMap,
1703
+ [errorMapKey]: fieldErrors?.[fieldName]
1704
+ },
1705
+ errorSourceMap: {
1706
+ ...prev.errorSourceMap,
1707
+ [errorMapKey]: "form"
1708
+ }
1709
+ }));
1710
+ }
1711
+ this.baseStore.setState((prev) => ({
1712
+ ...prev,
1713
+ errorMap: {
1714
+ ...prev.errorMap,
1715
+ [errorMapKey]: formError
1716
+ }
1717
+ }));
1718
+ } else this.baseStore.setState((prev) => ({
1719
+ ...prev,
1720
+ errorMap: {
1721
+ ...prev.errorMap,
1722
+ [errorMapKey]: value
1723
+ }
1724
+ }));
1725
+ });
1726
+ });
1727
+ };
1728
+ this.getAllErrors = () => {
1729
+ return {
1730
+ form: {
1731
+ errors: this.state.errors,
1732
+ errorMap: this.state.errorMap
1733
+ },
1734
+ fields: Object.entries(this.state.fieldMeta).reduce((acc, [fieldName, fieldMeta]) => {
1735
+ if (Object.keys(fieldMeta).length && fieldMeta.errors.length) acc[fieldName] = {
1736
+ errors: fieldMeta.errors,
1737
+ errorMap: fieldMeta.errorMap
1738
+ };
1739
+ return acc;
1740
+ }, {})
1741
+ };
1742
+ };
1743
+ this.parseValuesWithSchema = (schema) => {
1744
+ return standardSchemaValidators.validate({
1745
+ value: this.state.values,
1746
+ validationSource: "form"
1747
+ }, schema);
1748
+ };
1749
+ this.parseValuesWithSchemaAsync = (schema) => {
1750
+ return standardSchemaValidators.validateAsync({
1751
+ value: this.state.values,
1752
+ validationSource: "form"
1753
+ }, schema);
1754
+ };
1755
+ this.timeoutIds = {
1756
+ validations: {},
1757
+ listeners: {},
1758
+ formListeners: {}
1759
+ };
1760
+ this._formId = opts?.formId ?? uuid();
1761
+ this._devtoolsSubmissionOverride = false;
1762
+ let baseStoreVal = getDefaultFormState({
1763
+ ...opts?.defaultState,
1764
+ values: opts?.defaultValues ?? opts?.defaultState?.values
1765
+ });
1766
+ if (opts?.transform) {
1767
+ baseStoreVal = opts.transform({ state: baseStoreVal }).state;
1768
+ for (const errKey of Object.keys(baseStoreVal.errorMap)) {
1769
+ const errKeyMap = baseStoreVal.errorMap[errKey];
1770
+ if (errKeyMap === void 0 || !isGlobalFormValidationError(errKeyMap)) continue;
1771
+ for (const fieldName of Object.keys(errKeyMap.fields)) {
1772
+ const fieldErr = errKeyMap.fields[fieldName];
1773
+ if (fieldErr === void 0) continue;
1774
+ const existingFieldMeta = baseStoreVal.fieldMetaBase[fieldName];
1775
+ baseStoreVal.fieldMetaBase[fieldName] = {
1776
+ isTouched: false,
1777
+ isValidating: false,
1778
+ isBlurred: false,
1779
+ isDirty: false,
1780
+ ...existingFieldMeta ?? {},
1781
+ errorSourceMap: {
1782
+ ...existingFieldMeta?.["errorSourceMap"] ?? {},
1783
+ onChange: "form"
1784
+ },
1785
+ errorMap: {
1786
+ ...existingFieldMeta?.["errorMap"] ?? {},
1787
+ [errKey]: fieldErr
1788
+ }
1789
+ };
1790
+ }
1791
+ }
1792
+ }
1793
+ this.baseStore = createStore(baseStoreVal);
1794
+ let prevBaseStore = void 0;
1795
+ this.fieldMetaDerived = createStore((prevVal) => {
1796
+ const currBaseStore = this.baseStore.get();
1797
+ let originalMetaCount = 0;
1798
+ const fieldMeta = {};
1799
+ for (const fieldName of Object.keys(currBaseStore.fieldMetaBase)) {
1800
+ const currBaseMeta = currBaseStore.fieldMetaBase[fieldName];
1801
+ const prevBaseMeta = prevBaseStore?.fieldMetaBase[fieldName];
1802
+ const prevFieldInfo = prevVal?.[fieldName];
1803
+ const curFieldVal = getBy(currBaseStore.values, fieldName);
1804
+ let fieldErrors = prevFieldInfo?.errors;
1805
+ if (!prevBaseMeta || currBaseMeta.errorMap !== prevBaseMeta.errorMap) {
1806
+ fieldErrors = Object.values(currBaseMeta.errorMap ?? {}).filter((val) => val !== void 0);
1807
+ const fieldInstance = this.getFieldInfo(fieldName)?.instance;
1808
+ if (!fieldInstance || !fieldInstance.options.disableErrorFlat) fieldErrors = fieldErrors.flat(1);
1809
+ }
1810
+ const isFieldValid = !isNonEmptyArray(fieldErrors);
1811
+ const isFieldPristine = !currBaseMeta.isDirty;
1812
+ const isDefaultValue = evaluate(curFieldVal, getBy(this.options.defaultValues, fieldName)) || evaluate(curFieldVal, this.getFieldInfo(fieldName)?.instance?.options.defaultValue);
1813
+ if (prevFieldInfo && prevFieldInfo.isPristine === isFieldPristine && prevFieldInfo.isValid === isFieldValid && prevFieldInfo.isDefaultValue === isDefaultValue && prevFieldInfo.errors === fieldErrors && currBaseMeta === prevBaseMeta) {
1814
+ fieldMeta[fieldName] = prevFieldInfo;
1815
+ originalMetaCount++;
1816
+ continue;
1817
+ }
1818
+ fieldMeta[fieldName] = {
1819
+ ...currBaseMeta,
1820
+ errors: fieldErrors ?? [],
1821
+ isPristine: isFieldPristine,
1822
+ isValid: isFieldValid,
1823
+ isDefaultValue
1824
+ };
1825
+ }
1826
+ if (!Object.keys(currBaseStore.fieldMetaBase).length) return fieldMeta;
1827
+ if (prevVal && originalMetaCount === Object.keys(currBaseStore.fieldMetaBase).length) return prevVal;
1828
+ prevBaseStore = this.baseStore.get();
1829
+ return fieldMeta;
1830
+ });
1831
+ let prevBaseStoreForStore = void 0;
1832
+ this.store = createStore((prevVal) => {
1833
+ const currBaseStore = this.baseStore.get();
1834
+ const currFieldMeta = this.fieldMetaDerived.get();
1835
+ const fieldMetaValues = Object.values(currFieldMeta).filter(Boolean);
1836
+ const isFieldsValidating = fieldMetaValues.some((field) => field.isValidating);
1837
+ const isFieldsValid = fieldMetaValues.every((field) => field.isValid);
1838
+ const isTouched = fieldMetaValues.some((field) => field.isTouched);
1839
+ const isBlurred = fieldMetaValues.some((field) => field.isBlurred);
1840
+ const isDefaultValue = fieldMetaValues.every((field) => field.isDefaultValue);
1841
+ const shouldInvalidateOnMount = isTouched && currBaseStore.errorMap?.onMount;
1842
+ const isDirty = fieldMetaValues.some((field) => field.isDirty);
1843
+ const isPristine = !isDirty;
1844
+ const hasOnMountError = Boolean(currBaseStore.errorMap?.onMount || fieldMetaValues.some((f) => f?.errorMap?.onMount));
1845
+ const isValidating = !!isFieldsValidating;
1846
+ let errors = prevVal?.errors ?? [];
1847
+ if (!prevBaseStoreForStore || currBaseStore.errorMap !== prevBaseStoreForStore.errorMap) errors = Object.values(currBaseStore.errorMap).reduce((prev, curr) => {
1848
+ if (curr === void 0) return prev;
1849
+ if (curr && isGlobalFormValidationError(curr)) {
1850
+ prev.push(curr.form);
1851
+ return prev;
1852
+ }
1853
+ prev.push(curr);
1854
+ return prev;
1855
+ }, []);
1856
+ const isFormValid = errors.length === 0;
1857
+ const isValid = isFieldsValid && isFormValid;
1858
+ const submitInvalid = this.options.canSubmitWhenInvalid ?? false;
1859
+ const canSubmit = currBaseStore.submissionAttempts === 0 && !isTouched && !hasOnMountError || !isValidating && !currBaseStore.isSubmitting && isValid || submitInvalid;
1860
+ let errorMap = currBaseStore.errorMap;
1861
+ if (shouldInvalidateOnMount) {
1862
+ errors = errors.filter((err) => err !== currBaseStore.errorMap.onMount);
1863
+ errorMap = Object.assign(errorMap, { onMount: void 0 });
1864
+ }
1865
+ if (prevVal && prevBaseStoreForStore && prevVal.errorMap === errorMap && prevVal.fieldMeta === this.fieldMetaDerived.state && prevVal.errors === errors && prevVal.isFieldsValidating === isFieldsValidating && prevVal.isFieldsValid === isFieldsValid && prevVal.isFormValid === isFormValid && prevVal.isValid === isValid && prevVal.canSubmit === canSubmit && prevVal.isTouched === isTouched && prevVal.isBlurred === isBlurred && prevVal.isPristine === isPristine && prevVal.isDefaultValue === isDefaultValue && prevVal.isDirty === isDirty && evaluate(prevBaseStoreForStore, currBaseStore)) return prevVal;
1866
+ const state = {
1867
+ ...currBaseStore,
1868
+ errorMap,
1869
+ fieldMeta: this.fieldMetaDerived.state,
1870
+ errors,
1871
+ isFieldsValidating,
1872
+ isFieldsValid,
1873
+ isFormValid,
1874
+ isValid,
1875
+ canSubmit,
1876
+ isTouched,
1877
+ isBlurred,
1878
+ isPristine,
1879
+ isDefaultValue,
1880
+ isDirty
1881
+ };
1882
+ prevBaseStoreForStore = this.baseStore.get();
1883
+ return state;
1884
+ });
1885
+ this.handleSubmit = this.handleSubmit.bind(this);
1886
+ this.update(opts || {});
1887
+ }
1888
+ get state() {
1889
+ return this.store.state;
1890
+ }
1891
+ get formId() {
1892
+ return this._formId;
1893
+ }
1894
+ /**
1895
+ * @private
1896
+ */
1897
+ runValidator(props) {
1898
+ if (isStandardSchemaValidator(props.validate)) return standardSchemaValidators[props.type](props.value, props.validate);
1899
+ return props.validate(props.value);
1900
+ }
1901
+ handleSubmit(submitMeta) {
1902
+ return this._handleSubmit(submitMeta);
1903
+ }
1904
+ };
1905
+ function normalizeError$1(rawError) {
1906
+ if (rawError) {
1907
+ if (isGlobalFormValidationError(rawError)) return {
1908
+ formError: normalizeError$1(rawError.form).formError,
1909
+ fieldErrors: rawError.fields
1910
+ };
1911
+ return { formError: rawError };
1912
+ }
1913
+ return { formError: void 0 };
1914
+ }
1915
+ function getErrorMapKey$1(cause) {
1916
+ switch (cause) {
1917
+ case "submit": return "onSubmit";
1918
+ case "blur": return "onBlur";
1919
+ case "mount": return "onMount";
1920
+ case "server": return "onServer";
1921
+ case "dynamic": return "onDynamic";
1922
+ default: return "onChange";
1923
+ }
1924
+ }
1925
+ //#endregion
1926
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/FieldApi.js
1927
+ var FieldApi = class {
1928
+ /**
1929
+ * Initializes a new `FieldApi` instance.
1930
+ */
1931
+ constructor(opts) {
1932
+ this.options = {};
1933
+ this.mount = () => {
1934
+ if (this.options.defaultValue !== void 0 && !this.getMeta().isTouched) this.form.setFieldValue(this.name, this.options.defaultValue, { dontUpdateMeta: true });
1935
+ const info = this.getInfo();
1936
+ info.instance = this;
1937
+ this.update(this.options);
1938
+ const { onMount } = this.options.validators || {};
1939
+ if (onMount) {
1940
+ const error = this.runValidator({
1941
+ validate: onMount,
1942
+ value: {
1943
+ value: this.state.value,
1944
+ fieldApi: this,
1945
+ validationSource: "field"
1946
+ },
1947
+ type: "validate"
1948
+ });
1949
+ if (error) this.setMeta((prev) => ({
1950
+ ...prev,
1951
+ errorMap: {
1952
+ ...prev?.errorMap,
1953
+ onMount: error
1954
+ },
1955
+ errorSourceMap: {
1956
+ ...prev?.errorSourceMap,
1957
+ onMount: "field"
1958
+ }
1959
+ }));
1960
+ }
1961
+ this.options.listeners?.onMount?.({
1962
+ value: this.state.value,
1963
+ fieldApi: this
1964
+ });
1965
+ return () => {};
1966
+ };
1967
+ this.update = (opts2) => {
1968
+ this.options = opts2;
1969
+ this.name = opts2.name;
1970
+ if (!this.state.meta.isTouched && this.options.defaultValue !== void 0) {
1971
+ if (!evaluate(this.form.getFieldValue(this.name), opts2.defaultValue)) this.form.setFieldValue(this.name, opts2.defaultValue, {
1972
+ dontUpdateMeta: true,
1973
+ dontValidate: true,
1974
+ dontRunListeners: true
1975
+ });
1976
+ }
1977
+ if (!this.form.getFieldMeta(this.name)) this.form.setFieldMeta(this.name, this.state.meta);
1978
+ };
1979
+ this.getValue = () => {
1980
+ return this.form.getFieldValue(this.name);
1981
+ };
1982
+ this.setValue = (updater, options) => {
1983
+ this.form.setFieldValue(this.name, updater, mergeOpts(options, {
1984
+ dontRunListeners: true,
1985
+ dontValidate: true
1986
+ }));
1987
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
1988
+ if (!options?.dontValidate) this.validate("change");
1989
+ };
1990
+ this.getMeta = () => this.store.state.meta;
1991
+ this.setMeta = (updater) => this.form.setFieldMeta(this.name, updater);
1992
+ this.getInfo = () => this.form.getFieldInfo(this.name);
1993
+ this.pushValue = (value, options) => {
1994
+ this.form.pushFieldValue(this.name, value, mergeOpts(options, { dontRunListeners: true }));
1995
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
1996
+ };
1997
+ this.insertValue = (index, value, options) => {
1998
+ this.form.insertFieldValue(this.name, index, value, mergeOpts(options, { dontRunListeners: true }));
1999
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2000
+ };
2001
+ this.replaceValue = (index, value, options) => {
2002
+ this.form.replaceFieldValue(this.name, index, value, mergeOpts(options, { dontRunListeners: true }));
2003
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2004
+ };
2005
+ this.removeValue = (index, options) => {
2006
+ this.form.removeFieldValue(this.name, index, mergeOpts(options, { dontRunListeners: true }));
2007
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2008
+ };
2009
+ this.swapValues = (aIndex, bIndex, options) => {
2010
+ this.form.swapFieldValues(this.name, aIndex, bIndex, mergeOpts(options, { dontRunListeners: true }));
2011
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2012
+ };
2013
+ this.moveValue = (aIndex, bIndex, options) => {
2014
+ this.form.moveFieldValues(this.name, aIndex, bIndex, mergeOpts(options, { dontRunListeners: true }));
2015
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2016
+ };
2017
+ this.clearValues = (options) => {
2018
+ this.form.clearFieldValues(this.name, mergeOpts(options, { dontRunListeners: true }));
2019
+ if (!options?.dontRunListeners) this.triggerOnChangeListener();
2020
+ };
2021
+ this.getLinkedFields = (cause) => {
2022
+ const fields = Object.values(this.form.fieldInfo);
2023
+ const linkedFields = [];
2024
+ for (const field of fields) {
2025
+ if (!field.instance) continue;
2026
+ const { onChangeListenTo, onBlurListenTo } = field.instance.options.validators || {};
2027
+ if (cause === "change" && onChangeListenTo?.includes(this.name)) linkedFields.push(field.instance);
2028
+ if (cause === "blur" && onBlurListenTo?.includes(this.name)) linkedFields.push(field.instance);
2029
+ }
2030
+ return linkedFields;
2031
+ };
2032
+ this.validateSync = (cause, errorFromForm) => {
2033
+ const validates = getSyncValidatorArray(cause, {
2034
+ ...this.options,
2035
+ form: this.form,
2036
+ validationLogic: this.form.options.validationLogic || defaultValidationLogic
2037
+ });
2038
+ const linkedFieldValidates = this.getLinkedFields(cause).reduce((acc, field) => {
2039
+ const fieldValidates = getSyncValidatorArray(cause, {
2040
+ ...field.options,
2041
+ form: field.form,
2042
+ validationLogic: field.form.options.validationLogic || defaultValidationLogic
2043
+ });
2044
+ fieldValidates.forEach((validate) => {
2045
+ validate.field = field;
2046
+ });
2047
+ return acc.concat(fieldValidates);
2048
+ }, []);
2049
+ let hasErrored = false;
2050
+ batch(() => {
2051
+ const validateFieldFn = (field, validateObj) => {
2052
+ const errorMapKey = getErrorMapKey(validateObj.cause);
2053
+ const fieldLevelError = validateObj.validate ? normalizeError(field.runValidator({
2054
+ validate: validateObj.validate,
2055
+ value: {
2056
+ value: field.store.state.value,
2057
+ validationSource: "field",
2058
+ fieldApi: field
2059
+ },
2060
+ type: "validate"
2061
+ })) : void 0;
2062
+ const formLevelError = errorFromForm[errorMapKey];
2063
+ const { newErrorValue, newSource } = determineFieldLevelErrorSourceAndValue({
2064
+ formLevelError,
2065
+ fieldLevelError
2066
+ });
2067
+ if (field.state.meta.errorMap?.[errorMapKey] !== newErrorValue) field.setMeta((prev) => ({
2068
+ ...prev,
2069
+ errorMap: {
2070
+ ...prev.errorMap,
2071
+ [errorMapKey]: newErrorValue
2072
+ },
2073
+ errorSourceMap: {
2074
+ ...prev.errorSourceMap,
2075
+ [errorMapKey]: newSource
2076
+ }
2077
+ }));
2078
+ if (newErrorValue) hasErrored = true;
2079
+ };
2080
+ for (const validateObj of validates) validateFieldFn(this, validateObj);
2081
+ for (const fieldValitateObj of linkedFieldValidates) {
2082
+ if (!fieldValitateObj.validate) continue;
2083
+ validateFieldFn(fieldValitateObj.field, fieldValitateObj);
2084
+ }
2085
+ });
2086
+ const submitErrKey = getErrorMapKey("submit");
2087
+ if (this.state.meta.errorMap?.[submitErrKey] && cause !== "submit" && !hasErrored) this.setMeta((prev) => ({
2088
+ ...prev,
2089
+ errorMap: {
2090
+ ...prev.errorMap,
2091
+ [submitErrKey]: void 0
2092
+ },
2093
+ errorSourceMap: {
2094
+ ...prev.errorSourceMap,
2095
+ [submitErrKey]: void 0
2096
+ }
2097
+ }));
2098
+ return { hasErrored };
2099
+ };
2100
+ this.validateAsync = async (cause, formValidationResultPromise) => {
2101
+ const validates = getAsyncValidatorArray(cause, {
2102
+ ...this.options,
2103
+ form: this.form,
2104
+ validationLogic: this.form.options.validationLogic || defaultValidationLogic
2105
+ });
2106
+ const asyncFormValidationResults = await formValidationResultPromise;
2107
+ const linkedFields = this.getLinkedFields(cause);
2108
+ const linkedFieldValidates = linkedFields.reduce((acc, field) => {
2109
+ const fieldValidates = getAsyncValidatorArray(cause, {
2110
+ ...field.options,
2111
+ form: field.form,
2112
+ validationLogic: field.form.options.validationLogic || defaultValidationLogic
2113
+ });
2114
+ fieldValidates.forEach((validate) => {
2115
+ validate.field = field;
2116
+ });
2117
+ return acc.concat(fieldValidates);
2118
+ }, []);
2119
+ const validatesPromises = [];
2120
+ const linkedPromises = [];
2121
+ const hasAsyncValidators = validates.some((v) => v.validate) || linkedFieldValidates.some((v) => v.validate);
2122
+ if (hasAsyncValidators) {
2123
+ if (!this.state.meta.isValidating) this.setMeta((prev) => ({
2124
+ ...prev,
2125
+ isValidating: true
2126
+ }));
2127
+ for (const linkedField of linkedFields) linkedField.setMeta((prev) => ({
2128
+ ...prev,
2129
+ isValidating: true
2130
+ }));
2131
+ }
2132
+ const validateFieldAsyncFn = (field, validateObj, promises) => {
2133
+ const errorMapKey = getErrorMapKey(validateObj.cause);
2134
+ field.getInfo().validationMetaMap[errorMapKey]?.lastAbortController.abort();
2135
+ const controller = new AbortController();
2136
+ this.getInfo().validationMetaMap[errorMapKey] = { lastAbortController: controller };
2137
+ promises.push(new Promise(async (resolve) => {
2138
+ let rawError;
2139
+ try {
2140
+ rawError = await new Promise((rawResolve, rawReject) => {
2141
+ if (this.timeoutIds.validations[validateObj.cause]) clearTimeout(this.timeoutIds.validations[validateObj.cause]);
2142
+ this.timeoutIds.validations[validateObj.cause] = setTimeout(async () => {
2143
+ if (controller.signal.aborted) return rawResolve(void 0);
2144
+ try {
2145
+ rawResolve(await this.runValidator({
2146
+ validate: validateObj.validate,
2147
+ value: {
2148
+ value: field.store.state.value,
2149
+ fieldApi: field,
2150
+ signal: controller.signal,
2151
+ validationSource: "field"
2152
+ },
2153
+ type: "validateAsync"
2154
+ }));
2155
+ } catch (e) {
2156
+ rawReject(e);
2157
+ }
2158
+ }, validateObj.debounceMs);
2159
+ });
2160
+ } catch (e) {
2161
+ rawError = e;
2162
+ }
2163
+ if (controller.signal.aborted) return resolve(void 0);
2164
+ const fieldLevelError = normalizeError(rawError);
2165
+ const formLevelError = asyncFormValidationResults[this.name]?.[errorMapKey];
2166
+ const { newErrorValue, newSource } = determineFieldLevelErrorSourceAndValue({
2167
+ formLevelError,
2168
+ fieldLevelError
2169
+ });
2170
+ field.setMeta((prev) => {
2171
+ return {
2172
+ ...prev,
2173
+ errorMap: {
2174
+ ...prev?.errorMap,
2175
+ [errorMapKey]: newErrorValue
2176
+ },
2177
+ errorSourceMap: {
2178
+ ...prev.errorSourceMap,
2179
+ [errorMapKey]: newSource
2180
+ }
2181
+ };
2182
+ });
2183
+ resolve(newErrorValue);
2184
+ }));
2185
+ };
2186
+ for (const validateObj of validates) {
2187
+ if (!validateObj.validate) continue;
2188
+ validateFieldAsyncFn(this, validateObj, validatesPromises);
2189
+ }
2190
+ for (const fieldValitateObj of linkedFieldValidates) {
2191
+ if (!fieldValitateObj.validate) continue;
2192
+ validateFieldAsyncFn(fieldValitateObj.field, fieldValitateObj, linkedPromises);
2193
+ }
2194
+ let results = [];
2195
+ if (validatesPromises.length || linkedPromises.length) {
2196
+ results = await Promise.all(validatesPromises);
2197
+ await Promise.all(linkedPromises);
2198
+ }
2199
+ if (hasAsyncValidators) {
2200
+ this.setMeta((prev) => ({
2201
+ ...prev,
2202
+ isValidating: false
2203
+ }));
2204
+ for (const linkedField of linkedFields) linkedField.setMeta((prev) => ({
2205
+ ...prev,
2206
+ isValidating: false
2207
+ }));
2208
+ }
2209
+ return results.filter(Boolean);
2210
+ };
2211
+ this.validate = (cause, opts2) => {
2212
+ if (!this.state.meta.isTouched) return [];
2213
+ const { fieldsErrorMap } = opts2?.skipFormValidation ? { fieldsErrorMap: {} } : this.form.validateSync(cause);
2214
+ const { hasErrored } = this.validateSync(cause, fieldsErrorMap[this.name] ?? {});
2215
+ if (hasErrored && !this.options.asyncAlways) {
2216
+ this.getInfo().validationMetaMap[getErrorMapKey(cause)]?.lastAbortController.abort();
2217
+ return this.state.meta.errors;
2218
+ }
2219
+ const formValidationResultPromise = opts2?.skipFormValidation ? Promise.resolve({}) : this.form.validateAsync(cause);
2220
+ return this.validateAsync(cause, formValidationResultPromise);
2221
+ };
2222
+ this.handleChange = (updater) => {
2223
+ this.setValue(updater);
2224
+ };
2225
+ this.handleBlur = () => {
2226
+ if (!this.state.meta.isTouched) this.setMeta((prev) => ({
2227
+ ...prev,
2228
+ isTouched: true
2229
+ }));
2230
+ if (!this.state.meta.isBlurred) this.setMeta((prev) => ({
2231
+ ...prev,
2232
+ isBlurred: true
2233
+ }));
2234
+ this.validate("blur");
2235
+ this.triggerOnBlurListener();
2236
+ };
2237
+ this.setErrorMap = (errorMap) => {
2238
+ this.setMeta((prev) => ({
2239
+ ...prev,
2240
+ errorMap: {
2241
+ ...prev.errorMap,
2242
+ ...errorMap
2243
+ }
2244
+ }));
2245
+ };
2246
+ this.parseValueWithSchema = (schema) => {
2247
+ return standardSchemaValidators.validate({
2248
+ value: this.state.value,
2249
+ validationSource: "field"
2250
+ }, schema);
2251
+ };
2252
+ this.parseValueWithSchemaAsync = (schema) => {
2253
+ return standardSchemaValidators.validateAsync({
2254
+ value: this.state.value,
2255
+ validationSource: "field"
2256
+ }, schema);
2257
+ };
2258
+ this.triggerOnChangeListener = () => {
2259
+ const formDebounceMs = this.form.options.listeners?.onChangeDebounceMs;
2260
+ if (formDebounceMs && formDebounceMs > 0) {
2261
+ if (this.timeoutIds.formListeners.change) clearTimeout(this.timeoutIds.formListeners.change);
2262
+ this.timeoutIds.formListeners.change = setTimeout(() => {
2263
+ this.form.options.listeners?.onChange?.({
2264
+ formApi: this.form,
2265
+ fieldApi: this
2266
+ });
2267
+ }, formDebounceMs);
2268
+ } else this.form.options.listeners?.onChange?.({
2269
+ formApi: this.form,
2270
+ fieldApi: this
2271
+ });
2272
+ const fieldDebounceMs = this.options.listeners?.onChangeDebounceMs;
2273
+ if (fieldDebounceMs && fieldDebounceMs > 0) {
2274
+ if (this.timeoutIds.listeners.change) clearTimeout(this.timeoutIds.listeners.change);
2275
+ this.timeoutIds.listeners.change = setTimeout(() => {
2276
+ this.options.listeners?.onChange?.({
2277
+ value: this.state.value,
2278
+ fieldApi: this
2279
+ });
2280
+ }, fieldDebounceMs);
2281
+ } else this.options.listeners?.onChange?.({
2282
+ value: this.state.value,
2283
+ fieldApi: this
2284
+ });
2285
+ };
2286
+ this.form = opts.form;
2287
+ this.name = opts.name;
2288
+ this.options = opts;
2289
+ this.timeoutIds = {
2290
+ validations: {},
2291
+ listeners: {},
2292
+ formListeners: {}
2293
+ };
2294
+ this.store = createStore((prevVal) => {
2295
+ this.form.store.get();
2296
+ const meta = this.form.getFieldMeta(this.name) ?? {
2297
+ ...defaultFieldMeta,
2298
+ ...opts.defaultMeta
2299
+ };
2300
+ let value = this.form.getFieldValue(this.name);
2301
+ if (!meta.isTouched && value === void 0 && this.options.defaultValue !== void 0 && !evaluate(value, this.options.defaultValue)) value = this.options.defaultValue;
2302
+ if (prevVal && prevVal.value === value && prevVal.meta === meta) return prevVal;
2303
+ return {
2304
+ value,
2305
+ meta
2306
+ };
2307
+ });
2308
+ }
2309
+ /**
2310
+ * The current field state.
2311
+ */
2312
+ get state() {
2313
+ return this.store.state;
2314
+ }
2315
+ /**
2316
+ * @private
2317
+ */
2318
+ runValidator(props) {
2319
+ if (isStandardSchemaValidator(props.validate)) return standardSchemaValidators[props.type](props.value, props.validate);
2320
+ return props.validate(props.value);
2321
+ }
2322
+ triggerOnBlurListener() {
2323
+ const formDebounceMs = this.form.options.listeners?.onBlurDebounceMs;
2324
+ if (formDebounceMs && formDebounceMs > 0) {
2325
+ if (this.timeoutIds.formListeners.blur) clearTimeout(this.timeoutIds.formListeners.blur);
2326
+ this.timeoutIds.formListeners.blur = setTimeout(() => {
2327
+ this.form.options.listeners?.onBlur?.({
2328
+ formApi: this.form,
2329
+ fieldApi: this
2330
+ });
2331
+ }, formDebounceMs);
2332
+ } else this.form.options.listeners?.onBlur?.({
2333
+ formApi: this.form,
2334
+ fieldApi: this
2335
+ });
2336
+ const fieldDebounceMs = this.options.listeners?.onBlurDebounceMs;
2337
+ if (fieldDebounceMs && fieldDebounceMs > 0) {
2338
+ if (this.timeoutIds.listeners.blur) clearTimeout(this.timeoutIds.listeners.blur);
2339
+ this.timeoutIds.listeners.blur = setTimeout(() => {
2340
+ this.options.listeners?.onBlur?.({
2341
+ value: this.state.value,
2342
+ fieldApi: this
2343
+ });
2344
+ }, fieldDebounceMs);
2345
+ } else this.options.listeners?.onBlur?.({
2346
+ value: this.state.value,
2347
+ fieldApi: this
2348
+ });
2349
+ }
2350
+ };
2351
+ function normalizeError(rawError) {
2352
+ if (rawError) return rawError;
2353
+ }
2354
+ function getErrorMapKey(cause) {
2355
+ switch (cause) {
2356
+ case "submit": return "onSubmit";
2357
+ case "blur": return "onBlur";
2358
+ case "mount": return "onMount";
2359
+ case "server": return "onServer";
2360
+ case "dynamic": return "onDynamic";
2361
+ default: return "onChange";
2362
+ }
2363
+ }
2364
+ //#endregion
2365
+ //#region ../../node_modules/.pnpm/@tanstack+form-core@1.28.5/node_modules/@tanstack/form-core/dist/esm/transform.js
2366
+ function mergeAndUpdate(form, fn) {
2367
+ if (!fn) return;
2368
+ const newObj = Object.assign({}, form, { state: deepCopy(form.state) });
2369
+ fn(newObj);
2370
+ if (newObj.fieldInfo !== form.fieldInfo) form.fieldInfo = newObj.fieldInfo;
2371
+ if (newObj.options !== form.options) form.options = newObj.options;
2372
+ const diffedObject = Object.keys({
2373
+ values: null,
2374
+ validationMetaMap: null,
2375
+ fieldMetaBase: null,
2376
+ isSubmitting: null,
2377
+ isSubmitted: null,
2378
+ isValidating: null,
2379
+ submissionAttempts: null,
2380
+ isSubmitSuccessful: null,
2381
+ _force_re_eval: null
2382
+ }).reduce((prev, key) => {
2383
+ if (form.state[key] !== newObj.state[key]) prev[key] = newObj.state[key];
2384
+ return prev;
2385
+ }, {});
2386
+ batch(() => {
2387
+ if (Object.keys(diffedObject).length) form.baseStore.setState((prev) => ({
2388
+ ...prev,
2389
+ ...diffedObject
2390
+ }));
2391
+ if (newObj.state.errorMap !== form.state.errorMap) form.setErrorMap(newObj.state.errorMap);
2392
+ });
2393
+ return newObj;
2394
+ }
2395
+ //#endregion
2396
+ export { uuid as a, functionalUpdate as i, FieldApi as n, batch as o, FormApi as r, createStore as s, mergeAndUpdate as t };