cross-seed 7.0.0-21 → 7.0.0-23

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 (785) hide show
  1. package/dist/action.js +7 -8
  2. package/dist/action.js.map +1 -1
  3. package/dist/arr.js +2 -2
  4. package/dist/arr.js.map +1 -1
  5. package/dist/bencode.d.ts +62 -0
  6. package/dist/bencode.js +248 -0
  7. package/dist/bencode.js.map +1 -0
  8. package/dist/clients/Deluge.d.ts +5 -10
  9. package/dist/clients/Deluge.js +115 -89
  10. package/dist/clients/Deluge.js.map +1 -1
  11. package/dist/clients/QBittorrent.d.ts +3 -0
  12. package/dist/clients/QBittorrent.js +43 -30
  13. package/dist/clients/QBittorrent.js.map +1 -1
  14. package/dist/clients/RTorrent.d.ts +3 -2
  15. package/dist/clients/RTorrent.js +120 -41
  16. package/dist/clients/RTorrent.js.map +1 -1
  17. package/dist/clients/TorrentClient.d.ts +3 -2
  18. package/dist/clients/TorrentClient.js +3 -5
  19. package/dist/clients/TorrentClient.js.map +1 -1
  20. package/dist/clients/Transmission.d.ts +1 -0
  21. package/dist/clients/Transmission.js +90 -40
  22. package/dist/clients/Transmission.js.map +1 -1
  23. package/dist/clients/qbittorrent-version.d.ts +6 -0
  24. package/dist/clients/qbittorrent-version.js +11 -0
  25. package/dist/clients/qbittorrent-version.js.map +1 -0
  26. package/dist/clients/scgi.d.ts +14 -0
  27. package/dist/clients/scgi.js +111 -0
  28. package/dist/clients/scgi.js.map +1 -0
  29. package/dist/cmd.js +1 -1
  30. package/dist/cmd.js.map +1 -1
  31. package/dist/configuration.js +49 -9
  32. package/dist/configuration.js.map +1 -1
  33. package/dist/constants.d.ts +10 -0
  34. package/dist/constants.js +12 -2
  35. package/dist/constants.js.map +1 -1
  36. package/dist/dataFiles.d.ts +1 -0
  37. package/dist/dataFiles.js +252 -60
  38. package/dist/dataFiles.js.map +1 -1
  39. package/dist/db.js +8 -4
  40. package/dist/db.js.map +1 -1
  41. package/dist/decide.js +8 -8
  42. package/dist/decide.js.map +1 -1
  43. package/dist/devLogin.js.map +1 -1
  44. package/dist/diff.js.map +1 -1
  45. package/dist/indexers.js +5 -4
  46. package/dist/indexers.js.map +1 -1
  47. package/dist/inject.js +5 -5
  48. package/dist/inject.js.map +1 -1
  49. package/dist/jobs.js +2 -1
  50. package/dist/jobs.js.map +1 -1
  51. package/dist/libraryInventory.d.ts +176 -0
  52. package/dist/libraryInventory.js +701 -0
  53. package/dist/libraryInventory.js.map +1 -0
  54. package/dist/logger.js +7 -5
  55. package/dist/logger.js.map +1 -1
  56. package/dist/migrations/09-clientAndDataSearchees.js +1 -0
  57. package/dist/migrations/09-clientAndDataSearchees.js.map +1 -1
  58. package/dist/migrations/17-api-key-settings-json.js +3 -1
  59. package/dist/migrations/17-api-key-settings-json.js.map +1 -1
  60. package/dist/migrations/18-library-inventory.d.ts +9 -0
  61. package/dist/migrations/18-library-inventory.js +48 -0
  62. package/dist/migrations/18-library-inventory.js.map +1 -0
  63. package/dist/migrations/19-library-files.d.ts +9 -0
  64. package/dist/migrations/19-library-files.js +26 -0
  65. package/dist/migrations/19-library-files.js.map +1 -0
  66. package/dist/migrations/migrations.d.ts +12 -5
  67. package/dist/migrations/migrations.js +5 -1
  68. package/dist/migrations/migrations.js.map +1 -1
  69. package/dist/parseTorrent.d.ts +1 -1
  70. package/dist/parseTorrent.js +18 -4
  71. package/dist/parseTorrent.js.map +1 -1
  72. package/dist/pipeline.js +12 -11
  73. package/dist/pipeline.js.map +1 -1
  74. package/dist/problems/linking.js +1 -1
  75. package/dist/problems/linking.js.map +1 -1
  76. package/dist/problems.js +2 -1
  77. package/dist/problems.js.map +1 -1
  78. package/dist/pushNotifier.js +10 -9
  79. package/dist/pushNotifier.js.map +1 -1
  80. package/dist/routes/baseApi.d.ts +8 -0
  81. package/dist/routes/baseApi.js +26 -52
  82. package/dist/routes/baseApi.js.map +1 -1
  83. package/dist/routes/devLogin.js +1 -0
  84. package/dist/routes/devLogin.js.map +1 -1
  85. package/dist/routes/indexerApi.js +1 -0
  86. package/dist/routes/indexerApi.js.map +1 -1
  87. package/dist/routes/staticFrontendPlugin.js +1 -0
  88. package/dist/routes/staticFrontendPlugin.js.map +1 -1
  89. package/dist/searchee.d.ts +14 -2
  90. package/dist/searchee.js +26 -9
  91. package/dist/searchee.js.map +1 -1
  92. package/dist/services/indexerService.js +8 -2
  93. package/dist/services/indexerService.js.map +1 -1
  94. package/dist/startup.d.ts +1 -0
  95. package/dist/startup.js +11 -4
  96. package/dist/startup.js.map +1 -1
  97. package/dist/torrent.js +302 -115
  98. package/dist/torrent.js.map +1 -1
  99. package/dist/torznab.d.ts +2 -2
  100. package/dist/torznab.js +15 -14
  101. package/dist/torznab.js.map +1 -1
  102. package/dist/trpc/routers/auth.js +1 -1
  103. package/dist/trpc/routers/auth.js.map +1 -1
  104. package/dist/trpc/routers/clients.js +8 -13
  105. package/dist/trpc/routers/clients.js.map +1 -1
  106. package/dist/trpc/routers/index.d.ts +51 -50
  107. package/dist/trpc/routers/index.js +2 -2
  108. package/dist/trpc/routers/index.js.map +1 -1
  109. package/dist/trpc/routers/jobs.js +1 -1
  110. package/dist/trpc/routers/jobs.js.map +1 -1
  111. package/dist/trpc/routers/library.d.ts +50 -0
  112. package/dist/trpc/routers/library.js +85 -0
  113. package/dist/trpc/routers/library.js.map +1 -0
  114. package/dist/trpc/routers/logs.js +6 -5
  115. package/dist/trpc/routers/logs.js.map +1 -1
  116. package/dist/trpc/routers/settings.js +78 -21
  117. package/dist/trpc/routers/settings.js.map +1 -1
  118. package/dist/trpc/routers/stats.d.ts +1 -0
  119. package/dist/trpc/routers/stats.js +11 -5
  120. package/dist/trpc/routers/stats.js.map +1 -1
  121. package/dist/userAuth.js +1 -1
  122. package/dist/userAuth.js.map +1 -1
  123. package/dist/utils/background.d.ts +7 -0
  124. package/dist/utils/background.js +14 -0
  125. package/dist/utils/background.js.map +1 -0
  126. package/dist/utils/logWatcher.js +3 -2
  127. package/dist/utils/logWatcher.js.map +1 -1
  128. package/dist/utils.d.ts +11 -1
  129. package/dist/utils.js +47 -8
  130. package/dist/utils.js.map +1 -1
  131. package/dist/webui/assets/DeleteOption-DkdJCiOu.js +1 -0
  132. package/dist/webui/assets/FieldInfo-rcCXc0d-.js +1 -0
  133. package/dist/webui/assets/Page-CKwSnUie.js +1 -0
  134. package/dist/webui/assets/array-field-DM2mAVqa.js +1 -0
  135. package/dist/webui/assets/badge-CLUazitN.js +1 -0
  136. package/dist/webui/assets/button-DoKPR9Fv.js +1 -0
  137. package/dist/webui/assets/check-BlfHpqkp.js +1 -0
  138. package/dist/webui/assets/clients-B5C80D0F.js +1 -0
  139. package/dist/webui/assets/connect-BM7yGLAl.js +2 -0
  140. package/dist/webui/assets/createLucideIcon-Cv-_CLkr.js +1 -0
  141. package/dist/webui/assets/debug-C8d57uIb.js +1 -0
  142. package/dist/webui/assets/directories-DkJnb01t.js +1 -0
  143. package/dist/webui/assets/dist-B7BqKb_s.js +1 -0
  144. package/dist/webui/assets/dist-CXZZv-cf.js +41 -0
  145. package/dist/webui/assets/dist-ChMQZgJB.js +1 -0
  146. package/dist/webui/assets/dist-DQ6Xm99Z.js +1 -0
  147. package/dist/webui/assets/duration-field-w-qiOS_S.js +1 -0
  148. package/dist/webui/assets/general-2HmkyF5T.js +1 -0
  149. package/dist/webui/assets/health-D6tv4ioy.js +1 -0
  150. package/dist/webui/assets/index-NlorOk2I.js +11 -0
  151. package/dist/webui/assets/index-UQKt4Igp.css +2 -0
  152. package/dist/webui/assets/input-BggK3IOz.js +1 -0
  153. package/dist/webui/assets/jobs-Do8vAIqy.js +1 -0
  154. package/dist/webui/assets/library-B1r1nAY-.js +1 -0
  155. package/dist/webui/assets/loader-circle-D988WNxu.js +1 -0
  156. package/dist/webui/assets/logs-_rm8bxf-.js +1 -0
  157. package/dist/webui/assets/number-field-CeKyqI7R.js +1 -0
  158. package/dist/webui/assets/react-dom-DtIef6y6.js +1 -0
  159. package/dist/webui/assets/required-indicator-Ba9NOQEP.js +1 -0
  160. package/dist/webui/assets/routes-Djgf7dZI.js +1 -0
  161. package/dist/webui/assets/search-DGY0ui92.js +1 -0
  162. package/dist/webui/assets/select-BzZ418Yt.js +1 -0
  163. package/dist/webui/assets/select-field-DsBowTDT.js +1 -0
  164. package/dist/webui/assets/settings-B4G8vHXc.js +1 -0
  165. package/dist/webui/assets/sidebar-Qy-rYdhU.js +5 -0
  166. package/dist/webui/assets/submit-button-Bx2Dvr03.js +1 -0
  167. package/dist/webui/assets/switch-CttdmVGp.js +1 -0
  168. package/dist/webui/assets/switch-field-p-JPVVvW.js +1 -0
  169. package/dist/webui/assets/table-Bs6CQscS.js +1 -0
  170. package/dist/webui/assets/{test-tube-CbcievIk.js → test-tube-DD9Yz2bZ.js} +1 -1
  171. package/dist/webui/assets/text-field-B0a3dEGb.js +1 -0
  172. package/dist/webui/assets/time-KFQKyrl-.js +1 -0
  173. package/dist/webui/assets/trackers-DG-YCaaO.js +7 -0
  174. package/dist/webui/assets/{trash-D083IWKI.js → trash-PHXIGUCt.js} +1 -1
  175. package/dist/webui/assets/use-settings-form-submit-CDmMUcwW.js +57 -0
  176. package/dist/webui/assets/useSelector-BoN-mufS.js +2 -0
  177. package/dist/webui/assets/utils-P-unlvb4.js +1 -0
  178. package/dist/webui/assets/with-selector-fbK2t2oY.js +1 -0
  179. package/dist/webui/index.html +12 -14
  180. package/node_modules/@cross-seed/shared/dist/tsconfig.tsbuildinfo +1 -1
  181. package/node_modules/@cross-seed/shared/package.json +6 -2
  182. package/node_modules/zod/README.md +30 -20
  183. package/node_modules/zod/compile.cjs +96 -0
  184. package/node_modules/zod/compile.d.cts +1 -0
  185. package/node_modules/zod/compile.d.ts +1 -0
  186. package/node_modules/zod/compile.js +52 -0
  187. package/node_modules/zod/index.cjs +21 -2
  188. package/node_modules/zod/index.d.cts +1 -2
  189. package/node_modules/zod/index.d.ts +1 -2
  190. package/node_modules/zod/index.js +5 -2
  191. package/node_modules/zod/locales/index.cjs +19 -0
  192. package/node_modules/zod/locales/package.json +2 -1
  193. package/node_modules/zod/mini/index.cjs +19 -0
  194. package/node_modules/zod/mini/package.json +2 -1
  195. package/node_modules/zod/package.json +20 -8
  196. package/node_modules/zod/src/compile.ts +56 -0
  197. package/node_modules/zod/src/index.ts +5 -2
  198. package/node_modules/zod/src/v3/ZodError.ts +22 -12
  199. package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
  200. package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
  201. package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
  202. package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
  203. package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
  204. package/node_modules/zod/src/v3/tests/object.test.ts +8 -11
  205. package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
  206. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
  207. package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
  208. package/node_modules/zod/src/v3/types.ts +5 -5
  209. package/node_modules/zod/src/v4/classic/checks.ts +1 -0
  210. package/node_modules/zod/src/v4/classic/compat.ts +26 -18
  211. package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
  212. package/node_modules/zod/src/v4/classic/errors.ts +60 -45
  213. package/node_modules/zod/src/v4/classic/external.ts +15 -9
  214. package/node_modules/zod/src/v4/classic/from-json-schema.ts +389 -88
  215. package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
  216. package/node_modules/zod/src/v4/classic/index.ts +2 -2
  217. package/node_modules/zod/src/v4/classic/iso.ts +2 -72
  218. package/node_modules/zod/src/v4/classic/parse.ts +16 -10
  219. package/node_modules/zod/src/v4/classic/schemas.ts +863 -335
  220. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
  221. package/node_modules/zod/src/v4/classic/tests/array.test.ts +29 -2
  222. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +192 -0
  223. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
  224. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +328 -0
  225. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
  226. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +144 -2
  227. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +4 -4
  228. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
  229. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
  230. package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
  231. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +31 -17
  232. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
  233. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
  234. package/node_modules/zod/src/v4/classic/tests/default.test.ts +90 -0
  235. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +221 -0
  236. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +291 -10
  237. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
  238. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +324 -2
  239. package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
  240. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +743 -10
  241. package/node_modules/zod/src/v4/classic/tests/function.test.ts +37 -6
  242. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +32 -0
  243. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
  244. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
  245. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
  246. package/node_modules/zod/src/v4/classic/tests/index.test.ts +23 -4
  247. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
  248. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -0
  249. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
  250. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
  251. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
  252. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
  253. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
  254. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
  255. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
  256. package/node_modules/zod/src/v4/classic/tests/map.test.ts +19 -0
  257. package/node_modules/zod/src/v4/classic/tests/number.test.ts +138 -7
  258. package/node_modules/zod/src/v4/classic/tests/object.test.ts +378 -12
  259. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
  260. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +156 -13
  261. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +71 -1
  262. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +71 -1
  263. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +44 -0
  264. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +69 -0
  265. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
  266. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
  267. package/node_modules/zod/src/v4/classic/tests/record.test.ts +269 -16
  268. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +126 -1
  269. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
  270. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +123 -0
  271. package/node_modules/zod/src/v4/classic/tests/set.test.ts +15 -0
  272. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
  273. package/node_modules/zod/src/v4/classic/tests/string.test.ts +269 -4
  274. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
  275. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +48 -7
  276. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1948 -205
  277. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
  278. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +330 -2
  279. package/node_modules/zod/src/v4/classic/tests/union.test.ts +93 -2
  280. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
  281. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
  282. package/node_modules/zod/src/v4/core/api.ts +111 -34
  283. package/node_modules/zod/src/v4/core/checks.ts +120 -147
  284. package/node_modules/zod/src/v4/core/compile.ts +2322 -0
  285. package/node_modules/zod/src/v4/core/core.ts +116 -24
  286. package/node_modules/zod/src/v4/core/doc.ts +17 -9
  287. package/node_modules/zod/src/v4/core/errors.ts +138 -43
  288. package/node_modules/zod/src/v4/core/index.ts +3 -0
  289. package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
  290. package/node_modules/zod/src/v4/core/json-schema-processors.ts +440 -173
  291. package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
  292. package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
  293. package/node_modules/zod/src/v4/core/parse.ts +167 -53
  294. package/node_modules/zod/src/v4/core/regexes.ts +50 -16
  295. package/node_modules/zod/src/v4/core/registries.ts +2 -2
  296. package/node_modules/zod/src/v4/core/schemas.ts +1219 -531
  297. package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
  298. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
  299. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
  300. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
  301. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
  302. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
  303. package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
  304. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
  305. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +214 -0
  306. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
  307. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
  308. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
  309. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
  310. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
  311. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
  312. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
  313. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
  314. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
  315. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
  316. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
  317. package/node_modules/zod/src/v4/core/to-json-schema.ts +288 -44
  318. package/node_modules/zod/src/v4/core/util.ts +506 -179
  319. package/node_modules/zod/src/v4/core/versions.ts +2 -2
  320. package/node_modules/zod/src/v4/core/visit.ts +193 -0
  321. package/node_modules/zod/src/v4/index.ts +3 -3
  322. package/node_modules/zod/src/v4/locales/ar.ts +5 -0
  323. package/node_modules/zod/src/v4/locales/az.ts +5 -0
  324. package/node_modules/zod/src/v4/locales/be.ts +12 -0
  325. package/node_modules/zod/src/v4/locales/bg.ts +5 -0
  326. package/node_modules/zod/src/v4/locales/bn.ts +123 -0
  327. package/node_modules/zod/src/v4/locales/ca.ts +5 -0
  328. package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
  329. package/node_modules/zod/src/v4/locales/cs.ts +5 -0
  330. package/node_modules/zod/src/v4/locales/da.ts +7 -2
  331. package/node_modules/zod/src/v4/locales/de.ts +5 -0
  332. package/node_modules/zod/src/v4/locales/el.ts +124 -0
  333. package/node_modules/zod/src/v4/locales/en.ts +21 -4
  334. package/node_modules/zod/src/v4/locales/eo.ts +5 -0
  335. package/node_modules/zod/src/v4/locales/es.ts +4 -0
  336. package/node_modules/zod/src/v4/locales/fa.ts +5 -0
  337. package/node_modules/zod/src/v4/locales/fi.ts +5 -0
  338. package/node_modules/zod/src/v4/locales/fr-CA.ts +5 -0
  339. package/node_modules/zod/src/v4/locales/fr.ts +41 -18
  340. package/node_modules/zod/src/v4/locales/gu.ts +123 -0
  341. package/node_modules/zod/src/v4/locales/he.ts +8 -1
  342. package/node_modules/zod/src/v4/locales/hi.ts +126 -0
  343. package/node_modules/zod/src/v4/locales/hr.ts +135 -0
  344. package/node_modules/zod/src/v4/locales/hu.ts +5 -0
  345. package/node_modules/zod/src/v4/locales/hy.ts +11 -0
  346. package/node_modules/zod/src/v4/locales/id.ts +5 -0
  347. package/node_modules/zod/src/v4/locales/index.ts +14 -0
  348. package/node_modules/zod/src/v4/locales/is.ts +5 -0
  349. package/node_modules/zod/src/v4/locales/it.ts +6 -1
  350. package/node_modules/zod/src/v4/locales/ja.ts +5 -0
  351. package/node_modules/zod/src/v4/locales/ka.ts +13 -8
  352. package/node_modules/zod/src/v4/locales/km.ts +5 -0
  353. package/node_modules/zod/src/v4/locales/kn.ts +126 -0
  354. package/node_modules/zod/src/v4/locales/ko.ts +5 -0
  355. package/node_modules/zod/src/v4/locales/lt.ts +4 -0
  356. package/node_modules/zod/src/v4/locales/mk.ts +5 -0
  357. package/node_modules/zod/src/v4/locales/ms.ts +5 -0
  358. package/node_modules/zod/src/v4/locales/ne.ts +128 -0
  359. package/node_modules/zod/src/v4/locales/nl.ts +5 -0
  360. package/node_modules/zod/src/v4/locales/nn.ts +121 -0
  361. package/node_modules/zod/src/v4/locales/no.ts +7 -2
  362. package/node_modules/zod/src/v4/locales/ota.ts +5 -0
  363. package/node_modules/zod/src/v4/locales/pl.ts +5 -0
  364. package/node_modules/zod/src/v4/locales/ps.ts +5 -0
  365. package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
  366. package/node_modules/zod/src/v4/locales/pt.ts +101 -58
  367. package/node_modules/zod/src/v4/locales/ro.ts +132 -0
  368. package/node_modules/zod/src/v4/locales/ru.ts +12 -0
  369. package/node_modules/zod/src/v4/locales/sk.ts +123 -0
  370. package/node_modules/zod/src/v4/locales/sl.ts +5 -0
  371. package/node_modules/zod/src/v4/locales/sv.ts +7 -2
  372. package/node_modules/zod/src/v4/locales/ta.ts +5 -0
  373. package/node_modules/zod/src/v4/locales/tg.ts +135 -0
  374. package/node_modules/zod/src/v4/locales/th.ts +5 -0
  375. package/node_modules/zod/src/v4/locales/tk.ts +113 -0
  376. package/node_modules/zod/src/v4/locales/tr.ts +5 -0
  377. package/node_modules/zod/src/v4/locales/uk.ts +5 -0
  378. package/node_modules/zod/src/v4/locales/ur.ts +5 -0
  379. package/node_modules/zod/src/v4/locales/uz.ts +4 -0
  380. package/node_modules/zod/src/v4/locales/vi.ts +5 -0
  381. package/node_modules/zod/src/v4/locales/yo.ts +5 -0
  382. package/node_modules/zod/src/v4/locales/zh-CN.ts +5 -0
  383. package/node_modules/zod/src/v4/locales/zh-TW.ts +5 -0
  384. package/node_modules/zod/src/v4/mini/checks.ts +1 -0
  385. package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
  386. package/node_modules/zod/src/v4/mini/external.ts +13 -1
  387. package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
  388. package/node_modules/zod/src/v4/mini/parse.ts +2 -0
  389. package/node_modules/zod/src/v4/mini/schemas.ts +214 -79
  390. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
  391. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
  392. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
  393. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +54 -1
  394. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
  395. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
  396. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
  397. package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
  398. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
  399. package/node_modules/zod/src/v4/mini/tests/index.test.ts +187 -4
  400. package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
  401. package/node_modules/zod/src/v4/mini/tests/object.test.ts +74 -9
  402. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +67 -1
  403. package/node_modules/zod/src/v4/mini/tests/string.test.ts +49 -0
  404. package/node_modules/zod/v3/ZodError.cjs +41 -12
  405. package/node_modules/zod/v3/ZodError.d.cts +1 -1
  406. package/node_modules/zod/v3/ZodError.d.ts +1 -1
  407. package/node_modules/zod/v3/ZodError.js +22 -12
  408. package/node_modules/zod/v3/errors.cjs +19 -0
  409. package/node_modules/zod/v3/external.cjs +19 -0
  410. package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
  411. package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
  412. package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
  413. package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
  414. package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
  415. package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
  416. package/node_modules/zod/v3/helpers/util.cjs +19 -0
  417. package/node_modules/zod/v3/index.cjs +19 -0
  418. package/node_modules/zod/v3/package.json +2 -1
  419. package/node_modules/zod/v3/standard-schema.cjs +19 -0
  420. package/node_modules/zod/v3/types.cjs +26 -5
  421. package/node_modules/zod/v3/types.js +7 -5
  422. package/node_modules/zod/v4/classic/checks.cjs +21 -1
  423. package/node_modules/zod/v4/classic/checks.d.cts +1 -1
  424. package/node_modules/zod/v4/classic/checks.d.ts +1 -1
  425. package/node_modules/zod/v4/classic/checks.js +1 -1
  426. package/node_modules/zod/v4/classic/coerce.cjs +19 -0
  427. package/node_modules/zod/v4/classic/compat.cjs +19 -0
  428. package/node_modules/zod/v4/classic/compat.d.cts +9 -11
  429. package/node_modules/zod/v4/classic/compat.d.ts +9 -11
  430. package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
  431. package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
  432. package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
  433. package/node_modules/zod/v4/classic/deep-partial.js +13 -0
  434. package/node_modules/zod/v4/classic/errors.cjs +62 -34
  435. package/node_modules/zod/v4/classic/errors.d.cts +3 -4
  436. package/node_modules/zod/v4/classic/errors.d.ts +3 -4
  437. package/node_modules/zod/v4/classic/errors.js +44 -35
  438. package/node_modules/zod/v4/classic/external.cjs +51 -27
  439. package/node_modules/zod/v4/classic/external.d.cts +6 -2
  440. package/node_modules/zod/v4/classic/external.d.ts +6 -2
  441. package/node_modules/zod/v4/classic/external.js +5 -8
  442. package/node_modules/zod/v4/classic/from-json-schema.cjs +394 -78
  443. package/node_modules/zod/v4/classic/from-json-schema.js +375 -78
  444. package/node_modules/zod/v4/classic/in-out.cjs +82 -0
  445. package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
  446. package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
  447. package/node_modules/zod/v4/classic/in-out.js +36 -0
  448. package/node_modules/zod/v4/classic/index.cjs +21 -2
  449. package/node_modules/zod/v4/classic/index.d.cts +1 -2
  450. package/node_modules/zod/v4/classic/index.d.ts +1 -2
  451. package/node_modules/zod/v4/classic/index.js +2 -2
  452. package/node_modules/zod/v4/classic/iso.cjs +30 -22
  453. package/node_modules/zod/v4/classic/iso.d.cts +2 -17
  454. package/node_modules/zod/v4/classic/iso.d.ts +2 -17
  455. package/node_modules/zod/v4/classic/iso.js +2 -17
  456. package/node_modules/zod/v4/classic/package.json +2 -1
  457. package/node_modules/zod/v4/classic/parse.cjs +23 -1
  458. package/node_modules/zod/v4/classic/parse.d.cts +17 -4
  459. package/node_modules/zod/v4/classic/parse.d.ts +17 -4
  460. package/node_modules/zod/v4/classic/parse.js +1 -0
  461. package/node_modules/zod/v4/classic/schemas.cjs +629 -225
  462. package/node_modules/zod/v4/classic/schemas.d.cts +104 -27
  463. package/node_modules/zod/v4/classic/schemas.d.ts +104 -27
  464. package/node_modules/zod/v4/classic/schemas.js +601 -223
  465. package/node_modules/zod/v4/core/api.cjs +73 -26
  466. package/node_modules/zod/v4/core/api.d.cts +40 -9
  467. package/node_modules/zod/v4/core/api.d.ts +40 -9
  468. package/node_modules/zod/v4/core/api.js +51 -26
  469. package/node_modules/zod/v4/core/checks.cjs +88 -128
  470. package/node_modules/zod/v4/core/checks.d.cts +30 -14
  471. package/node_modules/zod/v4/core/checks.d.ts +30 -14
  472. package/node_modules/zod/v4/core/checks.js +68 -127
  473. package/node_modules/zod/v4/core/compile.cjs +1916 -0
  474. package/node_modules/zod/v4/core/compile.d.cts +65 -0
  475. package/node_modules/zod/v4/core/compile.d.ts +65 -0
  476. package/node_modules/zod/v4/core/compile.js +1866 -0
  477. package/node_modules/zod/v4/core/core.cjs +104 -20
  478. package/node_modules/zod/v4/core/core.d.cts +16 -4
  479. package/node_modules/zod/v4/core/core.d.ts +16 -4
  480. package/node_modules/zod/v4/core/core.js +87 -22
  481. package/node_modules/zod/v4/core/doc.cjs +31 -9
  482. package/node_modules/zod/v4/core/doc.d.cts +3 -1
  483. package/node_modules/zod/v4/core/doc.d.ts +3 -1
  484. package/node_modules/zod/v4/core/doc.js +12 -9
  485. package/node_modules/zod/v4/core/errors.cjs +146 -42
  486. package/node_modules/zod/v4/core/errors.d.cts +5 -0
  487. package/node_modules/zod/v4/core/errors.d.ts +5 -0
  488. package/node_modules/zod/v4/core/errors.js +127 -42
  489. package/node_modules/zod/v4/core/index.cjs +24 -1
  490. package/node_modules/zod/v4/core/index.d.cts +3 -0
  491. package/node_modules/zod/v4/core/index.d.ts +3 -0
  492. package/node_modules/zod/v4/core/index.js +3 -0
  493. package/node_modules/zod/v4/core/json-schema-generator.cjs +24 -1
  494. package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
  495. package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
  496. package/node_modules/zod/v4/core/json-schema-generator.js +6 -2
  497. package/node_modules/zod/v4/core/json-schema-processors.cjs +454 -173
  498. package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
  499. package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
  500. package/node_modules/zod/v4/core/json-schema-processors.js +413 -175
  501. package/node_modules/zod/v4/core/json-schema.cjs +19 -0
  502. package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
  503. package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
  504. package/node_modules/zod/v4/core/memoizer.cjs +360 -0
  505. package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
  506. package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
  507. package/node_modules/zod/v4/core/memoizer.js +311 -0
  508. package/node_modules/zod/v4/core/package.json +2 -1
  509. package/node_modules/zod/v4/core/parse.cjs +151 -49
  510. package/node_modules/zod/v4/core/parse.d.cts +14 -11
  511. package/node_modules/zod/v4/core/parse.d.ts +14 -11
  512. package/node_modules/zod/v4/core/parse.js +130 -48
  513. package/node_modules/zod/v4/core/regexes.cjs +61 -18
  514. package/node_modules/zod/v4/core/regexes.d.cts +11 -0
  515. package/node_modules/zod/v4/core/regexes.d.ts +11 -0
  516. package/node_modules/zod/v4/core/regexes.js +39 -16
  517. package/node_modules/zod/v4/core/registries.cjs +19 -0
  518. package/node_modules/zod/v4/core/registries.js +2 -2
  519. package/node_modules/zod/v4/core/schemas.cjs +957 -382
  520. package/node_modules/zod/v4/core/schemas.d.cts +154 -25
  521. package/node_modules/zod/v4/core/schemas.d.ts +154 -25
  522. package/node_modules/zod/v4/core/schemas.js +925 -382
  523. package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
  524. package/node_modules/zod/v4/core/to-json-schema.cjs +275 -40
  525. package/node_modules/zod/v4/core/to-json-schema.d.cts +45 -5
  526. package/node_modules/zod/v4/core/to-json-schema.d.ts +45 -5
  527. package/node_modules/zod/v4/core/to-json-schema.js +253 -39
  528. package/node_modules/zod/v4/core/util.cjs +428 -174
  529. package/node_modules/zod/v4/core/util.d.cts +82 -1
  530. package/node_modules/zod/v4/core/util.d.ts +82 -1
  531. package/node_modules/zod/v4/core/util.js +397 -175
  532. package/node_modules/zod/v4/core/versions.cjs +21 -2
  533. package/node_modules/zod/v4/core/versions.d.cts +1 -1
  534. package/node_modules/zod/v4/core/versions.d.ts +1 -1
  535. package/node_modules/zod/v4/core/versions.js +2 -2
  536. package/node_modules/zod/v4/core/visit.cjs +214 -0
  537. package/node_modules/zod/v4/core/visit.d.cts +30 -0
  538. package/node_modules/zod/v4/core/visit.d.ts +30 -0
  539. package/node_modules/zod/v4/core/visit.js +169 -0
  540. package/node_modules/zod/v4/index.cjs +34 -5
  541. package/node_modules/zod/v4/index.d.cts +2 -2
  542. package/node_modules/zod/v4/index.d.ts +2 -2
  543. package/node_modules/zod/v4/index.js +3 -2
  544. package/node_modules/zod/v4/locales/ar.cjs +5 -0
  545. package/node_modules/zod/v4/locales/ar.js +5 -0
  546. package/node_modules/zod/v4/locales/az.cjs +5 -0
  547. package/node_modules/zod/v4/locales/az.js +5 -0
  548. package/node_modules/zod/v4/locales/be.cjs +12 -0
  549. package/node_modules/zod/v4/locales/be.js +12 -0
  550. package/node_modules/zod/v4/locales/bg.cjs +5 -0
  551. package/node_modules/zod/v4/locales/bg.js +5 -0
  552. package/node_modules/zod/v4/locales/bn.cjs +140 -0
  553. package/node_modules/zod/v4/locales/bn.d.cts +5 -0
  554. package/node_modules/zod/v4/locales/bn.d.ts +4 -0
  555. package/node_modules/zod/v4/locales/bn.js +113 -0
  556. package/node_modules/zod/v4/locales/ca.cjs +5 -0
  557. package/node_modules/zod/v4/locales/ca.js +5 -0
  558. package/node_modules/zod/v4/locales/ckb.cjs +160 -0
  559. package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
  560. package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
  561. package/node_modules/zod/v4/locales/ckb.js +133 -0
  562. package/node_modules/zod/v4/locales/cs.cjs +5 -0
  563. package/node_modules/zod/v4/locales/cs.js +5 -0
  564. package/node_modules/zod/v4/locales/da.cjs +7 -2
  565. package/node_modules/zod/v4/locales/da.js +7 -2
  566. package/node_modules/zod/v4/locales/de.cjs +5 -0
  567. package/node_modules/zod/v4/locales/de.js +5 -0
  568. package/node_modules/zod/v4/locales/el.cjs +139 -0
  569. package/node_modules/zod/v4/locales/el.d.cts +5 -0
  570. package/node_modules/zod/v4/locales/el.d.ts +4 -0
  571. package/node_modules/zod/v4/locales/el.js +112 -0
  572. package/node_modules/zod/v4/locales/en.cjs +20 -4
  573. package/node_modules/zod/v4/locales/en.js +20 -4
  574. package/node_modules/zod/v4/locales/eo.cjs +5 -0
  575. package/node_modules/zod/v4/locales/eo.js +5 -0
  576. package/node_modules/zod/v4/locales/es.cjs +4 -0
  577. package/node_modules/zod/v4/locales/es.js +4 -0
  578. package/node_modules/zod/v4/locales/fa.cjs +5 -0
  579. package/node_modules/zod/v4/locales/fa.js +5 -0
  580. package/node_modules/zod/v4/locales/fi.cjs +5 -0
  581. package/node_modules/zod/v4/locales/fi.js +5 -0
  582. package/node_modules/zod/v4/locales/fr-CA.cjs +5 -0
  583. package/node_modules/zod/v4/locales/fr-CA.js +5 -0
  584. package/node_modules/zod/v4/locales/fr.cjs +38 -17
  585. package/node_modules/zod/v4/locales/fr.js +38 -17
  586. package/node_modules/zod/v4/locales/gu.cjs +140 -0
  587. package/node_modules/zod/v4/locales/gu.d.cts +5 -0
  588. package/node_modules/zod/v4/locales/gu.d.ts +4 -0
  589. package/node_modules/zod/v4/locales/gu.js +113 -0
  590. package/node_modules/zod/v4/locales/he.cjs +7 -0
  591. package/node_modules/zod/v4/locales/he.js +7 -0
  592. package/node_modules/zod/v4/locales/hi.cjs +138 -0
  593. package/node_modules/zod/v4/locales/hi.d.cts +5 -0
  594. package/node_modules/zod/v4/locales/hi.d.ts +4 -0
  595. package/node_modules/zod/v4/locales/hi.js +111 -0
  596. package/node_modules/zod/v4/locales/hr.cjs +153 -0
  597. package/node_modules/zod/v4/locales/hr.d.cts +5 -0
  598. package/node_modules/zod/v4/locales/hr.d.ts +4 -0
  599. package/node_modules/zod/v4/locales/hr.js +126 -0
  600. package/node_modules/zod/v4/locales/hu.cjs +5 -0
  601. package/node_modules/zod/v4/locales/hu.js +5 -0
  602. package/node_modules/zod/v4/locales/hy.cjs +11 -0
  603. package/node_modules/zod/v4/locales/hy.js +11 -0
  604. package/node_modules/zod/v4/locales/id.cjs +5 -0
  605. package/node_modules/zod/v4/locales/id.js +5 -0
  606. package/node_modules/zod/v4/locales/index.cjs +49 -1
  607. package/node_modules/zod/v4/locales/index.d.cts +14 -0
  608. package/node_modules/zod/v4/locales/index.d.ts +14 -0
  609. package/node_modules/zod/v4/locales/index.js +14 -0
  610. package/node_modules/zod/v4/locales/is.cjs +5 -0
  611. package/node_modules/zod/v4/locales/is.js +5 -0
  612. package/node_modules/zod/v4/locales/it.cjs +6 -1
  613. package/node_modules/zod/v4/locales/it.js +6 -1
  614. package/node_modules/zod/v4/locales/ja.cjs +5 -0
  615. package/node_modules/zod/v4/locales/ja.js +5 -0
  616. package/node_modules/zod/v4/locales/ka.cjs +13 -8
  617. package/node_modules/zod/v4/locales/ka.js +13 -8
  618. package/node_modules/zod/v4/locales/km.cjs +5 -0
  619. package/node_modules/zod/v4/locales/km.js +5 -0
  620. package/node_modules/zod/v4/locales/kn.cjs +143 -0
  621. package/node_modules/zod/v4/locales/kn.d.cts +5 -0
  622. package/node_modules/zod/v4/locales/kn.d.ts +4 -0
  623. package/node_modules/zod/v4/locales/kn.js +116 -0
  624. package/node_modules/zod/v4/locales/ko.cjs +5 -0
  625. package/node_modules/zod/v4/locales/ko.js +5 -0
  626. package/node_modules/zod/v4/locales/lt.cjs +4 -0
  627. package/node_modules/zod/v4/locales/lt.js +4 -0
  628. package/node_modules/zod/v4/locales/mk.cjs +5 -0
  629. package/node_modules/zod/v4/locales/mk.js +5 -0
  630. package/node_modules/zod/v4/locales/ms.cjs +5 -0
  631. package/node_modules/zod/v4/locales/ms.js +5 -0
  632. package/node_modules/zod/v4/locales/ne.cjs +138 -0
  633. package/node_modules/zod/v4/locales/ne.d.cts +5 -0
  634. package/node_modules/zod/v4/locales/ne.d.ts +4 -0
  635. package/node_modules/zod/v4/locales/ne.js +111 -0
  636. package/node_modules/zod/v4/locales/nl.cjs +5 -0
  637. package/node_modules/zod/v4/locales/nl.js +5 -0
  638. package/node_modules/zod/v4/locales/nn.cjs +140 -0
  639. package/node_modules/zod/v4/locales/nn.d.cts +5 -0
  640. package/node_modules/zod/v4/locales/nn.d.ts +4 -0
  641. package/node_modules/zod/v4/locales/nn.js +113 -0
  642. package/node_modules/zod/v4/locales/no.cjs +7 -2
  643. package/node_modules/zod/v4/locales/no.js +7 -2
  644. package/node_modules/zod/v4/locales/ota.cjs +5 -0
  645. package/node_modules/zod/v4/locales/ota.js +5 -0
  646. package/node_modules/zod/v4/locales/package.json +2 -1
  647. package/node_modules/zod/v4/locales/pl.cjs +5 -0
  648. package/node_modules/zod/v4/locales/pl.js +5 -0
  649. package/node_modules/zod/v4/locales/ps.cjs +5 -0
  650. package/node_modules/zod/v4/locales/ps.js +5 -0
  651. package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
  652. package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
  653. package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
  654. package/node_modules/zod/v4/locales/pt-BR.js +143 -0
  655. package/node_modules/zod/v4/locales/pt.cjs +89 -55
  656. package/node_modules/zod/v4/locales/pt.js +89 -55
  657. package/node_modules/zod/v4/locales/ro.cjs +149 -0
  658. package/node_modules/zod/v4/locales/ro.d.cts +5 -0
  659. package/node_modules/zod/v4/locales/ro.d.ts +4 -0
  660. package/node_modules/zod/v4/locales/ro.js +122 -0
  661. package/node_modules/zod/v4/locales/ru.cjs +12 -0
  662. package/node_modules/zod/v4/locales/ru.js +12 -0
  663. package/node_modules/zod/v4/locales/sk.cjs +143 -0
  664. package/node_modules/zod/v4/locales/sk.d.cts +5 -0
  665. package/node_modules/zod/v4/locales/sk.d.ts +4 -0
  666. package/node_modules/zod/v4/locales/sk.js +116 -0
  667. package/node_modules/zod/v4/locales/sl.cjs +5 -0
  668. package/node_modules/zod/v4/locales/sl.js +5 -0
  669. package/node_modules/zod/v4/locales/sv.cjs +7 -2
  670. package/node_modules/zod/v4/locales/sv.js +7 -2
  671. package/node_modules/zod/v4/locales/ta.cjs +5 -0
  672. package/node_modules/zod/v4/locales/ta.js +5 -0
  673. package/node_modules/zod/v4/locales/tg.cjs +144 -0
  674. package/node_modules/zod/v4/locales/tg.d.cts +5 -0
  675. package/node_modules/zod/v4/locales/tg.d.ts +4 -0
  676. package/node_modules/zod/v4/locales/tg.js +117 -0
  677. package/node_modules/zod/v4/locales/th.cjs +5 -0
  678. package/node_modules/zod/v4/locales/th.js +5 -0
  679. package/node_modules/zod/v4/locales/tk.cjs +134 -0
  680. package/node_modules/zod/v4/locales/tk.d.cts +5 -0
  681. package/node_modules/zod/v4/locales/tk.d.ts +4 -0
  682. package/node_modules/zod/v4/locales/tk.js +107 -0
  683. package/node_modules/zod/v4/locales/tr.cjs +5 -0
  684. package/node_modules/zod/v4/locales/tr.js +5 -0
  685. package/node_modules/zod/v4/locales/uk.cjs +5 -0
  686. package/node_modules/zod/v4/locales/uk.js +5 -0
  687. package/node_modules/zod/v4/locales/ur.cjs +5 -0
  688. package/node_modules/zod/v4/locales/ur.js +5 -0
  689. package/node_modules/zod/v4/locales/uz.cjs +4 -0
  690. package/node_modules/zod/v4/locales/uz.js +4 -0
  691. package/node_modules/zod/v4/locales/vi.cjs +5 -0
  692. package/node_modules/zod/v4/locales/vi.js +5 -0
  693. package/node_modules/zod/v4/locales/yo.cjs +5 -0
  694. package/node_modules/zod/v4/locales/yo.js +5 -0
  695. package/node_modules/zod/v4/locales/zh-CN.cjs +5 -0
  696. package/node_modules/zod/v4/locales/zh-CN.js +5 -0
  697. package/node_modules/zod/v4/locales/zh-TW.cjs +5 -0
  698. package/node_modules/zod/v4/locales/zh-TW.js +5 -0
  699. package/node_modules/zod/v4/mini/checks.cjs +21 -1
  700. package/node_modules/zod/v4/mini/checks.d.cts +1 -1
  701. package/node_modules/zod/v4/mini/checks.d.ts +1 -1
  702. package/node_modules/zod/v4/mini/checks.js +1 -1
  703. package/node_modules/zod/v4/mini/coerce.cjs +19 -0
  704. package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
  705. package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
  706. package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
  707. package/node_modules/zod/v4/mini/deep-partial.js +13 -0
  708. package/node_modules/zod/v4/mini/external.cjs +33 -1
  709. package/node_modules/zod/v4/mini/external.d.cts +6 -2
  710. package/node_modules/zod/v4/mini/external.d.ts +6 -2
  711. package/node_modules/zod/v4/mini/external.js +3 -1
  712. package/node_modules/zod/v4/mini/in-out.cjs +82 -0
  713. package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
  714. package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
  715. package/node_modules/zod/v4/mini/in-out.js +36 -0
  716. package/node_modules/zod/v4/mini/index.cjs +19 -0
  717. package/node_modules/zod/v4/mini/iso.cjs +19 -0
  718. package/node_modules/zod/v4/mini/package.json +2 -1
  719. package/node_modules/zod/v4/mini/parse.cjs +22 -1
  720. package/node_modules/zod/v4/mini/parse.d.cts +1 -1
  721. package/node_modules/zod/v4/mini/parse.d.ts +1 -1
  722. package/node_modules/zod/v4/mini/parse.js +1 -1
  723. package/node_modules/zod/v4/mini/schemas.cjs +151 -50
  724. package/node_modules/zod/v4/mini/schemas.d.cts +75 -22
  725. package/node_modules/zod/v4/mini/schemas.d.ts +75 -22
  726. package/node_modules/zod/v4/mini/schemas.js +125 -48
  727. package/node_modules/zod/v4/package.json +2 -1
  728. package/node_modules/zod/v4-mini/index.cjs +19 -0
  729. package/node_modules/zod/v4-mini/package.json +2 -1
  730. package/package.json +16 -14
  731. package/dist/trpc/routers/searchees.d.ts +0 -51
  732. package/dist/trpc/routers/searchees.js +0 -156
  733. package/dist/trpc/routers/searchees.js.map +0 -1
  734. package/dist/webui/assets/ClientOnly-CzZIsGML.js +0 -1
  735. package/dist/webui/assets/DeleteOption-dxKSbv6N.js +0 -1
  736. package/dist/webui/assets/FieldInfo-FLjtPgL4.js +0 -1
  737. package/dist/webui/assets/Page-C7KClZ28.js +0 -1
  738. package/dist/webui/assets/array-field-DGB7Lbh7.js +0 -1
  739. package/dist/webui/assets/badge-hukNSIir.js +0 -1
  740. package/dist/webui/assets/button-1cIaa9Lf.js +0 -1
  741. package/dist/webui/assets/check-CUrWQ2C7.js +0 -1
  742. package/dist/webui/assets/chevron-down-CVVogpPh.js +0 -1
  743. package/dist/webui/assets/clients-CHdgqO4r.js +0 -1
  744. package/dist/webui/assets/connect-Cr6Q3W8U.js +0 -2
  745. package/dist/webui/assets/createLucideIcon-zYRS_Hrv.js +0 -1
  746. package/dist/webui/assets/debug-CEmoQ2W_.js +0 -1
  747. package/dist/webui/assets/directories-CNuHKfHz.js +0 -1
  748. package/dist/webui/assets/dist-Bbmh5Du9.js +0 -1
  749. package/dist/webui/assets/dist-DhH_lYkz.js +0 -1
  750. package/dist/webui/assets/dist-DzdkRn7I.js +0 -1
  751. package/dist/webui/assets/dist-b2njvUJz.js +0 -41
  752. package/dist/webui/assets/dist-d-Lt00zD.js +0 -1
  753. package/dist/webui/assets/duration-field-CnlQcr37.js +0 -1
  754. package/dist/webui/assets/form-context-B-ekdUc0.js +0 -1
  755. package/dist/webui/assets/form-validation-context-CPAPOloL.js +0 -1
  756. package/dist/webui/assets/general-Cs8dEydJ.js +0 -1
  757. package/dist/webui/assets/health-DugF7R6A.js +0 -1
  758. package/dist/webui/assets/index-DhV1H9AB.css +0 -2
  759. package/dist/webui/assets/index-DinSQfHc.js +0 -11
  760. package/dist/webui/assets/input-CsfmMUT5.js +0 -1
  761. package/dist/webui/assets/jobs-Cr1xWWzM.js +0 -1
  762. package/dist/webui/assets/library-BNsctrbc.js +0 -1
  763. package/dist/webui/assets/loader-circle-BQbzoYGJ.js +0 -1
  764. package/dist/webui/assets/logs-C1l3cu_j.js +0 -1
  765. package/dist/webui/assets/number-field-Ce3QdLSz.js +0 -1
  766. package/dist/webui/assets/react-dom-mEftaaxx.js +0 -1
  767. package/dist/webui/assets/required-indicator-BXf2UzTH.js +0 -1
  768. package/dist/webui/assets/routes-Bw2nXmFg.js +0 -1
  769. package/dist/webui/assets/search-D9W5vk_0.js +0 -1
  770. package/dist/webui/assets/select-CZn10WME.js +0 -1
  771. package/dist/webui/assets/select-field-DozTirAZ.js +0 -1
  772. package/dist/webui/assets/settings-BXbhXNDK.js +0 -1
  773. package/dist/webui/assets/sidebar-y9WJu7Jw.js +0 -5
  774. package/dist/webui/assets/submit-button-CBOzR0f_.js +0 -1
  775. package/dist/webui/assets/switch-D4S9As9u.js +0 -1
  776. package/dist/webui/assets/switch-field-2E9ctvy_.js +0 -1
  777. package/dist/webui/assets/table-B1Y18B60.js +0 -1
  778. package/dist/webui/assets/text-field-DV4EP-I8.js +0 -1
  779. package/dist/webui/assets/time-DjUFOA4D.js +0 -1
  780. package/dist/webui/assets/trackers-ULhLxA6-.js +0 -7
  781. package/dist/webui/assets/use-settings-form-submit-D87nmJRy.js +0 -79
  782. package/dist/webui/assets/useBaseQuery-BvrWhgOK.js +0 -1
  783. package/dist/webui/assets/useRouterState-CZfD5Xdv.js +0 -1
  784. package/dist/webui/assets/useStore-CusP06SD.js +0 -1
  785. package/node_modules/zod/src/v4/core/config.ts +0 -15
