storybook 10.1.0-alpha.9 → 10.1.0-beta.0

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 (198) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2908 -8518
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +68 -69
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
  161. package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
  162. package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
  163. package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
  164. package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
  165. package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
  166. package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
  167. package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
  168. package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
  169. package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
  170. package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
  171. package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
  172. package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
  173. package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
  174. package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
  175. package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
  176. package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
  177. package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
  178. package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
  179. package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
  180. package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
  181. package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
  182. package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
  183. package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
  184. package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
  185. package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
  186. package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
  187. package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
  188. package/dist/_node-chunks/dist-SL73W244.js +0 -175
  189. package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
  190. package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
  192. package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
  193. package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
  194. package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
@@ -0,0 +1,3043 @@
1
+ import CJS_COMPAT_NODE_URL_hjmvusgt1gv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_hjmvusgt1gv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_hjmvusgt1gv from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_hjmvusgt1gv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_hjmvusgt1gv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_hjmvusgt1gv.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ invariant
14
+ } from "./chunk-O5CGEVRI.js";
15
+ import {
16
+ require_dist
17
+ } from "./chunk-XGK6MVKR.js";
18
+ import {
19
+ __export,
20
+ __toESM
21
+ } from "./chunk-UFOFO5H7.js";
22
+
23
+ // src/cli/globalSettings.ts
24
+ var import_ts_dedent = __toESM(require_dist(), 1);
25
+ import fs from "node:fs/promises";
26
+ import { homedir } from "node:os";
27
+ import { dirname, join } from "node:path";
28
+
29
+ // ../node_modules/zod/v3/external.js
30
+ var external_exports = {};
31
+ __export(external_exports, {
32
+ BRAND: () => BRAND,
33
+ DIRTY: () => DIRTY,
34
+ EMPTY_PATH: () => EMPTY_PATH,
35
+ INVALID: () => INVALID,
36
+ NEVER: () => NEVER,
37
+ OK: () => OK,
38
+ ParseStatus: () => ParseStatus,
39
+ Schema: () => ZodType,
40
+ ZodAny: () => ZodAny,
41
+ ZodArray: () => ZodArray,
42
+ ZodBigInt: () => ZodBigInt,
43
+ ZodBoolean: () => ZodBoolean,
44
+ ZodBranded: () => ZodBranded,
45
+ ZodCatch: () => ZodCatch,
46
+ ZodDate: () => ZodDate,
47
+ ZodDefault: () => ZodDefault,
48
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
49
+ ZodEffects: () => ZodEffects,
50
+ ZodEnum: () => ZodEnum,
51
+ ZodError: () => ZodError,
52
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
53
+ ZodFunction: () => ZodFunction,
54
+ ZodIntersection: () => ZodIntersection,
55
+ ZodIssueCode: () => ZodIssueCode,
56
+ ZodLazy: () => ZodLazy,
57
+ ZodLiteral: () => ZodLiteral,
58
+ ZodMap: () => ZodMap,
59
+ ZodNaN: () => ZodNaN,
60
+ ZodNativeEnum: () => ZodNativeEnum,
61
+ ZodNever: () => ZodNever,
62
+ ZodNull: () => ZodNull,
63
+ ZodNullable: () => ZodNullable,
64
+ ZodNumber: () => ZodNumber,
65
+ ZodObject: () => ZodObject,
66
+ ZodOptional: () => ZodOptional,
67
+ ZodParsedType: () => ZodParsedType,
68
+ ZodPipeline: () => ZodPipeline,
69
+ ZodPromise: () => ZodPromise,
70
+ ZodReadonly: () => ZodReadonly,
71
+ ZodRecord: () => ZodRecord,
72
+ ZodSchema: () => ZodType,
73
+ ZodSet: () => ZodSet,
74
+ ZodString: () => ZodString,
75
+ ZodSymbol: () => ZodSymbol,
76
+ ZodTransformer: () => ZodEffects,
77
+ ZodTuple: () => ZodTuple,
78
+ ZodType: () => ZodType,
79
+ ZodUndefined: () => ZodUndefined,
80
+ ZodUnion: () => ZodUnion,
81
+ ZodUnknown: () => ZodUnknown,
82
+ ZodVoid: () => ZodVoid,
83
+ addIssueToContext: () => addIssueToContext,
84
+ any: () => anyType,
85
+ array: () => arrayType,
86
+ bigint: () => bigIntType,
87
+ boolean: () => booleanType,
88
+ coerce: () => coerce,
89
+ custom: () => custom,
90
+ date: () => dateType,
91
+ datetimeRegex: () => datetimeRegex,
92
+ defaultErrorMap: () => en_default,
93
+ discriminatedUnion: () => discriminatedUnionType,
94
+ effect: () => effectsType,
95
+ enum: () => enumType,
96
+ function: () => functionType,
97
+ getErrorMap: () => getErrorMap,
98
+ getParsedType: () => getParsedType,
99
+ instanceof: () => instanceOfType,
100
+ intersection: () => intersectionType,
101
+ isAborted: () => isAborted,
102
+ isAsync: () => isAsync,
103
+ isDirty: () => isDirty,
104
+ isValid: () => isValid,
105
+ late: () => late,
106
+ lazy: () => lazyType,
107
+ literal: () => literalType,
108
+ makeIssue: () => makeIssue,
109
+ map: () => mapType,
110
+ nan: () => nanType,
111
+ nativeEnum: () => nativeEnumType,
112
+ never: () => neverType,
113
+ null: () => nullType,
114
+ nullable: () => nullableType,
115
+ number: () => numberType,
116
+ object: () => objectType,
117
+ objectUtil: () => objectUtil,
118
+ oboolean: () => oboolean,
119
+ onumber: () => onumber,
120
+ optional: () => optionalType,
121
+ ostring: () => ostring,
122
+ pipeline: () => pipelineType,
123
+ preprocess: () => preprocessType,
124
+ promise: () => promiseType,
125
+ quotelessJson: () => quotelessJson,
126
+ record: () => recordType,
127
+ set: () => setType,
128
+ setErrorMap: () => setErrorMap,
129
+ strictObject: () => strictObjectType,
130
+ string: () => stringType,
131
+ symbol: () => symbolType,
132
+ transformer: () => effectsType,
133
+ tuple: () => tupleType,
134
+ undefined: () => undefinedType,
135
+ union: () => unionType,
136
+ unknown: () => unknownType,
137
+ util: () => util,
138
+ void: () => voidType
139
+ });
140
+
141
+ // ../node_modules/zod/v3/helpers/util.js
142
+ var util;
143
+ (function(util2) {
144
+ util2.assertEqual = (_) => {
145
+ };
146
+ function assertIs(_arg) {
147
+ }
148
+ util2.assertIs = assertIs;
149
+ function assertNever(_x) {
150
+ throw new Error();
151
+ }
152
+ util2.assertNever = assertNever, util2.arrayToEnum = (items) => {
153
+ let obj = {};
154
+ for (let item of items)
155
+ obj[item] = item;
156
+ return obj;
157
+ }, util2.getValidEnumValues = (obj) => {
158
+ let validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] != "number"), filtered = {};
159
+ for (let k of validKeys)
160
+ filtered[k] = obj[k];
161
+ return util2.objectValues(filtered);
162
+ }, util2.objectValues = (obj) => util2.objectKeys(obj).map(function(e) {
163
+ return obj[e];
164
+ }), util2.objectKeys = typeof Object.keys == "function" ? (obj) => Object.keys(obj) : (object) => {
165
+ let keys = [];
166
+ for (let key in object)
167
+ Object.prototype.hasOwnProperty.call(object, key) && keys.push(key);
168
+ return keys;
169
+ }, util2.find = (arr, checker) => {
170
+ for (let item of arr)
171
+ if (checker(item))
172
+ return item;
173
+ }, util2.isInteger = typeof Number.isInteger == "function" ? (val) => Number.isInteger(val) : (val) => typeof val == "number" && Number.isFinite(val) && Math.floor(val) === val;
174
+ function joinValues(array, separator = " | ") {
175
+ return array.map((val) => typeof val == "string" ? `'${val}'` : val).join(separator);
176
+ }
177
+ util2.joinValues = joinValues, util2.jsonStringifyReplacer = (_, value) => typeof value == "bigint" ? value.toString() : value;
178
+ })(util || (util = {}));
179
+ var objectUtil;
180
+ (function(objectUtil2) {
181
+ objectUtil2.mergeShapes = (first, second) => ({
182
+ ...first,
183
+ ...second
184
+ // second overwrites first
185
+ });
186
+ })(objectUtil || (objectUtil = {}));
187
+ var ZodParsedType = util.arrayToEnum([
188
+ "string",
189
+ "nan",
190
+ "number",
191
+ "integer",
192
+ "float",
193
+ "boolean",
194
+ "date",
195
+ "bigint",
196
+ "symbol",
197
+ "function",
198
+ "undefined",
199
+ "null",
200
+ "array",
201
+ "object",
202
+ "unknown",
203
+ "promise",
204
+ "void",
205
+ "never",
206
+ "map",
207
+ "set"
208
+ ]), getParsedType = (data) => {
209
+ switch (typeof data) {
210
+ case "undefined":
211
+ return ZodParsedType.undefined;
212
+ case "string":
213
+ return ZodParsedType.string;
214
+ case "number":
215
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
216
+ case "boolean":
217
+ return ZodParsedType.boolean;
218
+ case "function":
219
+ return ZodParsedType.function;
220
+ case "bigint":
221
+ return ZodParsedType.bigint;
222
+ case "symbol":
223
+ return ZodParsedType.symbol;
224
+ case "object":
225
+ return Array.isArray(data) ? ZodParsedType.array : data === null ? ZodParsedType.null : data.then && typeof data.then == "function" && data.catch && typeof data.catch == "function" ? ZodParsedType.promise : typeof Map < "u" && data instanceof Map ? ZodParsedType.map : typeof Set < "u" && data instanceof Set ? ZodParsedType.set : typeof Date < "u" && data instanceof Date ? ZodParsedType.date : ZodParsedType.object;
226
+ default:
227
+ return ZodParsedType.unknown;
228
+ }
229
+ };
230
+
231
+ // ../node_modules/zod/v3/ZodError.js
232
+ var ZodIssueCode = util.arrayToEnum([
233
+ "invalid_type",
234
+ "invalid_literal",
235
+ "custom",
236
+ "invalid_union",
237
+ "invalid_union_discriminator",
238
+ "invalid_enum_value",
239
+ "unrecognized_keys",
240
+ "invalid_arguments",
241
+ "invalid_return_type",
242
+ "invalid_date",
243
+ "invalid_string",
244
+ "too_small",
245
+ "too_big",
246
+ "invalid_intersection_types",
247
+ "not_multiple_of",
248
+ "not_finite"
249
+ ]), quotelessJson = (obj) => JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:"), ZodError = class _ZodError extends Error {
250
+ get errors() {
251
+ return this.issues;
252
+ }
253
+ constructor(issues) {
254
+ super(), this.issues = [], this.addIssue = (sub) => {
255
+ this.issues = [...this.issues, sub];
256
+ }, this.addIssues = (subs = []) => {
257
+ this.issues = [...this.issues, ...subs];
258
+ };
259
+ let actualProto = new.target.prototype;
260
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, actualProto) : this.__proto__ = actualProto, this.name = "ZodError", this.issues = issues;
261
+ }
262
+ format(_mapper) {
263
+ let mapper = _mapper || function(issue) {
264
+ return issue.message;
265
+ }, fieldErrors = { _errors: [] }, processError = (error) => {
266
+ for (let issue of error.issues)
267
+ if (issue.code === "invalid_union")
268
+ issue.unionErrors.map(processError);
269
+ else if (issue.code === "invalid_return_type")
270
+ processError(issue.returnTypeError);
271
+ else if (issue.code === "invalid_arguments")
272
+ processError(issue.argumentsError);
273
+ else if (issue.path.length === 0)
274
+ fieldErrors._errors.push(mapper(issue));
275
+ else {
276
+ let curr = fieldErrors, i = 0;
277
+ for (; i < issue.path.length; ) {
278
+ let el = issue.path[i];
279
+ i === issue.path.length - 1 ? (curr[el] = curr[el] || { _errors: [] }, curr[el]._errors.push(mapper(issue))) : curr[el] = curr[el] || { _errors: [] }, curr = curr[el], i++;
280
+ }
281
+ }
282
+ };
283
+ return processError(this), fieldErrors;
284
+ }
285
+ static assert(value) {
286
+ if (!(value instanceof _ZodError))
287
+ throw new Error(`Not a ZodError: ${value}`);
288
+ }
289
+ toString() {
290
+ return this.message;
291
+ }
292
+ get message() {
293
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
294
+ }
295
+ get isEmpty() {
296
+ return this.issues.length === 0;
297
+ }
298
+ flatten(mapper = (issue) => issue.message) {
299
+ let fieldErrors = {}, formErrors = [];
300
+ for (let sub of this.issues)
301
+ if (sub.path.length > 0) {
302
+ let firstEl = sub.path[0];
303
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [], fieldErrors[firstEl].push(mapper(sub));
304
+ } else
305
+ formErrors.push(mapper(sub));
306
+ return { formErrors, fieldErrors };
307
+ }
308
+ get formErrors() {
309
+ return this.flatten();
310
+ }
311
+ };
312
+ ZodError.create = (issues) => new ZodError(issues);
313
+
314
+ // ../node_modules/zod/v3/locales/en.js
315
+ var errorMap = (issue, _ctx) => {
316
+ let message;
317
+ switch (issue.code) {
318
+ case ZodIssueCode.invalid_type:
319
+ issue.received === ZodParsedType.undefined ? message = "Required" : message = `Expected ${issue.expected}, received ${issue.received}`;
320
+ break;
321
+ case ZodIssueCode.invalid_literal:
322
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
323
+ break;
324
+ case ZodIssueCode.unrecognized_keys:
325
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
326
+ break;
327
+ case ZodIssueCode.invalid_union:
328
+ message = "Invalid input";
329
+ break;
330
+ case ZodIssueCode.invalid_union_discriminator:
331
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
332
+ break;
333
+ case ZodIssueCode.invalid_enum_value:
334
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
335
+ break;
336
+ case ZodIssueCode.invalid_arguments:
337
+ message = "Invalid function arguments";
338
+ break;
339
+ case ZodIssueCode.invalid_return_type:
340
+ message = "Invalid function return type";
341
+ break;
342
+ case ZodIssueCode.invalid_date:
343
+ message = "Invalid date";
344
+ break;
345
+ case ZodIssueCode.invalid_string:
346
+ typeof issue.validation == "object" ? "includes" in issue.validation ? (message = `Invalid input: must include "${issue.validation.includes}"`, typeof issue.validation.position == "number" && (message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`)) : "startsWith" in issue.validation ? message = `Invalid input: must start with "${issue.validation.startsWith}"` : "endsWith" in issue.validation ? message = `Invalid input: must end with "${issue.validation.endsWith}"` : util.assertNever(issue.validation) : issue.validation !== "regex" ? message = `Invalid ${issue.validation}` : message = "Invalid";
347
+ break;
348
+ case ZodIssueCode.too_small:
349
+ issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "more than"} ${issue.minimum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "over"} ${issue.minimum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${issue.minimum}` : issue.type === "bigint" ? message = `Number must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${issue.minimum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(issue.minimum))}` : message = "Invalid input";
350
+ break;
351
+ case ZodIssueCode.too_big:
352
+ issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "less than"} ${issue.maximum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "under"} ${issue.maximum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "bigint" ? message = `BigInt must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly" : issue.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(issue.maximum))}` : message = "Invalid input";
353
+ break;
354
+ case ZodIssueCode.custom:
355
+ message = "Invalid input";
356
+ break;
357
+ case ZodIssueCode.invalid_intersection_types:
358
+ message = "Intersection results could not be merged";
359
+ break;
360
+ case ZodIssueCode.not_multiple_of:
361
+ message = `Number must be a multiple of ${issue.multipleOf}`;
362
+ break;
363
+ case ZodIssueCode.not_finite:
364
+ message = "Number must be finite";
365
+ break;
366
+ default:
367
+ message = _ctx.defaultError, util.assertNever(issue);
368
+ }
369
+ return { message };
370
+ }, en_default = errorMap;
371
+
372
+ // ../node_modules/zod/v3/errors.js
373
+ var overrideErrorMap = en_default;
374
+ function setErrorMap(map) {
375
+ overrideErrorMap = map;
376
+ }
377
+ function getErrorMap() {
378
+ return overrideErrorMap;
379
+ }
380
+
381
+ // ../node_modules/zod/v3/helpers/parseUtil.js
382
+ var makeIssue = (params) => {
383
+ let { data, path, errorMaps, issueData } = params, fullPath = [...path, ...issueData.path || []], fullIssue = {
384
+ ...issueData,
385
+ path: fullPath
386
+ };
387
+ if (issueData.message !== void 0)
388
+ return {
389
+ ...issueData,
390
+ path: fullPath,
391
+ message: issueData.message
392
+ };
393
+ let errorMessage = "", maps = errorMaps.filter((m) => !!m).slice().reverse();
394
+ for (let map of maps)
395
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
396
+ return {
397
+ ...issueData,
398
+ path: fullPath,
399
+ message: errorMessage
400
+ };
401
+ }, EMPTY_PATH = [];
402
+ function addIssueToContext(ctx, issueData) {
403
+ let overrideMap = getErrorMap(), issue = makeIssue({
404
+ issueData,
405
+ data: ctx.data,
406
+ path: ctx.path,
407
+ errorMaps: [
408
+ ctx.common.contextualErrorMap,
409
+ // contextual error map is first priority
410
+ ctx.schemaErrorMap,
411
+ // then schema-bound map if available
412
+ overrideMap,
413
+ // then global override map
414
+ overrideMap === en_default ? void 0 : en_default
415
+ // then global default map
416
+ ].filter((x) => !!x)
417
+ });
418
+ ctx.common.issues.push(issue);
419
+ }
420
+ var ParseStatus = class _ParseStatus {
421
+ constructor() {
422
+ this.value = "valid";
423
+ }
424
+ dirty() {
425
+ this.value === "valid" && (this.value = "dirty");
426
+ }
427
+ abort() {
428
+ this.value !== "aborted" && (this.value = "aborted");
429
+ }
430
+ static mergeArray(status, results) {
431
+ let arrayValue = [];
432
+ for (let s of results) {
433
+ if (s.status === "aborted")
434
+ return INVALID;
435
+ s.status === "dirty" && status.dirty(), arrayValue.push(s.value);
436
+ }
437
+ return { status: status.value, value: arrayValue };
438
+ }
439
+ static async mergeObjectAsync(status, pairs) {
440
+ let syncPairs = [];
441
+ for (let pair of pairs) {
442
+ let key = await pair.key, value = await pair.value;
443
+ syncPairs.push({
444
+ key,
445
+ value
446
+ });
447
+ }
448
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
449
+ }
450
+ static mergeObjectSync(status, pairs) {
451
+ let finalObject = {};
452
+ for (let pair of pairs) {
453
+ let { key, value } = pair;
454
+ if (key.status === "aborted" || value.status === "aborted")
455
+ return INVALID;
456
+ key.status === "dirty" && status.dirty(), value.status === "dirty" && status.dirty(), key.value !== "__proto__" && (typeof value.value < "u" || pair.alwaysSet) && (finalObject[key.value] = value.value);
457
+ }
458
+ return { status: status.value, value: finalObject };
459
+ }
460
+ }, INVALID = Object.freeze({
461
+ status: "aborted"
462
+ }), DIRTY = (value) => ({ status: "dirty", value }), OK = (value) => ({ status: "valid", value }), isAborted = (x) => x.status === "aborted", isDirty = (x) => x.status === "dirty", isValid = (x) => x.status === "valid", isAsync = (x) => typeof Promise < "u" && x instanceof Promise;
463
+
464
+ // ../node_modules/zod/v3/helpers/errorUtil.js
465
+ var errorUtil;
466
+ (function(errorUtil2) {
467
+ errorUtil2.errToObj = (message) => typeof message == "string" ? { message } : message || {}, errorUtil2.toString = (message) => typeof message == "string" ? message : message?.message;
468
+ })(errorUtil || (errorUtil = {}));
469
+
470
+ // ../node_modules/zod/v3/types.js
471
+ var ParseInputLazyPath = class {
472
+ constructor(parent, value, path, key) {
473
+ this._cachedPath = [], this.parent = parent, this.data = value, this._path = path, this._key = key;
474
+ }
475
+ get path() {
476
+ return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
477
+ }
478
+ }, handleResult = (ctx, result) => {
479
+ if (isValid(result))
480
+ return { success: !0, data: result.value };
481
+ if (!ctx.common.issues.length)
482
+ throw new Error("Validation failed but no issues detected.");
483
+ return {
484
+ success: !1,
485
+ get error() {
486
+ if (this._error)
487
+ return this._error;
488
+ let error = new ZodError(ctx.common.issues);
489
+ return this._error = error, this._error;
490
+ }
491
+ };
492
+ };
493
+ function processCreateParams(params) {
494
+ if (!params)
495
+ return {};
496
+ let { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
497
+ if (errorMap2 && (invalid_type_error || required_error))
498
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
499
+ return errorMap2 ? { errorMap: errorMap2, description } : { errorMap: (iss, ctx) => {
500
+ let { message } = params;
501
+ return iss.code === "invalid_enum_value" ? { message: message ?? ctx.defaultError } : typeof ctx.data > "u" ? { message: message ?? required_error ?? ctx.defaultError } : iss.code !== "invalid_type" ? { message: ctx.defaultError } : { message: message ?? invalid_type_error ?? ctx.defaultError };
502
+ }, description };
503
+ }
504
+ var ZodType = class {
505
+ get description() {
506
+ return this._def.description;
507
+ }
508
+ _getType(input) {
509
+ return getParsedType(input.data);
510
+ }
511
+ _getOrReturnCtx(input, ctx) {
512
+ return ctx || {
513
+ common: input.parent.common,
514
+ data: input.data,
515
+ parsedType: getParsedType(input.data),
516
+ schemaErrorMap: this._def.errorMap,
517
+ path: input.path,
518
+ parent: input.parent
519
+ };
520
+ }
521
+ _processInputParams(input) {
522
+ return {
523
+ status: new ParseStatus(),
524
+ ctx: {
525
+ common: input.parent.common,
526
+ data: input.data,
527
+ parsedType: getParsedType(input.data),
528
+ schemaErrorMap: this._def.errorMap,
529
+ path: input.path,
530
+ parent: input.parent
531
+ }
532
+ };
533
+ }
534
+ _parseSync(input) {
535
+ let result = this._parse(input);
536
+ if (isAsync(result))
537
+ throw new Error("Synchronous parse encountered promise.");
538
+ return result;
539
+ }
540
+ _parseAsync(input) {
541
+ let result = this._parse(input);
542
+ return Promise.resolve(result);
543
+ }
544
+ parse(data, params) {
545
+ let result = this.safeParse(data, params);
546
+ if (result.success)
547
+ return result.data;
548
+ throw result.error;
549
+ }
550
+ safeParse(data, params) {
551
+ let ctx = {
552
+ common: {
553
+ issues: [],
554
+ async: params?.async ?? !1,
555
+ contextualErrorMap: params?.errorMap
556
+ },
557
+ path: params?.path || [],
558
+ schemaErrorMap: this._def.errorMap,
559
+ parent: null,
560
+ data,
561
+ parsedType: getParsedType(data)
562
+ }, result = this._parseSync({ data, path: ctx.path, parent: ctx });
563
+ return handleResult(ctx, result);
564
+ }
565
+ "~validate"(data) {
566
+ let ctx = {
567
+ common: {
568
+ issues: [],
569
+ async: !!this["~standard"].async
570
+ },
571
+ path: [],
572
+ schemaErrorMap: this._def.errorMap,
573
+ parent: null,
574
+ data,
575
+ parsedType: getParsedType(data)
576
+ };
577
+ if (!this["~standard"].async)
578
+ try {
579
+ let result = this._parseSync({ data, path: [], parent: ctx });
580
+ return isValid(result) ? {
581
+ value: result.value
582
+ } : {
583
+ issues: ctx.common.issues
584
+ };
585
+ } catch (err) {
586
+ err?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), ctx.common = {
587
+ issues: [],
588
+ async: !0
589
+ };
590
+ }
591
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
592
+ value: result.value
593
+ } : {
594
+ issues: ctx.common.issues
595
+ });
596
+ }
597
+ async parseAsync(data, params) {
598
+ let result = await this.safeParseAsync(data, params);
599
+ if (result.success)
600
+ return result.data;
601
+ throw result.error;
602
+ }
603
+ async safeParseAsync(data, params) {
604
+ let ctx = {
605
+ common: {
606
+ issues: [],
607
+ contextualErrorMap: params?.errorMap,
608
+ async: !0
609
+ },
610
+ path: params?.path || [],
611
+ schemaErrorMap: this._def.errorMap,
612
+ parent: null,
613
+ data,
614
+ parsedType: getParsedType(data)
615
+ }, maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }), result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
616
+ return handleResult(ctx, result);
617
+ }
618
+ refine(check, message) {
619
+ let getIssueProperties = (val) => typeof message == "string" || typeof message > "u" ? { message } : typeof message == "function" ? message(val) : message;
620
+ return this._refinement((val, ctx) => {
621
+ let result = check(val), setError = () => ctx.addIssue({
622
+ code: ZodIssueCode.custom,
623
+ ...getIssueProperties(val)
624
+ });
625
+ return typeof Promise < "u" && result instanceof Promise ? result.then((data) => data ? !0 : (setError(), !1)) : result ? !0 : (setError(), !1);
626
+ });
627
+ }
628
+ refinement(check, refinementData) {
629
+ return this._refinement((val, ctx) => check(val) ? !0 : (ctx.addIssue(typeof refinementData == "function" ? refinementData(val, ctx) : refinementData), !1));
630
+ }
631
+ _refinement(refinement) {
632
+ return new ZodEffects({
633
+ schema: this,
634
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
635
+ effect: { type: "refinement", refinement }
636
+ });
637
+ }
638
+ superRefine(refinement) {
639
+ return this._refinement(refinement);
640
+ }
641
+ constructor(def) {
642
+ this.spa = this.safeParseAsync, this._def = def, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
643
+ version: 1,
644
+ vendor: "zod",
645
+ validate: (data) => this["~validate"](data)
646
+ };
647
+ }
648
+ optional() {
649
+ return ZodOptional.create(this, this._def);
650
+ }
651
+ nullable() {
652
+ return ZodNullable.create(this, this._def);
653
+ }
654
+ nullish() {
655
+ return this.nullable().optional();
656
+ }
657
+ array() {
658
+ return ZodArray.create(this);
659
+ }
660
+ promise() {
661
+ return ZodPromise.create(this, this._def);
662
+ }
663
+ or(option) {
664
+ return ZodUnion.create([this, option], this._def);
665
+ }
666
+ and(incoming) {
667
+ return ZodIntersection.create(this, incoming, this._def);
668
+ }
669
+ transform(transform) {
670
+ return new ZodEffects({
671
+ ...processCreateParams(this._def),
672
+ schema: this,
673
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
674
+ effect: { type: "transform", transform }
675
+ });
676
+ }
677
+ default(def) {
678
+ let defaultValueFunc = typeof def == "function" ? def : () => def;
679
+ return new ZodDefault({
680
+ ...processCreateParams(this._def),
681
+ innerType: this,
682
+ defaultValue: defaultValueFunc,
683
+ typeName: ZodFirstPartyTypeKind.ZodDefault
684
+ });
685
+ }
686
+ brand() {
687
+ return new ZodBranded({
688
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
689
+ type: this,
690
+ ...processCreateParams(this._def)
691
+ });
692
+ }
693
+ catch(def) {
694
+ let catchValueFunc = typeof def == "function" ? def : () => def;
695
+ return new ZodCatch({
696
+ ...processCreateParams(this._def),
697
+ innerType: this,
698
+ catchValue: catchValueFunc,
699
+ typeName: ZodFirstPartyTypeKind.ZodCatch
700
+ });
701
+ }
702
+ describe(description) {
703
+ let This = this.constructor;
704
+ return new This({
705
+ ...this._def,
706
+ description
707
+ });
708
+ }
709
+ pipe(target) {
710
+ return ZodPipeline.create(this, target);
711
+ }
712
+ readonly() {
713
+ return ZodReadonly.create(this);
714
+ }
715
+ isOptional() {
716
+ return this.safeParse(void 0).success;
717
+ }
718
+ isNullable() {
719
+ return this.safeParse(null).success;
720
+ }
721
+ }, cuidRegex = /^c[^\s-]{8,}$/i, cuid2Regex = /^[0-9a-z]+$/, ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i, 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, nanoidRegex = /^[a-z0-9_-]{21}$/i, jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, 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)?)??$/, emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, _emojiRegex = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", emojiRegex, 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])$/, 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])$/, 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]))$/, 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])$/, base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, 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])))", dateRegex = new RegExp(`^${dateRegexSource}$`);
722
+ function timeRegexSource(args) {
723
+ let secondsRegexSource = "[0-5]\\d";
724
+ args.precision ? secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}` : args.precision == null && (secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`);
725
+ let secondsQuantifier = args.precision ? "+" : "?";
726
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
727
+ }
728
+ function timeRegex(args) {
729
+ return new RegExp(`^${timeRegexSource(args)}$`);
730
+ }
731
+ function datetimeRegex(args) {
732
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`, opts = [];
733
+ return opts.push(args.local ? "Z?" : "Z"), args.offset && opts.push("([+-]\\d{2}:?\\d{2})"), regex = `${regex}(${opts.join("|")})`, new RegExp(`^${regex}$`);
734
+ }
735
+ function isValidIP(ip, version) {
736
+ return !!((version === "v4" || !version) && ipv4Regex.test(ip) || (version === "v6" || !version) && ipv6Regex.test(ip));
737
+ }
738
+ function isValidJWT(jwt, alg) {
739
+ if (!jwtRegex.test(jwt))
740
+ return !1;
741
+ try {
742
+ let [header] = jwt.split(".");
743
+ if (!header)
744
+ return !1;
745
+ let base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "="), decoded = JSON.parse(atob(base64));
746
+ return !(typeof decoded != "object" || decoded === null || "typ" in decoded && decoded?.typ !== "JWT" || !decoded.alg || alg && decoded.alg !== alg);
747
+ } catch {
748
+ return !1;
749
+ }
750
+ }
751
+ function isValidCidr(ip, version) {
752
+ return !!((version === "v4" || !version) && ipv4CidrRegex.test(ip) || (version === "v6" || !version) && ipv6CidrRegex.test(ip));
753
+ }
754
+ var ZodString = class _ZodString extends ZodType {
755
+ _parse(input) {
756
+ if (this._def.coerce && (input.data = String(input.data)), this._getType(input) !== ZodParsedType.string) {
757
+ let ctx2 = this._getOrReturnCtx(input);
758
+ return addIssueToContext(ctx2, {
759
+ code: ZodIssueCode.invalid_type,
760
+ expected: ZodParsedType.string,
761
+ received: ctx2.parsedType
762
+ }), INVALID;
763
+ }
764
+ let status = new ParseStatus(), ctx;
765
+ for (let check of this._def.checks)
766
+ if (check.kind === "min")
767
+ input.data.length < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
768
+ code: ZodIssueCode.too_small,
769
+ minimum: check.value,
770
+ type: "string",
771
+ inclusive: !0,
772
+ exact: !1,
773
+ message: check.message
774
+ }), status.dirty());
775
+ else if (check.kind === "max")
776
+ input.data.length > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
777
+ code: ZodIssueCode.too_big,
778
+ maximum: check.value,
779
+ type: "string",
780
+ inclusive: !0,
781
+ exact: !1,
782
+ message: check.message
783
+ }), status.dirty());
784
+ else if (check.kind === "length") {
785
+ let tooBig = input.data.length > check.value, tooSmall = input.data.length < check.value;
786
+ (tooBig || tooSmall) && (ctx = this._getOrReturnCtx(input, ctx), tooBig ? addIssueToContext(ctx, {
787
+ code: ZodIssueCode.too_big,
788
+ maximum: check.value,
789
+ type: "string",
790
+ inclusive: !0,
791
+ exact: !0,
792
+ message: check.message
793
+ }) : tooSmall && addIssueToContext(ctx, {
794
+ code: ZodIssueCode.too_small,
795
+ minimum: check.value,
796
+ type: "string",
797
+ inclusive: !0,
798
+ exact: !0,
799
+ message: check.message
800
+ }), status.dirty());
801
+ } else if (check.kind === "email")
802
+ emailRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
803
+ validation: "email",
804
+ code: ZodIssueCode.invalid_string,
805
+ message: check.message
806
+ }), status.dirty());
807
+ else if (check.kind === "emoji")
808
+ emojiRegex || (emojiRegex = new RegExp(_emojiRegex, "u")), emojiRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
809
+ validation: "emoji",
810
+ code: ZodIssueCode.invalid_string,
811
+ message: check.message
812
+ }), status.dirty());
813
+ else if (check.kind === "uuid")
814
+ uuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
815
+ validation: "uuid",
816
+ code: ZodIssueCode.invalid_string,
817
+ message: check.message
818
+ }), status.dirty());
819
+ else if (check.kind === "nanoid")
820
+ nanoidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
821
+ validation: "nanoid",
822
+ code: ZodIssueCode.invalid_string,
823
+ message: check.message
824
+ }), status.dirty());
825
+ else if (check.kind === "cuid")
826
+ cuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
827
+ validation: "cuid",
828
+ code: ZodIssueCode.invalid_string,
829
+ message: check.message
830
+ }), status.dirty());
831
+ else if (check.kind === "cuid2")
832
+ cuid2Regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
833
+ validation: "cuid2",
834
+ code: ZodIssueCode.invalid_string,
835
+ message: check.message
836
+ }), status.dirty());
837
+ else if (check.kind === "ulid")
838
+ ulidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
839
+ validation: "ulid",
840
+ code: ZodIssueCode.invalid_string,
841
+ message: check.message
842
+ }), status.dirty());
843
+ else if (check.kind === "url")
844
+ try {
845
+ new URL(input.data);
846
+ } catch {
847
+ ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
848
+ validation: "url",
849
+ code: ZodIssueCode.invalid_string,
850
+ message: check.message
851
+ }), status.dirty();
852
+ }
853
+ else check.kind === "regex" ? (check.regex.lastIndex = 0, check.regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
854
+ validation: "regex",
855
+ code: ZodIssueCode.invalid_string,
856
+ message: check.message
857
+ }), status.dirty())) : check.kind === "trim" ? input.data = input.data.trim() : check.kind === "includes" ? input.data.includes(check.value, check.position) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
858
+ code: ZodIssueCode.invalid_string,
859
+ validation: { includes: check.value, position: check.position },
860
+ message: check.message
861
+ }), status.dirty()) : check.kind === "toLowerCase" ? input.data = input.data.toLowerCase() : check.kind === "toUpperCase" ? input.data = input.data.toUpperCase() : check.kind === "startsWith" ? input.data.startsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
862
+ code: ZodIssueCode.invalid_string,
863
+ validation: { startsWith: check.value },
864
+ message: check.message
865
+ }), status.dirty()) : check.kind === "endsWith" ? input.data.endsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
866
+ code: ZodIssueCode.invalid_string,
867
+ validation: { endsWith: check.value },
868
+ message: check.message
869
+ }), status.dirty()) : check.kind === "datetime" ? datetimeRegex(check).test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
870
+ code: ZodIssueCode.invalid_string,
871
+ validation: "datetime",
872
+ message: check.message
873
+ }), status.dirty()) : check.kind === "date" ? dateRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
874
+ code: ZodIssueCode.invalid_string,
875
+ validation: "date",
876
+ message: check.message
877
+ }), status.dirty()) : check.kind === "time" ? timeRegex(check).test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
878
+ code: ZodIssueCode.invalid_string,
879
+ validation: "time",
880
+ message: check.message
881
+ }), status.dirty()) : check.kind === "duration" ? durationRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
882
+ validation: "duration",
883
+ code: ZodIssueCode.invalid_string,
884
+ message: check.message
885
+ }), status.dirty()) : check.kind === "ip" ? isValidIP(input.data, check.version) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
886
+ validation: "ip",
887
+ code: ZodIssueCode.invalid_string,
888
+ message: check.message
889
+ }), status.dirty()) : check.kind === "jwt" ? isValidJWT(input.data, check.alg) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
890
+ validation: "jwt",
891
+ code: ZodIssueCode.invalid_string,
892
+ message: check.message
893
+ }), status.dirty()) : check.kind === "cidr" ? isValidCidr(input.data, check.version) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
894
+ validation: "cidr",
895
+ code: ZodIssueCode.invalid_string,
896
+ message: check.message
897
+ }), status.dirty()) : check.kind === "base64" ? base64Regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
898
+ validation: "base64",
899
+ code: ZodIssueCode.invalid_string,
900
+ message: check.message
901
+ }), status.dirty()) : check.kind === "base64url" ? base64urlRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
902
+ validation: "base64url",
903
+ code: ZodIssueCode.invalid_string,
904
+ message: check.message
905
+ }), status.dirty()) : util.assertNever(check);
906
+ return { status: status.value, value: input.data };
907
+ }
908
+ _regex(regex, validation, message) {
909
+ return this.refinement((data) => regex.test(data), {
910
+ validation,
911
+ code: ZodIssueCode.invalid_string,
912
+ ...errorUtil.errToObj(message)
913
+ });
914
+ }
915
+ _addCheck(check) {
916
+ return new _ZodString({
917
+ ...this._def,
918
+ checks: [...this._def.checks, check]
919
+ });
920
+ }
921
+ email(message) {
922
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
923
+ }
924
+ url(message) {
925
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
926
+ }
927
+ emoji(message) {
928
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
929
+ }
930
+ uuid(message) {
931
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
932
+ }
933
+ nanoid(message) {
934
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
935
+ }
936
+ cuid(message) {
937
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
938
+ }
939
+ cuid2(message) {
940
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
941
+ }
942
+ ulid(message) {
943
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
944
+ }
945
+ base64(message) {
946
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
947
+ }
948
+ base64url(message) {
949
+ return this._addCheck({
950
+ kind: "base64url",
951
+ ...errorUtil.errToObj(message)
952
+ });
953
+ }
954
+ jwt(options) {
955
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
956
+ }
957
+ ip(options) {
958
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
959
+ }
960
+ cidr(options) {
961
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
962
+ }
963
+ datetime(options) {
964
+ return typeof options == "string" ? this._addCheck({
965
+ kind: "datetime",
966
+ precision: null,
967
+ offset: !1,
968
+ local: !1,
969
+ message: options
970
+ }) : this._addCheck({
971
+ kind: "datetime",
972
+ precision: typeof options?.precision > "u" ? null : options?.precision,
973
+ offset: options?.offset ?? !1,
974
+ local: options?.local ?? !1,
975
+ ...errorUtil.errToObj(options?.message)
976
+ });
977
+ }
978
+ date(message) {
979
+ return this._addCheck({ kind: "date", message });
980
+ }
981
+ time(options) {
982
+ return typeof options == "string" ? this._addCheck({
983
+ kind: "time",
984
+ precision: null,
985
+ message: options
986
+ }) : this._addCheck({
987
+ kind: "time",
988
+ precision: typeof options?.precision > "u" ? null : options?.precision,
989
+ ...errorUtil.errToObj(options?.message)
990
+ });
991
+ }
992
+ duration(message) {
993
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
994
+ }
995
+ regex(regex, message) {
996
+ return this._addCheck({
997
+ kind: "regex",
998
+ regex,
999
+ ...errorUtil.errToObj(message)
1000
+ });
1001
+ }
1002
+ includes(value, options) {
1003
+ return this._addCheck({
1004
+ kind: "includes",
1005
+ value,
1006
+ position: options?.position,
1007
+ ...errorUtil.errToObj(options?.message)
1008
+ });
1009
+ }
1010
+ startsWith(value, message) {
1011
+ return this._addCheck({
1012
+ kind: "startsWith",
1013
+ value,
1014
+ ...errorUtil.errToObj(message)
1015
+ });
1016
+ }
1017
+ endsWith(value, message) {
1018
+ return this._addCheck({
1019
+ kind: "endsWith",
1020
+ value,
1021
+ ...errorUtil.errToObj(message)
1022
+ });
1023
+ }
1024
+ min(minLength, message) {
1025
+ return this._addCheck({
1026
+ kind: "min",
1027
+ value: minLength,
1028
+ ...errorUtil.errToObj(message)
1029
+ });
1030
+ }
1031
+ max(maxLength, message) {
1032
+ return this._addCheck({
1033
+ kind: "max",
1034
+ value: maxLength,
1035
+ ...errorUtil.errToObj(message)
1036
+ });
1037
+ }
1038
+ length(len, message) {
1039
+ return this._addCheck({
1040
+ kind: "length",
1041
+ value: len,
1042
+ ...errorUtil.errToObj(message)
1043
+ });
1044
+ }
1045
+ /**
1046
+ * Equivalent to `.min(1)`
1047
+ */
1048
+ nonempty(message) {
1049
+ return this.min(1, errorUtil.errToObj(message));
1050
+ }
1051
+ trim() {
1052
+ return new _ZodString({
1053
+ ...this._def,
1054
+ checks: [...this._def.checks, { kind: "trim" }]
1055
+ });
1056
+ }
1057
+ toLowerCase() {
1058
+ return new _ZodString({
1059
+ ...this._def,
1060
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1061
+ });
1062
+ }
1063
+ toUpperCase() {
1064
+ return new _ZodString({
1065
+ ...this._def,
1066
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1067
+ });
1068
+ }
1069
+ get isDatetime() {
1070
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1071
+ }
1072
+ get isDate() {
1073
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1074
+ }
1075
+ get isTime() {
1076
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1077
+ }
1078
+ get isDuration() {
1079
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1080
+ }
1081
+ get isEmail() {
1082
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1083
+ }
1084
+ get isURL() {
1085
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1086
+ }
1087
+ get isEmoji() {
1088
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1089
+ }
1090
+ get isUUID() {
1091
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1092
+ }
1093
+ get isNANOID() {
1094
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1095
+ }
1096
+ get isCUID() {
1097
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1098
+ }
1099
+ get isCUID2() {
1100
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1101
+ }
1102
+ get isULID() {
1103
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1104
+ }
1105
+ get isIP() {
1106
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1107
+ }
1108
+ get isCIDR() {
1109
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1110
+ }
1111
+ get isBase64() {
1112
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1113
+ }
1114
+ get isBase64url() {
1115
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1116
+ }
1117
+ get minLength() {
1118
+ let min = null;
1119
+ for (let ch of this._def.checks)
1120
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
1121
+ return min;
1122
+ }
1123
+ get maxLength() {
1124
+ let max = null;
1125
+ for (let ch of this._def.checks)
1126
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1127
+ return max;
1128
+ }
1129
+ };
1130
+ ZodString.create = (params) => new ZodString({
1131
+ checks: [],
1132
+ typeName: ZodFirstPartyTypeKind.ZodString,
1133
+ coerce: params?.coerce ?? !1,
1134
+ ...processCreateParams(params)
1135
+ });
1136
+ function floatSafeRemainder(val, step) {
1137
+ let valDecCount = (val.toString().split(".")[1] || "").length, stepDecCount = (step.toString().split(".")[1] || "").length, decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount, valInt = Number.parseInt(val.toFixed(decCount).replace(".", "")), stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1138
+ return valInt % stepInt / 10 ** decCount;
1139
+ }
1140
+ var ZodNumber = class _ZodNumber extends ZodType {
1141
+ constructor() {
1142
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1143
+ }
1144
+ _parse(input) {
1145
+ if (this._def.coerce && (input.data = Number(input.data)), this._getType(input) !== ZodParsedType.number) {
1146
+ let ctx2 = this._getOrReturnCtx(input);
1147
+ return addIssueToContext(ctx2, {
1148
+ code: ZodIssueCode.invalid_type,
1149
+ expected: ZodParsedType.number,
1150
+ received: ctx2.parsedType
1151
+ }), INVALID;
1152
+ }
1153
+ let ctx, status = new ParseStatus();
1154
+ for (let check of this._def.checks)
1155
+ check.kind === "int" ? util.isInteger(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1156
+ code: ZodIssueCode.invalid_type,
1157
+ expected: "integer",
1158
+ received: "float",
1159
+ message: check.message
1160
+ }), status.dirty()) : check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1161
+ code: ZodIssueCode.too_small,
1162
+ minimum: check.value,
1163
+ type: "number",
1164
+ inclusive: check.inclusive,
1165
+ exact: !1,
1166
+ message: check.message
1167
+ }), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1168
+ code: ZodIssueCode.too_big,
1169
+ maximum: check.value,
1170
+ type: "number",
1171
+ inclusive: check.inclusive,
1172
+ exact: !1,
1173
+ message: check.message
1174
+ }), status.dirty()) : check.kind === "multipleOf" ? floatSafeRemainder(input.data, check.value) !== 0 && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1175
+ code: ZodIssueCode.not_multiple_of,
1176
+ multipleOf: check.value,
1177
+ message: check.message
1178
+ }), status.dirty()) : check.kind === "finite" ? Number.isFinite(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1179
+ code: ZodIssueCode.not_finite,
1180
+ message: check.message
1181
+ }), status.dirty()) : util.assertNever(check);
1182
+ return { status: status.value, value: input.data };
1183
+ }
1184
+ gte(value, message) {
1185
+ return this.setLimit("min", value, !0, errorUtil.toString(message));
1186
+ }
1187
+ gt(value, message) {
1188
+ return this.setLimit("min", value, !1, errorUtil.toString(message));
1189
+ }
1190
+ lte(value, message) {
1191
+ return this.setLimit("max", value, !0, errorUtil.toString(message));
1192
+ }
1193
+ lt(value, message) {
1194
+ return this.setLimit("max", value, !1, errorUtil.toString(message));
1195
+ }
1196
+ setLimit(kind, value, inclusive, message) {
1197
+ return new _ZodNumber({
1198
+ ...this._def,
1199
+ checks: [
1200
+ ...this._def.checks,
1201
+ {
1202
+ kind,
1203
+ value,
1204
+ inclusive,
1205
+ message: errorUtil.toString(message)
1206
+ }
1207
+ ]
1208
+ });
1209
+ }
1210
+ _addCheck(check) {
1211
+ return new _ZodNumber({
1212
+ ...this._def,
1213
+ checks: [...this._def.checks, check]
1214
+ });
1215
+ }
1216
+ int(message) {
1217
+ return this._addCheck({
1218
+ kind: "int",
1219
+ message: errorUtil.toString(message)
1220
+ });
1221
+ }
1222
+ positive(message) {
1223
+ return this._addCheck({
1224
+ kind: "min",
1225
+ value: 0,
1226
+ inclusive: !1,
1227
+ message: errorUtil.toString(message)
1228
+ });
1229
+ }
1230
+ negative(message) {
1231
+ return this._addCheck({
1232
+ kind: "max",
1233
+ value: 0,
1234
+ inclusive: !1,
1235
+ message: errorUtil.toString(message)
1236
+ });
1237
+ }
1238
+ nonpositive(message) {
1239
+ return this._addCheck({
1240
+ kind: "max",
1241
+ value: 0,
1242
+ inclusive: !0,
1243
+ message: errorUtil.toString(message)
1244
+ });
1245
+ }
1246
+ nonnegative(message) {
1247
+ return this._addCheck({
1248
+ kind: "min",
1249
+ value: 0,
1250
+ inclusive: !0,
1251
+ message: errorUtil.toString(message)
1252
+ });
1253
+ }
1254
+ multipleOf(value, message) {
1255
+ return this._addCheck({
1256
+ kind: "multipleOf",
1257
+ value,
1258
+ message: errorUtil.toString(message)
1259
+ });
1260
+ }
1261
+ finite(message) {
1262
+ return this._addCheck({
1263
+ kind: "finite",
1264
+ message: errorUtil.toString(message)
1265
+ });
1266
+ }
1267
+ safe(message) {
1268
+ return this._addCheck({
1269
+ kind: "min",
1270
+ inclusive: !0,
1271
+ value: Number.MIN_SAFE_INTEGER,
1272
+ message: errorUtil.toString(message)
1273
+ })._addCheck({
1274
+ kind: "max",
1275
+ inclusive: !0,
1276
+ value: Number.MAX_SAFE_INTEGER,
1277
+ message: errorUtil.toString(message)
1278
+ });
1279
+ }
1280
+ get minValue() {
1281
+ let min = null;
1282
+ for (let ch of this._def.checks)
1283
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
1284
+ return min;
1285
+ }
1286
+ get maxValue() {
1287
+ let max = null;
1288
+ for (let ch of this._def.checks)
1289
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1290
+ return max;
1291
+ }
1292
+ get isInt() {
1293
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1294
+ }
1295
+ get isFinite() {
1296
+ let max = null, min = null;
1297
+ for (let ch of this._def.checks) {
1298
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf")
1299
+ return !0;
1300
+ ch.kind === "min" ? (min === null || ch.value > min) && (min = ch.value) : ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1301
+ }
1302
+ return Number.isFinite(min) && Number.isFinite(max);
1303
+ }
1304
+ };
1305
+ ZodNumber.create = (params) => new ZodNumber({
1306
+ checks: [],
1307
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1308
+ coerce: params?.coerce || !1,
1309
+ ...processCreateParams(params)
1310
+ });
1311
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1312
+ constructor() {
1313
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1314
+ }
1315
+ _parse(input) {
1316
+ if (this._def.coerce)
1317
+ try {
1318
+ input.data = BigInt(input.data);
1319
+ } catch {
1320
+ return this._getInvalidInput(input);
1321
+ }
1322
+ if (this._getType(input) !== ZodParsedType.bigint)
1323
+ return this._getInvalidInput(input);
1324
+ let ctx, status = new ParseStatus();
1325
+ for (let check of this._def.checks)
1326
+ check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1327
+ code: ZodIssueCode.too_small,
1328
+ type: "bigint",
1329
+ minimum: check.value,
1330
+ inclusive: check.inclusive,
1331
+ message: check.message
1332
+ }), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1333
+ code: ZodIssueCode.too_big,
1334
+ type: "bigint",
1335
+ maximum: check.value,
1336
+ inclusive: check.inclusive,
1337
+ message: check.message
1338
+ }), status.dirty()) : check.kind === "multipleOf" ? input.data % check.value !== BigInt(0) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1339
+ code: ZodIssueCode.not_multiple_of,
1340
+ multipleOf: check.value,
1341
+ message: check.message
1342
+ }), status.dirty()) : util.assertNever(check);
1343
+ return { status: status.value, value: input.data };
1344
+ }
1345
+ _getInvalidInput(input) {
1346
+ let ctx = this._getOrReturnCtx(input);
1347
+ return addIssueToContext(ctx, {
1348
+ code: ZodIssueCode.invalid_type,
1349
+ expected: ZodParsedType.bigint,
1350
+ received: ctx.parsedType
1351
+ }), INVALID;
1352
+ }
1353
+ gte(value, message) {
1354
+ return this.setLimit("min", value, !0, errorUtil.toString(message));
1355
+ }
1356
+ gt(value, message) {
1357
+ return this.setLimit("min", value, !1, errorUtil.toString(message));
1358
+ }
1359
+ lte(value, message) {
1360
+ return this.setLimit("max", value, !0, errorUtil.toString(message));
1361
+ }
1362
+ lt(value, message) {
1363
+ return this.setLimit("max", value, !1, errorUtil.toString(message));
1364
+ }
1365
+ setLimit(kind, value, inclusive, message) {
1366
+ return new _ZodBigInt({
1367
+ ...this._def,
1368
+ checks: [
1369
+ ...this._def.checks,
1370
+ {
1371
+ kind,
1372
+ value,
1373
+ inclusive,
1374
+ message: errorUtil.toString(message)
1375
+ }
1376
+ ]
1377
+ });
1378
+ }
1379
+ _addCheck(check) {
1380
+ return new _ZodBigInt({
1381
+ ...this._def,
1382
+ checks: [...this._def.checks, check]
1383
+ });
1384
+ }
1385
+ positive(message) {
1386
+ return this._addCheck({
1387
+ kind: "min",
1388
+ value: BigInt(0),
1389
+ inclusive: !1,
1390
+ message: errorUtil.toString(message)
1391
+ });
1392
+ }
1393
+ negative(message) {
1394
+ return this._addCheck({
1395
+ kind: "max",
1396
+ value: BigInt(0),
1397
+ inclusive: !1,
1398
+ message: errorUtil.toString(message)
1399
+ });
1400
+ }
1401
+ nonpositive(message) {
1402
+ return this._addCheck({
1403
+ kind: "max",
1404
+ value: BigInt(0),
1405
+ inclusive: !0,
1406
+ message: errorUtil.toString(message)
1407
+ });
1408
+ }
1409
+ nonnegative(message) {
1410
+ return this._addCheck({
1411
+ kind: "min",
1412
+ value: BigInt(0),
1413
+ inclusive: !0,
1414
+ message: errorUtil.toString(message)
1415
+ });
1416
+ }
1417
+ multipleOf(value, message) {
1418
+ return this._addCheck({
1419
+ kind: "multipleOf",
1420
+ value,
1421
+ message: errorUtil.toString(message)
1422
+ });
1423
+ }
1424
+ get minValue() {
1425
+ let min = null;
1426
+ for (let ch of this._def.checks)
1427
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
1428
+ return min;
1429
+ }
1430
+ get maxValue() {
1431
+ let max = null;
1432
+ for (let ch of this._def.checks)
1433
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1434
+ return max;
1435
+ }
1436
+ };
1437
+ ZodBigInt.create = (params) => new ZodBigInt({
1438
+ checks: [],
1439
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1440
+ coerce: params?.coerce ?? !1,
1441
+ ...processCreateParams(params)
1442
+ });
1443
+ var ZodBoolean = class extends ZodType {
1444
+ _parse(input) {
1445
+ if (this._def.coerce && (input.data = !!input.data), this._getType(input) !== ZodParsedType.boolean) {
1446
+ let ctx = this._getOrReturnCtx(input);
1447
+ return addIssueToContext(ctx, {
1448
+ code: ZodIssueCode.invalid_type,
1449
+ expected: ZodParsedType.boolean,
1450
+ received: ctx.parsedType
1451
+ }), INVALID;
1452
+ }
1453
+ return OK(input.data);
1454
+ }
1455
+ };
1456
+ ZodBoolean.create = (params) => new ZodBoolean({
1457
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1458
+ coerce: params?.coerce || !1,
1459
+ ...processCreateParams(params)
1460
+ });
1461
+ var ZodDate = class _ZodDate extends ZodType {
1462
+ _parse(input) {
1463
+ if (this._def.coerce && (input.data = new Date(input.data)), this._getType(input) !== ZodParsedType.date) {
1464
+ let ctx2 = this._getOrReturnCtx(input);
1465
+ return addIssueToContext(ctx2, {
1466
+ code: ZodIssueCode.invalid_type,
1467
+ expected: ZodParsedType.date,
1468
+ received: ctx2.parsedType
1469
+ }), INVALID;
1470
+ }
1471
+ if (Number.isNaN(input.data.getTime())) {
1472
+ let ctx2 = this._getOrReturnCtx(input);
1473
+ return addIssueToContext(ctx2, {
1474
+ code: ZodIssueCode.invalid_date
1475
+ }), INVALID;
1476
+ }
1477
+ let status = new ParseStatus(), ctx;
1478
+ for (let check of this._def.checks)
1479
+ check.kind === "min" ? input.data.getTime() < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1480
+ code: ZodIssueCode.too_small,
1481
+ message: check.message,
1482
+ inclusive: !0,
1483
+ exact: !1,
1484
+ minimum: check.value,
1485
+ type: "date"
1486
+ }), status.dirty()) : check.kind === "max" ? input.data.getTime() > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1487
+ code: ZodIssueCode.too_big,
1488
+ message: check.message,
1489
+ inclusive: !0,
1490
+ exact: !1,
1491
+ maximum: check.value,
1492
+ type: "date"
1493
+ }), status.dirty()) : util.assertNever(check);
1494
+ return {
1495
+ status: status.value,
1496
+ value: new Date(input.data.getTime())
1497
+ };
1498
+ }
1499
+ _addCheck(check) {
1500
+ return new _ZodDate({
1501
+ ...this._def,
1502
+ checks: [...this._def.checks, check]
1503
+ });
1504
+ }
1505
+ min(minDate, message) {
1506
+ return this._addCheck({
1507
+ kind: "min",
1508
+ value: minDate.getTime(),
1509
+ message: errorUtil.toString(message)
1510
+ });
1511
+ }
1512
+ max(maxDate, message) {
1513
+ return this._addCheck({
1514
+ kind: "max",
1515
+ value: maxDate.getTime(),
1516
+ message: errorUtil.toString(message)
1517
+ });
1518
+ }
1519
+ get minDate() {
1520
+ let min = null;
1521
+ for (let ch of this._def.checks)
1522
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
1523
+ return min != null ? new Date(min) : null;
1524
+ }
1525
+ get maxDate() {
1526
+ let max = null;
1527
+ for (let ch of this._def.checks)
1528
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1529
+ return max != null ? new Date(max) : null;
1530
+ }
1531
+ };
1532
+ ZodDate.create = (params) => new ZodDate({
1533
+ checks: [],
1534
+ coerce: params?.coerce || !1,
1535
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1536
+ ...processCreateParams(params)
1537
+ });
1538
+ var ZodSymbol = class extends ZodType {
1539
+ _parse(input) {
1540
+ if (this._getType(input) !== ZodParsedType.symbol) {
1541
+ let ctx = this._getOrReturnCtx(input);
1542
+ return addIssueToContext(ctx, {
1543
+ code: ZodIssueCode.invalid_type,
1544
+ expected: ZodParsedType.symbol,
1545
+ received: ctx.parsedType
1546
+ }), INVALID;
1547
+ }
1548
+ return OK(input.data);
1549
+ }
1550
+ };
1551
+ ZodSymbol.create = (params) => new ZodSymbol({
1552
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1553
+ ...processCreateParams(params)
1554
+ });
1555
+ var ZodUndefined = class extends ZodType {
1556
+ _parse(input) {
1557
+ if (this._getType(input) !== ZodParsedType.undefined) {
1558
+ let ctx = this._getOrReturnCtx(input);
1559
+ return addIssueToContext(ctx, {
1560
+ code: ZodIssueCode.invalid_type,
1561
+ expected: ZodParsedType.undefined,
1562
+ received: ctx.parsedType
1563
+ }), INVALID;
1564
+ }
1565
+ return OK(input.data);
1566
+ }
1567
+ };
1568
+ ZodUndefined.create = (params) => new ZodUndefined({
1569
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
1570
+ ...processCreateParams(params)
1571
+ });
1572
+ var ZodNull = class extends ZodType {
1573
+ _parse(input) {
1574
+ if (this._getType(input) !== ZodParsedType.null) {
1575
+ let ctx = this._getOrReturnCtx(input);
1576
+ return addIssueToContext(ctx, {
1577
+ code: ZodIssueCode.invalid_type,
1578
+ expected: ZodParsedType.null,
1579
+ received: ctx.parsedType
1580
+ }), INVALID;
1581
+ }
1582
+ return OK(input.data);
1583
+ }
1584
+ };
1585
+ ZodNull.create = (params) => new ZodNull({
1586
+ typeName: ZodFirstPartyTypeKind.ZodNull,
1587
+ ...processCreateParams(params)
1588
+ });
1589
+ var ZodAny = class extends ZodType {
1590
+ constructor() {
1591
+ super(...arguments), this._any = !0;
1592
+ }
1593
+ _parse(input) {
1594
+ return OK(input.data);
1595
+ }
1596
+ };
1597
+ ZodAny.create = (params) => new ZodAny({
1598
+ typeName: ZodFirstPartyTypeKind.ZodAny,
1599
+ ...processCreateParams(params)
1600
+ });
1601
+ var ZodUnknown = class extends ZodType {
1602
+ constructor() {
1603
+ super(...arguments), this._unknown = !0;
1604
+ }
1605
+ _parse(input) {
1606
+ return OK(input.data);
1607
+ }
1608
+ };
1609
+ ZodUnknown.create = (params) => new ZodUnknown({
1610
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
1611
+ ...processCreateParams(params)
1612
+ });
1613
+ var ZodNever = class extends ZodType {
1614
+ _parse(input) {
1615
+ let ctx = this._getOrReturnCtx(input);
1616
+ return addIssueToContext(ctx, {
1617
+ code: ZodIssueCode.invalid_type,
1618
+ expected: ZodParsedType.never,
1619
+ received: ctx.parsedType
1620
+ }), INVALID;
1621
+ }
1622
+ };
1623
+ ZodNever.create = (params) => new ZodNever({
1624
+ typeName: ZodFirstPartyTypeKind.ZodNever,
1625
+ ...processCreateParams(params)
1626
+ });
1627
+ var ZodVoid = class extends ZodType {
1628
+ _parse(input) {
1629
+ if (this._getType(input) !== ZodParsedType.undefined) {
1630
+ let ctx = this._getOrReturnCtx(input);
1631
+ return addIssueToContext(ctx, {
1632
+ code: ZodIssueCode.invalid_type,
1633
+ expected: ZodParsedType.void,
1634
+ received: ctx.parsedType
1635
+ }), INVALID;
1636
+ }
1637
+ return OK(input.data);
1638
+ }
1639
+ };
1640
+ ZodVoid.create = (params) => new ZodVoid({
1641
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
1642
+ ...processCreateParams(params)
1643
+ });
1644
+ var ZodArray = class _ZodArray extends ZodType {
1645
+ _parse(input) {
1646
+ let { ctx, status } = this._processInputParams(input), def = this._def;
1647
+ if (ctx.parsedType !== ZodParsedType.array)
1648
+ return addIssueToContext(ctx, {
1649
+ code: ZodIssueCode.invalid_type,
1650
+ expected: ZodParsedType.array,
1651
+ received: ctx.parsedType
1652
+ }), INVALID;
1653
+ if (def.exactLength !== null) {
1654
+ let tooBig = ctx.data.length > def.exactLength.value, tooSmall = ctx.data.length < def.exactLength.value;
1655
+ (tooBig || tooSmall) && (addIssueToContext(ctx, {
1656
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1657
+ minimum: tooSmall ? def.exactLength.value : void 0,
1658
+ maximum: tooBig ? def.exactLength.value : void 0,
1659
+ type: "array",
1660
+ inclusive: !0,
1661
+ exact: !0,
1662
+ message: def.exactLength.message
1663
+ }), status.dirty());
1664
+ }
1665
+ if (def.minLength !== null && ctx.data.length < def.minLength.value && (addIssueToContext(ctx, {
1666
+ code: ZodIssueCode.too_small,
1667
+ minimum: def.minLength.value,
1668
+ type: "array",
1669
+ inclusive: !0,
1670
+ exact: !1,
1671
+ message: def.minLength.message
1672
+ }), status.dirty()), def.maxLength !== null && ctx.data.length > def.maxLength.value && (addIssueToContext(ctx, {
1673
+ code: ZodIssueCode.too_big,
1674
+ maximum: def.maxLength.value,
1675
+ type: "array",
1676
+ inclusive: !0,
1677
+ exact: !1,
1678
+ message: def.maxLength.message
1679
+ }), status.dirty()), ctx.common.async)
1680
+ return Promise.all([...ctx.data].map((item, i) => def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i)))).then((result2) => ParseStatus.mergeArray(status, result2));
1681
+ let result = [...ctx.data].map((item, i) => def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i)));
1682
+ return ParseStatus.mergeArray(status, result);
1683
+ }
1684
+ get element() {
1685
+ return this._def.type;
1686
+ }
1687
+ min(minLength, message) {
1688
+ return new _ZodArray({
1689
+ ...this._def,
1690
+ minLength: { value: minLength, message: errorUtil.toString(message) }
1691
+ });
1692
+ }
1693
+ max(maxLength, message) {
1694
+ return new _ZodArray({
1695
+ ...this._def,
1696
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
1697
+ });
1698
+ }
1699
+ length(len, message) {
1700
+ return new _ZodArray({
1701
+ ...this._def,
1702
+ exactLength: { value: len, message: errorUtil.toString(message) }
1703
+ });
1704
+ }
1705
+ nonempty(message) {
1706
+ return this.min(1, message);
1707
+ }
1708
+ };
1709
+ ZodArray.create = (schema, params) => new ZodArray({
1710
+ type: schema,
1711
+ minLength: null,
1712
+ maxLength: null,
1713
+ exactLength: null,
1714
+ typeName: ZodFirstPartyTypeKind.ZodArray,
1715
+ ...processCreateParams(params)
1716
+ });
1717
+ function deepPartialify(schema) {
1718
+ if (schema instanceof ZodObject) {
1719
+ let newShape = {};
1720
+ for (let key in schema.shape) {
1721
+ let fieldSchema = schema.shape[key];
1722
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1723
+ }
1724
+ return new ZodObject({
1725
+ ...schema._def,
1726
+ shape: () => newShape
1727
+ });
1728
+ } else return schema instanceof ZodArray ? new ZodArray({
1729
+ ...schema._def,
1730
+ type: deepPartialify(schema.element)
1731
+ }) : schema instanceof ZodOptional ? ZodOptional.create(deepPartialify(schema.unwrap())) : schema instanceof ZodNullable ? ZodNullable.create(deepPartialify(schema.unwrap())) : schema instanceof ZodTuple ? ZodTuple.create(schema.items.map((item) => deepPartialify(item))) : schema;
1732
+ }
1733
+ var ZodObject = class _ZodObject extends ZodType {
1734
+ constructor() {
1735
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1736
+ }
1737
+ _getCached() {
1738
+ if (this._cached !== null)
1739
+ return this._cached;
1740
+ let shape = this._def.shape(), keys = util.objectKeys(shape);
1741
+ return this._cached = { shape, keys }, this._cached;
1742
+ }
1743
+ _parse(input) {
1744
+ if (this._getType(input) !== ZodParsedType.object) {
1745
+ let ctx2 = this._getOrReturnCtx(input);
1746
+ return addIssueToContext(ctx2, {
1747
+ code: ZodIssueCode.invalid_type,
1748
+ expected: ZodParsedType.object,
1749
+ received: ctx2.parsedType
1750
+ }), INVALID;
1751
+ }
1752
+ let { status, ctx } = this._processInputParams(input), { shape, keys: shapeKeys } = this._getCached(), extraKeys = [];
1753
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip"))
1754
+ for (let key in ctx.data)
1755
+ shapeKeys.includes(key) || extraKeys.push(key);
1756
+ let pairs = [];
1757
+ for (let key of shapeKeys) {
1758
+ let keyValidator = shape[key], value = ctx.data[key];
1759
+ pairs.push({
1760
+ key: { status: "valid", value: key },
1761
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
1762
+ alwaysSet: key in ctx.data
1763
+ });
1764
+ }
1765
+ if (this._def.catchall instanceof ZodNever) {
1766
+ let unknownKeys = this._def.unknownKeys;
1767
+ if (unknownKeys === "passthrough")
1768
+ for (let key of extraKeys)
1769
+ pairs.push({
1770
+ key: { status: "valid", value: key },
1771
+ value: { status: "valid", value: ctx.data[key] }
1772
+ });
1773
+ else if (unknownKeys === "strict")
1774
+ extraKeys.length > 0 && (addIssueToContext(ctx, {
1775
+ code: ZodIssueCode.unrecognized_keys,
1776
+ keys: extraKeys
1777
+ }), status.dirty());
1778
+ else if (unknownKeys !== "strip")
1779
+ throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1780
+ } else {
1781
+ let catchall = this._def.catchall;
1782
+ for (let key of extraKeys) {
1783
+ let value = ctx.data[key];
1784
+ pairs.push({
1785
+ key: { status: "valid", value: key },
1786
+ value: catchall._parse(
1787
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
1788
+ //, ctx.child(key), value, getParsedType(value)
1789
+ ),
1790
+ alwaysSet: key in ctx.data
1791
+ });
1792
+ }
1793
+ }
1794
+ return ctx.common.async ? Promise.resolve().then(async () => {
1795
+ let syncPairs = [];
1796
+ for (let pair of pairs) {
1797
+ let key = await pair.key, value = await pair.value;
1798
+ syncPairs.push({
1799
+ key,
1800
+ value,
1801
+ alwaysSet: pair.alwaysSet
1802
+ });
1803
+ }
1804
+ return syncPairs;
1805
+ }).then((syncPairs) => ParseStatus.mergeObjectSync(status, syncPairs)) : ParseStatus.mergeObjectSync(status, pairs);
1806
+ }
1807
+ get shape() {
1808
+ return this._def.shape();
1809
+ }
1810
+ strict(message) {
1811
+ return errorUtil.errToObj, new _ZodObject({
1812
+ ...this._def,
1813
+ unknownKeys: "strict",
1814
+ ...message !== void 0 ? {
1815
+ errorMap: (issue, ctx) => {
1816
+ let defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
1817
+ return issue.code === "unrecognized_keys" ? {
1818
+ message: errorUtil.errToObj(message).message ?? defaultError
1819
+ } : {
1820
+ message: defaultError
1821
+ };
1822
+ }
1823
+ } : {}
1824
+ });
1825
+ }
1826
+ strip() {
1827
+ return new _ZodObject({
1828
+ ...this._def,
1829
+ unknownKeys: "strip"
1830
+ });
1831
+ }
1832
+ passthrough() {
1833
+ return new _ZodObject({
1834
+ ...this._def,
1835
+ unknownKeys: "passthrough"
1836
+ });
1837
+ }
1838
+ // const AugmentFactory =
1839
+ // <Def extends ZodObjectDef>(def: Def) =>
1840
+ // <Augmentation extends ZodRawShape>(
1841
+ // augmentation: Augmentation
1842
+ // ): ZodObject<
1843
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1844
+ // Def["unknownKeys"],
1845
+ // Def["catchall"]
1846
+ // > => {
1847
+ // return new ZodObject({
1848
+ // ...def,
1849
+ // shape: () => ({
1850
+ // ...def.shape(),
1851
+ // ...augmentation,
1852
+ // }),
1853
+ // }) as any;
1854
+ // };
1855
+ extend(augmentation) {
1856
+ return new _ZodObject({
1857
+ ...this._def,
1858
+ shape: () => ({
1859
+ ...this._def.shape(),
1860
+ ...augmentation
1861
+ })
1862
+ });
1863
+ }
1864
+ /**
1865
+ * Prior to zod@1.0.12 there was a bug in the
1866
+ * inferred type of merged objects. Please
1867
+ * upgrade if you are experiencing issues.
1868
+ */
1869
+ merge(merging) {
1870
+ return new _ZodObject({
1871
+ unknownKeys: merging._def.unknownKeys,
1872
+ catchall: merging._def.catchall,
1873
+ shape: () => ({
1874
+ ...this._def.shape(),
1875
+ ...merging._def.shape()
1876
+ }),
1877
+ typeName: ZodFirstPartyTypeKind.ZodObject
1878
+ });
1879
+ }
1880
+ // merge<
1881
+ // Incoming extends AnyZodObject,
1882
+ // Augmentation extends Incoming["shape"],
1883
+ // NewOutput extends {
1884
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1885
+ // ? Augmentation[k]["_output"]
1886
+ // : k extends keyof Output
1887
+ // ? Output[k]
1888
+ // : never;
1889
+ // },
1890
+ // NewInput extends {
1891
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1892
+ // ? Augmentation[k]["_input"]
1893
+ // : k extends keyof Input
1894
+ // ? Input[k]
1895
+ // : never;
1896
+ // }
1897
+ // >(
1898
+ // merging: Incoming
1899
+ // ): ZodObject<
1900
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1901
+ // Incoming["_def"]["unknownKeys"],
1902
+ // Incoming["_def"]["catchall"],
1903
+ // NewOutput,
1904
+ // NewInput
1905
+ // > {
1906
+ // const merged: any = new ZodObject({
1907
+ // unknownKeys: merging._def.unknownKeys,
1908
+ // catchall: merging._def.catchall,
1909
+ // shape: () =>
1910
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1911
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1912
+ // }) as any;
1913
+ // return merged;
1914
+ // }
1915
+ setKey(key, schema) {
1916
+ return this.augment({ [key]: schema });
1917
+ }
1918
+ // merge<Incoming extends AnyZodObject>(
1919
+ // merging: Incoming
1920
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1921
+ // ZodObject<
1922
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1923
+ // Incoming["_def"]["unknownKeys"],
1924
+ // Incoming["_def"]["catchall"]
1925
+ // > {
1926
+ // // const mergedShape = objectUtil.mergeShapes(
1927
+ // // this._def.shape(),
1928
+ // // merging._def.shape()
1929
+ // // );
1930
+ // const merged: any = new ZodObject({
1931
+ // unknownKeys: merging._def.unknownKeys,
1932
+ // catchall: merging._def.catchall,
1933
+ // shape: () =>
1934
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1935
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1936
+ // }) as any;
1937
+ // return merged;
1938
+ // }
1939
+ catchall(index) {
1940
+ return new _ZodObject({
1941
+ ...this._def,
1942
+ catchall: index
1943
+ });
1944
+ }
1945
+ pick(mask) {
1946
+ let shape = {};
1947
+ for (let key of util.objectKeys(mask))
1948
+ mask[key] && this.shape[key] && (shape[key] = this.shape[key]);
1949
+ return new _ZodObject({
1950
+ ...this._def,
1951
+ shape: () => shape
1952
+ });
1953
+ }
1954
+ omit(mask) {
1955
+ let shape = {};
1956
+ for (let key of util.objectKeys(this.shape))
1957
+ mask[key] || (shape[key] = this.shape[key]);
1958
+ return new _ZodObject({
1959
+ ...this._def,
1960
+ shape: () => shape
1961
+ });
1962
+ }
1963
+ /**
1964
+ * @deprecated
1965
+ */
1966
+ deepPartial() {
1967
+ return deepPartialify(this);
1968
+ }
1969
+ partial(mask) {
1970
+ let newShape = {};
1971
+ for (let key of util.objectKeys(this.shape)) {
1972
+ let fieldSchema = this.shape[key];
1973
+ mask && !mask[key] ? newShape[key] = fieldSchema : newShape[key] = fieldSchema.optional();
1974
+ }
1975
+ return new _ZodObject({
1976
+ ...this._def,
1977
+ shape: () => newShape
1978
+ });
1979
+ }
1980
+ required(mask) {
1981
+ let newShape = {};
1982
+ for (let key of util.objectKeys(this.shape))
1983
+ if (mask && !mask[key])
1984
+ newShape[key] = this.shape[key];
1985
+ else {
1986
+ let newField = this.shape[key];
1987
+ for (; newField instanceof ZodOptional; )
1988
+ newField = newField._def.innerType;
1989
+ newShape[key] = newField;
1990
+ }
1991
+ return new _ZodObject({
1992
+ ...this._def,
1993
+ shape: () => newShape
1994
+ });
1995
+ }
1996
+ keyof() {
1997
+ return createZodEnum(util.objectKeys(this.shape));
1998
+ }
1999
+ };
2000
+ ZodObject.create = (shape, params) => new ZodObject({
2001
+ shape: () => shape,
2002
+ unknownKeys: "strip",
2003
+ catchall: ZodNever.create(),
2004
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2005
+ ...processCreateParams(params)
2006
+ });
2007
+ ZodObject.strictCreate = (shape, params) => new ZodObject({
2008
+ shape: () => shape,
2009
+ unknownKeys: "strict",
2010
+ catchall: ZodNever.create(),
2011
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2012
+ ...processCreateParams(params)
2013
+ });
2014
+ ZodObject.lazycreate = (shape, params) => new ZodObject({
2015
+ shape,
2016
+ unknownKeys: "strip",
2017
+ catchall: ZodNever.create(),
2018
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2019
+ ...processCreateParams(params)
2020
+ });
2021
+ var ZodUnion = class extends ZodType {
2022
+ _parse(input) {
2023
+ let { ctx } = this._processInputParams(input), options = this._def.options;
2024
+ function handleResults(results) {
2025
+ for (let result of results)
2026
+ if (result.result.status === "valid")
2027
+ return result.result;
2028
+ for (let result of results)
2029
+ if (result.result.status === "dirty")
2030
+ return ctx.common.issues.push(...result.ctx.common.issues), result.result;
2031
+ let unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2032
+ return addIssueToContext(ctx, {
2033
+ code: ZodIssueCode.invalid_union,
2034
+ unionErrors
2035
+ }), INVALID;
2036
+ }
2037
+ if (ctx.common.async)
2038
+ return Promise.all(options.map(async (option) => {
2039
+ let childCtx = {
2040
+ ...ctx,
2041
+ common: {
2042
+ ...ctx.common,
2043
+ issues: []
2044
+ },
2045
+ parent: null
2046
+ };
2047
+ return {
2048
+ result: await option._parseAsync({
2049
+ data: ctx.data,
2050
+ path: ctx.path,
2051
+ parent: childCtx
2052
+ }),
2053
+ ctx: childCtx
2054
+ };
2055
+ })).then(handleResults);
2056
+ {
2057
+ let dirty, issues = [];
2058
+ for (let option of options) {
2059
+ let childCtx = {
2060
+ ...ctx,
2061
+ common: {
2062
+ ...ctx.common,
2063
+ issues: []
2064
+ },
2065
+ parent: null
2066
+ }, result = option._parseSync({
2067
+ data: ctx.data,
2068
+ path: ctx.path,
2069
+ parent: childCtx
2070
+ });
2071
+ if (result.status === "valid")
2072
+ return result;
2073
+ result.status === "dirty" && !dirty && (dirty = { result, ctx: childCtx }), childCtx.common.issues.length && issues.push(childCtx.common.issues);
2074
+ }
2075
+ if (dirty)
2076
+ return ctx.common.issues.push(...dirty.ctx.common.issues), dirty.result;
2077
+ let unionErrors = issues.map((issues2) => new ZodError(issues2));
2078
+ return addIssueToContext(ctx, {
2079
+ code: ZodIssueCode.invalid_union,
2080
+ unionErrors
2081
+ }), INVALID;
2082
+ }
2083
+ }
2084
+ get options() {
2085
+ return this._def.options;
2086
+ }
2087
+ };
2088
+ ZodUnion.create = (types, params) => new ZodUnion({
2089
+ options: types,
2090
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2091
+ ...processCreateParams(params)
2092
+ });
2093
+ var getDiscriminator = (type) => type instanceof ZodLazy ? getDiscriminator(type.schema) : type instanceof ZodEffects ? getDiscriminator(type.innerType()) : type instanceof ZodLiteral ? [type.value] : type instanceof ZodEnum ? type.options : type instanceof ZodNativeEnum ? util.objectValues(type.enum) : type instanceof ZodDefault ? getDiscriminator(type._def.innerType) : type instanceof ZodUndefined ? [void 0] : type instanceof ZodNull ? [null] : type instanceof ZodOptional ? [void 0, ...getDiscriminator(type.unwrap())] : type instanceof ZodNullable ? [null, ...getDiscriminator(type.unwrap())] : type instanceof ZodBranded || type instanceof ZodReadonly ? getDiscriminator(type.unwrap()) : type instanceof ZodCatch ? getDiscriminator(type._def.innerType) : [], ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2094
+ _parse(input) {
2095
+ let { ctx } = this._processInputParams(input);
2096
+ if (ctx.parsedType !== ZodParsedType.object)
2097
+ return addIssueToContext(ctx, {
2098
+ code: ZodIssueCode.invalid_type,
2099
+ expected: ZodParsedType.object,
2100
+ received: ctx.parsedType
2101
+ }), INVALID;
2102
+ let discriminator = this.discriminator, discriminatorValue = ctx.data[discriminator], option = this.optionsMap.get(discriminatorValue);
2103
+ return option ? ctx.common.async ? option._parseAsync({
2104
+ data: ctx.data,
2105
+ path: ctx.path,
2106
+ parent: ctx
2107
+ }) : option._parseSync({
2108
+ data: ctx.data,
2109
+ path: ctx.path,
2110
+ parent: ctx
2111
+ }) : (addIssueToContext(ctx, {
2112
+ code: ZodIssueCode.invalid_union_discriminator,
2113
+ options: Array.from(this.optionsMap.keys()),
2114
+ path: [discriminator]
2115
+ }), INVALID);
2116
+ }
2117
+ get discriminator() {
2118
+ return this._def.discriminator;
2119
+ }
2120
+ get options() {
2121
+ return this._def.options;
2122
+ }
2123
+ get optionsMap() {
2124
+ return this._def.optionsMap;
2125
+ }
2126
+ /**
2127
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2128
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2129
+ * have a different value for each object in the union.
2130
+ * @param discriminator the name of the discriminator property
2131
+ * @param types an array of object schemas
2132
+ * @param params
2133
+ */
2134
+ static create(discriminator, options, params) {
2135
+ let optionsMap = /* @__PURE__ */ new Map();
2136
+ for (let type of options) {
2137
+ let discriminatorValues = getDiscriminator(type.shape[discriminator]);
2138
+ if (!discriminatorValues.length)
2139
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2140
+ for (let value of discriminatorValues) {
2141
+ if (optionsMap.has(value))
2142
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2143
+ optionsMap.set(value, type);
2144
+ }
2145
+ }
2146
+ return new _ZodDiscriminatedUnion({
2147
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2148
+ discriminator,
2149
+ options,
2150
+ optionsMap,
2151
+ ...processCreateParams(params)
2152
+ });
2153
+ }
2154
+ };
2155
+ function mergeValues(a, b) {
2156
+ let aType = getParsedType(a), bType = getParsedType(b);
2157
+ if (a === b)
2158
+ return { valid: !0, data: a };
2159
+ if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2160
+ let bKeys = util.objectKeys(b), sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1), newObj = { ...a, ...b };
2161
+ for (let key of sharedKeys) {
2162
+ let sharedValue = mergeValues(a[key], b[key]);
2163
+ if (!sharedValue.valid)
2164
+ return { valid: !1 };
2165
+ newObj[key] = sharedValue.data;
2166
+ }
2167
+ return { valid: !0, data: newObj };
2168
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2169
+ if (a.length !== b.length)
2170
+ return { valid: !1 };
2171
+ let newArray = [];
2172
+ for (let index = 0; index < a.length; index++) {
2173
+ let itemA = a[index], itemB = b[index], sharedValue = mergeValues(itemA, itemB);
2174
+ if (!sharedValue.valid)
2175
+ return { valid: !1 };
2176
+ newArray.push(sharedValue.data);
2177
+ }
2178
+ return { valid: !0, data: newArray };
2179
+ } else return aType === ZodParsedType.date && bType === ZodParsedType.date && +a == +b ? { valid: !0, data: a } : { valid: !1 };
2180
+ }
2181
+ var ZodIntersection = class extends ZodType {
2182
+ _parse(input) {
2183
+ let { status, ctx } = this._processInputParams(input), handleParsed = (parsedLeft, parsedRight) => {
2184
+ if (isAborted(parsedLeft) || isAborted(parsedRight))
2185
+ return INVALID;
2186
+ let merged = mergeValues(parsedLeft.value, parsedRight.value);
2187
+ return merged.valid ? ((isDirty(parsedLeft) || isDirty(parsedRight)) && status.dirty(), { status: status.value, value: merged.data }) : (addIssueToContext(ctx, {
2188
+ code: ZodIssueCode.invalid_intersection_types
2189
+ }), INVALID);
2190
+ };
2191
+ return ctx.common.async ? Promise.all([
2192
+ this._def.left._parseAsync({
2193
+ data: ctx.data,
2194
+ path: ctx.path,
2195
+ parent: ctx
2196
+ }),
2197
+ this._def.right._parseAsync({
2198
+ data: ctx.data,
2199
+ path: ctx.path,
2200
+ parent: ctx
2201
+ })
2202
+ ]).then(([left, right]) => handleParsed(left, right)) : handleParsed(this._def.left._parseSync({
2203
+ data: ctx.data,
2204
+ path: ctx.path,
2205
+ parent: ctx
2206
+ }), this._def.right._parseSync({
2207
+ data: ctx.data,
2208
+ path: ctx.path,
2209
+ parent: ctx
2210
+ }));
2211
+ }
2212
+ };
2213
+ ZodIntersection.create = (left, right, params) => new ZodIntersection({
2214
+ left,
2215
+ right,
2216
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2217
+ ...processCreateParams(params)
2218
+ });
2219
+ var ZodTuple = class _ZodTuple extends ZodType {
2220
+ _parse(input) {
2221
+ let { status, ctx } = this._processInputParams(input);
2222
+ if (ctx.parsedType !== ZodParsedType.array)
2223
+ return addIssueToContext(ctx, {
2224
+ code: ZodIssueCode.invalid_type,
2225
+ expected: ZodParsedType.array,
2226
+ received: ctx.parsedType
2227
+ }), INVALID;
2228
+ if (ctx.data.length < this._def.items.length)
2229
+ return addIssueToContext(ctx, {
2230
+ code: ZodIssueCode.too_small,
2231
+ minimum: this._def.items.length,
2232
+ inclusive: !0,
2233
+ exact: !1,
2234
+ type: "array"
2235
+ }), INVALID;
2236
+ !this._def.rest && ctx.data.length > this._def.items.length && (addIssueToContext(ctx, {
2237
+ code: ZodIssueCode.too_big,
2238
+ maximum: this._def.items.length,
2239
+ inclusive: !0,
2240
+ exact: !1,
2241
+ type: "array"
2242
+ }), status.dirty());
2243
+ let items = [...ctx.data].map((item, itemIndex) => {
2244
+ let schema = this._def.items[itemIndex] || this._def.rest;
2245
+ return schema ? schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)) : null;
2246
+ }).filter((x) => !!x);
2247
+ return ctx.common.async ? Promise.all(items).then((results) => ParseStatus.mergeArray(status, results)) : ParseStatus.mergeArray(status, items);
2248
+ }
2249
+ get items() {
2250
+ return this._def.items;
2251
+ }
2252
+ rest(rest) {
2253
+ return new _ZodTuple({
2254
+ ...this._def,
2255
+ rest
2256
+ });
2257
+ }
2258
+ };
2259
+ ZodTuple.create = (schemas, params) => {
2260
+ if (!Array.isArray(schemas))
2261
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2262
+ return new ZodTuple({
2263
+ items: schemas,
2264
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2265
+ rest: null,
2266
+ ...processCreateParams(params)
2267
+ });
2268
+ };
2269
+ var ZodRecord = class _ZodRecord extends ZodType {
2270
+ get keySchema() {
2271
+ return this._def.keyType;
2272
+ }
2273
+ get valueSchema() {
2274
+ return this._def.valueType;
2275
+ }
2276
+ _parse(input) {
2277
+ let { status, ctx } = this._processInputParams(input);
2278
+ if (ctx.parsedType !== ZodParsedType.object)
2279
+ return addIssueToContext(ctx, {
2280
+ code: ZodIssueCode.invalid_type,
2281
+ expected: ZodParsedType.object,
2282
+ received: ctx.parsedType
2283
+ }), INVALID;
2284
+ let pairs = [], keyType = this._def.keyType, valueType = this._def.valueType;
2285
+ for (let key in ctx.data)
2286
+ pairs.push({
2287
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2288
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2289
+ alwaysSet: key in ctx.data
2290
+ });
2291
+ return ctx.common.async ? ParseStatus.mergeObjectAsync(status, pairs) : ParseStatus.mergeObjectSync(status, pairs);
2292
+ }
2293
+ get element() {
2294
+ return this._def.valueType;
2295
+ }
2296
+ static create(first, second, third) {
2297
+ return second instanceof ZodType ? new _ZodRecord({
2298
+ keyType: first,
2299
+ valueType: second,
2300
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2301
+ ...processCreateParams(third)
2302
+ }) : new _ZodRecord({
2303
+ keyType: ZodString.create(),
2304
+ valueType: first,
2305
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2306
+ ...processCreateParams(second)
2307
+ });
2308
+ }
2309
+ }, ZodMap = class extends ZodType {
2310
+ get keySchema() {
2311
+ return this._def.keyType;
2312
+ }
2313
+ get valueSchema() {
2314
+ return this._def.valueType;
2315
+ }
2316
+ _parse(input) {
2317
+ let { status, ctx } = this._processInputParams(input);
2318
+ if (ctx.parsedType !== ZodParsedType.map)
2319
+ return addIssueToContext(ctx, {
2320
+ code: ZodIssueCode.invalid_type,
2321
+ expected: ZodParsedType.map,
2322
+ received: ctx.parsedType
2323
+ }), INVALID;
2324
+ let keyType = this._def.keyType, valueType = this._def.valueType, pairs = [...ctx.data.entries()].map(([key, value], index) => ({
2325
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2326
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2327
+ }));
2328
+ if (ctx.common.async) {
2329
+ let finalMap = /* @__PURE__ */ new Map();
2330
+ return Promise.resolve().then(async () => {
2331
+ for (let pair of pairs) {
2332
+ let key = await pair.key, value = await pair.value;
2333
+ if (key.status === "aborted" || value.status === "aborted")
2334
+ return INVALID;
2335
+ (key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
2336
+ }
2337
+ return { status: status.value, value: finalMap };
2338
+ });
2339
+ } else {
2340
+ let finalMap = /* @__PURE__ */ new Map();
2341
+ for (let pair of pairs) {
2342
+ let key = pair.key, value = pair.value;
2343
+ if (key.status === "aborted" || value.status === "aborted")
2344
+ return INVALID;
2345
+ (key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
2346
+ }
2347
+ return { status: status.value, value: finalMap };
2348
+ }
2349
+ }
2350
+ };
2351
+ ZodMap.create = (keyType, valueType, params) => new ZodMap({
2352
+ valueType,
2353
+ keyType,
2354
+ typeName: ZodFirstPartyTypeKind.ZodMap,
2355
+ ...processCreateParams(params)
2356
+ });
2357
+ var ZodSet = class _ZodSet extends ZodType {
2358
+ _parse(input) {
2359
+ let { status, ctx } = this._processInputParams(input);
2360
+ if (ctx.parsedType !== ZodParsedType.set)
2361
+ return addIssueToContext(ctx, {
2362
+ code: ZodIssueCode.invalid_type,
2363
+ expected: ZodParsedType.set,
2364
+ received: ctx.parsedType
2365
+ }), INVALID;
2366
+ let def = this._def;
2367
+ def.minSize !== null && ctx.data.size < def.minSize.value && (addIssueToContext(ctx, {
2368
+ code: ZodIssueCode.too_small,
2369
+ minimum: def.minSize.value,
2370
+ type: "set",
2371
+ inclusive: !0,
2372
+ exact: !1,
2373
+ message: def.minSize.message
2374
+ }), status.dirty()), def.maxSize !== null && ctx.data.size > def.maxSize.value && (addIssueToContext(ctx, {
2375
+ code: ZodIssueCode.too_big,
2376
+ maximum: def.maxSize.value,
2377
+ type: "set",
2378
+ inclusive: !0,
2379
+ exact: !1,
2380
+ message: def.maxSize.message
2381
+ }), status.dirty());
2382
+ let valueType = this._def.valueType;
2383
+ function finalizeSet(elements2) {
2384
+ let parsedSet = /* @__PURE__ */ new Set();
2385
+ for (let element of elements2) {
2386
+ if (element.status === "aborted")
2387
+ return INVALID;
2388
+ element.status === "dirty" && status.dirty(), parsedSet.add(element.value);
2389
+ }
2390
+ return { status: status.value, value: parsedSet };
2391
+ }
2392
+ let elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2393
+ return ctx.common.async ? Promise.all(elements).then((elements2) => finalizeSet(elements2)) : finalizeSet(elements);
2394
+ }
2395
+ min(minSize, message) {
2396
+ return new _ZodSet({
2397
+ ...this._def,
2398
+ minSize: { value: minSize, message: errorUtil.toString(message) }
2399
+ });
2400
+ }
2401
+ max(maxSize, message) {
2402
+ return new _ZodSet({
2403
+ ...this._def,
2404
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
2405
+ });
2406
+ }
2407
+ size(size, message) {
2408
+ return this.min(size, message).max(size, message);
2409
+ }
2410
+ nonempty(message) {
2411
+ return this.min(1, message);
2412
+ }
2413
+ };
2414
+ ZodSet.create = (valueType, params) => new ZodSet({
2415
+ valueType,
2416
+ minSize: null,
2417
+ maxSize: null,
2418
+ typeName: ZodFirstPartyTypeKind.ZodSet,
2419
+ ...processCreateParams(params)
2420
+ });
2421
+ var ZodFunction = class _ZodFunction extends ZodType {
2422
+ constructor() {
2423
+ super(...arguments), this.validate = this.implement;
2424
+ }
2425
+ _parse(input) {
2426
+ let { ctx } = this._processInputParams(input);
2427
+ if (ctx.parsedType !== ZodParsedType.function)
2428
+ return addIssueToContext(ctx, {
2429
+ code: ZodIssueCode.invalid_type,
2430
+ expected: ZodParsedType.function,
2431
+ received: ctx.parsedType
2432
+ }), INVALID;
2433
+ function makeArgsIssue(args, error) {
2434
+ return makeIssue({
2435
+ data: args,
2436
+ path: ctx.path,
2437
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
2438
+ issueData: {
2439
+ code: ZodIssueCode.invalid_arguments,
2440
+ argumentsError: error
2441
+ }
2442
+ });
2443
+ }
2444
+ function makeReturnsIssue(returns, error) {
2445
+ return makeIssue({
2446
+ data: returns,
2447
+ path: ctx.path,
2448
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
2449
+ issueData: {
2450
+ code: ZodIssueCode.invalid_return_type,
2451
+ returnTypeError: error
2452
+ }
2453
+ });
2454
+ }
2455
+ let params = { errorMap: ctx.common.contextualErrorMap }, fn = ctx.data;
2456
+ if (this._def.returns instanceof ZodPromise) {
2457
+ let me = this;
2458
+ return OK(async function(...args) {
2459
+ let error = new ZodError([]), parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2460
+ throw error.addIssue(makeArgsIssue(args, e)), error;
2461
+ }), result = await Reflect.apply(fn, this, parsedArgs);
2462
+ return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
2463
+ throw error.addIssue(makeReturnsIssue(result, e)), error;
2464
+ });
2465
+ });
2466
+ } else {
2467
+ let me = this;
2468
+ return OK(function(...args) {
2469
+ let parsedArgs = me._def.args.safeParse(args, params);
2470
+ if (!parsedArgs.success)
2471
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2472
+ let result = Reflect.apply(fn, this, parsedArgs.data), parsedReturns = me._def.returns.safeParse(result, params);
2473
+ if (!parsedReturns.success)
2474
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2475
+ return parsedReturns.data;
2476
+ });
2477
+ }
2478
+ }
2479
+ parameters() {
2480
+ return this._def.args;
2481
+ }
2482
+ returnType() {
2483
+ return this._def.returns;
2484
+ }
2485
+ args(...items) {
2486
+ return new _ZodFunction({
2487
+ ...this._def,
2488
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
2489
+ });
2490
+ }
2491
+ returns(returnType) {
2492
+ return new _ZodFunction({
2493
+ ...this._def,
2494
+ returns: returnType
2495
+ });
2496
+ }
2497
+ implement(func) {
2498
+ return this.parse(func);
2499
+ }
2500
+ strictImplement(func) {
2501
+ return this.parse(func);
2502
+ }
2503
+ static create(args, returns, params) {
2504
+ return new _ZodFunction({
2505
+ args: args || ZodTuple.create([]).rest(ZodUnknown.create()),
2506
+ returns: returns || ZodUnknown.create(),
2507
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
2508
+ ...processCreateParams(params)
2509
+ });
2510
+ }
2511
+ }, ZodLazy = class extends ZodType {
2512
+ get schema() {
2513
+ return this._def.getter();
2514
+ }
2515
+ _parse(input) {
2516
+ let { ctx } = this._processInputParams(input);
2517
+ return this._def.getter()._parse({ data: ctx.data, path: ctx.path, parent: ctx });
2518
+ }
2519
+ };
2520
+ ZodLazy.create = (getter, params) => new ZodLazy({
2521
+ getter,
2522
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
2523
+ ...processCreateParams(params)
2524
+ });
2525
+ var ZodLiteral = class extends ZodType {
2526
+ _parse(input) {
2527
+ if (input.data !== this._def.value) {
2528
+ let ctx = this._getOrReturnCtx(input);
2529
+ return addIssueToContext(ctx, {
2530
+ received: ctx.data,
2531
+ code: ZodIssueCode.invalid_literal,
2532
+ expected: this._def.value
2533
+ }), INVALID;
2534
+ }
2535
+ return { status: "valid", value: input.data };
2536
+ }
2537
+ get value() {
2538
+ return this._def.value;
2539
+ }
2540
+ };
2541
+ ZodLiteral.create = (value, params) => new ZodLiteral({
2542
+ value,
2543
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
2544
+ ...processCreateParams(params)
2545
+ });
2546
+ function createZodEnum(values, params) {
2547
+ return new ZodEnum({
2548
+ values,
2549
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
2550
+ ...processCreateParams(params)
2551
+ });
2552
+ }
2553
+ var ZodEnum = class _ZodEnum extends ZodType {
2554
+ _parse(input) {
2555
+ if (typeof input.data != "string") {
2556
+ let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
2557
+ return addIssueToContext(ctx, {
2558
+ expected: util.joinValues(expectedValues),
2559
+ received: ctx.parsedType,
2560
+ code: ZodIssueCode.invalid_type
2561
+ }), INVALID;
2562
+ }
2563
+ if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(input.data)) {
2564
+ let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
2565
+ return addIssueToContext(ctx, {
2566
+ received: ctx.data,
2567
+ code: ZodIssueCode.invalid_enum_value,
2568
+ options: expectedValues
2569
+ }), INVALID;
2570
+ }
2571
+ return OK(input.data);
2572
+ }
2573
+ get options() {
2574
+ return this._def.values;
2575
+ }
2576
+ get enum() {
2577
+ let enumValues = {};
2578
+ for (let val of this._def.values)
2579
+ enumValues[val] = val;
2580
+ return enumValues;
2581
+ }
2582
+ get Values() {
2583
+ let enumValues = {};
2584
+ for (let val of this._def.values)
2585
+ enumValues[val] = val;
2586
+ return enumValues;
2587
+ }
2588
+ get Enum() {
2589
+ let enumValues = {};
2590
+ for (let val of this._def.values)
2591
+ enumValues[val] = val;
2592
+ return enumValues;
2593
+ }
2594
+ extract(values, newDef = this._def) {
2595
+ return _ZodEnum.create(values, {
2596
+ ...this._def,
2597
+ ...newDef
2598
+ });
2599
+ }
2600
+ exclude(values, newDef = this._def) {
2601
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
2602
+ ...this._def,
2603
+ ...newDef
2604
+ });
2605
+ }
2606
+ };
2607
+ ZodEnum.create = createZodEnum;
2608
+ var ZodNativeEnum = class extends ZodType {
2609
+ _parse(input) {
2610
+ let nativeEnumValues = util.getValidEnumValues(this._def.values), ctx = this._getOrReturnCtx(input);
2611
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
2612
+ let expectedValues = util.objectValues(nativeEnumValues);
2613
+ return addIssueToContext(ctx, {
2614
+ expected: util.joinValues(expectedValues),
2615
+ received: ctx.parsedType,
2616
+ code: ZodIssueCode.invalid_type
2617
+ }), INVALID;
2618
+ }
2619
+ if (this._cache || (this._cache = new Set(util.getValidEnumValues(this._def.values))), !this._cache.has(input.data)) {
2620
+ let expectedValues = util.objectValues(nativeEnumValues);
2621
+ return addIssueToContext(ctx, {
2622
+ received: ctx.data,
2623
+ code: ZodIssueCode.invalid_enum_value,
2624
+ options: expectedValues
2625
+ }), INVALID;
2626
+ }
2627
+ return OK(input.data);
2628
+ }
2629
+ get enum() {
2630
+ return this._def.values;
2631
+ }
2632
+ };
2633
+ ZodNativeEnum.create = (values, params) => new ZodNativeEnum({
2634
+ values,
2635
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
2636
+ ...processCreateParams(params)
2637
+ });
2638
+ var ZodPromise = class extends ZodType {
2639
+ unwrap() {
2640
+ return this._def.type;
2641
+ }
2642
+ _parse(input) {
2643
+ let { ctx } = this._processInputParams(input);
2644
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === !1)
2645
+ return addIssueToContext(ctx, {
2646
+ code: ZodIssueCode.invalid_type,
2647
+ expected: ZodParsedType.promise,
2648
+ received: ctx.parsedType
2649
+ }), INVALID;
2650
+ let promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
2651
+ return OK(promisified.then((data) => this._def.type.parseAsync(data, {
2652
+ path: ctx.path,
2653
+ errorMap: ctx.common.contextualErrorMap
2654
+ })));
2655
+ }
2656
+ };
2657
+ ZodPromise.create = (schema, params) => new ZodPromise({
2658
+ type: schema,
2659
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
2660
+ ...processCreateParams(params)
2661
+ });
2662
+ var ZodEffects = class extends ZodType {
2663
+ innerType() {
2664
+ return this._def.schema;
2665
+ }
2666
+ sourceType() {
2667
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2668
+ }
2669
+ _parse(input) {
2670
+ let { status, ctx } = this._processInputParams(input), effect = this._def.effect || null, checkCtx = {
2671
+ addIssue: (arg) => {
2672
+ addIssueToContext(ctx, arg), arg.fatal ? status.abort() : status.dirty();
2673
+ },
2674
+ get path() {
2675
+ return ctx.path;
2676
+ }
2677
+ };
2678
+ if (checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx), effect.type === "preprocess") {
2679
+ let processed = effect.transform(ctx.data, checkCtx);
2680
+ if (ctx.common.async)
2681
+ return Promise.resolve(processed).then(async (processed2) => {
2682
+ if (status.value === "aborted")
2683
+ return INVALID;
2684
+ let result = await this._def.schema._parseAsync({
2685
+ data: processed2,
2686
+ path: ctx.path,
2687
+ parent: ctx
2688
+ });
2689
+ return result.status === "aborted" ? INVALID : result.status === "dirty" ? DIRTY(result.value) : status.value === "dirty" ? DIRTY(result.value) : result;
2690
+ });
2691
+ {
2692
+ if (status.value === "aborted")
2693
+ return INVALID;
2694
+ let result = this._def.schema._parseSync({
2695
+ data: processed,
2696
+ path: ctx.path,
2697
+ parent: ctx
2698
+ });
2699
+ return result.status === "aborted" ? INVALID : result.status === "dirty" ? DIRTY(result.value) : status.value === "dirty" ? DIRTY(result.value) : result;
2700
+ }
2701
+ }
2702
+ if (effect.type === "refinement") {
2703
+ let executeRefinement = (acc) => {
2704
+ let result = effect.refinement(acc, checkCtx);
2705
+ if (ctx.common.async)
2706
+ return Promise.resolve(result);
2707
+ if (result instanceof Promise)
2708
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2709
+ return acc;
2710
+ };
2711
+ if (ctx.common.async === !1) {
2712
+ let inner = this._def.schema._parseSync({
2713
+ data: ctx.data,
2714
+ path: ctx.path,
2715
+ parent: ctx
2716
+ });
2717
+ return inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value), { status: status.value, value: inner.value });
2718
+ } else
2719
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value).then(() => ({ status: status.value, value: inner.value }))));
2720
+ }
2721
+ if (effect.type === "transform")
2722
+ if (ctx.common.async === !1) {
2723
+ let base = this._def.schema._parseSync({
2724
+ data: ctx.data,
2725
+ path: ctx.path,
2726
+ parent: ctx
2727
+ });
2728
+ if (!isValid(base))
2729
+ return INVALID;
2730
+ let result = effect.transform(base.value, checkCtx);
2731
+ if (result instanceof Promise)
2732
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2733
+ return { status: status.value, value: result };
2734
+ } else
2735
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => isValid(base) ? Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
2736
+ status: status.value,
2737
+ value: result
2738
+ })) : INVALID);
2739
+ util.assertNever(effect);
2740
+ }
2741
+ };
2742
+ ZodEffects.create = (schema, effect, params) => new ZodEffects({
2743
+ schema,
2744
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2745
+ effect,
2746
+ ...processCreateParams(params)
2747
+ });
2748
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => new ZodEffects({
2749
+ schema,
2750
+ effect: { type: "preprocess", transform: preprocess },
2751
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2752
+ ...processCreateParams(params)
2753
+ });
2754
+ var ZodOptional = class extends ZodType {
2755
+ _parse(input) {
2756
+ return this._getType(input) === ZodParsedType.undefined ? OK(void 0) : this._def.innerType._parse(input);
2757
+ }
2758
+ unwrap() {
2759
+ return this._def.innerType;
2760
+ }
2761
+ };
2762
+ ZodOptional.create = (type, params) => new ZodOptional({
2763
+ innerType: type,
2764
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
2765
+ ...processCreateParams(params)
2766
+ });
2767
+ var ZodNullable = class extends ZodType {
2768
+ _parse(input) {
2769
+ return this._getType(input) === ZodParsedType.null ? OK(null) : this._def.innerType._parse(input);
2770
+ }
2771
+ unwrap() {
2772
+ return this._def.innerType;
2773
+ }
2774
+ };
2775
+ ZodNullable.create = (type, params) => new ZodNullable({
2776
+ innerType: type,
2777
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
2778
+ ...processCreateParams(params)
2779
+ });
2780
+ var ZodDefault = class extends ZodType {
2781
+ _parse(input) {
2782
+ let { ctx } = this._processInputParams(input), data = ctx.data;
2783
+ return ctx.parsedType === ZodParsedType.undefined && (data = this._def.defaultValue()), this._def.innerType._parse({
2784
+ data,
2785
+ path: ctx.path,
2786
+ parent: ctx
2787
+ });
2788
+ }
2789
+ removeDefault() {
2790
+ return this._def.innerType;
2791
+ }
2792
+ };
2793
+ ZodDefault.create = (type, params) => new ZodDefault({
2794
+ innerType: type,
2795
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
2796
+ defaultValue: typeof params.default == "function" ? params.default : () => params.default,
2797
+ ...processCreateParams(params)
2798
+ });
2799
+ var ZodCatch = class extends ZodType {
2800
+ _parse(input) {
2801
+ let { ctx } = this._processInputParams(input), newCtx = {
2802
+ ...ctx,
2803
+ common: {
2804
+ ...ctx.common,
2805
+ issues: []
2806
+ }
2807
+ }, result = this._def.innerType._parse({
2808
+ data: newCtx.data,
2809
+ path: newCtx.path,
2810
+ parent: {
2811
+ ...newCtx
2812
+ }
2813
+ });
2814
+ return isAsync(result) ? result.then((result2) => ({
2815
+ status: "valid",
2816
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
2817
+ get error() {
2818
+ return new ZodError(newCtx.common.issues);
2819
+ },
2820
+ input: newCtx.data
2821
+ })
2822
+ })) : {
2823
+ status: "valid",
2824
+ value: result.status === "valid" ? result.value : this._def.catchValue({
2825
+ get error() {
2826
+ return new ZodError(newCtx.common.issues);
2827
+ },
2828
+ input: newCtx.data
2829
+ })
2830
+ };
2831
+ }
2832
+ removeCatch() {
2833
+ return this._def.innerType;
2834
+ }
2835
+ };
2836
+ ZodCatch.create = (type, params) => new ZodCatch({
2837
+ innerType: type,
2838
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
2839
+ catchValue: typeof params.catch == "function" ? params.catch : () => params.catch,
2840
+ ...processCreateParams(params)
2841
+ });
2842
+ var ZodNaN = class extends ZodType {
2843
+ _parse(input) {
2844
+ if (this._getType(input) !== ZodParsedType.nan) {
2845
+ let ctx = this._getOrReturnCtx(input);
2846
+ return addIssueToContext(ctx, {
2847
+ code: ZodIssueCode.invalid_type,
2848
+ expected: ZodParsedType.nan,
2849
+ received: ctx.parsedType
2850
+ }), INVALID;
2851
+ }
2852
+ return { status: "valid", value: input.data };
2853
+ }
2854
+ };
2855
+ ZodNaN.create = (params) => new ZodNaN({
2856
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
2857
+ ...processCreateParams(params)
2858
+ });
2859
+ var BRAND = Symbol("zod_brand"), ZodBranded = class extends ZodType {
2860
+ _parse(input) {
2861
+ let { ctx } = this._processInputParams(input), data = ctx.data;
2862
+ return this._def.type._parse({
2863
+ data,
2864
+ path: ctx.path,
2865
+ parent: ctx
2866
+ });
2867
+ }
2868
+ unwrap() {
2869
+ return this._def.type;
2870
+ }
2871
+ }, ZodPipeline = class _ZodPipeline extends ZodType {
2872
+ _parse(input) {
2873
+ let { status, ctx } = this._processInputParams(input);
2874
+ if (ctx.common.async)
2875
+ return (async () => {
2876
+ let inResult = await this._def.in._parseAsync({
2877
+ data: ctx.data,
2878
+ path: ctx.path,
2879
+ parent: ctx
2880
+ });
2881
+ return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), DIRTY(inResult.value)) : this._def.out._parseAsync({
2882
+ data: inResult.value,
2883
+ path: ctx.path,
2884
+ parent: ctx
2885
+ });
2886
+ })();
2887
+ {
2888
+ let inResult = this._def.in._parseSync({
2889
+ data: ctx.data,
2890
+ path: ctx.path,
2891
+ parent: ctx
2892
+ });
2893
+ return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), {
2894
+ status: "dirty",
2895
+ value: inResult.value
2896
+ }) : this._def.out._parseSync({
2897
+ data: inResult.value,
2898
+ path: ctx.path,
2899
+ parent: ctx
2900
+ });
2901
+ }
2902
+ }
2903
+ static create(a, b) {
2904
+ return new _ZodPipeline({
2905
+ in: a,
2906
+ out: b,
2907
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
2908
+ });
2909
+ }
2910
+ }, ZodReadonly = class extends ZodType {
2911
+ _parse(input) {
2912
+ let result = this._def.innerType._parse(input), freeze = (data) => (isValid(data) && (data.value = Object.freeze(data.value)), data);
2913
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
2914
+ }
2915
+ unwrap() {
2916
+ return this._def.innerType;
2917
+ }
2918
+ };
2919
+ ZodReadonly.create = (type, params) => new ZodReadonly({
2920
+ innerType: type,
2921
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
2922
+ ...processCreateParams(params)
2923
+ });
2924
+ function cleanParams(params, data) {
2925
+ let p = typeof params == "function" ? params(data) : typeof params == "string" ? { message: params } : params;
2926
+ return typeof p == "string" ? { message: p } : p;
2927
+ }
2928
+ function custom(check, _params = {}, fatal) {
2929
+ return check ? ZodAny.create().superRefine((data, ctx) => {
2930
+ let r = check(data);
2931
+ if (r instanceof Promise)
2932
+ return r.then((r2) => {
2933
+ if (!r2) {
2934
+ let params = cleanParams(_params, data), _fatal = params.fatal ?? fatal ?? !0;
2935
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
2936
+ }
2937
+ });
2938
+ if (!r) {
2939
+ let params = cleanParams(_params, data), _fatal = params.fatal ?? fatal ?? !0;
2940
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
2941
+ }
2942
+ }) : ZodAny.create();
2943
+ }
2944
+ var late = {
2945
+ object: ZodObject.lazycreate
2946
+ }, ZodFirstPartyTypeKind;
2947
+ (function(ZodFirstPartyTypeKind2) {
2948
+ ZodFirstPartyTypeKind2.ZodString = "ZodString", ZodFirstPartyTypeKind2.ZodNumber = "ZodNumber", ZodFirstPartyTypeKind2.ZodNaN = "ZodNaN", ZodFirstPartyTypeKind2.ZodBigInt = "ZodBigInt", ZodFirstPartyTypeKind2.ZodBoolean = "ZodBoolean", ZodFirstPartyTypeKind2.ZodDate = "ZodDate", ZodFirstPartyTypeKind2.ZodSymbol = "ZodSymbol", ZodFirstPartyTypeKind2.ZodUndefined = "ZodUndefined", ZodFirstPartyTypeKind2.ZodNull = "ZodNull", ZodFirstPartyTypeKind2.ZodAny = "ZodAny", ZodFirstPartyTypeKind2.ZodUnknown = "ZodUnknown", ZodFirstPartyTypeKind2.ZodNever = "ZodNever", ZodFirstPartyTypeKind2.ZodVoid = "ZodVoid", ZodFirstPartyTypeKind2.ZodArray = "ZodArray", ZodFirstPartyTypeKind2.ZodObject = "ZodObject", ZodFirstPartyTypeKind2.ZodUnion = "ZodUnion", ZodFirstPartyTypeKind2.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", ZodFirstPartyTypeKind2.ZodIntersection = "ZodIntersection", ZodFirstPartyTypeKind2.ZodTuple = "ZodTuple", ZodFirstPartyTypeKind2.ZodRecord = "ZodRecord", ZodFirstPartyTypeKind2.ZodMap = "ZodMap", ZodFirstPartyTypeKind2.ZodSet = "ZodSet", ZodFirstPartyTypeKind2.ZodFunction = "ZodFunction", ZodFirstPartyTypeKind2.ZodLazy = "ZodLazy", ZodFirstPartyTypeKind2.ZodLiteral = "ZodLiteral", ZodFirstPartyTypeKind2.ZodEnum = "ZodEnum", ZodFirstPartyTypeKind2.ZodEffects = "ZodEffects", ZodFirstPartyTypeKind2.ZodNativeEnum = "ZodNativeEnum", ZodFirstPartyTypeKind2.ZodOptional = "ZodOptional", ZodFirstPartyTypeKind2.ZodNullable = "ZodNullable", ZodFirstPartyTypeKind2.ZodDefault = "ZodDefault", ZodFirstPartyTypeKind2.ZodCatch = "ZodCatch", ZodFirstPartyTypeKind2.ZodPromise = "ZodPromise", ZodFirstPartyTypeKind2.ZodBranded = "ZodBranded", ZodFirstPartyTypeKind2.ZodPipeline = "ZodPipeline", ZodFirstPartyTypeKind2.ZodReadonly = "ZodReadonly";
2949
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2950
+ var instanceOfType = (cls, params = {
2951
+ message: `Input not instance of ${cls.name}`
2952
+ }) => custom((data) => data instanceof cls, params), stringType = ZodString.create, numberType = ZodNumber.create, nanType = ZodNaN.create, bigIntType = ZodBigInt.create, booleanType = ZodBoolean.create, dateType = ZodDate.create, symbolType = ZodSymbol.create, undefinedType = ZodUndefined.create, nullType = ZodNull.create, anyType = ZodAny.create, unknownType = ZodUnknown.create, neverType = ZodNever.create, voidType = ZodVoid.create, arrayType = ZodArray.create, objectType = ZodObject.create, strictObjectType = ZodObject.strictCreate, unionType = ZodUnion.create, discriminatedUnionType = ZodDiscriminatedUnion.create, intersectionType = ZodIntersection.create, tupleType = ZodTuple.create, recordType = ZodRecord.create, mapType = ZodMap.create, setType = ZodSet.create, functionType = ZodFunction.create, lazyType = ZodLazy.create, literalType = ZodLiteral.create, enumType = ZodEnum.create, nativeEnumType = ZodNativeEnum.create, promiseType = ZodPromise.create, effectsType = ZodEffects.create, optionalType = ZodOptional.create, nullableType = ZodNullable.create, preprocessType = ZodEffects.createWithPreprocess, pipelineType = ZodPipeline.create, ostring = () => stringType().optional(), onumber = () => numberType().optional(), oboolean = () => booleanType().optional(), coerce = {
2953
+ string: ((arg) => ZodString.create({ ...arg, coerce: !0 })),
2954
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: !0 })),
2955
+ boolean: ((arg) => ZodBoolean.create({
2956
+ ...arg,
2957
+ coerce: !0
2958
+ })),
2959
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: !0 })),
2960
+ date: ((arg) => ZodDate.create({ ...arg, coerce: !0 }))
2961
+ };
2962
+ var NEVER = INVALID;
2963
+
2964
+ // src/cli/globalSettings.ts
2965
+ var DEFAULT_SETTINGS_PATH = join(homedir(), ".storybook", "settings.json"), VERSION = 1, statusValue = external_exports.strictObject({
2966
+ status: external_exports.enum(["open", "accepted", "done", "skipped"]).optional(),
2967
+ mutedAt: external_exports.number().optional()
2968
+ }).optional(), userSettingSchema = external_exports.object({
2969
+ version: external_exports.number(),
2970
+ // NOTE: every key (and subkey) below must be optional, for forwards compatibility reasons
2971
+ // (we can remove keys once they are deprecated)
2972
+ userSince: external_exports.number().optional(),
2973
+ init: external_exports.object({ skipOnboarding: external_exports.boolean().optional() }).optional(),
2974
+ checklist: external_exports.object({
2975
+ items: external_exports.object({
2976
+ accessibilityTests: statusValue,
2977
+ autodocs: statusValue,
2978
+ ciTests: statusValue,
2979
+ controls: statusValue,
2980
+ coverage: statusValue,
2981
+ guidedTour: statusValue,
2982
+ installA11y: statusValue,
2983
+ installChromatic: statusValue,
2984
+ installDocs: statusValue,
2985
+ installVitest: statusValue,
2986
+ mdxDocs: statusValue,
2987
+ moreComponents: statusValue,
2988
+ moreStories: statusValue,
2989
+ onboardingSurvey: statusValue,
2990
+ organizeStories: statusValue,
2991
+ publishStorybook: statusValue,
2992
+ renderComponent: statusValue,
2993
+ runTests: statusValue,
2994
+ viewports: statusValue,
2995
+ visualTests: statusValue,
2996
+ whatsNewStorybook10: statusValue,
2997
+ writeInteractions: statusValue
2998
+ }).optional(),
2999
+ widget: external_exports.object({ disable: external_exports.boolean().optional() }).optional()
3000
+ }).optional()
3001
+ }), settings;
3002
+ async function globalSettings(filePath = DEFAULT_SETTINGS_PATH) {
3003
+ if (settings)
3004
+ return settings;
3005
+ try {
3006
+ let content = await fs.readFile(filePath, "utf8"), settingsValue = userSettingSchema.parse(JSON.parse(content));
3007
+ settings = new Settings(filePath, settingsValue);
3008
+ } catch {
3009
+ settings = new Settings(filePath, { version: VERSION, userSince: Date.now() }), await settings.save();
3010
+ }
3011
+ return settings;
3012
+ }
3013
+ function _clearGlobalSettings() {
3014
+ settings = void 0;
3015
+ }
3016
+ var Settings = class {
3017
+ /**
3018
+ * Create a new Settings instance
3019
+ *
3020
+ * @param filePath Path to the JSON settings file
3021
+ * @param value Loaded value of settings
3022
+ */
3023
+ constructor(filePath, value) {
3024
+ this.filePath = filePath, this.value = value;
3025
+ }
3026
+ /** Save settings to the file */
3027
+ async save() {
3028
+ invariant(this.filePath, "No file path to save settings to");
3029
+ try {
3030
+ await fs.mkdir(dirname(this.filePath), { recursive: !0 }), await fs.writeFile(this.filePath, JSON.stringify(this.value, null, 2));
3031
+ } catch (err) {
3032
+ console.warn(import_ts_dedent.dedent`
3033
+ Unable to save global settings file to ${this.filePath}
3034
+ ${err && `Reason: ${err.message ?? err}`}`);
3035
+ }
3036
+ }
3037
+ };
3038
+
3039
+ export {
3040
+ globalSettings,
3041
+ _clearGlobalSettings,
3042
+ Settings
3043
+ };