@openclaw/feishu 2026.9.4 → 2026.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (743) hide show
  1. package/assets/activity.svg +3 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/{accounts-cCMNFBKg.js → .setup/accounts-DmU0xYPx.mjs} +1 -1
  4. package/dist/{app-registration-BI99e_JI.js → .setup/app-registration-Bv4mvauR.mjs} +1 -1
  5. package/dist/{channel-HDnQAH4Z.js → .setup/channel-C1KrXXJa.mjs} +93 -86
  6. package/dist/{channel.runtime-B-f6ajOp.js → .setup/channel.runtime-Bizuv7WZ.mjs} +32 -18
  7. package/dist/{chat-zhIPXu4X.js → .setup/chat-dWJYS63b.mjs} +2 -2
  8. package/dist/{client-DMbIL3UH.js → .setup/client-DCwNVFZg.mjs} +128 -11
  9. package/dist/{conversation-id-VYgGQ-GX.js → .setup/conversation-id-H-lUayji.mjs} +49 -14
  10. package/dist/{monitor-EuNsFn2T.js → .setup/monitor-C69OLzgO.mjs} +4 -4
  11. package/dist/{monitor.account-CZ7EtqYS.js → .setup/monitor.account-zwHb3HKM.mjs} +68 -52
  12. package/dist/{probe-D_SatdZl.js → .setup/probe-bdidyhAn.mjs} +2 -2
  13. package/dist/{reply-delivery-result-C3smdVzb.js → .setup/reply-delivery-result-DFjxGLgX.mjs} +129 -116
  14. package/dist/.setup/runtime-setter-api-CG-RC4_r.mjs +3 -0
  15. package/dist/.setup/secret-contract-api-jmCkqVLc.mjs +3 -0
  16. package/dist/{security-audit-DKfR4Cv3.js → .setup/security-audit-CmiKKfU-.mjs} +1 -1
  17. package/dist/{session-conversation-DFCIvQK-.js → .setup/session-conversation-ZC6TC1zk.mjs} +1 -1
  18. package/dist/.setup/setup-api-CTRwX09n.mjs +3 -0
  19. package/dist/{subagent-hooks-Buadpie_.js → .setup/subagent-hooks-BBfF1hZk.mjs} +3 -19
  20. package/dist/api.js +29 -15
  21. package/dist/channel-plugin-api.js +1 -1
  22. package/dist/contract-api.js +3 -3
  23. package/dist/doctor-contract-api.js +1 -1
  24. package/dist/runtime-api.js +1 -1
  25. package/dist/runtime-setter-api.js +1 -1
  26. package/dist/secret-contract-api.js +1 -1
  27. package/dist/security-contract-api.js +1 -1
  28. package/dist/session-binding-contract-api.js +1 -1
  29. package/dist/session-key-api.js +1 -1
  30. package/dist/setup-api.js +1 -1
  31. package/dist/setup-entry.js +4 -3
  32. package/dist/subagent-hooks-api.js +1 -1
  33. package/node_modules/@larksuiteoapi/node-sdk/es/index.js +199 -35
  34. package/node_modules/@larksuiteoapi/node-sdk/lib/index.js +199 -35
  35. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/CHANGELOG.md +62 -0
  36. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/README.md +233 -5
  37. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.js +387 -89
  38. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js +3 -3
  39. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js.map +1 -1
  40. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/browser/axios.cjs +458 -98
  41. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.js +458 -98
  42. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js +2 -2
  43. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  44. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/node/axios.cjs +568 -116
  45. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.cts +4 -0
  46. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.ts +4 -0
  47. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/fetch.js +64 -11
  48. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/http.js +134 -50
  49. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/xhr.js +52 -3
  50. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/Axios.js +19 -14
  51. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/InterceptorManager.js +107 -8
  52. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/buildFullPath.js +1 -13
  53. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/dispatchRequest.js +8 -2
  54. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/mergeConfig.js +1 -1
  55. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/methodList.js +17 -0
  56. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/defaults/index.js +2 -1
  57. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/env/data.js +1 -1
  58. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
  59. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
  60. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
  61. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  62. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
  63. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
  64. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
  65. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/throttle.js +3 -2
  66. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/toFormData.js +14 -21
  67. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/utils.js +134 -13
  68. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/package.json +1 -1
  69. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/README.md +24 -17
  70. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.js +124 -14
  71. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  72. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  73. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  74. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.js +63 -9
  75. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  76. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  77. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  78. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.js +133 -18
  79. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  80. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  81. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  82. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/descriptor.generated.d.ts +7 -0
  83. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/descriptor.js +24 -0
  84. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/protojson.js +14 -4
  85. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/textformat.js +8 -4
  86. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/google/protobuf/descriptor.json +20 -1
  87. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/google/protobuf/descriptor.proto +14 -1
  88. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/index.d.ts +12 -0
  89. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/package.json +1 -1
  90. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/decoder.js +31 -2
  91. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/enum.js +10 -0
  92. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/object.js +5 -2
  93. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/parse.js +9 -4
  94. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/reader.js +61 -7
  95. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/type.js +10 -0
  96. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/wrappers.js +5 -1
  97. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  98. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/CHANGELOG.md +15 -0
  99. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/README.md +19 -1
  100. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/dist/qs.js +21 -21
  101. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/eslint.config.mjs +1 -1
  102. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/parse.js +3 -4
  103. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/stringify.js +23 -8
  104. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/utils.js +10 -3
  105. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/package.json +4 -4
  106. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/parse.js +192 -3
  107. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/stringify.js +317 -0
  108. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/utils.js +12 -0
  109. package/node_modules/@larksuiteoapi/node-sdk/package.json +1 -1
  110. package/node_modules/@larksuiteoapi/node-sdk/types/index.d.ts +35 -0
  111. package/node_modules/typebox/build/compile/validator.d.mts +1 -1
  112. package/node_modules/typebox/build/compile/validator.mjs +1 -1
  113. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +7 -5
  114. package/node_modules/typebox/build/format/iri.mjs +5 -1
  115. package/node_modules/typebox/build/guard/emit.mjs +2 -4
  116. package/node_modules/typebox/build/guard/guard.mjs +6 -18
  117. package/node_modules/typebox/build/guard/string.mjs +16 -24
  118. package/node_modules/typebox/build/schema/build.mjs +2 -2
  119. package/node_modules/typebox/build/schema/check.mjs +1 -1
  120. package/node_modules/typebox/build/schema/compile.d.mts +3 -2
  121. package/node_modules/typebox/build/schema/compile.mjs +8 -8
  122. package/node_modules/typebox/build/schema/engine/_context.d.mts +6 -7
  123. package/node_modules/typebox/build/schema/engine/_context.mjs +23 -15
  124. package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
  125. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
  126. package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
  127. package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
  128. package/node_modules/typebox/build/schema/engine/_refine.mjs +4 -7
  129. package/node_modules/typebox/build/schema/engine/_stack.d.mts +34 -16
  130. package/node_modules/typebox/build/schema/engine/_stack.mjs +148 -104
  131. package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
  132. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -8
  133. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +26 -18
  134. package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
  135. package/node_modules/typebox/build/schema/engine/allOf.mjs +3 -3
  136. package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
  137. package/node_modules/typebox/build/schema/engine/anyOf.mjs +5 -10
  138. package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
  139. package/node_modules/typebox/build/schema/engine/boolean.mjs +2 -6
  140. package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
  141. package/node_modules/typebox/build/schema/engine/const.mjs +2 -6
  142. package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
  143. package/node_modules/typebox/build/schema/engine/contains.mjs +2 -6
  144. package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
  145. package/node_modules/typebox/build/schema/engine/dependencies.mjs +3 -6
  146. package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
  147. package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +2 -6
  148. package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
  149. package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
  150. package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +11 -7
  151. package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
  152. package/node_modules/typebox/build/schema/engine/enum.mjs +2 -6
  153. package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
  154. package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +2 -6
  155. package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
  156. package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +2 -6
  157. package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
  158. package/node_modules/typebox/build/schema/engine/format.mjs +2 -6
  159. package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
  160. package/node_modules/typebox/build/schema/engine/if.mjs +7 -15
  161. package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
  162. package/node_modules/typebox/build/schema/engine/items.mjs +1 -1
  163. package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
  164. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -6
  165. package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
  166. package/node_modules/typebox/build/schema/engine/maxItems.mjs +2 -6
  167. package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
  168. package/node_modules/typebox/build/schema/engine/maxLength.mjs +2 -6
  169. package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
  170. package/node_modules/typebox/build/schema/engine/maxProperties.mjs +2 -6
  171. package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
  172. package/node_modules/typebox/build/schema/engine/maximum.mjs +2 -6
  173. package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
  174. package/node_modules/typebox/build/schema/engine/minContains.mjs +2 -6
  175. package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
  176. package/node_modules/typebox/build/schema/engine/minItems.mjs +2 -6
  177. package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
  178. package/node_modules/typebox/build/schema/engine/minLength.mjs +2 -6
  179. package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
  180. package/node_modules/typebox/build/schema/engine/minProperties.mjs +2 -6
  181. package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
  182. package/node_modules/typebox/build/schema/engine/minimum.mjs +2 -6
  183. package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
  184. package/node_modules/typebox/build/schema/engine/multipleOf.mjs +2 -6
  185. package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
  186. package/node_modules/typebox/build/schema/engine/not.mjs +4 -8
  187. package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
  188. package/node_modules/typebox/build/schema/engine/oneOf.mjs +6 -11
  189. package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
  190. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -7
  191. package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
  192. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +1 -1
  193. package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
  194. package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
  195. package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
  196. package/node_modules/typebox/build/schema/engine/properties.mjs +1 -1
  197. package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
  198. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +4 -10
  199. package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
  200. package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +11 -7
  201. package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
  202. package/node_modules/typebox/build/schema/engine/ref.mjs +19 -15
  203. package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
  204. package/node_modules/typebox/build/schema/engine/required.mjs +2 -6
  205. package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
  206. package/node_modules/typebox/build/schema/engine/schema.mjs +137 -133
  207. package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
  208. package/node_modules/typebox/build/schema/engine/type.mjs +2 -6
  209. package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
  210. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +5 -9
  211. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
  212. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +5 -9
  213. package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
  214. package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +2 -6
  215. package/node_modules/typebox/build/schema/errors.d.mts +2 -2
  216. package/node_modules/typebox/build/schema/errors.mjs +8 -14
  217. package/node_modules/typebox/build/schema/intern/index.d.mts +1 -0
  218. package/node_modules/typebox/build/schema/intern/index.mjs +1 -0
  219. package/node_modules/typebox/build/schema/intern/intern.d.mts +11 -0
  220. package/node_modules/typebox/build/schema/intern/intern.mjs +293 -0
  221. package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +2 -0
  222. package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +288 -0
  223. package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +2 -0
  224. package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +300 -0
  225. package/node_modules/typebox/build/schema/meta/draft_3.d.mts +2 -0
  226. package/node_modules/typebox/build/schema/meta/draft_3.mjs +143 -0
  227. package/node_modules/typebox/build/schema/meta/draft_4.d.mts +2 -0
  228. package/node_modules/typebox/build/schema/meta/draft_4.mjs +149 -0
  229. package/node_modules/typebox/build/schema/meta/draft_6.d.mts +2 -0
  230. package/node_modules/typebox/build/schema/meta/draft_6.mjs +155 -0
  231. package/node_modules/typebox/build/schema/meta/draft_7.d.mts +2 -0
  232. package/node_modules/typebox/build/schema/meta/draft_7.mjs +172 -0
  233. package/node_modules/typebox/build/schema/meta/index.d.mts +2 -0
  234. package/node_modules/typebox/build/schema/meta/index.mjs +2 -0
  235. package/node_modules/typebox/build/schema/meta/meta.d.mts +9 -0
  236. package/node_modules/typebox/build/schema/meta/meta.mjs +15 -0
  237. package/node_modules/typebox/build/schema/meta/schema.d.mts +6 -0
  238. package/node_modules/typebox/build/schema/meta/schema.mjs +1 -0
  239. package/node_modules/typebox/build/schema/parse.d.mts +1 -0
  240. package/node_modules/typebox/build/schema/parse.mjs +10 -5
  241. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +8 -3
  242. package/node_modules/typebox/build/schema/resolve/resolve.mjs +268 -139
  243. package/node_modules/typebox/build/schema/schema.d.mts +2 -0
  244. package/node_modules/typebox/build/schema/schema.mjs +2 -0
  245. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -12
  246. package/node_modules/typebox/build/value/errors/errors.mjs +2 -7
  247. package/node_modules/typebox/package.json +1 -1
  248. package/node_modules/typebox/readme.md +59 -89
  249. package/node_modules/zod/README.md +27 -0
  250. package/node_modules/zod/compile.cjs +77 -0
  251. package/node_modules/zod/compile.d.cts +1 -0
  252. package/node_modules/zod/compile.d.ts +1 -0
  253. package/node_modules/zod/compile.js +52 -0
  254. package/node_modules/zod/index.cjs +2 -2
  255. package/node_modules/zod/index.d.cts +1 -2
  256. package/node_modules/zod/index.d.ts +1 -2
  257. package/node_modules/zod/index.js +5 -2
  258. package/node_modules/zod/package.json +13 -2
  259. package/node_modules/zod/src/compile.ts +56 -0
  260. package/node_modules/zod/src/index.ts +5 -2
  261. package/node_modules/zod/src/v3/ZodError.ts +22 -12
  262. package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
  263. package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
  264. package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
  265. package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
  266. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
  267. package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
  268. package/node_modules/zod/src/v3/types.ts +5 -5
  269. package/node_modules/zod/src/v4/classic/checks.ts +1 -0
  270. package/node_modules/zod/src/v4/classic/compat.ts +26 -18
  271. package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
  272. package/node_modules/zod/src/v4/classic/errors.ts +59 -44
  273. package/node_modules/zod/src/v4/classic/external.ts +12 -9
  274. package/node_modules/zod/src/v4/classic/from-json-schema.ts +140 -78
  275. package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
  276. package/node_modules/zod/src/v4/classic/index.ts +2 -2
  277. package/node_modules/zod/src/v4/classic/iso.ts +2 -72
  278. package/node_modules/zod/src/v4/classic/parse.ts +10 -4
  279. package/node_modules/zod/src/v4/classic/schemas.ts +452 -262
  280. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
  281. package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
  282. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +135 -0
  283. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +30 -1
  284. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
  285. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
  286. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
  287. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
  288. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
  289. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +720 -0
  290. package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
  291. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
  292. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
  293. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
  294. package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
  295. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
  296. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +155 -13
  297. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +11 -0
  298. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
  299. package/node_modules/zod/src/v4/classic/tests/error.test.ts +274 -6
  300. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +425 -10
  301. package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
  302. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
  303. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
  304. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
  305. package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
  306. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +281 -0
  307. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +47 -0
  308. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
  309. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +183 -0
  310. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
  311. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
  312. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
  313. package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
  314. package/node_modules/zod/src/v4/classic/tests/number.test.ts +46 -9
  315. package/node_modules/zod/src/v4/classic/tests/object.test.ts +245 -12
  316. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +234 -0
  317. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
  318. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
  319. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
  320. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
  321. package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
  322. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +33 -2
  323. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
  324. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
  325. package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
  326. package/node_modules/zod/src/v4/classic/tests/string.test.ts +127 -5
  327. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
  328. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +11 -2
  329. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1585 -173
  330. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
  331. package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
  332. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +76 -0
  333. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
  334. package/node_modules/zod/src/v4/core/api.ts +48 -12
  335. package/node_modules/zod/src/v4/core/checks.ts +57 -44
  336. package/node_modules/zod/src/v4/core/compile.ts +2188 -0
  337. package/node_modules/zod/src/v4/core/core.ts +98 -19
  338. package/node_modules/zod/src/v4/core/doc.ts +11 -7
  339. package/node_modules/zod/src/v4/core/errors.ts +115 -24
  340. package/node_modules/zod/src/v4/core/index.ts +3 -0
  341. package/node_modules/zod/src/v4/core/json-schema-generator.ts +6 -1
  342. package/node_modules/zod/src/v4/core/json-schema-processors.ts +257 -93
  343. package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
  344. package/node_modules/zod/src/v4/core/memoizer.ts +284 -0
  345. package/node_modules/zod/src/v4/core/parse.ts +131 -38
  346. package/node_modules/zod/src/v4/core/regexes.ts +30 -13
  347. package/node_modules/zod/src/v4/core/registries.ts +2 -2
  348. package/node_modules/zod/src/v4/core/schemas.ts +759 -461
  349. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +969 -0
  350. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
  351. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
  352. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
  353. package/node_modules/zod/src/v4/core/tests/compile.test.ts +1639 -0
  354. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
  355. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
  356. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
  357. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
  358. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
  359. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
  360. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +31 -0
  361. package/node_modules/zod/src/v4/core/to-json-schema.ts +275 -42
  362. package/node_modules/zod/src/v4/core/util.ts +268 -42
  363. package/node_modules/zod/src/v4/core/versions.ts +2 -2
  364. package/node_modules/zod/src/v4/core/visit.ts +193 -0
  365. package/node_modules/zod/src/v4/index.ts +3 -3
  366. package/node_modules/zod/src/v4/locales/ar.ts +3 -0
  367. package/node_modules/zod/src/v4/locales/az.ts +3 -0
  368. package/node_modules/zod/src/v4/locales/be.ts +10 -0
  369. package/node_modules/zod/src/v4/locales/bg.ts +3 -0
  370. package/node_modules/zod/src/v4/locales/bn.ts +121 -0
  371. package/node_modules/zod/src/v4/locales/ca.ts +3 -0
  372. package/node_modules/zod/src/v4/locales/ckb.ts +138 -0
  373. package/node_modules/zod/src/v4/locales/cs.ts +3 -0
  374. package/node_modules/zod/src/v4/locales/da.ts +5 -2
  375. package/node_modules/zod/src/v4/locales/de.ts +3 -0
  376. package/node_modules/zod/src/v4/locales/el.ts +1 -0
  377. package/node_modules/zod/src/v4/locales/en.ts +15 -4
  378. package/node_modules/zod/src/v4/locales/eo.ts +3 -0
  379. package/node_modules/zod/src/v4/locales/es.ts +2 -0
  380. package/node_modules/zod/src/v4/locales/fa.ts +3 -0
  381. package/node_modules/zod/src/v4/locales/fi.ts +3 -0
  382. package/node_modules/zod/src/v4/locales/fr-CA.ts +3 -0
  383. package/node_modules/zod/src/v4/locales/fr.ts +19 -14
  384. package/node_modules/zod/src/v4/locales/gu.ts +121 -0
  385. package/node_modules/zod/src/v4/locales/he.ts +6 -1
  386. package/node_modules/zod/src/v4/locales/hi.ts +124 -0
  387. package/node_modules/zod/src/v4/locales/hr.ts +2 -0
  388. package/node_modules/zod/src/v4/locales/hu.ts +3 -0
  389. package/node_modules/zod/src/v4/locales/hy.ts +9 -0
  390. package/node_modules/zod/src/v4/locales/id.ts +3 -0
  391. package/node_modules/zod/src/v4/locales/index.ts +10 -0
  392. package/node_modules/zod/src/v4/locales/is.ts +3 -0
  393. package/node_modules/zod/src/v4/locales/it.ts +3 -0
  394. package/node_modules/zod/src/v4/locales/ja.ts +3 -0
  395. package/node_modules/zod/src/v4/locales/ka.ts +3 -0
  396. package/node_modules/zod/src/v4/locales/km.ts +3 -0
  397. package/node_modules/zod/src/v4/locales/kn.ts +124 -0
  398. package/node_modules/zod/src/v4/locales/ko.ts +3 -0
  399. package/node_modules/zod/src/v4/locales/lt.ts +2 -0
  400. package/node_modules/zod/src/v4/locales/mk.ts +3 -0
  401. package/node_modules/zod/src/v4/locales/ms.ts +3 -0
  402. package/node_modules/zod/src/v4/locales/ne.ts +126 -0
  403. package/node_modules/zod/src/v4/locales/nl.ts +3 -0
  404. package/node_modules/zod/src/v4/locales/nn.ts +119 -0
  405. package/node_modules/zod/src/v4/locales/no.ts +5 -2
  406. package/node_modules/zod/src/v4/locales/ota.ts +3 -0
  407. package/node_modules/zod/src/v4/locales/pl.ts +3 -0
  408. package/node_modules/zod/src/v4/locales/ps.ts +3 -0
  409. package/node_modules/zod/src/v4/locales/pt-BR.ts +159 -0
  410. package/node_modules/zod/src/v4/locales/pt.ts +99 -58
  411. package/node_modules/zod/src/v4/locales/ro.ts +1 -0
  412. package/node_modules/zod/src/v4/locales/ru.ts +10 -0
  413. package/node_modules/zod/src/v4/locales/sk.ts +121 -0
  414. package/node_modules/zod/src/v4/locales/sl.ts +3 -0
  415. package/node_modules/zod/src/v4/locales/sv.ts +5 -2
  416. package/node_modules/zod/src/v4/locales/ta.ts +3 -0
  417. package/node_modules/zod/src/v4/locales/th.ts +3 -0
  418. package/node_modules/zod/src/v4/locales/tk.ts +111 -0
  419. package/node_modules/zod/src/v4/locales/tr.ts +3 -0
  420. package/node_modules/zod/src/v4/locales/uk.ts +3 -0
  421. package/node_modules/zod/src/v4/locales/ur.ts +3 -0
  422. package/node_modules/zod/src/v4/locales/uz.ts +1 -0
  423. package/node_modules/zod/src/v4/locales/vi.ts +3 -0
  424. package/node_modules/zod/src/v4/locales/yo.ts +3 -0
  425. package/node_modules/zod/src/v4/locales/zh-CN.ts +3 -0
  426. package/node_modules/zod/src/v4/locales/zh-TW.ts +3 -0
  427. package/node_modules/zod/src/v4/mini/checks.ts +1 -0
  428. package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
  429. package/node_modules/zod/src/v4/mini/external.ts +10 -1
  430. package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
  431. package/node_modules/zod/src/v4/mini/parse.ts +2 -0
  432. package/node_modules/zod/src/v4/mini/schemas.ts +135 -56
  433. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
  434. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
  435. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
  436. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
  437. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
  438. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
  439. package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
  440. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
  441. package/node_modules/zod/src/v4/mini/tests/index.test.ts +72 -5
  442. package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
  443. package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
  444. package/node_modules/zod/src/v4/mini/tests/string.test.ts +21 -0
  445. package/node_modules/zod/v3/ZodError.cjs +22 -12
  446. package/node_modules/zod/v3/ZodError.d.cts +1 -1
  447. package/node_modules/zod/v3/ZodError.d.ts +1 -1
  448. package/node_modules/zod/v3/ZodError.js +22 -12
  449. package/node_modules/zod/v3/types.cjs +7 -5
  450. package/node_modules/zod/v3/types.js +7 -5
  451. package/node_modules/zod/v4/classic/checks.cjs +2 -1
  452. package/node_modules/zod/v4/classic/checks.d.cts +1 -1
  453. package/node_modules/zod/v4/classic/checks.d.ts +1 -1
  454. package/node_modules/zod/v4/classic/checks.js +1 -1
  455. package/node_modules/zod/v4/classic/compat.d.cts +9 -11
  456. package/node_modules/zod/v4/classic/compat.d.ts +9 -11
  457. package/node_modules/zod/v4/classic/deep-partial.cjs +39 -0
  458. package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
  459. package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
  460. package/node_modules/zod/v4/classic/deep-partial.js +13 -0
  461. package/node_modules/zod/v4/classic/errors.cjs +43 -34
  462. package/node_modules/zod/v4/classic/errors.d.cts +3 -4
  463. package/node_modules/zod/v4/classic/errors.d.ts +3 -4
  464. package/node_modules/zod/v4/classic/errors.js +43 -34
  465. package/node_modules/zod/v4/classic/external.cjs +30 -27
  466. package/node_modules/zod/v4/classic/external.d.cts +5 -2
  467. package/node_modules/zod/v4/classic/external.d.ts +5 -2
  468. package/node_modules/zod/v4/classic/external.js +5 -8
  469. package/node_modules/zod/v4/classic/from-json-schema.cjs +136 -75
  470. package/node_modules/zod/v4/classic/from-json-schema.js +136 -75
  471. package/node_modules/zod/v4/classic/in-out.cjs +63 -0
  472. package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
  473. package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
  474. package/node_modules/zod/v4/classic/in-out.js +36 -0
  475. package/node_modules/zod/v4/classic/index.cjs +2 -2
  476. package/node_modules/zod/v4/classic/index.d.cts +1 -2
  477. package/node_modules/zod/v4/classic/index.d.ts +1 -2
  478. package/node_modules/zod/v4/classic/index.js +2 -2
  479. package/node_modules/zod/v4/classic/iso.cjs +11 -22
  480. package/node_modules/zod/v4/classic/iso.d.cts +2 -17
  481. package/node_modules/zod/v4/classic/iso.d.ts +2 -17
  482. package/node_modules/zod/v4/classic/iso.js +2 -17
  483. package/node_modules/zod/v4/classic/parse.cjs +4 -1
  484. package/node_modules/zod/v4/classic/parse.d.cts +17 -4
  485. package/node_modules/zod/v4/classic/parse.d.ts +17 -4
  486. package/node_modules/zod/v4/classic/parse.js +1 -0
  487. package/node_modules/zod/v4/classic/schemas.cjs +498 -398
  488. package/node_modules/zod/v4/classic/schemas.d.cts +53 -18
  489. package/node_modules/zod/v4/classic/schemas.d.ts +53 -18
  490. package/node_modules/zod/v4/classic/schemas.js +492 -396
  491. package/node_modules/zod/v4/core/api.cjs +23 -4
  492. package/node_modules/zod/v4/core/api.d.cts +13 -9
  493. package/node_modules/zod/v4/core/api.d.ts +13 -9
  494. package/node_modules/zod/v4/core/api.js +21 -4
  495. package/node_modules/zod/v4/core/checks.cjs +37 -31
  496. package/node_modules/zod/v4/core/checks.d.cts +13 -13
  497. package/node_modules/zod/v4/core/checks.d.ts +13 -13
  498. package/node_modules/zod/v4/core/checks.js +37 -31
  499. package/node_modules/zod/v4/core/compile.cjs +1813 -0
  500. package/node_modules/zod/v4/core/compile.d.cts +51 -0
  501. package/node_modules/zod/v4/core/compile.d.ts +51 -0
  502. package/node_modules/zod/v4/core/compile.js +1783 -0
  503. package/node_modules/zod/v4/core/core.cjs +81 -18
  504. package/node_modules/zod/v4/core/core.d.cts +16 -4
  505. package/node_modules/zod/v4/core/core.d.ts +16 -4
  506. package/node_modules/zod/v4/core/core.js +82 -19
  507. package/node_modules/zod/v4/core/doc.cjs +5 -7
  508. package/node_modules/zod/v4/core/doc.d.cts +3 -1
  509. package/node_modules/zod/v4/core/doc.d.ts +3 -1
  510. package/node_modules/zod/v4/core/doc.js +5 -7
  511. package/node_modules/zod/v4/core/errors.cjs +110 -25
  512. package/node_modules/zod/v4/core/errors.d.cts +4 -0
  513. package/node_modules/zod/v4/core/errors.d.ts +4 -0
  514. package/node_modules/zod/v4/core/errors.js +110 -25
  515. package/node_modules/zod/v4/core/index.cjs +5 -1
  516. package/node_modules/zod/v4/core/index.d.cts +3 -0
  517. package/node_modules/zod/v4/core/index.d.ts +3 -0
  518. package/node_modules/zod/v4/core/index.js +3 -0
  519. package/node_modules/zod/v4/core/json-schema-generator.cjs +4 -0
  520. package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
  521. package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
  522. package/node_modules/zod/v4/core/json-schema-generator.js +4 -0
  523. package/node_modules/zod/v4/core/json-schema-processors.cjs +264 -95
  524. package/node_modules/zod/v4/core/json-schema-processors.js +243 -97
  525. package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
  526. package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
  527. package/node_modules/zod/v4/core/memoizer.cjs +272 -0
  528. package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
  529. package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
  530. package/node_modules/zod/v4/core/memoizer.js +265 -0
  531. package/node_modules/zod/v4/core/parse.cjs +96 -34
  532. package/node_modules/zod/v4/core/parse.d.cts +14 -11
  533. package/node_modules/zod/v4/core/parse.d.ts +14 -11
  534. package/node_modules/zod/v4/core/parse.js +94 -33
  535. package/node_modules/zod/v4/core/regexes.cjs +27 -15
  536. package/node_modules/zod/v4/core/regexes.d.cts +2 -0
  537. package/node_modules/zod/v4/core/regexes.d.ts +2 -0
  538. package/node_modules/zod/v4/core/regexes.js +24 -13
  539. package/node_modules/zod/v4/core/registries.js +2 -2
  540. package/node_modules/zod/v4/core/schemas.cjs +537 -326
  541. package/node_modules/zod/v4/core/schemas.d.cts +100 -31
  542. package/node_modules/zod/v4/core/schemas.d.ts +100 -31
  543. package/node_modules/zod/v4/core/schemas.js +526 -325
  544. package/node_modules/zod/v4/core/to-json-schema.cjs +242 -39
  545. package/node_modules/zod/v4/core/to-json-schema.d.cts +42 -3
  546. package/node_modules/zod/v4/core/to-json-schema.d.ts +42 -3
  547. package/node_modules/zod/v4/core/to-json-schema.js +241 -39
  548. package/node_modules/zod/v4/core/util.cjs +212 -31
  549. package/node_modules/zod/v4/core/util.d.cts +58 -1
  550. package/node_modules/zod/v4/core/util.d.ts +58 -1
  551. package/node_modules/zod/v4/core/util.js +202 -30
  552. package/node_modules/zod/v4/core/versions.cjs +2 -2
  553. package/node_modules/zod/v4/core/versions.d.cts +1 -1
  554. package/node_modules/zod/v4/core/versions.d.ts +1 -1
  555. package/node_modules/zod/v4/core/versions.js +2 -2
  556. package/node_modules/zod/v4/core/visit.cjs +195 -0
  557. package/node_modules/zod/v4/core/visit.d.cts +30 -0
  558. package/node_modules/zod/v4/core/visit.d.ts +30 -0
  559. package/node_modules/zod/v4/core/visit.js +169 -0
  560. package/node_modules/zod/v4/index.cjs +15 -5
  561. package/node_modules/zod/v4/index.d.cts +2 -2
  562. package/node_modules/zod/v4/index.d.ts +2 -2
  563. package/node_modules/zod/v4/index.js +3 -2
  564. package/node_modules/zod/v4/locales/ar.cjs +3 -0
  565. package/node_modules/zod/v4/locales/ar.js +3 -0
  566. package/node_modules/zod/v4/locales/az.cjs +3 -0
  567. package/node_modules/zod/v4/locales/az.js +3 -0
  568. package/node_modules/zod/v4/locales/be.cjs +10 -0
  569. package/node_modules/zod/v4/locales/be.js +10 -0
  570. package/node_modules/zod/v4/locales/bg.cjs +3 -0
  571. package/node_modules/zod/v4/locales/bg.js +3 -0
  572. package/node_modules/zod/v4/locales/bn.cjs +138 -0
  573. package/node_modules/zod/v4/locales/bn.d.cts +5 -0
  574. package/node_modules/zod/v4/locales/bn.d.ts +4 -0
  575. package/node_modules/zod/v4/locales/bn.js +111 -0
  576. package/node_modules/zod/v4/locales/ca.cjs +3 -0
  577. package/node_modules/zod/v4/locales/ca.js +3 -0
  578. package/node_modules/zod/v4/locales/ckb.cjs +158 -0
  579. package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
  580. package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
  581. package/node_modules/zod/v4/locales/ckb.js +131 -0
  582. package/node_modules/zod/v4/locales/cs.cjs +3 -0
  583. package/node_modules/zod/v4/locales/cs.js +3 -0
  584. package/node_modules/zod/v4/locales/da.cjs +5 -2
  585. package/node_modules/zod/v4/locales/da.js +5 -2
  586. package/node_modules/zod/v4/locales/de.cjs +3 -0
  587. package/node_modules/zod/v4/locales/de.js +3 -0
  588. package/node_modules/zod/v4/locales/el.cjs +1 -0
  589. package/node_modules/zod/v4/locales/el.js +1 -0
  590. package/node_modules/zod/v4/locales/en.cjs +14 -4
  591. package/node_modules/zod/v4/locales/en.js +14 -4
  592. package/node_modules/zod/v4/locales/eo.cjs +3 -0
  593. package/node_modules/zod/v4/locales/eo.js +3 -0
  594. package/node_modules/zod/v4/locales/es.cjs +2 -0
  595. package/node_modules/zod/v4/locales/es.js +2 -0
  596. package/node_modules/zod/v4/locales/fa.cjs +3 -0
  597. package/node_modules/zod/v4/locales/fa.js +3 -0
  598. package/node_modules/zod/v4/locales/fi.cjs +3 -0
  599. package/node_modules/zod/v4/locales/fi.js +3 -0
  600. package/node_modules/zod/v4/locales/fr-CA.cjs +3 -0
  601. package/node_modules/zod/v4/locales/fr-CA.js +3 -0
  602. package/node_modules/zod/v4/locales/fr.cjs +16 -14
  603. package/node_modules/zod/v4/locales/fr.js +16 -14
  604. package/node_modules/zod/v4/locales/gu.cjs +138 -0
  605. package/node_modules/zod/v4/locales/gu.d.cts +5 -0
  606. package/node_modules/zod/v4/locales/gu.d.ts +4 -0
  607. package/node_modules/zod/v4/locales/gu.js +111 -0
  608. package/node_modules/zod/v4/locales/he.cjs +5 -0
  609. package/node_modules/zod/v4/locales/he.js +5 -0
  610. package/node_modules/zod/v4/locales/hi.cjs +136 -0
  611. package/node_modules/zod/v4/locales/hi.d.cts +5 -0
  612. package/node_modules/zod/v4/locales/hi.d.ts +4 -0
  613. package/node_modules/zod/v4/locales/hi.js +109 -0
  614. package/node_modules/zod/v4/locales/hr.cjs +2 -0
  615. package/node_modules/zod/v4/locales/hr.js +2 -0
  616. package/node_modules/zod/v4/locales/hu.cjs +3 -0
  617. package/node_modules/zod/v4/locales/hu.js +3 -0
  618. package/node_modules/zod/v4/locales/hy.cjs +9 -0
  619. package/node_modules/zod/v4/locales/hy.js +9 -0
  620. package/node_modules/zod/v4/locales/id.cjs +3 -0
  621. package/node_modules/zod/v4/locales/id.js +3 -0
  622. package/node_modules/zod/v4/locales/index.cjs +22 -2
  623. package/node_modules/zod/v4/locales/index.d.cts +10 -0
  624. package/node_modules/zod/v4/locales/index.d.ts +10 -0
  625. package/node_modules/zod/v4/locales/index.js +10 -0
  626. package/node_modules/zod/v4/locales/is.cjs +3 -0
  627. package/node_modules/zod/v4/locales/is.js +3 -0
  628. package/node_modules/zod/v4/locales/it.cjs +3 -0
  629. package/node_modules/zod/v4/locales/it.js +3 -0
  630. package/node_modules/zod/v4/locales/ja.cjs +3 -0
  631. package/node_modules/zod/v4/locales/ja.js +3 -0
  632. package/node_modules/zod/v4/locales/ka.cjs +3 -0
  633. package/node_modules/zod/v4/locales/ka.js +3 -0
  634. package/node_modules/zod/v4/locales/km.cjs +3 -0
  635. package/node_modules/zod/v4/locales/km.js +3 -0
  636. package/node_modules/zod/v4/locales/kn.cjs +141 -0
  637. package/node_modules/zod/v4/locales/kn.d.cts +5 -0
  638. package/node_modules/zod/v4/locales/kn.d.ts +4 -0
  639. package/node_modules/zod/v4/locales/kn.js +114 -0
  640. package/node_modules/zod/v4/locales/ko.cjs +3 -0
  641. package/node_modules/zod/v4/locales/ko.js +3 -0
  642. package/node_modules/zod/v4/locales/lt.cjs +2 -0
  643. package/node_modules/zod/v4/locales/lt.js +2 -0
  644. package/node_modules/zod/v4/locales/mk.cjs +3 -0
  645. package/node_modules/zod/v4/locales/mk.js +3 -0
  646. package/node_modules/zod/v4/locales/ms.cjs +3 -0
  647. package/node_modules/zod/v4/locales/ms.js +3 -0
  648. package/node_modules/zod/v4/locales/ne.cjs +136 -0
  649. package/node_modules/zod/v4/locales/ne.d.cts +5 -0
  650. package/node_modules/zod/v4/locales/ne.d.ts +4 -0
  651. package/node_modules/zod/v4/locales/ne.js +109 -0
  652. package/node_modules/zod/v4/locales/nl.cjs +3 -0
  653. package/node_modules/zod/v4/locales/nl.js +3 -0
  654. package/node_modules/zod/v4/locales/nn.cjs +138 -0
  655. package/node_modules/zod/v4/locales/nn.d.cts +5 -0
  656. package/node_modules/zod/v4/locales/nn.d.ts +4 -0
  657. package/node_modules/zod/v4/locales/nn.js +111 -0
  658. package/node_modules/zod/v4/locales/no.cjs +5 -2
  659. package/node_modules/zod/v4/locales/no.js +5 -2
  660. package/node_modules/zod/v4/locales/ota.cjs +3 -0
  661. package/node_modules/zod/v4/locales/ota.js +3 -0
  662. package/node_modules/zod/v4/locales/pl.cjs +3 -0
  663. package/node_modules/zod/v4/locales/pl.js +3 -0
  664. package/node_modules/zod/v4/locales/ps.cjs +3 -0
  665. package/node_modules/zod/v4/locales/ps.js +3 -0
  666. package/node_modules/zod/v4/locales/pt-BR.cjs +168 -0
  667. package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
  668. package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
  669. package/node_modules/zod/v4/locales/pt-BR.js +141 -0
  670. package/node_modules/zod/v4/locales/pt.cjs +87 -55
  671. package/node_modules/zod/v4/locales/pt.js +87 -55
  672. package/node_modules/zod/v4/locales/ro.cjs +1 -0
  673. package/node_modules/zod/v4/locales/ro.js +1 -0
  674. package/node_modules/zod/v4/locales/ru.cjs +10 -0
  675. package/node_modules/zod/v4/locales/ru.js +10 -0
  676. package/node_modules/zod/v4/locales/sk.cjs +141 -0
  677. package/node_modules/zod/v4/locales/sk.d.cts +5 -0
  678. package/node_modules/zod/v4/locales/sk.d.ts +4 -0
  679. package/node_modules/zod/v4/locales/sk.js +114 -0
  680. package/node_modules/zod/v4/locales/sl.cjs +3 -0
  681. package/node_modules/zod/v4/locales/sl.js +3 -0
  682. package/node_modules/zod/v4/locales/sv.cjs +5 -2
  683. package/node_modules/zod/v4/locales/sv.js +5 -2
  684. package/node_modules/zod/v4/locales/ta.cjs +3 -0
  685. package/node_modules/zod/v4/locales/ta.js +3 -0
  686. package/node_modules/zod/v4/locales/th.cjs +3 -0
  687. package/node_modules/zod/v4/locales/th.js +3 -0
  688. package/node_modules/zod/v4/locales/tk.cjs +132 -0
  689. package/node_modules/zod/v4/locales/tk.d.cts +5 -0
  690. package/node_modules/zod/v4/locales/tk.d.ts +4 -0
  691. package/node_modules/zod/v4/locales/tk.js +105 -0
  692. package/node_modules/zod/v4/locales/tr.cjs +3 -0
  693. package/node_modules/zod/v4/locales/tr.js +3 -0
  694. package/node_modules/zod/v4/locales/uk.cjs +3 -0
  695. package/node_modules/zod/v4/locales/uk.js +3 -0
  696. package/node_modules/zod/v4/locales/ur.cjs +3 -0
  697. package/node_modules/zod/v4/locales/ur.js +3 -0
  698. package/node_modules/zod/v4/locales/uz.cjs +1 -0
  699. package/node_modules/zod/v4/locales/uz.js +1 -0
  700. package/node_modules/zod/v4/locales/vi.cjs +3 -0
  701. package/node_modules/zod/v4/locales/vi.js +3 -0
  702. package/node_modules/zod/v4/locales/yo.cjs +3 -0
  703. package/node_modules/zod/v4/locales/yo.js +3 -0
  704. package/node_modules/zod/v4/locales/zh-CN.cjs +3 -0
  705. package/node_modules/zod/v4/locales/zh-CN.js +3 -0
  706. package/node_modules/zod/v4/locales/zh-TW.cjs +3 -0
  707. package/node_modules/zod/v4/locales/zh-TW.js +3 -0
  708. package/node_modules/zod/v4/mini/checks.cjs +2 -1
  709. package/node_modules/zod/v4/mini/checks.d.cts +1 -1
  710. package/node_modules/zod/v4/mini/checks.d.ts +1 -1
  711. package/node_modules/zod/v4/mini/checks.js +1 -1
  712. package/node_modules/zod/v4/mini/deep-partial.cjs +39 -0
  713. package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
  714. package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
  715. package/node_modules/zod/v4/mini/deep-partial.js +13 -0
  716. package/node_modules/zod/v4/mini/external.cjs +12 -1
  717. package/node_modules/zod/v4/mini/external.d.cts +5 -2
  718. package/node_modules/zod/v4/mini/external.d.ts +5 -2
  719. package/node_modules/zod/v4/mini/external.js +3 -1
  720. package/node_modules/zod/v4/mini/in-out.cjs +63 -0
  721. package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
  722. package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
  723. package/node_modules/zod/v4/mini/in-out.js +36 -0
  724. package/node_modules/zod/v4/mini/parse.cjs +3 -1
  725. package/node_modules/zod/v4/mini/parse.d.cts +1 -1
  726. package/node_modules/zod/v4/mini/parse.d.ts +1 -1
  727. package/node_modules/zod/v4/mini/parse.js +1 -1
  728. package/node_modules/zod/v4/mini/schemas.cjs +75 -47
  729. package/node_modules/zod/v4/mini/schemas.d.cts +43 -13
  730. package/node_modules/zod/v4/mini/schemas.d.ts +43 -13
  731. package/node_modules/zod/v4/mini/schemas.js +71 -45
  732. package/openclaw.plugin.json +25 -58
  733. package/package.json +10 -7
  734. package/dist/targets-BTQCYRZQ.js +0 -48
  735. package/node_modules/zod/src/v4/core/config.ts +0 -15
  736. /package/dist/{audio-preflight.runtime-BBfC9elv.js → .setup/audio-preflight.runtime-BBfC9elv.mjs} +0 -0
  737. /package/dist/{doctor-contract-w6FpMypv.js → .setup/doctor-contract-w6FpMypv.mjs} +0 -0
  738. /package/dist/{json-response-DXajw_FU.js → .setup/json-response-DXajw_FU.mjs} +0 -0
  739. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  740. /package/dist/{runtime-C5JxBWZp.js → .setup/runtime-C5JxBWZp.mjs} +0 -0
  741. /package/dist/{secret-contract-BCpDLdg9.js → .setup/secret-contract-BCpDLdg9.mjs} +0 -0
  742. /package/dist/{security-audit-shared-CK5rVR-1.js → .setup/security-audit-shared-CK5rVR-1.mjs} +0 -0
  743. /package/dist/{thread-bindings-BiL1wGqK.js → .setup/thread-bindings-BiL1wGqK.mjs} +0 -0