@@ -1,7 +1,7 @@
1
1
  import * as checks from "./checks.js";
2
2
  import * as core from "./core.js";
3
3
  import { Doc } from "./doc.js";
4
- import { parse, parseAsync, safeParse, safeParseAsync } from "./parse.js";
4
+ import { parse, parseAsync } from "./parse.js";
5
5
  import * as regexes from "./regexes.js";
6
6
  import * as util from "./util.js";
7
7
  import { version } from "./versions.js";
@@ -11,19 +11,20 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
11
11
  inst._zod.def = def; // set _def property
12
12
  inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
13
13
  inst._zod.version = version;
14
- const checks = [...(inst._zod.def.checks ?? [])];
14
+ const defChecks = inst._zod.def.checks;
15
15
  // if inst is itself a checks.$ZodCheck, run it as a check
16
- if (inst._zod.traits.has("$ZodCheck")) {
17
- checks.unshift(inst);
18
- }
16
+ const checks = inst._zod.traits.has("$ZodCheck")
17
+ ? [inst, ...(defChecks ?? [])]
18
+ : defChecks?.length
19
+ ? [...defChecks]
20
+ : [];
19
21
  for (const ch of checks) {
20
22
  for (const fn of ch._zod.onattach) {
21
23
  fn(inst);
22
24
  }
23
25
  }
