@rpgjs/client 5.0.0-alpha.9 → 5.0.0-beta.10

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 (347) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +19 -0
  3. package/dist/Game/AnimationManager.d.ts +8 -0
  4. package/dist/Game/AnimationManager.js +35 -0
  5. package/dist/Game/AnimationManager.js.map +1 -0
  6. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  7. package/dist/Game/Event.d.ts +1 -1
  8. package/dist/Game/Event.js +12 -0
  9. package/dist/Game/Event.js.map +1 -0
  10. package/dist/Game/Map.d.ts +31 -2
  11. package/dist/Game/Map.js +138 -0
  12. package/dist/Game/Map.js.map +1 -0
  13. package/dist/Game/Object.d.ts +189 -0
  14. package/dist/Game/Object.js +255 -0
  15. package/dist/Game/Object.js.map +1 -0
  16. package/dist/Game/Player.d.ts +1 -1
  17. package/dist/Game/Player.js +12 -0
  18. package/dist/Game/Player.js.map +1 -0
  19. package/dist/Gui/Gui.d.ts +192 -7
  20. package/dist/Gui/Gui.js +475 -0
  21. package/dist/Gui/Gui.js.map +1 -0
  22. package/dist/Gui/Gui.spec.d.ts +1 -0
  23. package/dist/Gui/NotificationManager.d.ts +23 -0
  24. package/dist/Gui/NotificationManager.js +49 -0
  25. package/dist/Gui/NotificationManager.js.map +1 -0
  26. package/dist/Resource.d.ts +97 -0
  27. package/dist/Resource.js +133 -0
  28. package/dist/Resource.js.map +1 -0
  29. package/dist/RpgClient.d.ts +295 -13
  30. package/dist/RpgClientEngine.d.ts +671 -15
  31. package/dist/RpgClientEngine.js +1442 -0
  32. package/dist/RpgClientEngine.js.map +1 -0
  33. package/dist/Sound.d.ts +199 -0
  34. package/dist/Sound.js +167 -0
  35. package/dist/Sound.js.map +1 -0
  36. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/decorate.js +9 -0
  37. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/decorateMetadata.js +6 -0
  38. package/dist/components/animations/animation.ce.js +23 -0
  39. package/dist/components/animations/animation.ce.js.map +1 -0
  40. package/dist/components/animations/hit.ce.js +64 -0
  41. package/dist/components/animations/hit.ce.js.map +1 -0
  42. package/dist/components/animations/index.d.ts +4 -0
  43. package/dist/components/animations/index.js +11 -0
  44. package/dist/components/animations/index.js.map +1 -0
  45. package/dist/components/character.ce.js +572 -0
  46. package/dist/components/character.ce.js.map +1 -0
  47. package/dist/components/dynamics/bar.ce.js +96 -0
  48. package/dist/components/dynamics/bar.ce.js.map +1 -0
  49. package/dist/components/dynamics/image.ce.js +23 -0
  50. package/dist/components/dynamics/image.ce.js.map +1 -0
  51. package/dist/components/dynamics/parse-value.d.ts +4 -0
  52. package/dist/components/dynamics/parse-value.js +63 -0
  53. package/dist/components/dynamics/parse-value.js.map +1 -0
  54. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  55. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  56. package/dist/components/dynamics/shape-utils.js +73 -0
  57. package/dist/components/dynamics/shape-utils.js.map +1 -0
  58. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  59. package/dist/components/dynamics/shape.ce.js +83 -0
  60. package/dist/components/dynamics/shape.ce.js.map +1 -0
  61. package/dist/components/dynamics/text.ce.js +50 -0
  62. package/dist/components/dynamics/text.ce.js.map +1 -0
  63. package/dist/components/gui/box.ce.js +26 -0
  64. package/dist/components/gui/box.ce.js.map +1 -0
  65. package/dist/components/gui/dialogbox/index.ce.js +198 -0
  66. package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
  67. package/dist/components/gui/gameover.ce.js +169 -0
  68. package/dist/components/gui/gameover.ce.js.map +1 -0
  69. package/dist/components/gui/hud/hud.ce.js +83 -0
  70. package/dist/components/gui/hud/hud.ce.js.map +1 -0
  71. package/dist/components/gui/index.d.ts +15 -3
  72. package/dist/components/gui/index.js +14 -0
  73. package/dist/components/gui/menu/equip-menu.ce.js +427 -0
  74. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
  75. package/dist/components/gui/menu/exit-menu.ce.js +55 -0
  76. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
  77. package/dist/components/gui/menu/items-menu.ce.js +326 -0
  78. package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
  79. package/dist/components/gui/menu/main-menu.ce.js +399 -0
  80. package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
  81. package/dist/components/gui/menu/options-menu.ce.js +49 -0
  82. package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
  83. package/dist/components/gui/menu/skills-menu.ce.js +102 -0
  84. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
  85. package/dist/components/gui/mobile/index.d.ts +8 -0
  86. package/dist/components/gui/mobile/index.js +21 -0
  87. package/dist/components/gui/mobile/index.js.map +1 -0
  88. package/dist/components/gui/mobile/mobile.ce.js +79 -0
  89. package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
  90. package/dist/components/gui/notification/notification.ce.js +62 -0
  91. package/dist/components/gui/notification/notification.ce.js.map +1 -0
  92. package/dist/components/gui/save-load.ce.js +211 -0
  93. package/dist/components/gui/save-load.ce.js.map +1 -0
  94. package/dist/components/gui/shop/shop.ce.js +614 -0
  95. package/dist/components/gui/shop/shop.ce.js.map +1 -0
  96. package/dist/components/gui/title-screen.ce.js +164 -0
  97. package/dist/components/gui/title-screen.ce.js.map +1 -0
  98. package/dist/components/index.d.ts +1 -0
  99. package/dist/components/index.js +4 -0
  100. package/dist/components/player-components-utils.d.ts +67 -0
  101. package/dist/components/player-components-utils.js +162 -0
  102. package/dist/components/player-components-utils.js.map +1 -0
  103. package/dist/components/player-components-utils.spec.d.ts +1 -0
  104. package/dist/components/player-components.ce.js +188 -0
  105. package/dist/components/player-components.ce.js.map +1 -0
  106. package/dist/components/prebuilt/hp-bar.ce.js +113 -0
  107. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
  108. package/dist/components/prebuilt/index.d.ts +19 -0
  109. package/dist/components/prebuilt/index.js +2 -0
  110. package/dist/components/prebuilt/light-halo.ce.js +70 -0
  111. package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
  112. package/dist/components/scenes/canvas.ce.js +196 -0
  113. package/dist/components/scenes/canvas.ce.js.map +1 -0
  114. package/dist/components/scenes/draw-map.ce.js +79 -0
  115. package/dist/components/scenes/draw-map.ce.js.map +1 -0
  116. package/dist/components/scenes/event-layer.ce.js +29 -0
  117. package/dist/components/scenes/event-layer.ce.js.map +1 -0
  118. package/dist/core/inject.js +18 -0
  119. package/dist/core/inject.js.map +1 -0
  120. package/dist/core/setup.js +16 -0
  121. package/dist/core/setup.js.map +1 -0
  122. package/dist/decorators/spritesheet.d.ts +1 -0
  123. package/dist/decorators/spritesheet.js +11 -0
  124. package/dist/decorators/spritesheet.js.map +1 -0
  125. package/dist/index.d.ts +16 -1
  126. package/dist/index.js +45 -14
  127. package/dist/module.d.ts +43 -4
  128. package/dist/module.js +179 -0
  129. package/dist/module.js.map +1 -0
  130. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js +167 -0
  131. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
  132. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
  133. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
  134. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
  135. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
  136. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
  137. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
  138. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
  139. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  140. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js +241 -0
  141. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
  142. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
  143. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
  144. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
  145. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
  146. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  147. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
  148. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
  149. package/dist/presets/animation.d.ts +31 -0
  150. package/dist/presets/animation.js +39 -0
  151. package/dist/presets/animation.js.map +1 -0
  152. package/dist/presets/faceset.d.ts +30 -0
  153. package/dist/presets/faceset.js +51 -0
  154. package/dist/presets/faceset.js.map +1 -0
  155. package/dist/presets/icon.d.ts +20 -0
  156. package/dist/presets/icon.js +15 -0
  157. package/dist/presets/icon.js.map +1 -0
  158. package/dist/presets/index.d.ts +123 -0
  159. package/dist/presets/index.js +17 -0
  160. package/dist/presets/index.js.map +1 -0
  161. package/dist/presets/lpc.d.ts +89 -0
  162. package/dist/presets/lpc.js +98 -0
  163. package/dist/presets/lpc.js.map +1 -0
  164. package/dist/presets/rmspritesheet.js +42 -0
  165. package/dist/presets/rmspritesheet.js.map +1 -0
  166. package/dist/services/AbstractSocket.d.ts +9 -5
  167. package/dist/services/AbstractSocket.js +11 -0
  168. package/dist/services/AbstractSocket.js.map +1 -0
  169. package/dist/services/keyboardControls.d.ts +15 -0
  170. package/dist/services/keyboardControls.js +23 -0
  171. package/dist/services/keyboardControls.js.map +1 -0
  172. package/dist/services/loadMap.d.ts +6 -0
  173. package/dist/services/loadMap.js +123 -0
  174. package/dist/services/loadMap.js.map +1 -0
  175. package/dist/services/mmorpg.d.ts +21 -9
  176. package/dist/services/mmorpg.js +136 -0
  177. package/dist/services/mmorpg.js.map +1 -0
  178. package/dist/services/save.d.ts +19 -0
  179. package/dist/services/save.js +77 -0
  180. package/dist/services/save.js.map +1 -0
  181. package/dist/services/save.spec.d.ts +1 -0
  182. package/dist/services/standalone.d.ts +67 -7
  183. package/dist/services/standalone.js +168 -0
  184. package/dist/services/standalone.js.map +1 -0
  185. package/dist/utils/getEntityProp.d.ts +39 -0
  186. package/dist/utils/getEntityProp.js +53 -0
  187. package/dist/utils/getEntityProp.js.map +1 -0
  188. package/dist/utils/getEntityProp.spec.d.ts +1 -0
  189. package/dist/utils/readPropValue.d.ts +2 -0
  190. package/dist/utils/readPropValue.js +13 -0
  191. package/dist/utils/readPropValue.js.map +1 -0
  192. package/package.json +14 -11
  193. package/src/Game/AnimationManager.spec.ts +30 -0
  194. package/src/Game/AnimationManager.ts +33 -0
  195. package/src/Game/Event.ts +1 -1
  196. package/src/Game/Map.ts +184 -3
  197. package/src/Game/Object.ts +409 -14
  198. package/src/Game/Player.ts +1 -1
  199. package/src/Gui/Gui.spec.ts +273 -0
  200. package/src/Gui/Gui.ts +566 -23
  201. package/src/Gui/NotificationManager.ts +69 -0
  202. package/src/Resource.ts +149 -0
  203. package/src/RpgClient.ts +309 -14
  204. package/src/RpgClientEngine.ts +1790 -63
  205. package/src/Sound.ts +253 -0
  206. package/src/components/{effects → animations}/animation.ce +3 -6
  207. package/src/components/{effects → animations}/index.ts +1 -1
  208. package/src/components/character.ce +801 -59
  209. package/src/components/dynamics/bar.ce +87 -0
  210. package/src/components/dynamics/image.ce +20 -0
  211. package/src/components/dynamics/parse-value.spec.ts +83 -0
  212. package/src/components/dynamics/parse-value.ts +154 -0
  213. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  214. package/src/components/dynamics/shape-utils.ts +61 -0
  215. package/src/components/dynamics/shape.ce +89 -0
  216. package/src/components/dynamics/text.ce +68 -0
  217. package/src/components/gui/box.ce +17 -0
  218. package/src/components/gui/dialogbox/index.ce +213 -187
  219. package/src/components/gui/gameover.ce +158 -0
  220. package/src/components/gui/hud/hud.ce +61 -0
  221. package/src/components/gui/index.ts +30 -4
  222. package/src/components/gui/menu/equip-menu.ce +410 -0
  223. package/src/components/gui/menu/exit-menu.ce +41 -0
  224. package/src/components/gui/menu/items-menu.ce +317 -0
  225. package/src/components/gui/menu/main-menu.ce +294 -0
  226. package/src/components/gui/menu/options-menu.ce +35 -0
  227. package/src/components/gui/menu/skills-menu.ce +83 -0
  228. package/src/components/gui/mobile/index.ts +24 -0
  229. package/src/components/gui/mobile/mobile.ce +80 -0
  230. package/src/components/gui/notification/notification.ce +51 -0
  231. package/src/components/gui/save-load.ce +208 -0
  232. package/src/components/gui/shop/shop.ce +493 -0
  233. package/src/components/gui/title-screen.ce +163 -0
  234. package/src/components/index.ts +3 -0
  235. package/src/components/player-components-utils.spec.ts +109 -0
  236. package/src/components/player-components-utils.ts +205 -0
  237. package/src/components/player-components.ce +221 -0
  238. package/src/components/prebuilt/hp-bar.ce +255 -0
  239. package/src/components/prebuilt/index.ts +24 -0
  240. package/src/components/prebuilt/light-halo.ce +148 -0
  241. package/src/components/scenes/canvas.ce +185 -21
  242. package/src/components/scenes/draw-map.ce +55 -21
  243. package/src/components/scenes/event-layer.ce +8 -2
  244. package/src/components/scenes/transition.ce +60 -0
  245. package/src/core/setup.ts +2 -2
  246. package/src/decorators/spritesheet.ts +8 -0
  247. package/src/index.ts +17 -2
  248. package/src/module.ts +132 -10
  249. package/src/presets/animation.ts +46 -0
  250. package/src/presets/faceset.ts +60 -0
  251. package/src/presets/icon.ts +17 -0
  252. package/src/presets/index.ts +9 -1
  253. package/src/presets/lpc.ts +108 -0
  254. package/src/services/AbstractSocket.ts +10 -2
  255. package/src/services/keyboardControls.ts +20 -0
  256. package/src/services/loadMap.ts +3 -1
  257. package/src/services/mmorpg.ts +106 -12
  258. package/src/services/save.spec.ts +127 -0
  259. package/src/services/save.ts +103 -0
  260. package/src/services/standalone.ts +110 -18
  261. package/src/utils/getEntityProp.spec.ts +96 -0
  262. package/src/utils/getEntityProp.ts +88 -0
  263. package/src/utils/readPropValue.ts +16 -0
  264. package/vite.config.ts +4 -2
  265. package/dist/Game/EffectManager.d.ts +0 -5
  266. package/dist/components/effects/index.d.ts +0 -4
  267. package/dist/index.js.map +0 -1
  268. package/dist/index10.js +0 -8
  269. package/dist/index10.js.map +0 -1
  270. package/dist/index11.js +0 -10
  271. package/dist/index11.js.map +0 -1
  272. package/dist/index12.js +0 -8
  273. package/dist/index12.js.map +0 -1
  274. package/dist/index13.js +0 -17
  275. package/dist/index13.js.map +0 -1
  276. package/dist/index14.js +0 -107
  277. package/dist/index14.js.map +0 -1
  278. package/dist/index15.js +0 -50
  279. package/dist/index15.js.map +0 -1
  280. package/dist/index16.js +0 -191
  281. package/dist/index16.js.map +0 -1
  282. package/dist/index17.js +0 -9
  283. package/dist/index17.js.map +0 -1
  284. package/dist/index18.js +0 -387
  285. package/dist/index18.js.map +0 -1
  286. package/dist/index19.js +0 -31
  287. package/dist/index19.js.map +0 -1
  288. package/dist/index2.js +0 -181
  289. package/dist/index2.js.map +0 -1
  290. package/dist/index20.js +0 -24
  291. package/dist/index20.js.map +0 -1
  292. package/dist/index21.js +0 -2421
  293. package/dist/index21.js.map +0 -1
  294. package/dist/index22.js +0 -114
  295. package/dist/index22.js.map +0 -1
  296. package/dist/index23.js +0 -109
  297. package/dist/index23.js.map +0 -1
  298. package/dist/index24.js +0 -71
  299. package/dist/index24.js.map +0 -1
  300. package/dist/index25.js +0 -21
  301. package/dist/index25.js.map +0 -1
  302. package/dist/index26.js +0 -41
  303. package/dist/index26.js.map +0 -1
  304. package/dist/index27.js +0 -5
  305. package/dist/index27.js.map +0 -1
  306. package/dist/index28.js +0 -322
  307. package/dist/index28.js.map +0 -1
  308. package/dist/index29.js +0 -27
  309. package/dist/index29.js.map +0 -1
  310. package/dist/index3.js +0 -87
  311. package/dist/index3.js.map +0 -1
  312. package/dist/index30.js +0 -11
  313. package/dist/index30.js.map +0 -1
  314. package/dist/index31.js +0 -11
  315. package/dist/index31.js.map +0 -1
  316. package/dist/index32.js +0 -174
  317. package/dist/index32.js.map +0 -1
  318. package/dist/index33.js +0 -501
  319. package/dist/index33.js.map +0 -1
  320. package/dist/index34.js +0 -12
  321. package/dist/index34.js.map +0 -1
  322. package/dist/index35.js +0 -4403
  323. package/dist/index35.js.map +0 -1
  324. package/dist/index36.js +0 -316
  325. package/dist/index36.js.map +0 -1
  326. package/dist/index37.js +0 -61
  327. package/dist/index37.js.map +0 -1
  328. package/dist/index38.js +0 -20
  329. package/dist/index38.js.map +0 -1
  330. package/dist/index39.js +0 -20
  331. package/dist/index39.js.map +0 -1
  332. package/dist/index4.js +0 -67
  333. package/dist/index4.js.map +0 -1
  334. package/dist/index5.js +0 -16
  335. package/dist/index5.js.map +0 -1
  336. package/dist/index6.js +0 -17
  337. package/dist/index6.js.map +0 -1
  338. package/dist/index7.js +0 -39
  339. package/dist/index7.js.map +0 -1
  340. package/dist/index8.js +0 -108
  341. package/dist/index8.js.map +0 -1
  342. package/dist/index9.js +0 -76
  343. package/dist/index9.js.map +0 -1
  344. package/src/Game/EffectManager.ts +0 -20
  345. package/src/components/gui/dialogbox/itemMenu.ce +0 -23
  346. package/src/components/gui/dialogbox/selection.ce +0 -67
  347. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -0,0 +1,3756 @@