@@ -1,5 +1,6 @@
1
- import type { $ZodTypeDiscriminable } from "./api.js";
2
1
  import * as checks from "./checks.js";
2
+ import type { $ZodNumberFormats } from "./checks.js";
3
+ import type { $ZodBigIntFormats } from "./checks.js";
3
4
  import * as core from "./core.js";
4
5
  import { Doc } from "./doc.js";
5
6
  import type * as errors from "./errors.js";
@@ -31,16 +32,21 @@ export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> ex
31
32
  readonly skipChecks?: boolean;
32
33
  }
33
34
 
35
+ /** Gives a container cycle support: `attach` wraps its parse, and `alloc` registers the object it builds into before any child is parsed so a reference back to the same input resolves to it. */
36
+ export interface $ZodMemoizer {
37
+ attach(inst: $ZodType): void;
38
+ guard(inst: $ZodType): void;
39
+ alloc<T extends object>(inst: $ZodType, payload: ParsePayload, empty: T, ctx: ParseContextInternal): T;
40
+ }
41
+
34
42
  export interface ParsePayload<T = unknown> {
35
43
  value: T;
36
44
  issues: errors.$ZodRawIssue[];
37
45
  /** A way to mark a whole payload as aborted. Used in codecs/pipes. */
38
46
  aborted?: boolean;
39
- /** @internal Marks a value as a fallback that an outer wrapper (e.g.
40
- * $ZodOptional) may override with its own interpretation when input was
41
- * undefined. Set by $ZodCatch when catchValue substitutes and by every
42
- * $ZodTransform invocation. */
43
- fallback?: boolean | undefined;
47
+ /** @internal Set when the value came from a repeat visit to a node still being
48
+ * parsed. Its checks run on the node itself, against the finished value. */
49
+ memo?: boolean | undefined;
44
50
  }