24
26
  if (checks.length === 0) {
25
- // deferred initializer
26
- // inst._zod.parse is not yet defined
27
+ // deferred initializer inst._zod.parse is not yet defined
27
28
  (_a = inst._zod).deferred ?? (_a.deferred = []);
28
29
  inst._zod.deferred?.push(() => {
29
30
  inst._zod.run = inst._zod.parse;
@@ -31,10 +32,14 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
31
32
  }
32
33
  else {
33
34
  const runChecks = (payload, checks, ctx) => {
35
+ if (payload.memo)
36
+ return payload;
34
37
  let isAborted = util.aborted(payload);
35
38
  let asyncResult;
36
39
  for (const ch of checks) {
37
40
  if (ch._zod.def.when) {
41
+ if (util.explicitlyAborted(payload))
42
+ continue;
38
43
  const shouldRun = ch._zod.def.when(payload);
39
44
  if (!shouldRun)
40
45
  continue;
@@ -53,6 +58,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
53
58
  const nextLen = payload.issues.length;
54
59
  if (nextLen === currLen)
55
60
  return;
61
+ util.attachSchema(payload.issues, currLen, inst);
56
62
  if (!isAborted)
57
63
  isAborted = util.aborted(payload, currLen);
58
64
  });
@@ -61,6 +67,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
61
67
  const nextLen = payload.issues.length;
62
68
  if (nextLen === currLen)
63
69
  continue;
70
+ util.attachSchema(payload.issues, currLen, inst);
64
71
  if (!isAborted)
65
72
  isAborted = util.aborted(payload, currLen);
66
73
  }
@@ -92,8 +99,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
92
99
  return inst._zod.parse(payload, ctx);
93
100
  }
94
101
  if (ctx.direction === "backward") {
95
- // run canary
96
- // initial pass (no checks)
102
+ // run canary initial pass (no checks)
97
103
  const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
98
104
  if (canary instanceof Promise) {
99
105
  return canary.then((canary) => {
@@ -112,25 +118,44 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
112
118
  return runChecks(result, checks, ctx);
113
119
  };
114
120
  }
115
- // Lazy initialize ~standard to avoid creating objects for every schema
116
- util.defineLazy(inst, "~standard", () => ({
121
+ }, {
122
+ // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
123
+ get "~standard"() {
124
+ return util.hide(this, "~standard", standardProps(this));
125
+ },
126
+ set "~standard"(value) {
127
+ util.own(this, "~standard", value);
128
+ },
129
+ });
130
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
131
+ // a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
132
+ const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
133
+ async function validateAsync(inst, value) {
134
+ const ctx = { async: true };
135
+ return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
136
+ }
137
+ export function standardProps(inst) {
138
+ return {
117
139
  validate: (value) => {
140
+ const ctx = { async: false };
118
141
  try {
119
- const r = safeParse(inst, value);
120
- return r.success ? { value: r.data } : { issues: r.error?.issues };
121
- }
122
- catch (_) {
123
- return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
142
+ const r = inst._zod.run({ value, issues: [] }, ctx);
143
+ if (!(r instanceof Promise))
144
+ return toStandardResult(r, ctx);
124
145
  }
146
+ catch (_) { }
147
+ // async function so a synchronously throwing check rejects instead of escaping validate
148
+ return validateAsync(inst, value);
125
149
  },
126
150
  vendor: "zod",
127
151
  version: 1,
128
- }));
129
- });
152
+ };
153
+ }
130
154
  export { clone } from "./util.js";
