attaform 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -10
- package/dist/chunks/dev-key-collision-warnings.cjs +0 -33
- package/dist/chunks/dev-key-collision-warnings.cjs.map +1 -1
- package/dist/chunks/dev-key-collision-warnings.mjs +1 -33
- package/dist/chunks/dev-key-collision-warnings.mjs.map +1 -1
- package/dist/chunks/devtools.cjs +3 -5
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +3 -5
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/fingerprint2.cjs +1 -1
- package/dist/chunks/fingerprint2.mjs +1 -1
- package/dist/index.cjs +3 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -41
- package/dist/index.d.mts +6 -41
- package/dist/index.d.ts +6 -41
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +3 -11
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.BGwNZ9GV.d.cts → attaform.BGMRvckW.d.ts} +10 -77
- package/dist/shared/{attaform.DvUH4a3o.d.ts → attaform.BJnNK75Y.d.cts} +45 -670
- package/dist/shared/{attaform.DvUH4a3o.d.mts → attaform.BJnNK75Y.d.mts} +45 -670
- package/dist/shared/{attaform.DvUH4a3o.d.cts → attaform.BJnNK75Y.d.ts} +45 -670
- package/dist/shared/{attaform.BKFwekY2.mjs → attaform.BhI9Icek.mjs} +3 -287
- package/dist/shared/attaform.BhI9Icek.mjs.map +1 -0
- package/dist/shared/{attaform.CRzpFCjV.cjs → attaform.BibT5AS_.cjs} +2 -2
- package/dist/shared/{attaform.CRzpFCjV.cjs.map → attaform.BibT5AS_.cjs.map} +1 -1
- package/dist/shared/{attaform.DkA5J8NW.d.cts → attaform.CO0e7YVY.d.cts} +1 -46
- package/dist/shared/{attaform.DkA5J8NW.d.ts → attaform.CO0e7YVY.d.mts} +1 -46
- package/dist/shared/{attaform.DkA5J8NW.d.mts → attaform.CO0e7YVY.d.ts} +1 -46
- package/dist/shared/{attaform.Q3eAD2wD.cjs → attaform.CaYj3ZfY.cjs} +3 -3
- package/dist/shared/{attaform.Q3eAD2wD.cjs.map → attaform.CaYj3ZfY.cjs.map} +1 -1
- package/dist/shared/{attaform.AyujQoHp.cjs → attaform.Cmb_LCie.cjs} +4 -4
- package/dist/shared/{attaform.DNuiFCXG.mjs.map → attaform.Cmb_LCie.cjs.map} +1 -1
- package/dist/shared/{attaform.CsB-iKbU.mjs → attaform.CtJOd7ox.mjs} +81 -591
- package/dist/shared/attaform.CtJOd7ox.mjs.map +1 -0
- package/dist/shared/{attaform.DgCfLqay.mjs → attaform.CzVta5o2.mjs} +4 -4
- package/dist/shared/attaform.CzVta5o2.mjs.map +1 -0
- package/dist/shared/{attaform.FN0vaQAg.d.mts → attaform.D52oJiYC.d.cts} +1 -1
- package/dist/shared/{attaform.aekT7mMx.d.cts → attaform.DCkSNnPr.d.mts} +1 -1
- package/dist/shared/{attaform.01iKS_lz.cjs → attaform.Db4E4IW6.cjs} +2 -294
- package/dist/shared/attaform.Db4E4IW6.cjs.map +1 -0
- package/dist/shared/{attaform.C-RtnCJM.cjs → attaform.DbyTD8N2.cjs} +4 -4
- package/dist/shared/attaform.DbyTD8N2.cjs.map +1 -0
- package/dist/shared/{attaform.DCjgGir_.mjs → attaform.Dd1Kmmaj.mjs} +3 -3
- package/dist/shared/{attaform.DCjgGir_.mjs.map → attaform.Dd1Kmmaj.mjs.map} +1 -1
- package/dist/shared/{attaform.D4XYaasQ.d.ts → attaform.DrY8srOp.d.mts} +10 -77
- package/dist/shared/{attaform.CjMcwV7W.cjs → attaform.DsQkXE3o.cjs} +79 -599
- package/dist/shared/attaform.DsQkXE3o.cjs.map +1 -0
- package/dist/shared/{attaform.CCCeEPwa.d.mts → attaform.DuPneYR0.d.cts} +10 -77
- package/dist/shared/{attaform.6xE0Lcfd.mjs → attaform.Dx9-QQE2.mjs} +2 -2
- package/dist/shared/{attaform.6xE0Lcfd.mjs.map → attaform.Dx9-QQE2.mjs.map} +1 -1
- package/dist/shared/{attaform.DUMWQefY.d.ts → attaform.WEwfXcHq.d.ts} +1 -1
- package/dist/shared/{attaform.DNuiFCXG.mjs → attaform.alpG7rT7.mjs} +4 -4
- package/dist/shared/{attaform.AyujQoHp.cjs.map → attaform.alpG7rT7.mjs.map} +1 -1
- package/dist/zod-v3.cjs +2 -2
- package/dist/zod-v3.d.cts +3 -3
- package/dist/zod-v3.d.mts +3 -3
- package/dist/zod-v3.d.ts +3 -3
- package/dist/zod-v3.mjs +2 -2
- package/dist/zod-v4.cjs +2 -2
- package/dist/zod-v4.d.cts +5 -5
- package/dist/zod-v4.d.mts +5 -5
- package/dist/zod-v4.d.ts +5 -5
- package/dist/zod-v4.mjs +2 -2
- package/dist/zod.cjs +5 -5
- package/dist/zod.d.cts +5 -5
- package/dist/zod.d.mts +5 -5
- package/dist/zod.d.ts +5 -5
- package/dist/zod.mjs +5 -5
- package/package.json +1 -1
- package/dist/chunks/indexeddb.cjs +0 -119
- package/dist/chunks/indexeddb.cjs.map +0 -1
- package/dist/chunks/indexeddb.mjs +0 -117
- package/dist/chunks/indexeddb.mjs.map +0 -1
- package/dist/chunks/local-storage.cjs +0 -58
- package/dist/chunks/local-storage.cjs.map +0 -1
- package/dist/chunks/local-storage.mjs +0 -56
- package/dist/chunks/local-storage.mjs.map +0 -1
- package/dist/chunks/multi-tab-sync.cjs +0 -367
- package/dist/chunks/multi-tab-sync.cjs.map +0 -1
- package/dist/chunks/multi-tab-sync.mjs +0 -364
- package/dist/chunks/multi-tab-sync.mjs.map +0 -1
- package/dist/chunks/session-storage.cjs +0 -58
- package/dist/chunks/session-storage.cjs.map +0 -1
- package/dist/chunks/session-storage.mjs +0 -56
- package/dist/chunks/session-storage.mjs.map +0 -1
- package/dist/chunks/wire-persistence.cjs +0 -396
- package/dist/chunks/wire-persistence.cjs.map +0 -1
- package/dist/chunks/wire-persistence.mjs +0 -394
- package/dist/chunks/wire-persistence.mjs.map +0 -1
- package/dist/shared/attaform.01iKS_lz.cjs.map +0 -1
- package/dist/shared/attaform.BKFwekY2.mjs.map +0 -1
- package/dist/shared/attaform.C-RtnCJM.cjs.map +0 -1
- package/dist/shared/attaform.CjMcwV7W.cjs.map +0 -1
- package/dist/shared/attaform.CsB-iKbU.mjs.map +0 -1
- package/dist/shared/attaform.DgCfLqay.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attaform.AyujQoHp.cjs","sources":["../../src/runtime/adapters/zod-v4/field-meta.ts","../../src/runtime/adapters/zod-v4/errors.ts","../../src/runtime/adapters/zod-v4/introspect.ts","../../src/runtime/adapters/zod-v4/assert-supported.ts","../../src/runtime/adapters/zod-v4/discriminator.ts","../../src/runtime/adapters/zod-v4/walker-introspector.ts","../../src/runtime/adapters/zod-v4/slim-primitives.ts","../../src/runtime/adapters/zod-v4/path-walker.ts","../../src/runtime/adapters/zod-v4/strip.ts","../../src/runtime/adapters/zod-v4/default-values.ts","../../src/runtime/adapters/zod-v4/adapter.ts","../../src/runtime/adapters/zod-v4/index.ts"],"sourcesContent":["/**\n * Field-metadata write/read API for the Zod v4 adapter.\n *\n * Storage lives in the shared `field-meta-store` core — every entry\n * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and\n * reads from the same `WeakMap`s, so a payload registered via any\n * entry surfaces at lookup regardless of which adapter actually runs.\n *\n * The native chain `schema.register(fieldMeta, payload)` still works\n * — Zod 4's `.register` calls `registry.add(this, payload)` and\n * returns the schema; the shared store satisfies that structurally.\n *\n * **Registration patterns:** both styles work — register on whatever\n * schema reference you assign into the parent's shape, OR on the\n * inner schema before wrapping. The adapter's resolver tries the\n * walker-returned schema first, then falls back to the peeled\n * inner so either ordering hits:\n *\n * // both equivalent — registry hits at lookup time\n * withMeta(z.string(), { label: 'Email' }).optional()\n * withMeta(z.string().optional(), { label: 'Email' })\n * z.string().optional().register(fieldMeta, { label: 'Email' })\n * z.string().register(fieldMeta, { label: 'Email' }).optional()\n *\n * The path walker returns the wrapper at terminal positions\n * (`['email']` against `{ email: z.string().optional() }` resolves\n * to `ZodOptional<ZodString>`) and peels at intermediate descent\n * (`['address', 'street']` peels through `address`'s wrapper to\n * reach the inner object). The two-stage lookup covers both leaf\n * and container registrations symmetrically.\n */\nimport type { z } from 'zod'\nimport type { FieldMetaPayload } from '../../core/field-meta'\nimport {\n fieldMetaStore,\n getFieldMetaForSchema,\n getFieldMetaListForSchema,\n} from '../../core/field-meta-store'\n\n// `$ZodRegistry` isn't surfaced under zod's classic external `z`\n// namespace, but `z.registry()` returns one — `ReturnType<typeof\n// z.registry<T>>` resolves to the registry type without a direct\n// import. The `import type` keeps the reference type-only so no\n// `z.registry` lands in the bundle.\ntype ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>\n\n/**\n * The shared registry every Attaform-aware Zod 4 schema can register\n * field metadata against. Backed by the cross-adapter\n * `fieldMetaStore` — one module-scoped instance, shared with the v3\n * adapter and the unified `attaform/zod` entry, so a `.register()`\n * chain in one place is read by adapters in another.\n *\n * Consumers extending `FieldMetaPayload` via declaration merging\n * automatically get the richer payload type at every `register` /\n * `add` / `get` call site.\n *\n * **Shared-instance disambiguation.** A single schema instance reused\n * at multiple form paths (e.g. one address schema bound to both\n * `pickup` and `delivery`) can carry distinct metadata per path —\n * even via the canonical `schema.register(fieldMeta, payload)` chain.\n * The shared store keeps a parallel list of every registration; the\n * path-resolver walks the form's schema tree counting per-schema\n * occurrences to pick the right payload for each path. Object\n * literals evaluate left-to-right, so registration order matches\n * tree-walk order, and shared schemas pair their two registrations\n * to the two paths correctly:\n *\n * z.object({\n * pickup: addressSchema.register(fieldMeta, { label: 'Pickup address' }),\n * delivery: addressSchema.register(fieldMeta, { label: 'Delivery address' }),\n * })\n * // form.fields('pickup').label → 'Pickup address'\n * // form.fields('delivery').label → 'Delivery address'\n *\n * Schemas reused via `withMeta()` get a fresh clone per call (see\n * `withMeta` below), so they never share a registry slot in the\n * first place.\n *\n * Cast to `z.$ZodRegistry<FieldMetaPayload>` so that\n * `schema.register(fieldMeta, payload)` chains type-check at the call\n * site — Zod 4's `.register()` only calls `.add(this, payload)`\n * structurally, so the cast is sound at runtime.\n */\nexport const fieldMeta = fieldMetaStore as unknown as ZodFieldMetaRegistry\n\n/**\n * Read the list of payloads registered against `schema`, in\n * registration order. Empty list when nothing has been registered.\n *\n * Used by the v4 adapter's path-resolver to disambiguate per\n * occurrence when a schema is shared across multiple form paths.\n * Most consumers won't need this — use `fieldMeta.get(schema)` for\n * the single-payload case.\n */\nexport function getFieldMetaList(schema: z.ZodType): readonly FieldMetaPayload[] {\n return getFieldMetaListForSchema(schema as object)\n}\n\n/**\n * Attach `payload` to `schema` in the shared `fieldMeta` registry\n * and return `schema` (chainable). Cross-version with `attaform/zod-v3`'s\n * `withMeta()`; user code that uses this helper reads the same on\n * either adapter.\n *\n * Equivalent to `schema.register(fieldMeta, payload)` on Zod 4.\n * Prefer the native chain for v4-only code; reach for `withMeta`\n * when authoring schema modules that may need to compile under both\n * adapters.\n *\n * Registers on the schema reference passed in. See the\n * \"Registration rule\" note in this file's header — register on the\n * inner schema before wrapping with `.optional()` / `.nullable()` /\n * `.default()` / etc.\n */\nexport function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S {\n // Clone first so each `withMeta` returns a fresh schema identity.\n // The fieldMeta registry keys on schema reference; without\n // cloning, two registrations on the same instance — common when a\n // sub-schema is reused at multiple form paths (e.g. address shared\n // between pickup and delivery) — would overwrite (last-write-wins)\n // and every path would resolve to the most recently registered\n // payload. Cloning gives every callsite its own slot.\n //\n // Merge any existing payload through so chaining accumulates\n // fields rather than replacing — `withMeta(withMeta(s, {label}), {description})`\n // keeps both keys.\n const existing = getFieldMetaForSchema(schema as object) ?? {}\n const cloned = schema.clone() as S\n fieldMetaStore.add(cloned as object, { ...existing, ...payload })\n return cloned\n}\n\n/**\n * Read the registered payload for a schema. Returns `undefined`\n * when nothing has been registered — callers apply their own\n * fallbacks (humanize for label, `.describe()` for description).\n *\n * Internal helper used by the v4 adapter's `getFieldMetaAtPath`.\n * Not part of the public `attaform/zod` surface.\n */\nexport function getFieldMeta(schema: z.ZodType): FieldMetaPayload | undefined {\n return getFieldMetaForSchema(schema as object)\n}\n","import type { z } from 'zod'\nimport { __DEV__ } from '../../core/dev'\nimport { AttaformError } from '../../core/errors'\nimport type { FormKey, ValidationError } from '../../types/types-api'\n\nlet warnedZodCodeMissing = false\n\n/**\n * Normalise a batch of Zod v4 issues into the framework's `ValidationError`\n * shape. v4 types `issue.path` as `PropertyKey[]` (includes symbols);\n * we coerce symbols to strings at the boundary so downstream consumers\n * only see string-or-number segments.\n *\n * The `code` field is stamped as `zod:${issue.code}` (e.g.\n * `zod:too_small`, `zod:invalid_format`). If a custom Zod plugin\n * emits an issue without a string `code`, we fall back to\n * `'zod:unknown'` and dev-warn once per process.\n */\nexport function zodIssuesToValidationErrors(\n issues: readonly z.core.$ZodIssue[],\n formKey: FormKey\n): ValidationError[] {\n return issues.map((issue) => {\n let code: string\n if (typeof issue.code === 'string' && issue.code.length > 0) {\n code = `zod:${issue.code}`\n } else {\n code = 'zod:unknown'\n if (__DEV__ && !warnedZodCodeMissing) {\n warnedZodCodeMissing = true\n console.warn(\n '[attaform] zod-v4 adapter received an issue with no string `code`; ' +\n \"stamping `'zod:unknown'`. This usually means a custom Zod plugin emitted \" +\n 'an issue without the standard code field.'\n )\n }\n }\n return {\n message: issue.message,\n // Adapter-side paths stay schema-relative — the validation\n // pipeline in `create-form-store.ts` prepends the parent path\n // to absolutise, then routes form-level (absolute path length 0)\n // entries to the empty-string bucket at storage time.\n path: issue.path.map((seg) => (typeof seg === 'number' ? seg : String(seg))),\n formKey,\n code,\n }\n })\n}\n\n/**\n * Thrown when a Zod schema includes a kind the form library cannot\n * represent: `z.promise`, `z.custom`, or `z.templateLiteral`.\n *\n * The error message includes the dotted path of the offending node\n * so you can locate it without traversing the whole schema.\n *\n * Recursive `z.lazy(...)` is supported, not unsupported: the\n * construction-time walk stops descending on the second encounter\n * of the same getter, and downstream walks cap their descent via\n * `maxRecursionDepth`.\n */\nexport class UnsupportedSchemaError extends AttaformError {}\n","/**\n * The single file that reads Zod v4's internal `def` shape. Every other\n * file in the zod-v4 adapter uses these public-shaped accessors — future\n * Zod minor bumps that reshape internals touch only this file.\n *\n * Design principle: treat `schema.def.*` as an unstable surface, even when\n * Zod's docs say otherwise. Each helper returns a narrow, well-typed slice;\n * no adapter code outside this file does shape-based pattern matching on\n * `def`.\n */\nimport type { z } from 'zod'\n\n/**\n * Stable kind discriminant for a Zod v4 schema. Returned by\n * `kindOf(schema)`. Use when building a custom integration that\n * needs to branch on schema shape — most consumers don't need this.\n */\nexport type ZodKind =\n | 'object'\n | 'array'\n | 'set'\n | 'record'\n | 'tuple'\n | 'union'\n | 'discriminated-union'\n | 'string'\n | 'number'\n | 'boolean'\n | 'bigint'\n | 'date'\n | 'enum'\n | 'literal'\n | 'null'\n | 'undefined'\n | 'any'\n | 'unknown'\n | 'optional'\n | 'nullable'\n | 'default'\n | 'pipe'\n | 'readonly'\n | 'nan'\n | 'void'\n | 'never'\n | 'lazy'\n | 'intersection'\n | 'catch'\n | 'promise'\n | 'custom'\n | 'template-literal'\n | 'transform'\n | 'file'\n // Enumerated so `assert-supported.ts` can reject them at construction\n // (none are form-representable — see the rationale on `UNSUPPORTED`).\n // Without explicit cases they would fall to `'unknown'` and the assert\n // step would treat them as opaque leaves.\n | 'map'\n | 'symbol'\n | 'function'\n\n// Narrow accessor for the unstable `def` surface. All reads from this\n// object go through helpers below — never inline.\ninterface ZodInternalShape {\n def?: {\n type?: string\n element?: unknown\n innerType?: unknown\n options?: readonly unknown[]\n shape?: Record<string, unknown>\n keyType?: unknown\n valueType?: unknown\n items?: readonly unknown[]\n values?: readonly unknown[]\n entries?: Record<string, unknown>\n discriminator?: string\n defaultValue?: unknown\n in?: unknown\n out?: unknown\n checks?: readonly unknown[]\n // Added for the extended kind coverage. `getter` on z.lazy(),\n // `left`/`right` on z.intersection(), `catchValue` on z.catch(),\n // `parts` on z.templateLiteral().\n getter?: () => unknown\n left?: unknown\n right?: unknown\n catchValue?: (ctx: { error: unknown; input: unknown }) => unknown\n parts?: readonly unknown[]\n // ZodTransform's user-supplied function (preprocess uses this\n // shape internally — `z.preprocess(fn, inner)` desugars to a pipe\n // whose `def.in` is a ZodTransform with `def.transform = fn`).\n transform?: unknown\n // `z.coerce.X()` in Zod v4 is a primitive schema (ZodString /\n // ZodNumber / etc.) with `def.coerce === true`. It is NOT a pipe;\n // the flag drives Zod's internal `safeParse` to cast the input.\n coerce?: boolean\n }\n}\n\nfunction readDef(schema: unknown): ZodInternalShape['def'] | undefined {\n if (schema === null || typeof schema !== 'object') return undefined\n return (schema as ZodInternalShape).def\n}\n\n/**\n * Inspect a Zod v4 schema and return its `ZodKind`. Returns\n * `'unknown'` for non-Zod inputs and unrecognised shapes.\n *\n * Useful when writing introspection helpers that branch on schema\n * structure (e.g. custom error formatters or doc generators).\n */\nexport function kindOf(schema: unknown): ZodKind {\n const def = readDef(schema)\n const rawType = def?.type\n if (rawType === undefined) return 'unknown'\n switch (rawType) {\n case 'object':\n return 'object'\n case 'array':\n return 'array'\n case 'set':\n return 'set'\n case 'record':\n return 'record'\n case 'tuple':\n return 'tuple'\n case 'union':\n // v4 stores `z.discriminatedUnion(...)` as `type: 'union'` with an\n // extra `discriminator: string` field — differentiate here.\n return def?.discriminator !== undefined ? 'discriminated-union' : 'union'\n case 'discriminated_union':\n case 'discriminatedUnion':\n return 'discriminated-union'\n case 'string':\n return 'string'\n case 'number':\n return 'number'\n case 'boolean':\n return 'boolean'\n case 'bigint':\n return 'bigint'\n case 'date':\n return 'date'\n case 'enum':\n return 'enum'\n case 'literal':\n return 'literal'\n case 'null':\n return 'null'\n case 'undefined':\n return 'undefined'\n case 'optional':\n return 'optional'\n case 'nullable':\n return 'nullable'\n case 'default':\n case 'prefault':\n return 'default'\n case 'pipe':\n return 'pipe'\n case 'readonly':\n return 'readonly'\n case 'any':\n return 'any'\n case 'nan':\n return 'nan'\n case 'void':\n return 'void'\n case 'never':\n return 'never'\n case 'lazy':\n return 'lazy'\n case 'intersection':\n return 'intersection'\n case 'catch':\n return 'catch'\n case 'transform':\n return 'transform'\n case 'promise':\n return 'promise'\n case 'custom':\n return 'custom'\n case 'template_literal':\n case 'templateLiteral':\n return 'template-literal'\n case 'file':\n return 'file'\n case 'map':\n return 'map'\n case 'symbol':\n return 'symbol'\n case 'function':\n return 'function'\n default:\n return 'unknown'\n }\n}\n\n/** Returns schema.shape as Record<string, ZodTypeAny>. */\nexport function getObjectShape(schema: z.ZodObject): Record<string, z.ZodType> {\n const s = schema as unknown as { shape: Record<string, z.ZodType> }\n return s.shape\n}\n\nexport function getArrayElement(schema: z.ZodArray): z.ZodType {\n const def = readDef(schema)\n return def?.element as z.ZodType\n}\n\n/**\n * Returns the element schema of a `z.set(...)`. Symmetric to\n * `getArrayElement`; v4 stores the set's element type on `def.valueType`.\n */\nexport function getSetValueType(schema: z.ZodType): z.ZodType {\n const def = readDef(schema)\n return def?.valueType as z.ZodType\n}\n\nexport function getRecordKeyType(schema: z.ZodType): z.ZodType {\n const def = readDef(schema)\n return def?.keyType as z.ZodType\n}\n\nexport function getRecordValueType(schema: z.ZodType): z.ZodType {\n const def = readDef(schema)\n return def?.valueType as z.ZodType\n}\n\nexport function getTupleItems(schema: z.ZodType): readonly z.ZodType[] {\n const def = readDef(schema)\n return (def?.items as readonly z.ZodType[] | undefined) ?? []\n}\n\nexport function getUnionOptions(schema: z.ZodType): readonly z.ZodType[] {\n const def = readDef(schema)\n return (def?.options as readonly z.ZodType[] | undefined) ?? []\n}\n\nexport function getLiteralValues(schema: z.ZodType): readonly unknown[] {\n const def = readDef(schema)\n return def?.values ?? []\n}\n\nexport function getEnumValues(schema: z.ZodType): readonly (string | number)[] {\n const def = readDef(schema)\n const entries = def?.entries\n if (entries === undefined) return []\n return Object.values(entries) as (string | number)[]\n}\n\nexport function unwrapInner(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.innerType as z.ZodType | undefined\n}\n\nexport function unwrapPipe(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return (def?.in as z.ZodType | undefined) ?? (def?.out as z.ZodType | undefined)\n}\n\n/** Input side of a pipe — for preprocess detection, this is the transform. */\nexport function unwrapPipeIn(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.in as z.ZodType | undefined\n}\n\n/**\n * Detect `z.coerce.X()` — a primitive schema (ZodString / ZodNumber /\n * etc.) carrying `def.coerce === true`. Zod v4 does NOT wrap coerce in\n * a pipe; the flag drives `safeParse` to cast the input. Returns true\n * for any schema whose def opted into coerce, regardless of kind.\n */\nexport function isCoercePrimitive(schema: z.ZodType): boolean {\n return readDef(schema)?.coerce === true\n}\n\n/**\n * Detect `z.preprocess(fn, inner)` — v4 desugars this to a pipe whose\n * `def.in` is a `ZodTransform`. The factory's `isPreprocessOrCoerceLeaf`\n * consults this alongside `isCoercePrimitive` to gate raw consumer\n * writes verbatim through the wrapped subtree.\n */\nexport function isPreprocessNode(schema: z.ZodType): boolean {\n if (kindOf(schema) !== 'pipe') return false\n const pipeIn = unwrapPipeIn(schema)\n return pipeIn !== undefined && kindOf(pipeIn) === 'transform'\n}\n\n/** Output side of a pipe — the inner schema in `z.preprocess(fn, inner)`. */\nexport function unwrapPipeOut(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.out as z.ZodType | undefined\n}\n\n/**\n * Resolve a `z.lazy(() => inner)` to its inner schema by invoking the\n * factory. Each invocation runs the arrow function fresh, so the returned\n * schema is a distinct object on each call — cycle detection must track\n * the getter function identity, not the resulting schema.\n */\nexport function unwrapLazy(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n const getter = def?.getter\n if (typeof getter !== 'function') return undefined\n return getter() as z.ZodType\n}\n\n/** Getter function reference on a `z.lazy()` — used for recursion detection. */\nexport function getLazyGetter(schema: z.ZodType): (() => unknown) | undefined {\n const def = readDef(schema)\n return typeof def?.getter === 'function' ? def.getter : undefined\n}\n\nexport function getIntersectionLeft(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.left as z.ZodType | undefined\n}\n\nexport function getIntersectionRight(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.right as z.ZodType | undefined\n}\n\n/**\n * Materialise the fallback value of a `z.catch(inner, value)` wrapper.\n * v4 stores the catch as a function `(ctx) => value` on `def.catchValue`;\n * we invoke it with a placeholder context. Consumer catch functions that\n * inspect `ctx.input` / `ctx.error` during default-values derivation are\n * rare — if the function throws, we surface `undefined` and let the\n * validate-then-fix loop find a fallback.\n */\nexport function getCatchDefault(schema: z.ZodType): unknown {\n const def = readDef(schema)\n const cv = def?.catchValue\n if (typeof cv !== 'function') return undefined\n try {\n return cv({ error: new Error('atta:default-values'), input: undefined })\n } catch {\n return undefined\n }\n}\n\n/** True iff the schema carries a callable `z.catch(...)` fallback. */\nexport function hasCatchValue(schema: z.ZodType): boolean {\n const def = readDef(schema)\n return typeof def?.catchValue === 'function'\n}\n\nexport function getDefaultValue(schema: z.ZodType): unknown {\n const def = readDef(schema)\n // In v4, defaultValue is stored as a getter that returns the value directly\n // (v3 stored a function that had to be called). We read the property via\n // normal access so the getter fires.\n return def?.defaultValue\n}\n\n/**\n * v3-parity stub: Zod v4 folds `z.nativeEnum(E)` into the regular `enum`\n * kind, so a v4 schema never returns a reverse-mapped values object.\n * Kept on the introspect surface so the shared `SchemaIntrospector`\n * contract is uniform between v3 and v4; the core walkers consult this\n * for the v3-specific native-enum branch and silently skip on v4.\n */\nexport function getNativeEnumValues(_schema: z.ZodType): Record<string, unknown> | undefined {\n return undefined\n}\n\n/**\n * v3-parity stub: Zod v4 has no `ZodEffects` wrapper — refinements live\n * on the schema's `def.checks`, transforms are pipe `def.in`, and\n * preprocess is pipe-with-transform-on-`in`. Returns undefined so the\n * shared walkers treat any v4 schema as \"no effects source to peel\".\n */\nexport function unwrapEffectsSource(_schema: z.ZodType): z.ZodType | undefined {\n return undefined\n}\n\n/**\n * v3-parity stub: Zod v4 has no `ZodBranded` wrapper — brand types\n * carry their brand on the type level only and don't introduce a\n * runtime wrapper. Returns undefined so the shared walkers treat\n * any v4 schema as \"no branded inner to peel\".\n */\nexport function unwrapBranded(_schema: z.ZodType): z.ZodType | undefined {\n return undefined\n}\n\n/** True if the schema's `def` carries refinement checks (e.g. `.min(3)`). */\nexport function hasChecks(schema: z.ZodType): boolean {\n const def = readDef(schema)\n const checks = def?.checks\n return Array.isArray(checks) && checks.length > 0\n}\n\n/** Raw checks array. Empty when the schema has no refinements. */\nexport function getChecks(schema: z.ZodType): readonly unknown[] {\n const def = readDef(schema)\n const checks = def?.checks\n return Array.isArray(checks) ? (checks as readonly unknown[]) : []\n}\n\n/** ZodDiscriminatedUnion: the discriminator key (e.g. 'status'). */\nexport function getDiscriminator(schema: z.ZodType): string | undefined {\n const def = readDef(schema)\n return def?.discriminator\n}\n\n/** ZodDiscriminatedUnion: the option objects (typed narrowly as ZodObject). */\nexport function getDiscriminatedOptions(schema: z.ZodType): readonly z.ZodObject[] {\n const def = readDef(schema)\n const options = def?.options\n return Array.isArray(options) ? (options as readonly z.ZodObject[]) : []\n}\n\n/**\n * Verify a schema is Zod v4. Throws a clear error if it's a v3\n * schema mistakenly imported through `attaform/zod`.\n *\n * Most consumers never call this directly — the v4 adapter calls it\n * internally on every schema. Reach for it only when wiring a custom\n * adapter that needs the same guard.\n */\nexport function assertZodVersion(schema: unknown): void {\n const def = readDef(schema)\n if (def?.type === undefined) {\n throw new Error(\n '[attaform/zod-v4] Schema is not a Zod v4 schema. The `attaform/zod-v4` adapter requires ' +\n 'zod@^4. Either: (a) install zod@^4 in your project; (b) import from `attaform/zod`, ' +\n 'which auto-detects the Zod version (and tree-shakes to a single adapter when the ' +\n '`attaform/vite` plugin is active); or (c) import from `attaform/zod-v3` if you are ' +\n 'staying on Zod v3.'\n )\n }\n}\n\n/**\n * Generalized depth-first walk over Zod v4's schema tree. The visitor\n * decides per-node whether the predicate fires; this walker handles\n * recursion through every descendable `def.*` child (innerType, element,\n * pipe in/out, intersection sides, record key/value, object shape, DU\n * entries, union options, tuple items, lazy getter).\n *\n * First `visit(node) === true` short-circuits the whole walk. The\n * shared `WeakSet<object>` guards against cycles (lazy schemas whose\n * resolver returns the SAME instance on repeat calls). The lazy\n * resolver invocation is wrapped in try/catch because some\n * recursively-defined schemas throw before their inner is constructed\n * — treated as no-match for that branch and walk continues.\n *\n * Three top-level predicates (`containsAsyncRefine`,\n * `containsAsyncTransform`, `hasContainerOrRootRefine`) all express\n * \"walk the tree, short-circuit on first hit\" — the walker hosts that\n * shape once, the predicates contribute only the per-node test.\n */\nexport function walkSchemaTree(\n schema: z.ZodType,\n visit: (node: z.ZodType) => boolean,\n seen?: WeakSet<object>\n): boolean {\n const visited = seen ?? new WeakSet<object>()\n // Defensive guard: sub-adapters cast through `as` and a malformed leaf\n // could land here as a non-object. The TS signature claims object, but\n // runtime safety beats the conditional-narrowing lint complaint.\n const candidate = schema as unknown\n if (typeof candidate !== 'object' || candidate === null) return false\n if (visited.has(candidate)) return false\n visited.add(candidate)\n\n if (visit(schema)) return true\n\n const def = readDef(schema)\n if (def === undefined) return false\n\n if (def.innerType !== undefined && walkSchemaTree(def.innerType as z.ZodType, visit, visited)) {\n return true\n }\n if (def.element !== undefined && walkSchemaTree(def.element as z.ZodType, visit, visited)) {\n return true\n }\n if (def.in !== undefined && walkSchemaTree(def.in as z.ZodType, visit, visited)) return true\n if (def.out !== undefined && walkSchemaTree(def.out as z.ZodType, visit, visited)) return true\n if (def.left !== undefined && walkSchemaTree(def.left as z.ZodType, visit, visited)) return true\n if (def.right !== undefined && walkSchemaTree(def.right as z.ZodType, visit, visited)) return true\n if (def.keyType !== undefined && walkSchemaTree(def.keyType as z.ZodType, visit, visited)) {\n return true\n }\n if (def.valueType !== undefined && walkSchemaTree(def.valueType as z.ZodType, visit, visited)) {\n return true\n }\n if (def.shape !== undefined) {\n for (const sub of Object.values(def.shape)) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (def.entries !== undefined) {\n for (const sub of Object.values(def.entries)) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (def.options !== undefined) {\n for (const sub of def.options) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (def.items !== undefined) {\n for (const sub of def.items) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (typeof def.getter === 'function') {\n try {\n const inner = def.getter() as z.ZodType\n if (walkSchemaTree(inner, visit, visited)) return true\n } catch {\n // Lazy schemas may throw on resolution before their referenced\n // schema is constructed; treat as no match and continue.\n }\n }\n\n return false\n}\n\n/**\n * True iff any refinement check on the schema (or any descendant\n * subschema) is async. Detection: walks the tree once via\n * `walkSchemaTree`, inspecting each `def.checks[].def.fn` for\n * `constructor.name === 'AsyncFunction'`. Direct `async (v) => …`\n * refinements are caught; sync functions that happen to return a\n * Promise (rare; we'd recommend marking them `async`) are NOT.\n *\n * Used by the adapter's `needsAsyncValidation()` to drive the\n * runtime's construction-time async-validation seed (see\n * create-form-store's strict-mode block). False negatives just delay\n * async refines until first mutation — matches the pre-detection\n * behavior. False positives are unlikely (the AsyncFunction check is\n * precise) and cost only one extra microtask of validation work.\n */\nexport function containsAsyncRefine(schema: z.ZodType, seen?: WeakSet<object>): boolean {\n return walkSchemaTree(\n schema,\n (node) => {\n for (const check of getChecks(node)) {\n if (isAsyncCheck(check)) return true\n }\n return false\n },\n seen\n )\n}\n\n/**\n * True iff the schema tree carries any refine / check / transform at\n * the root or at a non-leaf node. False means every check is at a leaf\n * — a per-keystroke subtree pass will catch the same verdicts as a\n * whole-form pass, and the runtime can scope leaf validation to the\n * edited path. True forces whole-form (correct, just slower).\n *\n * \"Non-leaf\" is detected by the presence of descendable children on\n * `def`: `shape` / `entries` / `element` / `options` / `items` /\n * `keyType` / `valueType` / `left` / `right`. The root is always\n * eligible — its checks ARE root refines. Transparent wrappers\n * (Optional / Nullable / Default / Catch / Readonly / Pipe / Lazy)\n * peel through to their inner without re-flagging — a `.refine` added\n * on top of a wrapper lands its check on the WRAPPER node itself, so\n * the wrapper's own `def.checks` is what's inspected.\n *\n * Bias conservative: a missed wrapper variant or an exotic `def`\n * shape we don't yet recognise returns false ONLY for that node,\n * but `walkSchemaTree`'s descent continues, so a container refine\n * nested inside still triggers `true`. Unknown wrappers we forget\n * to peel only lose the perf win, never correctness.\n */\nexport function hasContainerOrRootRefine(schema: z.ZodType, seen?: WeakSet<object>): boolean {\n return walkSchemaTree(\n schema,\n (node) => {\n const def = readDef(node)\n if (def === undefined) return false\n const isContainer =\n def.shape !== undefined ||\n def.entries !== undefined ||\n def.element !== undefined ||\n def.options !== undefined ||\n def.items !== undefined ||\n def.keyType !== undefined ||\n def.valueType !== undefined ||\n def.left !== undefined ||\n def.right !== undefined\n if (!isContainer) return false\n return getChecks(node).length > 0\n },\n seen\n )\n}\n\n/**\n * True iff any `ZodTransform` in the schema tree wraps an async\n * function. `z.preprocess(fn, inner)` desugars to a pipe whose\n * `def.in` is a `ZodTransform` with `def.transform = fn`; an async\n * `fn` makes the input side async-only, so a sync `safeParse` cannot\n * run it cleanly. The function gets invoked synchronously, returns\n * a Promise, and any throw / rejection inside it propagates as an\n * unhandled rejection because nothing's listening.\n *\n * Distinct from `containsAsyncRefine`: that one walks\n * `def.checks[].def.fn` (refinement predicates). This walks\n * `def.transform` (the transform's payload). The two flags are OR'd\n * by the adapter to drive `needsAsyncValidation()`, but the\n * construction-time strict-mode pass treats them differently:\n * async refines can be stripped and the parse retried; async\n * transforms cannot, so the strict pass skips entirely and defers\n * to the post-mount `safeParseAsync` pass.\n */\nexport function containsAsyncTransform(schema: z.ZodType, seen?: WeakSet<object>): boolean {\n return walkSchemaTree(\n schema,\n (node) => {\n const def = readDef(node)\n if (def === undefined) return false\n const fn = def.transform\n if (typeof fn !== 'function') return false\n return (fn as { constructor: { name: string } }).constructor.name === 'AsyncFunction'\n },\n seen\n )\n}\n\ninterface ZodCheckInternals {\n _def?: { fn?: unknown }\n def?: { fn?: unknown }\n _zod?: { def?: { fn?: unknown } }\n}\n\nexport function isAsyncCheck(check: unknown): boolean {\n if (typeof check !== 'object' || check === null) return false\n const c = check as ZodCheckInternals\n const fn = c._def?.fn ?? c.def?.fn ?? c._zod?.def?.fn\n if (typeof fn !== 'function') return false\n return fn.constructor.name === 'AsyncFunction'\n}\n","import type { z } from 'zod'\nimport { UnsupportedSchemaError } from './errors'\nimport {\n getArrayElement,\n getDiscriminatedOptions,\n getIntersectionLeft,\n getIntersectionRight,\n getLazyGetter,\n getObjectShape,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipe,\n type ZodKind,\n} from './introspect'\n\n/**\n * Kinds the adapter does not implement.\n *\n * - `z.promise(...)`, `z.custom(...)`, and `z.templateLiteral(...)` carry\n * no form-representable initial value: Promise-valued fields have no\n * meaningful starting state, custom predicates have no derivable\n * default, and template-literal schemas parse strings against a\n * pattern that has no obvious \"empty\" form.\n * - `z.map(...)`, `z.symbol()`, and `z.function(...)` are equally\n * unrepresentable: Maps have no obvious form encoding, symbols are\n * not JSON-serialisable so persistence and SSR round-trip would\n * silently drop them, and functions have no meaningful initial state.\n * Matches the v3 adapter's symmetric rejection list.\n *\n * The adapter rejects all six at construction so the failure surfaces\n * at `useForm(...)` rather than as a mystery `undefined` at render time.\n */\nconst UNSUPPORTED: readonly ZodKind[] = [\n 'promise',\n 'custom',\n 'template-literal',\n 'map',\n 'symbol',\n 'function',\n]\n\nfunction labelPath(path: readonly string[]): string {\n return path.length === 0 ? '<root>' : path.join('.')\n}\n\n/**\n * Walk the schema tree and fail fast on unsupported kinds.\n *\n * Recursive `z.lazy(...)` is detected (via getter identity on the\n * descent stack) and the descent stops at the second encounter — but\n * does NOT throw. Recursive schemas are supported: downstream walks\n * (default derivation, slim-primitive gate, path resolution) cap their\n * own descent via `maxRecursionDepth`. The assert step exists only to\n * surface kinds the adapter has no semantics for (`z.promise`, etc.);\n * recursive lazies are a fine shape.\n *\n * This runs once, at adapter construction time, so the cost is paid\n * at app startup rather than per keystroke.\n */\nexport function assertSupportedKinds(\n schema: z.ZodType,\n path: readonly string[] = [],\n lazyGetters: readonly (() => unknown)[] = []\n): void {\n const kind = kindOf(schema)\n\n if (UNSUPPORTED.includes(kind)) {\n throw new UnsupportedSchemaError(\n `[attaform/zod] unsupported kind '${kind}' at '${labelPath(path)}'`\n )\n }\n\n switch (kind) {\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n for (const [key, sub] of Object.entries(shape)) {\n assertSupportedKinds(sub, [...path, key], lazyGetters)\n }\n return\n }\n case 'array':\n assertSupportedKinds(getArrayElement(schema as z.ZodArray), [...path, '*'], lazyGetters)\n return\n case 'set':\n assertSupportedKinds(getSetValueType(schema), [...path, '*'], lazyGetters)\n return\n case 'record':\n assertSupportedKinds(getRecordValueType(schema), [...path, '*'], lazyGetters)\n return\n case 'tuple': {\n const items = getTupleItems(schema)\n items.forEach((item, i) => assertSupportedKinds(item, [...path, String(i)], lazyGetters))\n return\n }\n case 'union': {\n const options = getUnionOptions(schema)\n options.forEach((opt, i) => assertSupportedKinds(opt, [...path, `|${i}`], lazyGetters))\n return\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(schema)\n options.forEach((opt, i) => assertSupportedKinds(opt, [...path, `|${i}`], lazyGetters))\n return\n }\n case 'optional':\n case 'nullable':\n case 'default':\n case 'readonly':\n case 'catch': {\n const inner = unwrapInner(schema)\n if (inner !== undefined) assertSupportedKinds(inner, path, lazyGetters)\n return\n }\n case 'pipe': {\n const inner = unwrapPipe(schema)\n if (inner !== undefined) assertSupportedKinds(inner, path, lazyGetters)\n return\n }\n case 'lazy': {\n const getter = getLazyGetter(schema)\n // Stop descending on the second encounter of a getter — that's\n // a recursive `z.lazy()`. The construction-time walk only needs\n // to verify the *shape* (kinds) of the schema; downstream walks\n // handle recursion via `maxRecursionDepth`. Returning here leaves\n // recursive schemas free to mount.\n if (getter !== undefined && lazyGetters.includes(getter)) return\n const inner = unwrapLazy(schema)\n if (inner !== undefined) {\n assertSupportedKinds(\n inner,\n path,\n getter === undefined ? lazyGetters : [...lazyGetters, getter]\n )\n }\n return\n }\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n if (left !== undefined) assertSupportedKinds(left, [...path, 'left'], lazyGetters)\n if (right !== undefined) assertSupportedKinds(right, [...path, 'right'], lazyGetters)\n return\n }\n // Leaves: nothing to descend into.\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'nan':\n case 'any':\n case 'unknown':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return\n default: {\n const _exhaustive: never = kind\n throw new Error(`assertSupportedKinds: unhandled ZodKind '${_exhaustive as string}'`)\n }\n }\n}\n","import type { z } from 'zod'\nimport {\n getDiscriminatedOptions,\n getIntersectionLeft,\n getIntersectionRight,\n kindOf,\n unwrapInner,\n unwrapPipe,\n} from './introspect'\n\n/**\n * Peel optional/nullable/default/readonly/catch/pipe/intersection\n * wrappers off a schema, returning the innermost discriminated union —\n * or `undefined` if none is found. Used by the default-values walker\n * and the discriminator-aware reshape so that e.g.\n *\n * z.discriminatedUnion('status', [...]).optional().default({...})\n * z.discriminatedUnion('kind', [...]).catch({ kind: 'a', ... })\n * z.intersection(z.discriminatedUnion('kind', [...]), sharedSchema)\n *\n * still reach the DU. Catch is load-bearing here: the fallback exists\n * to fail open to a usable variant, so the runtime must still know\n * which variant the catch-default selects (otherwise it falls back to\n * a plain write and the variant-aware reshape never fires).\n * Intersections with a DU on EXACTLY ONE side resolve to that side;\n * intersections of two distinct DUs are ambiguous and return\n * `undefined` so the runtime falls back to plain writes.\n */\nexport function unwrapToDiscriminatedUnion(schema: z.ZodType): z.ZodType | undefined {\n let current: z.ZodType = schema\n // Bounded descent — any well-formed Zod schema tree terminates quickly.\n for (let i = 0; i < 64; i++) {\n const kind = kindOf(current)\n if (kind === 'discriminated-union') return current\n let next: z.ZodType | undefined\n if (\n kind === 'optional' ||\n kind === 'nullable' ||\n kind === 'default' ||\n kind === 'readonly' ||\n kind === 'catch'\n ) {\n next = unwrapInner(current)\n } else if (kind === 'pipe') {\n next = unwrapPipe(current)\n } else if (kind === 'intersection') {\n const left = getIntersectionLeft(current)\n const right = getIntersectionRight(current)\n const leftDU = left !== undefined ? unwrapToDiscriminatedUnion(left) : undefined\n const rightDU = right !== undefined ? unwrapToDiscriminatedUnion(right) : undefined\n if (leftDU !== undefined && rightDU !== undefined) {\n // Ambiguous: both sides resolve to DUs. The reshape can't pick\n // one without arbitrary preference; bail and let the runtime\n // fall through to a plain write.\n return undefined\n }\n return leftDU ?? rightDU\n }\n if (next === undefined) return undefined\n current = next\n }\n return undefined\n}\n\n/**\n * First option of a discriminated union — used as the default when no\n * discriminator value is known at default-values construction time.\n */\nexport function getDiscriminatedUnionFirstOption(schema: z.ZodType): z.ZodObject | undefined {\n const options = getDiscriminatedOptions(schema)\n return options[0]\n}\n","/**\n * Module-level `SchemaIntrospector<z.ZodType>` instance for the v4\n * adapter. The instance is stateless — every method receives a schema\n * and reads its `def.*` shape via the introspect-module accessors.\n *\n * Hosted in its own file so the per-walker modules (`path-walker.ts`,\n * `slim-primitives.ts`, `default-values.ts`) can import it without\n * routing through `adapter.ts` (which would create an import cycle:\n * `adapter.ts → path-walker.ts → adapter.ts`).\n */\nimport type { z } from 'zod'\nimport type { SchemaIntrospector, SharedZodKind } from '../../core/abstract-schema-factory'\nimport {\n containsAsyncRefine,\n containsAsyncTransform,\n getArrayElement,\n getCatchDefault,\n getDefaultValue,\n getDiscriminatedOptions,\n getDiscriminator,\n getEnumValues,\n getIntersectionLeft,\n getIntersectionRight,\n getLazyGetter,\n getLiteralValues,\n getNativeEnumValues,\n getObjectShape,\n getRecordKeyType,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n hasCatchValue,\n hasContainerOrRootRefine,\n isCoercePrimitive,\n isPreprocessNode,\n kindOf,\n unwrapBranded,\n unwrapEffectsSource,\n unwrapInner,\n unwrapLazy,\n unwrapPipeIn,\n unwrapPipeOut,\n} from './introspect'\n\nexport const V4_INTROSPECTOR: SchemaIntrospector<z.ZodType> = {\n kindOf: (schema) => kindOf(schema) as SharedZodKind | string,\n getObjectShape: (schema) => getObjectShape(schema as z.ZodObject),\n getTupleItems,\n getDiscriminatedOptions: (schema) => getDiscriminatedOptions(schema) as readonly z.ZodType[],\n getDiscriminator,\n getLiteralValues,\n isPreprocessNode,\n isCoercePrimitive,\n containsAsyncRefine,\n containsAsyncTransform,\n hasContainerOrRootRefine,\n\n // Walker accessors (D2 / D3 / D5).\n getArrayElement: (schema) => {\n if (kindOf(schema) !== 'array') return undefined\n return getArrayElement(schema as z.ZodArray)\n },\n getSetValueType: (schema) => (kindOf(schema) === 'set' ? getSetValueType(schema) : undefined),\n getRecordKeyType: (schema) =>\n kindOf(schema) === 'record' ? getRecordKeyType(schema) : undefined,\n getRecordValueType: (schema) =>\n kindOf(schema) === 'record' ? getRecordValueType(schema) : undefined,\n getUnionOptions,\n getIntersectionLeft,\n getIntersectionRight,\n getEnumValues,\n getNativeEnumValues,\n unwrapInner,\n unwrapBranded,\n unwrapEffectsSource,\n unwrapPipeIn,\n unwrapPipeOut,\n unwrapLazy,\n getLazyGetter,\n getDefaultValue,\n getCatchDefault,\n hasCatchValue,\n}\n","/**\n * Slim-primitive walker for the zod-v4 adapter. Returns the set of\n * `SlimPrimitiveKind`s a schema accepts at write time — wrappers are\n * peeled, refinement-level constraints (`.email()`, `.min(N)`, enum\n * membership, literal equality, regex) are ignored.\n *\n * Thin wrapper around the shared `slimPrimitivesWalk` core walker; v3\n * and v4 dispatch through the same body via their respective\n * `SchemaIntrospector` instance. See `core/walk-slim-primitives.ts`\n * for the per-kind dispatch rules.\n *\n * The runtime gate (`src/runtime/core/slim-primitive-gate.ts`) calls\n * the adapter method `getSlimPrimitiveTypesAtPath(path)`, which\n * resolves leaf candidates via `getNestedZodSchemasAtPath` and unions\n * `slimPrimitivesOf` across them.\n */\nimport type { z } from 'zod'\nimport type { SlimPrimitiveKind } from '../../types/types-api'\nimport { PERMISSIVE_SLIM_KINDS, slimPrimitivesWalk } from '../../core/walk-slim-primitives'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\nexport const PERMISSIVE: ReadonlySet<SlimPrimitiveKind> = PERMISSIVE_SLIM_KINDS\n\n/**\n * Walk a v4 schema, emitting the union of slim primitive kinds it\n * accepts. Clones once at the public boundary so callers get a\n * fresh mutable Set; the internal walk reuses frozen singletons for\n * leaf kinds.\n */\nexport function slimPrimitivesOf(\n schema: z.ZodType,\n maxRecursionDepth: number\n): Set<SlimPrimitiveKind> {\n return new Set(slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth))\n}\n","import type { z } from 'zod'\nimport { walkPathSegments } from '../../core/walk-path-segments'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\nconst PATH_SEPARATOR = '.'\n\n/**\n * Walk a dotted path through a Zod v4 schema tree and return the\n * subschema(s) that live at that path.\n *\n * Thin wrapper around the shared `walkPathSegments` core walker; both\n * v3 and v4 dispatch through the same body via their respective\n * `SchemaIntrospector` instance. See `core/walk-path-segments.ts` for\n * the per-kind dispatch rules.\n *\n * `maxRecursionDepth` caps descent through `z.lazy()`. Once the walker\n * has crossed `maxRecursionDepth + 1` lazy boundaries it returns `[]`,\n * so writes at recursive paths deeper than the cap fall back to a\n * permissive type gate.\n */\nexport function getNestedZodSchemasAtPath(\n schema: z.ZodType,\n path: string | readonly (string | number)[],\n maxRecursionDepth: number\n): z.ZodType[] {\n if (Array.isArray(path)) {\n return walkPathSegments(schema, path.map(String), V4_INTROSPECTOR, maxRecursionDepth, 0)\n }\n const pathString = path as string\n if (pathString.length === 0) return [schema]\n return walkPathSegments(\n schema,\n pathString.split(PATH_SEPARATOR),\n V4_INTROSPECTOR,\n maxRecursionDepth,\n 0\n )\n}\n","import { z } from 'zod'\nimport {\n getArrayElement,\n getCatchDefault,\n getChecks,\n getDefaultValue,\n getDiscriminatedOptions,\n getDiscriminator,\n getIntersectionLeft,\n getIntersectionRight,\n getObjectShape,\n getRecordKeyType,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n hasChecks,\n isAsyncCheck,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipeIn,\n unwrapPipeOut,\n} from './introspect'\n\ntype StripConfigInternal = Pick<StripConfig, 'stripRefinements'> & {\n /**\n * Optional per-check predicate. When provided, only checks for which\n * `shouldKeepCheck` returns `true` are re-applied to the rebuilt\n * schema. `stripAsyncChecks` uses this to filter async refines while\n * preserving every sync check verbatim. Absent → keep all checks\n * (existing behaviour for `getSlimSchema` callers).\n */\n shouldKeepCheck?: (check: unknown) => boolean\n}\n\n/**\n * Re-apply the container-level checks from `original` to `rebuilt`.\n * Container constructors (`z.object`, `z.array`, `z.tuple`, `z.record`,\n * `z.union`) don't accept checks in their factory signature, so\n * rebuilding a container drops `.min(1)` / `.max(3)` / `.strict()` /\n * etc. silently. Without this, a schema like\n * `z.array(z.string()).min(1)` in strict mode (where\n * `stripRefinements !== true`) would accept `[]` — the bug CR\n * reported.\n *\n * `.check(...)` accepts raw check instances, which is exactly what\n * the internal `def.checks` array holds. Skipping when\n * `stripRefinements === true` matches the leaf branches at the bottom\n * of `getSlimSchema`.\n */\nfunction carryChecks<Rebuilt extends z.ZodType>(\n rebuilt: Rebuilt,\n original: z.ZodType,\n stripConfig: StripConfigInternal\n): Rebuilt {\n if (stripConfig.stripRefinements === true) return rebuilt\n if (!hasChecks(original)) return rebuilt\n const all = getChecks(original)\n const checks =\n stripConfig.shouldKeepCheck === undefined ? all : all.filter(stripConfig.shouldKeepCheck)\n if (checks.length === 0) return rebuilt\n // `.check` on a concrete ZodType accepts instances of `$ZodCheck`\n // in Zod v4; the introspection helper returns exactly that shape,\n // so the cast is the boundary between adapter-internal typing and\n // Zod's public API.\n return (rebuilt as z.ZodType<unknown>).check(\n ...(checks as Parameters<z.ZodType<unknown>['check']>)\n ) as Rebuilt\n}\n\n/**\n * Compile-time exhaustiveness pin + runtime guard for the kind-switches\n * in this file. Passing the switch discriminant to a `never` parameter\n * means that if `ZodKind` grows a new variant, the offending `default`\n * call breaks first — pointing at the exact switch — instead of a\n * diffuse \"function lacks return statement\" elsewhere in the file.\n * Mirrors the pattern in assertSupportedKinds.\n */\nfunction unhandledZodKind(fnName: string, kind: never): never {\n throw new Error(`${fnName}: unhandled ZodKind '${kind as string}'`)\n}\n\n/**\n * stripRefinements: rebuild the schema tree with all refinement checks\n * (`z.string().min(3)`, `z.number().multipleOf(2)`, etc.) removed. The\n * validate-then-fix loop uses this so a default like `''` can satisfy a\n * `z.string().email()` during default-values construction in lax mode.\n *\n * The semantics match v3's `stripRefinements`: descend through container\n * types and rebuild leaves without their checks.\n */\nexport function stripRefinements(schema: z.ZodType): z.ZodType {\n const kind = kindOf(schema)\n switch (kind) {\n case 'string':\n return hasChecks(schema) ? z.string() : schema\n case 'number':\n return hasChecks(schema) ? z.number() : schema\n case 'bigint':\n return hasChecks(schema) ? z.bigint() : schema\n case 'array': {\n const element = getArrayElement(schema as z.ZodArray)\n return z.array(stripRefinements(element))\n }\n case 'set': {\n const valueType = getSetValueType(schema)\n return z.set(stripRefinements(valueType))\n }\n case 'tuple': {\n const items = getTupleItems(schema).map(stripRefinements)\n // z.tuple requires [T, ...T[]] but the runtime accepts an array.\n return z.tuple(items as unknown as [z.ZodType, ...z.ZodType[]]) as unknown as z.ZodType\n }\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n const next: Record<string, z.ZodType> = {}\n for (const [k, v] of Object.entries(shape)) {\n next[k] = stripRefinements(v)\n }\n return z.object(next)\n }\n case 'record': {\n const keyType = getRecordKeyType(\n schema\n ) as unknown as z.core.$ZodRecord['_zod']['def']['keyType']\n const valueType = stripRefinements(getRecordValueType(schema))\n return z.record(keyType as z.ZodType<string | number | symbol>, valueType)\n }\n case 'union': {\n const options = getUnionOptions(schema).map(stripRefinements)\n return z.union(options as unknown as readonly [z.ZodType, z.ZodType, ...z.ZodType[]])\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(schema).map(\n (opt) => stripRefinements(opt) as z.ZodObject\n )\n const discriminator = getDiscriminator(schema)\n if (discriminator === undefined) return schema\n return z.discriminatedUnion(\n discriminator,\n options as unknown as readonly [z.ZodObject, ...z.ZodObject[]]\n )\n }\n // Wrappers: strip the inner, preserve the wrapper semantics where\n // possible. For stripping refinements we typically want wrappers to\n // survive (optional/nullable/default), so leave them alone.\n case 'optional':\n case 'nullable':\n case 'default':\n case 'readonly':\n case 'pipe':\n // These wrappers are handled by getSlimSchema below per stripConfig.\n return schema\n case 'lazy': {\n const inner = unwrapLazy(schema)\n if (inner === undefined) return schema\n const slimmedInner = stripRefinements(inner)\n return z.lazy(() => slimmedInner)\n }\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n if (left === undefined || right === undefined) return schema\n return z.intersection(stripRefinements(left), stripRefinements(right))\n }\n case 'catch': {\n const inner = unwrapInner(schema)\n if (inner === undefined) return schema\n const slimmedInner = stripRefinements(inner)\n return (slimmedInner as z.ZodType).catch(getCatchDefault(schema) as never)\n }\n // Leaf types without refinements, or Zod features we don't rewrite.\n case 'boolean':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return schema\n default:\n return unhandledZodKind('stripRefinements', kind)\n }\n}\n\n/**\n * Walk the schema tree and rebuild each node with async refinement\n * checks removed. Sync `.refine` / `.superRefine` / built-in checks\n * (`min`, `max`, `email`, etc.) are preserved; wrappers (`.optional()`,\n * `.nullable()`, `.default(v)`, `.readonly()`, `.catch(v)`) are\n * preserved structurally and recursed into.\n *\n * Used by the construction-time `getDefaultValues` fallback in the\n * adapter: when `rootSchema.safeParse(data)` throws because the\n * schema contains an async refine, retrying against\n * `stripAsyncChecks(rootSchema)` surfaces every sync-refinement\n * violation that the original parse would have collected if the\n * async sibling weren't poisoning the sync entry point.\n *\n * Conceptually distinct from `stripRefinements` (drop-all, leaf\n * operation) and `getSlimSchema` (configurable peeling for default\n * derivation): this is a tree-walk that filters by sync/async at\n * every check site.\n *\n * Adapter-divergence note (Phase 12 part 2 / ADAPT-D4 deferred):\n * this stays per-adapter rather than dedup-ing into a shared core\n * walker. The structural skeleton (recurse + rebuild containers +\n * wrappers + carry container-level constraints) is parallel to v3's\n * `zod-v3/strip-async.ts:stripAsyncChecks`, but the per-check filter\n * is irreducibly asymmetric:\n *\n * - v4 filters by `isAsyncCheck(check)` at every check site — v4\n * knows the user fn directly (`check.def.fn.constructor.name`).\n * Sync refines survive the rebuild.\n * - v3 cannot statically distinguish sync from async `.refine(fn)`\n * because v3 wraps the user fn inside a sync closure that hides\n * `constructor.name`. v3 therefore drops EVERY `ZodEffects` it\n * encounters, losing sync refine seeding in mixed forms.\n *\n * A unified walker would need to either parameterise the rebuild\n * with `shouldKeepCheck` AND `shouldDropWrapperWholesale` AND\n * `rebuildLeaf` AND `rebuildContainer` services — which yields a\n * walker bigger than the two it replaces — or special-case the v3\n * effects-dropping at the call site, defeating the dedup. The\n * docblocks on both files cross-reference so future readers see\n * the deliberate asymmetry.\n */\nexport function stripAsyncChecks(schema: z.ZodType): z.ZodType {\n const config: StripConfigInternal = {\n stripRefinements: false,\n shouldKeepCheck: (c) => !isAsyncCheck(c),\n }\n // Cycle-detection set scoped to one strip pass. Mirrors the\n // pattern in `containsAsyncRefine` (introspect.ts) — pathological\n // `z.lazy(() => self)` schemas would otherwise infinite-recurse.\n const seen = new WeakSet<object>()\n\n function recurse(s: z.ZodType): z.ZodType {\n // ZodType instances are always objects — the WeakSet add/check\n // is unconditional once we're inside this function.\n if (seen.has(s)) return s\n seen.add(s)\n\n const kind = kindOf(s)\n switch (kind) {\n case 'string':\n return hasChecks(s) ? carryChecks(z.string(), s, config) : s\n case 'number':\n return hasChecks(s) ? carryChecks(z.number(), s, config) : s\n case 'bigint':\n return hasChecks(s) ? carryChecks(z.bigint(), s, config) : s\n\n case 'array': {\n const element = getArrayElement(s as z.ZodArray)\n return carryChecks(z.array(recurse(element)), s, config)\n }\n case 'set': {\n const valueType = getSetValueType(s)\n return carryChecks(z.set(recurse(valueType)), s, config)\n }\n case 'tuple': {\n const items = getTupleItems(s).map(recurse)\n const rebuilt = z.tuple(\n items as unknown as [z.ZodType, ...z.ZodType[]]\n ) as unknown as z.ZodType\n return carryChecks(rebuilt, s, config)\n }\n case 'object': {\n const shape = getObjectShape(s as z.ZodObject)\n const next: Record<string, z.ZodType> = {}\n for (const [k, v] of Object.entries(shape)) {\n next[k] = recurse(v as z.ZodType)\n }\n return carryChecks(z.object(next), s, config)\n }\n case 'record': {\n const keyType = getRecordKeyType(s)\n const valueType = recurse(getRecordValueType(s))\n const rebuilt = z.record(keyType as z.ZodType<string | number | symbol>, valueType)\n return carryChecks(rebuilt, s, config)\n }\n case 'union': {\n const options = getUnionOptions(s).map(recurse)\n const rebuilt = z.union(\n options as unknown as readonly [z.ZodType, z.ZodType, ...z.ZodType[]]\n )\n return carryChecks(rebuilt, s, config)\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(s).map((opt) => recurse(opt) as z.ZodObject)\n const discriminator = getDiscriminator(s)\n if (discriminator === undefined) return s\n return z.discriminatedUnion(\n discriminator,\n options as unknown as readonly [z.ZodObject, ...z.ZodObject[]]\n )\n }\n\n case 'optional': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).optional()\n }\n case 'nullable': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).nullable()\n }\n case 'default': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).default(getDefaultValue(s) as never)\n }\n case 'readonly': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).readonly()\n }\n\n case 'pipe':\n // Pipes carry transforms whose output shape would change if\n // we rebuilt them blindly; recursing through both halves of a\n // pipe also requires both halves to be addressable, which\n // `unwrapPipe` doesn't expose. If an async refine lives\n // inside a pipe, its throw surfaces from the inner\n // defensive catch in `getDefaultValues` — same observable\n // behaviour as today's pre-fix catch path. Common-case sync\n // siblings on flat object schemas are unaffected.\n return s\n\n case 'lazy': {\n const inner = unwrapLazy(s)\n if (inner === undefined) return s\n const stripped = recurse(inner)\n return z.lazy(() => stripped)\n }\n case 'intersection': {\n const left = getIntersectionLeft(s)\n const right = getIntersectionRight(s)\n if (left === undefined || right === undefined) return s\n return z.intersection(recurse(left), recurse(right))\n }\n case 'catch': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).catch(getCatchDefault(s) as never)\n }\n\n // Leaves with no checks — pass through unchanged.\n case 'boolean':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return s\n default:\n return unhandledZodKind('stripAsyncChecks', kind)\n }\n }\n\n return recurse(schema)\n}\n\nexport type StripConfig = {\n /** Strip `.default(v)` wrappers so the walker produces the leaf's empty value. */\n stripDefaultValues?: boolean\n /** Strip `.optional()` so `undefined` values are rejected. */\n stripOptional?: boolean\n /** Strip `.nullable()` so `null` values are rejected. */\n stripNullable?: boolean\n /** Strip refinement checks (email, min, etc.). Same semantic as v3's stripZodRefinements. */\n stripRefinements?: boolean\n /** Strip pipe transforms (refine/transform). Same semantic as v3's stripZodEffects. */\n stripPipe?: boolean\n}\n\n/**\n * getSlimSchema: walk the schema tree and apply `stripConfig` transparently.\n * Wrappers get peeled when their corresponding flag is set; refinements get\n * rebuilt when `stripRefinements` is set. Every branch recurses so deeply\n * nested wrappers inside objects/arrays/unions all get the same treatment.\n *\n * `maxRecursionDepth` caps descent through `z.lazy()`. At the cap, the\n * walker returns the original lazy unchanged — keeping the schema valid\n * for the consumer's actual data while bounding the slim-rebuild work.\n */\nexport function getSlimSchema(\n schema: z.ZodType,\n stripConfig: StripConfig,\n maxRecursionDepth: number\n): z.ZodType {\n return walkSlim(schema, stripConfig, maxRecursionDepth, 0)\n}\n\nfunction walkSlim(\n schema: z.ZodType,\n stripConfig: StripConfig,\n maxDepth: number,\n lazyDepth: number\n): z.ZodType {\n const kind = kindOf(schema)\n switch (kind) {\n case 'optional': {\n const inner = unwrapInner(schema) ?? schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n return stripConfig.stripOptional === true ? slimmedInner : slimmedInner.optional()\n }\n case 'nullable': {\n const inner = unwrapInner(schema) ?? schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n return stripConfig.stripNullable === true ? slimmedInner : slimmedInner.nullable()\n }\n case 'default': {\n const inner = unwrapInner(schema) ?? schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n if (stripConfig.stripDefaultValues === true) return slimmedInner\n // Re-apply the default to the slimmed inner. Returning `schema`\n // unchanged would skip nested stripping (refinements / pipe inside\n // a `.default()` wrapper would survive, breaking parity with the\n // optional / nullable cases above). The default value lives on\n // the wrapper at `_zod.def.defaultValue`; introspect.getDefaultValue\n // reads it through the v4 getter and resolves to the materialised\n // value (lazy `.default(() => x)` getters fire here — we rewrap\n // as a fixed value, which is correct for the slim schema's\n // single-shot use during default-values derivation).\n const defaultValue = getDefaultValue(schema)\n return (slimmedInner as z.ZodType).default(defaultValue as never)\n }\n case 'readonly': {\n // `.readonly()` wraps the output in `Object.freeze` — dropping the\n // wrapper after slimming would hand callers a mutable default,\n // which breaks invariants inside refinements that rely on the\n // frozen shape. Re-wrap the slimmed inner so the observable parse\n // behaviour matches the unstripped schema.\n const inner = unwrapInner(schema)\n return inner === undefined\n ? schema\n : (walkSlim(inner, stripConfig, maxDepth, lazyDepth) as z.ZodType).readonly()\n }\n case 'pipe': {\n // `.pipe(...)` chains schemas sequentially — the output of one\n // feeds the input of the next — and typically carries a\n // `.transform(...)` that mutates the runtime shape. Slimming the\n // inner and dropping the pipe wrapper would lose that\n // transformation, so by default we return the original schema\n // unchanged. Consumers who explicitly opt in via `stripPipe`\n // (e.g. default-values derivation, where a transform doesn't make\n // sense) get the \"real\" leg of the pipe — the side that ISN'T\n // a ZodTransform. For `z.preprocess(fn, inner)` that's `def.out`\n // (the inner schema); for `someSchema.transform(fn)` that's\n // `def.in` (the source schema). Falling through to the transform\n // side would re-run the user's fn during default-values\n // derivation — for preprocess that means a throwing fn crashes\n // mount even though there's nothing to normalize at init time.\n if (stripConfig.stripPipe === true) {\n const pipeIn = unwrapPipeIn(schema)\n const pipeOut = unwrapPipeOut(schema)\n const real =\n pipeIn !== undefined && kindOf(pipeIn) !== 'transform'\n ? pipeIn\n : pipeOut !== undefined && kindOf(pipeOut) !== 'transform'\n ? pipeOut\n : (pipeIn ?? pipeOut ?? schema)\n return walkSlim(real, stripConfig, maxDepth, lazyDepth)\n }\n return schema\n }\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n const next: Record<string, z.ZodType> = {}\n for (const [k, v] of Object.entries(shape)) {\n next[k] = walkSlim(v, stripConfig, maxDepth, lazyDepth)\n }\n return carryChecks(z.object(next), schema, stripConfig)\n }\n case 'array': {\n const element = getArrayElement(schema as z.ZodArray)\n return carryChecks(\n z.array(walkSlim(element, stripConfig, maxDepth, lazyDepth)),\n schema,\n stripConfig\n )\n }\n case 'set': {\n const valueType = getSetValueType(schema)\n return carryChecks(\n z.set(walkSlim(valueType, stripConfig, maxDepth, lazyDepth)),\n schema,\n stripConfig\n )\n }\n case 'tuple': {\n const items = getTupleItems(schema).map((it) =>\n walkSlim(it, stripConfig, maxDepth, lazyDepth)\n )\n const rebuilt = z.tuple(\n items as unknown as [z.ZodType, ...z.ZodType[]]\n ) as unknown as z.ZodType\n return carryChecks(rebuilt, schema, stripConfig)\n }\n case 'record': {\n const keyType = getRecordKeyType(schema)\n const valueType = walkSlim(getRecordValueType(schema), stripConfig, maxDepth, lazyDepth)\n const rebuilt = z.record(keyType as z.ZodType<string | number | symbol>, valueType)\n return carryChecks(rebuilt, schema, stripConfig)\n }\n case 'union': {\n const options = getUnionOptions(schema).map((opt) =>\n walkSlim(opt, stripConfig, maxDepth, lazyDepth)\n )\n const rebuilt = z.union(options as unknown as readonly [z.ZodType, z.ZodType, ...z.ZodType[]])\n return carryChecks(rebuilt, schema, stripConfig)\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(schema).map(\n (opt) => walkSlim(opt, stripConfig, maxDepth, lazyDepth) as z.ZodObject\n )\n const discriminator = getDiscriminator(schema)\n if (discriminator === undefined) return schema\n return z.discriminatedUnion(\n discriminator,\n options as unknown as readonly [z.ZodObject, ...z.ZodObject[]]\n )\n }\n // Leaves: strip refinements if requested, otherwise pass through.\n case 'string':\n case 'number':\n case 'bigint':\n return stripConfig.stripRefinements === true && hasChecks(schema)\n ? stripRefinements(schema)\n : schema\n case 'boolean':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'map':\n case 'symbol':\n case 'function':\n return schema\n case 'lazy': {\n // Past the cap, leave the original lazy in place. The slim schema\n // is for default-derivation and structural shape checks; keeping\n // the raw lazy at the recursion frontier is safe — parsing reaches\n // the same downstream getter either way.\n if (lazyDepth >= maxDepth) return schema\n const inner = unwrapLazy(schema)\n if (inner === undefined) return schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth + 1)\n return z.lazy(() => slimmedInner)\n }\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n if (left === undefined || right === undefined) return schema\n return z.intersection(\n walkSlim(left, stripConfig, maxDepth, lazyDepth),\n walkSlim(right, stripConfig, maxDepth, lazyDepth)\n )\n }\n case 'catch': {\n const inner = unwrapInner(schema)\n if (inner === undefined) return schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n // Preserve the catch wrapper so downstream safeParse still uses\n // the declared fallback — stripping it would discard user intent.\n return (slimmedInner as z.ZodType).catch(getCatchDefault(schema) as never)\n }\n case 'transform':\n case 'file':\n // ZodTransform is the input side of `z.preprocess(fn, inner)` and\n // never appears as a top-level schema reachable from the slim path\n // (the surrounding pipe descends into `.out` for the inner shape).\n // `file` has no refinements to strip beyond what the leaf schema\n // already represents. Pass through unchanged.\n return schema\n default:\n return unhandledZodKind('getSlimSchema', kind)\n }\n}\n","import type { z } from 'zod'\nimport { getAtPath, setAtPath } from '../../core/path-walker'\nimport { slimKindOf } from '../../core/slim-primitive-gate'\nimport { mergeDeep } from '../../core/merge-deep'\nimport { deriveDefaultWalk } from '../../core/walk-derive-default'\nimport { getDiscriminatedUnionFirstOption, unwrapToDiscriminatedUnion } from './discriminator'\nimport { slimPrimitivesOf } from './slim-primitives'\nimport {\n getDiscriminatedOptions,\n getUnionOptions,\n isCoercePrimitive,\n kindOf,\n unwrapPipeIn,\n} from './introspect'\nimport { getNestedZodSchemasAtPath } from './path-walker'\nimport { getSlimSchema } from './strip'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\n/**\n * Derive a default value for any Zod v4 schema.\n *\n * Thin wrapper around the shared `deriveDefaultWalk` core walker —\n * v3 and v4 dispatch through the same body via their respective\n * `SchemaIntrospector` instance. See `core/walk-derive-default.ts`\n * for the per-kind dispatch rules, including the\n * `peelEmbeddedDefault` chain-walk that closes the v3↔v4 parity gap\n * on `Optional(Default('x'))` / `Nullable(Default('x'))` / etc.\n *\n * When `useDefault` is false, `.default(x)` wrappers are skipped so\n * the walker produces the underlying leaf's empty value instead —\n * useful when the caller wants a \"blank\" initial state rather than\n * the schema's declared defaults.\n *\n * `maxRecursionDepth` caps descent through `z.lazy()`: the counter\n * bumps only when the walker crosses a lazy boundary.\n */\nexport function deriveDefault(\n schema: z.ZodType,\n useDefault: boolean,\n maxRecursionDepth: number\n): unknown {\n return deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth, {\n // v4 has an exhaustive switch against `SchemaIntrospector.kindOf`;\n // unknown kinds genuinely shouldn't appear, so return undefined.\n unsupportedKindFallback: () => undefined,\n // v4 historically recurses into the inner on `useDefault=false`\n // so a `.catch(v)` slot returns the leaf empty rather than the\n // fallback. Pinned by `test/adapters/zod-v4/unsupported-kinds.test.ts`\n // (`z.catch falls through to inner leaf default when useDefault=false`).\n catchOnUseDefaultFalse: 'recurseInner',\n })\n}\n\n// `defaultForKind` body lifted to `core/walk-derive-default.ts`; this\n// module now just adapts the result to the v4-specific\n// `getDefaultValuesFromZodSchema` validate-then-fix loop.\n\n// `mergeDeep` lifted to `core/merge-deep.ts` so v3 and v4 share one\n// body. Re-exported below as `mergeDeep` for backwards-compatible\n// internal callers (the v4 strict-mode flow still consults it).\n\nexport type GetDefaultValuesOptions = {\n schema: z.ZodObject\n useDefaultSchemaValues: boolean\n constraints: unknown\n maxRecursionDepth: number\n}\n\nexport type DefaultValuesResult<Form> = {\n data: Form\n success: boolean\n slimSchema: z.ZodType\n}\n\n/**\n * getDefaultValuesFromZodSchema — produces a form's starting value.\n *\n * The algorithm mirrors v3's: walk the schema to derive blank defaults,\n * merge constraints, then run the schema's `safeParse`. On failure, walk\n * the resulting issues and fill in issue-specific defaults at each\n * complaining path — e.g. `invalid_type` with `issue.expected === 'string'`\n * fills in `''`, `invalid_value` picks the first allowed value, etc. Re-\n * parse and return.\n *\n * Refinements are always stripped from the slim schema — this helper's\n * concern is producing usable starting data, not surfacing refinement\n * errors. Refinement enforcement (in strict mode) lives upstream in\n * `adapter.ts`'s `rootSchema.safeParse(data)` pass, which uses the full\n * schema. Stripping here is also what keeps `safeParse` from throwing\n * synchronously when the schema contains an async refine.\n */\nexport function getDefaultValuesFromZodSchema<Form>(\n opts: GetDefaultValuesOptions\n): DefaultValuesResult<Form> {\n const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts\n const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth)\n const merged = mergeDeep(initial, constraints) as unknown\n\n // Strip wrappers, including refinements. The slim schema is for\n // *default-value derivation* — its job is to produce usable starting\n // data, not to surface refinement errors. Refinement errors are the\n // domain of the strict-mode pass downstream (`adapter.ts`'s\n // `rootSchema.safeParse(data)`), which uses the full schema.\n //\n // Crucially, this also avoids `safeParse` throwing synchronously when\n // the schema contains an async refine (zod's \"Encountered Promise\n // during synchronous parse\" error) — which would otherwise crash\n // construction for any strict-mode form with `z.string().refine(async …)`.\n const slimSchema = getSlimSchema(\n schema,\n {\n stripDefaultValues: true,\n stripPipe: true,\n stripRefinements: true,\n },\n maxRecursionDepth\n )\n\n const firstParse = slimSchema.safeParse(merged)\n if (firstParse.success) {\n return { data: firstParse.data as Form, success: true, slimSchema }\n }\n\n // Validate-then-fix: walk issues and fill defaults per path. Under\n // the slim-primitive write contract, we only fix issues that violate\n // STRUCTURAL or PRIMITIVE-TYPE shape. Refinement-level issues (enum\n // membership, literal equality, .email/.min(N)/regex, custom\n // refines, unrecognized_keys) pass THROUGH unchanged — the user's\n // defaultValues are preserved verbatim and the strict-mode\n // validation pass downstream surfaces the error at construction.\n //\n // The discriminant: look up the actual offending value at the\n // issue's path and check its slim primitive kind against the\n // candidate schema's slim primitive set. If the value's kind IS in\n // the set, the issue is refinement-level → skip. If it's NOT in\n // the set, the issue is primitive/structural → fix. This unifies\n // every issue code under one check rather than enumerating refinement\n // codes (which differ between Zod versions and grow over time).\n let fixedData = merged as Record<string, unknown>\n for (const issue of firstParse.error.issues) {\n const pathSegments = issue.path.map((seg) => (typeof seg === 'number' ? seg : String(seg))) as (\n | string\n | number\n )[]\n // Schema-side input normalizers (preprocess pipes, coerce-flagged\n // primitives) are slim-stripped, so the slim-schema sees only the\n // post-strip leaf and complains when storage is `undefined`. Look\n // up the ORIGINAL schema at the path; if it's such a wrapper, the\n // `undefined` is intentional under the no-write-mutation contract\n // and we leave it alone.\n const originalCandidate = getNestedZodSchemasAtPath(schema, pathSegments, maxRecursionDepth)[0]\n if (originalCandidate !== undefined) {\n if (isCoercePrimitive(originalCandidate)) continue\n if (kindOf(originalCandidate) === 'pipe') {\n const pipeIn = unwrapPipeIn(originalCandidate)\n if (pipeIn !== undefined && kindOf(pipeIn) === 'transform') continue\n }\n }\n\n // Pass the structured path directly — joining with '.' would merge\n // a literal-dot key (`['profile.name']`) into two segments and\n // target the wrong sub-schema during fix-up.\n const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments, maxRecursionDepth)\n if (candidates.length === 0) continue\n const candidate = candidates[0]\n if (candidate === undefined) continue\n\n // Refinement-vs-primitive classification.\n const valueAtPath = getAtPath(merged, pathSegments)\n const slimKinds = slimPrimitivesOf(candidate, maxRecursionDepth)\n if (slimKinds.size > 0 && slimKinds.has(slimKindOf(valueAtPath))) {\n // Refinement-level: pass through unchanged.\n continue\n }\n\n // Some issues don't carry a type path: fall back to deriving a default\n // for the schema at that location.\n const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth)\n if (fixValue === SKIP) continue\n fixedData = (\n pathSegments.length === 0 ? fixValue : setAtPath(fixedData, pathSegments, fixValue)\n ) as Record<string, unknown>\n }\n\n const secondParse = slimSchema.safeParse(fixedData)\n if (secondParse.success) {\n return { data: secondParse.data as Form, success: true, slimSchema }\n }\n\n // Last-resort: hand back what we constructed even if it still doesn't\n // parse. Better a partially-valid form than an exception at mount time.\n return { data: fixedData as unknown as Form, success: false, slimSchema }\n}\n\nconst SKIP = Symbol('atta:skip-fix')\n\n/**\n * Map a Zod v4 issue to a concrete replacement value for the path the\n * issue points at. Falls back to the candidate subschema's walker default\n * when the issue code doesn't carry enough info.\n */\nfunction defaultFromIssue(\n issue: z.core.$ZodIssue,\n candidate: z.ZodType,\n useDefaultSchemaValues: boolean,\n maxRecursionDepth: number\n): unknown {\n if (issue.code === 'invalid_type') {\n // If the candidate is (or wraps) a discriminated union, prefer the\n // first-option default over `undefined` — matches v3's behaviour.\n const du = unwrapToDiscriminatedUnion(candidate)\n if (du !== undefined) {\n const first = getDiscriminatedUnionFirstOption(du)\n if (first !== undefined)\n return deriveDefault(first, useDefaultSchemaValues, maxRecursionDepth)\n }\n return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth)\n }\n if (issue.code === 'invalid_value') {\n const values = (issue as unknown as { values?: readonly unknown[] }).values\n if (values !== undefined && values.length > 0) return values[0]\n return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth)\n }\n // Other issue codes (too_small/too_big/invalid_format) only fire in strict\n // mode since lax mode strips refinements. Fall back to the walker default.\n return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth)\n}\n\n/**\n * Exported for callers who want the discriminated-union option set for\n * path resolution (used by the adapter's getSchemasAtPath).\n */\nexport { getDiscriminatedOptions, getUnionOptions }\n","import type { z } from 'zod'\nimport type {\n AbstractSchema,\n DefaultValuesResponse,\n FormKey,\n GetDefaultValuesConfig,\n ResolvedFieldMeta,\n SchemaFactoryOptions,\n} from '../../types/types-api'\nimport {\n createAbstractSchema,\n type AbstractSchemaServices,\n} from '../../core/abstract-schema-factory'\nimport { getFieldMeta, getFieldMetaList } from './field-meta'\nimport { humanize } from '../../core/humanize'\nimport { canonicalizePath, type Path } from '../../core/paths'\nimport type { DeepPartial, GenericForm } from '../../types/types-core'\nimport { assertSupportedKinds } from './assert-supported'\nimport { unwrapToDiscriminatedUnion } from './discriminator'\nimport { zodIssuesToValidationErrors } from './errors'\nimport { deriveDefault, getDefaultValuesFromZodSchema } from './default-values'\nimport {\n assertZodVersion,\n containsAsyncRefine,\n containsAsyncTransform,\n getDiscriminatedOptions,\n getIntersectionLeft,\n getIntersectionRight,\n getUnionOptions,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipe,\n} from './introspect'\nimport { getNestedZodSchemasAtPath } from './path-walker'\nimport { slimPrimitivesOf } from './slim-primitives'\nimport { stripAsyncChecks } from './strip'\nimport { getFieldMetaPathMap } from '../../core/walk-field-meta'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\n/**\n * Zod v4 adapter — implements `AbstractSchema` against Zod v4's public\n * surface. Internal (`def.*`) access is quarantined to introspect.ts and\n * the co-located modules (default-values, strip, path-walker, discriminator,\n * errors). This file is the wiring layer between those modules and the\n * framework's AbstractSchema contract.\n *\n * Feature parity with the v3 adapter:\n * - getDefaultValues: validate-then-fix loop (delegated to default-values.ts)\n * with refinement stripping in lax mode; discriminated-union-aware\n * first-option fallback for invalid_type issues.\n * - getSchemasAtPath: discriminated-union-aware path walker.\n * - validateAtPath: per-union-branch parse with aggregated errors.\n */\n\n/**\n * Peel `.optional()` / `.nullable()` wrappers off a leaf schema ONLY\n * when the inner type is structurally fillable (object, array, tuple,\n * record, discriminated/plain union, intersection — or itself a\n * peelable wrapper that resolves to one of those). Peeling exposes\n * the inner shape's default so consumer-supplied partial writes\n * through optional sub-schemas (`{ profile: z.object({...}).optional() }`,\n * `setValue('profile', { name: 'X' })`) get the inner shape's\n * structural defaults filled in.\n *\n * For PRIMITIVE inner (ZodString, ZodNumber, ZodBoolean, ZodLiteral,\n * etc.), the wrapper IS the meaningful schema — `optional` means\n * \"missing is allowed\", `nullable` means \"null is allowed\". Peeling\n * an optional string to its inner string would default the leaf to\n * `''` and cause mergeStructural to write `notes: ''` instead of\n * `notes: undefined` when filling sibling keys at the parent object\n * — the runtime would silently overwrite the optional's \"absent\"\n * intent with a non-empty marker.\n *\n * `.default(x)` is left intact at every level so deriveDefault\n * returns the explicit default value. Bounded iteration cap as a\n * runaway guard for pathological wrappers.\n */\nfunction unwrapStructuralWrappers(schema: z.ZodType): z.ZodType {\n let current: z.ZodType = schema\n for (let i = 0; i < 64; i++) {\n const outerKind = kindOf(current)\n if (outerKind !== 'optional' && outerKind !== 'nullable') break\n const inner = unwrapInner(current)\n if (inner === undefined) return current\n if (!isStructuralKind(kindOf(inner))) break\n current = inner\n }\n return current\n}\n\n/**\n * Peel every transparent wrapper (optional / nullable / default /\n * readonly / catch / pipe / lazy) off `schema`. Stops on the first\n * non-wrapper kind. Used by `arrayShapeAtPath` for shape\n * introspection where we want the inner kind regardless of what the\n * default-value semantic is — different from\n * `unwrapStructuralWrappers`, which preserves `.default()` so the\n * runtime fill returns the explicit default.\n *\n * Bounded iteration cap as a runaway guard for pathological wrappers.\n */\nfunction peelAllWrappers(schema: z.ZodType): z.ZodType {\n let current: z.ZodType = schema\n for (let i = 0; i < 64; i++) {\n const k = kindOf(current)\n let inner: z.ZodType | undefined\n if (\n k === 'optional' ||\n k === 'nullable' ||\n k === 'default' ||\n k === 'readonly' ||\n k === 'catch'\n ) {\n inner = unwrapInner(current)\n } else if (k === 'pipe') {\n inner = unwrapPipe(current)\n } else if (k === 'lazy') {\n inner = unwrapLazy(current)\n } else {\n return current\n }\n if (inner === undefined) return current\n current = inner\n }\n return current\n}\n\n/**\n * Kinds for which mergeStructural can recurse to fill missing keys\n * or pad missing positions. Primitive leaves (string / number / etc.)\n * and opaque non-recursable wrappers fall outside this set, so\n * peeling Optional / Nullable around them would lose information\n * (the wrapper's \"absent / null\" semantic) without enabling any fill.\n *\n * Wrappers themselves count as structural — `unwrapStructuralWrappers`\n * recurses to re-check their inner kind.\n */\nconst STRUCTURAL_KINDS: ReadonlySet<ReturnType<typeof kindOf>> = new Set([\n 'object',\n 'array',\n 'tuple',\n 'record',\n 'discriminated-union',\n 'union',\n 'intersection',\n 'optional',\n 'nullable',\n 'default',\n 'readonly',\n 'catch',\n 'pipe',\n 'lazy',\n])\n\nfunction isStructuralKind(kind: ReturnType<typeof kindOf>): boolean {\n return STRUCTURAL_KINDS.has(kind)\n}\n\nconst MAX_REQUIRED_DEPTH = 64\n\n/**\n * `true` if the leaf is required — `false` if any wrapper layer admits\n * \"empty\" via `.optional()`, `.nullable()`, `.default(N)`, or\n * `.catch(N)`. See `AbstractSchema.isRequiredAtPath` for the full\n * semantic specification (union → permissive, intersection → strict,\n * readonly/pipe/lazy → transparent peel).\n */\nfunction isLeafRequired(schema: z.ZodType, depth = 0): boolean {\n if (depth > MAX_REQUIRED_DEPTH) return true\n const kind = kindOf(schema)\n // Direct \"schema accepts empty\" wrappers and bare empty-marker leaves —\n // short-circuit. `z.undefined()` / `z.null()` / `z.void()` inside a\n // union (`z.union([z.number(), z.undefined()])`) are how schema authors\n // express \"this field can be absent\" without a wrapper, so they count\n // as not-required here.\n if (\n kind === 'optional' ||\n kind === 'nullable' ||\n kind === 'default' ||\n kind === 'catch' ||\n kind === 'undefined' ||\n kind === 'null' ||\n kind === 'void'\n ) {\n return false\n }\n // Transparent wrappers — peel and re-check.\n if (kind === 'readonly') {\n const inner = unwrapInner(schema)\n return inner === undefined ? true : isLeafRequired(inner, depth + 1)\n }\n if (kind === 'pipe') {\n // Use the input side: blank is a write-time concern.\n const inner = unwrapPipe(schema)\n return inner === undefined ? true : isLeafRequired(inner, depth + 1)\n }\n if (kind === 'lazy') {\n const inner = unwrapLazy(schema)\n return inner === undefined ? true : isLeafRequired(inner, depth + 1)\n }\n // Union — required only if EVERY branch is required (any permissive\n // branch makes the union permissive at parse time).\n if (kind === 'union' || kind === 'discriminated-union') {\n const options =\n kind === 'discriminated-union' ? getDiscriminatedOptions(schema) : getUnionOptions(schema)\n if (options.length === 0) return true\n return options.every((opt) => isLeafRequired(opt as z.ZodType, depth + 1))\n }\n // Intersection — required if EITHER side is required (a parse must\n // satisfy both; the strict side governs).\n if (kind === 'intersection') {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n const leftReq = left === undefined ? true : isLeafRequired(left, depth + 1)\n const rightReq = right === undefined ? true : isLeafRequired(right, depth + 1)\n return leftReq || rightReq\n }\n // Direct primitive leaf or unsupported kind — required by default.\n return true\n}\n\n/**\n * Wrap a Zod v4 `ZodObject` schema in an `AbstractSchema` factory.\n *\n * Most consumers never call this directly — `useForm` from\n * `attaform/zod` does the wrapping automatically. Reach for\n * it when you need an adapter outside of `useForm` (e.g. validating\n * data with the same library used elsewhere in the form runtime, or\n * exposing the adapter to a custom integration).\n *\n * The returned factory accepts per-form `SchemaFactoryOptions` (notably\n * `maxRecursionDepth`); the adapter closure bakes them into every\n * downstream walk so a per-form override can lift the cap without\n * touching the app-level default.\n *\n * Throws if the schema isn't Zod v4 or contains kinds the adapter\n * cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`).\n * Recursive `z.lazy(...)` is supported — the runtime walks bound their\n * descent via `maxRecursionDepth`.\n */\nexport function zodV4Adapter<\n FormSchema extends z.ZodObject,\n Form extends z.input<FormSchema>,\n GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>,\n>(\n rootSchema: FormSchema\n): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType> {\n assertZodVersion(rootSchema)\n // Fail fast at adapter construction if the schema uses kinds we can't\n // represent (z.promise / z.custom / z.templateLiteral). Errors carry\n // the dotted path to the offending node. Recursive lazies pass — the\n // runtime walks cap their descent via `maxRecursionDepth`.\n assertSupportedKinds(rootSchema)\n\n return (formKey: FormKey, options: SchemaFactoryOptions) =>\n createAbstractSchema<z.ZodType, Form, GetValueFormType>(\n rootSchema,\n V4_INTROSPECTOR,\n buildV4Services<Form, GetValueFormType>(),\n formKey,\n options\n )\n}\n\n/**\n * Build the v4 `AbstractSchemaServices` instance. The services are\n * stateless — every method receives the schema it acts on plus the\n * factory-supplied `formKey` / `maxRecursionDepth`. The function is\n * generic in `Form` / `GetValueFormType` so the typed methods\n * (`runStrictGetDefaults` / `makeSubSchema`) propagate the form\n * shape correctly.\n */\n// Lazy fingerprint: the only consumers are opt-in async features\n// (multi-tab channel name, persistence storage key) plus a dev-only\n// mismatch warning, so the structural walk + its `canonicalStringify`\n// helper load on demand off the eager `useForm` path instead of being\n// anchored eager by a static import.\nasync function lazyFingerprint(schema: z.ZodType): Promise<string> {\n const { fingerprintZodSchema } = await import('./fingerprint')\n return fingerprintZodSchema(schema)\n}\n\nfunction buildV4Services<\n Form extends GenericForm,\n GetValueFormType extends GenericForm,\n>(): AbstractSchemaServices<z.ZodType, Form, GetValueFormType> {\n return {\n fingerprint: (schema) => lazyFingerprint(schema),\n getNestedSchemasAtPath: (schema, path, maxRecursionDepth) =>\n getNestedZodSchemasAtPath(schema as z.ZodObject, path, maxRecursionDepth),\n // v4 doesn't pre-strip for the slim-mode walk — its path walker\n // already peels every transparent wrapper inline, so the slim and\n // unstripped walks coincide.\n getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) =>\n getNestedZodSchemasAtPath(schema as z.ZodObject, path, maxRecursionDepth),\n slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),\n deriveDefault: (schema, useDefault, maxRecursionDepth) =>\n deriveDefault(schema, useDefault, maxRecursionDepth),\n runStrictGetDefaults: (schema, config, fk, maxRecursionDepth) =>\n runStrictGetDefaultsV4<Form>(schema as FormSchemaAlias<Form>, config, fk, maxRecursionDepth),\n unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),\n unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),\n peelAllWrappers: (schema) => peelAllWrappers(schema),\n isLeafRequired: (schema) => isLeafRequired(schema),\n resolveFieldMetaAtPath: (schema, path, maxRecursionDepth) =>\n resolveFieldMetaAtPath(schema, path, maxRecursionDepth),\n issuesToValidationErrors: (issues, fk) =>\n zodIssuesToValidationErrors(issues as z.core.$ZodIssue[], fk),\n safeParseSync: (schema, data) => {\n const result = schema.safeParse(data) as z.ZodSafeParseResult<unknown>\n return result.success\n ? { success: true, data: result.data }\n : { success: false, issues: result.error.issues }\n },\n safeParseAsync: async (schema, data) => {\n const result = (await schema.safeParseAsync(data)) as z.ZodSafeParseResult<unknown>\n return result.success\n ? { success: true, data: result.data }\n : { success: false, issues: result.error.issues }\n },\n makeSubSchema: (schema, fk, maxRecursionDepth) =>\n buildSubSchemaStubV4<GetValueFormType>(schema, fk, maxRecursionDepth),\n }\n}\n\n// `runStrictGetDefaultsV4` infers its target shape from a single schema\n// argument; this alias lets the service signature compose without the\n// adapter having to repeat the ZodObject constraint inline.\ntype FormSchemaAlias<Form> = z.ZodType & { _output: Form }\n\n/**\n * v4's construction-time `getDefaultValues` flow. Wraps the slim\n * default-value derivation (`getDefaultValuesFromZodSchema`) with a\n * strict-mode parse that surfaces refinement errors at construction,\n * with two pre-flight gates:\n *\n * 1. Async transforms (`z.preprocess(async fn, T)`) cannot be\n * stripped — the transform's output shape is load-bearing for\n * the inner schema's input. Skip the strict pass; the post-mount\n * async pass picks up verdicts via `safeParseAsync`.\n *\n * 2. Async refines CAN be stripped (the predicate is detachable\n * from the schema's shape). Strip them up front so the sync\n * parse runs cleanly; sync-refinement seeds on supplied defaults\n * still surface.\n *\n * Lax mode short-circuits: the validate-then-fix loop inside the slim\n * derivation has done everything it can; partial-valid state ships\n * over a mount-time exception.\n */\nfunction runStrictGetDefaultsV4<Form>(\n rootSchema: z.ZodType & { _output: Form },\n config: GetDefaultValuesConfig<Form>,\n formKey: FormKey,\n maxRecursionDepth: number\n): DefaultValuesResponse<Form> {\n const { data } = getDefaultValuesFromZodSchema<Form>({\n schema: rootSchema as unknown as z.ZodObject,\n useDefaultSchemaValues: config.useDefaultSchemaValues,\n constraints: config.constraints,\n maxRecursionDepth,\n })\n\n if (config.strict === false) {\n // Lax mode: see docblock — partial-valid initial state preferred\n // to a mount-time exception.\n return { data, errors: undefined, success: true, formKey }\n }\n\n if (containsAsyncTransform(rootSchema)) {\n return { data, errors: undefined, success: true, formKey }\n }\n\n const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema\n try {\n const strictResult = parseTarget.safeParse(data) as z.ZodSafeParseResult<Form>\n if (strictResult.success) {\n // Storage holds the pre-transform `z.input` view, so we return\n // the original `data` (already filled by\n // `getDefaultValuesFromZodSchema`) rather than `strictResult.data`\n // (the post-transform `z.output`). For schemas without\n // `.transform()` the two coincide; for schemas with one the\n // storage stays the honest input view that `form.values` reflects.\n return { data, errors: undefined, success: true, formKey }\n }\n return {\n data,\n errors: zodIssuesToValidationErrors(strictResult.error.issues, formKey),\n success: false,\n formKey,\n }\n } catch {\n // Defensive floor: the strip walker covers every ZodKind, but a\n // future Zod construct or a user-defined sync refine that itself\n // throws would land here. Mount cleanly; the post-mount async\n // pass is the source of truth for any verdict this code path\n // can't surface.\n return { data, errors: undefined, success: true, formKey }\n }\n}\n\n/**\n * Build the 5-method sub-schema stub that v4 returns from\n * `getSchemasAtPath`. Mirrors the shape consumers expect\n * (`fingerprint`, `needsAsyncValidation`, `getDefaultValues`,\n * `getSchemasAtPath: () => []`, `validateAtPath`) without re-walking\n * through the full factory — sub-schemas in the runtime are only\n * queried for `needsAsyncValidation`, so the stub is observationally\n * interchangeable with the recursive shape v3 returns.\n */\nfunction buildSubSchemaStubV4<GetValueFormType extends GenericForm>(\n schema: z.ZodType,\n formKey: FormKey,\n maxRecursionDepth: number\n): AbstractSchema<unknown, GetValueFormType> {\n return {\n fingerprint: () => lazyFingerprint(schema),\n needsAsyncValidation: () => containsAsyncRefine(schema),\n getDefaultValues: () => ({\n data: deriveDefault(schema, true, maxRecursionDepth) as unknown,\n errors: undefined,\n success: true,\n formKey,\n }),\n getSchemasAtPath: () => [],\n validateAtPath: async (data: unknown) => {\n // safeParseAsync accepts both sync and async refinements — sync\n // check perf is a microtask slower than safeParse but we trade\n // that for the ability to express .refine(async).\n const result = await schema.safeParseAsync(data)\n if (result.success) {\n return {\n data: result.data as GetValueFormType,\n errors: undefined,\n success: true,\n formKey,\n }\n }\n return {\n data: undefined,\n errors: zodIssuesToValidationErrors(result.error.issues, formKey),\n success: false,\n formKey,\n }\n },\n } as unknown as AbstractSchema<unknown, GetValueFormType>\n}\n\n/**\n * Resolve the field metadata for the schema node at `path`. Reads\n * the `fieldMeta` registry on the resolved Zod schema and applies\n * the precedence rules in `getFieldMetaAtPath`'s docblock:\n *\n * - label: registry → humanize(lastSegment)\n * - description: registry → schema.description (.describe()) → undefined\n * - placeholder: registry → undefined\n * - meta: registry payload (frozen) — empty object when absent\n *\n * Returns the empty resolution when the path doesn't resolve in the\n * schema. DU branches: first candidate wins (matches the existing\n * first-success precedent in `getDefaultAtPath` / `validateAtPath`).\n *\n * For shared schemas registered at multiple paths (the canonical\n * `addressSchema.register(fieldMeta, A); addressSchema.register(fieldMeta, B)`\n * footgun), the path-resolver builds a per-rootSchema path → payload\n * map by walking the schema tree once, counting per-schema\n * occurrences and pairing them with the registration list in\n * declaration order. Object literals evaluate left-to-right, so\n * registration order matches tree-walk order, and the mapping pairs\n * correctly.\n */\nfunction resolveFieldMetaAtPath(\n rootSchema: z.ZodType,\n path: Path,\n maxRecursionDepth: number\n): ResolvedFieldMeta {\n const lastSegment = path.length === 0 ? '' : (path[path.length - 1] as string | number)\n const candidates =\n path.length === 0\n ? [rootSchema]\n : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth)\n const target = candidates[0]\n if (target === undefined) {\n return {\n label: humanize(lastSegment),\n description: undefined,\n placeholder: undefined,\n meta: Object.freeze({}),\n }\n }\n // Path-keyed payload map (built once per rootSchema) disambiguates\n // shared schemas. Falls back to the schema-keyed registry for paths\n // not visited by the walker (e.g. dynamic discriminated-union\n // sub-paths the walker can't statically enumerate).\n const pathMap = getFieldMetaPathMap(rootSchema, {\n intro: V4_INTROSPECTOR,\n peelAllWrappers,\n getFieldMetaList,\n })\n const pathKey = canonicalizePath(path).key\n const peeled = peelAllWrappers(target)\n const payload =\n pathMap.get(pathKey) ??\n getFieldMeta(target) ??\n (peeled !== target ? getFieldMeta(peeled) : undefined)\n // `description` is exposed as a public property on Zod 4 schemas;\n // when set via `.describe('...')` or `.meta({ description })`, it\n // reads back as a string. Read from the target first; fall back to\n // the peeled inner so a `.describe()` on `z.string()` is still\n // visible when wrapped in `.optional()`.\n const targetDescription = readDescription(target)\n const peeledDescription = peeled !== target ? readDescription(peeled) : undefined\n const schemaDescription = targetDescription ?? peeledDescription\n return {\n label: payload?.label ?? humanize(lastSegment),\n description: payload?.description ?? schemaDescription ?? undefined,\n placeholder: payload?.placeholder ?? undefined,\n meta: Object.freeze({ ...(payload ?? {}) }),\n }\n}\n\nfunction readDescription(schema: z.ZodType): string | undefined {\n const candidate = (schema as z.ZodType & { description?: unknown }).description\n return typeof candidate === 'string' ? candidate : undefined\n}\n\n// Type-only re-export so downstream code can reference the Form shape.\nexport type { DeepPartial, GenericForm }\n","/**\n * Zod v4 adapter entry point. Re-exports the adapter + the useForm\n * wrapper that threads zod-v4-specific schema types through\n * useAbstractForm.\n */\nimport type { z } from 'zod'\nimport { useAbstractForm } from '../../composables/use-abstract-form'\nimport { InvalidUseFormConfigError } from '../../core/errors'\nimport type {\n AbstractSchema,\n FormKey,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n SchemaFactoryOptions,\n} from '../../types/types-api'\nimport type { DefaultValuesInput, FlatPath, GenericForm, NestedType } from '../../types/types-core'\nimport { zodV4Adapter } from './adapter'\nimport type { StorageShape } from './types-storage-shape'\n\nexport { zodV4Adapter as zodAdapter } from './adapter'\nexport { UnsupportedSchemaError } from './errors'\nexport { assertZodVersion, kindOf } from './introspect'\nexport type { ZodKind } from './introspect'\nexport type { StorageLeaf, StorageShape } from './types-storage-shape'\n\n/**\n * Type of the value accepted at `Path` for `setValue` / `defaultValues`\n * — the schema's `z.input<Schema>` shape at that path. Matches what\n * `form.values.X` returns at runtime (the honest input view storage\n * holds before transforms run).\n *\n * ```ts\n * const schema = z.object({\n * flag: z.string().transform((v) => v.length > 10),\n * })\n * type FlagWriteIn = PathInput<typeof schema, 'flag'> // string\n * ```\n */\nexport type PathInput<Schema extends z.ZodType, Path extends string> =\n z.input<Schema> extends GenericForm\n ? Path extends FlatPath<z.input<Schema>>\n ? NestedType<z.input<Schema>, Path>\n : never\n : never\n\n/**\n * Type produced at `Path` after the full parse pipeline — the schema's\n * `z.output<Schema>` shape at that path. Matches the `data` payload of\n * `form.parse()` and the value handed to `handleSubmit`'s callback.\n *\n * ```ts\n * const schema = z.object({\n * flag: z.string().transform((v) => v.length > 10),\n * })\n * type FlagParsedOut = PathOutput<typeof schema, 'flag'> // boolean\n * ```\n */\nexport type PathOutput<Schema extends z.ZodType, Path extends string> =\n z.output<Schema> extends GenericForm\n ? Path extends FlatPath<z.output<Schema>>\n ? NestedType<z.output<Schema>, Path>\n : never\n : never\n\n/**\n * Create a form bound to a Zod v4 schema.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod'\n *\n * const form = useForm({\n * schema: z.object({\n * email: z.email(),\n * password: z.string().min(8),\n * }),\n * defaultValues: { email: '' },\n * })\n * ```\n *\n * Returns a form API exposing `register`, `values`, `errors`,\n * `fields`, `setValue`, `handleSubmit`, `meta`, field-array\n * helpers, and more. See `UseFormReturnType` for the full\n * surface.\n *\n * For Zod v3, import from `attaform/zod-v3` instead.\n */\n/**\n * `FormOf` / `OutOf` / `ReadOf` factor the three identical-shape\n * conditionals out of `useForm`'s public signature. The bundled\n * `.d.ts` then carries one alias per shape rather than re-inlining\n * `z.input<Schema> extends GenericForm ? z.input<Schema> : never`\n * four times — which is what produces TS2589 (\"Type instantiation\n * is excessively deep\") on consumer call sites with complex schemas\n * (discriminated unions, transform pipes, deep `.register()` chains).\n * Each alias is computed once per `Schema` instantiation; downstream\n * generics ride on the alias rather than re-evaluating the\n * conditional from scratch.\n */\ntype FormOf<Schema extends z.ZodObject> =\n z.input<Schema> extends GenericForm ? z.input<Schema> : never\ntype OutOf<Schema extends z.ZodObject> =\n z.output<Schema> extends GenericForm ? z.output<Schema> : never\ntype ReadOf<Schema extends z.ZodObject> =\n StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never\n\nexport function useForm<Schema extends z.ZodObject, K extends FormKey = FormKey>(\n configuration: Omit<\n UseFormConfiguration<\n FormOf<Schema>,\n OutOf<Schema>,\n AbstractSchema<FormOf<Schema>, OutOf<Schema>>,\n DefaultValuesInput<FormOf<Schema>>,\n K\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K> {\n // Foot-gun guard: catches `useForm(z.object({...}))` (raw schema as\n // the first arg — its `.schema` field is undefined), `useForm()` (no\n // args), and `useForm({ schema: undefined })` before they reach the\n // adapter and crash deep with an opaque message. JS callers and\n // `as any` callers can defy the static signature; the `unknown`\n // cast forces the runtime checks to stay live under tsc.\n const candidate = configuration as unknown\n if (\n candidate === undefined ||\n candidate === null ||\n (candidate as { schema?: unknown }).schema === undefined\n ) {\n throw new InvalidUseFormConfigError()\n }\n // Three-slot generic split:\n // - `Form` (z.input) is the WRITE view — what setValue / register\n // / defaultValues accept. Loose for honest-input wrappers\n // (preprocess accepts `unknown` at the write boundary).\n // - `Out` (z.output) is the parsed-output view — what handleSubmit\n // and form.parse() yield. Refinements have fired, transforms\n // have run.\n // - `Read` (StorageShape) is the READ view — what form.values /\n // form.fields / register's read side / toRef expose. Per-key\n // z.output for write-boundary wrappers (default / preprocess /\n // etc.) so defaulted leaves type as `T` (not `T | undefined`),\n // z.input for transforms (storage holds pre-transform input).\n type Form = z.input<Schema> extends GenericForm ? z.input<Schema> : never\n type Out = z.output<Schema> extends GenericForm ? z.output<Schema> : never\n type Read = StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never\n // `zodV4Adapter` returns a factory\n // `(formKey, options: SchemaFactoryOptions) => AbstractSchema`;\n // `UseFormConfiguration.schema` accepts `Schema | ((key, options) => Schema)`,\n // so the factory is a first-class input — previously the call site cast it\n // through `unknown as AbstractSchema`, which converted a function to an\n // object type and hid the mismatch. The narrower cast below preserves the\n // factory shape at the boundary so per-form `maxRecursionDepth` threads\n // through cleanly.\n const adapter: (key: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, Out> =\n zodV4Adapter(configuration.schema) as (\n key: FormKey,\n options: SchemaFactoryOptions\n ) => AbstractSchema<Form, Out>\n // The discriminated `ValidateOnConfig` doesn't narrow cleanly through\n // `Omit` + spread — TS picks the wrong variant after the structural\n // rebuild. The runtime input is genuinely the right shape (the\n // public `useForm` signature already enforced the discriminant on\n // `configuration` before we got here), so cast to the parameter\n // type to side-step the structural disagreement.\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return useAbstractForm<Form, Out, Read, K>({\n ...configuration,\n schema: adapter,\n } as Parameters<typeof useAbstractForm<Form, Out, Read, K>>[0])\n}\n"],"names":["fieldMetaStore","getFieldMetaListForSchema","getFieldMetaForSchema","__DEV__","AttaformError","slimPrimitivesWalk","walkPathSegments","z","deriveDefaultWalk","mergeDeep","getAtPath","slimKindOf","setAtPath","createAbstractSchema","humanize","getFieldMetaPathMap","canonicalizePath","InvalidUseFormConfigError","useAbstractForm"],"mappings":";;;;;;;AAoFO,MAAM,SAAA,GAAYA;AAWlB,SAAS,iBAAiB,MAAA,EAAgD;AAC/E,EAAA,OAAOC,wCAA0B,MAAgB,CAAA;AACnD;AAkBO,SAAS,QAAA,CAA8B,QAAW,OAAA,EAA8B;AAYrF,EAAA,MAAM,QAAA,GAAWC,mCAAA,CAAsB,MAAgB,CAAA,IAAK,EAAC;AA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,MAAA,EAAuC;AAC9D,EAAA,MAAM,YAAa,MAAA,CAAiD,WAAA;AACpE,EAAA,OAAO,OAAO,SAAA,KAAc,QAAA,GAAW,SAAA,GAAY,MAAA;AACrD;;AClaO,SAAS,QACd,aAAA,EAUqE;AAOrE,EAAA,MAAM,SAAA,GAAY,aAAA;AAClB,EAAA,IACE,cAAc,MAAA,IACd,SAAA,KAAc,IAAA,IACb,SAAA,CAAmC,WAAW,MAAA,EAC/C;AACA,IAAA,MAAM,IAAIG,+BAAA,EAA0B;AAAA,EACtC;AAwBA,EAAA,MAAM,OAAA,GACJ,YAAA,CAAa,aAAA,CAAc,MAAM,CAAA;AAWnC,EAAA,OAAOC,4BAAA,CAAoC;AAAA,IACzC,GAAG,aAAA;AAAA,IACH,MAAA,EAAQ;AAAA,GACoD,CAAA;AAChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"attaform.alpG7rT7.mjs","sources":["../../src/runtime/adapters/zod-v4/field-meta.ts","../../src/runtime/adapters/zod-v4/errors.ts","../../src/runtime/adapters/zod-v4/introspect.ts","../../src/runtime/adapters/zod-v4/assert-supported.ts","../../src/runtime/adapters/zod-v4/discriminator.ts","../../src/runtime/adapters/zod-v4/walker-introspector.ts","../../src/runtime/adapters/zod-v4/slim-primitives.ts","../../src/runtime/adapters/zod-v4/path-walker.ts","../../src/runtime/adapters/zod-v4/strip.ts","../../src/runtime/adapters/zod-v4/default-values.ts","../../src/runtime/adapters/zod-v4/adapter.ts","../../src/runtime/adapters/zod-v4/index.ts"],"sourcesContent":["/**\n * Field-metadata write/read API for the Zod v4 adapter.\n *\n * Storage lives in the shared `field-meta-store` core — every entry\n * (`attaform/zod`, `attaform/zod-v3`, `attaform/zod-v4`) writes to and\n * reads from the same `WeakMap`s, so a payload registered via any\n * entry surfaces at lookup regardless of which adapter actually runs.\n *\n * The native chain `schema.register(fieldMeta, payload)` still works\n * — Zod 4's `.register` calls `registry.add(this, payload)` and\n * returns the schema; the shared store satisfies that structurally.\n *\n * **Registration patterns:** both styles work — register on whatever\n * schema reference you assign into the parent's shape, OR on the\n * inner schema before wrapping. The adapter's resolver tries the\n * walker-returned schema first, then falls back to the peeled\n * inner so either ordering hits:\n *\n * // both equivalent — registry hits at lookup time\n * withMeta(z.string(), { label: 'Email' }).optional()\n * withMeta(z.string().optional(), { label: 'Email' })\n * z.string().optional().register(fieldMeta, { label: 'Email' })\n * z.string().register(fieldMeta, { label: 'Email' }).optional()\n *\n * The path walker returns the wrapper at terminal positions\n * (`['email']` against `{ email: z.string().optional() }` resolves\n * to `ZodOptional<ZodString>`) and peels at intermediate descent\n * (`['address', 'street']` peels through `address`'s wrapper to\n * reach the inner object). The two-stage lookup covers both leaf\n * and container registrations symmetrically.\n */\nimport type { z } from 'zod'\nimport type { FieldMetaPayload } from '../../core/field-meta'\nimport {\n fieldMetaStore,\n getFieldMetaForSchema,\n getFieldMetaListForSchema,\n} from '../../core/field-meta-store'\n\n// `$ZodRegistry` isn't surfaced under zod's classic external `z`\n// namespace, but `z.registry()` returns one — `ReturnType<typeof\n// z.registry<T>>` resolves to the registry type without a direct\n// import. The `import type` keeps the reference type-only so no\n// `z.registry` lands in the bundle.\ntype ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>\n\n/**\n * The shared registry every Attaform-aware Zod 4 schema can register\n * field metadata against. Backed by the cross-adapter\n * `fieldMetaStore` — one module-scoped instance, shared with the v3\n * adapter and the unified `attaform/zod` entry, so a `.register()`\n * chain in one place is read by adapters in another.\n *\n * Consumers extending `FieldMetaPayload` via declaration merging\n * automatically get the richer payload type at every `register` /\n * `add` / `get` call site.\n *\n * **Shared-instance disambiguation.** A single schema instance reused\n * at multiple form paths (e.g. one address schema bound to both\n * `pickup` and `delivery`) can carry distinct metadata per path —\n * even via the canonical `schema.register(fieldMeta, payload)` chain.\n * The shared store keeps a parallel list of every registration; the\n * path-resolver walks the form's schema tree counting per-schema\n * occurrences to pick the right payload for each path. Object\n * literals evaluate left-to-right, so registration order matches\n * tree-walk order, and shared schemas pair their two registrations\n * to the two paths correctly:\n *\n * z.object({\n * pickup: addressSchema.register(fieldMeta, { label: 'Pickup address' }),\n * delivery: addressSchema.register(fieldMeta, { label: 'Delivery address' }),\n * })\n * // form.fields('pickup').label → 'Pickup address'\n * // form.fields('delivery').label → 'Delivery address'\n *\n * Schemas reused via `withMeta()` get a fresh clone per call (see\n * `withMeta` below), so they never share a registry slot in the\n * first place.\n *\n * Cast to `z.$ZodRegistry<FieldMetaPayload>` so that\n * `schema.register(fieldMeta, payload)` chains type-check at the call\n * site — Zod 4's `.register()` only calls `.add(this, payload)`\n * structurally, so the cast is sound at runtime.\n */\nexport const fieldMeta = fieldMetaStore as unknown as ZodFieldMetaRegistry\n\n/**\n * Read the list of payloads registered against `schema`, in\n * registration order. Empty list when nothing has been registered.\n *\n * Used by the v4 adapter's path-resolver to disambiguate per\n * occurrence when a schema is shared across multiple form paths.\n * Most consumers won't need this — use `fieldMeta.get(schema)` for\n * the single-payload case.\n */\nexport function getFieldMetaList(schema: z.ZodType): readonly FieldMetaPayload[] {\n return getFieldMetaListForSchema(schema as object)\n}\n\n/**\n * Attach `payload` to `schema` in the shared `fieldMeta` registry\n * and return `schema` (chainable). Cross-version with `attaform/zod-v3`'s\n * `withMeta()`; user code that uses this helper reads the same on\n * either adapter.\n *\n * Equivalent to `schema.register(fieldMeta, payload)` on Zod 4.\n * Prefer the native chain for v4-only code; reach for `withMeta`\n * when authoring schema modules that may need to compile under both\n * adapters.\n *\n * Registers on the schema reference passed in. See the\n * \"Registration rule\" note in this file's header — register on the\n * inner schema before wrapping with `.optional()` / `.nullable()` /\n * `.default()` / etc.\n */\nexport function withMeta<S extends z.ZodType>(schema: S, payload: FieldMetaPayload): S {\n // Clone first so each `withMeta` returns a fresh schema identity.\n // The fieldMeta registry keys on schema reference; without\n // cloning, two registrations on the same instance — common when a\n // sub-schema is reused at multiple form paths (e.g. address shared\n // between pickup and delivery) — would overwrite (last-write-wins)\n // and every path would resolve to the most recently registered\n // payload. Cloning gives every callsite its own slot.\n //\n // Merge any existing payload through so chaining accumulates\n // fields rather than replacing — `withMeta(withMeta(s, {label}), {description})`\n // keeps both keys.\n const existing = getFieldMetaForSchema(schema as object) ?? {}\n const cloned = schema.clone() as S\n fieldMetaStore.add(cloned as object, { ...existing, ...payload })\n return cloned\n}\n\n/**\n * Read the registered payload for a schema. Returns `undefined`\n * when nothing has been registered — callers apply their own\n * fallbacks (humanize for label, `.describe()` for description).\n *\n * Internal helper used by the v4 adapter's `getFieldMetaAtPath`.\n * Not part of the public `attaform/zod` surface.\n */\nexport function getFieldMeta(schema: z.ZodType): FieldMetaPayload | undefined {\n return getFieldMetaForSchema(schema as object)\n}\n","import type { z } from 'zod'\nimport { __DEV__ } from '../../core/dev'\nimport { AttaformError } from '../../core/errors'\nimport type { FormKey, ValidationError } from '../../types/types-api'\n\nlet warnedZodCodeMissing = false\n\n/**\n * Normalise a batch of Zod v4 issues into the framework's `ValidationError`\n * shape. v4 types `issue.path` as `PropertyKey[]` (includes symbols);\n * we coerce symbols to strings at the boundary so downstream consumers\n * only see string-or-number segments.\n *\n * The `code` field is stamped as `zod:${issue.code}` (e.g.\n * `zod:too_small`, `zod:invalid_format`). If a custom Zod plugin\n * emits an issue without a string `code`, we fall back to\n * `'zod:unknown'` and dev-warn once per process.\n */\nexport function zodIssuesToValidationErrors(\n issues: readonly z.core.$ZodIssue[],\n formKey: FormKey\n): ValidationError[] {\n return issues.map((issue) => {\n let code: string\n if (typeof issue.code === 'string' && issue.code.length > 0) {\n code = `zod:${issue.code}`\n } else {\n code = 'zod:unknown'\n if (__DEV__ && !warnedZodCodeMissing) {\n warnedZodCodeMissing = true\n console.warn(\n '[attaform] zod-v4 adapter received an issue with no string `code`; ' +\n \"stamping `'zod:unknown'`. This usually means a custom Zod plugin emitted \" +\n 'an issue without the standard code field.'\n )\n }\n }\n return {\n message: issue.message,\n // Adapter-side paths stay schema-relative — the validation\n // pipeline in `create-form-store.ts` prepends the parent path\n // to absolutise, then routes form-level (absolute path length 0)\n // entries to the empty-string bucket at storage time.\n path: issue.path.map((seg) => (typeof seg === 'number' ? seg : String(seg))),\n formKey,\n code,\n }\n })\n}\n\n/**\n * Thrown when a Zod schema includes a kind the form library cannot\n * represent: `z.promise`, `z.custom`, or `z.templateLiteral`.\n *\n * The error message includes the dotted path of the offending node\n * so you can locate it without traversing the whole schema.\n *\n * Recursive `z.lazy(...)` is supported, not unsupported: the\n * construction-time walk stops descending on the second encounter\n * of the same getter, and downstream walks cap their descent via\n * `maxRecursionDepth`.\n */\nexport class UnsupportedSchemaError extends AttaformError {}\n","/**\n * The single file that reads Zod v4's internal `def` shape. Every other\n * file in the zod-v4 adapter uses these public-shaped accessors — future\n * Zod minor bumps that reshape internals touch only this file.\n *\n * Design principle: treat `schema.def.*` as an unstable surface, even when\n * Zod's docs say otherwise. Each helper returns a narrow, well-typed slice;\n * no adapter code outside this file does shape-based pattern matching on\n * `def`.\n */\nimport type { z } from 'zod'\n\n/**\n * Stable kind discriminant for a Zod v4 schema. Returned by\n * `kindOf(schema)`. Use when building a custom integration that\n * needs to branch on schema shape — most consumers don't need this.\n */\nexport type ZodKind =\n | 'object'\n | 'array'\n | 'set'\n | 'record'\n | 'tuple'\n | 'union'\n | 'discriminated-union'\n | 'string'\n | 'number'\n | 'boolean'\n | 'bigint'\n | 'date'\n | 'enum'\n | 'literal'\n | 'null'\n | 'undefined'\n | 'any'\n | 'unknown'\n | 'optional'\n | 'nullable'\n | 'default'\n | 'pipe'\n | 'readonly'\n | 'nan'\n | 'void'\n | 'never'\n | 'lazy'\n | 'intersection'\n | 'catch'\n | 'promise'\n | 'custom'\n | 'template-literal'\n | 'transform'\n | 'file'\n // Enumerated so `assert-supported.ts` can reject them at construction\n // (none are form-representable — see the rationale on `UNSUPPORTED`).\n // Without explicit cases they would fall to `'unknown'` and the assert\n // step would treat them as opaque leaves.\n | 'map'\n | 'symbol'\n | 'function'\n\n// Narrow accessor for the unstable `def` surface. All reads from this\n// object go through helpers below — never inline.\ninterface ZodInternalShape {\n def?: {\n type?: string\n element?: unknown\n innerType?: unknown\n options?: readonly unknown[]\n shape?: Record<string, unknown>\n keyType?: unknown\n valueType?: unknown\n items?: readonly unknown[]\n values?: readonly unknown[]\n entries?: Record<string, unknown>\n discriminator?: string\n defaultValue?: unknown\n in?: unknown\n out?: unknown\n checks?: readonly unknown[]\n // Added for the extended kind coverage. `getter` on z.lazy(),\n // `left`/`right` on z.intersection(), `catchValue` on z.catch(),\n // `parts` on z.templateLiteral().\n getter?: () => unknown\n left?: unknown\n right?: unknown\n catchValue?: (ctx: { error: unknown; input: unknown }) => unknown\n parts?: readonly unknown[]\n // ZodTransform's user-supplied function (preprocess uses this\n // shape internally — `z.preprocess(fn, inner)` desugars to a pipe\n // whose `def.in` is a ZodTransform with `def.transform = fn`).\n transform?: unknown\n // `z.coerce.X()` in Zod v4 is a primitive schema (ZodString /\n // ZodNumber / etc.) with `def.coerce === true`. It is NOT a pipe;\n // the flag drives Zod's internal `safeParse` to cast the input.\n coerce?: boolean\n }\n}\n\nfunction readDef(schema: unknown): ZodInternalShape['def'] | undefined {\n if (schema === null || typeof schema !== 'object') return undefined\n return (schema as ZodInternalShape).def\n}\n\n/**\n * Inspect a Zod v4 schema and return its `ZodKind`. Returns\n * `'unknown'` for non-Zod inputs and unrecognised shapes.\n *\n * Useful when writing introspection helpers that branch on schema\n * structure (e.g. custom error formatters or doc generators).\n */\nexport function kindOf(schema: unknown): ZodKind {\n const def = readDef(schema)\n const rawType = def?.type\n if (rawType === undefined) return 'unknown'\n switch (rawType) {\n case 'object':\n return 'object'\n case 'array':\n return 'array'\n case 'set':\n return 'set'\n case 'record':\n return 'record'\n case 'tuple':\n return 'tuple'\n case 'union':\n // v4 stores `z.discriminatedUnion(...)` as `type: 'union'` with an\n // extra `discriminator: string` field — differentiate here.\n return def?.discriminator !== undefined ? 'discriminated-union' : 'union'\n case 'discriminated_union':\n case 'discriminatedUnion':\n return 'discriminated-union'\n case 'string':\n return 'string'\n case 'number':\n return 'number'\n case 'boolean':\n return 'boolean'\n case 'bigint':\n return 'bigint'\n case 'date':\n return 'date'\n case 'enum':\n return 'enum'\n case 'literal':\n return 'literal'\n case 'null':\n return 'null'\n case 'undefined':\n return 'undefined'\n case 'optional':\n return 'optional'\n case 'nullable':\n return 'nullable'\n case 'default':\n case 'prefault':\n return 'default'\n case 'pipe':\n return 'pipe'\n case 'readonly':\n return 'readonly'\n case 'any':\n return 'any'\n case 'nan':\n return 'nan'\n case 'void':\n return 'void'\n case 'never':\n return 'never'\n case 'lazy':\n return 'lazy'\n case 'intersection':\n return 'intersection'\n case 'catch':\n return 'catch'\n case 'transform':\n return 'transform'\n case 'promise':\n return 'promise'\n case 'custom':\n return 'custom'\n case 'template_literal':\n case 'templateLiteral':\n return 'template-literal'\n case 'file':\n return 'file'\n case 'map':\n return 'map'\n case 'symbol':\n return 'symbol'\n case 'function':\n return 'function'\n default:\n return 'unknown'\n }\n}\n\n/** Returns schema.shape as Record<string, ZodTypeAny>. */\nexport function getObjectShape(schema: z.ZodObject): Record<string, z.ZodType> {\n const s = schema as unknown as { shape: Record<string, z.ZodType> }\n return s.shape\n}\n\nexport function getArrayElement(schema: z.ZodArray): z.ZodType {\n const def = readDef(schema)\n return def?.element as z.ZodType\n}\n\n/**\n * Returns the element schema of a `z.set(...)`. Symmetric to\n * `getArrayElement`; v4 stores the set's element type on `def.valueType`.\n */\nexport function getSetValueType(schema: z.ZodType): z.ZodType {\n const def = readDef(schema)\n return def?.valueType as z.ZodType\n}\n\nexport function getRecordKeyType(schema: z.ZodType): z.ZodType {\n const def = readDef(schema)\n return def?.keyType as z.ZodType\n}\n\nexport function getRecordValueType(schema: z.ZodType): z.ZodType {\n const def = readDef(schema)\n return def?.valueType as z.ZodType\n}\n\nexport function getTupleItems(schema: z.ZodType): readonly z.ZodType[] {\n const def = readDef(schema)\n return (def?.items as readonly z.ZodType[] | undefined) ?? []\n}\n\nexport function getUnionOptions(schema: z.ZodType): readonly z.ZodType[] {\n const def = readDef(schema)\n return (def?.options as readonly z.ZodType[] | undefined) ?? []\n}\n\nexport function getLiteralValues(schema: z.ZodType): readonly unknown[] {\n const def = readDef(schema)\n return def?.values ?? []\n}\n\nexport function getEnumValues(schema: z.ZodType): readonly (string | number)[] {\n const def = readDef(schema)\n const entries = def?.entries\n if (entries === undefined) return []\n return Object.values(entries) as (string | number)[]\n}\n\nexport function unwrapInner(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.innerType as z.ZodType | undefined\n}\n\nexport function unwrapPipe(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return (def?.in as z.ZodType | undefined) ?? (def?.out as z.ZodType | undefined)\n}\n\n/** Input side of a pipe — for preprocess detection, this is the transform. */\nexport function unwrapPipeIn(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.in as z.ZodType | undefined\n}\n\n/**\n * Detect `z.coerce.X()` — a primitive schema (ZodString / ZodNumber /\n * etc.) carrying `def.coerce === true`. Zod v4 does NOT wrap coerce in\n * a pipe; the flag drives `safeParse` to cast the input. Returns true\n * for any schema whose def opted into coerce, regardless of kind.\n */\nexport function isCoercePrimitive(schema: z.ZodType): boolean {\n return readDef(schema)?.coerce === true\n}\n\n/**\n * Detect `z.preprocess(fn, inner)` — v4 desugars this to a pipe whose\n * `def.in` is a `ZodTransform`. The factory's `isPreprocessOrCoerceLeaf`\n * consults this alongside `isCoercePrimitive` to gate raw consumer\n * writes verbatim through the wrapped subtree.\n */\nexport function isPreprocessNode(schema: z.ZodType): boolean {\n if (kindOf(schema) !== 'pipe') return false\n const pipeIn = unwrapPipeIn(schema)\n return pipeIn !== undefined && kindOf(pipeIn) === 'transform'\n}\n\n/** Output side of a pipe — the inner schema in `z.preprocess(fn, inner)`. */\nexport function unwrapPipeOut(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.out as z.ZodType | undefined\n}\n\n/**\n * Resolve a `z.lazy(() => inner)` to its inner schema by invoking the\n * factory. Each invocation runs the arrow function fresh, so the returned\n * schema is a distinct object on each call — cycle detection must track\n * the getter function identity, not the resulting schema.\n */\nexport function unwrapLazy(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n const getter = def?.getter\n if (typeof getter !== 'function') return undefined\n return getter() as z.ZodType\n}\n\n/** Getter function reference on a `z.lazy()` — used for recursion detection. */\nexport function getLazyGetter(schema: z.ZodType): (() => unknown) | undefined {\n const def = readDef(schema)\n return typeof def?.getter === 'function' ? def.getter : undefined\n}\n\nexport function getIntersectionLeft(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.left as z.ZodType | undefined\n}\n\nexport function getIntersectionRight(schema: z.ZodType): z.ZodType | undefined {\n const def = readDef(schema)\n return def?.right as z.ZodType | undefined\n}\n\n/**\n * Materialise the fallback value of a `z.catch(inner, value)` wrapper.\n * v4 stores the catch as a function `(ctx) => value` on `def.catchValue`;\n * we invoke it with a placeholder context. Consumer catch functions that\n * inspect `ctx.input` / `ctx.error` during default-values derivation are\n * rare — if the function throws, we surface `undefined` and let the\n * validate-then-fix loop find a fallback.\n */\nexport function getCatchDefault(schema: z.ZodType): unknown {\n const def = readDef(schema)\n const cv = def?.catchValue\n if (typeof cv !== 'function') return undefined\n try {\n return cv({ error: new Error('atta:default-values'), input: undefined })\n } catch {\n return undefined\n }\n}\n\n/** True iff the schema carries a callable `z.catch(...)` fallback. */\nexport function hasCatchValue(schema: z.ZodType): boolean {\n const def = readDef(schema)\n return typeof def?.catchValue === 'function'\n}\n\nexport function getDefaultValue(schema: z.ZodType): unknown {\n const def = readDef(schema)\n // In v4, defaultValue is stored as a getter that returns the value directly\n // (v3 stored a function that had to be called). We read the property via\n // normal access so the getter fires.\n return def?.defaultValue\n}\n\n/**\n * v3-parity stub: Zod v4 folds `z.nativeEnum(E)` into the regular `enum`\n * kind, so a v4 schema never returns a reverse-mapped values object.\n * Kept on the introspect surface so the shared `SchemaIntrospector`\n * contract is uniform between v3 and v4; the core walkers consult this\n * for the v3-specific native-enum branch and silently skip on v4.\n */\nexport function getNativeEnumValues(_schema: z.ZodType): Record<string, unknown> | undefined {\n return undefined\n}\n\n/**\n * v3-parity stub: Zod v4 has no `ZodEffects` wrapper — refinements live\n * on the schema's `def.checks`, transforms are pipe `def.in`, and\n * preprocess is pipe-with-transform-on-`in`. Returns undefined so the\n * shared walkers treat any v4 schema as \"no effects source to peel\".\n */\nexport function unwrapEffectsSource(_schema: z.ZodType): z.ZodType | undefined {\n return undefined\n}\n\n/**\n * v3-parity stub: Zod v4 has no `ZodBranded` wrapper — brand types\n * carry their brand on the type level only and don't introduce a\n * runtime wrapper. Returns undefined so the shared walkers treat\n * any v4 schema as \"no branded inner to peel\".\n */\nexport function unwrapBranded(_schema: z.ZodType): z.ZodType | undefined {\n return undefined\n}\n\n/** True if the schema's `def` carries refinement checks (e.g. `.min(3)`). */\nexport function hasChecks(schema: z.ZodType): boolean {\n const def = readDef(schema)\n const checks = def?.checks\n return Array.isArray(checks) && checks.length > 0\n}\n\n/** Raw checks array. Empty when the schema has no refinements. */\nexport function getChecks(schema: z.ZodType): readonly unknown[] {\n const def = readDef(schema)\n const checks = def?.checks\n return Array.isArray(checks) ? (checks as readonly unknown[]) : []\n}\n\n/** ZodDiscriminatedUnion: the discriminator key (e.g. 'status'). */\nexport function getDiscriminator(schema: z.ZodType): string | undefined {\n const def = readDef(schema)\n return def?.discriminator\n}\n\n/** ZodDiscriminatedUnion: the option objects (typed narrowly as ZodObject). */\nexport function getDiscriminatedOptions(schema: z.ZodType): readonly z.ZodObject[] {\n const def = readDef(schema)\n const options = def?.options\n return Array.isArray(options) ? (options as readonly z.ZodObject[]) : []\n}\n\n/**\n * Verify a schema is Zod v4. Throws a clear error if it's a v3\n * schema mistakenly imported through `attaform/zod`.\n *\n * Most consumers never call this directly — the v4 adapter calls it\n * internally on every schema. Reach for it only when wiring a custom\n * adapter that needs the same guard.\n */\nexport function assertZodVersion(schema: unknown): void {\n const def = readDef(schema)\n if (def?.type === undefined) {\n throw new Error(\n '[attaform/zod-v4] Schema is not a Zod v4 schema. The `attaform/zod-v4` adapter requires ' +\n 'zod@^4. Either: (a) install zod@^4 in your project; (b) import from `attaform/zod`, ' +\n 'which auto-detects the Zod version (and tree-shakes to a single adapter when the ' +\n '`attaform/vite` plugin is active); or (c) import from `attaform/zod-v3` if you are ' +\n 'staying on Zod v3.'\n )\n }\n}\n\n/**\n * Generalized depth-first walk over Zod v4's schema tree. The visitor\n * decides per-node whether the predicate fires; this walker handles\n * recursion through every descendable `def.*` child (innerType, element,\n * pipe in/out, intersection sides, record key/value, object shape, DU\n * entries, union options, tuple items, lazy getter).\n *\n * First `visit(node) === true` short-circuits the whole walk. The\n * shared `WeakSet<object>` guards against cycles (lazy schemas whose\n * resolver returns the SAME instance on repeat calls). The lazy\n * resolver invocation is wrapped in try/catch because some\n * recursively-defined schemas throw before their inner is constructed\n * — treated as no-match for that branch and walk continues.\n *\n * Three top-level predicates (`containsAsyncRefine`,\n * `containsAsyncTransform`, `hasContainerOrRootRefine`) all express\n * \"walk the tree, short-circuit on first hit\" — the walker hosts that\n * shape once, the predicates contribute only the per-node test.\n */\nexport function walkSchemaTree(\n schema: z.ZodType,\n visit: (node: z.ZodType) => boolean,\n seen?: WeakSet<object>\n): boolean {\n const visited = seen ?? new WeakSet<object>()\n // Defensive guard: sub-adapters cast through `as` and a malformed leaf\n // could land here as a non-object. The TS signature claims object, but\n // runtime safety beats the conditional-narrowing lint complaint.\n const candidate = schema as unknown\n if (typeof candidate !== 'object' || candidate === null) return false\n if (visited.has(candidate)) return false\n visited.add(candidate)\n\n if (visit(schema)) return true\n\n const def = readDef(schema)\n if (def === undefined) return false\n\n if (def.innerType !== undefined && walkSchemaTree(def.innerType as z.ZodType, visit, visited)) {\n return true\n }\n if (def.element !== undefined && walkSchemaTree(def.element as z.ZodType, visit, visited)) {\n return true\n }\n if (def.in !== undefined && walkSchemaTree(def.in as z.ZodType, visit, visited)) return true\n if (def.out !== undefined && walkSchemaTree(def.out as z.ZodType, visit, visited)) return true\n if (def.left !== undefined && walkSchemaTree(def.left as z.ZodType, visit, visited)) return true\n if (def.right !== undefined && walkSchemaTree(def.right as z.ZodType, visit, visited)) return true\n if (def.keyType !== undefined && walkSchemaTree(def.keyType as z.ZodType, visit, visited)) {\n return true\n }\n if (def.valueType !== undefined && walkSchemaTree(def.valueType as z.ZodType, visit, visited)) {\n return true\n }\n if (def.shape !== undefined) {\n for (const sub of Object.values(def.shape)) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (def.entries !== undefined) {\n for (const sub of Object.values(def.entries)) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (def.options !== undefined) {\n for (const sub of def.options) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (def.items !== undefined) {\n for (const sub of def.items) {\n if (walkSchemaTree(sub as z.ZodType, visit, visited)) return true\n }\n }\n if (typeof def.getter === 'function') {\n try {\n const inner = def.getter() as z.ZodType\n if (walkSchemaTree(inner, visit, visited)) return true\n } catch {\n // Lazy schemas may throw on resolution before their referenced\n // schema is constructed; treat as no match and continue.\n }\n }\n\n return false\n}\n\n/**\n * True iff any refinement check on the schema (or any descendant\n * subschema) is async. Detection: walks the tree once via\n * `walkSchemaTree`, inspecting each `def.checks[].def.fn` for\n * `constructor.name === 'AsyncFunction'`. Direct `async (v) => …`\n * refinements are caught; sync functions that happen to return a\n * Promise (rare; we'd recommend marking them `async`) are NOT.\n *\n * Used by the adapter's `needsAsyncValidation()` to drive the\n * runtime's construction-time async-validation seed (see\n * create-form-store's strict-mode block). False negatives just delay\n * async refines until first mutation — matches the pre-detection\n * behavior. False positives are unlikely (the AsyncFunction check is\n * precise) and cost only one extra microtask of validation work.\n */\nexport function containsAsyncRefine(schema: z.ZodType, seen?: WeakSet<object>): boolean {\n return walkSchemaTree(\n schema,\n (node) => {\n for (const check of getChecks(node)) {\n if (isAsyncCheck(check)) return true\n }\n return false\n },\n seen\n )\n}\n\n/**\n * True iff the schema tree carries any refine / check / transform at\n * the root or at a non-leaf node. False means every check is at a leaf\n * — a per-keystroke subtree pass will catch the same verdicts as a\n * whole-form pass, and the runtime can scope leaf validation to the\n * edited path. True forces whole-form (correct, just slower).\n *\n * \"Non-leaf\" is detected by the presence of descendable children on\n * `def`: `shape` / `entries` / `element` / `options` / `items` /\n * `keyType` / `valueType` / `left` / `right`. The root is always\n * eligible — its checks ARE root refines. Transparent wrappers\n * (Optional / Nullable / Default / Catch / Readonly / Pipe / Lazy)\n * peel through to their inner without re-flagging — a `.refine` added\n * on top of a wrapper lands its check on the WRAPPER node itself, so\n * the wrapper's own `def.checks` is what's inspected.\n *\n * Bias conservative: a missed wrapper variant or an exotic `def`\n * shape we don't yet recognise returns false ONLY for that node,\n * but `walkSchemaTree`'s descent continues, so a container refine\n * nested inside still triggers `true`. Unknown wrappers we forget\n * to peel only lose the perf win, never correctness.\n */\nexport function hasContainerOrRootRefine(schema: z.ZodType, seen?: WeakSet<object>): boolean {\n return walkSchemaTree(\n schema,\n (node) => {\n const def = readDef(node)\n if (def === undefined) return false\n const isContainer =\n def.shape !== undefined ||\n def.entries !== undefined ||\n def.element !== undefined ||\n def.options !== undefined ||\n def.items !== undefined ||\n def.keyType !== undefined ||\n def.valueType !== undefined ||\n def.left !== undefined ||\n def.right !== undefined\n if (!isContainer) return false\n return getChecks(node).length > 0\n },\n seen\n )\n}\n\n/**\n * True iff any `ZodTransform` in the schema tree wraps an async\n * function. `z.preprocess(fn, inner)` desugars to a pipe whose\n * `def.in` is a `ZodTransform` with `def.transform = fn`; an async\n * `fn` makes the input side async-only, so a sync `safeParse` cannot\n * run it cleanly. The function gets invoked synchronously, returns\n * a Promise, and any throw / rejection inside it propagates as an\n * unhandled rejection because nothing's listening.\n *\n * Distinct from `containsAsyncRefine`: that one walks\n * `def.checks[].def.fn` (refinement predicates). This walks\n * `def.transform` (the transform's payload). The two flags are OR'd\n * by the adapter to drive `needsAsyncValidation()`, but the\n * construction-time strict-mode pass treats them differently:\n * async refines can be stripped and the parse retried; async\n * transforms cannot, so the strict pass skips entirely and defers\n * to the post-mount `safeParseAsync` pass.\n */\nexport function containsAsyncTransform(schema: z.ZodType, seen?: WeakSet<object>): boolean {\n return walkSchemaTree(\n schema,\n (node) => {\n const def = readDef(node)\n if (def === undefined) return false\n const fn = def.transform\n if (typeof fn !== 'function') return false\n return (fn as { constructor: { name: string } }).constructor.name === 'AsyncFunction'\n },\n seen\n )\n}\n\ninterface ZodCheckInternals {\n _def?: { fn?: unknown }\n def?: { fn?: unknown }\n _zod?: { def?: { fn?: unknown } }\n}\n\nexport function isAsyncCheck(check: unknown): boolean {\n if (typeof check !== 'object' || check === null) return false\n const c = check as ZodCheckInternals\n const fn = c._def?.fn ?? c.def?.fn ?? c._zod?.def?.fn\n if (typeof fn !== 'function') return false\n return fn.constructor.name === 'AsyncFunction'\n}\n","import type { z } from 'zod'\nimport { UnsupportedSchemaError } from './errors'\nimport {\n getArrayElement,\n getDiscriminatedOptions,\n getIntersectionLeft,\n getIntersectionRight,\n getLazyGetter,\n getObjectShape,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipe,\n type ZodKind,\n} from './introspect'\n\n/**\n * Kinds the adapter does not implement.\n *\n * - `z.promise(...)`, `z.custom(...)`, and `z.templateLiteral(...)` carry\n * no form-representable initial value: Promise-valued fields have no\n * meaningful starting state, custom predicates have no derivable\n * default, and template-literal schemas parse strings against a\n * pattern that has no obvious \"empty\" form.\n * - `z.map(...)`, `z.symbol()`, and `z.function(...)` are equally\n * unrepresentable: Maps have no obvious form encoding, symbols are\n * not JSON-serialisable so persistence and SSR round-trip would\n * silently drop them, and functions have no meaningful initial state.\n * Matches the v3 adapter's symmetric rejection list.\n *\n * The adapter rejects all six at construction so the failure surfaces\n * at `useForm(...)` rather than as a mystery `undefined` at render time.\n */\nconst UNSUPPORTED: readonly ZodKind[] = [\n 'promise',\n 'custom',\n 'template-literal',\n 'map',\n 'symbol',\n 'function',\n]\n\nfunction labelPath(path: readonly string[]): string {\n return path.length === 0 ? '<root>' : path.join('.')\n}\n\n/**\n * Walk the schema tree and fail fast on unsupported kinds.\n *\n * Recursive `z.lazy(...)` is detected (via getter identity on the\n * descent stack) and the descent stops at the second encounter — but\n * does NOT throw. Recursive schemas are supported: downstream walks\n * (default derivation, slim-primitive gate, path resolution) cap their\n * own descent via `maxRecursionDepth`. The assert step exists only to\n * surface kinds the adapter has no semantics for (`z.promise`, etc.);\n * recursive lazies are a fine shape.\n *\n * This runs once, at adapter construction time, so the cost is paid\n * at app startup rather than per keystroke.\n */\nexport function assertSupportedKinds(\n schema: z.ZodType,\n path: readonly string[] = [],\n lazyGetters: readonly (() => unknown)[] = []\n): void {\n const kind = kindOf(schema)\n\n if (UNSUPPORTED.includes(kind)) {\n throw new UnsupportedSchemaError(\n `[attaform/zod] unsupported kind '${kind}' at '${labelPath(path)}'`\n )\n }\n\n switch (kind) {\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n for (const [key, sub] of Object.entries(shape)) {\n assertSupportedKinds(sub, [...path, key], lazyGetters)\n }\n return\n }\n case 'array':\n assertSupportedKinds(getArrayElement(schema as z.ZodArray), [...path, '*'], lazyGetters)\n return\n case 'set':\n assertSupportedKinds(getSetValueType(schema), [...path, '*'], lazyGetters)\n return\n case 'record':\n assertSupportedKinds(getRecordValueType(schema), [...path, '*'], lazyGetters)\n return\n case 'tuple': {\n const items = getTupleItems(schema)\n items.forEach((item, i) => assertSupportedKinds(item, [...path, String(i)], lazyGetters))\n return\n }\n case 'union': {\n const options = getUnionOptions(schema)\n options.forEach((opt, i) => assertSupportedKinds(opt, [...path, `|${i}`], lazyGetters))\n return\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(schema)\n options.forEach((opt, i) => assertSupportedKinds(opt, [...path, `|${i}`], lazyGetters))\n return\n }\n case 'optional':\n case 'nullable':\n case 'default':\n case 'readonly':\n case 'catch': {\n const inner = unwrapInner(schema)\n if (inner !== undefined) assertSupportedKinds(inner, path, lazyGetters)\n return\n }\n case 'pipe': {\n const inner = unwrapPipe(schema)\n if (inner !== undefined) assertSupportedKinds(inner, path, lazyGetters)\n return\n }\n case 'lazy': {\n const getter = getLazyGetter(schema)\n // Stop descending on the second encounter of a getter — that's\n // a recursive `z.lazy()`. The construction-time walk only needs\n // to verify the *shape* (kinds) of the schema; downstream walks\n // handle recursion via `maxRecursionDepth`. Returning here leaves\n // recursive schemas free to mount.\n if (getter !== undefined && lazyGetters.includes(getter)) return\n const inner = unwrapLazy(schema)\n if (inner !== undefined) {\n assertSupportedKinds(\n inner,\n path,\n getter === undefined ? lazyGetters : [...lazyGetters, getter]\n )\n }\n return\n }\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n if (left !== undefined) assertSupportedKinds(left, [...path, 'left'], lazyGetters)\n if (right !== undefined) assertSupportedKinds(right, [...path, 'right'], lazyGetters)\n return\n }\n // Leaves: nothing to descend into.\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'nan':\n case 'any':\n case 'unknown':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return\n default: {\n const _exhaustive: never = kind\n throw new Error(`assertSupportedKinds: unhandled ZodKind '${_exhaustive as string}'`)\n }\n }\n}\n","import type { z } from 'zod'\nimport {\n getDiscriminatedOptions,\n getIntersectionLeft,\n getIntersectionRight,\n kindOf,\n unwrapInner,\n unwrapPipe,\n} from './introspect'\n\n/**\n * Peel optional/nullable/default/readonly/catch/pipe/intersection\n * wrappers off a schema, returning the innermost discriminated union —\n * or `undefined` if none is found. Used by the default-values walker\n * and the discriminator-aware reshape so that e.g.\n *\n * z.discriminatedUnion('status', [...]).optional().default({...})\n * z.discriminatedUnion('kind', [...]).catch({ kind: 'a', ... })\n * z.intersection(z.discriminatedUnion('kind', [...]), sharedSchema)\n *\n * still reach the DU. Catch is load-bearing here: the fallback exists\n * to fail open to a usable variant, so the runtime must still know\n * which variant the catch-default selects (otherwise it falls back to\n * a plain write and the variant-aware reshape never fires).\n * Intersections with a DU on EXACTLY ONE side resolve to that side;\n * intersections of two distinct DUs are ambiguous and return\n * `undefined` so the runtime falls back to plain writes.\n */\nexport function unwrapToDiscriminatedUnion(schema: z.ZodType): z.ZodType | undefined {\n let current: z.ZodType = schema\n // Bounded descent — any well-formed Zod schema tree terminates quickly.\n for (let i = 0; i < 64; i++) {\n const kind = kindOf(current)\n if (kind === 'discriminated-union') return current\n let next: z.ZodType | undefined\n if (\n kind === 'optional' ||\n kind === 'nullable' ||\n kind === 'default' ||\n kind === 'readonly' ||\n kind === 'catch'\n ) {\n next = unwrapInner(current)\n } else if (kind === 'pipe') {\n next = unwrapPipe(current)\n } else if (kind === 'intersection') {\n const left = getIntersectionLeft(current)\n const right = getIntersectionRight(current)\n const leftDU = left !== undefined ? unwrapToDiscriminatedUnion(left) : undefined\n const rightDU = right !== undefined ? unwrapToDiscriminatedUnion(right) : undefined\n if (leftDU !== undefined && rightDU !== undefined) {\n // Ambiguous: both sides resolve to DUs. The reshape can't pick\n // one without arbitrary preference; bail and let the runtime\n // fall through to a plain write.\n return undefined\n }\n return leftDU ?? rightDU\n }\n if (next === undefined) return undefined\n current = next\n }\n return undefined\n}\n\n/**\n * First option of a discriminated union — used as the default when no\n * discriminator value is known at default-values construction time.\n */\nexport function getDiscriminatedUnionFirstOption(schema: z.ZodType): z.ZodObject | undefined {\n const options = getDiscriminatedOptions(schema)\n return options[0]\n}\n","/**\n * Module-level `SchemaIntrospector<z.ZodType>` instance for the v4\n * adapter. The instance is stateless — every method receives a schema\n * and reads its `def.*` shape via the introspect-module accessors.\n *\n * Hosted in its own file so the per-walker modules (`path-walker.ts`,\n * `slim-primitives.ts`, `default-values.ts`) can import it without\n * routing through `adapter.ts` (which would create an import cycle:\n * `adapter.ts → path-walker.ts → adapter.ts`).\n */\nimport type { z } from 'zod'\nimport type { SchemaIntrospector, SharedZodKind } from '../../core/abstract-schema-factory'\nimport {\n containsAsyncRefine,\n containsAsyncTransform,\n getArrayElement,\n getCatchDefault,\n getDefaultValue,\n getDiscriminatedOptions,\n getDiscriminator,\n getEnumValues,\n getIntersectionLeft,\n getIntersectionRight,\n getLazyGetter,\n getLiteralValues,\n getNativeEnumValues,\n getObjectShape,\n getRecordKeyType,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n hasCatchValue,\n hasContainerOrRootRefine,\n isCoercePrimitive,\n isPreprocessNode,\n kindOf,\n unwrapBranded,\n unwrapEffectsSource,\n unwrapInner,\n unwrapLazy,\n unwrapPipeIn,\n unwrapPipeOut,\n} from './introspect'\n\nexport const V4_INTROSPECTOR: SchemaIntrospector<z.ZodType> = {\n kindOf: (schema) => kindOf(schema) as SharedZodKind | string,\n getObjectShape: (schema) => getObjectShape(schema as z.ZodObject),\n getTupleItems,\n getDiscriminatedOptions: (schema) => getDiscriminatedOptions(schema) as readonly z.ZodType[],\n getDiscriminator,\n getLiteralValues,\n isPreprocessNode,\n isCoercePrimitive,\n containsAsyncRefine,\n containsAsyncTransform,\n hasContainerOrRootRefine,\n\n // Walker accessors (D2 / D3 / D5).\n getArrayElement: (schema) => {\n if (kindOf(schema) !== 'array') return undefined\n return getArrayElement(schema as z.ZodArray)\n },\n getSetValueType: (schema) => (kindOf(schema) === 'set' ? getSetValueType(schema) : undefined),\n getRecordKeyType: (schema) =>\n kindOf(schema) === 'record' ? getRecordKeyType(schema) : undefined,\n getRecordValueType: (schema) =>\n kindOf(schema) === 'record' ? getRecordValueType(schema) : undefined,\n getUnionOptions,\n getIntersectionLeft,\n getIntersectionRight,\n getEnumValues,\n getNativeEnumValues,\n unwrapInner,\n unwrapBranded,\n unwrapEffectsSource,\n unwrapPipeIn,\n unwrapPipeOut,\n unwrapLazy,\n getLazyGetter,\n getDefaultValue,\n getCatchDefault,\n hasCatchValue,\n}\n","/**\n * Slim-primitive walker for the zod-v4 adapter. Returns the set of\n * `SlimPrimitiveKind`s a schema accepts at write time — wrappers are\n * peeled, refinement-level constraints (`.email()`, `.min(N)`, enum\n * membership, literal equality, regex) are ignored.\n *\n * Thin wrapper around the shared `slimPrimitivesWalk` core walker; v3\n * and v4 dispatch through the same body via their respective\n * `SchemaIntrospector` instance. See `core/walk-slim-primitives.ts`\n * for the per-kind dispatch rules.\n *\n * The runtime gate (`src/runtime/core/slim-primitive-gate.ts`) calls\n * the adapter method `getSlimPrimitiveTypesAtPath(path)`, which\n * resolves leaf candidates via `getNestedZodSchemasAtPath` and unions\n * `slimPrimitivesOf` across them.\n */\nimport type { z } from 'zod'\nimport type { SlimPrimitiveKind } from '../../types/types-api'\nimport { PERMISSIVE_SLIM_KINDS, slimPrimitivesWalk } from '../../core/walk-slim-primitives'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\nexport const PERMISSIVE: ReadonlySet<SlimPrimitiveKind> = PERMISSIVE_SLIM_KINDS\n\n/**\n * Walk a v4 schema, emitting the union of slim primitive kinds it\n * accepts. Clones once at the public boundary so callers get a\n * fresh mutable Set; the internal walk reuses frozen singletons for\n * leaf kinds.\n */\nexport function slimPrimitivesOf(\n schema: z.ZodType,\n maxRecursionDepth: number\n): Set<SlimPrimitiveKind> {\n return new Set(slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth))\n}\n","import type { z } from 'zod'\nimport { walkPathSegments } from '../../core/walk-path-segments'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\nconst PATH_SEPARATOR = '.'\n\n/**\n * Walk a dotted path through a Zod v4 schema tree and return the\n * subschema(s) that live at that path.\n *\n * Thin wrapper around the shared `walkPathSegments` core walker; both\n * v3 and v4 dispatch through the same body via their respective\n * `SchemaIntrospector` instance. See `core/walk-path-segments.ts` for\n * the per-kind dispatch rules.\n *\n * `maxRecursionDepth` caps descent through `z.lazy()`. Once the walker\n * has crossed `maxRecursionDepth + 1` lazy boundaries it returns `[]`,\n * so writes at recursive paths deeper than the cap fall back to a\n * permissive type gate.\n */\nexport function getNestedZodSchemasAtPath(\n schema: z.ZodType,\n path: string | readonly (string | number)[],\n maxRecursionDepth: number\n): z.ZodType[] {\n if (Array.isArray(path)) {\n return walkPathSegments(schema, path.map(String), V4_INTROSPECTOR, maxRecursionDepth, 0)\n }\n const pathString = path as string\n if (pathString.length === 0) return [schema]\n return walkPathSegments(\n schema,\n pathString.split(PATH_SEPARATOR),\n V4_INTROSPECTOR,\n maxRecursionDepth,\n 0\n )\n}\n","import { z } from 'zod'\nimport {\n getArrayElement,\n getCatchDefault,\n getChecks,\n getDefaultValue,\n getDiscriminatedOptions,\n getDiscriminator,\n getIntersectionLeft,\n getIntersectionRight,\n getObjectShape,\n getRecordKeyType,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n hasChecks,\n isAsyncCheck,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipeIn,\n unwrapPipeOut,\n} from './introspect'\n\ntype StripConfigInternal = Pick<StripConfig, 'stripRefinements'> & {\n /**\n * Optional per-check predicate. When provided, only checks for which\n * `shouldKeepCheck` returns `true` are re-applied to the rebuilt\n * schema. `stripAsyncChecks` uses this to filter async refines while\n * preserving every sync check verbatim. Absent → keep all checks\n * (existing behaviour for `getSlimSchema` callers).\n */\n shouldKeepCheck?: (check: unknown) => boolean\n}\n\n/**\n * Re-apply the container-level checks from `original` to `rebuilt`.\n * Container constructors (`z.object`, `z.array`, `z.tuple`, `z.record`,\n * `z.union`) don't accept checks in their factory signature, so\n * rebuilding a container drops `.min(1)` / `.max(3)` / `.strict()` /\n * etc. silently. Without this, a schema like\n * `z.array(z.string()).min(1)` in strict mode (where\n * `stripRefinements !== true`) would accept `[]` — the bug CR\n * reported.\n *\n * `.check(...)` accepts raw check instances, which is exactly what\n * the internal `def.checks` array holds. Skipping when\n * `stripRefinements === true` matches the leaf branches at the bottom\n * of `getSlimSchema`.\n */\nfunction carryChecks<Rebuilt extends z.ZodType>(\n rebuilt: Rebuilt,\n original: z.ZodType,\n stripConfig: StripConfigInternal\n): Rebuilt {\n if (stripConfig.stripRefinements === true) return rebuilt\n if (!hasChecks(original)) return rebuilt\n const all = getChecks(original)\n const checks =\n stripConfig.shouldKeepCheck === undefined ? all : all.filter(stripConfig.shouldKeepCheck)\n if (checks.length === 0) return rebuilt\n // `.check` on a concrete ZodType accepts instances of `$ZodCheck`\n // in Zod v4; the introspection helper returns exactly that shape,\n // so the cast is the boundary between adapter-internal typing and\n // Zod's public API.\n return (rebuilt as z.ZodType<unknown>).check(\n ...(checks as Parameters<z.ZodType<unknown>['check']>)\n ) as Rebuilt\n}\n\n/**\n * Compile-time exhaustiveness pin + runtime guard for the kind-switches\n * in this file. Passing the switch discriminant to a `never` parameter\n * means that if `ZodKind` grows a new variant, the offending `default`\n * call breaks first — pointing at the exact switch — instead of a\n * diffuse \"function lacks return statement\" elsewhere in the file.\n * Mirrors the pattern in assertSupportedKinds.\n */\nfunction unhandledZodKind(fnName: string, kind: never): never {\n throw new Error(`${fnName}: unhandled ZodKind '${kind as string}'`)\n}\n\n/**\n * stripRefinements: rebuild the schema tree with all refinement checks\n * (`z.string().min(3)`, `z.number().multipleOf(2)`, etc.) removed. The\n * validate-then-fix loop uses this so a default like `''` can satisfy a\n * `z.string().email()` during default-values construction in lax mode.\n *\n * The semantics match v3's `stripRefinements`: descend through container\n * types and rebuild leaves without their checks.\n */\nexport function stripRefinements(schema: z.ZodType): z.ZodType {\n const kind = kindOf(schema)\n switch (kind) {\n case 'string':\n return hasChecks(schema) ? z.string() : schema\n case 'number':\n return hasChecks(schema) ? z.number() : schema\n case 'bigint':\n return hasChecks(schema) ? z.bigint() : schema\n case 'array': {\n const element = getArrayElement(schema as z.ZodArray)\n return z.array(stripRefinements(element))\n }\n case 'set': {\n const valueType = getSetValueType(schema)\n return z.set(stripRefinements(valueType))\n }\n case 'tuple': {\n const items = getTupleItems(schema).map(stripRefinements)\n // z.tuple requires [T, ...T[]] but the runtime accepts an array.\n return z.tuple(items as unknown as [z.ZodType, ...z.ZodType[]]) as unknown as z.ZodType\n }\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n const next: Record<string, z.ZodType> = {}\n for (const [k, v] of Object.entries(shape)) {\n next[k] = stripRefinements(v)\n }\n return z.object(next)\n }\n case 'record': {\n const keyType = getRecordKeyType(\n schema\n ) as unknown as z.core.$ZodRecord['_zod']['def']['keyType']\n const valueType = stripRefinements(getRecordValueType(schema))\n return z.record(keyType as z.ZodType<string | number | symbol>, valueType)\n }\n case 'union': {\n const options = getUnionOptions(schema).map(stripRefinements)\n return z.union(options as unknown as readonly [z.ZodType, z.ZodType, ...z.ZodType[]])\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(schema).map(\n (opt) => stripRefinements(opt) as z.ZodObject\n )\n const discriminator = getDiscriminator(schema)\n if (discriminator === undefined) return schema\n return z.discriminatedUnion(\n discriminator,\n options as unknown as readonly [z.ZodObject, ...z.ZodObject[]]\n )\n }\n // Wrappers: strip the inner, preserve the wrapper semantics where\n // possible. For stripping refinements we typically want wrappers to\n // survive (optional/nullable/default), so leave them alone.\n case 'optional':\n case 'nullable':\n case 'default':\n case 'readonly':\n case 'pipe':\n // These wrappers are handled by getSlimSchema below per stripConfig.\n return schema\n case 'lazy': {\n const inner = unwrapLazy(schema)\n if (inner === undefined) return schema\n const slimmedInner = stripRefinements(inner)\n return z.lazy(() => slimmedInner)\n }\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n if (left === undefined || right === undefined) return schema\n return z.intersection(stripRefinements(left), stripRefinements(right))\n }\n case 'catch': {\n const inner = unwrapInner(schema)\n if (inner === undefined) return schema\n const slimmedInner = stripRefinements(inner)\n return (slimmedInner as z.ZodType).catch(getCatchDefault(schema) as never)\n }\n // Leaf types without refinements, or Zod features we don't rewrite.\n case 'boolean':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return schema\n default:\n return unhandledZodKind('stripRefinements', kind)\n }\n}\n\n/**\n * Walk the schema tree and rebuild each node with async refinement\n * checks removed. Sync `.refine` / `.superRefine` / built-in checks\n * (`min`, `max`, `email`, etc.) are preserved; wrappers (`.optional()`,\n * `.nullable()`, `.default(v)`, `.readonly()`, `.catch(v)`) are\n * preserved structurally and recursed into.\n *\n * Used by the construction-time `getDefaultValues` fallback in the\n * adapter: when `rootSchema.safeParse(data)` throws because the\n * schema contains an async refine, retrying against\n * `stripAsyncChecks(rootSchema)` surfaces every sync-refinement\n * violation that the original parse would have collected if the\n * async sibling weren't poisoning the sync entry point.\n *\n * Conceptually distinct from `stripRefinements` (drop-all, leaf\n * operation) and `getSlimSchema` (configurable peeling for default\n * derivation): this is a tree-walk that filters by sync/async at\n * every check site.\n *\n * Adapter-divergence note (Phase 12 part 2 / ADAPT-D4 deferred):\n * this stays per-adapter rather than dedup-ing into a shared core\n * walker. The structural skeleton (recurse + rebuild containers +\n * wrappers + carry container-level constraints) is parallel to v3's\n * `zod-v3/strip-async.ts:stripAsyncChecks`, but the per-check filter\n * is irreducibly asymmetric:\n *\n * - v4 filters by `isAsyncCheck(check)` at every check site — v4\n * knows the user fn directly (`check.def.fn.constructor.name`).\n * Sync refines survive the rebuild.\n * - v3 cannot statically distinguish sync from async `.refine(fn)`\n * because v3 wraps the user fn inside a sync closure that hides\n * `constructor.name`. v3 therefore drops EVERY `ZodEffects` it\n * encounters, losing sync refine seeding in mixed forms.\n *\n * A unified walker would need to either parameterise the rebuild\n * with `shouldKeepCheck` AND `shouldDropWrapperWholesale` AND\n * `rebuildLeaf` AND `rebuildContainer` services — which yields a\n * walker bigger than the two it replaces — or special-case the v3\n * effects-dropping at the call site, defeating the dedup. The\n * docblocks on both files cross-reference so future readers see\n * the deliberate asymmetry.\n */\nexport function stripAsyncChecks(schema: z.ZodType): z.ZodType {\n const config: StripConfigInternal = {\n stripRefinements: false,\n shouldKeepCheck: (c) => !isAsyncCheck(c),\n }\n // Cycle-detection set scoped to one strip pass. Mirrors the\n // pattern in `containsAsyncRefine` (introspect.ts) — pathological\n // `z.lazy(() => self)` schemas would otherwise infinite-recurse.\n const seen = new WeakSet<object>()\n\n function recurse(s: z.ZodType): z.ZodType {\n // ZodType instances are always objects — the WeakSet add/check\n // is unconditional once we're inside this function.\n if (seen.has(s)) return s\n seen.add(s)\n\n const kind = kindOf(s)\n switch (kind) {\n case 'string':\n return hasChecks(s) ? carryChecks(z.string(), s, config) : s\n case 'number':\n return hasChecks(s) ? carryChecks(z.number(), s, config) : s\n case 'bigint':\n return hasChecks(s) ? carryChecks(z.bigint(), s, config) : s\n\n case 'array': {\n const element = getArrayElement(s as z.ZodArray)\n return carryChecks(z.array(recurse(element)), s, config)\n }\n case 'set': {\n const valueType = getSetValueType(s)\n return carryChecks(z.set(recurse(valueType)), s, config)\n }\n case 'tuple': {\n const items = getTupleItems(s).map(recurse)\n const rebuilt = z.tuple(\n items as unknown as [z.ZodType, ...z.ZodType[]]\n ) as unknown as z.ZodType\n return carryChecks(rebuilt, s, config)\n }\n case 'object': {\n const shape = getObjectShape(s as z.ZodObject)\n const next: Record<string, z.ZodType> = {}\n for (const [k, v] of Object.entries(shape)) {\n next[k] = recurse(v as z.ZodType)\n }\n return carryChecks(z.object(next), s, config)\n }\n case 'record': {\n const keyType = getRecordKeyType(s)\n const valueType = recurse(getRecordValueType(s))\n const rebuilt = z.record(keyType as z.ZodType<string | number | symbol>, valueType)\n return carryChecks(rebuilt, s, config)\n }\n case 'union': {\n const options = getUnionOptions(s).map(recurse)\n const rebuilt = z.union(\n options as unknown as readonly [z.ZodType, z.ZodType, ...z.ZodType[]]\n )\n return carryChecks(rebuilt, s, config)\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(s).map((opt) => recurse(opt) as z.ZodObject)\n const discriminator = getDiscriminator(s)\n if (discriminator === undefined) return s\n return z.discriminatedUnion(\n discriminator,\n options as unknown as readonly [z.ZodObject, ...z.ZodObject[]]\n )\n }\n\n case 'optional': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).optional()\n }\n case 'nullable': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).nullable()\n }\n case 'default': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).default(getDefaultValue(s) as never)\n }\n case 'readonly': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).readonly()\n }\n\n case 'pipe':\n // Pipes carry transforms whose output shape would change if\n // we rebuilt them blindly; recursing through both halves of a\n // pipe also requires both halves to be addressable, which\n // `unwrapPipe` doesn't expose. If an async refine lives\n // inside a pipe, its throw surfaces from the inner\n // defensive catch in `getDefaultValues` — same observable\n // behaviour as today's pre-fix catch path. Common-case sync\n // siblings on flat object schemas are unaffected.\n return s\n\n case 'lazy': {\n const inner = unwrapLazy(s)\n if (inner === undefined) return s\n const stripped = recurse(inner)\n return z.lazy(() => stripped)\n }\n case 'intersection': {\n const left = getIntersectionLeft(s)\n const right = getIntersectionRight(s)\n if (left === undefined || right === undefined) return s\n return z.intersection(recurse(left), recurse(right))\n }\n case 'catch': {\n const inner = unwrapInner(s)\n if (inner === undefined) return s\n return (recurse(inner) as z.ZodType).catch(getCatchDefault(s) as never)\n }\n\n // Leaves with no checks — pass through unchanged.\n case 'boolean':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return s\n default:\n return unhandledZodKind('stripAsyncChecks', kind)\n }\n }\n\n return recurse(schema)\n}\n\nexport type StripConfig = {\n /** Strip `.default(v)` wrappers so the walker produces the leaf's empty value. */\n stripDefaultValues?: boolean\n /** Strip `.optional()` so `undefined` values are rejected. */\n stripOptional?: boolean\n /** Strip `.nullable()` so `null` values are rejected. */\n stripNullable?: boolean\n /** Strip refinement checks (email, min, etc.). Same semantic as v3's stripZodRefinements. */\n stripRefinements?: boolean\n /** Strip pipe transforms (refine/transform). Same semantic as v3's stripZodEffects. */\n stripPipe?: boolean\n}\n\n/**\n * getSlimSchema: walk the schema tree and apply `stripConfig` transparently.\n * Wrappers get peeled when their corresponding flag is set; refinements get\n * rebuilt when `stripRefinements` is set. Every branch recurses so deeply\n * nested wrappers inside objects/arrays/unions all get the same treatment.\n *\n * `maxRecursionDepth` caps descent through `z.lazy()`. At the cap, the\n * walker returns the original lazy unchanged — keeping the schema valid\n * for the consumer's actual data while bounding the slim-rebuild work.\n */\nexport function getSlimSchema(\n schema: z.ZodType,\n stripConfig: StripConfig,\n maxRecursionDepth: number\n): z.ZodType {\n return walkSlim(schema, stripConfig, maxRecursionDepth, 0)\n}\n\nfunction walkSlim(\n schema: z.ZodType,\n stripConfig: StripConfig,\n maxDepth: number,\n lazyDepth: number\n): z.ZodType {\n const kind = kindOf(schema)\n switch (kind) {\n case 'optional': {\n const inner = unwrapInner(schema) ?? schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n return stripConfig.stripOptional === true ? slimmedInner : slimmedInner.optional()\n }\n case 'nullable': {\n const inner = unwrapInner(schema) ?? schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n return stripConfig.stripNullable === true ? slimmedInner : slimmedInner.nullable()\n }\n case 'default': {\n const inner = unwrapInner(schema) ?? schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n if (stripConfig.stripDefaultValues === true) return slimmedInner\n // Re-apply the default to the slimmed inner. Returning `schema`\n // unchanged would skip nested stripping (refinements / pipe inside\n // a `.default()` wrapper would survive, breaking parity with the\n // optional / nullable cases above). The default value lives on\n // the wrapper at `_zod.def.defaultValue`; introspect.getDefaultValue\n // reads it through the v4 getter and resolves to the materialised\n // value (lazy `.default(() => x)` getters fire here — we rewrap\n // as a fixed value, which is correct for the slim schema's\n // single-shot use during default-values derivation).\n const defaultValue = getDefaultValue(schema)\n return (slimmedInner as z.ZodType).default(defaultValue as never)\n }\n case 'readonly': {\n // `.readonly()` wraps the output in `Object.freeze` — dropping the\n // wrapper after slimming would hand callers a mutable default,\n // which breaks invariants inside refinements that rely on the\n // frozen shape. Re-wrap the slimmed inner so the observable parse\n // behaviour matches the unstripped schema.\n const inner = unwrapInner(schema)\n return inner === undefined\n ? schema\n : (walkSlim(inner, stripConfig, maxDepth, lazyDepth) as z.ZodType).readonly()\n }\n case 'pipe': {\n // `.pipe(...)` chains schemas sequentially — the output of one\n // feeds the input of the next — and typically carries a\n // `.transform(...)` that mutates the runtime shape. Slimming the\n // inner and dropping the pipe wrapper would lose that\n // transformation, so by default we return the original schema\n // unchanged. Consumers who explicitly opt in via `stripPipe`\n // (e.g. default-values derivation, where a transform doesn't make\n // sense) get the \"real\" leg of the pipe — the side that ISN'T\n // a ZodTransform. For `z.preprocess(fn, inner)` that's `def.out`\n // (the inner schema); for `someSchema.transform(fn)` that's\n // `def.in` (the source schema). Falling through to the transform\n // side would re-run the user's fn during default-values\n // derivation — for preprocess that means a throwing fn crashes\n // mount even though there's nothing to normalize at init time.\n if (stripConfig.stripPipe === true) {\n const pipeIn = unwrapPipeIn(schema)\n const pipeOut = unwrapPipeOut(schema)\n const real =\n pipeIn !== undefined && kindOf(pipeIn) !== 'transform'\n ? pipeIn\n : pipeOut !== undefined && kindOf(pipeOut) !== 'transform'\n ? pipeOut\n : (pipeIn ?? pipeOut ?? schema)\n return walkSlim(real, stripConfig, maxDepth, lazyDepth)\n }\n return schema\n }\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n const next: Record<string, z.ZodType> = {}\n for (const [k, v] of Object.entries(shape)) {\n next[k] = walkSlim(v, stripConfig, maxDepth, lazyDepth)\n }\n return carryChecks(z.object(next), schema, stripConfig)\n }\n case 'array': {\n const element = getArrayElement(schema as z.ZodArray)\n return carryChecks(\n z.array(walkSlim(element, stripConfig, maxDepth, lazyDepth)),\n schema,\n stripConfig\n )\n }\n case 'set': {\n const valueType = getSetValueType(schema)\n return carryChecks(\n z.set(walkSlim(valueType, stripConfig, maxDepth, lazyDepth)),\n schema,\n stripConfig\n )\n }\n case 'tuple': {\n const items = getTupleItems(schema).map((it) =>\n walkSlim(it, stripConfig, maxDepth, lazyDepth)\n )\n const rebuilt = z.tuple(\n items as unknown as [z.ZodType, ...z.ZodType[]]\n ) as unknown as z.ZodType\n return carryChecks(rebuilt, schema, stripConfig)\n }\n case 'record': {\n const keyType = getRecordKeyType(schema)\n const valueType = walkSlim(getRecordValueType(schema), stripConfig, maxDepth, lazyDepth)\n const rebuilt = z.record(keyType as z.ZodType<string | number | symbol>, valueType)\n return carryChecks(rebuilt, schema, stripConfig)\n }\n case 'union': {\n const options = getUnionOptions(schema).map((opt) =>\n walkSlim(opt, stripConfig, maxDepth, lazyDepth)\n )\n const rebuilt = z.union(options as unknown as readonly [z.ZodType, z.ZodType, ...z.ZodType[]])\n return carryChecks(rebuilt, schema, stripConfig)\n }\n case 'discriminated-union': {\n const options = getDiscriminatedOptions(schema).map(\n (opt) => walkSlim(opt, stripConfig, maxDepth, lazyDepth) as z.ZodObject\n )\n const discriminator = getDiscriminator(schema)\n if (discriminator === undefined) return schema\n return z.discriminatedUnion(\n discriminator,\n options as unknown as readonly [z.ZodObject, ...z.ZodObject[]]\n )\n }\n // Leaves: strip refinements if requested, otherwise pass through.\n case 'string':\n case 'number':\n case 'bigint':\n return stripConfig.stripRefinements === true && hasChecks(schema)\n ? stripRefinements(schema)\n : schema\n case 'boolean':\n case 'date':\n case 'enum':\n case 'literal':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'map':\n case 'symbol':\n case 'function':\n return schema\n case 'lazy': {\n // Past the cap, leave the original lazy in place. The slim schema\n // is for default-derivation and structural shape checks; keeping\n // the raw lazy at the recursion frontier is safe — parsing reaches\n // the same downstream getter either way.\n if (lazyDepth >= maxDepth) return schema\n const inner = unwrapLazy(schema)\n if (inner === undefined) return schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth + 1)\n return z.lazy(() => slimmedInner)\n }\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n if (left === undefined || right === undefined) return schema\n return z.intersection(\n walkSlim(left, stripConfig, maxDepth, lazyDepth),\n walkSlim(right, stripConfig, maxDepth, lazyDepth)\n )\n }\n case 'catch': {\n const inner = unwrapInner(schema)\n if (inner === undefined) return schema\n const slimmedInner = walkSlim(inner, stripConfig, maxDepth, lazyDepth)\n // Preserve the catch wrapper so downstream safeParse still uses\n // the declared fallback — stripping it would discard user intent.\n return (slimmedInner as z.ZodType).catch(getCatchDefault(schema) as never)\n }\n case 'transform':\n case 'file':\n // ZodTransform is the input side of `z.preprocess(fn, inner)` and\n // never appears as a top-level schema reachable from the slim path\n // (the surrounding pipe descends into `.out` for the inner shape).\n // `file` has no refinements to strip beyond what the leaf schema\n // already represents. Pass through unchanged.\n return schema\n default:\n return unhandledZodKind('getSlimSchema', kind)\n }\n}\n","import type { z } from 'zod'\nimport { getAtPath, setAtPath } from '../../core/path-walker'\nimport { slimKindOf } from '../../core/slim-primitive-gate'\nimport { mergeDeep } from '../../core/merge-deep'\nimport { deriveDefaultWalk } from '../../core/walk-derive-default'\nimport { getDiscriminatedUnionFirstOption, unwrapToDiscriminatedUnion } from './discriminator'\nimport { slimPrimitivesOf } from './slim-primitives'\nimport {\n getDiscriminatedOptions,\n getUnionOptions,\n isCoercePrimitive,\n kindOf,\n unwrapPipeIn,\n} from './introspect'\nimport { getNestedZodSchemasAtPath } from './path-walker'\nimport { getSlimSchema } from './strip'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\n/**\n * Derive a default value for any Zod v4 schema.\n *\n * Thin wrapper around the shared `deriveDefaultWalk` core walker —\n * v3 and v4 dispatch through the same body via their respective\n * `SchemaIntrospector` instance. See `core/walk-derive-default.ts`\n * for the per-kind dispatch rules, including the\n * `peelEmbeddedDefault` chain-walk that closes the v3↔v4 parity gap\n * on `Optional(Default('x'))` / `Nullable(Default('x'))` / etc.\n *\n * When `useDefault` is false, `.default(x)` wrappers are skipped so\n * the walker produces the underlying leaf's empty value instead —\n * useful when the caller wants a \"blank\" initial state rather than\n * the schema's declared defaults.\n *\n * `maxRecursionDepth` caps descent through `z.lazy()`: the counter\n * bumps only when the walker crosses a lazy boundary.\n */\nexport function deriveDefault(\n schema: z.ZodType,\n useDefault: boolean,\n maxRecursionDepth: number\n): unknown {\n return deriveDefaultWalk(schema, useDefault, V4_INTROSPECTOR, maxRecursionDepth, {\n // v4 has an exhaustive switch against `SchemaIntrospector.kindOf`;\n // unknown kinds genuinely shouldn't appear, so return undefined.\n unsupportedKindFallback: () => undefined,\n // v4 historically recurses into the inner on `useDefault=false`\n // so a `.catch(v)` slot returns the leaf empty rather than the\n // fallback. Pinned by `test/adapters/zod-v4/unsupported-kinds.test.ts`\n // (`z.catch falls through to inner leaf default when useDefault=false`).\n catchOnUseDefaultFalse: 'recurseInner',\n })\n}\n\n// `defaultForKind` body lifted to `core/walk-derive-default.ts`; this\n// module now just adapts the result to the v4-specific\n// `getDefaultValuesFromZodSchema` validate-then-fix loop.\n\n// `mergeDeep` lifted to `core/merge-deep.ts` so v3 and v4 share one\n// body. Re-exported below as `mergeDeep` for backwards-compatible\n// internal callers (the v4 strict-mode flow still consults it).\n\nexport type GetDefaultValuesOptions = {\n schema: z.ZodObject\n useDefaultSchemaValues: boolean\n constraints: unknown\n maxRecursionDepth: number\n}\n\nexport type DefaultValuesResult<Form> = {\n data: Form\n success: boolean\n slimSchema: z.ZodType\n}\n\n/**\n * getDefaultValuesFromZodSchema — produces a form's starting value.\n *\n * The algorithm mirrors v3's: walk the schema to derive blank defaults,\n * merge constraints, then run the schema's `safeParse`. On failure, walk\n * the resulting issues and fill in issue-specific defaults at each\n * complaining path — e.g. `invalid_type` with `issue.expected === 'string'`\n * fills in `''`, `invalid_value` picks the first allowed value, etc. Re-\n * parse and return.\n *\n * Refinements are always stripped from the slim schema — this helper's\n * concern is producing usable starting data, not surfacing refinement\n * errors. Refinement enforcement (in strict mode) lives upstream in\n * `adapter.ts`'s `rootSchema.safeParse(data)` pass, which uses the full\n * schema. Stripping here is also what keeps `safeParse` from throwing\n * synchronously when the schema contains an async refine.\n */\nexport function getDefaultValuesFromZodSchema<Form>(\n opts: GetDefaultValuesOptions\n): DefaultValuesResult<Form> {\n const { schema, useDefaultSchemaValues, constraints, maxRecursionDepth } = opts\n const initial = deriveDefault(schema, useDefaultSchemaValues, maxRecursionDepth)\n const merged = mergeDeep(initial, constraints) as unknown\n\n // Strip wrappers, including refinements. The slim schema is for\n // *default-value derivation* — its job is to produce usable starting\n // data, not to surface refinement errors. Refinement errors are the\n // domain of the strict-mode pass downstream (`adapter.ts`'s\n // `rootSchema.safeParse(data)`), which uses the full schema.\n //\n // Crucially, this also avoids `safeParse` throwing synchronously when\n // the schema contains an async refine (zod's \"Encountered Promise\n // during synchronous parse\" error) — which would otherwise crash\n // construction for any strict-mode form with `z.string().refine(async …)`.\n const slimSchema = getSlimSchema(\n schema,\n {\n stripDefaultValues: true,\n stripPipe: true,\n stripRefinements: true,\n },\n maxRecursionDepth\n )\n\n const firstParse = slimSchema.safeParse(merged)\n if (firstParse.success) {\n return { data: firstParse.data as Form, success: true, slimSchema }\n }\n\n // Validate-then-fix: walk issues and fill defaults per path. Under\n // the slim-primitive write contract, we only fix issues that violate\n // STRUCTURAL or PRIMITIVE-TYPE shape. Refinement-level issues (enum\n // membership, literal equality, .email/.min(N)/regex, custom\n // refines, unrecognized_keys) pass THROUGH unchanged — the user's\n // defaultValues are preserved verbatim and the strict-mode\n // validation pass downstream surfaces the error at construction.\n //\n // The discriminant: look up the actual offending value at the\n // issue's path and check its slim primitive kind against the\n // candidate schema's slim primitive set. If the value's kind IS in\n // the set, the issue is refinement-level → skip. If it's NOT in\n // the set, the issue is primitive/structural → fix. This unifies\n // every issue code under one check rather than enumerating refinement\n // codes (which differ between Zod versions and grow over time).\n let fixedData = merged as Record<string, unknown>\n for (const issue of firstParse.error.issues) {\n const pathSegments = issue.path.map((seg) => (typeof seg === 'number' ? seg : String(seg))) as (\n | string\n | number\n )[]\n // Schema-side input normalizers (preprocess pipes, coerce-flagged\n // primitives) are slim-stripped, so the slim-schema sees only the\n // post-strip leaf and complains when storage is `undefined`. Look\n // up the ORIGINAL schema at the path; if it's such a wrapper, the\n // `undefined` is intentional under the no-write-mutation contract\n // and we leave it alone.\n const originalCandidate = getNestedZodSchemasAtPath(schema, pathSegments, maxRecursionDepth)[0]\n if (originalCandidate !== undefined) {\n if (isCoercePrimitive(originalCandidate)) continue\n if (kindOf(originalCandidate) === 'pipe') {\n const pipeIn = unwrapPipeIn(originalCandidate)\n if (pipeIn !== undefined && kindOf(pipeIn) === 'transform') continue\n }\n }\n\n // Pass the structured path directly — joining with '.' would merge\n // a literal-dot key (`['profile.name']`) into two segments and\n // target the wrong sub-schema during fix-up.\n const candidates = getNestedZodSchemasAtPath(slimSchema, pathSegments, maxRecursionDepth)\n if (candidates.length === 0) continue\n const candidate = candidates[0]\n if (candidate === undefined) continue\n\n // Refinement-vs-primitive classification.\n const valueAtPath = getAtPath(merged, pathSegments)\n const slimKinds = slimPrimitivesOf(candidate, maxRecursionDepth)\n if (slimKinds.size > 0 && slimKinds.has(slimKindOf(valueAtPath))) {\n // Refinement-level: pass through unchanged.\n continue\n }\n\n // Some issues don't carry a type path: fall back to deriving a default\n // for the schema at that location.\n const fixValue = defaultFromIssue(issue, candidate, useDefaultSchemaValues, maxRecursionDepth)\n if (fixValue === SKIP) continue\n fixedData = (\n pathSegments.length === 0 ? fixValue : setAtPath(fixedData, pathSegments, fixValue)\n ) as Record<string, unknown>\n }\n\n const secondParse = slimSchema.safeParse(fixedData)\n if (secondParse.success) {\n return { data: secondParse.data as Form, success: true, slimSchema }\n }\n\n // Last-resort: hand back what we constructed even if it still doesn't\n // parse. Better a partially-valid form than an exception at mount time.\n return { data: fixedData as unknown as Form, success: false, slimSchema }\n}\n\nconst SKIP = Symbol('atta:skip-fix')\n\n/**\n * Map a Zod v4 issue to a concrete replacement value for the path the\n * issue points at. Falls back to the candidate subschema's walker default\n * when the issue code doesn't carry enough info.\n */\nfunction defaultFromIssue(\n issue: z.core.$ZodIssue,\n candidate: z.ZodType,\n useDefaultSchemaValues: boolean,\n maxRecursionDepth: number\n): unknown {\n if (issue.code === 'invalid_type') {\n // If the candidate is (or wraps) a discriminated union, prefer the\n // first-option default over `undefined` — matches v3's behaviour.\n const du = unwrapToDiscriminatedUnion(candidate)\n if (du !== undefined) {\n const first = getDiscriminatedUnionFirstOption(du)\n if (first !== undefined)\n return deriveDefault(first, useDefaultSchemaValues, maxRecursionDepth)\n }\n return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth)\n }\n if (issue.code === 'invalid_value') {\n const values = (issue as unknown as { values?: readonly unknown[] }).values\n if (values !== undefined && values.length > 0) return values[0]\n return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth)\n }\n // Other issue codes (too_small/too_big/invalid_format) only fire in strict\n // mode since lax mode strips refinements. Fall back to the walker default.\n return deriveDefault(candidate, useDefaultSchemaValues, maxRecursionDepth)\n}\n\n/**\n * Exported for callers who want the discriminated-union option set for\n * path resolution (used by the adapter's getSchemasAtPath).\n */\nexport { getDiscriminatedOptions, getUnionOptions }\n","import type { z } from 'zod'\nimport type {\n AbstractSchema,\n DefaultValuesResponse,\n FormKey,\n GetDefaultValuesConfig,\n ResolvedFieldMeta,\n SchemaFactoryOptions,\n} from '../../types/types-api'\nimport {\n createAbstractSchema,\n type AbstractSchemaServices,\n} from '../../core/abstract-schema-factory'\nimport { getFieldMeta, getFieldMetaList } from './field-meta'\nimport { humanize } from '../../core/humanize'\nimport { canonicalizePath, type Path } from '../../core/paths'\nimport type { DeepPartial, GenericForm } from '../../types/types-core'\nimport { assertSupportedKinds } from './assert-supported'\nimport { unwrapToDiscriminatedUnion } from './discriminator'\nimport { zodIssuesToValidationErrors } from './errors'\nimport { deriveDefault, getDefaultValuesFromZodSchema } from './default-values'\nimport {\n assertZodVersion,\n containsAsyncRefine,\n containsAsyncTransform,\n getDiscriminatedOptions,\n getIntersectionLeft,\n getIntersectionRight,\n getUnionOptions,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipe,\n} from './introspect'\nimport { getNestedZodSchemasAtPath } from './path-walker'\nimport { slimPrimitivesOf } from './slim-primitives'\nimport { stripAsyncChecks } from './strip'\nimport { getFieldMetaPathMap } from '../../core/walk-field-meta'\nimport { V4_INTROSPECTOR } from './walker-introspector'\n\n/**\n * Zod v4 adapter — implements `AbstractSchema` against Zod v4's public\n * surface. Internal (`def.*`) access is quarantined to introspect.ts and\n * the co-located modules (default-values, strip, path-walker, discriminator,\n * errors). This file is the wiring layer between those modules and the\n * framework's AbstractSchema contract.\n *\n * Feature parity with the v3 adapter:\n * - getDefaultValues: validate-then-fix loop (delegated to default-values.ts)\n * with refinement stripping in lax mode; discriminated-union-aware\n * first-option fallback for invalid_type issues.\n * - getSchemasAtPath: discriminated-union-aware path walker.\n * - validateAtPath: per-union-branch parse with aggregated errors.\n */\n\n/**\n * Peel `.optional()` / `.nullable()` wrappers off a leaf schema ONLY\n * when the inner type is structurally fillable (object, array, tuple,\n * record, discriminated/plain union, intersection — or itself a\n * peelable wrapper that resolves to one of those). Peeling exposes\n * the inner shape's default so consumer-supplied partial writes\n * through optional sub-schemas (`{ profile: z.object({...}).optional() }`,\n * `setValue('profile', { name: 'X' })`) get the inner shape's\n * structural defaults filled in.\n *\n * For PRIMITIVE inner (ZodString, ZodNumber, ZodBoolean, ZodLiteral,\n * etc.), the wrapper IS the meaningful schema — `optional` means\n * \"missing is allowed\", `nullable` means \"null is allowed\". Peeling\n * an optional string to its inner string would default the leaf to\n * `''` and cause mergeStructural to write `notes: ''` instead of\n * `notes: undefined` when filling sibling keys at the parent object\n * — the runtime would silently overwrite the optional's \"absent\"\n * intent with a non-empty marker.\n *\n * `.default(x)` is left intact at every level so deriveDefault\n * returns the explicit default value. Bounded iteration cap as a\n * runaway guard for pathological wrappers.\n */\nfunction unwrapStructuralWrappers(schema: z.ZodType): z.ZodType {\n let current: z.ZodType = schema\n for (let i = 0; i < 64; i++) {\n const outerKind = kindOf(current)\n if (outerKind !== 'optional' && outerKind !== 'nullable') break\n const inner = unwrapInner(current)\n if (inner === undefined) return current\n if (!isStructuralKind(kindOf(inner))) break\n current = inner\n }\n return current\n}\n\n/**\n * Peel every transparent wrapper (optional / nullable / default /\n * readonly / catch / pipe / lazy) off `schema`. Stops on the first\n * non-wrapper kind. Used by `arrayShapeAtPath` for shape\n * introspection where we want the inner kind regardless of what the\n * default-value semantic is — different from\n * `unwrapStructuralWrappers`, which preserves `.default()` so the\n * runtime fill returns the explicit default.\n *\n * Bounded iteration cap as a runaway guard for pathological wrappers.\n */\nfunction peelAllWrappers(schema: z.ZodType): z.ZodType {\n let current: z.ZodType = schema\n for (let i = 0; i < 64; i++) {\n const k = kindOf(current)\n let inner: z.ZodType | undefined\n if (\n k === 'optional' ||\n k === 'nullable' ||\n k === 'default' ||\n k === 'readonly' ||\n k === 'catch'\n ) {\n inner = unwrapInner(current)\n } else if (k === 'pipe') {\n inner = unwrapPipe(current)\n } else if (k === 'lazy') {\n inner = unwrapLazy(current)\n } else {\n return current\n }\n if (inner === undefined) return current\n current = inner\n }\n return current\n}\n\n/**\n * Kinds for which mergeStructural can recurse to fill missing keys\n * or pad missing positions. Primitive leaves (string / number / etc.)\n * and opaque non-recursable wrappers fall outside this set, so\n * peeling Optional / Nullable around them would lose information\n * (the wrapper's \"absent / null\" semantic) without enabling any fill.\n *\n * Wrappers themselves count as structural — `unwrapStructuralWrappers`\n * recurses to re-check their inner kind.\n */\nconst STRUCTURAL_KINDS: ReadonlySet<ReturnType<typeof kindOf>> = new Set([\n 'object',\n 'array',\n 'tuple',\n 'record',\n 'discriminated-union',\n 'union',\n 'intersection',\n 'optional',\n 'nullable',\n 'default',\n 'readonly',\n 'catch',\n 'pipe',\n 'lazy',\n])\n\nfunction isStructuralKind(kind: ReturnType<typeof kindOf>): boolean {\n return STRUCTURAL_KINDS.has(kind)\n}\n\nconst MAX_REQUIRED_DEPTH = 64\n\n/**\n * `true` if the leaf is required — `false` if any wrapper layer admits\n * \"empty\" via `.optional()`, `.nullable()`, `.default(N)`, or\n * `.catch(N)`. See `AbstractSchema.isRequiredAtPath` for the full\n * semantic specification (union → permissive, intersection → strict,\n * readonly/pipe/lazy → transparent peel).\n */\nfunction isLeafRequired(schema: z.ZodType, depth = 0): boolean {\n if (depth > MAX_REQUIRED_DEPTH) return true\n const kind = kindOf(schema)\n // Direct \"schema accepts empty\" wrappers and bare empty-marker leaves —\n // short-circuit. `z.undefined()` / `z.null()` / `z.void()` inside a\n // union (`z.union([z.number(), z.undefined()])`) are how schema authors\n // express \"this field can be absent\" without a wrapper, so they count\n // as not-required here.\n if (\n kind === 'optional' ||\n kind === 'nullable' ||\n kind === 'default' ||\n kind === 'catch' ||\n kind === 'undefined' ||\n kind === 'null' ||\n kind === 'void'\n ) {\n return false\n }\n // Transparent wrappers — peel and re-check.\n if (kind === 'readonly') {\n const inner = unwrapInner(schema)\n return inner === undefined ? true : isLeafRequired(inner, depth + 1)\n }\n if (kind === 'pipe') {\n // Use the input side: blank is a write-time concern.\n const inner = unwrapPipe(schema)\n return inner === undefined ? true : isLeafRequired(inner, depth + 1)\n }\n if (kind === 'lazy') {\n const inner = unwrapLazy(schema)\n return inner === undefined ? true : isLeafRequired(inner, depth + 1)\n }\n // Union — required only if EVERY branch is required (any permissive\n // branch makes the union permissive at parse time).\n if (kind === 'union' || kind === 'discriminated-union') {\n const options =\n kind === 'discriminated-union' ? getDiscriminatedOptions(schema) : getUnionOptions(schema)\n if (options.length === 0) return true\n return options.every((opt) => isLeafRequired(opt as z.ZodType, depth + 1))\n }\n // Intersection — required if EITHER side is required (a parse must\n // satisfy both; the strict side governs).\n if (kind === 'intersection') {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n const leftReq = left === undefined ? true : isLeafRequired(left, depth + 1)\n const rightReq = right === undefined ? true : isLeafRequired(right, depth + 1)\n return leftReq || rightReq\n }\n // Direct primitive leaf or unsupported kind — required by default.\n return true\n}\n\n/**\n * Wrap a Zod v4 `ZodObject` schema in an `AbstractSchema` factory.\n *\n * Most consumers never call this directly — `useForm` from\n * `attaform/zod` does the wrapping automatically. Reach for\n * it when you need an adapter outside of `useForm` (e.g. validating\n * data with the same library used elsewhere in the form runtime, or\n * exposing the adapter to a custom integration).\n *\n * The returned factory accepts per-form `SchemaFactoryOptions` (notably\n * `maxRecursionDepth`); the adapter closure bakes them into every\n * downstream walk so a per-form override can lift the cap without\n * touching the app-level default.\n *\n * Throws if the schema isn't Zod v4 or contains kinds the adapter\n * cannot represent (`z.promise`, `z.custom`, `z.templateLiteral`).\n * Recursive `z.lazy(...)` is supported — the runtime walks bound their\n * descent via `maxRecursionDepth`.\n */\nexport function zodV4Adapter<\n FormSchema extends z.ZodObject,\n Form extends z.input<FormSchema>,\n GetValueFormType extends z.output<FormSchema> = z.output<FormSchema>,\n>(\n rootSchema: FormSchema\n): (formKey: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, GetValueFormType> {\n assertZodVersion(rootSchema)\n // Fail fast at adapter construction if the schema uses kinds we can't\n // represent (z.promise / z.custom / z.templateLiteral). Errors carry\n // the dotted path to the offending node. Recursive lazies pass — the\n // runtime walks cap their descent via `maxRecursionDepth`.\n assertSupportedKinds(rootSchema)\n\n return (formKey: FormKey, options: SchemaFactoryOptions) =>\n createAbstractSchema<z.ZodType, Form, GetValueFormType>(\n rootSchema,\n V4_INTROSPECTOR,\n buildV4Services<Form, GetValueFormType>(),\n formKey,\n options\n )\n}\n\n/**\n * Build the v4 `AbstractSchemaServices` instance. The services are\n * stateless — every method receives the schema it acts on plus the\n * factory-supplied `formKey` / `maxRecursionDepth`. The function is\n * generic in `Form` / `GetValueFormType` so the typed methods\n * (`runStrictGetDefaults` / `makeSubSchema`) propagate the form\n * shape correctly.\n */\n// Lazy fingerprint: the only consumers are opt-in async features\n// (the persistence storage key) plus a dev-only\n// mismatch warning, so the structural walk + its `canonicalStringify`\n// helper load on demand off the eager `useForm` path instead of being\n// anchored eager by a static import.\nasync function lazyFingerprint(schema: z.ZodType): Promise<string> {\n const { fingerprintZodSchema } = await import('./fingerprint')\n return fingerprintZodSchema(schema)\n}\n\nfunction buildV4Services<\n Form extends GenericForm,\n GetValueFormType extends GenericForm,\n>(): AbstractSchemaServices<z.ZodType, Form, GetValueFormType> {\n return {\n fingerprint: (schema) => lazyFingerprint(schema),\n getNestedSchemasAtPath: (schema, path, maxRecursionDepth) =>\n getNestedZodSchemasAtPath(schema as z.ZodObject, path, maxRecursionDepth),\n // v4 doesn't pre-strip for the slim-mode walk — its path walker\n // already peels every transparent wrapper inline, so the slim and\n // unstripped walks coincide.\n getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) =>\n getNestedZodSchemasAtPath(schema as z.ZodObject, path, maxRecursionDepth),\n slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),\n deriveDefault: (schema, useDefault, maxRecursionDepth) =>\n deriveDefault(schema, useDefault, maxRecursionDepth),\n runStrictGetDefaults: (schema, config, fk, maxRecursionDepth) =>\n runStrictGetDefaultsV4<Form>(schema as FormSchemaAlias<Form>, config, fk, maxRecursionDepth),\n unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),\n unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),\n peelAllWrappers: (schema) => peelAllWrappers(schema),\n isLeafRequired: (schema) => isLeafRequired(schema),\n resolveFieldMetaAtPath: (schema, path, maxRecursionDepth) =>\n resolveFieldMetaAtPath(schema, path, maxRecursionDepth),\n issuesToValidationErrors: (issues, fk) =>\n zodIssuesToValidationErrors(issues as z.core.$ZodIssue[], fk),\n safeParseSync: (schema, data) => {\n const result = schema.safeParse(data) as z.ZodSafeParseResult<unknown>\n return result.success\n ? { success: true, data: result.data }\n : { success: false, issues: result.error.issues }\n },\n safeParseAsync: async (schema, data) => {\n const result = (await schema.safeParseAsync(data)) as z.ZodSafeParseResult<unknown>\n return result.success\n ? { success: true, data: result.data }\n : { success: false, issues: result.error.issues }\n },\n makeSubSchema: (schema, fk, maxRecursionDepth) =>\n buildSubSchemaStubV4<GetValueFormType>(schema, fk, maxRecursionDepth),\n }\n}\n\n// `runStrictGetDefaultsV4` infers its target shape from a single schema\n// argument; this alias lets the service signature compose without the\n// adapter having to repeat the ZodObject constraint inline.\ntype FormSchemaAlias<Form> = z.ZodType & { _output: Form }\n\n/**\n * v4's construction-time `getDefaultValues` flow. Wraps the slim\n * default-value derivation (`getDefaultValuesFromZodSchema`) with a\n * strict-mode parse that surfaces refinement errors at construction,\n * with two pre-flight gates:\n *\n * 1. Async transforms (`z.preprocess(async fn, T)`) cannot be\n * stripped — the transform's output shape is load-bearing for\n * the inner schema's input. Skip the strict pass; the post-mount\n * async pass picks up verdicts via `safeParseAsync`.\n *\n * 2. Async refines CAN be stripped (the predicate is detachable\n * from the schema's shape). Strip them up front so the sync\n * parse runs cleanly; sync-refinement seeds on supplied defaults\n * still surface.\n *\n * Lax mode short-circuits: the validate-then-fix loop inside the slim\n * derivation has done everything it can; partial-valid state ships\n * over a mount-time exception.\n */\nfunction runStrictGetDefaultsV4<Form>(\n rootSchema: z.ZodType & { _output: Form },\n config: GetDefaultValuesConfig<Form>,\n formKey: FormKey,\n maxRecursionDepth: number\n): DefaultValuesResponse<Form> {\n const { data } = getDefaultValuesFromZodSchema<Form>({\n schema: rootSchema as unknown as z.ZodObject,\n useDefaultSchemaValues: config.useDefaultSchemaValues,\n constraints: config.constraints,\n maxRecursionDepth,\n })\n\n if (config.strict === false) {\n // Lax mode: see docblock — partial-valid initial state preferred\n // to a mount-time exception.\n return { data, errors: undefined, success: true, formKey }\n }\n\n if (containsAsyncTransform(rootSchema)) {\n return { data, errors: undefined, success: true, formKey }\n }\n\n const parseTarget = containsAsyncRefine(rootSchema) ? stripAsyncChecks(rootSchema) : rootSchema\n try {\n const strictResult = parseTarget.safeParse(data) as z.ZodSafeParseResult<Form>\n if (strictResult.success) {\n // Storage holds the pre-transform `z.input` view, so we return\n // the original `data` (already filled by\n // `getDefaultValuesFromZodSchema`) rather than `strictResult.data`\n // (the post-transform `z.output`). For schemas without\n // `.transform()` the two coincide; for schemas with one the\n // storage stays the honest input view that `form.values` reflects.\n return { data, errors: undefined, success: true, formKey }\n }\n return {\n data,\n errors: zodIssuesToValidationErrors(strictResult.error.issues, formKey),\n success: false,\n formKey,\n }\n } catch {\n // Defensive floor: the strip walker covers every ZodKind, but a\n // future Zod construct or a user-defined sync refine that itself\n // throws would land here. Mount cleanly; the post-mount async\n // pass is the source of truth for any verdict this code path\n // can't surface.\n return { data, errors: undefined, success: true, formKey }\n }\n}\n\n/**\n * Build the 5-method sub-schema stub that v4 returns from\n * `getSchemasAtPath`. Mirrors the shape consumers expect\n * (`fingerprint`, `needsAsyncValidation`, `getDefaultValues`,\n * `getSchemasAtPath: () => []`, `validateAtPath`) without re-walking\n * through the full factory — sub-schemas in the runtime are only\n * queried for `needsAsyncValidation`, so the stub is observationally\n * interchangeable with the recursive shape v3 returns.\n */\nfunction buildSubSchemaStubV4<GetValueFormType extends GenericForm>(\n schema: z.ZodType,\n formKey: FormKey,\n maxRecursionDepth: number\n): AbstractSchema<unknown, GetValueFormType> {\n return {\n fingerprint: () => lazyFingerprint(schema),\n needsAsyncValidation: () => containsAsyncRefine(schema),\n getDefaultValues: () => ({\n data: deriveDefault(schema, true, maxRecursionDepth) as unknown,\n errors: undefined,\n success: true,\n formKey,\n }),\n getSchemasAtPath: () => [],\n validateAtPath: async (data: unknown) => {\n // safeParseAsync accepts both sync and async refinements — sync\n // check perf is a microtask slower than safeParse but we trade\n // that for the ability to express .refine(async).\n const result = await schema.safeParseAsync(data)\n if (result.success) {\n return {\n data: result.data as GetValueFormType,\n errors: undefined,\n success: true,\n formKey,\n }\n }\n return {\n data: undefined,\n errors: zodIssuesToValidationErrors(result.error.issues, formKey),\n success: false,\n formKey,\n }\n },\n } as unknown as AbstractSchema<unknown, GetValueFormType>\n}\n\n/**\n * Resolve the field metadata for the schema node at `path`. Reads\n * the `fieldMeta` registry on the resolved Zod schema and applies\n * the precedence rules in `getFieldMetaAtPath`'s docblock:\n *\n * - label: registry → humanize(lastSegment)\n * - description: registry → schema.description (.describe()) → undefined\n * - placeholder: registry → undefined\n * - meta: registry payload (frozen) — empty object when absent\n *\n * Returns the empty resolution when the path doesn't resolve in the\n * schema. DU branches: first candidate wins (matches the existing\n * first-success precedent in `getDefaultAtPath` / `validateAtPath`).\n *\n * For shared schemas registered at multiple paths (the canonical\n * `addressSchema.register(fieldMeta, A); addressSchema.register(fieldMeta, B)`\n * footgun), the path-resolver builds a per-rootSchema path → payload\n * map by walking the schema tree once, counting per-schema\n * occurrences and pairing them with the registration list in\n * declaration order. Object literals evaluate left-to-right, so\n * registration order matches tree-walk order, and the mapping pairs\n * correctly.\n */\nfunction resolveFieldMetaAtPath(\n rootSchema: z.ZodType,\n path: Path,\n maxRecursionDepth: number\n): ResolvedFieldMeta {\n const lastSegment = path.length === 0 ? '' : (path[path.length - 1] as string | number)\n const candidates =\n path.length === 0\n ? [rootSchema]\n : getNestedZodSchemasAtPath(rootSchema, path, maxRecursionDepth)\n const target = candidates[0]\n if (target === undefined) {\n return {\n label: humanize(lastSegment),\n description: undefined,\n placeholder: undefined,\n meta: Object.freeze({}),\n }\n }\n // Path-keyed payload map (built once per rootSchema) disambiguates\n // shared schemas. Falls back to the schema-keyed registry for paths\n // not visited by the walker (e.g. dynamic discriminated-union\n // sub-paths the walker can't statically enumerate).\n const pathMap = getFieldMetaPathMap(rootSchema, {\n intro: V4_INTROSPECTOR,\n peelAllWrappers,\n getFieldMetaList,\n })\n const pathKey = canonicalizePath(path).key\n const peeled = peelAllWrappers(target)\n const payload =\n pathMap.get(pathKey) ??\n getFieldMeta(target) ??\n (peeled !== target ? getFieldMeta(peeled) : undefined)\n // `description` is exposed as a public property on Zod 4 schemas;\n // when set via `.describe('...')` or `.meta({ description })`, it\n // reads back as a string. Read from the target first; fall back to\n // the peeled inner so a `.describe()` on `z.string()` is still\n // visible when wrapped in `.optional()`.\n const targetDescription = readDescription(target)\n const peeledDescription = peeled !== target ? readDescription(peeled) : undefined\n const schemaDescription = targetDescription ?? peeledDescription\n return {\n label: payload?.label ?? humanize(lastSegment),\n description: payload?.description ?? schemaDescription ?? undefined,\n placeholder: payload?.placeholder ?? undefined,\n meta: Object.freeze({ ...(payload ?? {}) }),\n }\n}\n\nfunction readDescription(schema: z.ZodType): string | undefined {\n const candidate = (schema as z.ZodType & { description?: unknown }).description\n return typeof candidate === 'string' ? candidate : undefined\n}\n\n// Type-only re-export so downstream code can reference the Form shape.\nexport type { DeepPartial, GenericForm }\n","/**\n * Zod v4 adapter entry point. Re-exports the adapter + the useForm\n * wrapper that threads zod-v4-specific schema types through\n * useAbstractForm.\n */\nimport type { z } from 'zod'\nimport { useAbstractForm } from '../../composables/use-abstract-form'\nimport { InvalidUseFormConfigError } from '../../core/errors'\nimport type {\n AbstractSchema,\n FormKey,\n ValidateOnConfig,\n UseFormReturnType,\n UseFormConfiguration,\n SchemaFactoryOptions,\n} from '../../types/types-api'\nimport type { DefaultValuesInput, FlatPath, GenericForm, NestedType } from '../../types/types-core'\nimport { zodV4Adapter } from './adapter'\nimport type { StorageShape } from './types-storage-shape'\n\nexport { zodV4Adapter as zodAdapter } from './adapter'\nexport { UnsupportedSchemaError } from './errors'\nexport { assertZodVersion, kindOf } from './introspect'\nexport type { ZodKind } from './introspect'\nexport type { StorageLeaf, StorageShape } from './types-storage-shape'\n\n/**\n * Type of the value accepted at `Path` for `setValue` / `defaultValues`\n * — the schema's `z.input<Schema>` shape at that path. Matches what\n * `form.values.X` returns at runtime (the honest input view storage\n * holds before transforms run).\n *\n * ```ts\n * const schema = z.object({\n * flag: z.string().transform((v) => v.length > 10),\n * })\n * type FlagWriteIn = PathInput<typeof schema, 'flag'> // string\n * ```\n */\nexport type PathInput<Schema extends z.ZodType, Path extends string> =\n z.input<Schema> extends GenericForm\n ? Path extends FlatPath<z.input<Schema>>\n ? NestedType<z.input<Schema>, Path>\n : never\n : never\n\n/**\n * Type produced at `Path` after the full parse pipeline — the schema's\n * `z.output<Schema>` shape at that path. Matches the `data` payload of\n * `form.parse()` and the value handed to `handleSubmit`'s callback.\n *\n * ```ts\n * const schema = z.object({\n * flag: z.string().transform((v) => v.length > 10),\n * })\n * type FlagParsedOut = PathOutput<typeof schema, 'flag'> // boolean\n * ```\n */\nexport type PathOutput<Schema extends z.ZodType, Path extends string> =\n z.output<Schema> extends GenericForm\n ? Path extends FlatPath<z.output<Schema>>\n ? NestedType<z.output<Schema>, Path>\n : never\n : never\n\n/**\n * Create a form bound to a Zod v4 schema.\n *\n * ```ts\n * import { useForm } from 'attaform/zod'\n * import { z } from 'zod'\n *\n * const form = useForm({\n * schema: z.object({\n * email: z.email(),\n * password: z.string().min(8),\n * }),\n * defaultValues: { email: '' },\n * })\n * ```\n *\n * Returns a form API exposing `register`, `values`, `errors`,\n * `fields`, `setValue`, `handleSubmit`, `meta`, field-array\n * helpers, and more. See `UseFormReturnType` for the full\n * surface.\n *\n * For Zod v3, import from `attaform/zod-v3` instead.\n */\n/**\n * `FormOf` / `OutOf` / `ReadOf` factor the three identical-shape\n * conditionals out of `useForm`'s public signature. The bundled\n * `.d.ts` then carries one alias per shape rather than re-inlining\n * `z.input<Schema> extends GenericForm ? z.input<Schema> : never`\n * four times — which is what produces TS2589 (\"Type instantiation\n * is excessively deep\") on consumer call sites with complex schemas\n * (discriminated unions, transform pipes, deep `.register()` chains).\n * Each alias is computed once per `Schema` instantiation; downstream\n * generics ride on the alias rather than re-evaluating the\n * conditional from scratch.\n */\ntype FormOf<Schema extends z.ZodObject> =\n z.input<Schema> extends GenericForm ? z.input<Schema> : never\ntype OutOf<Schema extends z.ZodObject> =\n z.output<Schema> extends GenericForm ? z.output<Schema> : never\ntype ReadOf<Schema extends z.ZodObject> =\n StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never\n\nexport function useForm<Schema extends z.ZodObject, K extends FormKey = FormKey>(\n configuration: Omit<\n UseFormConfiguration<\n FormOf<Schema>,\n OutOf<Schema>,\n AbstractSchema<FormOf<Schema>, OutOf<Schema>>,\n DefaultValuesInput<FormOf<Schema>>,\n K\n >,\n 'schema' | 'validateOn' | 'debounceMs'\n > & { schema: Schema } & ValidateOnConfig\n): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K> {\n // Foot-gun guard: catches `useForm(z.object({...}))` (raw schema as\n // the first arg — its `.schema` field is undefined), `useForm()` (no\n // args), and `useForm({ schema: undefined })` before they reach the\n // adapter and crash deep with an opaque message. JS callers and\n // `as any` callers can defy the static signature; the `unknown`\n // cast forces the runtime checks to stay live under tsc.\n const candidate = configuration as unknown\n if (\n candidate === undefined ||\n candidate === null ||\n (candidate as { schema?: unknown }).schema === undefined\n ) {\n throw new InvalidUseFormConfigError()\n }\n // Three-slot generic split:\n // - `Form` (z.input) is the WRITE view — what setValue / register\n // / defaultValues accept. Loose for honest-input wrappers\n // (preprocess accepts `unknown` at the write boundary).\n // - `Out` (z.output) is the parsed-output view — what handleSubmit\n // and form.parse() yield. Refinements have fired, transforms\n // have run.\n // - `Read` (StorageShape) is the READ view — what form.values /\n // form.fields / register's read side / toRef expose. Per-key\n // z.output for write-boundary wrappers (default / preprocess /\n // etc.) so defaulted leaves type as `T` (not `T | undefined`),\n // z.input for transforms (storage holds pre-transform input).\n type Form = z.input<Schema> extends GenericForm ? z.input<Schema> : never\n type Out = z.output<Schema> extends GenericForm ? z.output<Schema> : never\n type Read = StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never\n // `zodV4Adapter` returns a factory\n // `(formKey, options: SchemaFactoryOptions) => AbstractSchema`;\n // `UseFormConfiguration.schema` accepts `Schema | ((key, options) => Schema)`,\n // so the factory is a first-class input — previously the call site cast it\n // through `unknown as AbstractSchema`, which converted a function to an\n // object type and hid the mismatch. The narrower cast below preserves the\n // factory shape at the boundary so per-form `maxRecursionDepth` threads\n // through cleanly.\n const adapter: (key: FormKey, options: SchemaFactoryOptions) => AbstractSchema<Form, Out> =\n zodV4Adapter(configuration.schema) as (\n key: FormKey,\n options: SchemaFactoryOptions\n ) => AbstractSchema<Form, Out>\n // The discriminated `ValidateOnConfig` doesn't narrow cleanly through\n // `Omit` + spread — TS picks the wrong variant after the structural\n // rebuild. The runtime input is genuinely the right shape (the\n // public `useForm` signature already enforced the discriminant on\n // `configuration` before we got here), so cast to the parameter\n // type to side-step the structural disagreement.\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return useAbstractForm<Form, Out, Read, K>({\n ...configuration,\n schema: adapter,\n } as Parameters<typeof useAbstractForm<Form, Out, Read, K>>[0])\n}\n"],"names":[],"mappings":";;;;;AAoFO,MAAM,SAAA,GAAY;AAWlB,SAAS,iBAAiB,MAAA,EAAgD;AAC/E,EAAA,OAAO,0BAA0B,MAAgB,CAAA;AACnD;AAkBO,SAAS,QAAA,CAA8B,QAAW,OAAA,EAA8B;AAYrF,EAAA,MAAM,QAAA,GAAW,qBAAA,CAAsB,MAAgB,CAAA,IAAK,EAAC;AAC7D,EAAA,MAAM,MAAA,GAAS,OAAO,KAAA,EAAM;AAC5B,EAAA,cAAA,CAAe,IAAI,MAAA,EAA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