45
51
 
46
52
  export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
@@ -120,8 +126,13 @@ export interface _$ZodTypeInternals {
120
126
  * @default Required
121
127
  */
122
128
 
123
- /** @internal */
124
- optin?: "optional" | undefined;
129
+ /** @internal Three rungs, each strictly stronger than the last:
130
+ * undefined — required; the container may not omit this slot
131
+ * "optional" — the container may omit it; nothing is supplied in its place
132
+ * "defaulted" — the container may omit it AND this schema substitutes a value
133
+ * Consumers asking "may the slot be absent?" test `!== undefined`.
134
+ * $ZodOptional asks the stronger question and tests `=== "defaulted"`. */
135
+ optin?: "optional" | "defaulted" | undefined;
125
136
  /** @internal */
126
137
  optout?: "optional" | undefined;
127
138
 
@@ -187,137 +198,156 @@ export interface $ZodType<
187
198
  export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals>
188
199
  extends $ZodType<T["output"], T["input"], T> {}
189
200
 
190
- export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
191
- inst ??= {} as any;
192
-
193
- inst._zod.def = def; // set _def property
194
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
195
- inst._zod.version = version;
196
-
197
- const checks = [...(inst._zod.def.checks ?? [])];
198
-
199
- // if inst is itself a checks.$ZodCheck, run it as a check
200
- if (inst._zod.traits.has("$ZodCheck")) {
201
- checks.unshift(inst as any);
202
- }
203
-
204
- for (const ch of checks) {
205
- for (const fn of ch._zod.onattach) {
206
- fn(inst);
201
+ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor<$ZodType>(
202
+ "$ZodType",
203
+ (inst, def) => {
204
+ inst ??= {} as any;
205
+
206
+ inst._zod.def = def; // set _def property
207
+ inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
208
+ inst._zod.version = version;
209
+
210
+ const defChecks = inst._zod.def.checks;
211
+ // if inst is itself a checks.$ZodCheck, run it as a check
212
+ const checks: checks.$ZodCheck<never>[] = inst._zod.traits.has("$ZodCheck")
213
+ ? [inst as any, ...(defChecks ?? [])]
214
+ : defChecks?.length
215
+ ? [...defChecks]
216
+ : [];
217
+
218
+ for (const ch of checks) {
219
+ for (const fn of ch._zod.onattach) {
220
+ fn(inst);
221
+ }
207
222
  }
208
- }
209
223
 
210
- if (checks.length === 0) {
211
- // deferred initializer
212
- // inst._zod.parse is not yet defined
213
- inst._zod.deferred ??= [];
214
- inst._zod.deferred?.push(() => {
215
- inst._zod.run = inst._zod.parse;
216
- });
217
- } else {
218
- const runChecks = (
219
- payload: ParsePayload,
220
- checks: checks.$ZodCheck<never>[],
221
- ctx?: ParseContextInternal | undefined
222
- ): util.MaybeAsync<ParsePayload> => {
223
- let isAborted = util.aborted(payload);
224
-
225
- let asyncResult!: Promise<unknown> | undefined;
226
- for (const ch of checks) {
227
- if (ch._zod.def.when) {
228
- if (util.explicitlyAborted(payload)) continue;
229
- const shouldRun = ch._zod.def.when(payload);
230
- if (!shouldRun) continue;
231
- } else if (isAborted) {
232
- continue;
233
- }
234
- const currLen = payload.issues.length;
235
- const _ = ch._zod.check(payload as any) as any as ParsePayload;
224
+ if (checks.length === 0) {
225
+ // deferred initializer inst._zod.parse is not yet defined
226
+ inst._zod.deferred ??= [];
227
+ inst._zod.deferred?.push(() => {
228
+ inst._zod.run = inst._zod.parse;
229
+ });
230
+ } else {
231
+ const runChecks = (
232
+ payload: ParsePayload,
233
+ checks: checks.$ZodCheck<never>[],
234
+ ctx?: ParseContextInternal | undefined
235
+ ): util.MaybeAsync<ParsePayload> => {
236
+ if (payload.memo) return payload;
237
+
238
+ let isAborted = util.aborted(payload);
239
+
240
+ let asyncResult!: Promise<unknown> | undefined;
241
+ for (const ch of checks) {
242
+ if (ch._zod.def.when) {
243
+ if (util.explicitlyAborted(payload)) continue;
244
+ const shouldRun = ch._zod.def.when(payload);
245
+ if (!shouldRun) continue;
246
+ } else if (isAborted) {
247
+ continue;
248
+ }
249
+ const currLen = payload.issues.length;
250
+ const _ = ch._zod.check(payload as any) as any as ParsePayload;
236
251
 
237
- if (_ instanceof Promise && ctx?.async === false) {
238
- throw new core.$ZodAsyncError();
239
- }
240
- if (asyncResult || _ instanceof Promise) {
241
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
242
- await _;
252
+ if (_ instanceof Promise && ctx?.async === false) {
253
+ throw new core.$ZodAsyncError();
254
+ }
255
+ if (asyncResult || _ instanceof Promise) {
256
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
257
+ await _;
258
+ const nextLen = payload.issues.length;
259
+ if (nextLen === currLen) return;
260
+ util.attachSchema(payload.issues, currLen, inst);
261
+ if (!isAborted) isAborted = util.aborted(payload, currLen);
262
+ });
263
+ } else {
243
264
  const nextLen = payload.issues.length;
244
- if (nextLen === currLen) return;
265
+ if (nextLen === currLen) continue;
266
+ util.attachSchema(payload.issues, currLen, inst);
245
267
  if (!isAborted) isAborted = util.aborted(payload, currLen);
268
+ }
269
+ }
270
+
271
+ if (asyncResult) {
272
+ return asyncResult.then(() => {
273
+ return payload;
246
274
  });
247
- } else {
248
- const nextLen = payload.issues.length;
249
- if (nextLen === currLen) continue;
250
- if (!isAborted) isAborted = util.aborted(payload, currLen);
251
275
  }
252
- }
276
+ return payload;
277
+ };
253
278
 
254
- if (asyncResult) {
255
- return asyncResult.then(() => {
256
- return payload;
257
- });
258
- }
259
- return payload;
260
- };
279
+ const handleCanaryResult = (canary: ParsePayload, payload: ParsePayload, ctx: ParseContextInternal) => {
280
+ // abort if the canary is aborted
281
+ if (util.aborted(canary)) {
282
+ canary.aborted = true;
283
+ return canary;
284
+ }
261
285
 
262
- const handleCanaryResult = (canary: ParsePayload, payload: ParsePayload, ctx: ParseContextInternal) => {
263
- // abort if the canary is aborted
264
- if (util.aborted(canary)) {
265
- canary.aborted = true;
266
- return canary;
267
- }
286
+ // run checks first, then
287
+ const checkResult = runChecks(payload, checks, ctx);
288
+ if (checkResult instanceof Promise) {
289
+ if (ctx.async === false) throw new core.$ZodAsyncError();
290
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
291
+ }
292
+ return inst._zod.parse(checkResult, ctx);
293
+ };
268
294
 
269
- // run checks first, then
270
- const checkResult = runChecks(payload, checks, ctx);
271
- if (checkResult instanceof Promise) {
272
- if (ctx.async === false) throw new core.$ZodAsyncError();
273
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
274
- }
275
- return inst._zod.parse(checkResult, ctx);
276
- };
295
+ inst._zod.run = (payload, ctx) => {
296
+ if (ctx.skipChecks) {
297
+ return inst._zod.parse(payload, ctx);
298
+ }
299
+ if (ctx.direction === "backward") {
300
+ // run canary initial pass (no checks)
301
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
277
302
 
278
- inst._zod.run = (payload, ctx) => {
279
- if (ctx.skipChecks) {
280
- return inst._zod.parse(payload, ctx);
281
- }
282
- if (ctx.direction === "backward") {
283
- // run canary
284
- // initial pass (no checks)
285
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
303
+ if (canary instanceof Promise) {
304
+ return canary.then((canary) => {
305
+ return handleCanaryResult(canary, payload, ctx);
306
+ });
307
+ }
286
308
 
287
- if (canary instanceof Promise) {
288
- return canary.then((canary) => {
289
- return handleCanaryResult(canary, payload, ctx);
290
- });
309
+ return handleCanaryResult(canary, payload, ctx);
291
310
  }
292
311
 
293
- return handleCanaryResult(canary, payload, ctx);
294
- }
295
-
296
- // forward
297
- const result = inst._zod.parse(payload, ctx);
298
- if (result instanceof Promise) {
299
- if (ctx.async === false) throw new core.$ZodAsyncError();
300
- return result.then((result) => runChecks(result, checks, ctx));
301
- }
312
+ // forward
313
+ const result = inst._zod.parse(payload, ctx);
314
+ if (result instanceof Promise) {
315
+ if (ctx.async === false) throw new core.$ZodAsyncError();
316
+ return result.then((result) => runChecks(result, checks, ctx));
317
+ }
302
318
 
303
- return runChecks(result, checks, ctx);
304
- };
319
+ return runChecks(result, checks, ctx);
320
+ };
321
+ }
322
+ },
323
+ {
324
+ // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
325
+ get "~standard"(): StandardSchemaV1.Props<any, any> {
326
+ return util.hide(this, "~standard", standardProps(this));
327
+ },
328
+ set "~standard"(value: StandardSchemaV1.Props<any, any>) {
329
+ util.own(this, "~standard", value);
330
+ },
305
331
  }
332
+ );
306
333
 
307
- // Lazy initialize ~standard to avoid creating objects for every schema
308
- util.defineLazy(inst, "~standard", () => ({
334
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
335
+ const toStandardResult = (r: util.SafeParseResult<unknown>) =>
336
+ r.success ? { value: r.data } : { issues: r.error?.issues };
337
+
338
+ export function standardProps(inst: $ZodType): StandardSchemaV1.Props<any, any> {
339
+ return {
309
340
  validate: (value: unknown) => {
310
341
  try {
311
- const r = safeParse(inst, value);
312
- return r.success ? { value: r.data } : { issues: r.error?.issues };
342
+ return toStandardResult(safeParse(inst, value));
313
343
  } catch (_) {
314
- return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
344
+ return safeParseAsync(inst, value).then(toStandardResult);
315
345
  }
316
346
  },
317
347
  vendor: "zod",
318
348
  version: 1 as const,
319
- }));
320
- });
349
+ };
350
+ }
321
351
 
322
352
  export { clone } from "./util.js";
323
353
 
@@ -347,6 +377,8 @@ export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, In
347
377
  patterns: Set<RegExp>;
348
378
  format: string;
349
379
  contentEncoding: string;
380
+ /** the pattern admits strings its `format` keyword forbids, so `toJSONSchema` must not emit it */
381
+ laxFormat: boolean;
350
382
  }>;