131
155
  export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
132
156
  $ZodType.init(inst, def);
133
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
157
+ // a format's own pattern, else unbounded; a template literal derives the check-aware form itself
158
+ inst._zod.pattern = def.pattern ?? regexes.anyString;
134
159
  inst._zod.parse = (payload, _) => {
135
160
  if (def.coerce)
136
161
  try {
@@ -182,51 +207,115 @@ export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def
182
207
  def.pattern ?? (def.pattern = regexes.email);
183
208
  $ZodStringFormat.init(inst, def);
184
209
  });
210
+ /** The `://` guard rejected the input before the URL constructor saw it. */
211
+ export const URL_BAD_FORMAT = 1;
212
+ /** The URL parser rejected the input. */
213
+ export const URL_UNPARSEABLE = 2;
214
+ export function canParseURL(input) {
215
+ try {
216
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function")
217
+ return URL.canParse(input);
218
+ new URL(input);
219
+ return true;
220
+ }
221
+ catch {
222
+ return false;
223
+ }
224
+ }
225
+ export function validateURL(trimmed, def) {
226
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
227
+ return canParseURL(trimmed) || URL_UNPARSEABLE;
228
+ }
229
+ return parseURLObject(trimmed, def);
230
+ }
231
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
232
+ export function parseURLObject(trimmed, def) {
233
+ // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
234
+ if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
235
+ return URL_BAD_FORMAT;
236
+ }
237
+ try {
238
+ if (typeof URL !== "undefined") {
239
+ const URLStatic = URL;
240
+ if (typeof URLStatic.parse === "function")
241
+ return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
242
+ }
243
+ // @ts-ignore
244
+ return new URL(trimmed);
245
+ }
246
+ catch {
247
+ return URL_UNPARSEABLE;
248
+ }
249
+ }
250
+ const asciiTabOrNewline = /[\t\n\r]/g;
251
+ /** 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. */
252
+ export function stripTabAndNewline(value) {
253
+ return value.replace(asciiTabOrNewline, "");
254
+ }
255
+ export function urlHostnameOk(url, hostname) {
256
+ hostname.lastIndex = 0;
257
+ return hostname.test(url.hostname);
258
+ }
259
+ export function urlProtocolOk(url, protocol) {
260
+ protocol.lastIndex = 0;
261
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
262
+ }
185
263
  export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
186
264
  $ZodStringFormat.init(inst, def);
187
265
  inst._zod.check = (payload) => {
188
266
  try {
189
267
  // Trim whitespace from input
190
268
  const trimmed = payload.value.trim();
191
- // @ts-ignore
192
- const url = new URL(trimmed);
193
- if (def.hostname) {
194
- def.hostname.lastIndex = 0;
195
- if (!def.hostname.test(url.hostname)) {
196
- payload.issues.push({
197
- code: "invalid_format",
198
- format: "url",
199
- note: "Invalid hostname",
200
- pattern: def.hostname.source,
201
- input: payload.value,
202
- inst,
203
- continue: !def.abort,
204
- });
205
- }
269
+ const url = validateURL(trimmed, def);
270
+ if (url === URL_BAD_FORMAT) {
271
+ payload.issues.push({
272
+ code: "invalid_format",
273
+ format: "url",
274
+ note: "Invalid URL format",
275
+ input: payload.value,
276
+ inst,
277
+ continue: !def.abort,
278
+ });
279
+ return;
206
280
  }
207
- if (def.protocol) {
208
- def.protocol.lastIndex = 0;
209
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
210
- payload.issues.push({
211
- code: "invalid_format",
212
- format: "url",
213
- note: "Invalid protocol",
214
- pattern: def.protocol.source,
215
- input: payload.value,
216
- inst,
217
- continue: !def.abort,
218
- });
219
- }
281
+ if (url === URL_UNPARSEABLE) {
282
+ payload.issues.push({
283
+ code: "invalid_format",
284
+ format: "url",
285
+ input: payload.value,
286
+ inst,
287
+ continue: !def.abort,
288
+ });
289
+ return;
220
290
  }
221
- // Set the output value based on normalize flag
222
- if (def.normalize) {
223
- // Use normalized URL
224
- payload.value = url.href;
291
+ if (url === true) {
292
+ payload.value = stripTabAndNewline(trimmed);
293
+ return;
225
294
  }
226
- else {
227
- // Preserve the original input (trimmed)
228
- payload.value = trimmed;
295
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) {
296
+ payload.issues.push({
297
+ code: "invalid_format",
298
+ format: "url",
299
+ note: "Invalid hostname",
300
+ pattern: def.hostname.source,
301
+ input: payload.value,
302
+ inst,
303
+ continue: !def.abort,
304
+ });
305
+ }
306
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) {
307
+ payload.issues.push({
308
+ code: "invalid_format",
309
+ format: "url",
310
+ note: "Invalid protocol",
311
+ pattern: def.protocol.source,
312
+ input: payload.value,
313
+ inst,
314
+ continue: !def.abort,
315
+ });
229
316
  }
317
+ // Set the output value based on normalize flag
318
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
230
319
  return;
231
320
  }
232
321
  catch (_) {
@@ -245,9 +334,16 @@ export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def
245
334
  $ZodStringFormat.init(inst, def);
246
335
  });
247
336
  export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
248
- def.pattern ?? (def.pattern = regexes.nanoid);
337
+ if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
338
+ throw new Error(`Invalid nanoid length: ${def.length}`);
339
+ def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
249
340
  $ZodStringFormat.init(inst, def);
250
341
  });
342
+ /**
343
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
344
+ * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
345
+ * See https://github.com/paralleldrive/cuid.
346
+ */
251
347
  export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
252
348
  def.pattern ?? (def.pattern = regexes.cuid);
253
349
  $ZodStringFormat.init(inst, def);
@@ -287,19 +383,19 @@ export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration"
287
383
  export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
288
384
  def.pattern ?? (def.pattern = regexes.ipv4);
289
385
  $ZodStringFormat.init(inst, def);
290
- inst._zod.bag.format = `ipv4`;
291
386
  });
387
+ /** 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`. */
388
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
389
+ export function isValidIPv6(value) {
390
+ if (!ipv6Alphabet.test(value))
391
+ return false;
392
+ return canParseURL(`http://[${value}]`);
393
+ }
292
394
  export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
293
395
  def.pattern ?? (def.pattern = regexes.ipv6);
294
396
  $ZodStringFormat.init(inst, def);
295
- inst._zod.bag.format = `ipv6`;
296
397
  inst._zod.check = (payload) => {
297
- try {
298
- // @ts-ignore
299
- new URL(`http://[${payload.value}]`);
300
- // return;
301
- }
302
- catch {
398
+ if (!isValidIPv6(payload.value)) {
303
399
  payload.issues.push({
304
400
  code: "invalid_format",
305
401
  format: "ipv6",
@@ -313,32 +409,30 @@ export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def)
313
409
  export const $ZodMAC = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def) => {
314
410
  def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
315
411
  $ZodStringFormat.init(inst, def);
316
- inst._zod.bag.format = `mac`;
317
412
  });
318
413
  export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
319
414
  def.pattern ?? (def.pattern = regexes.cidrv4);
320
415
  $ZodStringFormat.init(inst, def);
321
416
  });
417
+ export function isValidCIDRv6(value) {
418
+ const parts = value.split("/");
419
+ if (parts.length !== 2)
420
+ return false;
421
+ const [address, prefix] = parts;
422
+ if (!prefix)
423
+ return false;
424
+ const prefixNum = Number(prefix);
425
+ if (`${prefixNum}` !== prefix)
426
+ return false;
427
+ if (prefixNum < 0 || prefixNum > 128)
428
+ return false;
429
+ return isValidIPv6(address);
430
+ }
322
431
  export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
323
432
  def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
324
433
  $ZodStringFormat.init(inst, def);
325
434
  inst._zod.check = (payload) => {
326
- const parts = payload.value.split("/");
327
- try {
328
- if (parts.length !== 2)
329
- throw new Error();
330
- const [address, prefix] = parts;
331
- if (!prefix)
332
- throw new Error();
333
- const prefixNum = Number(prefix);
334
- if (`${prefixNum}` !== prefix)
335
- throw new Error();
336
- if (prefixNum < 0 || prefixNum > 128)
337
- throw new Error();
338
- // @ts-ignore
339
- new URL(`http://[${address}]`);
340
- }
341
- catch {
435
+ if (!isValidCIDRv6(payload.value)) {
342
436
  payload.issues.push({
343
437
  code: "invalid_format",
344
438
  format: "cidrv6",
@@ -353,6 +447,9 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
353
447
  export function isValidBase64(data) {
354
448
  if (data === "")
355
449
  return true;
450
+ // atob ignores whitespace, so reject it up front.
451
+ if (/\s/.test(data))
452
+ return false;
356
453
  if (data.length % 4 !== 0)
357
454
  return false;
358
455
  try {
@@ -364,10 +461,11 @@ export function isValidBase64(data) {
364
461
  return false;
365
462
  }
366
463
  }
464
+ // lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
465
+ export const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
367
466
  export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
368
- def.pattern ?? (def.pattern = regexes.base64);
467
+ def.pattern ?? (def.pattern = base64Charset);
369
468
  $ZodStringFormat.init(inst, def);
370
- inst._zod.bag.contentEncoding = "base64";
371
469
  inst._zod.check = (payload) => {
372
470
  if (isValidBase64(payload.value))
373
471
  return;
@@ -380,18 +478,19 @@ export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, d
380
478
  });
381
479
  };
382
480
  });
383
- ////////////////////////////// ZodBase64 //////////////////////////////
481
+ ////////////////////////////// ZodBase64URL //////////////////////////////
482
+ // lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
483
+ export const base64urlCharset = /^[A-Za-z0-9_-]*$/;
384
484
  export function isValidBase64URL(data) {
385
- if (!regexes.base64url.test(data))
485
+ if (!base64urlCharset.test(data))
386
486
  return false;
387
487
  const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
388
488
  const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
389
489
  return isValidBase64(padded);
390
490
  }
391
491
  export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
392
- def.pattern ?? (def.pattern = regexes.base64url);
492
+ def.pattern ?? (def.pattern = base64urlCharset);
393
493
  $ZodStringFormat.init(inst, def);
394
- inst._zod.bag.contentEncoding = "base64url";
395
494
  inst._zod.check = (payload) => {
396
495
  if (isValidBase64URL(payload.value))
397
496
  return;
@@ -408,6 +507,77 @@ export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def)
408
507
  def.pattern ?? (def.pattern = regexes.e164);
409
508
  $ZodStringFormat.init(inst, def);
410
509
  });
