@design-edito/tools 0.1.65 → 0.1.68

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