351
383
  }
352
384
 
@@ -477,70 +509,103 @@ export interface $ZodURL extends $ZodType {
477
509
  _zod: $ZodURLInternals;
478
510
  }
479
511
 
512
+ /** The `://` guard rejected the input before the URL constructor saw it. */
513
+ export const URL_BAD_FORMAT = 1;
514
+ /** The URL constructor rejected the input. */
515
+ export const URL_UNPARSEABLE = 2;
516
+
517
+ /** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
518
+ export function parseURLObject(
519
+ trimmed: string,
520
+ def: Pick<$ZodURLDef, "protocol" | "normalize">
521
+ ): URL | typeof URL_BAD_FORMAT | typeof URL_UNPARSEABLE {
522
+ // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
523
+ if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
524
+ return URL_BAD_FORMAT;
525
+ }
526
+
527
+ try {
528
+ // @ts-ignore
529
+ return new URL(trimmed);
530
+ } catch {
531
+ return URL_UNPARSEABLE;
532
+ }
533
+ }
534
+
535
+ const asciiTabOrNewline = /[\t\n\r]/g;
536
+
537
+ /** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
538
+ export function stripTabAndNewline(value: string): string {
539
+ return value.replace(asciiTabOrNewline, "");
540
+ }
541
+
542
+ export function urlHostnameOk(url: URL, hostname: RegExp): boolean {
543
+ hostname.lastIndex = 0;
544
+ return hostname.test(url.hostname);
545
+ }
546
+
547
+ export function urlProtocolOk(url: URL, protocol: RegExp): boolean {
548
+ protocol.lastIndex = 0;
549
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
550
+ }
551
+
480
552
  export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
481
553
  $ZodStringFormat.init(inst, def);
482
554
  inst._zod.check = (payload) => {
483
555
  try {
484
556
  // Trim whitespace from input
485
557
  const trimmed = payload.value.trim();
558
+ const url = parseURLObject(trimmed, def);
486
559
 
487
- // When normalize is off, require :// for http/https URLs
488
- // This prevents strings like "http:example.com" or "https:/path" from being silently accepted
489
- if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
490
- if (!/^https?:\/\//i.test(trimmed)) {
491
- payload.issues.push({
492
- code: "invalid_format",
493
- format: "url",
494
- note: "Invalid URL format",
495
- input: payload.value,
496
- inst,
497
- continue: !def.abort,
498
- });
499
- return;
500
- }
560
+ if (url === URL_BAD_FORMAT) {
561
+ payload.issues.push({
562
+ code: "invalid_format",
563
+ format: "url",
564
+ note: "Invalid URL format",
565
+ input: payload.value,
566
+ inst,
567
+ continue: !def.abort,
568
+ });
569
+ return;
501
570
  }
502
571
 
503
- // @ts-ignore
504
- const url = new URL(trimmed);
572
+ if (url === URL_UNPARSEABLE) {
573
+ payload.issues.push({
574
+ code: "invalid_format",
575
+ format: "url",
576
+ input: payload.value,
577
+ inst,
578
+ continue: !def.abort,
579
+ });
580
+ return;
581
+ }
505
582
 
506
- if (def.hostname) {
507
- def.hostname.lastIndex = 0;
508
- if (!def.hostname.test(url.hostname)) {
509
- payload.issues.push({
510
- code: "invalid_format",
511
- format: "url",
512
- note: "Invalid hostname",
513
- pattern: def.hostname.source,
514
- input: payload.value,
515
- inst,
516
- continue: !def.abort,
517
- });
518
- }
583
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) {
584
+ payload.issues.push({
585
+ code: "invalid_format",
586
+ format: "url",
587
+ note: "Invalid hostname",
588
+ pattern: def.hostname.source,
589
+ input: payload.value,
590
+ inst,
591
+ continue: !def.abort,
592
+ });
519
593
  }
520
594
 
521
- if (def.protocol) {
522
- def.protocol.lastIndex = 0;
523
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
524
- payload.issues.push({
525
- code: "invalid_format",
526
- format: "url",
527
- note: "Invalid protocol",
528
- pattern: def.protocol.source,
529
- input: payload.value,
530
- inst,
531
- continue: !def.abort,
532
- });
533
- }
595
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) {
596
+ payload.issues.push({
597
+ code: "invalid_format",
598
+ format: "url",
599
+ note: "Invalid protocol",
600
+ pattern: def.protocol.source,
601
+ input: payload.value,
602
+ inst,
603
+ continue: !def.abort,
604
+ });
534
605
  }
535
606
 
536
607
  // Set the output value based on normalize flag
537
- if (def.normalize) {
538
- // Use normalized URL
539
- payload.value = url.href;
540
- } else {
541
- // Preserve the original input (trimmed)
542
- payload.value = trimmed;
543
- }
608
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
544
609
 
545
610
  return;
546
611
  } catch (_) {
@@ -574,8 +639,12 @@ export const $ZodEmoji: core.$constructor<$ZodEmoji> = /*@__PURE__*/ core.$const
574
639
 
575
640
  ////////////////////////////// ZodNanoID //////////////////////////////
576
641
 
577
- export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {}
578
- export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {}
642
+ export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
643
+ length?: number | undefined;
644
+ }
645
+ export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
646
+ def: $ZodNanoIDDef;
647
+ }
579
648
 
580
649
  export interface $ZodNanoID extends $ZodType {
581
650
  _zod: $ZodNanoIDInternals;
@@ -584,7 +653,9 @@ export interface $ZodNanoID extends $ZodType {
584
653
  export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$constructor(
585
654
  "$ZodNanoID",
586
655
  (inst, def): void => {
587
- def.pattern ??= regexes.nanoid;
656
+ if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
657
+ throw new Error(`Invalid nanoid length: ${def.length}`);
658
+ def.pattern ??= def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length);
588
659
  $ZodStringFormat.init(inst, def);
589
660
  }
590
661
  );
@@ -706,6 +777,14 @@ export const $ZodISODateTime: core.$constructor<$ZodISODateTime> = /*@__PURE__*/
706
777
  (inst, def): void => {
707
778
  def.pattern ??= regexes.datetime(def);
708
779
  $ZodStringFormat.init(inst, def);
780
+
781
+ // these two drop the offset or seconds `date-time` requires — on the bag not the def, since `z.string().check(...)` lands the format on a different schema
782
+ if (def.local || def.precision === -1) {
783
+ inst._zod.bag.laxFormat = true;
784
+ inst._zod.onattach.push((s) => {
785
+ (s._zod.bag as $ZodStringInternals<unknown>["bag"]).laxFormat = true;
786
+ });
787
+ }
709
788
  }
710
789
  );
711
790
 
@@ -800,6 +879,20 @@ export interface $ZodIPv6 extends $ZodType {
800
879
  _zod: $ZodIPv6Internals;
801
880
  }
802
881
 