510
+ ////////////////////////////// ZodCreditCard //////////////////////////////
511
+ const CC_SANITIZE = /[- ]/g;
512
+ /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
513
+ function isLuhnAlgo(digits) {
514
+ let length = digits.length;
515
+ let bit = 1;
516
+ let sum = 0;
517
+ while (length) {
518
+ const value = digits.charCodeAt(--length) - 48;
519
+ bit ^= 1;
520
+ sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
521
+ }
522
+ return sum % 10 === 0;
523
+ }
524
+ export function isValidCreditCard(input) {
525
+ if (!regexes.creditCard.test(input))
526
+ return false;
527
+ return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
528
+ }
529
+ export const $ZodCreditCard = /*@__PURE__*/ core.$constructor("$ZodCreditCard", (inst, def) => {
530
+ // 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.
531
+ def.pattern ?? (def.pattern = regexes.creditCard);
532
+ $ZodStringFormat.init(inst, def);
533
+ inst._zod.check = (payload) => {
534
+ if (isValidCreditCard(payload.value))
535
+ return;
536
+ payload.issues.push({
537
+ code: "invalid_format",
538
+ format: "credit_card",
539
+ input: payload.value,
540
+ inst,
541
+ continue: !def.abort,
542
+ });
543
+ };
544
+ });
545
+ ////////////////////////////// ZodIBAN //////////////////////////////
546
+ // iso 7064 mod 97-10 checksum without BigInt
547
+ function isIso7064Mod97(iban) {
548
+ let remainder = 0;
549
+ const len = iban.length;
550
+ for (let i = 4; i < len; i++) {
551
+ const code = iban.charCodeAt(i);
552
+ remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
553
+ }
554
+ for (let i = 0; i < 4; i++) {
555
+ const code = iban.charCodeAt(i);
556
+ remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
557
+ }
558
+ return remainder === 1;
559
+ }
560
+ export function isValidIBAN(input) {
561
+ if (!regexes.iban.test(input))
562
+ return false;
563
+ return isIso7064Mod97(input);
564
+ }
565
+ export const $ZodIBAN = /*@__PURE__*/ core.$constructor("$ZodIBAN", (inst, def) => {
566
+ // shape only — checksum is not expressible as a pattern
567
+ def.pattern ?? (def.pattern = regexes.iban);
568
+ $ZodStringFormat.init(inst, def);
569
+ inst._zod.check = (payload) => {
570
+ if (isValidIBAN(payload.value))
571
+ return;
572
+ payload.issues.push({
573
+ code: "invalid_format",
574
+ format: "iban",
575
+ input: payload.value,
576
+ inst,
577
+ continue: !def.abort,
578
+ });
579
+ };
580
+ });
411
581
  ////////////////////////////// ZodJWT //////////////////////////////
412
582
  export function isValidJWT(token, algorithm = null) {
413
583
  try {
@@ -461,7 +631,7 @@ export const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCusto
461
631
  });
462
632
  export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
463
633
  $ZodType.init(inst, def);
464
- inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
634
+ inst._zod.pattern = regexes.number;
465
635
  inst._zod.parse = (payload, _ctx) => {
466
636
  if (def.coerce)
467
637
  try {
@@ -476,7 +646,7 @@ export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, d
476
646
  ? Number.isNaN(input)
477
647
  ? "NaN"
478
648
  : !Number.isFinite(input)
479
- ? "Infinity"
649
+ ? String(input)
480
650
  : undefined
481
651
  : undefined;
482
652
  payload.issues.push({
@@ -557,8 +727,6 @@ export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (i
557
727
  $ZodType.init(inst, def);
558
728
  inst._zod.pattern = regexes.undefined;
559
729
  inst._zod.values = new Set([undefined]);
560
- inst._zod.optin = "optional";
561
- inst._zod.optout = "optional";
562
730
  inst._zod.parse = (payload, _ctx) => {
563
731
  const input = payload.value;
564
732
  if (typeof input === "undefined")
@@ -648,6 +816,33 @@ export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def)
648
816
  return payload;
649
817
  };
650
818
  });
819
+ // an oversized container fails its leading size checks before any element is parsed
820
+ function capSize(inst, size) {
821
+ const caps = util.sizeCaps(inst._zod.def.checks);
822
+ if (!caps.length)
823
+ return;
824
+ const cap = Math.min(...caps.map((c) => c[0]));
825
+ const parse = inst._zod.parse;
826
+ inst._zod.parse = (payload, ctx) => {
827
+ const n = size(payload.value);
828
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
829
+ for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
830
+ if (n > max && ch._zod.def.when(payload)) {
831
+ const start = payload.issues.length;
832
+ ch._zod.check(payload);
833
+ // the value is still the raw input, so no later check may read it
834
+ payload.issues[start].continue = false;
835
+ util.attachSchema(payload.issues, start, inst);
836
+ return payload;
837
+ }
838
+ }
839
+ }
840
+ return parse(payload, ctx);
841
+ };
842
+ }
843
+ const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
844
+ const mapSize = (input) => (input instanceof Map ? input.size : -1);
845
+ const setSize = (input) => (input instanceof Set ? input.size : -1);
651
846
  function handleArrayResult(result, final, index) {
652
847
  if (result.issues.length) {
653
848
  final.issues.push(...util.prefixIssues(index, result.issues));
@@ -656,6 +851,8 @@ function handleArrayResult(result, final, index) {
656
851
  }
657
852
  export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
658
853
  $ZodType.init(inst, def);
854
+ const memo = core.globalConfig.memoizer;
855
+ memo?.attach(inst);
659
856
  inst._zod.parse = (payload, ctx) => {
660
857
  const input = payload.value;
661
858
  if (!Array.isArray(input)) {
@@ -667,8 +864,9 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
667
864
  });
668
865
  return payload;
669
866
  }
670
- payload.value = Array(input.length);
867
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
671
868
  const proms = [];
869
+ const abortEarly = ctx?.abortEarly;
672
870
  for (let i = 0; i < input.length; i++) {
673
871
  const item = input[i];
674
872
  const result = def.element._zod.run({
@@ -680,6 +878,9 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
680
878
  }
681
879
  else {
682
880
  handleArrayResult(result, payload, i);
881
+ // the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
882
+ if (abortEarly && result.issues.length !== 0 && util.aborted(result))
883
+ break;
683
884
  }
684
885
  }
685
886
  if (proms.length) {
@@ -687,17 +888,35 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
687
888
  }
688
889
  return payload; //handleArrayResultsAsync(parseResults, final);
689
890
  };
891
+ capSize(inst, arraySize);
690
892
  });
