@chaos-maker/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- var He = Object.defineProperty;
2
- var We = (s, e, t) => e in s ? He(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var E = (s, e, t) => We(s, typeof e != "symbol" ? e + "" : e, t);
4
- var b;
1
+ var ht = Object.defineProperty;
2
+ var pt = (s, e, t) => e in s ? ht(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var P = (s, e, t) => pt(s, typeof e != "symbol" ? e + "" : e, t);
4
+ var C;
5
5
  (function(s) {
6
6
  s.assertEqual = (n) => {
7
7
  };
@@ -13,40 +13,40 @@ var b;
13
13
  }
14
14
  s.assertNever = t, s.arrayToEnum = (n) => {
15
15
  const a = {};
16
- for (const o of n)
17
- a[o] = o;
16
+ for (const i of n)
17
+ a[i] = i;
18
18
  return a;
19
19
  }, s.getValidEnumValues = (n) => {
20
- const a = s.objectKeys(n).filter((i) => typeof n[n[i]] != "number"), o = {};
21
- for (const i of a)
22
- o[i] = n[i];
23
- return s.objectValues(o);
20
+ const a = s.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
21
+ for (const o of a)
22
+ i[o] = n[o];
23
+ return s.objectValues(i);
24
24
  }, s.objectValues = (n) => s.objectKeys(n).map(function(a) {
25
25
  return n[a];
26
26
  }), s.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
27
27
  const a = [];
28
- for (const o in n)
29
- Object.prototype.hasOwnProperty.call(n, o) && a.push(o);
28
+ for (const i in n)
29
+ Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
30
30
  return a;
31
31
  }, s.find = (n, a) => {
32
- for (const o of n)
33
- if (a(o))
34
- return o;
32
+ for (const i of n)
33
+ if (a(i))
34
+ return i;
35
35
  }, s.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
36
36
  function r(n, a = " | ") {
37
- return n.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
37
+ return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
38
38
  }
39
39
  s.joinValues = r, s.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
40
- })(b || (b = {}));
41
- var _e;
40
+ })(C || (C = {}));
41
+ var Ze;
42
42
  (function(s) {
43
43
  s.mergeShapes = (e, t) => ({
44
44
  ...e,
45
45
  ...t
46
46
  // second overwrites first
47
47
  });
48
- })(_e || (_e = {}));
49
- const h = b.arrayToEnum([
48
+ })(Ze || (Ze = {}));
49
+ const h = C.arrayToEnum([
50
50
  "string",
51
51
  "nan",
52
52
  "number",
@@ -67,7 +67,7 @@ const h = b.arrayToEnum([
67
67
  "never",
68
68
  "map",
69
69
  "set"
70
- ]), V = (s) => {
70
+ ]), K = (s) => {
71
71
  switch (typeof s) {
72
72
  case "undefined":
73
73
  return h.undefined;
@@ -88,7 +88,7 @@ const h = b.arrayToEnum([
88
88
  default:
89
89
  return h.unknown;
90
90
  }
91
- }, c = b.arrayToEnum([
91
+ }, u = C.arrayToEnum([
92
92
  "invalid_type",
93
93
  "invalid_literal",
94
94
  "custom",
@@ -106,7 +106,7 @@ const h = b.arrayToEnum([
106
106
  "not_multiple_of",
107
107
  "not_finite"
108
108
  ]);
109
- class P extends Error {
109
+ class J extends Error {
110
110
  get errors() {
111
111
  return this.issues;
112
112
  }
@@ -123,34 +123,34 @@ class P extends Error {
123
123
  const t = e || function(a) {
124
124
  return a.message;
125
125
  }, r = { _errors: [] }, n = (a) => {
126
- for (const o of a.issues)
127
- if (o.code === "invalid_union")
128
- o.unionErrors.map(n);
129
- else if (o.code === "invalid_return_type")
130
- n(o.returnTypeError);
131
- else if (o.code === "invalid_arguments")
132
- n(o.argumentsError);
133
- else if (o.path.length === 0)
134
- r._errors.push(t(o));
126
+ for (const i of a.issues)
127
+ if (i.code === "invalid_union")
128
+ i.unionErrors.map(n);
129
+ else if (i.code === "invalid_return_type")
130
+ n(i.returnTypeError);
131
+ else if (i.code === "invalid_arguments")
132
+ n(i.argumentsError);
133
+ else if (i.path.length === 0)
134
+ r._errors.push(t(i));
135
135
  else {
136
- let i = r, d = 0;
137
- for (; d < o.path.length; ) {
138
- const l = o.path[d];
139
- d === o.path.length - 1 ? (i[l] = i[l] || { _errors: [] }, i[l]._errors.push(t(o))) : i[l] = i[l] || { _errors: [] }, i = i[l], d++;
136
+ let o = r, l = 0;
137
+ for (; l < i.path.length; ) {
138
+ const c = i.path[l];
139
+ l === i.path.length - 1 ? (o[c] = o[c] || { _errors: [] }, o[c]._errors.push(t(i))) : o[c] = o[c] || { _errors: [] }, o = o[c], l++;
140
140
  }
141
141
  }
142
142
  };
143
143
  return n(this), r;
144
144
  }
145
145
  static assert(e) {
146
- if (!(e instanceof P))
146
+ if (!(e instanceof J))
147
147
  throw new Error(`Not a ZodError: ${e}`);
148
148
  }
149
149
  toString() {
150
150
  return this.message;
151
151
  }
152
152
  get message() {
153
- return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
153
+ return JSON.stringify(this.issues, C.jsonStringifyReplacer, 2);
154
154
  }
155
155
  get isEmpty() {
156
156
  return this.issues.length === 0;
@@ -169,69 +169,69 @@ class P extends Error {
169
169
  return this.flatten();
170
170
  }
171
171
  }
172
- P.create = (s) => new P(s);
173
- const le = (s, e) => {
172
+ J.create = (s) => new J(s);
173
+ const Te = (s, e) => {
174
174
  let t;
175
175
  switch (s.code) {
176
- case c.invalid_type:
176
+ case u.invalid_type:
177
177
  s.received === h.undefined ? t = "Required" : t = `Expected ${s.expected}, received ${s.received}`;
178
178
  break;
179
- case c.invalid_literal:
180
- t = `Invalid literal value, expected ${JSON.stringify(s.expected, b.jsonStringifyReplacer)}`;
179
+ case u.invalid_literal:
180
+ t = `Invalid literal value, expected ${JSON.stringify(s.expected, C.jsonStringifyReplacer)}`;
181
181
  break;
182
- case c.unrecognized_keys:
183
- t = `Unrecognized key(s) in object: ${b.joinValues(s.keys, ", ")}`;
182
+ case u.unrecognized_keys:
183
+ t = `Unrecognized key(s) in object: ${C.joinValues(s.keys, ", ")}`;
184
184
  break;
185
- case c.invalid_union:
185
+ case u.invalid_union:
186
186
  t = "Invalid input";
187
187
  break;
188
- case c.invalid_union_discriminator:
189
- t = `Invalid discriminator value. Expected ${b.joinValues(s.options)}`;
188
+ case u.invalid_union_discriminator:
189
+ t = `Invalid discriminator value. Expected ${C.joinValues(s.options)}`;
190
190
  break;
191
- case c.invalid_enum_value:
192
- t = `Invalid enum value. Expected ${b.joinValues(s.options)}, received '${s.received}'`;
191
+ case u.invalid_enum_value:
192
+ t = `Invalid enum value. Expected ${C.joinValues(s.options)}, received '${s.received}'`;
193
193
  break;
194
- case c.invalid_arguments:
194
+ case u.invalid_arguments:
195
195
  t = "Invalid function arguments";
196
196
  break;
197
- case c.invalid_return_type:
197
+ case u.invalid_return_type:
198
198
  t = "Invalid function return type";
199
199
  break;
200
- case c.invalid_date:
200
+ case u.invalid_date:
201
201
  t = "Invalid date";
202
202
  break;
203
- case c.invalid_string:
204
- typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : b.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
203
+ case u.invalid_string:
204
+ typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : C.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
205
205
  break;
206
- case c.too_small:
206
+ case u.too_small:
207
207
  s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "more than"} ${s.minimum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "over"} ${s.minimum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "bigint" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(s.minimum))}` : t = "Invalid input";
208
208
  break;
209
- case c.too_big:
209
+ case u.too_big:
210
210
  s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "less than"} ${s.maximum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "under"} ${s.maximum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "bigint" ? t = `BigInt must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly" : s.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(s.maximum))}` : t = "Invalid input";
211
211
  break;
212
- case c.custom:
212
+ case u.custom:
213
213
  t = "Invalid input";
214
214
  break;
215
- case c.invalid_intersection_types:
215
+ case u.invalid_intersection_types:
216
216
  t = "Intersection results could not be merged";
217
217
  break;
218
- case c.not_multiple_of:
218
+ case u.not_multiple_of:
219
219
  t = `Number must be a multiple of ${s.multipleOf}`;
220
220
  break;
221
- case c.not_finite:
221
+ case u.not_finite:
222
222
  t = "Number must be finite";
223
223
  break;
224
224
  default:
225
- t = e.defaultError, b.assertNever(s);
225
+ t = e.defaultError, C.assertNever(s);
226
226
  }
227
227
  return { message: t };
228
228
  };
229
- let Xe = le;
230
- function Ge() {
231
- return Xe;
229
+ let mt = Te;
230
+ function yt() {
231
+ return mt;
232
232
  }
233
- const Je = (s) => {
234
- const { data: e, path: t, errorMaps: r, issueData: n } = s, a = [...t, ...n.path || []], o = {
233
+ const gt = (s) => {
234
+ const { data: e, path: t, errorMaps: r, issueData: n } = s, a = [...t, ...n.path || []], i = {
235
235
  ...n,
236
236
  path: a
237
237
  };
@@ -241,18 +241,18 @@ const Je = (s) => {
241
241
  path: a,
242
242
  message: n.message
243
243
  };
244
- let i = "";
245
- const d = r.filter((l) => !!l).slice().reverse();
246
- for (const l of d)
247
- i = l(o, { data: e, defaultError: i }).message;
244
+ let o = "";
245
+ const l = r.filter((c) => !!c).slice().reverse();
246
+ for (const c of l)
247
+ o = c(i, { data: e, defaultError: o }).message;
248
248
  return {
249
249
  ...n,
250
250
  path: a,
251
- message: i
251
+ message: o
252
252
  };
253
253
  };
254
- function u(s, e) {
255
- const t = Ge(), r = Je({
254
+ function f(s, e) {
255
+ const t = yt(), r = gt({
256
256
  issueData: e,
257
257
  data: s.data,
258
258
  path: s.path,
@@ -263,13 +263,13 @@ function u(s, e) {
263
263
  // then schema-bound map if available
264
264
  t,
265
265
  // then global override map
266
- t === le ? void 0 : le
266
+ t === Te ? void 0 : Te
267
267
  // then global default map
268
268
  ].filter((n) => !!n)
269
269
  });
270
270
  s.common.issues.push(r);
271
271
  }
272
- class O {
272
+ class $ {
273
273
  constructor() {
274
274
  this.value = "valid";
275
275
  }
@@ -283,7 +283,7 @@ class O {
283
283
  const r = [];
284
284
  for (const n of t) {
285
285
  if (n.status === "aborted")
286
- return g;
286
+ return _;
287
287
  n.status === "dirty" && e.dirty(), r.push(n.value);
288
288
  }
289
289
  return { status: e.value, value: r };
@@ -291,33 +291,33 @@ class O {
291
291
  static async mergeObjectAsync(e, t) {
292
292
  const r = [];
293
293
  for (const n of t) {
294
- const a = await n.key, o = await n.value;
294
+ const a = await n.key, i = await n.value;
295
295
  r.push({
296
296
  key: a,
297
- value: o
297
+ value: i
298
298
  });
299
299
  }
300
- return O.mergeObjectSync(e, r);
300
+ return $.mergeObjectSync(e, r);
301
301
  }
302
302
  static mergeObjectSync(e, t) {
303
303
  const r = {};
304
304
  for (const n of t) {
305
- const { key: a, value: o } = n;
306
- if (a.status === "aborted" || o.status === "aborted")
307
- return g;
308
- a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || n.alwaysSet) && (r[a.value] = o.value);
305
+ const { key: a, value: i } = n;
306
+ if (a.status === "aborted" || i.status === "aborted")
307
+ return _;
308
+ a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (r[a.value] = i.value);
309
309
  }
310
310
  return { status: e.value, value: r };
311
311
  }
312
312
  }
313
- const g = Object.freeze({
313
+ const _ = Object.freeze({
314
314
  status: "aborted"
315
- }), Y = (s) => ({ status: "dirty", value: s }), N = (s) => ({ status: "valid", value: s }), be = (s) => s.status === "aborted", ke = (s) => s.status === "dirty", B = (s) => s.status === "valid", re = (s) => typeof Promise < "u" && s instanceof Promise;
316
- var f;
315
+ }), he = (s) => ({ status: "dirty", value: s }), q = (s) => ({ status: "valid", value: s }), $e = (s) => s.status === "aborted", Ie = (s) => s.status === "dirty", oe = (s) => s.status === "valid", ve = (s) => typeof Promise < "u" && s instanceof Promise;
316
+ var y;
317
317
  (function(s) {
318
318
  s.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, s.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
319
- })(f || (f = {}));
320
- class I {
319
+ })(y || (y = {}));
320
+ class H {
321
321
  constructor(e, t, r, n) {
322
322
  this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = n;
323
323
  }
@@ -325,8 +325,8 @@ class I {
325
325
  return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
326
326
  }
327
327
  }
328
- const xe = (s, e) => {
329
- if (B(e))
328
+ const Le = (s, e) => {
329
+ if (oe(e))
330
330
  return { success: !0, data: e.value };
331
331
  if (!s.common.issues.length)
332
332
  throw new Error("Validation failed but no issues detected.");
@@ -335,34 +335,34 @@ const xe = (s, e) => {
335
335
  get error() {
336
336
  if (this._error)
337
337
  return this._error;
338
- const t = new P(s.common.issues);
338
+ const t = new J(s.common.issues);
339
339
  return this._error = t, this._error;
340
340
  }
341
341
  };
342
342
  };
343
- function v(s) {
343
+ function k(s) {
344
344
  if (!s)
345
345
  return {};
346
346
  const { errorMap: e, invalid_type_error: t, required_error: r, description: n } = s;
347
347
  if (e && (t || r))
348
348
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
349
- return e ? { errorMap: e, description: n } : { errorMap: (o, i) => {
350
- const { message: d } = s;
351
- return o.code === "invalid_enum_value" ? { message: d ?? i.defaultError } : typeof i.data > "u" ? { message: d ?? r ?? i.defaultError } : o.code !== "invalid_type" ? { message: i.defaultError } : { message: d ?? t ?? i.defaultError };
349
+ return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
350
+ const { message: l } = s;
351
+ return i.code === "invalid_enum_value" ? { message: l ?? o.defaultError } : typeof o.data > "u" ? { message: l ?? r ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: l ?? t ?? o.defaultError };
352
352
  }, description: n };
353
353
  }
354
- class _ {
354
+ class x {
355
355
  get description() {
356
356
  return this._def.description;
357
357
  }
358
358
  _getType(e) {
359
- return V(e.data);
359
+ return K(e.data);
360
360
  }
361
361
  _getOrReturnCtx(e, t) {
362
362
  return t || {
363
363
  common: e.parent.common,
364
364
  data: e.data,
365
- parsedType: V(e.data),
365
+ parsedType: K(e.data),
366
366
  schemaErrorMap: this._def.errorMap,
367
367
  path: e.path,
368
368
  parent: e.parent
@@ -370,11 +370,11 @@ class _ {
370
370
  }
371
371
  _processInputParams(e) {
372
372
  return {
373
- status: new O(),
373
+ status: new $(),
374
374
  ctx: {
375
375
  common: e.parent.common,
376
376
  data: e.data,
377
- parsedType: V(e.data),
377
+ parsedType: K(e.data),
378
378
  schemaErrorMap: this._def.errorMap,
379
379
  path: e.path,
380
380
  parent: e.parent
@@ -383,7 +383,7 @@ class _ {
383
383
  }
384
384
  _parseSync(e) {
385
385
  const t = this._parse(e);
386
- if (re(t))
386
+ if (ve(t))
387
387
  throw new Error("Synchronous parse encountered promise.");
388
388
  return t;
389
389
  }
@@ -408,9 +408,9 @@ class _ {
408
408
  schemaErrorMap: this._def.errorMap,
409
409
  parent: null,
410
410
  data: e,
411
- parsedType: V(e)
411
+ parsedType: K(e)
412
412
  }, n = this._parseSync({ data: e, path: r.path, parent: r });
413
- return xe(r, n);
413
+ return Le(r, n);
414
414
  }
415
415
  "~validate"(e) {
416
416
  var r, n;
@@ -423,12 +423,12 @@ class _ {
423
423
  schemaErrorMap: this._def.errorMap,
424
424
  parent: null,
425
425
  data: e,
426
- parsedType: V(e)
426
+ parsedType: K(e)
427
427
  };
428
428
  if (!this["~standard"].async)
429
429
  try {
430
430
  const a = this._parseSync({ data: e, path: [], parent: t });
431
- return B(a) ? {
431
+ return oe(a) ? {
432
432
  value: a.value
433
433
  } : {
434
434
  issues: t.common.issues
@@ -439,7 +439,7 @@ class _ {
439
439
  async: !0
440
440
  };
441
441
  }
442
- return this._parseAsync({ data: e, path: [], parent: t }).then((a) => B(a) ? {
442
+ return this._parseAsync({ data: e, path: [], parent: t }).then((a) => oe(a) ? {
443
443
  value: a.value
444
444
  } : {
445
445
  issues: t.common.issues
@@ -462,27 +462,27 @@ class _ {
462
462
  schemaErrorMap: this._def.errorMap,
463
463
  parent: null,
464
464
  data: e,
465
- parsedType: V(e)
466
- }, n = this._parse({ data: e, path: r.path, parent: r }), a = await (re(n) ? n : Promise.resolve(n));
467
- return xe(r, a);
465
+ parsedType: K(e)
466
+ }, n = this._parse({ data: e, path: r.path, parent: r }), a = await (ve(n) ? n : Promise.resolve(n));
467
+ return Le(r, a);
468
468
  }
469
469
  refine(e, t) {
470
470
  const r = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
471
471
  return this._refinement((n, a) => {
472
- const o = e(n), i = () => a.addIssue({
473
- code: c.custom,
472
+ const i = e(n), o = () => a.addIssue({
473
+ code: u.custom,
474
474
  ...r(n)
475
475
  });
476
- return typeof Promise < "u" && o instanceof Promise ? o.then((d) => d ? !0 : (i(), !1)) : o ? !0 : (i(), !1);
476
+ return typeof Promise < "u" && i instanceof Promise ? i.then((l) => l ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
477
477
  });
478
478
  }
479
479
  refinement(e, t) {
480
480
  return this._refinement((r, n) => e(r) ? !0 : (n.addIssue(typeof t == "function" ? t(r, n) : t), !1));
481
481
  }
482
482
  _refinement(e) {
483
- return new X({
483
+ return new ue({
484
484
  schema: this,
485
- typeName: y.ZodEffects,
485
+ typeName: v.ZodEffects,
486
486
  effect: { type: "refinement", refinement: e }
487
487
  });
488
488
  }
@@ -497,57 +497,57 @@ class _ {
497
497
  };
498
498
  }
499
499
  optional() {
500
- return z.create(this, this._def);
500
+ return ee.create(this, this._def);
501
501
  }
502
502
  nullable() {
503
- return G.create(this, this._def);
503
+ return le.create(this, this._def);
504
504
  }
505
505
  nullish() {
506
506
  return this.nullable().optional();
507
507
  }
508
508
  array() {
509
- return j.create(this);
509
+ return B.create(this);
510
510
  }
511
511
  promise() {
512
- return ce.create(this, this._def);
512
+ return xe.create(this, this._def);
513
513
  }
514
514
  or(e) {
515
- return ae.create([this, e], this._def);
515
+ return be.create([this, e], this._def);
516
516
  }
517
517
  and(e) {
518
- return ie.create(this, e, this._def);
518
+ return ke.create(this, e, this._def);
519
519
  }
520
520
  transform(e) {
521
- return new X({
522
- ...v(this._def),
521
+ return new ue({
522
+ ...k(this._def),
523
523
  schema: this,
524
- typeName: y.ZodEffects,
524
+ typeName: v.ZodEffects,
525
525
  effect: { type: "transform", transform: e }
526
526
  });
527
527
  }
528
528
  default(e) {
529
529
  const t = typeof e == "function" ? e : () => e;
530
- return new fe({
531
- ...v(this._def),
530
+ return new Ne({
531
+ ...k(this._def),
532
532
  innerType: this,
533
533
  defaultValue: t,
534
- typeName: y.ZodDefault
534
+ typeName: v.ZodDefault
535
535
  });
536
536
  }
537
537
  brand() {
538
- return new _t({
539
- typeName: y.ZodBranded,
538
+ return new Vt({
539
+ typeName: v.ZodBranded,
540
540
  type: this,
541
- ...v(this._def)
541
+ ...k(this._def)
542
542
  });
543
543
  }
544
544
  catch(e) {
545
545
  const t = typeof e == "function" ? e : () => e;
546
- return new pe({
547
- ...v(this._def),
546
+ return new Ae({
547
+ ...k(this._def),
548
548
  innerType: this,
549
549
  catchValue: t,
550
- typeName: y.ZodCatch
550
+ typeName: v.ZodCatch
551
551
  });
552
552
  }
553
553
  describe(e) {
@@ -558,10 +558,10 @@ class _ {
558
558
  });
559
559
  }
560
560
  pipe(e) {
561
- return ge.create(this, e);
561
+ return Me.create(this, e);
562
562
  }
563
563
  readonly() {
564
- return me.create(this);
564
+ return Ee.create(this);
565
565
  }
566
566
  isOptional() {
567
567
  return this.safeParse(void 0).success;
@@ -570,28 +570,28 @@ class _ {
570
570
  return this.safeParse(null).success;
571
571
  }
572
572
  }
573
- const Ye = /^c[^\s-]{8,}$/i, Qe = /^[0-9a-z]+$/, Ke = /^[0-9A-HJKMNP-TV-Z]{26}$/i, et = /^[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, tt = /^[a-z0-9_-]{21}$/i, st = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, rt = /^[-+]?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)?)??$/, nt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, at = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
574
- let ue;
575
- const it = /^(?:(?: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])$/, ot = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, ct = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, dt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, ut = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, lt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ve = "((\\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])))", ht = new RegExp(`^${Ve}$`);
576
- function ze(s) {
573
+ const vt = /^c[^\s-]{8,}$/i, _t = /^[0-9a-z]+$/, bt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kt = /^[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, wt = /^[a-z0-9_-]{21}$/i, xt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ct = /^[-+]?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)?)??$/, St = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Tt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
574
+ let Se;
575
+ const Ot = /^(?:(?: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])$/, Nt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, At = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Et = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Rt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Mt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, ct = "((\\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])))", jt = new RegExp(`^${ct}$`);
576
+ function dt(s) {
577
577
  let e = "[0-5]\\d";
578
578
  s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`);
579
579
  const t = s.precision ? "+" : "?";
580
580
  return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
581
581
  }
582
- function ft(s) {
583
- return new RegExp(`^${ze(s)}$`);
582
+ function Pt(s) {
583
+ return new RegExp(`^${dt(s)}$`);
584
584
  }
585
- function pt(s) {
586
- let e = `${Ve}T${ze(s)}`;
585
+ function Zt(s) {
586
+ let e = `${ct}T${dt(s)}`;
587
587
  const t = [];
588
588
  return t.push(s.local ? "Z?" : "Z"), s.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
589
589
  }
590
- function mt(s, e) {
591
- return !!((e === "v4" || !e) && it.test(s) || (e === "v6" || !e) && ct.test(s));
590
+ function $t(s, e) {
591
+ return !!((e === "v4" || !e) && Ot.test(s) || (e === "v6" || !e) && At.test(s));
592
592
  }
593
- function yt(s, e) {
594
- if (!st.test(s))
593
+ function It(s, e) {
594
+ if (!xt.test(s))
595
595
  return !1;
596
596
  try {
597
597
  const [t] = s.split(".");
@@ -603,25 +603,25 @@ function yt(s, e) {
603
603
  return !1;
604
604
  }
605
605
  }
606
- function gt(s, e) {
607
- return !!((e === "v4" || !e) && ot.test(s) || (e === "v6" || !e) && dt.test(s));
606
+ function Lt(s, e) {
607
+ return !!((e === "v4" || !e) && Nt.test(s) || (e === "v6" || !e) && Et.test(s));
608
608
  }
609
- class L extends _ {
609
+ class G extends x {
610
610
  _parse(e) {
611
611
  if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
612
612
  const a = this._getOrReturnCtx(e);
613
- return u(a, {
614
- code: c.invalid_type,
613
+ return f(a, {
614
+ code: u.invalid_type,
615
615
  expected: h.string,
616
616
  received: a.parsedType
617
- }), g;
617
+ }), _;
618
618
  }
619
- const r = new O();
619
+ const r = new $();
620
620
  let n;
621
621
  for (const a of this._def.checks)
622
622
  if (a.kind === "min")
623
- e.data.length < a.value && (n = this._getOrReturnCtx(e, n), u(n, {
624
- code: c.too_small,
623
+ e.data.length < a.value && (n = this._getOrReturnCtx(e, n), f(n, {
624
+ code: u.too_small,
625
625
  minimum: a.value,
626
626
  type: "string",
627
627
  inclusive: !0,
@@ -629,8 +629,8 @@ class L extends _ {
629
629
  message: a.message
630
630
  }), r.dirty());
631
631
  else if (a.kind === "max")
632
- e.data.length > a.value && (n = this._getOrReturnCtx(e, n), u(n, {
633
- code: c.too_big,
632
+ e.data.length > a.value && (n = this._getOrReturnCtx(e, n), f(n, {
633
+ code: u.too_big,
634
634
  maximum: a.value,
635
635
  type: "string",
636
636
  inclusive: !0,
@@ -638,16 +638,16 @@ class L extends _ {
638
638
  message: a.message
639
639
  }), r.dirty());
640
640
  else if (a.kind === "length") {
641
- const o = e.data.length > a.value, i = e.data.length < a.value;
642
- (o || i) && (n = this._getOrReturnCtx(e, n), o ? u(n, {
643
- code: c.too_big,
641
+ const i = e.data.length > a.value, o = e.data.length < a.value;
642
+ (i || o) && (n = this._getOrReturnCtx(e, n), i ? f(n, {
643
+ code: u.too_big,
644
644
  maximum: a.value,
645
645
  type: "string",
646
646
  inclusive: !0,
647
647
  exact: !0,
648
648
  message: a.message
649
- }) : i && u(n, {
650
- code: c.too_small,
649
+ }) : o && f(n, {
650
+ code: u.too_small,
651
651
  minimum: a.value,
652
652
  type: "string",
653
653
  inclusive: !0,
@@ -655,166 +655,166 @@ class L extends _ {
655
655
  message: a.message
656
656
  }), r.dirty());
657
657
  } else if (a.kind === "email")
658
- nt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
658
+ St.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
659
659
  validation: "email",
660
- code: c.invalid_string,
660
+ code: u.invalid_string,
661
661
  message: a.message
662
662
  }), r.dirty());
663
663
  else if (a.kind === "emoji")
664
- ue || (ue = new RegExp(at, "u")), ue.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
664
+ Se || (Se = new RegExp(Tt, "u")), Se.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
665
665
  validation: "emoji",
666
- code: c.invalid_string,
666
+ code: u.invalid_string,
667
667
  message: a.message
668
668
  }), r.dirty());
669
669
  else if (a.kind === "uuid")
670
- et.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
670
+ kt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
671
671
  validation: "uuid",
672
- code: c.invalid_string,
672
+ code: u.invalid_string,
673
673
  message: a.message
674
674
  }), r.dirty());
675
675
  else if (a.kind === "nanoid")
676
- tt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
676
+ wt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
677
677
  validation: "nanoid",
678
- code: c.invalid_string,
678
+ code: u.invalid_string,
679
679
  message: a.message
680
680
  }), r.dirty());
681
681
  else if (a.kind === "cuid")
682
- Ye.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
682
+ vt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
683
683
  validation: "cuid",
684
- code: c.invalid_string,
684
+ code: u.invalid_string,
685
685
  message: a.message
686
686
  }), r.dirty());
687
687
  else if (a.kind === "cuid2")
688
- Qe.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
688
+ _t.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
689
689
  validation: "cuid2",
690
- code: c.invalid_string,
690
+ code: u.invalid_string,
691
691
  message: a.message
692
692
  }), r.dirty());
693
693
  else if (a.kind === "ulid")
694
- Ke.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
694
+ bt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
695
695
  validation: "ulid",
696
- code: c.invalid_string,
696
+ code: u.invalid_string,
697
697
  message: a.message
698
698
  }), r.dirty());
699
699
  else if (a.kind === "url")
700
700
  try {
701
701
  new URL(e.data);
702
702
  } catch {
703
- n = this._getOrReturnCtx(e, n), u(n, {
703
+ n = this._getOrReturnCtx(e, n), f(n, {
704
704
  validation: "url",
705
- code: c.invalid_string,
705
+ code: u.invalid_string,
706
706
  message: a.message
707
707
  }), r.dirty();
708
708
  }
709
- else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
709
+ else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
710
710
  validation: "regex",
711
- code: c.invalid_string,
711
+ code: u.invalid_string,
712
712
  message: a.message
713
- }), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), u(n, {
714
- code: c.invalid_string,
713
+ }), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), f(n, {
714
+ code: u.invalid_string,
715
715
  validation: { includes: a.value, position: a.position },
716
716
  message: a.message
717
- }), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (n = this._getOrReturnCtx(e, n), u(n, {
718
- code: c.invalid_string,
717
+ }), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (n = this._getOrReturnCtx(e, n), f(n, {
718
+ code: u.invalid_string,
719
719
  validation: { startsWith: a.value },
720
720
  message: a.message
721
- }), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), u(n, {
722
- code: c.invalid_string,
721
+ }), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), f(n, {
722
+ code: u.invalid_string,
723
723
  validation: { endsWith: a.value },
724
724
  message: a.message
725
- }), r.dirty()) : a.kind === "datetime" ? pt(a).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
726
- code: c.invalid_string,
725
+ }), r.dirty()) : a.kind === "datetime" ? Zt(a).test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
726
+ code: u.invalid_string,
727
727
  validation: "datetime",
728
728
  message: a.message
729
- }), r.dirty()) : a.kind === "date" ? ht.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
730
- code: c.invalid_string,
729
+ }), r.dirty()) : a.kind === "date" ? jt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
730
+ code: u.invalid_string,
731
731
  validation: "date",
732
732
  message: a.message
733
- }), r.dirty()) : a.kind === "time" ? ft(a).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
734
- code: c.invalid_string,
733
+ }), r.dirty()) : a.kind === "time" ? Pt(a).test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
734
+ code: u.invalid_string,
735
735
  validation: "time",
736
736
  message: a.message
737
- }), r.dirty()) : a.kind === "duration" ? rt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
737
+ }), r.dirty()) : a.kind === "duration" ? Ct.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
738
738
  validation: "duration",
739
- code: c.invalid_string,
739
+ code: u.invalid_string,
740
740
  message: a.message
741
- }), r.dirty()) : a.kind === "ip" ? mt(e.data, a.version) || (n = this._getOrReturnCtx(e, n), u(n, {
741
+ }), r.dirty()) : a.kind === "ip" ? $t(e.data, a.version) || (n = this._getOrReturnCtx(e, n), f(n, {
742
742
  validation: "ip",
743
- code: c.invalid_string,
743
+ code: u.invalid_string,
744
744
  message: a.message
745
- }), r.dirty()) : a.kind === "jwt" ? yt(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), u(n, {
745
+ }), r.dirty()) : a.kind === "jwt" ? It(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), f(n, {
746
746
  validation: "jwt",
747
- code: c.invalid_string,
747
+ code: u.invalid_string,
748
748
  message: a.message
749
- }), r.dirty()) : a.kind === "cidr" ? gt(e.data, a.version) || (n = this._getOrReturnCtx(e, n), u(n, {
749
+ }), r.dirty()) : a.kind === "cidr" ? Lt(e.data, a.version) || (n = this._getOrReturnCtx(e, n), f(n, {
750
750
  validation: "cidr",
751
- code: c.invalid_string,
751
+ code: u.invalid_string,
752
752
  message: a.message
753
- }), r.dirty()) : a.kind === "base64" ? ut.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
753
+ }), r.dirty()) : a.kind === "base64" ? Rt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
754
754
  validation: "base64",
755
- code: c.invalid_string,
755
+ code: u.invalid_string,
756
756
  message: a.message
757
- }), r.dirty()) : a.kind === "base64url" ? lt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
757
+ }), r.dirty()) : a.kind === "base64url" ? Mt.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
758
758
  validation: "base64url",
759
- code: c.invalid_string,
759
+ code: u.invalid_string,
760
760
  message: a.message
761
- }), r.dirty()) : b.assertNever(a);
761
+ }), r.dirty()) : C.assertNever(a);
762
762
  return { status: r.value, value: e.data };
763
763
  }
764
764
  _regex(e, t, r) {
765
765
  return this.refinement((n) => e.test(n), {
766
766
  validation: t,
767
- code: c.invalid_string,
768
- ...f.errToObj(r)
767
+ code: u.invalid_string,
768
+ ...y.errToObj(r)
769
769
  });
770
770
  }
771
771
  _addCheck(e) {
772
- return new L({
772
+ return new G({
773
773
  ...this._def,
774
774
  checks: [...this._def.checks, e]
775
775
  });
776
776
  }
777
777
  email(e) {
778
- return this._addCheck({ kind: "email", ...f.errToObj(e) });
778
+ return this._addCheck({ kind: "email", ...y.errToObj(e) });
779
779
  }
780
780
  url(e) {
781
- return this._addCheck({ kind: "url", ...f.errToObj(e) });
781
+ return this._addCheck({ kind: "url", ...y.errToObj(e) });
782
782
  }
783
783
  emoji(e) {
784
- return this._addCheck({ kind: "emoji", ...f.errToObj(e) });
784
+ return this._addCheck({ kind: "emoji", ...y.errToObj(e) });
785
785
  }
786
786
  uuid(e) {
787
- return this._addCheck({ kind: "uuid", ...f.errToObj(e) });
787
+ return this._addCheck({ kind: "uuid", ...y.errToObj(e) });
788
788
  }
789
789
  nanoid(e) {
790
- return this._addCheck({ kind: "nanoid", ...f.errToObj(e) });
790
+ return this._addCheck({ kind: "nanoid", ...y.errToObj(e) });
791
791
  }
792
792
  cuid(e) {
793
- return this._addCheck({ kind: "cuid", ...f.errToObj(e) });
793
+ return this._addCheck({ kind: "cuid", ...y.errToObj(e) });
794
794
  }
795
795
  cuid2(e) {
796
- return this._addCheck({ kind: "cuid2", ...f.errToObj(e) });
796
+ return this._addCheck({ kind: "cuid2", ...y.errToObj(e) });
797
797
  }
798
798
  ulid(e) {
799
- return this._addCheck({ kind: "ulid", ...f.errToObj(e) });
799
+ return this._addCheck({ kind: "ulid", ...y.errToObj(e) });
800
800
  }
801
801
  base64(e) {
802
- return this._addCheck({ kind: "base64", ...f.errToObj(e) });
802
+ return this._addCheck({ kind: "base64", ...y.errToObj(e) });
803
803
  }
804
804
  base64url(e) {
805
805
  return this._addCheck({
806
806
  kind: "base64url",
807
- ...f.errToObj(e)
807
+ ...y.errToObj(e)
808
808
  });
809
809
  }
810
810
  jwt(e) {
811
- return this._addCheck({ kind: "jwt", ...f.errToObj(e) });
811
+ return this._addCheck({ kind: "jwt", ...y.errToObj(e) });
812
812
  }
813
813
  ip(e) {
814
- return this._addCheck({ kind: "ip", ...f.errToObj(e) });
814
+ return this._addCheck({ kind: "ip", ...y.errToObj(e) });
815
815
  }
816
816
  cidr(e) {
817
- return this._addCheck({ kind: "cidr", ...f.errToObj(e) });
817
+ return this._addCheck({ kind: "cidr", ...y.errToObj(e) });
818
818
  }
819
819
  datetime(e) {
820
820
  return typeof e == "string" ? this._addCheck({
@@ -828,7 +828,7 @@ class L extends _ {
828
828
  precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
829
829
  offset: (e == null ? void 0 : e.offset) ?? !1,
830
830
  local: (e == null ? void 0 : e.local) ?? !1,
831
- ...f.errToObj(e == null ? void 0 : e.message)
831
+ ...y.errToObj(e == null ? void 0 : e.message)
832
832
  });
833
833
  }
834
834
  date(e) {
@@ -842,17 +842,17 @@ class L extends _ {
842
842
  }) : this._addCheck({
843
843
  kind: "time",
844
844
  precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
845
- ...f.errToObj(e == null ? void 0 : e.message)
845
+ ...y.errToObj(e == null ? void 0 : e.message)
846
846
  });
847
847
  }
848
848
  duration(e) {
849
- return this._addCheck({ kind: "duration", ...f.errToObj(e) });
849
+ return this._addCheck({ kind: "duration", ...y.errToObj(e) });
850
850
  }
851
851
  regex(e, t) {
852
852
  return this._addCheck({
853
853
  kind: "regex",
854
854
  regex: e,
855
- ...f.errToObj(t)
855
+ ...y.errToObj(t)
856
856
  });
857
857
  }
858
858
  includes(e, t) {
@@ -860,64 +860,64 @@ class L extends _ {
860
860
  kind: "includes",
861
861
  value: e,
862
862
  position: t == null ? void 0 : t.position,
863
- ...f.errToObj(t == null ? void 0 : t.message)
863
+ ...y.errToObj(t == null ? void 0 : t.message)
864
864
  });
865
865
  }
866
866
  startsWith(e, t) {
867
867
  return this._addCheck({
868
868
  kind: "startsWith",
869
869
  value: e,
870
- ...f.errToObj(t)
870
+ ...y.errToObj(t)
871
871
  });
872
872
  }
873
873
  endsWith(e, t) {
874
874
  return this._addCheck({
875
875
  kind: "endsWith",
876
876
  value: e,
877
- ...f.errToObj(t)
877
+ ...y.errToObj(t)
878
878
  });
879
879
  }
880
880
  min(e, t) {
881
881
  return this._addCheck({
882
882
  kind: "min",
883
883
  value: e,
884
- ...f.errToObj(t)
884
+ ...y.errToObj(t)
885
885
  });
886
886
  }
887
887
  max(e, t) {
888
888
  return this._addCheck({
889
889
  kind: "max",
890
890
  value: e,
891
- ...f.errToObj(t)
891
+ ...y.errToObj(t)
892
892
  });
893
893
  }
894
894
  length(e, t) {
895
895
  return this._addCheck({
896
896
  kind: "length",
897
897
  value: e,
898
- ...f.errToObj(t)
898
+ ...y.errToObj(t)
899
899
  });
900
900
  }
901
901
  /**
902
902
  * Equivalent to `.min(1)`
903
903
  */
904
904
  nonempty(e) {
905
- return this.min(1, f.errToObj(e));
905
+ return this.min(1, y.errToObj(e));
906
906
  }
907
907
  trim() {
908
- return new L({
908
+ return new G({
909
909
  ...this._def,
910
910
  checks: [...this._def.checks, { kind: "trim" }]
911
911
  });
912
912
  }
913
913
  toLowerCase() {
914
- return new L({
914
+ return new G({
915
915
  ...this._def,
916
916
  checks: [...this._def.checks, { kind: "toLowerCase" }]
917
917
  });
918
918
  }
919
919
  toUpperCase() {
920
- return new L({
920
+ return new G({
921
921
  ...this._def,
922
922
  checks: [...this._def.checks, { kind: "toUpperCase" }]
923
923
  });
@@ -983,75 +983,75 @@ class L extends _ {
983
983
  return e;
984
984
  }
985
985
  }
986
- L.create = (s) => new L({
986
+ G.create = (s) => new G({
987
987
  checks: [],
988
- typeName: y.ZodString,
988
+ typeName: v.ZodString,
989
989
  coerce: (s == null ? void 0 : s.coerce) ?? !1,
990
- ...v(s)
990
+ ...k(s)
991
991
  });
992
- function vt(s, e) {
993
- const t = (s.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, n = t > r ? t : r, a = Number.parseInt(s.toFixed(n).replace(".", "")), o = Number.parseInt(e.toFixed(n).replace(".", ""));
994
- return a % o / 10 ** n;
992
+ function Dt(s, e) {
993
+ const t = (s.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, n = t > r ? t : r, a = Number.parseInt(s.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
994
+ return a % i / 10 ** n;
995
995
  }
996
- class H extends _ {
996
+ class ce extends x {
997
997
  constructor() {
998
998
  super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
999
999
  }
1000
1000
  _parse(e) {
1001
1001
  if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
1002
1002
  const a = this._getOrReturnCtx(e);
1003
- return u(a, {
1004
- code: c.invalid_type,
1003
+ return f(a, {
1004
+ code: u.invalid_type,
1005
1005
  expected: h.number,
1006
1006
  received: a.parsedType
1007
- }), g;
1007
+ }), _;
1008
1008
  }
1009
1009
  let r;
1010
- const n = new O();
1010
+ const n = new $();
1011
1011
  for (const a of this._def.checks)
1012
- a.kind === "int" ? b.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), u(r, {
1013
- code: c.invalid_type,
1012
+ a.kind === "int" ? C.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1013
+ code: u.invalid_type,
1014
1014
  expected: "integer",
1015
1015
  received: "float",
1016
1016
  message: a.message
1017
- }), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1018
- code: c.too_small,
1017
+ }), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1018
+ code: u.too_small,
1019
1019
  minimum: a.value,
1020
1020
  type: "number",
1021
1021
  inclusive: a.inclusive,
1022
1022
  exact: !1,
1023
1023
  message: a.message
1024
- }), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1025
- code: c.too_big,
1024
+ }), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1025
+ code: u.too_big,
1026
1026
  maximum: a.value,
1027
1027
  type: "number",
1028
1028
  inclusive: a.inclusive,
1029
1029
  exact: !1,
1030
1030
  message: a.message
1031
- }), n.dirty()) : a.kind === "multipleOf" ? vt(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), u(r, {
1032
- code: c.not_multiple_of,
1031
+ }), n.dirty()) : a.kind === "multipleOf" ? Dt(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), f(r, {
1032
+ code: u.not_multiple_of,
1033
1033
  multipleOf: a.value,
1034
1034
  message: a.message
1035
- }), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), u(r, {
1036
- code: c.not_finite,
1035
+ }), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1036
+ code: u.not_finite,
1037
1037
  message: a.message
1038
- }), n.dirty()) : b.assertNever(a);
1038
+ }), n.dirty()) : C.assertNever(a);
1039
1039
  return { status: n.value, value: e.data };
1040
1040
  }
1041
1041
  gte(e, t) {
1042
- return this.setLimit("min", e, !0, f.toString(t));
1042
+ return this.setLimit("min", e, !0, y.toString(t));
1043
1043
  }
1044
1044
  gt(e, t) {
1045
- return this.setLimit("min", e, !1, f.toString(t));
1045
+ return this.setLimit("min", e, !1, y.toString(t));
1046
1046
  }
1047
1047
  lte(e, t) {
1048
- return this.setLimit("max", e, !0, f.toString(t));
1048
+ return this.setLimit("max", e, !0, y.toString(t));
1049
1049
  }
1050
1050
  lt(e, t) {
1051
- return this.setLimit("max", e, !1, f.toString(t));
1051
+ return this.setLimit("max", e, !1, y.toString(t));
1052
1052
  }
1053
1053
  setLimit(e, t, r, n) {
1054
- return new H({
1054
+ return new ce({
1055
1055
  ...this._def,
1056
1056
  checks: [
1057
1057
  ...this._def.checks,
@@ -1059,13 +1059,13 @@ class H extends _ {
1059
1059
  kind: e,
1060
1060
  value: t,
1061
1061
  inclusive: r,
1062
- message: f.toString(n)
1062
+ message: y.toString(n)
1063
1063
  }
1064
1064
  ]
1065
1065
  });
1066
1066
  }
1067
1067
  _addCheck(e) {
1068
- return new H({
1068
+ return new ce({
1069
1069
  ...this._def,
1070
1070
  checks: [...this._def.checks, e]
1071
1071
  });
@@ -1073,7 +1073,7 @@ class H extends _ {
1073
1073
  int(e) {
1074
1074
  return this._addCheck({
1075
1075
  kind: "int",
1076
- message: f.toString(e)
1076
+ message: y.toString(e)
1077
1077
  });
1078
1078
  }
1079
1079
  positive(e) {
@@ -1081,7 +1081,7 @@ class H extends _ {
1081
1081
  kind: "min",
1082
1082
  value: 0,
1083
1083
  inclusive: !1,
1084
- message: f.toString(e)
1084
+ message: y.toString(e)
1085
1085
  });
1086
1086
  }
1087
1087
  negative(e) {
@@ -1089,7 +1089,7 @@ class H extends _ {
1089
1089
  kind: "max",
1090
1090
  value: 0,
1091
1091
  inclusive: !1,
1092
- message: f.toString(e)
1092
+ message: y.toString(e)
1093
1093
  });
1094
1094
  }
1095
1095
  nonpositive(e) {
@@ -1097,7 +1097,7 @@ class H extends _ {
1097
1097
  kind: "max",
1098
1098
  value: 0,
1099
1099
  inclusive: !0,
1100
- message: f.toString(e)
1100
+ message: y.toString(e)
1101
1101
  });
1102
1102
  }
1103
1103
  nonnegative(e) {
@@ -1105,20 +1105,20 @@ class H extends _ {
1105
1105
  kind: "min",
1106
1106
  value: 0,
1107
1107
  inclusive: !0,
1108
- message: f.toString(e)
1108
+ message: y.toString(e)
1109
1109
  });
1110
1110
  }
1111
1111
  multipleOf(e, t) {
1112
1112
  return this._addCheck({
1113
1113
  kind: "multipleOf",
1114
1114
  value: e,
1115
- message: f.toString(t)
1115
+ message: y.toString(t)
1116
1116
  });
1117
1117
  }
1118
1118
  finite(e) {
1119
1119
  return this._addCheck({
1120
1120
  kind: "finite",
1121
- message: f.toString(e)
1121
+ message: y.toString(e)
1122
1122
  });
1123
1123
  }
1124
1124
  safe(e) {
@@ -1126,12 +1126,12 @@ class H extends _ {
1126
1126
  kind: "min",
1127
1127
  inclusive: !0,
1128
1128
  value: Number.MIN_SAFE_INTEGER,
1129
- message: f.toString(e)
1129
+ message: y.toString(e)
1130
1130
  })._addCheck({
1131
1131
  kind: "max",
1132
1132
  inclusive: !0,
1133
1133
  value: Number.MAX_SAFE_INTEGER,
1134
- message: f.toString(e)
1134
+ message: y.toString(e)
1135
1135
  });
1136
1136
  }
1137
1137
  get minValue() {
@@ -1147,7 +1147,7 @@ class H extends _ {
1147
1147
  return e;
1148
1148
  }
1149
1149
  get isInt() {
1150
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && b.isInteger(e.value));
1150
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && C.isInteger(e.value));
1151
1151
  }
1152
1152
  get isFinite() {
1153
1153
  let e = null, t = null;
@@ -1159,13 +1159,13 @@ class H extends _ {
1159
1159
  return Number.isFinite(t) && Number.isFinite(e);
1160
1160
  }
1161
1161
  }
1162
- H.create = (s) => new H({
1162
+ ce.create = (s) => new ce({
1163
1163
  checks: [],
1164
- typeName: y.ZodNumber,
1164
+ typeName: v.ZodNumber,
1165
1165
  coerce: (s == null ? void 0 : s.coerce) || !1,
1166
- ...v(s)
1166
+ ...k(s)
1167
1167
  });
1168
- class Q extends _ {
1168
+ class pe extends x {
1169
1169
  constructor() {
1170
1170
  super(...arguments), this.min = this.gte, this.max = this.lte;
1171
1171
  }
@@ -1179,49 +1179,49 @@ class Q extends _ {
1179
1179
  if (this._getType(e) !== h.bigint)
1180
1180
  return this._getInvalidInput(e);
1181
1181
  let r;
1182
- const n = new O();
1182
+ const n = new $();
1183
1183
  for (const a of this._def.checks)
1184
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1185
- code: c.too_small,
1184
+ a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1185
+ code: u.too_small,
1186
1186
  type: "bigint",
1187
1187
  minimum: a.value,
1188
1188
  inclusive: a.inclusive,
1189
1189
  message: a.message
1190
- }), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), u(r, {
1191
- code: c.too_big,
1190
+ }), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1191
+ code: u.too_big,
1192
1192
  type: "bigint",
1193
1193
  maximum: a.value,
1194
1194
  inclusive: a.inclusive,
1195
1195
  message: a.message
1196
- }), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), u(r, {
1197
- code: c.not_multiple_of,
1196
+ }), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), f(r, {
1197
+ code: u.not_multiple_of,
1198
1198
  multipleOf: a.value,
1199
1199
  message: a.message
1200
- }), n.dirty()) : b.assertNever(a);
1200
+ }), n.dirty()) : C.assertNever(a);
1201
1201
  return { status: n.value, value: e.data };
1202
1202
  }
1203
1203
  _getInvalidInput(e) {
1204
1204
  const t = this._getOrReturnCtx(e);
1205
- return u(t, {
1206
- code: c.invalid_type,
1205
+ return f(t, {
1206
+ code: u.invalid_type,
1207
1207
  expected: h.bigint,
1208
1208
  received: t.parsedType
1209
- }), g;
1209
+ }), _;
1210
1210
  }
1211
1211
  gte(e, t) {
1212
- return this.setLimit("min", e, !0, f.toString(t));
1212
+ return this.setLimit("min", e, !0, y.toString(t));
1213
1213
  }
1214
1214
  gt(e, t) {
1215
- return this.setLimit("min", e, !1, f.toString(t));
1215
+ return this.setLimit("min", e, !1, y.toString(t));
1216
1216
  }
1217
1217
  lte(e, t) {
1218
- return this.setLimit("max", e, !0, f.toString(t));
1218
+ return this.setLimit("max", e, !0, y.toString(t));
1219
1219
  }
1220
1220
  lt(e, t) {
1221
- return this.setLimit("max", e, !1, f.toString(t));
1221
+ return this.setLimit("max", e, !1, y.toString(t));
1222
1222
  }
1223
1223
  setLimit(e, t, r, n) {
1224
- return new Q({
1224
+ return new pe({
1225
1225
  ...this._def,
1226
1226
  checks: [
1227
1227
  ...this._def.checks,
@@ -1229,13 +1229,13 @@ class Q extends _ {
1229
1229
  kind: e,
1230
1230
  value: t,
1231
1231
  inclusive: r,
1232
- message: f.toString(n)
1232
+ message: y.toString(n)
1233
1233
  }
1234
1234
  ]
1235
1235
  });
1236
1236
  }
1237
1237
  _addCheck(e) {
1238
- return new Q({
1238
+ return new pe({
1239
1239
  ...this._def,
1240
1240
  checks: [...this._def.checks, e]
1241
1241
  });
@@ -1245,7 +1245,7 @@ class Q extends _ {
1245
1245
  kind: "min",
1246
1246
  value: BigInt(0),
1247
1247
  inclusive: !1,
1248
- message: f.toString(e)
1248
+ message: y.toString(e)
1249
1249
  });
1250
1250
  }
1251
1251
  negative(e) {
@@ -1253,7 +1253,7 @@ class Q extends _ {
1253
1253
  kind: "max",
1254
1254
  value: BigInt(0),
1255
1255
  inclusive: !1,
1256
- message: f.toString(e)
1256
+ message: y.toString(e)
1257
1257
  });
1258
1258
  }
1259
1259
  nonpositive(e) {
@@ -1261,7 +1261,7 @@ class Q extends _ {
1261
1261
  kind: "max",
1262
1262
  value: BigInt(0),
1263
1263
  inclusive: !0,
1264
- message: f.toString(e)
1264
+ message: y.toString(e)
1265
1265
  });
1266
1266
  }
1267
1267
  nonnegative(e) {
@@ -1269,14 +1269,14 @@ class Q extends _ {
1269
1269
  kind: "min",
1270
1270
  value: BigInt(0),
1271
1271
  inclusive: !0,
1272
- message: f.toString(e)
1272
+ message: y.toString(e)
1273
1273
  });
1274
1274
  }
1275
1275
  multipleOf(e, t) {
1276
1276
  return this._addCheck({
1277
1277
  kind: "multipleOf",
1278
1278
  value: e,
1279
- message: f.toString(t)
1279
+ message: y.toString(t)
1280
1280
  });
1281
1281
  }
1282
1282
  get minValue() {
@@ -1292,71 +1292,71 @@ class Q extends _ {
1292
1292
  return e;
1293
1293
  }
1294
1294
  }
1295
- Q.create = (s) => new Q({
1295
+ pe.create = (s) => new pe({
1296
1296
  checks: [],
1297
- typeName: y.ZodBigInt,
1297
+ typeName: v.ZodBigInt,
1298
1298
  coerce: (s == null ? void 0 : s.coerce) ?? !1,
1299
- ...v(s)
1299
+ ...k(s)
1300
1300
  });
1301
- class we extends _ {
1301
+ class De extends x {
1302
1302
  _parse(e) {
1303
1303
  if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
1304
1304
  const r = this._getOrReturnCtx(e);
1305
- return u(r, {
1306
- code: c.invalid_type,
1305
+ return f(r, {
1306
+ code: u.invalid_type,
1307
1307
  expected: h.boolean,
1308
1308
  received: r.parsedType
1309
- }), g;
1309
+ }), _;
1310
1310
  }
1311
- return N(e.data);
1311
+ return q(e.data);
1312
1312
  }
1313
1313
  }
1314
- we.create = (s) => new we({
1315
- typeName: y.ZodBoolean,
1314
+ De.create = (s) => new De({
1315
+ typeName: v.ZodBoolean,
1316
1316
  coerce: (s == null ? void 0 : s.coerce) || !1,
1317
- ...v(s)
1317
+ ...k(s)
1318
1318
  });
1319
- class ne extends _ {
1319
+ class _e extends x {
1320
1320
  _parse(e) {
1321
1321
  if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
1322
1322
  const a = this._getOrReturnCtx(e);
1323
- return u(a, {
1324
- code: c.invalid_type,
1323
+ return f(a, {
1324
+ code: u.invalid_type,
1325
1325
  expected: h.date,
1326
1326
  received: a.parsedType
1327
- }), g;
1327
+ }), _;
1328
1328
  }
1329
1329
  if (Number.isNaN(e.data.getTime())) {
1330
1330
  const a = this._getOrReturnCtx(e);
1331
- return u(a, {
1332
- code: c.invalid_date
1333
- }), g;
1331
+ return f(a, {
1332
+ code: u.invalid_date
1333
+ }), _;
1334
1334
  }
1335
- const r = new O();
1335
+ const r = new $();
1336
1336
  let n;
1337
1337
  for (const a of this._def.checks)
1338
- a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), u(n, {
1339
- code: c.too_small,
1338
+ a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), f(n, {
1339
+ code: u.too_small,
1340
1340
  message: a.message,
1341
1341
  inclusive: !0,
1342
1342
  exact: !1,
1343
1343
  minimum: a.value,
1344
1344
  type: "date"
1345
- }), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), u(n, {
1346
- code: c.too_big,
1345
+ }), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), f(n, {
1346
+ code: u.too_big,
1347
1347
  message: a.message,
1348
1348
  inclusive: !0,
1349
1349
  exact: !1,
1350
1350
  maximum: a.value,
1351
1351
  type: "date"
1352
- }), r.dirty()) : b.assertNever(a);
1352
+ }), r.dirty()) : C.assertNever(a);
1353
1353
  return {
1354
1354
  status: r.value,
1355
1355
  value: new Date(e.data.getTime())
1356
1356
  };
1357
1357
  }
1358
1358
  _addCheck(e) {
1359
- return new ne({
1359
+ return new _e({
1360
1360
  ...this._def,
1361
1361
  checks: [...this._def.checks, e]
1362
1362
  });
@@ -1365,14 +1365,14 @@ class ne extends _ {
1365
1365
  return this._addCheck({
1366
1366
  kind: "min",
1367
1367
  value: e.getTime(),
1368
- message: f.toString(t)
1368
+ message: y.toString(t)
1369
1369
  });
1370
1370
  }
1371
1371
  max(e, t) {
1372
1372
  return this._addCheck({
1373
1373
  kind: "max",
1374
1374
  value: e.getTime(),
1375
- message: f.toString(t)
1375
+ message: y.toString(t)
1376
1376
  });
1377
1377
  }
1378
1378
  get minDate() {
@@ -1388,293 +1388,293 @@ class ne extends _ {
1388
1388
  return e != null ? new Date(e) : null;
1389
1389
  }
1390
1390
  }
1391
- ne.create = (s) => new ne({
1391
+ _e.create = (s) => new _e({
1392
1392
  checks: [],
1393
1393
  coerce: (s == null ? void 0 : s.coerce) || !1,
1394
- typeName: y.ZodDate,
1395
- ...v(s)
1394
+ typeName: v.ZodDate,
1395
+ ...k(s)
1396
1396
  });
1397
- class Ce extends _ {
1397
+ class Ve extends x {
1398
1398
  _parse(e) {
1399
1399
  if (this._getType(e) !== h.symbol) {
1400
1400
  const r = this._getOrReturnCtx(e);
1401
- return u(r, {
1402
- code: c.invalid_type,
1401
+ return f(r, {
1402
+ code: u.invalid_type,
1403
1403
  expected: h.symbol,
1404
1404
  received: r.parsedType
1405
- }), g;
1405
+ }), _;
1406
1406
  }
1407
- return N(e.data);
1407
+ return q(e.data);
1408
1408
  }
1409
1409
  }
1410
- Ce.create = (s) => new Ce({
1411
- typeName: y.ZodSymbol,
1412
- ...v(s)
1410
+ Ve.create = (s) => new Ve({
1411
+ typeName: v.ZodSymbol,
1412
+ ...k(s)
1413
1413
  });
1414
- class Te extends _ {
1414
+ class ze extends x {
1415
1415
  _parse(e) {
1416
1416
  if (this._getType(e) !== h.undefined) {
1417
1417
  const r = this._getOrReturnCtx(e);
1418
- return u(r, {
1419
- code: c.invalid_type,
1418
+ return f(r, {
1419
+ code: u.invalid_type,
1420
1420
  expected: h.undefined,
1421
1421
  received: r.parsedType
1422
- }), g;
1422
+ }), _;
1423
1423
  }
1424
- return N(e.data);
1424
+ return q(e.data);
1425
1425
  }
1426
1426
  }
1427
- Te.create = (s) => new Te({
1428
- typeName: y.ZodUndefined,
1429
- ...v(s)
1427
+ ze.create = (s) => new ze({
1428
+ typeName: v.ZodUndefined,
1429
+ ...k(s)
1430
1430
  });
1431
- class Oe extends _ {
1431
+ class Ue extends x {
1432
1432
  _parse(e) {
1433
1433
  if (this._getType(e) !== h.null) {
1434
1434
  const r = this._getOrReturnCtx(e);
1435
- return u(r, {
1436
- code: c.invalid_type,
1435
+ return f(r, {
1436
+ code: u.invalid_type,
1437
1437
  expected: h.null,
1438
1438
  received: r.parsedType
1439
- }), g;
1439
+ }), _;
1440
1440
  }
1441
- return N(e.data);
1441
+ return q(e.data);
1442
1442
  }
1443
1443
  }
1444
- Oe.create = (s) => new Oe({
1445
- typeName: y.ZodNull,
1446
- ...v(s)
1444
+ Ue.create = (s) => new Ue({
1445
+ typeName: v.ZodNull,
1446
+ ...k(s)
1447
1447
  });
1448
- class Se extends _ {
1448
+ class qe extends x {
1449
1449
  constructor() {
1450
1450
  super(...arguments), this._any = !0;
1451
1451
  }
1452
1452
  _parse(e) {
1453
- return N(e.data);
1453
+ return q(e.data);
1454
1454
  }
1455
1455
  }
1456
- Se.create = (s) => new Se({
1457
- typeName: y.ZodAny,
1458
- ...v(s)
1456
+ qe.create = (s) => new qe({
1457
+ typeName: v.ZodAny,
1458
+ ...k(s)
1459
1459
  });
1460
- class Ae extends _ {
1460
+ class Fe extends x {
1461
1461
  constructor() {
1462
1462
  super(...arguments), this._unknown = !0;
1463
1463
  }
1464
1464
  _parse(e) {
1465
- return N(e.data);
1465
+ return q(e.data);
1466
1466
  }
1467
1467
  }
1468
- Ae.create = (s) => new Ae({
1469
- typeName: y.ZodUnknown,
1470
- ...v(s)
1468
+ Fe.create = (s) => new Fe({
1469
+ typeName: v.ZodUnknown,
1470
+ ...k(s)
1471
1471
  });
1472
- class U extends _ {
1472
+ class te extends x {
1473
1473
  _parse(e) {
1474
1474
  const t = this._getOrReturnCtx(e);
1475
- return u(t, {
1476
- code: c.invalid_type,
1475
+ return f(t, {
1476
+ code: u.invalid_type,
1477
1477
  expected: h.never,
1478
1478
  received: t.parsedType
1479
- }), g;
1479
+ }), _;
1480
1480
  }
1481
1481
  }
1482
- U.create = (s) => new U({
1483
- typeName: y.ZodNever,
1484
- ...v(s)
1482
+ te.create = (s) => new te({
1483
+ typeName: v.ZodNever,
1484
+ ...k(s)
1485
1485
  });
1486
- class Ee extends _ {
1486
+ class Be extends x {
1487
1487
  _parse(e) {
1488
1488
  if (this._getType(e) !== h.undefined) {
1489
1489
  const r = this._getOrReturnCtx(e);
1490
- return u(r, {
1491
- code: c.invalid_type,
1490
+ return f(r, {
1491
+ code: u.invalid_type,
1492
1492
  expected: h.void,
1493
1493
  received: r.parsedType
1494
- }), g;
1494
+ }), _;
1495
1495
  }
1496
- return N(e.data);
1496
+ return q(e.data);
1497
1497
  }
1498
1498
  }
1499
- Ee.create = (s) => new Ee({
1500
- typeName: y.ZodVoid,
1501
- ...v(s)
1499
+ Be.create = (s) => new Be({
1500
+ typeName: v.ZodVoid,
1501
+ ...k(s)
1502
1502
  });
1503
- class j extends _ {
1503
+ class B extends x {
1504
1504
  _parse(e) {
1505
1505
  const { ctx: t, status: r } = this._processInputParams(e), n = this._def;
1506
1506
  if (t.parsedType !== h.array)
1507
- return u(t, {
1508
- code: c.invalid_type,
1507
+ return f(t, {
1508
+ code: u.invalid_type,
1509
1509
  expected: h.array,
1510
1510
  received: t.parsedType
1511
- }), g;
1511
+ }), _;
1512
1512
  if (n.exactLength !== null) {
1513
- const o = t.data.length > n.exactLength.value, i = t.data.length < n.exactLength.value;
1514
- (o || i) && (u(t, {
1515
- code: o ? c.too_big : c.too_small,
1516
- minimum: i ? n.exactLength.value : void 0,
1517
- maximum: o ? n.exactLength.value : void 0,
1513
+ const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
1514
+ (i || o) && (f(t, {
1515
+ code: i ? u.too_big : u.too_small,
1516
+ minimum: o ? n.exactLength.value : void 0,
1517
+ maximum: i ? n.exactLength.value : void 0,
1518
1518
  type: "array",
1519
1519
  inclusive: !0,
1520
1520
  exact: !0,
1521
1521
  message: n.exactLength.message
1522
1522
  }), r.dirty());
1523
1523
  }
1524
- if (n.minLength !== null && t.data.length < n.minLength.value && (u(t, {
1525
- code: c.too_small,
1524
+ if (n.minLength !== null && t.data.length < n.minLength.value && (f(t, {
1525
+ code: u.too_small,
1526
1526
  minimum: n.minLength.value,
1527
1527
  type: "array",
1528
1528
  inclusive: !0,
1529
1529
  exact: !1,
1530
1530
  message: n.minLength.message
1531
- }), r.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (u(t, {
1532
- code: c.too_big,
1531
+ }), r.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (f(t, {
1532
+ code: u.too_big,
1533
1533
  maximum: n.maxLength.value,
1534
1534
  type: "array",
1535
1535
  inclusive: !0,
1536
1536
  exact: !1,
1537
1537
  message: n.maxLength.message
1538
1538
  }), r.dirty()), t.common.async)
1539
- return Promise.all([...t.data].map((o, i) => n.type._parseAsync(new I(t, o, t.path, i)))).then((o) => O.mergeArray(r, o));
1540
- const a = [...t.data].map((o, i) => n.type._parseSync(new I(t, o, t.path, i)));
1541
- return O.mergeArray(r, a);
1539
+ return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new H(t, i, t.path, o)))).then((i) => $.mergeArray(r, i));
1540
+ const a = [...t.data].map((i, o) => n.type._parseSync(new H(t, i, t.path, o)));
1541
+ return $.mergeArray(r, a);
1542
1542
  }
1543
1543
  get element() {
1544
1544
  return this._def.type;
1545
1545
  }
1546
1546
  min(e, t) {
1547
- return new j({
1547
+ return new B({
1548
1548
  ...this._def,
1549
- minLength: { value: e, message: f.toString(t) }
1549
+ minLength: { value: e, message: y.toString(t) }
1550
1550
  });
1551
1551
  }
1552
1552
  max(e, t) {
1553
- return new j({
1553
+ return new B({
1554
1554
  ...this._def,
1555
- maxLength: { value: e, message: f.toString(t) }
1555
+ maxLength: { value: e, message: y.toString(t) }
1556
1556
  });
1557
1557
  }
1558
1558
  length(e, t) {
1559
- return new j({
1559
+ return new B({
1560
1560
  ...this._def,
1561
- exactLength: { value: e, message: f.toString(t) }
1561
+ exactLength: { value: e, message: y.toString(t) }
1562
1562
  });
1563
1563
  }
1564
1564
  nonempty(e) {
1565
1565
  return this.min(1, e);
1566
1566
  }
1567
1567
  }
1568
- j.create = (s, e) => new j({
1568
+ B.create = (s, e) => new B({
1569
1569
  type: s,
1570
1570
  minLength: null,
1571
1571
  maxLength: null,
1572
1572
  exactLength: null,
1573
- typeName: y.ZodArray,
1574
- ...v(e)
1573
+ typeName: v.ZodArray,
1574
+ ...k(e)
1575
1575
  });
1576
- function q(s) {
1577
- if (s instanceof k) {
1576
+ function ie(s) {
1577
+ if (s instanceof A) {
1578
1578
  const e = {};
1579
1579
  for (const t in s.shape) {
1580
1580
  const r = s.shape[t];
1581
- e[t] = z.create(q(r));
1581
+ e[t] = ee.create(ie(r));
1582
1582
  }
1583
- return new k({
1583
+ return new A({
1584
1584
  ...s._def,
1585
1585
  shape: () => e
1586
1586
  });
1587
- } else return s instanceof j ? new j({
1587
+ } else return s instanceof B ? new B({
1588
1588
  ...s._def,
1589
- type: q(s.element)
1590
- }) : s instanceof z ? z.create(q(s.unwrap())) : s instanceof G ? G.create(q(s.unwrap())) : s instanceof F ? F.create(s.items.map((e) => q(e))) : s;
1589
+ type: ie(s.element)
1590
+ }) : s instanceof ee ? ee.create(ie(s.unwrap())) : s instanceof le ? le.create(ie(s.unwrap())) : s instanceof re ? re.create(s.items.map((e) => ie(e))) : s;
1591
1591
  }
1592
- class k extends _ {
1592
+ class A extends x {
1593
1593
  constructor() {
1594
1594
  super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1595
1595
  }
1596
1596
  _getCached() {
1597
1597
  if (this._cached !== null)
1598
1598
  return this._cached;
1599
- const e = this._def.shape(), t = b.objectKeys(e);
1599
+ const e = this._def.shape(), t = C.objectKeys(e);
1600
1600
  return this._cached = { shape: e, keys: t }, this._cached;
1601
1601
  }
1602
1602
  _parse(e) {
1603
1603
  if (this._getType(e) !== h.object) {
1604
- const l = this._getOrReturnCtx(e);
1605
- return u(l, {
1606
- code: c.invalid_type,
1604
+ const c = this._getOrReturnCtx(e);
1605
+ return f(c, {
1606
+ code: u.invalid_type,
1607
1607
  expected: h.object,
1608
- received: l.parsedType
1609
- }), g;
1608
+ received: c.parsedType
1609
+ }), _;
1610
1610
  }
1611
- const { status: r, ctx: n } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), i = [];
1612
- if (!(this._def.catchall instanceof U && this._def.unknownKeys === "strip"))
1613
- for (const l in n.data)
1614
- o.includes(l) || i.push(l);
1615
- const d = [];
1616
- for (const l of o) {
1617
- const m = a[l], w = n.data[l];
1618
- d.push({
1619
- key: { status: "valid", value: l },
1620
- value: m._parse(new I(n, w, n.path, l)),
1621
- alwaysSet: l in n.data
1611
+ const { status: r, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1612
+ if (!(this._def.catchall instanceof te && this._def.unknownKeys === "strip"))
1613
+ for (const c in n.data)
1614
+ i.includes(c) || o.push(c);
1615
+ const l = [];
1616
+ for (const c of i) {
1617
+ const g = a[c], O = n.data[c];
1618
+ l.push({
1619
+ key: { status: "valid", value: c },
1620
+ value: g._parse(new H(n, O, n.path, c)),
1621
+ alwaysSet: c in n.data
1622
1622
  });
1623
1623
  }
1624
- if (this._def.catchall instanceof U) {
1625
- const l = this._def.unknownKeys;
1626
- if (l === "passthrough")
1627
- for (const m of i)
1628
- d.push({
1629
- key: { status: "valid", value: m },
1630
- value: { status: "valid", value: n.data[m] }
1624
+ if (this._def.catchall instanceof te) {
1625
+ const c = this._def.unknownKeys;
1626
+ if (c === "passthrough")
1627
+ for (const g of o)
1628
+ l.push({
1629
+ key: { status: "valid", value: g },
1630
+ value: { status: "valid", value: n.data[g] }
1631
1631
  });
1632
- else if (l === "strict")
1633
- i.length > 0 && (u(n, {
1634
- code: c.unrecognized_keys,
1635
- keys: i
1632
+ else if (c === "strict")
1633
+ o.length > 0 && (f(n, {
1634
+ code: u.unrecognized_keys,
1635
+ keys: o
1636
1636
  }), r.dirty());
1637
- else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1637
+ else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1638
1638
  } else {
1639
- const l = this._def.catchall;
1640
- for (const m of i) {
1641
- const w = n.data[m];
1642
- d.push({
1643
- key: { status: "valid", value: m },
1644
- value: l._parse(
1645
- new I(n, w, n.path, m)
1639
+ const c = this._def.catchall;
1640
+ for (const g of o) {
1641
+ const O = n.data[g];
1642
+ l.push({
1643
+ key: { status: "valid", value: g },
1644
+ value: c._parse(
1645
+ new H(n, O, n.path, g)
1646
1646
  //, ctx.child(key), value, getParsedType(value)
1647
1647
  ),
1648
- alwaysSet: m in n.data
1648
+ alwaysSet: g in n.data
1649
1649
  });
1650
1650
  }
1651
1651
  }
1652
1652
  return n.common.async ? Promise.resolve().then(async () => {
1653
- const l = [];
1654
- for (const m of d) {
1655
- const w = await m.key, x = await m.value;
1656
- l.push({
1657
- key: w,
1658
- value: x,
1659
- alwaysSet: m.alwaysSet
1653
+ const c = [];
1654
+ for (const g of l) {
1655
+ const O = await g.key, N = await g.value;
1656
+ c.push({
1657
+ key: O,
1658
+ value: N,
1659
+ alwaysSet: g.alwaysSet
1660
1660
  });
1661
1661
  }
1662
- return l;
1663
- }).then((l) => O.mergeObjectSync(r, l)) : O.mergeObjectSync(r, d);
1662
+ return c;
1663
+ }).then((c) => $.mergeObjectSync(r, c)) : $.mergeObjectSync(r, l);
1664
1664
  }
1665
1665
  get shape() {
1666
1666
  return this._def.shape();
1667
1667
  }
1668
1668
  strict(e) {
1669
- return f.errToObj, new k({
1669
+ return y.errToObj, new A({
1670
1670
  ...this._def,
1671
1671
  unknownKeys: "strict",
1672
1672
  ...e !== void 0 ? {
1673
1673
  errorMap: (t, r) => {
1674
- var a, o;
1675
- const n = ((o = (a = this._def).errorMap) == null ? void 0 : o.call(a, t, r).message) ?? r.defaultError;
1674
+ var a, i;
1675
+ const n = ((i = (a = this._def).errorMap) == null ? void 0 : i.call(a, t, r).message) ?? r.defaultError;
1676
1676
  return t.code === "unrecognized_keys" ? {
1677
- message: f.errToObj(e).message ?? n
1677
+ message: y.errToObj(e).message ?? n
1678
1678
  } : {
1679
1679
  message: n
1680
1680
  };
@@ -1683,13 +1683,13 @@ class k extends _ {
1683
1683
  });
1684
1684
  }
1685
1685
  strip() {
1686
- return new k({
1686
+ return new A({
1687
1687
  ...this._def,
1688
1688
  unknownKeys: "strip"
1689
1689
  });
1690
1690
  }
1691
1691
  passthrough() {
1692
- return new k({
1692
+ return new A({
1693
1693
  ...this._def,
1694
1694
  unknownKeys: "passthrough"
1695
1695
  });
@@ -1712,7 +1712,7 @@ class k extends _ {
1712
1712
  // }) as any;
1713
1713
  // };
1714
1714
  extend(e) {
1715
- return new k({
1715
+ return new A({
1716
1716
  ...this._def,
1717
1717
  shape: () => ({
1718
1718
  ...this._def.shape(),
@@ -1726,14 +1726,14 @@ class k extends _ {
1726
1726
  * upgrade if you are experiencing issues.
1727
1727
  */
1728
1728
  merge(e) {
1729
- return new k({
1729
+ return new A({
1730
1730
  unknownKeys: e._def.unknownKeys,
1731
1731
  catchall: e._def.catchall,
1732
1732
  shape: () => ({
1733
1733
  ...this._def.shape(),
1734
1734
  ...e._def.shape()
1735
1735
  }),
1736
- typeName: y.ZodObject
1736
+ typeName: v.ZodObject
1737
1737
  });
1738
1738
  }
1739
1739
  // merge<
@@ -1796,25 +1796,25 @@ class k extends _ {
1796
1796
  // return merged;
1797
1797
  // }
1798
1798
  catchall(e) {
1799
- return new k({
1799
+ return new A({
1800
1800
  ...this._def,
1801
1801
  catchall: e
1802
1802
  });
1803
1803
  }
1804
1804
  pick(e) {
1805
1805
  const t = {};
1806
- for (const r of b.objectKeys(e))
1806
+ for (const r of C.objectKeys(e))
1807
1807
  e[r] && this.shape[r] && (t[r] = this.shape[r]);
1808
- return new k({
1808
+ return new A({
1809
1809
  ...this._def,
1810
1810
  shape: () => t
1811
1811
  });
1812
1812
  }
1813
1813
  omit(e) {
1814
1814
  const t = {};
1815
- for (const r of b.objectKeys(this.shape))
1815
+ for (const r of C.objectKeys(this.shape))
1816
1816
  e[r] || (t[r] = this.shape[r]);
1817
- return new k({
1817
+ return new A({
1818
1818
  ...this._def,
1819
1819
  shape: () => t
1820
1820
  });
@@ -1823,79 +1823,79 @@ class k extends _ {
1823
1823
  * @deprecated
1824
1824
  */
1825
1825
  deepPartial() {
1826
- return q(this);
1826
+ return ie(this);
1827
1827
  }
1828
1828
  partial(e) {
1829
1829
  const t = {};
1830
- for (const r of b.objectKeys(this.shape)) {
1830
+ for (const r of C.objectKeys(this.shape)) {
1831
1831
  const n = this.shape[r];
1832
1832
  e && !e[r] ? t[r] = n : t[r] = n.optional();
1833
1833
  }
1834
- return new k({
1834
+ return new A({
1835
1835
  ...this._def,
1836
1836
  shape: () => t
1837
1837
  });
1838
1838
  }
1839
1839
  required(e) {
1840
1840
  const t = {};
1841
- for (const r of b.objectKeys(this.shape))
1841
+ for (const r of C.objectKeys(this.shape))
1842
1842
  if (e && !e[r])
1843
1843
  t[r] = this.shape[r];
1844
1844
  else {
1845
1845
  let a = this.shape[r];
1846
- for (; a instanceof z; )
1846
+ for (; a instanceof ee; )
1847
1847
  a = a._def.innerType;
1848
1848
  t[r] = a;
1849
1849
  }
1850
- return new k({
1850
+ return new A({
1851
1851
  ...this._def,
1852
1852
  shape: () => t
1853
1853
  });
1854
1854
  }
1855
1855
  keyof() {
1856
- return Ue(b.objectKeys(this.shape));
1856
+ return ut(C.objectKeys(this.shape));
1857
1857
  }
1858
1858
  }
1859
- k.create = (s, e) => new k({
1859
+ A.create = (s, e) => new A({
1860
1860
  shape: () => s,
1861
1861
  unknownKeys: "strip",
1862
- catchall: U.create(),
1863
- typeName: y.ZodObject,
1864
- ...v(e)
1862
+ catchall: te.create(),
1863
+ typeName: v.ZodObject,
1864
+ ...k(e)
1865
1865
  });
1866
- k.strictCreate = (s, e) => new k({
1866
+ A.strictCreate = (s, e) => new A({
1867
1867
  shape: () => s,
1868
1868
  unknownKeys: "strict",
1869
- catchall: U.create(),
1870
- typeName: y.ZodObject,
1871
- ...v(e)
1869
+ catchall: te.create(),
1870
+ typeName: v.ZodObject,
1871
+ ...k(e)
1872
1872
  });
1873
- k.lazycreate = (s, e) => new k({
1873
+ A.lazycreate = (s, e) => new A({
1874
1874
  shape: s,
1875
1875
  unknownKeys: "strip",
1876
- catchall: U.create(),
1877
- typeName: y.ZodObject,
1878
- ...v(e)
1876
+ catchall: te.create(),
1877
+ typeName: v.ZodObject,
1878
+ ...k(e)
1879
1879
  });
1880
- class ae extends _ {
1880
+ class be extends x {
1881
1881
  _parse(e) {
1882
1882
  const { ctx: t } = this._processInputParams(e), r = this._def.options;
1883
1883
  function n(a) {
1884
- for (const i of a)
1885
- if (i.result.status === "valid")
1886
- return i.result;
1887
- for (const i of a)
1888
- if (i.result.status === "dirty")
1889
- return t.common.issues.push(...i.ctx.common.issues), i.result;
1890
- const o = a.map((i) => new P(i.ctx.common.issues));
1891
- return u(t, {
1892
- code: c.invalid_union,
1893
- unionErrors: o
1894
- }), g;
1884
+ for (const o of a)
1885
+ if (o.result.status === "valid")
1886
+ return o.result;
1887
+ for (const o of a)
1888
+ if (o.result.status === "dirty")
1889
+ return t.common.issues.push(...o.ctx.common.issues), o.result;
1890
+ const i = a.map((o) => new J(o.ctx.common.issues));
1891
+ return f(t, {
1892
+ code: u.invalid_union,
1893
+ unionErrors: i
1894
+ }), _;
1895
1895
  }
1896
1896
  if (t.common.async)
1897
1897
  return Promise.all(r.map(async (a) => {
1898
- const o = {
1898
+ const i = {
1899
1899
  ...t,
1900
1900
  common: {
1901
1901
  ...t.common,
@@ -1907,84 +1907,84 @@ class ae extends _ {
1907
1907
  result: await a._parseAsync({
1908
1908
  data: t.data,
1909
1909
  path: t.path,
1910
- parent: o
1910
+ parent: i
1911
1911
  }),
1912
- ctx: o
1912
+ ctx: i
1913
1913
  };
1914
1914
  })).then(n);
1915
1915
  {
1916
1916
  let a;
1917
- const o = [];
1918
- for (const d of r) {
1919
- const l = {
1917
+ const i = [];
1918
+ for (const l of r) {
1919
+ const c = {
1920
1920
  ...t,
1921
1921
  common: {
1922
1922
  ...t.common,
1923
1923
  issues: []
1924
1924
  },
1925
1925
  parent: null
1926
- }, m = d._parseSync({
1926
+ }, g = l._parseSync({
1927
1927
  data: t.data,
1928
1928
  path: t.path,
1929
- parent: l
1929
+ parent: c
1930
1930
  });
1931
- if (m.status === "valid")
1932
- return m;
1933
- m.status === "dirty" && !a && (a = { result: m, ctx: l }), l.common.issues.length && o.push(l.common.issues);
1931
+ if (g.status === "valid")
1932
+ return g;
1933
+ g.status === "dirty" && !a && (a = { result: g, ctx: c }), c.common.issues.length && i.push(c.common.issues);
1934
1934
  }
1935
1935
  if (a)
1936
1936
  return t.common.issues.push(...a.ctx.common.issues), a.result;
1937
- const i = o.map((d) => new P(d));
1938
- return u(t, {
1939
- code: c.invalid_union,
1940
- unionErrors: i
1941
- }), g;
1937
+ const o = i.map((l) => new J(l));
1938
+ return f(t, {
1939
+ code: u.invalid_union,
1940
+ unionErrors: o
1941
+ }), _;
1942
1942
  }
1943
1943
  }
1944
1944
  get options() {
1945
1945
  return this._def.options;
1946
1946
  }
1947
1947
  }
1948
- ae.create = (s, e) => new ae({
1948
+ be.create = (s, e) => new be({
1949
1949
  options: s,
1950
- typeName: y.ZodUnion,
1951
- ...v(e)
1950
+ typeName: v.ZodUnion,
1951
+ ...k(e)
1952
1952
  });
1953
- function he(s, e) {
1954
- const t = V(s), r = V(e);
1953
+ function Oe(s, e) {
1954
+ const t = K(s), r = K(e);
1955
1955
  if (s === e)
1956
1956
  return { valid: !0, data: s };
1957
1957
  if (t === h.object && r === h.object) {
1958
- const n = b.objectKeys(e), a = b.objectKeys(s).filter((i) => n.indexOf(i) !== -1), o = { ...s, ...e };
1959
- for (const i of a) {
1960
- const d = he(s[i], e[i]);
1961
- if (!d.valid)
1958
+ const n = C.objectKeys(e), a = C.objectKeys(s).filter((o) => n.indexOf(o) !== -1), i = { ...s, ...e };
1959
+ for (const o of a) {
1960
+ const l = Oe(s[o], e[o]);
1961
+ if (!l.valid)
1962
1962
  return { valid: !1 };
1963
- o[i] = d.data;
1963
+ i[o] = l.data;
1964
1964
  }
1965
- return { valid: !0, data: o };
1965
+ return { valid: !0, data: i };
1966
1966
  } else if (t === h.array && r === h.array) {
1967
1967
  if (s.length !== e.length)
1968
1968
  return { valid: !1 };
1969
1969
  const n = [];
1970
1970
  for (let a = 0; a < s.length; a++) {
1971
- const o = s[a], i = e[a], d = he(o, i);
1972
- if (!d.valid)
1971
+ const i = s[a], o = e[a], l = Oe(i, o);
1972
+ if (!l.valid)
1973
1973
  return { valid: !1 };
1974
- n.push(d.data);
1974
+ n.push(l.data);
1975
1975
  }
1976
1976
  return { valid: !0, data: n };
1977
1977
  } else return t === h.date && r === h.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
1978
1978
  }
1979
- class ie extends _ {
1979
+ class ke extends x {
1980
1980
  _parse(e) {
1981
- const { status: t, ctx: r } = this._processInputParams(e), n = (a, o) => {
1982
- if (be(a) || be(o))
1983
- return g;
1984
- const i = he(a.value, o.value);
1985
- return i.valid ? ((ke(a) || ke(o)) && t.dirty(), { status: t.value, value: i.data }) : (u(r, {
1986
- code: c.invalid_intersection_types
1987
- }), g);
1981
+ const { status: t, ctx: r } = this._processInputParams(e), n = (a, i) => {
1982
+ if ($e(a) || $e(i))
1983
+ return _;
1984
+ const o = Oe(a.value, i.value);
1985
+ return o.valid ? ((Ie(a) || Ie(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(r, {
1986
+ code: u.invalid_intersection_types
1987
+ }), _);
1988
1988
  };
1989
1989
  return r.common.async ? Promise.all([
1990
1990
  this._def.left._parseAsync({
@@ -1997,7 +1997,7 @@ class ie extends _ {
1997
1997
  path: r.path,
1998
1998
  parent: r
1999
1999
  })
2000
- ]).then(([a, o]) => n(a, o)) : n(this._def.left._parseSync({
2000
+ ]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
2001
2001
  data: r.data,
2002
2002
  path: r.path,
2003
2003
  parent: r
@@ -2008,63 +2008,63 @@ class ie extends _ {
2008
2008
  }));
2009
2009
  }
2010
2010
  }
2011
- ie.create = (s, e, t) => new ie({
2011
+ ke.create = (s, e, t) => new ke({
2012
2012
  left: s,
2013
2013
  right: e,
2014
- typeName: y.ZodIntersection,
2015
- ...v(t)
2014
+ typeName: v.ZodIntersection,
2015
+ ...k(t)
2016
2016
  });
2017
- class F extends _ {
2017
+ class re extends x {
2018
2018
  _parse(e) {
2019
2019
  const { status: t, ctx: r } = this._processInputParams(e);
2020
2020
  if (r.parsedType !== h.array)
2021
- return u(r, {
2022
- code: c.invalid_type,
2021
+ return f(r, {
2022
+ code: u.invalid_type,
2023
2023
  expected: h.array,
2024
2024
  received: r.parsedType
2025
- }), g;
2025
+ }), _;
2026
2026
  if (r.data.length < this._def.items.length)
2027
- return u(r, {
2028
- code: c.too_small,
2027
+ return f(r, {
2028
+ code: u.too_small,
2029
2029
  minimum: this._def.items.length,
2030
2030
  inclusive: !0,
2031
2031
  exact: !1,
2032
2032
  type: "array"
2033
- }), g;
2034
- !this._def.rest && r.data.length > this._def.items.length && (u(r, {
2035
- code: c.too_big,
2033
+ }), _;
2034
+ !this._def.rest && r.data.length > this._def.items.length && (f(r, {
2035
+ code: u.too_big,
2036
2036
  maximum: this._def.items.length,
2037
2037
  inclusive: !0,
2038
2038
  exact: !1,
2039
2039
  type: "array"
2040
2040
  }), t.dirty());
2041
- const a = [...r.data].map((o, i) => {
2042
- const d = this._def.items[i] || this._def.rest;
2043
- return d ? d._parse(new I(r, o, r.path, i)) : null;
2044
- }).filter((o) => !!o);
2045
- return r.common.async ? Promise.all(a).then((o) => O.mergeArray(t, o)) : O.mergeArray(t, a);
2041
+ const a = [...r.data].map((i, o) => {
2042
+ const l = this._def.items[o] || this._def.rest;
2043
+ return l ? l._parse(new H(r, i, r.path, o)) : null;
2044
+ }).filter((i) => !!i);
2045
+ return r.common.async ? Promise.all(a).then((i) => $.mergeArray(t, i)) : $.mergeArray(t, a);
2046
2046
  }
2047
2047
  get items() {
2048
2048
  return this._def.items;
2049
2049
  }
2050
2050
  rest(e) {
2051
- return new F({
2051
+ return new re({
2052
2052
  ...this._def,
2053
2053
  rest: e
2054
2054
  });
2055
2055
  }
2056
2056
  }
2057
- F.create = (s, e) => {
2057
+ re.create = (s, e) => {
2058
2058
  if (!Array.isArray(s))
2059
2059
  throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2060
- return new F({
2060
+ return new re({
2061
2061
  items: s,
2062
- typeName: y.ZodTuple,
2062
+ typeName: v.ZodTuple,
2063
2063
  rest: null,
2064
- ...v(e)
2064
+ ...k(e)
2065
2065
  });
2066
2066
  };
2067
- class oe extends _ {
2067
+ class we extends x {
2068
2068
  get keySchema() {
2069
2069
  return this._def.keyType;
2070
2070
  }
@@ -2074,38 +2074,38 @@ class oe extends _ {
2074
2074
  _parse(e) {
2075
2075
  const { status: t, ctx: r } = this._processInputParams(e);
2076
2076
  if (r.parsedType !== h.object)
2077
- return u(r, {
2078
- code: c.invalid_type,
2077
+ return f(r, {
2078
+ code: u.invalid_type,
2079
2079
  expected: h.object,
2080
2080
  received: r.parsedType
2081
- }), g;
2082
- const n = [], a = this._def.keyType, o = this._def.valueType;
2083
- for (const i in r.data)
2081
+ }), _;
2082
+ const n = [], a = this._def.keyType, i = this._def.valueType;
2083
+ for (const o in r.data)
2084
2084
  n.push({
2085
- key: a._parse(new I(r, i, r.path, i)),
2086
- value: o._parse(new I(r, r.data[i], r.path, i)),
2087
- alwaysSet: i in r.data
2085
+ key: a._parse(new H(r, o, r.path, o)),
2086
+ value: i._parse(new H(r, r.data[o], r.path, o)),
2087
+ alwaysSet: o in r.data
2088
2088
  });
2089
- return r.common.async ? O.mergeObjectAsync(t, n) : O.mergeObjectSync(t, n);
2089
+ return r.common.async ? $.mergeObjectAsync(t, n) : $.mergeObjectSync(t, n);
2090
2090
  }
2091
2091
  get element() {
2092
2092
  return this._def.valueType;
2093
2093
  }
2094
2094
  static create(e, t, r) {
2095
- return t instanceof _ ? new oe({
2095
+ return t instanceof x ? new we({
2096
2096
  keyType: e,
2097
2097
  valueType: t,
2098
- typeName: y.ZodRecord,
2099
- ...v(r)
2100
- }) : new oe({
2101
- keyType: L.create(),
2098
+ typeName: v.ZodRecord,
2099
+ ...k(r)
2100
+ }) : new we({
2101
+ keyType: G.create(),
2102
2102
  valueType: e,
2103
- typeName: y.ZodRecord,
2104
- ...v(t)
2103
+ typeName: v.ZodRecord,
2104
+ ...k(t)
2105
2105
  });
2106
2106
  }
2107
2107
  }
2108
- class Ne extends _ {
2108
+ class He extends x {
2109
2109
  get keySchema() {
2110
2110
  return this._def.keyType;
2111
2111
  }
@@ -2115,63 +2115,63 @@ class Ne extends _ {
2115
2115
  _parse(e) {
2116
2116
  const { status: t, ctx: r } = this._processInputParams(e);
2117
2117
  if (r.parsedType !== h.map)
2118
- return u(r, {
2119
- code: c.invalid_type,
2118
+ return f(r, {
2119
+ code: u.invalid_type,
2120
2120
  expected: h.map,
2121
2121
  received: r.parsedType
2122
- }), g;
2123
- const n = this._def.keyType, a = this._def.valueType, o = [...r.data.entries()].map(([i, d], l) => ({
2124
- key: n._parse(new I(r, i, r.path, [l, "key"])),
2125
- value: a._parse(new I(r, d, r.path, [l, "value"]))
2122
+ }), _;
2123
+ const n = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o, l], c) => ({
2124
+ key: n._parse(new H(r, o, r.path, [c, "key"])),
2125
+ value: a._parse(new H(r, l, r.path, [c, "value"]))
2126
2126
  }));
2127
2127
  if (r.common.async) {
2128
- const i = /* @__PURE__ */ new Map();
2128
+ const o = /* @__PURE__ */ new Map();
2129
2129
  return Promise.resolve().then(async () => {
2130
- for (const d of o) {
2131
- const l = await d.key, m = await d.value;
2132
- if (l.status === "aborted" || m.status === "aborted")
2133
- return g;
2134
- (l.status === "dirty" || m.status === "dirty") && t.dirty(), i.set(l.value, m.value);
2130
+ for (const l of i) {
2131
+ const c = await l.key, g = await l.value;
2132
+ if (c.status === "aborted" || g.status === "aborted")
2133
+ return _;
2134
+ (c.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(c.value, g.value);
2135
2135
  }
2136
- return { status: t.value, value: i };
2136
+ return { status: t.value, value: o };
2137
2137
  });
2138
2138
  } else {
2139
- const i = /* @__PURE__ */ new Map();
2140
- for (const d of o) {
2141
- const l = d.key, m = d.value;
2142
- if (l.status === "aborted" || m.status === "aborted")
2143
- return g;
2144
- (l.status === "dirty" || m.status === "dirty") && t.dirty(), i.set(l.value, m.value);
2139
+ const o = /* @__PURE__ */ new Map();
2140
+ for (const l of i) {
2141
+ const c = l.key, g = l.value;
2142
+ if (c.status === "aborted" || g.status === "aborted")
2143
+ return _;
2144
+ (c.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(c.value, g.value);
2145
2145
  }
2146
- return { status: t.value, value: i };
2146
+ return { status: t.value, value: o };
2147
2147
  }
2148
2148
  }
2149
2149
  }
2150
- Ne.create = (s, e, t) => new Ne({
2150
+ He.create = (s, e, t) => new He({
2151
2151
  valueType: e,
2152
2152
  keyType: s,
2153
- typeName: y.ZodMap,
2154
- ...v(t)
2153
+ typeName: v.ZodMap,
2154
+ ...k(t)
2155
2155
  });
2156
- class K extends _ {
2156
+ class me extends x {
2157
2157
  _parse(e) {
2158
2158
  const { status: t, ctx: r } = this._processInputParams(e);
2159
2159
  if (r.parsedType !== h.set)
2160
- return u(r, {
2161
- code: c.invalid_type,
2160
+ return f(r, {
2161
+ code: u.invalid_type,
2162
2162
  expected: h.set,
2163
2163
  received: r.parsedType
2164
- }), g;
2164
+ }), _;
2165
2165
  const n = this._def;
2166
- n.minSize !== null && r.data.size < n.minSize.value && (u(r, {
2167
- code: c.too_small,
2166
+ n.minSize !== null && r.data.size < n.minSize.value && (f(r, {
2167
+ code: u.too_small,
2168
2168
  minimum: n.minSize.value,
2169
2169
  type: "set",
2170
2170
  inclusive: !0,
2171
2171
  exact: !1,
2172
2172
  message: n.minSize.message
2173
- }), t.dirty()), n.maxSize !== null && r.data.size > n.maxSize.value && (u(r, {
2174
- code: c.too_big,
2173
+ }), t.dirty()), n.maxSize !== null && r.data.size > n.maxSize.value && (f(r, {
2174
+ code: u.too_big,
2175
2175
  maximum: n.maxSize.value,
2176
2176
  type: "set",
2177
2177
  inclusive: !0,
@@ -2179,28 +2179,28 @@ class K extends _ {
2179
2179
  message: n.maxSize.message
2180
2180
  }), t.dirty());
2181
2181
  const a = this._def.valueType;
2182
- function o(d) {
2183
- const l = /* @__PURE__ */ new Set();
2184
- for (const m of d) {
2185
- if (m.status === "aborted")
2186
- return g;
2187
- m.status === "dirty" && t.dirty(), l.add(m.value);
2182
+ function i(l) {
2183
+ const c = /* @__PURE__ */ new Set();
2184
+ for (const g of l) {
2185
+ if (g.status === "aborted")
2186
+ return _;
2187
+ g.status === "dirty" && t.dirty(), c.add(g.value);
2188
2188
  }
2189
- return { status: t.value, value: l };
2189
+ return { status: t.value, value: c };
2190
2190
  }
2191
- const i = [...r.data.values()].map((d, l) => a._parse(new I(r, d, r.path, l)));
2192
- return r.common.async ? Promise.all(i).then((d) => o(d)) : o(i);
2191
+ const o = [...r.data.values()].map((l, c) => a._parse(new H(r, l, r.path, c)));
2192
+ return r.common.async ? Promise.all(o).then((l) => i(l)) : i(o);
2193
2193
  }
2194
2194
  min(e, t) {
2195
- return new K({
2195
+ return new me({
2196
2196
  ...this._def,
2197
- minSize: { value: e, message: f.toString(t) }
2197
+ minSize: { value: e, message: y.toString(t) }
2198
2198
  });
2199
2199
  }
2200
2200
  max(e, t) {
2201
- return new K({
2201
+ return new me({
2202
2202
  ...this._def,
2203
- maxSize: { value: e, message: f.toString(t) }
2203
+ maxSize: { value: e, message: y.toString(t) }
2204
2204
  });
2205
2205
  }
2206
2206
  size(e, t) {
@@ -2210,14 +2210,14 @@ class K extends _ {
2210
2210
  return this.min(1, e);
2211
2211
  }
2212
2212
  }
2213
- K.create = (s, e) => new K({
2213
+ me.create = (s, e) => new me({
2214
2214
  valueType: s,
2215
2215
  minSize: null,
2216
2216
  maxSize: null,
2217
- typeName: y.ZodSet,
2218
- ...v(e)
2217
+ typeName: v.ZodSet,
2218
+ ...k(e)
2219
2219
  });
2220
- class Re extends _ {
2220
+ class We extends x {
2221
2221
  get schema() {
2222
2222
  return this._def.getter();
2223
2223
  }
@@ -2226,20 +2226,20 @@ class Re extends _ {
2226
2226
  return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2227
2227
  }
2228
2228
  }
2229
- Re.create = (s, e) => new Re({
2229
+ We.create = (s, e) => new We({
2230
2230
  getter: s,
2231
- typeName: y.ZodLazy,
2232
- ...v(e)
2231
+ typeName: v.ZodLazy,
2232
+ ...k(e)
2233
2233
  });
2234
- class Ze extends _ {
2234
+ class Xe extends x {
2235
2235
  _parse(e) {
2236
2236
  if (e.data !== this._def.value) {
2237
2237
  const t = this._getOrReturnCtx(e);
2238
- return u(t, {
2238
+ return f(t, {
2239
2239
  received: t.data,
2240
- code: c.invalid_literal,
2240
+ code: u.invalid_literal,
2241
2241
  expected: this._def.value
2242
- }), g;
2242
+ }), _;
2243
2243
  }
2244
2244
  return { status: "valid", value: e.data };
2245
2245
  }
@@ -2247,37 +2247,37 @@ class Ze extends _ {
2247
2247
  return this._def.value;
2248
2248
  }
2249
2249
  }
2250
- Ze.create = (s, e) => new Ze({
2250
+ Xe.create = (s, e) => new Xe({
2251
2251
  value: s,
2252
- typeName: y.ZodLiteral,
2253
- ...v(e)
2252
+ typeName: v.ZodLiteral,
2253
+ ...k(e)
2254
2254
  });
2255
- function Ue(s, e) {
2256
- return new W({
2255
+ function ut(s, e) {
2256
+ return new de({
2257
2257
  values: s,
2258
- typeName: y.ZodEnum,
2259
- ...v(e)
2258
+ typeName: v.ZodEnum,
2259
+ ...k(e)
2260
2260
  });
2261
2261
  }
2262
- class W extends _ {
2262
+ class de extends x {
2263
2263
  _parse(e) {
2264
2264
  if (typeof e.data != "string") {
2265
2265
  const t = this._getOrReturnCtx(e), r = this._def.values;
2266
- return u(t, {
2267
- expected: b.joinValues(r),
2266
+ return f(t, {
2267
+ expected: C.joinValues(r),
2268
2268
  received: t.parsedType,
2269
- code: c.invalid_type
2270
- }), g;
2269
+ code: u.invalid_type
2270
+ }), _;
2271
2271
  }
2272
2272
  if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2273
2273
  const t = this._getOrReturnCtx(e), r = this._def.values;
2274
- return u(t, {
2274
+ return f(t, {
2275
2275
  received: t.data,
2276
- code: c.invalid_enum_value,
2276
+ code: u.invalid_enum_value,
2277
2277
  options: r
2278
- }), g;
2278
+ }), _;
2279
2279
  }
2280
- return N(e.data);
2280
+ return q(e.data);
2281
2281
  }
2282
2282
  get options() {
2283
2283
  return this._def.values;
@@ -2301,192 +2301,192 @@ class W extends _ {
2301
2301
  return e;
2302
2302
  }
2303
2303
  extract(e, t = this._def) {
2304
- return W.create(e, {
2304
+ return de.create(e, {
2305
2305
  ...this._def,
2306
2306
  ...t
2307
2307
  });
2308
2308
  }
2309
2309
  exclude(e, t = this._def) {
2310
- return W.create(this.options.filter((r) => !e.includes(r)), {
2310
+ return de.create(this.options.filter((r) => !e.includes(r)), {
2311
2311
  ...this._def,
2312
2312
  ...t
2313
2313
  });
2314
2314
  }
2315
2315
  }
2316
- W.create = Ue;
2317
- class $e extends _ {
2316
+ de.create = ut;
2317
+ class Ge extends x {
2318
2318
  _parse(e) {
2319
- const t = b.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
2319
+ const t = C.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
2320
2320
  if (r.parsedType !== h.string && r.parsedType !== h.number) {
2321
- const n = b.objectValues(t);
2322
- return u(r, {
2323
- expected: b.joinValues(n),
2321
+ const n = C.objectValues(t);
2322
+ return f(r, {
2323
+ expected: C.joinValues(n),
2324
2324
  received: r.parsedType,
2325
- code: c.invalid_type
2326
- }), g;
2325
+ code: u.invalid_type
2326
+ }), _;
2327
2327
  }
2328
- if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2329
- const n = b.objectValues(t);
2330
- return u(r, {
2328
+ if (this._cache || (this._cache = new Set(C.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2329
+ const n = C.objectValues(t);
2330
+ return f(r, {
2331
2331
  received: r.data,
2332
- code: c.invalid_enum_value,
2332
+ code: u.invalid_enum_value,
2333
2333
  options: n
2334
- }), g;
2334
+ }), _;
2335
2335
  }
2336
- return N(e.data);
2336
+ return q(e.data);
2337
2337
  }
2338
2338
  get enum() {
2339
2339
  return this._def.values;
2340
2340
  }
2341
2341
  }
2342
- $e.create = (s, e) => new $e({
2342
+ Ge.create = (s, e) => new Ge({
2343
2343
  values: s,
2344
- typeName: y.ZodNativeEnum,
2345
- ...v(e)
2344
+ typeName: v.ZodNativeEnum,
2345
+ ...k(e)
2346
2346
  });
2347
- class ce extends _ {
2347
+ class xe extends x {
2348
2348
  unwrap() {
2349
2349
  return this._def.type;
2350
2350
  }
2351
2351
  _parse(e) {
2352
2352
  const { ctx: t } = this._processInputParams(e);
2353
2353
  if (t.parsedType !== h.promise && t.common.async === !1)
2354
- return u(t, {
2355
- code: c.invalid_type,
2354
+ return f(t, {
2355
+ code: u.invalid_type,
2356
2356
  expected: h.promise,
2357
2357
  received: t.parsedType
2358
- }), g;
2358
+ }), _;
2359
2359
  const r = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
2360
- return N(r.then((n) => this._def.type.parseAsync(n, {
2360
+ return q(r.then((n) => this._def.type.parseAsync(n, {
2361
2361
  path: t.path,
2362
2362
  errorMap: t.common.contextualErrorMap
2363
2363
  })));
2364
2364
  }
2365
2365
  }
2366
- ce.create = (s, e) => new ce({
2366
+ xe.create = (s, e) => new xe({
2367
2367
  type: s,
2368
- typeName: y.ZodPromise,
2369
- ...v(e)
2368
+ typeName: v.ZodPromise,
2369
+ ...k(e)
2370
2370
  });
2371
- class X extends _ {
2371
+ class ue extends x {
2372
2372
  innerType() {
2373
2373
  return this._def.schema;
2374
2374
  }
2375
2375
  sourceType() {
2376
- return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2376
+ return this._def.schema._def.typeName === v.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2377
2377
  }
2378
2378
  _parse(e) {
2379
2379
  const { status: t, ctx: r } = this._processInputParams(e), n = this._def.effect || null, a = {
2380
- addIssue: (o) => {
2381
- u(r, o), o.fatal ? t.abort() : t.dirty();
2380
+ addIssue: (i) => {
2381
+ f(r, i), i.fatal ? t.abort() : t.dirty();
2382
2382
  },
2383
2383
  get path() {
2384
2384
  return r.path;
2385
2385
  }
2386
2386
  };
2387
2387
  if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
2388
- const o = n.transform(r.data, a);
2388
+ const i = n.transform(r.data, a);
2389
2389
  if (r.common.async)
2390
- return Promise.resolve(o).then(async (i) => {
2390
+ return Promise.resolve(i).then(async (o) => {
2391
2391
  if (t.value === "aborted")
2392
- return g;
2393
- const d = await this._def.schema._parseAsync({
2394
- data: i,
2392
+ return _;
2393
+ const l = await this._def.schema._parseAsync({
2394
+ data: o,
2395
2395
  path: r.path,
2396
2396
  parent: r
2397
2397
  });
2398
- return d.status === "aborted" ? g : d.status === "dirty" || t.value === "dirty" ? Y(d.value) : d;
2398
+ return l.status === "aborted" ? _ : l.status === "dirty" || t.value === "dirty" ? he(l.value) : l;
2399
2399
  });
2400
2400
  {
2401
2401
  if (t.value === "aborted")
2402
- return g;
2403
- const i = this._def.schema._parseSync({
2404
- data: o,
2402
+ return _;
2403
+ const o = this._def.schema._parseSync({
2404
+ data: i,
2405
2405
  path: r.path,
2406
2406
  parent: r
2407
2407
  });
2408
- return i.status === "aborted" ? g : i.status === "dirty" || t.value === "dirty" ? Y(i.value) : i;
2408
+ return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ? he(o.value) : o;
2409
2409
  }
2410
2410
  }
2411
2411
  if (n.type === "refinement") {
2412
- const o = (i) => {
2413
- const d = n.refinement(i, a);
2412
+ const i = (o) => {
2413
+ const l = n.refinement(o, a);
2414
2414
  if (r.common.async)
2415
- return Promise.resolve(d);
2416
- if (d instanceof Promise)
2415
+ return Promise.resolve(l);
2416
+ if (l instanceof Promise)
2417
2417
  throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2418
- return i;
2418
+ return o;
2419
2419
  };
2420
2420
  if (r.common.async === !1) {
2421
- const i = this._def.schema._parseSync({
2421
+ const o = this._def.schema._parseSync({
2422
2422
  data: r.data,
2423
2423
  path: r.path,
2424
2424
  parent: r
2425
2425
  });
2426
- return i.status === "aborted" ? g : (i.status === "dirty" && t.dirty(), o(i.value), { status: t.value, value: i.value });
2426
+ return o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2427
2427
  } else
2428
- return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => i.status === "aborted" ? g : (i.status === "dirty" && t.dirty(), o(i.value).then(() => ({ status: t.value, value: i.value }))));
2428
+ return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2429
2429
  }
2430
2430
  if (n.type === "transform")
2431
2431
  if (r.common.async === !1) {
2432
- const o = this._def.schema._parseSync({
2432
+ const i = this._def.schema._parseSync({
2433
2433
  data: r.data,
2434
2434
  path: r.path,
2435
2435
  parent: r
2436
2436
  });
2437
- if (!B(o))
2438
- return g;
2439
- const i = n.transform(o.value, a);
2440
- if (i instanceof Promise)
2437
+ if (!oe(i))
2438
+ return _;
2439
+ const o = n.transform(i.value, a);
2440
+ if (o instanceof Promise)
2441
2441
  throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2442
- return { status: t.value, value: i };
2442
+ return { status: t.value, value: o };
2443
2443
  } else
2444
- return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => B(o) ? Promise.resolve(n.transform(o.value, a)).then((i) => ({
2444
+ return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => oe(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({
2445
2445
  status: t.value,
2446
- value: i
2447
- })) : g);
2448
- b.assertNever(n);
2446
+ value: o
2447
+ })) : _);
2448
+ C.assertNever(n);
2449
2449
  }
2450
2450
  }
2451
- X.create = (s, e, t) => new X({
2451
+ ue.create = (s, e, t) => new ue({
2452
2452
  schema: s,
2453
- typeName: y.ZodEffects,
2453
+ typeName: v.ZodEffects,
2454
2454
  effect: e,
2455
- ...v(t)
2455
+ ...k(t)
2456
2456
  });
2457
- X.createWithPreprocess = (s, e, t) => new X({
2457
+ ue.createWithPreprocess = (s, e, t) => new ue({
2458
2458
  schema: e,
2459
2459
  effect: { type: "preprocess", transform: s },
2460
- typeName: y.ZodEffects,
2461
- ...v(t)
2460
+ typeName: v.ZodEffects,
2461
+ ...k(t)
2462
2462
  });
2463
- class z extends _ {
2463
+ class ee extends x {
2464
2464
  _parse(e) {
2465
- return this._getType(e) === h.undefined ? N(void 0) : this._def.innerType._parse(e);
2465
+ return this._getType(e) === h.undefined ? q(void 0) : this._def.innerType._parse(e);
2466
2466
  }
2467
2467
  unwrap() {
2468
2468
  return this._def.innerType;
2469
2469
  }
2470
2470
  }
2471
- z.create = (s, e) => new z({
2471
+ ee.create = (s, e) => new ee({
2472
2472
  innerType: s,
2473
- typeName: y.ZodOptional,
2474
- ...v(e)
2473
+ typeName: v.ZodOptional,
2474
+ ...k(e)
2475
2475
  });
2476
- class G extends _ {
2476
+ class le extends x {
2477
2477
  _parse(e) {
2478
- return this._getType(e) === h.null ? N(null) : this._def.innerType._parse(e);
2478
+ return this._getType(e) === h.null ? q(null) : this._def.innerType._parse(e);
2479
2479
  }
2480
2480
  unwrap() {
2481
2481
  return this._def.innerType;
2482
2482
  }
2483
2483
  }
2484
- G.create = (s, e) => new G({
2484
+ le.create = (s, e) => new le({
2485
2485
  innerType: s,
2486
- typeName: y.ZodNullable,
2487
- ...v(e)
2486
+ typeName: v.ZodNullable,
2487
+ ...k(e)
2488
2488
  });
2489
- class fe extends _ {
2489
+ class Ne extends x {
2490
2490
  _parse(e) {
2491
2491
  const { ctx: t } = this._processInputParams(e);
2492
2492
  let r = t.data;
@@ -2500,13 +2500,13 @@ class fe extends _ {
2500
2500
  return this._def.innerType;
2501
2501
  }
2502
2502
  }
2503
- fe.create = (s, e) => new fe({
2503
+ Ne.create = (s, e) => new Ne({
2504
2504
  innerType: s,
2505
- typeName: y.ZodDefault,
2505
+ typeName: v.ZodDefault,
2506
2506
  defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2507
- ...v(e)
2507
+ ...k(e)
2508
2508
  });
2509
- class pe extends _ {
2509
+ class Ae extends x {
2510
2510
  _parse(e) {
2511
2511
  const { ctx: t } = this._processInputParams(e), r = {
2512
2512
  ...t,
@@ -2521,11 +2521,11 @@ class pe extends _ {
2521
2521
  ...r
2522
2522
  }
2523
2523
  });
2524
- return re(n) ? n.then((a) => ({
2524
+ return ve(n) ? n.then((a) => ({
2525
2525
  status: "valid",
2526
2526
  value: a.status === "valid" ? a.value : this._def.catchValue({
2527
2527
  get error() {
2528
- return new P(r.common.issues);
2528
+ return new J(r.common.issues);
2529
2529
  },
2530
2530
  input: r.data
2531
2531
  })
@@ -2533,7 +2533,7 @@ class pe extends _ {
2533
2533
  status: "valid",
2534
2534
  value: n.status === "valid" ? n.value : this._def.catchValue({
2535
2535
  get error() {
2536
- return new P(r.common.issues);
2536
+ return new J(r.common.issues);
2537
2537
  },
2538
2538
  input: r.data
2539
2539
  })
@@ -2543,30 +2543,30 @@ class pe extends _ {
2543
2543
  return this._def.innerType;
2544
2544
  }
2545
2545
  }
2546
- pe.create = (s, e) => new pe({
2546
+ Ae.create = (s, e) => new Ae({
2547
2547
  innerType: s,
2548
- typeName: y.ZodCatch,
2548
+ typeName: v.ZodCatch,
2549
2549
  catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2550
- ...v(e)
2550
+ ...k(e)
2551
2551
  });
2552
- class je extends _ {
2552
+ class Je extends x {
2553
2553
  _parse(e) {
2554
2554
  if (this._getType(e) !== h.nan) {
2555
2555
  const r = this._getOrReturnCtx(e);
2556
- return u(r, {
2557
- code: c.invalid_type,
2556
+ return f(r, {
2557
+ code: u.invalid_type,
2558
2558
  expected: h.nan,
2559
2559
  received: r.parsedType
2560
- }), g;
2560
+ }), _;
2561
2561
  }
2562
2562
  return { status: "valid", value: e.data };
2563
2563
  }
2564
2564
  }
2565
- je.create = (s) => new je({
2566
- typeName: y.ZodNaN,
2567
- ...v(s)
2565
+ Je.create = (s) => new Je({
2566
+ typeName: v.ZodNaN,
2567
+ ...k(s)
2568
2568
  });
2569
- class _t extends _ {
2569
+ class Vt extends x {
2570
2570
  _parse(e) {
2571
2571
  const { ctx: t } = this._processInputParams(e), r = t.data;
2572
2572
  return this._def.type._parse({
@@ -2579,7 +2579,7 @@ class _t extends _ {
2579
2579
  return this._def.type;
2580
2580
  }
2581
2581
  }
2582
- class ge extends _ {
2582
+ class Me extends x {
2583
2583
  _parse(e) {
2584
2584
  const { status: t, ctx: r } = this._processInputParams(e);
2585
2585
  if (r.common.async)
@@ -2589,7 +2589,7 @@ class ge extends _ {
2589
2589
  path: r.path,
2590
2590
  parent: r
2591
2591
  });
2592
- return a.status === "aborted" ? g : a.status === "dirty" ? (t.dirty(), Y(a.value)) : this._def.out._parseAsync({
2592
+ return a.status === "aborted" ? _ : a.status === "dirty" ? (t.dirty(), he(a.value)) : this._def.out._parseAsync({
2593
2593
  data: a.value,
2594
2594
  path: r.path,
2595
2595
  parent: r
@@ -2601,7 +2601,7 @@ class ge extends _ {
2601
2601
  path: r.path,
2602
2602
  parent: r
2603
2603
  });
2604
- return n.status === "aborted" ? g : n.status === "dirty" ? (t.dirty(), {
2604
+ return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), {
2605
2605
  status: "dirty",
2606
2606
  value: n.value
2607
2607
  }) : this._def.out._parseSync({
@@ -2612,108 +2612,175 @@ class ge extends _ {
2612
2612
  }
2613
2613
  }
2614
2614
  static create(e, t) {
2615
- return new ge({
2615
+ return new Me({
2616
2616
  in: e,
2617
2617
  out: t,
2618
- typeName: y.ZodPipeline
2618
+ typeName: v.ZodPipeline
2619
2619
  });
2620
2620
  }
2621
2621
  }
2622
- class me extends _ {
2622
+ class Ee extends x {
2623
2623
  _parse(e) {
2624
- const t = this._def.innerType._parse(e), r = (n) => (B(n) && (n.value = Object.freeze(n.value)), n);
2625
- return re(t) ? t.then((n) => r(n)) : r(t);
2624
+ const t = this._def.innerType._parse(e), r = (n) => (oe(n) && (n.value = Object.freeze(n.value)), n);
2625
+ return ve(t) ? t.then((n) => r(n)) : r(t);
2626
2626
  }
2627
2627
  unwrap() {
2628
2628
  return this._def.innerType;
2629
2629
  }
2630
2630
  }
2631
- me.create = (s, e) => new me({
2631
+ Ee.create = (s, e) => new Ee({
2632
2632
  innerType: s,
2633
- typeName: y.ZodReadonly,
2634
- ...v(e)
2633
+ typeName: v.ZodReadonly,
2634
+ ...k(e)
2635
2635
  });
2636
- var y;
2636
+ var v;
2637
2637
  (function(s) {
2638
2638
  s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
2639
- })(y || (y = {}));
2640
- const S = L.create, de = H.create;
2641
- U.create;
2642
- const R = j.create, D = k.create;
2643
- ae.create;
2644
- ie.create;
2645
- F.create;
2646
- const bt = oe.create, Fe = W.create;
2647
- ce.create;
2648
- z.create;
2649
- G.create;
2650
- class kt extends Error {
2639
+ })(v || (v = {}));
2640
+ const E = G.create, W = ce.create;
2641
+ te.create;
2642
+ const Z = B.create, I = A.create;
2643
+ be.create;
2644
+ ke.create;
2645
+ re.create;
2646
+ const zt = we.create, Ce = de.create;
2647
+ xe.create;
2648
+ ee.create;
2649
+ le.create;
2650
+ class Ut extends Error {
2651
2651
  constructor(t) {
2652
2652
  const r = `Invalid ChaosConfig:
2653
2653
  ${t.map((n) => ` - ${n}`).join(`
2654
2654
  `)}`;
2655
2655
  super(r);
2656
- E(this, "issues");
2656
+ P(this, "issues");
2657
2657
  this.name = "ChaosConfigError", this.issues = t;
2658
2658
  }
2659
2659
  }
2660
- const J = de().min(0, "Probability must be >= 0").max(1, "Probability must be <= 1"), xt = D({
2661
- urlPattern: S().min(1, "urlPattern must not be empty"),
2662
- methods: R(S()).optional(),
2663
- statusCode: de().int().min(100).max(599),
2664
- probability: J,
2665
- body: S().optional(),
2666
- statusText: S().optional(),
2667
- headers: bt(S()).optional()
2668
- }).strict(), wt = D({
2669
- urlPattern: S().min(1, "urlPattern must not be empty"),
2670
- methods: R(S()).optional(),
2671
- delayMs: de().min(0, "delayMs must be >= 0"),
2672
- probability: J
2673
- }).strict(), Ct = D({
2674
- urlPattern: S().min(1, "urlPattern must not be empty"),
2675
- methods: R(S()).optional(),
2676
- probability: J,
2677
- timeout: de().min(0, "timeout must be >= 0").optional()
2678
- }).strict(), Tt = D({
2679
- urlPattern: S().min(1, "urlPattern must not be empty"),
2680
- methods: R(S()).optional(),
2681
- probability: J,
2682
- strategy: Fe(["truncate", "malformed-json", "empty", "wrong-type"])
2683
- }).strict(), Ot = D({
2684
- urlPattern: S().min(1, "urlPattern must not be empty"),
2685
- methods: R(S()).optional(),
2686
- probability: J
2687
- }).strict(), St = D({
2688
- failures: R(xt).optional(),
2689
- latencies: R(wt).optional(),
2690
- aborts: R(Ct).optional(),
2691
- corruptions: R(Tt).optional(),
2692
- cors: R(Ot).optional()
2693
- }).strict(), At = D({
2694
- selector: S().min(1, "selector must not be empty"),
2695
- action: Fe(["disable", "hide", "remove"]),
2696
- probability: J
2697
- }).strict(), Et = D({
2698
- assaults: R(At).optional()
2699
- }).strict(), Nt = D({
2700
- network: St.optional(),
2701
- ui: Et.optional()
2660
+ const X = W().min(0, "Probability must be >= 0").max(1, "Probability must be <= 1"), Ye = W().int().min(1), Y = {
2661
+ onNth: Ye.optional(),
2662
+ everyNth: Ye.optional(),
2663
+ afterN: W().int().min(0).optional()
2664
+ }, qt = (s) => [s.onNth, s.everyNth, s.afterN].filter((e) => e !== void 0).length <= 1, Q = [
2665
+ qt,
2666
+ { message: "Only one of onNth, everyNth, or afterN may be set on a single rule" }
2667
+ ], Ft = I({
2668
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2669
+ methods: Z(E()).optional(),
2670
+ statusCode: W().int().min(100).max(599),
2671
+ probability: X,
2672
+ body: E().optional(),
2673
+ statusText: E().optional(),
2674
+ headers: zt(E()).optional(),
2675
+ ...Y
2676
+ }).strict().refine(...Q), Bt = I({
2677
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2678
+ methods: Z(E()).optional(),
2679
+ delayMs: W().min(0, "delayMs must be >= 0"),
2680
+ probability: X,
2681
+ ...Y
2682
+ }).strict().refine(...Q), Ht = I({
2683
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2684
+ methods: Z(E()).optional(),
2685
+ probability: X,
2686
+ timeout: W().min(0, "timeout must be >= 0").optional(),
2687
+ ...Y
2688
+ }).strict().refine(...Q), Wt = I({
2689
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2690
+ methods: Z(E()).optional(),
2691
+ probability: X,
2692
+ strategy: Ce(["truncate", "malformed-json", "empty", "wrong-type"]),
2693
+ ...Y
2694
+ }).strict().refine(...Q), Xt = I({
2695
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2696
+ methods: Z(E()).optional(),
2697
+ probability: X,
2698
+ ...Y
2699
+ }).strict().refine(...Q), Gt = I({
2700
+ failures: Z(Ft).optional(),
2701
+ latencies: Z(Bt).optional(),
2702
+ aborts: Z(Ht).optional(),
2703
+ corruptions: Z(Wt).optional(),
2704
+ cors: Z(Xt).optional()
2705
+ }).strict(), Jt = I({
2706
+ selector: E().min(1, "selector must not be empty"),
2707
+ action: Ce(["disable", "hide", "remove"]),
2708
+ probability: X
2709
+ }).strict(), Yt = I({
2710
+ assaults: Z(Jt).optional()
2711
+ }).strict(), je = Ce(["inbound", "outbound", "both"]), Qt = I({
2712
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2713
+ direction: je,
2714
+ probability: X,
2715
+ ...Y
2716
+ }).strict().refine(...Q), Kt = I({
2717
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2718
+ direction: je,
2719
+ delayMs: W().min(0, "delayMs must be >= 0"),
2720
+ probability: X,
2721
+ ...Y
2722
+ }).strict().refine(...Q), es = I({
2723
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2724
+ direction: je,
2725
+ strategy: Ce(["truncate", "malformed-json", "empty", "wrong-type"]),
2726
+ probability: X,
2727
+ ...Y
2728
+ }).strict().refine(...Q), ts = W().int().refine(
2729
+ (s) => s === 1e3 || s >= 3e3 && s <= 4999,
2730
+ { message: "code must be 1000 or in the range 3000-4999" }
2731
+ ), ss = E().refine(
2732
+ (s) => new TextEncoder().encode(s).length <= 123,
2733
+ { message: "reason must be <= 123 UTF-8 bytes" }
2734
+ ), rs = I({
2735
+ urlPattern: E().min(1, "urlPattern must not be empty"),
2736
+ code: ts.optional(),
2737
+ reason: ss.optional(),
2738
+ afterMs: W().min(0, "afterMs must be >= 0").optional(),
2739
+ probability: X,
2740
+ ...Y
2741
+ }).strict().refine(...Q), ns = I({
2742
+ drops: Z(Qt).optional(),
2743
+ delays: Z(Kt).optional(),
2744
+ corruptions: Z(es).optional(),
2745
+ closes: Z(rs).optional()
2746
+ }).strict(), as = I({
2747
+ network: Gt.optional(),
2748
+ ui: Yt.optional(),
2749
+ websocket: ns.optional(),
2750
+ seed: W().int("Seed must be an integer").optional()
2702
2751
  }).strict();
2703
- function Rt(s) {
2704
- const e = Nt.safeParse(s);
2752
+ function is(s) {
2753
+ const e = as.safeParse(s);
2705
2754
  if (!e.success) {
2706
2755
  const t = e.error.issues.map(
2707
2756
  (r) => `${r.path.join(".")}: ${r.message}`
2708
2757
  );
2709
- throw new kt(t);
2758
+ throw new Ut(t);
2710
2759
  }
2711
2760
  return e.data;
2712
2761
  }
2713
- class Zt {
2762
+ function os(s) {
2763
+ let e = s | 0;
2764
+ return () => {
2765
+ e = e + 1831565813 | 0;
2766
+ let t = Math.imul(e ^ e >>> 15, 1 | e);
2767
+ return t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t, ((t ^ t >>> 14) >>> 0) / 4294967296;
2768
+ };
2769
+ }
2770
+ function cs() {
2771
+ return Math.random() * 4294967296 >>> 0;
2772
+ }
2773
+ function ds(s) {
2774
+ const e = s ?? cs();
2775
+ return {
2776
+ random: os(e),
2777
+ seed: e
2778
+ };
2779
+ }
2780
+ class us {
2714
2781
  constructor(e = 2e3) {
2715
- E(this, "listeners", /* @__PURE__ */ new Map());
2716
- E(this, "log", []);
2782
+ P(this, "listeners", /* @__PURE__ */ new Map());
2783
+ P(this, "log", []);
2717
2784
  this.maxLogEntries = e;
2718
2785
  }
2719
2786
  on(e, t) {
@@ -2741,13 +2808,20 @@ class Zt {
2741
2808
  }
2742
2809
  }
2743
2810
  }
2744
- function Z(s) {
2745
- return Math.random() < s;
2811
+ function D(s, e = Math.random) {
2812
+ return e() < s;
2746
2813
  }
2747
- function $(s, e) {
2814
+ function V(s, e) {
2815
+ const t = (e.get(s) ?? 0) + 1;
2816
+ return e.set(s, t), t;
2817
+ }
2818
+ function z(s, e) {
2819
+ return s.onNth !== void 0 ? e === s.onNth : s.everyNth !== void 0 ? e % s.everyNth === 0 : s.afterN !== void 0 ? e > s.afterN : !0;
2820
+ }
2821
+ function U(s, e) {
2748
2822
  return e === "*" ? !0 : s.includes(e);
2749
2823
  }
2750
- function qe(s, e) {
2824
+ function lt(s, e) {
2751
2825
  switch (e) {
2752
2826
  case "truncate":
2753
2827
  return s.slice(0, Math.max(0, Math.floor(s.length / 2)));
@@ -2759,44 +2833,44 @@ function qe(s, e) {
2759
2833
  return "<html><body>Unexpected HTML</body></html>";
2760
2834
  }
2761
2835
  }
2762
- function ve(s) {
2836
+ function Pe(s) {
2763
2837
  return typeof Request < "u" && s instanceof Request;
2764
2838
  }
2765
- function $t(s) {
2766
- return ve(s) ? s.url : s.toString();
2839
+ function ls(s) {
2840
+ return Pe(s) ? s.url : s.toString();
2767
2841
  }
2768
- function jt(s, e) {
2769
- return e != null && e.method ? e.method.toUpperCase() : ve(s) ? s.method.toUpperCase() : "GET";
2842
+ function fs(s, e) {
2843
+ return e != null && e.method ? e.method.toUpperCase() : Pe(s) ? s.method.toUpperCase() : "GET";
2770
2844
  }
2771
- function It(s, e) {
2845
+ function hs(s, e) {
2772
2846
  if (e != null && e.signal)
2773
2847
  return e.signal;
2774
- if (ve(s))
2848
+ if (Pe(s))
2775
2849
  return s.signal;
2776
2850
  }
2777
- function Mt() {
2851
+ function ps() {
2778
2852
  if (typeof DOMException < "u")
2779
2853
  return new DOMException("The user aborted a request.", "AbortError");
2780
2854
  const s = new Error("The user aborted a request.");
2781
2855
  return s.name = "AbortError", s;
2782
2856
  }
2783
- function Lt(s, e) {
2857
+ function ms(s, e) {
2784
2858
  if (!e)
2785
2859
  return s;
2786
- const t = new AbortController(), r = (i) => {
2787
- o(), t.signal.aborted || t.abort(i.reason);
2788
- }, n = () => r(s), a = () => r(e), o = () => {
2860
+ const t = new AbortController(), r = (o) => {
2861
+ i(), t.signal.aborted || t.abort(o.reason);
2862
+ }, n = () => r(s), a = () => r(e), i = () => {
2789
2863
  s.removeEventListener("abort", n), e.removeEventListener("abort", a);
2790
2864
  };
2791
2865
  return s.aborted ? (r(s), t.signal) : e.aborted ? (r(e), t.signal) : (s.addEventListener("abort", n, { once: !0 }), e.addEventListener("abort", a, { once: !0 }), t.signal);
2792
2866
  }
2793
- function Pt(s, e) {
2867
+ function ys(s, e) {
2794
2868
  return e ? {
2795
2869
  ...s ?? {},
2796
2870
  signal: e
2797
2871
  } : s;
2798
2872
  }
2799
- function Ie(s, e, t, r, n) {
2873
+ function Qe(s, e, t, r, n) {
2800
2874
  s == null || s.emit({
2801
2875
  type: "network:abort",
2802
2876
  timestamp: Date.now(),
@@ -2804,7 +2878,7 @@ function Ie(s, e, t, r, n) {
2804
2878
  detail: { url: t, method: r, timeoutMs: e.timeout }
2805
2879
  });
2806
2880
  }
2807
- function te(s, e, t, r, n) {
2881
+ function ye(s, e, t, r, n) {
2808
2882
  s == null || s.emit({
2809
2883
  type: "network:corruption",
2810
2884
  timestamp: Date.now(),
@@ -2812,119 +2886,129 @@ function te(s, e, t, r, n) {
2812
2886
  detail: { url: t, method: r, strategy: e.strategy }
2813
2887
  });
2814
2888
  }
2815
- function Dt(s, e, t) {
2816
- return async (r, n) => {
2817
- const a = $t(r), o = jt(r, n), i = It(r, n);
2889
+ function gs(s, e, t, r = Math.random, n = /* @__PURE__ */ new Map()) {
2890
+ return async (a, i) => {
2891
+ const o = ls(a), l = fs(a, i), c = hs(a, i);
2818
2892
  if (e.cors) {
2819
- for (const p of e.cors)
2820
- if ($(a, p.urlPattern) && (!p.methods || p.methods.includes(o))) {
2821
- const A = Z(p.probability);
2893
+ for (const d of e.cors)
2894
+ if (U(o, d.urlPattern) && (!d.methods || d.methods.includes(l))) {
2895
+ const b = V(d, n);
2896
+ if (!z(d, b)) continue;
2897
+ const w = D(d.probability, r);
2822
2898
  if (t == null || t.emit({
2823
2899
  type: "network:cors",
2824
2900
  timestamp: Date.now(),
2825
- applied: A,
2826
- detail: { url: a, method: o }
2827
- }), A) {
2828
- console.debug(`[chaos-maker] CORS block: ${o} ${a}`);
2829
- const M = new TypeError("Failed to fetch");
2830
- throw M.stack = "", M;
2901
+ applied: w,
2902
+ detail: { url: o, method: l }
2903
+ }), w) {
2904
+ console.debug(`[chaos-maker] CORS block: ${l} ${o}`);
2905
+ const S = new TypeError("Failed to fetch");
2906
+ throw S.stack = "", S;
2831
2907
  }
2832
2908
  }
2833
2909
  }
2834
- let d = null, l, m, w = !1;
2835
- const x = (p) => {
2836
- !d || w || (w = !0, m && (clearTimeout(m), m = void 0), Ie(t, d, a, o, p));
2910
+ let g = null, O, N, M = !1;
2911
+ const R = (d) => {
2912
+ !g || M || (M = !0, N && (clearTimeout(N), N = void 0), Qe(t, g, o, l, d));
2837
2913
  };
2838
2914
  if (e.aborts) {
2839
- for (const p of e.aborts)
2840
- if ($(a, p.urlPattern) && (!p.methods || p.methods.includes(o))) {
2841
- if (!Z(p.probability)) {
2842
- Ie(t, p, a, o, !1);
2915
+ for (const d of e.aborts)
2916
+ if (U(o, d.urlPattern) && (!d.methods || d.methods.includes(l))) {
2917
+ const b = V(d, n);
2918
+ if (!z(d, b)) continue;
2919
+ if (!D(d.probability, r)) {
2920
+ Qe(t, d, o, l, !1);
2843
2921
  continue;
2844
2922
  }
2845
- console.warn(`CHAOS: Aborting ${o} ${a} after ${p.timeout || 0}ms`), d = p;
2846
- const M = new AbortController();
2847
- l = Lt(M.signal, i);
2848
- const ee = () => {
2849
- w || (x(!0), M.abort(Mt()));
2923
+ console.warn(`CHAOS: Aborting ${l} ${o} after ${d.timeout || 0}ms`), g = d;
2924
+ const S = new AbortController();
2925
+ O = ms(S.signal, c);
2926
+ const T = () => {
2927
+ M || (R(!0), S.abort(ps()));
2850
2928
  };
2851
- p.timeout ? m = setTimeout(ee, p.timeout) : ee();
2929
+ d.timeout ? N = setTimeout(T, d.timeout) : T();
2852
2930
  break;
2853
2931
  }
2854
2932
  }
2855
- if (d)
2933
+ if (g)
2856
2934
  try {
2857
- const p = await s(r, Pt(n, l));
2858
- return x(!1), p;
2859
- } catch (p) {
2860
- throw x(!1), p;
2935
+ const d = await s(a, ys(i, O));
2936
+ return R(!1), d;
2937
+ } catch (d) {
2938
+ throw R(!1), d;
2861
2939
  }
2862
2940
  if (e.failures) {
2863
- for (const p of e.failures)
2864
- if ($(a, p.urlPattern) && (!p.methods || p.methods.includes(o))) {
2865
- const A = Z(p.probability);
2941
+ for (const d of e.failures)
2942
+ if (U(o, d.urlPattern) && (!d.methods || d.methods.includes(l))) {
2943
+ const b = V(d, n);
2944
+ if (!z(d, b)) continue;
2945
+ const w = D(d.probability, r);
2866
2946
  if (t == null || t.emit({
2867
2947
  type: "network:failure",
2868
2948
  timestamp: Date.now(),
2869
- applied: A,
2870
- detail: { url: a, method: o, statusCode: p.statusCode }
2871
- }), A) {
2872
- console.warn(`CHAOS: Forcing ${p.statusCode} for ${o} ${a}`);
2873
- const M = p.body ?? JSON.stringify({ error: "Chaos Maker Attack!" }), ee = p.headers ?? {};
2874
- return new Response(M, {
2875
- status: p.statusCode,
2876
- statusText: p.statusText ?? "Service Unavailable (Chaos)",
2877
- headers: ee
2949
+ applied: w,
2950
+ detail: { url: o, method: l, statusCode: d.statusCode }
2951
+ }), w) {
2952
+ console.warn(`CHAOS: Forcing ${d.statusCode} for ${l} ${o}`);
2953
+ const S = d.body ?? JSON.stringify({ error: "Chaos Maker Attack!" }), T = d.headers ?? {};
2954
+ return new Response(S, {
2955
+ status: d.statusCode,
2956
+ statusText: d.statusText ?? "Service Unavailable (Chaos)",
2957
+ headers: T
2878
2958
  });
2879
2959
  }
2880
2960
  }
2881
2961
  }
2882
2962
  if (e.latencies) {
2883
- for (const p of e.latencies)
2884
- if ($(a, p.urlPattern) && (!p.methods || p.methods.includes(o))) {
2885
- const A = Z(p.probability);
2963
+ for (const d of e.latencies)
2964
+ if (U(o, d.urlPattern) && (!d.methods || d.methods.includes(l))) {
2965
+ const b = V(d, n);
2966
+ if (!z(d, b)) continue;
2967
+ const w = D(d.probability, r);
2886
2968
  t == null || t.emit({
2887
2969
  type: "network:latency",
2888
2970
  timestamp: Date.now(),
2889
- applied: A,
2890
- detail: { url: a, method: o, delayMs: p.delayMs }
2891
- }), A && (console.warn(`CHAOS: Adding ${p.delayMs}ms latency to ${o} ${a}`), await new Promise((M) => setTimeout(M, p.delayMs)));
2971
+ applied: w,
2972
+ detail: { url: o, method: l, delayMs: d.delayMs }
2973
+ }), w && (console.warn(`CHAOS: Adding ${d.delayMs}ms latency to ${l} ${o}`), await new Promise((S) => setTimeout(S, d.delayMs)));
2892
2974
  }
2893
2975
  }
2894
- let T = null;
2976
+ let m = null;
2895
2977
  if (e.corruptions) {
2896
- for (const p of e.corruptions)
2897
- if ($(a, p.urlPattern) && (!p.methods || p.methods.includes(o))) {
2898
- if (!Z(p.probability)) {
2899
- te(t, p, a, o, !1);
2978
+ for (const d of e.corruptions)
2979
+ if (U(o, d.urlPattern) && (!d.methods || d.methods.includes(l))) {
2980
+ const b = V(d, n);
2981
+ if (!z(d, b)) continue;
2982
+ if (!D(d.probability, r)) {
2983
+ ye(t, d, o, l, !1);
2900
2984
  continue;
2901
2985
  }
2902
- T = p;
2986
+ m = d;
2903
2987
  break;
2904
2988
  }
2905
2989
  }
2906
- let C;
2990
+ let p;
2907
2991
  try {
2908
- C = await s(r, n);
2909
- } catch (p) {
2910
- throw T && te(t, T, a, o, !1), p;
2992
+ p = await s(a, i);
2993
+ } catch (d) {
2994
+ throw m && ye(t, m, o, l, !1), d;
2911
2995
  }
2912
- if (!T)
2913
- return C;
2996
+ if (!m)
2997
+ return p;
2914
2998
  try {
2915
- console.warn(`CHAOS: Corrupting response for ${o} ${a} with strategy: ${T.strategy}`);
2916
- const p = await C.text(), A = qe(p, T.strategy);
2917
- return te(t, T, a, o, !0), new Response(A, {
2918
- status: C.status,
2919
- statusText: C.statusText,
2920
- headers: C.headers
2999
+ console.warn(`CHAOS: Corrupting response for ${l} ${o} with strategy: ${m.strategy}`);
3000
+ const d = await p.text(), b = lt(d, m.strategy);
3001
+ return ye(t, m, o, l, !0), new Response(b, {
3002
+ status: p.status,
3003
+ statusText: p.statusText,
3004
+ headers: p.headers
2921
3005
  });
2922
- } catch (p) {
2923
- throw te(t, T, a, o, !1), p;
3006
+ } catch (d) {
3007
+ throw ye(t, m, o, l, !1), d;
2924
3008
  }
2925
3009
  };
2926
3010
  }
2927
- function Me(s, e, t, r, n) {
3011
+ function Ke(s, e, t, r, n) {
2928
3012
  s == null || s.emit({
2929
3013
  type: "network:abort",
2930
3014
  timestamp: Date.now(),
@@ -2932,7 +3016,7 @@ function Me(s, e, t, r, n) {
2932
3016
  detail: { url: t, method: r, timeoutMs: e.timeout }
2933
3017
  });
2934
3018
  }
2935
- function Le(s, e, t, r, n) {
3019
+ function et(s, e, t, r, n) {
2936
3020
  s == null || s.emit({
2937
3021
  type: "network:corruption",
2938
3022
  timestamp: Date.now(),
@@ -2940,80 +3024,86 @@ function Le(s, e, t, r, n) {
2940
3024
  detail: { url: t, method: r, strategy: e.strategy }
2941
3025
  });
2942
3026
  }
2943
- function Vt(s, e, t) {
2944
- return function(r) {
2945
- const n = this._chaos_url, a = this._chaos_method;
3027
+ function vs(s, e, t, r = Math.random, n = /* @__PURE__ */ new Map()) {
3028
+ return function(a) {
3029
+ const i = this._chaos_url, o = this._chaos_method;
2946
3030
  if (e.cors) {
2947
- for (const i of e.cors)
2948
- if ($(n, i.urlPattern) && (!i.methods || i.methods.includes(a))) {
2949
- const d = Z(i.probability);
3031
+ for (const c of e.cors)
3032
+ if (U(i, c.urlPattern) && (!c.methods || c.methods.includes(o))) {
3033
+ const g = V(c, n);
3034
+ if (!z(c, g)) continue;
3035
+ const O = D(c.probability, r);
2950
3036
  if (t == null || t.emit({
2951
3037
  type: "network:cors",
2952
3038
  timestamp: Date.now(),
2953
- applied: d,
2954
- detail: { url: n, method: a }
2955
- }), d) {
2956
- console.debug(`[chaos-maker] CORS block: ${a} ${n}`), Object.defineProperty(this, "status", { value: 0 }), Object.defineProperty(this, "statusText", { value: "" }), this.dispatchEvent(new Event("error")), this.dispatchEvent(new Event("loadend"));
3039
+ applied: O,
3040
+ detail: { url: i, method: o }
3041
+ }), O) {
3042
+ console.debug(`[chaos-maker] CORS block: ${o} ${i}`), Object.defineProperty(this, "status", { value: 0 }), Object.defineProperty(this, "statusText", { value: "" }), this.dispatchEvent(new Event("error")), this.dispatchEvent(new Event("loadend"));
2957
3043
  return;
2958
3044
  }
2959
3045
  }
2960
3046
  }
2961
3047
  if (e.aborts) {
2962
- for (const i of e.aborts)
2963
- if ($(n, i.urlPattern) && (!i.methods || i.methods.includes(a))) {
2964
- if (!Z(i.probability)) {
2965
- Me(t, i, n, a, !1);
3048
+ for (const c of e.aborts)
3049
+ if (U(i, c.urlPattern) && (!c.methods || c.methods.includes(o))) {
3050
+ const g = V(c, n);
3051
+ if (!z(c, g)) continue;
3052
+ if (!D(c.probability, r)) {
3053
+ Ke(t, c, i, o, !1);
2966
3054
  continue;
2967
3055
  }
2968
- console.warn(`CHAOS: Aborting ${a} ${n} after ${i.timeout || 0}ms`);
2969
- let l = !1, m;
2970
- const w = () => {
2971
- m && (clearTimeout(m), m = void 0), typeof this.removeEventListener == "function" && this.removeEventListener("loadend", T);
2972
- }, x = (p) => {
2973
- l || (l = !0, w(), Me(t, i, n, a, p));
2974
- }, T = () => {
2975
- x(!1);
2976
- }, C = () => {
2977
- l || (x(!0), this.abort());
3056
+ console.warn(`CHAOS: Aborting ${o} ${i} after ${c.timeout || 0}ms`);
3057
+ let N = !1, M;
3058
+ const R = () => {
3059
+ M && (clearTimeout(M), M = void 0), typeof this.removeEventListener == "function" && this.removeEventListener("loadend", p);
3060
+ }, m = (b) => {
3061
+ N || (N = !0, R(), Ke(t, c, i, o, b));
3062
+ }, p = () => {
3063
+ m(!1);
3064
+ }, d = () => {
3065
+ N || (m(!0), this.abort());
2978
3066
  };
2979
- typeof this.addEventListener == "function" && this.addEventListener("loadend", T);
3067
+ typeof this.addEventListener == "function" && this.addEventListener("loadend", p);
2980
3068
  try {
2981
- s.call(this, r);
2982
- } catch (p) {
2983
- throw x(!1), p;
3069
+ s.call(this, a);
3070
+ } catch (b) {
3071
+ throw m(!1), b;
2984
3072
  }
2985
- if (l)
3073
+ if (N)
2986
3074
  return;
2987
- i.timeout ? m = setTimeout(C, i.timeout) : C();
3075
+ c.timeout ? M = setTimeout(d, c.timeout) : d();
2988
3076
  return;
2989
3077
  }
2990
3078
  }
2991
3079
  if (e.failures) {
2992
- for (const i of e.failures)
2993
- if ($(n, i.urlPattern) && (!i.methods || i.methods.includes(a))) {
2994
- const d = Z(i.probability);
3080
+ for (const c of e.failures)
3081
+ if (U(i, c.urlPattern) && (!c.methods || c.methods.includes(o))) {
3082
+ const g = V(c, n);
3083
+ if (!z(c, g)) continue;
3084
+ const O = D(c.probability, r);
2995
3085
  if (t == null || t.emit({
2996
3086
  type: "network:failure",
2997
3087
  timestamp: Date.now(),
2998
- applied: d,
2999
- detail: { url: n, method: a, statusCode: i.statusCode }
3000
- }), d) {
3001
- console.warn(`CHAOS: Forcing ${i.statusCode} for ${a} ${n}`), Object.defineProperty(this, "status", { value: i.statusCode }), Object.defineProperty(this, "statusText", {
3002
- value: i.statusText ?? "Service Unavailable (Chaos)"
3088
+ applied: O,
3089
+ detail: { url: i, method: o, statusCode: c.statusCode }
3090
+ }), O) {
3091
+ console.warn(`CHAOS: Forcing ${c.statusCode} for ${o} ${i}`), Object.defineProperty(this, "status", { value: c.statusCode }), Object.defineProperty(this, "statusText", {
3092
+ value: c.statusText ?? "Service Unavailable (Chaos)"
3003
3093
  });
3004
- const l = i.body ?? JSON.stringify({ error: "Chaos Maker Attack!" });
3005
- Object.defineProperty(this, "responseText", { value: l, configurable: !0 });
3006
- const m = i.headers ?? {};
3094
+ const N = c.body ?? JSON.stringify({ error: "Chaos Maker Attack!" });
3095
+ Object.defineProperty(this, "responseText", { value: N, configurable: !0 });
3096
+ const M = c.headers ?? {};
3007
3097
  Object.defineProperty(this, "getResponseHeader", {
3008
- value: (w) => {
3009
- const x = Object.keys(m).find(
3010
- (T) => T.toLowerCase() === w.toLowerCase()
3098
+ value: (R) => {
3099
+ const m = Object.keys(M).find(
3100
+ (p) => p.toLowerCase() === R.toLowerCase()
3011
3101
  );
3012
- return x ? m[x] : null;
3102
+ return m ? M[m] : null;
3013
3103
  },
3014
3104
  configurable: !0
3015
3105
  }), Object.defineProperty(this, "getAllResponseHeaders", {
3016
- value: () => Object.entries(m).map(([w, x]) => `${w}: ${x}`).join(`\r
3106
+ value: () => Object.entries(M).map(([R, m]) => `${R}: ${m}`).join(`\r
3017
3107
  `),
3018
3108
  configurable: !0
3019
3109
  }), this.dispatchEvent(new Event("error")), this.dispatchEvent(new Event("load")), this.dispatchEvent(new Event("loadend"));
@@ -3021,83 +3111,87 @@ function Vt(s, e, t) {
3021
3111
  }
3022
3112
  }
3023
3113
  }
3024
- let o = null;
3114
+ let l = null;
3025
3115
  if (e.corruptions) {
3026
- for (const i of e.corruptions)
3027
- if ($(n, i.urlPattern) && (!i.methods || i.methods.includes(a))) {
3028
- if (!Z(i.probability)) {
3029
- Le(t, i, n, a, !1);
3116
+ for (const c of e.corruptions)
3117
+ if (U(i, c.urlPattern) && (!c.methods || c.methods.includes(o))) {
3118
+ const g = V(c, n);
3119
+ if (!z(c, g)) continue;
3120
+ if (!D(c.probability, r)) {
3121
+ et(t, c, i, o, !1);
3030
3122
  continue;
3031
3123
  }
3032
- o = i;
3124
+ l = c;
3033
3125
  break;
3034
3126
  }
3035
3127
  }
3036
- if (o) {
3037
- let i = !1, d = null;
3038
- const l = () => {
3039
- typeof this.removeEventListener == "function" && (this.removeEventListener("error", x), this.removeEventListener("abort", x), this.removeEventListener("loadend", T));
3040
- }, m = (C) => {
3041
- i || (i = !0, Le(t, o, n, a, C), l());
3042
- }, w = () => {
3043
- if (d !== null)
3044
- return d;
3128
+ if (l) {
3129
+ let c = !1, g = null;
3130
+ const O = () => {
3131
+ typeof this.removeEventListener == "function" && (this.removeEventListener("error", R), this.removeEventListener("abort", R), this.removeEventListener("loadend", m));
3132
+ }, N = (p) => {
3133
+ c || (c = !0, et(t, l, i, o, p), O());
3134
+ }, M = () => {
3135
+ if (g !== null)
3136
+ return g;
3045
3137
  delete this.responseText;
3046
3138
  try {
3047
- const C = this.responseText;
3048
- return typeof C != "string" ? (Object.defineProperty(this, "responseText", { value: C, configurable: !0 }), m(!1), C) : (d = qe(C, o.strategy), Object.defineProperty(this, "responseText", { value: d, configurable: !0 }), m(!0), d);
3049
- } catch (C) {
3050
- throw m(!1), C;
3139
+ const p = this.responseText;
3140
+ return typeof p != "string" ? (Object.defineProperty(this, "responseText", { value: p, configurable: !0 }), N(!1), p) : (g = lt(p, l.strategy), Object.defineProperty(this, "responseText", { value: g, configurable: !0 }), N(!0), g);
3141
+ } catch (p) {
3142
+ throw N(!1), p;
3051
3143
  }
3052
- }, x = () => {
3053
- m(!1);
3054
- }, T = () => {
3055
- if (!i)
3144
+ }, R = () => {
3145
+ N(!1);
3146
+ }, m = () => {
3147
+ if (!c)
3056
3148
  try {
3057
- w();
3149
+ M();
3058
3150
  } catch {
3059
3151
  }
3060
3152
  };
3061
- typeof this.addEventListener == "function" && (this.addEventListener("error", x), this.addEventListener("abort", x), this.addEventListener("loadend", T)), Object.defineProperty(this, "responseText", {
3153
+ typeof this.addEventListener == "function" && (this.addEventListener("error", R), this.addEventListener("abort", R), this.addEventListener("loadend", m)), Object.defineProperty(this, "responseText", {
3062
3154
  get() {
3063
- return w();
3155
+ return M();
3064
3156
  },
3065
3157
  configurable: !0
3066
3158
  });
3067
3159
  }
3068
3160
  if (e.latencies) {
3069
- for (const i of e.latencies)
3070
- if ($(n, i.urlPattern) && (!i.methods || i.methods.includes(a))) {
3071
- const d = Z(i.probability);
3161
+ for (const c of e.latencies)
3162
+ if (U(i, c.urlPattern) && (!c.methods || c.methods.includes(o))) {
3163
+ const g = V(c, n);
3164
+ if (!z(c, g)) continue;
3165
+ const O = D(c.probability, r);
3072
3166
  if (t == null || t.emit({
3073
3167
  type: "network:latency",
3074
3168
  timestamp: Date.now(),
3075
- applied: d,
3076
- detail: { url: n, method: a, delayMs: i.delayMs }
3077
- }), d) {
3078
- console.warn(`CHAOS: Adding ${i.delayMs}ms latency to ${a} ${n}`), setTimeout(() => {
3079
- s.call(this, r);
3080
- }, i.delayMs);
3169
+ applied: O,
3170
+ detail: { url: i, method: o, delayMs: c.delayMs }
3171
+ }), O) {
3172
+ console.warn(`CHAOS: Adding ${c.delayMs}ms latency to ${o} ${i}`), setTimeout(() => {
3173
+ s.call(this, a);
3174
+ }, c.delayMs);
3081
3175
  return;
3082
3176
  }
3083
3177
  }
3084
3178
  }
3085
- s.call(this, r);
3179
+ s.call(this, a);
3086
3180
  };
3087
3181
  }
3088
- function zt(s) {
3182
+ function _s(s) {
3089
3183
  return function(e, t) {
3090
3184
  this._chaos_url = t.toString(), this._chaos_method = e.toUpperCase(), s.call(this, e, t);
3091
3185
  };
3092
3186
  }
3093
- function ye(s, e, t) {
3094
- const r = Z(e.probability);
3187
+ function Re(s, e, t, r = Math.random) {
3188
+ const n = D(e.probability, r);
3095
3189
  if (t == null || t.emit({
3096
3190
  type: "ui:assault",
3097
3191
  timestamp: Date.now(),
3098
- applied: r,
3192
+ applied: n,
3099
3193
  detail: { selector: e.selector, action: e.action }
3100
- }), !!r) {
3194
+ }), !!n) {
3101
3195
  console.warn(`CHAOS: Applying action '${e.action}' to element:`, s);
3102
3196
  try {
3103
3197
  switch (e.action) {
@@ -3111,53 +3205,288 @@ function ye(s, e, t) {
3111
3205
  s.remove();
3112
3206
  break;
3113
3207
  }
3114
- } catch (n) {
3115
- console.error("Chaos Maker failed to assault element:", n, s);
3208
+ } catch (a) {
3209
+ console.error("Chaos Maker failed to assault element:", a, s);
3116
3210
  }
3117
3211
  }
3118
3212
  }
3119
- function Ut(s, e, t) {
3213
+ function bs(s, e, t, r = Math.random) {
3120
3214
  if (s.nodeType !== Node.ELEMENT_NODE || !e.assaults)
3121
3215
  return;
3122
- const r = s;
3123
- for (const n of e.assaults) {
3216
+ const n = s;
3217
+ for (const a of e.assaults) {
3124
3218
  try {
3125
- r.matches(n.selector) && ye(r, n, t);
3126
- } catch (a) {
3127
- console.error(`Chaos Maker: Invalid selector '${n.selector}'`, a);
3219
+ n.matches(a.selector) && Re(n, a, t, r);
3220
+ } catch (i) {
3221
+ console.error(`Chaos Maker: Invalid selector '${a.selector}'`, i);
3128
3222
  }
3129
- r.querySelectorAll(n.selector).forEach((a) => {
3130
- ye(a, n, t);
3223
+ n.querySelectorAll(a.selector).forEach((i) => {
3224
+ Re(i, a, t, r);
3131
3225
  });
3132
3226
  }
3133
3227
  }
3134
- function Ft(s, e) {
3228
+ function ks(s, e, t = Math.random) {
3135
3229
  if (s.assaults) {
3136
3230
  console.log("CHAOS: Running initial DOM scan for existing elements...");
3137
- for (const r of s.assaults)
3231
+ for (const n of s.assaults)
3138
3232
  try {
3139
- document.querySelectorAll(r.selector).forEach((n) => {
3140
- ye(n, r, e);
3233
+ document.querySelectorAll(n.selector).forEach((a) => {
3234
+ Re(a, n, e, t);
3141
3235
  });
3142
- } catch (n) {
3143
- console.error(`Chaos Maker: Invalid selector in initial scan '${r.selector}'`, n);
3236
+ } catch (a) {
3237
+ console.error(`Chaos Maker: Invalid selector in initial scan '${n.selector}'`, a);
3144
3238
  }
3145
3239
  }
3146
- return new MutationObserver((r) => {
3147
- for (const n of r)
3148
- n.type === "childList" && n.addedNodes.forEach((a) => Ut(a, s, e));
3240
+ return new MutationObserver((n) => {
3241
+ for (const a of n)
3242
+ a.type === "childList" && a.addedNodes.forEach((i) => bs(i, s, e, t));
3149
3243
  });
3150
3244
  }
3151
- class Pe {
3245
+ const tt = /* @__PURE__ */ Symbol.for("chaos-maker.websocket.intercepted");
3246
+ function ws(s, e) {
3247
+ return s === "both" ? !0 : s === e;
3248
+ }
3249
+ function st(s) {
3250
+ return typeof s == "string" ? "text" : "binary";
3251
+ }
3252
+ function rt(s, e) {
3253
+ switch (e) {
3254
+ case "truncate":
3255
+ return s.slice(0, Math.max(0, Math.floor(s.length / 2)));
3256
+ case "malformed-json":
3257
+ return `${s}"}`;
3258
+ case "empty":
3259
+ return "";
3260
+ case "wrong-type":
3261
+ return "<html><body>Unexpected HTML</body></html>";
3262
+ }
3263
+ }
3264
+ function nt(s, e) {
3265
+ if (e === "malformed-json" || e === "wrong-type") return null;
3266
+ if (e === "empty")
3267
+ return typeof Blob < "u" && s instanceof Blob ? new Blob([]) : s instanceof ArrayBuffer ? new ArrayBuffer(0) : new Uint8Array(0);
3268
+ if (typeof Blob < "u" && s instanceof Blob)
3269
+ return s.slice(0, Math.max(0, Math.floor(s.size / 2)));
3270
+ if (s instanceof ArrayBuffer)
3271
+ return s.slice(0, Math.max(0, Math.floor(s.byteLength / 2)));
3272
+ const t = s, r = Math.max(0, Math.floor(t.byteLength / 2));
3273
+ return new Uint8Array(t.buffer.slice(t.byteOffset, t.byteOffset + r));
3274
+ }
3275
+ function ne(s, e, t, r, n) {
3276
+ if (!s) return null;
3277
+ for (const a of s) {
3278
+ if (!U(e, a.urlPattern) || !ws(a.direction, t)) continue;
3279
+ const i = V(a, n);
3280
+ if (z(a, i) && D(a.probability, r))
3281
+ return a;
3282
+ }
3283
+ return null;
3284
+ }
3285
+ function ge(s, e, t, r, n) {
3286
+ s.emit({
3287
+ type: "websocket:drop",
3288
+ timestamp: Date.now(),
3289
+ applied: !0,
3290
+ detail: { url: e, direction: t, payloadType: r, ...n ? { reason: n } : {} }
3291
+ });
3292
+ }
3293
+ function at(s, e, t, r, n) {
3294
+ s.emit({
3295
+ type: "websocket:delay",
3296
+ timestamp: Date.now(),
3297
+ applied: !0,
3298
+ detail: { url: e, direction: t, payloadType: r, delayMs: n }
3299
+ });
3300
+ }
3301
+ function ae(s, e, t, r, n, a, i) {
3302
+ s.emit({
3303
+ type: "websocket:corrupt",
3304
+ timestamp: Date.now(),
3305
+ applied: a,
3306
+ detail: { url: e, direction: t, payloadType: r, strategy: n, ...i ? { reason: i } : {} }
3307
+ });
3308
+ }
3309
+ function xs(s, e, t, r) {
3310
+ s.emit({
3311
+ type: "websocket:close",
3312
+ timestamp: Date.now(),
3313
+ applied: !0,
3314
+ detail: { url: e, closeCode: t, closeReason: r }
3315
+ });
3316
+ }
3317
+ function Cs(s, e, t, r, n) {
3318
+ const a = /* @__PURE__ */ new Map();
3319
+ let i = !0;
3320
+ const o = (m, p) => {
3321
+ let d = a.get(m);
3322
+ d || (d = /* @__PURE__ */ new Set(), a.set(m, d)), d.add(p);
3323
+ }, l = (m, p) => {
3324
+ var d;
3325
+ (d = a.get(m)) == null || d.delete(p);
3326
+ }, c = (m, p) => {
3327
+ const d = a.get(m);
3328
+ if (d) {
3329
+ for (const b of d)
3330
+ clearTimeout(b.handle), b.kind === "delay" && ge(t, b.url, b.direction, b.payloadType, p);
3331
+ a.delete(m);
3332
+ }
3333
+ }, g = (m, p, d) => {
3334
+ const b = new MessageEvent("message", {
3335
+ data: d,
3336
+ origin: p.origin,
3337
+ lastEventId: p.lastEventId,
3338
+ source: p.source,
3339
+ ports: Array.from(p.ports ?? [])
3340
+ });
3341
+ b[tt] = !0, m.dispatchEvent(b);
3342
+ }, O = (m, p, d, b) => {
3343
+ if (!i) return { handled: !1, data: d };
3344
+ const w = "outbound", S = st(d);
3345
+ if (ne(e.drops, p, w, r, n))
3346
+ return ge(t, p, w, S), { handled: !0, data: d };
3347
+ let T = d;
3348
+ const j = ne(e.corruptions, p, w, r, n);
3349
+ if (j)
3350
+ if (S === "text")
3351
+ T = rt(T, j.strategy), ae(t, p, w, S, j.strategy, !0);
3352
+ else {
3353
+ const F = nt(T, j.strategy);
3354
+ F === null ? ae(t, p, w, S, j.strategy, !1, "incompatible-payload-type") : (T = F, ae(t, p, w, S, j.strategy, !0));
3355
+ }
3356
+ const L = ne(e.delays, p, w, r, n);
3357
+ if (L) {
3358
+ at(t, p, w, S, L.delayMs);
3359
+ const F = {
3360
+ kind: "delay",
3361
+ handle: setTimeout(() => {
3362
+ l(m, F);
3363
+ try {
3364
+ b(T);
3365
+ } catch {
3366
+ }
3367
+ }, L.delayMs),
3368
+ url: p,
3369
+ direction: w,
3370
+ payloadType: S
3371
+ };
3372
+ return o(m, F), { handled: !0, data: T };
3373
+ }
3374
+ return { handled: !1, data: T };
3375
+ }, N = (m, p) => {
3376
+ m.addEventListener("message", (d) => {
3377
+ const b = d;
3378
+ if (b[tt] || !i) return;
3379
+ const w = "inbound", S = st(b.data);
3380
+ if (ne(e.drops, p, w, r, n)) {
3381
+ b.stopImmediatePropagation(), ge(t, p, w, S);
3382
+ return;
3383
+ }
3384
+ let T = b.data, j = !1;
3385
+ const L = ne(e.corruptions, p, w, r, n);
3386
+ if (L)
3387
+ if (S === "text")
3388
+ T = rt(T, L.strategy), j = !0, ae(t, p, w, S, L.strategy, !0);
3389
+ else {
3390
+ const fe = nt(T, L.strategy);
3391
+ fe === null ? ae(t, p, w, S, L.strategy, !1, "incompatible-payload-type") : (T = fe, j = !0, ae(t, p, w, S, L.strategy, !0));
3392
+ }
3393
+ const F = ne(e.delays, p, w, r, n);
3394
+ if (F) {
3395
+ b.stopImmediatePropagation(), at(t, p, w, S, F.delayMs);
3396
+ const fe = {
3397
+ kind: "delay",
3398
+ handle: setTimeout(() => {
3399
+ l(m, fe), g(m, b, T);
3400
+ }, F.delayMs),
3401
+ url: p,
3402
+ direction: w,
3403
+ payloadType: S
3404
+ };
3405
+ o(m, fe);
3406
+ return;
3407
+ }
3408
+ j && (b.stopImmediatePropagation(), g(m, b, T));
3409
+ });
3410
+ }, M = (m, p) => {
3411
+ if (e.closes)
3412
+ for (const d of e.closes) {
3413
+ if (!U(p, d.urlPattern)) continue;
3414
+ const b = V(d, n);
3415
+ if (!z(d, b) || !D(d.probability, r)) continue;
3416
+ const w = d.code ?? 1e3, S = d.reason ?? "Chaos Maker close", T = d.afterMs ?? 0, j = () => {
3417
+ if (i) {
3418
+ c(m, "close-interrupt"), xs(t, p, w, S);
3419
+ try {
3420
+ m.close(w, S);
3421
+ } catch {
3422
+ try {
3423
+ m.close();
3424
+ } catch {
3425
+ }
3426
+ }
3427
+ }
3428
+ };
3429
+ if (T <= 0)
3430
+ m.readyState === m.OPEN ? j() : m.addEventListener("open", j, { once: !0 });
3431
+ else {
3432
+ const L = () => {
3433
+ const F = {
3434
+ kind: "close",
3435
+ handle: setTimeout(j, T)
3436
+ };
3437
+ o(m, F);
3438
+ };
3439
+ m.readyState === m.OPEN ? L() : m.addEventListener("open", L, { once: !0 });
3440
+ }
3441
+ return;
3442
+ }
3443
+ };
3444
+ function R(m, p) {
3445
+ const d = new s(m, p), b = typeof m == "string" ? m : m.toString(), w = d.send.bind(d);
3446
+ return d.send = function(T) {
3447
+ const j = O(d, b, T, w);
3448
+ j.handled || w(j.data);
3449
+ }, N(d, b), M(d, b), d;
3450
+ }
3451
+ Object.defineProperty(R, "prototype", {
3452
+ value: s.prototype,
3453
+ writable: !1
3454
+ });
3455
+ for (const m of ["CONNECTING", "OPEN", "CLOSING", "CLOSED"])
3456
+ R[m] = s[m];
3457
+ return {
3458
+ Wrapped: R,
3459
+ uninstall() {
3460
+ i = !1;
3461
+ for (const [, m] of a)
3462
+ for (const p of m)
3463
+ clearTimeout(p.handle), p.kind === "delay" && ge(t, p.url, p.direction, p.payloadType, "stop-during-delay");
3464
+ a.clear();
3465
+ }
3466
+ };
3467
+ }
3468
+ class it {
3152
3469
  constructor(e) {
3153
- E(this, "config");
3154
- E(this, "emitter");
3155
- E(this, "running", !1);
3156
- E(this, "originalFetch");
3157
- E(this, "originalXhrSend");
3158
- E(this, "originalXhrOpen");
3159
- E(this, "domObserver");
3160
- this.config = Rt(e), this.emitter = new Zt(), console.log("Chaos Maker initialized with config:", e);
3470
+ P(this, "config");
3471
+ P(this, "emitter");
3472
+ P(this, "random");
3473
+ P(this, "seed");
3474
+ P(this, "running", !1);
3475
+ P(this, "originalFetch");
3476
+ P(this, "originalXhrSend");
3477
+ P(this, "originalXhrOpen");
3478
+ P(this, "domObserver");
3479
+ P(this, "originalWebSocket");
3480
+ P(this, "webSocketHandle");
3481
+ /** Shared counters keyed by config rule object reference. Shared across fetch + XHR + WS. */
3482
+ P(this, "requestCounters", /* @__PURE__ */ new Map());
3483
+ this.config = is(e), this.emitter = new us();
3484
+ const t = ds(e.seed);
3485
+ this.random = t.random, this.seed = t.seed, console.log(`Chaos Maker initialized (seed: ${this.seed})`);
3486
+ }
3487
+ /** Get the seed used by this instance. Log this on failure to reproduce exact chaos decisions. */
3488
+ getSeed() {
3489
+ return this.seed;
3161
3490
  }
3162
3491
  on(e, t) {
3163
3492
  this.emitter.on(e, t);
@@ -3176,55 +3505,133 @@ class Pe {
3176
3505
  console.warn("Chaos Maker is already running. Call stop() first.");
3177
3506
  return;
3178
3507
  }
3179
- this.running = !0, console.log("🛠️ Chaos Maker ENGAGED 🛠️"), this.config.network && (this.originalFetch = window.fetch, window.fetch = Dt(this.originalFetch.bind(window), this.config.network, this.emitter), this.originalXhrOpen = window.XMLHttpRequest.prototype.open, window.XMLHttpRequest.prototype.open = zt(this.originalXhrOpen), this.originalXhrSend = window.XMLHttpRequest.prototype.send, window.XMLHttpRequest.prototype.send = Vt(this.originalXhrSend, this.config.network, this.emitter)), this.config.ui && (this.domObserver = Ft(this.config.ui, this.emitter), this.domObserver.observe(document.body, {
3508
+ this.requestCounters.clear(), this.running = !0, console.log("🛠️ Chaos Maker ENGAGED 🛠️"), this.config.network && (this.originalFetch = window.fetch, window.fetch = gs(this.originalFetch.bind(window), this.config.network, this.emitter, this.random, this.requestCounters), this.originalXhrOpen = window.XMLHttpRequest.prototype.open, window.XMLHttpRequest.prototype.open = _s(this.originalXhrOpen), this.originalXhrSend = window.XMLHttpRequest.prototype.send, window.XMLHttpRequest.prototype.send = vs(this.originalXhrSend, this.config.network, this.emitter, this.random, this.requestCounters)), this.config.ui && (this.domObserver = ks(this.config.ui, this.emitter, this.random), this.domObserver.observe(document.body, {
3180
3509
  childList: !0,
3181
3510
  subtree: !0
3182
- }), console.log("UI Assailant is now observing the DOM."));
3511
+ }), console.log("UI Assailant is now observing the DOM.")), this.config.websocket && typeof window < "u" && typeof window.WebSocket < "u" && (this.originalWebSocket = window.WebSocket, this.webSocketHandle = Cs(
3512
+ this.originalWebSocket,
3513
+ this.config.websocket,
3514
+ this.emitter,
3515
+ this.random,
3516
+ this.requestCounters
3517
+ ), window.WebSocket = this.webSocketHandle.Wrapped);
3183
3518
  }
3184
3519
  stop() {
3185
- this.running = !1, console.log("🛑 Chaos Maker DISENGAGED 🛑"), this.originalFetch && (window.fetch = this.originalFetch), this.originalXhrSend && (window.XMLHttpRequest.prototype.send = this.originalXhrSend), this.originalXhrOpen && (window.XMLHttpRequest.prototype.open = this.originalXhrOpen), this.domObserver && (this.domObserver.disconnect(), console.log("UI Assailant has stopped observing."));
3520
+ this.running = !1, console.log("🛑 Chaos Maker DISENGAGED 🛑"), this.originalFetch && (window.fetch = this.originalFetch), this.originalXhrSend && (window.XMLHttpRequest.prototype.send = this.originalXhrSend), this.originalXhrOpen && (window.XMLHttpRequest.prototype.open = this.originalXhrOpen), this.domObserver && (this.domObserver.disconnect(), console.log("UI Assailant has stopped observing.")), this.originalWebSocket && (window.WebSocket = this.originalWebSocket, this.originalWebSocket = void 0), this.webSocketHandle && (this.webSocketHandle.uninstall(), this.webSocketHandle = void 0);
3186
3521
  }
3187
3522
  }
3188
- function De(s) {
3523
+ function ot(s) {
3189
3524
  return JSON.parse(JSON.stringify(s));
3190
3525
  }
3191
- class Bt {
3526
+ class Ts {
3192
3527
  constructor(e) {
3193
- E(this, "config");
3194
- this.config = e ? De(e) : { network: {}, ui: {} }, this.config.network || (this.config.network = {}), this.config.ui || (this.config.ui = {});
3528
+ P(this, "config");
3529
+ this.config = e ? ot(e) : { network: {}, ui: {}, websocket: {} }, this.config.network || (this.config.network = {}), this.config.ui || (this.config.ui = {}), this.config.websocket || (this.config.websocket = {});
3530
+ }
3531
+ failRequests(e, t, r, n, a, i, o) {
3532
+ return this.config.network.failures || (this.config.network.failures = []), this.config.network.failures.push({ urlPattern: e, statusCode: t, probability: r, methods: n, body: a, headers: i, ...o }), this;
3533
+ }
3534
+ addLatency(e, t, r, n, a) {
3535
+ return this.config.network.latencies || (this.config.network.latencies = []), this.config.network.latencies.push({ urlPattern: e, delayMs: t, probability: r, methods: n, ...a }), this;
3536
+ }
3537
+ abortRequests(e, t, r, n, a) {
3538
+ return this.config.network.aborts || (this.config.network.aborts = []), this.config.network.aborts.push({ urlPattern: e, probability: t, timeout: r, methods: n, ...a }), this;
3539
+ }
3540
+ corruptResponses(e, t, r, n, a) {
3541
+ return this.config.network.corruptions || (this.config.network.corruptions = []), this.config.network.corruptions.push({ urlPattern: e, strategy: t, probability: r, methods: n, ...a }), this;
3542
+ }
3543
+ simulateCors(e, t, r, n) {
3544
+ return this.config.network.cors || (this.config.network.cors = []), this.config.network.cors.push({ urlPattern: e, probability: t, methods: r, ...n }), this;
3545
+ }
3546
+ // --- onNth shortcuts ---
3547
+ failRequestsOnNth(e, t, r, n) {
3548
+ return this.failRequests(e, t, 1, n, void 0, void 0, { onNth: r });
3549
+ }
3550
+ addLatencyOnNth(e, t, r, n) {
3551
+ return this.addLatency(e, t, 1, n, { onNth: r });
3552
+ }
3553
+ abortRequestsOnNth(e, t, r, n) {
3554
+ return this.abortRequests(e, 1, r, n, { onNth: t });
3555
+ }
3556
+ corruptResponsesOnNth(e, t, r, n) {
3557
+ return this.corruptResponses(e, t, 1, n, { onNth: r });
3558
+ }
3559
+ simulateCorsOnNth(e, t, r) {
3560
+ return this.simulateCors(e, 1, r, { onNth: t });
3195
3561
  }
3196
- failRequests(e, t, r, n, a, o) {
3197
- return this.config.network.failures || (this.config.network.failures = []), this.config.network.failures.push({ urlPattern: e, statusCode: t, probability: r, methods: n, body: a, headers: o }), this;
3562
+ // --- everyNth shortcuts ---
3563
+ failRequestsEveryNth(e, t, r, n) {
3564
+ return this.failRequests(e, t, 1, n, void 0, void 0, { everyNth: r });
3198
3565
  }
3199
- addLatency(e, t, r, n) {
3200
- return this.config.network.latencies || (this.config.network.latencies = []), this.config.network.latencies.push({ urlPattern: e, delayMs: t, probability: r, methods: n }), this;
3566
+ addLatencyEveryNth(e, t, r, n) {
3567
+ return this.addLatency(e, t, 1, n, { everyNth: r });
3201
3568
  }
3202
- abortRequests(e, t, r, n) {
3203
- return this.config.network.aborts || (this.config.network.aborts = []), this.config.network.aborts.push({ urlPattern: e, probability: t, timeout: r, methods: n }), this;
3569
+ abortRequestsEveryNth(e, t, r, n) {
3570
+ return this.abortRequests(e, 1, r, n, { everyNth: t });
3204
3571
  }
3205
- corruptResponses(e, t, r, n) {
3206
- return this.config.network.corruptions || (this.config.network.corruptions = []), this.config.network.corruptions.push({ urlPattern: e, strategy: t, probability: r, methods: n }), this;
3572
+ corruptResponsesEveryNth(e, t, r, n) {
3573
+ return this.corruptResponses(e, t, 1, n, { everyNth: r });
3207
3574
  }
3208
- simulateCors(e, t, r) {
3209
- return this.config.network.cors || (this.config.network.cors = []), this.config.network.cors.push({ urlPattern: e, probability: t, methods: r }), this;
3575
+ simulateCorsEveryNth(e, t, r) {
3576
+ return this.simulateCors(e, 1, r, { everyNth: t });
3577
+ }
3578
+ // --- afterN shortcuts ---
3579
+ failRequestsAfterN(e, t, r, n) {
3580
+ return this.failRequests(e, t, 1, n, void 0, void 0, { afterN: r });
3581
+ }
3582
+ addLatencyAfterN(e, t, r, n) {
3583
+ return this.addLatency(e, t, 1, n, { afterN: r });
3584
+ }
3585
+ abortRequestsAfterN(e, t, r, n) {
3586
+ return this.abortRequests(e, 1, r, n, { afterN: t });
3587
+ }
3588
+ corruptResponsesAfterN(e, t, r, n) {
3589
+ return this.corruptResponses(e, t, 1, n, { afterN: r });
3590
+ }
3591
+ simulateCorsAfterN(e, t, r) {
3592
+ return this.simulateCors(e, 1, r, { afterN: t });
3210
3593
  }
3211
3594
  assaultUi(e, t, r) {
3212
3595
  return this.config.ui.assaults || (this.config.ui.assaults = []), this.config.ui.assaults.push({ selector: e, action: t, probability: r }), this;
3213
3596
  }
3597
+ // --- WebSocket chaos ---
3598
+ dropMessages(e, t, r, n) {
3599
+ return this.config.websocket.drops || (this.config.websocket.drops = []), this.config.websocket.drops.push({ urlPattern: e, direction: t, probability: r, ...n }), this;
3600
+ }
3601
+ delayMessages(e, t, r, n, a) {
3602
+ return this.config.websocket.delays || (this.config.websocket.delays = []), this.config.websocket.delays.push({ urlPattern: e, direction: t, delayMs: r, probability: n, ...a }), this;
3603
+ }
3604
+ corruptMessages(e, t, r, n, a) {
3605
+ return this.config.websocket.corruptions || (this.config.websocket.corruptions = []), this.config.websocket.corruptions.push({ urlPattern: e, direction: t, strategy: r, probability: n, ...a }), this;
3606
+ }
3607
+ closeConnection(e, t, r, n) {
3608
+ return this.config.websocket.closes || (this.config.websocket.closes = []), this.config.websocket.closes.push({ urlPattern: e, probability: t, ...r, ...n }), this;
3609
+ }
3610
+ // Counting shortcuts (only the two highest-value ones — see plan §8).
3611
+ dropMessagesOnNth(e, t, r) {
3612
+ return this.dropMessages(e, t, 1, { onNth: r });
3613
+ }
3614
+ delayMessagesOnNth(e, t, r, n) {
3615
+ return this.delayMessages(e, t, r, 1, { onNth: n });
3616
+ }
3617
+ /** Set the PRNG seed for reproducible chaos. */
3618
+ withSeed(e) {
3619
+ return this.config.seed = e, this;
3620
+ }
3214
3621
  build() {
3215
- return De(this.config);
3622
+ return ot(this.config);
3216
3623
  }
3217
3624
  }
3218
3625
  const se = "*";
3219
- function Be(s) {
3626
+ function ft(s) {
3220
3627
  if (s && typeof s == "object" && !Object.isFrozen(s)) {
3221
3628
  Object.freeze(s);
3222
3629
  for (const e of Object.values(s))
3223
- Be(e);
3630
+ ft(e);
3224
3631
  }
3225
3632
  return s;
3226
3633
  }
3227
- const Ht = Be({
3634
+ const Os = ft({
3228
3635
  unstableApi: {
3229
3636
  network: {
3230
3637
  failures: [{ urlPattern: "/api/", statusCode: 500, probability: 0.1 }],
@@ -3254,21 +3661,29 @@ const Ht = Be({
3254
3661
  { selector: "a", action: "hide", probability: 0.1 }
3255
3662
  ]
3256
3663
  }
3664
+ },
3665
+ unreliableWebSocket: {
3666
+ websocket: {
3667
+ drops: [{ urlPattern: se, direction: "both", probability: 0.1 }],
3668
+ delays: [{ urlPattern: se, direction: "inbound", delayMs: 500, probability: 1 }],
3669
+ corruptions: [{ urlPattern: se, direction: "inbound", strategy: "truncate", probability: 0.05 }]
3670
+ }
3257
3671
  }
3258
3672
  });
3259
3673
  if (typeof window < "u") {
3260
- window.ChaosMaker = Pe;
3674
+ window.ChaosMaker = it;
3261
3675
  const s = {
3262
3676
  instance: null,
3263
3677
  start: (e) => {
3264
3678
  try {
3265
- return s.instance && s.instance.stop(), s.instance = new Pe(e), s.instance.start(), { success: !0, message: "Chaos started" };
3679
+ return s.instance && s.instance.stop(), s.instance = new it(e), s.instance.start(), { success: !0, message: "Chaos started" };
3266
3680
  } catch (t) {
3267
3681
  return console.error("Chaos Utils Error:", t), { success: !1, message: t.message };
3268
3682
  }
3269
3683
  },
3270
3684
  stop: () => s.instance ? (s.instance.stop(), s.instance = null, { success: !0, message: "Chaos stopped" }) : { success: !1, message: "No chaos instance to stop" },
3271
- getLog: () => s.instance ? s.instance.getLog() : []
3685
+ getLog: () => s.instance ? s.instance.getLog() : [],
3686
+ getSeed: () => s.instance ? s.instance.getSeed() : null
3272
3687
  };
3273
3688
  if (window.chaosUtils = s, window.__CHAOS_CONFIG__)
3274
3689
  try {
@@ -3279,10 +3694,12 @@ if (typeof window < "u") {
3279
3694
  }
3280
3695
  }
3281
3696
  export {
3282
- Bt as ChaosConfigBuilder,
3283
- kt as ChaosConfigError,
3284
- Zt as ChaosEventEmitter,
3285
- Pe as ChaosMaker,
3286
- Ht as presets,
3287
- Rt as validateConfig
3697
+ Ts as ChaosConfigBuilder,
3698
+ Ut as ChaosConfigError,
3699
+ us as ChaosEventEmitter,
3700
+ it as ChaosMaker,
3701
+ ds as createPrng,
3702
+ cs as generateSeed,
3703
+ Os as presets,
3704
+ is as validateConfig
3288
3705
  };