882
+ /** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
883
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
884
+
885
+ export function isValidIPv6(value: string): boolean {
886
+ if (!ipv6Alphabet.test(value)) return false;
887
+ try {
888
+ // @ts-ignore
889
+ new URL(`http://[${value}]`);
890
+ return true;
891
+ } catch {
892
+ return false;
893
+ }
894
+ }
895
+
803
896
  export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def): void => {
804
897
  def.pattern ??= regexes.ipv6;
805
898
  $ZodStringFormat.init(inst, def);
@@ -807,11 +900,7 @@ export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constru
807
900
  inst._zod.bag.format = `ipv6`;
808
901
 
809
902
  inst._zod.check = (payload) => {
810
- try {
811
- // @ts-ignore
812
- new URL(`http://[${payload.value}]`);
813
- // return;
814
- } catch {
903
+ if (!isValidIPv6(payload.value)) {
815
904
  payload.issues.push({
816
905
  code: "invalid_format",
817
906
  format: "ipv6",
@@ -879,6 +968,17 @@ export interface $ZodCIDRv6 extends $ZodType {
879
968
  _zod: $ZodCIDRv6Internals;
880
969
  }
881
970
 
971
+ export function isValidCIDRv6(value: string): boolean {
972
+ const parts = value.split("/");
973
+ if (parts.length !== 2) return false;
974
+ const [address, prefix] = parts;
975
+ if (!prefix) return false;
976
+ const prefixNum = Number(prefix);
977
+ if (`${prefixNum}` !== prefix) return false;
978
+ if (prefixNum < 0 || prefixNum > 128) return false;
979
+ return isValidIPv6(address);
980
+ }
981
+
882
982
  export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$constructor(
883
983
  "$ZodCIDRv6",
884
984
  (inst, def): void => {
@@ -886,17 +986,7 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
886
986
  $ZodStringFormat.init(inst, def);
887
987
 
888
988
  inst._zod.check = (payload) => {
889
- const parts = payload.value.split("/");
890
- try {
891
- if (parts.length !== 2) throw new Error();
892
- const [address, prefix] = parts;
893
- if (!prefix) throw new Error();
894
- const prefixNum = Number(prefix);
895
- if (`${prefixNum}` !== prefix) throw new Error();
896
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
897
- // @ts-ignore
898
- new URL(`http://[${address}]`);
899
- } catch {
989
+ if (!isValidCIDRv6(payload.value)) {
900
990
  payload.issues.push({
901
991
  code: "invalid_format",
902
992
  format: "cidrv6",
@@ -1004,6 +1094,56 @@ export const $ZodE164: core.$constructor<$ZodE164> = /*@__PURE__*/ core.$constru
1004
1094
  $ZodStringFormat.init(inst, def);
1005
1095
  });
1006
1096
 
1097
+ ////////////////////////////// ZodCreditCard //////////////////////////////
1098
+
1099
+ const CC_SANITIZE = /[- ]/g;
1100
+
1101
+ /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
1102
+ function isLuhnAlgo(digits: string): boolean {
1103
+ let length = digits.length;
1104
+ let bit = 1;
1105
+ let sum = 0;
1106
+ while (length) {
1107
+ const value = +digits[--length]!;
1108
+ bit ^= 1;
1109
+ sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value]! : value;
1110
+ }
1111
+ return sum % 10 === 0;
1112
+ }
1113
+
1114
+ export function isValidCreditCard(input: string): boolean {
1115
+ if (!regexes.creditCard.test(input)) return false;
1116
+ return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
1117
+ }
1118
+
1119
+ export interface $ZodCreditCardDef extends $ZodStringFormatDef<"credit_card"> {}
1120
+ export interface $ZodCreditCardInternals extends $ZodStringFormatInternals<"credit_card"> {
1121
+ def: $ZodCreditCardDef;
1122
+ }
1123
+
1124
+ export interface $ZodCreditCard extends $ZodType {
1125
+ _zod: $ZodCreditCardInternals;
1126
+ }
1127
+
1128
+ export const $ZodCreditCard: core.$constructor<$ZodCreditCard> = /*@__PURE__*/ core.$constructor(
1129
+ "$ZodCreditCard",
1130
+ (inst, def): void => {
1131
+ // Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
1132
+ def.pattern ??= regexes.creditCard;
1133
+ $ZodStringFormat.init(inst, def);
1134
+ inst._zod.check = (payload) => {
1135
+ if (isValidCreditCard(payload.value)) return;
1136
+ payload.issues.push({
1137
+ code: "invalid_format",
1138
+ format: "credit_card",
1139
+ input: payload.value,
1140
+ inst,
1141
+ continue: !def.abort,
1142
+ });
1143
+ };
1144
+ }
1145
+ );
1146
+
1007
1147
  ////////////////////////////// ZodJWT //////////////////////////////
1008
1148
 