691
- function handlePropertyResult(result, final, key, input, isOptionalOut) {
893
+ function handlePropertyResult(result, final, key, input, optin, optout) {
894
+ const isPresent = key in input;
895
+ const isOptionalOut = optout === "optional";
896
+ // 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.
897
+ if (!isPresent && isOptionalOut && optin === "optional") {
898
+ return;
899
+ }
692
900
  if (result.issues.length) {
693
- // For optional-out schemas, ignore errors on absent keys
694
- if (isOptionalOut && !(key in input)) {
901
+ // For optional-in/out schemas, ignore errors on absent keys.
902
+ if (optin !== undefined && isOptionalOut && !isPresent) {
695
903
  return;
696
904
  }
697
905
  final.issues.push(...util.prefixIssues(key, result.issues));
698
906
  }
907
+ if (!isPresent && optin === undefined) {
908
+ if (!result.issues.length) {
909
+ final.issues.push({
910
+ code: "invalid_type",
911
+ expected: "nonoptional",
912
+ input: undefined,
913
+ path: [key],
914
+ });
915
+ }
916
+ return;
917
+ }
699
918
  if (result.value === undefined) {
700
- if (key in input) {
919
+ if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
701
920
  final.value[key] = undefined;
702
921
  }
703
922
  }
@@ -705,42 +924,64 @@ function handlePropertyResult(result, final, key, input, isOptionalOut) {
705
924
  final.value[key] = result.value;
706
925
  }
707
926
  }
927
+ // one shared instance; a fresh [] per schema cost 56 bytes retained
928
+ const NO_SYMBOL_KEYS = [];
708
929
  function normalizeDef(def) {
709
930
  const keys = Object.keys(def.shape);
710
- for (const k of keys) {
931
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
932
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
933
+ // aliases `keys` when there are no symbols, so a string-only shape keeps one array
934
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
935
+ for (const k of allKeys) {
711
936
  if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
712
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
937
+ throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
713
938
  }
714
939
  }
715
940
  const okeys = util.optionalKeys(def.shape);
716
941
  return {
717
942
  ...def,
718
- keys,
943
+ allKeys,
944
+ symbolKeys,
945
+ // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
719
946
  keySet: new Set(keys),
720
947
  numKeys: keys.length,
721
948
  optionalKeys: new Set(okeys),
722
949
  };
723
950
  }
724
- function handleCatchall(proms, input, payload, ctx, def, inst) {
951
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
725
952
  const unrecognized = [];
726
- // iterate over input keys
727
953
  const keySet = def.keySet;
728
954
  const _catchall = def.catchall._zod;
729
955
  const t = _catchall.def.type;
730
- const isOptionalOut = _catchall.optout === "optional";
956
+ const optin = _catchall.optin;
957
+ const optout = _catchall.optout;
958
+ // starts at 0, not the current length: the shape phase already ran and may have aborted
959
+ let seen = 0;
731
960
  for (const key in input) {
961
+ if (abortEarly && payload.issues.length !== seen) {
962
+ if (util.aborted(payload, seen))
963
+ break;
964
+ seen = payload.issues.length;
965
+ }
966
+ // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
732
967
  if (keySet.has(key))
733
968
  continue;
969
+ // 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.
970
+ if (key === "__proto__") {
971
+ if (t === "never")
972
+ unrecognized.push(key);
973
+ continue;
974
+ }
734
975
  if (t === "never") {
735
976
  unrecognized.push(key);
736
977
  continue;
737
978
  }
738
979
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
739
980
  if (r instanceof Promise) {
740
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
981
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
741
982
  }
742
983
  else {
743
- handlePropertyResult(r, payload, key, input, isOptionalOut);
984
+ handlePropertyResult(r, payload, key, input, optin, optout);
744
985
  }
745
986
  }
746
987
  if (unrecognized.length) {
@@ -749,6 +990,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
749
990
  keys: unrecognized,
750
991
  input,
751
992
  inst,
993
+ // 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.
994
+ continue: true,
752
995
  });
753
996
  }
754
997
  if (!proms.length)
@@ -760,30 +1003,35 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
760
1003
  export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
761
1004
  // requires cast because technically $ZodObject doesn't extend
762
1005
  $ZodType.init(inst, def);
763
- // const sh = def.shape;
764
1006
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
765
- if (!desc?.get) {
766
- const sh = def.shape;
767
- Object.defineProperty(def, "shape", {
768
- get: () => {
769
- const newSh = { ...sh };
770
- Object.defineProperty(def, "shape", {
771
- value: newSh,
772
- });
773
- return newSh;
774
- },
775
- });
1007
+ // a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
1008
+ const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
1009
+ if (sh) {
1010
+ // Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
1011
+ const get = () => {
1012
+ const newSh = { ...sh };
1013
+ Object.defineProperty(def, "shape", { value: newSh });
1014
+ get.raw = newSh;
1015
+ return newSh;
1016
+ };
1017
+ get.raw = sh;
1018
+ Object.defineProperty(def, "shape", { get });
776
1019
  }
777
1020
  const _normalized = util.cached(() => normalizeDef(def));
778
- util.defineLazy(inst._zod, "propValues", () => {
779
- const shape = def.shape;
1021
+ util.defineLazyInternal(inst, "propValues", (zod) => {
1022
+ const shape = zod.def.shape;
780
1023
  const propValues = {};
781
1024
  for (const key in shape) {
782
1025
  const field = shape[key]._zod;
783
1026
  if (field.values) {
784
- propValues[key] ?? (propValues[key] = new Set());
1027
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
1028
+ util.assignProp(propValues, key, new Set());
1029
+ }
785
1030
  for (const v of field.values)
786
1031
  propValues[key].add(v);
1032
+ // 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.
1033
+ if (field.optin !== undefined)
1034
+ propValues[key].add(undefined);
787
1035
  }
788
1036
  }
789
1037
  return propValues;
@@ -791,6 +1039,8 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
791
1039
  const isObject = util.isObject;
792
1040
  const catchall = def.catchall;
793
1041
  let value;
1042
+ const memo = core.globalConfig.memoizer;
1043
+ memo?.attach(inst);
794
1044
  inst._zod.parse = (payload, ctx) => {
795
1045
  value ?? (value = _normalized.value);
796
1046
  const input = payload.value;
@@ -803,24 +1053,34 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
803
1053
  });
804
1054
  return payload;
805
1055
  }
806
- payload.value = {};
1056
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
807
1057
  const proms = [];
808
1058
  const shape = value.shape;
809
- for (const key of value.keys) {
1059
+ const abortEarly = ctx?.abortEarly;
1060
+ let seen = payload.issues.length;
1061
+ for (const key of value.allKeys) {
1062
+ if (abortEarly && payload.issues.length !== seen) {
1063
+ if (util.aborted(payload, seen))
1064
+ break;
1065
+ seen = payload.issues.length;
1066
+ }
1067
+ if (key === "__proto__")
1068
+ continue;
810
1069
  const el = shape[key];
811
- const isOptionalOut = el._zod.optout === "optional";
1070
+ const optin = el._zod.optin;
1071
+ const optout = el._zod.optout;
812
1072
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
813
1073
  if (r instanceof Promise) {
814
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1074
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
815
1075
  }
816
1076
  else {
817
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1077
+ handlePropertyResult(r, payload, key, input, optin, optout);
818
1078
  }
819
1079
  }
820
1080
  if (!catchall) {
821
1081
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
822
1082
  }
823
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1083
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
824
1084
  };
825
1085
  });
826
1086
  export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (inst, def) => {
@@ -828,73 +1088,106 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
828
1088
  $ZodObject.init(inst, def);
829
1089
  const superParse = inst._zod.parse;
830
1090
  const _normalized = util.cached(() => normalizeDef(def));
1091
+ const memo = core.globalConfig.memoizer;
831
1092
  const generateFastpass = (shape) => {
832
- const doc = new Doc(["shape", "payload", "ctx"]);
833
1093
  const normalized = _normalized.value;
834
- const parseStr = (key) => {
835
- const k = util.esc(key);
836
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
837
- };
1094
+ const syms = normalized.symbolKeys;
1095
+ // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
1096
+ const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
1097
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1098
+ // prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
1099
+ const prefixStr = (id, k) => `
1100
+ let ${id}_ab = false;
1101
+ for (let i = 0; i < ${id}.issues.length; i++) {
1102
+ const iss = ${id}.issues[i];
1103
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
1104
+ payload.issues.push(iss);
1105
+ if (iss.continue !== true) ${id}_ab = true;
1106
+ }
1107
+ if (${id}_ab && ctx && ctx.abortEarly) {
1108
+ payload.value = newResult;
1109
+ return payload;
1110
+ }`;
838
1111
  doc.write(`const input = payload.value;`);
839
1112
  const ids = Object.create(null);
840
1113
  let counter = 0;
841
- for (const key of normalized.keys) {
1114
+ for (const key of normalized.allKeys) {
842
1115
  ids[key] = `key_${counter++}`;
843
1116
  }
844
1117
  // A: preserve key order {
845
- doc.write(`const newResult = {};`);
846
- for (const key of normalized.keys) {
1118
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
1119
+ for (const key of normalized.allKeys) {
1120
+ if (key === "__proto__")
1121
+ continue;
847
1122
  const id = ids[key];
848
- const k = util.esc(key);
1123
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
1124
+ const isPresent = `${k} in input`;
849
1125
  const schema = shape[key];
1126
+ const optin = schema?._zod?.optin;
1127
+ const isOptionalIn = optin !== undefined;
850
1128
  const isOptionalOut = schema?._zod?.optout === "optional";
851
- doc.write(`const ${id} = ${parseStr(key)};`);
852
- if (isOptionalOut) {
853
- // For optional-out schemas, ignore errors on absent keys
1129
+ doc.write(`const ${id} = ${parseStr(k)};`);
1130
+ if (isOptionalIn && isOptionalOut) {
1131
+ // 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.
1132
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
854
1133
  doc.write(`
855
- if (${id}.issues.length) {
856
- if (${k} in input) {
857
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
858
- ...iss,
859
- path: iss.path ? [${k}, ...iss.path] : [${k}]
860
- })));
1134
+ const ${id}_present = ${isPresent};
1135
+ if (!${id}.issues.length || ${id}_present) {
1136
+ if (${id}.issues.length) {${prefixStr(id, k)}
1137
+ }
1138
+
1139
+ if (${assign}) {
1140
+ newResult[${k}] = ${id}.value;
861
1141
  }
862
1142
  }
863
-
864
- if (${id}.value === undefined) {
865
- if (${k} in input) {
866
- newResult[${k}] = undefined;
1143
+
1144
+ `);
1145
+ }
1146
+ else if (!isOptionalIn) {
1147
+ doc.write(`
1148
+ const ${id}_present = ${isPresent};
1149
+ if (${id}.issues.length) {${prefixStr(id, k)}
1150
+ }
1151
+ if (!${id}_present && !${id}.issues.length) {
1152
+ payload.issues.push({
1153
+ code: "invalid_type",
1154
+ expected: "nonoptional",
1155
+ input: undefined,
1156
+ path: [${k}]
1157
+ });
1158
+ if (ctx && ctx.abortEarly) {
1159
+ payload.value = newResult;
1160
+ return payload;
867
1161
  }
868
- } else {
1162
+ }
1163
+
1164
+ if (${id}_present) {
869
1165
  newResult[${k}] = ${id}.value;
870
1166
  }
871
-
1167
+
872
1168
  `);
873
1169
  }
874
1170
  else {
875
1171
  doc.write(`
876
- if (${id}.issues.length) {
877
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
878
- ...iss,
879
- path: iss.path ? [${k}, ...iss.path] : [${k}]
880
- })));
881
- }
882
-
883
- if (${id}.value === undefined) {
884
- if (${k} in input) {
885
- newResult[${k}] = undefined;
886
- }
887
- } else {
1172
+ if (${id}.issues.length) {${prefixStr(id, k)}
1173
+ }
1174
+ `);
1175
+ if (optin === "defaulted") {
1176
+ doc.write(`newResult[${k}] = ${id}.value;`);
1177
+ }
1178
+ else {
1179
+ doc.write(`
1180
+ if (${id}.value !== undefined || ${isPresent}) {
888
1181
  newResult[${k}] = ${id}.value;
889
1182
  }
890
-
891
1183
  `);
1184
+ }
892
1185
  }
893
1186
  }
894
1187
  doc.write(`payload.value = newResult;`);
895
1188
  doc.write(`return payload;`);
896
- const fn = doc.compile();
897
- return (payload, ctx) => fn(shape, payload, ctx);
1189
+ // 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
1190
+ return doc.compile();
898
1191
  };
899
1192
  let fastpass;
900
1193
  const isObject = util.isObject;
@@ -922,7 +1215,7 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
922
1215
  payload = fastpass(payload, ctx);
923
1216
  if (!catchall)
924
1217
  return payload;
925
- return handleCatchall([], input, payload, ctx, value, inst);
1218
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
926
1219
  }
927
1220
  return superParse(payload, ctx);
928
1221
  };
@@ -949,25 +1242,28 @@ function handleUnionResults(results, final, inst, ctx) {
949
1242
  }
950
1243
  export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
951
1244
  $ZodType.init(inst, def);
952
- util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
953
- util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
954
- util.defineLazy(inst._zod, "values", () => {
955
- if (def.options.every((o) => o._zod.values)) {
956
- return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1245
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
1246
+ ? "defaulted"
1247
+ : zod.def.options.some((o) => o._zod.optin !== undefined)
1248
+ ? "optional"
1249
+ : undefined);
1250
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1251
+ util.defineLazyInternal(inst, "values", (zod) => {
1252
+ if (zod.def.options.every((o) => o._zod.values)) {
1253
+ return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
957
1254
  }
958
1255
  return undefined;
959
1256
  });
960
- util.defineLazy(inst._zod, "pattern", () => {
961
- if (def.options.every((o) => o._zod.pattern)) {
962
- const patterns = def.options.map((o) => o._zod.pattern);
1257
+ util.defineLazyInternal(inst, "pattern", (zod) => {
1258
+ if (zod.def.options.every((o) => o._zod.pattern)) {
1259
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
963
1260
  return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
964
1261
  }
965
1262
  return undefined;
966
1263
  });
967
- const single = def.options.length === 1;
968
- const first = def.options[0]._zod.run;
1264
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
969
1265
  inst._zod.parse = (payload, ctx) => {
970
- if (single) {
1266
+ if (first) {
971
1267
  return first(payload, ctx);
972
1268
  }
973
1269
  let async = false;
@@ -995,12 +1291,16 @@ export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def
995
1291
  };
996
1292
  });
997
1293
  function handleExclusiveUnionResults(results, final, inst, ctx) {
998
- const successes = results.filter((r) => r.issues.length === 0);
999
- if (successes.length === 1) {
1000
- final.value = successes[0].value;
1294
+ const matches = [];
1295
+ for (let i = 0; i < results.length; i++) {
1296
+ if (results[i].issues.length === 0)
1297
+ matches.push(i);
1298
+ }
1299
+ if (matches.length === 1) {
1300
+ final.value = results[matches[0]].value;
1001
1301
  return final;
1002
1302
  }
1003
- if (successes.length === 0) {
1303
+ if (matches.length === 0) {
1004
1304
  // No matches - same as regular union
1005
1305
  final.issues.push({
1006
1306
  code: "invalid_union",
@@ -1017,6 +1317,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
1017
1317
  inst,
1018
1318
  errors: [],
1019
1319
  inclusive: false,
1320
+ matches,
1020
1321
  });
1021
1322
  }
1022
1323
  return final;
@@ -1024,10 +1325,9 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
1024
1325
  export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
1025
1326
  $ZodUnion.init(inst, def);
1026
1327
  def.inclusive = false;
1027
- const single = def.options.length === 1;
1028
- const first = def.options[0]._zod.run;
1328
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1029
1329
  inst._zod.parse = (payload, ctx) => {
1030
- if (single) {
1330
+ if (first) {
1031
1331
  return first(payload, ctx);
1032
1332
  }
1033
1333
  let async = false;
@@ -1052,44 +1352,75 @@ export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) =>
1052
1352
  });
1053
1353
  };
1054
1354
  });
1355
+ /** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
1356
+ export function getDiscriminatedOption(union, value) {
1357
+ const internals = union._zod;
1358
+ let map = internals.bag.optionsMap;
1359
+ if (!map) {
1360
+ map = discriminatorMap(internals.def);
1361
+ internals.bag.optionsMap = map;
1362
+ }
1363
+ const option = map.get(value);
1364
+ if (option === null)
1365
+ throw new Error(`Ambiguous discriminator value "${String(value)}"`);
1366
+ return option;
1367
+ }
1368
+ function discriminatorMap(def) {
1369
+ const map = new Map();
1370
+ for (const option of def.options) {
1371
+ const values = option._zod.propValues?.[def.discriminator];
1372
+ if (!values || values.size === 0)
1373
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1374
+ for (const value of values) {
1375
+ if (map.has(value)) {
1376
+ if (value !== undefined)
1377
+ throw new Error(`Duplicate discriminator value "${String(value)}"`);
1378
+ // keep the collision marked so a later member cannot reclaim it
1379
+ map.set(value, null);
1380
+ }
1381
+ else {
1382
+ map.set(value, option);
1383
+ }
1384
+ }
1385
+ }
1386
+ return map;
1387
+ }
1055
1388
  export const $ZodDiscriminatedUnion =
1056
1389
  /*@__PURE__*/
1057
1390
  core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1058
1391
  def.inclusive = false;
1059
1392
  $ZodUnion.init(inst, def);
1060
1393
  const _super = inst._zod.parse;
1061
- util.defineLazy(inst._zod, "propValues", () => {
1394
+ util.defineLazyInternal(inst, "propValues", (zod) => {
1062
1395
  const propValues = {};
1063
- for (const option of def.options) {
1396
+ let undefinedCount = 0;
1397
+ for (const option of zod.def.options) {
1064
1398
  const pv = option._zod.propValues;
1065
1399
  if (!pv || Object.keys(pv).length === 0)
1066
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1400
+ throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
1401
+ if (pv[zod.def.discriminator]?.has(undefined))
1402
+ undefinedCount++;
1067
1403
  for (const [k, v] of Object.entries(pv)) {
1068
- if (!propValues[k])
1069
- propValues[k] = new Set();
1404
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
1405
+ util.assignProp(propValues, k, new Set());
1406
+ }
1070
1407
  for (const val of v) {
1071
1408
  propValues[k].add(val);
1072
1409
  }
1073
1410
  }
1074
1411
  }
1412
+ if (!zod.def.unionFallback && undefinedCount > 1)
1413
+ propValues[zod.def.discriminator]?.delete(undefined);
1075
1414
  return propValues;
1076
1415
  });
1077
- const disc = util.cached(() => {
1078
- const opts = def.options;
1079
- const map = new Map();
1080
- for (const o of opts) {
1081
- const values = o._zod.propValues?.[def.discriminator];
1082
- if (!values || values.size === 0)
1083
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1084
- for (const v of values) {
1085
- if (map.has(v)) {
1086
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
1087
- }
1088
- map.set(v, o);
1089
- }
1416
+ // 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 and lazies — are left to the map.
1417
+ def.options.forEach((option, i) => {
1418
+ const propShape = util.rawShape(option._zod.def);
1419
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
1420
+ throw new Error(`Invalid discriminated union option at index "${i}"`);
1090
1421
  }
1091
- return map;
1092
1422
  });
1423
+ const disc = util.cached(() => discriminatorMap(def));
1093
1424
  inst._zod.parse = (payload, ctx) => {
1094
1425
  const input = payload.value;
1095
1426
  if (!util.isObject(input)) {
@@ -1101,11 +1432,16 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1101
1432
  });
1102
1433
  return payload;
1103
1434
  }
1104
- const opt = disc.value.get(input?.[def.discriminator]);
1105
- if (opt) {
1435
+ const value = input?.[def.discriminator];
1436
+ const opt = disc.value.get(value);
1437
+ // forward metadata cannot choose an encoder for an absent tag
1438
+ if (opt && (value !== undefined || ctx.direction !== "backward")) {
1106
1439
  return opt._zod.run(payload, ctx);
1107
1440
  }
1108
- if (def.unionFallback) {
1441
+ // Fall back to union matching when the fast discriminator path fails:
1442
+ // - explicitly enabled via unionFallback, or
1443
+ // - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
1444
+ if (def.unionFallback || ctx.direction === "backward") {
1109
1445
  return _super(payload, ctx);
1110
1446
  }
1111
1447
  // no matching discriminator
@@ -1114,6 +1450,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1114
1450
  errors: [],
1115
1451
  note: "No matching discriminator",
1116
1452
  discriminator: def.discriminator,
1453
+ options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
1117
1454
  input,
1118
1455
  path: [def.discriminator],
1119
1456
  inst,
@@ -1136,7 +1473,7 @@ export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersectio
1136
1473
  return handleIntersectionResults(payload, left, right);
1137
1474
  };
1138
1475
  });
1139
- function mergeValues(a, b) {
1476
+ export function mergeValues(a, b) {
1140
1477
  // const aType = parse.t(a);
1141
1478
  // const bType = parse.t(b);
1142
1479
  if (a === b) {
@@ -1149,7 +1486,11 @@ function mergeValues(a, b) {
1149
1486
  const bKeys = Object.keys(b);
1150
1487
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1151
1488
  const newObj = { ...a, ...b };
1489
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
1490
+ delete newObj.__proto__;
1152
1491
  for (const key of sharedKeys) {
1492
+ if (key === "__proto__")
1493
+ continue;
1153
1494
  const sharedValue = mergeValues(a[key], b[key]);
1154
1495
  if (!sharedValue.valid) {
1155
1496
  return {
@@ -1183,43 +1524,55 @@ function mergeValues(a, b) {
1183
1524
  return { valid: false, mergeErrorPath: [] };
1184
1525
  }
1185
1526
  function handleIntersectionResults(result, left, right) {
1186
- // Track which side(s) report each key as unrecognized
1527
+ // 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.
1187
1528
  const unrecKeys = new Map();
1188
1529
  let unrecIssue;
1189
- for (const iss of left.issues) {
1190
- if (iss.code === "unrecognized_keys") {
1530
+ const keyIssues = new Map();
1531
+ const collect = (iss, side) => {
1532
+ let keys;
1533
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
1191
1534
  unrecIssue ?? (unrecIssue = iss);
1192
- for (const k of iss.keys) {
1193
- if (!unrecKeys.has(k))
1194
- unrecKeys.set(k, {});
1195
- unrecKeys.get(k).l = true;
1196
- }
1535
+ keys = iss.keys;
1536
+ }
1537
+ else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
1538
+ const k = String(iss.path[0]);
1539
+ if (!keyIssues.has(k))
1540
+ keyIssues.set(k, iss);
1541
+ keys = [k];
1197
1542
  }
1198
1543
  else {
1199
- result.issues.push(iss);
1544
+ return false;
1545
+ }
1546
+ for (const k of keys) {
1547
+ if (!unrecKeys.has(k))
1548
+ unrecKeys.set(k, {});
1549
+ unrecKeys.get(k)[side] = true;
1200
1550
  }
1551
+ return true;
1552
+ };
1553
+ for (const iss of left.issues) {
1554
+ if (!collect(iss, "l"))
1555
+ result.issues.push(iss);
1201
1556
  }
1202
1557
  for (const iss of right.issues) {
1203
- if (iss.code === "unrecognized_keys") {
1204
- for (const k of iss.keys) {
1205
- if (!unrecKeys.has(k))
1206
- unrecKeys.set(k, {});
1207
- unrecKeys.get(k).r = true;
1208
- }
1209
- }
1210
- else {
1558
+ if (!collect(iss, "r"))
1211
1559
  result.issues.push(iss);
1212
- }
1213
1560
  }
1214
- // Report only keys unrecognized by BOTH sides
1561
+ // Report only keys rejected by BOTH sides
1215
1562
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1216
- if (bothKeys.length && unrecIssue) {
1217
- result.issues.push({ ...unrecIssue, keys: bothKeys });
1563
+ if (bothKeys.length) {
1564
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
1565
+ if (aggregated.length)
1566
+ result.issues.push({ ...unrecIssue, keys: aggregated });
1567
+ for (const k of bothKeys) {
1568
+ if (!aggregated.includes(k) && keyIssues.has(k))
1569
+ result.issues.push(keyIssues.get(k));
1570
+ }
1218
1571
  }
1219
- if (util.aborted(result))
1220
- return result;
1221
1572
  const merged = mergeValues(left.value, right.value);
1222
1573
  if (!merged.valid) {
1574
+ if (util.aborted(result))
1575
+ return result;
1223
1576
  throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1224
1577
  }
1225
1578
  result.value = merged.data;
@@ -1228,6 +1581,8 @@ function handleIntersectionResults(result, left, right) {
1228
1581
  export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
1229
1582
  $ZodType.init(inst, def);
1230
1583
  const items = def.items;
1584
+ const memo = core.globalConfig.memoizer;
1585
+ memo?.attach(inst);
1231
1586
  inst._zod.parse = (payload, ctx) => {
1232
1587
  const input = payload.value;
1233
1588
  if (!Array.isArray(input)) {
@@ -1239,71 +1594,132 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
1239
1594
  });
1240
1595
  return payload;
1241
1596
  }
1242
- payload.value = [];
1597
+ payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
1243
1598
  const proms = [];
1244
- const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
1245
- const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
1599
+ const optinStart = getTupleOptStart(items, "optin");
1600
+ const optoutStart = getTupleOptStart(items, "optout");
1246
1601
  if (!def.rest) {
1247
- const tooBig = input.length > items.length;
1248
- const tooSmall = input.length < optStart - 1;
1249
- if (tooBig || tooSmall) {
1602
+ if (input.length < optinStart) {
1250
1603
  payload.issues.push({
1251
- ...(tooBig
1252
- ? { code: "too_big", maximum: items.length, inclusive: true }
1253
- : { code: "too_small", minimum: items.length }),
1604
+ code: "too_small",
1605
+ minimum: optinStart,
1606
+ inclusive: true,
1254
1607
  input,
1255
1608
  inst,
1256
1609
  origin: "array",
1257
1610
  });
1258
1611
  return payload;
1259
1612
  }
1613
+ if (input.length > items.length) {
1614
+ payload.issues.push({
1615
+ code: "too_big",
1616
+ maximum: items.length,
1617
+ inclusive: true,
1618
+ input,
1619
+ inst,
1620
+ origin: "array",
1621
+ });
1622
+ }
1260
1623
  }
1261
- let i = -1;
1262
- for (const item of items) {
1263
- i++;
1264
- if (i >= input.length)
1265
- if (i >= optStart)
1266
- continue;
1267
- const result = item._zod.run({
1268
- value: input[i],
1269
- issues: [],
1270
- }, ctx);
1271
- if (result instanceof Promise) {
1272
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1624
+ // 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.
1625
+ const itemResults = new Array(items.length);
1626
+ // only tracked when there is a rest loop to skip
1627
+ const abortEarly = def.rest ? ctx?.abortEarly : undefined;
1628
+ let itemAborted = false;
1629
+ for (let i = 0; i < items.length; i++) {
1630
+ const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
1631
+ if (r instanceof Promise) {
1632
+ proms.push(r.then((rr) => {
1633
+ itemResults[i] = rr;
1634
+ }));
1273
1635
  }
1274
1636
  else {
1275
- handleTupleResult(result, payload, i);
1637
+ itemResults[i] = r;
1638
+ if (abortEarly && !itemAborted && r.issues.length)
1639
+ itemAborted = util.aborted(r);
1276
1640
  }
1277
1641
  }
1278
- if (def.rest) {
1642
+ // sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
1643
+ if (def.rest && !itemAborted) {
1644
+ let i = items.length - 1;
1279
1645
  const rest = input.slice(items.length);
1646
+ let seen = payload.issues.length;
1280
1647
  for (const el of rest) {
1648
+ if (abortEarly && payload.issues.length !== seen) {
1649
+ if (util.aborted(payload, seen))
1650
+ break;
1651
+ seen = payload.issues.length;
1652
+ }
1281
1653
  i++;
1282
- const result = def.rest._zod.run({
1283
- value: el,
1284
- issues: [],
1285
- }, ctx);
1654
+ const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
1286
1655
  if (result instanceof Promise) {
1287
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1656
+ proms.push(result.then((r) => handleTupleResult(r, payload, i)));
1288
1657
  }
1289
1658
  else {
1290
1659
  handleTupleResult(result, payload, i);
1291
1660
  }
1292
1661
  }
1293
1662
  }
1294
- if (proms.length)
1295
- return Promise.all(proms).then(() => payload);
1296
- return payload;
1663
+ if (proms.length) {
1664
+ return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
1665
+ }
1666
+ return handleTupleResults(itemResults, payload, items, input, optoutStart);
1297
1667
  };
1298
1668
  });
1669
+ function getTupleOptStart(items, key) {
1670
+ for (let i = items.length - 1; i >= 0; i--) {
1671
+ // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1672
+ const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
1673
+ if (!omittable)
1674
+ return i + 1;
1675
+ }
1676
+ return 0;
1677
+ }
1299
1678
  function handleTupleResult(result, final, index) {
1300
1679
  if (result.issues.length) {
1301
1680
  final.issues.push(...util.prefixIssues(index, result.issues));
1302
1681
  }
1303
1682
  final.value[index] = result.value;
1304
1683
  }
1684
+ function handleTupleResults(itemResults, final, items, input, optoutStart) {
1685
+ // 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.
1686
+ for (let i = 0; i < items.length; i++) {
1687
+ const r = itemResults[i];
1688
+ const isPresent = i < input.length;
1689
+ // 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`.
1690
+ if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
1691
+ final.value.length = i;
1692
+ break;
1693
+ }
1694
+ if (r.issues.length) {
1695
+ if (!isPresent && i >= optoutStart) {
1696
+ final.value.length = i;
1697
+ break;
1698
+ }
1699
+ final.issues.push(...util.prefixIssues(i, r.issues));
1700
+ }
1701
+ final.value[i] = r.value;
1702
+ }
1703
+ // Drop trailing slots that produced `undefined` for absent input
1704
+ // (the array analog of an absent optional key on an object). The
1705
+ // `i >= input.length` floor is critical: an explicit `undefined`
1706
+ // *inside* the input must be preserved even when the schema is
1707
+ // optional-out (e.g. `z.string().or(z.undefined())` accepting an
1708
+ // explicit undefined value).
1709
+ for (let i = final.value.length - 1; i >= input.length; i--) {
1710
+ if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
1711
+ final.value.length = i;
1712
+ }
1713
+ else {
1714
+ break;
1715
+ }
1716
+ }
1717
+ return final;
1718
+ }
1305
1719
  export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
1306
1720
  $ZodType.init(inst, def);
1721
+ const memo = core.globalConfig.memoizer;
1722
+ memo?.attach(inst);
1307
1723
  inst._zod.parse = (payload, ctx) => {
1308
1724
  const input = payload.value;
1309
1725
  if (!util.isPlainObject(input)) {
@@ -1315,36 +1731,66 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
1315
1731
  });
1316
1732
  return payload;
1317
1733
  }
1734
+ // no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
1318
1735
  const proms = [];
1319
1736
  const values = def.keyType._zod.values;
1320
- if (values) {
1321
- payload.value = {};
1737
+ if (values && !def.partial) {
1738
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1322
1739
  const recordKeys = new Set();
1323
1740
  for (const key of values) {
1324
1741
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1325
1742
  recordKeys.add(typeof key === "number" ? key.toString() : key);
1743
+ // A declared __proto__ is stripped but is not an unrecognized key.
1744
+ if (key === "__proto__")
1745
+ continue;
1746
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1747
+ if (keyResult instanceof Promise) {
1748
+ throw new Error("Async schemas not supported in object keys currently");
1749
+ }
1750
+ if (keyResult.issues.length) {
1751
+ payload.issues.push({
1752
+ code: "invalid_key",
1753
+ origin: "record",
1754
+ issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1755
+ input: key,
1756
+ path: [key],
1757
+ inst,
1758
+ });
1759
+ continue;
1760
+ }
1761
+ const outKey = keyResult.value;
1762
+ if (outKey === "__proto__")
1763
+ continue;
1326
1764
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1327
1765
  if (result instanceof Promise) {
1328
1766
  proms.push(result.then((result) => {
1329
1767
  if (result.issues.length) {
1330
1768
  payload.issues.push(...util.prefixIssues(key, result.issues));
1331
1769
  }
1332
- payload.value[key] = result.value;
1770
+ payload.value[outKey] = result.value;
1333
1771
  }));
1334
1772
  }
1335
1773
  else {
1336
1774
  if (result.issues.length) {
1337
1775
  payload.issues.push(...util.prefixIssues(key, result.issues));
1338
1776
  }
1339
- payload.value[key] = result.value;
1777
+ payload.value[outKey] = result.value;
1340
1778
  }
1341
1779
  }
1342
1780
  }
1343
1781
  let unrecognized;
1344
1782
  for (const key in input) {
1345
1783
  if (!recordKeys.has(key)) {
1346
- unrecognized = unrecognized ?? [];
1347
- unrecognized.push(key);
1784
+ if (def.mode === "loose") {
1785
+ // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
1786
+ if (key === "__proto__")
1787
+ continue;
1788
+ payload.value[key] = input[key];
1789
+ }
1790
+ else {
1791
+ unrecognized = unrecognized ?? [];
1792
+ unrecognized.push(key);
1793
+ }
1348
1794
  }
1349
1795
  }
1350
1796
  if (unrecognized && unrecognized.length > 0) {
@@ -1353,20 +1799,25 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
1353
1799
  input,
1354
1800
  inst,
1355
1801
  keys: unrecognized,
1802
+ continue: true,
1356
1803
  });
1357
1804
  }
1358
1805
  }
1359
1806
  else {
1360
- payload.value = {};
1807
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1808
+ // 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.
1809
+ let unrecognized;
1810
+ // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
1361
1811
  for (const key of Reflect.ownKeys(input)) {
1362
1812
  if (key === "__proto__")
1363
1813
  continue;
1814
+ if (!Object.prototype.propertyIsEnumerable.call(input, key))
1815
+ continue;
1364
1816
  let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1365
1817
  if (keyResult instanceof Promise) {
1366
1818
  throw new Error("Async schemas not supported in object keys currently");
1367
1819
  }
1368
- // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
1369
- // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
1820
+ // 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
1370
1821
  const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
1371
1822
  if (checkNumericKey) {
1372
1823
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
@@ -1382,6 +1833,10 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
1382
1833
  // Pass through unchanged
1383
1834
  payload.value[key] = input[key];
1384
1835
  }
1836
+ else if (values) {
1837
+ unrecognized = unrecognized ?? [];
1838
+ unrecognized.push(key);
1839
+ }
1385
1840
  else {
1386
1841
  // Default "strict" behavior: error on invalid key
1387
1842
  payload.issues.push({
@@ -1395,22 +1850,35 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
1395
1850
  }
1396
1851
  continue;
1397
1852
  }
1853
+ // 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
1854
+ const outKey = keyResult.value;
1855
+ if (outKey === "__proto__")
1856
+ continue;
1398
1857
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1399
1858
  if (result instanceof Promise) {
1400
1859
  proms.push(result.then((result) => {
1401
1860
  if (result.issues.length) {
1402
1861
  payload.issues.push(...util.prefixIssues(key, result.issues));
1403
1862
  }
1404
- payload.value[keyResult.value] = result.value;
1863
+ payload.value[outKey] = result.value;
1405
1864
  }));
1406
1865
  }
1407
1866
  else {
1408
1867
  if (result.issues.length) {
1409
1868
  payload.issues.push(...util.prefixIssues(key, result.issues));
1410
1869
  }
1411
- payload.value[keyResult.value] = result.value;
1870
+ payload.value[outKey] = result.value;
1412
1871
  }
1413
1872
  }
1873
+ if (unrecognized && unrecognized.length > 0) {
1874
+ payload.issues.push({
1875
+ code: "unrecognized_keys",
1876
+ input,
1877
+ inst,
1878
+ keys: unrecognized,
1879
+ continue: true,
1880
+ });
1881
+ }
1414
1882
  }
1415
1883
  if (proms.length) {
1416
1884
  return Promise.all(proms).then(() => payload);
@@ -1420,6 +1888,8 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
1420
1888
  });
1421
1889
  export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
1422
1890
  $ZodType.init(inst, def);
1891
+ const memo = core.globalConfig.memoizer;
1892
+ memo?.attach(inst);
1423
1893
  inst._zod.parse = (payload, ctx) => {
1424
1894
  const input = payload.value;
1425
1895
  if (!(input instanceof Map)) {
@@ -1432,8 +1902,15 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
1432
1902
  return payload;
1433
1903
  }
1434
1904
  const proms = [];
1435
- payload.value = new Map();
1905
+ payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
1906
+ const abortEarly = ctx?.abortEarly;
1907
+ let seen = payload.issues.length;
1436
1908
  for (const [key, value] of input) {
1909
+ if (abortEarly && payload.issues.length !== seen) {
1910
+ if (util.aborted(payload, seen))
1911
+ break;
1912
+ seen = payload.issues.length;
1913
+ }
1437
1914
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1438
1915
  const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1439
1916
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
@@ -1449,6 +1926,7 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
1449
1926
  return Promise.all(proms).then(() => payload);
1450
1927
  return payload;
1451
1928
  };
1929
+ capSize(inst, mapSize);
1452
1930
  });
1453
1931
  function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1454
1932
  if (keyResult.issues.length) {
@@ -1484,6 +1962,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1484
1962
  }
1485
1963
  export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
1486
1964
  $ZodType.init(inst, def);
1965
+ const memo = core.globalConfig.memoizer;
1966
+ memo?.attach(inst);
1487
1967
  inst._zod.parse = (payload, ctx) => {
1488
1968
  const input = payload.value;
1489
1969
  if (!(input instanceof Set)) {
@@ -1496,8 +1976,15 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
1496
1976
  return payload;
1497
1977
  }
1498
1978
  const proms = [];
1499
- payload.value = new Set();
1979
+ payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
1980
+ const abortEarly = ctx?.abortEarly;
1981
+ let seen = payload.issues.length;
1500
1982
  for (const item of input) {
1983
+ if (abortEarly && payload.issues.length !== seen) {
1984
+ if (util.aborted(payload, seen))
1985
+ break;
1986
+ seen = payload.issues.length;
1987
+ }
1501
1988
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
1502
1989
  if (result instanceof Promise) {
1503
1990
  proms.push(result.then((result) => handleSetResult(result, payload)));
@@ -1509,6 +1996,7 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
1509
1996
  return Promise.all(proms).then(() => payload);
1510
1997
  return payload;
1511
1998
  };
1999
+ capSize(inst, setSize);
1512
2000
  });
1513
2001
  function handleSetResult(result, final) {
1514
2002
  if (result.issues.length) {
@@ -1521,10 +2009,11 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
1521
2009
  const values = util.getEnumValues(def.entries);
1522
2010
  const valuesSet = new Set(values);
1523
2011
  inst._zod.values = valuesSet;
1524
- inst._zod.pattern = new RegExp(`^(${values
1525
- .filter((k) => util.propertyKeyTypes.has(typeof k))
1526
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
1527
- .join("|")})$`);
2012
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2013
+ const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
2014
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2015
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2016
+ });
1528
2017
  inst._zod.parse = (payload, _ctx) => {
1529
2018
  const input = payload.value;
1530
2019
  if (valuesSet.has(input)) {
@@ -1541,14 +2030,17 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
1541
2030
  });
1542
2031
  export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
1543
2032
  $ZodType.init(inst, def);
1544
- if (def.values.length === 0) {
1545
- throw new Error("Cannot create literal schema with no valid values");
1546
- }
1547
2033
  const values = new Set(def.values);
1548
2034
  inst._zod.values = values;
1549
- inst._zod.pattern = new RegExp(`^(${def.values
1550
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
1551
- .join("|")})$`);
2035
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2036
+ const vals = zod.def.values;
2037
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2038
+ return new RegExp(vals.length
2039
+ ? `^(${vals
2040
+ .map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
2041
+ .join("|")})$`
2042
+ : "^[^\\s\\S]$");
2043
+ });
1552
2044
  inst._zod.parse = (payload, _ctx) => {
1553
2045
  const input = payload.value;
1554
2046
  if (values.has(input)) {
@@ -1581,6 +2073,8 @@ export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def)
1581
2073
  });
1582
2074
  export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
1583
2075
  $ZodType.init(inst, def);
2076
+ inst._zod.optin = "optional";
2077
+ core.globalConfig.memoizer?.guard(inst);
1584
2078
  inst._zod.parse = (payload, ctx) => {
1585
2079
  if (ctx.direction === "backward") {
1586
2080
  throw new core.$ZodEncodeError(inst.constructor.name);
@@ -1600,32 +2094,34 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
1600
2094
  return payload;
1601
2095
  };
1602
2096
  });
1603
- function handleOptionalResult(result, input) {
1604
- if (result.issues.length && input === undefined) {
1605
- return { issues: [], value: undefined };
1606
- }
1607
- return result;
2097
+ function handleOptionalResult(payload, result) {
2098
+ // 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.
2099
+ payload.value = result.issues.length ? undefined : result.value;
2100
+ return payload;
1608
2101
  }
1609
2102
  export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
1610
2103
  $ZodType.init(inst, def);
1611
- inst._zod.optin = "optional";
2104
+ // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
2105
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
1612
2106
  inst._zod.optout = "optional";
1613
- util.defineLazy(inst._zod, "values", () => {
1614
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
2107
+ util.defineLazyInternal(inst, "values", (zod) => {
2108
+ const values = zod.def.innerType._zod.values;
2109
+ return values ? new Set([...values, undefined]) : undefined;
1615
2110
  });
1616
- util.defineLazy(inst._zod, "pattern", () => {
1617
- const pattern = def.innerType._zod.pattern;
2111
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2112
+ const pattern = zod.def.innerType._zod.pattern;
1618
2113
  return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
1619
2114
  });
1620
2115
  inst._zod.parse = (payload, ctx) => {
1621
- if (def.innerType._zod.optin === "optional") {
1622
- const result = def.innerType._zod.run(payload, ctx);
1623
- if (result instanceof Promise)
1624
- return result.then((r) => handleOptionalResult(r, payload.value));
1625
- return handleOptionalResult(result, payload.value);
1626
- }
1627
2116
  if (payload.value === undefined) {
1628
- return payload;
2117
+ // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
2118
+ if (def.innerType._zod.optin !== "defaulted")
2119
+ return payload;
2120
+ // 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.
2121
+ const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2122
+ if (result instanceof Promise)
2123
+ return result.then((result) => handleOptionalResult(payload, result));
2124
+ return handleOptionalResult(payload, result);
1629
2125
  }
1630
2126
  return def.innerType._zod.run(payload, ctx);
1631
2127
  };
@@ -1634,8 +2130,8 @@ export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptio
1634
2130
  // Call parent init - inherits optin/optout = "optional"
1635
2131
  $ZodOptional.init(inst, def);
1636
2132
  // Override values/pattern to NOT add undefined
1637
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1638
- util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2133
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2134
+ util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
1639
2135
  // Override parse to just delegate (no undefined handling)
1640
2136
  inst._zod.parse = (payload, ctx) => {
1641
2137
  return def.innerType._zod.run(payload, ctx);
@@ -1643,14 +2139,14 @@ export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptio
1643
2139
  });
1644
2140
  export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
1645
2141
  $ZodType.init(inst, def);
1646
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1647
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1648
- util.defineLazy(inst._zod, "pattern", () => {
1649
- const pattern = def.innerType._zod.pattern;
2142
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2143
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2144
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2145
+ const pattern = zod.def.innerType._zod.pattern;
1650
2146
  return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
1651
2147
  });
1652
- util.defineLazy(inst._zod, "values", () => {
1653
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
2148
+ util.defineLazyInternal(inst, "values", (zod) => {
2149
+ return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
1654
2150
  });
1655
2151
  inst._zod.parse = (payload, ctx) => {
1656
2152
  // Forward direction (decode): allow null to pass through
@@ -1662,8 +2158,8 @@ export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (ins
1662
2158
  export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
1663
2159
  $ZodType.init(inst, def);
1664
2160
  // inst._zod.qin = "true";
1665
- inst._zod.optin = "optional";
1666
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2161
+ inst._zod.optin = "defaulted";
2162
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1667
2163
  inst._zod.parse = (payload, ctx) => {
1668
2164
  if (ctx.direction === "backward") {
1669
2165
  return def.innerType._zod.run(payload, ctx);
@@ -1692,8 +2188,8 @@ function handleDefaultResult(payload, def) {
1692
2188
  }
1693
2189
  export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
1694
2190
  $ZodType.init(inst, def);
1695
- inst._zod.optin = "optional";
1696
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2191
+ inst._zod.optin = "defaulted";
2192
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1697
2193
  inst._zod.parse = (payload, ctx) => {
1698
2194
  if (ctx.direction === "backward") {
1699
2195
  return def.innerType._zod.run(payload, ctx);
@@ -1707,8 +2203,8 @@ export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (ins
1707
2203
  });
1708
2204
  export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
1709
2205
  $ZodType.init(inst, def);
1710
- util.defineLazy(inst._zod, "values", () => {
1711
- const v = def.innerType._zod.values;
2206
+ util.defineLazyInternal(inst, "values", (zod) => {
2207
+ const v = zod.def.innerType._zod.values;
1712
2208
  return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
1713
2209
  });
1714
2210
  inst._zod.parse = (payload, ctx) => {
@@ -1747,45 +2243,40 @@ export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst,
1747
2243
  return payload;
1748
2244
  };
1749
2245
  });
2246
+ function handleCatchResult(payload, result, def, ctx) {
2247
+ if (!result.issues.length) {
2248
+ payload.value = result.value;
2249
+ // 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.
2250
+ if (result.memo)
2251
+ payload.memo = true;
2252
+ return payload;
2253
+ }
2254
+ // 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.
2255
+ payload.value = def.catchValue({
2256
+ ...result,
2257
+ value: payload.value,
2258
+ error: {
2259
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2260
+ },
2261
+ input: payload.value,
2262
+ });
2263
+ return payload;
2264
+ }
1750
2265
  export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
1751
2266
  $ZodType.init(inst, def);
1752
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1753
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1754
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2267
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2268
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2269
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1755
2270
  inst._zod.parse = (payload, ctx) => {
1756
2271
  if (ctx.direction === "backward") {
1757
2272
  return def.innerType._zod.run(payload, ctx);
1758
2273
  }
1759
2274
  // Forward direction (decode): apply catch logic
1760
- const result = def.innerType._zod.run(payload, ctx);
2275
+ const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
1761
2276
  if (result instanceof Promise) {
1762
- return result.then((result) => {
1763
- payload.value = result.value;
1764
- if (result.issues.length) {
1765
- payload.value = def.catchValue({
1766
- ...payload,
1767
- error: {
1768
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1769
- },
1770
- input: payload.value,
1771
- });
1772
- payload.issues = [];
1773
- }
1774
- return payload;
1775
- });
2277
+ return result.then((result) => handleCatchResult(payload, result, def, ctx));
1776
2278
  }
1777
- payload.value = result.value;
1778
- if (result.issues.length) {
1779
- payload.value = def.catchValue({
1780
- ...payload,
1781
- error: {
1782
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1783
- },
1784
- input: payload.value,
1785
- });
1786
- payload.issues = [];
1787
- }
1788
- return payload;
2279
+ return handleCatchResult(payload, result, def, ctx);
1789
2280
  };
1790
2281
  });
1791
2282
  export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
@@ -1805,10 +2296,10 @@ export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) =>
1805
2296
  });
1806
2297
  export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
1807
2298
  $ZodType.init(inst, def);
1808
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1809
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1810
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1811
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2299
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2300
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2301
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2302
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
1812
2303
  inst._zod.parse = (payload, ctx) => {
1813
2304
  if (ctx.direction === "backward") {
1814
2305
  const right = def.out._zod.run(payload, ctx);
@@ -1825,7 +2316,8 @@ export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def)
1825
2316
  };
1826
2317
  });
1827
2318
  function handlePipeResult(left, next, ctx) {
1828
- if (left.issues.length) {
2319
+ // 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.
2320
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
1829
2321
  // prevent further checks
1830
2322
  left.aborted = true;
1831
2323
  return left;
@@ -1834,10 +2326,10 @@ function handlePipeResult(left, next, ctx) {
1834
2326
  }
1835
2327
  export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
1836
2328
  $ZodType.init(inst, def);
1837
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1838
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1839
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1840
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2329
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2330
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2331
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2332
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
1841
2333
  inst._zod.parse = (payload, ctx) => {
1842
2334
  const direction = ctx.direction || "forward";
1843
2335
  if (direction === "forward") {
@@ -1886,12 +2378,15 @@ function handleCodecTxResult(left, value, nextSchema, ctx) {
1886
2378
  }
1887
2379
  return nextSchema._zod.run({ value, issues: left.issues }, ctx);
1888
2380
  }
2381
+ export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess", (inst, def) => {
2382
+ $ZodPipe.init(inst, def);
2383
+ });
1889
2384
  export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
1890
2385
  $ZodType.init(inst, def);
1891
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1892
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1893
- util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
1894
- util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2386
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2387
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2388
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2389
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
1895
2390
  inst._zod.parse = (payload, ctx) => {
1896
2391
  if (ctx.direction === "backward") {
1897
2392
  return def.innerType._zod.run(payload, ctx);
@@ -1904,25 +2399,72 @@ export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (ins
1904
2399
  };
1905
2400
  });
1906
2401
  function handleReadonlyResult(payload) {
1907
- payload.value = Object.freeze(payload.value);
2402
+ // 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.
2403
+ if (!payload.memo)
2404
+ payload.value = Object.freeze(payload.value);
1908
2405
  return payload;
1909
2406
  }
2407
+ // a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
2408
+ function leafPattern(schema) {
2409
+ const def = schema._zod.def;
2410
+ let pattern = def.pattern;
2411
+ let isInt = !!def.format?.includes("int");
2412
+ let minimum;
2413
+ let maximum;
2414
+ for (const ch of def.checks ?? []) {
2415
+ const d = ch._zod.def;
2416
+ if (d.pattern)
2417
+ pattern = d.pattern;
2418
+ isInt || (isInt = !!d.format?.includes("int"));
2419
+ const lo = d.minimum ?? d.length;
2420
+ const hi = d.maximum ?? d.length;
2421
+ if (lo !== undefined && (minimum === undefined || lo > minimum))
2422
+ minimum = lo;
2423
+ if (hi !== undefined && (maximum === undefined || hi < maximum))
2424
+ maximum = hi;
2425
+ }
2426
+ if (pattern)
2427
+ return pattern.source;
2428
+ // an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
2429
+ if (minimum !== undefined && maximum !== undefined && minimum > maximum)
2430
+ return "(?!)";
2431
+ if (minimum !== undefined || maximum !== undefined)
2432
+ return regexes.string({ minimum, maximum }).source;
2433
+ const own = schema._zod.pattern;
2434
+ return (isInt && own === regexes.number ? regexes.integer : own)?.source;
2435
+ }
2436
+ // a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
2437
+ function partPattern(schema) {
2438
+ const def = schema._zod.def;
2439
+ const own = schema._zod.pattern?.source;
2440
+ // lazy resolves its inner on the internals, not the def
2441
+ const inner = def.innerType ?? schema._zod.innerType;
2442
+ if (inner) {
2443
+ const before = inner._zod.pattern?.source;
2444
+ const after = partPattern(inner);
2445
+ if (own && before && after && after !== before) {
2446
+ return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
2447
+ }
2448
+ return own;
2449
+ }
2450
+ if (def.options) {
2451
+ const sources = def.options.map(partPattern);
2452
+ if (sources.every(Boolean))
2453
+ return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
2454
+ }
2455
+ return leafPattern(schema);
2456
+ }
1910
2457
  export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
1911
2458
  $ZodType.init(inst, def);
1912
2459
  const regexParts = [];
1913
2460
  for (const part of def.parts) {
1914
2461
  if (typeof part === "object" && part !== null) {
1915
2462
  // is Zod schema
1916
- if (!part._zod.pattern) {
1917
- // if (!source)
2463
+ const source = partPattern(part);
2464
+ if (!source) {
1918
2465
  throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
1919
2466
  }
1920
- const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
1921
- if (!source)
1922
- throw new Error(`Invalid template literal part: ${part._zod.traits}`);
1923
- const start = source.startsWith("^") ? 1 : 0;
1924
- const end = source.endsWith("$") ? source.length - 1 : source.length;
1925
- regexParts.push(source.slice(start, end));
2467
+ regexParts.push(util.cleanRegex(source));
1926
2468
  }
1927
2469
  else if (part === null || util.primitiveTypes.has(typeof part)) {
1928
2470
  regexParts.push(util.escapeRegex(`${part}`));
@@ -1958,33 +2500,35 @@ export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplate
1958
2500
  });
1959
2501
  export const $ZodFunction = /*@__PURE__*/ core.$constructor("$ZodFunction", (inst, def) => {
1960
2502
  $ZodType.init(inst, def);
1961
- inst._def = def;
2503
+ // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
2504
+ Object.defineProperty(inst, "_def", { value: def });
1962
2505
  inst._zod.def = def;
1963
2506
  inst.implement = (func) => {
1964
2507
  if (typeof func !== "function") {
1965
2508
  throw new Error("implement() must be called with a function");
1966
2509
  }
1967
- return function (...args) {
2510
+ // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
2511
+ return Object.defineProperty(function (...args) {
1968
2512
  const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
1969
2513
  const result = Reflect.apply(func, this, parsedArgs);
1970
2514
  if (inst._def.output) {
1971
2515
  return parse(inst._def.output, result);
1972
2516
  }
1973
2517
  return result;
1974
- };
2518
+ }, "_zod", { value: inst._zod, enumerable: false });
1975
2519
  };
1976
2520
  inst.implementAsync = (func) => {
1977
2521
  if (typeof func !== "function") {
1978
2522
  throw new Error("implementAsync() must be called with a function");
1979
2523
  }
1980
- return async function (...args) {
2524
+ return Object.defineProperty(async function (...args) {
1981
2525
  const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
1982
2526
  const result = await Reflect.apply(func, this, parsedArgs);
1983
2527
  if (inst._def.output) {
1984
2528
  return await parseAsync(inst._def.output, result);
1985
2529
  }
1986
2530
  return result;
1987
- };
2531
+ }, "_zod", { value: inst._zod, enumerable: false });
1988
2532
  };
1989
2533
  inst._zod.parse = (payload, _ctx) => {
1990
2534
  if (typeof payload.value !== "function") {
@@ -2043,18 +2587,17 @@ export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst,
2043
2587
  });
2044
2588
  export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
2045
2589
  $ZodType.init(inst, def);
2046
- // let _innerType!: any;
2047
- // util.defineLazy(def, "getter", () => {
2048
- // if (!_innerType) {
2049
- // _innerType = def.getter();
2050
- // }
2051
- // return () => _innerType;
2052
- // });
2053
- util.defineLazy(inst._zod, "innerType", () => def.getter());
2054
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2055
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2056
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
2057
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
2590
+ // 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.
2591
+ util.defineLazy(inst._zod, "innerType", () => {
2592
+ const d = def;
2593
+ if (!d._cachedInner)
2594
+ d._cachedInner = def.getter();
2595
+ return d._cachedInner;
2596
+ });
2597
+ util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
2598
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
2599
+ util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
2600
+ util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
2058
2601
  inst._zod.parse = (payload, ctx) => {
2059
2602
  const inner = inst._zod.innerType;
2060
2603
  return inner._zod.run(payload, ctx);