drizzle-kit 0.20.17-b2e8c7f → 0.20.17-b4f119e

Sign up to get free protection for your applications and to get access to all the features.
package/utils-studio.js CHANGED
@@ -33,522 +33,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
37
- function assembleStyles() {
38
- const codes = /* @__PURE__ */ new Map();
39
- for (const [groupName, group] of Object.entries(styles)) {
40
- for (const [styleName, style] of Object.entries(group)) {
41
- styles[styleName] = {
42
- open: `\x1B[${style[0]}m`,
43
- close: `\x1B[${style[1]}m`
44
- };
45
- group[styleName] = styles[styleName];
46
- codes.set(style[0], style[1]);
47
- }
48
- Object.defineProperty(styles, groupName, {
49
- value: group,
50
- enumerable: false
51
- });
52
- }
53
- Object.defineProperty(styles, "codes", {
54
- value: codes,
55
- enumerable: false
56
- });
57
- styles.color.close = "\x1B[39m";
58
- styles.bgColor.close = "\x1B[49m";
59
- styles.color.ansi = wrapAnsi16();
60
- styles.color.ansi256 = wrapAnsi256();
61
- styles.color.ansi16m = wrapAnsi16m();
62
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
63
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
64
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
65
- Object.defineProperties(styles, {
66
- rgbToAnsi256: {
67
- value(red, green, blue) {
68
- if (red === green && green === blue) {
69
- if (red < 8) {
70
- return 16;
71
- }
72
- if (red > 248) {
73
- return 231;
74
- }
75
- return Math.round((red - 8) / 247 * 24) + 232;
76
- }
77
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
78
- },
79
- enumerable: false
80
- },
81
- hexToRgb: {
82
- value(hex) {
83
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
84
- if (!matches) {
85
- return [0, 0, 0];
86
- }
87
- let [colorString] = matches;
88
- if (colorString.length === 3) {
89
- colorString = [...colorString].map((character) => character + character).join("");
90
- }
91
- const integer = Number.parseInt(colorString, 16);
92
- return [
93
- /* eslint-disable no-bitwise */
94
- integer >> 16 & 255,
95
- integer >> 8 & 255,
96
- integer & 255
97
- /* eslint-enable no-bitwise */
98
- ];
99
- },
100
- enumerable: false
101
- },
102
- hexToAnsi256: {
103
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
104
- enumerable: false
105
- },
106
- ansi256ToAnsi: {
107
- value(code) {
108
- if (code < 8) {
109
- return 30 + code;
110
- }
111
- if (code < 16) {
112
- return 90 + (code - 8);
113
- }
114
- let red;
115
- let green;
116
- let blue;
117
- if (code >= 232) {
118
- red = ((code - 232) * 10 + 8) / 255;
119
- green = red;
120
- blue = red;
121
- } else {
122
- code -= 16;
123
- const remainder = code % 36;
124
- red = Math.floor(code / 36) / 5;
125
- green = Math.floor(remainder / 6) / 5;
126
- blue = remainder % 6 / 5;
127
- }
128
- const value = Math.max(red, green, blue) * 2;
129
- if (value === 0) {
130
- return 30;
131
- }
132
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
133
- if (value === 2) {
134
- result += 60;
135
- }
136
- return result;
137
- },
138
- enumerable: false
139
- },
140
- rgbToAnsi: {
141
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
142
- enumerable: false
143
- },
144
- hexToAnsi: {
145
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
146
- enumerable: false
147
- }
148
- });
149
- return styles;
150
- }
151
- var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
152
- var init_ansi_styles = __esm({
153
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
154
- ANSI_BACKGROUND_OFFSET = 10;
155
- wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
156
- wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
157
- wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
158
- styles = {
159
- modifier: {
160
- reset: [0, 0],
161
- // 21 isn't widely supported and 22 does the same thing
162
- bold: [1, 22],
163
- dim: [2, 22],
164
- italic: [3, 23],
165
- underline: [4, 24],
166
- overline: [53, 55],
167
- inverse: [7, 27],
168
- hidden: [8, 28],
169
- strikethrough: [9, 29]
170
- },
171
- color: {
172
- black: [30, 39],
173
- red: [31, 39],
174
- green: [32, 39],
175
- yellow: [33, 39],
176
- blue: [34, 39],
177
- magenta: [35, 39],
178
- cyan: [36, 39],
179
- white: [37, 39],
180
- // Bright color
181
- blackBright: [90, 39],
182
- gray: [90, 39],
183
- // Alias of `blackBright`
184
- grey: [90, 39],
185
- // Alias of `blackBright`
186
- redBright: [91, 39],
187
- greenBright: [92, 39],
188
- yellowBright: [93, 39],
189
- blueBright: [94, 39],
190
- magentaBright: [95, 39],
191
- cyanBright: [96, 39],
192
- whiteBright: [97, 39]
193
- },
194
- bgColor: {
195
- bgBlack: [40, 49],
196
- bgRed: [41, 49],
197
- bgGreen: [42, 49],
198
- bgYellow: [43, 49],
199
- bgBlue: [44, 49],
200
- bgMagenta: [45, 49],
201
- bgCyan: [46, 49],
202
- bgWhite: [47, 49],
203
- // Bright color
204
- bgBlackBright: [100, 49],
205
- bgGray: [100, 49],
206
- // Alias of `bgBlackBright`
207
- bgGrey: [100, 49],
208
- // Alias of `bgBlackBright`
209
- bgRedBright: [101, 49],
210
- bgGreenBright: [102, 49],
211
- bgYellowBright: [103, 49],
212
- bgBlueBright: [104, 49],
213
- bgMagentaBright: [105, 49],
214
- bgCyanBright: [106, 49],
215
- bgWhiteBright: [107, 49]
216
- }
217
- };
218
- modifierNames = Object.keys(styles.modifier);
219
- foregroundColorNames = Object.keys(styles.color);
220
- backgroundColorNames = Object.keys(styles.bgColor);
221
- colorNames = [...foregroundColorNames, ...backgroundColorNames];
222
- ansiStyles = assembleStyles();
223
- ansi_styles_default = ansiStyles;
224
- }
225
- });
226
-
227
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
228
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
229
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
230
- const position = argv.indexOf(prefix + flag);
231
- const terminatorPosition = argv.indexOf("--");
232
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
233
- }
234
- function envForceColor() {
235
- if ("FORCE_COLOR" in env) {
236
- if (env.FORCE_COLOR === "true") {
237
- return 1;
238
- }
239
- if (env.FORCE_COLOR === "false") {
240
- return 0;
241
- }
242
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
243
- }
244
- }
245
- function translateLevel(level) {
246
- if (level === 0) {
247
- return false;
248
- }
249
- return {
250
- level,
251
- hasBasic: true,
252
- has256: level >= 2,
253
- has16m: level >= 3
254
- };
255
- }
256
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
257
- const noFlagForceColor = envForceColor();
258
- if (noFlagForceColor !== void 0) {
259
- flagForceColor = noFlagForceColor;
260
- }
261
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
262
- if (forceColor === 0) {
263
- return 0;
264
- }
265
- if (sniffFlags) {
266
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
267
- return 3;
268
- }
269
- if (hasFlag("color=256")) {
270
- return 2;
271
- }
272
- }
273
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
274
- return 1;
275
- }
276
- if (haveStream && !streamIsTTY && forceColor === void 0) {
277
- return 0;
278
- }
279
- const min = forceColor || 0;
280
- if (env.TERM === "dumb") {
281
- return min;
282
- }
283
- if (import_node_process.default.platform === "win32") {
284
- const osRelease = import_node_os.default.release().split(".");
285
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
286
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
287
- }
288
- return 1;
289
- }
290
- if ("CI" in env) {
291
- if ("GITHUB_ACTIONS" in env) {
292
- return 3;
293
- }
294
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
295
- return 1;
296
- }
297
- return min;
298
- }
299
- if ("TEAMCITY_VERSION" in env) {
300
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
301
- }
302
- if (env.COLORTERM === "truecolor") {
303
- return 3;
304
- }
305
- if (env.TERM === "xterm-kitty") {
306
- return 3;
307
- }
308
- if ("TERM_PROGRAM" in env) {
309
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
310
- switch (env.TERM_PROGRAM) {
311
- case "iTerm.app": {
312
- return version >= 3 ? 3 : 2;
313
- }
314
- case "Apple_Terminal": {
315
- return 2;
316
- }
317
- }
318
- }
319
- if (/-256(color)?$/i.test(env.TERM)) {
320
- return 2;
321
- }
322
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
323
- return 1;
324
- }
325
- if ("COLORTERM" in env) {
326
- return 1;
327
- }
328
- return min;
329
- }
330
- function createSupportsColor(stream, options = {}) {
331
- const level = _supportsColor(stream, {
332
- streamIsTTY: stream && stream.isTTY,
333
- ...options
334
- });
335
- return translateLevel(level);
336
- }
337
- var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
338
- var init_supports_color = __esm({
339
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
340
- import_node_process = __toESM(require("node:process"), 1);
341
- import_node_os = __toESM(require("node:os"), 1);
342
- import_node_tty = __toESM(require("node:tty"), 1);
343
- ({ env } = import_node_process.default);
344
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
345
- flagForceColor = 0;
346
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
347
- flagForceColor = 1;
348
- }
349
- supportsColor = {
350
- stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
351
- stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
352
- };
353
- supports_color_default = supportsColor;
354
- }
355
- });
356
-
357
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
358
- function stringReplaceAll(string, substring, replacer) {
359
- let index4 = string.indexOf(substring);
360
- if (index4 === -1) {
361
- return string;
362
- }
363
- const substringLength = substring.length;
364
- let endIndex = 0;
365
- let returnValue = "";
366
- do {
367
- returnValue += string.slice(endIndex, index4) + substring + replacer;
368
- endIndex = index4 + substringLength;
369
- index4 = string.indexOf(substring, endIndex);
370
- } while (index4 !== -1);
371
- returnValue += string.slice(endIndex);
372
- return returnValue;
373
- }
374
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
375
- let endIndex = 0;
376
- let returnValue = "";
377
- do {
378
- const gotCR = string[index4 - 1] === "\r";
379
- returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
380
- endIndex = index4 + 1;
381
- index4 = string.indexOf("\n", endIndex);
382
- } while (index4 !== -1);
383
- returnValue += string.slice(endIndex);
384
- return returnValue;
385
- }
386
- var init_utilities = __esm({
387
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
388
- }
389
- });
390
-
391
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
392
- function createChalk(options) {
393
- return chalkFactory(options);
394
- }
395
- var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr;
396
- var init_source = __esm({
397
- "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
398
- init_ansi_styles();
399
- init_supports_color();
400
- init_utilities();
401
- init_ansi_styles();
402
- ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
403
- GENERATOR = Symbol("GENERATOR");
404
- STYLER = Symbol("STYLER");
405
- IS_EMPTY = Symbol("IS_EMPTY");
406
- levelMapping = [
407
- "ansi",
408
- "ansi",
409
- "ansi256",
410
- "ansi16m"
411
- ];
412
- styles2 = /* @__PURE__ */ Object.create(null);
413
- applyOptions = (object, options = {}) => {
414
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
415
- throw new Error("The `level` option should be an integer from 0 to 3");
416
- }
417
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
418
- object.level = options.level === void 0 ? colorLevel : options.level;
419
- };
420
- chalkFactory = (options) => {
421
- const chalk2 = (...strings) => strings.join(" ");
422
- applyOptions(chalk2, options);
423
- Object.setPrototypeOf(chalk2, createChalk.prototype);
424
- return chalk2;
425
- };
426
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
427
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
428
- styles2[styleName] = {
429
- get() {
430
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
431
- Object.defineProperty(this, styleName, { value: builder });
432
- return builder;
433
- }
434
- };
435
- }
436
- styles2.visible = {
437
- get() {
438
- const builder = createBuilder(this, this[STYLER], true);
439
- Object.defineProperty(this, "visible", { value: builder });
440
- return builder;
441
- }
442
- };
443
- getModelAnsi = (model, level, type, ...arguments_) => {
444
- if (model === "rgb") {
445
- if (level === "ansi16m") {
446
- return ansi_styles_default[type].ansi16m(...arguments_);
447
- }
448
- if (level === "ansi256") {
449
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
450
- }
451
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
452
- }
453
- if (model === "hex") {
454
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
455
- }
456
- return ansi_styles_default[type][model](...arguments_);
457
- };
458
- usedModels = ["rgb", "hex", "ansi256"];
459
- for (const model of usedModels) {
460
- styles2[model] = {
461
- get() {
462
- const { level } = this;
463
- return function(...arguments_) {
464
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
465
- return createBuilder(this, styler, this[IS_EMPTY]);
466
- };
467
- }
468
- };
469
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
470
- styles2[bgModel] = {
471
- get() {
472
- const { level } = this;
473
- return function(...arguments_) {
474
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
475
- return createBuilder(this, styler, this[IS_EMPTY]);
476
- };
477
- }
478
- };
479
- }
480
- proto = Object.defineProperties(() => {
481
- }, {
482
- ...styles2,
483
- level: {
484
- enumerable: true,
485
- get() {
486
- return this[GENERATOR].level;
487
- },
488
- set(level) {
489
- this[GENERATOR].level = level;
490
- }
491
- }
492
- });
493
- createStyler = (open, close, parent) => {
494
- let openAll;
495
- let closeAll;
496
- if (parent === void 0) {
497
- openAll = open;
498
- closeAll = close;
499
- } else {
500
- openAll = parent.openAll + open;
501
- closeAll = close + parent.closeAll;
502
- }
503
- return {
504
- open,
505
- close,
506
- openAll,
507
- closeAll,
508
- parent
509
- };
510
- };
511
- createBuilder = (self2, _styler, _isEmpty) => {
512
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
513
- Object.setPrototypeOf(builder, proto);
514
- builder[GENERATOR] = self2;
515
- builder[STYLER] = _styler;
516
- builder[IS_EMPTY] = _isEmpty;
517
- return builder;
518
- };
519
- applyStyle = (self2, string) => {
520
- if (self2.level <= 0 || !string) {
521
- return self2[IS_EMPTY] ? "" : string;
522
- }
523
- let styler = self2[STYLER];
524
- if (styler === void 0) {
525
- return string;
526
- }
527
- const { openAll, closeAll } = styler;
528
- if (string.includes("\x1B")) {
529
- while (styler !== void 0) {
530
- string = stringReplaceAll(string, styler.close, styler.open);
531
- styler = styler.parent;
532
- }
533
- }
534
- const lfIndex = string.indexOf("\n");
535
- if (lfIndex !== -1) {
536
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
537
- }
538
- return openAll + string + closeAll;
539
- };
540
- Object.defineProperties(createChalk.prototype, styles2);
541
- chalk = createChalk();
542
- chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
543
- }
544
- });
545
-
546
36
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
547
37
  var require_readline = __commonJS({
548
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
38
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports2) {
549
39
  "use strict";
550
- Object.defineProperty(exports, "__esModule", { value: true });
551
- exports.prepareReadLine = void 0;
40
+ Object.defineProperty(exports2, "__esModule", { value: true });
41
+ exports2.prepareReadLine = void 0;
552
42
  var prepareReadLine = () => {
553
43
  const stdin = process.stdin;
554
44
  const stdout = process.stdout;
@@ -564,13 +54,13 @@ var require_readline = __commonJS({
564
54
  closable: rl
565
55
  };
566
56
  };
567
- exports.prepareReadLine = prepareReadLine;
57
+ exports2.prepareReadLine = prepareReadLine;
568
58
  }
569
59
  });
