@rpgjs/client 5.0.0-alpha.8 → 5.0.0-beta.1

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