attaform 0.16.4 → 0.17.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 (84) hide show
  1. package/README.md +4 -2
  2. package/dist/chunks/devtools.cjs +19 -12
  3. package/dist/chunks/devtools.cjs.map +1 -1
  4. package/dist/chunks/devtools.mjs +19 -12
  5. package/dist/chunks/devtools.mjs.map +1 -1
  6. package/dist/chunks/indexeddb.cjs +1 -1
  7. package/dist/chunks/indexeddb.mjs +1 -1
  8. package/dist/chunks/local-storage.cjs +1 -1
  9. package/dist/chunks/local-storage.mjs +1 -1
  10. package/dist/chunks/session-storage.cjs +1 -1
  11. package/dist/chunks/session-storage.mjs +1 -1
  12. package/dist/index.cjs +26 -7
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +52 -9
  15. package/dist/index.d.mts +52 -9
  16. package/dist/index.d.ts +52 -9
  17. package/dist/index.mjs +28 -9
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/nuxt.d.cts +1 -1
  20. package/dist/nuxt.d.mts +1 -1
  21. package/dist/nuxt.d.ts +1 -1
  22. package/dist/runtime/plugins/attaform.cjs +3 -3
  23. package/dist/runtime/plugins/attaform.cjs.map +1 -1
  24. package/dist/runtime/plugins/attaform.mjs +3 -3
  25. package/dist/runtime/plugins/attaform.mjs.map +1 -1
  26. package/dist/shared/{attaform.CMRmwGDt.d.cts → attaform.B1jvxsOF.d.mts} +1 -1
  27. package/dist/shared/{attaform.DyV1O4tI.mjs → attaform.B3ZaPIzS.mjs} +1436 -391
  28. package/dist/shared/attaform.B3ZaPIzS.mjs.map +1 -0
  29. package/dist/shared/{attaform.Dd_pWnmn.cjs → attaform.B5qiXQwN.cjs} +59 -10
  30. package/dist/shared/attaform.B5qiXQwN.cjs.map +1 -0
  31. package/dist/shared/{attaform.CIwZtbGV.cjs → attaform.BBM2muQ9.cjs} +2 -2
  32. package/dist/shared/{attaform.CIwZtbGV.cjs.map → attaform.BBM2muQ9.cjs.map} +1 -1
  33. package/dist/shared/{attaform.keLBaHB6.cjs → attaform.BV40t5y2.cjs} +240 -115
  34. package/dist/shared/attaform.BV40t5y2.cjs.map +1 -0
  35. package/dist/shared/attaform.C0iFnTN0.d.ts +165 -0
  36. package/dist/shared/{attaform.CXMOheyZ.d.mts → attaform.C6qzEdIM.d.cts} +1 -1
  37. package/dist/shared/{attaform.CJttVxRj.cjs → attaform.C8LVFVVe.cjs} +2 -2
  38. package/dist/shared/{attaform.CJttVxRj.cjs.map → attaform.C8LVFVVe.cjs.map} +1 -1
  39. package/dist/shared/attaform.CHorcsIU.d.cts +165 -0
  40. package/dist/shared/{attaform.BfMxsfmE.mjs → attaform.CIEQgJnM.mjs} +143 -78
  41. package/dist/shared/attaform.CIEQgJnM.mjs.map +1 -0
  42. package/dist/shared/{attaform.CCQkY4Ta.d.ts → attaform.CTwNcpLE.d.ts} +1 -1
  43. package/dist/shared/{attaform.UA19EF3J.mjs → attaform.CVCmBKZX.mjs} +59 -10
  44. package/dist/shared/attaform.CVCmBKZX.mjs.map +1 -0
  45. package/dist/shared/{attaform.CU3JperC.d.cts → attaform.C_5aB6EQ.d.cts} +657 -135
  46. package/dist/shared/{attaform.CU3JperC.d.mts → attaform.C_5aB6EQ.d.mts} +657 -135
  47. package/dist/shared/{attaform.CU3JperC.d.ts → attaform.C_5aB6EQ.d.ts} +657 -135
  48. package/dist/shared/{attaform.fegmBJaq.cjs → attaform.Cer8JO_P.cjs} +1435 -389
  49. package/dist/shared/attaform.Cer8JO_P.cjs.map +1 -0
  50. package/dist/shared/{attaform.g7rfuXdz.mjs → attaform.CpERWz3u.mjs} +240 -115
  51. package/dist/shared/attaform.CpERWz3u.mjs.map +1 -0
  52. package/dist/shared/attaform.CuE-bS1C.d.mts +165 -0
  53. package/dist/shared/{attaform.rIRYSUI1.cjs → attaform.Dee2rU1P.cjs} +145 -77
  54. package/dist/shared/attaform.Dee2rU1P.cjs.map +1 -0
  55. package/dist/shared/{attaform.CINUMjPq.mjs → attaform.Vo-Kft0t.mjs} +2 -2
  56. package/dist/shared/{attaform.CINUMjPq.mjs.map → attaform.Vo-Kft0t.mjs.map} +1 -1
  57. package/dist/shared/{attaform.DZRj9s0s.mjs → attaform.h1sq3BFu.mjs} +2 -2
  58. package/dist/shared/{attaform.DZRj9s0s.mjs.map → attaform.h1sq3BFu.mjs.map} +1 -1
  59. package/dist/zod-v3.cjs +3 -3
  60. package/dist/zod-v3.d.cts +27 -5
  61. package/dist/zod-v3.d.mts +27 -5
  62. package/dist/zod-v3.d.ts +27 -5
  63. package/dist/zod-v3.mjs +3 -3
  64. package/dist/zod-v4.cjs +3 -3
  65. package/dist/zod-v4.d.cts +16 -42
  66. package/dist/zod-v4.d.mts +16 -42
  67. package/dist/zod-v4.d.ts +16 -42
  68. package/dist/zod-v4.mjs +3 -3
  69. package/dist/zod.cjs +4 -4
  70. package/dist/zod.cjs.map +1 -1
  71. package/dist/zod.d.cts +7 -5
  72. package/dist/zod.d.mts +7 -5
  73. package/dist/zod.d.ts +7 -5
  74. package/dist/zod.mjs +5 -5
  75. package/dist/zod.mjs.map +1 -1
  76. package/package.json +6 -11
  77. package/dist/shared/attaform.BfMxsfmE.mjs.map +0 -1
  78. package/dist/shared/attaform.Dd_pWnmn.cjs.map +0 -1
  79. package/dist/shared/attaform.DyV1O4tI.mjs.map +0 -1
  80. package/dist/shared/attaform.UA19EF3J.mjs.map +0 -1
  81. package/dist/shared/attaform.fegmBJaq.cjs.map +0 -1
  82. package/dist/shared/attaform.g7rfuXdz.mjs.map +0 -1
  83. package/dist/shared/attaform.keLBaHB6.cjs.map +0 -1
  84. package/dist/shared/attaform.rIRYSUI1.cjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const useFormContext = require('./attaform.fegmBJaq.cjs');
