attaform 0.27.6 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +1 -2
  4. package/dist/chunks/fingerprint2.mjs +2 -3
  5. package/dist/dev/abstract.mjs +4 -0
  6. package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
  7. package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
  8. package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
  9. package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
  10. package/dist/dev/directive.mjs +1 -0
  11. package/dist/dev/history.mjs +89 -0
  12. package/dist/dev/index.mjs +5 -0
  13. package/dist/dev/runtime/plugins/attaform.mjs +40 -0
  14. package/dist/dev/shared/attaform-dev.A-TpJW0B.mjs +207 -0
  15. package/dist/dev/shared/attaform-dev.BO-71R54.mjs +820 -0
  16. package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.BgM6FdtA.mjs} +324 -73
  17. package/dist/dev/shared/attaform-dev.ButTkwHd.mjs +375 -0
  18. package/dist/{shared/attaform.BJGA_UOS.mjs → dev/shared/attaform-dev.BxfsuwBR.mjs} +8 -1
  19. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.D8aoKb89.mjs} +190 -400
  20. package/dist/dev/shared/attaform-dev.DD5m2W51.mjs +220 -0
  21. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.DHuydLAC.mjs} +3867 -4731
  22. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.DrzObAZo.mjs} +6 -7
  23. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.q6UutkCx.mjs} +274 -672
  24. package/dist/dev/zod-v3.mjs +17 -0
  25. package/dist/dev/zod-v4.mjs +16 -0
  26. package/dist/dev/zod.mjs +5 -0
  27. package/dist/directive.d.mts +20 -0
  28. package/dist/directive.mjs +1 -0
  29. package/dist/esbuild.mjs +0 -1
  30. package/dist/history.d.mts +59 -0
  31. package/dist/history.mjs +89 -0
  32. package/dist/index.d.mts +14 -6
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +10 -10
  35. package/dist/nuxt.mjs +5 -2
  36. package/dist/rollup.mjs +0 -1
  37. package/dist/rspack.d.mts +6 -1
  38. package/dist/rspack.mjs +0 -1
  39. package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
  40. package/dist/runtime/plugins/attaform.mjs +1 -2
  41. package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.B0dKL8ST.mjs} +309 -46
  42. package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -140
  43. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.BndjUUYX.mjs} +11 -16
  44. package/dist/shared/{attaform.CQN9R62B.cjs → attaform.BxfsuwBR.mjs} +9 -4
  45. package/dist/shared/attaform.C2MVyuxC.mjs +811 -0
  46. package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.CIWLMY-R.d.mts} +2 -2
  47. package/dist/shared/attaform.CZMAYwSK.mjs +6383 -0
  48. package/dist/shared/attaform.CZYt_5N_.mjs +207 -0
  49. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.CsoeRi3P.d.mts} +490 -98
  50. package/dist/shared/attaform.Cvao8bW5.mjs +358 -0
  51. package/dist/shared/attaform.D0x-qSXm.mjs +197 -0
  52. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.D1fnTifF.mjs} +279 -692
  53. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.DDtqHYv1.d.mts} +155 -184
  54. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.DffRL5pP.mjs} +215 -547
  55. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  56. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  57. package/dist/shared/attaform.axHXVQO7.d.mts +44 -0
  58. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  59. package/dist/transforms.d.mts +0 -22
  60. package/dist/transforms.mjs +1 -2
  61. package/dist/vite.d.mts +30 -9
  62. package/dist/vite.mjs +27 -4
  63. package/dist/webpack.d.mts +6 -1
  64. package/dist/webpack.mjs +0 -1
  65. package/dist/zod-v3.d.mts +13 -6
  66. package/dist/zod-v3.mjs +17 -4
  67. package/dist/zod-v4.d.mts +19 -26
  68. package/dist/zod-v4.mjs +16 -4
  69. package/dist/zod.d.mts +4 -3
  70. package/dist/zod.mjs +5 -4
  71. package/package.json +38 -20
  72. package/skills/attaform/SKILL.md +6 -2
  73. package/skills/attaform/references/custom-components.md +7 -2
  74. package/skills/attaform/references/errors.md +8 -3
  75. package/skills/attaform/references/saving.md +77 -0
  76. package/skills/attaform/references/wizards.md +10 -8
  77. package/dist/abstract.cjs +0 -48
  78. package/dist/abstract.cjs.map +0 -1
  79. package/dist/abstract.d.cts +0 -42
  80. package/dist/abstract.d.ts +0 -42
  81. package/dist/abstract.mjs.map +0 -1
  82. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  83. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  84. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  85. package/dist/chunks/devtools.cjs +0 -157
  86. package/dist/chunks/devtools.cjs.map +0 -1
  87. package/dist/chunks/devtools.mjs.map +0 -1
  88. package/dist/chunks/fingerprint.cjs.map +0 -1
  89. package/dist/chunks/fingerprint.mjs.map +0 -1
  90. package/dist/chunks/fingerprint2.cjs.map +0 -1
  91. package/dist/chunks/fingerprint2.mjs.map +0 -1
  92. package/dist/esbuild.cjs +0 -28
  93. package/dist/esbuild.cjs.map +0 -1
  94. package/dist/esbuild.d.cts +0 -56
  95. package/dist/esbuild.d.ts +0 -56
  96. package/dist/esbuild.mjs.map +0 -1
  97. package/dist/index.cjs +0 -51
  98. package/dist/index.cjs.map +0 -1
  99. package/dist/index.d.cts +0 -249
  100. package/dist/index.d.ts +0 -249
  101. package/dist/index.mjs.map +0 -1
  102. package/dist/nuxt.cjs +0 -84
  103. package/dist/nuxt.cjs.map +0 -1
  104. package/dist/nuxt.d.cts +0 -66
  105. package/dist/nuxt.d.ts +0 -66
  106. package/dist/nuxt.mjs.map +0 -1
  107. package/dist/rollup.cjs +0 -24
  108. package/dist/rollup.cjs.map +0 -1
  109. package/dist/rollup.d.cts +0 -35
  110. package/dist/rollup.d.ts +0 -35
  111. package/dist/rollup.mjs.map +0 -1
  112. package/dist/rspack.cjs +0 -10
  113. package/dist/rspack.cjs.map +0 -1
  114. package/dist/rspack.d.cts +0 -40
  115. package/dist/rspack.d.ts +0 -40
  116. package/dist/rspack.mjs.map +0 -1
  117. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  118. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  119. package/dist/runtime/plugins/attaform.cjs +0 -43
  120. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  121. package/dist/runtime/plugins/attaform.d.cts +0 -5
  122. package/dist/runtime/plugins/attaform.d.ts +0 -5
  123. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  124. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  125. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  126. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  127. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  128. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  129. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  130. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  131. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  132. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  133. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  134. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  135. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  136. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  137. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  138. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  139. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  140. package/dist/shared/attaform.DMxM2kol.mjs +0 -1275
  141. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  142. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  143. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  144. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  145. package/dist/shared/attaform.DdQN7sgN.cjs +0 -1302
  146. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  147. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  148. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  149. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  150. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  151. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  152. package/dist/shared/attaform.DrvMscNX.cjs +0 -7697
  153. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  154. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  155. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  156. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  157. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  158. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  159. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  160. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  161. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  162. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  163. package/dist/transforms.cjs +0 -12
  164. package/dist/transforms.cjs.map +0 -1
  165. package/dist/transforms.d.cts +0 -73
  166. package/dist/transforms.d.ts +0 -73
  167. package/dist/transforms.mjs.map +0 -1
  168. package/dist/vite.cjs +0 -363
  169. package/dist/vite.cjs.map +0 -1
  170. package/dist/vite.d.cts +0 -133
  171. package/dist/vite.d.ts +0 -133
  172. package/dist/vite.mjs.map +0 -1
  173. package/dist/webpack.cjs +0 -10
  174. package/dist/webpack.cjs.map +0 -1
  175. package/dist/webpack.d.cts +0 -37
  176. package/dist/webpack.d.ts +0 -37
  177. package/dist/webpack.mjs.map +0 -1
  178. package/dist/zod-v3.cjs +0 -53
  179. package/dist/zod-v3.cjs.map +0 -1
  180. package/dist/zod-v3.d.cts +0 -246
  181. package/dist/zod-v3.d.ts +0 -246
  182. package/dist/zod-v3.mjs.map +0 -1
  183. package/dist/zod-v4.cjs +0 -55
  184. package/dist/zod-v4.cjs.map +0 -1
  185. package/dist/zod-v4.d.cts +0 -172
  186. package/dist/zod-v4.d.ts +0 -172
  187. package/dist/zod-v4.mjs.map +0 -1
  188. package/dist/zod.cjs +0 -51
  189. package/dist/zod.cjs.map +0 -1
  190. package/dist/zod.d.cts +0 -7
  191. package/dist/zod.d.ts +0 -7
  192. package/dist/zod.mjs.map +0 -1
