tenjin-cli 0.1.0-alpha.15 → 0.1.0-alpha.16

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 (267) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +41 -310
  3. package/dist/{_esm-N4KAVXQR.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/{ccip-ZGGWQN4X.js → ccip-7RMRLAGV.js} +4 -4
  5. package/dist/{ccip-RPPPKTJR.js → ccip-NLCSCHKI.js} +5 -5
  6. package/dist/chunk-25TJPVBF.js +353 -0
  7. package/dist/chunk-25TJPVBF.js.map +1 -0
  8. package/dist/chunk-2BKS2FVE.js +93 -0
  9. package/dist/chunk-2BKS2FVE.js.map +1 -0
  10. package/dist/chunk-2QYORQBF.js +55 -0
  11. package/dist/chunk-2QYORQBF.js.map +1 -0
  12. package/dist/{chunk-NIKXHWOL.js → chunk-2U5ZVEV3.js} +16 -16
  13. package/dist/chunk-2U5ZVEV3.js.map +1 -0
  14. package/dist/{chunk-HPJGOLTN.js → chunk-3AJS6LLN.js} +13 -8
  15. package/dist/chunk-3AJS6LLN.js.map +1 -0
  16. package/dist/{chunk-KINZ23CV.js → chunk-3AUDA53C.js} +4740 -23
  17. package/dist/chunk-3AUDA53C.js.map +1 -0
  18. package/dist/{chunk-MJZZTKCC.js → chunk-56MOAIP5.js} +5 -10
  19. package/dist/chunk-56MOAIP5.js.map +1 -0
  20. package/dist/{chunk-U5S527PP.js → chunk-5IEP5EGE.js} +3 -3
  21. package/dist/chunk-5X4SZ5BF.js +227 -0
  22. package/dist/chunk-5X4SZ5BF.js.map +1 -0
  23. package/dist/chunk-7WEQQJLG.js +68 -0
  24. package/dist/chunk-7WEQQJLG.js.map +1 -0
  25. package/dist/{chunk-7FK2UN2T.js → chunk-AWQPGIR6.js} +65 -67
  26. package/dist/{chunk-7FK2UN2T.js.map → chunk-AWQPGIR6.js.map} +1 -1
  27. package/dist/{chunk-ZFJJ3EXC.js → chunk-BBVUVBUO.js} +516 -185
  28. package/dist/chunk-BBVUVBUO.js.map +1 -0
  29. package/dist/{chunk-JBIKAAT3.js → chunk-BFFM2WFK.js} +8 -8
  30. package/dist/chunk-BFFM2WFK.js.map +1 -0
  31. package/dist/{chunk-KYQVEKP5.js → chunk-BPMWXTFX.js} +8 -8
  32. package/dist/chunk-DMZZLPZN.js +205 -0
  33. package/dist/chunk-DMZZLPZN.js.map +1 -0
  34. package/dist/{chunk-47PP7TAG.js → chunk-EGELTSPU.js} +1356 -1356
  35. package/dist/chunk-EGELTSPU.js.map +1 -0
  36. package/dist/chunk-GULLJQXA.js +698 -0
  37. package/dist/chunk-GULLJQXA.js.map +1 -0
  38. package/dist/{chunk-S5RYMCV6.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-HVRC33OL.js +174 -0
  40. package/dist/chunk-HVRC33OL.js.map +1 -0
  41. package/dist/{chunk-W6R3HAAG.js → chunk-JRGFKVAZ.js} +2 -2
  42. package/dist/{chunk-XJN5WUKL.js → chunk-KG3D7FIF.js} +2 -2
  43. package/dist/chunk-L3PVMIYQ.js +10328 -0
  44. package/dist/chunk-L3PVMIYQ.js.map +1 -0
  45. package/dist/{chunk-QW2Q2KAH.js → chunk-LHHMV4GU.js} +2 -2
  46. package/dist/{chunk-ZOBNS7CX.js → chunk-MEFB5KHA.js} +4 -18
  47. package/dist/chunk-MEFB5KHA.js.map +1 -0
  48. package/dist/{chunk-M2O56UK7.js → chunk-N35E6CM2.js} +293 -163
  49. package/dist/chunk-N35E6CM2.js.map +1 -0
  50. package/dist/chunk-OCBHUHWB.js +69 -0
  51. package/dist/chunk-OCBHUHWB.js.map +1 -0
  52. package/dist/chunk-OIM4HLN6.js +1405 -0
  53. package/dist/chunk-OIM4HLN6.js.map +1 -0
  54. package/dist/{chunk-VYOJOX4Z.js → chunk-OJLYNM4Z.js} +54 -33
  55. package/dist/chunk-OJLYNM4Z.js.map +1 -0
  56. package/dist/{chunk-POJRB2AE.js → chunk-POUWHWID.js} +2 -2
  57. package/dist/chunk-PZEN5PHN.js +285 -0
  58. package/dist/chunk-PZEN5PHN.js.map +1 -0
  59. package/dist/chunk-SKAHDQH7.js +1785 -0
  60. package/dist/chunk-SKAHDQH7.js.map +1 -0
  61. package/dist/{chunk-KZAAWQNP.js → chunk-TTNESUPQ.js} +3 -3
  62. package/dist/chunk-U5DXNFJC.js +137 -0
  63. package/dist/chunk-U5DXNFJC.js.map +1 -0
  64. package/dist/chunk-USS336NF.js +165 -0
  65. package/dist/chunk-USS336NF.js.map +1 -0
  66. package/dist/{chunk-UO22YNY4.js → chunk-WH7OWT6G.js} +49 -1
  67. package/dist/chunk-WH7OWT6G.js.map +1 -0
  68. package/dist/chunk-WXC57XGG.js +29 -0
  69. package/dist/chunk-WXC57XGG.js.map +1 -0
  70. package/dist/{chunk-YLYINX2H.js → chunk-XZKD7DIF.js} +3 -3
  71. package/dist/{chunk-CPCX67TI.js → chunk-YEETV6IW.js} +1079 -1039
  72. package/dist/chunk-YEETV6IW.js.map +1 -0
  73. package/dist/{chunk-OLWTRUTS.js → chunk-YJHHCWM3.js} +35 -16
  74. package/dist/chunk-YJHHCWM3.js.map +1 -0
  75. package/dist/{cli-KKRKBU5T.js → cli-M3XCSOU6.js} +289 -374
  76. package/dist/cli-M3XCSOU6.js.map +1 -0
  77. package/dist/config-MXOX7XDR.js +41 -0
  78. package/dist/{dist-U4M6QCKE.js → dist-3LOO6M4U.js} +10 -10
  79. package/dist/doctor-LU4YIZWM.js +349 -0
  80. package/dist/doctor-LU4YIZWM.js.map +1 -0
  81. package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  82. package/dist/{chunk-KAJZHIQ4.js → fund-A54P2QFK.js} +80 -24
  83. package/dist/fund-A54P2QFK.js.map +1 -0
  84. package/dist/hook-command-U6KWPEDQ.js +377 -0
  85. package/dist/hook-command-U6KWPEDQ.js.map +1 -0
  86. package/dist/index.js +8 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/install-XUM2XSHW.js +53 -0
  89. package/dist/install-wallet-QIOFORTX.js +105 -0
  90. package/dist/install-wallet-QIOFORTX.js.map +1 -0
  91. package/dist/{run-XYTQ5TWQ.js → mcp-HJC2PLRV.js} +3727 -10670
  92. package/dist/mcp-HJC2PLRV.js.map +1 -0
  93. package/dist/paths-P2N4JTDZ.js +49 -0
  94. package/dist/pay-SBXZEPEP.js +37 -0
  95. package/dist/redact-46ZHF2NH.js +17 -0
  96. package/dist/{secp256k1-XRPVBC6V.js → secp256k1-ZZZT2CAX.js} +3 -3
  97. package/dist/{send-G746D7PQ.js → send-ASD2ZXJD.js} +28 -29
  98. package/dist/send-ASD2ZXJD.js.map +1 -0
  99. package/dist/{chunk-QZ6ROAJU.js → skill-placement-NFVHY6A3.js} +157 -11
  100. package/dist/skill-placement-NFVHY6A3.js.map +1 -0
  101. package/dist/status-T2SDB57A.js +63 -0
  102. package/dist/status-T2SDB57A.js.map +1 -0
  103. package/dist/status-line-CGPUSDMC.js +71 -0
  104. package/dist/status-line-CGPUSDMC.js.map +1 -0
  105. package/dist/status-line-wiring-BYPHTYZE.js +30 -0
  106. package/dist/tenjin-daemon.mjs +20060 -0
  107. package/dist/tenjin-shim.mjs +251 -0
  108. package/dist/tenjin-vitest-reporter.mjs +49 -0
  109. package/dist/uninstall-FKYZHAM3.js +144 -0
  110. package/dist/uninstall-FKYZHAM3.js.map +1 -0
  111. package/dist/{update-R76LHOZW.js → update-ANJ2AOTN.js} +133 -16
  112. package/dist/update-ANJ2AOTN.js.map +1 -0
  113. package/dist/{viemAdapter-By13KInL-TUQJBMHM.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  114. package/dist/wallet-PWAHVKWW.js +31 -0
  115. package/dist/wallet-kdf-worker.mjs +980 -0
  116. package/docs/agent-permissions.md +65 -354
  117. package/docs/safety-model.md +16 -6
  118. package/package.json +8 -7
  119. package/LICENSE +0 -21
  120. package/dist/buy-VIRNSYGN.js +0 -47
  121. package/dist/chunk-2MYQN7HM.js +0 -247
  122. package/dist/chunk-2MYQN7HM.js.map +0 -1
  123. package/dist/chunk-2RF2GIJQ.js +0 -1188
  124. package/dist/chunk-2RF2GIJQ.js.map +0 -1
  125. package/dist/chunk-3GL2Z5QK.js +0 -57
  126. package/dist/chunk-3GL2Z5QK.js.map +0 -1
  127. package/dist/chunk-47PP7TAG.js.map +0 -1
  128. package/dist/chunk-4CQIDQOT.js +0 -167
  129. package/dist/chunk-4CQIDQOT.js.map +0 -1
  130. package/dist/chunk-4KG27W2S.js +0 -614
  131. package/dist/chunk-4KG27W2S.js.map +0 -1
  132. package/dist/chunk-5QQTYWEU.js +0 -199
  133. package/dist/chunk-5QQTYWEU.js.map +0 -1
  134. package/dist/chunk-65DTCCJ7.js +0 -21
  135. package/dist/chunk-65DTCCJ7.js.map +0 -1
  136. package/dist/chunk-A5DKHMUN.js +0 -173
  137. package/dist/chunk-A5DKHMUN.js.map +0 -1
  138. package/dist/chunk-B63XPWQ4.js +0 -246
  139. package/dist/chunk-B63XPWQ4.js.map +0 -1
  140. package/dist/chunk-CAR6FHK6.js +0 -105
  141. package/dist/chunk-CAR6FHK6.js.map +0 -1
  142. package/dist/chunk-CPCX67TI.js.map +0 -1
  143. package/dist/chunk-CQBVCYI2.js +0 -162
  144. package/dist/chunk-CQBVCYI2.js.map +0 -1
  145. package/dist/chunk-DBU5CXBV.js +0 -4731
  146. package/dist/chunk-DBU5CXBV.js.map +0 -1
  147. package/dist/chunk-DHJD77OW.js +0 -81
  148. package/dist/chunk-DHJD77OW.js.map +0 -1
  149. package/dist/chunk-EDZSNPE5.js +0 -35
  150. package/dist/chunk-EDZSNPE5.js.map +0 -1
  151. package/dist/chunk-EFWZPUTC.js +0 -65
  152. package/dist/chunk-EFWZPUTC.js.map +0 -1
  153. package/dist/chunk-EPFL6CTE.js +0 -448
  154. package/dist/chunk-EPFL6CTE.js.map +0 -1
  155. package/dist/chunk-GHLVXVZD.js +0 -142
  156. package/dist/chunk-GHLVXVZD.js.map +0 -1
  157. package/dist/chunk-H3SOOJ2I.js +0 -580
  158. package/dist/chunk-H3SOOJ2I.js.map +0 -1
  159. package/dist/chunk-HPJGOLTN.js.map +0 -1
  160. package/dist/chunk-HRGBS2PA.js +0 -203
  161. package/dist/chunk-HRGBS2PA.js.map +0 -1
  162. package/dist/chunk-ITUXPJIS.js +0 -314
  163. package/dist/chunk-ITUXPJIS.js.map +0 -1
  164. package/dist/chunk-JBIKAAT3.js.map +0 -1
  165. package/dist/chunk-KAJZHIQ4.js.map +0 -1
  166. package/dist/chunk-KINZ23CV.js.map +0 -1
  167. package/dist/chunk-LRYV3SK7.js +0 -235
  168. package/dist/chunk-LRYV3SK7.js.map +0 -1
  169. package/dist/chunk-M2O56UK7.js.map +0 -1
  170. package/dist/chunk-MJZZTKCC.js.map +0 -1
  171. package/dist/chunk-NIKXHWOL.js.map +0 -1
  172. package/dist/chunk-OKDRDT74.js +0 -209
  173. package/dist/chunk-OKDRDT74.js.map +0 -1
  174. package/dist/chunk-OKYSNAS3.js +0 -2144
  175. package/dist/chunk-OKYSNAS3.js.map +0 -1
  176. package/dist/chunk-OLWTRUTS.js.map +0 -1
  177. package/dist/chunk-QQ6ELLSA.js +0 -143
  178. package/dist/chunk-QQ6ELLSA.js.map +0 -1
  179. package/dist/chunk-QZ6ROAJU.js.map +0 -1
  180. package/dist/chunk-R7RSCBI7.js +0 -794
  181. package/dist/chunk-R7RSCBI7.js.map +0 -1
  182. package/dist/chunk-SGK2B724.js +0 -67
  183. package/dist/chunk-SGK2B724.js.map +0 -1
  184. package/dist/chunk-U6VPKMGC.js +0 -390
  185. package/dist/chunk-U6VPKMGC.js.map +0 -1
  186. package/dist/chunk-UHTVXQ2O.js +0 -140
  187. package/dist/chunk-UHTVXQ2O.js.map +0 -1
  188. package/dist/chunk-UO22YNY4.js.map +0 -1
  189. package/dist/chunk-US456VUI.js +0 -149
  190. package/dist/chunk-US456VUI.js.map +0 -1
  191. package/dist/chunk-V44J2MXV.js +0 -400
  192. package/dist/chunk-V44J2MXV.js.map +0 -1
  193. package/dist/chunk-VJQKL3YH.js +0 -216
  194. package/dist/chunk-VJQKL3YH.js.map +0 -1
  195. package/dist/chunk-VJSQSLBM.js +0 -1442
  196. package/dist/chunk-VJSQSLBM.js.map +0 -1
  197. package/dist/chunk-VYOJOX4Z.js.map +0 -1
  198. package/dist/chunk-WY2K35OL.js +0 -269
  199. package/dist/chunk-WY2K35OL.js.map +0 -1
  200. package/dist/chunk-ZFJJ3EXC.js.map +0 -1
  201. package/dist/chunk-ZOBNS7CX.js.map +0 -1
  202. package/dist/cli-KKRKBU5T.js.map +0 -1
  203. package/dist/config-JMRUNYE6.js +0 -37
  204. package/dist/discover-B5HF6SHM.js +0 -102
  205. package/dist/discover-B5HF6SHM.js.map +0 -1
  206. package/dist/doctor-ZBG7X66D.js +0 -32
  207. package/dist/edit-PZJIILQE.js +0 -40
  208. package/dist/fund-EUDH5KPA.js +0 -40
  209. package/dist/inspect-QC6WEQPN.js +0 -37
  210. package/dist/install-GNK2W3PI.js +0 -972
  211. package/dist/install-GNK2W3PI.js.map +0 -1
  212. package/dist/outcome-KSGWZHUS.js +0 -24
  213. package/dist/pay-BC4UICPA.js +0 -361
  214. package/dist/pay-BC4UICPA.js.map +0 -1
  215. package/dist/publish-LXWFDIKF.js +0 -42
  216. package/dist/read-JMNUQ56P.js +0 -160
  217. package/dist/read-JMNUQ56P.js.map +0 -1
  218. package/dist/run-XYTQ5TWQ.js.map +0 -1
  219. package/dist/search-TSQAB45E.js +0 -25
  220. package/dist/secp256k1-XRPVBC6V.js.map +0 -1
  221. package/dist/send-G746D7PQ.js.map +0 -1
  222. package/dist/session-JBKWMJ24.js +0 -89
  223. package/dist/session-JBKWMJ24.js.map +0 -1
  224. package/dist/skill-heal-WKD67SLJ.js +0 -92
  225. package/dist/skill-heal-WKD67SLJ.js.map +0 -1
  226. package/dist/skill-placement-RIU4AMC2.js +0 -20
  227. package/dist/skill-placement-RIU4AMC2.js.map +0 -1
  228. package/dist/uninstall-5E263VTS.js +0 -73
  229. package/dist/uninstall-5E263VTS.js.map +0 -1
  230. package/dist/update-R76LHOZW.js.map +0 -1
  231. package/dist/usdc-4VCDHFWX.js +0 -38
  232. package/dist/usdc-4VCDHFWX.js.map +0 -1
  233. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +0 -1
  234. package/dist/wallet-TQ7D5EQ7.js +0 -41
  235. package/dist/wallet-TQ7D5EQ7.js.map +0 -1
  236. package/dist/wallet-ZAVXWLWP.js +0 -32
  237. package/dist/wallet-ZAVXWLWP.js.map +0 -1
  238. package/docs/command-reference.md +0 -303
  239. package/skills/tenjin/SKILL.md +0 -373
  240. package/skills/tenjin-pay/SKILL.md +0 -76
  241. package/skills/tenjin-publish/SKILL.md +0 -227
  242. package/skills/tenjin-publish/references/maintain.md +0 -39
  243. package/skills/tenjin-search/SKILL.md +0 -154
  244. package/skills/tenjin-search/references/permissions.md +0 -112
  245. /package/dist/{_esm-N4KAVXQR.js.map → _esm-CE7KNONL.js.map} +0 -0
  246. /package/dist/{buy-VIRNSYGN.js.map → ccip-7RMRLAGV.js.map} +0 -0
  247. /package/dist/{ccip-RPPPKTJR.js.map → ccip-NLCSCHKI.js.map} +0 -0
  248. /package/dist/{chunk-U5S527PP.js.map → chunk-5IEP5EGE.js.map} +0 -0
  249. /package/dist/{chunk-KYQVEKP5.js.map → chunk-BPMWXTFX.js.map} +0 -0
  250. /package/dist/{chunk-S5RYMCV6.js.map → chunk-HPWO4O6S.js.map} +0 -0
  251. /package/dist/{chunk-W6R3HAAG.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  252. /package/dist/{chunk-XJN5WUKL.js.map → chunk-KG3D7FIF.js.map} +0 -0
  253. /package/dist/{chunk-QW2Q2KAH.js.map → chunk-LHHMV4GU.js.map} +0 -0
  254. /package/dist/{chunk-POJRB2AE.js.map → chunk-POUWHWID.js.map} +0 -0
  255. /package/dist/{chunk-KZAAWQNP.js.map → chunk-TTNESUPQ.js.map} +0 -0
  256. /package/dist/{chunk-YLYINX2H.js.map → chunk-XZKD7DIF.js.map} +0 -0
  257. /package/dist/{ccip-ZGGWQN4X.js.map → config-MXOX7XDR.js.map} +0 -0
  258. /package/dist/{dist-U4M6QCKE.js.map → dist-3LOO6M4U.js.map} +0 -0
  259. /package/dist/{config-JMRUNYE6.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  260. /package/dist/{doctor-ZBG7X66D.js.map → install-XUM2XSHW.js.map} +0 -0
  261. /package/dist/{edit-PZJIILQE.js.map → paths-P2N4JTDZ.js.map} +0 -0
  262. /package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js.map → pay-SBXZEPEP.js.map} +0 -0
  263. /package/dist/{fund-EUDH5KPA.js.map → redact-46ZHF2NH.js.map} +0 -0
  264. /package/dist/{inspect-QC6WEQPN.js.map → secp256k1-ZZZT2CAX.js.map} +0 -0
  265. /package/dist/{outcome-KSGWZHUS.js.map → status-line-wiring-BYPHTYZE.js.map} +0 -0
  266. /package/dist/{publish-LXWFDIKF.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
  267. /package/dist/{search-TSQAB45E.js.map → wallet-PWAHVKWW.js.map} +0 -0
@@ -1,8 +1,4 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- external_exports,
4
- safeBase64Encode
5
- } from "./chunk-DBU5CXBV.js";
6
2
  import {
7
3
  AbiDecodingDataSizeTooSmallError,
8
4
  AbiDecodingZeroDataError,
@@ -154,7 +150,7 @@ import {
154
150
  validate,
155
151
  validate2,
156
152
  withResolvers
157
- } from "./chunk-KZAAWQNP.js";
153
+ } from "./chunk-TTNESUPQ.js";
158
154
  import {
159
155
  a,
160
156
  c,
@@ -168,16 +164,16 @@ import {
168
164
  s,
169
165
  t2 as t,
170
166
  u
171
- } from "./chunk-YLYINX2H.js";
167
+ } from "./chunk-XZKD7DIF.js";
172
168
  import {
173
169
  sha256
174
- } from "./chunk-UHTVXQ2O.js";
170
+ } from "./chunk-N35E6CM2.js";
175
171
  import {
176
172
  secp256k1
177
- } from "./chunk-W6R3HAAG.js";
173
+ } from "./chunk-JRGFKVAZ.js";
178
174
  import {
179
175
  keccak_256
180
- } from "./chunk-XJN5WUKL.js";
176
+ } from "./chunk-KG3D7FIF.js";
181
177
  import {
182
178
  __commonJS,
183
179
  __export,
@@ -2410,6 +2406,4720 @@ var require_nacl_fast = __commonJS({
2410
2406
  }
2411
2407
  });
2412
2408
 
2409
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
2410
+ var external_exports = {};
2411
+ __export(external_exports, {
2412
+ BRAND: () => BRAND,
2413
+ DIRTY: () => DIRTY,
2414
+ EMPTY_PATH: () => EMPTY_PATH,
2415
+ INVALID: () => INVALID,
2416
+ NEVER: () => NEVER,
2417
+ OK: () => OK,
2418
+ ParseStatus: () => ParseStatus,
2419
+ Schema: () => ZodType,
2420
+ ZodAny: () => ZodAny,
2421
+ ZodArray: () => ZodArray,
2422
+ ZodBigInt: () => ZodBigInt,
2423
+ ZodBoolean: () => ZodBoolean,
2424
+ ZodBranded: () => ZodBranded,
2425
+ ZodCatch: () => ZodCatch,
2426
+ ZodDate: () => ZodDate,
2427
+ ZodDefault: () => ZodDefault,
2428
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
2429
+ ZodEffects: () => ZodEffects,
2430
+ ZodEnum: () => ZodEnum,
2431
+ ZodError: () => ZodError,
2432
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
2433
+ ZodFunction: () => ZodFunction,
2434
+ ZodIntersection: () => ZodIntersection,
2435
+ ZodIssueCode: () => ZodIssueCode,
2436
+ ZodLazy: () => ZodLazy,
2437
+ ZodLiteral: () => ZodLiteral,
2438
+ ZodMap: () => ZodMap,
2439
+ ZodNaN: () => ZodNaN,
2440
+ ZodNativeEnum: () => ZodNativeEnum,
2441
+ ZodNever: () => ZodNever,
2442
+ ZodNull: () => ZodNull,
2443
+ ZodNullable: () => ZodNullable,
2444
+ ZodNumber: () => ZodNumber,
2445
+ ZodObject: () => ZodObject,
2446
+ ZodOptional: () => ZodOptional,
2447
+ ZodParsedType: () => ZodParsedType,
2448
+ ZodPipeline: () => ZodPipeline,
2449
+ ZodPromise: () => ZodPromise,
2450
+ ZodReadonly: () => ZodReadonly,
2451
+ ZodRecord: () => ZodRecord,
2452
+ ZodSchema: () => ZodType,
2453
+ ZodSet: () => ZodSet,
2454
+ ZodString: () => ZodString,
2455
+ ZodSymbol: () => ZodSymbol,
2456
+ ZodTransformer: () => ZodEffects,
2457
+ ZodTuple: () => ZodTuple,
2458
+ ZodType: () => ZodType,
2459
+ ZodUndefined: () => ZodUndefined,
2460
+ ZodUnion: () => ZodUnion,
2461
+ ZodUnknown: () => ZodUnknown,
2462
+ ZodVoid: () => ZodVoid,
2463
+ addIssueToContext: () => addIssueToContext,
2464
+ any: () => anyType,
2465
+ array: () => arrayType,
2466
+ bigint: () => bigIntType,
2467
+ boolean: () => booleanType,
2468
+ coerce: () => coerce,
2469
+ custom: () => custom,
2470
+ date: () => dateType,
2471
+ datetimeRegex: () => datetimeRegex,
2472
+ defaultErrorMap: () => en_default,
2473
+ discriminatedUnion: () => discriminatedUnionType,
2474
+ effect: () => effectsType,
2475
+ enum: () => enumType,
2476
+ function: () => functionType,
2477
+ getErrorMap: () => getErrorMap,
2478
+ getParsedType: () => getParsedType,
2479
+ instanceof: () => instanceOfType,
2480
+ intersection: () => intersectionType,
2481
+ isAborted: () => isAborted,
2482
+ isAsync: () => isAsync,
2483
+ isDirty: () => isDirty,
2484
+ isValid: () => isValid,
2485
+ late: () => late,
2486
+ lazy: () => lazyType,
2487
+ literal: () => literalType,
2488
+ makeIssue: () => makeIssue,
2489
+ map: () => mapType,
2490
+ nan: () => nanType,
2491
+ nativeEnum: () => nativeEnumType,
2492
+ never: () => neverType,
2493
+ null: () => nullType,
2494
+ nullable: () => nullableType,
2495
+ number: () => numberType,
2496
+ object: () => objectType,
2497
+ objectUtil: () => objectUtil,
2498
+ oboolean: () => oboolean,
2499
+ onumber: () => onumber,
2500
+ optional: () => optionalType,
2501
+ ostring: () => ostring,
2502
+ pipeline: () => pipelineType,
2503
+ preprocess: () => preprocessType,
2504
+ promise: () => promiseType,
2505
+ quotelessJson: () => quotelessJson,
2506
+ record: () => recordType,
2507
+ set: () => setType,
2508
+ setErrorMap: () => setErrorMap,
2509
+ strictObject: () => strictObjectType,
2510
+ string: () => stringType,
2511
+ symbol: () => symbolType,
2512
+ transformer: () => effectsType,
2513
+ tuple: () => tupleType,
2514
+ undefined: () => undefinedType,
2515
+ union: () => unionType,
2516
+ unknown: () => unknownType,
2517
+ util: () => util,
2518
+ void: () => voidType
2519
+ });
2520
+
2521
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
2522
+ var util;
2523
+ (function(util2) {
2524
+ util2.assertEqual = (_) => {
2525
+ };
2526
+ function assertIs(_arg) {
2527
+ }
2528
+ util2.assertIs = assertIs;
2529
+ function assertNever(_x) {
2530
+ throw new Error();
2531
+ }
2532
+ util2.assertNever = assertNever;
2533
+ util2.arrayToEnum = (items) => {
2534
+ const obj = {};
2535
+ for (const item of items) {
2536
+ obj[item] = item;
2537
+ }
2538
+ return obj;
2539
+ };
2540
+ util2.getValidEnumValues = (obj) => {
2541
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
2542
+ const filtered = {};
2543
+ for (const k of validKeys) {
2544
+ filtered[k] = obj[k];
2545
+ }
2546
+ return util2.objectValues(filtered);
2547
+ };
2548
+ util2.objectValues = (obj) => {
2549
+ return util2.objectKeys(obj).map(function(e) {
2550
+ return obj[e];
2551
+ });
2552
+ };
2553
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
2554
+ const keys = [];
2555
+ for (const key in object) {
2556
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
2557
+ keys.push(key);
2558
+ }
2559
+ }
2560
+ return keys;
2561
+ };
2562
+ util2.find = (arr, checker) => {
2563
+ for (const item of arr) {
2564
+ if (checker(item))
2565
+ return item;
2566
+ }
2567
+ return void 0;
2568
+ };
2569
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
2570
+ function joinValues(array, separator = " | ") {
2571
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
2572
+ }
2573
+ util2.joinValues = joinValues;
2574
+ util2.jsonStringifyReplacer = (_, value) => {
2575
+ if (typeof value === "bigint") {
2576
+ return value.toString();
2577
+ }
2578
+ return value;
2579
+ };
2580
+ })(util || (util = {}));
2581
+ var objectUtil;
2582
+ (function(objectUtil2) {
2583
+ objectUtil2.mergeShapes = (first, second) => {
2584
+ return {
2585
+ ...first,
2586
+ ...second
2587
+ // second overwrites first
2588
+ };
2589
+ };
2590
+ })(objectUtil || (objectUtil = {}));
2591
+ var ZodParsedType = util.arrayToEnum([
2592
+ "string",
2593
+ "nan",
2594
+ "number",
2595
+ "integer",
2596
+ "float",
2597
+ "boolean",
2598
+ "date",
2599
+ "bigint",
2600
+ "symbol",
2601
+ "function",
2602
+ "undefined",
2603
+ "null",
2604
+ "array",
2605
+ "object",
2606
+ "unknown",
2607
+ "promise",
2608
+ "void",
2609
+ "never",
2610
+ "map",
2611
+ "set"
2612
+ ]);
2613
+ var getParsedType = (data) => {
2614
+ const t2 = typeof data;
2615
+ switch (t2) {
2616
+ case "undefined":
2617
+ return ZodParsedType.undefined;
2618
+ case "string":
2619
+ return ZodParsedType.string;
2620
+ case "number":
2621
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
2622
+ case "boolean":
2623
+ return ZodParsedType.boolean;
2624
+ case "function":
2625
+ return ZodParsedType.function;
2626
+ case "bigint":
2627
+ return ZodParsedType.bigint;
2628
+ case "symbol":
2629
+ return ZodParsedType.symbol;
2630
+ case "object":
2631
+ if (Array.isArray(data)) {
2632
+ return ZodParsedType.array;
2633
+ }
2634
+ if (data === null) {
2635
+ return ZodParsedType.null;
2636
+ }
2637
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
2638
+ return ZodParsedType.promise;
2639
+ }
2640
+ if (typeof Map !== "undefined" && data instanceof Map) {
2641
+ return ZodParsedType.map;
2642
+ }
2643
+ if (typeof Set !== "undefined" && data instanceof Set) {
2644
+ return ZodParsedType.set;
2645
+ }
2646
+ if (typeof Date !== "undefined" && data instanceof Date) {
2647
+ return ZodParsedType.date;
2648
+ }
2649
+ return ZodParsedType.object;
2650
+ default:
2651
+ return ZodParsedType.unknown;
2652
+ }
2653
+ };
2654
+
2655
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
2656
+ var ZodIssueCode = util.arrayToEnum([
2657
+ "invalid_type",
2658
+ "invalid_literal",
2659
+ "custom",
2660
+ "invalid_union",
2661
+ "invalid_union_discriminator",
2662
+ "invalid_enum_value",
2663
+ "unrecognized_keys",
2664
+ "invalid_arguments",
2665
+ "invalid_return_type",
2666
+ "invalid_date",
2667
+ "invalid_string",
2668
+ "too_small",
2669
+ "too_big",
2670
+ "invalid_intersection_types",
2671
+ "not_multiple_of",
2672
+ "not_finite"
2673
+ ]);
2674
+ var quotelessJson = (obj) => {
2675
+ const json = JSON.stringify(obj, null, 2);
2676
+ return json.replace(/"([^"]+)":/g, "$1:");
2677
+ };
2678
+ var ZodError = class _ZodError extends Error {
2679
+ get errors() {
2680
+ return this.issues;
2681
+ }
2682
+ constructor(issues) {
2683
+ super();
2684
+ this.issues = [];
2685
+ this.addIssue = (sub) => {
2686
+ this.issues = [...this.issues, sub];
2687
+ };
2688
+ this.addIssues = (subs = []) => {
2689
+ this.issues = [...this.issues, ...subs];
2690
+ };
2691
+ const actualProto = new.target.prototype;
2692
+ if (Object.setPrototypeOf) {
2693
+ Object.setPrototypeOf(this, actualProto);
2694
+ } else {
2695
+ this.__proto__ = actualProto;
2696
+ }
2697
+ this.name = "ZodError";
2698
+ this.issues = issues;
2699
+ }
2700
+ format(_mapper) {
2701
+ const mapper = _mapper || function(issue) {
2702
+ return issue.message;
2703
+ };
2704
+ const fieldErrors = { _errors: [] };
2705
+ const processError = (error) => {
2706
+ for (const issue of error.issues) {
2707
+ if (issue.code === "invalid_union") {
2708
+ issue.unionErrors.map(processError);
2709
+ } else if (issue.code === "invalid_return_type") {
2710
+ processError(issue.returnTypeError);
2711
+ } else if (issue.code === "invalid_arguments") {
2712
+ processError(issue.argumentsError);
2713
+ } else if (issue.path.length === 0) {
2714
+ fieldErrors._errors.push(mapper(issue));
2715
+ } else {
2716
+ let curr = fieldErrors;
2717
+ let i3 = 0;
2718
+ while (i3 < issue.path.length) {
2719
+ const el = issue.path[i3];
2720
+ const terminal = i3 === issue.path.length - 1;
2721
+ if (!terminal) {
2722
+ curr[el] = curr[el] || { _errors: [] };
2723
+ } else {
2724
+ curr[el] = curr[el] || { _errors: [] };
2725
+ curr[el]._errors.push(mapper(issue));
2726
+ }
2727
+ curr = curr[el];
2728
+ i3++;
2729
+ }
2730
+ }
2731
+ }
2732
+ };
2733
+ processError(this);
2734
+ return fieldErrors;
2735
+ }
2736
+ static assert(value) {
2737
+ if (!(value instanceof _ZodError)) {
2738
+ throw new Error(`Not a ZodError: ${value}`);
2739
+ }
2740
+ }
2741
+ toString() {
2742
+ return this.message;
2743
+ }
2744
+ get message() {
2745
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
2746
+ }
2747
+ get isEmpty() {
2748
+ return this.issues.length === 0;
2749
+ }
2750
+ flatten(mapper = (issue) => issue.message) {
2751
+ const fieldErrors = {};
2752
+ const formErrors = [];
2753
+ for (const sub of this.issues) {
2754
+ if (sub.path.length > 0) {
2755
+ const firstEl = sub.path[0];
2756
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
2757
+ fieldErrors[firstEl].push(mapper(sub));
2758
+ } else {
2759
+ formErrors.push(mapper(sub));
2760
+ }
2761
+ }
2762
+ return { formErrors, fieldErrors };
2763
+ }
2764
+ get formErrors() {
2765
+ return this.flatten();
2766
+ }
2767
+ };
2768
+ ZodError.create = (issues) => {
2769
+ const error = new ZodError(issues);
2770
+ return error;
2771
+ };
2772
+
2773
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
2774
+ var errorMap = (issue, _ctx) => {
2775
+ let message;
2776
+ switch (issue.code) {
2777
+ case ZodIssueCode.invalid_type:
2778
+ if (issue.received === ZodParsedType.undefined) {
2779
+ message = "Required";
2780
+ } else {
2781
+ message = `Expected ${issue.expected}, received ${issue.received}`;
2782
+ }
2783
+ break;
2784
+ case ZodIssueCode.invalid_literal:
2785
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
2786
+ break;
2787
+ case ZodIssueCode.unrecognized_keys:
2788
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
2789
+ break;
2790
+ case ZodIssueCode.invalid_union:
2791
+ message = `Invalid input`;
2792
+ break;
2793
+ case ZodIssueCode.invalid_union_discriminator:
2794
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
2795
+ break;
2796
+ case ZodIssueCode.invalid_enum_value:
2797
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
2798
+ break;
2799
+ case ZodIssueCode.invalid_arguments:
2800
+ message = `Invalid function arguments`;
2801
+ break;
2802
+ case ZodIssueCode.invalid_return_type:
2803
+ message = `Invalid function return type`;
2804
+ break;
2805
+ case ZodIssueCode.invalid_date:
2806
+ message = `Invalid date`;
2807
+ break;
2808
+ case ZodIssueCode.invalid_string:
2809
+ if (typeof issue.validation === "object") {
2810
+ if ("includes" in issue.validation) {
2811
+ message = `Invalid input: must include "${issue.validation.includes}"`;
2812
+ if (typeof issue.validation.position === "number") {
2813
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
2814
+ }
2815
+ } else if ("startsWith" in issue.validation) {
2816
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
2817
+ } else if ("endsWith" in issue.validation) {
2818
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
2819
+ } else {
2820
+ util.assertNever(issue.validation);
2821
+ }
2822
+ } else if (issue.validation !== "regex") {
2823
+ message = `Invalid ${issue.validation}`;
2824
+ } else {
2825
+ message = "Invalid";
2826
+ }
2827
+ break;
2828
+ case ZodIssueCode.too_small:
2829
+ if (issue.type === "array")
2830
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
2831
+ else if (issue.type === "string")
2832
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
2833
+ else if (issue.type === "number")
2834
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
2835
+ else if (issue.type === "bigint")
2836
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
2837
+ else if (issue.type === "date")
2838
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
2839
+ else
2840
+ message = "Invalid input";
2841
+ break;
2842
+ case ZodIssueCode.too_big:
2843
+ if (issue.type === "array")
2844
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
2845
+ else if (issue.type === "string")
2846
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
2847
+ else if (issue.type === "number")
2848
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
2849
+ else if (issue.type === "bigint")
2850
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
2851
+ else if (issue.type === "date")
2852
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
2853
+ else
2854
+ message = "Invalid input";
2855
+ break;
2856
+ case ZodIssueCode.custom:
2857
+ message = `Invalid input`;
2858
+ break;
2859
+ case ZodIssueCode.invalid_intersection_types:
2860
+ message = `Intersection results could not be merged`;
2861
+ break;
2862
+ case ZodIssueCode.not_multiple_of:
2863
+ message = `Number must be a multiple of ${issue.multipleOf}`;
2864
+ break;
2865
+ case ZodIssueCode.not_finite:
2866
+ message = "Number must be finite";
2867
+ break;
2868
+ default:
2869
+ message = _ctx.defaultError;
2870
+ util.assertNever(issue);
2871
+ }
2872
+ return { message };
2873
+ };
2874
+ var en_default = errorMap;
2875
+
2876
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
2877
+ var overrideErrorMap = en_default;
2878
+ function setErrorMap(map) {
2879
+ overrideErrorMap = map;
2880
+ }
2881
+ function getErrorMap() {
2882
+ return overrideErrorMap;
2883
+ }
2884
+
2885
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
2886
+ var makeIssue = (params) => {
2887
+ const { data, path, errorMaps, issueData } = params;
2888
+ const fullPath = [...path, ...issueData.path || []];
2889
+ const fullIssue = {
2890
+ ...issueData,
2891
+ path: fullPath
2892
+ };
2893
+ if (issueData.message !== void 0) {
2894
+ return {
2895
+ ...issueData,
2896
+ path: fullPath,
2897
+ message: issueData.message
2898
+ };
2899
+ }
2900
+ let errorMessage = "";
2901
+ const maps = errorMaps.filter((m3) => !!m3).slice().reverse();
2902
+ for (const map of maps) {
2903
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
2904
+ }
2905
+ return {
2906
+ ...issueData,
2907
+ path: fullPath,
2908
+ message: errorMessage
2909
+ };
2910
+ };
2911
+ var EMPTY_PATH = [];
2912
+ function addIssueToContext(ctx, issueData) {
2913
+ const overrideMap = getErrorMap();
2914
+ const issue = makeIssue({
2915
+ issueData,
2916
+ data: ctx.data,
2917
+ path: ctx.path,
2918
+ errorMaps: [
2919
+ ctx.common.contextualErrorMap,
2920
+ // contextual error map is first priority
2921
+ ctx.schemaErrorMap,
2922
+ // then schema-bound map if available
2923
+ overrideMap,
2924
+ // then global override map
2925
+ overrideMap === en_default ? void 0 : en_default
2926
+ // then global default map
2927
+ ].filter((x) => !!x)
2928
+ });
2929
+ ctx.common.issues.push(issue);
2930
+ }
2931
+ var ParseStatus = class _ParseStatus {
2932
+ constructor() {
2933
+ this.value = "valid";
2934
+ }
2935
+ dirty() {
2936
+ if (this.value === "valid")
2937
+ this.value = "dirty";
2938
+ }
2939
+ abort() {
2940
+ if (this.value !== "aborted")
2941
+ this.value = "aborted";
2942
+ }
2943
+ static mergeArray(status, results) {
2944
+ const arrayValue = [];
2945
+ for (const s5 of results) {
2946
+ if (s5.status === "aborted")
2947
+ return INVALID;
2948
+ if (s5.status === "dirty")
2949
+ status.dirty();
2950
+ arrayValue.push(s5.value);
2951
+ }
2952
+ return { status: status.value, value: arrayValue };
2953
+ }
2954
+ static async mergeObjectAsync(status, pairs) {
2955
+ const syncPairs = [];
2956
+ for (const pair of pairs) {
2957
+ const key = await pair.key;
2958
+ const value = await pair.value;
2959
+ syncPairs.push({
2960
+ key,
2961
+ value
2962
+ });
2963
+ }
2964
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
2965
+ }
2966
+ static mergeObjectSync(status, pairs) {
2967
+ const finalObject = {};
2968
+ for (const pair of pairs) {
2969
+ const { key, value } = pair;
2970
+ if (key.status === "aborted")
2971
+ return INVALID;
2972
+ if (value.status === "aborted")
2973
+ return INVALID;
2974
+ if (key.status === "dirty")
2975
+ status.dirty();
2976
+ if (value.status === "dirty")
2977
+ status.dirty();
2978
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
2979
+ finalObject[key.value] = value.value;
2980
+ }
2981
+ }
2982
+ return { status: status.value, value: finalObject };
2983
+ }
2984
+ };
2985
+ var INVALID = Object.freeze({
2986
+ status: "aborted"
2987
+ });
2988
+ var DIRTY = (value) => ({ status: "dirty", value });
2989
+ var OK = (value) => ({ status: "valid", value });
2990
+ var isAborted = (x) => x.status === "aborted";
2991
+ var isDirty = (x) => x.status === "dirty";
2992
+ var isValid = (x) => x.status === "valid";
2993
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
2994
+
2995
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
2996
+ var errorUtil;
2997
+ (function(errorUtil2) {
2998
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
2999
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
3000
+ })(errorUtil || (errorUtil = {}));
3001
+
3002
+ // node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
3003
+ var ParseInputLazyPath = class {
3004
+ constructor(parent, value, path, key) {
3005
+ this._cachedPath = [];
3006
+ this.parent = parent;
3007
+ this.data = value;
3008
+ this._path = path;
3009
+ this._key = key;
3010
+ }
3011
+ get path() {
3012
+ if (!this._cachedPath.length) {
3013
+ if (Array.isArray(this._key)) {
3014
+ this._cachedPath.push(...this._path, ...this._key);
3015
+ } else {
3016
+ this._cachedPath.push(...this._path, this._key);
3017
+ }
3018
+ }
3019
+ return this._cachedPath;
3020
+ }
3021
+ };
3022
+ var handleResult = (ctx, result) => {
3023
+ if (isValid(result)) {
3024
+ return { success: true, data: result.value };
3025
+ } else {
3026
+ if (!ctx.common.issues.length) {
3027
+ throw new Error("Validation failed but no issues detected.");
3028
+ }
3029
+ return {
3030
+ success: false,
3031
+ get error() {
3032
+ if (this._error)
3033
+ return this._error;
3034
+ const error = new ZodError(ctx.common.issues);
3035
+ this._error = error;
3036
+ return this._error;
3037
+ }
3038
+ };
3039
+ }
3040
+ };
3041
+ function processCreateParams(params) {
3042
+ if (!params)
3043
+ return {};
3044
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
3045
+ if (errorMap2 && (invalid_type_error || required_error)) {
3046
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
3047
+ }
3048
+ if (errorMap2)
3049
+ return { errorMap: errorMap2, description };
3050
+ const customMap = (iss, ctx) => {
3051
+ const { message } = params;
3052
+ if (iss.code === "invalid_enum_value") {
3053
+ return { message: message ?? ctx.defaultError };
3054
+ }
3055
+ if (typeof ctx.data === "undefined") {
3056
+ return { message: message ?? required_error ?? ctx.defaultError };
3057
+ }
3058
+ if (iss.code !== "invalid_type")
3059
+ return { message: ctx.defaultError };
3060
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
3061
+ };
3062
+ return { errorMap: customMap, description };
3063
+ }
3064
+ var ZodType = class {
3065
+ get description() {
3066
+ return this._def.description;
3067
+ }
3068
+ _getType(input) {
3069
+ return getParsedType(input.data);
3070
+ }
3071
+ _getOrReturnCtx(input, ctx) {
3072
+ return ctx || {
3073
+ common: input.parent.common,
3074
+ data: input.data,
3075
+ parsedType: getParsedType(input.data),
3076
+ schemaErrorMap: this._def.errorMap,
3077
+ path: input.path,
3078
+ parent: input.parent
3079
+ };
3080
+ }
3081
+ _processInputParams(input) {
3082
+ return {
3083
+ status: new ParseStatus(),
3084
+ ctx: {
3085
+ common: input.parent.common,
3086
+ data: input.data,
3087
+ parsedType: getParsedType(input.data),
3088
+ schemaErrorMap: this._def.errorMap,
3089
+ path: input.path,
3090
+ parent: input.parent
3091
+ }
3092
+ };
3093
+ }
3094
+ _parseSync(input) {
3095
+ const result = this._parse(input);
3096
+ if (isAsync(result)) {
3097
+ throw new Error("Synchronous parse encountered promise.");
3098
+ }
3099
+ return result;
3100
+ }
3101
+ _parseAsync(input) {
3102
+ const result = this._parse(input);
3103
+ return Promise.resolve(result);
3104
+ }
3105
+ parse(data, params) {
3106
+ const result = this.safeParse(data, params);
3107
+ if (result.success)
3108
+ return result.data;
3109
+ throw result.error;
3110
+ }
3111
+ safeParse(data, params) {
3112
+ const ctx = {
3113
+ common: {
3114
+ issues: [],
3115
+ async: params?.async ?? false,
3116
+ contextualErrorMap: params?.errorMap
3117
+ },
3118
+ path: params?.path || [],
3119
+ schemaErrorMap: this._def.errorMap,
3120
+ parent: null,
3121
+ data,
3122
+ parsedType: getParsedType(data)
3123
+ };
3124
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
3125
+ return handleResult(ctx, result);
3126
+ }
3127
+ "~validate"(data) {
3128
+ const ctx = {
3129
+ common: {
3130
+ issues: [],
3131
+ async: !!this["~standard"].async
3132
+ },
3133
+ path: [],
3134
+ schemaErrorMap: this._def.errorMap,
3135
+ parent: null,
3136
+ data,
3137
+ parsedType: getParsedType(data)
3138
+ };
3139
+ if (!this["~standard"].async) {
3140
+ try {
3141
+ const result = this._parseSync({ data, path: [], parent: ctx });
3142
+ return isValid(result) ? {
3143
+ value: result.value
3144
+ } : {
3145
+ issues: ctx.common.issues
3146
+ };
3147
+ } catch (err) {
3148
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
3149
+ this["~standard"].async = true;
3150
+ }
3151
+ ctx.common = {
3152
+ issues: [],
3153
+ async: true
3154
+ };
3155
+ }
3156
+ }
3157
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
3158
+ value: result.value
3159
+ } : {
3160
+ issues: ctx.common.issues
3161
+ });
3162
+ }
3163
+ async parseAsync(data, params) {
3164
+ const result = await this.safeParseAsync(data, params);
3165
+ if (result.success)
3166
+ return result.data;
3167
+ throw result.error;
3168
+ }
3169
+ async safeParseAsync(data, params) {
3170
+ const ctx = {
3171
+ common: {
3172
+ issues: [],
3173
+ contextualErrorMap: params?.errorMap,
3174
+ async: true
3175
+ },
3176
+ path: params?.path || [],
3177
+ schemaErrorMap: this._def.errorMap,
3178
+ parent: null,
3179
+ data,
3180
+ parsedType: getParsedType(data)
3181
+ };
3182
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
3183
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
3184
+ return handleResult(ctx, result);
3185
+ }
3186
+ refine(check, message) {
3187
+ const getIssueProperties = (val) => {
3188
+ if (typeof message === "string" || typeof message === "undefined") {
3189
+ return { message };
3190
+ } else if (typeof message === "function") {
3191
+ return message(val);
3192
+ } else {
3193
+ return message;
3194
+ }
3195
+ };
3196
+ return this._refinement((val, ctx) => {
3197
+ const result = check(val);
3198
+ const setError = () => ctx.addIssue({
3199
+ code: ZodIssueCode.custom,
3200
+ ...getIssueProperties(val)
3201
+ });
3202
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
3203
+ return result.then((data) => {
3204
+ if (!data) {
3205
+ setError();
3206
+ return false;
3207
+ } else {
3208
+ return true;
3209
+ }
3210
+ });
3211
+ }
3212
+ if (!result) {
3213
+ setError();
3214
+ return false;
3215
+ } else {
3216
+ return true;
3217
+ }
3218
+ });
3219
+ }
3220
+ refinement(check, refinementData) {
3221
+ return this._refinement((val, ctx) => {
3222
+ if (!check(val)) {
3223
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
3224
+ return false;
3225
+ } else {
3226
+ return true;
3227
+ }
3228
+ });
3229
+ }
3230
+ _refinement(refinement) {
3231
+ return new ZodEffects({
3232
+ schema: this,
3233
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3234
+ effect: { type: "refinement", refinement }
3235
+ });
3236
+ }
3237
+ superRefine(refinement) {
3238
+ return this._refinement(refinement);
3239
+ }
3240
+ constructor(def) {
3241
+ this.spa = this.safeParseAsync;
3242
+ this._def = def;
3243
+ this.parse = this.parse.bind(this);
3244
+ this.safeParse = this.safeParse.bind(this);
3245
+ this.parseAsync = this.parseAsync.bind(this);
3246
+ this.safeParseAsync = this.safeParseAsync.bind(this);
3247
+ this.spa = this.spa.bind(this);
3248
+ this.refine = this.refine.bind(this);
3249
+ this.refinement = this.refinement.bind(this);
3250
+ this.superRefine = this.superRefine.bind(this);
3251
+ this.optional = this.optional.bind(this);
3252
+ this.nullable = this.nullable.bind(this);
3253
+ this.nullish = this.nullish.bind(this);
3254
+ this.array = this.array.bind(this);
3255
+ this.promise = this.promise.bind(this);
3256
+ this.or = this.or.bind(this);
3257
+ this.and = this.and.bind(this);
3258
+ this.transform = this.transform.bind(this);
3259
+ this.brand = this.brand.bind(this);
3260
+ this.default = this.default.bind(this);
3261
+ this.catch = this.catch.bind(this);
3262
+ this.describe = this.describe.bind(this);
3263
+ this.pipe = this.pipe.bind(this);
3264
+ this.readonly = this.readonly.bind(this);
3265
+ this.isNullable = this.isNullable.bind(this);
3266
+ this.isOptional = this.isOptional.bind(this);
3267
+ this["~standard"] = {
3268
+ version: 1,
3269
+ vendor: "zod",
3270
+ validate: (data) => this["~validate"](data)
3271
+ };
3272
+ }
3273
+ optional() {
3274
+ return ZodOptional.create(this, this._def);
3275
+ }
3276
+ nullable() {
3277
+ return ZodNullable.create(this, this._def);
3278
+ }
3279
+ nullish() {
3280
+ return this.nullable().optional();
3281
+ }
3282
+ array() {
3283
+ return ZodArray.create(this);
3284
+ }
3285
+ promise() {
3286
+ return ZodPromise.create(this, this._def);
3287
+ }
3288
+ or(option) {
3289
+ return ZodUnion.create([this, option], this._def);
3290
+ }
3291
+ and(incoming) {
3292
+ return ZodIntersection.create(this, incoming, this._def);
3293
+ }
3294
+ transform(transform) {
3295
+ return new ZodEffects({
3296
+ ...processCreateParams(this._def),
3297
+ schema: this,
3298
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3299
+ effect: { type: "transform", transform }
3300
+ });
3301
+ }
3302
+ default(def) {
3303
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
3304
+ return new ZodDefault({
3305
+ ...processCreateParams(this._def),
3306
+ innerType: this,
3307
+ defaultValue: defaultValueFunc,
3308
+ typeName: ZodFirstPartyTypeKind.ZodDefault
3309
+ });
3310
+ }
3311
+ brand() {
3312
+ return new ZodBranded({
3313
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
3314
+ type: this,
3315
+ ...processCreateParams(this._def)
3316
+ });
3317
+ }
3318
+ catch(def) {
3319
+ const catchValueFunc = typeof def === "function" ? def : () => def;
3320
+ return new ZodCatch({
3321
+ ...processCreateParams(this._def),
3322
+ innerType: this,
3323
+ catchValue: catchValueFunc,
3324
+ typeName: ZodFirstPartyTypeKind.ZodCatch
3325
+ });
3326
+ }
3327
+ describe(description) {
3328
+ const This = this.constructor;
3329
+ return new This({
3330
+ ...this._def,
3331
+ description
3332
+ });
3333
+ }
3334
+ pipe(target) {
3335
+ return ZodPipeline.create(this, target);
3336
+ }
3337
+ readonly() {
3338
+ return ZodReadonly.create(this);
3339
+ }
3340
+ isOptional() {
3341
+ return this.safeParse(void 0).success;
3342
+ }
3343
+ isNullable() {
3344
+ return this.safeParse(null).success;
3345
+ }
3346
+ };
3347
+ var cuidRegex = /^c[^\s-]{8,}$/i;
3348
+ var cuid2Regex = /^[0-9a-z]+$/;
3349
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
3350
+ 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;
3351
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
3352
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
3353
+ 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)?)??$/;
3354
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
3355
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
3356
+ var emojiRegex;
3357
+ 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])$/;
3358
+ 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])$/;
3359
+ 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]))$/;
3360
+ 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])$/;
3361
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
3362
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
3363
+ 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])))`;
3364
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
3365
+ function timeRegexSource(args) {
3366
+ let secondsRegexSource = `[0-5]\\d`;
3367
+ if (args.precision) {
3368
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
3369
+ } else if (args.precision == null) {
3370
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
3371
+ }
3372
+ const secondsQuantifier = args.precision ? "+" : "?";
3373
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
3374
+ }
3375
+ function timeRegex(args) {
3376
+ return new RegExp(`^${timeRegexSource(args)}$`);
3377
+ }
3378
+ function datetimeRegex(args) {
3379
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
3380
+ const opts = [];
3381
+ opts.push(args.local ? `Z?` : `Z`);
3382
+ if (args.offset)
3383
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
3384
+ regex = `${regex}(${opts.join("|")})`;
3385
+ return new RegExp(`^${regex}$`);
3386
+ }
3387
+ function isValidIP(ip, version) {
3388
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
3389
+ return true;
3390
+ }
3391
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
3392
+ return true;
3393
+ }
3394
+ return false;
3395
+ }
3396
+ function isValidJWT(jwt, alg) {
3397
+ if (!jwtRegex.test(jwt))
3398
+ return false;
3399
+ try {
3400
+ const [header] = jwt.split(".");
3401
+ if (!header)
3402
+ return false;
3403
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
3404
+ const decoded = JSON.parse(atob(base64));
3405
+ if (typeof decoded !== "object" || decoded === null)
3406
+ return false;
3407
+ if ("typ" in decoded && decoded?.typ !== "JWT")
3408
+ return false;
3409
+ if (!decoded.alg)
3410
+ return false;
3411
+ if (alg && decoded.alg !== alg)
3412
+ return false;
3413
+ return true;
3414
+ } catch {
3415
+ return false;
3416
+ }
3417
+ }
3418
+ function isValidCidr(ip, version) {
3419
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
3420
+ return true;
3421
+ }
3422
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
3423
+ return true;
3424
+ }
3425
+ return false;
3426
+ }
3427
+ var ZodString = class _ZodString extends ZodType {
3428
+ _parse(input) {
3429
+ if (this._def.coerce) {
3430
+ input.data = String(input.data);
3431
+ }
3432
+ const parsedType = this._getType(input);
3433
+ if (parsedType !== ZodParsedType.string) {
3434
+ const ctx2 = this._getOrReturnCtx(input);
3435
+ addIssueToContext(ctx2, {
3436
+ code: ZodIssueCode.invalid_type,
3437
+ expected: ZodParsedType.string,
3438
+ received: ctx2.parsedType
3439
+ });
3440
+ return INVALID;
3441
+ }
3442
+ const status = new ParseStatus();
3443
+ let ctx = void 0;
3444
+ for (const check of this._def.checks) {
3445
+ if (check.kind === "min") {
3446
+ if (input.data.length < check.value) {
3447
+ ctx = this._getOrReturnCtx(input, ctx);
3448
+ addIssueToContext(ctx, {
3449
+ code: ZodIssueCode.too_small,
3450
+ minimum: check.value,
3451
+ type: "string",
3452
+ inclusive: true,
3453
+ exact: false,
3454
+ message: check.message
3455
+ });
3456
+ status.dirty();
3457
+ }
3458
+ } else if (check.kind === "max") {
3459
+ if (input.data.length > check.value) {
3460
+ ctx = this._getOrReturnCtx(input, ctx);
3461
+ addIssueToContext(ctx, {
3462
+ code: ZodIssueCode.too_big,
3463
+ maximum: check.value,
3464
+ type: "string",
3465
+ inclusive: true,
3466
+ exact: false,
3467
+ message: check.message
3468
+ });
3469
+ status.dirty();
3470
+ }
3471
+ } else if (check.kind === "length") {
3472
+ const tooBig = input.data.length > check.value;
3473
+ const tooSmall = input.data.length < check.value;
3474
+ if (tooBig || tooSmall) {
3475
+ ctx = this._getOrReturnCtx(input, ctx);
3476
+ if (tooBig) {
3477
+ addIssueToContext(ctx, {
3478
+ code: ZodIssueCode.too_big,
3479
+ maximum: check.value,
3480
+ type: "string",
3481
+ inclusive: true,
3482
+ exact: true,
3483
+ message: check.message
3484
+ });
3485
+ } else if (tooSmall) {
3486
+ addIssueToContext(ctx, {
3487
+ code: ZodIssueCode.too_small,
3488
+ minimum: check.value,
3489
+ type: "string",
3490
+ inclusive: true,
3491
+ exact: true,
3492
+ message: check.message
3493
+ });
3494
+ }
3495
+ status.dirty();
3496
+ }
3497
+ } else if (check.kind === "email") {
3498
+ if (!emailRegex.test(input.data)) {
3499
+ ctx = this._getOrReturnCtx(input, ctx);
3500
+ addIssueToContext(ctx, {
3501
+ validation: "email",
3502
+ code: ZodIssueCode.invalid_string,
3503
+ message: check.message
3504
+ });
3505
+ status.dirty();
3506
+ }
3507
+ } else if (check.kind === "emoji") {
3508
+ if (!emojiRegex) {
3509
+ emojiRegex = new RegExp(_emojiRegex, "u");
3510
+ }
3511
+ if (!emojiRegex.test(input.data)) {
3512
+ ctx = this._getOrReturnCtx(input, ctx);
3513
+ addIssueToContext(ctx, {
3514
+ validation: "emoji",
3515
+ code: ZodIssueCode.invalid_string,
3516
+ message: check.message
3517
+ });
3518
+ status.dirty();
3519
+ }
3520
+ } else if (check.kind === "uuid") {
3521
+ if (!uuidRegex.test(input.data)) {
3522
+ ctx = this._getOrReturnCtx(input, ctx);
3523
+ addIssueToContext(ctx, {
3524
+ validation: "uuid",
3525
+ code: ZodIssueCode.invalid_string,
3526
+ message: check.message
3527
+ });
3528
+ status.dirty();
3529
+ }
3530
+ } else if (check.kind === "nanoid") {
3531
+ if (!nanoidRegex.test(input.data)) {
3532
+ ctx = this._getOrReturnCtx(input, ctx);
3533
+ addIssueToContext(ctx, {
3534
+ validation: "nanoid",
3535
+ code: ZodIssueCode.invalid_string,
3536
+ message: check.message
3537
+ });
3538
+ status.dirty();
3539
+ }
3540
+ } else if (check.kind === "cuid") {
3541
+ if (!cuidRegex.test(input.data)) {
3542
+ ctx = this._getOrReturnCtx(input, ctx);
3543
+ addIssueToContext(ctx, {
3544
+ validation: "cuid",
3545
+ code: ZodIssueCode.invalid_string,
3546
+ message: check.message
3547
+ });
3548
+ status.dirty();
3549
+ }
3550
+ } else if (check.kind === "cuid2") {
3551
+ if (!cuid2Regex.test(input.data)) {
3552
+ ctx = this._getOrReturnCtx(input, ctx);
3553
+ addIssueToContext(ctx, {
3554
+ validation: "cuid2",
3555
+ code: ZodIssueCode.invalid_string,
3556
+ message: check.message
3557
+ });
3558
+ status.dirty();
3559
+ }
3560
+ } else if (check.kind === "ulid") {
3561
+ if (!ulidRegex.test(input.data)) {
3562
+ ctx = this._getOrReturnCtx(input, ctx);
3563
+ addIssueToContext(ctx, {
3564
+ validation: "ulid",
3565
+ code: ZodIssueCode.invalid_string,
3566
+ message: check.message
3567
+ });
3568
+ status.dirty();
3569
+ }
3570
+ } else if (check.kind === "url") {
3571
+ try {
3572
+ new URL(input.data);
3573
+ } catch {
3574
+ ctx = this._getOrReturnCtx(input, ctx);
3575
+ addIssueToContext(ctx, {
3576
+ validation: "url",
3577
+ code: ZodIssueCode.invalid_string,
3578
+ message: check.message
3579
+ });
3580
+ status.dirty();
3581
+ }
3582
+ } else if (check.kind === "regex") {
3583
+ check.regex.lastIndex = 0;
3584
+ const testResult = check.regex.test(input.data);
3585
+ if (!testResult) {
3586
+ ctx = this._getOrReturnCtx(input, ctx);
3587
+ addIssueToContext(ctx, {
3588
+ validation: "regex",
3589
+ code: ZodIssueCode.invalid_string,
3590
+ message: check.message
3591
+ });
3592
+ status.dirty();
3593
+ }
3594
+ } else if (check.kind === "trim") {
3595
+ input.data = input.data.trim();
3596
+ } else if (check.kind === "includes") {
3597
+ if (!input.data.includes(check.value, check.position)) {
3598
+ ctx = this._getOrReturnCtx(input, ctx);
3599
+ addIssueToContext(ctx, {
3600
+ code: ZodIssueCode.invalid_string,
3601
+ validation: { includes: check.value, position: check.position },
3602
+ message: check.message
3603
+ });
3604
+ status.dirty();
3605
+ }
3606
+ } else if (check.kind === "toLowerCase") {
3607
+ input.data = input.data.toLowerCase();
3608
+ } else if (check.kind === "toUpperCase") {
3609
+ input.data = input.data.toUpperCase();
3610
+ } else if (check.kind === "startsWith") {
3611
+ if (!input.data.startsWith(check.value)) {
3612
+ ctx = this._getOrReturnCtx(input, ctx);
3613
+ addIssueToContext(ctx, {
3614
+ code: ZodIssueCode.invalid_string,
3615
+ validation: { startsWith: check.value },
3616
+ message: check.message
3617
+ });
3618
+ status.dirty();
3619
+ }
3620
+ } else if (check.kind === "endsWith") {
3621
+ if (!input.data.endsWith(check.value)) {
3622
+ ctx = this._getOrReturnCtx(input, ctx);
3623
+ addIssueToContext(ctx, {
3624
+ code: ZodIssueCode.invalid_string,
3625
+ validation: { endsWith: check.value },
3626
+ message: check.message
3627
+ });
3628
+ status.dirty();
3629
+ }
3630
+ } else if (check.kind === "datetime") {
3631
+ const regex = datetimeRegex(check);
3632
+ if (!regex.test(input.data)) {
3633
+ ctx = this._getOrReturnCtx(input, ctx);
3634
+ addIssueToContext(ctx, {
3635
+ code: ZodIssueCode.invalid_string,
3636
+ validation: "datetime",
3637
+ message: check.message
3638
+ });
3639
+ status.dirty();
3640
+ }
3641
+ } else if (check.kind === "date") {
3642
+ const regex = dateRegex;
3643
+ if (!regex.test(input.data)) {
3644
+ ctx = this._getOrReturnCtx(input, ctx);
3645
+ addIssueToContext(ctx, {
3646
+ code: ZodIssueCode.invalid_string,
3647
+ validation: "date",
3648
+ message: check.message
3649
+ });
3650
+ status.dirty();
3651
+ }
3652
+ } else if (check.kind === "time") {
3653
+ const regex = timeRegex(check);
3654
+ if (!regex.test(input.data)) {
3655
+ ctx = this._getOrReturnCtx(input, ctx);
3656
+ addIssueToContext(ctx, {
3657
+ code: ZodIssueCode.invalid_string,
3658
+ validation: "time",
3659
+ message: check.message
3660
+ });
3661
+ status.dirty();
3662
+ }
3663
+ } else if (check.kind === "duration") {
3664
+ if (!durationRegex.test(input.data)) {
3665
+ ctx = this._getOrReturnCtx(input, ctx);
3666
+ addIssueToContext(ctx, {
3667
+ validation: "duration",
3668
+ code: ZodIssueCode.invalid_string,
3669
+ message: check.message
3670
+ });
3671
+ status.dirty();
3672
+ }
3673
+ } else if (check.kind === "ip") {
3674
+ if (!isValidIP(input.data, check.version)) {
3675
+ ctx = this._getOrReturnCtx(input, ctx);
3676
+ addIssueToContext(ctx, {
3677
+ validation: "ip",
3678
+ code: ZodIssueCode.invalid_string,
3679
+ message: check.message
3680
+ });
3681
+ status.dirty();
3682
+ }
3683
+ } else if (check.kind === "jwt") {
3684
+ if (!isValidJWT(input.data, check.alg)) {
3685
+ ctx = this._getOrReturnCtx(input, ctx);
3686
+ addIssueToContext(ctx, {
3687
+ validation: "jwt",
3688
+ code: ZodIssueCode.invalid_string,
3689
+ message: check.message
3690
+ });
3691
+ status.dirty();
3692
+ }
3693
+ } else if (check.kind === "cidr") {
3694
+ if (!isValidCidr(input.data, check.version)) {
3695
+ ctx = this._getOrReturnCtx(input, ctx);
3696
+ addIssueToContext(ctx, {
3697
+ validation: "cidr",
3698
+ code: ZodIssueCode.invalid_string,
3699
+ message: check.message
3700
+ });
3701
+ status.dirty();
3702
+ }
3703
+ } else if (check.kind === "base64") {
3704
+ if (!base64Regex.test(input.data)) {
3705
+ ctx = this._getOrReturnCtx(input, ctx);
3706
+ addIssueToContext(ctx, {
3707
+ validation: "base64",
3708
+ code: ZodIssueCode.invalid_string,
3709
+ message: check.message
3710
+ });
3711
+ status.dirty();
3712
+ }
3713
+ } else if (check.kind === "base64url") {
3714
+ if (!base64urlRegex.test(input.data)) {
3715
+ ctx = this._getOrReturnCtx(input, ctx);
3716
+ addIssueToContext(ctx, {
3717
+ validation: "base64url",
3718
+ code: ZodIssueCode.invalid_string,
3719
+ message: check.message
3720
+ });
3721
+ status.dirty();
3722
+ }
3723
+ } else {
3724
+ util.assertNever(check);
3725
+ }
3726
+ }
3727
+ return { status: status.value, value: input.data };
3728
+ }
3729
+ _regex(regex, validation, message) {
3730
+ return this.refinement((data) => regex.test(data), {
3731
+ validation,
3732
+ code: ZodIssueCode.invalid_string,
3733
+ ...errorUtil.errToObj(message)
3734
+ });
3735
+ }
3736
+ _addCheck(check) {
3737
+ return new _ZodString({
3738
+ ...this._def,
3739
+ checks: [...this._def.checks, check]
3740
+ });
3741
+ }
3742
+ email(message) {
3743
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
3744
+ }
3745
+ url(message) {
3746
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
3747
+ }
3748
+ emoji(message) {
3749
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
3750
+ }
3751
+ uuid(message) {
3752
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
3753
+ }
3754
+ nanoid(message) {
3755
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
3756
+ }
3757
+ cuid(message) {
3758
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
3759
+ }
3760
+ cuid2(message) {
3761
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
3762
+ }
3763
+ ulid(message) {
3764
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
3765
+ }
3766
+ base64(message) {
3767
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
3768
+ }
3769
+ base64url(message) {
3770
+ return this._addCheck({
3771
+ kind: "base64url",
3772
+ ...errorUtil.errToObj(message)
3773
+ });
3774
+ }
3775
+ jwt(options) {
3776
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
3777
+ }
3778
+ ip(options) {
3779
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
3780
+ }
3781
+ cidr(options) {
3782
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
3783
+ }
3784
+ datetime(options) {
3785
+ if (typeof options === "string") {
3786
+ return this._addCheck({
3787
+ kind: "datetime",
3788
+ precision: null,
3789
+ offset: false,
3790
+ local: false,
3791
+ message: options
3792
+ });
3793
+ }
3794
+ return this._addCheck({
3795
+ kind: "datetime",
3796
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
3797
+ offset: options?.offset ?? false,
3798
+ local: options?.local ?? false,
3799
+ ...errorUtil.errToObj(options?.message)
3800
+ });
3801
+ }
3802
+ date(message) {
3803
+ return this._addCheck({ kind: "date", message });
3804
+ }
3805
+ time(options) {
3806
+ if (typeof options === "string") {
3807
+ return this._addCheck({
3808
+ kind: "time",
3809
+ precision: null,
3810
+ message: options
3811
+ });
3812
+ }
3813
+ return this._addCheck({
3814
+ kind: "time",
3815
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
3816
+ ...errorUtil.errToObj(options?.message)
3817
+ });
3818
+ }
3819
+ duration(message) {
3820
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
3821
+ }
3822
+ regex(regex, message) {
3823
+ return this._addCheck({
3824
+ kind: "regex",
3825
+ regex,
3826
+ ...errorUtil.errToObj(message)
3827
+ });
3828
+ }
3829
+ includes(value, options) {
3830
+ return this._addCheck({
3831
+ kind: "includes",
3832
+ value,
3833
+ position: options?.position,
3834
+ ...errorUtil.errToObj(options?.message)
3835
+ });
3836
+ }
3837
+ startsWith(value, message) {
3838
+ return this._addCheck({
3839
+ kind: "startsWith",
3840
+ value,
3841
+ ...errorUtil.errToObj(message)
3842
+ });
3843
+ }
3844
+ endsWith(value, message) {
3845
+ return this._addCheck({
3846
+ kind: "endsWith",
3847
+ value,
3848
+ ...errorUtil.errToObj(message)
3849
+ });
3850
+ }
3851
+ min(minLength, message) {
3852
+ return this._addCheck({
3853
+ kind: "min",
3854
+ value: minLength,
3855
+ ...errorUtil.errToObj(message)
3856
+ });
3857
+ }
3858
+ max(maxLength, message) {
3859
+ return this._addCheck({
3860
+ kind: "max",
3861
+ value: maxLength,
3862
+ ...errorUtil.errToObj(message)
3863
+ });
3864
+ }
3865
+ length(len, message) {
3866
+ return this._addCheck({
3867
+ kind: "length",
3868
+ value: len,
3869
+ ...errorUtil.errToObj(message)
3870
+ });
3871
+ }
3872
+ /**
3873
+ * Equivalent to `.min(1)`
3874
+ */
3875
+ nonempty(message) {
3876
+ return this.min(1, errorUtil.errToObj(message));
3877
+ }
3878
+ trim() {
3879
+ return new _ZodString({
3880
+ ...this._def,
3881
+ checks: [...this._def.checks, { kind: "trim" }]
3882
+ });
3883
+ }
3884
+ toLowerCase() {
3885
+ return new _ZodString({
3886
+ ...this._def,
3887
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
3888
+ });
3889
+ }
3890
+ toUpperCase() {
3891
+ return new _ZodString({
3892
+ ...this._def,
3893
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
3894
+ });
3895
+ }
3896
+ get isDatetime() {
3897
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
3898
+ }
3899
+ get isDate() {
3900
+ return !!this._def.checks.find((ch) => ch.kind === "date");
3901
+ }
3902
+ get isTime() {
3903
+ return !!this._def.checks.find((ch) => ch.kind === "time");
3904
+ }
3905
+ get isDuration() {
3906
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
3907
+ }
3908
+ get isEmail() {
3909
+ return !!this._def.checks.find((ch) => ch.kind === "email");
3910
+ }
3911
+ get isURL() {
3912
+ return !!this._def.checks.find((ch) => ch.kind === "url");
3913
+ }
3914
+ get isEmoji() {
3915
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
3916
+ }
3917
+ get isUUID() {
3918
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
3919
+ }
3920
+ get isNANOID() {
3921
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
3922
+ }
3923
+ get isCUID() {
3924
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
3925
+ }
3926
+ get isCUID2() {
3927
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
3928
+ }
3929
+ get isULID() {
3930
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
3931
+ }
3932
+ get isIP() {
3933
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
3934
+ }
3935
+ get isCIDR() {
3936
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
3937
+ }
3938
+ get isBase64() {
3939
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
3940
+ }
3941
+ get isBase64url() {
3942
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
3943
+ }
3944
+ get minLength() {
3945
+ let min = null;
3946
+ for (const ch of this._def.checks) {
3947
+ if (ch.kind === "min") {
3948
+ if (min === null || ch.value > min)
3949
+ min = ch.value;
3950
+ }
3951
+ }
3952
+ return min;
3953
+ }
3954
+ get maxLength() {
3955
+ let max = null;
3956
+ for (const ch of this._def.checks) {
3957
+ if (ch.kind === "max") {
3958
+ if (max === null || ch.value < max)
3959
+ max = ch.value;
3960
+ }
3961
+ }
3962
+ return max;
3963
+ }
3964
+ };
3965
+ ZodString.create = (params) => {
3966
+ return new ZodString({
3967
+ checks: [],
3968
+ typeName: ZodFirstPartyTypeKind.ZodString,
3969
+ coerce: params?.coerce ?? false,
3970
+ ...processCreateParams(params)
3971
+ });
3972
+ };
3973
+ function floatSafeRemainder(val, step) {
3974
+ const valDecCount = (val.toString().split(".")[1] || "").length;
3975
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
3976
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
3977
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
3978
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
3979
+ return valInt % stepInt / 10 ** decCount;
3980
+ }
3981
+ var ZodNumber = class _ZodNumber extends ZodType {
3982
+ constructor() {
3983
+ super(...arguments);
3984
+ this.min = this.gte;
3985
+ this.max = this.lte;
3986
+ this.step = this.multipleOf;
3987
+ }
3988
+ _parse(input) {
3989
+ if (this._def.coerce) {
3990
+ input.data = Number(input.data);
3991
+ }
3992
+ const parsedType = this._getType(input);
3993
+ if (parsedType !== ZodParsedType.number) {
3994
+ const ctx2 = this._getOrReturnCtx(input);
3995
+ addIssueToContext(ctx2, {
3996
+ code: ZodIssueCode.invalid_type,
3997
+ expected: ZodParsedType.number,
3998
+ received: ctx2.parsedType
3999
+ });
4000
+ return INVALID;
4001
+ }
4002
+ let ctx = void 0;
4003
+ const status = new ParseStatus();
4004
+ for (const check of this._def.checks) {
4005
+ if (check.kind === "int") {
4006
+ if (!util.isInteger(input.data)) {
4007
+ ctx = this._getOrReturnCtx(input, ctx);
4008
+ addIssueToContext(ctx, {
4009
+ code: ZodIssueCode.invalid_type,
4010
+ expected: "integer",
4011
+ received: "float",
4012
+ message: check.message
4013
+ });
4014
+ status.dirty();
4015
+ }
4016
+ } else if (check.kind === "min") {
4017
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
4018
+ if (tooSmall) {
4019
+ ctx = this._getOrReturnCtx(input, ctx);
4020
+ addIssueToContext(ctx, {
4021
+ code: ZodIssueCode.too_small,
4022
+ minimum: check.value,
4023
+ type: "number",
4024
+ inclusive: check.inclusive,
4025
+ exact: false,
4026
+ message: check.message
4027
+ });
4028
+ status.dirty();
4029
+ }
4030
+ } else if (check.kind === "max") {
4031
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
4032
+ if (tooBig) {
4033
+ ctx = this._getOrReturnCtx(input, ctx);
4034
+ addIssueToContext(ctx, {
4035
+ code: ZodIssueCode.too_big,
4036
+ maximum: check.value,
4037
+ type: "number",
4038
+ inclusive: check.inclusive,
4039
+ exact: false,
4040
+ message: check.message
4041
+ });
4042
+ status.dirty();
4043
+ }
4044
+ } else if (check.kind === "multipleOf") {
4045
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
4046
+ ctx = this._getOrReturnCtx(input, ctx);
4047
+ addIssueToContext(ctx, {
4048
+ code: ZodIssueCode.not_multiple_of,
4049
+ multipleOf: check.value,
4050
+ message: check.message
4051
+ });
4052
+ status.dirty();
4053
+ }
4054
+ } else if (check.kind === "finite") {
4055
+ if (!Number.isFinite(input.data)) {
4056
+ ctx = this._getOrReturnCtx(input, ctx);
4057
+ addIssueToContext(ctx, {
4058
+ code: ZodIssueCode.not_finite,
4059
+ message: check.message
4060
+ });
4061
+ status.dirty();
4062
+ }
4063
+ } else {
4064
+ util.assertNever(check);
4065
+ }
4066
+ }
4067
+ return { status: status.value, value: input.data };
4068
+ }
4069
+ gte(value, message) {
4070
+ return this.setLimit("min", value, true, errorUtil.toString(message));
4071
+ }
4072
+ gt(value, message) {
4073
+ return this.setLimit("min", value, false, errorUtil.toString(message));
4074
+ }
4075
+ lte(value, message) {
4076
+ return this.setLimit("max", value, true, errorUtil.toString(message));
4077
+ }
4078
+ lt(value, message) {
4079
+ return this.setLimit("max", value, false, errorUtil.toString(message));
4080
+ }
4081
+ setLimit(kind, value, inclusive, message) {
4082
+ return new _ZodNumber({
4083
+ ...this._def,
4084
+ checks: [
4085
+ ...this._def.checks,
4086
+ {
4087
+ kind,
4088
+ value,
4089
+ inclusive,
4090
+ message: errorUtil.toString(message)
4091
+ }
4092
+ ]
4093
+ });
4094
+ }
4095
+ _addCheck(check) {
4096
+ return new _ZodNumber({
4097
+ ...this._def,
4098
+ checks: [...this._def.checks, check]
4099
+ });
4100
+ }
4101
+ int(message) {
4102
+ return this._addCheck({
4103
+ kind: "int",
4104
+ message: errorUtil.toString(message)
4105
+ });
4106
+ }
4107
+ positive(message) {
4108
+ return this._addCheck({
4109
+ kind: "min",
4110
+ value: 0,
4111
+ inclusive: false,
4112
+ message: errorUtil.toString(message)
4113
+ });
4114
+ }
4115
+ negative(message) {
4116
+ return this._addCheck({
4117
+ kind: "max",
4118
+ value: 0,
4119
+ inclusive: false,
4120
+ message: errorUtil.toString(message)
4121
+ });
4122
+ }
4123
+ nonpositive(message) {
4124
+ return this._addCheck({
4125
+ kind: "max",
4126
+ value: 0,
4127
+ inclusive: true,
4128
+ message: errorUtil.toString(message)
4129
+ });
4130
+ }
4131
+ nonnegative(message) {
4132
+ return this._addCheck({
4133
+ kind: "min",
4134
+ value: 0,
4135
+ inclusive: true,
4136
+ message: errorUtil.toString(message)
4137
+ });
4138
+ }
4139
+ multipleOf(value, message) {
4140
+ return this._addCheck({
4141
+ kind: "multipleOf",
4142
+ value,
4143
+ message: errorUtil.toString(message)
4144
+ });
4145
+ }
4146
+ finite(message) {
4147
+ return this._addCheck({
4148
+ kind: "finite",
4149
+ message: errorUtil.toString(message)
4150
+ });
4151
+ }
4152
+ safe(message) {
4153
+ return this._addCheck({
4154
+ kind: "min",
4155
+ inclusive: true,
4156
+ value: Number.MIN_SAFE_INTEGER,
4157
+ message: errorUtil.toString(message)
4158
+ })._addCheck({
4159
+ kind: "max",
4160
+ inclusive: true,
4161
+ value: Number.MAX_SAFE_INTEGER,
4162
+ message: errorUtil.toString(message)
4163
+ });
4164
+ }
4165
+ get minValue() {
4166
+ let min = null;
4167
+ for (const ch of this._def.checks) {
4168
+ if (ch.kind === "min") {
4169
+ if (min === null || ch.value > min)
4170
+ min = ch.value;
4171
+ }
4172
+ }
4173
+ return min;
4174
+ }
4175
+ get maxValue() {
4176
+ let max = null;
4177
+ for (const ch of this._def.checks) {
4178
+ if (ch.kind === "max") {
4179
+ if (max === null || ch.value < max)
4180
+ max = ch.value;
4181
+ }
4182
+ }
4183
+ return max;
4184
+ }
4185
+ get isInt() {
4186
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
4187
+ }
4188
+ get isFinite() {
4189
+ let max = null;
4190
+ let min = null;
4191
+ for (const ch of this._def.checks) {
4192
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
4193
+ return true;
4194
+ } else if (ch.kind === "min") {
4195
+ if (min === null || ch.value > min)
4196
+ min = ch.value;
4197
+ } else if (ch.kind === "max") {
4198
+ if (max === null || ch.value < max)
4199
+ max = ch.value;
4200
+ }
4201
+ }
4202
+ return Number.isFinite(min) && Number.isFinite(max);
4203
+ }
4204
+ };
4205
+ ZodNumber.create = (params) => {
4206
+ return new ZodNumber({
4207
+ checks: [],
4208
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
4209
+ coerce: params?.coerce || false,
4210
+ ...processCreateParams(params)
4211
+ });
4212
+ };
4213
+ var ZodBigInt = class _ZodBigInt extends ZodType {
4214
+ constructor() {
4215
+ super(...arguments);
4216
+ this.min = this.gte;
4217
+ this.max = this.lte;
4218
+ }
4219
+ _parse(input) {
4220
+ if (this._def.coerce) {
4221
+ try {
4222
+ input.data = BigInt(input.data);
4223
+ } catch {
4224
+ return this._getInvalidInput(input);
4225
+ }
4226
+ }
4227
+ const parsedType = this._getType(input);
4228
+ if (parsedType !== ZodParsedType.bigint) {
4229
+ return this._getInvalidInput(input);
4230
+ }
4231
+ let ctx = void 0;
4232
+ const status = new ParseStatus();
4233
+ for (const check of this._def.checks) {
4234
+ if (check.kind === "min") {
4235
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
4236
+ if (tooSmall) {
4237
+ ctx = this._getOrReturnCtx(input, ctx);
4238
+ addIssueToContext(ctx, {
4239
+ code: ZodIssueCode.too_small,
4240
+ type: "bigint",
4241
+ minimum: check.value,
4242
+ inclusive: check.inclusive,
4243
+ message: check.message
4244
+ });
4245
+ status.dirty();
4246
+ }
4247
+ } else if (check.kind === "max") {
4248
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
4249
+ if (tooBig) {
4250
+ ctx = this._getOrReturnCtx(input, ctx);
4251
+ addIssueToContext(ctx, {
4252
+ code: ZodIssueCode.too_big,
4253
+ type: "bigint",
4254
+ maximum: check.value,
4255
+ inclusive: check.inclusive,
4256
+ message: check.message
4257
+ });
4258
+ status.dirty();
4259
+ }
4260
+ } else if (check.kind === "multipleOf") {
4261
+ if (input.data % check.value !== BigInt(0)) {
4262
+ ctx = this._getOrReturnCtx(input, ctx);
4263
+ addIssueToContext(ctx, {
4264
+ code: ZodIssueCode.not_multiple_of,
4265
+ multipleOf: check.value,
4266
+ message: check.message
4267
+ });
4268
+ status.dirty();
4269
+ }
4270
+ } else {
4271
+ util.assertNever(check);
4272
+ }
4273
+ }
4274
+ return { status: status.value, value: input.data };
4275
+ }
4276
+ _getInvalidInput(input) {
4277
+ const ctx = this._getOrReturnCtx(input);
4278
+ addIssueToContext(ctx, {
4279
+ code: ZodIssueCode.invalid_type,
4280
+ expected: ZodParsedType.bigint,
4281
+ received: ctx.parsedType
4282
+ });
4283
+ return INVALID;
4284
+ }
4285
+ gte(value, message) {
4286
+ return this.setLimit("min", value, true, errorUtil.toString(message));
4287
+ }
4288
+ gt(value, message) {
4289
+ return this.setLimit("min", value, false, errorUtil.toString(message));
4290
+ }
4291
+ lte(value, message) {
4292
+ return this.setLimit("max", value, true, errorUtil.toString(message));
4293
+ }
4294
+ lt(value, message) {
4295
+ return this.setLimit("max", value, false, errorUtil.toString(message));
4296
+ }
4297
+ setLimit(kind, value, inclusive, message) {
4298
+ return new _ZodBigInt({
4299
+ ...this._def,
4300
+ checks: [
4301
+ ...this._def.checks,
4302
+ {
4303
+ kind,
4304
+ value,
4305
+ inclusive,
4306
+ message: errorUtil.toString(message)
4307
+ }
4308
+ ]
4309
+ });
4310
+ }
4311
+ _addCheck(check) {
4312
+ return new _ZodBigInt({
4313
+ ...this._def,
4314
+ checks: [...this._def.checks, check]
4315
+ });
4316
+ }
4317
+ positive(message) {
4318
+ return this._addCheck({
4319
+ kind: "min",
4320
+ value: BigInt(0),
4321
+ inclusive: false,
4322
+ message: errorUtil.toString(message)
4323
+ });
4324
+ }
4325
+ negative(message) {
4326
+ return this._addCheck({
4327
+ kind: "max",
4328
+ value: BigInt(0),
4329
+ inclusive: false,
4330
+ message: errorUtil.toString(message)
4331
+ });
4332
+ }
4333
+ nonpositive(message) {
4334
+ return this._addCheck({
4335
+ kind: "max",
4336
+ value: BigInt(0),
4337
+ inclusive: true,
4338
+ message: errorUtil.toString(message)
4339
+ });
4340
+ }
4341
+ nonnegative(message) {
4342
+ return this._addCheck({
4343
+ kind: "min",
4344
+ value: BigInt(0),
4345
+ inclusive: true,
4346
+ message: errorUtil.toString(message)
4347
+ });
4348
+ }
4349
+ multipleOf(value, message) {
4350
+ return this._addCheck({
4351
+ kind: "multipleOf",
4352
+ value,
4353
+ message: errorUtil.toString(message)
4354
+ });
4355
+ }
4356
+ get minValue() {
4357
+ let min = null;
4358
+ for (const ch of this._def.checks) {
4359
+ if (ch.kind === "min") {
4360
+ if (min === null || ch.value > min)
4361
+ min = ch.value;
4362
+ }
4363
+ }
4364
+ return min;
4365
+ }
4366
+ get maxValue() {
4367
+ let max = null;
4368
+ for (const ch of this._def.checks) {
4369
+ if (ch.kind === "max") {
4370
+ if (max === null || ch.value < max)
4371
+ max = ch.value;
4372
+ }
4373
+ }
4374
+ return max;
4375
+ }
4376
+ };
4377
+ ZodBigInt.create = (params) => {
4378
+ return new ZodBigInt({
4379
+ checks: [],
4380
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
4381
+ coerce: params?.coerce ?? false,
4382
+ ...processCreateParams(params)
4383
+ });
4384
+ };
4385
+ var ZodBoolean = class extends ZodType {
4386
+ _parse(input) {
4387
+ if (this._def.coerce) {
4388
+ input.data = Boolean(input.data);
4389
+ }
4390
+ const parsedType = this._getType(input);
4391
+ if (parsedType !== ZodParsedType.boolean) {
4392
+ const ctx = this._getOrReturnCtx(input);
4393
+ addIssueToContext(ctx, {
4394
+ code: ZodIssueCode.invalid_type,
4395
+ expected: ZodParsedType.boolean,
4396
+ received: ctx.parsedType
4397
+ });
4398
+ return INVALID;
4399
+ }
4400
+ return OK(input.data);
4401
+ }
4402
+ };
4403
+ ZodBoolean.create = (params) => {
4404
+ return new ZodBoolean({
4405
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
4406
+ coerce: params?.coerce || false,
4407
+ ...processCreateParams(params)
4408
+ });
4409
+ };
4410
+ var ZodDate = class _ZodDate extends ZodType {
4411
+ _parse(input) {
4412
+ if (this._def.coerce) {
4413
+ input.data = new Date(input.data);
4414
+ }
4415
+ const parsedType = this._getType(input);
4416
+ if (parsedType !== ZodParsedType.date) {
4417
+ const ctx2 = this._getOrReturnCtx(input);
4418
+ addIssueToContext(ctx2, {
4419
+ code: ZodIssueCode.invalid_type,
4420
+ expected: ZodParsedType.date,
4421
+ received: ctx2.parsedType
4422
+ });
4423
+ return INVALID;
4424
+ }
4425
+ if (Number.isNaN(input.data.getTime())) {
4426
+ const ctx2 = this._getOrReturnCtx(input);
4427
+ addIssueToContext(ctx2, {
4428
+ code: ZodIssueCode.invalid_date
4429
+ });
4430
+ return INVALID;
4431
+ }
4432
+ const status = new ParseStatus();
4433
+ let ctx = void 0;
4434
+ for (const check of this._def.checks) {
4435
+ if (check.kind === "min") {
4436
+ if (input.data.getTime() < check.value) {
4437
+ ctx = this._getOrReturnCtx(input, ctx);
4438
+ addIssueToContext(ctx, {
4439
+ code: ZodIssueCode.too_small,
4440
+ message: check.message,
4441
+ inclusive: true,
4442
+ exact: false,
4443
+ minimum: check.value,
4444
+ type: "date"
4445
+ });
4446
+ status.dirty();
4447
+ }
4448
+ } else if (check.kind === "max") {
4449
+ if (input.data.getTime() > check.value) {
4450
+ ctx = this._getOrReturnCtx(input, ctx);
4451
+ addIssueToContext(ctx, {
4452
+ code: ZodIssueCode.too_big,
4453
+ message: check.message,
4454
+ inclusive: true,
4455
+ exact: false,
4456
+ maximum: check.value,
4457
+ type: "date"
4458
+ });
4459
+ status.dirty();
4460
+ }
4461
+ } else {
4462
+ util.assertNever(check);
4463
+ }
4464
+ }
4465
+ return {
4466
+ status: status.value,
4467
+ value: new Date(input.data.getTime())
4468
+ };
4469
+ }
4470
+ _addCheck(check) {
4471
+ return new _ZodDate({
4472
+ ...this._def,
4473
+ checks: [...this._def.checks, check]
4474
+ });
4475
+ }
4476
+ min(minDate, message) {
4477
+ return this._addCheck({
4478
+ kind: "min",
4479
+ value: minDate.getTime(),
4480
+ message: errorUtil.toString(message)
4481
+ });
4482
+ }
4483
+ max(maxDate, message) {
4484
+ return this._addCheck({
4485
+ kind: "max",
4486
+ value: maxDate.getTime(),
4487
+ message: errorUtil.toString(message)
4488
+ });
4489
+ }
4490
+ get minDate() {
4491
+ let min = null;
4492
+ for (const ch of this._def.checks) {
4493
+ if (ch.kind === "min") {
4494
+ if (min === null || ch.value > min)
4495
+ min = ch.value;
4496
+ }
4497
+ }
4498
+ return min != null ? new Date(min) : null;
4499
+ }
4500
+ get maxDate() {
4501
+ let max = null;
4502
+ for (const ch of this._def.checks) {
4503
+ if (ch.kind === "max") {
4504
+ if (max === null || ch.value < max)
4505
+ max = ch.value;
4506
+ }
4507
+ }
4508
+ return max != null ? new Date(max) : null;
4509
+ }
4510
+ };
4511
+ ZodDate.create = (params) => {
4512
+ return new ZodDate({
4513
+ checks: [],
4514
+ coerce: params?.coerce || false,
4515
+ typeName: ZodFirstPartyTypeKind.ZodDate,
4516
+ ...processCreateParams(params)
4517
+ });
4518
+ };
4519
+ var ZodSymbol = class extends ZodType {
4520
+ _parse(input) {
4521
+ const parsedType = this._getType(input);
4522
+ if (parsedType !== ZodParsedType.symbol) {
4523
+ const ctx = this._getOrReturnCtx(input);
4524
+ addIssueToContext(ctx, {
4525
+ code: ZodIssueCode.invalid_type,
4526
+ expected: ZodParsedType.symbol,
4527
+ received: ctx.parsedType
4528
+ });
4529
+ return INVALID;
4530
+ }
4531
+ return OK(input.data);
4532
+ }
4533
+ };
4534
+ ZodSymbol.create = (params) => {
4535
+ return new ZodSymbol({
4536
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
4537
+ ...processCreateParams(params)
4538
+ });
4539
+ };
4540
+ var ZodUndefined = class extends ZodType {
4541
+ _parse(input) {
4542
+ const parsedType = this._getType(input);
4543
+ if (parsedType !== ZodParsedType.undefined) {
4544
+ const ctx = this._getOrReturnCtx(input);
4545
+ addIssueToContext(ctx, {
4546
+ code: ZodIssueCode.invalid_type,
4547
+ expected: ZodParsedType.undefined,
4548
+ received: ctx.parsedType
4549
+ });
4550
+ return INVALID;
4551
+ }
4552
+ return OK(input.data);
4553
+ }
4554
+ };
4555
+ ZodUndefined.create = (params) => {
4556
+ return new ZodUndefined({
4557
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
4558
+ ...processCreateParams(params)
4559
+ });
4560
+ };
4561
+ var ZodNull = class extends ZodType {
4562
+ _parse(input) {
4563
+ const parsedType = this._getType(input);
4564
+ if (parsedType !== ZodParsedType.null) {
4565
+ const ctx = this._getOrReturnCtx(input);
4566
+ addIssueToContext(ctx, {
4567
+ code: ZodIssueCode.invalid_type,
4568
+ expected: ZodParsedType.null,
4569
+ received: ctx.parsedType
4570
+ });
4571
+ return INVALID;
4572
+ }
4573
+ return OK(input.data);
4574
+ }
4575
+ };
4576
+ ZodNull.create = (params) => {
4577
+ return new ZodNull({
4578
+ typeName: ZodFirstPartyTypeKind.ZodNull,
4579
+ ...processCreateParams(params)
4580
+ });
4581
+ };
4582
+ var ZodAny = class extends ZodType {
4583
+ constructor() {
4584
+ super(...arguments);
4585
+ this._any = true;
4586
+ }
4587
+ _parse(input) {
4588
+ return OK(input.data);
4589
+ }
4590
+ };
4591
+ ZodAny.create = (params) => {
4592
+ return new ZodAny({
4593
+ typeName: ZodFirstPartyTypeKind.ZodAny,
4594
+ ...processCreateParams(params)
4595
+ });
4596
+ };
4597
+ var ZodUnknown = class extends ZodType {
4598
+ constructor() {
4599
+ super(...arguments);
4600
+ this._unknown = true;
4601
+ }
4602
+ _parse(input) {
4603
+ return OK(input.data);
4604
+ }
4605
+ };
4606
+ ZodUnknown.create = (params) => {
4607
+ return new ZodUnknown({
4608
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
4609
+ ...processCreateParams(params)
4610
+ });
4611
+ };
4612
+ var ZodNever = class extends ZodType {
4613
+ _parse(input) {
4614
+ const ctx = this._getOrReturnCtx(input);
4615
+ addIssueToContext(ctx, {
4616
+ code: ZodIssueCode.invalid_type,
4617
+ expected: ZodParsedType.never,
4618
+ received: ctx.parsedType
4619
+ });
4620
+ return INVALID;
4621
+ }
4622
+ };
4623
+ ZodNever.create = (params) => {
4624
+ return new ZodNever({
4625
+ typeName: ZodFirstPartyTypeKind.ZodNever,
4626
+ ...processCreateParams(params)
4627
+ });
4628
+ };
4629
+ var ZodVoid = class extends ZodType {
4630
+ _parse(input) {
4631
+ const parsedType = this._getType(input);
4632
+ if (parsedType !== ZodParsedType.undefined) {
4633
+ const ctx = this._getOrReturnCtx(input);
4634
+ addIssueToContext(ctx, {
4635
+ code: ZodIssueCode.invalid_type,
4636
+ expected: ZodParsedType.void,
4637
+ received: ctx.parsedType
4638
+ });
4639
+ return INVALID;
4640
+ }
4641
+ return OK(input.data);
4642
+ }
4643
+ };
4644
+ ZodVoid.create = (params) => {
4645
+ return new ZodVoid({
4646
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
4647
+ ...processCreateParams(params)
4648
+ });
4649
+ };
4650
+ var ZodArray = class _ZodArray extends ZodType {
4651
+ _parse(input) {
4652
+ const { ctx, status } = this._processInputParams(input);
4653
+ const def = this._def;
4654
+ if (ctx.parsedType !== ZodParsedType.array) {
4655
+ addIssueToContext(ctx, {
4656
+ code: ZodIssueCode.invalid_type,
4657
+ expected: ZodParsedType.array,
4658
+ received: ctx.parsedType
4659
+ });
4660
+ return INVALID;
4661
+ }
4662
+ if (def.exactLength !== null) {
4663
+ const tooBig = ctx.data.length > def.exactLength.value;
4664
+ const tooSmall = ctx.data.length < def.exactLength.value;
4665
+ if (tooBig || tooSmall) {
4666
+ addIssueToContext(ctx, {
4667
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
4668
+ minimum: tooSmall ? def.exactLength.value : void 0,
4669
+ maximum: tooBig ? def.exactLength.value : void 0,
4670
+ type: "array",
4671
+ inclusive: true,
4672
+ exact: true,
4673
+ message: def.exactLength.message
4674
+ });
4675
+ status.dirty();
4676
+ }
4677
+ }
4678
+ if (def.minLength !== null) {
4679
+ if (ctx.data.length < def.minLength.value) {
4680
+ addIssueToContext(ctx, {
4681
+ code: ZodIssueCode.too_small,
4682
+ minimum: def.minLength.value,
4683
+ type: "array",
4684
+ inclusive: true,
4685
+ exact: false,
4686
+ message: def.minLength.message
4687
+ });
4688
+ status.dirty();
4689
+ }
4690
+ }
4691
+ if (def.maxLength !== null) {
4692
+ if (ctx.data.length > def.maxLength.value) {
4693
+ addIssueToContext(ctx, {
4694
+ code: ZodIssueCode.too_big,
4695
+ maximum: def.maxLength.value,
4696
+ type: "array",
4697
+ inclusive: true,
4698
+ exact: false,
4699
+ message: def.maxLength.message
4700
+ });
4701
+ status.dirty();
4702
+ }
4703
+ }
4704
+ if (ctx.common.async) {
4705
+ return Promise.all([...ctx.data].map((item, i3) => {
4706
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i3));
4707
+ })).then((result2) => {
4708
+ return ParseStatus.mergeArray(status, result2);
4709
+ });
4710
+ }
4711
+ const result = [...ctx.data].map((item, i3) => {
4712
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i3));
4713
+ });
4714
+ return ParseStatus.mergeArray(status, result);
4715
+ }
4716
+ get element() {
4717
+ return this._def.type;
4718
+ }
4719
+ min(minLength, message) {
4720
+ return new _ZodArray({
4721
+ ...this._def,
4722
+ minLength: { value: minLength, message: errorUtil.toString(message) }
4723
+ });
4724
+ }
4725
+ max(maxLength, message) {
4726
+ return new _ZodArray({
4727
+ ...this._def,
4728
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
4729
+ });
4730
+ }
4731
+ length(len, message) {
4732
+ return new _ZodArray({
4733
+ ...this._def,
4734
+ exactLength: { value: len, message: errorUtil.toString(message) }
4735
+ });
4736
+ }
4737
+ nonempty(message) {
4738
+ return this.min(1, message);
4739
+ }
4740
+ };
4741
+ ZodArray.create = (schema, params) => {
4742
+ return new ZodArray({
4743
+ type: schema,
4744
+ minLength: null,
4745
+ maxLength: null,
4746
+ exactLength: null,
4747
+ typeName: ZodFirstPartyTypeKind.ZodArray,
4748
+ ...processCreateParams(params)
4749
+ });
4750
+ };
4751
+ function deepPartialify(schema) {
4752
+ if (schema instanceof ZodObject) {
4753
+ const newShape = {};
4754
+ for (const key in schema.shape) {
4755
+ const fieldSchema = schema.shape[key];
4756
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
4757
+ }
4758
+ return new ZodObject({
4759
+ ...schema._def,
4760
+ shape: () => newShape
4761
+ });
4762
+ } else if (schema instanceof ZodArray) {
4763
+ return new ZodArray({
4764
+ ...schema._def,
4765
+ type: deepPartialify(schema.element)
4766
+ });
4767
+ } else if (schema instanceof ZodOptional) {
4768
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
4769
+ } else if (schema instanceof ZodNullable) {
4770
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
4771
+ } else if (schema instanceof ZodTuple) {
4772
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
4773
+ } else {
4774
+ return schema;
4775
+ }
4776
+ }
4777
+ var ZodObject = class _ZodObject extends ZodType {
4778
+ constructor() {
4779
+ super(...arguments);
4780
+ this._cached = null;
4781
+ this.nonstrict = this.passthrough;
4782
+ this.augment = this.extend;
4783
+ }
4784
+ _getCached() {
4785
+ if (this._cached !== null)
4786
+ return this._cached;
4787
+ const shape = this._def.shape();
4788
+ const keys = util.objectKeys(shape);
4789
+ this._cached = { shape, keys };
4790
+ return this._cached;
4791
+ }
4792
+ _parse(input) {
4793
+ const parsedType = this._getType(input);
4794
+ if (parsedType !== ZodParsedType.object) {
4795
+ const ctx2 = this._getOrReturnCtx(input);
4796
+ addIssueToContext(ctx2, {
4797
+ code: ZodIssueCode.invalid_type,
4798
+ expected: ZodParsedType.object,
4799
+ received: ctx2.parsedType
4800
+ });
4801
+ return INVALID;
4802
+ }
4803
+ const { status, ctx } = this._processInputParams(input);
4804
+ const { shape, keys: shapeKeys } = this._getCached();
4805
+ const extraKeys = [];
4806
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
4807
+ for (const key in ctx.data) {
4808
+ if (!shapeKeys.includes(key)) {
4809
+ extraKeys.push(key);
4810
+ }
4811
+ }
4812
+ }
4813
+ const pairs = [];
4814
+ for (const key of shapeKeys) {
4815
+ const keyValidator = shape[key];
4816
+ const value = ctx.data[key];
4817
+ pairs.push({
4818
+ key: { status: "valid", value: key },
4819
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
4820
+ alwaysSet: key in ctx.data
4821
+ });
4822
+ }
4823
+ if (this._def.catchall instanceof ZodNever) {
4824
+ const unknownKeys = this._def.unknownKeys;
4825
+ if (unknownKeys === "passthrough") {
4826
+ for (const key of extraKeys) {
4827
+ pairs.push({
4828
+ key: { status: "valid", value: key },
4829
+ value: { status: "valid", value: ctx.data[key] }
4830
+ });
4831
+ }
4832
+ } else if (unknownKeys === "strict") {
4833
+ if (extraKeys.length > 0) {
4834
+ addIssueToContext(ctx, {
4835
+ code: ZodIssueCode.unrecognized_keys,
4836
+ keys: extraKeys
4837
+ });
4838
+ status.dirty();
4839
+ }
4840
+ } else if (unknownKeys === "strip") {
4841
+ } else {
4842
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
4843
+ }
4844
+ } else {
4845
+ const catchall = this._def.catchall;
4846
+ for (const key of extraKeys) {
4847
+ const value = ctx.data[key];
4848
+ pairs.push({
4849
+ key: { status: "valid", value: key },
4850
+ value: catchall._parse(
4851
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
4852
+ //, ctx.child(key), value, getParsedType(value)
4853
+ ),
4854
+ alwaysSet: key in ctx.data
4855
+ });
4856
+ }
4857
+ }
4858
+ if (ctx.common.async) {
4859
+ return Promise.resolve().then(async () => {
4860
+ const syncPairs = [];
4861
+ for (const pair of pairs) {
4862
+ const key = await pair.key;
4863
+ const value = await pair.value;
4864
+ syncPairs.push({
4865
+ key,
4866
+ value,
4867
+ alwaysSet: pair.alwaysSet
4868
+ });
4869
+ }
4870
+ return syncPairs;
4871
+ }).then((syncPairs) => {
4872
+ return ParseStatus.mergeObjectSync(status, syncPairs);
4873
+ });
4874
+ } else {
4875
+ return ParseStatus.mergeObjectSync(status, pairs);
4876
+ }
4877
+ }
4878
+ get shape() {
4879
+ return this._def.shape();
4880
+ }
4881
+ strict(message) {
4882
+ errorUtil.errToObj;
4883
+ return new _ZodObject({
4884
+ ...this._def,
4885
+ unknownKeys: "strict",
4886
+ ...message !== void 0 ? {
4887
+ errorMap: (issue, ctx) => {
4888
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
4889
+ if (issue.code === "unrecognized_keys")
4890
+ return {
4891
+ message: errorUtil.errToObj(message).message ?? defaultError
4892
+ };
4893
+ return {
4894
+ message: defaultError
4895
+ };
4896
+ }
4897
+ } : {}
4898
+ });
4899
+ }
4900
+ strip() {
4901
+ return new _ZodObject({
4902
+ ...this._def,
4903
+ unknownKeys: "strip"
4904
+ });
4905
+ }
4906
+ passthrough() {
4907
+ return new _ZodObject({
4908
+ ...this._def,
4909
+ unknownKeys: "passthrough"
4910
+ });
4911
+ }
4912
+ // const AugmentFactory =
4913
+ // <Def extends ZodObjectDef>(def: Def) =>
4914
+ // <Augmentation extends ZodRawShape>(
4915
+ // augmentation: Augmentation
4916
+ // ): ZodObject<
4917
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
4918
+ // Def["unknownKeys"],
4919
+ // Def["catchall"]
4920
+ // > => {
4921
+ // return new ZodObject({
4922
+ // ...def,
4923
+ // shape: () => ({
4924
+ // ...def.shape(),
4925
+ // ...augmentation,
4926
+ // }),
4927
+ // }) as any;
4928
+ // };
4929
+ extend(augmentation) {
4930
+ return new _ZodObject({
4931
+ ...this._def,
4932
+ shape: () => ({
4933
+ ...this._def.shape(),
4934
+ ...augmentation
4935
+ })
4936
+ });
4937
+ }
4938
+ /**
4939
+ * Prior to zod@1.0.12 there was a bug in the
4940
+ * inferred type of merged objects. Please
4941
+ * upgrade if you are experiencing issues.
4942
+ */
4943
+ merge(merging) {
4944
+ const merged = new _ZodObject({
4945
+ unknownKeys: merging._def.unknownKeys,
4946
+ catchall: merging._def.catchall,
4947
+ shape: () => ({
4948
+ ...this._def.shape(),
4949
+ ...merging._def.shape()
4950
+ }),
4951
+ typeName: ZodFirstPartyTypeKind.ZodObject
4952
+ });
4953
+ return merged;
4954
+ }
4955
+ // merge<
4956
+ // Incoming extends AnyZodObject,
4957
+ // Augmentation extends Incoming["shape"],
4958
+ // NewOutput extends {
4959
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
4960
+ // ? Augmentation[k]["_output"]
4961
+ // : k extends keyof Output
4962
+ // ? Output[k]
4963
+ // : never;
4964
+ // },
4965
+ // NewInput extends {
4966
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
4967
+ // ? Augmentation[k]["_input"]
4968
+ // : k extends keyof Input
4969
+ // ? Input[k]
4970
+ // : never;
4971
+ // }
4972
+ // >(
4973
+ // merging: Incoming
4974
+ // ): ZodObject<
4975
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
4976
+ // Incoming["_def"]["unknownKeys"],
4977
+ // Incoming["_def"]["catchall"],
4978
+ // NewOutput,
4979
+ // NewInput
4980
+ // > {
4981
+ // const merged: any = new ZodObject({
4982
+ // unknownKeys: merging._def.unknownKeys,
4983
+ // catchall: merging._def.catchall,
4984
+ // shape: () =>
4985
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
4986
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
4987
+ // }) as any;
4988
+ // return merged;
4989
+ // }
4990
+ setKey(key, schema) {
4991
+ return this.augment({ [key]: schema });
4992
+ }
4993
+ // merge<Incoming extends AnyZodObject>(
4994
+ // merging: Incoming
4995
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
4996
+ // ZodObject<
4997
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
4998
+ // Incoming["_def"]["unknownKeys"],
4999
+ // Incoming["_def"]["catchall"]
5000
+ // > {
5001
+ // // const mergedShape = objectUtil.mergeShapes(
5002
+ // // this._def.shape(),
5003
+ // // merging._def.shape()
5004
+ // // );
5005
+ // const merged: any = new ZodObject({
5006
+ // unknownKeys: merging._def.unknownKeys,
5007
+ // catchall: merging._def.catchall,
5008
+ // shape: () =>
5009
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
5010
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
5011
+ // }) as any;
5012
+ // return merged;
5013
+ // }
5014
+ catchall(index2) {
5015
+ return new _ZodObject({
5016
+ ...this._def,
5017
+ catchall: index2
5018
+ });
5019
+ }
5020
+ pick(mask) {
5021
+ const shape = {};
5022
+ for (const key of util.objectKeys(mask)) {
5023
+ if (mask[key] && this.shape[key]) {
5024
+ shape[key] = this.shape[key];
5025
+ }
5026
+ }
5027
+ return new _ZodObject({
5028
+ ...this._def,
5029
+ shape: () => shape
5030
+ });
5031
+ }
5032
+ omit(mask) {
5033
+ const shape = {};
5034
+ for (const key of util.objectKeys(this.shape)) {
5035
+ if (!mask[key]) {
5036
+ shape[key] = this.shape[key];
5037
+ }
5038
+ }
5039
+ return new _ZodObject({
5040
+ ...this._def,
5041
+ shape: () => shape
5042
+ });
5043
+ }
5044
+ /**
5045
+ * @deprecated
5046
+ */
5047
+ deepPartial() {
5048
+ return deepPartialify(this);
5049
+ }
5050
+ partial(mask) {
5051
+ const newShape = {};
5052
+ for (const key of util.objectKeys(this.shape)) {
5053
+ const fieldSchema = this.shape[key];
5054
+ if (mask && !mask[key]) {
5055
+ newShape[key] = fieldSchema;
5056
+ } else {
5057
+ newShape[key] = fieldSchema.optional();
5058
+ }
5059
+ }
5060
+ return new _ZodObject({
5061
+ ...this._def,
5062
+ shape: () => newShape
5063
+ });
5064
+ }
5065
+ required(mask) {
5066
+ const newShape = {};
5067
+ for (const key of util.objectKeys(this.shape)) {
5068
+ if (mask && !mask[key]) {
5069
+ newShape[key] = this.shape[key];
5070
+ } else {
5071
+ const fieldSchema = this.shape[key];
5072
+ let newField = fieldSchema;
5073
+ while (newField instanceof ZodOptional) {
5074
+ newField = newField._def.innerType;
5075
+ }
5076
+ newShape[key] = newField;
5077
+ }
5078
+ }
5079
+ return new _ZodObject({
5080
+ ...this._def,
5081
+ shape: () => newShape
5082
+ });
5083
+ }
5084
+ keyof() {
5085
+ return createZodEnum(util.objectKeys(this.shape));
5086
+ }
5087
+ };
5088
+ ZodObject.create = (shape, params) => {
5089
+ return new ZodObject({
5090
+ shape: () => shape,
5091
+ unknownKeys: "strip",
5092
+ catchall: ZodNever.create(),
5093
+ typeName: ZodFirstPartyTypeKind.ZodObject,
5094
+ ...processCreateParams(params)
5095
+ });
5096
+ };
5097
+ ZodObject.strictCreate = (shape, params) => {
5098
+ return new ZodObject({
5099
+ shape: () => shape,
5100
+ unknownKeys: "strict",
5101
+ catchall: ZodNever.create(),
5102
+ typeName: ZodFirstPartyTypeKind.ZodObject,
5103
+ ...processCreateParams(params)
5104
+ });
5105
+ };
5106
+ ZodObject.lazycreate = (shape, params) => {
5107
+ return new ZodObject({
5108
+ shape,
5109
+ unknownKeys: "strip",
5110
+ catchall: ZodNever.create(),
5111
+ typeName: ZodFirstPartyTypeKind.ZodObject,
5112
+ ...processCreateParams(params)
5113
+ });
5114
+ };
5115
+ var ZodUnion = class extends ZodType {
5116
+ _parse(input) {
5117
+ const { ctx } = this._processInputParams(input);
5118
+ const options = this._def.options;
5119
+ function handleResults(results) {
5120
+ for (const result of results) {
5121
+ if (result.result.status === "valid") {
5122
+ return result.result;
5123
+ }
5124
+ }
5125
+ for (const result of results) {
5126
+ if (result.result.status === "dirty") {
5127
+ ctx.common.issues.push(...result.ctx.common.issues);
5128
+ return result.result;
5129
+ }
5130
+ }
5131
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
5132
+ addIssueToContext(ctx, {
5133
+ code: ZodIssueCode.invalid_union,
5134
+ unionErrors
5135
+ });
5136
+ return INVALID;
5137
+ }
5138
+ if (ctx.common.async) {
5139
+ return Promise.all(options.map(async (option) => {
5140
+ const childCtx = {
5141
+ ...ctx,
5142
+ common: {
5143
+ ...ctx.common,
5144
+ issues: []
5145
+ },
5146
+ parent: null
5147
+ };
5148
+ return {
5149
+ result: await option._parseAsync({
5150
+ data: ctx.data,
5151
+ path: ctx.path,
5152
+ parent: childCtx
5153
+ }),
5154
+ ctx: childCtx
5155
+ };
5156
+ })).then(handleResults);
5157
+ } else {
5158
+ let dirty = void 0;
5159
+ const issues = [];
5160
+ for (const option of options) {
5161
+ const childCtx = {
5162
+ ...ctx,
5163
+ common: {
5164
+ ...ctx.common,
5165
+ issues: []
5166
+ },
5167
+ parent: null
5168
+ };
5169
+ const result = option._parseSync({
5170
+ data: ctx.data,
5171
+ path: ctx.path,
5172
+ parent: childCtx
5173
+ });
5174
+ if (result.status === "valid") {
5175
+ return result;
5176
+ } else if (result.status === "dirty" && !dirty) {
5177
+ dirty = { result, ctx: childCtx };
5178
+ }
5179
+ if (childCtx.common.issues.length) {
5180
+ issues.push(childCtx.common.issues);
5181
+ }
5182
+ }
5183
+ if (dirty) {
5184
+ ctx.common.issues.push(...dirty.ctx.common.issues);
5185
+ return dirty.result;
5186
+ }
5187
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
5188
+ addIssueToContext(ctx, {
5189
+ code: ZodIssueCode.invalid_union,
5190
+ unionErrors
5191
+ });
5192
+ return INVALID;
5193
+ }
5194
+ }
5195
+ get options() {
5196
+ return this._def.options;
5197
+ }
5198
+ };
5199
+ ZodUnion.create = (types, params) => {
5200
+ return new ZodUnion({
5201
+ options: types,
5202
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
5203
+ ...processCreateParams(params)
5204
+ });
5205
+ };
5206
+ var getDiscriminator = (type) => {
5207
+ if (type instanceof ZodLazy) {
5208
+ return getDiscriminator(type.schema);
5209
+ } else if (type instanceof ZodEffects) {
5210
+ return getDiscriminator(type.innerType());
5211
+ } else if (type instanceof ZodLiteral) {
5212
+ return [type.value];
5213
+ } else if (type instanceof ZodEnum) {
5214
+ return type.options;
5215
+ } else if (type instanceof ZodNativeEnum) {
5216
+ return util.objectValues(type.enum);
5217
+ } else if (type instanceof ZodDefault) {
5218
+ return getDiscriminator(type._def.innerType);
5219
+ } else if (type instanceof ZodUndefined) {
5220
+ return [void 0];
5221
+ } else if (type instanceof ZodNull) {
5222
+ return [null];
5223
+ } else if (type instanceof ZodOptional) {
5224
+ return [void 0, ...getDiscriminator(type.unwrap())];
5225
+ } else if (type instanceof ZodNullable) {
5226
+ return [null, ...getDiscriminator(type.unwrap())];
5227
+ } else if (type instanceof ZodBranded) {
5228
+ return getDiscriminator(type.unwrap());
5229
+ } else if (type instanceof ZodReadonly) {
5230
+ return getDiscriminator(type.unwrap());
5231
+ } else if (type instanceof ZodCatch) {
5232
+ return getDiscriminator(type._def.innerType);
5233
+ } else {
5234
+ return [];
5235
+ }
5236
+ };
5237
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
5238
+ _parse(input) {
5239
+ const { ctx } = this._processInputParams(input);
5240
+ if (ctx.parsedType !== ZodParsedType.object) {
5241
+ addIssueToContext(ctx, {
5242
+ code: ZodIssueCode.invalid_type,
5243
+ expected: ZodParsedType.object,
5244
+ received: ctx.parsedType
5245
+ });
5246
+ return INVALID;
5247
+ }
5248
+ const discriminator = this.discriminator;
5249
+ const discriminatorValue = ctx.data[discriminator];
5250
+ const option = this.optionsMap.get(discriminatorValue);
5251
+ if (!option) {
5252
+ addIssueToContext(ctx, {
5253
+ code: ZodIssueCode.invalid_union_discriminator,
5254
+ options: Array.from(this.optionsMap.keys()),
5255
+ path: [discriminator]
5256
+ });
5257
+ return INVALID;
5258
+ }
5259
+ if (ctx.common.async) {
5260
+ return option._parseAsync({
5261
+ data: ctx.data,
5262
+ path: ctx.path,
5263
+ parent: ctx
5264
+ });
5265
+ } else {
5266
+ return option._parseSync({
5267
+ data: ctx.data,
5268
+ path: ctx.path,
5269
+ parent: ctx
5270
+ });
5271
+ }
5272
+ }
5273
+ get discriminator() {
5274
+ return this._def.discriminator;
5275
+ }
5276
+ get options() {
5277
+ return this._def.options;
5278
+ }
5279
+ get optionsMap() {
5280
+ return this._def.optionsMap;
5281
+ }
5282
+ /**
5283
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
5284
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
5285
+ * have a different value for each object in the union.
5286
+ * @param discriminator the name of the discriminator property
5287
+ * @param types an array of object schemas
5288
+ * @param params
5289
+ */
5290
+ static create(discriminator, options, params) {
5291
+ const optionsMap = /* @__PURE__ */ new Map();
5292
+ for (const type of options) {
5293
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
5294
+ if (!discriminatorValues.length) {
5295
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
5296
+ }
5297
+ for (const value of discriminatorValues) {
5298
+ if (optionsMap.has(value)) {
5299
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
5300
+ }
5301
+ optionsMap.set(value, type);
5302
+ }
5303
+ }
5304
+ return new _ZodDiscriminatedUnion({
5305
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
5306
+ discriminator,
5307
+ options,
5308
+ optionsMap,
5309
+ ...processCreateParams(params)
5310
+ });
5311
+ }
5312
+ };
5313
+ function mergeValues(a4, b) {
5314
+ const aType = getParsedType(a4);
5315
+ const bType = getParsedType(b);
5316
+ if (a4 === b) {
5317
+ return { valid: true, data: a4 };
5318
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
5319
+ const bKeys = util.objectKeys(b);
5320
+ const sharedKeys = util.objectKeys(a4).filter((key) => bKeys.indexOf(key) !== -1);
5321
+ const newObj = { ...a4, ...b };
5322
+ for (const key of sharedKeys) {
5323
+ const sharedValue = mergeValues(a4[key], b[key]);
5324
+ if (!sharedValue.valid) {
5325
+ return { valid: false };
5326
+ }
5327
+ newObj[key] = sharedValue.data;
5328
+ }
5329
+ return { valid: true, data: newObj };
5330
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
5331
+ if (a4.length !== b.length) {
5332
+ return { valid: false };
5333
+ }
5334
+ const newArray = [];
5335
+ for (let index2 = 0; index2 < a4.length; index2++) {
5336
+ const itemA = a4[index2];
5337
+ const itemB = b[index2];
5338
+ const sharedValue = mergeValues(itemA, itemB);
5339
+ if (!sharedValue.valid) {
5340
+ return { valid: false };
5341
+ }
5342
+ newArray.push(sharedValue.data);
5343
+ }
5344
+ return { valid: true, data: newArray };
5345
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a4 === +b) {
5346
+ return { valid: true, data: a4 };
5347
+ } else {
5348
+ return { valid: false };
5349
+ }
5350
+ }
5351
+ var ZodIntersection = class extends ZodType {
5352
+ _parse(input) {
5353
+ const { status, ctx } = this._processInputParams(input);
5354
+ const handleParsed = (parsedLeft, parsedRight) => {
5355
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
5356
+ return INVALID;
5357
+ }
5358
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
5359
+ if (!merged.valid) {
5360
+ addIssueToContext(ctx, {
5361
+ code: ZodIssueCode.invalid_intersection_types
5362
+ });
5363
+ return INVALID;
5364
+ }
5365
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
5366
+ status.dirty();
5367
+ }
5368
+ return { status: status.value, value: merged.data };
5369
+ };
5370
+ if (ctx.common.async) {
5371
+ return Promise.all([
5372
+ this._def.left._parseAsync({
5373
+ data: ctx.data,
5374
+ path: ctx.path,
5375
+ parent: ctx
5376
+ }),
5377
+ this._def.right._parseAsync({
5378
+ data: ctx.data,
5379
+ path: ctx.path,
5380
+ parent: ctx
5381
+ })
5382
+ ]).then(([left, right]) => handleParsed(left, right));
5383
+ } else {
5384
+ return handleParsed(this._def.left._parseSync({
5385
+ data: ctx.data,
5386
+ path: ctx.path,
5387
+ parent: ctx
5388
+ }), this._def.right._parseSync({
5389
+ data: ctx.data,
5390
+ path: ctx.path,
5391
+ parent: ctx
5392
+ }));
5393
+ }
5394
+ }
5395
+ };
5396
+ ZodIntersection.create = (left, right, params) => {
5397
+ return new ZodIntersection({
5398
+ left,
5399
+ right,
5400
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
5401
+ ...processCreateParams(params)
5402
+ });
5403
+ };
5404
+ var ZodTuple = class _ZodTuple extends ZodType {
5405
+ _parse(input) {
5406
+ const { status, ctx } = this._processInputParams(input);
5407
+ if (ctx.parsedType !== ZodParsedType.array) {
5408
+ addIssueToContext(ctx, {
5409
+ code: ZodIssueCode.invalid_type,
5410
+ expected: ZodParsedType.array,
5411
+ received: ctx.parsedType
5412
+ });
5413
+ return INVALID;
5414
+ }
5415
+ if (ctx.data.length < this._def.items.length) {
5416
+ addIssueToContext(ctx, {
5417
+ code: ZodIssueCode.too_small,
5418
+ minimum: this._def.items.length,
5419
+ inclusive: true,
5420
+ exact: false,
5421
+ type: "array"
5422
+ });
5423
+ return INVALID;
5424
+ }
5425
+ const rest = this._def.rest;
5426
+ if (!rest && ctx.data.length > this._def.items.length) {
5427
+ addIssueToContext(ctx, {
5428
+ code: ZodIssueCode.too_big,
5429
+ maximum: this._def.items.length,
5430
+ inclusive: true,
5431
+ exact: false,
5432
+ type: "array"
5433
+ });
5434
+ status.dirty();
5435
+ }
5436
+ const items = [...ctx.data].map((item, itemIndex) => {
5437
+ const schema = this._def.items[itemIndex] || this._def.rest;
5438
+ if (!schema)
5439
+ return null;
5440
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
5441
+ }).filter((x) => !!x);
5442
+ if (ctx.common.async) {
5443
+ return Promise.all(items).then((results) => {
5444
+ return ParseStatus.mergeArray(status, results);
5445
+ });
5446
+ } else {
5447
+ return ParseStatus.mergeArray(status, items);
5448
+ }
5449
+ }
5450
+ get items() {
5451
+ return this._def.items;
5452
+ }
5453
+ rest(rest) {
5454
+ return new _ZodTuple({
5455
+ ...this._def,
5456
+ rest
5457
+ });
5458
+ }
5459
+ };
5460
+ ZodTuple.create = (schemas, params) => {
5461
+ if (!Array.isArray(schemas)) {
5462
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
5463
+ }
5464
+ return new ZodTuple({
5465
+ items: schemas,
5466
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
5467
+ rest: null,
5468
+ ...processCreateParams(params)
5469
+ });
5470
+ };
5471
+ var ZodRecord = class _ZodRecord extends ZodType {
5472
+ get keySchema() {
5473
+ return this._def.keyType;
5474
+ }
5475
+ get valueSchema() {
5476
+ return this._def.valueType;
5477
+ }
5478
+ _parse(input) {
5479
+ const { status, ctx } = this._processInputParams(input);
5480
+ if (ctx.parsedType !== ZodParsedType.object) {
5481
+ addIssueToContext(ctx, {
5482
+ code: ZodIssueCode.invalid_type,
5483
+ expected: ZodParsedType.object,
5484
+ received: ctx.parsedType
5485
+ });
5486
+ return INVALID;
5487
+ }
5488
+ const pairs = [];
5489
+ const keyType = this._def.keyType;
5490
+ const valueType = this._def.valueType;
5491
+ for (const key in ctx.data) {
5492
+ pairs.push({
5493
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
5494
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
5495
+ alwaysSet: key in ctx.data
5496
+ });
5497
+ }
5498
+ if (ctx.common.async) {
5499
+ return ParseStatus.mergeObjectAsync(status, pairs);
5500
+ } else {
5501
+ return ParseStatus.mergeObjectSync(status, pairs);
5502
+ }
5503
+ }
5504
+ get element() {
5505
+ return this._def.valueType;
5506
+ }
5507
+ static create(first, second, third) {
5508
+ if (second instanceof ZodType) {
5509
+ return new _ZodRecord({
5510
+ keyType: first,
5511
+ valueType: second,
5512
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
5513
+ ...processCreateParams(third)
5514
+ });
5515
+ }
5516
+ return new _ZodRecord({
5517
+ keyType: ZodString.create(),
5518
+ valueType: first,
5519
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
5520
+ ...processCreateParams(second)
5521
+ });
5522
+ }
5523
+ };
5524
+ var ZodMap = class extends ZodType {
5525
+ get keySchema() {
5526
+ return this._def.keyType;
5527
+ }
5528
+ get valueSchema() {
5529
+ return this._def.valueType;
5530
+ }
5531
+ _parse(input) {
5532
+ const { status, ctx } = this._processInputParams(input);
5533
+ if (ctx.parsedType !== ZodParsedType.map) {
5534
+ addIssueToContext(ctx, {
5535
+ code: ZodIssueCode.invalid_type,
5536
+ expected: ZodParsedType.map,
5537
+ received: ctx.parsedType
5538
+ });
5539
+ return INVALID;
5540
+ }
5541
+ const keyType = this._def.keyType;
5542
+ const valueType = this._def.valueType;
5543
+ const pairs = [...ctx.data.entries()].map(([key, value], index2) => {
5544
+ return {
5545
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])),
5546
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"]))
5547
+ };
5548
+ });
5549
+ if (ctx.common.async) {
5550
+ const finalMap = /* @__PURE__ */ new Map();
5551
+ return Promise.resolve().then(async () => {
5552
+ for (const pair of pairs) {
5553
+ const key = await pair.key;
5554
+ const value = await pair.value;
5555
+ if (key.status === "aborted" || value.status === "aborted") {
5556
+ return INVALID;
5557
+ }
5558
+ if (key.status === "dirty" || value.status === "dirty") {
5559
+ status.dirty();
5560
+ }
5561
+ finalMap.set(key.value, value.value);
5562
+ }
5563
+ return { status: status.value, value: finalMap };
5564
+ });
5565
+ } else {
5566
+ const finalMap = /* @__PURE__ */ new Map();
5567
+ for (const pair of pairs) {
5568
+ const key = pair.key;
5569
+ const value = pair.value;
5570
+ if (key.status === "aborted" || value.status === "aborted") {
5571
+ return INVALID;
5572
+ }
5573
+ if (key.status === "dirty" || value.status === "dirty") {
5574
+ status.dirty();
5575
+ }
5576
+ finalMap.set(key.value, value.value);
5577
+ }
5578
+ return { status: status.value, value: finalMap };
5579
+ }
5580
+ }
5581
+ };
5582
+ ZodMap.create = (keyType, valueType, params) => {
5583
+ return new ZodMap({
5584
+ valueType,
5585
+ keyType,
5586
+ typeName: ZodFirstPartyTypeKind.ZodMap,
5587
+ ...processCreateParams(params)
5588
+ });
5589
+ };
5590
+ var ZodSet = class _ZodSet extends ZodType {
5591
+ _parse(input) {
5592
+ const { status, ctx } = this._processInputParams(input);
5593
+ if (ctx.parsedType !== ZodParsedType.set) {
5594
+ addIssueToContext(ctx, {
5595
+ code: ZodIssueCode.invalid_type,
5596
+ expected: ZodParsedType.set,
5597
+ received: ctx.parsedType
5598
+ });
5599
+ return INVALID;
5600
+ }
5601
+ const def = this._def;
5602
+ if (def.minSize !== null) {
5603
+ if (ctx.data.size < def.minSize.value) {
5604
+ addIssueToContext(ctx, {
5605
+ code: ZodIssueCode.too_small,
5606
+ minimum: def.minSize.value,
5607
+ type: "set",
5608
+ inclusive: true,
5609
+ exact: false,
5610
+ message: def.minSize.message
5611
+ });
5612
+ status.dirty();
5613
+ }
5614
+ }
5615
+ if (def.maxSize !== null) {
5616
+ if (ctx.data.size > def.maxSize.value) {
5617
+ addIssueToContext(ctx, {
5618
+ code: ZodIssueCode.too_big,
5619
+ maximum: def.maxSize.value,
5620
+ type: "set",
5621
+ inclusive: true,
5622
+ exact: false,
5623
+ message: def.maxSize.message
5624
+ });
5625
+ status.dirty();
5626
+ }
5627
+ }
5628
+ const valueType = this._def.valueType;
5629
+ function finalizeSet(elements2) {
5630
+ const parsedSet = /* @__PURE__ */ new Set();
5631
+ for (const element of elements2) {
5632
+ if (element.status === "aborted")
5633
+ return INVALID;
5634
+ if (element.status === "dirty")
5635
+ status.dirty();
5636
+ parsedSet.add(element.value);
5637
+ }
5638
+ return { status: status.value, value: parsedSet };
5639
+ }
5640
+ const elements = [...ctx.data.values()].map((item, i3) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i3)));
5641
+ if (ctx.common.async) {
5642
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
5643
+ } else {
5644
+ return finalizeSet(elements);
5645
+ }
5646
+ }
5647
+ min(minSize, message) {
5648
+ return new _ZodSet({
5649
+ ...this._def,
5650
+ minSize: { value: minSize, message: errorUtil.toString(message) }
5651
+ });
5652
+ }
5653
+ max(maxSize, message) {
5654
+ return new _ZodSet({
5655
+ ...this._def,
5656
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
5657
+ });
5658
+ }
5659
+ size(size5, message) {
5660
+ return this.min(size5, message).max(size5, message);
5661
+ }
5662
+ nonempty(message) {
5663
+ return this.min(1, message);
5664
+ }
5665
+ };
5666
+ ZodSet.create = (valueType, params) => {
5667
+ return new ZodSet({
5668
+ valueType,
5669
+ minSize: null,
5670
+ maxSize: null,
5671
+ typeName: ZodFirstPartyTypeKind.ZodSet,
5672
+ ...processCreateParams(params)
5673
+ });
5674
+ };
5675
+ var ZodFunction = class _ZodFunction extends ZodType {
5676
+ constructor() {
5677
+ super(...arguments);
5678
+ this.validate = this.implement;
5679
+ }
5680
+ _parse(input) {
5681
+ const { ctx } = this._processInputParams(input);
5682
+ if (ctx.parsedType !== ZodParsedType.function) {
5683
+ addIssueToContext(ctx, {
5684
+ code: ZodIssueCode.invalid_type,
5685
+ expected: ZodParsedType.function,
5686
+ received: ctx.parsedType
5687
+ });
5688
+ return INVALID;
5689
+ }
5690
+ function makeArgsIssue(args, error) {
5691
+ return makeIssue({
5692
+ data: args,
5693
+ path: ctx.path,
5694
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
5695
+ issueData: {
5696
+ code: ZodIssueCode.invalid_arguments,
5697
+ argumentsError: error
5698
+ }
5699
+ });
5700
+ }
5701
+ function makeReturnsIssue(returns, error) {
5702
+ return makeIssue({
5703
+ data: returns,
5704
+ path: ctx.path,
5705
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
5706
+ issueData: {
5707
+ code: ZodIssueCode.invalid_return_type,
5708
+ returnTypeError: error
5709
+ }
5710
+ });
5711
+ }
5712
+ const params = { errorMap: ctx.common.contextualErrorMap };
5713
+ const fn = ctx.data;
5714
+ if (this._def.returns instanceof ZodPromise) {
5715
+ const me = this;
5716
+ return OK(async function(...args) {
5717
+ const error = new ZodError([]);
5718
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
5719
+ error.addIssue(makeArgsIssue(args, e));
5720
+ throw error;
5721
+ });
5722
+ const result = await Reflect.apply(fn, this, parsedArgs);
5723
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
5724
+ error.addIssue(makeReturnsIssue(result, e));
5725
+ throw error;
5726
+ });
5727
+ return parsedReturns;
5728
+ });
5729
+ } else {
5730
+ const me = this;
5731
+ return OK(function(...args) {
5732
+ const parsedArgs = me._def.args.safeParse(args, params);
5733
+ if (!parsedArgs.success) {
5734
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
5735
+ }
5736
+ const result = Reflect.apply(fn, this, parsedArgs.data);
5737
+ const parsedReturns = me._def.returns.safeParse(result, params);
5738
+ if (!parsedReturns.success) {
5739
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
5740
+ }
5741
+ return parsedReturns.data;
5742
+ });
5743
+ }
5744
+ }
5745
+ parameters() {
5746
+ return this._def.args;
5747
+ }
5748
+ returnType() {
5749
+ return this._def.returns;
5750
+ }
5751
+ args(...items) {
5752
+ return new _ZodFunction({
5753
+ ...this._def,
5754
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
5755
+ });
5756
+ }
5757
+ returns(returnType) {
5758
+ return new _ZodFunction({
5759
+ ...this._def,
5760
+ returns: returnType
5761
+ });
5762
+ }
5763
+ implement(func) {
5764
+ const validatedFunc = this.parse(func);
5765
+ return validatedFunc;
5766
+ }
5767
+ strictImplement(func) {
5768
+ const validatedFunc = this.parse(func);
5769
+ return validatedFunc;
5770
+ }
5771
+ static create(args, returns, params) {
5772
+ return new _ZodFunction({
5773
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
5774
+ returns: returns || ZodUnknown.create(),
5775
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
5776
+ ...processCreateParams(params)
5777
+ });
5778
+ }
5779
+ };
5780
+ var ZodLazy = class extends ZodType {
5781
+ get schema() {
5782
+ return this._def.getter();
5783
+ }
5784
+ _parse(input) {
5785
+ const { ctx } = this._processInputParams(input);
5786
+ const lazySchema = this._def.getter();
5787
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
5788
+ }
5789
+ };
5790
+ ZodLazy.create = (getter, params) => {
5791
+ return new ZodLazy({
5792
+ getter,
5793
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
5794
+ ...processCreateParams(params)
5795
+ });
5796
+ };
5797
+ var ZodLiteral = class extends ZodType {
5798
+ _parse(input) {
5799
+ if (input.data !== this._def.value) {
5800
+ const ctx = this._getOrReturnCtx(input);
5801
+ addIssueToContext(ctx, {
5802
+ received: ctx.data,
5803
+ code: ZodIssueCode.invalid_literal,
5804
+ expected: this._def.value
5805
+ });
5806
+ return INVALID;
5807
+ }
5808
+ return { status: "valid", value: input.data };
5809
+ }
5810
+ get value() {
5811
+ return this._def.value;
5812
+ }
5813
+ };
5814
+ ZodLiteral.create = (value, params) => {
5815
+ return new ZodLiteral({
5816
+ value,
5817
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
5818
+ ...processCreateParams(params)
5819
+ });
5820
+ };
5821
+ function createZodEnum(values, params) {
5822
+ return new ZodEnum({
5823
+ values,
5824
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
5825
+ ...processCreateParams(params)
5826
+ });
5827
+ }
5828
+ var ZodEnum = class _ZodEnum extends ZodType {
5829
+ _parse(input) {
5830
+ if (typeof input.data !== "string") {
5831
+ const ctx = this._getOrReturnCtx(input);
5832
+ const expectedValues = this._def.values;
5833
+ addIssueToContext(ctx, {
5834
+ expected: util.joinValues(expectedValues),
5835
+ received: ctx.parsedType,
5836
+ code: ZodIssueCode.invalid_type
5837
+ });
5838
+ return INVALID;
5839
+ }
5840
+ if (!this._cache) {
5841
+ this._cache = new Set(this._def.values);
5842
+ }
5843
+ if (!this._cache.has(input.data)) {
5844
+ const ctx = this._getOrReturnCtx(input);
5845
+ const expectedValues = this._def.values;
5846
+ addIssueToContext(ctx, {
5847
+ received: ctx.data,
5848
+ code: ZodIssueCode.invalid_enum_value,
5849
+ options: expectedValues
5850
+ });
5851
+ return INVALID;
5852
+ }
5853
+ return OK(input.data);
5854
+ }
5855
+ get options() {
5856
+ return this._def.values;
5857
+ }
5858
+ get enum() {
5859
+ const enumValues = {};
5860
+ for (const val of this._def.values) {
5861
+ enumValues[val] = val;
5862
+ }
5863
+ return enumValues;
5864
+ }
5865
+ get Values() {
5866
+ const enumValues = {};
5867
+ for (const val of this._def.values) {
5868
+ enumValues[val] = val;
5869
+ }
5870
+ return enumValues;
5871
+ }
5872
+ get Enum() {
5873
+ const enumValues = {};
5874
+ for (const val of this._def.values) {
5875
+ enumValues[val] = val;
5876
+ }
5877
+ return enumValues;
5878
+ }
5879
+ extract(values, newDef = this._def) {
5880
+ return _ZodEnum.create(values, {
5881
+ ...this._def,
5882
+ ...newDef
5883
+ });
5884
+ }
5885
+ exclude(values, newDef = this._def) {
5886
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
5887
+ ...this._def,
5888
+ ...newDef
5889
+ });
5890
+ }
5891
+ };
5892
+ ZodEnum.create = createZodEnum;
5893
+ var ZodNativeEnum = class extends ZodType {
5894
+ _parse(input) {
5895
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
5896
+ const ctx = this._getOrReturnCtx(input);
5897
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
5898
+ const expectedValues = util.objectValues(nativeEnumValues);
5899
+ addIssueToContext(ctx, {
5900
+ expected: util.joinValues(expectedValues),
5901
+ received: ctx.parsedType,
5902
+ code: ZodIssueCode.invalid_type
5903
+ });
5904
+ return INVALID;
5905
+ }
5906
+ if (!this._cache) {
5907
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
5908
+ }
5909
+ if (!this._cache.has(input.data)) {
5910
+ const expectedValues = util.objectValues(nativeEnumValues);
5911
+ addIssueToContext(ctx, {
5912
+ received: ctx.data,
5913
+ code: ZodIssueCode.invalid_enum_value,
5914
+ options: expectedValues
5915
+ });
5916
+ return INVALID;
5917
+ }
5918
+ return OK(input.data);
5919
+ }
5920
+ get enum() {
5921
+ return this._def.values;
5922
+ }
5923
+ };
5924
+ ZodNativeEnum.create = (values, params) => {
5925
+ return new ZodNativeEnum({
5926
+ values,
5927
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
5928
+ ...processCreateParams(params)
5929
+ });
5930
+ };
5931
+ var ZodPromise = class extends ZodType {
5932
+ unwrap() {
5933
+ return this._def.type;
5934
+ }
5935
+ _parse(input) {
5936
+ const { ctx } = this._processInputParams(input);
5937
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
5938
+ addIssueToContext(ctx, {
5939
+ code: ZodIssueCode.invalid_type,
5940
+ expected: ZodParsedType.promise,
5941
+ received: ctx.parsedType
5942
+ });
5943
+ return INVALID;
5944
+ }
5945
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
5946
+ return OK(promisified.then((data) => {
5947
+ return this._def.type.parseAsync(data, {
5948
+ path: ctx.path,
5949
+ errorMap: ctx.common.contextualErrorMap
5950
+ });
5951
+ }));
5952
+ }
5953
+ };
5954
+ ZodPromise.create = (schema, params) => {
5955
+ return new ZodPromise({
5956
+ type: schema,
5957
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
5958
+ ...processCreateParams(params)
5959
+ });
5960
+ };
5961
+ var ZodEffects = class extends ZodType {
5962
+ innerType() {
5963
+ return this._def.schema;
5964
+ }
5965
+ sourceType() {
5966
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
5967
+ }
5968
+ _parse(input) {
5969
+ const { status, ctx } = this._processInputParams(input);
5970
+ const effect = this._def.effect || null;
5971
+ const checkCtx = {
5972
+ addIssue: (arg) => {
5973
+ addIssueToContext(ctx, arg);
5974
+ if (arg.fatal) {
5975
+ status.abort();
5976
+ } else {
5977
+ status.dirty();
5978
+ }
5979
+ },
5980
+ get path() {
5981
+ return ctx.path;
5982
+ }
5983
+ };
5984
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
5985
+ if (effect.type === "preprocess") {
5986
+ const processed = effect.transform(ctx.data, checkCtx);
5987
+ if (ctx.common.async) {
5988
+ return Promise.resolve(processed).then(async (processed2) => {
5989
+ if (status.value === "aborted")
5990
+ return INVALID;
5991
+ const result = await this._def.schema._parseAsync({
5992
+ data: processed2,
5993
+ path: ctx.path,
5994
+ parent: ctx
5995
+ });
5996
+ if (result.status === "aborted")
5997
+ return INVALID;
5998
+ if (result.status === "dirty")
5999
+ return DIRTY(result.value);
6000
+ if (status.value === "dirty")
6001
+ return DIRTY(result.value);
6002
+ return result;
6003
+ });
6004
+ } else {
6005
+ if (status.value === "aborted")
6006
+ return INVALID;
6007
+ const result = this._def.schema._parseSync({
6008
+ data: processed,
6009
+ path: ctx.path,
6010
+ parent: ctx
6011
+ });
6012
+ if (result.status === "aborted")
6013
+ return INVALID;
6014
+ if (result.status === "dirty")
6015
+ return DIRTY(result.value);
6016
+ if (status.value === "dirty")
6017
+ return DIRTY(result.value);
6018
+ return result;
6019
+ }
6020
+ }
6021
+ if (effect.type === "refinement") {
6022
+ const executeRefinement = (acc) => {
6023
+ const result = effect.refinement(acc, checkCtx);
6024
+ if (ctx.common.async) {
6025
+ return Promise.resolve(result);
6026
+ }
6027
+ if (result instanceof Promise) {
6028
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
6029
+ }
6030
+ return acc;
6031
+ };
6032
+ if (ctx.common.async === false) {
6033
+ const inner = this._def.schema._parseSync({
6034
+ data: ctx.data,
6035
+ path: ctx.path,
6036
+ parent: ctx
6037
+ });
6038
+ if (inner.status === "aborted")
6039
+ return INVALID;
6040
+ if (inner.status === "dirty")
6041
+ status.dirty();
6042
+ executeRefinement(inner.value);
6043
+ return { status: status.value, value: inner.value };
6044
+ } else {
6045
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
6046
+ if (inner.status === "aborted")
6047
+ return INVALID;
6048
+ if (inner.status === "dirty")
6049
+ status.dirty();
6050
+ return executeRefinement(inner.value).then(() => {
6051
+ return { status: status.value, value: inner.value };
6052
+ });
6053
+ });
6054
+ }
6055
+ }
6056
+ if (effect.type === "transform") {
6057
+ if (ctx.common.async === false) {
6058
+ const base = this._def.schema._parseSync({
6059
+ data: ctx.data,
6060
+ path: ctx.path,
6061
+ parent: ctx
6062
+ });
6063
+ if (!isValid(base))
6064
+ return INVALID;
6065
+ const result = effect.transform(base.value, checkCtx);
6066
+ if (result instanceof Promise) {
6067
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
6068
+ }
6069
+ return { status: status.value, value: result };
6070
+ } else {
6071
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
6072
+ if (!isValid(base))
6073
+ return INVALID;
6074
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
6075
+ status: status.value,
6076
+ value: result
6077
+ }));
6078
+ });
6079
+ }
6080
+ }
6081
+ util.assertNever(effect);
6082
+ }
6083
+ };
6084
+ ZodEffects.create = (schema, effect, params) => {
6085
+ return new ZodEffects({
6086
+ schema,
6087
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
6088
+ effect,
6089
+ ...processCreateParams(params)
6090
+ });
6091
+ };
6092
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
6093
+ return new ZodEffects({
6094
+ schema,
6095
+ effect: { type: "preprocess", transform: preprocess },
6096
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
6097
+ ...processCreateParams(params)
6098
+ });
6099
+ };
6100
+ var ZodOptional = class extends ZodType {
6101
+ _parse(input) {
6102
+ const parsedType = this._getType(input);
6103
+ if (parsedType === ZodParsedType.undefined) {
6104
+ return OK(void 0);
6105
+ }
6106
+ return this._def.innerType._parse(input);
6107
+ }
6108
+ unwrap() {
6109
+ return this._def.innerType;
6110
+ }
6111
+ };
6112
+ ZodOptional.create = (type, params) => {
6113
+ return new ZodOptional({
6114
+ innerType: type,
6115
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
6116
+ ...processCreateParams(params)
6117
+ });
6118
+ };
6119
+ var ZodNullable = class extends ZodType {
6120
+ _parse(input) {
6121
+ const parsedType = this._getType(input);
6122
+ if (parsedType === ZodParsedType.null) {
6123
+ return OK(null);
6124
+ }
6125
+ return this._def.innerType._parse(input);
6126
+ }
6127
+ unwrap() {
6128
+ return this._def.innerType;
6129
+ }
6130
+ };
6131
+ ZodNullable.create = (type, params) => {
6132
+ return new ZodNullable({
6133
+ innerType: type,
6134
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
6135
+ ...processCreateParams(params)
6136
+ });
6137
+ };
6138
+ var ZodDefault = class extends ZodType {
6139
+ _parse(input) {
6140
+ const { ctx } = this._processInputParams(input);
6141
+ let data = ctx.data;
6142
+ if (ctx.parsedType === ZodParsedType.undefined) {
6143
+ data = this._def.defaultValue();
6144
+ }
6145
+ return this._def.innerType._parse({
6146
+ data,
6147
+ path: ctx.path,
6148
+ parent: ctx
6149
+ });
6150
+ }
6151
+ removeDefault() {
6152
+ return this._def.innerType;
6153
+ }
6154
+ };
6155
+ ZodDefault.create = (type, params) => {
6156
+ return new ZodDefault({
6157
+ innerType: type,
6158
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
6159
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
6160
+ ...processCreateParams(params)
6161
+ });
6162
+ };
6163
+ var ZodCatch = class extends ZodType {
6164
+ _parse(input) {
6165
+ const { ctx } = this._processInputParams(input);
6166
+ const newCtx = {
6167
+ ...ctx,
6168
+ common: {
6169
+ ...ctx.common,
6170
+ issues: []
6171
+ }
6172
+ };
6173
+ const result = this._def.innerType._parse({
6174
+ data: newCtx.data,
6175
+ path: newCtx.path,
6176
+ parent: {
6177
+ ...newCtx
6178
+ }
6179
+ });
6180
+ if (isAsync(result)) {
6181
+ return result.then((result2) => {
6182
+ return {
6183
+ status: "valid",
6184
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
6185
+ get error() {
6186
+ return new ZodError(newCtx.common.issues);
6187
+ },
6188
+ input: newCtx.data
6189
+ })
6190
+ };
6191
+ });
6192
+ } else {
6193
+ return {
6194
+ status: "valid",
6195
+ value: result.status === "valid" ? result.value : this._def.catchValue({
6196
+ get error() {
6197
+ return new ZodError(newCtx.common.issues);
6198
+ },
6199
+ input: newCtx.data
6200
+ })
6201
+ };
6202
+ }
6203
+ }
6204
+ removeCatch() {
6205
+ return this._def.innerType;
6206
+ }
6207
+ };
6208
+ ZodCatch.create = (type, params) => {
6209
+ return new ZodCatch({
6210
+ innerType: type,
6211
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
6212
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
6213
+ ...processCreateParams(params)
6214
+ });
6215
+ };
6216
+ var ZodNaN = class extends ZodType {
6217
+ _parse(input) {
6218
+ const parsedType = this._getType(input);
6219
+ if (parsedType !== ZodParsedType.nan) {
6220
+ const ctx = this._getOrReturnCtx(input);
6221
+ addIssueToContext(ctx, {
6222
+ code: ZodIssueCode.invalid_type,
6223
+ expected: ZodParsedType.nan,
6224
+ received: ctx.parsedType
6225
+ });
6226
+ return INVALID;
6227
+ }
6228
+ return { status: "valid", value: input.data };
6229
+ }
6230
+ };
6231
+ ZodNaN.create = (params) => {
6232
+ return new ZodNaN({
6233
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
6234
+ ...processCreateParams(params)
6235
+ });
6236
+ };
6237
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
6238
+ var ZodBranded = class extends ZodType {
6239
+ _parse(input) {
6240
+ const { ctx } = this._processInputParams(input);
6241
+ const data = ctx.data;
6242
+ return this._def.type._parse({
6243
+ data,
6244
+ path: ctx.path,
6245
+ parent: ctx
6246
+ });
6247
+ }
6248
+ unwrap() {
6249
+ return this._def.type;
6250
+ }
6251
+ };
6252
+ var ZodPipeline = class _ZodPipeline extends ZodType {
6253
+ _parse(input) {
6254
+ const { status, ctx } = this._processInputParams(input);
6255
+ if (ctx.common.async) {
6256
+ const handleAsync = async () => {
6257
+ const inResult = await this._def.in._parseAsync({
6258
+ data: ctx.data,
6259
+ path: ctx.path,
6260
+ parent: ctx
6261
+ });
6262
+ if (inResult.status === "aborted")
6263
+ return INVALID;
6264
+ if (inResult.status === "dirty") {
6265
+ status.dirty();
6266
+ return DIRTY(inResult.value);
6267
+ } else {
6268
+ return this._def.out._parseAsync({
6269
+ data: inResult.value,
6270
+ path: ctx.path,
6271
+ parent: ctx
6272
+ });
6273
+ }
6274
+ };
6275
+ return handleAsync();
6276
+ } else {
6277
+ const inResult = this._def.in._parseSync({
6278
+ data: ctx.data,
6279
+ path: ctx.path,
6280
+ parent: ctx
6281
+ });
6282
+ if (inResult.status === "aborted")
6283
+ return INVALID;
6284
+ if (inResult.status === "dirty") {
6285
+ status.dirty();
6286
+ return {
6287
+ status: "dirty",
6288
+ value: inResult.value
6289
+ };
6290
+ } else {
6291
+ return this._def.out._parseSync({
6292
+ data: inResult.value,
6293
+ path: ctx.path,
6294
+ parent: ctx
6295
+ });
6296
+ }
6297
+ }
6298
+ }
6299
+ static create(a4, b) {
6300
+ return new _ZodPipeline({
6301
+ in: a4,
6302
+ out: b,
6303
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
6304
+ });
6305
+ }
6306
+ };
6307
+ var ZodReadonly = class extends ZodType {
6308
+ _parse(input) {
6309
+ const result = this._def.innerType._parse(input);
6310
+ const freeze = (data) => {
6311
+ if (isValid(data)) {
6312
+ data.value = Object.freeze(data.value);
6313
+ }
6314
+ return data;
6315
+ };
6316
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
6317
+ }
6318
+ unwrap() {
6319
+ return this._def.innerType;
6320
+ }
6321
+ };
6322
+ ZodReadonly.create = (type, params) => {
6323
+ return new ZodReadonly({
6324
+ innerType: type,
6325
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
6326
+ ...processCreateParams(params)
6327
+ });
6328
+ };
6329
+ function cleanParams(params, data) {
6330
+ const p2 = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
6331
+ const p22 = typeof p2 === "string" ? { message: p2 } : p2;
6332
+ return p22;
6333
+ }
6334
+ function custom(check, _params = {}, fatal) {
6335
+ if (check)
6336
+ return ZodAny.create().superRefine((data, ctx) => {
6337
+ const r2 = check(data);
6338
+ if (r2 instanceof Promise) {
6339
+ return r2.then((r3) => {
6340
+ if (!r3) {
6341
+ const params = cleanParams(_params, data);
6342
+ const _fatal = params.fatal ?? fatal ?? true;
6343
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
6344
+ }
6345
+ });
6346
+ }
6347
+ if (!r2) {
6348
+ const params = cleanParams(_params, data);
6349
+ const _fatal = params.fatal ?? fatal ?? true;
6350
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
6351
+ }
6352
+ return;
6353
+ });
6354
+ return ZodAny.create();
6355
+ }
6356
+ var late = {
6357
+ object: ZodObject.lazycreate
6358
+ };
6359
+ var ZodFirstPartyTypeKind;
6360
+ (function(ZodFirstPartyTypeKind2) {
6361
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
6362
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
6363
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
6364
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
6365
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
6366
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
6367
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
6368
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
6369
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
6370
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
6371
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
6372
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
6373
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
6374
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
6375
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
6376
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
6377
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
6378
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
6379
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
6380
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
6381
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
6382
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
6383
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
6384
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
6385
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
6386
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
6387
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
6388
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
6389
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
6390
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
6391
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
6392
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
6393
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
6394
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
6395
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
6396
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
6397
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
6398
+ var instanceOfType = (cls, params = {
6399
+ message: `Input not instance of ${cls.name}`
6400
+ }) => custom((data) => data instanceof cls, params);
6401
+ var stringType = ZodString.create;
6402
+ var numberType = ZodNumber.create;
6403
+ var nanType = ZodNaN.create;
6404
+ var bigIntType = ZodBigInt.create;
6405
+ var booleanType = ZodBoolean.create;
6406
+ var dateType = ZodDate.create;
6407
+ var symbolType = ZodSymbol.create;
6408
+ var undefinedType = ZodUndefined.create;
6409
+ var nullType = ZodNull.create;
6410
+ var anyType = ZodAny.create;
6411
+ var unknownType = ZodUnknown.create;
6412
+ var neverType = ZodNever.create;
6413
+ var voidType = ZodVoid.create;
6414
+ var arrayType = ZodArray.create;
6415
+ var objectType = ZodObject.create;
6416
+ var strictObjectType = ZodObject.strictCreate;
6417
+ var unionType = ZodUnion.create;
6418
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
6419
+ var intersectionType = ZodIntersection.create;
6420
+ var tupleType = ZodTuple.create;
6421
+ var recordType = ZodRecord.create;
6422
+ var mapType = ZodMap.create;
6423
+ var setType = ZodSet.create;
6424
+ var functionType = ZodFunction.create;
6425
+ var lazyType = ZodLazy.create;
6426
+ var literalType = ZodLiteral.create;
6427
+ var enumType = ZodEnum.create;
6428
+ var nativeEnumType = ZodNativeEnum.create;
6429
+ var promiseType = ZodPromise.create;
6430
+ var effectsType = ZodEffects.create;
6431
+ var optionalType = ZodOptional.create;
6432
+ var nullableType = ZodNullable.create;
6433
+ var preprocessType = ZodEffects.createWithPreprocess;
6434
+ var pipelineType = ZodPipeline.create;
6435
+ var ostring = () => stringType().optional();
6436
+ var onumber = () => numberType().optional();
6437
+ var oboolean = () => booleanType().optional();
6438
+ var coerce = {
6439
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
6440
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
6441
+ boolean: ((arg) => ZodBoolean.create({
6442
+ ...arg,
6443
+ coerce: true
6444
+ })),
6445
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
6446
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
6447
+ };
6448
+ var NEVER = INVALID;
6449
+
6450
+ // node_modules/.pnpm/@x402+core@2.17.0/node_modules/@x402/core/dist/esm/chunk-FPXAE3OS.mjs
6451
+ var NonEmptyString = external_exports.string().min(1);
6452
+ var Any = external_exports.record(external_exports.unknown());
6453
+ var OptionalAny = external_exports.record(external_exports.unknown()).optional().nullable();
6454
+ var NetworkSchemaV1 = NonEmptyString;
6455
+ var NetworkSchemaV2 = external_exports.string().min(3).refine((val) => val.includes(":"), {
6456
+ message: "Network must be in CAIP-2 format (e.g., 'eip155:84532')"
6457
+ });
6458
+ var NetworkSchema = external_exports.union([NetworkSchemaV1, NetworkSchemaV2]);
6459
+ var PRINTABLE_ASCII_REGEX = /^[\x20-\x7e]+$/;
6460
+ var ResourceInfoSchema = external_exports.object({
6461
+ url: NonEmptyString,
6462
+ description: external_exports.string().optional(),
6463
+ mimeType: external_exports.string().optional(),
6464
+ serviceName: external_exports.string().min(1).max(32).regex(PRINTABLE_ASCII_REGEX).optional(),
6465
+ tags: external_exports.array(external_exports.string().min(1).max(32).regex(PRINTABLE_ASCII_REGEX)).max(5).optional(),
6466
+ iconUrl: external_exports.string().max(2048).optional()
6467
+ });
6468
+ var PaymentRequirementsV1Schema = external_exports.object({
6469
+ scheme: NonEmptyString,
6470
+ network: NetworkSchemaV1,
6471
+ maxAmountRequired: NonEmptyString,
6472
+ resource: NonEmptyString,
6473
+ // URL string in V1
6474
+ description: external_exports.string(),
6475
+ mimeType: external_exports.string().optional(),
6476
+ outputSchema: Any.optional().nullable(),
6477
+ payTo: NonEmptyString,
6478
+ maxTimeoutSeconds: external_exports.number().positive(),
6479
+ asset: NonEmptyString,
6480
+ extra: OptionalAny
6481
+ });
6482
+ var PaymentRequiredV1Schema = external_exports.object({
6483
+ x402Version: external_exports.literal(1),
6484
+ error: external_exports.string().optional(),
6485
+ accepts: external_exports.array(PaymentRequirementsV1Schema).min(1)
6486
+ });
6487
+ var PaymentPayloadV1Schema = external_exports.object({
6488
+ x402Version: external_exports.literal(1),
6489
+ scheme: NonEmptyString,
6490
+ network: NetworkSchemaV1,
6491
+ payload: Any
6492
+ });
6493
+ var PaymentRequirementsV2Schema = external_exports.object({
6494
+ scheme: NonEmptyString,
6495
+ network: NetworkSchemaV2,
6496
+ amount: NonEmptyString,
6497
+ asset: NonEmptyString,
6498
+ payTo: NonEmptyString,
6499
+ maxTimeoutSeconds: external_exports.number().positive(),
6500
+ extra: OptionalAny
6501
+ });
6502
+ var PaymentRequiredV2Schema = external_exports.object({
6503
+ x402Version: external_exports.literal(2),
6504
+ error: external_exports.string().optional(),
6505
+ resource: ResourceInfoSchema,
6506
+ accepts: external_exports.array(PaymentRequirementsV2Schema).min(1),
6507
+ extensions: OptionalAny
6508
+ });
6509
+ var PaymentPayloadV2Schema = external_exports.object({
6510
+ x402Version: external_exports.literal(2),
6511
+ resource: ResourceInfoSchema.optional(),
6512
+ accepted: PaymentRequirementsV2Schema,
6513
+ payload: Any,
6514
+ extensions: OptionalAny
6515
+ });
6516
+ var PaymentRequirementsSchema = external_exports.union([
6517
+ PaymentRequirementsV1Schema,
6518
+ PaymentRequirementsV2Schema
6519
+ ]);
6520
+ var PaymentRequiredSchema = external_exports.discriminatedUnion("x402Version", [
6521
+ PaymentRequiredV1Schema,
6522
+ PaymentRequiredV2Schema
6523
+ ]);
6524
+ var PaymentPayloadSchema = external_exports.discriminatedUnion("x402Version", [
6525
+ PaymentPayloadV1Schema,
6526
+ PaymentPayloadV2Schema
6527
+ ]);
6528
+
6529
+ // node_modules/.pnpm/@x402+core@2.17.0/node_modules/@x402/core/dist/esm/chunk-VE37GDG2.mjs
6530
+ var x402Version = 2;
6531
+
6532
+ // node_modules/.pnpm/@x402+core@2.17.0/node_modules/@x402/core/dist/esm/chunk-AGOUMC4P.mjs
6533
+ var VerifyError = class extends Error {
6534
+ /**
6535
+ * Creates a VerifyError from a failed verification response.
6536
+ *
6537
+ * @param statusCode - HTTP status code from the facilitator
6538
+ * @param response - The verify response containing failure details
6539
+ */
6540
+ constructor(statusCode, response) {
6541
+ const reason = response.invalidReason || "unknown reason";
6542
+ const message = response.invalidMessage;
6543
+ super(message ? `${reason}: ${message}` : reason);
6544
+ this.name = "VerifyError";
6545
+ this.statusCode = statusCode;
6546
+ this.invalidReason = response.invalidReason;
6547
+ this.invalidMessage = response.invalidMessage;
6548
+ this.payer = response.payer;
6549
+ }
6550
+ };
6551
+ var SettleError = class extends Error {
6552
+ /**
6553
+ * Creates a SettleError from a failed settlement response.
6554
+ *
6555
+ * @param statusCode - HTTP status code from the facilitator
6556
+ * @param response - The settle response containing error details
6557
+ */
6558
+ constructor(statusCode, response) {
6559
+ const reason = response.errorReason || "unknown reason";
6560
+ const message = response.errorMessage;
6561
+ super(message ? `${reason}: ${message}` : reason);
6562
+ this.name = "SettleError";
6563
+ this.statusCode = statusCode;
6564
+ this.errorReason = response.errorReason;
6565
+ this.errorMessage = response.errorMessage;
6566
+ this.payer = response.payer;
6567
+ this.transaction = response.transaction;
6568
+ this.network = response.network;
6569
+ }
6570
+ };
6571
+ var FacilitatorResponseError = class extends Error {
6572
+ /**
6573
+ * Creates a FacilitatorResponseError for malformed facilitator responses.
6574
+ *
6575
+ * @param message - The boundary error message
6576
+ */
6577
+ constructor(message) {
6578
+ super(message);
6579
+ this.name = "FacilitatorResponseError";
6580
+ }
6581
+ };
6582
+
6583
+ // node_modules/.pnpm/@x402+core@2.17.0/node_modules/@x402/core/dist/esm/chunk-ABS7D6VX.mjs
6584
+ var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6585
+ var networkPatternToRegExp = (pattern) => {
6586
+ const source = escapeRegExp(pattern).replace(/\\\*/g, ".*");
6587
+ return new RegExp(`^${source}$`);
6588
+ };
6589
+ var networkMatchesPattern = (pattern, network) => {
6590
+ return networkPatternToRegExp(pattern).test(network);
6591
+ };
6592
+ var findSchemesByNetwork = (map, network) => {
6593
+ let implementationsByScheme = map.get(network);
6594
+ if (!implementationsByScheme) {
6595
+ for (const [registeredNetworkPattern, implementations] of map.entries()) {
6596
+ if (networkMatchesPattern(registeredNetworkPattern, network)) {
6597
+ implementationsByScheme = implementations;
6598
+ break;
6599
+ }
6600
+ }
6601
+ }
6602
+ return implementationsByScheme;
6603
+ };
6604
+ var findByNetworkAndScheme = (map, scheme, network) => {
6605
+ return findSchemesByNetwork(map, network)?.get(scheme);
6606
+ };
6607
+ var Base64EncodedRegex = /^[A-Za-z0-9+/]*={0,2}$/;
6608
+ function safeBase64Encode(data) {
6609
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
6610
+ const bytes = new TextEncoder().encode(data);
6611
+ const binaryString = Array.from(bytes, (byte) => String.fromCharCode(byte)).join("");
6612
+ return globalThis.btoa(binaryString);
6613
+ }
6614
+ return Buffer.from(data, "utf8").toString("base64");
6615
+ }
6616
+ function safeBase64Decode(data) {
6617
+ if (typeof globalThis !== "undefined" && typeof globalThis.atob === "function") {
6618
+ const binaryString = globalThis.atob(data);
6619
+ const bytes = new Uint8Array(binaryString.length);
6620
+ for (let i3 = 0; i3 < binaryString.length; i3++) {
6621
+ bytes[i3] = binaryString.charCodeAt(i3);
6622
+ }
6623
+ const decoder = new TextDecoder("utf-8");
6624
+ return decoder.decode(bytes);
6625
+ }
6626
+ return Buffer.from(data, "base64").toString("utf-8");
6627
+ }
6628
+
6629
+ // node_modules/.pnpm/@x402+core@2.17.0/node_modules/@x402/core/dist/esm/chunk-YEYZQZNL.mjs
6630
+ var DEFAULT_FACILITATOR_URL = "https://x402.org/facilitator";
6631
+ var GET_SUPPORTED_RETRIES = 3;
6632
+ var GET_SUPPORTED_RETRY_DELAY_MS = 1e3;
6633
+ var MAX_RETRY_DELAY_MS = 3e4;
6634
+ function computeRetryDelay(retryAfter, attempt) {
6635
+ let delay = null;
6636
+ if (retryAfter !== null) {
6637
+ const trimmedRetryAfter = retryAfter.trim();
6638
+ if (/^\d+$/.test(trimmedRetryAfter)) {
6639
+ delay = Number(trimmedRetryAfter) * 1e3;
6640
+ } else {
6641
+ const retryDate = Date.parse(retryAfter);
6642
+ if (!isNaN(retryDate)) {
6643
+ delay = retryDate - Date.now();
6644
+ }
6645
+ }
6646
+ }
6647
+ if (delay === null || delay <= 0) {
6648
+ delay = GET_SUPPORTED_RETRY_DELAY_MS * Math.pow(2, attempt);
6649
+ }
6650
+ return Math.min(delay, MAX_RETRY_DELAY_MS);
6651
+ }
6652
+ var verifyResponseSchema = external_exports.object({
6653
+ isValid: external_exports.boolean(),
6654
+ invalidReason: external_exports.string().nullish().transform((v) => v ?? void 0),
6655
+ invalidMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
6656
+ payer: external_exports.string().nullish().transform((v) => v ?? void 0),
6657
+ extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0),
6658
+ extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
6659
+ });
6660
+ var settleResponseSchema = external_exports.object({
6661
+ success: external_exports.boolean(),
6662
+ errorReason: external_exports.string().nullish().transform((v) => v ?? void 0),
6663
+ errorMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
6664
+ payer: external_exports.string().nullish().transform((v) => v ?? void 0),
6665
+ transaction: external_exports.string(),
6666
+ network: external_exports.custom((value) => typeof value === "string"),
6667
+ amount: external_exports.string().nullish().transform((v) => v ?? void 0),
6668
+ extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0),
6669
+ extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
6670
+ });
6671
+ var supportedKindSchema = external_exports.object({
6672
+ x402Version: external_exports.number(),
6673
+ scheme: external_exports.string(),
6674
+ network: external_exports.custom(
6675
+ (value) => typeof value === "string"
6676
+ ),
6677
+ extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
6678
+ });
6679
+ var supportedResponseSchema = external_exports.object({
6680
+ kinds: external_exports.array(supportedKindSchema),
6681
+ extensions: external_exports.array(external_exports.string()).default([]),
6682
+ signers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).default({})
6683
+ });
6684
+ function responseExcerpt(text, limit = 200) {
6685
+ const compact = text.trim().replace(/\s+/g, " ");
6686
+ if (!compact) {
6687
+ return "<empty response>";
6688
+ }
6689
+ if (compact.length <= limit) {
6690
+ return compact;
6691
+ }
6692
+ return `${compact.slice(0, limit - 3)}...`;
6693
+ }
6694
+ var EXTENSION_RESPONSE_LOG_FIELD_ALLOWLIST = ["status", "rejectedReason", "reason", "code"];
6695
+ function logExtensionResponsesHeader(response) {
6696
+ const header = response.headers.get("EXTENSION-RESPONSES");
6697
+ if (!header) return;
6698
+ try {
6699
+ const decoded = JSON.parse(safeBase64Decode(header));
6700
+ if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) return;
6701
+ const sanitized = {};
6702
+ for (const [extensionKey, payload] of Object.entries(decoded)) {
6703
+ const source = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
6704
+ const filtered = {};
6705
+ for (const key of EXTENSION_RESPONSE_LOG_FIELD_ALLOWLIST) {
6706
+ if (source[key] !== void 0) {
6707
+ filtered[key] = source[key];
6708
+ }
6709
+ }
6710
+ sanitized[extensionKey] = filtered;
6711
+ }
6712
+ console.log(`[x402] extension responses: ${JSON.stringify(sanitized)}`);
6713
+ } catch {
6714
+ }
6715
+ }
6716
+ async function parseSuccessResponse(response, schema, operation) {
6717
+ const text = await response.text();
6718
+ let data;
6719
+ try {
6720
+ data = JSON.parse(text);
6721
+ } catch {
6722
+ throw new FacilitatorResponseError(
6723
+ `Facilitator ${operation} returned invalid JSON: ${responseExcerpt(text)}`
6724
+ );
6725
+ }
6726
+ const parsed = schema.safeParse(data);
6727
+ if (!parsed.success) {
6728
+ throw new FacilitatorResponseError(
6729
+ `Facilitator ${operation} returned invalid data: ${responseExcerpt(text)}`
6730
+ );
6731
+ }
6732
+ return parsed.data;
6733
+ }
6734
+ var HTTPFacilitatorClient = class {
6735
+ /**
6736
+ * Creates a new HTTPFacilitatorClient instance.
6737
+ *
6738
+ * @param config - Configuration options for the facilitator client
6739
+ */
6740
+ constructor(config) {
6741
+ this.url = (config?.url || DEFAULT_FACILITATOR_URL).replace(/\/+$/, "");
6742
+ this._createAuthHeaders = config?.createAuthHeaders;
6743
+ }
6744
+ /**
6745
+ * Verify a payment with the facilitator
6746
+ *
6747
+ * @param paymentPayload - The payment to verify
6748
+ * @param paymentRequirements - The requirements to verify against
6749
+ * @returns Verification response
6750
+ */
6751
+ async verify(paymentPayload, paymentRequirements) {
6752
+ let headers = {
6753
+ "Content-Type": "application/json"
6754
+ };
6755
+ if (this._createAuthHeaders) {
6756
+ const authHeaders = await this.createAuthHeaders("verify");
6757
+ headers = { ...headers, ...authHeaders.headers };
6758
+ }
6759
+ const response = await fetch(`${this.url}/verify`, {
6760
+ method: "POST",
6761
+ headers,
6762
+ redirect: "follow",
6763
+ body: JSON.stringify({
6764
+ x402Version: paymentPayload.x402Version,
6765
+ paymentPayload: this.toJsonSafe(paymentPayload),
6766
+ paymentRequirements: this.toJsonSafe(paymentRequirements)
6767
+ })
6768
+ });
6769
+ if (!response.ok) {
6770
+ const text = await response.text();
6771
+ let data;
6772
+ try {
6773
+ data = JSON.parse(text);
6774
+ } catch {
6775
+ throw new Error(`Facilitator verify failed (${response.status}): ${responseExcerpt(text)}`);
6776
+ }
6777
+ if (typeof data === "object" && data !== null && "isValid" in data) {
6778
+ throw new VerifyError(response.status, data);
6779
+ }
6780
+ throw new Error(
6781
+ `Facilitator verify failed (${response.status}): ${responseExcerpt(JSON.stringify(data))}`
6782
+ );
6783
+ }
6784
+ const verifyResult = await parseSuccessResponse(response, verifyResponseSchema, "verify");
6785
+ logExtensionResponsesHeader(response);
6786
+ return verifyResult;
6787
+ }
6788
+ /**
6789
+ * Settle a payment with the facilitator
6790
+ *
6791
+ * @param paymentPayload - The payment to settle
6792
+ * @param paymentRequirements - The requirements for settlement
6793
+ * @returns Settlement response
6794
+ */
6795
+ async settle(paymentPayload, paymentRequirements) {
6796
+ let headers = {
6797
+ "Content-Type": "application/json"
6798
+ };
6799
+ if (this._createAuthHeaders) {
6800
+ const authHeaders = await this.createAuthHeaders("settle");
6801
+ headers = { ...headers, ...authHeaders.headers };
6802
+ }
6803
+ const response = await fetch(`${this.url}/settle`, {
6804
+ method: "POST",
6805
+ headers,
6806
+ redirect: "follow",
6807
+ body: JSON.stringify({
6808
+ x402Version: paymentPayload.x402Version,
6809
+ paymentPayload: this.toJsonSafe(paymentPayload),
6810
+ paymentRequirements: this.toJsonSafe(paymentRequirements)
6811
+ })
6812
+ });
6813
+ if (!response.ok) {
6814
+ const text = await response.text();
6815
+ let data;
6816
+ try {
6817
+ data = JSON.parse(text);
6818
+ } catch {
6819
+ throw new Error(`Facilitator settle failed (${response.status}): ${responseExcerpt(text)}`);
6820
+ }
6821
+ if (typeof data === "object" && data !== null && "success" in data) {
6822
+ throw new SettleError(response.status, data);
6823
+ }
6824
+ throw new Error(
6825
+ `Facilitator settle failed (${response.status}): ${responseExcerpt(JSON.stringify(data))}`
6826
+ );
6827
+ }
6828
+ const settleResult = await parseSuccessResponse(response, settleResponseSchema, "settle");
6829
+ logExtensionResponsesHeader(response);
6830
+ return settleResult;
6831
+ }
6832
+ /**
6833
+ * Get supported payment kinds and extensions from the facilitator.
6834
+ * Retries with exponential backoff on 429 rate limit errors.
6835
+ *
6836
+ * @returns Supported payment kinds and extensions
6837
+ */
6838
+ async getSupported() {
6839
+ let headers = {
6840
+ "Content-Type": "application/json"
6841
+ };
6842
+ if (this._createAuthHeaders) {
6843
+ const authHeaders = await this.createAuthHeaders("supported");
6844
+ headers = { ...headers, ...authHeaders.headers };
6845
+ }
6846
+ let lastError = null;
6847
+ for (let attempt = 0; attempt < GET_SUPPORTED_RETRIES; attempt++) {
6848
+ const response = await fetch(`${this.url}/supported`, {
6849
+ method: "GET",
6850
+ headers,
6851
+ redirect: "follow"
6852
+ });
6853
+ if (response.ok) {
6854
+ return parseSuccessResponse(response, supportedResponseSchema, "supported");
6855
+ }
6856
+ const errorText = await response.text().catch(() => response.statusText);
6857
+ lastError = new Error(
6858
+ `Facilitator getSupported failed (${response.status}): ${responseExcerpt(errorText)}`
6859
+ );
6860
+ if (response.status === 429 && attempt < GET_SUPPORTED_RETRIES - 1) {
6861
+ const delay = computeRetryDelay(response.headers.get("Retry-After"), attempt);
6862
+ await new Promise((resolve) => setTimeout(resolve, delay));
6863
+ continue;
6864
+ }
6865
+ throw lastError;
6866
+ }
6867
+ throw lastError ?? new Error("Facilitator getSupported failed after retries");
6868
+ }
6869
+ /**
6870
+ * Creates authentication headers for a specific path.
6871
+ *
6872
+ * @param path - The path to create authentication headers for (e.g., "verify", "settle", "supported")
6873
+ * @returns An object containing the authentication headers for the specified path
6874
+ */
6875
+ async createAuthHeaders(path) {
6876
+ if (this._createAuthHeaders) {
6877
+ const authHeaders = await this._createAuthHeaders();
6878
+ return {
6879
+ headers: authHeaders[path] ?? {}
6880
+ };
6881
+ }
6882
+ return {
6883
+ headers: {}
6884
+ };
6885
+ }
6886
+ /**
6887
+ * Helper to convert objects to JSON-safe format.
6888
+ * Handles BigInt and other non-JSON types.
6889
+ *
6890
+ * @param obj - The object to convert
6891
+ * @returns The JSON-safe representation of the object
6892
+ */
6893
+ toJsonSafe(obj) {
6894
+ return JSON.parse(
6895
+ JSON.stringify(obj, (_, value) => typeof value === "bigint" ? value.toString() : value)
6896
+ );
6897
+ }
6898
+ };
6899
+ var x402HTTPClient = class {
6900
+ /**
6901
+ * Creates a new x402HTTPClient instance.
6902
+ *
6903
+ * @param client - The underlying x402Client for payment logic
6904
+ */
6905
+ constructor(client) {
6906
+ this.client = client;
6907
+ this.paymentRequiredHooks = [];
6908
+ }
6909
+ /**
6910
+ * Register a hook to handle 402 responses before payment.
6911
+ * Hooks run in order; first to return headers wins.
6912
+ *
6913
+ * @param hook - The hook function to register
6914
+ * @returns This instance for chaining
6915
+ */
6916
+ onPaymentRequired(hook) {
6917
+ this.paymentRequiredHooks.push(hook);
6918
+ return this;
6919
+ }
6920
+ /**
6921
+ * Run hooks and return headers if any hook provides them.
6922
+ *
6923
+ * @param paymentRequired - The payment required response from the server
6924
+ * @returns Headers to use for retry, or null to proceed to payment
6925
+ */
6926
+ async handlePaymentRequired(paymentRequired) {
6927
+ for (const hook of this.getPaymentRequiredHooks(paymentRequired)) {
6928
+ const result = await hook({ paymentRequired });
6929
+ if (result?.headers) {
6930
+ return result.headers;
6931
+ }
6932
+ }
6933
+ return null;
6934
+ }
6935
+ /**
6936
+ * Encodes a payment payload into appropriate HTTP headers based on version.
6937
+ *
6938
+ * @param paymentPayload - The payment payload to encode
6939
+ * @returns HTTP headers containing the encoded payment signature
6940
+ */
6941
+ encodePaymentSignatureHeader(paymentPayload) {
6942
+ switch (paymentPayload.x402Version) {
6943
+ case 2:
6944
+ return {
6945
+ "PAYMENT-SIGNATURE": encodePaymentSignatureHeader(paymentPayload)
6946
+ };
6947
+ case 1:
6948
+ return {
6949
+ "X-PAYMENT": encodePaymentSignatureHeader(paymentPayload)
6950
+ };
6951
+ default:
6952
+ throw new Error(
6953
+ `Unsupported x402 version: ${paymentPayload.x402Version}`
6954
+ );
6955
+ }
6956
+ }
6957
+ /**
6958
+ * Extracts payment required information from HTTP response.
6959
+ *
6960
+ * @param getHeader - Function to retrieve header value by name (case-insensitive)
6961
+ * @param body - Optional response body for v1 compatibility
6962
+ * @returns The payment required object
6963
+ */
6964
+ getPaymentRequiredResponse(getHeader, body) {
6965
+ const paymentRequired = getHeader("PAYMENT-REQUIRED");
6966
+ if (paymentRequired) {
6967
+ return decodePaymentRequiredHeader(paymentRequired);
6968
+ }
6969
+ if (body && body instanceof Object && "x402Version" in body && body.x402Version === 1) {
6970
+ return body;
6971
+ }
6972
+ throw new Error("Invalid payment required response");
6973
+ }
6974
+ /**
6975
+ * Extracts payment settlement response from HTTP headers.
6976
+ *
6977
+ * @param getHeader - Function to retrieve header value by name (case-insensitive)
6978
+ * @returns The settlement response object
6979
+ */
6980
+ getPaymentSettleResponse(getHeader) {
6981
+ const paymentResponse = getHeader("PAYMENT-RESPONSE");
6982
+ if (paymentResponse) {
6983
+ return decodePaymentResponseHeader(paymentResponse);
6984
+ }
6985
+ const xPaymentResponse = getHeader("X-PAYMENT-RESPONSE");
6986
+ if (xPaymentResponse) {
6987
+ return decodePaymentResponseHeader(xPaymentResponse);
6988
+ }
6989
+ throw new Error("Payment response header not found");
6990
+ }
6991
+ /**
6992
+ * Creates a payment payload for the given payment requirements.
6993
+ * Delegates to the underlying x402Client.
6994
+ *
6995
+ * @param paymentRequired - The payment required response from the server
6996
+ * @returns Promise resolving to the payment payload
6997
+ */
6998
+ async createPaymentPayload(paymentRequired) {
6999
+ return this.client.createPaymentPayload(paymentRequired);
7000
+ }
7001
+ /**
7002
+ * Parses response headers into protocol types, fires payment response hooks (v2 only),
7003
+ * and returns whether a hook signaled recovery.
7004
+ *
7005
+ * Called by transport wrappers (fetch, axios) after the paid request completes.
7006
+ *
7007
+ * @param paymentPayload - The payload that was sent with the request
7008
+ * @param getHeader - Function to retrieve a response header by name
7009
+ * @param status - The HTTP status code of the response
7010
+ * @returns Whether a hook recovered and the parsed settle response (if any)
7011
+ */
7012
+ async processPaymentResult(paymentPayload, getHeader, status) {
7013
+ let settleResponse;
7014
+ try {
7015
+ settleResponse = this.getPaymentSettleResponse(getHeader);
7016
+ } catch {
7017
+ }
7018
+ if (paymentPayload.x402Version === 1) {
7019
+ return { recovered: false, settleResponse };
7020
+ }
7021
+ let paymentRequired;
7022
+ if (!settleResponse && status === 402) {
7023
+ try {
7024
+ paymentRequired = this.getPaymentRequiredResponse(getHeader);
7025
+ } catch {
7026
+ }
7027
+ }
7028
+ const requirements = paymentPayload.accepted;
7029
+ if (!requirements) {
7030
+ throw new Error("Invalid x402 v2 payment payload: missing `accepted`");
7031
+ }
7032
+ const ctx = {
7033
+ paymentPayload,
7034
+ requirements,
7035
+ ...settleResponse ? { settleResponse } : {},
7036
+ ...paymentRequired ? { paymentRequired } : {}
7037
+ };
7038
+ const result = await this.client.handlePaymentResponse(ctx);
7039
+ return { recovered: result?.recovered === true, settleResponse };
7040
+ }
7041
+ /**
7042
+ * Parses HTTP status, headers, and body into an `HTTPResourceResponse`.
7043
+ *
7044
+ * Decodes the x402 payment header into `header`: the `PAYMENT-RESPONSE`
7045
+ * settlement if present, otherwise the `PAYMENT-REQUIRED` declaration on
7046
+ * 402 responses (whose `error` field carries the server's failure reason).
7047
+ *
7048
+ * @param args - Normalized response inputs from any HTTP transport
7049
+ * @param args.status - HTTP response status code
7050
+ * @param args.getHeader - Callback to read response headers by name
7051
+ * @param args.body - Response body payload
7052
+ * @returns The parsed status, body, and decoded payment header
7053
+ */
7054
+ parsePaymentResult(args) {
7055
+ const { status, getHeader, body } = args;
7056
+ let header;
7057
+ try {
7058
+ header = this.getPaymentSettleResponse(getHeader);
7059
+ } catch {
7060
+ if (status === 402) {
7061
+ try {
7062
+ header = this.getPaymentRequiredResponse(getHeader, body);
7063
+ } catch {
7064
+ }
7065
+ }
7066
+ }
7067
+ let paymentStatus = "none";
7068
+ if (header && !("success" in header)) {
7069
+ paymentStatus = "payment_required";
7070
+ }
7071
+ if (header && "success" in header) {
7072
+ paymentStatus = header.success ? "settled" : "settle_failed";
7073
+ }
7074
+ return { status, paymentStatus, body, header };
7075
+ }
7076
+ /**
7077
+ * Parses a fetch Response into an `HTTPResourceResponse` for app-level convenience.
7078
+ *
7079
+ * @param response - The fetch Response to process
7080
+ * @returns The parsed status, body, and decoded payment header
7081
+ */
7082
+ async processResponse(response) {
7083
+ const getHeader = (name) => response.headers.get(name);
7084
+ const contentType = response.headers.get("content-type") ?? "";
7085
+ const body = contentType.includes("application/json") ? await response.json() : await response.text();
7086
+ return this.parsePaymentResult({ status: response.status, getHeader, body });
7087
+ }
7088
+ /**
7089
+ * Manual HTTP hooks run before extension hooks scoped to the 402 response.
7090
+ *
7091
+ * @param paymentRequired - The payment required response from the server
7092
+ * @returns Hooks in invocation order
7093
+ */
7094
+ getPaymentRequiredHooks(paymentRequired) {
7095
+ const hooks = [...this.paymentRequiredHooks];
7096
+ const declaredExtensions = paymentRequired.extensions;
7097
+ if (!declaredExtensions) return hooks;
7098
+ for (const extension of this.client.getExtensions()) {
7099
+ const httpExtension = extension;
7100
+ const hook = httpExtension.transportHooks?.http?.onPaymentRequired;
7101
+ if (!hook || !(extension.key in declaredExtensions)) continue;
7102
+ hooks.push((context) => hook(declaredExtensions[extension.key], context));
7103
+ }
7104
+ return hooks;
7105
+ }
7106
+ };
7107
+ function encodePaymentSignatureHeader(paymentPayload) {
7108
+ return safeBase64Encode(JSON.stringify(paymentPayload));
7109
+ }
7110
+ function decodePaymentRequiredHeader(paymentRequiredHeader) {
7111
+ if (!Base64EncodedRegex.test(paymentRequiredHeader)) {
7112
+ throw new Error("Invalid payment required header");
7113
+ }
7114
+ return JSON.parse(safeBase64Decode(paymentRequiredHeader));
7115
+ }
7116
+ function decodePaymentResponseHeader(paymentResponseHeader) {
7117
+ if (!Base64EncodedRegex.test(paymentResponseHeader)) {
7118
+ throw new Error("Invalid payment response header");
7119
+ }
7120
+ return JSON.parse(safeBase64Decode(paymentResponseHeader));
7121
+ }
7122
+
2413
7123
  // node_modules/.pnpm/@x402+extensions@2.17.0_typescript@6.0.3/node_modules/@x402/extensions/dist/esm/chunk-LMLJI6VE.mjs
2414
7124
  var import_tweetnacl = __toESM(require_nacl_fast(), 1);
2415
7125
 
@@ -2554,7 +7264,7 @@ function publicKeyToAddress(publicKey) {
2554
7264
  // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@3.25.76/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
2555
7265
  async function recoverPublicKey({ hash: hash2, signature }) {
2556
7266
  const hashHex = isHex(hash2) ? hash2 : toHex(hash2);
2557
- const { secp256k1: secp256k12 } = await import("./secp256k1-XRPVBC6V.js");
7267
+ const { secp256k1: secp256k12 } = await import("./secp256k1-ZZZT2CAX.js");
2558
7268
  const signature_ = (() => {
2559
7269
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
2560
7270
  const { r: r2, s: s5, v, yParity } = signature;
@@ -4695,7 +9405,7 @@ var EnsAvatarUnsupportedNamespaceError = class extends BaseError {
4695
9405
  // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@3.25.76/node_modules/viem/_esm/utils/ens/avatar/utils.js
4696
9406
  var networkRegex = /(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/;
4697
9407
  var ipfsHashRegex = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/;
4698
- var base64Regex = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/;
9408
+ var base64Regex2 = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/;
4699
9409
  var dataURIRegex = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
4700
9410
  async function isImageUri(uri) {
4701
9411
  try {
@@ -4723,15 +9433,15 @@ async function isImageUri(uri) {
4723
9433
  });
4724
9434
  }
4725
9435
  }
4726
- function getGateway(custom, defaultGateway) {
4727
- if (!custom)
9436
+ function getGateway(custom2, defaultGateway) {
9437
+ if (!custom2)
4728
9438
  return defaultGateway;
4729
- if (custom.endsWith("/"))
4730
- return custom.slice(0, -1);
4731
- return custom;
9439
+ if (custom2.endsWith("/"))
9440
+ return custom2.slice(0, -1);
9441
+ return custom2;
4732
9442
  }
4733
9443
  function resolveAvatarUri({ uri, gatewayUrls }) {
4734
- const isEncoded = base64Regex.test(uri);
9444
+ const isEncoded = base64Regex2.test(uri);
4735
9445
  if (isEncoded)
4736
9446
  return { uri, isOnChain: true, isEncoded };
4737
9447
  const ipfsGateway = getGateway(gatewayUrls?.ipfs, "https://ipfs.io");
@@ -9404,7 +14114,7 @@ async function verifySiweMessage(client, parameters) {
9404
14114
  const parsed = parseSiweMessage(message);
9405
14115
  if (!parsed.address)
9406
14116
  return false;
9407
- const isValid = validateSiweMessage({
14117
+ const isValid2 = validateSiweMessage({
9408
14118
  address,
9409
14119
  domain,
9410
14120
  message: parsed,
@@ -9412,7 +14122,7 @@ async function verifySiweMessage(client, parameters) {
9412
14122
  scheme,
9413
14123
  time
9414
14124
  });
9415
- if (!isValid)
14125
+ if (!isValid2)
9416
14126
  return false;
9417
14127
  const hash2 = hashMessage(message);
9418
14128
  return verifyHash(client, {
@@ -9846,7 +14556,7 @@ async function C(e) {
9846
14556
  let { provider: t2 } = e, r2 = c();
9847
14557
  if (r2) {
9848
14558
  if (t2 && !r2.checkContractWalletSignature) {
9849
- let { tryAutoDetectEthers: e2 } = await import("./ethersCompat-Df4a6QIZ-WHYKB6HA.js").then((e3) => e3.n), n2 = await e2(t2);
14559
+ let { tryAutoDetectEthers: e2 } = await import("./ethersCompat-Df4a6QIZ-THAVUGIJ.js").then((e3) => e3.n), n2 = await e2(t2);
9850
14560
  if (n2) return {
9851
14561
  ...r2,
9852
14562
  checkContractWalletSignature: n2.checkContractWalletSignature
@@ -9854,7 +14564,7 @@ async function C(e) {
9854
14564
  }
9855
14565
  return r2;
9856
14566
  }
9857
- let { tryAutoDetectEthers: i3 } = await import("./ethersCompat-Df4a6QIZ-WHYKB6HA.js").then((e2) => e2.n), o = await i3(t2);
14567
+ let { tryAutoDetectEthers: i3 } = await import("./ethersCompat-Df4a6QIZ-THAVUGIJ.js").then((e2) => e2.n), o = await i3(t2);
9858
14568
  if (o) return o;
9859
14569
  throw new r(i2.MISSING_CONFIG, "SiweConfig via configure(), opts.config, or auto-detection", "No config found");
9860
14570
  }
@@ -10154,7 +14864,7 @@ function encodeSIWxHeader(payload) {
10154
14864
  }
10155
14865
 
10156
14866
  // src/lib/siwx.ts
10157
- import { randomUUID } from "crypto";
14867
+ import { randomUUID } from "node:crypto";
10158
14868
  var SIWX_HEADER = "SIGN-IN-WITH-X";
10159
14869
  async function buildSiwxHeader(signer, opts) {
10160
14870
  const url = new URL(opts.baseUrl);
@@ -10183,10 +14893,17 @@ async function buildSiwxHeader(signer, opts) {
10183
14893
  }
10184
14894
 
10185
14895
  export {
14896
+ findSchemesByNetwork,
14897
+ findByNetworkAndScheme,
10186
14898
  createPublicClient,
10187
14899
  http,
14900
+ x402Version,
14901
+ HTTPFacilitatorClient,
14902
+ x402HTTPClient,
14903
+ decodePaymentRequiredHeader,
14904
+ decodePaymentResponseHeader,
10188
14905
  SIGN_IN_WITH_X,
10189
14906
  SIWX_HEADER,
10190
14907
  buildSiwxHeader
10191
14908
  };
10192
- //# sourceMappingURL=chunk-KINZ23CV.js.map
14909
+ //# sourceMappingURL=chunk-3AUDA53C.js.map