570
60
 
571
61
  // node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
572
62
  var require_src = __commonJS({
573
- "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
63
+ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) {
574
64
  "use strict";
575
65
  var ESC = "\x1B";
576
66
  var CSI = `${ESC}[`;
@@ -631,10 +121,10 @@ var require_src = __commonJS({
631
121
 
632
122
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
633
123
  var require_utils = __commonJS({
634
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
124
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports2) {
635
125
  "use strict";
636
- Object.defineProperty(exports, "__esModule", { value: true });
637
- exports.clear = void 0;
126
+ Object.defineProperty(exports2, "__esModule", { value: true });
127
+ exports2.clear = void 0;
638
128
  var sisteransi_1 = require_src();
639
129
  var strip = (str) => {
640
130
  const pattern = [
@@ -655,13 +145,13 @@ var require_utils = __commonJS({
655
145
  }
656
146
  return sisteransi_1.erase.lines(rows);
657
147
  };
658
- exports.clear = clear;
148
+ exports2.clear = clear;
659
149
  }
660
150
  });
661
151
 
662
152
  // node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
663
153
  var require_lodash = __commonJS({
664
- "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module2) {
154
+ "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports2, module2) {
665
155
  var FUNC_ERROR_TEXT = "Expected a function";
666
156
  var NAN = 0 / 0;
667
157
  var symbolTag = "[object Symbol]";
@@ -809,9 +299,9 @@ var require_lodash = __commonJS({
809
299
 
810
300
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
811
301
  var require_hanji = __commonJS({
812
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports) {
302
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports2) {
813
303
  "use strict";
814
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
304
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
815
305
  function adopt(value) {
816
306
  return value instanceof P ? value : new P(function(resolve) {
817
307
  resolve(value);
@@ -838,11 +328,11 @@ var require_hanji = __commonJS({
838
328
  step((generator = generator.apply(thisArg, _arguments || [])).next());
839
329
  });
840
330
  };
841
- var __importDefault = exports && exports.__importDefault || function(mod) {
331
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
842
332
  return mod && mod.__esModule ? mod : { "default": mod };
843
333
  };
844
- Object.defineProperty(exports, "__esModule", { value: true });
845
- exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
334
+ Object.defineProperty(exports2, "__esModule", { value: true });
335
+ exports2.onTerminate = exports2.renderWithTask = exports2.render = exports2.TaskTerminal = exports2.TaskView = exports2.Terminal = exports2.deferred = exports2.SelectState = exports2.Prompt = void 0;
846
336
  var readline_1 = require_readline();
847
337
  var sisteransi_1 = require_src();
848
338
  var utils_1 = require_utils();
@@ -877,7 +367,7 @@ var require_hanji = __commonJS({
877
367
  this.inputCallbacks.forEach((it) => it(str, key));
878
368
  }
879
369
  };
880
- exports.Prompt = Prompt2;
370
+ exports2.Prompt = Prompt2;
881
371
  var SelectState2 = class {
882
372
  constructor(items) {
883
373
  this.items = items;
@@ -905,7 +395,7 @@ var require_hanji = __commonJS({
905
395
  return false;
906
396
  }
907
397
  };
908
- exports.SelectState = SelectState2;
398
+ exports2.SelectState = SelectState2;
909
399
  var deferred = () => {
910
400
  let resolve;
911
401
  let reject;
@@ -919,7 +409,7 @@ var require_hanji = __commonJS({
919
409
  promise
920
410
  };
921
411
  };
922
- exports.deferred = deferred;
412
+ exports2.deferred = deferred;
923
413
  var Terminal = class {
924
414
  constructor(view, stdin, stdout, closable) {
925
415
  this.view = view;
@@ -964,7 +454,7 @@ var require_hanji = __commonJS({
964
454
  };
965
455
  this.stdin.on("keypress", keypress);
966
456
  this.view.attach(this);
967
- const { resolve, promise } = (0, exports.deferred)();
457
+ const { resolve, promise } = (0, exports2.deferred)();
968
458
  this.resolve = resolve;
969
459
  this.promise = promise;
970
460
  this.renderFunc = (0, lodash_throttle_1.default)((str) => {
@@ -995,7 +485,7 @@ var require_hanji = __commonJS({
995
485
  this.renderFunc(`${clearPrefix}${string}`);
996
486
  }
997
487
  };
998
- exports.Terminal = Terminal;
488
+ exports2.Terminal = Terminal;
999
489
  var TaskView2 = class {
1000
490
  constructor() {
1001
491
  this.attachCallbacks = [];
@@ -1020,7 +510,7 @@ var require_hanji = __commonJS({
1020
510
  }
1021
511
  }
1022
512
  };
1023
- exports.TaskView = TaskView2;
513
+ exports2.TaskView = TaskView2;
1024
514
  var TaskTerminal = class {
1025
515
  constructor(view, stdout) {
1026
516
  this.view = view;
@@ -1041,7 +531,7 @@ var require_hanji = __commonJS({
1041
531
  this.stdout.write(`${clearPrefix}${string}`);
1042
532
  }
1043
533
  };
1044
- exports.TaskTerminal = TaskTerminal;
534
+ exports2.TaskTerminal = TaskTerminal;
1045
535
  function render2(view) {
1046
536
  const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
1047
537
  if (view instanceof Prompt2) {
@@ -1054,7 +544,7 @@ var require_hanji = __commonJS({
1054
544
  closable.close();
1055
545
  return;
1056
546
  }
1057
- exports.render = render2;
547
+ exports2.render = render2;
1058
548
  function renderWithTask2(view, task) {
1059
549
  return __awaiter(this, void 0, void 0, function* () {
1060
550
  const terminal = new TaskTerminal(view, process.stdout);
@@ -1064,12 +554,12 @@ var require_hanji = __commonJS({
1064
554
  return result;
1065
555
  });
1066
556
  }
1067
- exports.renderWithTask = renderWithTask2;
557
+ exports2.renderWithTask = renderWithTask2;
1068
558
  var terminateHandler;
1069
559
  function onTerminate(callback) {
1070
560
  terminateHandler = callback;
1071
561
  }
1072
- exports.onTerminate = onTerminate;
562
+ exports2.onTerminate = onTerminate;
1073
563
  }
1074
564
  });
1075
565
 
@@ -1083,11 +573,12 @@ var init_global = __esm({
1083
573
  }
1084
574
  });
1085
575
 
1086
- // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
576
+ // node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs
1087
577
  function getErrorMap() {
1088
578
  return overrideErrorMap;
1089
579
  }
1090
580
  function addIssueToContext(ctx, issueData) {
581
+ const overrideMap = getErrorMap();
1091
582
  const issue = makeIssue({
1092
583
  issueData,
1093
584
  data: ctx.data,
@@ -1095,13 +586,29 @@ function addIssueToContext(ctx, issueData) {
1095
586
  errorMaps: [
1096
587
  ctx.common.contextualErrorMap,
1097
588
  ctx.schemaErrorMap,
1098
- getErrorMap(),
1099
- errorMap
589
+ overrideMap,
590
+ overrideMap === errorMap ? void 0 : errorMap
1100
591
  // then global default map
1101
592
  ].filter((x) => !!x)
1102
593
  });
1103
594
  ctx.common.issues.push(issue);
1104
595
  }
596
+ function __classPrivateFieldGet(receiver, state, kind, f) {
597
+ if (kind === "a" && !f)
598
+ throw new TypeError("Private accessor was defined without a getter");
599
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
600
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
601
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
602
+ }
603
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
604
+ if (kind === "m")
605
+ throw new TypeError("Private method is not writable");
606
+ if (kind === "a" && !f)
607
+ throw new TypeError("Private accessor was defined without a setter");
608
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
609
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
610
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
611
+ }
1105
612
  function processCreateParams(params) {
1106
613
  if (!params)
1107
614
  return {};
@@ -1112,15 +619,50 @@ function processCreateParams(params) {
1112
619
  if (errorMap2)
1113
620
  return { errorMap: errorMap2, description };
1114
621
  const customMap = (iss, ctx) => {
1115
- if (iss.code !== "invalid_type")
1116
- return { message: ctx.defaultError };
622
+ var _a, _b;
623
+ const { message } = params;
624
+ if (iss.code === "invalid_enum_value") {
625
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
626
+ }
1117
627
  if (typeof ctx.data === "undefined") {
1118
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
628
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1119
629
  }
1120
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
630
+ if (iss.code !== "invalid_type")
631
+ return { message: ctx.defaultError };
632
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
1121
633
  };
1122
634
  return { errorMap: customMap, description };
1123
635
  }
636
+ function timeRegexSource(args) {
637
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
638
+ if (args.precision) {
639
+ regex = `${regex}\\.\\d{${args.precision}}`;
640
+ } else if (args.precision == null) {
641
+ regex = `${regex}(\\.\\d+)?`;
642
+ }
643
+ return regex;
644
+ }
645
+ function timeRegex(args) {
646
+ return new RegExp(`^${timeRegexSource(args)}$`);
647
+ }
648
+ function datetimeRegex(args) {
649
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
650
+ const opts = [];
651
+ opts.push(args.local ? `Z?` : `Z`);
652
+ if (args.offset)
653
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
654
+ regex = `${regex}(${opts.join("|")})`;
655
+ return new RegExp(`^${regex}$`);
656
+ }
657
+ function isValidIP(ip, version) {
658
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
659
+ return true;
660
+ }
661
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
662
+ return true;
663
+ }
664
+ return false;
665
+ }
1124
666
  function floatSafeRemainder(val, step) {
1125
667
  const valDecCount = (val.toString().split(".")[1] || "").length;
1126
668
  const stepDecCount = (step.toString().split(".")[1] || "").length;
@@ -1141,7 +683,10 @@ function deepPartialify(schema3) {
1141
683
  shape: () => newShape
1142
684
  });
1143
685
  } else if (schema3 instanceof ZodArray) {
1144
- return ZodArray.create(deepPartialify(schema3.element));
686
+ return new ZodArray({
687
+ ...schema3._def,
688
+ type: deepPartialify(schema3.element)
689
+ });
1145
690
  } else if (schema3 instanceof ZodOptional) {
1146
691
  return ZodOptional.create(deepPartialify(schema3.unwrap()));
1147
692
  } else if (schema3 instanceof ZodNullable) {
@@ -1197,9 +742,9 @@ function createZodEnum(values, params) {
1197
742
  ...processCreateParams(params)
1198
743
  });
1199
744
  }
1200
- var util, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, ParseInputLazyPath, handleResult, ZodType, cuidRegex, uuidRegex, emailRegex, datetimeRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, objectUtil, AugmentFactory, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType;
745
+ var util, objectUtil, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, _ZodEnum_cache, _ZodNativeEnum_cache, ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv6Regex, base64Regex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType;
1201
746
  var init_lib = __esm({
1202
- "node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs"() {
747
+ "node_modules/.pnpm/zod@3.23.4/node_modules/zod/lib/index.mjs"() {
1203
748
  (function(util2) {
1204
749
  util2.assertEqual = (val) => val;
1205
750
  function assertIs(_arg) {
@@ -1257,6 +802,15 @@ var init_lib = __esm({
1257
802
  return value;
1258
803
  };
1259
804
  })(util || (util = {}));
805
+ (function(objectUtil2) {
806
+ objectUtil2.mergeShapes = (first, second) => {
807
+ return {
808
+ ...first,
809
+ ...second
810
+ // second overwrites first
811
+ };
812
+ };
813
+ })(objectUtil || (objectUtil = {}));
1260
814
  ZodParsedType = util.arrayToEnum([
1261
815
  "string",
1262
816
  "nan",
@@ -1338,7 +892,7 @@ var init_lib = __esm({
1338
892
  "not_multiple_of",
1339
893
  "not_finite"
1340
894
  ]);
1341
- ZodError = class extends Error {
895
+ ZodError = class _ZodError extends Error {
1342
896
  constructor(issues) {
1343
897
  super();
1344
898
  this.issues = [];
@@ -1396,6 +950,11 @@ var init_lib = __esm({
1396
950
  processError(this);
1397
951
  return fieldErrors;
1398
952
  }
953
+ static assert(value) {
954
+ if (!(value instanceof _ZodError)) {
955
+ throw new Error(`Not a ZodError: ${value}`);
956
+ }
957
+ }
1399
958
  toString() {
1400
959
  return this.message;
1401
960
  }
@@ -1462,7 +1021,12 @@ var init_lib = __esm({
1462
1021
  break;
1463
1022
  case ZodIssueCode.invalid_string:
1464
1023
  if (typeof issue.validation === "object") {
1465
- if ("startsWith" in issue.validation) {
1024
+ if ("includes" in issue.validation) {
1025
+ message = `Invalid input: must include "${issue.validation.includes}"`;
1026
+ if (typeof issue.validation.position === "number") {
1027
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1028
+ }
1029
+ } else if ("startsWith" in issue.validation) {
1466
1030
  message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1467
1031
  } else if ("endsWith" in issue.validation) {
1468
1032
  message = `Invalid input: must end with "${issue.validation.endsWith}"`;
@@ -1483,7 +1047,7 @@ var init_lib = __esm({
1483
1047
  else if (issue.type === "number")
1484
1048
  message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1485
1049
  else if (issue.type === "date")
1486
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
1050
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1487
1051
  else
1488
1052
  message = "Invalid input";
1489
1053
  break;
@@ -1494,8 +1058,10 @@ var init_lib = __esm({
1494
1058
  message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1495
1059
  else if (issue.type === "number")
1496
1060
  message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1061
+ else if (issue.type === "bigint")
1062
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1497
1063
  else if (issue.type === "date")
1498
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
1064
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1499
1065
  else
1500
1066
  message = "Invalid input";
1501
1067
  break;
@@ -1525,6 +1091,13 @@ var init_lib = __esm({
1525
1091
  ...issueData,
1526
1092
  path: fullPath
1527
1093
  };
1094
+ if (issueData.message !== void 0) {
1095
+ return {
1096
+ ...issueData,
1097
+ path: fullPath,
1098
+ message: issueData.message
1099
+ };
1100
+ }
1528
1101
  let errorMessage = "";
1529
1102
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
1530
1103
  for (const map of maps) {
@@ -1533,7 +1106,7 @@ var init_lib = __esm({
1533
1106
  return {
1534
1107
  ...issueData,
1535
1108
  path: fullPath,
1536
- message: issueData.message || errorMessage
1109
+ message: errorMessage
1537
1110
  };
1538
1111
  };
1539
1112
  ParseStatus = class _ParseStatus {
@@ -1562,9 +1135,11 @@ var init_lib = __esm({
1562
1135
  static async mergeObjectAsync(status, pairs) {
1563
1136
  const syncPairs = [];
1564
1137
  for (const pair of pairs) {
1138
+ const key = await pair.key;
1139
+ const value = await pair.value;
1565
1140
  syncPairs.push({
1566
- key: await pair.key,
1567
- value: await pair.value
1141
+ key,
1142
+ value
1568
1143
  });
1569
1144
  }
1570
1145
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -1581,7 +1156,7 @@ var init_lib = __esm({
1581
1156
  status.dirty();
1582
1157
  if (value.status === "dirty")
1583
1158
  status.dirty();
1584
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
1159
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1585
1160
  finalObject[key.value] = value.value;
1586
1161
  }
1587
1162
  }
@@ -1596,20 +1171,28 @@ var init_lib = __esm({
1596
1171
  isAborted = (x) => x.status === "aborted";
1597
1172
  isDirty = (x) => x.status === "dirty";
1598
1173
  isValid = (x) => x.status === "valid";
1599
- isAsync = (x) => typeof Promise !== void 0 && x instanceof Promise;
1174
+ isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1600
1175
  (function(errorUtil2) {
1601
1176
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1602
1177
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1603
1178
  })(errorUtil || (errorUtil = {}));
1604
1179
  ParseInputLazyPath = class {
1605
1180
  constructor(parent, value, path2, key) {
1181
+ this._cachedPath = [];
1606
1182
  this.parent = parent;
1607
1183
  this.data = value;
1608
1184
  this._path = path2;
1609
1185
  this._key = key;
1610
1186
  }
1611
1187
  get path() {
1612
- return this._path.concat(this._key);
1188
+ if (!this._cachedPath.length) {
1189
+ if (this._key instanceof Array) {
1190
+ this._cachedPath.push(...this._path, ...this._key);
1191
+ } else {
1192
+ this._cachedPath.push(...this._path, this._key);
1193
+ }
1194
+ }
1195
+ return this._cachedPath;
1613
1196
  }
1614
1197
  };
1615
1198
  handleResult = (ctx, result) => {
@@ -1619,8 +1202,16 @@ var init_lib = __esm({
1619
1202
  if (!ctx.common.issues.length) {
1620
1203
  throw new Error("Validation failed but no issues detected.");
1621
1204
  }
1622
- const error2 = new ZodError(ctx.common.issues);
1623
- return { success: false, error: error2 };
1205
+ return {
1206
+ success: false,
1207
+ get error() {
1208
+ if (this._error)
1209
+ return this._error;
1210
+ const error2 = new ZodError(ctx.common.issues);
1211
+ this._error = error2;
1212
+ return this._error;
1213
+ }
1214
+ };
1624
1215
  }
1625
1216
  };
1626
1217
  ZodType = class {
@@ -1648,6 +1239,7 @@ var init_lib = __esm({
1648
1239
  this.catch = this.catch.bind(this);
1649
1240
  this.describe = this.describe.bind(this);
1650
1241
  this.pipe = this.pipe.bind(this);
1242
+ this.readonly = this.readonly.bind(this);
1651
1243
  this.isNullable = this.isNullable.bind(this);
1652
1244
  this.isOptional = this.isOptional.bind(this);
1653
1245
  }
@@ -1792,28 +1384,29 @@ var init_lib = __esm({
1792
1384
  return this._refinement(refinement);
1793
1385
  }
1794
1386
  optional() {
1795
- return ZodOptional.create(this);
1387
+ return ZodOptional.create(this, this._def);
1796
1388
  }
1797
1389
  nullable() {
1798
- return ZodNullable.create(this);
1390
+ return ZodNullable.create(this, this._def);
1799
1391
  }
1800
1392
  nullish() {
1801
- return this.optional().nullable();
1393
+ return this.nullable().optional();
1802
1394
  }
1803
1395
  array() {
1804
- return ZodArray.create(this);
1396
+ return ZodArray.create(this, this._def);
1805
1397
  }
1806
1398
  promise() {
1807
- return ZodPromise.create(this);
1399
+ return ZodPromise.create(this, this._def);
1808
1400
  }
1809
1401
  or(option) {
1810
- return ZodUnion.create([this, option]);
1402
+ return ZodUnion.create([this, option], this._def);
1811
1403
  }
1812
1404
  and(incoming) {
1813
- return ZodIntersection.create(this, incoming);
1405
+ return ZodIntersection.create(this, incoming, this._def);
1814
1406
  }
1815
1407
  transform(transform) {
1816
1408
  return new ZodEffects({
1409
+ ...processCreateParams(this._def),
1817
1410
  schema: this,
1818
1411
  typeName: ZodFirstPartyTypeKind.ZodEffects,
1819
1412
  effect: { type: "transform", transform }
@@ -1822,6 +1415,7 @@ var init_lib = __esm({
1822
1415
  default(def) {
1823
1416
  const defaultValueFunc = typeof def === "function" ? def : () => def;
1824
1417
  return new ZodDefault({
1418
+ ...processCreateParams(this._def),
1825
1419
  innerType: this,
1826
1420
  defaultValue: defaultValueFunc,
1827
1421
  typeName: ZodFirstPartyTypeKind.ZodDefault
@@ -1831,14 +1425,15 @@ var init_lib = __esm({
1831
1425
  return new ZodBranded({
1832
1426
  typeName: ZodFirstPartyTypeKind.ZodBranded,
1833
1427
  type: this,
1834
- ...processCreateParams(void 0)
1428
+ ...processCreateParams(this._def)
1835
1429
  });
1836
1430
  }
1837
1431
  catch(def) {
1838
- const defaultValueFunc = typeof def === "function" ? def : () => def;
1432
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1839
1433
  return new ZodCatch({
1434
+ ...processCreateParams(this._def),
1840
1435
  innerType: this,
1841
- defaultValue: defaultValueFunc,
1436
+ catchValue: catchValueFunc,
1842
1437
  typeName: ZodFirstPartyTypeKind.ZodCatch
1843
1438
  });
1844
1439
  }
@@ -1852,6 +1447,9 @@ var init_lib = __esm({
1852
1447
  pipe(target) {
1853
1448
  return ZodPipeline.create(this, target);
1854
1449
  }
1450
+ readonly() {
1451
+ return ZodReadonly.create(this);
1452
+ }
1855
1453
  isOptional() {
1856
1454
  return this.safeParse(void 0).success;
1857
1455
  }
@@ -1860,43 +1458,19 @@ var init_lib = __esm({
1860
1458
  }
1861
1459
  };
1862
1460
  cuidRegex = /^c[^\s-]{8,}$/i;
1863
- uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
1864
- emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1865
- datetimeRegex = (args) => {
1866
- if (args.precision) {
1867
- if (args.offset) {
1868
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
1869
- } else {
1870
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
1871
- }
1872
- } else if (args.precision === 0) {
1873
- if (args.offset) {
1874
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
1875
- } else {
1876
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
1877
- }
1878
- } else {
1879
- if (args.offset) {
1880
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
1881
- } else {
1882
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
1883
- }
1884
- }
1885
- };
1461
+ cuid2Regex = /^[0-9a-z]+$/;
1462
+ ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
1463
+ 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;
1464
+ nanoidRegex = /^[a-z0-9_-]{21}$/i;
1465
+ 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)?)??$/;
1466
+ emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1467
+ _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1468
+ 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])$/;
1469
+ ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
1470
+ base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1471
+ 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])))`;
1472
+ dateRegex = new RegExp(`^${dateRegexSource}$`);
1886
1473
  ZodString = class _ZodString extends ZodType {
1887
- constructor() {
1888
- super(...arguments);
1889
- this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
1890
- validation,
1891
- code: ZodIssueCode.invalid_string,
1892
- ...errorUtil.errToObj(message)
1893
- });
1894
- this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
1895
- this.trim = () => new _ZodString({
1896
- ...this._def,
1897
- checks: [...this._def.checks, { kind: "trim" }]
1898
- });
1899
- }
1900
1474
  _parse(input) {
1901
1475
  if (this._def.coerce) {
1902
1476
  input.data = String(input.data);
@@ -1904,15 +1478,11 @@ var init_lib = __esm({
1904
1478
  const parsedType = this._getType(input);
1905
1479
  if (parsedType !== ZodParsedType.string) {
1906
1480
  const ctx2 = this._getOrReturnCtx(input);
1907
- addIssueToContext(
1908
- ctx2,
1909
- {
1910
- code: ZodIssueCode.invalid_type,
1911
- expected: ZodParsedType.string,
1912
- received: ctx2.parsedType
1913
- }
1914
- //
1915
- );
1481
+ addIssueToContext(ctx2, {
1482
+ code: ZodIssueCode.invalid_type,
1483
+ expected: ZodParsedType.string,
1484
+ received: ctx2.parsedType
1485
+ });
1916
1486
  return INVALID;
1917
1487
  }
1918
1488
  const status = new ParseStatus();
@@ -1980,6 +1550,19 @@ var init_lib = __esm({
1980
1550
  });
1981
1551
  status.dirty();
1982
1552
  }
1553
+ } else if (check.kind === "emoji") {
1554
+ if (!emojiRegex) {
1555
+ emojiRegex = new RegExp(_emojiRegex, "u");
1556
+ }
1557
+ if (!emojiRegex.test(input.data)) {
1558
+ ctx = this._getOrReturnCtx(input, ctx);
1559
+ addIssueToContext(ctx, {
1560
+ validation: "emoji",
1561
+ code: ZodIssueCode.invalid_string,
1562
+ message: check.message
1563
+ });
1564
+ status.dirty();
1565
+ }
1983
1566
  } else if (check.kind === "uuid") {
1984
1567
  if (!uuidRegex.test(input.data)) {
1985
1568
  ctx = this._getOrReturnCtx(input, ctx);
@@ -1990,6 +1573,16 @@ var init_lib = __esm({
1990
1573
  });
1991
1574
  status.dirty();
1992
1575
  }
1576
+ } else if (check.kind === "nanoid") {
1577
+ if (!nanoidRegex.test(input.data)) {
1578
+ ctx = this._getOrReturnCtx(input, ctx);
1579
+ addIssueToContext(ctx, {
1580
+ validation: "nanoid",
1581
+ code: ZodIssueCode.invalid_string,
1582
+ message: check.message
1583
+ });
1584
+ status.dirty();
1585
+ }
1993
1586
  } else if (check.kind === "cuid") {
1994
1587
  if (!cuidRegex.test(input.data)) {
1995
1588
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2000,6 +1593,26 @@ var init_lib = __esm({
2000
1593
  });
2001
1594
  status.dirty();
2002
1595
  }
1596
+ } else if (check.kind === "cuid2") {
1597
+ if (!cuid2Regex.test(input.data)) {
1598
+ ctx = this._getOrReturnCtx(input, ctx);
1599
+ addIssueToContext(ctx, {
1600
+ validation: "cuid2",
1601
+ code: ZodIssueCode.invalid_string,
1602
+ message: check.message
1603
+ });
1604
+ status.dirty();
1605
+ }
1606
+ } else if (check.kind === "ulid") {
1607
+ if (!ulidRegex.test(input.data)) {
1608
+ ctx = this._getOrReturnCtx(input, ctx);
1609
+ addIssueToContext(ctx, {
1610
+ validation: "ulid",
1611
+ code: ZodIssueCode.invalid_string,
1612
+ message: check.message
1613
+ });
1614
+ status.dirty();
1615
+ }
2003
1616
  } else if (check.kind === "url") {
2004
1617
  try {
2005
1618
  new URL(input.data);
@@ -2026,6 +1639,20 @@ var init_lib = __esm({
2026
1639
  }
2027
1640
  } else if (check.kind === "trim") {
2028
1641
  input.data = input.data.trim();
1642
+ } else if (check.kind === "includes") {
1643
+ if (!input.data.includes(check.value, check.position)) {
1644
+ ctx = this._getOrReturnCtx(input, ctx);
1645
+ addIssueToContext(ctx, {
1646
+ code: ZodIssueCode.invalid_string,
1647
+ validation: { includes: check.value, position: check.position },
1648
+ message: check.message
1649
+ });
1650
+ status.dirty();
1651
+ }
1652
+ } else if (check.kind === "toLowerCase") {
1653
+ input.data = input.data.toLowerCase();
1654
+ } else if (check.kind === "toUpperCase") {
1655
+ input.data = input.data.toUpperCase();
2029
1656
  } else if (check.kind === "startsWith") {
2030
1657
  if (!input.data.startsWith(check.value)) {
2031
1658
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2057,12 +1684,71 @@ var init_lib = __esm({
2057
1684
  });
2058
1685
  status.dirty();
2059
1686
  }
1687
+ } else if (check.kind === "date") {
1688
+ const regex = dateRegex;
1689
+ if (!regex.test(input.data)) {
1690
+ ctx = this._getOrReturnCtx(input, ctx);
1691
+ addIssueToContext(ctx, {
1692
+ code: ZodIssueCode.invalid_string,
1693
+ validation: "date",
1694
+ message: check.message
1695
+ });
1696
+ status.dirty();
1697
+ }
1698
+ } else if (check.kind === "time") {
1699
+ const regex = timeRegex(check);
1700
+ if (!regex.test(input.data)) {
1701
+ ctx = this._getOrReturnCtx(input, ctx);
1702
+ addIssueToContext(ctx, {
1703
+ code: ZodIssueCode.invalid_string,
1704
+ validation: "time",
1705
+ message: check.message
1706
+ });
1707
+ status.dirty();
1708
+ }
1709
+ } else if (check.kind === "duration") {
1710
+ if (!durationRegex.test(input.data)) {
1711
+ ctx = this._getOrReturnCtx(input, ctx);
1712
+ addIssueToContext(ctx, {
1713
+ validation: "duration",
1714
+ code: ZodIssueCode.invalid_string,
1715
+ message: check.message
1716
+ });
1717
+ status.dirty();
1718
+ }
1719
+ } else if (check.kind === "ip") {
1720
+ if (!isValidIP(input.data, check.version)) {
1721
+ ctx = this._getOrReturnCtx(input, ctx);
1722
+ addIssueToContext(ctx, {
1723
+ validation: "ip",
1724
+ code: ZodIssueCode.invalid_string,
1725
+ message: check.message
1726
+ });
1727
+ status.dirty();
1728
+ }
1729
+ } else if (check.kind === "base64") {
1730
+ if (!base64Regex.test(input.data)) {
1731
+ ctx = this._getOrReturnCtx(input, ctx);
1732
+ addIssueToContext(ctx, {
1733
+ validation: "base64",
1734
+ code: ZodIssueCode.invalid_string,
1735
+ message: check.message
1736
+ });
1737
+ status.dirty();
1738
+ }
2060
1739
  } else {
2061
1740
  util.assertNever(check);
2062
1741
  }
2063
1742
  }
2064
1743
  return { status: status.value, value: input.data };
2065
1744
  }
1745
+ _regex(regex, validation, message) {
1746
+ return this.refinement((data) => regex.test(data), {
1747
+ validation,
1748
+ code: ZodIssueCode.invalid_string,
1749
+ ...errorUtil.errToObj(message)
1750
+ });
1751
+ }
2066
1752
  _addCheck(check) {
2067
1753
  return new _ZodString({
2068
1754
  ...this._def,
@@ -2075,19 +1761,38 @@ var init_lib = __esm({
2075
1761
  url(message) {
2076
1762
  return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2077
1763
  }
1764
+ emoji(message) {
1765
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1766
+ }
2078
1767
  uuid(message) {
2079
1768
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2080
1769
  }
1770
+ nanoid(message) {
1771
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1772
+ }
2081
1773
  cuid(message) {
2082
1774
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2083
1775
  }
1776
+ cuid2(message) {
1777
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1778
+ }
1779
+ ulid(message) {
1780
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1781
+ }
1782
+ base64(message) {
1783
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1784
+ }
1785
+ ip(options) {
1786
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1787
+ }
2084
1788
  datetime(options) {
2085
- var _a;
1789
+ var _a, _b;
2086
1790
  if (typeof options === "string") {
2087
1791
  return this._addCheck({
2088
1792
  kind: "datetime",
2089
1793
  precision: null,
2090
1794
  offset: false,
1795
+ local: false,
2091
1796
  message: options
2092
1797
  });
2093
1798
  }
@@ -2095,9 +1800,30 @@ var init_lib = __esm({
2095
1800
  kind: "datetime",
2096
1801
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2097
1802
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1803
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2098
1804
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2099
1805
  });
2100
1806
  }
1807
+ date(message) {
1808
+ return this._addCheck({ kind: "date", message });
1809
+ }
1810
+ time(options) {
1811
+ if (typeof options === "string") {
1812
+ return this._addCheck({
1813
+ kind: "time",
1814
+ precision: null,
1815
+ message: options
1816
+ });
1817
+ }
1818
+ return this._addCheck({
1819
+ kind: "time",
1820
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1821
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1822
+ });
1823
+ }
1824
+ duration(message) {
1825
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1826
+ }
2101
1827
  regex(regex, message) {
2102
1828
  return this._addCheck({
2103
1829
  kind: "regex",
@@ -2105,6 +1831,14 @@ var init_lib = __esm({
2105
1831
  ...errorUtil.errToObj(message)
2106
1832
  });
2107
1833
  }
1834
+ includes(value, options) {
1835
+ return this._addCheck({
1836
+ kind: "includes",
1837
+ value,
1838
+ position: options === null || options === void 0 ? void 0 : options.position,
1839
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1840
+ });
1841
+ }
2108
1842
  startsWith(value, message) {
2109
1843
  return this._addCheck({
2110
1844
  kind: "startsWith",
@@ -2133,29 +1867,295 @@ var init_lib = __esm({
2133
1867
  ...errorUtil.errToObj(message)
2134
1868
  });
2135
1869
  }
2136
- length(len, message) {
1870
+ length(len, message) {
1871
+ return this._addCheck({
1872
+ kind: "length",
1873
+ value: len,
1874
+ ...errorUtil.errToObj(message)
1875
+ });
1876
+ }
1877
+ /**
1878
+ * @deprecated Use z.string().min(1) instead.
1879
+ * @see {@link ZodString.min}
1880
+ */
1881
+ nonempty(message) {
1882
+ return this.min(1, errorUtil.errToObj(message));
1883
+ }
1884
+ trim() {
1885
+ return new _ZodString({
1886
+ ...this._def,
1887
+ checks: [...this._def.checks, { kind: "trim" }]
1888
+ });
1889
+ }
1890
+ toLowerCase() {
1891
+ return new _ZodString({
1892
+ ...this._def,
1893
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1894
+ });
1895
+ }
1896
+ toUpperCase() {
1897
+ return new _ZodString({
1898
+ ...this._def,
1899
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1900
+ });
1901
+ }
1902
+ get isDatetime() {
1903
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1904
+ }
1905
+ get isDate() {
1906
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1907
+ }
1908
+ get isTime() {
1909
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1910
+ }
1911
+ get isDuration() {
1912
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1913
+ }
1914
+ get isEmail() {
1915
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1916
+ }
1917
+ get isURL() {
1918
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1919
+ }
1920
+ get isEmoji() {
1921
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1922
+ }
1923
+ get isUUID() {
1924
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1925
+ }
1926
+ get isNANOID() {
1927
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1928
+ }
1929
+ get isCUID() {
1930
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1931
+ }
1932
+ get isCUID2() {
1933
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1934
+ }
1935
+ get isULID() {
1936
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1937
+ }
1938
+ get isIP() {
1939
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1940
+ }
1941
+ get isBase64() {
1942
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1943
+ }
1944
+ get minLength() {
1945
+ let min = null;
1946
+ for (const ch of this._def.checks) {
1947
+ if (ch.kind === "min") {
1948
+ if (min === null || ch.value > min)
1949
+ min = ch.value;
1950
+ }
1951
+ }
1952
+ return min;
1953
+ }
1954
+ get maxLength() {
1955
+ let max = null;
1956
+ for (const ch of this._def.checks) {
1957
+ if (ch.kind === "max") {
1958
+ if (max === null || ch.value < max)
1959
+ max = ch.value;
1960
+ }
1961
+ }
1962
+ return max;
1963
+ }
1964
+ };
1965
+ ZodString.create = (params) => {
1966
+ var _a;
1967
+ return new ZodString({
1968
+ checks: [],
1969
+ typeName: ZodFirstPartyTypeKind.ZodString,
1970
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1971
+ ...processCreateParams(params)
1972
+ });
1973
+ };
1974
+ ZodNumber = class _ZodNumber extends ZodType {
1975
+ constructor() {
1976
+ super(...arguments);
1977
+ this.min = this.gte;
1978
+ this.max = this.lte;
1979
+ this.step = this.multipleOf;
1980
+ }
1981
+ _parse(input) {
1982
+ if (this._def.coerce) {
1983
+ input.data = Number(input.data);
1984
+ }
1985
+ const parsedType = this._getType(input);
1986
+ if (parsedType !== ZodParsedType.number) {
1987
+ const ctx2 = this._getOrReturnCtx(input);
1988
+ addIssueToContext(ctx2, {
1989
+ code: ZodIssueCode.invalid_type,
1990
+ expected: ZodParsedType.number,
1991
+ received: ctx2.parsedType
1992
+ });
1993
+ return INVALID;
1994
+ }
1995
+ let ctx = void 0;
1996
+ const status = new ParseStatus();
1997
+ for (const check of this._def.checks) {
1998
+ if (check.kind === "int") {
1999
+ if (!util.isInteger(input.data)) {
2000
+ ctx = this._getOrReturnCtx(input, ctx);
2001
+ addIssueToContext(ctx, {
2002
+ code: ZodIssueCode.invalid_type,
2003
+ expected: "integer",
2004
+ received: "float",
2005
+ message: check.message
2006
+ });
2007
+ status.dirty();
2008
+ }
2009
+ } else if (check.kind === "min") {
2010
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2011
+ if (tooSmall) {
2012
+ ctx = this._getOrReturnCtx(input, ctx);
2013
+ addIssueToContext(ctx, {
2014
+ code: ZodIssueCode.too_small,
2015
+ minimum: check.value,
2016
+ type: "number",
2017
+ inclusive: check.inclusive,
2018
+ exact: false,
2019
+ message: check.message
2020
+ });
2021
+ status.dirty();
2022
+ }
2023
+ } else if (check.kind === "max") {
2024
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2025
+ if (tooBig) {
2026
+ ctx = this._getOrReturnCtx(input, ctx);
2027
+ addIssueToContext(ctx, {
2028
+ code: ZodIssueCode.too_big,
2029
+ maximum: check.value,
2030
+ type: "number",
2031
+ inclusive: check.inclusive,
2032
+ exact: false,
2033
+ message: check.message
2034
+ });
2035
+ status.dirty();
2036
+ }
2037
+ } else if (check.kind === "multipleOf") {
2038
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
2039
+ ctx = this._getOrReturnCtx(input, ctx);
2040
+ addIssueToContext(ctx, {
2041
+ code: ZodIssueCode.not_multiple_of,
2042
+ multipleOf: check.value,
2043
+ message: check.message
2044
+ });
2045
+ status.dirty();
2046
+ }
2047
+ } else if (check.kind === "finite") {
2048
+ if (!Number.isFinite(input.data)) {
2049
+ ctx = this._getOrReturnCtx(input, ctx);
2050
+ addIssueToContext(ctx, {
2051
+ code: ZodIssueCode.not_finite,
2052
+ message: check.message
2053
+ });
2054
+ status.dirty();
2055
+ }
2056
+ } else {
2057
+ util.assertNever(check);
2058
+ }
2059
+ }
2060
+ return { status: status.value, value: input.data };
2061
+ }
2062
+ gte(value, message) {
2063
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2064
+ }
2065
+ gt(value, message) {
2066
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2067
+ }
2068
+ lte(value, message) {
2069
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2070
+ }
2071
+ lt(value, message) {
2072
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2073
+ }
2074
+ setLimit(kind, value, inclusive, message) {
2075
+ return new _ZodNumber({
2076
+ ...this._def,
2077
+ checks: [
2078
+ ...this._def.checks,
2079
+ {
2080
+ kind,
2081
+ value,
2082
+ inclusive,
2083
+ message: errorUtil.toString(message)
2084
+ }
2085
+ ]
2086
+ });
2087
+ }
2088
+ _addCheck(check) {
2089
+ return new _ZodNumber({
2090
+ ...this._def,
2091
+ checks: [...this._def.checks, check]
2092
+ });
2093
+ }
2094
+ int(message) {
2095
+ return this._addCheck({
2096
+ kind: "int",
2097
+ message: errorUtil.toString(message)
2098
+ });
2099
+ }
2100
+ positive(message) {
2101
+ return this._addCheck({
2102
+ kind: "min",
2103
+ value: 0,
2104
+ inclusive: false,
2105
+ message: errorUtil.toString(message)
2106
+ });
2107
+ }
2108
+ negative(message) {
2109
+ return this._addCheck({
2110
+ kind: "max",
2111
+ value: 0,
2112
+ inclusive: false,
2113
+ message: errorUtil.toString(message)
2114
+ });
2115
+ }
2116
+ nonpositive(message) {
2117
+ return this._addCheck({
2118
+ kind: "max",
2119
+ value: 0,
2120
+ inclusive: true,
2121
+ message: errorUtil.toString(message)
2122
+ });
2123
+ }
2124
+ nonnegative(message) {
2125
+ return this._addCheck({
2126
+ kind: "min",
2127
+ value: 0,
2128
+ inclusive: true,
2129
+ message: errorUtil.toString(message)
2130
+ });
2131
+ }
2132
+ multipleOf(value, message) {
2133
+ return this._addCheck({
2134
+ kind: "multipleOf",
2135
+ value,
2136
+ message: errorUtil.toString(message)
2137
+ });
2138
+ }
2139
+ finite(message) {
2140
+ return this._addCheck({
2141
+ kind: "finite",
2142
+ message: errorUtil.toString(message)
2143
+ });
2144
+ }
2145
+ safe(message) {
2137
2146
  return this._addCheck({
2138
- kind: "length",
2139
- value: len,
2140
- ...errorUtil.errToObj(message)
2147
+ kind: "min",
2148
+ inclusive: true,
2149
+ value: Number.MIN_SAFE_INTEGER,
2150
+ message: errorUtil.toString(message)
2151
+ })._addCheck({
2152
+ kind: "max",
2153
+ inclusive: true,
2154
+ value: Number.MAX_SAFE_INTEGER,
2155
+ message: errorUtil.toString(message)
2141
2156
  });
2142
2157
  }
2143
- get isDatetime() {
2144
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
2145
- }
2146
- get isEmail() {
2147
- return !!this._def.checks.find((ch) => ch.kind === "email");
2148
- }
2149
- get isURL() {
2150
- return !!this._def.checks.find((ch) => ch.kind === "url");
2151
- }
2152
- get isUUID() {
2153
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
2154
- }
2155
- get isCUID() {
2156
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
2157
- }
2158
- get minLength() {
2158
+ get minValue() {
2159
2159
  let min = null;
2160
2160
  for (const ch of this._def.checks) {
2161
2161
  if (ch.kind === "min") {
@@ -2165,7 +2165,7 @@ var init_lib = __esm({
2165
2165
  }
2166
2166
  return min;
2167
2167
  }
2168
- get maxLength() {
2168
+ get maxValue() {
2169
2169
  let max = null;
2170
2170
  for (const ch of this._def.checks) {
2171
2171
  if (ch.kind === "max") {
@@ -2175,33 +2175,49 @@ var init_lib = __esm({
2175
2175
  }
2176
2176
  return max;
2177
2177
  }
2178
+ get isInt() {
2179
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2180
+ }
2181
+ get isFinite() {
2182
+ let max = null, min = null;
2183
+ for (const ch of this._def.checks) {
2184
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2185
+ return true;
2186
+ } else if (ch.kind === "min") {
2187
+ if (min === null || ch.value > min)
2188
+ min = ch.value;
2189
+ } else if (ch.kind === "max") {
2190
+ if (max === null || ch.value < max)
2191
+ max = ch.value;
2192
+ }
2193
+ }
2194
+ return Number.isFinite(min) && Number.isFinite(max);
2195
+ }
2178
2196
  };
2179
- ZodString.create = (params) => {
2180
- var _a;
2181
- return new ZodString({
2197
+ ZodNumber.create = (params) => {
2198
+ return new ZodNumber({
2182
2199
  checks: [],
2183
- typeName: ZodFirstPartyTypeKind.ZodString,
2184
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2200
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2201
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2185
2202
  ...processCreateParams(params)
2186
2203
  });
2187
2204
  };
2188
- ZodNumber = class _ZodNumber extends ZodType {
2205
+ ZodBigInt = class _ZodBigInt extends ZodType {
2189
2206
  constructor() {
2190
2207
  super(...arguments);
2191
2208
  this.min = this.gte;
2192
2209
  this.max = this.lte;
2193
- this.step = this.multipleOf;
2194
2210
  }
2195
2211
  _parse(input) {
2196
2212
  if (this._def.coerce) {
2197
- input.data = Number(input.data);
2213
+ input.data = BigInt(input.data);
2198
2214
  }
2199
2215
  const parsedType = this._getType(input);
2200
- if (parsedType !== ZodParsedType.number) {
2216
+ if (parsedType !== ZodParsedType.bigint) {
2201
2217
  const ctx2 = this._getOrReturnCtx(input);
2202
2218
  addIssueToContext(ctx2, {
2203
2219
  code: ZodIssueCode.invalid_type,
2204
- expected: ZodParsedType.number,
2220
+ expected: ZodParsedType.bigint,
2205
2221
  received: ctx2.parsedType
2206
2222
  });
2207
2223
  return INVALID;
@@ -2209,27 +2225,15 @@ var init_lib = __esm({
2209
2225
  let ctx = void 0;
2210
2226
  const status = new ParseStatus();
2211
2227
  for (const check of this._def.checks) {
2212
- if (check.kind === "int") {
2213
- if (!util.isInteger(input.data)) {
2214
- ctx = this._getOrReturnCtx(input, ctx);
2215
- addIssueToContext(ctx, {
2216
- code: ZodIssueCode.invalid_type,
2217
- expected: "integer",
2218
- received: "float",
2219
- message: check.message
2220
- });
2221
- status.dirty();
2222
- }
2223
- } else if (check.kind === "min") {
2228
+ if (check.kind === "min") {
2224
2229
  const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2225
2230
  if (tooSmall) {
2226
2231
  ctx = this._getOrReturnCtx(input, ctx);
2227
2232
  addIssueToContext(ctx, {
2228
2233
  code: ZodIssueCode.too_small,
2234
+ type: "bigint",
2229
2235
  minimum: check.value,
2230
- type: "number",
2231
2236
  inclusive: check.inclusive,
2232
- exact: false,
2233
2237
  message: check.message
2234
2238
  });
2235
2239
  status.dirty();
@@ -2240,16 +2244,15 @@ var init_lib = __esm({
2240
2244
  ctx = this._getOrReturnCtx(input, ctx);
2241
2245
  addIssueToContext(ctx, {
2242
2246
  code: ZodIssueCode.too_big,
2247
+ type: "bigint",
2243
2248
  maximum: check.value,
2244
- type: "number",
2245
2249
  inclusive: check.inclusive,
2246
- exact: false,
2247
2250
  message: check.message
2248
2251
  });
2249
2252
  status.dirty();
2250
2253
  }
2251
2254
  } else if (check.kind === "multipleOf") {
2252
- if (floatSafeRemainder(input.data, check.value) !== 0) {
2255
+ if (input.data % check.value !== BigInt(0)) {
2253
2256
  ctx = this._getOrReturnCtx(input, ctx);
2254
2257
  addIssueToContext(ctx, {
2255
2258
  code: ZodIssueCode.not_multiple_of,
@@ -2258,15 +2261,6 @@ var init_lib = __esm({
2258
2261
  });
2259
2262
  status.dirty();
2260
2263
  }
2261
- } else if (check.kind === "finite") {
2262
- if (!Number.isFinite(input.data)) {
2263
- ctx = this._getOrReturnCtx(input, ctx);
2264
- addIssueToContext(ctx, {
2265
- code: ZodIssueCode.not_finite,
2266
- message: check.message
2267
- });
2268
- status.dirty();
2269
- }
2270
2264
  } else {
2271
2265
  util.assertNever(check);
2272
2266
  }
@@ -2286,7 +2280,7 @@ var init_lib = __esm({
2286
2280
  return this.setLimit("max", value, false, errorUtil.toString(message));
2287
2281
  }
2288
2282
  setLimit(kind, value, inclusive, message) {
2289
- return new _ZodNumber({
2283
+ return new _ZodBigInt({
2290
2284
  ...this._def,
2291
2285
  checks: [
2292
2286
  ...this._def.checks,
@@ -2300,21 +2294,15 @@ var init_lib = __esm({
2300
2294
  });
2301
2295
  }
2302
2296
  _addCheck(check) {
2303
- return new _ZodNumber({
2297
+ return new _ZodBigInt({
2304
2298
  ...this._def,
2305
2299
  checks: [...this._def.checks, check]
2306
2300
  });
2307
2301
  }
2308
- int(message) {
2309
- return this._addCheck({
2310
- kind: "int",
2311
- message: errorUtil.toString(message)
2312
- });
2313
- }
2314
2302
  positive(message) {
2315
2303
  return this._addCheck({
2316
2304
  kind: "min",
2317
- value: 0,
2305
+ value: BigInt(0),
2318
2306
  inclusive: false,
2319
2307
  message: errorUtil.toString(message)
2320
2308
  });
@@ -2322,7 +2310,7 @@ var init_lib = __esm({
2322
2310
  negative(message) {
2323
2311
  return this._addCheck({
2324
2312
  kind: "max",
2325
- value: 0,
2313
+ value: BigInt(0),
2326
2314
  inclusive: false,
2327
2315
  message: errorUtil.toString(message)
2328
2316
  });
@@ -2330,7 +2318,7 @@ var init_lib = __esm({
2330
2318
  nonpositive(message) {
2331
2319
  return this._addCheck({
2332
2320
  kind: "max",
2333
- value: 0,
2321
+ value: BigInt(0),
2334
2322
  inclusive: true,
2335
2323
  message: errorUtil.toString(message)
2336
2324
  });
@@ -2338,7 +2326,7 @@ var init_lib = __esm({
2338
2326
  nonnegative(message) {
2339
2327
  return this._addCheck({
2340
2328
  kind: "min",
2341
- value: 0,
2329
+ value: BigInt(0),
2342
2330
  inclusive: true,
2343
2331
  message: errorUtil.toString(message)
2344
2332
  });
@@ -2350,12 +2338,6 @@ var init_lib = __esm({
2350
2338
  message: errorUtil.toString(message)
2351
2339
  });
2352
2340
  }
2353
- finite(message) {
2354
- return this._addCheck({
2355
- kind: "finite",
2356
- message: errorUtil.toString(message)
2357
- });
2358
- }
2359
2341
  get minValue() {
2360
2342
  let min = null;
2361
2343
  for (const ch of this._def.checks) {
@@ -2376,39 +2358,11 @@ var init_lib = __esm({
2376
2358
  }
2377
2359
  return max;
2378
2360
  }
2379
- get isInt() {
2380
- return !!this._def.checks.find((ch) => ch.kind === "int");
2381
- }
2382
- };
2383
- ZodNumber.create = (params) => {
2384
- return new ZodNumber({
2385
- checks: [],
2386
- typeName: ZodFirstPartyTypeKind.ZodNumber,
2387
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2388
- ...processCreateParams(params)
2389
- });
2390
- };
2391
- ZodBigInt = class extends ZodType {
2392
- _parse(input) {
2393
- if (this._def.coerce) {
2394
- input.data = BigInt(input.data);
2395
- }
2396
- const parsedType = this._getType(input);
2397
- if (parsedType !== ZodParsedType.bigint) {
2398
- const ctx = this._getOrReturnCtx(input);
2399
- addIssueToContext(ctx, {
2400
- code: ZodIssueCode.invalid_type,
2401
- expected: ZodParsedType.bigint,
2402
- received: ctx.parsedType
2403
- });
2404
- return INVALID;
2405
- }
2406
- return OK(input.data);
2407
- }
2408
2361
  };
2409
2362
  ZodBigInt.create = (params) => {
2410
2363
  var _a;
2411
2364
  return new ZodBigInt({
2365
+ checks: [],
2412
2366
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
2413
2367
  coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2414
2368
  ...processCreateParams(params)
@@ -2734,13 +2688,13 @@ var init_lib = __esm({
2734
2688
  }
2735
2689
  }
2736
2690
  if (ctx.common.async) {
2737
- return Promise.all(ctx.data.map((item, i) => {
2691
+ return Promise.all([...ctx.data].map((item, i) => {
2738
2692
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2739
2693
  })).then((result2) => {
2740
2694
  return ParseStatus.mergeArray(status, result2);
2741
2695
  });
2742
2696
  }
2743
- const result = ctx.data.map((item, i) => {
2697
+ const result = [...ctx.data].map((item, i) => {
2744
2698
  return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2745
2699
  });
2746
2700
  return ParseStatus.mergeArray(status, result);
@@ -2780,31 +2734,12 @@ var init_lib = __esm({
2780
2734
  ...processCreateParams(params)
2781
2735
  });
2782
2736
  };
2783
- (function(objectUtil2) {
2784
- objectUtil2.mergeShapes = (first, second) => {
2785
- return {
2786
- ...first,
2787
- ...second
2788
- // second overwrites first
2789
- };
2790
- };
2791
- })(objectUtil || (objectUtil = {}));
2792
- AugmentFactory = (def) => (augmentation) => {
2793
- return new ZodObject({
2794
- ...def,
2795
- shape: () => ({
2796
- ...def.shape(),
2797
- ...augmentation
2798
- })
2799
- });
2800
- };
2801
2737
  ZodObject = class _ZodObject extends ZodType {
2802
2738
  constructor() {
2803
2739
  super(...arguments);
2804
2740
  this._cached = null;
2805
2741
  this.nonstrict = this.passthrough;
2806
- this.augment = AugmentFactory(this._def);
2807
- this.extend = AugmentFactory(this._def);
2742
+ this.augment = this.extend;
2808
2743
  }
2809
2744
  _getCached() {
2810
2745
  if (this._cached !== null)
@@ -2885,9 +2820,10 @@ var init_lib = __esm({
2885
2820
  const syncPairs = [];
2886
2821
  for (const pair of pairs) {
2887
2822
  const key = await pair.key;
2823
+ const value = await pair.value;
2888
2824
  syncPairs.push({
2889
2825
  key,
2890
- value: await pair.value,
2826
+ value,
2891
2827
  alwaysSet: pair.alwaysSet
2892
2828
  });
2893
2829
  }
@@ -2934,8 +2870,31 @@ var init_lib = __esm({
2934
2870
  unknownKeys: "passthrough"
2935
2871
  });
2936
2872
  }
2937
- setKey(key, schema3) {
2938
- return this.augment({ [key]: schema3 });
2873
+ // const AugmentFactory =
2874
+ // <Def extends ZodObjectDef>(def: Def) =>
2875
+ // <Augmentation extends ZodRawShape>(
2876
+ // augmentation: Augmentation
2877
+ // ): ZodObject<
2878
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2879
+ // Def["unknownKeys"],
2880
+ // Def["catchall"]
2881
+ // > => {
2882
+ // return new ZodObject({
2883
+ // ...def,
2884
+ // shape: () => ({
2885
+ // ...def.shape(),
2886
+ // ...augmentation,
2887
+ // }),
2888
+ // }) as any;
2889
+ // };
2890
+ extend(augmentation) {
2891
+ return new _ZodObject({
2892
+ ...this._def,
2893
+ shape: () => ({
2894
+ ...this._def.shape(),
2895
+ ...augmentation
2896
+ })
2897
+ });
2939
2898
  }
2940
2899
  /**
2941
2900
  * Prior to zod@1.0.12 there was a bug in the
@@ -2946,11 +2905,73 @@ var init_lib = __esm({
2946
2905
  const merged = new _ZodObject({
2947
2906
  unknownKeys: merging._def.unknownKeys,
2948
2907
  catchall: merging._def.catchall,
2949
- shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2908
+ shape: () => ({
2909
+ ...this._def.shape(),
2910
+ ...merging._def.shape()
2911
+ }),
2950
2912
  typeName: ZodFirstPartyTypeKind.ZodObject
2951
2913
  });
2952
2914
  return merged;
2953
2915
  }
2916
+ // merge<
2917
+ // Incoming extends AnyZodObject,
2918
+ // Augmentation extends Incoming["shape"],
2919
+ // NewOutput extends {
2920
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2921
+ // ? Augmentation[k]["_output"]
2922
+ // : k extends keyof Output
2923
+ // ? Output[k]
2924
+ // : never;
2925
+ // },
2926
+ // NewInput extends {
2927
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2928
+ // ? Augmentation[k]["_input"]
2929
+ // : k extends keyof Input
2930
+ // ? Input[k]
2931
+ // : never;
2932
+ // }
2933
+ // >(
2934
+ // merging: Incoming
2935
+ // ): ZodObject<
2936
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2937
+ // Incoming["_def"]["unknownKeys"],
2938
+ // Incoming["_def"]["catchall"],
2939
+ // NewOutput,
2940
+ // NewInput
2941
+ // > {
2942
+ // const merged: any = new ZodObject({
2943
+ // unknownKeys: merging._def.unknownKeys,
2944
+ // catchall: merging._def.catchall,
2945
+ // shape: () =>
2946
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2947
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2948
+ // }) as any;
2949
+ // return merged;
2950
+ // }
2951
+ setKey(key, schema3) {
2952
+ return this.augment({ [key]: schema3 });
2953
+ }
2954
+ // merge<Incoming extends AnyZodObject>(
2955
+ // merging: Incoming
2956
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2957
+ // ZodObject<
2958
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2959
+ // Incoming["_def"]["unknownKeys"],
2960
+ // Incoming["_def"]["catchall"]
2961
+ // > {
2962
+ // // const mergedShape = objectUtil.mergeShapes(
2963
+ // // this._def.shape(),
2964
+ // // merging._def.shape()
2965
+ // // );
2966
+ // const merged: any = new ZodObject({
2967
+ // unknownKeys: merging._def.unknownKeys,
2968
+ // catchall: merging._def.catchall,
2969
+ // shape: () =>
2970
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2971
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2972
+ // }) as any;
2973
+ // return merged;
2974
+ // }
2954
2975
  catchall(index4) {
2955
2976
  return new _ZodObject({
2956
2977
  ...this._def,
@@ -2959,9 +2980,10 @@ var init_lib = __esm({
2959
2980
  }
2960
2981
  pick(mask) {
2961
2982
  const shape = {};
2962
- util.objectKeys(mask).map((key) => {
2963
- if (this.shape[key])
2983
+ util.objectKeys(mask).forEach((key) => {
2984
+ if (mask[key] && this.shape[key]) {
2964
2985
  shape[key] = this.shape[key];
2986
+ }
2965
2987
  });
2966
2988
  return new _ZodObject({
2967
2989
  ...this._def,
@@ -2970,8 +2992,8 @@ var init_lib = __esm({
2970
2992
  }
2971
2993
  omit(mask) {
2972
2994
  const shape = {};
2973
- util.objectKeys(this.shape).map((key) => {
2974
- if (util.objectKeys(mask).indexOf(key) === -1) {
2995
+ util.objectKeys(this.shape).forEach((key) => {
2996
+ if (!mask[key]) {
2975
2997
  shape[key] = this.shape[key];
2976
2998
  }
2977
2999
  });
@@ -2980,29 +3002,22 @@ var init_lib = __esm({
2980
3002
  shape: () => shape
2981
3003
  });
2982
3004
  }
3005
+ /**
3006
+ * @deprecated
3007
+ */
2983
3008
  deepPartial() {
2984
3009
  return deepPartialify(this);
2985
3010
  }
2986
3011
  partial(mask) {
2987
3012
  const newShape = {};
2988
- if (mask) {
2989
- util.objectKeys(this.shape).map((key) => {
2990
- if (util.objectKeys(mask).indexOf(key) === -1) {
2991
- newShape[key] = this.shape[key];
2992
- } else {
2993
- newShape[key] = this.shape[key].optional();
2994
- }
2995
- });
2996
- return new _ZodObject({
2997
- ...this._def,
2998
- shape: () => newShape
2999
- });
3000
- } else {
3001
- for (const key in this.shape) {
3002
- const fieldSchema = this.shape[key];
3013
+ util.objectKeys(this.shape).forEach((key) => {
3014
+ const fieldSchema = this.shape[key];
3015
+ if (mask && !mask[key]) {
3016
+ newShape[key] = fieldSchema;
3017
+ } else {
3003
3018
  newShape[key] = fieldSchema.optional();
3004
3019
  }
3005
- }
3020
+ });
3006
3021
  return new _ZodObject({
3007
3022
  ...this._def,
3008
3023
  shape: () => newShape
@@ -3010,21 +3025,10 @@ var init_lib = __esm({
3010
3025
  }
3011
3026
  required(mask) {
3012
3027
  const newShape = {};
3013
- if (mask) {
3014
- util.objectKeys(this.shape).map((key) => {
3015
- if (util.objectKeys(mask).indexOf(key) === -1) {
3016
- newShape[key] = this.shape[key];
3017
- } else {
3018
- const fieldSchema = this.shape[key];
3019
- let newField = fieldSchema;
3020
- while (newField instanceof ZodOptional) {
3021
- newField = newField._def.innerType;
3022
- }
3023
- newShape[key] = newField;
3024
- }
3025
- });
3026
- } else {
3027
- for (const key in this.shape) {
3028
+ util.objectKeys(this.shape).forEach((key) => {
3029
+ if (mask && !mask[key]) {
3030
+ newShape[key] = this.shape[key];
3031
+ } else {
3028
3032
  const fieldSchema = this.shape[key];
3029
3033
  let newField = fieldSchema;
3030
3034
  while (newField instanceof ZodOptional) {
@@ -3032,7 +3036,7 @@ var init_lib = __esm({
3032
3036
  }
3033
3037
  newShape[key] = newField;
3034
3038
  }
3035
- }
3039
+ });
3036
3040
  return new _ZodObject({
3037
3041
  ...this._def,
3038
3042
  shape: () => newShape
@@ -3170,15 +3174,25 @@ var init_lib = __esm({
3170
3174
  } else if (type instanceof ZodEnum) {
3171
3175
  return type.options;
3172
3176
  } else if (type instanceof ZodNativeEnum) {
3173
- return Object.keys(type.enum);
3177
+ return util.objectValues(type.enum);
3174
3178
  } else if (type instanceof ZodDefault) {
3175
3179
  return getDiscriminator(type._def.innerType);
3176
3180
  } else if (type instanceof ZodUndefined) {
3177
3181
  return [void 0];
3178
3182
  } else if (type instanceof ZodNull) {
3179
3183
  return [null];
3184
+ } else if (type instanceof ZodOptional) {
3185
+ return [void 0, ...getDiscriminator(type.unwrap())];
3186
+ } else if (type instanceof ZodNullable) {
3187
+ return [null, ...getDiscriminator(type.unwrap())];
3188
+ } else if (type instanceof ZodBranded) {
3189
+ return getDiscriminator(type.unwrap());
3190
+ } else if (type instanceof ZodReadonly) {
3191
+ return getDiscriminator(type.unwrap());
3192
+ } else if (type instanceof ZodCatch) {
3193
+ return getDiscriminator(type._def.innerType);
3180
3194
  } else {
3181
- return null;
3195
+ return [];
3182
3196
  }
3183
3197
  };
3184
3198
  ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -3238,7 +3252,7 @@ var init_lib = __esm({
3238
3252
  const optionsMap = /* @__PURE__ */ new Map();
3239
3253
  for (const type of options) {
3240
3254
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3241
- if (!discriminatorValues) {
3255
+ if (!discriminatorValues.length) {
3242
3256
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3243
3257
  }
3244
3258
  for (const value of discriminatorValues) {
@@ -3342,7 +3356,7 @@ var init_lib = __esm({
3342
3356
  });
3343
3357
  status.dirty();
3344
3358
  }
3345
- const items = ctx.data.map((item, itemIndex) => {
3359
+ const items = [...ctx.data].map((item, itemIndex) => {
3346
3360
  const schema3 = this._def.items[itemIndex] || this._def.rest;
3347
3361
  if (!schema3)
3348
3362
  return null;
@@ -3400,7 +3414,8 @@ var init_lib = __esm({
3400
3414
  for (const key in ctx.data) {
3401
3415
  pairs.push({
3402
3416
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3403
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3417
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3418
+ alwaysSet: key in ctx.data
3404
3419
  });
3405
3420
  }
3406
3421
  if (ctx.common.async) {
@@ -3430,6 +3445,12 @@ var init_lib = __esm({
3430
3445
  }
3431
3446
  };
3432
3447
  ZodMap = class extends ZodType {
3448
+ get keySchema() {
3449
+ return this._def.keyType;
3450
+ }
3451
+ get valueSchema() {
3452
+ return this._def.valueType;
3453
+ }
3433
3454
  _parse(input) {
3434
3455
  const { status, ctx } = this._processInputParams(input);
3435
3456
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -3624,27 +3645,29 @@ var init_lib = __esm({
3624
3645
  const params = { errorMap: ctx.common.contextualErrorMap };
3625
3646
  const fn = ctx.data;
3626
3647
  if (this._def.returns instanceof ZodPromise) {
3627
- return OK(async (...args) => {
3648
+ const me = this;
3649
+ return OK(async function(...args) {
3628
3650
  const error2 = new ZodError([]);
3629
- const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3651
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3630
3652
  error2.addIssue(makeArgsIssue(args, e));
3631
3653
  throw error2;
3632
3654
  });
3633
- const result = await fn(...parsedArgs);
3634
- const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
3655
+ const result = await Reflect.apply(fn, this, parsedArgs);
3656
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3635
3657
  error2.addIssue(makeReturnsIssue(result, e));
3636
3658
  throw error2;
3637
3659
  });
3638
3660
  return parsedReturns;
3639
3661
  });
3640
3662
  } else {
3641
- return OK((...args) => {
3642
- const parsedArgs = this._def.args.safeParse(args, params);
3663
+ const me = this;
3664
+ return OK(function(...args) {
3665
+ const parsedArgs = me._def.args.safeParse(args, params);
3643
3666
  if (!parsedArgs.success) {
3644
3667
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3645
3668
  }
3646
- const result = fn(...parsedArgs.data);
3647
- const parsedReturns = this._def.returns.safeParse(result, params);
3669
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3670
+ const parsedReturns = me._def.returns.safeParse(result, params);
3648
3671
  if (!parsedReturns.success) {
3649
3672
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3650
3673
  }
@@ -3709,6 +3732,7 @@ var init_lib = __esm({
3709
3732
  if (input.data !== this._def.value) {
3710
3733
  const ctx = this._getOrReturnCtx(input);
3711
3734
  addIssueToContext(ctx, {
3735
+ received: ctx.data,
3712
3736
  code: ZodIssueCode.invalid_literal,
3713
3737
  expected: this._def.value
3714
3738
  });
@@ -3727,7 +3751,11 @@ var init_lib = __esm({
3727
3751
  ...processCreateParams(params)
3728
3752
  });
3729
3753
  };
3730
- ZodEnum = class extends ZodType {
3754
+ ZodEnum = class _ZodEnum extends ZodType {
3755
+ constructor() {
3756
+ super(...arguments);
3757
+ _ZodEnum_cache.set(this, void 0);
3758
+ }
3731
3759
  _parse(input) {
3732
3760
  if (typeof input.data !== "string") {
3733
3761
  const ctx = this._getOrReturnCtx(input);
@@ -3739,7 +3767,10 @@ var init_lib = __esm({
3739
3767
  });
3740
3768
  return INVALID;
3741
3769
  }
3742
- if (this._def.values.indexOf(input.data) === -1) {
3770
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3771
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3772
+ }
3773
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3743
3774
  const ctx = this._getOrReturnCtx(input);
3744
3775
  const expectedValues = this._def.values;
3745
3776
  addIssueToContext(ctx, {
@@ -3775,9 +3806,26 @@ var init_lib = __esm({
3775
3806
  }
3776
3807
  return enumValues;
3777
3808
  }
3809
+ extract(values, newDef = this._def) {
3810
+ return _ZodEnum.create(values, {
3811
+ ...this._def,
3812
+ ...newDef
3813
+ });
3814
+ }
3815
+ exclude(values, newDef = this._def) {
3816
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3817
+ ...this._def,
3818
+ ...newDef
3819
+ });
3820
+ }
3778
3821
  };
3822
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3779
3823
  ZodEnum.create = createZodEnum;
3780
3824
  ZodNativeEnum = class extends ZodType {
3825
+ constructor() {
3826
+ super(...arguments);
3827
+ _ZodNativeEnum_cache.set(this, void 0);
3828
+ }
3781
3829
  _parse(input) {
3782
3830
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3783
3831
  const ctx = this._getOrReturnCtx(input);
@@ -3790,7 +3838,10 @@ var init_lib = __esm({
3790
3838
  });
3791
3839
  return INVALID;
3792
3840
  }
3793
- if (nativeEnumValues.indexOf(input.data) === -1) {
3841
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3842
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3843
+ }
3844
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3794
3845
  const expectedValues = util.objectValues(nativeEnumValues);
3795
3846
  addIssueToContext(ctx, {
3796
3847
  received: ctx.data,
@@ -3805,6 +3856,7 @@ var init_lib = __esm({
3805
3856
  return this._def.values;
3806
3857
  }
3807
3858
  };
3859
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3808
3860
  ZodNativeEnum.create = (values, params) => {
3809
3861
  return new ZodNativeEnum({
3810
3862
  values,
@@ -3813,6 +3865,9 @@ var init_lib = __esm({
3813
3865
  });
3814
3866
  };
3815
3867
  ZodPromise = class extends ZodType {
3868
+ unwrap() {
3869
+ return this._def.type;
3870
+ }
3816
3871
  _parse(input) {
3817
3872
  const { ctx } = this._processInputParams(input);
3818
3873
  if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
@@ -3849,24 +3904,6 @@ var init_lib = __esm({
3849
3904
  _parse(input) {
3850
3905
  const { status, ctx } = this._processInputParams(input);
3851
3906
  const effect = this._def.effect || null;
3852
- if (effect.type === "preprocess") {
3853
- const processed = effect.transform(ctx.data);
3854
- if (ctx.common.async) {
3855
- return Promise.resolve(processed).then((processed2) => {
3856
- return this._def.schema._parseAsync({
3857
- data: processed2,
3858
- path: ctx.path,
3859
- parent: ctx
3860
- });
3861
- });
3862
- } else {
3863
- return this._def.schema._parseSync({
3864
- data: processed,
3865
- path: ctx.path,
3866
- parent: ctx
3867
- });
3868
- }
3869
- }
3870
3907
  const checkCtx = {
3871
3908
  addIssue: (arg) => {
3872
3909
  addIssueToContext(ctx, arg);
@@ -3881,6 +3918,42 @@ var init_lib = __esm({
3881
3918
  }
3882
3919
  };
3883
3920
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3921
+ if (effect.type === "preprocess") {
3922
+ const processed = effect.transform(ctx.data, checkCtx);
3923
+ if (ctx.common.async) {
3924
+ return Promise.resolve(processed).then(async (processed2) => {
3925
+ if (status.value === "aborted")
3926
+ return INVALID;
3927
+ const result = await this._def.schema._parseAsync({
3928
+ data: processed2,
3929
+ path: ctx.path,
3930
+ parent: ctx
3931
+ });
3932
+ if (result.status === "aborted")
3933
+ return INVALID;
3934
+ if (result.status === "dirty")
3935
+ return DIRTY(result.value);
3936
+ if (status.value === "dirty")
3937
+ return DIRTY(result.value);
3938
+ return result;
3939
+ });
3940
+ } else {
3941
+ if (status.value === "aborted")
3942
+ return INVALID;
3943
+ const result = this._def.schema._parseSync({
3944
+ data: processed,
3945
+ path: ctx.path,
3946
+ parent: ctx
3947
+ });
3948
+ if (result.status === "aborted")
3949
+ return INVALID;
3950
+ if (result.status === "dirty")
3951
+ return DIRTY(result.value);
3952
+ if (status.value === "dirty")
3953
+ return DIRTY(result.value);
3954
+ return result;
3955
+ }
3956
+ }
3884
3957
  if (effect.type === "refinement") {
3885
3958
  const executeRefinement = (acc) => {
3886
3959
  const result = effect.refinement(acc, checkCtx);
@@ -4023,26 +4096,45 @@ var init_lib = __esm({
4023
4096
  ZodCatch = class extends ZodType {
4024
4097
  _parse(input) {
4025
4098
  const { ctx } = this._processInputParams(input);
4099
+ const newCtx = {
4100
+ ...ctx,
4101
+ common: {
4102
+ ...ctx.common,
4103
+ issues: []
4104
+ }
4105
+ };
4026
4106
  const result = this._def.innerType._parse({
4027
- data: ctx.data,
4028
- path: ctx.path,
4029
- parent: ctx
4107
+ data: newCtx.data,
4108
+ path: newCtx.path,
4109
+ parent: {
4110
+ ...newCtx
4111
+ }
4030
4112
  });
4031
4113
  if (isAsync(result)) {
4032
4114
  return result.then((result2) => {
4033
4115
  return {
4034
4116
  status: "valid",
4035
- value: result2.status === "valid" ? result2.value : this._def.defaultValue()
4117
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
4118
+ get error() {
4119
+ return new ZodError(newCtx.common.issues);
4120
+ },
4121
+ input: newCtx.data
4122
+ })
4036
4123
  };
4037
4124
  });
4038
4125
  } else {
4039
4126
  return {
4040
4127
  status: "valid",
4041
- value: result.status === "valid" ? result.value : this._def.defaultValue()
4128
+ value: result.status === "valid" ? result.value : this._def.catchValue({
4129
+ get error() {
4130
+ return new ZodError(newCtx.common.issues);
4131
+ },
4132
+ input: newCtx.data
4133
+ })
4042
4134
  };
4043
4135
  }
4044
4136
  }
4045
- removeDefault() {
4137
+ removeCatch() {
4046
4138
  return this._def.innerType;
4047
4139
  }
4048
4140
  };
@@ -4050,7 +4142,7 @@ var init_lib = __esm({
4050
4142
  return new ZodCatch({
4051
4143
  innerType: type,
4052
4144
  typeName: ZodFirstPartyTypeKind.ZodCatch,
4053
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4145
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4054
4146
  ...processCreateParams(params)
4055
4147
  });
4056
4148
  };
@@ -4145,6 +4237,25 @@ var init_lib = __esm({
4145
4237
  });
4146
4238
  }
4147
4239
  };
4240
+ ZodReadonly = class extends ZodType {
4241
+ _parse(input) {
4242
+ const result = this._def.innerType._parse(input);
4243
+ if (isValid(result)) {
4244
+ result.value = Object.freeze(result.value);
4245
+ }
4246
+ return result;
4247
+ }
4248
+ unwrap() {
4249
+ return this._def.innerType;
4250
+ }
4251
+ };
4252
+ ZodReadonly.create = (type, params) => {
4253
+ return new ZodReadonly({
4254
+ innerType: type,
4255
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4256
+ ...processCreateParams(params)
4257
+ });
4258
+ };
4148
4259
  late = {
4149
4260
  object: ZodObject.lazycreate
4150
4261
  };
@@ -4184,6 +4295,7 @@ var init_lib = __esm({
4184
4295
  ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4185
4296
  ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4186
4297
  ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4298
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4187
4299
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4188
4300
  stringType = ZodString.create;
4189
4301
  numberType = ZodNumber.create;
@@ -4750,7 +4862,6 @@ var init_utils = __esm({
4750
4862
  init_mysqlSchema();
4751
4863
  init_pgSchema();
4752
4864
  init_sqliteSchema();
4753
- init_source();
4754
4865
  init_global();
4755
4866
  }
4756
4867
  });
@@ -4760,7 +4871,6 @@ var import_hanji;
4760
4871
  var init_views = __esm({
4761
4872
  "src/cli/views.ts"() {
4762
4873
  "use strict";
4763
- init_source();
4764
4874
  import_hanji = __toESM(require_hanji());
4765
4875
  init_utils();
4766
4876
  }
@@ -4772,7 +4882,6 @@ var init_serializer = __esm({
4772
4882
  "src/serializer/index.ts"() {
4773
4883
  "use strict";
4774
4884
  glob = __toESM(require("glob"));
4775
- init_source();
4776
4885
  init_views();
4777
4886
  }
4778
4887
  });
@@ -4781,7 +4890,6 @@ var init_serializer = __esm({
4781
4890
  var init_outputs = __esm({
4782
4891
  "src/cli/validations/outputs.ts"() {
4783
4892
  "use strict";
4784
- init_source();
4785
4893
  }
4786
4894
  });
4787
4895
 
@@ -4833,7 +4941,6 @@ var init_sqliteSerializer = __esm({
4833
4941
  import_sqlite_core2 = require("drizzle-orm/sqlite-core");
4834
4942
  init_serializer();
4835
4943
  init_outputs();
4836
- init_source();
4837
4944
  dialect3 = new import_sqlite_core2.SQLiteSyncDialect();
4838
4945
  fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
4839
4946
  const result = {};
@@ -5034,7 +5141,7 @@ WHERE
5034
5141
 
5035
5142
  // node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
5036
5143
  var require_balanced_match = __commonJS({
5037
- "node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module2) {
5144
+ "node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports2, module2) {
5038
5145
  "use strict";
5039
5146
  module2.exports = balanced;
5040
5147
  function balanced(a, b, str) {
@@ -5094,7 +5201,7 @@ var require_balanced_match = __commonJS({
5094
5201
 
5095
5202
  // node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js
5096
5203
  var require_brace_expansion = __commonJS({
5097
- "node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module2) {
5204
+ "node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports2, module2) {
5098
5205
  var balanced = require_balanced_match();
5099
5206
  module2.exports = expandTop;
5100
5207
  var escSlash = "\0SLASH" + Math.random() + "\0";
@@ -5252,7 +5359,6 @@ var init_pgSerializer = __esm({
5252
5359
  import_pg_core3 = require("drizzle-orm/pg-core");
5253
5360
  import_drizzle_orm2 = require("drizzle-orm");
5254
5361
  init_serializer();
5255
- init_source();
5256
5362
  init_outputs();
5257
5363
  dialect4 = new import_pg_core2.PgDialect();
5258
5364
  trimChar = (str, char) => {
@@ -5940,10 +6046,10 @@ Array.prototype.random = function() {
5940
6046
  return this[~~(Math.random() * this.length)];
5941
6047
  };
5942
6048
 
5943
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
6049
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
5944
6050
  var import_brace_expansion = __toESM(require_brace_expansion(), 1);
5945
6051
 
5946
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/brace-expressions.js
6052
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/brace-expressions.js
5947
6053
  var posixClasses = {
5948
6054
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
5949
6055
  "[:alpha:]": ["\\p{L}\\p{Nl}", true],
@@ -6053,17 +6159,17 @@ var parseClass = (glob2, position) => {
6053
6159
  return [comb, uflag, endPos - pos, true];
6054
6160
  };
6055
6161
 
6056
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/escape.js
6162
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/escape.js
6057
6163
  var escape = (s, { windowsPathsNoEscape = false } = {}) => {
6058
6164
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
6059
6165
  };
6060
6166
 
6061
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/unescape.js
6167
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/unescape.js
6062
6168
  var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
6063
6169
  return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
6064
6170
  };
6065
6171
 
6066
- // node_modules/.pnpm/minimatch@7.4.3/node_modules/minimatch/dist/mjs/index.js
6172
+ // node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
6067
6173
  var minimatch = (p, pattern, options = {}) => {
6068
6174
  assertValidPattern(pattern);
6069
6175
  if (!options.nocomment && pattern.charAt(0) === "#") {