@@ -0,0 +1,811 @@
1
+ import { q as humanize, h as useAbstractForm } from './attaform.CZMAYwSK.mjs';
2
+ import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.CZYt_5N_.mjs';
3
+ import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, b as buildFieldMetaPathMap, a as getFieldMetaListForSchema, g as getFieldMetaForSchema } from './attaform.B0dKL8ST.mjs';
4
+ import { c as callConsumerSchemaFn } from './attaform.Cvao8bW5.mjs';
5
+ import { z } from 'zod';
6
+
7
+ function readDef(schema) {
8
+ if (schema === null || typeof schema !== "object") return void 0;
9
+ return schema.def;
10
+ }
11
+ const KIND_ALIAS = /* @__PURE__ */ new Map([
12
+ ["discriminated_union", "discriminated-union"],
13
+ ["discriminatedUnion", "discriminated-union"],
14
+ ["prefault", "default"],
15
+ ["template_literal", "template-literal"],
16
+ ["templateLiteral", "template-literal"]
17
+ ]);
18
+ const IDENTITY_KINDS = /* @__PURE__ */ new Set([
19
+ "object",
20
+ "array",
21
+ "set",
22
+ "record",
23
+ "tuple",
24
+ "string",
25
+ "number",
26
+ "boolean",
27
+ "bigint",
28
+ "date",
29
+ "enum",
30
+ "literal",
31
+ "null",
32
+ "undefined",
33
+ "any",
34
+ "unknown",
35
+ "optional",
36
+ "nullable",
37
+ "default",
38
+ "pipe",
39
+ "readonly",
40
+ "nan",
41
+ "void",
42
+ "never",
43
+ "lazy",
44
+ "intersection",
45
+ "catch",
46
+ "promise",
47
+ "custom",
48
+ "transform",
49
+ "file",
50
+ "map",
51
+ "symbol",
52
+ "function"
53
+ ]);
54
+ function kindOf(schema) {
55
+ const def = readDef(schema);
56
+ const rawType = def?.type;
57
+ if (rawType === void 0) return "unknown";
58
+ if (rawType === "union") {
59
+ return def?.discriminator !== void 0 ? "discriminated-union" : "union";
60
+ }
61
+ const alias = KIND_ALIAS.get(rawType);
62
+ if (alias !== void 0) return alias;
63
+ return IDENTITY_KINDS.has(rawType) ? rawType : "unknown";
64
+ }
65
+ function getObjectShape(schema) {
66
+ const s = schema;
67
+ return s.shape;
68
+ }
69
+ function getArrayElement(schema) {
70
+ const def = readDef(schema);
71
+ return def?.element;
72
+ }
73
+ function getSetValueType(schema) {
74
+ const def = readDef(schema);
75
+ return def?.valueType;
76
+ }
77
+ function getRecordKeyType(schema) {
78
+ const def = readDef(schema);
79
+ return def?.keyType;
80
+ }
81
+ function getRecordValueType(schema) {
82
+ const def = readDef(schema);
83
+ return def?.valueType;
84
+ }
85
+ const getMapKeyType = getRecordKeyType;
86
+ const getMapValueType = getRecordValueType;
87
+ function getTupleItems(schema) {
88
+ const def = readDef(schema);
89
+ return def?.items ?? [];
90
+ }
91
+ function getUnionOptions(schema) {
92
+ const def = readDef(schema);
93
+ return def?.options ?? [];
94
+ }
95
+ function getLiteralValues(schema) {
96
+ const def = readDef(schema);
97
+ return def?.values ?? [];
98
+ }
99
+ function getEnumValues(schema) {
100
+ const def = readDef(schema);
101
+ const entries = def?.entries;
102
+ if (entries === void 0) return [];
103
+ return Object.values(entries);
104
+ }
105
+ function unwrapInner(schema) {
106
+ const def = readDef(schema);
107
+ return def?.innerType;
108
+ }
109
+ function unwrapPipe(schema) {
110
+ const def = readDef(schema);
111
+ return def?.in ?? def?.out;
112
+ }
113
+ function unwrapPipeIn(schema) {
114
+ const def = readDef(schema);
115
+ return def?.in;
116
+ }
117
+ function isCoercePrimitive(schema) {
118
+ return readDef(schema)?.coerce === true;
119
+ }
120
+ function isPreprocessNode(schema) {
121
+ if (kindOf(schema) !== "pipe") return false;
122
+ const pipeIn = unwrapPipeIn(schema);
123
+ return pipeIn !== void 0 && kindOf(pipeIn) === "transform";
124
+ }
125
+ function unwrapPipeOut(schema) {
126
+ const def = readDef(schema);
127
+ return def?.out;
128
+ }
129
+ function unwrapLazy(schema) {
130
+ const def = readDef(schema);
131
+ const getter = def?.getter;
132
+ if (typeof getter !== "function") return void 0;
133
+ return callConsumerSchemaFn(() => getter(), void 0);
134
+ }
135
+ function getLazyGetter(schema) {
136
+ const def = readDef(schema);
137
+ return typeof def?.getter === "function" ? def.getter : void 0;
138
+ }
139
+ function getIntersectionLeft(schema) {
140
+ const def = readDef(schema);
141
+ return def?.left;
142
+ }
143
+ function getIntersectionRight(schema) {
144
+ const def = readDef(schema);
145
+ return def?.right;
146
+ }
147
+ function getCatchDefault(schema) {
148
+ const def = readDef(schema);
149
+ const cv = def?.catchValue;
150
+ if (typeof cv !== "function") return void 0;
151
+ return callConsumerSchemaFn(
152
+ () => cv({ error: new Error("atta:default-values"), input: void 0 }),
153
+ void 0);
154
+ }
155
+ function hasCatchValue(schema) {
156
+ const def = readDef(schema);
157
+ return typeof def?.catchValue === "function";
158
+ }
159
+ function getDefaultValue(schema) {
160
+ const def = readDef(schema);
161
+ return callConsumerSchemaFn(() => def?.defaultValue, void 0);
162
+ }
163
+ function getNativeEnumValues(_schema) {
164
+ return void 0;
165
+ }
166
+ function unwrapEffectsSource(_schema) {
167
+ return void 0;
168
+ }
169
+ function unwrapBranded(_schema) {
170
+ return void 0;
171
+ }
172
+ function hasChecks(schema) {
173
+ const def = readDef(schema);
174
+ const checks = def?.checks;
175
+ return Array.isArray(checks) && checks.length > 0;
176
+ }
177
+ function getChecks(schema) {
178
+ const def = readDef(schema);
179
+ const checks = def?.checks;
180
+ return Array.isArray(checks) ? checks : [];
181
+ }
182
+ function getDiscriminator(schema) {
183
+ const def = readDef(schema);
184
+ return def?.discriminator;
185
+ }
186
+ function getDiscriminatedOptions(schema) {
187
+ const def = readDef(schema);
188
+ const options = def?.options;
189
+ return Array.isArray(options) ? options : [];
190
+ }
191
+ function assertZodVersion(schema) {
192
+ const def = readDef(schema);
193
+ if (def?.type === void 0) {
194
+ throw new Error(
195
+ "[attaform] AF01 attaform.dev/e/af01"
196
+ );
197
+ }
198
+ }
199
+ const DESCEND_SINGLE = [
200
+ "innerType",
201
+ "element",
202
+ "in",
203
+ "out",
204
+ "left",
205
+ "right",
206
+ "keyType",
207
+ "valueType"
208
+ ];
209
+ const DESCEND_RECORD = ["shape", "entries"];
210
+ const DESCEND_LIST = ["options", "items"];
211
+ function walkSchemaTree(schema, visit, seen) {
212
+ const visited = seen ?? /* @__PURE__ */ new WeakSet();
213
+ const candidate = schema;
214
+ if (typeof candidate !== "object" || candidate === null) return false;
215
+ if (visited.has(candidate)) return false;
216
+ visited.add(candidate);
217
+ if (visit(schema)) return true;
218
+ const def = readDef(schema);
219
+ if (def === void 0) return false;
220
+ const slots = def;
221
+ for (const key of DESCEND_SINGLE) {
222
+ const child = slots[key];
223
+ if (child !== void 0 && walkSchemaTree(child, visit, visited)) return true;
224
+ }
225
+ for (const key of DESCEND_RECORD) {
226
+ const record = slots[key];
227
+ if (record !== void 0) {
228
+ for (const sub of Object.values(record)) {
229
+ if (walkSchemaTree(sub, visit, visited)) return true;
230
+ }
231
+ }
232
+ }
233
+ for (const key of DESCEND_LIST) {
234
+ const list = slots[key];
235
+ if (list !== void 0) {
236
+ for (const sub of list) {
237
+ if (walkSchemaTree(sub, visit, visited)) return true;
238
+ }
239
+ }
240
+ }
241
+ if (typeof def.getter === "function") {
242
+ try {
243
+ const inner = def.getter();
244
+ if (walkSchemaTree(inner, visit, visited)) return true;
245
+ } catch {
246
+ }
247
+ }
248
+ return false;
249
+ }
250
+ function containsDiscriminatedUnion(schema, seen) {
251
+ return walkSchemaTree(schema, (node) => kindOf(node) === "discriminated-union", seen);
252
+ }
253
+ function containsAsyncRefine(schema, seen) {
254
+ return walkSchemaTree(
255
+ schema,
256
+ (node) => {
257
+ for (const check of getChecks(node)) {
258
+ if (isAsyncCheck(check)) return true;
259
+ }
260
+ return false;
261
+ },
262
+ seen
263
+ );
264
+ }
265
+ const CONTAINER_SLOTS = [
266
+ "shape",
267
+ "entries",
268
+ "element",
269
+ "options",
270
+ "items",
271
+ "keyType",
272
+ "valueType",
273
+ "left",
274
+ "right"
275
+ ];
276
+ function hasContainerOrRootRefine(schema, seen) {
277
+ return walkSchemaTree(
278
+ schema,
279
+ (node) => {
280
+ const def = readDef(node);
281
+ if (def === void 0) return false;
282
+ const slots = def;
283
+ if (!CONTAINER_SLOTS.some((key) => slots[key] !== void 0)) return false;
284
+ return getChecks(node).length > 0;
285
+ },
286
+ seen
287
+ );
288
+ }
289
+ function containsAsyncTransform(schema, seen) {
290
+ return walkSchemaTree(
291
+ schema,
292
+ (node) => {
293
+ const def = readDef(node);
294
+ if (def === void 0) return false;
295
+ const fn = def.transform;
296
+ if (typeof fn !== "function") return false;
297
+ return fn.constructor.name === "AsyncFunction";
298
+ },
299
+ seen
300
+ );
301
+ }
302
+ function isAsyncCheck(check) {
303
+ if (typeof check !== "object" || check === null) return false;
304
+ const c = check;
305
+ const fn = c._def?.fn ?? c.def?.fn ?? c._zod?.def?.fn;
306
+ if (typeof fn !== "function") return false;
307
+ return fn.constructor.name === "AsyncFunction";
308
+ }
309
+
310
+ function unwrapToDiscriminatedUnion(schema) {
311
+ let current = schema;
312
+ for (let i = 0; i < 64; i++) {
313
+ const kind = kindOf(current);
314
+ if (kind === "discriminated-union") return current;
315
+ let next;
316
+ if (kind === "optional" || kind === "nullable" || kind === "default" || kind === "readonly" || kind === "catch") {
317
+ next = unwrapInner(current);
318
+ } else if (kind === "pipe") {
319
+ next = unwrapPipe(current);
320
+ } else if (kind === "intersection") {
321
+ const left = getIntersectionLeft(current);
322
+ const right = getIntersectionRight(current);
323
+ const leftDU = left !== void 0 ? unwrapToDiscriminatedUnion(left) : void 0;
324
+ const rightDU = right !== void 0 ? unwrapToDiscriminatedUnion(right) : void 0;
325
+ if (leftDU !== void 0 && rightDU !== void 0) {
326
+ return void 0;
327
+ }
328
+ return leftDU ?? rightDU;
329
+ }
330
+ if (next === void 0) return void 0;
331
+ current = next;
332
+ }
333
+ return void 0;
334
+ }
335
+
336
+ function zodIssuesToValidationErrors(issues) {
337
+ return issues.map((issue) => {
338
+ let code;
339
+ if (typeof issue.code === "string" && issue.code.length > 0) {
340
+ code = `zod:${issue.code}`;
341
+ } else {
342
+ code = "zod:unknown";
343
+ }
344
+ return {
345
+ message: issue.message,
346
+ // Adapter-side paths stay schema-relative — the validation
347
+ // pipeline in `create-form-store.ts` prepends the parent path
348
+ // to absolutise, then routes form-level (absolute path length 0)
349
+ // entries to the empty-string bucket at storage time.
350
+ path: issue.path.map((seg) => typeof seg === "number" ? seg : String(seg)),
351
+ code
352
+ };
353
+ });
354
+ }
355
+
356
+ const V4_INTROSPECTOR = {
357
+ kindOf: (schema) => kindOf(schema),
358
+ getObjectShape: (schema) => getObjectShape(schema),
359
+ getTupleItems,
360
+ getDiscriminatedOptions: (schema) => getDiscriminatedOptions(schema),
361
+ getDiscriminator,
362
+ getLiteralValues,
363
+ isPreprocessNode,
364
+ isCoercePrimitive,
365
+ containsAsyncRefine,
366
+ containsAsyncTransform,
367
+ containsDiscriminatedUnion,
368
+ hasContainerOrRootRefine,
369
+ // Walker accessors (D2 / D3 / D5).
370
+ getArrayElement: (schema) => {
371
+ if (kindOf(schema) !== "array") return void 0;
372
+ return getArrayElement(schema);
373
+ },
374
+ getSetValueType: (schema) => kindOf(schema) === "set" ? getSetValueType(schema) : void 0,
375
+ getRecordKeyType: (schema) => kindOf(schema) === "record" ? getRecordKeyType(schema) : void 0,
376
+ getRecordValueType: (schema) => kindOf(schema) === "record" ? getRecordValueType(schema) : void 0,
377
+ getMapKeyType: (schema) => kindOf(schema) === "map" ? getMapKeyType(schema) : void 0,
378
+ getMapValueType: (schema) => kindOf(schema) === "map" ? getMapValueType(schema) : void 0,
379
+ getUnionOptions,
380
+ getIntersectionLeft,
381
+ getIntersectionRight,
382
+ getEnumValues,
383
+ getNativeEnumValues,
384
+ unwrapInner,
385
+ unwrapBranded,
386
+ unwrapEffectsSource,
387
+ unwrapPipeIn,
388
+ unwrapPipeOut,
389
+ unwrapLazy,
390
+ getLazyGetter,
391
+ getDefaultValue,
392
+ getCatchDefault,
393
+ hasCatchValue
394
+ };
395
+
396
+ function slimPrimitivesOf(schema, maxRecursionDepth) {
397
+ return new Set(slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth));
398
+ }
399
+
400
+ function deriveDefault(schema, useDefault, maxRecursionDepth) {
401
+ return deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth, {
402
+ // v4 has an exhaustive switch against `SchemaIntrospector.kindOf`;
403
+ // unknown kinds genuinely shouldn't appear, so return undefined.
404
+ unsupportedKindFallback: () => void 0
405
+ });
406
+ }
407
+ function getDefaultValuesFromZodSchema(opts) {
408
+ const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts;
409
+ const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth);
410
+ const merged = mergeDeep(initial, constraints);
411
+ return fixStructuralDefaults(
412
+ schema,
413
+ merged,
414
+ useDefaultSchemaValues,
415
+ maxRecursionDepth,
416
+ {
417
+ intro: V4_INTROSPECTOR,
418
+ slimPrimitivesOf: (s) => slimPrimitivesOf(s, maxRecursionDepth),
419
+ deriveDefault: (s, useDefault) => deriveDefault(s, useDefault, maxRecursionDepth),
420
+ unwrapToDiscriminatedUnion
421
+ }
422
+ );
423
+ }
424
+
425
+ const PATH_SEPARATOR = ".";
426
+ function getNestedZodSchemasAtPath(schema, path, maxRecursionDepth) {
427
+ if (Array.isArray(path)) {
428
+ return walkPathSegments(schema, path.map(String), V4_INTROSPECTOR, maxRecursionDepth, 0);
429
+ }
430
+ const pathString = path;
431
+ if (pathString.length === 0) return [schema];
432
+ return walkPathSegments(
433
+ schema,
434
+ pathString.split(PATH_SEPARATOR),
435
+ V4_INTROSPECTOR,
436
+ maxRecursionDepth,
437
+ 0
438
+ );
439
+ }
440
+
441
+ function carrySyncChecks(rebuilt, original) {
442
+ if (!hasChecks(original)) return rebuilt;
443
+ const checks = getChecks(original).filter((c) => !isAsyncCheck(c));
444
+ if (checks.length === 0) return rebuilt;
445
+ return rebuilt.check(
446
+ ...checks
447
+ );
448
+ }
449
+ function stripAsyncChecks(schema) {
450
+ const seen = /* @__PURE__ */ new WeakSet();
451
+ function recurse(s) {
452
+ if (seen.has(s)) return s;
453
+ seen.add(s);
454
+ const kind = kindOf(s);
455
+ switch (kind) {
456
+ case "string":
457
+ return hasChecks(s) ? carrySyncChecks(z.string(), s) : s;
458
+ case "number":
459
+ return hasChecks(s) ? carrySyncChecks(z.number(), s) : s;
460
+ case "bigint":
461
+ return hasChecks(s) ? carrySyncChecks(z.bigint(), s) : s;
462
+ case "array": {
463
+ const element = getArrayElement(s);
464
+ return carrySyncChecks(z.array(recurse(element)), s);
465
+ }
466
+ case "set": {
467
+ return carrySyncChecks(z.set(recurse(getSetValueType(s))), s);
468
+ }
469
+ case "tuple": {
470
+ const items = getTupleItems(s).map(recurse);
471
+ const rebuilt = z.tuple(
472
+ items
473
+ );
474
+ return carrySyncChecks(rebuilt, s);
475
+ }
476
+ case "object": {
477
+ const shape = getObjectShape(s);
478
+ const next = {};
479
+ for (const [k, v] of Object.entries(shape)) {
480
+ next[k] = recurse(v);
481
+ }
482
+ return carrySyncChecks(z.object(next), s);
483
+ }
484
+ case "record": {
485
+ const keyType = getRecordKeyType(s);
486
+ const valueType = recurse(getRecordValueType(s));
487
+ return carrySyncChecks(
488
+ z.record(keyType, valueType),
489
+ s
490
+ );
491
+ }
492
+ case "union": {
493
+ const options = getUnionOptions(s).map(recurse);
494
+ return carrySyncChecks(
495
+ z.union(options),
496
+ s
497
+ );
498
+ }
499
+ case "discriminated-union": {
500
+ const options = getDiscriminatedOptions(s).map((opt) => recurse(opt));
501
+ const discriminator = getDiscriminator(s);
502
+ if (discriminator === void 0) return s;
503
+ return z.discriminatedUnion(
504
+ discriminator,
505
+ options
506
+ );
507
+ }
508
+ case "optional": {
509
+ const inner = unwrapInner(s);
510
+ return inner === void 0 ? s : recurse(inner).optional();
511
+ }
512
+ case "nullable": {
513
+ const inner = unwrapInner(s);
514
+ return inner === void 0 ? s : recurse(inner).nullable();
515
+ }
516
+ case "default": {
517
+ const inner = unwrapInner(s);
518
+ if (inner === void 0) return s;
519
+ return recurse(inner).default(getDefaultValue(s));
520
+ }
521
+ case "readonly": {
522
+ const inner = unwrapInner(s);
523
+ return inner === void 0 ? s : recurse(inner).readonly();
524
+ }
525
+ case "lazy": {
526
+ const inner = unwrapLazy(s);
527
+ if (inner === void 0) return s;
528
+ const stripped = recurse(inner);
529
+ return z.lazy(() => stripped);
530
+ }
531
+ case "intersection": {
532
+ const left = getIntersectionLeft(s);
533
+ const right = getIntersectionRight(s);
534
+ if (left === void 0 || right === void 0) return s;
535
+ return z.intersection(recurse(left), recurse(right));
536
+ }
537
+ case "catch": {
538
+ const inner = unwrapInner(s);
539
+ if (inner === void 0) return s;
540
+ return recurse(inner).catch(getCatchDefault(s));
541
+ }
542
+ // Pipes pass through (see the docblock); the rest are leaves
543
+ // whose checks the strip walker deliberately leaves in place —
544
+ // an async check on one of these still poisons the sync parse
545
+ // and the callers' defensive catch owns that case.
546
+ case "pipe":
547
+ case "boolean":
548
+ case "date":
549
+ case "enum":
550
+ case "literal":
551
+ case "null":
552
+ case "undefined":
553
+ case "any":
554
+ case "unknown":
555
+ case "nan":
556
+ case "void":
557
+ case "never":
558
+ case "promise":
559
+ case "custom":
560
+ case "template-literal":
561
+ case "transform":
562
+ case "file":
563
+ case "map":
564
+ case "symbol":
565
+ case "function":
566
+ return s;
567
+ }
568
+ }
569
+ return recurse(schema);
570
+ }
571
+
572
+ function unwrapStructuralWrappers(schema) {
573
+ let current = schema;
574
+ for (let i = 0; i < 64; i++) {
575
+ const outerKind = kindOf(current);
576
+ if (outerKind !== "optional" && outerKind !== "nullable") break;
577
+ const inner = unwrapInner(current);
578
+ if (inner === void 0) return current;
579
+ if (!isStructuralKind(kindOf(inner))) break;
580
+ current = inner;
581
+ }
582
+ return current;
583
+ }
584
+ function assertKeyedRoot(rootSchema) {
585
+ const kind = kindOf(peelAllWrappers(rootSchema));
586
+ if (kind === "object" || kind === "record" || kind === "discriminated-union") return;
587
+ throw new AttaformError(
588
+ `[attaform] AF15 attaform.dev/e/af15 '${kind}'`
589
+ );
590
+ }
591
+ function peelAllWrappers(schema) {
592
+ let current = schema;
593
+ for (let i = 0; i < 64; i++) {
594
+ const k = kindOf(current);
595
+ let inner;
596
+ if (k === "optional" || k === "nullable" || k === "default" || k === "readonly" || k === "catch") {
597
+ inner = unwrapInner(current);
598
+ } else if (k === "pipe") {
599
+ inner = unwrapPipe(current);
600
+ } else if (k === "lazy") {
601
+ inner = unwrapLazy(current);
602
+ } else {
603
+ return current;
604
+ }
605
+ if (inner === void 0) return current;
606
+ current = inner;
607
+ }
608
+ return current;
609
+ }
610
+ const STRUCTURAL_KINDS = /* @__PURE__ */ new Set([
611
+ "object",
612
+ "array",
613
+ "tuple",
614
+ "record",
615
+ "discriminated-union",
616
+ "union",
617
+ "intersection",
618
+ "optional",
619
+ "nullable",
620
+ "default",
621
+ "readonly",
622
+ "catch",
623
+ "pipe",
624
+ "lazy"
625
+ ]);
626
+ function isStructuralKind(kind) {
627
+ return STRUCTURAL_KINDS.has(kind);
628
+ }
629
+ const MAX_REQUIRED_DEPTH = 64;
630
+ function isLeafRequired(schema, depth = 0) {
631
+ if (depth > MAX_REQUIRED_DEPTH) return true;
632
+ const kind = kindOf(schema);
633
+ if (kind === "optional" || kind === "nullable" || kind === "default" || kind === "catch" || kind === "undefined" || kind === "null" || kind === "void") {
634
+ return false;
635
+ }
636
+ if (kind === "readonly") {
637
+ const inner = unwrapInner(schema);
638
+ return inner === void 0 ? true : isLeafRequired(inner, depth + 1);
639
+ }
640
+ if (kind === "pipe") {
641
+ const inner = unwrapPipe(schema);
642
+ return inner === void 0 ? true : isLeafRequired(inner, depth + 1);
643
+ }
644
+ if (kind === "lazy") {
645
+ const inner = unwrapLazy(schema);
646
+ return inner === void 0 ? true : isLeafRequired(inner, depth + 1);
647
+ }
648
+ if (kind === "union" || kind === "discriminated-union") {
649
+ const options = kind === "discriminated-union" ? getDiscriminatedOptions(schema) : getUnionOptions(schema);
650
+ if (options.length === 0) return true;
651
+ return options.every((opt) => isLeafRequired(opt, depth + 1));
652
+ }
653
+ if (kind === "intersection") {
654
+ const left = getIntersectionLeft(schema);
655
+ const right = getIntersectionRight(schema);
656
+ const leftReq = left === void 0 ? true : isLeafRequired(left, depth + 1);
657
+ const rightReq = right === void 0 ? true : isLeafRequired(right, depth + 1);
658
+ return leftReq || rightReq;
659
+ }
660
+ return true;
661
+ }
662
+ function zodV4Adapter(rootSchema) {
663
+ assertZodVersion(rootSchema);
664
+ assertKeyedRoot(rootSchema);
665
+ return (formKey, options) => createAbstractSchema(
666
+ rootSchema,
667
+ V4_INTROSPECTOR,
668
+ buildV4Services(),
669
+ formKey,
670
+ options
671
+ );
672
+ }
673
+ async function lazyFingerprint(schema) {
674
+ const { fingerprintZodSchema } = await import('../chunks/fingerprint2.mjs');
675
+ return fingerprintZodSchema(schema);
676
+ }
677
+ function buildV4Services() {
678
+ return {
679
+ fingerprint: (schema) => lazyFingerprint(schema),
680
+ getNestedSchemasAtPath: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
681
+ // v4 doesn't pre-strip for the slim-mode walk — its path walker
682
+ // already peels every transparent wrapper inline, so the slim and
683
+ // unstripped walks coincide.
684
+ getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
685
+ slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
686
+ deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
687
+ runStrictGetDefaults: (schema, config, fk, maxRecursionDepth) => runStrictGetDefaultsV4(schema, config, fk, maxRecursionDepth),
688
+ unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
689
+ unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
690
+ peelAllWrappers: (schema) => peelAllWrappers(schema),
691
+ isLeafRequired: (schema) => isLeafRequired(schema),
692
+ resolveFieldMetaAtPath: (schema, path, maxRecursionDepth) => resolveFieldMetaAtPath(schema, path, maxRecursionDepth),
693
+ issuesToValidationErrors: (issues) => zodIssuesToValidationErrors(issues),
694
+ safeParseSync: (schema, data) => {
695
+ const result = schema.safeParse(data);
696
+ return result.success ? { success: true, data: result.data } : { success: false, issues: result.error.issues };
697
+ },
698
+ safeParseAsync: async (schema, data) => {
699
+ const result = await schema.safeParseAsync(data);
700
+ return result.success ? { success: true, data: result.data } : { success: false, issues: result.error.issues };
701
+ },
702
+ makeSubSchema: (schema, fk, maxRecursionDepth) => buildSubSchemaStubV4(schema, fk, maxRecursionDepth)
703
+ };
704
+ }
705
+ function runStrictGetDefaultsV4(rootSchema, config, formKey, maxRecursionDepth) {
706
+ const { data } = getDefaultValuesFromZodSchema({
707
+ schema: rootSchema,
708
+ useDefaultSchemaValues: config.useDefaultSchemaValues,
709
+ constraints: config.constraints,
710
+ maxRecursionDepth
711
+ });
712
+ if (config.strict === false) {
713
+ return { data, errors: void 0, success: true, formKey };
714
+ }
715
+ if (containsAsyncTransform(rootSchema)) {
716
+ return { data, errors: void 0, success: true, formKey };
717
+ }
718
+ const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema;
719
+ try {
720
+ const strictResult = parseTarget.safeParse(data);
721
+ if (strictResult.success) {
722
+ return { data, errors: void 0, success: true, formKey };
723
+ }
724
+ return {
725
+ data,
726
+ errors: zodIssuesToValidationErrors(strictResult.error.issues),
727
+ success: false,
728
+ formKey
729
+ };
730
+ } catch {
731
+ return { data, errors: void 0, success: true, formKey };
732
+ }
733
+ }
734
+ function buildSubSchemaStubV4(schema, formKey, maxRecursionDepth) {
735
+ return {
736
+ fingerprint: () => lazyFingerprint(schema),
737
+ needsAsyncValidation: () => containsAsyncRefine(schema),
738
+ getDefaultValues: () => ({
739
+ data: deriveDefault(schema, true, maxRecursionDepth),
740
+ errors: void 0,
741
+ success: true,
742
+ formKey
743
+ }),
744
+ getSchemasAtPath: () => [],
745
+ validateAtPath: async (data) => {
746
+ const result = await schema.safeParseAsync(data);
747
+ if (result.success) {
748
+ return {
749
+ data: result.data,
750
+ errors: void 0,
751
+ success: true,
752
+ formKey
753
+ };
754
+ }
755
+ return {
756
+ data: void 0,
757
+ errors: zodIssuesToValidationErrors(result.error.issues),
758
+ success: false,
759
+ formKey
760
+ };
761
+ }
762
+ };
763
+ }
764
+ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
765
+ const lastSegment = path.length === 0 ? "" : path[path.length - 1];
766
+ const candidates = path.length === 0 ? [rootSchema] : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth);
767
+ const target = candidates[0];
768
+ if (target === void 0) {
769
+ return {
770
+ label: humanize(lastSegment),
771
+ description: void 0,
772
+ placeholder: void 0,
773
+ meta: Object.freeze({})
774
+ };
775
+ }
776
+ const pathMap = buildFieldMetaPathMap(rootSchema, {
777
+ intro: V4_INTROSPECTOR,
778
+ peelAllWrappers,
779
+ getFieldMetaList: getFieldMetaListForSchema
780
+ });
781
+ const pathKey = canonicalizePath(path).key;
782
+ const peeled = peelAllWrappers(target);
783
+ const payload = pathMap?.get(pathKey) ?? getFieldMetaForSchema(target) ?? (peeled !== target ? getFieldMetaForSchema(peeled) : void 0);
784
+ const targetDescription = readDescription(target);
785
+ const peeledDescription = peeled !== target ? readDescription(peeled) : void 0;
786
+ const schemaDescription = targetDescription ?? peeledDescription;
787
+ return {
788
+ label: payload?.label ?? humanize(lastSegment),
789
+ description: payload?.description ?? schemaDescription ?? void 0,
790
+ placeholder: payload?.placeholder ?? void 0,
791
+ meta: Object.freeze({ ...payload ?? {} })
792
+ };
793
+ }
794
+ function readDescription(schema) {
795
+ const candidate = schema.description;
796
+ return typeof candidate === "string" ? candidate : void 0;
797
+ }
798
+
799
+ function useForm(configuration) {
800
+ const candidate = configuration;
801
+ if (candidate === void 0 || candidate === null || candidate.schema === void 0) {
802
+ throw new InvalidUseFormConfigError();
803
+ }
804
+ const adapter = zodV4Adapter(configuration.schema);
805
+ return useAbstractForm({
806
+ ...configuration,
807
+ schema: adapter
808
+ });
809
+ }
810
+
811
+ export { assertZodVersion as a, getIntersectionRight as b, unwrapLazy as c, unwrapInner as d, unwrapPipe as e, getDiscriminator as f, getIntersectionLeft as g, getDiscriminatedOptions as h, getUnionOptions as i, getRecordKeyType as j, kindOf as k, getRecordValueType as l, getTupleItems as m, getSetValueType as n, getArrayElement as o, getObjectShape as p, getEnumValues as q, getLiteralValues as r, getChecks as s, getCatchDefault as t, useForm as u, getDefaultValue as v, zodV4Adapter as z };