4
- const plugin = require('./attaform.rIRYSUI1.cjs');
3
+ const useFormContext = require('./attaform.Cer8JO_P.cjs');
4
+ const plugin = require('./attaform.Dee2rU1P.cjs');
5
5
  const fieldMetaStore = require('./attaform.C8CyvYa_.cjs');
6
- const paths = require('./attaform.CIwZtbGV.cjs');
6
+ const paths = require('./attaform.BBM2muQ9.cjs');
7
7
  const zod = require('zod');
8
8
 
9
9
  const fieldMeta = fieldMetaStore.fieldMetaStore;
@@ -117,6 +117,8 @@ function kindOf(schema) {
117
117
  return "intersection";
118
118
  case "catch":
119
119
  return "catch";
120
+ case "transform":
121
+ return "transform";
120
122
  case "promise":
121
123
  return "promise";
122
124
  case "custom":
@@ -174,6 +176,18 @@ function unwrapPipe(schema) {
174
176
  const def = readDef(schema);
175
177
  return def?.in ?? def?.out;
176
178
  }
179
+ function unwrapPipeIn(schema) {
180
+ const def = readDef(schema);
181
+ return def?.in;
182
+ }
183
+ function unwrapPipeOut(schema) {
184
+ const def = readDef(schema);
185
+ return def?.out;
186
+ }
187
+ function readTransformFn(schema) {
188
+ const def = readDef(schema);
189
+ return typeof def?.transform === "function" ? def.transform : void 0;
190
+ }
177
191
  function unwrapLazy(schema) {
178
192
  const def = readDef(schema);
179
193
  const getter = def?.getter;
@@ -365,11 +379,7 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
365
379
  }
366
380
  case "lazy": {
367
381
  const getter = getLazyGetter(schema);
368
- if (getter !== void 0 && lazyGetters.includes(getter)) {
369
- throw new UnsupportedSchemaError(
370
- `[attaform/zod] Recursive z.lazy() at '${labelPath(path)}'`
371
- );
372
- }
382
+ if (getter !== void 0 && lazyGetters.includes(getter)) return;
373
383
  const inner = unwrapLazy(schema);
374
384
  if (inner !== void 0) {
375
385
  assertSupportedKinds(
@@ -405,6 +415,7 @@ function assertSupportedKinds(schema, path = [], lazyGetters = []) {
405
415
  case "promise":
406
416
  case "custom":
407
417
  case "template-literal":
418
+ case "transform":
408
419
  return;
409
420
  default: {
410
421
  const _exhaustive = kind;
@@ -423,6 +434,15 @@ function unwrapToDiscriminatedUnion(schema) {
423
434
  next = unwrapInner(current);
424
435
  } else if (kind === "pipe") {
425
436
  next = unwrapPipe(current);
437
+ } else if (kind === "intersection") {
438
+ const left = getIntersectionLeft(current);
439
+ const right = getIntersectionRight(current);
440
+ const leftDU = left !== void 0 ? unwrapToDiscriminatedUnion(left) : void 0;
441
+ const rightDU = right !== void 0 ? unwrapToDiscriminatedUnion(right) : void 0;
442
+ if (leftDU !== void 0 && rightDU !== void 0) {
443
+ return void 0;
444
+ }
445
+ return leftDU ?? rightDU;
426
446
  }
427
447
  if (next === void 0) return void 0;
428
448
  current = next;
@@ -550,6 +570,7 @@ function computeFingerprint(schema, cache, inProgress) {
550
570
  case "promise":
551
571
  case "custom":
552
572
  case "template-literal":
573
+ case "transform":
553
574
  return `${kind}:*`;
554
575
  default: {
555
576
  const _ = kind;
@@ -631,12 +652,10 @@ const PERMISSIVE = /* @__PURE__ */ new Set([
631
652
  "map",
632
653
  "set"
633
654
  ]);
634
- const MAX_LAZY_DEPTH = 64;
635
- function slimPrimitivesOf(schema) {
636
- return walk(schema, 0);
655
+ function slimPrimitivesOf(schema, maxRecursionDepth) {
656
+ return walk(schema, 0, maxRecursionDepth);
637
657
  }
638
- function walk(schema, depth) {
639
- if (depth > MAX_LAZY_DEPTH) return new Set(PERMISSIVE);
658
+ function walk(schema, lazyDepth, maxDepth) {
640
659
  const kind = kindOf(schema);
641
660
  switch (kind) {
642
661
  case "string":
@@ -680,13 +699,13 @@ function walk(schema, depth) {
680
699
  return /* @__PURE__ */ new Set(["set"]);
681
700
  case "optional": {
682
701
  const inner = unwrapInner(schema);
683
- const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, depth + 1);
702
+ const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, lazyDepth, maxDepth);
684
703
  innerSet.add("undefined");
685
704
  return innerSet;
686
705
  }
687
706
  case "nullable": {
688
707
  const inner = unwrapInner(schema);
689
- const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, depth + 1);
708
+ const innerSet = inner === void 0 ? /* @__PURE__ */ new Set() : walk(inner, lazyDepth, maxDepth);
690
709
  innerSet.add("null");
691
710
  return innerSet;
692
711
  }
@@ -694,30 +713,31 @@ function walk(schema, depth) {
694
713
  case "readonly":
695
714
  case "catch": {
696
715
  const inner = unwrapInner(schema);
697
- return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, depth + 1);
716
+ return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, lazyDepth, maxDepth);
698
717
  }
699
718
  case "pipe": {
700
719
  const inner = unwrapPipe(schema);
701
- return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, depth + 1);
720
+ return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, lazyDepth, maxDepth);
702
721
  }
703
722
  case "lazy": {
723
+ if (lazyDepth >= maxDepth) return new Set(PERMISSIVE);
704
724
  const inner = unwrapLazy(schema);
705
- return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, depth + 1);
725
+ return inner === void 0 ? new Set(PERMISSIVE) : walk(inner, lazyDepth + 1, maxDepth);
706
726
  }
707
727
  case "union":
708
728
  case "discriminated-union": {
709
729
  const options = getUnionOptions(schema);
710
730
  const out = /* @__PURE__ */ new Set();
711
731
  for (const opt of options) {
712
- for (const k of walk(opt, depth + 1)) out.add(k);
732
+ for (const k of walk(opt, lazyDepth, maxDepth)) out.add(k);
713
733
  }
714
734
  return out.size === 0 ? new Set(PERMISSIVE) : out;
715
735
  }
716
736
  case "intersection": {
717
737
  const left = getIntersectionLeft(schema);
718
738
  const right = getIntersectionRight(schema);
719
- const leftSet = left === void 0 ? new Set(PERMISSIVE) : walk(left, depth + 1);
720
- const rightSet = right === void 0 ? new Set(PERMISSIVE) : walk(right, depth + 1);
739
+ const leftSet = left === void 0 ? new Set(PERMISSIVE) : walk(left, lazyDepth, maxDepth);
740
+ const rightSet = right === void 0 ? new Set(PERMISSIVE) : walk(right, lazyDepth, maxDepth);
721
741
  const out = /* @__PURE__ */ new Set();
722
742
  for (const k of leftSet) if (rightSet.has(k)) out.add(k);
723
743
  return out;
@@ -733,6 +753,8 @@ function walk(schema, depth) {
733
753
  case "promise":
734
754
  case "custom":
735
755
  case "template-literal":
756
+ case "transform":
757
+ return new Set(PERMISSIVE);
736
758
  default:
737
759
  return new Set(PERMISSIVE);
738
760
  }
@@ -766,13 +788,13 @@ function slimKindOfRaw(value) {
766
788
  }
767
789
 
768
790
  const PATH_SEPARATOR$1 = ".";
769
- function getNestedZodSchemasAtPath(schema, path) {
770
- if (Array.isArray(path)) return walkSegments(schema, path.map(String));
791
+ function getNestedZodSchemasAtPath(schema, path, maxRecursionDepth) {
792
+ if (Array.isArray(path)) return walkSegments(schema, path.map(String), maxRecursionDepth, 0);
771
793
  const pathString = path;
772
794
  if (pathString.length === 0) return [schema];
773
- return walkSegments(schema, pathString.split(PATH_SEPARATOR$1));
795
+ return walkSegments(schema, pathString.split(PATH_SEPARATOR$1), maxRecursionDepth, 0);
774
796
  }
775
- function walkSegments(schema, segments) {
797
+ function walkSegments(schema, segments, maxDepth, lazyDepth) {
776
798
  if (segments.length === 0) return [schema];
777
799
  const [head, ...rest] = segments;
778
800
  if (head === void 0) return [schema];
@@ -782,23 +804,25 @@ function walkSegments(schema, segments) {
782
804
  const shape = getObjectShape(schema);
783
805
  if (!Object.hasOwn(shape, head)) return [];
784
806
  const next = shape[head];
785
- return next === void 0 ? [] : walkSegments(next, rest);
807
+ return next === void 0 ? [] : walkSegments(next, rest, maxDepth, lazyDepth);
786
808
  }
787
809
  case "array":
788
- return walkSegments(getArrayElement(schema), rest);
810
+ return walkSegments(getArrayElement(schema), rest, maxDepth, lazyDepth);
789
811
  case "set":
790
- return walkSegments(getSetValueType(schema), rest);
812
+ return walkSegments(getSetValueType(schema), rest, maxDepth, lazyDepth);
791
813
  case "record":
792
- return walkSegments(getRecordValueType(schema), rest);
814
+ return walkSegments(getRecordValueType(schema), rest, maxDepth, lazyDepth);
793
815
  case "tuple": {
794
816
  const index = Number(head);
795
817
  if (!Number.isInteger(index)) return [];
796
818
  const items = getTupleItems(schema);
797
819
  const item = items[index];
798
- return item === void 0 ? [] : walkSegments(item, rest);
820
+ return item === void 0 ? [] : walkSegments(item, rest, maxDepth, lazyDepth);
799
821
  }
800
822
  case "union":
801
- return getUnionOptions(schema).flatMap((opt) => walkSegments(opt, segments));
823
+ return getUnionOptions(schema).flatMap(
824
+ (opt) => walkSegments(opt, segments, maxDepth, lazyDepth)
825
+ );
802
826
  case "discriminated-union": {
803
827
  const options = getDiscriminatedOptions(schema);
804
828
  const matching = options.filter((opt) => {
@@ -806,7 +830,7 @@ function walkSegments(schema, segments) {
806
830
  return Object.hasOwn(shape, head);
807
831
  });
808
832
  const candidates = matching.length > 0 ? matching : options;
809
- return candidates.flatMap((opt) => walkSegments(opt, segments));
833
+ return candidates.flatMap((opt) => walkSegments(opt, segments, maxDepth, lazyDepth));
810
834
  }
811
835
  case "optional":
812
836
  case "nullable":
@@ -814,21 +838,22 @@ function walkSegments(schema, segments) {
814
838
  case "readonly":
815
839
  case "catch": {
816
840
  const inner = unwrapInner(schema);
817
- return inner === void 0 ? [] : walkSegments(inner, segments);
841
+ return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth);
818
842
  }
819
843
  case "pipe": {
820
844
  const inner = unwrapPipe(schema);
821
- return inner === void 0 ? [] : walkSegments(inner, segments);
845
+ return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth);
822
846
  }
823
847
  case "lazy": {
848
+ if (lazyDepth >= maxDepth) return [];
824
849
  const inner = unwrapLazy(schema);
825
- return inner === void 0 ? [] : walkSegments(inner, segments);
850
+ return inner === void 0 ? [] : walkSegments(inner, segments, maxDepth, lazyDepth + 1);
826
851
  }
827
852
  case "intersection": {
828
853
  const left = getIntersectionLeft(schema);
829
854
  const right = getIntersectionRight(schema);
830
- const leftResults = left === void 0 ? [] : walkSegments(left, segments);
831
- const rightResults = right === void 0 ? [] : walkSegments(right, segments);
855
+ const leftResults = left === void 0 ? [] : walkSegments(left, segments, maxDepth, lazyDepth);
856
+ const rightResults = right === void 0 ? [] : walkSegments(right, segments, maxDepth, lazyDepth);
832
857
  return [...leftResults, ...rightResults];
833
858
  }
834
859
  // Leaf types — can't descend further.
@@ -849,6 +874,7 @@ function walkSegments(schema, segments) {
849
874
  case "promise":
850
875
  case "custom":
851
876
  case "template-literal":
877
+ case "transform":
852
878
  return [];
853
879
  default: {
854
880
  const _exhaustive = kind;
@@ -960,6 +986,7 @@ function stripRefinements(schema) {
960
986
  case "promise":
961
987
  case "custom":
962
988
  case "template-literal":
989
+ case "transform":
963
990
  return schema;
964
991
  default: {
965
992
  const _exhaustive = kind;
@@ -1083,6 +1110,7 @@ function stripAsyncChecks(schema) {
1083
1110
  case "promise":
1084
1111
  case "custom":
1085
1112
  case "template-literal":
1113
+ case "transform":
1086
1114
  return s;
1087
1115
  default: {
1088
1116
  const _exhaustive = kind;
@@ -1092,34 +1120,39 @@ function stripAsyncChecks(schema) {
1092
1120
  }
1093
1121
  return recurse(schema);
1094
1122
  }
1095
- function getSlimSchema(schema, stripConfig) {
1123
+ function getSlimSchema(schema, stripConfig, maxRecursionDepth) {
1124
+ return walkSlim(schema, stripConfig, maxRecursionDepth, 0);
1125
+ }
1126
+ function walkSlim(schema, stripConfig, maxDepth, lazyDepth) {
1096
1127
  const kind = kindOf(schema);
1097
1128
  switch (kind) {
1098
1129
  case "optional": {
1099
1130
  const inner = unwrapInner(schema) ?? schema;
1100
- const slimmedInner = getSlimSchema(inner, stripConfig);
1131
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1101
1132
  return stripConfig.stripOptional === true ? slimmedInner : slimmedInner.optional();
1102
1133
  }
1103
1134
  case "nullable": {
1104
1135
  const inner = unwrapInner(schema) ?? schema;
1105
- const slimmedInner = getSlimSchema(inner, stripConfig);
1136
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1106
1137
  return stripConfig.stripNullable === true ? slimmedInner : slimmedInner.nullable();
1107
1138
  }
1108
1139
  case "default": {
1109
1140
  const inner = unwrapInner(schema) ?? schema;
1110
- const slimmedInner = getSlimSchema(inner, stripConfig);
1141
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1111
1142
  if (stripConfig.stripDefaultValues === true) return slimmedInner;
1112
1143
  const defaultValue = getDefaultValue(schema);
1113
1144
  return slimmedInner.default(defaultValue);
1114
1145
  }
1115
1146
  case "readonly": {
1116
1147
  const inner = unwrapInner(schema);
1117
- return inner === void 0 ? schema : getSlimSchema(inner, stripConfig).readonly();
1148
+ return inner === void 0 ? schema : walkSlim(inner, stripConfig, maxDepth, lazyDepth).readonly();
1118
1149
  }
1119
1150
  case "pipe": {
1120
1151
  if (stripConfig.stripPipe === true) {
1121
- const inner = unwrapPipe(schema) ?? schema;
1122
- return getSlimSchema(inner, stripConfig);
1152
+ const pipeIn = unwrapPipeIn(schema);
1153
+ const pipeOut = unwrapPipeOut(schema);
1154
+ const real = pipeIn !== void 0 && kindOf(pipeIn) !== "transform" ? pipeIn : pipeOut !== void 0 && kindOf(pipeOut) !== "transform" ? pipeOut : pipeIn ?? pipeOut ?? schema;
1155
+ return walkSlim(real, stripConfig, maxDepth, lazyDepth);
1123
1156
  }
1124
1157
  return schema;
1125
1158
  }
@@ -1127,20 +1160,30 @@ function getSlimSchema(schema, stripConfig) {
1127
1160
  const shape = getObjectShape(schema);
1128
1161
  const next = {};
1129
1162
  for (const [k, v] of Object.entries(shape)) {
1130
- next[k] = getSlimSchema(v, stripConfig);
1163
+ next[k] = walkSlim(v, stripConfig, maxDepth, lazyDepth);
1131
1164
  }
1132
1165
  return carryChecks(zod.z.object(next), schema, stripConfig);
1133
1166
  }
1134
1167
  case "array": {
1135
1168
  const element = getArrayElement(schema);
1136
- return carryChecks(zod.z.array(getSlimSchema(element, stripConfig)), schema, stripConfig);
1169
+ return carryChecks(
1170
+ zod.z.array(walkSlim(element, stripConfig, maxDepth, lazyDepth)),
1171
+ schema,
1172
+ stripConfig
1173
+ );
1137
1174
  }
1138
1175
  case "set": {
1139
1176
  const valueType = getSetValueType(schema);
1140
- return carryChecks(zod.z.set(getSlimSchema(valueType, stripConfig)), schema, stripConfig);
1177
+ return carryChecks(
1178
+ zod.z.set(walkSlim(valueType, stripConfig, maxDepth, lazyDepth)),
1179
+ schema,
1180
+ stripConfig
1181
+ );
1141
1182
  }
1142
1183
  case "tuple": {
1143
- const items = getTupleItems(schema).map((it) => getSlimSchema(it, stripConfig));
1184
+ const items = getTupleItems(schema).map(
1185
+ (it) => walkSlim(it, stripConfig, maxDepth, lazyDepth)
1186
+ );
1144
1187
  const rebuilt = zod.z.tuple(
1145
1188
  items
1146
1189
  );
@@ -1148,18 +1191,20 @@ function getSlimSchema(schema, stripConfig) {
1148
1191
  }
1149
1192
  case "record": {
1150
1193
  const keyType = getRecordKeyType(schema);
1151
- const valueType = getSlimSchema(getRecordValueType(schema), stripConfig);
1194
+ const valueType = walkSlim(getRecordValueType(schema), stripConfig, maxDepth, lazyDepth);
1152
1195
  const rebuilt = zod.z.record(keyType, valueType);
1153
1196
  return carryChecks(rebuilt, schema, stripConfig);
1154
1197
  }
1155
1198
  case "union": {
1156
- const options = getUnionOptions(schema).map((opt) => getSlimSchema(opt, stripConfig));
1199
+ const options = getUnionOptions(schema).map(
1200
+ (opt) => walkSlim(opt, stripConfig, maxDepth, lazyDepth)
1201
+ );
1157
1202
  const rebuilt = zod.z.union(options);
1158
1203
  return carryChecks(rebuilt, schema, stripConfig);
1159
1204
  }
1160
1205
  case "discriminated-union": {
1161
1206
  const options = getDiscriminatedOptions(schema).map(
1162
- (opt) => getSlimSchema(opt, stripConfig)
1207
+ (opt) => walkSlim(opt, stripConfig, maxDepth, lazyDepth)
1163
1208
  );
1164
1209
  const discriminator = getDiscriminator(schema);
1165
1210
  if (discriminator === void 0) return schema;
@@ -1189,23 +1234,29 @@ function getSlimSchema(schema, stripConfig) {
1189
1234
  case "template-literal":
1190
1235
  return schema;
1191
1236
  case "lazy": {
1237
+ if (lazyDepth >= maxDepth) return schema;
1192
1238
  const inner = unwrapLazy(schema);
1193
1239
  if (inner === void 0) return schema;
1194
- const slimmedInner = getSlimSchema(inner, stripConfig);
1240
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth + 1);
1195
1241
  return zod.z.lazy(() => slimmedInner);
1196
1242
  }
1197
1243
  case "intersection": {
1198
1244
  const left = getIntersectionLeft(schema);
1199
1245
  const right = getIntersectionRight(schema);
1200
1246
  if (left === void 0 || right === void 0) return schema;
1201
- return zod.z.intersection(getSlimSchema(left, stripConfig), getSlimSchema(right, stripConfig));
1247
+ return zod.z.intersection(
1248
+ walkSlim(left, stripConfig, maxDepth, lazyDepth),
1249
+ walkSlim(right, stripConfig, maxDepth, lazyDepth)
1250
+ );
1202
1251
  }
1203
1252
  case "catch": {
1204
1253
  const inner = unwrapInner(schema);
1205
1254
  if (inner === void 0) return schema;
1206
- const slimmedInner = getSlimSchema(inner, stripConfig);
1255
+ const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth);
1207
1256
  return slimmedInner.catch(getCatchDefault(schema));
1208
1257
  }
1258
+ case "transform":
1259
+ return schema;
1209
1260
  default: {
1210
1261
  const _exhaustive = kind;
1211
1262
  throw new Error(`getSlimSchema: unhandled ZodKind '${_exhaustive}'`);
@@ -1213,23 +1264,23 @@ function getSlimSchema(schema, stripConfig) {
1213
1264
  }
1214
1265
  }
1215
1266
 
1216
- function deriveDefault(schema, useDefault) {
1217
- return defaultForKind(kindOf(schema), schema, useDefault);
1267
+ function deriveDefault(schema, useDefault, maxRecursionDepth) {
1268
+ return defaultForKind(kindOf(schema), schema, useDefault, maxRecursionDepth, 0);
1218
1269
  }
1219
- function defaultForKind(kind, schema, useDefault) {
1270
+ function defaultForKind(kind, schema, useDefault, maxDepth, lazyDepth) {
1220
1271
  switch (kind) {
1221
1272
  case "object": {
1222
1273
  const shape = getObjectShape(schema);
1223
1274
  const out = {};
1224
1275
  for (const [key, subSchema] of Object.entries(shape)) {
1225
- out[key] = deriveDefault(subSchema, useDefault);
1276
+ out[key] = defaultForKind(kindOf(subSchema), subSchema, useDefault, maxDepth, lazyDepth);
1226
1277
  }
1227
1278
  return out;
1228
1279
  }
1229
1280
  case "default": {
1230
1281
  if (useDefault) return getDefaultValue(schema);
1231
1282
  const inner = unwrapInner(schema);
1232
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1283
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1233
1284
  }
1234
1285
  case "optional":
1235
1286
  return void 0;
@@ -1237,11 +1288,13 @@ function defaultForKind(kind, schema, useDefault) {
1237
1288
  return null;
1238
1289
  case "readonly": {
1239
1290
  const inner = unwrapInner(schema);
1240
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1291
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1241
1292
  }
1242
1293
  case "pipe": {
1243
- const inner = unwrapPipe(schema);
1244
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1294
+ const out = unwrapPipeOut(schema);
1295
+ const inn = unwrapPipeIn(schema);
1296
+ const real = inn !== void 0 && kindOf(inn) !== "transform" ? inn : out !== void 0 && kindOf(out) !== "transform" ? out : inn ?? out;
1297
+ return real === void 0 ? void 0 : defaultForKind(kindOf(real), real, useDefault, maxDepth, lazyDepth);
1245
1298
  }
1246
1299
  case "array":
1247
1300
  return [];
@@ -1251,16 +1304,18 @@ function defaultForKind(kind, schema, useDefault) {
1251
1304
  return {};
1252
1305
  case "tuple": {
1253
1306
  const items = getTupleItems(schema);
1254
- return items.map((item) => deriveDefault(item, useDefault));
1307
+ return items.map(
1308
+ (item) => defaultForKind(kindOf(item), item, useDefault, maxDepth, lazyDepth)
1309
+ );
1255
1310
  }
1256
1311
  case "union": {
1257
1312
  const options = getUnionOptions(schema);
1258
1313
  const first = options[0];
1259
- return first === void 0 ? void 0 : deriveDefault(first, useDefault);
1314
+ return first === void 0 ? void 0 : defaultForKind(kindOf(first), first, useDefault, maxDepth, lazyDepth);
1260
1315
  }
1261
1316
  case "discriminated-union": {
1262
1317
  const first = getDiscriminatedUnionFirstOption(schema);
1263
- return first === void 0 ? void 0 : deriveDefault(first, useDefault);
1318
+ return first === void 0 ? void 0 : defaultForKind(kindOf(first), first, useDefault, maxDepth, lazyDepth);
1264
1319
  }
1265
1320
  case "string":
1266
1321
  return "";
@@ -1287,20 +1342,21 @@ function defaultForKind(kind, schema, useDefault) {
1287
1342
  case "nan":
1288
1343
  return NaN;
1289
1344
  case "lazy": {
1345
+ if (lazyDepth >= maxDepth) return void 0;
1290
1346
  const inner = unwrapLazy(schema);
1291
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1347
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth + 1);
1292
1348
  }
1293
1349
  case "intersection": {
1294
1350
  const left = getIntersectionLeft(schema);
1295
1351
  const right = getIntersectionRight(schema);
1296
- const l = left === void 0 ? void 0 : deriveDefault(left, useDefault);
1297
- const r = right === void 0 ? void 0 : deriveDefault(right, useDefault);
1352
+ const l = left === void 0 ? void 0 : defaultForKind(kindOf(left), left, useDefault, maxDepth, lazyDepth);
1353
+ const r = right === void 0 ? void 0 : defaultForKind(kindOf(right), right, useDefault, maxDepth, lazyDepth);
1298
1354
  return mergeDeep(l, r);
1299
1355
  }
1300
1356
  case "catch": {
1301
1357
  if (useDefault) return getCatchDefault(schema);
1302
1358
  const inner = unwrapInner(schema);
1303
- return inner === void 0 ? void 0 : deriveDefault(inner, useDefault);
1359
+ return inner === void 0 ? void 0 : defaultForKind(kindOf(inner), inner, useDefault, maxDepth, lazyDepth);
1304
1360
  }
1305
1361
  case "any":
1306
1362
  case "unknown":
@@ -1309,6 +1365,7 @@ function defaultForKind(kind, schema, useDefault) {
1309
1365
  case "promise":
1310
1366
  case "custom":
1311
1367
  case "template-literal":
1368
+ case "transform":
1312
1369
  return void 0;
1313
1370
  default: {
1314
1371
  const _exhaustive = kind;
@@ -1333,14 +1390,18 @@ function mergeDeep(base, override) {
1333
1390
  return result;
1334
1391
  }
1335
1392
  function getDefaultValuesFromZodSchema(opts) {
1336
- const { schema, useDefaultSchemaValues, constraints } = opts;
1337
- const initial = deriveDefault(schema, useDefaultSchemaValues);
1393
+ const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts;
1394
+ const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth);
1338
1395
  const merged = mergeDeep(initial, constraints);
1339
- const slimSchema = getSlimSchema(schema, {
1340
- stripDefaultValues: true,
1341
- stripPipe: true,
1342
- stripRefinements: true
1343
- });
1396
+ const slimSchema = getSlimSchema(
1397
+ schema,
1398
+ {
1399
+ stripDefaultValues: true,
1400
+ stripPipe: true,
1401
+ stripRefinements: true
1402
+ },
1403
+ maxRecursionDepth
1404
+ );
1344
1405
  const firstParse = slimSchema.safeParse(merged);
1345
1406
  if (firstParse.success) {
1346
1407
  return { data: firstParse.data, success: true, slimSchema };
@@ -1348,16 +1409,16 @@ function getDefaultValuesFromZodSchema(opts) {
1348
1409
  let fixedData = merged;
1349
1410
  for (const issue of firstParse.error.issues) {
1350
1411
  const pathSegments = issue.path.map((seg) => typeof seg === "number" ? seg : String(seg));
1351
- const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments);
1412
+ const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments, maxRecursionDepth);
1352
1413
  if (candidates.length === 0) continue;
1353
1414
  const candidate = candidates[0];
1354
1415
  if (candidate === void 0) continue;
1355
1416
  const valueAtPath = useFormContext.getAtPath(merged, pathSegments);
1356
- const slimKinds = slimPrimitivesOf(candidate);
1417
+ const slimKinds = slimPrimitivesOf(candidate, maxRecursionDepth);
1357
1418
  if (slimKinds.size > 0 && slimKinds.has(useFormContext.slimKindOf(valueAtPath))) {
1358
1419
  continue;
1359
1420
  }
1360
- const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues);
1421
+ const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth);
1361
1422
  if (fixValue === SKIP) continue;
1362
1423
  fixedData = pathSegments.length === 0 ? fixValue : useFormContext.setAtPath(fixedData, pathSegments, fixValue);
1363
1424
  }
@@ -1368,21 +1429,22 @@ function getDefaultValuesFromZodSchema(opts) {
1368
1429
  return { data: fixedData, success: false, slimSchema };
1369
1430
  }
1370
1431
  const SKIP = Symbol("atta:skip-fix");
1371
- function defaultFromIssue(issue, candidate, useDefaultSchemaValues) {
1432
+ function defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth) {
1372
1433
  if (issue.code === "invalid_type") {
1373
1434
  const du = unwrapToDiscriminatedUnion(candidate);
1374
1435
  if (du !== void 0) {
1375
1436
  const first = getDiscriminatedUnionFirstOption(du);
1376
- if (first !== void 0) return deriveDefault(first, useDefaultSchemaValues);
1437
+ if (first !== void 0)
1438
+ return deriveDefault(first, useDefaultSchemaValues, maxRecursionDepth);
1377
1439
  }
1378
- return deriveDefault(candidate, useDefaultSchemaValues);
1440
+ return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1379
1441
  }
1380
1442
  if (issue.code === "invalid_value") {
1381
1443
  const values = issue.values;
1382
1444
  if (values !== void 0 && values.length > 0) return values[0];
1383
- return deriveDefault(candidate, useDefaultSchemaValues);
1445
+ return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1384
1446
  }
1385
- return deriveDefault(candidate, useDefaultSchemaValues);
1447
+ return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth);
1386
1448
  }
1387
1449
 
1388
1450
  const PATH_SEPARATOR = ".";
@@ -1472,7 +1534,8 @@ function isLeafRequired(schema, depth = 0) {
1472
1534
  function zodV4Adapter(rootSchema) {
1473
1535
  assertZodVersion(rootSchema);
1474
1536
  assertSupportedKinds(rootSchema);
1475
- return (formKey) => {
1537
+ return (formKey, options) => {
1538
+ const maxRecursionDepth = options.maxRecursionDepth;
1476
1539
  const leafCache = /* @__PURE__ */ new Map();
1477
1540
  let asyncValidationFlag = null;
1478
1541
  return {
@@ -1485,13 +1548,16 @@ function zodV4Adapter(rootSchema) {
1485
1548
  const { data } = getDefaultValuesFromZodSchema({
1486
1549
  schema: rootSchema,
1487
1550
  useDefaultSchemaValues: config.useDefaultSchemaValues,
1488
- constraints: config.constraints
1551
+ constraints: config.constraints,
1552
+ maxRecursionDepth
1489
1553
  });
1490
1554
  if (config.strict !== false) {
1491
1555
  try {
1492
- const strictResult = rootSchema.safeParse(data);
1556
+ const strictResult = rootSchema.safeParse(
1557
+ data
1558
+ );
1493
1559
  if (strictResult.success) {
1494
- return { data: strictResult.data, errors: void 0, success: true, formKey };
1560
+ return { data, errors: void 0, success: true, formKey };
1495
1561
  }
1496
1562
  return {
1497
1563
  data,
@@ -1519,15 +1585,52 @@ function zodV4Adapter(rootSchema) {
1519
1585
  }
1520
1586
  return { data, errors: void 0, success: true, formKey };
1521
1587
  },
1588
+ normalizeWriteValueAtPath(value, path) {
1589
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1590
+ const [first] = candidates;
1591
+ if (first === void 0) return value;
1592
+ let current = first;
1593
+ let result = value;
1594
+ for (let i = 0; i < 64; i++) {
1595
+ if (kindOf(current) !== "pipe") break;
1596
+ const pipeIn = unwrapPipeIn(current);
1597
+ if (pipeIn === void 0 || kindOf(pipeIn) !== "transform") break;
1598
+ const fn = readTransformFn(pipeIn);
1599
+ if (typeof fn !== "function") break;
1600
+ let next;
1601
+ try {
1602
+ next = fn(result);
1603
+ } catch (cause) {
1604
+ throw new Error(
1605
+ `[attaform] input normalization at path "${path.join(".")}" threw \u2014 write rejected.`,
1606
+ { cause }
1607
+ );
1608
+ }
1609
+ if (next instanceof Promise) {
1610
+ return value;
1611
+ }
1612
+ result = next;
1613
+ const out = unwrapPipeOut(current);
1614
+ if (out === void 0) break;
1615
+ current = out;
1616
+ }
1617
+ return result;
1618
+ },
1522
1619
  getDefaultAtPath(path) {
1523
- if (path.length === 0) return deriveDefault(rootSchema, true);
1524
- const [first] = getNestedZodSchemasAtPath(rootSchema, path);
1620
+ if (path.length === 0) return deriveDefault(rootSchema, true, maxRecursionDepth);
1621
+ const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1525
1622
  if (first === void 0) return void 0;
1526
- return deriveDefault(unwrapStructuralWrappers(first), true);
1623
+ return deriveDefault(unwrapStructuralWrappers(first), true, maxRecursionDepth);
1624
+ },
1625
+ getEmptyValueAtPath(path) {
1626
+ if (path.length === 0) return deriveDefault(rootSchema, false, maxRecursionDepth);
1627
+ const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1628
+ if (first === void 0) return void 0;
1629
+ return deriveDefault(first, false, maxRecursionDepth);
1527
1630
  },
1528
1631
  arrayShapeAtPath(path) {
1529
1632
  if (path.length === 0) return void 0;
1530
- const [first] = getNestedZodSchemasAtPath(rootSchema, path);
1633
+ const [first] = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1531
1634
  if (first === void 0) return void 0;
1532
1635
  const peeled = peelAllWrappers(first);
1533
1636
  const kind = kindOf(peeled);
@@ -1536,13 +1639,13 @@ function zodV4Adapter(rootSchema) {
1536
1639
  return void 0;
1537
1640
  },
1538
1641
  getSchemasAtPath(path) {
1539
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1642
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1540
1643
  return resolved.map(
1541
1644
  (schema) => ({
1542
1645
  fingerprint: () => fingerprintZodSchema(schema),
1543
1646
  needsAsyncValidation: () => containsAsyncRefine(schema),
1544
1647
  getDefaultValues: () => ({
1545
- data: deriveDefault(schema, true),
1648
+ data: deriveDefault(schema, true, maxRecursionDepth),
1546
1649
  errors: void 0,
1547
1650
  success: true,
1548
1651
  formKey
@@ -1565,11 +1668,11 @@ function zodV4Adapter(rootSchema) {
1565
1668
  },
1566
1669
  getSlimPrimitiveTypesAtPath(path) {
1567
1670
  if (path.length === 0) return /* @__PURE__ */ new Set(["object"]);
1568
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1671
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1569
1672
  if (resolved.length === 0) return /* @__PURE__ */ new Set();
1570
1673
  const out = /* @__PURE__ */ new Set();
1571
1674
  for (const candidate of resolved) {
1572
- for (const k of slimPrimitivesOf(candidate)) out.add(k);
1675
+ for (const k of slimPrimitivesOf(candidate, maxRecursionDepth)) out.add(k);
1573
1676
  }
1574
1677
  return out;
1575
1678
  },
@@ -1584,15 +1687,15 @@ function zodV4Adapter(rootSchema) {
1584
1687
  },
1585
1688
  isRequiredAtPath(path) {
1586
1689
  if (path.length === 0) return true;
1587
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1690
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1588
1691
  if (resolved.length === 0) return false;
1589
1692
  return resolved.every((candidate) => isLeafRequired(candidate));
1590
1693
  },
1591
1694
  getFieldMetaAtPath(path) {
1592
- return resolveFieldMetaAtPath(rootSchema, path);
1695
+ return resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth);
1593
1696
  },
1594
1697
  getUnionDiscriminatorAtPath(path) {
1595
- const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path);
1698
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1596
1699
  let matchedUnion;
1597
1700
  for (const candidate of candidates) {
1598
1701
  const du = unwrapToDiscriminatedUnion(candidate);
@@ -1603,24 +1706,35 @@ function zodV4Adapter(rootSchema) {
1603
1706
  if (matchedUnion === void 0) return void 0;
1604
1707
  const discKey = getDiscriminator(matchedUnion);
1605
1708
  if (discKey === void 0) return void 0;
1606
- const options = getDiscriminatedOptions(matchedUnion);
1709
+ const options2 = getDiscriminatedOptions(matchedUnion);
1710
+ const literalSet = /* @__PURE__ */ new Set();
1711
+ for (const opt of options2) {
1712
+ const shape = getObjectShape(opt);
1713
+ const litSchema = shape[discKey];
1714
+ if (litSchema === void 0) continue;
1715
+ if (kindOf(litSchema) !== "literal") continue;
1716
+ for (const v of getLiteralValues(litSchema)) literalSet.add(v);
1717
+ }
1607
1718
  return {
1608
1719
  discriminatorKey: discKey,
1609
1720
  getVariantDefault(value) {
1610
- for (const opt of options) {
1721
+ for (const opt of options2) {
1611
1722
  const shape = getObjectShape(opt);
1612
1723
  const litSchema = shape[discKey];
1613
1724
  if (litSchema === void 0) continue;
1614
1725
  if (kindOf(litSchema) !== "literal") continue;
1615
1726
  const literalValues = getLiteralValues(litSchema);
1616
- if (literalValues.includes(value)) return deriveDefault(opt, true);
1727
+ if (literalValues.includes(value)) return deriveDefault(opt, true, maxRecursionDepth);
1617
1728
  }
1618
1729
  return void 0;
1730
+ },
1731
+ isVariantSelected(value) {
1732
+ return literalSet.has(value);
1619
1733
  }
1620
1734
  };
1621
1735
  },
1622
- validateAtPath(data, path, options) {
1623
- const trySync = options?.sync === true;
1736
+ validateAtPath(data, path, options2) {
1737
+ const trySync = options2?.sync === true;
1624
1738
  if (trySync) {
1625
1739
  try {
1626
1740
  return runSync();
@@ -1638,13 +1752,18 @@ function zodV4Adapter(rootSchema) {
1638
1752
  formKey
1639
1753
  };
1640
1754
  }
1641
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1755
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1642
1756
  if (resolved.length === 0) return pathNotFound(path);
1643
1757
  const aggregated = [];
1644
1758
  for (const candidate of resolved) {
1645
1759
  const result = candidate.safeParse(data);
1646
1760
  if (result.success) {
1647
- return { data: result.data, errors: void 0, success: true, formKey };
1761
+ return {
1762
+ data: result.data,
1763
+ errors: void 0,
1764
+ success: true,
1765
+ formKey
1766
+ };
1648
1767
  }
1649
1768
  aggregated.push(...zodIssuesToValidationErrors(result.error.issues, formKey));
1650
1769
  }
@@ -1652,7 +1771,9 @@ function zodV4Adapter(rootSchema) {
1652
1771
  }
1653
1772
  async function runAsync() {
1654
1773
  if (path === void 0) {
1655
- const result = await rootSchema.safeParseAsync(data);
1774
+ const result = await rootSchema.safeParseAsync(
1775
+ data
1776
+ );
1656
1777
  return result.success ? { data: result.data, errors: void 0, success: true, formKey } : {
1657
1778
  data: void 0,
1658
1779
  errors: zodIssuesToValidationErrors(result.error.issues, formKey),
@@ -1660,13 +1781,18 @@ function zodV4Adapter(rootSchema) {
1660
1781
  formKey
1661
1782
  };
1662
1783
  }
1663
- const resolved = getNestedZodSchemasAtPath(rootSchema, path);
1784
+ const resolved = getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1664
1785
  if (resolved.length === 0) return pathNotFound(path);
1665
1786
  const aggregated = [];
1666
1787
  for (const candidate of resolved) {
1667
1788
  const result = await candidate.safeParseAsync(data);
1668
1789
  if (result.success) {
1669
- return { data: result.data, errors: void 0, success: true, formKey };
1790
+ return {
1791
+ data: result.data,
1792
+ errors: void 0,
1793
+ success: true,
1794
+ formKey
1795
+ };
1670
1796
  }
1671
1797
  aggregated.push(...zodIssuesToValidationErrors(result.error.issues, formKey));
1672
1798
  }
@@ -1844,6 +1970,7 @@ function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress)
1844
1970
  case "promise":
1845
1971
  case "custom":
1846
1972
  case "template-literal":
1973
+ case "transform":
1847
1974
  return;
1848
1975
  }
1849
1976
  } finally {
@@ -1858,9 +1985,9 @@ function consumePayload(schema, counters) {
1858
1985
  counters.set(schema, idx + 1);
1859
1986
  return payload;
1860
1987
  }
1861
- function resolveFieldMetaAtPath(rootSchema, path) {
1988
+ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
1862
1989
  const lastSegment = path.length === 0 ? "" : path[path.length - 1];
1863
- const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path);
1990
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
1864
1991
  const target = candidates[0];
1865
1992
  if (target === void 0) {
1866
1993
  return {
@@ -1894,9 +2021,7 @@ function useForm(configuration) {
1894
2021
  if (candidate === void 0 || candidate === null || candidate.schema === void 0) {
1895
2022
  throw new plugin.InvalidUseFormConfigError();
1896
2023
  }
1897
- const adapter = zodV4Adapter(
1898
- configuration.schema
1899
- );
2024
+ const adapter = zodV4Adapter(configuration.schema);
1900
2025
  return useFormContext.useAbstractForm({
1901
2026
  ...configuration,
1902
2027
  schema: adapter
@@ -1910,4 +2035,4 @@ exports.kindOf = kindOf;
1910
2035
  exports.useForm = useForm;
1911
2036
  exports.withMeta = withMeta;
1912
2037
  exports.zodV4Adapter = zodV4Adapter;
1913
- //# sourceMappingURL=attaform.keLBaHB6.cjs.map
2038
+ //# sourceMappingURL=attaform.BV40t5y2.cjs.map