1
+ //#region ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
2
+ var util;
3
+ (function(util) {
4
+ util.assertEqual = (val) => val;
5
+ function assertIs(_arg) {}
6
+ util.assertIs = assertIs;
7
+ function assertNever(_x) {
8
+ throw new Error();
9
+ }
10
+ util.assertNever = assertNever;
11
+ util.arrayToEnum = (items) => {
12
+ const obj = {};
13
+ for (const item of items) obj[item] = item;
14
+ return obj;
15
+ };
16
+ util.getValidEnumValues = (obj) => {
17
+ const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
18
+ const filtered = {};
19
+ for (const k of validKeys) filtered[k] = obj[k];
20
+ return util.objectValues(filtered);
21
+ };
22
+ util.objectValues = (obj) => {
23
+ return util.objectKeys(obj).map(function(e) {
24
+ return obj[e];
25
+ });
26
+ };
27
+ util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
28
+ const keys = [];
29
+ for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) keys.push(key);
30
+ return keys;
31
+ };
32
+ util.find = (arr, checker) => {
33
+ for (const item of arr) if (checker(item)) return item;
34
+ };
35
+ util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
36
+ function joinValues(array, separator = " | ") {
37
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
38
+ }
39
+ util.joinValues = joinValues;
40
+ util.jsonStringifyReplacer = (_, value) => {
41
+ if (typeof value === "bigint") return value.toString();
42
+ return value;
43
+ };
44
+ })(util || (util = {}));
45
+ var objectUtil;
46
+ (function(objectUtil) {
47
+ objectUtil.mergeShapes = (first, second) => {
48
+ return {
49
+ ...first,
50
+ ...second
51
+ };
52
+ };
53
+ })(objectUtil || (objectUtil = {}));
54
+ var ZodParsedType = util.arrayToEnum([
55
+ "string",
56
+ "nan",
57
+ "number",
58
+ "integer",
59
+ "float",
60
+ "boolean",
61
+ "date",
62
+ "bigint",
63
+ "symbol",
64
+ "function",
65
+ "undefined",
66
+ "null",
67
+ "array",
68
+ "object",
69
+ "unknown",
70
+ "promise",
71
+ "void",
72
+ "never",
73
+ "map",
74
+ "set"
75
+ ]);
76
+ var getParsedType = (data) => {
77
+ switch (typeof data) {
78
+ case "undefined": return ZodParsedType.undefined;
79
+ case "string": return ZodParsedType.string;
80
+ case "number": return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
81
+ case "boolean": return ZodParsedType.boolean;
82
+ case "function": return ZodParsedType.function;
83
+ case "bigint": return ZodParsedType.bigint;
84
+ case "symbol": return ZodParsedType.symbol;
85
+ case "object":
86
+ if (Array.isArray(data)) return ZodParsedType.array;
87
+ if (data === null) return ZodParsedType.null;
88
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return ZodParsedType.promise;
89
+ if (typeof Map !== "undefined" && data instanceof Map) return ZodParsedType.map;
90
+ if (typeof Set !== "undefined" && data instanceof Set) return ZodParsedType.set;
91
+ if (typeof Date !== "undefined" && data instanceof Date) return ZodParsedType.date;
92
+ return ZodParsedType.object;
93
+ default: return ZodParsedType.unknown;
94
+ }
95
+ };
96
+ var ZodIssueCode = util.arrayToEnum([
97
+ "invalid_type",
98
+ "invalid_literal",
99
+ "custom",
100
+ "invalid_union",
101
+ "invalid_union_discriminator",
102
+ "invalid_enum_value",
103
+ "unrecognized_keys",
104
+ "invalid_arguments",
105
+ "invalid_return_type",
106
+ "invalid_date",
107
+ "invalid_string",
108
+ "too_small",
109
+ "too_big",
110
+ "invalid_intersection_types",
111
+ "not_multiple_of",
112
+ "not_finite"
113
+ ]);
114
+ var quotelessJson = (obj) => {
115
+ return JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:");
116
+ };
117
+ var ZodError = class ZodError extends Error {
118
+ get errors() {
119
+ return this.issues;
120
+ }
121
+ constructor(issues) {
122
+ super();
123
+ this.issues = [];
124
+ this.addIssue = (sub) => {
125
+ this.issues = [...this.issues, sub];
126
+ };
127
+ this.addIssues = (subs = []) => {
128
+ this.issues = [...this.issues, ...subs];
129
+ };
130
+ const actualProto = new.target.prototype;
131
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
132
+ else this.__proto__ = actualProto;
133
+ this.name = "ZodError";
134
+ this.issues = issues;
135
+ }
136
+ format(_mapper) {
137
+ const mapper = _mapper || function(issue) {
138
+ return issue.message;
139
+ };
140
+ const fieldErrors = { _errors: [] };
141
+ const processError = (error) => {
142
+ for (const issue of error.issues) if (issue.code === "invalid_union") issue.unionErrors.map(processError);
143
+ else if (issue.code === "invalid_return_type") processError(issue.returnTypeError);
144
+ else if (issue.code === "invalid_arguments") processError(issue.argumentsError);
145
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
146
+ else {
147
+ let curr = fieldErrors;
148
+ let i = 0;
149
+ while (i < issue.path.length) {
150
+ const el = issue.path[i];
151
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
152
+ else {
153
+ curr[el] = curr[el] || { _errors: [] };
154
+ curr[el]._errors.push(mapper(issue));
155
+ }
156
+ curr = curr[el];
157
+ i++;
158
+ }
159
+ }
160
+ };
161
+ processError(this);
162
+ return fieldErrors;
163
+ }
164
+ static assert(value) {
165
+ if (!(value instanceof ZodError)) throw new Error(`Not a ZodError: ${value}`);
166
+ }
167
+ toString() {
168
+ return this.message;
169
+ }
170
+ get message() {
171
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
172
+ }
173
+ get isEmpty() {
174
+ return this.issues.length === 0;
175
+ }
176
+ flatten(mapper = (issue) => issue.message) {
177
+ const fieldErrors = {};
178
+ const formErrors = [];
179
+ for (const sub of this.issues) if (sub.path.length > 0) {
180
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
181
+ fieldErrors[sub.path[0]].push(mapper(sub));
182
+ } else formErrors.push(mapper(sub));
183
+ return {
184
+ formErrors,
185
+ fieldErrors
186
+ };
187
+ }
188
+ get formErrors() {
189
+ return this.flatten();
190
+ }
191
+ };
192
+ ZodError.create = (issues) => {
193
+ return new ZodError(issues);
194
+ };
195
+ var errorMap = (issue, _ctx) => {
196
+ let message;
197
+ switch (issue.code) {
198
+ case ZodIssueCode.invalid_type:
199
+ if (issue.received === ZodParsedType.undefined) message = "Required";
200
+ else message = `Expected ${issue.expected}, received ${issue.received}`;
201
+ break;
202
+ case ZodIssueCode.invalid_literal:
203
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
204
+ break;
205
+ case ZodIssueCode.unrecognized_keys:
206
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
207
+ break;
208
+ case ZodIssueCode.invalid_union:
209
+ message = `Invalid input`;
210
+ break;
211
+ case ZodIssueCode.invalid_union_discriminator:
212
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
213
+ break;
214
+ case ZodIssueCode.invalid_enum_value:
215
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
216
+ break;
217
+ case ZodIssueCode.invalid_arguments:
218
+ message = `Invalid function arguments`;
219
+ break;
220
+ case ZodIssueCode.invalid_return_type:
221
+ message = `Invalid function return type`;
222
+ break;
223
+ case ZodIssueCode.invalid_date:
224
+ message = `Invalid date`;
225
+ break;
226
+ case ZodIssueCode.invalid_string:
227
+ if (typeof issue.validation === "object") if ("includes" in issue.validation) {
228
+ message = `Invalid input: must include "${issue.validation.includes}"`;
229
+ if (typeof issue.validation.position === "number") message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
230
+ } else if ("startsWith" in issue.validation) message = `Invalid input: must start with "${issue.validation.startsWith}"`;
231
+ else if ("endsWith" in issue.validation) message = `Invalid input: must end with "${issue.validation.endsWith}"`;
232
+ else util.assertNever(issue.validation);
233
+ else if (issue.validation !== "regex") message = `Invalid ${issue.validation}`;
234
+ else message = "Invalid";
235
+ break;
236
+ case ZodIssueCode.too_small:
237
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
238
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
239
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
240
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
241
+ else message = "Invalid input";
242
+ break;
243
+ case ZodIssueCode.too_big:
244
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
245
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
246
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
247
+ else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
248
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
249
+ else message = "Invalid input";
250
+ break;
251
+ case ZodIssueCode.custom:
252
+ message = `Invalid input`;
253
+ break;
254
+ case ZodIssueCode.invalid_intersection_types:
255
+ message = `Intersection results could not be merged`;
256
+ break;
257
+ case ZodIssueCode.not_multiple_of:
258
+ message = `Number must be a multiple of ${issue.multipleOf}`;
259
+ break;
260
+ case ZodIssueCode.not_finite:
261
+ message = "Number must be finite";
262
+ break;
263
+ default:
264
+ message = _ctx.defaultError;
265
+ util.assertNever(issue);
266
+ }
267
+ return { message };
268
+ };
269
+ var overrideErrorMap = errorMap;
270
+ function setErrorMap(map) {
271
+ overrideErrorMap = map;
272
+ }
273
+ function getErrorMap() {
274
+ return overrideErrorMap;
275
+ }
276
+ var makeIssue = (params) => {
277
+ const { data, path, errorMaps, issueData } = params;
278
+ const fullPath = [...path, ...issueData.path || []];
279
+ const fullIssue = {
280
+ ...issueData,
281
+ path: fullPath
282
+ };
283
+ if (issueData.message !== void 0) return {
284
+ ...issueData,
285
+ path: fullPath,
286
+ message: issueData.message
287
+ };
288
+ let errorMessage = "";
289
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
290
+ for (const map of maps) errorMessage = map(fullIssue, {
291
+ data,
292
+ defaultError: errorMessage
293
+ }).message;
294
+ return {
295
+ ...issueData,
296
+ path: fullPath,
297
+ message: errorMessage
298
+ };
299
+ };
300
+ var EMPTY_PATH = [];
301
+ function addIssueToContext(ctx, issueData) {
302
+ const overrideMap = getErrorMap();
303
+ const issue = makeIssue({
304
+ issueData,
305
+ data: ctx.data,
306
+ path: ctx.path,
307
+ errorMaps: [
308
+ ctx.common.contextualErrorMap,
309
+ ctx.schemaErrorMap,
310
+ overrideMap,
311
+ overrideMap === errorMap ? void 0 : errorMap
312
+ ].filter((x) => !!x)
313
+ });
314
+ ctx.common.issues.push(issue);
315
+ }
316
+ var ParseStatus = class ParseStatus {
317
+ constructor() {
318
+ this.value = "valid";
319
+ }
320
+ dirty() {
321
+ if (this.value === "valid") this.value = "dirty";
322
+ }
323
+ abort() {
324
+ if (this.value !== "aborted") this.value = "aborted";
325
+ }
326
+ static mergeArray(status, results) {
327
+ const arrayValue = [];
328
+ for (const s of results) {
329
+ if (s.status === "aborted") return INVALID;
330
+ if (s.status === "dirty") status.dirty();
331
+ arrayValue.push(s.value);
332
+ }
333
+ return {
334
+ status: status.value,
335
+ value: arrayValue
336
+ };
337
+ }
338
+ static async mergeObjectAsync(status, pairs) {
339
+ const syncPairs = [];
340
+ for (const pair of pairs) {
341
+ const key = await pair.key;
342
+ const value = await pair.value;
343
+ syncPairs.push({
344
+ key,
345
+ value
346
+ });
347
+ }
348
+ return ParseStatus.mergeObjectSync(status, syncPairs);
349
+ }
350
+ static mergeObjectSync(status, pairs) {
351
+ const finalObject = {};
352
+ for (const pair of pairs) {
353
+ const { key, value } = pair;
354
+ if (key.status === "aborted") return INVALID;
355
+ if (value.status === "aborted") return INVALID;
356
+ if (key.status === "dirty") status.dirty();
357
+ if (value.status === "dirty") status.dirty();
358
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) finalObject[key.value] = value.value;
359
+ }
360
+ return {
361
+ status: status.value,
362
+ value: finalObject
363
+ };
364
+ }
365
+ };
366
+ var INVALID = Object.freeze({ status: "aborted" });
367
+ var DIRTY = (value) => ({
368
+ status: "dirty",
369
+ value
370
+ });
371
+ var OK = (value) => ({
372
+ status: "valid",
373
+ value
374
+ });
375
+ var isAborted = (x) => x.status === "aborted";
376
+ var isDirty = (x) => x.status === "dirty";
377
+ var isValid = (x) => x.status === "valid";
378
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
379
+ /******************************************************************************
380
+ Copyright (c) Microsoft Corporation.
381
+
382
+ Permission to use, copy, modify, and/or distribute this software for any
383
+ purpose with or without fee is hereby granted.
384
+
385
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
386
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
387
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
388
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
389
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
390
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
391
+ PERFORMANCE OF THIS SOFTWARE.
392
+ ***************************************************************************** */
393
+ function __classPrivateFieldGet(receiver, state, kind, f) {
394
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
395
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
396
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
397
+ }
398
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
399
+ if (kind === "m") throw new TypeError("Private method is not writable");
400
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
401
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
402
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
403
+ }
404
+ var errorUtil;
405
+ (function(errorUtil) {
406
+ errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
407
+ errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
408
+ })(errorUtil || (errorUtil = {}));
409
+ var _ZodEnum_cache, _ZodNativeEnum_cache;
410
+ var ParseInputLazyPath = class {
411
+ constructor(parent, value, path, key) {
412
+ this._cachedPath = [];
413
+ this.parent = parent;
414
+ this.data = value;
415
+ this._path = path;
416
+ this._key = key;
417
+ }
418
+ get path() {
419
+ if (!this._cachedPath.length) if (this._key instanceof Array) this._cachedPath.push(...this._path, ...this._key);
420
+ else this._cachedPath.push(...this._path, this._key);
421
+ return this._cachedPath;
422
+ }
423
+ };
424
+ var handleResult = (ctx, result) => {
425
+ if (isValid(result)) return {
426
+ success: true,
427
+ data: result.value
428
+ };
429
+ else {
430
+ if (!ctx.common.issues.length) throw new Error("Validation failed but no issues detected.");
431
+ return {
432
+ success: false,
433
+ get error() {
434
+ if (this._error) return this._error;
435
+ const error = new ZodError(ctx.common.issues);
436
+ this._error = error;
437
+ return this._error;
438
+ }
439
+ };
440
+ }
441
+ };
442
+ function processCreateParams(params) {
443
+ if (!params) return {};
444
+ const { errorMap, invalid_type_error, required_error, description } = params;
445
+ if (errorMap && (invalid_type_error || required_error)) throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
446
+ if (errorMap) return {
447
+ errorMap,
448
+ description
449
+ };
450
+ const customMap = (iss, ctx) => {
451
+ var _a, _b;
452
+ const { message } = params;
453
+ if (iss.code === "invalid_enum_value") return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
454
+ if (typeof ctx.data === "undefined") return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
455
+ if (iss.code !== "invalid_type") return { message: ctx.defaultError };
456
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
457
+ };
458
+ return {
459
+ errorMap: customMap,
460
+ description
461
+ };
462
+ }
463
+ var ZodType = class {
464
+ get description() {
465
+ return this._def.description;
466
+ }
467
+ _getType(input) {
468
+ return getParsedType(input.data);
469
+ }
470
+ _getOrReturnCtx(input, ctx) {
471
+ return ctx || {
472
+ common: input.parent.common,
473
+ data: input.data,
474
+ parsedType: getParsedType(input.data),
475
+ schemaErrorMap: this._def.errorMap,
476
+ path: input.path,
477
+ parent: input.parent
478
+ };
479
+ }
480
+ _processInputParams(input) {
481
+ return {
482
+ status: new ParseStatus(),
483
+ ctx: {
484
+ common: input.parent.common,
485
+ data: input.data,
486
+ parsedType: getParsedType(input.data),
487
+ schemaErrorMap: this._def.errorMap,
488
+ path: input.path,
489
+ parent: input.parent
490
+ }
491
+ };
492
+ }
493
+ _parseSync(input) {
494
+ const result = this._parse(input);
495
+ if (isAsync(result)) throw new Error("Synchronous parse encountered promise.");
496
+ return result;
497
+ }
498
+ _parseAsync(input) {
499
+ const result = this._parse(input);
500
+ return Promise.resolve(result);
501
+ }
502
+ parse(data, params) {
503
+ const result = this.safeParse(data, params);
504
+ if (result.success) return result.data;
505
+ throw result.error;
506
+ }
507
+ safeParse(data, params) {
508
+ var _a;
509
+ const ctx = {
510
+ common: {
511
+ issues: [],
512
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
513
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
514
+ },
515
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
516
+ schemaErrorMap: this._def.errorMap,
517
+ parent: null,
518
+ data,
519
+ parsedType: getParsedType(data)
520
+ };
521
+ return handleResult(ctx, this._parseSync({
522
+ data,
523
+ path: ctx.path,
524
+ parent: ctx
525
+ }));
526
+ }
527
+ "~validate"(data) {
528
+ var _a, _b;
529
+ const ctx = {
530
+ common: {
531
+ issues: [],
532
+ async: !!this["~standard"].async
533
+ },
534
+ path: [],
535
+ schemaErrorMap: this._def.errorMap,
536
+ parent: null,
537
+ data,
538
+ parsedType: getParsedType(data)
539
+ };
540
+ if (!this["~standard"].async) try {
541
+ const result = this._parseSync({
542
+ data,
543
+ path: [],
544
+ parent: ctx
545
+ });
546
+ return isValid(result) ? { value: result.value } : { issues: ctx.common.issues };
547
+ } catch (err) {
548
+ if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) this["~standard"].async = true;
549
+ ctx.common = {
550
+ issues: [],
551
+ async: true
552
+ };
553
+ }
554
+ return this._parseAsync({
555
+ data,
556
+ path: [],
557
+ parent: ctx
558
+ }).then((result) => isValid(result) ? { value: result.value } : { issues: ctx.common.issues });
559
+ }
560
+ async parseAsync(data, params) {
561
+ const result = await this.safeParseAsync(data, params);
562
+ if (result.success) return result.data;
563
+ throw result.error;
564
+ }
565
+ async safeParseAsync(data, params) {
566
+ const ctx = {
567
+ common: {
568
+ issues: [],
569
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
570
+ async: true
571
+ },
572
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
573
+ schemaErrorMap: this._def.errorMap,
574
+ parent: null,
575
+ data,
576
+ parsedType: getParsedType(data)
577
+ };
578
+ const maybeAsyncResult = this._parse({
579
+ data,
580
+ path: ctx.path,
581
+ parent: ctx
582
+ });
583
+ return handleResult(ctx, await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)));
584
+ }
585
+ refine(check, message) {
586
+ const getIssueProperties = (val) => {
587
+ if (typeof message === "string" || typeof message === "undefined") return { message };
588
+ else if (typeof message === "function") return message(val);
589
+ else return message;
590
+ };
591
+ return this._refinement((val, ctx) => {
592
+ const result = check(val);
593
+ const setError = () => ctx.addIssue({
594
+ code: ZodIssueCode.custom,
595
+ ...getIssueProperties(val)
596
+ });
597
+ if (typeof Promise !== "undefined" && result instanceof Promise) return result.then((data) => {
598
+ if (!data) {
599
+ setError();
600
+ return false;
601
+ } else return true;
602
+ });
603
+ if (!result) {
604
+ setError();
605
+ return false;
606
+ } else return true;
607
+ });
608
+ }
609
+ refinement(check, refinementData) {
610
+ return this._refinement((val, ctx) => {
611
+ if (!check(val)) {
612
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
613
+ return false;
614
+ } else return true;
615
+ });
616
+ }
617
+ _refinement(refinement) {
618
+ return new ZodEffects({
619
+ schema: this,
620
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
621
+ effect: {
622
+ type: "refinement",
623
+ refinement
624
+ }
625
+ });
626
+ }
627
+ superRefine(refinement) {
628
+ return this._refinement(refinement);
629
+ }
630
+ constructor(def) {
631
+ /** Alias of safeParseAsync */
632
+ this.spa = this.safeParseAsync;
633
+ this._def = def;
634
+ this.parse = this.parse.bind(this);
635
+ this.safeParse = this.safeParse.bind(this);
636
+ this.parseAsync = this.parseAsync.bind(this);
637
+ this.safeParseAsync = this.safeParseAsync.bind(this);
638
+ this.spa = this.spa.bind(this);
639
+ this.refine = this.refine.bind(this);
640
+ this.refinement = this.refinement.bind(this);
641
+ this.superRefine = this.superRefine.bind(this);
642
+ this.optional = this.optional.bind(this);
643
+ this.nullable = this.nullable.bind(this);
644
+ this.nullish = this.nullish.bind(this);
645
+ this.array = this.array.bind(this);
646
+ this.promise = this.promise.bind(this);
647
+ this.or = this.or.bind(this);
648
+ this.and = this.and.bind(this);
649
+ this.transform = this.transform.bind(this);
650
+ this.brand = this.brand.bind(this);
651
+ this.default = this.default.bind(this);
652
+ this.catch = this.catch.bind(this);
653
+ this.describe = this.describe.bind(this);
654
+ this.pipe = this.pipe.bind(this);
655
+ this.readonly = this.readonly.bind(this);
656
+ this.isNullable = this.isNullable.bind(this);
657
+ this.isOptional = this.isOptional.bind(this);
658
+ this["~standard"] = {
659
+ version: 1,
660
+ vendor: "zod",
661
+ validate: (data) => this["~validate"](data)
662
+ };
663
+ }
664
+ optional() {
665
+ return ZodOptional.create(this, this._def);
666
+ }
667
+ nullable() {
668
+ return ZodNullable.create(this, this._def);
669
+ }
670
+ nullish() {
671
+ return this.nullable().optional();
672
+ }
673
+ array() {
674
+ return ZodArray.create(this);
675
+ }
676
+ promise() {
677
+ return ZodPromise.create(this, this._def);
678
+ }
679
+ or(option) {
680
+ return ZodUnion.create([this, option], this._def);
681
+ }
682
+ and(incoming) {
683
+ return ZodIntersection.create(this, incoming, this._def);
684
+ }
685
+ transform(transform) {
686
+ return new ZodEffects({
687
+ ...processCreateParams(this._def),
688
+ schema: this,
689
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
690
+ effect: {
691
+ type: "transform",
692
+ transform
693
+ }
694
+ });
695
+ }
696
+ default(def) {
697
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
698
+ return new ZodDefault({
699
+ ...processCreateParams(this._def),
700
+ innerType: this,
701
+ defaultValue: defaultValueFunc,
702
+ typeName: ZodFirstPartyTypeKind.ZodDefault
703
+ });
704
+ }
705
+ brand() {
706
+ return new ZodBranded({
707
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
708
+ type: this,
709
+ ...processCreateParams(this._def)
710
+ });
711
+ }
712
+ catch(def) {
713
+ const catchValueFunc = typeof def === "function" ? def : () => def;
714
+ return new ZodCatch({
715
+ ...processCreateParams(this._def),
716
+ innerType: this,
717
+ catchValue: catchValueFunc,
718
+ typeName: ZodFirstPartyTypeKind.ZodCatch
719
+ });
720
+ }
721
+ describe(description) {
722
+ const This = this.constructor;
723
+ return new This({
724
+ ...this._def,
725
+ description
726
+ });
727
+ }
728
+ pipe(target) {
729
+ return ZodPipeline.create(this, target);
730
+ }
731
+ readonly() {
732
+ return ZodReadonly.create(this);
733
+ }
734
+ isOptional() {
735
+ return this.safeParse(void 0).success;
736
+ }
737
+ isNullable() {
738
+ return this.safeParse(null).success;
739
+ }
740
+ };
741
+ var cuidRegex = /^c[^\s-]{8,}$/i;
742
+ var cuid2Regex = /^[0-9a-z]+$/;
743
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
744
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
745
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
746
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
747
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
748
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
749
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
750
+ var emojiRegex;
751
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
752
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
753
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
754
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
755
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
756
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
757
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
758
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
759
+ function timeRegexSource(args) {
760
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
761
+ if (args.precision) regex = `${regex}\\.\\d{${args.precision}}`;
762
+ else if (args.precision == null) regex = `${regex}(\\.\\d+)?`;
763
+ return regex;
764
+ }
765
+ function timeRegex(args) {
766
+ return new RegExp(`^${timeRegexSource(args)}$`);
767
+ }
768
+ function datetimeRegex(args) {
769
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
770
+ const opts = [];
771
+ opts.push(args.local ? `Z?` : `Z`);
772
+ if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
773
+ regex = `${regex}(${opts.join("|")})`;
774
+ return new RegExp(`^${regex}$`);
775
+ }
776
+ function isValidIP(ip, version) {
777
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) return true;
778
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) return true;
779
+ return false;
780
+ }
781
+ function isValidJWT(jwt, alg) {
782
+ if (!jwtRegex.test(jwt)) return false;
783
+ try {
784
+ const [header] = jwt.split(".");
785
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
786
+ const decoded = JSON.parse(atob(base64));
787
+ if (typeof decoded !== "object" || decoded === null) return false;
788
+ if (!decoded.typ || !decoded.alg) return false;
789
+ if (alg && decoded.alg !== alg) return false;
790
+ return true;
791
+ } catch (_a) {
792
+ return false;
793
+ }
794
+ }
795
+ function isValidCidr(ip, version) {
796
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) return true;
797
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) return true;
798
+ return false;
799
+ }
800
+ var ZodString = class ZodString extends ZodType {
801
+ _parse(input) {
802
+ if (this._def.coerce) input.data = String(input.data);
803
+ if (this._getType(input) !== ZodParsedType.string) {
804
+ const ctx = this._getOrReturnCtx(input);
805
+ addIssueToContext(ctx, {
806
+ code: ZodIssueCode.invalid_type,
807
+ expected: ZodParsedType.string,
808
+ received: ctx.parsedType
809
+ });
810
+ return INVALID;
811
+ }
812
+ const status = new ParseStatus();
813
+ let ctx = void 0;
814
+ for (const check of this._def.checks) if (check.kind === "min") {
815
+ if (input.data.length < check.value) {
816
+ ctx = this._getOrReturnCtx(input, ctx);
817
+ addIssueToContext(ctx, {
818
+ code: ZodIssueCode.too_small,
819
+ minimum: check.value,
820
+ type: "string",
821
+ inclusive: true,
822
+ exact: false,
823
+ message: check.message
824
+ });
825
+ status.dirty();
826
+ }
827
+ } else if (check.kind === "max") {
828
+ if (input.data.length > check.value) {
829
+ ctx = this._getOrReturnCtx(input, ctx);
830
+ addIssueToContext(ctx, {
831
+ code: ZodIssueCode.too_big,
832
+ maximum: check.value,
833
+ type: "string",
834
+ inclusive: true,
835
+ exact: false,
836
+ message: check.message
837
+ });
838
+ status.dirty();
839
+ }
840
+ } else if (check.kind === "length") {
841
+ const tooBig = input.data.length > check.value;
842
+ const tooSmall = input.data.length < check.value;
843
+ if (tooBig || tooSmall) {
844
+ ctx = this._getOrReturnCtx(input, ctx);
845
+ if (tooBig) addIssueToContext(ctx, {
846
+ code: ZodIssueCode.too_big,
847
+ maximum: check.value,
848
+ type: "string",
849
+ inclusive: true,
850
+ exact: true,
851
+ message: check.message
852
+ });
853
+ else if (tooSmall) addIssueToContext(ctx, {
854
+ code: ZodIssueCode.too_small,
855
+ minimum: check.value,
856
+ type: "string",
857
+ inclusive: true,
858
+ exact: true,
859
+ message: check.message
860
+ });
861
+ status.dirty();
862
+ }
863
+ } else if (check.kind === "email") {
864
+ if (!emailRegex.test(input.data)) {
865
+ ctx = this._getOrReturnCtx(input, ctx);
866
+ addIssueToContext(ctx, {
867
+ validation: "email",
868
+ code: ZodIssueCode.invalid_string,
869
+ message: check.message
870
+ });
871
+ status.dirty();
872
+ }
873
+ } else if (check.kind === "emoji") {
874
+ if (!emojiRegex) emojiRegex = new RegExp(_emojiRegex, "u");
875
+ if (!emojiRegex.test(input.data)) {
876
+ ctx = this._getOrReturnCtx(input, ctx);
877
+ addIssueToContext(ctx, {
878
+ validation: "emoji",
879
+ code: ZodIssueCode.invalid_string,
880
+ message: check.message
881
+ });
882
+ status.dirty();
883
+ }
884
+ } else if (check.kind === "uuid") {
885
+ if (!uuidRegex.test(input.data)) {
886
+ ctx = this._getOrReturnCtx(input, ctx);
887
+ addIssueToContext(ctx, {
888
+ validation: "uuid",
889
+ code: ZodIssueCode.invalid_string,
890
+ message: check.message
891
+ });
892
+ status.dirty();
893
+ }
894
+ } else if (check.kind === "nanoid") {
895
+ if (!nanoidRegex.test(input.data)) {
896
+ ctx = this._getOrReturnCtx(input, ctx);
897
+ addIssueToContext(ctx, {
898
+ validation: "nanoid",
899
+ code: ZodIssueCode.invalid_string,
900
+ message: check.message
901
+ });
902
+ status.dirty();
903
+ }
904
+ } else if (check.kind === "cuid") {
905
+ if (!cuidRegex.test(input.data)) {
906
+ ctx = this._getOrReturnCtx(input, ctx);
907
+ addIssueToContext(ctx, {
908
+ validation: "cuid",
909
+ code: ZodIssueCode.invalid_string,
910
+ message: check.message
911
+ });
912
+ status.dirty();
913
+ }
914
+ } else if (check.kind === "cuid2") {
915
+ if (!cuid2Regex.test(input.data)) {
916
+ ctx = this._getOrReturnCtx(input, ctx);
917
+ addIssueToContext(ctx, {
918
+ validation: "cuid2",
919
+ code: ZodIssueCode.invalid_string,
920
+ message: check.message
921
+ });
922
+ status.dirty();
923
+ }
924
+ } else if (check.kind === "ulid") {
925
+ if (!ulidRegex.test(input.data)) {
926
+ ctx = this._getOrReturnCtx(input, ctx);
927
+ addIssueToContext(ctx, {
928
+ validation: "ulid",
929
+ code: ZodIssueCode.invalid_string,
930
+ message: check.message
931
+ });
932
+ status.dirty();
933
+ }
934
+ } else if (check.kind === "url") try {
935
+ new URL(input.data);
936
+ } catch (_a) {
937
+ ctx = this._getOrReturnCtx(input, ctx);
938
+ addIssueToContext(ctx, {
939
+ validation: "url",
940
+ code: ZodIssueCode.invalid_string,
941
+ message: check.message
942
+ });
943
+ status.dirty();
944
+ }
945
+ else if (check.kind === "regex") {
946
+ check.regex.lastIndex = 0;
947
+ if (!check.regex.test(input.data)) {
948
+ ctx = this._getOrReturnCtx(input, ctx);
949
+ addIssueToContext(ctx, {
950
+ validation: "regex",
951
+ code: ZodIssueCode.invalid_string,
952
+ message: check.message
953
+ });
954
+ status.dirty();
955
+ }
956
+ } else if (check.kind === "trim") input.data = input.data.trim();
957
+ else if (check.kind === "includes") {
958
+ if (!input.data.includes(check.value, check.position)) {
959
+ ctx = this._getOrReturnCtx(input, ctx);
960
+ addIssueToContext(ctx, {
961
+ code: ZodIssueCode.invalid_string,
962
+ validation: {
963
+ includes: check.value,
964
+ position: check.position
965
+ },
966
+ message: check.message
967
+ });
968
+ status.dirty();
969
+ }
970
+ } else if (check.kind === "toLowerCase") input.data = input.data.toLowerCase();
971
+ else if (check.kind === "toUpperCase") input.data = input.data.toUpperCase();
972
+ else if (check.kind === "startsWith") {
973
+ if (!input.data.startsWith(check.value)) {
974
+ ctx = this._getOrReturnCtx(input, ctx);
975
+ addIssueToContext(ctx, {
976
+ code: ZodIssueCode.invalid_string,
977
+ validation: { startsWith: check.value },
978
+ message: check.message
979
+ });
980
+ status.dirty();
981
+ }
982
+ } else if (check.kind === "endsWith") {
983
+ if (!input.data.endsWith(check.value)) {
984
+ ctx = this._getOrReturnCtx(input, ctx);
985
+ addIssueToContext(ctx, {
986
+ code: ZodIssueCode.invalid_string,
987
+ validation: { endsWith: check.value },
988
+ message: check.message
989
+ });
990
+ status.dirty();
991
+ }
992
+ } else if (check.kind === "datetime") {
993
+ if (!datetimeRegex(check).test(input.data)) {
994
+ ctx = this._getOrReturnCtx(input, ctx);
995
+ addIssueToContext(ctx, {
996
+ code: ZodIssueCode.invalid_string,
997
+ validation: "datetime",
998
+ message: check.message
999
+ });
1000
+ status.dirty();
1001
+ }
1002
+ } else if (check.kind === "date") {
1003
+ if (!dateRegex.test(input.data)) {
1004
+ ctx = this._getOrReturnCtx(input, ctx);
1005
+ addIssueToContext(ctx, {
1006
+ code: ZodIssueCode.invalid_string,
1007
+ validation: "date",
1008
+ message: check.message
1009
+ });
1010
+ status.dirty();
1011
+ }
1012
+ } else if (check.kind === "time") {
1013
+ if (!timeRegex(check).test(input.data)) {
1014
+ ctx = this._getOrReturnCtx(input, ctx);
1015
+ addIssueToContext(ctx, {
1016
+ code: ZodIssueCode.invalid_string,
1017
+ validation: "time",
1018
+ message: check.message
1019
+ });
1020
+ status.dirty();
1021
+ }
1022
+ } else if (check.kind === "duration") {
1023
+ if (!durationRegex.test(input.data)) {
1024
+ ctx = this._getOrReturnCtx(input, ctx);
1025
+ addIssueToContext(ctx, {
1026
+ validation: "duration",
1027
+ code: ZodIssueCode.invalid_string,
1028
+ message: check.message
1029
+ });
1030
+ status.dirty();
1031
+ }
1032
+ } else if (check.kind === "ip") {
1033
+ if (!isValidIP(input.data, check.version)) {
1034
+ ctx = this._getOrReturnCtx(input, ctx);
1035
+ addIssueToContext(ctx, {
1036
+ validation: "ip",
1037
+ code: ZodIssueCode.invalid_string,
1038
+ message: check.message
1039
+ });
1040
+ status.dirty();
1041
+ }
1042
+ } else if (check.kind === "jwt") {
1043
+ if (!isValidJWT(input.data, check.alg)) {
1044
+ ctx = this._getOrReturnCtx(input, ctx);
1045
+ addIssueToContext(ctx, {
1046
+ validation: "jwt",
1047
+ code: ZodIssueCode.invalid_string,
1048
+ message: check.message
1049
+ });
1050
+ status.dirty();
1051
+ }
1052
+ } else if (check.kind === "cidr") {
1053
+ if (!isValidCidr(input.data, check.version)) {
1054
+ ctx = this._getOrReturnCtx(input, ctx);
1055
+ addIssueToContext(ctx, {
1056
+ validation: "cidr",
1057
+ code: ZodIssueCode.invalid_string,
1058
+ message: check.message
1059
+ });
1060
+ status.dirty();
1061
+ }
1062
+ } else if (check.kind === "base64") {
1063
+ if (!base64Regex.test(input.data)) {
1064
+ ctx = this._getOrReturnCtx(input, ctx);
1065
+ addIssueToContext(ctx, {
1066
+ validation: "base64",
1067
+ code: ZodIssueCode.invalid_string,
1068
+ message: check.message
1069
+ });
1070
+ status.dirty();
1071
+ }
1072
+ } else if (check.kind === "base64url") {
1073
+ if (!base64urlRegex.test(input.data)) {
1074
+ ctx = this._getOrReturnCtx(input, ctx);
1075
+ addIssueToContext(ctx, {
1076
+ validation: "base64url",
1077
+ code: ZodIssueCode.invalid_string,
1078
+ message: check.message
1079
+ });
1080
+ status.dirty();
1081
+ }
1082
+ } else util.assertNever(check);
1083
+ return {
1084
+ status: status.value,
1085
+ value: input.data
1086
+ };
1087
+ }
1088
+ _regex(regex, validation, message) {
1089
+ return this.refinement((data) => regex.test(data), {
1090
+ validation,
1091
+ code: ZodIssueCode.invalid_string,
1092
+ ...errorUtil.errToObj(message)
1093
+ });
1094
+ }
1095
+ _addCheck(check) {
1096
+ return new ZodString({
1097
+ ...this._def,
1098
+ checks: [...this._def.checks, check]
1099
+ });
1100
+ }
1101
+ email(message) {
1102
+ return this._addCheck({
1103
+ kind: "email",
1104
+ ...errorUtil.errToObj(message)
1105
+ });
1106
+ }
1107
+ url(message) {
1108
+ return this._addCheck({
1109
+ kind: "url",
1110
+ ...errorUtil.errToObj(message)
1111
+ });
1112
+ }
1113
+ emoji(message) {
1114
+ return this._addCheck({
1115
+ kind: "emoji",
1116
+ ...errorUtil.errToObj(message)
1117
+ });
1118
+ }
1119
+ uuid(message) {
1120
+ return this._addCheck({
1121
+ kind: "uuid",
1122
+ ...errorUtil.errToObj(message)
1123
+ });
1124
+ }
1125
+ nanoid(message) {
1126
+ return this._addCheck({
1127
+ kind: "nanoid",
1128
+ ...errorUtil.errToObj(message)
1129
+ });
1130
+ }
1131
+ cuid(message) {
1132
+ return this._addCheck({
1133
+ kind: "cuid",
1134
+ ...errorUtil.errToObj(message)
1135
+ });
1136
+ }
1137
+ cuid2(message) {
1138
+ return this._addCheck({
1139
+ kind: "cuid2",
1140
+ ...errorUtil.errToObj(message)
1141
+ });
1142
+ }
1143
+ ulid(message) {
1144
+ return this._addCheck({
1145
+ kind: "ulid",
1146
+ ...errorUtil.errToObj(message)
1147
+ });
1148
+ }
1149
+ base64(message) {
1150
+ return this._addCheck({
1151
+ kind: "base64",
1152
+ ...errorUtil.errToObj(message)
1153
+ });
1154
+ }
1155
+ base64url(message) {
1156
+ return this._addCheck({
1157
+ kind: "base64url",
1158
+ ...errorUtil.errToObj(message)
1159
+ });
1160
+ }
1161
+ jwt(options) {
1162
+ return this._addCheck({
1163
+ kind: "jwt",
1164
+ ...errorUtil.errToObj(options)
1165
+ });
1166
+ }
1167
+ ip(options) {
1168
+ return this._addCheck({
1169
+ kind: "ip",
1170
+ ...errorUtil.errToObj(options)
1171
+ });
1172
+ }
1173
+ cidr(options) {
1174
+ return this._addCheck({
1175
+ kind: "cidr",
1176
+ ...errorUtil.errToObj(options)
1177
+ });
1178
+ }
1179
+ datetime(options) {
1180
+ var _a, _b;
1181
+ if (typeof options === "string") return this._addCheck({
1182
+ kind: "datetime",
1183
+ precision: null,
1184
+ offset: false,
1185
+ local: false,
1186
+ message: options
1187
+ });
1188
+ return this._addCheck({
1189
+ kind: "datetime",
1190
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1191
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1192
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1193
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1194
+ });
1195
+ }
1196
+ date(message) {
1197
+ return this._addCheck({
1198
+ kind: "date",
1199
+ message
1200
+ });
1201
+ }
1202
+ time(options) {
1203
+ if (typeof options === "string") return this._addCheck({
1204
+ kind: "time",
1205
+ precision: null,
1206
+ message: options
1207
+ });
1208
+ return this._addCheck({
1209
+ kind: "time",
1210
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1211
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1212
+ });
1213
+ }
1214
+ duration(message) {
1215
+ return this._addCheck({
1216
+ kind: "duration",
1217
+ ...errorUtil.errToObj(message)
1218
+ });
1219
+ }
1220
+ regex(regex, message) {
1221
+ return this._addCheck({
1222
+ kind: "regex",
1223
+ regex,
1224
+ ...errorUtil.errToObj(message)
1225
+ });
1226
+ }
1227
+ includes(value, options) {
1228
+ return this._addCheck({
1229
+ kind: "includes",
1230
+ value,
1231
+ position: options === null || options === void 0 ? void 0 : options.position,
1232
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1233
+ });
1234
+ }
1235
+ startsWith(value, message) {
1236
+ return this._addCheck({
1237
+ kind: "startsWith",
1238
+ value,
1239
+ ...errorUtil.errToObj(message)
1240
+ });
1241
+ }
1242
+ endsWith(value, message) {
1243
+ return this._addCheck({
1244
+ kind: "endsWith",
1245
+ value,
1246
+ ...errorUtil.errToObj(message)
1247
+ });
1248
+ }
1249
+ min(minLength, message) {
1250
+ return this._addCheck({
1251
+ kind: "min",
1252
+ value: minLength,
1253
+ ...errorUtil.errToObj(message)
1254
+ });
1255
+ }
1256
+ max(maxLength, message) {
1257
+ return this._addCheck({
1258
+ kind: "max",
1259
+ value: maxLength,
1260
+ ...errorUtil.errToObj(message)
1261
+ });
1262
+ }
1263
+ length(len, message) {
1264
+ return this._addCheck({
1265
+ kind: "length",
1266
+ value: len,
1267
+ ...errorUtil.errToObj(message)
1268
+ });
1269
+ }
1270
+ /**
1271
+ * Equivalent to `.min(1)`
1272
+ */
1273
+ nonempty(message) {
1274
+ return this.min(1, errorUtil.errToObj(message));
1275
+ }
1276
+ trim() {
1277
+ return new ZodString({
1278
+ ...this._def,
1279
+ checks: [...this._def.checks, { kind: "trim" }]
1280
+ });
1281
+ }
1282
+ toLowerCase() {
1283
+ return new ZodString({
1284
+ ...this._def,
1285
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1286
+ });
1287
+ }
1288
+ toUpperCase() {
1289
+ return new ZodString({
1290
+ ...this._def,
1291
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1292
+ });
1293
+ }
1294
+ get isDatetime() {
1295
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1296
+ }
1297
+ get isDate() {
1298
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1299
+ }
1300
+ get isTime() {
1301
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1302
+ }
1303
+ get isDuration() {
1304
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1305
+ }
1306
+ get isEmail() {
1307
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1308
+ }
1309
+ get isURL() {
1310
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1311
+ }
1312
+ get isEmoji() {
1313
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1314
+ }
1315
+ get isUUID() {
1316
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1317
+ }
1318
+ get isNANOID() {
1319
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1320
+ }
1321
+ get isCUID() {
1322
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1323
+ }
1324
+ get isCUID2() {
1325
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1326
+ }
1327
+ get isULID() {
1328
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1329
+ }
1330
+ get isIP() {
1331
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1332
+ }
1333
+ get isCIDR() {
1334
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1335
+ }
1336
+ get isBase64() {
1337
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1338
+ }
1339
+ get isBase64url() {
1340
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1341
+ }
1342
+ get minLength() {
1343
+ let min = null;
1344
+ for (const ch of this._def.checks) if (ch.kind === "min") {
1345
+ if (min === null || ch.value > min) min = ch.value;
1346
+ }
1347
+ return min;
1348
+ }
1349
+ get maxLength() {
1350
+ let max = null;
1351
+ for (const ch of this._def.checks) if (ch.kind === "max") {
1352
+ if (max === null || ch.value < max) max = ch.value;
1353
+ }
1354
+ return max;
1355
+ }
1356
+ };
1357
+ ZodString.create = (params) => {
1358
+ var _a;
1359
+ return new ZodString({
1360
+ checks: [],
1361
+ typeName: ZodFirstPartyTypeKind.ZodString,
1362
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1363
+ ...processCreateParams(params)
1364
+ });
1365
+ };
1366
+ function floatSafeRemainder(val, step) {
1367
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1368
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1369
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1370
+ return parseInt(val.toFixed(decCount).replace(".", "")) % parseInt(step.toFixed(decCount).replace(".", "")) / Math.pow(10, decCount);
1371
+ }
1372
+ var ZodNumber = class ZodNumber extends ZodType {
1373
+ constructor() {
1374
+ super(...arguments);
1375
+ this.min = this.gte;
1376
+ this.max = this.lte;
1377
+ this.step = this.multipleOf;
1378
+ }
1379
+ _parse(input) {
1380
+ if (this._def.coerce) input.data = Number(input.data);
1381
+ if (this._getType(input) !== ZodParsedType.number) {
1382
+ const ctx = this._getOrReturnCtx(input);
1383
+ addIssueToContext(ctx, {
1384
+ code: ZodIssueCode.invalid_type,
1385
+ expected: ZodParsedType.number,
1386
+ received: ctx.parsedType
1387
+ });
1388
+ return INVALID;
1389
+ }
1390
+ let ctx = void 0;
1391
+ const status = new ParseStatus();
1392
+ for (const check of this._def.checks) if (check.kind === "int") {
1393
+ if (!util.isInteger(input.data)) {
1394
+ ctx = this._getOrReturnCtx(input, ctx);
1395
+ addIssueToContext(ctx, {
1396
+ code: ZodIssueCode.invalid_type,
1397
+ expected: "integer",
1398
+ received: "float",
1399
+ message: check.message
1400
+ });
1401
+ status.dirty();
1402
+ }
1403
+ } else if (check.kind === "min") {
1404
+ if (check.inclusive ? input.data < check.value : input.data <= check.value) {
1405
+ ctx = this._getOrReturnCtx(input, ctx);
1406
+ addIssueToContext(ctx, {
1407
+ code: ZodIssueCode.too_small,
1408
+ minimum: check.value,
1409
+ type: "number",
1410
+ inclusive: check.inclusive,
1411
+ exact: false,
1412
+ message: check.message
1413
+ });
1414
+ status.dirty();
1415
+ }
1416
+ } else if (check.kind === "max") {
1417
+ if (check.inclusive ? input.data > check.value : input.data >= check.value) {
1418
+ ctx = this._getOrReturnCtx(input, ctx);
1419
+ addIssueToContext(ctx, {
1420
+ code: ZodIssueCode.too_big,
1421
+ maximum: check.value,
1422
+ type: "number",
1423
+ inclusive: check.inclusive,
1424
+ exact: false,
1425
+ message: check.message
1426
+ });
1427
+ status.dirty();
1428
+ }
1429
+ } else if (check.kind === "multipleOf") {
1430
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1431
+ ctx = this._getOrReturnCtx(input, ctx);
1432
+ addIssueToContext(ctx, {
1433
+ code: ZodIssueCode.not_multiple_of,
1434
+ multipleOf: check.value,
1435
+ message: check.message
1436
+ });
1437
+ status.dirty();
1438
+ }
1439
+ } else if (check.kind === "finite") {
1440
+ if (!Number.isFinite(input.data)) {
1441
+ ctx = this._getOrReturnCtx(input, ctx);
1442
+ addIssueToContext(ctx, {
1443
+ code: ZodIssueCode.not_finite,
1444
+ message: check.message
1445
+ });
1446
+ status.dirty();
1447
+ }
1448
+ } else util.assertNever(check);
1449
+ return {
1450
+ status: status.value,
1451
+ value: input.data
1452
+ };
1453
+ }
1454
+ gte(value, message) {
1455
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1456
+ }
1457
+ gt(value, message) {
1458
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1459
+ }
1460
+ lte(value, message) {
1461
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1462
+ }
1463
+ lt(value, message) {
1464
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1465
+ }
1466
+ setLimit(kind, value, inclusive, message) {
1467
+ return new ZodNumber({
1468
+ ...this._def,
1469
+ checks: [...this._def.checks, {
1470
+ kind,
1471
+ value,
1472
+ inclusive,
1473
+ message: errorUtil.toString(message)
1474
+ }]
1475
+ });
1476
+ }
1477
+ _addCheck(check) {
1478
+ return new ZodNumber({
1479
+ ...this._def,
1480
+ checks: [...this._def.checks, check]
1481
+ });
1482
+ }
1483
+ int(message) {
1484
+ return this._addCheck({
1485
+ kind: "int",
1486
+ message: errorUtil.toString(message)
1487
+ });
1488
+ }
1489
+ positive(message) {
1490
+ return this._addCheck({
1491
+ kind: "min",
1492
+ value: 0,
1493
+ inclusive: false,
1494
+ message: errorUtil.toString(message)
1495
+ });
1496
+ }
1497
+ negative(message) {
1498
+ return this._addCheck({
1499
+ kind: "max",
1500
+ value: 0,
1501
+ inclusive: false,
1502
+ message: errorUtil.toString(message)
1503
+ });
1504
+ }
1505
+ nonpositive(message) {
1506
+ return this._addCheck({
1507
+ kind: "max",
1508
+ value: 0,
1509
+ inclusive: true,
1510
+ message: errorUtil.toString(message)
1511
+ });
1512
+ }
1513
+ nonnegative(message) {
1514
+ return this._addCheck({
1515
+ kind: "min",
1516
+ value: 0,
1517
+ inclusive: true,
1518
+ message: errorUtil.toString(message)
1519
+ });
1520
+ }
1521
+ multipleOf(value, message) {
1522
+ return this._addCheck({
1523
+ kind: "multipleOf",
1524
+ value,
1525
+ message: errorUtil.toString(message)
1526
+ });
1527
+ }
1528
+ finite(message) {
1529
+ return this._addCheck({
1530
+ kind: "finite",
1531
+ message: errorUtil.toString(message)
1532
+ });
1533
+ }
1534
+ safe(message) {
1535
+ return this._addCheck({
1536
+ kind: "min",
1537
+ inclusive: true,
1538
+ value: Number.MIN_SAFE_INTEGER,
1539
+ message: errorUtil.toString(message)
1540
+ })._addCheck({
1541
+ kind: "max",
1542
+ inclusive: true,
1543
+ value: Number.MAX_SAFE_INTEGER,
1544
+ message: errorUtil.toString(message)
1545
+ });
1546
+ }
1547
+ get minValue() {
1548
+ let min = null;
1549
+ for (const ch of this._def.checks) if (ch.kind === "min") {
1550
+ if (min === null || ch.value > min) min = ch.value;
1551
+ }
1552
+ return min;
1553
+ }
1554
+ get maxValue() {
1555
+ let max = null;
1556
+ for (const ch of this._def.checks) if (ch.kind === "max") {
1557
+ if (max === null || ch.value < max) max = ch.value;
1558
+ }
1559
+ return max;
1560
+ }
1561
+ get isInt() {
1562
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1563
+ }
1564
+ get isFinite() {
1565
+ let max = null, min = null;
1566
+ for (const ch of this._def.checks) if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") return true;
1567
+ else if (ch.kind === "min") {
1568
+ if (min === null || ch.value > min) min = ch.value;
1569
+ } else if (ch.kind === "max") {
1570
+ if (max === null || ch.value < max) max = ch.value;
1571
+ }
1572
+ return Number.isFinite(min) && Number.isFinite(max);
1573
+ }
1574
+ };
1575
+ ZodNumber.create = (params) => {
1576
+ return new ZodNumber({
1577
+ checks: [],
1578
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1579
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1580
+ ...processCreateParams(params)
1581
+ });
1582
+ };
1583
+ var ZodBigInt = class ZodBigInt extends ZodType {
1584
+ constructor() {
1585
+ super(...arguments);
1586
+ this.min = this.gte;
1587
+ this.max = this.lte;
1588
+ }
1589
+ _parse(input) {
1590
+ if (this._def.coerce) try {
1591
+ input.data = BigInt(input.data);
1592
+ } catch (_a) {
1593
+ return this._getInvalidInput(input);
1594
+ }
1595
+ if (this._getType(input) !== ZodParsedType.bigint) return this._getInvalidInput(input);
1596
+ let ctx = void 0;
1597
+ const status = new ParseStatus();
1598
+ for (const check of this._def.checks) if (check.kind === "min") {
1599
+ if (check.inclusive ? input.data < check.value : input.data <= check.value) {
1600
+ ctx = this._getOrReturnCtx(input, ctx);
1601
+ addIssueToContext(ctx, {
1602
+ code: ZodIssueCode.too_small,
1603
+ type: "bigint",
1604
+ minimum: check.value,
1605
+ inclusive: check.inclusive,
1606
+ message: check.message
1607
+ });
1608
+ status.dirty();
1609
+ }
1610
+ } else if (check.kind === "max") {
1611
+ if (check.inclusive ? input.data > check.value : input.data >= check.value) {
1612
+ ctx = this._getOrReturnCtx(input, ctx);
1613
+ addIssueToContext(ctx, {
1614
+ code: ZodIssueCode.too_big,
1615
+ type: "bigint",
1616
+ maximum: check.value,
1617
+ inclusive: check.inclusive,
1618
+ message: check.message
1619
+ });
1620
+ status.dirty();
1621
+ }
1622
+ } else if (check.kind === "multipleOf") {
1623
+ if (input.data % check.value !== BigInt(0)) {
1624
+ ctx = this._getOrReturnCtx(input, ctx);
1625
+ addIssueToContext(ctx, {
1626
+ code: ZodIssueCode.not_multiple_of,
1627
+ multipleOf: check.value,
1628
+ message: check.message
1629
+ });
1630
+ status.dirty();
1631
+ }
1632
+ } else util.assertNever(check);
1633
+ return {
1634
+ status: status.value,
1635
+ value: input.data
1636
+ };
1637
+ }
1638
+ _getInvalidInput(input) {
1639
+ const ctx = this._getOrReturnCtx(input);
1640
+ addIssueToContext(ctx, {
1641
+ code: ZodIssueCode.invalid_type,
1642
+ expected: ZodParsedType.bigint,
1643
+ received: ctx.parsedType
1644
+ });
1645
+ return INVALID;
1646
+ }
1647
+ gte(value, message) {
1648
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1649
+ }
1650
+ gt(value, message) {
1651
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1652
+ }
1653
+ lte(value, message) {
1654
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1655
+ }
1656
+ lt(value, message) {
1657
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1658
+ }
1659
+ setLimit(kind, value, inclusive, message) {
1660
+ return new ZodBigInt({
1661
+ ...this._def,
1662
+ checks: [...this._def.checks, {
1663
+ kind,
1664
+ value,
1665
+ inclusive,
1666
+ message: errorUtil.toString(message)
1667
+ }]
1668
+ });
1669
+ }
1670
+ _addCheck(check) {
1671
+ return new ZodBigInt({
1672
+ ...this._def,
1673
+ checks: [...this._def.checks, check]
1674
+ });
1675
+ }
1676
+ positive(message) {
1677
+ return this._addCheck({
1678
+ kind: "min",
1679
+ value: BigInt(0),
1680
+ inclusive: false,
1681
+ message: errorUtil.toString(message)
1682
+ });
1683
+ }
1684
+ negative(message) {
1685
+ return this._addCheck({
1686
+ kind: "max",
1687
+ value: BigInt(0),
1688
+ inclusive: false,
1689
+ message: errorUtil.toString(message)
1690
+ });
1691
+ }
1692
+ nonpositive(message) {
1693
+ return this._addCheck({
1694
+ kind: "max",
1695
+ value: BigInt(0),
1696
+ inclusive: true,
1697
+ message: errorUtil.toString(message)
1698
+ });
1699
+ }
1700
+ nonnegative(message) {
1701
+ return this._addCheck({
1702
+ kind: "min",
1703
+ value: BigInt(0),
1704
+ inclusive: true,
1705
+ message: errorUtil.toString(message)
1706
+ });
1707
+ }
1708
+ multipleOf(value, message) {
1709
+ return this._addCheck({
1710
+ kind: "multipleOf",
1711
+ value,
1712
+ message: errorUtil.toString(message)
1713
+ });
1714
+ }
1715
+ get minValue() {
1716
+ let min = null;
1717
+ for (const ch of this._def.checks) if (ch.kind === "min") {
1718
+ if (min === null || ch.value > min) min = ch.value;
1719
+ }
1720
+ return min;
1721
+ }
1722
+ get maxValue() {
1723
+ let max = null;
1724
+ for (const ch of this._def.checks) if (ch.kind === "max") {
1725
+ if (max === null || ch.value < max) max = ch.value;
1726
+ }
1727
+ return max;
1728
+ }
1729
+ };
1730
+ ZodBigInt.create = (params) => {
1731
+ var _a;
1732
+ return new ZodBigInt({
1733
+ checks: [],
1734
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1735
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1736
+ ...processCreateParams(params)
1737
+ });
1738
+ };
1739
+ var ZodBoolean = class extends ZodType {
1740
+ _parse(input) {
1741
+ if (this._def.coerce) input.data = Boolean(input.data);
1742
+ if (this._getType(input) !== ZodParsedType.boolean) {
1743
+ const ctx = this._getOrReturnCtx(input);
1744
+ addIssueToContext(ctx, {
1745
+ code: ZodIssueCode.invalid_type,
1746
+ expected: ZodParsedType.boolean,
1747
+ received: ctx.parsedType
1748
+ });
1749
+ return INVALID;
1750
+ }
1751
+ return OK(input.data);
1752
+ }
1753
+ };
1754
+ ZodBoolean.create = (params) => {
1755
+ return new ZodBoolean({
1756
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1757
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1758
+ ...processCreateParams(params)
1759
+ });
1760
+ };
1761
+ var ZodDate = class ZodDate extends ZodType {
1762
+ _parse(input) {
1763
+ if (this._def.coerce) input.data = new Date(input.data);
1764
+ if (this._getType(input) !== ZodParsedType.date) {
1765
+ const ctx = this._getOrReturnCtx(input);
1766
+ addIssueToContext(ctx, {
1767
+ code: ZodIssueCode.invalid_type,
1768
+ expected: ZodParsedType.date,
1769
+ received: ctx.parsedType
1770
+ });
1771
+ return INVALID;
1772
+ }
1773
+ if (isNaN(input.data.getTime())) {
1774
+ addIssueToContext(this._getOrReturnCtx(input), { code: ZodIssueCode.invalid_date });
1775
+ return INVALID;
1776
+ }
1777
+ const status = new ParseStatus();
1778
+ let ctx = void 0;
1779
+ for (const check of this._def.checks) if (check.kind === "min") {
1780
+ if (input.data.getTime() < check.value) {
1781
+ ctx = this._getOrReturnCtx(input, ctx);
1782
+ addIssueToContext(ctx, {
1783
+ code: ZodIssueCode.too_small,
1784
+ message: check.message,
1785
+ inclusive: true,
1786
+ exact: false,
1787
+ minimum: check.value,
1788
+ type: "date"
1789
+ });
1790
+ status.dirty();
1791
+ }
1792
+ } else if (check.kind === "max") {
1793
+ if (input.data.getTime() > check.value) {
1794
+ ctx = this._getOrReturnCtx(input, ctx);
1795
+ addIssueToContext(ctx, {
1796
+ code: ZodIssueCode.too_big,
1797
+ message: check.message,
1798
+ inclusive: true,
1799
+ exact: false,
1800
+ maximum: check.value,
1801
+ type: "date"
1802
+ });
1803
+ status.dirty();
1804
+ }
1805
+ } else util.assertNever(check);
1806
+ return {
1807
+ status: status.value,
1808
+ value: new Date(input.data.getTime())
1809
+ };
1810
+ }
1811
+ _addCheck(check) {
1812
+ return new ZodDate({
1813
+ ...this._def,
1814
+ checks: [...this._def.checks, check]
1815
+ });
1816
+ }
1817
+ min(minDate, message) {
1818
+ return this._addCheck({
1819
+ kind: "min",
1820
+ value: minDate.getTime(),
1821
+ message: errorUtil.toString(message)
1822
+ });
1823
+ }
1824
+ max(maxDate, message) {
1825
+ return this._addCheck({
1826
+ kind: "max",
1827
+ value: maxDate.getTime(),
1828
+ message: errorUtil.toString(message)
1829
+ });
1830
+ }
1831
+ get minDate() {
1832
+ let min = null;
1833
+ for (const ch of this._def.checks) if (ch.kind === "min") {
1834
+ if (min === null || ch.value > min) min = ch.value;
1835
+ }
1836
+ return min != null ? new Date(min) : null;
1837
+ }
1838
+ get maxDate() {
1839
+ let max = null;
1840
+ for (const ch of this._def.checks) if (ch.kind === "max") {
1841
+ if (max === null || ch.value < max) max = ch.value;
1842
+ }
1843
+ return max != null ? new Date(max) : null;
1844
+ }
1845
+ };
1846
+ ZodDate.create = (params) => {
1847
+ return new ZodDate({
1848
+ checks: [],
1849
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1850
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1851
+ ...processCreateParams(params)
1852
+ });
1853
+ };
1854
+ var ZodSymbol = class extends ZodType {
1855
+ _parse(input) {
1856
+ if (this._getType(input) !== ZodParsedType.symbol) {
1857
+ const ctx = this._getOrReturnCtx(input);
1858
+ addIssueToContext(ctx, {
1859
+ code: ZodIssueCode.invalid_type,
1860
+ expected: ZodParsedType.symbol,
1861
+ received: ctx.parsedType
1862
+ });
1863
+ return INVALID;
1864
+ }
1865
+ return OK(input.data);
1866
+ }
1867
+ };
1868
+ ZodSymbol.create = (params) => {
1869
+ return new ZodSymbol({
1870
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1871
+ ...processCreateParams(params)
1872
+ });
1873
+ };
1874
+ var ZodUndefined = class extends ZodType {
1875
+ _parse(input) {
1876
+ if (this._getType(input) !== ZodParsedType.undefined) {
1877
+ const ctx = this._getOrReturnCtx(input);
1878
+ addIssueToContext(ctx, {
1879
+ code: ZodIssueCode.invalid_type,
1880
+ expected: ZodParsedType.undefined,
1881
+ received: ctx.parsedType
1882
+ });
1883
+ return INVALID;
1884
+ }
1885
+ return OK(input.data);
1886
+ }
1887
+ };
1888
+ ZodUndefined.create = (params) => {
1889
+ return new ZodUndefined({
1890
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
1891
+ ...processCreateParams(params)
1892
+ });
1893
+ };
1894
+ var ZodNull = class extends ZodType {
1895
+ _parse(input) {
1896
+ if (this._getType(input) !== ZodParsedType.null) {
1897
+ const ctx = this._getOrReturnCtx(input);
1898
+ addIssueToContext(ctx, {
1899
+ code: ZodIssueCode.invalid_type,
1900
+ expected: ZodParsedType.null,
1901
+ received: ctx.parsedType
1902
+ });
1903
+ return INVALID;
1904
+ }
1905
+ return OK(input.data);
1906
+ }
1907
+ };
1908
+ ZodNull.create = (params) => {
1909
+ return new ZodNull({
1910
+ typeName: ZodFirstPartyTypeKind.ZodNull,
1911
+ ...processCreateParams(params)
1912
+ });
1913
+ };
1914
+ var ZodAny = class extends ZodType {
1915
+ constructor() {
1916
+ super(...arguments);
1917
+ this._any = true;
1918
+ }
1919
+ _parse(input) {
1920
+ return OK(input.data);
1921
+ }
1922
+ };
1923
+ ZodAny.create = (params) => {
1924
+ return new ZodAny({
1925
+ typeName: ZodFirstPartyTypeKind.ZodAny,
1926
+ ...processCreateParams(params)
1927
+ });
1928
+ };
1929
+ var ZodUnknown = class extends ZodType {
1930
+ constructor() {
1931
+ super(...arguments);
1932
+ this._unknown = true;
1933
+ }
1934
+ _parse(input) {
1935
+ return OK(input.data);
1936
+ }
1937
+ };
1938
+ ZodUnknown.create = (params) => {
1939
+ return new ZodUnknown({
1940
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
1941
+ ...processCreateParams(params)
1942
+ });
1943
+ };
1944
+ var ZodNever = class extends ZodType {
1945
+ _parse(input) {
1946
+ const ctx = this._getOrReturnCtx(input);
1947
+ addIssueToContext(ctx, {
1948
+ code: ZodIssueCode.invalid_type,
1949
+ expected: ZodParsedType.never,
1950
+ received: ctx.parsedType
1951
+ });
1952
+ return INVALID;
1953
+ }
1954
+ };
1955
+ ZodNever.create = (params) => {
1956
+ return new ZodNever({
1957
+ typeName: ZodFirstPartyTypeKind.ZodNever,
1958
+ ...processCreateParams(params)
1959
+ });
1960
+ };
1961
+ var ZodVoid = class extends ZodType {
1962
+ _parse(input) {
1963
+ if (this._getType(input) !== ZodParsedType.undefined) {
1964
+ const ctx = this._getOrReturnCtx(input);
1965
+ addIssueToContext(ctx, {
1966
+ code: ZodIssueCode.invalid_type,
1967
+ expected: ZodParsedType.void,
1968
+ received: ctx.parsedType
1969
+ });
1970
+ return INVALID;
1971
+ }
1972
+ return OK(input.data);
1973
+ }
1974
+ };
1975
+ ZodVoid.create = (params) => {
1976
+ return new ZodVoid({
1977
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
1978
+ ...processCreateParams(params)
1979
+ });
1980
+ };
1981
+ var ZodArray = class ZodArray extends ZodType {
1982
+ _parse(input) {
1983
+ const { ctx, status } = this._processInputParams(input);
1984
+ const def = this._def;
1985
+ if (ctx.parsedType !== ZodParsedType.array) {
1986
+ addIssueToContext(ctx, {
1987
+ code: ZodIssueCode.invalid_type,
1988
+ expected: ZodParsedType.array,
1989
+ received: ctx.parsedType
1990
+ });
1991
+ return INVALID;
1992
+ }
1993
+ if (def.exactLength !== null) {
1994
+ const tooBig = ctx.data.length > def.exactLength.value;
1995
+ const tooSmall = ctx.data.length < def.exactLength.value;
1996
+ if (tooBig || tooSmall) {
1997
+ addIssueToContext(ctx, {
1998
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1999
+ minimum: tooSmall ? def.exactLength.value : void 0,
2000
+ maximum: tooBig ? def.exactLength.value : void 0,
2001
+ type: "array",
2002
+ inclusive: true,
2003
+ exact: true,
2004
+ message: def.exactLength.message
2005
+ });
2006
+ status.dirty();
2007
+ }
2008
+ }
2009
+ if (def.minLength !== null) {
2010
+ if (ctx.data.length < def.minLength.value) {
2011
+ addIssueToContext(ctx, {
2012
+ code: ZodIssueCode.too_small,
2013
+ minimum: def.minLength.value,
2014
+ type: "array",
2015
+ inclusive: true,
2016
+ exact: false,
2017
+ message: def.minLength.message
2018
+ });
2019
+ status.dirty();
2020
+ }
2021
+ }
2022
+ if (def.maxLength !== null) {
2023
+ if (ctx.data.length > def.maxLength.value) {
2024
+ addIssueToContext(ctx, {
2025
+ code: ZodIssueCode.too_big,
2026
+ maximum: def.maxLength.value,
2027
+ type: "array",
2028
+ inclusive: true,
2029
+ exact: false,
2030
+ message: def.maxLength.message
2031
+ });
2032
+ status.dirty();
2033
+ }
2034
+ }
2035
+ if (ctx.common.async) return Promise.all([...ctx.data].map((item, i) => {
2036
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2037
+ })).then((result) => {
2038
+ return ParseStatus.mergeArray(status, result);
2039
+ });
2040
+ const result = [...ctx.data].map((item, i) => {
2041
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2042
+ });
2043
+ return ParseStatus.mergeArray(status, result);
2044
+ }
2045
+ get element() {
2046
+ return this._def.type;
2047
+ }
2048
+ min(minLength, message) {
2049
+ return new ZodArray({
2050
+ ...this._def,
2051
+ minLength: {
2052
+ value: minLength,
2053
+ message: errorUtil.toString(message)
2054
+ }
2055
+ });
2056
+ }
2057
+ max(maxLength, message) {
2058
+ return new ZodArray({
2059
+ ...this._def,
2060
+ maxLength: {
2061
+ value: maxLength,
2062
+ message: errorUtil.toString(message)
2063
+ }
2064
+ });
2065
+ }
2066
+ length(len, message) {
2067
+ return new ZodArray({
2068
+ ...this._def,
2069
+ exactLength: {
2070
+ value: len,
2071
+ message: errorUtil.toString(message)
2072
+ }
2073
+ });
2074
+ }
2075
+ nonempty(message) {
2076
+ return this.min(1, message);
2077
+ }
2078
+ };
2079
+ ZodArray.create = (schema, params) => {
2080
+ return new ZodArray({
2081
+ type: schema,
2082
+ minLength: null,
2083
+ maxLength: null,
2084
+ exactLength: null,
2085
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2086
+ ...processCreateParams(params)
2087
+ });
2088
+ };
2089
+ function deepPartialify(schema) {
2090
+ if (schema instanceof ZodObject) {
2091
+ const newShape = {};
2092
+ for (const key in schema.shape) {
2093
+ const fieldSchema = schema.shape[key];
2094
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2095
+ }
2096
+ return new ZodObject({
2097
+ ...schema._def,
2098
+ shape: () => newShape
2099
+ });
2100
+ } else if (schema instanceof ZodArray) return new ZodArray({
2101
+ ...schema._def,
2102
+ type: deepPartialify(schema.element)
2103
+ });
2104
+ else if (schema instanceof ZodOptional) return ZodOptional.create(deepPartialify(schema.unwrap()));
2105
+ else if (schema instanceof ZodNullable) return ZodNullable.create(deepPartialify(schema.unwrap()));
2106
+ else if (schema instanceof ZodTuple) return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2107
+ else return schema;
2108
+ }
2109
+ var ZodObject = class ZodObject extends ZodType {
2110
+ constructor() {
2111
+ super(...arguments);
2112
+ this._cached = null;
2113
+ /**
2114
+ * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
2115
+ * If you want to pass through unknown properties, use `.passthrough()` instead.
2116
+ */
2117
+ this.nonstrict = this.passthrough;
2118
+ /**
2119
+ * @deprecated Use `.extend` instead
2120
+ * */
2121
+ this.augment = this.extend;
2122
+ }
2123
+ _getCached() {
2124
+ if (this._cached !== null) return this._cached;
2125
+ const shape = this._def.shape();
2126
+ const keys = util.objectKeys(shape);
2127
+ return this._cached = {
2128
+ shape,
2129
+ keys
2130
+ };
2131
+ }
2132
+ _parse(input) {
2133
+ if (this._getType(input) !== ZodParsedType.object) {
2134
+ const ctx = this._getOrReturnCtx(input);
2135
+ addIssueToContext(ctx, {
2136
+ code: ZodIssueCode.invalid_type,
2137
+ expected: ZodParsedType.object,
2138
+ received: ctx.parsedType
2139
+ });
2140
+ return INVALID;
2141
+ }
2142
+ const { status, ctx } = this._processInputParams(input);
2143
+ const { shape, keys: shapeKeys } = this._getCached();
2144
+ const extraKeys = [];
2145
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2146
+ for (const key in ctx.data) if (!shapeKeys.includes(key)) extraKeys.push(key);
2147
+ }
2148
+ const pairs = [];
2149
+ for (const key of shapeKeys) {
2150
+ const keyValidator = shape[key];
2151
+ const value = ctx.data[key];
2152
+ pairs.push({
2153
+ key: {
2154
+ status: "valid",
2155
+ value: key
2156
+ },
2157
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2158
+ alwaysSet: key in ctx.data
2159
+ });
2160
+ }
2161
+ if (this._def.catchall instanceof ZodNever) {
2162
+ const unknownKeys = this._def.unknownKeys;
2163
+ if (unknownKeys === "passthrough") for (const key of extraKeys) pairs.push({
2164
+ key: {
2165
+ status: "valid",
2166
+ value: key
2167
+ },
2168
+ value: {
2169
+ status: "valid",
2170
+ value: ctx.data[key]
2171
+ }
2172
+ });
2173
+ else if (unknownKeys === "strict") {
2174
+ if (extraKeys.length > 0) {
2175
+ addIssueToContext(ctx, {
2176
+ code: ZodIssueCode.unrecognized_keys,
2177
+ keys: extraKeys
2178
+ });
2179
+ status.dirty();
2180
+ }
2181
+ } else if (unknownKeys === "strip");
2182
+ else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2183
+ } else {
2184
+ const catchall = this._def.catchall;
2185
+ for (const key of extraKeys) {
2186
+ const value = ctx.data[key];
2187
+ pairs.push({
2188
+ key: {
2189
+ status: "valid",
2190
+ value: key
2191
+ },
2192
+ value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2193
+ alwaysSet: key in ctx.data
2194
+ });
2195
+ }
2196
+ }
2197
+ if (ctx.common.async) return Promise.resolve().then(async () => {
2198
+ const syncPairs = [];
2199
+ for (const pair of pairs) {
2200
+ const key = await pair.key;
2201
+ const value = await pair.value;
2202
+ syncPairs.push({
2203
+ key,
2204
+ value,
2205
+ alwaysSet: pair.alwaysSet
2206
+ });
2207
+ }
2208
+ return syncPairs;
2209
+ }).then((syncPairs) => {
2210
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2211
+ });
2212
+ else return ParseStatus.mergeObjectSync(status, pairs);
2213
+ }
2214
+ get shape() {
2215
+ return this._def.shape();
2216
+ }
2217
+ strict(message) {
2218
+ errorUtil.errToObj;
2219
+ return new ZodObject({
2220
+ ...this._def,
2221
+ unknownKeys: "strict",
2222
+ ...message !== void 0 ? { errorMap: (issue, ctx) => {
2223
+ var _a, _b, _c, _d;
2224
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2225
+ if (issue.code === "unrecognized_keys") return { message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError };
2226
+ return { message: defaultError };
2227
+ } } : {}
2228
+ });
2229
+ }
2230
+ strip() {
2231
+ return new ZodObject({
2232
+ ...this._def,
2233
+ unknownKeys: "strip"
2234
+ });
2235
+ }
2236
+ passthrough() {
2237
+ return new ZodObject({
2238
+ ...this._def,
2239
+ unknownKeys: "passthrough"
2240
+ });
2241
+ }
2242
+ extend(augmentation) {
2243
+ return new ZodObject({
2244
+ ...this._def,
2245
+ shape: () => ({
2246
+ ...this._def.shape(),
2247
+ ...augmentation
2248
+ })
2249
+ });
2250
+ }
2251
+ /**
2252
+ * Prior to zod@1.0.12 there was a bug in the
2253
+ * inferred type of merged objects. Please
2254
+ * upgrade if you are experiencing issues.
2255
+ */
2256
+ merge(merging) {
2257
+ return new ZodObject({
2258
+ unknownKeys: merging._def.unknownKeys,
2259
+ catchall: merging._def.catchall,
2260
+ shape: () => ({
2261
+ ...this._def.shape(),
2262
+ ...merging._def.shape()
2263
+ }),
2264
+ typeName: ZodFirstPartyTypeKind.ZodObject
2265
+ });
2266
+ }
2267
+ setKey(key, schema) {
2268
+ return this.augment({ [key]: schema });
2269
+ }
2270
+ catchall(index) {
2271
+ return new ZodObject({
2272
+ ...this._def,
2273
+ catchall: index
2274
+ });
2275
+ }
2276
+ pick(mask) {
2277
+ const shape = {};
2278
+ util.objectKeys(mask).forEach((key) => {
2279
+ if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
2280
+ });
2281
+ return new ZodObject({
2282
+ ...this._def,
2283
+ shape: () => shape
2284
+ });
2285
+ }
2286
+ omit(mask) {
2287
+ const shape = {};
2288
+ util.objectKeys(this.shape).forEach((key) => {
2289
+ if (!mask[key]) shape[key] = this.shape[key];
2290
+ });
2291
+ return new ZodObject({
2292
+ ...this._def,
2293
+ shape: () => shape
2294
+ });
2295
+ }
2296
+ /**
2297
+ * @deprecated
2298
+ */
2299
+ deepPartial() {
2300
+ return deepPartialify(this);
2301
+ }
2302
+ partial(mask) {
2303
+ const newShape = {};
2304
+ util.objectKeys(this.shape).forEach((key) => {
2305
+ const fieldSchema = this.shape[key];
2306
+ if (mask && !mask[key]) newShape[key] = fieldSchema;
2307
+ else newShape[key] = fieldSchema.optional();
2308
+ });
2309
+ return new ZodObject({
2310
+ ...this._def,
2311
+ shape: () => newShape
2312
+ });
2313
+ }
2314
+ required(mask) {
2315
+ const newShape = {};
2316
+ util.objectKeys(this.shape).forEach((key) => {
2317
+ if (mask && !mask[key]) newShape[key] = this.shape[key];
2318
+ else {
2319
+ let newField = this.shape[key];
2320
+ while (newField instanceof ZodOptional) newField = newField._def.innerType;
2321
+ newShape[key] = newField;
2322
+ }
2323
+ });
2324
+ return new ZodObject({
2325
+ ...this._def,
2326
+ shape: () => newShape
2327
+ });
2328
+ }
2329
+ keyof() {
2330
+ return createZodEnum(util.objectKeys(this.shape));
2331
+ }
2332
+ };
2333
+ ZodObject.create = (shape, params) => {
2334
+ return new ZodObject({
2335
+ shape: () => shape,
2336
+ unknownKeys: "strip",
2337
+ catchall: ZodNever.create(),
2338
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2339
+ ...processCreateParams(params)
2340
+ });
2341
+ };
2342
+ ZodObject.strictCreate = (shape, params) => {
2343
+ return new ZodObject({
2344
+ shape: () => shape,
2345
+ unknownKeys: "strict",
2346
+ catchall: ZodNever.create(),
2347
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2348
+ ...processCreateParams(params)
2349
+ });
2350
+ };
2351
+ ZodObject.lazycreate = (shape, params) => {
2352
+ return new ZodObject({
2353
+ shape,
2354
+ unknownKeys: "strip",
2355
+ catchall: ZodNever.create(),
2356
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2357
+ ...processCreateParams(params)
2358
+ });
2359
+ };
2360
+ var ZodUnion = class extends ZodType {
2361
+ _parse(input) {
2362
+ const { ctx } = this._processInputParams(input);
2363
+ const options = this._def.options;
2364
+ function handleResults(results) {
2365
+ for (const result of results) if (result.result.status === "valid") return result.result;
2366
+ for (const result of results) if (result.result.status === "dirty") {
2367
+ ctx.common.issues.push(...result.ctx.common.issues);
2368
+ return result.result;
2369
+ }
2370
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2371
+ addIssueToContext(ctx, {
2372
+ code: ZodIssueCode.invalid_union,
2373
+ unionErrors
2374
+ });
2375
+ return INVALID;
2376
+ }
2377
+ if (ctx.common.async) return Promise.all(options.map(async (option) => {
2378
+ const childCtx = {
2379
+ ...ctx,
2380
+ common: {
2381
+ ...ctx.common,
2382
+ issues: []
2383
+ },
2384
+ parent: null
2385
+ };
2386
+ return {
2387
+ result: await option._parseAsync({
2388
+ data: ctx.data,
2389
+ path: ctx.path,
2390
+ parent: childCtx
2391
+ }),
2392
+ ctx: childCtx
2393
+ };
2394
+ })).then(handleResults);
2395
+ else {
2396
+ let dirty = void 0;
2397
+ const issues = [];
2398
+ for (const option of options) {
2399
+ const childCtx = {
2400
+ ...ctx,
2401
+ common: {
2402
+ ...ctx.common,
2403
+ issues: []
2404
+ },
2405
+ parent: null
2406
+ };
2407
+ const result = option._parseSync({
2408
+ data: ctx.data,
2409
+ path: ctx.path,
2410
+ parent: childCtx
2411
+ });
2412
+ if (result.status === "valid") return result;
2413
+ else if (result.status === "dirty" && !dirty) dirty = {
2414
+ result,
2415
+ ctx: childCtx
2416
+ };
2417
+ if (childCtx.common.issues.length) issues.push(childCtx.common.issues);
2418
+ }
2419
+ if (dirty) {
2420
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2421
+ return dirty.result;
2422
+ }
2423
+ const unionErrors = issues.map((issues) => new ZodError(issues));
2424
+ addIssueToContext(ctx, {
2425
+ code: ZodIssueCode.invalid_union,
2426
+ unionErrors
2427
+ });
2428
+ return INVALID;
2429
+ }
2430
+ }
2431
+ get options() {
2432
+ return this._def.options;
2433
+ }
2434
+ };
2435
+ ZodUnion.create = (types, params) => {
2436
+ return new ZodUnion({
2437
+ options: types,
2438
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2439
+ ...processCreateParams(params)
2440
+ });
2441
+ };
2442
+ var getDiscriminator = (type) => {
2443
+ if (type instanceof ZodLazy) return getDiscriminator(type.schema);
2444
+ else if (type instanceof ZodEffects) return getDiscriminator(type.innerType());
2445
+ else if (type instanceof ZodLiteral) return [type.value];
2446
+ else if (type instanceof ZodEnum) return type.options;
2447
+ else if (type instanceof ZodNativeEnum) return util.objectValues(type.enum);
2448
+ else if (type instanceof ZodDefault) return getDiscriminator(type._def.innerType);
2449
+ else if (type instanceof ZodUndefined) return [void 0];
2450
+ else if (type instanceof ZodNull) return [null];
2451
+ else if (type instanceof ZodOptional) return [void 0, ...getDiscriminator(type.unwrap())];
2452
+ else if (type instanceof ZodNullable) return [null, ...getDiscriminator(type.unwrap())];
2453
+ else if (type instanceof ZodBranded) return getDiscriminator(type.unwrap());
2454
+ else if (type instanceof ZodReadonly) return getDiscriminator(type.unwrap());
2455
+ else if (type instanceof ZodCatch) return getDiscriminator(type._def.innerType);
2456
+ else return [];
2457
+ };
2458
+ var ZodDiscriminatedUnion = class ZodDiscriminatedUnion extends ZodType {
2459
+ _parse(input) {
2460
+ const { ctx } = this._processInputParams(input);
2461
+ if (ctx.parsedType !== ZodParsedType.object) {
2462
+ addIssueToContext(ctx, {
2463
+ code: ZodIssueCode.invalid_type,
2464
+ expected: ZodParsedType.object,
2465
+ received: ctx.parsedType
2466
+ });
2467
+ return INVALID;
2468
+ }
2469
+ const discriminator = this.discriminator;
2470
+ const discriminatorValue = ctx.data[discriminator];
2471
+ const option = this.optionsMap.get(discriminatorValue);
2472
+ if (!option) {
2473
+ addIssueToContext(ctx, {
2474
+ code: ZodIssueCode.invalid_union_discriminator,
2475
+ options: Array.from(this.optionsMap.keys()),
2476
+ path: [discriminator]
2477
+ });
2478
+ return INVALID;
2479
+ }
2480
+ if (ctx.common.async) return option._parseAsync({
2481
+ data: ctx.data,
2482
+ path: ctx.path,
2483
+ parent: ctx
2484
+ });
2485
+ else return option._parseSync({
2486
+ data: ctx.data,
2487
+ path: ctx.path,
2488
+ parent: ctx
2489
+ });
2490
+ }
2491
+ get discriminator() {
2492
+ return this._def.discriminator;
2493
+ }
2494
+ get options() {
2495
+ return this._def.options;
2496
+ }
2497
+ get optionsMap() {
2498
+ return this._def.optionsMap;
2499
+ }
2500
+ /**
2501
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2502
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2503
+ * have a different value for each object in the union.
2504
+ * @param discriminator the name of the discriminator property
2505
+ * @param types an array of object schemas
2506
+ * @param params
2507
+ */
2508
+ static create(discriminator, options, params) {
2509
+ const optionsMap = /* @__PURE__ */ new Map();
2510
+ for (const type of options) {
2511
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2512
+ if (!discriminatorValues.length) throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2513
+ for (const value of discriminatorValues) {
2514
+ if (optionsMap.has(value)) throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2515
+ optionsMap.set(value, type);
2516
+ }
2517
+ }
2518
+ return new ZodDiscriminatedUnion({
2519
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2520
+ discriminator,
2521
+ options,
2522
+ optionsMap,
2523
+ ...processCreateParams(params)
2524
+ });
2525
+ }
2526
+ };
2527
+ function mergeValues(a, b) {
2528
+ const aType = getParsedType(a);
2529
+ const bType = getParsedType(b);
2530
+ if (a === b) return {
2531
+ valid: true,
2532
+ data: a
2533
+ };
2534
+ else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2535
+ const bKeys = util.objectKeys(b);
2536
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2537
+ const newObj = {
2538
+ ...a,
2539
+ ...b
2540
+ };
2541
+ for (const key of sharedKeys) {
2542
+ const sharedValue = mergeValues(a[key], b[key]);
2543
+ if (!sharedValue.valid) return { valid: false };
2544
+ newObj[key] = sharedValue.data;
2545
+ }
2546
+ return {
2547
+ valid: true,
2548
+ data: newObj
2549
+ };
2550
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2551
+ if (a.length !== b.length) return { valid: false };
2552
+ const newArray = [];
2553
+ for (let index = 0; index < a.length; index++) {
2554
+ const itemA = a[index];
2555
+ const itemB = b[index];
2556
+ const sharedValue = mergeValues(itemA, itemB);
2557
+ if (!sharedValue.valid) return { valid: false };
2558
+ newArray.push(sharedValue.data);
2559
+ }
2560
+ return {
2561
+ valid: true,
2562
+ data: newArray
2563
+ };
2564
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) return {
2565
+ valid: true,
2566
+ data: a
2567
+ };
2568
+ else return { valid: false };
2569
+ }
2570
+ var ZodIntersection = class extends ZodType {
2571
+ _parse(input) {
2572
+ const { status, ctx } = this._processInputParams(input);
2573
+ const handleParsed = (parsedLeft, parsedRight) => {
2574
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) return INVALID;
2575
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2576
+ if (!merged.valid) {
2577
+ addIssueToContext(ctx, { code: ZodIssueCode.invalid_intersection_types });
2578
+ return INVALID;
2579
+ }
2580
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) status.dirty();
2581
+ return {
2582
+ status: status.value,
2583
+ value: merged.data
2584
+ };
2585
+ };
2586
+ if (ctx.common.async) return Promise.all([this._def.left._parseAsync({
2587
+ data: ctx.data,
2588
+ path: ctx.path,
2589
+ parent: ctx
2590
+ }), this._def.right._parseAsync({
2591
+ data: ctx.data,
2592
+ path: ctx.path,
2593
+ parent: ctx
2594
+ })]).then(([left, right]) => handleParsed(left, right));
2595
+ else return handleParsed(this._def.left._parseSync({
2596
+ data: ctx.data,
2597
+ path: ctx.path,
2598
+ parent: ctx
2599
+ }), this._def.right._parseSync({
2600
+ data: ctx.data,
2601
+ path: ctx.path,
2602
+ parent: ctx
2603
+ }));
2604
+ }
2605
+ };
2606
+ ZodIntersection.create = (left, right, params) => {
2607
+ return new ZodIntersection({
2608
+ left,
2609
+ right,
2610
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2611
+ ...processCreateParams(params)
2612
+ });
2613
+ };
2614
+ var ZodTuple = class ZodTuple extends ZodType {
2615
+ _parse(input) {
2616
+ const { status, ctx } = this._processInputParams(input);
2617
+ if (ctx.parsedType !== ZodParsedType.array) {
2618
+ addIssueToContext(ctx, {
2619
+ code: ZodIssueCode.invalid_type,
2620
+ expected: ZodParsedType.array,
2621
+ received: ctx.parsedType
2622
+ });
2623
+ return INVALID;
2624
+ }
2625
+ if (ctx.data.length < this._def.items.length) {
2626
+ addIssueToContext(ctx, {
2627
+ code: ZodIssueCode.too_small,
2628
+ minimum: this._def.items.length,
2629
+ inclusive: true,
2630
+ exact: false,
2631
+ type: "array"
2632
+ });
2633
+ return INVALID;
2634
+ }
2635
+ if (!this._def.rest && ctx.data.length > this._def.items.length) {
2636
+ addIssueToContext(ctx, {
2637
+ code: ZodIssueCode.too_big,
2638
+ maximum: this._def.items.length,
2639
+ inclusive: true,
2640
+ exact: false,
2641
+ type: "array"
2642
+ });
2643
+ status.dirty();
2644
+ }
2645
+ const items = [...ctx.data].map((item, itemIndex) => {
2646
+ const schema = this._def.items[itemIndex] || this._def.rest;
2647
+ if (!schema) return null;
2648
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2649
+ }).filter((x) => !!x);
2650
+ if (ctx.common.async) return Promise.all(items).then((results) => {
2651
+ return ParseStatus.mergeArray(status, results);
2652
+ });
2653
+ else return ParseStatus.mergeArray(status, items);
2654
+ }
2655
+ get items() {
2656
+ return this._def.items;
2657
+ }
2658
+ rest(rest) {
2659
+ return new ZodTuple({
2660
+ ...this._def,
2661
+ rest
2662
+ });
2663
+ }
2664
+ };
2665
+ ZodTuple.create = (schemas, params) => {
2666
+ if (!Array.isArray(schemas)) throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2667
+ return new ZodTuple({
2668
+ items: schemas,
2669
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2670
+ rest: null,
2671
+ ...processCreateParams(params)
2672
+ });
2673
+ };
2674
+ var ZodRecord = class ZodRecord extends ZodType {
2675
+ get keySchema() {
2676
+ return this._def.keyType;
2677
+ }
2678
+ get valueSchema() {
2679
+ return this._def.valueType;
2680
+ }
2681
+ _parse(input) {
2682
+ const { status, ctx } = this._processInputParams(input);
2683
+ if (ctx.parsedType !== ZodParsedType.object) {
2684
+ addIssueToContext(ctx, {
2685
+ code: ZodIssueCode.invalid_type,
2686
+ expected: ZodParsedType.object,
2687
+ received: ctx.parsedType
2688
+ });
2689
+ return INVALID;
2690
+ }
2691
+ const pairs = [];
2692
+ const keyType = this._def.keyType;
2693
+ const valueType = this._def.valueType;
2694
+ for (const key in ctx.data) pairs.push({
2695
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2696
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2697
+ alwaysSet: key in ctx.data
2698
+ });
2699
+ if (ctx.common.async) return ParseStatus.mergeObjectAsync(status, pairs);
2700
+ else return ParseStatus.mergeObjectSync(status, pairs);
2701
+ }
2702
+ get element() {
2703
+ return this._def.valueType;
2704
+ }
2705
+ static create(first, second, third) {
2706
+ if (second instanceof ZodType) return new ZodRecord({
2707
+ keyType: first,
2708
+ valueType: second,
2709
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2710
+ ...processCreateParams(third)
2711
+ });
2712
+ return new ZodRecord({
2713
+ keyType: ZodString.create(),
2714
+ valueType: first,
2715
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2716
+ ...processCreateParams(second)
2717
+ });
2718
+ }
2719
+ };
2720
+ var ZodMap = class extends ZodType {
2721
+ get keySchema() {
2722
+ return this._def.keyType;
2723
+ }
2724
+ get valueSchema() {
2725
+ return this._def.valueType;
2726
+ }
2727
+ _parse(input) {
2728
+ const { status, ctx } = this._processInputParams(input);
2729
+ if (ctx.parsedType !== ZodParsedType.map) {
2730
+ addIssueToContext(ctx, {
2731
+ code: ZodIssueCode.invalid_type,
2732
+ expected: ZodParsedType.map,
2733
+ received: ctx.parsedType
2734
+ });
2735
+ return INVALID;
2736
+ }
2737
+ const keyType = this._def.keyType;
2738
+ const valueType = this._def.valueType;
2739
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2740
+ return {
2741
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2742
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2743
+ };
2744
+ });
2745
+ if (ctx.common.async) {
2746
+ const finalMap = /* @__PURE__ */ new Map();
2747
+ return Promise.resolve().then(async () => {
2748
+ for (const pair of pairs) {
2749
+ const key = await pair.key;
2750
+ const value = await pair.value;
2751
+ if (key.status === "aborted" || value.status === "aborted") return INVALID;
2752
+ if (key.status === "dirty" || value.status === "dirty") status.dirty();
2753
+ finalMap.set(key.value, value.value);
2754
+ }
2755
+ return {
2756
+ status: status.value,
2757
+ value: finalMap
2758
+ };
2759
+ });
2760
+ } else {
2761
+ const finalMap = /* @__PURE__ */ new Map();
2762
+ for (const pair of pairs) {
2763
+ const key = pair.key;
2764
+ const value = pair.value;
2765
+ if (key.status === "aborted" || value.status === "aborted") return INVALID;
2766
+ if (key.status === "dirty" || value.status === "dirty") status.dirty();
2767
+ finalMap.set(key.value, value.value);
2768
+ }
2769
+ return {
2770
+ status: status.value,
2771
+ value: finalMap
2772
+ };
2773
+ }
2774
+ }
2775
+ };
2776
+ ZodMap.create = (keyType, valueType, params) => {
2777
+ return new ZodMap({
2778
+ valueType,
2779
+ keyType,
2780
+ typeName: ZodFirstPartyTypeKind.ZodMap,
2781
+ ...processCreateParams(params)
2782
+ });
2783
+ };
2784
+ var ZodSet = class ZodSet extends ZodType {
2785
+ _parse(input) {
2786
+ const { status, ctx } = this._processInputParams(input);
2787
+ if (ctx.parsedType !== ZodParsedType.set) {
2788
+ addIssueToContext(ctx, {
2789
+ code: ZodIssueCode.invalid_type,
2790
+ expected: ZodParsedType.set,
2791
+ received: ctx.parsedType
2792
+ });
2793
+ return INVALID;
2794
+ }
2795
+ const def = this._def;
2796
+ if (def.minSize !== null) {
2797
+ if (ctx.data.size < def.minSize.value) {
2798
+ addIssueToContext(ctx, {
2799
+ code: ZodIssueCode.too_small,
2800
+ minimum: def.minSize.value,
2801
+ type: "set",
2802
+ inclusive: true,
2803
+ exact: false,
2804
+ message: def.minSize.message
2805
+ });
2806
+ status.dirty();
2807
+ }
2808
+ }
2809
+ if (def.maxSize !== null) {
2810
+ if (ctx.data.size > def.maxSize.value) {
2811
+ addIssueToContext(ctx, {
2812
+ code: ZodIssueCode.too_big,
2813
+ maximum: def.maxSize.value,
2814
+ type: "set",
2815
+ inclusive: true,
2816
+ exact: false,
2817
+ message: def.maxSize.message
2818
+ });
2819
+ status.dirty();
2820
+ }
2821
+ }
2822
+ const valueType = this._def.valueType;
2823
+ function finalizeSet(elements) {
2824
+ const parsedSet = /* @__PURE__ */ new Set();
2825
+ for (const element of elements) {
2826
+ if (element.status === "aborted") return INVALID;
2827
+ if (element.status === "dirty") status.dirty();
2828
+ parsedSet.add(element.value);
2829
+ }
2830
+ return {
2831
+ status: status.value,
2832
+ value: parsedSet
2833
+ };
2834
+ }
2835
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2836
+ if (ctx.common.async) return Promise.all(elements).then((elements) => finalizeSet(elements));
2837
+ else return finalizeSet(elements);
2838
+ }
2839
+ min(minSize, message) {
2840
+ return new ZodSet({
2841
+ ...this._def,
2842
+ minSize: {
2843
+ value: minSize,
2844
+ message: errorUtil.toString(message)
2845
+ }
2846
+ });
2847
+ }
2848
+ max(maxSize, message) {
2849
+ return new ZodSet({
2850
+ ...this._def,
2851
+ maxSize: {
2852
+ value: maxSize,
2853
+ message: errorUtil.toString(message)
2854
+ }
2855
+ });
2856
+ }
2857
+ size(size, message) {
2858
+ return this.min(size, message).max(size, message);
2859
+ }
2860
+ nonempty(message) {
2861
+ return this.min(1, message);
2862
+ }
2863
+ };
2864
+ ZodSet.create = (valueType, params) => {
2865
+ return new ZodSet({
2866
+ valueType,
2867
+ minSize: null,
2868
+ maxSize: null,
2869
+ typeName: ZodFirstPartyTypeKind.ZodSet,
2870
+ ...processCreateParams(params)
2871
+ });
2872
+ };
2873
+ var ZodFunction = class ZodFunction extends ZodType {
2874
+ constructor() {
2875
+ super(...arguments);
2876
+ this.validate = this.implement;
2877
+ }
2878
+ _parse(input) {
2879
+ const { ctx } = this._processInputParams(input);
2880
+ if (ctx.parsedType !== ZodParsedType.function) {
2881
+ addIssueToContext(ctx, {
2882
+ code: ZodIssueCode.invalid_type,
2883
+ expected: ZodParsedType.function,
2884
+ received: ctx.parsedType
2885
+ });
2886
+ return INVALID;
2887
+ }
2888
+ function makeArgsIssue(args, error) {
2889
+ return makeIssue({
2890
+ data: args,
2891
+ path: ctx.path,
2892
+ errorMaps: [
2893
+ ctx.common.contextualErrorMap,
2894
+ ctx.schemaErrorMap,
2895
+ getErrorMap(),
2896
+ errorMap
2897
+ ].filter((x) => !!x),
2898
+ issueData: {
2899
+ code: ZodIssueCode.invalid_arguments,
2900
+ argumentsError: error
2901
+ }
2902
+ });
2903
+ }
2904
+ function makeReturnsIssue(returns, error) {
2905
+ return makeIssue({
2906
+ data: returns,
2907
+ path: ctx.path,
2908
+ errorMaps: [
2909
+ ctx.common.contextualErrorMap,
2910
+ ctx.schemaErrorMap,
2911
+ getErrorMap(),
2912
+ errorMap
2913
+ ].filter((x) => !!x),
2914
+ issueData: {
2915
+ code: ZodIssueCode.invalid_return_type,
2916
+ returnTypeError: error
2917
+ }
2918
+ });
2919
+ }
2920
+ const params = { errorMap: ctx.common.contextualErrorMap };
2921
+ const fn = ctx.data;
2922
+ if (this._def.returns instanceof ZodPromise) {
2923
+ const me = this;
2924
+ return OK(async function(...args) {
2925
+ const error = new ZodError([]);
2926
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2927
+ error.addIssue(makeArgsIssue(args, e));
2928
+ throw error;
2929
+ });
2930
+ const result = await Reflect.apply(fn, this, parsedArgs);
2931
+ return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
2932
+ error.addIssue(makeReturnsIssue(result, e));
2933
+ throw error;
2934
+ });
2935
+ });
2936
+ } else {
2937
+ const me = this;
2938
+ return OK(function(...args) {
2939
+ const parsedArgs = me._def.args.safeParse(args, params);
2940
+ if (!parsedArgs.success) throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2941
+ const result = Reflect.apply(fn, this, parsedArgs.data);
2942
+ const parsedReturns = me._def.returns.safeParse(result, params);
2943
+ if (!parsedReturns.success) throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2944
+ return parsedReturns.data;
2945
+ });
2946
+ }
2947
+ }
2948
+ parameters() {
2949
+ return this._def.args;
2950
+ }
2951
+ returnType() {
2952
+ return this._def.returns;
2953
+ }
2954
+ args(...items) {
2955
+ return new ZodFunction({
2956
+ ...this._def,
2957
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
2958
+ });
2959
+ }
2960
+ returns(returnType) {
2961
+ return new ZodFunction({
2962
+ ...this._def,
2963
+ returns: returnType
2964
+ });
2965
+ }
2966
+ implement(func) {
2967
+ return this.parse(func);
2968
+ }
2969
+ strictImplement(func) {
2970
+ return this.parse(func);
2971
+ }
2972
+ static create(args, returns, params) {
2973
+ return new ZodFunction({
2974
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
2975
+ returns: returns || ZodUnknown.create(),
2976
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
2977
+ ...processCreateParams(params)
2978
+ });
2979
+ }
2980
+ };
2981
+ var ZodLazy = class extends ZodType {
2982
+ get schema() {
2983
+ return this._def.getter();
2984
+ }
2985
+ _parse(input) {
2986
+ const { ctx } = this._processInputParams(input);
2987
+ return this._def.getter()._parse({
2988
+ data: ctx.data,
2989
+ path: ctx.path,
2990
+ parent: ctx
2991
+ });
2992
+ }
2993
+ };
2994
+ ZodLazy.create = (getter, params) => {
2995
+ return new ZodLazy({
2996
+ getter,
2997
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
2998
+ ...processCreateParams(params)
2999
+ });
3000
+ };
3001
+ var ZodLiteral = class extends ZodType {
3002
+ _parse(input) {
3003
+ if (input.data !== this._def.value) {
3004
+ const ctx = this._getOrReturnCtx(input);
3005
+ addIssueToContext(ctx, {
3006
+ received: ctx.data,
3007
+ code: ZodIssueCode.invalid_literal,
3008
+ expected: this._def.value
3009
+ });
3010
+ return INVALID;
3011
+ }
3012
+ return {
3013
+ status: "valid",
3014
+ value: input.data
3015
+ };
3016
+ }
3017
+ get value() {
3018
+ return this._def.value;
3019
+ }
3020
+ };
3021
+ ZodLiteral.create = (value, params) => {
3022
+ return new ZodLiteral({
3023
+ value,
3024
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3025
+ ...processCreateParams(params)
3026
+ });
3027
+ };
3028
+ function createZodEnum(values, params) {
3029
+ return new ZodEnum({
3030
+ values,
3031
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3032
+ ...processCreateParams(params)
3033
+ });
3034
+ }
3035
+ var ZodEnum = class ZodEnum extends ZodType {
3036
+ constructor() {
3037
+ super(...arguments);
3038
+ _ZodEnum_cache.set(this, void 0);
3039
+ }
3040
+ _parse(input) {
3041
+ if (typeof input.data !== "string") {
3042
+ const ctx = this._getOrReturnCtx(input);
3043
+ const expectedValues = this._def.values;
3044
+ addIssueToContext(ctx, {
3045
+ expected: util.joinValues(expectedValues),
3046
+ received: ctx.parsedType,
3047
+ code: ZodIssueCode.invalid_type
3048
+ });
3049
+ return INVALID;
3050
+ }
3051
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3052
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3053
+ const ctx = this._getOrReturnCtx(input);
3054
+ const expectedValues = this._def.values;
3055
+ addIssueToContext(ctx, {
3056
+ received: ctx.data,
3057
+ code: ZodIssueCode.invalid_enum_value,
3058
+ options: expectedValues
3059
+ });
3060
+ return INVALID;
3061
+ }
3062
+ return OK(input.data);
3063
+ }
3064
+ get options() {
3065
+ return this._def.values;
3066
+ }
3067
+ get enum() {
3068
+ const enumValues = {};
3069
+ for (const val of this._def.values) enumValues[val] = val;
3070
+ return enumValues;
3071
+ }
3072
+ get Values() {
3073
+ const enumValues = {};
3074
+ for (const val of this._def.values) enumValues[val] = val;
3075
+ return enumValues;
3076
+ }
3077
+ get Enum() {
3078
+ const enumValues = {};
3079
+ for (const val of this._def.values) enumValues[val] = val;
3080
+ return enumValues;
3081
+ }
3082
+ extract(values, newDef = this._def) {
3083
+ return ZodEnum.create(values, {
3084
+ ...this._def,
3085
+ ...newDef
3086
+ });
3087
+ }
3088
+ exclude(values, newDef = this._def) {
3089
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3090
+ ...this._def,
3091
+ ...newDef
3092
+ });
3093
+ }
3094
+ };
3095
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3096
+ ZodEnum.create = createZodEnum;
3097
+ var ZodNativeEnum = class extends ZodType {
3098
+ constructor() {
3099
+ super(...arguments);
3100
+ _ZodNativeEnum_cache.set(this, void 0);
3101
+ }
3102
+ _parse(input) {
3103
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3104
+ const ctx = this._getOrReturnCtx(input);
3105
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3106
+ const expectedValues = util.objectValues(nativeEnumValues);
3107
+ addIssueToContext(ctx, {
3108
+ expected: util.joinValues(expectedValues),
3109
+ received: ctx.parsedType,
3110
+ code: ZodIssueCode.invalid_type
3111
+ });
3112
+ return INVALID;
3113
+ }
3114
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3115
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3116
+ const expectedValues = util.objectValues(nativeEnumValues);
3117
+ addIssueToContext(ctx, {
3118
+ received: ctx.data,
3119
+ code: ZodIssueCode.invalid_enum_value,
3120
+ options: expectedValues
3121
+ });
3122
+ return INVALID;
3123
+ }
3124
+ return OK(input.data);
3125
+ }
3126
+ get enum() {
3127
+ return this._def.values;
3128
+ }
3129
+ };
3130
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3131
+ ZodNativeEnum.create = (values, params) => {
3132
+ return new ZodNativeEnum({
3133
+ values,
3134
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3135
+ ...processCreateParams(params)
3136
+ });
3137
+ };
3138
+ var ZodPromise = class extends ZodType {
3139
+ unwrap() {
3140
+ return this._def.type;
3141
+ }
3142
+ _parse(input) {
3143
+ const { ctx } = this._processInputParams(input);
3144
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3145
+ addIssueToContext(ctx, {
3146
+ code: ZodIssueCode.invalid_type,
3147
+ expected: ZodParsedType.promise,
3148
+ received: ctx.parsedType
3149
+ });
3150
+ return INVALID;
3151
+ }
3152
+ return OK((ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data)).then((data) => {
3153
+ return this._def.type.parseAsync(data, {
3154
+ path: ctx.path,
3155
+ errorMap: ctx.common.contextualErrorMap
3156
+ });
3157
+ }));
3158
+ }
3159
+ };
3160
+ ZodPromise.create = (schema, params) => {
3161
+ return new ZodPromise({
3162
+ type: schema,
3163
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3164
+ ...processCreateParams(params)
3165
+ });
3166
+ };
3167
+ var ZodEffects = class extends ZodType {
3168
+ innerType() {
3169
+ return this._def.schema;
3170
+ }
3171
+ sourceType() {
3172
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3173
+ }
3174
+ _parse(input) {
3175
+ const { status, ctx } = this._processInputParams(input);
3176
+ const effect = this._def.effect || null;
3177
+ const checkCtx = {
3178
+ addIssue: (arg) => {
3179
+ addIssueToContext(ctx, arg);
3180
+ if (arg.fatal) status.abort();
3181
+ else status.dirty();
3182
+ },
3183
+ get path() {
3184
+ return ctx.path;
3185
+ }
3186
+ };
3187
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3188
+ if (effect.type === "preprocess") {
3189
+ const processed = effect.transform(ctx.data, checkCtx);
3190
+ if (ctx.common.async) return Promise.resolve(processed).then(async (processed) => {
3191
+ if (status.value === "aborted") return INVALID;
3192
+ const result = await this._def.schema._parseAsync({
3193
+ data: processed,
3194
+ path: ctx.path,
3195
+ parent: ctx
3196
+ });
3197
+ if (result.status === "aborted") return INVALID;
3198
+ if (result.status === "dirty") return DIRTY(result.value);
3199
+ if (status.value === "dirty") return DIRTY(result.value);
3200
+ return result;
3201
+ });
3202
+ else {
3203
+ if (status.value === "aborted") return INVALID;
3204
+ const result = this._def.schema._parseSync({
3205
+ data: processed,
3206
+ path: ctx.path,
3207
+ parent: ctx
3208
+ });
3209
+ if (result.status === "aborted") return INVALID;
3210
+ if (result.status === "dirty") return DIRTY(result.value);
3211
+ if (status.value === "dirty") return DIRTY(result.value);
3212
+ return result;
3213
+ }
3214
+ }
3215
+ if (effect.type === "refinement") {
3216
+ const executeRefinement = (acc) => {
3217
+ const result = effect.refinement(acc, checkCtx);
3218
+ if (ctx.common.async) return Promise.resolve(result);
3219
+ if (result instanceof Promise) throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3220
+ return acc;
3221
+ };
3222
+ if (ctx.common.async === false) {
3223
+ const inner = this._def.schema._parseSync({
3224
+ data: ctx.data,
3225
+ path: ctx.path,
3226
+ parent: ctx
3227
+ });
3228
+ if (inner.status === "aborted") return INVALID;
3229
+ if (inner.status === "dirty") status.dirty();
3230
+ executeRefinement(inner.value);
3231
+ return {
3232
+ status: status.value,
3233
+ value: inner.value
3234
+ };
3235
+ } else return this._def.schema._parseAsync({
3236
+ data: ctx.data,
3237
+ path: ctx.path,
3238
+ parent: ctx
3239
+ }).then((inner) => {
3240
+ if (inner.status === "aborted") return INVALID;
3241
+ if (inner.status === "dirty") status.dirty();
3242
+ return executeRefinement(inner.value).then(() => {
3243
+ return {
3244
+ status: status.value,
3245
+ value: inner.value
3246
+ };
3247
+ });
3248
+ });
3249
+ }
3250
+ if (effect.type === "transform") if (ctx.common.async === false) {
3251
+ const base = this._def.schema._parseSync({
3252
+ data: ctx.data,
3253
+ path: ctx.path,
3254
+ parent: ctx
3255
+ });
3256
+ if (!isValid(base)) return base;
3257
+ const result = effect.transform(base.value, checkCtx);
3258
+ if (result instanceof Promise) throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3259
+ return {
3260
+ status: status.value,
3261
+ value: result
3262
+ };
3263
+ } else return this._def.schema._parseAsync({
3264
+ data: ctx.data,
3265
+ path: ctx.path,
3266
+ parent: ctx
3267
+ }).then((base) => {
3268
+ if (!isValid(base)) return base;
3269
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3270
+ status: status.value,
3271
+ value: result
3272
+ }));
3273
+ });
3274
+ util.assertNever(effect);
3275
+ }
3276
+ };
3277
+ ZodEffects.create = (schema, effect, params) => {
3278
+ return new ZodEffects({
3279
+ schema,
3280
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3281
+ effect,
3282
+ ...processCreateParams(params)
3283
+ });
3284
+ };
3285
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3286
+ return new ZodEffects({
3287
+ schema,
3288
+ effect: {
3289
+ type: "preprocess",
3290
+ transform: preprocess
3291
+ },
3292
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3293
+ ...processCreateParams(params)
3294
+ });
3295
+ };
3296
+ var ZodOptional = class extends ZodType {
3297
+ _parse(input) {
3298
+ if (this._getType(input) === ZodParsedType.undefined) return OK(void 0);
3299
+ return this._def.innerType._parse(input);
3300
+ }
3301
+ unwrap() {
3302
+ return this._def.innerType;
3303
+ }
3304
+ };
3305
+ ZodOptional.create = (type, params) => {
3306
+ return new ZodOptional({
3307
+ innerType: type,
3308
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3309
+ ...processCreateParams(params)
3310
+ });
3311
+ };
3312
+ var ZodNullable = class extends ZodType {
3313
+ _parse(input) {
3314
+ if (this._getType(input) === ZodParsedType.null) return OK(null);
3315
+ return this._def.innerType._parse(input);
3316
+ }
3317
+ unwrap() {
3318
+ return this._def.innerType;
3319
+ }
3320
+ };
3321
+ ZodNullable.create = (type, params) => {
3322
+ return new ZodNullable({
3323
+ innerType: type,
3324
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3325
+ ...processCreateParams(params)
3326
+ });
3327
+ };
3328
+ var ZodDefault = class extends ZodType {
3329
+ _parse(input) {
3330
+ const { ctx } = this._processInputParams(input);
3331
+ let data = ctx.data;
3332
+ if (ctx.parsedType === ZodParsedType.undefined) data = this._def.defaultValue();
3333
+ return this._def.innerType._parse({
3334
+ data,
3335
+ path: ctx.path,
3336
+ parent: ctx
3337
+ });
3338
+ }
3339
+ removeDefault() {
3340
+ return this._def.innerType;
3341
+ }
3342
+ };
3343
+ ZodDefault.create = (type, params) => {
3344
+ return new ZodDefault({
3345
+ innerType: type,
3346
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3347
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3348
+ ...processCreateParams(params)
3349
+ });
3350
+ };
3351
+ var ZodCatch = class extends ZodType {
3352
+ _parse(input) {
3353
+ const { ctx } = this._processInputParams(input);
3354
+ const newCtx = {
3355
+ ...ctx,
3356
+ common: {
3357
+ ...ctx.common,
3358
+ issues: []
3359
+ }
3360
+ };
3361
+ const result = this._def.innerType._parse({
3362
+ data: newCtx.data,
3363
+ path: newCtx.path,
3364
+ parent: { ...newCtx }
3365
+ });
3366
+ if (isAsync(result)) return result.then((result) => {
3367
+ return {
3368
+ status: "valid",
3369
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3370
+ get error() {
3371
+ return new ZodError(newCtx.common.issues);
3372
+ },
3373
+ input: newCtx.data
3374
+ })
3375
+ };
3376
+ });
3377
+ else return {
3378
+ status: "valid",
3379
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3380
+ get error() {
3381
+ return new ZodError(newCtx.common.issues);
3382
+ },
3383
+ input: newCtx.data
3384
+ })
3385
+ };
3386
+ }
3387
+ removeCatch() {
3388
+ return this._def.innerType;
3389
+ }
3390
+ };
3391
+ ZodCatch.create = (type, params) => {
3392
+ return new ZodCatch({
3393
+ innerType: type,
3394
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3395
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3396
+ ...processCreateParams(params)
3397
+ });
3398
+ };
3399
+ var ZodNaN = class extends ZodType {
3400
+ _parse(input) {
3401
+ if (this._getType(input) !== ZodParsedType.nan) {
3402
+ const ctx = this._getOrReturnCtx(input);
3403
+ addIssueToContext(ctx, {
3404
+ code: ZodIssueCode.invalid_type,
3405
+ expected: ZodParsedType.nan,
3406
+ received: ctx.parsedType
3407
+ });
3408
+ return INVALID;
3409
+ }
3410
+ return {
3411
+ status: "valid",
3412
+ value: input.data
3413
+ };
3414
+ }
3415
+ };
3416
+ ZodNaN.create = (params) => {
3417
+ return new ZodNaN({
3418
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3419
+ ...processCreateParams(params)
3420
+ });
3421
+ };
3422
+ var BRAND = Symbol("zod_brand");
3423
+ var ZodBranded = class extends ZodType {
3424
+ _parse(input) {
3425
+ const { ctx } = this._processInputParams(input);
3426
+ const data = ctx.data;
3427
+ return this._def.type._parse({
3428
+ data,
3429
+ path: ctx.path,
3430
+ parent: ctx
3431
+ });
3432
+ }
3433
+ unwrap() {
3434
+ return this._def.type;
3435
+ }
3436
+ };
3437
+ var ZodPipeline = class ZodPipeline extends ZodType {
3438
+ _parse(input) {
3439
+ const { status, ctx } = this._processInputParams(input);
3440
+ if (ctx.common.async) {
3441
+ const handleAsync = async () => {
3442
+ const inResult = await this._def.in._parseAsync({
3443
+ data: ctx.data,
3444
+ path: ctx.path,
3445
+ parent: ctx
3446
+ });
3447
+ if (inResult.status === "aborted") return INVALID;
3448
+ if (inResult.status === "dirty") {
3449
+ status.dirty();
3450
+ return DIRTY(inResult.value);
3451
+ } else return this._def.out._parseAsync({
3452
+ data: inResult.value,
3453
+ path: ctx.path,
3454
+ parent: ctx
3455
+ });
3456
+ };
3457
+ return handleAsync();
3458
+ } else {
3459
+ const inResult = this._def.in._parseSync({
3460
+ data: ctx.data,
3461
+ path: ctx.path,
3462
+ parent: ctx
3463
+ });
3464
+ if (inResult.status === "aborted") return INVALID;
3465
+ if (inResult.status === "dirty") {
3466
+ status.dirty();
3467
+ return {
3468
+ status: "dirty",
3469
+ value: inResult.value
3470
+ };
3471
+ } else return this._def.out._parseSync({
3472
+ data: inResult.value,
3473
+ path: ctx.path,
3474
+ parent: ctx
3475
+ });
3476
+ }
3477
+ }
3478
+ static create(a, b) {
3479
+ return new ZodPipeline({
3480
+ in: a,
3481
+ out: b,
3482
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3483
+ });
3484
+ }
3485
+ };
3486
+ var ZodReadonly = class extends ZodType {
3487
+ _parse(input) {
3488
+ const result = this._def.innerType._parse(input);
3489
+ const freeze = (data) => {
3490
+ if (isValid(data)) data.value = Object.freeze(data.value);
3491
+ return data;
3492
+ };
3493
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3494
+ }
3495
+ unwrap() {
3496
+ return this._def.innerType;
3497
+ }
3498
+ };
3499
+ ZodReadonly.create = (type, params) => {
3500
+ return new ZodReadonly({
3501
+ innerType: type,
3502
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3503
+ ...processCreateParams(params)
3504
+ });
3505
+ };
3506
+ function cleanParams(params, data) {
3507
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3508
+ return typeof p === "string" ? { message: p } : p;
3509
+ }
3510
+ function custom(check, _params = {}, fatal) {
3511
+ if (check) return ZodAny.create().superRefine((data, ctx) => {
3512
+ var _a, _b;
3513
+ const r = check(data);
3514
+ if (r instanceof Promise) return r.then((r) => {
3515
+ var _a, _b;
3516
+ if (!r) {
3517
+ const params = cleanParams(_params, data);
3518
+ const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3519
+ ctx.addIssue({
3520
+ code: "custom",
3521
+ ...params,
3522
+ fatal: _fatal
3523
+ });
3524
+ }
3525
+ });
3526
+ if (!r) {
3527
+ const params = cleanParams(_params, data);
3528
+ const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3529
+ ctx.addIssue({
3530
+ code: "custom",
3531
+ ...params,
3532
+ fatal: _fatal
3533
+ });
3534
+ }
3535
+ });
3536
+ return ZodAny.create();
3537
+ }
3538
+ var late = { object: ZodObject.lazycreate };
3539
+ var ZodFirstPartyTypeKind;
3540
+ (function(ZodFirstPartyTypeKind) {
3541
+ ZodFirstPartyTypeKind["ZodString"] = "ZodString";
3542
+ ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
3543
+ ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
3544
+ ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
3545
+ ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
3546
+ ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3547
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
3548
+ ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
3549
+ ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
3550
+ ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
3551
+ ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
3552
+ ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
3553
+ ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
3554
+ ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
3555
+ ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
3556
+ ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
3557
+ ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3558
+ ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
3559
+ ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
3560
+ ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
3561
+ ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
3562
+ ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
3563
+ ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
3564
+ ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
3565
+ ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
3566
+ ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
3567
+ ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
3568
+ ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
3569
+ ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
3570
+ ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
3571
+ ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3572
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
3573
+ ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
3574
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3575
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
3576
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
3577
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3578
+ var instanceOfType = (cls, params = { message: `Input not instance of ${cls.name}` }) => custom((data) => data instanceof cls, params);
3579
+ var stringType = ZodString.create;
3580
+ var numberType = ZodNumber.create;
3581
+ var nanType = ZodNaN.create;
3582
+ var bigIntType = ZodBigInt.create;
3583
+ var booleanType = ZodBoolean.create;
3584
+ var dateType = ZodDate.create;
3585
+ var symbolType = ZodSymbol.create;
3586
+ var undefinedType = ZodUndefined.create;
3587
+ var nullType = ZodNull.create;
3588
+ var anyType = ZodAny.create;
3589
+ var unknownType = ZodUnknown.create;
3590
+ var neverType = ZodNever.create;
3591
+ var voidType = ZodVoid.create;
3592
+ var arrayType = ZodArray.create;
3593
+ var objectType = ZodObject.create;
3594
+ var strictObjectType = ZodObject.strictCreate;
3595
+ var unionType = ZodUnion.create;
3596
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
3597
+ var intersectionType = ZodIntersection.create;
3598
+ var tupleType = ZodTuple.create;
3599
+ var recordType = ZodRecord.create;
3600
+ var mapType = ZodMap.create;
3601
+ var setType = ZodSet.create;
3602
+ var functionType = ZodFunction.create;
3603
+ var lazyType = ZodLazy.create;
3604
+ var literalType = ZodLiteral.create;
3605
+ var enumType = ZodEnum.create;
3606
+ var nativeEnumType = ZodNativeEnum.create;
3607
+ var promiseType = ZodPromise.create;
3608
+ var effectsType = ZodEffects.create;
3609
+ var optionalType = ZodOptional.create;
3610
+ var nullableType = ZodNullable.create;
3611
+ var preprocessType = ZodEffects.createWithPreprocess;
3612
+ var pipelineType = ZodPipeline.create;
3613
+ var ostring = () => stringType().optional();
3614
+ var onumber = () => numberType().optional();
3615
+ var oboolean = () => booleanType().optional();
3616
+ var z = /* @__PURE__ */ Object.freeze({
3617
+ __proto__: null,
3618
+ defaultErrorMap: errorMap,
3619
+ setErrorMap,
3620
+ getErrorMap,
3621
+ makeIssue,
3622
+ EMPTY_PATH,
3623
+ addIssueToContext,
3624
+ ParseStatus,
3625
+ INVALID,
3626
+ DIRTY,
3627
+ OK,
3628
+ isAborted,
3629
+ isDirty,
3630
+ isValid,
3631
+ isAsync,
3632
+ get util() {
3633
+ return util;
3634
+ },
3635
+ get objectUtil() {
3636
+ return objectUtil;
3637
+ },
3638
+ ZodParsedType,
3639
+ getParsedType,
3640
+ ZodType,
3641
+ datetimeRegex,
3642
+ ZodString,
3643
+ ZodNumber,
3644
+ ZodBigInt,
3645
+ ZodBoolean,
3646
+ ZodDate,
3647
+ ZodSymbol,
3648
+ ZodUndefined,
3649
+ ZodNull,
3650
+ ZodAny,
3651
+ ZodUnknown,
3652
+ ZodNever,
3653
+ ZodVoid,
3654
+ ZodArray,
3655
+ ZodObject,
3656
+ ZodUnion,
3657
+ ZodDiscriminatedUnion,
3658
+ ZodIntersection,
3659
+ ZodTuple,
3660
+ ZodRecord,
3661
+ ZodMap,
3662
+ ZodSet,
3663
+ ZodFunction,
3664
+ ZodLazy,
3665
+ ZodLiteral,
3666
+ ZodEnum,
3667
+ ZodNativeEnum,
3668
+ ZodPromise,
3669
+ ZodEffects,
3670
+ ZodTransformer: ZodEffects,
3671
+ ZodOptional,
3672
+ ZodNullable,
3673
+ ZodDefault,
3674
+ ZodCatch,
3675
+ ZodNaN,
3676
+ BRAND,
3677
+ ZodBranded,
3678
+ ZodPipeline,
3679
+ ZodReadonly,
3680
+ custom,
3681
+ Schema: ZodType,
3682
+ ZodSchema: ZodType,
3683
+ late,
3684
+ get ZodFirstPartyTypeKind() {
3685
+ return ZodFirstPartyTypeKind;
3686
+ },
3687
+ coerce: {
3688
+ string: ((arg) => ZodString.create({
3689
+ ...arg,
3690
+ coerce: true
3691
+ })),
3692
+ number: ((arg) => ZodNumber.create({
3693
+ ...arg,
3694
+ coerce: true
3695
+ })),
3696
+ boolean: ((arg) => ZodBoolean.create({
3697
+ ...arg,
3698
+ coerce: true
3699
+ })),
3700
+ bigint: ((arg) => ZodBigInt.create({
3701
+ ...arg,
3702
+ coerce: true
3703
+ })),
3704
+ date: ((arg) => ZodDate.create({
3705
+ ...arg,
3706
+ coerce: true
3707
+ }))
3708
+ },
3709
+ any: anyType,
3710
+ array: arrayType,
3711
+ bigint: bigIntType,
3712
+ boolean: booleanType,
3713
+ date: dateType,
3714
+ discriminatedUnion: discriminatedUnionType,
3715
+ effect: effectsType,
3716
+ "enum": enumType,
3717
+ "function": functionType,
3718
+ "instanceof": instanceOfType,
3719
+ intersection: intersectionType,
3720
+ lazy: lazyType,
3721
+ literal: literalType,
3722
+ map: mapType,
3723
+ nan: nanType,
3724
+ nativeEnum: nativeEnumType,
3725
+ never: neverType,
3726
+ "null": nullType,
3727
+ nullable: nullableType,
3728
+ number: numberType,
3729
+ object: objectType,
3730
+ oboolean,
3731
+ onumber,
3732
+ optional: optionalType,
3733
+ ostring,
3734
+ pipeline: pipelineType,
3735
+ preprocess: preprocessType,
3736
+ promise: promiseType,
3737
+ record: recordType,
3738
+ set: setType,
3739
+ strictObject: strictObjectType,
3740
+ string: stringType,
3741
+ symbol: symbolType,
3742
+ transformer: effectsType,
3743
+ tuple: tupleType,
3744
+ "undefined": undefinedType,
3745
+ union: unionType,
3746
+ unknown: unknownType,
3747
+ "void": voidType,
3748
+ NEVER: INVALID,
3749
+ ZodIssueCode,
3750
+ quotelessJson,
3751
+ ZodError
3752
+ });
3753
+ //#endregion
3754
+ export { z };
3755
+
3756
+ //# sourceMappingURL=index.js.map