1009
1149
  export function isValidJWT(token: string, algorithm: util.JWTAlgorithm | null = null): boolean {
@@ -1136,7 +1276,7 @@ export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$con
1136
1276
  ? Number.isNaN(input)
1137
1277
  ? "NaN"
1138
1278
  : !Number.isFinite(input)
1139
- ? "Infinity"
1279
+ ? String(input)
1140
1280
  : undefined
1141
1281
  : undefined;
1142
1282
 
@@ -1155,15 +1295,19 @@ export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$con
1155
1295
  ///////////////////////////////////////////////
1156
1296
  ////////// ZodNumberFormat //////////
1157
1297
  ///////////////////////////////////////////////
1158
- export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {}
1159
-
1160
- export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
1161
- def: $ZodNumberFormatDef;
1298
+ export interface $ZodNumberFormatDef<Format extends $ZodNumberFormats = $ZodNumberFormats>
1299
+ extends $ZodNumberDef,
1300
+ checks.$ZodCheckNumberFormatDef<Format> {}
1301
+
1302
+ export interface $ZodNumberFormatInternals<Format extends $ZodNumberFormats = $ZodNumberFormats>
1303
+ extends $ZodNumberInternals<number>,
1304
+ checks.$ZodCheckNumberFormatInternals<Format> {
1305
+ def: $ZodNumberFormatDef<Format>;
1162
1306
  isst: errors.$ZodIssueInvalidType;
1163
1307
  }
1164
1308
 
1165
- export interface $ZodNumberFormat extends $ZodType {
1166
- _zod: $ZodNumberFormatInternals;
1309
+ export interface $ZodNumberFormat<Format extends $ZodNumberFormats = $ZodNumberFormats> extends $ZodType {
1310
+ _zod: $ZodNumberFormatInternals<Format>;
1167
1311
  }
1168
1312
 
1169
1313
  export const $ZodNumberFormat: core.$constructor<$ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
@@ -1278,16 +1422,20 @@ export const $ZodBigInt: core.$constructor<$ZodBigInt> = /*@__PURE__*/ core.$con
1278
1422
  ///////////////////////////////////////////////
1279
1423
  ////////// ZodBigIntFormat //////////
1280
1424
  ///////////////////////////////////////////////
1281
- export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
1425
+ export interface $ZodBigIntFormatDef<Format extends $ZodBigIntFormats = $ZodBigIntFormats>
1426
+ extends $ZodBigIntDef,
1427
+ checks.$ZodCheckBigIntFormatDef<Format> {
1282
1428
  check: "bigint_format";
1283
1429
  }
1284
1430
 
1285
- export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
1286
- def: $ZodBigIntFormatDef;
1431
+ export interface $ZodBigIntFormatInternals<Format extends $ZodBigIntFormats = $ZodBigIntFormats>
1432
+ extends $ZodBigIntInternals<bigint>,
1433
+ checks.$ZodCheckBigIntFormatInternals<Format> {
1434
+ def: $ZodBigIntFormatDef<Format>;
1287
1435
  }
1288
1436
 
1289
- export interface $ZodBigIntFormat extends $ZodType {
1290
- _zod: $ZodBigIntFormatInternals;
1437
+ export interface $ZodBigIntFormat<Format extends $ZodBigIntFormats = $ZodBigIntFormats> extends $ZodType {
1438
+ _zod: $ZodBigIntFormatInternals<Format>;
1291
1439
  }
1292
1440
 
1293
1441
  export const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
@@ -1637,6 +1785,9 @@ function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>
1637
1785
  export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
1638
1786
  $ZodType.init(inst, def);
1639
1787
 
1788
+ const memo = core.globalConfig.memoizer;
1789
+ memo?.attach(inst);
1790
+
1640
1791
  inst._zod.parse = (payload, ctx) => {
1641
1792
  const input = payload.value;
1642
1793
 
@@ -1651,7 +1802,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
1651
1802
  return payload;
1652
1803
  }
1653
1804
 
1654
- payload.value = Array(input.length);
1805
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1655
1806
  const proms: Promise<any>[] = [];
1656
1807
  for (let i = 0; i < input.length; i++) {
1657
1808
  const item = input[i];
@@ -1687,7 +1838,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
1687
1838
  //////////////////////////////////////////
1688
1839
 
1689
1840
  type OptionalOutSchema = { _zod: { optout: "optional" } };
1690
- type OptionalInSchema = { _zod: { optin: "optional" } };
1841
+ type OptionalInSchema = { _zod: { optin: "optional" | "defaulted" } };
1691
1842
 
1692
1843
  export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1693
1844
  ? util.IsAny<T[keyof T]> extends true
@@ -1752,19 +1903,24 @@ function handlePropertyResult(
1752
1903
  final: ParsePayload,
1753
1904
  key: PropertyKey,
1754
1905
  input: any,
1755
- isOptionalIn: boolean,
1756
- isOptionalOut: boolean
1906
+ optin: "optional" | "defaulted" | undefined,
1907
+ optout: "optional" | undefined
1757
1908
  ) {
1758
1909
  const isPresent = key in input;
1910
+ const isOptionalOut = optout === "optional";
1911
+ // The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
1912
+ if (!isPresent && isOptionalOut && optin === "optional") {
1913
+ return;
1914
+ }
1759
1915
  if (result.issues.length) {
1760
1916
  // For optional-in/out schemas, ignore errors on absent keys.
1761
- if (isOptionalIn && isOptionalOut && !isPresent) {
1917
+ if (optin !== undefined && isOptionalOut && !isPresent) {
1762
1918
  return;
1763
1919
  }
1764
1920
  final.issues.push(...util.prefixIssues(key, result.issues));
1765
1921
  }
1766
1922
 
1767
- if (!isPresent && !isOptionalIn) {
1923
+ if (!isPresent && optin === undefined) {
1768
1924
  if (!result.issues.length) {
1769
1925
  final.issues.push({
1770
1926
  code: "invalid_type",
@@ -1835,18 +1991,27 @@ export interface $ZodObject<
1835
1991
  out Params extends $ZodObjectConfig = $ZodObjectConfig,
1836
1992
  > extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {}
1837
1993
 
1994
+ // one shared instance; a fresh [] per schema cost 56 bytes retained
1995
+ const NO_SYMBOL_KEYS: symbol[] = [];
1996
+
1838
1997
  function normalizeDef(def: $ZodObjectDef) {
1839
1998
  const keys = Object.keys(def.shape);
1840
- for (const k of keys) {
1841
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1842
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1999
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
2000
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
2001
+ // aliases `keys` when there are no symbols, so a string-only shape keeps one array
2002
+ const allKeys: (string | symbol)[] = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
2003
+ for (const k of allKeys) {
2004
+ if (!(def.shape as any)?.[k]?._zod?.traits?.has("$ZodType")) {
2005
+ throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
1843
2006
  }
1844
2007
  }
1845
2008
  const okeys = util.optionalKeys(def.shape);
1846
2009
 
1847
2010
  return {
1848
2011
  ...def,
1849
- keys,
2012
+ allKeys,
2013
+ symbolKeys,
2014
+ // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
1850
2015
  keySet: new Set(keys),
1851
2016
  numKeys: keys.length,
1852
2017
  optionalKeys: new Set(okeys),
@@ -1865,13 +2030,16 @@ function handleCatchall(
1865
2030
  const keySet = def.keySet;
1866
2031
  const _catchall = def.catchall!._zod;
1867
2032
  const t = _catchall.def.type;
1868
- const isOptionalIn = _catchall.optin === "optional";
1869
- const isOptionalOut = _catchall.optout === "optional";
2033
+ const optin = _catchall.optin;
2034
+ const optout = _catchall.optout;
1870
2035
  for (const key in input) {
1871
- // skip __proto__ so it can't replace the result prototype via the
1872
- // assignment setter on the plain {} we build into
1873
- if (key === "__proto__") continue;
2036
+ // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
1874
2037
  if (keySet.has(key)) continue;
2038
+ // Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
2039
+ if (key === "__proto__") {
2040
+ if (t === "never") unrecognized.push(key);
2041
+ continue;
2042
+ }
1875
2043
  if (t === "never") {
1876
2044
  unrecognized.push(key);
1877
2045
  continue;
@@ -1879,9 +2047,9 @@ function handleCatchall(
1879
2047
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1880
2048
 
1881
2049
  if (r instanceof Promise) {
1882
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2050
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1883
2051
  } else {
1884
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2052
+ handlePropertyResult(r, payload, key, input, optin, optout);
1885
2053
  }
1886
2054
  }
1887
2055
 
@@ -1891,6 +2059,8 @@ function handleCatchall(
1891
2059
  keys: unrecognized,
1892
2060
  input,
1893
2061
  inst,
2062
+ // Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
2063
+ continue: true,
1894
2064
  });
1895
2065
  }
1896
2066
 
@@ -1900,6 +2070,9 @@ function handleCatchall(
1900
2070
  });
1901
2071
  }
1902
2072
 
2073
+ // Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it. Keyed by def, so a def rebuilt by a builder is simply absent rather than inheriting the source's. Read its keys with `Object.keys`, which does not invoke them — that is what lets a discriminated union check its discriminator without resolving an option whose getters reference the union being constructed.
2074
+ const propShapes = new WeakMap<object, Record<string, unknown>>();
2075
+
1903
2076
  export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
1904
2077
  // requires cast because technically $ZodObject doesn't extend
1905
2078
  $ZodType.init(inst, def);
@@ -1907,12 +2080,14 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
1907
2080
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
1908
2081
  if (!desc?.get) {
1909
2082
  const sh = def.shape;
2083
+ propShapes.set(def, sh);
1910
2084
  Object.defineProperty(def, "shape", {
1911
2085
  get: () => {
1912
2086
  const newSh = { ...sh };
1913
2087
  Object.defineProperty(def, "shape", {
1914
2088
  value: newSh,
1915
2089
  });
2090
+ propShapes.set(def, newSh);
1916
2091
 
1917
2092
  return newSh;
1918
2093
  },
@@ -1921,14 +2096,18 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
1921
2096
 
1922
2097
  const _normalized = util.cached(() => normalizeDef(def));
1923
2098
 
1924
- util.defineLazy(inst._zod, "propValues", () => {
1925
- const shape = def.shape;
2099
+ util.defineLazyInternal(inst, "propValues", (zod) => {
2100
+ const shape = zod.def.shape;
1926
2101
  const propValues: util.PropValues = {};
1927
2102
  for (const key in shape) {
1928
2103
  const field = shape[key]!._zod;
1929
2104
  if (field.values) {
1930
- propValues[key] ??= new Set();
2105
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
2106
+ util.assignProp(propValues, key, new Set());
2107
+ }
1931
2108
  for (const v of field.values) propValues[key].add(v);
2109
+ // An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
2110
+ if (field.optin !== undefined) propValues[key].add(undefined);
1932
2111
  }
1933
2112
  }
1934
2113
  return propValues;
@@ -1938,6 +2117,8 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
1938
2117
  const catchall = def.catchall;
1939
2118
 
1940
2119
  let value!: typeof _normalized.value;
2120
+ const memo = core.globalConfig.memoizer;
2121
+ memo?.attach(inst);
1941
2122
 
1942
2123
  inst._zod.parse = (payload, ctx) => {
1943
2124
  value ??= _normalized.value;
@@ -1952,21 +2133,22 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
1952
2133
  return payload;
1953
2134
  }
1954
2135
 
1955
- payload.value = {};
2136
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1956
2137
 
1957
2138
  const proms: Promise<any>[] = [];
1958
2139
  const shape = value.shape;
1959
2140
 
1960
- for (const key of value.keys) {
1961
- const el = shape[key]!;
1962
- const isOptionalIn = el._zod.optin === "optional";
1963
- const isOptionalOut = el._zod.optout === "optional";
2141
+ for (const key of value.allKeys) {
2142
+ if (key === "__proto__") continue;
2143
+ const el = (shape as any)[key]!;
2144
+ const optin = el._zod.optin;
2145
+ const optout = el._zod.optout;
1964
2146
 
1965
2147
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1966
2148
  if (r instanceof Promise) {
1967
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2149
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1968
2150
  } else {
1969
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2151
+ handlePropertyResult(r, payload, key, input, optin, optout);
1970
2152
  }
1971
2153
  }
1972
2154
 
@@ -1987,63 +2169,65 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
1987
2169
  const superParse = inst._zod.parse;
1988
2170
  const _normalized = util.cached(() => normalizeDef(def));
1989
2171
 
2172
+ const memo = core.globalConfig.memoizer;
2173
+
1990
2174
  const generateFastpass = (shape: any) => {
1991
- const doc = new Doc(["shape", "payload", "ctx"]);
1992
2175
  const normalized = _normalized.value;
2176
+ const syms = normalized.symbolKeys;
2177
+ // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
2178
+ const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
1993
2179
 
1994
- const parseStr = (key: string) => {
1995
- const k = util.esc(key);
1996
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1997
- };
2180
+ const parseStr = (k: string) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2181
+
2182
+ // Prefixes in place, like util.prefixIssues does for every interpreted path.
2183
+ const prefixStr = (id: string, k: string) => `
2184
+ for (let i = 0; i < ${id}.issues.length; i++) {
2185
+ const iss = ${id}.issues[i];
2186
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2187
+ payload.issues.push(iss);
2188
+ }`;
1998
2189
 
1999
2190
  doc.write(`const input = payload.value;`);
2000
2191
 
2001
2192
  const ids: any = Object.create(null);
2002
2193
  let counter = 0;
2003
- for (const key of normalized.keys) {
2194
+ for (const key of normalized.allKeys) {
2004
2195
  ids[key] = `key_${counter++}`;
2005
2196
  }
2006
2197
 
2007
2198
  // A: preserve key order {
2008
- doc.write(`const newResult = {};`);
2009
- for (const key of normalized.keys) {
2199
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2200
+ for (const key of normalized.allKeys) {
2201
+ if (key === "__proto__") continue;
2010
2202
  const id = ids[key];
2011
- const k = util.esc(key);
2203
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
2204
+ const isPresent = `${k} in input`;
2012
2205
  const schema = shape[key];
2013
- const isOptionalIn = schema?._zod?.optin === "optional";
2206
+ const optin = schema?._zod?.optin;
2207
+ const isOptionalIn = optin !== undefined;
2014
2208
  const isOptionalOut = schema?._zod?.optout === "optional";
2015
2209
 
2016
- doc.write(`const ${id} = ${parseStr(key)};`);
2210
+ doc.write(`const ${id} = ${parseStr(k)};`);
2017
2211
 
2018
2212
  if (isOptionalIn && isOptionalOut) {
2019
- // For optional-in/out schemas, ignore errors on absent keys
2213
+ // For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
2214
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2020
2215
  doc.write(`
2021
- if (${id}.issues.length) {
2022
- if (${k} in input) {
2023
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2024
- ...iss,
2025
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2026
- })));
2216
+ const ${id}_present = ${isPresent};
2217
+ if (!${id}.issues.length || ${id}_present) {
2218
+ if (${id}.issues.length) {${prefixStr(id, k)}
2027
2219
  }
2028
- }
2029
-
2030
- if (${id}.value === undefined) {
2031
- if (${k} in input) {
2032
- newResult[${k}] = undefined;
2220
+
2221
+ if (${assign}) {
2222
+ newResult[${k}] = ${id}.value;
2033
2223
  }
2034
- } else {
2035
- newResult[${k}] = ${id}.value;
2036
2224
  }
2037
-
2225
+
2038
2226
  `);
2039
2227
  } else if (!isOptionalIn) {
2040
2228
  doc.write(`
2041
- const ${id}_present = ${k} in input;
2042
- if (${id}.issues.length) {
2043
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2044
- ...iss,
2045
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2046
- })));
2229
+ const ${id}_present = ${isPresent};
2230
+ if (${id}.issues.length) {${prefixStr(id, k)}
2047
2231
  }
2048
2232
  if (!${id}_present && !${id}.issues.length) {
2049
2233
  payload.issues.push({
@@ -2055,39 +2239,31 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
2055
2239
  }
2056
2240
 
2057
2241
  if (${id}_present) {
2058
- if (${id}.value === undefined) {
2059
- newResult[${k}] = undefined;
2060
- } else {
2061
- newResult[${k}] = ${id}.value;
2062
- }
2242
+ newResult[${k}] = ${id}.value;
2063
2243
  }
2064
2244
 
2065
2245
  `);
2066
2246
  } else {
2067
2247
  doc.write(`
2068
- if (${id}.issues.length) {
2069
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2070
- ...iss,
2071
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2072
- })));
2248
+ if (${id}.issues.length) {${prefixStr(id, k)}
2073
2249
  }
2074
2250
 
2075
2251
  if (${id}.value === undefined) {
2076
- if (${k} in input) {
2252
+ if (${isPresent}) {
2077
2253
  newResult[${k}] = undefined;
2078
2254
  }
2079
2255
  } else {
2080
2256
  newResult[${k}] = ${id}.value;
2081
2257
  }
2082
-
2258
+
2083
2259
  `);
2084
2260
  }
2085
2261
  }
2086
2262
 
2087
2263
  doc.write(`payload.value = newResult;`);
2088
2264
  doc.write(`return payload;`);
2089
- const fn = doc.compile();
2090
- return (payload: any, ctx: any) => fn(shape, payload, ctx);
2265
+ // closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
2266
+ return doc.compile() as (payload: any, ctx: any) => any;
2091
2267
  };
2092
2268
 
2093
2269
  let fastpass!: ReturnType<typeof generateFastpass>;
@@ -2155,7 +2331,7 @@ export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $Zo
2155
2331
  output: $InferUnionOutput<T[number]>;
2156
2332
  input: $InferUnionInput<T[number]>;
2157
2333
  // if any element in the union is optional, then the union is optional
2158
- optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
2334
+ optin: IsOptionalIn<T[number]> extends false ? "optional" | "defaulted" | undefined : "optional" | "defaulted";
2159
2335
  optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
2160
2336
  }
2161
2337
 
@@ -2192,24 +2368,28 @@ function handleUnionResults(results: ParsePayload[], final: ParsePayload, inst:
2192
2368
  export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
2193
2369
  $ZodType.init(inst, def);
2194
2370
 
2195
- util.defineLazy(inst._zod, "optin", () =>
2196
- def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined
2371
+ util.defineLazyInternal(inst, "optin", (zod) =>
2372
+ zod.def.options.some((o) => o._zod.optin === "defaulted")
2373
+ ? "defaulted"
2374
+ : zod.def.options.some((o) => o._zod.optin !== undefined)
2375
+ ? "optional"
2376
+ : undefined
2197
2377
  );
2198
2378
 
2199
- util.defineLazy(inst._zod, "optout", () =>
2200
- def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
2379
+ util.defineLazyInternal(inst, "optout", (zod) =>
2380
+ zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
2201
2381
  );
2202
2382
 
2203
- util.defineLazy(inst._zod, "values", () => {
2204
- if (def.options.every((o) => o._zod.values)) {
2205
- return new Set<util.Primitive>(def.options.flatMap((option) => Array.from(option._zod.values!)));
2383
+ util.defineLazyInternal(inst, "values", (zod) => {
2384
+ if (zod.def.options.every((o) => o._zod.values)) {
2385
+ return new Set<util.Primitive>(zod.def.options.flatMap((option) => Array.from(option._zod.values!)));
2206
2386
  }
2207
2387
  return undefined;
2208
2388
  });
2209
2389
 
2210
- util.defineLazy(inst._zod, "pattern", () => {
2211
- if (def.options.every((o) => o._zod.pattern)) {
2212
- const patterns = def.options.map((o) => o._zod.pattern);
2390
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2391
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2392
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
2213
2393
  return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p!.source)).join("|")})$`);
2214
2394
  }
2215
2395
  return undefined;
@@ -2254,14 +2434,17 @@ function handleExclusiveUnionResults(
2254
2434
  inst: $ZodUnion,
2255
2435
  ctx?: ParseContext
2256
2436
  ) {
2257
- const successes = results.filter((r) => r.issues.length === 0);
2437
+ const matches: number[] = [];
2438
+ for (let i = 0; i < results.length; i++) {
2439
+ if (results[i].issues.length === 0) matches.push(i);
2440
+ }
2258
2441
 
2259
- if (successes.length === 1) {
2260
- final.value = successes[0].value;
2442
+ if (matches.length === 1) {
2443
+ final.value = results[matches[0]].value;
2261
2444
  return final;
2262
2445
  }
2263
2446
 
2264
- if (successes.length === 0) {
2447
+ if (matches.length === 0) {
2265
2448
  // No matches - same as regular union
2266
2449
  final.issues.push({
2267
2450
  code: "invalid_union",
@@ -2277,6 +2460,7 @@ function handleExclusiveUnionResults(
2277
2460
  inst,
2278
2461
  errors: [],
2279
2462
  inclusive: false,
2463
+ matches,
2280
2464
  });
2281
2465
  }
2282
2466
 
@@ -2348,6 +2532,49 @@ export interface $ZodDiscriminatedUnionInternals<
2348
2532
  > extends $ZodUnionInternals<Options> {
2349
2533
  def: $ZodDiscriminatedUnionDef<Options, Disc>;
2350
2534
  propValues: util.PropValues;
2535
+ bag: util.LoosePartial<{
2536
+ optionsMap: Map<util.Primitive, $ZodType>;
2537
+ }>;
2538
+ }
2539
+
2540
+ /** The discriminator values a member of `Options` can declare. An omittable discriminator contributes `undefined`, matching what `propValues` claims for it. */
2541
+ export type $DiscriminatorValue<Options extends readonly SomeType[], Disc extends string> = {
2542
+ [I in keyof Options]: Options[I] extends { _zod: { output: infer Out } }
2543
+ ? Disc extends keyof Out
2544
+ ? Out[Disc]
2545
+ : never
2546
+ : never;
2547
+ }[number];
2548
+
2549
+ /** The member of `Options` that declares `V`. */
2550
+ export type $DiscriminatedOption<Options extends readonly SomeType[], Disc extends string, V> = {
2551
+ [I in keyof Options]: Options[I] extends { _zod: { output: infer Out } }
2552
+ ? Disc extends keyof Out
2553
+ ? V extends Out[Disc]
2554
+ ? Options[I]
2555
+ : never
2556
+ : never
2557
+ : never;
2558
+ }[number];
2559
+
2560
+ /** Returns the option of `union` whose discriminator claims `value`. */
2561
+ export function getDiscriminatedOption<
2562
+ Options extends readonly SomeType[],
2563
+ Disc extends string,
2564
+ const V extends $DiscriminatorValue<Options, Disc>,
2565
+ >(union: $ZodDiscriminatedUnion<Options, Disc>, value: V): $DiscriminatedOption<Options, Disc, V> {
2566
+ const internals = union._zod;
2567
+ let map = internals.bag.optionsMap;
2568
+ if (!map) {
2569
+ map = new Map();
2570
+ const { options, discriminator } = internals.def;
2571
+ for (const option of options as unknown as readonly $ZodType[]) {
2572
+ // First declaration wins, matching the order the parse path resolves a duplicate in.
2573
+ for (const v of option._zod.propValues?.[discriminator] ?? []) if (!map.has(v)) map.set(v, option);
2574
+ }
2575
+ internals.bag.optionsMap = map;
2576
+ }
2577
+ return map.get(value as util.Primitive) as any;
2351
2578
  }
2352
2579
 
2353
2580
  export interface $ZodDiscriminatedUnion<
@@ -2365,14 +2592,16 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2365
2592
  $ZodUnion.init(inst, def);
2366
2593
 
2367
2594
  const _super = inst._zod.parse;
2368
- util.defineLazy(inst._zod, "propValues", () => {
2595
+ util.defineLazyInternal(inst, "propValues", (zod) => {
2369
2596
  const propValues: util.PropValues = {};
2370
- for (const option of def.options) {
2597
+ for (const option of zod.def.options) {
2371
2598
  const pv = option._zod.propValues;
2372
2599
  if (!pv || Object.keys(pv).length === 0)
2373
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2600
+ throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
2374
2601
  for (const [k, v] of Object.entries(pv!)) {
2375
- if (!propValues[k]) propValues[k] = new Set();
2602
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
2603
+ util.assignProp(propValues, k, new Set());
2604
+ }
2376
2605
  for (const val of v) {
2377
2606
  propValues[k].add(val);
2378
2607
  }
@@ -2381,8 +2610,16 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2381
2610
  return propValues;
2382
2611
  });
2383
2612
 
2613
+ // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes, lazies, and objects rebuilt by a builder such as `.extend()` — are left to the map.
2614
+ def.options.forEach((option, i) => {
2615
+ const propShape = propShapes.get(option._zod.def);
2616
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
2617
+ throw new Error(`Invalid discriminated union option at index "${i}"`);
2618
+ }
2619
+ });
2620
+
2384
2621
  const disc = util.cached(() => {
2385
- const opts = def.options as $ZodTypeDiscriminable[];
2622
+ const opts = def.options;
2386
2623
  const map: Map<util.Primitive, $ZodType> = new Map();
2387
2624
  for (const o of opts) {
2388
2625
  const values = o._zod.propValues?.[def.discriminator];
@@ -2418,8 +2655,7 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2418
2655
 
2419
2656
  // Fall back to union matching when the fast discriminator path fails:
2420
2657
  // - explicitly enabled via unionFallback, or
2421
- // - during backward direction (encode), since codec-based discriminators
2422
- // have different values in forward vs backward directions
2658
+ // - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
2423
2659
  if (def.unionFallback || ctx.direction === "backward") {
2424
2660
  return _super(payload, ctx);
2425
2661
  }
@@ -2492,7 +2728,7 @@ export const $ZodIntersection: core.$constructor<$ZodIntersection> = /*@__PURE__
2492
2728
  }
2493
2729
  );
2494
2730
 
2495
- function mergeValues(
2731
+ export function mergeValues(
2496
2732
  a: any,
2497
2733
  b: any
2498
2734
  ): { valid: true; data: any } | { valid: false; mergeErrorPath: (string | number)[] } {
@@ -2510,7 +2746,9 @@ function mergeValues(
2510
2746
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2511
2747
 
2512
2748
  const newObj: any = { ...a, ...b };
2749
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
2513
2750
  for (const key of sharedKeys) {
2751
+ if (key === "__proto__") continue;
2514
2752
  const sharedValue = mergeValues(a[key], b[key]);
2515
2753
  if (!sharedValue.valid) {
2516
2754
  return {
@@ -2551,44 +2789,52 @@ function mergeValues(
2551
2789
  }
2552
2790
 
2553
2791
  function handleIntersectionResults(result: ParsePayload, left: ParsePayload, right: ParsePayload): ParsePayload {
2554
- // Track which side(s) report each key as unrecognized
2792
+ // Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
2555
2793
  const unrecKeys = new Map<string, { l?: true; r?: true }>();
2556
2794
  let unrecIssue: errors.$ZodRawIssue | undefined;
2795
+ const keyIssues = new Map<string, errors.$ZodRawIssue>();
2557
2796
 
2558
- for (const iss of left.issues) {
2559
- if (iss.code === "unrecognized_keys") {
2797
+ const collect = (iss: errors.$ZodRawIssue, side: "l" | "r"): boolean => {
2798
+ let keys: string[];
2799
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2560
2800
  unrecIssue ??= iss;
2561
- for (const k of iss.keys) {
2562
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2563
- unrecKeys.get(k)!.l = true;
2564
- }
2801
+ keys = iss.keys as string[];
2802
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2803
+ const k = String(iss.path[0]);
2804
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2805
+ keys = [k];
2565
2806
  } else {
2566
- result.issues.push(iss);
2807
+ return false;
2567
2808
  }
2809
+ for (const k of keys) {
2810
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2811
+ unrecKeys.get(k)![side] = true;
2812
+ }
2813
+ return true;
2814
+ };
2815
+
2816
+ for (const iss of left.issues) {
2817
+ if (!collect(iss, "l")) result.issues.push(iss);
2568
2818
  }
2569
2819
 
2570
2820
  for (const iss of right.issues) {
2571
- if (iss.code === "unrecognized_keys") {
2572
- for (const k of iss.keys) {
2573
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2574
- unrecKeys.get(k)!.r = true;
2575
- }
2576
- } else {
2577
- result.issues.push(iss);
2578
- }
2821
+ if (!collect(iss, "r")) result.issues.push(iss);
2579
2822
  }
2580
2823
 
2581
- // Report only keys unrecognized by BOTH sides
2824
+ // Report only keys rejected by BOTH sides
2582
2825
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2583
- if (bothKeys.length && unrecIssue) {
2584
- result.issues.push({ ...unrecIssue, keys: bothKeys });
2826
+ if (bothKeys.length) {
2827
+ const aggregated = unrecIssue ? bothKeys.filter((k) => (unrecIssue!.keys as string[]).includes(k)) : [];
2828
+ if (aggregated.length) result.issues.push({ ...unrecIssue!, keys: aggregated });
2829
+ for (const k of bothKeys) {
2830
+ if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k)!);
2831
+ }
2585
2832
  }
2586
2833
 
2587
- if (util.aborted(result)) return result;
2588
-
2589
2834
  const merged = mergeValues(left.value, right.value);
2590
2835
 
2591
2836
  if (!merged.valid) {
2837
+ if (util.aborted(result)) return result;
2592
2838
  throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
2593
2839
  }
2594
2840
 
@@ -2624,7 +2870,7 @@ type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly
2624
2870
  ...infer Prefix extends SomeType[],
2625
2871
  infer Tail extends SomeType,
2626
2872
  ]
2627
- ? Tail["_zod"]["optin"] extends "optional"
2873
+ ? Tail["_zod"]["optin"] extends "optional" | "defaulted"
2628
2874
  ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?]
2629
2875
  : TupleInputTypeNoOptionals<T>
2630
2876
  : [];
@@ -2666,6 +2912,8 @@ export interface $ZodTuple<
2666
2912
  export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
2667
2913
  $ZodType.init(inst, def);
2668
2914
  const items = def.items;
2915
+ const memo = core.globalConfig.memoizer;
2916
+ memo?.attach(inst);
2669
2917
 
2670
2918
  inst._zod.parse = (payload, ctx) => {
2671
2919
  const input = payload.value;
@@ -2679,7 +2927,7 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
2679
2927
  return payload;
2680
2928
  }
2681
2929
 
2682
- payload.value = [];
2930
+ payload.value = memo ? memo.alloc(inst, payload, [] as unknown[], ctx) : [];
2683
2931
  const proms: Promise<any>[] = [];
2684
2932
 
2685
2933
  const optinStart = getTupleOptStart(items, "optin");
@@ -2709,10 +2957,7 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
2709
2957
  }
2710
2958
  }
2711
2959
 
2712
- // Run every item in parallel, collecting results into an indexed
2713
- // array. The post-processing in `handleTupleResults` walks them in
2714
- // order so it can decide whether an absent optional-output error can
2715
- // truncate the tail or must be reported to preserve required output.
2960
+ // Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
2716
2961
  const itemResults: ParsePayload[] = new Array(items.length);
2717
2962
  for (let i = 0; i < items.length; i++) {
2718
2963
  const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
@@ -2750,7 +2995,9 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
2750
2995
 
2751
2996
  function getTupleOptStart(items: readonly $ZodType[], key: "optin" | "optout") {
2752
2997
  for (let i = items.length - 1; i >= 0; i--) {
2753
- if (items[i]._zod[key] !== "optional") return i + 1;
2998
+ // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
2999
+ const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
3000
+ if (!omittable) return i + 1;
2754
3001
  }
2755
3002
  return 0;
2756
3003
  }
@@ -2769,12 +3016,15 @@ function handleTupleResults(
2769
3016
  input: unknown[],
2770
3017
  optoutStart: number
2771
3018
  ) {
2772
- // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
2773
- // rule, but only after `optoutStart`: the first index where the output
2774
- // tuple tail can be absent.
3019
+ // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
2775
3020
  for (let i = 0; i < items.length; i++) {
2776
3021
  const r = itemResults[i];
2777
3022
  const isPresent = i < input.length;
3023
+ // The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
3024
+ if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
3025
+ final.value.length = i;
3026
+ break;
3027
+ }
2778
3028
  if (r.issues.length) {
2779
3029
  if (!isPresent && i >= optoutStart) {
2780
3030
  final.value.length = i;
@@ -2817,6 +3067,7 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
2817
3067
  valueType: Value;
2818
3068
  /** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */
2819
3069
  mode?: "strict" | "loose";
3070
+ partial?: boolean;
2820
3071
  }
2821
3072
 
2822
3073
  // export type $InferZodRecordOutput<
@@ -2856,7 +3107,10 @@ export type $InferZodRecordInput<
2856
3107
  Value extends SomeType = $ZodType,
2857
3108
  > = Key extends $partial
2858
3109
  ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>>
2859
- : Record<core.input<Key> & PropertyKey, core.input<Value>>;
3110
+ : // A value schema that accepts an absent slot makes the key omittable on the way in, exactly as it does in an object shape. The output side keeps every key, since the parser fills each one.
3111
+ [Value] extends [OptionalInSchema]
3112
+ ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>>
3113
+ : Record<core.input<Key> & PropertyKey, core.input<Value>>;
2860
3114
 
2861
3115
  export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2862
3116
  extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
@@ -2874,6 +3128,8 @@ export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value ext
2874
3128
 
2875
3129
  export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
2876
3130
  $ZodType.init(inst, def);
3131
+ const memo = core.globalConfig.memoizer;
3132
+ memo?.attach(inst);
2877
3133
 
2878
3134
  inst._zod.parse = (payload, ctx) => {
2879
3135
  const input = payload.value;
@@ -2892,12 +3148,14 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2892
3148
  const proms: Promise<any>[] = [];
2893
3149
 
2894
3150
  const values = def.keyType._zod.values;
2895
- if (values) {
2896
- payload.value = {};
3151
+ if (values && !def.partial) {
3152
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
2897
3153
  const recordKeys = new Set<string | symbol>();
2898
3154
  for (const key of values) {
2899
3155
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2900
3156
  recordKeys.add(typeof key === "number" ? key.toString() : key);
3157
+ // A declared __proto__ is stripped but is not an unrecognized key.
3158
+ if (key === "__proto__") continue;
2901
3159
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2902
3160
  if (keyResult instanceof Promise) {
2903
3161
  throw new Error("Async schemas not supported in object keys currently");
@@ -2914,6 +3172,7 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2914
3172
  continue;
2915
3173
  }
2916
3174
  const outKey = keyResult.value as PropertyKey;
3175
+ if (outKey === "__proto__") continue;
2917
3176
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2918
3177
 
2919
3178
  if (result instanceof Promise) {
@@ -2937,8 +3196,14 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2937
3196
  let unrecognized!: string[];
2938
3197
  for (const key in input) {
2939
3198
  if (!recordKeys.has(key)) {
2940
- unrecognized = unrecognized ?? [];
2941
- unrecognized.push(key);
3199
+ if (def.mode === "loose") {
3200
+ // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
3201
+ if (key === "__proto__") continue;
3202
+ payload.value[key] = input[key];
3203
+ } else {
3204
+ unrecognized = unrecognized ?? [];
3205
+ unrecognized.push(key);
3206
+ }
2942
3207
  }
2943
3208
  }
2944
3209
  if (unrecognized && unrecognized.length > 0) {
@@ -2948,10 +3213,13 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2948
3213
  input,
2949
3214
  inst,
2950
3215
  keys: unrecognized,
3216
+ continue: true,
2951
3217
  });
2952
3218
  }
2953
3219
  } else {
2954
- payload.value = {};
3220
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
3221
+ // An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
3222
+ let unrecognized!: string[];
2955
3223
  // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
2956
3224
  for (const key of Reflect.ownKeys(input)) {
2957
3225
  if (key === "__proto__") continue;
@@ -2961,8 +3229,7 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2961
3229
  throw new Error("Async schemas not supported in object keys currently");
2962
3230
  }
2963
3231
 
2964
- // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
2965
- // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
3232
+ // Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
2966
3233
  const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
2967
3234
  if (checkNumericKey) {
2968
3235
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
@@ -2978,6 +3245,9 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2978
3245
  if (def.mode === "loose") {
2979
3246
  // Pass through unchanged
2980
3247
  payload.value[key] = input[key];
3248
+ } else if (values) {
3249
+ unrecognized = unrecognized ?? [];
3250
+ unrecognized.push(key as string);
2981
3251
  } else {
2982
3252
  // Default "strict" behavior: error on invalid key
2983
3253
  payload.issues.push({
@@ -2992,6 +3262,10 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
2992
3262
  continue;
2993
3263
  }
2994
3264
 
3265
+ // the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
3266
+ const outKey = keyResult.value as PropertyKey;
3267
+ if (outKey === "__proto__") continue;
3268
+
2995
3269
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2996
3270
 
2997
3271
  if (result instanceof Promise) {
@@ -3000,16 +3274,27 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
3000
3274
  if (result.issues.length) {
3001
3275
  payload.issues.push(...util.prefixIssues(key, result.issues));
3002
3276
  }
3003
- payload.value[keyResult.value as PropertyKey] = result.value;
3277
+ payload.value[outKey] = result.value;
3004
3278
  })
3005
3279
  );
3006
3280
  } else {
3007
3281
  if (result.issues.length) {
3008
3282
  payload.issues.push(...util.prefixIssues(key, result.issues));
3009
3283
  }
3010
- payload.value[keyResult.value as PropertyKey] = result.value;
3284
+ payload.value[outKey] = result.value;
3011
3285
  }
3012
3286
  }
3287
+
3288
+ if (unrecognized && unrecognized.length > 0) {
3289
+ payload.issues.push({
3290
+ code: "unrecognized_keys",
3291
+
3292
+ input,
3293
+ inst,
3294
+ keys: unrecognized,
3295
+ continue: true,
3296
+ });
3297
+ }
3013
3298
  }
3014
3299
 
3015
3300
  if (proms.length) {
@@ -3046,6 +3331,8 @@ export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType
3046
3331
 
3047
3332
  export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
3048
3333
  $ZodType.init(inst, def);
3334
+ const memo = core.globalConfig.memoizer;
3335
+ memo?.attach(inst);
3049
3336
 
3050
3337
  inst._zod.parse = (payload, ctx) => {
3051
3338
  const input = payload.value;
@@ -3061,7 +3348,7 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
3061
3348
  }
3062
3349
 
3063
3350
  const proms: Promise<any>[] = [];
3064
- payload.value = new Map();
3351
+ payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
3065
3352
 
3066
3353
  for (const [key, value] of input) {
3067
3354
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
@@ -3150,6 +3437,8 @@ export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
3150
3437
 
3151
3438
  export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
3152
3439
  $ZodType.init(inst, def);
3440
+ const memo = core.globalConfig.memoizer;
3441
+ memo?.attach(inst);
3153
3442
 
3154
3443
  inst._zod.parse = (payload, ctx) => {
3155
3444
  const input = payload.value;
@@ -3164,7 +3453,7 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
3164
3453
  }
3165
3454
 
3166
3455
  const proms: Promise<any>[] = [];
3167
- payload.value = new Set();
3456
+ payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
3168
3457
  for (const item of input) {
3169
3458
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
3170
3459
  if (result instanceof Promise) {
@@ -3224,11 +3513,11 @@ export const $ZodEnum: core.$constructor<$ZodEnum> = /*@__PURE__*/ core.$constru
3224
3513
  const valuesSet = new Set<util.Primitive>(values);
3225
3514
  inst._zod.values = valuesSet;
3226
3515
 
3516
+ const patternValues = values.filter((k) => util.propertyKeyTypes.has(typeof k));
3517
+
3518
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
3227
3519
  inst._zod.pattern = new RegExp(
3228
- `^(${values
3229
- .filter((k) => util.propertyKeyTypes.has(typeof k))
3230
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
3231
- .join("|")})$`
3520
+ patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$"
3232
3521
  );
3233
3522
 
3234
3523
  inst._zod.parse = (payload, _ctx) => {
@@ -3275,17 +3564,17 @@ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$c
3275
3564
  "$ZodLiteral",
3276
3565
  (inst, def) => {
3277
3566
  $ZodType.init(inst, def);
3278
- if (def.values.length === 0) {
3279
- throw new Error("Cannot create literal schema with no valid values");
3280
- }
3281
3567
 
3282
3568
  const values = new Set<util.Literal>(def.values);
3283
3569
  inst._zod.values = values;
3284
- inst._zod.pattern = new RegExp(
3285
- `^(${def.values
3286
3570
 
3287
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
3288
- .join("|")})$`
3571
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
3572
+ inst._zod.pattern = new RegExp(
3573
+ def.values.length
3574
+ ? `^(${def.values
3575
+ .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
3576
+ .join("|")})$`
3577
+ : "^[^\\s\\S]$"
3289
3578
  );
3290
3579
 
3291
3580
  inst._zod.parse = (payload, _ctx) => {
@@ -3423,6 +3712,8 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
3423
3712
  (inst, def) => {
3424
3713
  $ZodType.init(inst, def);
3425
3714
  inst._zod.optin = "optional";
3715
+ core.globalConfig.memoizer?.guard(inst);
3716
+
3426
3717
  inst._zod.parse = (payload, ctx) => {
3427
3718
  if (ctx.direction === "backward") {
3428
3719
  throw new core.$ZodEncodeError(inst.constructor.name);
@@ -3433,7 +3724,6 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
3433
3724
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
3434
3725
  return output.then((output) => {
3435
3726
  payload.value = output;
3436
- payload.fallback = true;
3437
3727
  return payload;
3438
3728
  });
3439
3729
  }
@@ -3443,7 +3733,6 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
3443
3733
  }
3444
3734
 
3445
3735
  payload.value = _out;
3446
- payload.fallback = true;
3447
3736
  return payload;
3448
3737
  };
3449
3738
  }
@@ -3464,7 +3753,7 @@ export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodType
3464
3753
  export interface $ZodOptionalInternals<T extends SomeType = $ZodType>
3465
3754
  extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
3466
3755
  def: $ZodOptionalDef<T>;
3467
- optin: "optional";
3756
+ optin: "optional" | "defaulted";
3468
3757
  optout: "optional";
3469
3758
  isst: never;
3470
3759
  values: T["_zod"]["values"];
@@ -3475,37 +3764,39 @@ export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
3475
3764
  _zod: $ZodOptionalInternals<T>;
3476
3765
  }
3477
3766
 
3478
- function handleOptionalResult(result: ParsePayload, input: unknown) {
3479
- if (input === undefined && (result.issues.length || result.fallback)) {
3480
- return { issues: [], value: undefined };
3481
- }
3482
- return result;
3767
+ function handleOptionalResult(payload: ParsePayload, result: ParsePayload) {
3768
+ // A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
3769
+ payload.value = result.issues.length ? undefined : result.value;
3770
+ return payload;
3483
3771
  }
3484
3772
 
3485
3773
  export const $ZodOptional: core.$constructor<$ZodOptional> = /*@__PURE__*/ core.$constructor(
3486
3774
  "$ZodOptional",
3487
3775
  (inst, def) => {
3488
3776
  $ZodType.init(inst, def);
3489
- inst._zod.optin = "optional";
3777
+ // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
3778
+ util.defineLazyInternal(inst, "optin", (zod) =>
3779
+ zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional"
3780
+ );
3490
3781
  inst._zod.optout = "optional";
3491
3782
 
3492
- util.defineLazy(inst._zod, "values", () => {
3493
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
3783
+ util.defineLazyInternal(inst, "values", (zod) => {
3784
+ const values = (zod.def as $ZodOptionalDef).innerType._zod.values;
3785
+ return values ? new Set([...values, undefined]) : undefined;
3494
3786
  });
3495
- util.defineLazy(inst._zod, "pattern", () => {
3496
- const pattern = def.innerType._zod.pattern;
3787
+ util.defineLazyInternal(inst, "pattern", (zod) => {
3788
+ const pattern = (zod.def as $ZodOptionalDef).innerType._zod.pattern;
3497
3789
  return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
3498
3790
  });
3499
3791
 
3500
3792
  inst._zod.parse = (payload, ctx) => {
3501
- if (def.innerType._zod.optin === "optional") {
3502
- const input = payload.value;
3503
- const result = def.innerType._zod.run(payload, ctx);
3504
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
3505
- return handleOptionalResult(result, input);
3506
- }
3507
3793
  if (payload.value === undefined) {
3508
- return payload;
3794
+ // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
3795
+ if (def.innerType._zod.optin !== "defaulted") return payload;
3796
+ // Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
3797
+ const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
3798
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
3799
+ return handleOptionalResult(payload, result);
3509
3800
  }
3510
3801
  return def.innerType._zod.run(payload, ctx);
3511
3802
  };
@@ -3541,8 +3832,8 @@ export const $ZodExactOptional: core.$constructor<$ZodExactOptional> = /*@__PURE
3541
3832
  $ZodOptional.init(inst, def);
3542
3833
 
3543
3834
  // Override values/pattern to NOT add undefined
3544
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3545
- util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
3835
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
3836
+ util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
3546
3837
 
3547
3838
  // Override parse to just delegate (no undefined handling)
3548
3839
  inst._zod.parse = (payload, ctx) => {
@@ -3581,16 +3872,16 @@ export const $ZodNullable: core.$constructor<$ZodNullable> = /*@__PURE__*/ core.
3581
3872
  "$ZodNullable",
3582
3873
  (inst, def) => {
3583
3874
  $ZodType.init(inst, def);
3584
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3585
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3875
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
3876
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
3586
3877
 
3587
- util.defineLazy(inst._zod, "pattern", () => {
3588
- const pattern = def.innerType._zod.pattern;
3878
+ util.defineLazyInternal(inst, "pattern", (zod) => {
3879
+ const pattern = zod.def.innerType._zod.pattern;
3589
3880
  return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
3590
3881
  });
3591
3882
 
3592
- util.defineLazy(inst._zod, "values", () => {
3593
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
3883
+ util.defineLazyInternal(inst, "values", (zod) => {
3884
+ return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
3594
3885
  });
3595
3886
 
3596
3887
  inst._zod.parse = (payload, ctx) => {
@@ -3619,7 +3910,7 @@ export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeD
3619
3910
  export interface $ZodDefaultInternals<T extends SomeType = $ZodType>
3620
3911
  extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3621
3912
  def: $ZodDefaultDef<T>;
3622
- optin: "optional";
3913
+ optin: "defaulted";
3623
3914
  optout?: "optional" | undefined; // required
3624
3915
  isst: never;
3625
3916
  values: T["_zod"]["values"];
@@ -3635,8 +3926,8 @@ export const $ZodDefault: core.$constructor<$ZodDefault> = /*@__PURE__*/ core.$c
3635
3926
  $ZodType.init(inst, def);
3636
3927
 
3637
3928
  // inst._zod.qin = "true";
3638
- inst._zod.optin = "optional";
3639
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3929
+ inst._zod.optin = "defaulted";
3930
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
3640
3931
 
3641
3932
  inst._zod.parse = (payload, ctx) => {
3642
3933
  if (ctx.direction === "backward") {
@@ -3686,7 +3977,7 @@ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodType
3686
3977
  export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
3687
3978
  extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3688
3979
  def: $ZodPrefaultDef<T>;
3689
- optin: "optional";
3980
+ optin: "defaulted";
3690
3981
  optout?: "optional" | undefined;
3691
3982
  isst: never;
3692
3983
  values: T["_zod"]["values"];
@@ -3701,8 +3992,8 @@ export const $ZodPrefault: core.$constructor<$ZodPrefault> = /*@__PURE__*/ core.
3701
3992
  (inst, def) => {
3702
3993
  $ZodType.init(inst, def);
3703
3994
 
3704
- inst._zod.optin = "optional";
3705
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3995
+ inst._zod.optin = "defaulted";
3996
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
3706
3997
 
3707
3998
  inst._zod.parse = (payload, ctx) => {
3708
3999
  if (ctx.direction === "backward") {
@@ -3748,8 +4039,8 @@ export const $ZodNonOptional: core.$constructor<$ZodNonOptional> = /*@__PURE__*/
3748
4039
  (inst, def) => {
3749
4040
  $ZodType.init(inst, def);
3750
4041
 
3751
- util.defineLazy(inst._zod, "values", () => {
3752
- const v = def.innerType._zod.values;
4042
+ util.defineLazyInternal(inst, "values", (zod) => {
4043
+ const v = zod.def.innerType._zod.values;
3753
4044
  return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
3754
4045
  });
3755
4046
 
@@ -3893,11 +4184,33 @@ export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
3893
4184
  _zod: $ZodCatchInternals<T>;
3894
4185
  }
3895
4186
 
4187
+ function handleCatchResult(payload: ParsePayload, result: ParsePayload, def: $ZodCatchDef, ctx: ParseContextInternal) {
4188
+ if (!result.issues.length) {
4189
+ payload.value = result.value;
4190
+ // The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
4191
+ if (result.memo) payload.memo = true;
4192
+ return payload;
4193
+ }
4194
+
4195
+ // Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
4196
+ payload.value = def.catchValue({
4197
+ ...result,
4198
+ value: payload.value,
4199
+ error: {
4200
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
4201
+ },
4202
+ input: payload.value,
4203
+ });
4204
+ return payload;
4205
+ }
4206
+
3896
4207
  export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
3897
4208
  $ZodType.init(inst, def);
3898
- inst._zod.optin = "optional";
3899
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3900
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
4209
+ util.defineLazyInternal(inst, "optin", (zod) =>
4210
+ zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional"
4211
+ );
4212
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
4213
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
3901
4214
 
3902
4215
  inst._zod.parse = (payload, ctx) => {
3903
4216
  if (ctx.direction === "backward") {
@@ -3905,41 +4218,12 @@ export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$const
3905
4218
  }
3906
4219
 
3907
4220
  // Forward direction (decode): apply catch logic
3908
- const result = def.innerType._zod.run(payload, ctx);
4221
+ const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
3909
4222
  if (result instanceof Promise) {
3910
- return result.then((result) => {
3911
- payload.value = result.value;
3912
- if (result.issues.length) {
3913
- payload.value = def.catchValue({
3914
- ...payload,
3915
- error: {
3916
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3917
- },
3918
- input: payload.value,
3919
- });
3920
- payload.issues = [];
3921
- payload.fallback = true;
3922
- }
3923
-
3924
- return payload;
3925
- });
4223
+ return result.then((result) => handleCatchResult(payload, result, def, ctx));
3926
4224
  }
3927
4225
 
3928
- payload.value = result.value;
3929
- if (result.issues.length) {
3930
- payload.value = def.catchValue({
3931
- ...payload,
3932
- error: {
3933
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3934
- },
3935
- input: payload.value,
3936
- });
3937
-
3938
- payload.issues = [];
3939
- payload.fallback = true;
3940
- }
3941
-
3942
- return payload;
4226
+ return handleCatchResult(payload, result, def, ctx);
3943
4227
  };
3944
4228
  });
3945
4229
 
@@ -4013,10 +4297,10 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
4013
4297
 
4014
4298
  export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
4015
4299
  $ZodType.init(inst, def);
4016
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
4017
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
4018
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
4019
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
4300
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
4301
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
4302
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
4303
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
4020
4304
 
4021
4305
  inst._zod.parse = (payload, ctx) => {
4022
4306
  if (ctx.direction === "backward") {
@@ -4036,12 +4320,13 @@ export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constru
4036
4320
  });
4037
4321
 
4038
4322
  function handlePipeResult(left: ParsePayload, next: $ZodType, ctx: ParseContextInternal) {
4039
- if (left.issues.length) {
4323
+ // Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
4324
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
4040
4325
  // prevent further checks
4041
4326
  left.aborted = true;
4042
4327
  return left;
4043
4328
  }
4044
- return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
4329
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
4045
4330
  }
4046
4331
 
4047
4332
  ////////////////////////////////////////////
@@ -4072,10 +4357,10 @@ export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $
4072
4357
 
4073
4358
  export const $ZodCodec: core.$constructor<$ZodCodec> = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
4074
4359
  $ZodType.init(inst, def);
4075
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
4076
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
4077
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
4078
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
4360
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
4361
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
4362
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
4363
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
4079
4364
 
4080
4365
  inst._zod.parse = (payload, ctx) => {
4081
4366
  const direction = ctx.direction || "forward";
@@ -4136,19 +4421,22 @@ function handleCodecTxResult(left: ParsePayload, value: any, nextSchema: SomeTyp
4136
4421
  ////////// //////////
4137
4422
  /////////////////////////////////////////////////
4138
4423
  /////////////////////////////////////////////////
4139
- export interface $ZodPreprocessDef<B extends SomeType = $ZodType> extends $ZodPipeDef<$ZodTransform, B> {
4140
- in: $ZodTransform;
4424
+ export interface $ZodPreprocessDef<B extends SomeType = $ZodType, I = unknown>
4425
+ extends $ZodPipeDef<$ZodTransform<unknown, I>, B> {
4426
+ in: $ZodTransform<unknown, I>;
4141
4427
  out: B;
4142
4428
  }
4143
4429
 
4144
- export interface $ZodPreprocessInternals<B extends SomeType = $ZodType> extends $ZodPipeInternals<$ZodTransform, B> {
4145
- def: $ZodPreprocessDef<B>;
4430
+ export interface $ZodPreprocessInternals<B extends SomeType = $ZodType, I = unknown>
4431
+ extends $ZodPipeInternals<$ZodTransform<unknown, I>, B> {
4432
+ def: $ZodPreprocessDef<B, I>;
4146
4433
  optin: B["_zod"]["optin"];
4147
4434
  optout: B["_zod"]["optout"];
4148
4435
  }
4149
4436
 
4150
- export interface $ZodPreprocess<B extends SomeType = $ZodType> extends $ZodPipe<$ZodTransform, B> {
4151
- _zod: $ZodPreprocessInternals<B>;
4437
+ export interface $ZodPreprocess<B extends SomeType = $ZodType, I = unknown>
4438
+ extends $ZodPipe<$ZodTransform<unknown, I>, B> {
4439
+ _zod: $ZodPreprocessInternals<B, I>;
4152
4440
  }
4153
4441
 
4154
4442
  export const $ZodPreprocess: core.$constructor<$ZodPreprocess> = /*@__PURE__*/ core.$constructor(
@@ -4189,10 +4477,10 @@ export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.
4189
4477
  "$ZodReadonly",
4190
4478
  (inst, def) => {
4191
4479
  $ZodType.init(inst, def);
4192
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
4193
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
4194
- util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
4195
- util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
4480
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
4481
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
4482
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
4483
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
4196
4484
 
4197
4485
  inst._zod.parse = (payload, ctx) => {
4198
4486
  if (ctx.direction === "backward") {
@@ -4208,7 +4496,8 @@ export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.
4208
4496
  );
4209
4497
 
4210
4498
  function handleReadonlyResult(payload: ParsePayload): ParsePayload {
4211
- payload.value = Object.freeze(payload.value);
4499
+ // A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
4500
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
4212
4501
  return payload;
4213
4502
  }
4214
4503
 
@@ -4424,35 +4713,45 @@ export const $ZodFunction: core.$constructor<$ZodFunction> = /*@__PURE__*/ core.
4424
4713
  "$ZodFunction",
4425
4714
  (inst, def) => {
4426
4715
  $ZodType.init(inst, def);
4427
- inst._def = def;
4716
+ // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
4717
+ Object.defineProperty(inst, "_def", { value: def });
4428
4718
  inst._zod.def = def;
4429
4719
 
4430
4720
  inst.implement = (func) => {
4431
4721
  if (typeof func !== "function") {
4432
4722
  throw new Error("implement() must be called with a function");
4433
4723
  }
4434
- return function (this: any, ...args: never[]) {
4435
- const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
4436
- const result = Reflect.apply(func, this, parsedArgs as never[]);
4437
- if (inst._def.output) {
4438
- return parse(inst._def.output, result);
4439
- }
4440
- return result as any;
4441
- };
4724
+ // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
4725
+ return Object.defineProperty(
4726
+ function (this: any, ...args: never[]) {
4727
+ const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
4728
+ const result = Reflect.apply(func, this, parsedArgs as never[]);
4729
+ if (inst._def.output) {
4730
+ return parse(inst._def.output, result);
4731
+ }
4732
+ return result as any;
4733
+ },
4734
+ "_zod",
4735
+ { value: inst._zod, enumerable: false }
4736
+ ) as any;
4442
4737
  };
4443
4738
 
4444
4739
  inst.implementAsync = (func) => {
4445
4740
  if (typeof func !== "function") {
4446
4741
  throw new Error("implementAsync() must be called with a function");
4447
4742
  }
4448
- return async function (this: any, ...args: never[]) {
4449
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
4450
- const result = await Reflect.apply(func, this, parsedArgs as never[]);
4451
- if (inst._def.output) {
4452
- return await parseAsync(inst._def.output, result);
4453
- }
4454
- return result;
4455
- } as any;
4743
+ return Object.defineProperty(
4744
+ async function (this: any, ...args: never[]) {
4745
+ const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
4746
+ const result = await Reflect.apply(func, this, parsedArgs as never[]);
4747
+ if (inst._def.output) {
4748
+ return await parseAsync(inst._def.output, result);
4749
+ }
4750
+ return result;
4751
+ },
4752
+ "_zod",
4753
+ { value: inst._zod, enumerable: false }
4754
+ ) as any;
4456
4755
  };
4457
4756
 
4458
4757
  inst._zod.parse = (payload, _ctx) => {
@@ -4576,18 +4875,16 @@ export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
4576
4875
  export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
4577
4876
  $ZodType.init(inst, def);
4578
4877
 
4579
- // Cache the resolved inner type on the shared `def` so all clones of this
4580
- // lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
4581
- // preserving identity for cycle detection on recursive schemas.
4878
+ // Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
4582
4879
  util.defineLazy(inst._zod, "innerType", () => {
4583
4880
  const d = def as $ZodLazyDef & { _cachedInner?: $ZodType };
4584
4881
  if (!d._cachedInner) d._cachedInner = def.getter() as $ZodType;
4585
4882
  return d._cachedInner;
4586
4883
  });
4587
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
4588
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
4589
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
4590
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
4884
+ util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
4885
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
4886
+ util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
4887
+ util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
4591
4888
  inst._zod.parse = (payload, ctx) => {
4592
4889
  const inner = inst._zod.innerType;
4593
4890
  return inner._zod.run(payload, ctx);
@@ -4724,6 +5021,7 @@ export type $ZodStringFormatTypes =
4724
5021
  | $ZodBase64
4725
5022
  | $ZodBase64URL
4726
5023
  | $ZodE164
5024
+ | $ZodCreditCard
4727
5025
  | $ZodJWT
4728
5026
  | $ZodCustomStringFormat<"hex">
4729
5027
  | $ZodCustomStringFormat<util.HashFormat>