var e;
(function (e) {
e.assertEqual = (e) => {};
function t(e) {}
e.assertIs = t;
function n(e) {
throw Error();
}
((e.assertNever = n),
(e.arrayToEnum = (e) => {
let t = {};
for (let n of e) t[n] = n;
return t;
}),
(e.getValidEnumValues = (t) => {
let n = e.objectKeys(t).filter((e) => typeof t[t[e]] != `number`),
r = {};
for (let e of n) r[e] = t[e];
return e.objectValues(r);
}),
(e.objectValues = (t) =>
e.objectKeys(t).map(function (e) {
return t[e];
})),
(e.objectKeys =
typeof Object.keys == `function`
? (e) => Object.keys(e)
: (e) => {
let t = [];
for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && t.push(n);
return t;
}),
(e.find = (e, t) => {
for (let n of e) if (t(n)) return n;
}),
(e.isInteger =
typeof Number.isInteger == `function`
? (e) => Number.isInteger(e)
: (e) => typeof e == `number` && Number.isFinite(e) && Math.floor(e) === e));
function r(e, t = ` | `) {
return e.map((e) => (typeof e == `string` ? `'${e}'` : e)).join(t);
}
((e.joinValues = r),
(e.jsonStringifyReplacer = (e, t) => (typeof t == `bigint` ? t.toString() : t)));
})((e ||= {}));
var t;
(function (e) {
e.mergeShapes = (e, t) => ({ ...e, ...t });
})((t ||= {}));
const n = e.arrayToEnum([
`string`,
`nan`,
`number`,
`integer`,
`float`,
`boolean`,
`date`,
`bigint`,
`symbol`,
`function`,
`undefined`,
`null`,
`array`,
`object`,
`unknown`,
`promise`,
`void`,
`never`,
`map`,
`set`,
]),
r = (e) => {
switch (typeof e) {
case `undefined`:
return n.undefined;
case `string`:
return n.string;
case `number`:
return Number.isNaN(e) ? n.nan : n.number;
case `boolean`:
return n.boolean;
case `function`:
return n.function;
case `bigint`:
return n.bigint;
case `symbol`:
return n.symbol;
case `object`:
return Array.isArray(e)
? n.array
: e === null
? n.null
: e.then && typeof e.then == `function` && e.catch && typeof e.catch == `function`
? n.promise
: typeof Map < `u` && e instanceof Map
? n.map
: typeof Set < `u` && e instanceof Set
? n.set
: typeof Date < `u` && e instanceof Date
? n.date
: n.object;
default:
return n.unknown;
}
},
i = e.arrayToEnum([
`invalid_type`,
`invalid_literal`,
`custom`,
`invalid_union`,
`invalid_union_discriminator`,
`invalid_enum_value`,
`unrecognized_keys`,
`invalid_arguments`,
`invalid_return_type`,
`invalid_date`,
`invalid_string`,
`too_small`,
`too_big`,
`invalid_intersection_types`,
`not_multiple_of`,
`not_finite`,
]);
var a = class t extends Error {
get errors() {
return this.issues;
}
constructor(e) {
(super(),
(this.issues = []),
(this.addIssue = (e) => {
this.issues = [...this.issues, e];
}),
(this.addIssues = (e = []) => {
this.issues = [...this.issues, ...e];
}));
let t = new.target.prototype;
(Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : (this.__proto__ = t),
(this.name = `ZodError`),
(this.issues = e));
}
format(e) {
let t =
e ||
function (e) {
return e.message;
},
n = { _errors: [] },
r = (e) => {
for (let i of e.issues)
if (i.code === `invalid_union`) i.unionErrors.map(r);
else if (i.code === `invalid_return_type`) r(i.returnTypeError);
else if (i.code === `invalid_arguments`) r(i.argumentsError);
else if (i.path.length === 0) n._errors.push(t(i));
else {
let e = n,
r = 0;
for (; r < i.path.length;) {
let n = i.path[r];
(r === i.path.length - 1
? ((e[n] = e[n] || { _errors: [] }), e[n]._errors.push(t(i)))
: (e[n] = e[n] || { _errors: [] }),
(e = e[n]),
r++);
}
}
};
return (r(this), n);
}
static assert(e) {
if (!(e instanceof t)) throw Error(`Not a ZodError: ${e}`);
}
toString() {
return this.message;
}
get message() {
return JSON.stringify(this.issues, e.jsonStringifyReplacer, 2);
}
get isEmpty() {
return this.issues.length === 0;
}
flatten(e = (e) => e.message) {
let t = Object.create(null),
n = [];
for (let r of this.issues)
if (r.path.length > 0) {
let n = r.path[0];
((t[n] = t[n] || []), t[n].push(e(r)));
} else n.push(e(r));
return { formErrors: n, fieldErrors: t };
}
get formErrors() {
return this.flatten();
}
};
a.create = (e) => new a(e);
const o = (t, r) => {
let a;
switch (t.code) {
case i.invalid_type:
a =
t.received === n.undefined ? `Required` : `Expected ${t.expected}, received ${t.received}`;
break;
case i.invalid_literal:
a = `Invalid literal value, expected ${JSON.stringify(t.expected, e.jsonStringifyReplacer)}`;
break;
case i.unrecognized_keys:
a = `Unrecognized key(s) in object: ${e.joinValues(t.keys, `, `)}`;
break;
case i.invalid_union:
a = `Invalid input`;
break;
case i.invalid_union_discriminator:
a = `Invalid discriminator value. Expected ${e.joinValues(t.options)}`;
break;
case i.invalid_enum_value:
a = `Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;
break;
case i.invalid_arguments:
a = `Invalid function arguments`;
break;
case i.invalid_return_type:
a = `Invalid function return type`;
break;
case i.invalid_date:
a = `Invalid date`;
break;
case i.invalid_string:
typeof t.validation == `object`
? `includes` in t.validation
? ((a = `Invalid input: must include "${t.validation.includes}"`),
typeof t.validation.position == `number` &&
(a = `${a} at one or more positions greater than or equal to ${t.validation.position}`))
: `startsWith` in t.validation
? (a = `Invalid input: must start with "${t.validation.startsWith}"`)
: `endsWith` in t.validation
? (a = `Invalid input: must end with "${t.validation.endsWith}"`)
: e.assertNever(t.validation)
: (a = t.validation === `regex` ? `Invalid` : `Invalid ${t.validation}`);
break;
case i.too_small:
a =
t.type === `array`
? `Array must contain ${t.exact ? `exactly` : t.inclusive ? `at least` : `more than`} ${t.minimum} element(s)`
: t.type === `string`
? `String must contain ${t.exact ? `exactly` : t.inclusive ? `at least` : `over`} ${t.minimum} character(s)`
: t.type === `number` || t.type === `bigint`
? `Number must be ${t.exact ? `exactly equal to ` : t.inclusive ? `greater than or equal to ` : `greater than `}${t.minimum}`
: t.type === `date`
? `Date must be ${t.exact ? `exactly equal to ` : t.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(t.minimum))}`
: `Invalid input`;
break;
case i.too_big:
a =
t.type === `array`
? `Array must contain ${t.exact ? `exactly` : t.inclusive ? `at most` : `less than`} ${t.maximum} element(s)`
: t.type === `string`
? `String must contain ${t.exact ? `exactly` : t.inclusive ? `at most` : `under`} ${t.maximum} character(s)`
: t.type === `number`
? `Number must be ${t.exact ? `exactly` : t.inclusive ? `less than or equal to` : `less than`} ${t.maximum}`
: t.type === `bigint`
? `BigInt must be ${t.exact ? `exactly` : t.inclusive ? `less than or equal to` : `less than`} ${t.maximum}`
: t.type === `date`
? `Date must be ${t.exact ? `exactly` : t.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(t.maximum))}`
: `Invalid input`;
break;
case i.custom:
a = `Invalid input`;
break;
case i.invalid_intersection_types:
a = `Intersection results could not be merged`;
break;
case i.not_multiple_of:
a = `Number must be a multiple of ${t.multipleOf}`;
break;
case i.not_finite:
a = `Number must be finite`;
break;
default:
((a = r.defaultError), e.assertNever(t));
}
return { message: a };
};
let s = o;
function c() {
return s;
}
const ee = (e) => {
let { data: t, path: n, errorMaps: r, issueData: i } = e,
a = [...n, ...(i.path || [])],
o = { ...i, path: a };
if (i.message !== void 0) return { ...i, path: a, message: i.message };
let s = ``,
c = r
.filter((e) => !!e)
.slice()
.reverse();
for (let e of c) s = e(o, { data: t, defaultError: s }).message;
return { ...i, path: a, message: s };
};
function l(e, t) {
let n = c(),
r = ee({
issueData: t,
data: e.data,
path: e.path,
errorMaps: [e.common.contextualErrorMap, e.schemaErrorMap, n, n === o ? void 0 : o].filter(
(e) => !!e,
),
});
e.common.issues.push(r);
}
var u = class e {
constructor() {
this.value = `valid`;
}
dirty() {
this.value === `valid` && (this.value = `dirty`);
}
abort() {
this.value !== `aborted` && (this.value = `aborted`);
}
static mergeArray(e, t) {
let n = [];
for (let r of t) {
if (r.status === `aborted`) return d;
(r.status === `dirty` && e.dirty(), n.push(r.value));
}
return { status: e.value, value: n };
}
static async mergeObjectAsync(t, n) {
let r = [];
for (let e of n) {
let t = await e.key,
n = await e.value;
r.push({ key: t, value: n });
}
return e.mergeObjectSync(t, r);
}
static mergeObjectSync(e, t) {
let n = {};
for (let r of t) {
let { key: t, value: i } = r;
if (t.status === `aborted` || i.status === `aborted`) return d;
(t.status === `dirty` && e.dirty(),
i.status === `dirty` && e.dirty(),
t.value !== `__proto__` && (i.value !== void 0 || r.alwaysSet) && (n[t.value] = i.value));
}
return { status: e.value, value: n };
}
};
const d = Object.freeze({ status: `aborted` }),
f = (e) => ({ status: `dirty`, value: e }),
p = (e) => ({ status: `valid`, value: e }),
te = (e) => e.status === `aborted`,
ne = (e) => e.status === `dirty`,
m = (e) => e.status === `valid`,
h = (e) => typeof Promise < `u` && e instanceof Promise;
var g;
(function (e) {
((e.errToObj = (e) => (typeof e == `string` ? { message: e } : e || {})),
(e.toString = (e) => (typeof e == `string` ? e : e?.message)));
})((g ||= {}));
var _ = class {
constructor(e, t, n, r) {
((this._cachedPath = []),
(this.parent = e),
(this.data = t),
(this._path = n),
(this._key = r));
}
get path() {
return (
this._cachedPath.length ||
(Array.isArray(this._key)
? this._cachedPath.push(...this._path, ...this._key)
: this._cachedPath.push(...this._path, this._key)),
this._cachedPath
);
}
};
const re = (e, t) => {
if (m(t)) return { success: !0, data: t.value };
if (!e.common.issues.length) throw Error(`Validation failed but no issues detected.`);
return {
success: !1,
get error() {
if (this._error) return this._error;
let t = new a(e.common.issues);
return ((this._error = t), this._error);
},
};
};
function v(e) {
if (!e) return {};
let { errorMap: t, invalid_type_error: n, required_error: r, description: i } = e;
if (t && (n || r))
throw Error(
`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`,
);
return t
? { errorMap: t, description: i }
: {
errorMap: (t, i) => {
let { message: a } = e;
return t.code === `invalid_enum_value`
? { message: a ?? i.defaultError }
: i.data === void 0
? { message: a ?? r ?? i.defaultError }
: t.code === `invalid_type`
? { message: a ?? n ?? i.defaultError }
: { message: i.defaultError };
},
description: i,
};
}
var y = class {
get description() {
return this._def.description;
}
_getType(e) {
return r(e.data);
}
_getOrReturnCtx(e, t) {
return (
t || {
common: e.parent.common,
data: e.data,
parsedType: r(e.data),
schemaErrorMap: this._def.errorMap,
path: e.path,
parent: e.parent,
}
);
}
_processInputParams(e) {
return {
status: new u(),
ctx: {
common: e.parent.common,
data: e.data,
parsedType: r(e.data),
schemaErrorMap: this._def.errorMap,
path: e.path,
parent: e.parent,
},
};
}
_parseSync(e) {
let t = this._parse(e);
if (h(t)) throw Error(`Synchronous parse encountered promise.`);
return t;
}
_parseAsync(e) {
let t = this._parse(e);
return Promise.resolve(t);
}
parse(e, t) {
let n = this.safeParse(e, t);
if (n.success) return n.data;
throw n.error;
}
safeParse(e, t) {
let n = {
common: { issues: [], async: t?.async ?? !1, contextualErrorMap: t?.errorMap },
path: t?.path || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data: e,
parsedType: r(e),
},
i = this._parseSync({ data: e, path: n.path, parent: n });
return re(n, i);
}
"~validate"(e) {
let t = {
common: { issues: [], async: !!this[`~standard`].async },
path: [],
schemaErrorMap: this._def.errorMap,
parent: null,
data: e,
parsedType: r(e),
};
if (!this[`~standard`].async)
try {
let n = this._parseSync({ data: e, path: [], parent: t });
return m(n) ? { value: n.value } : { issues: t.common.issues };
} catch (e) {
(e?.message?.toLowerCase()?.includes(`encountered`) && (this[`~standard`].async = !0),
(t.common = { issues: [], async: !0 }));
}
return this._parseAsync({ data: e, path: [], parent: t }).then((e) =>
m(e) ? { value: e.value } : { issues: t.common.issues },
);
}
async parseAsync(e, t) {
let n = await this.safeParseAsync(e, t);
if (n.success) return n.data;
throw n.error;
}
async safeParseAsync(e, t) {
let n = {
common: { issues: [], contextualErrorMap: t?.errorMap, async: !0 },
path: t?.path || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data: e,
parsedType: r(e),
},
i = this._parse({ data: e, path: n.path, parent: n }),
a = await (h(i) ? i : Promise.resolve(i));
return re(n, a);
}
refine(e, t) {
let n = (e) =>
typeof t == `string` || t === void 0 ? { message: t } : typeof t == `function` ? t(e) : t;
return this._refinement((t, r) => {
let a = e(t),
o = () => r.addIssue({ code: i.custom, ...n(t) });
return typeof Promise < `u` && a instanceof Promise
? a.then((e) => (e ? !0 : (o(), !1)))
: a
? !0
: (o(), !1);
});
}
refinement(e, t) {
return this._refinement((n, r) =>
e(n) ? !0 : (r.addIssue(typeof t == `function` ? t(n, r) : t), !1),
);
}
_refinement(e) {
return new U({
schema: this,
typeName: X.ZodEffects,
effect: { type: `refinement`, refinement: e },
});
}
superRefine(e) {
return this._refinement(e);
}
constructor(e) {
((this.spa = this.safeParseAsync),
(this._def = e),
(this.parse = this.parse.bind(this)),
(this.safeParse = this.safeParse.bind(this)),
(this.parseAsync = this.parseAsync.bind(this)),
(this.safeParseAsync = this.safeParseAsync.bind(this)),
(this.spa = this.spa.bind(this)),
(this.refine = this.refine.bind(this)),
(this.refinement = this.refinement.bind(this)),
(this.superRefine = this.superRefine.bind(this)),
(this.optional = this.optional.bind(this)),
(this.nullable = this.nullable.bind(this)),
(this.nullish = this.nullish.bind(this)),
(this.array = this.array.bind(this)),
(this.promise = this.promise.bind(this)),
(this.or = this.or.bind(this)),
(this.and = this.and.bind(this)),
(this.transform = this.transform.bind(this)),
(this.brand = this.brand.bind(this)),
(this.default = this.default.bind(this)),
(this.catch = this.catch.bind(this)),
(this.describe = this.describe.bind(this)),
(this.pipe = this.pipe.bind(this)),
(this.readonly = this.readonly.bind(this)),
(this.isNullable = this.isNullable.bind(this)),
(this.isOptional = this.isOptional.bind(this)),
(this[`~standard`] = { version: 1, vendor: `zod`, validate: (e) => this[`~validate`](e) }));
}
optional() {
return W.create(this, this._def);
}
nullable() {
return G.create(this, this._def);
}
nullish() {
return this.nullable().optional();
}
array() {
return j.create(this);
}
promise() {
return H.create(this, this._def);
}
or(e) {
return P.create([this, e], this._def);
}
and(e) {
return I.create(this, e, this._def);
}
transform(e) {
return new U({
...v(this._def),
schema: this,
typeName: X.ZodEffects,
effect: { type: `transform`, transform: e },
});
}
default(e) {
let t = typeof e == `function` ? e : () => e;
return new K({ ...v(this._def), innerType: this, defaultValue: t, typeName: X.ZodDefault });
}
brand() {
return new Ie({ typeName: X.ZodBranded, type: this, ...v(this._def) });
}
catch(e) {
let t = typeof e == `function` ? e : () => e;
return new q({ ...v(this._def), innerType: this, catchValue: t, typeName: X.ZodCatch });
}
describe(e) {
let t = this.constructor;
return new t({ ...this._def, description: e });
}
pipe(e) {
return Le.create(this, e);
}
readonly() {
return Y.create(this);
}
isOptional() {
return this.safeParse(void 0).success;
}
isNullable() {
return this.safeParse(null).success;
}
};
const ie = /^c[^\s-]{8,}$/i,
ae = /^[0-9a-z]+$/,
oe = /^[0-9A-HJKMNP-TV-Z]{26}$/i,
se = /^[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,
ce = /^[a-z0-9_-]{21}$/i,
le = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,
ue =
/^[-+]?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)?)??$/,
de = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
let fe;
const pe =
/^(?:(?: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])$/,
me =
/^(?:(?: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])$/,
he =
/^(([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]))$/,
ge =
/^(([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])$/,
_e = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
ve = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
ye = `((\\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])))`,
be = RegExp(`^${ye}$`);
function xe(e) {
let t = `[0-5]\\d`;
e.precision ? (t = `${t}\\.\\d{${e.precision}}`) : (e.precision ?? (t = `${t}(\\.\\d+)?`));
let n = e.precision ? `+` : `?`;
return `([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`;
}
function Se(e) {
return RegExp(`^${xe(e)}$`);
}
function Ce(e) {
let t = `${ye}T${xe(e)}`,
n = [];
return (
n.push(e.local ? `Z?` : `Z`),
e.offset && n.push(`([+-]\\d{2}:?\\d{2})`),
(t = `${t}(${n.join(`|`)})`),
RegExp(`^${t}$`)
);
}
function we(e, t) {
return !!(((t === `v4` || !t) && pe.test(e)) || ((t === `v6` || !t) && he.test(e)));
}
function Te(e, t) {
if (!le.test(e)) return !1;
try {
let [n] = e.split(`.`);
if (!n) return !1;
let r = n
.replace(/-/g, `+`)
.replace(/_/g, `/`)
.padEnd(n.length + ((4 - (n.length % 4)) % 4), `=`),
i = JSON.parse(atob(r));
return !(
typeof i != `object` ||
!i ||
(`typ` in i && i?.typ !== `JWT`) ||
!i.alg ||
(t && i.alg !== t)
);
} catch {
return !1;
}
}
function Ee(e, t) {
return !!(((t === `v4` || !t) && me.test(e)) || ((t === `v6` || !t) && ge.test(e)));
}
var b = class t extends y {
_parse(t) {
if ((this._def.coerce && (t.data = String(t.data)), this._getType(t) !== n.string)) {
let e = this._getOrReturnCtx(t);
return (l(e, { code: i.invalid_type, expected: n.string, received: e.parsedType }), d);
}
let r = new u(),
a;
for (let n of this._def.checks)
if (n.kind === `min`)
t.data.length < n.value &&
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.too_small,
minimum: n.value,
type: `string`,
inclusive: !0,
exact: !1,
message: n.message,
}),
r.dirty());
else if (n.kind === `max`)
t.data.length > n.value &&
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.too_big,
maximum: n.value,
type: `string`,
inclusive: !0,
exact: !1,
message: n.message,
}),
r.dirty());
else if (n.kind === `length`) {
let e = t.data.length > n.value,
o = t.data.length < n.value;
(e || o) &&
((a = this._getOrReturnCtx(t, a)),
e
? l(a, {
code: i.too_big,
maximum: n.value,
type: `string`,
inclusive: !0,
exact: !0,
message: n.message,
})
: o &&
l(a, {
code: i.too_small,
minimum: n.value,
type: `string`,
inclusive: !0,
exact: !0,
message: n.message,
}),
r.dirty());
} else if (n.kind === `email`)
de.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `email`, code: i.invalid_string, message: n.message }),
r.dirty());
else if (n.kind === `emoji`)
((fe ||= RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`, `u`)),
fe.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `emoji`, code: i.invalid_string, message: n.message }),
r.dirty()));
else if (n.kind === `uuid`)
se.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `uuid`, code: i.invalid_string, message: n.message }),
r.dirty());
else if (n.kind === `nanoid`)
ce.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `nanoid`, code: i.invalid_string, message: n.message }),
r.dirty());
else if (n.kind === `cuid`)
ie.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `cuid`, code: i.invalid_string, message: n.message }),
r.dirty());
else if (n.kind === `cuid2`)
ae.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `cuid2`, code: i.invalid_string, message: n.message }),
r.dirty());
else if (n.kind === `ulid`)
oe.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `ulid`, code: i.invalid_string, message: n.message }),
r.dirty());
else if (n.kind === `url`)
try {
new URL(t.data);
} catch {
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `url`, code: i.invalid_string, message: n.message }),
r.dirty());
}
else
n.kind === `regex`
? ((n.regex.lastIndex = 0),
n.regex.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, { validation: `regex`, code: i.invalid_string, message: n.message }),
r.dirty()))
: n.kind === `trim`
? (t.data = t.data.trim())
: n.kind === `includes`
? t.data.includes(n.value, n.position) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.invalid_string,
validation: { includes: n.value, position: n.position },
message: n.message,
}),
r.dirty())
: n.kind === `toLowerCase`
? (t.data = t.data.toLowerCase())
: n.kind === `toUpperCase`
? (t.data = t.data.toUpperCase())
: n.kind === `startsWith`
? t.data.startsWith(n.value) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.invalid_string,
validation: { startsWith: n.value },
message: n.message,
}),
r.dirty())
: n.kind === `endsWith`
? t.data.endsWith(n.value) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.invalid_string,
validation: { endsWith: n.value },
message: n.message,
}),
r.dirty())
: n.kind === `datetime`
? Ce(n).test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.invalid_string,
validation: `datetime`,
message: n.message,
}),
r.dirty())
: n.kind === `date`
? be.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.invalid_string,
validation: `date`,
message: n.message,
}),
r.dirty())
: n.kind === `time`
? Se(n).test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.invalid_string,
validation: `time`,
message: n.message,
}),
r.dirty())
: n.kind === `duration`
? ue.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
validation: `duration`,
code: i.invalid_string,
message: n.message,
}),
r.dirty())
: n.kind === `ip`
? we(t.data, n.version) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
validation: `ip`,
code: i.invalid_string,
message: n.message,
}),
r.dirty())
: n.kind === `jwt`
? Te(t.data, n.alg) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
validation: `jwt`,
code: i.invalid_string,
message: n.message,
}),
r.dirty())
: n.kind === `cidr`
? Ee(t.data, n.version) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
validation: `cidr`,
code: i.invalid_string,
message: n.message,
}),
r.dirty())
: n.kind === `base64`
? _e.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
validation: `base64`,
code: i.invalid_string,
message: n.message,
}),
r.dirty())
: n.kind === `base64url`
? ve.test(t.data) ||
((a = this._getOrReturnCtx(t, a)),
l(a, {
validation: `base64url`,
code: i.invalid_string,
message: n.message,
}),
r.dirty())
: e.assertNever(n);
return { status: r.value, value: t.data };
}
_regex(e, t, n) {
return this.refinement((t) => e.test(t), {
validation: t,
code: i.invalid_string,
...g.errToObj(n),
});
}
_addCheck(e) {
return new t({ ...this._def, checks: [...this._def.checks, e] });
}
email(e) {
return this._addCheck({ kind: `email`, ...g.errToObj(e) });
}
url(e) {
return this._addCheck({ kind: `url`, ...g.errToObj(e) });
}
emoji(e) {
return this._addCheck({ kind: `emoji`, ...g.errToObj(e) });
}
uuid(e) {
return this._addCheck({ kind: `uuid`, ...g.errToObj(e) });
}
nanoid(e) {
return this._addCheck({ kind: `nanoid`, ...g.errToObj(e) });
}
cuid(e) {
return this._addCheck({ kind: `cuid`, ...g.errToObj(e) });
}
cuid2(e) {
return this._addCheck({ kind: `cuid2`, ...g.errToObj(e) });
}
ulid(e) {
return this._addCheck({ kind: `ulid`, ...g.errToObj(e) });
}
base64(e) {
return this._addCheck({ kind: `base64`, ...g.errToObj(e) });
}
base64url(e) {
return this._addCheck({ kind: `base64url`, ...g.errToObj(e) });
}
jwt(e) {
return this._addCheck({ kind: `jwt`, ...g.errToObj(e) });
}
ip(e) {
return this._addCheck({ kind: `ip`, ...g.errToObj(e) });
}
cidr(e) {
return this._addCheck({ kind: `cidr`, ...g.errToObj(e) });
}
datetime(e) {
return typeof e == `string`
? this._addCheck({ kind: `datetime`, precision: null, offset: !1, local: !1, message: e })
: this._addCheck({
kind: `datetime`,
precision: e?.precision === void 0 ? null : e?.precision,
offset: e?.offset ?? !1,
local: e?.local ?? !1,
...g.errToObj(e?.message),
});
}
date(e) {
return this._addCheck({ kind: `date`, message: e });
}
time(e) {
return typeof e == `string`
? this._addCheck({ kind: `time`, precision: null, message: e })
: this._addCheck({
kind: `time`,
precision: e?.precision === void 0 ? null : e?.precision,
...g.errToObj(e?.message),
});
}
duration(e) {
return this._addCheck({ kind: `duration`, ...g.errToObj(e) });
}
regex(e, t) {
return this._addCheck({ kind: `regex`, regex: e, ...g.errToObj(t) });
}
includes(e, t) {
return this._addCheck({
kind: `includes`,
value: e,
position: t?.position,
...g.errToObj(t?.message),
});
}
startsWith(e, t) {
return this._addCheck({ kind: `startsWith`, value: e, ...g.errToObj(t) });
}
endsWith(e, t) {
return this._addCheck({ kind: `endsWith`, value: e, ...g.errToObj(t) });
}
min(e, t) {
return this._addCheck({ kind: `min`, value: e, ...g.errToObj(t) });
}
max(e, t) {
return this._addCheck({ kind: `max`, value: e, ...g.errToObj(t) });
}
length(e, t) {
return this._addCheck({ kind: `length`, value: e, ...g.errToObj(t) });
}
nonempty(e) {
return this.min(1, g.errToObj(e));
}
trim() {
return new t({ ...this._def, checks: [...this._def.checks, { kind: `trim` }] });
}
toLowerCase() {
return new t({ ...this._def, checks: [...this._def.checks, { kind: `toLowerCase` }] });
}
toUpperCase() {
return new t({ ...this._def, checks: [...this._def.checks, { kind: `toUpperCase` }] });
}
get isDatetime() {
return !!this._def.checks.find((e) => e.kind === `datetime`);
}
get isDate() {
return !!this._def.checks.find((e) => e.kind === `date`);
}
get isTime() {
return !!this._def.checks.find((e) => e.kind === `time`);
}
get isDuration() {
return !!this._def.checks.find((e) => e.kind === `duration`);
}
get isEmail() {
return !!this._def.checks.find((e) => e.kind === `email`);
}
get isURL() {
return !!this._def.checks.find((e) => e.kind === `url`);
}
get isEmoji() {
return !!this._def.checks.find((e) => e.kind === `emoji`);
}
get isUUID() {
return !!this._def.checks.find((e) => e.kind === `uuid`);
}
get isNANOID() {
return !!this._def.checks.find((e) => e.kind === `nanoid`);
}
get isCUID() {
return !!this._def.checks.find((e) => e.kind === `cuid`);
}
get isCUID2() {
return !!this._def.checks.find((e) => e.kind === `cuid2`);
}
get isULID() {
return !!this._def.checks.find((e) => e.kind === `ulid`);
}
get isIP() {
return !!this._def.checks.find((e) => e.kind === `ip`);
}
get isCIDR() {
return !!this._def.checks.find((e) => e.kind === `cidr`);
}
get isBase64() {
return !!this._def.checks.find((e) => e.kind === `base64`);
}
get isBase64url() {
return !!this._def.checks.find((e) => e.kind === `base64url`);
}
get minLength() {
let e = null;
for (let t of this._def.checks)
t.kind === `min` && (e === null || t.value > e) && (e = t.value);
return e;
}
get maxLength() {
let e = null;
for (let t of this._def.checks)
t.kind === `max` && (e === null || t.value < e) && (e = t.value);
return e;
}
};
b.create = (e) => new b({ checks: [], typeName: X.ZodString, coerce: e?.coerce ?? !1, ...v(e) });
function De(e, t) {
let n = (e.toString().split(`.`)[1] || ``).length,
r = (t.toString().split(`.`)[1] || ``).length,
i = n > r ? n : r;
return (
(Number.parseInt(e.toFixed(i).replace(`.`, ``)) %
Number.parseInt(t.toFixed(i).replace(`.`, ``))) /
10 ** i
);
}
var x = class t extends y {
constructor() {
(super(...arguments),
(this.min = this.gte),
(this.max = this.lte),
(this.step = this.multipleOf));
}
_parse(t) {
if ((this._def.coerce && (t.data = Number(t.data)), this._getType(t) !== n.number)) {
let e = this._getOrReturnCtx(t);
return (l(e, { code: i.invalid_type, expected: n.number, received: e.parsedType }), d);
}
let r,
a = new u();
for (let n of this._def.checks)
n.kind === `int`
? e.isInteger(t.data) ||
((r = this._getOrReturnCtx(t, r)),
l(r, {
code: i.invalid_type,
expected: `integer`,
received: `float`,
message: n.message,
}),
a.dirty())
: n.kind === `min`
? (n.inclusive ? t.data < n.value : t.data <= n.value) &&
((r = this._getOrReturnCtx(t, r)),
l(r, {
code: i.too_small,
minimum: n.value,
type: `number`,
inclusive: n.inclusive,
exact: !1,
message: n.message,
}),
a.dirty())
: n.kind === `max`
? (n.inclusive ? t.data > n.value : t.data >= n.value) &&
((r = this._getOrReturnCtx(t, r)),
l(r, {
code: i.too_big,
maximum: n.value,
type: `number`,
inclusive: n.inclusive,
exact: !1,
message: n.message,
}),
a.dirty())
: n.kind === `multipleOf`
? De(t.data, n.value) !== 0 &&
((r = this._getOrReturnCtx(t, r)),
l(r, { code: i.not_multiple_of, multipleOf: n.value, message: n.message }),
a.dirty())
: n.kind === `finite`
? Number.isFinite(t.data) ||
((r = this._getOrReturnCtx(t, r)),
l(r, { code: i.not_finite, message: n.message }),
a.dirty())
: e.assertNever(n);
return { status: a.value, value: t.data };
}
gte(e, t) {
return this.setLimit(`min`, e, !0, g.toString(t));
}
gt(e, t) {
return this.setLimit(`min`, e, !1, g.toString(t));
}
lte(e, t) {
return this.setLimit(`max`, e, !0, g.toString(t));
}
lt(e, t) {
return this.setLimit(`max`, e, !1, g.toString(t));
}
setLimit(e, n, r, i) {
return new t({
...this._def,
checks: [...this._def.checks, { kind: e, value: n, inclusive: r, message: g.toString(i) }],
});
}
_addCheck(e) {
return new t({ ...this._def, checks: [...this._def.checks, e] });
}
int(e) {
return this._addCheck({ kind: `int`, message: g.toString(e) });
}
positive(e) {
return this._addCheck({ kind: `min`, value: 0, inclusive: !1, message: g.toString(e) });
}
negative(e) {
return this._addCheck({ kind: `max`, value: 0, inclusive: !1, message: g.toString(e) });
}
nonpositive(e) {
return this._addCheck({ kind: `max`, value: 0, inclusive: !0, message: g.toString(e) });
}
nonnegative(e) {
return this._addCheck({ kind: `min`, value: 0, inclusive: !0, message: g.toString(e) });
}
multipleOf(e, t) {
return this._addCheck({ kind: `multipleOf`, value: e, message: g.toString(t) });
}
finite(e) {
return this._addCheck({ kind: `finite`, message: g.toString(e) });
}
safe(e) {
return this._addCheck({
kind: `min`,
inclusive: !0,
value: -(2 ** 53 - 1),
message: g.toString(e),
})._addCheck({ kind: `max`, inclusive: !0, value: 2 ** 53 - 1, message: g.toString(e) });
}
get minValue() {
let e = null;
for (let t of this._def.checks)
t.kind === `min` && (e === null || t.value > e) && (e = t.value);
return e;
}
get maxValue() {
let e = null;
for (let t of this._def.checks)
t.kind === `max` && (e === null || t.value < e) && (e = t.value);
return e;
}
get isInt() {
return !!this._def.checks.find(
(t) => t.kind === `int` || (t.kind === `multipleOf` && e.isInteger(t.value)),
);
}
get isFinite() {
let e = null,
t = null;
for (let n of this._def.checks)
if (n.kind === `finite` || n.kind === `int` || n.kind === `multipleOf`) return !0;
else
n.kind === `min`
? (t === null || n.value > t) && (t = n.value)
: n.kind === `max` && (e === null || n.value < e) && (e = n.value);
return Number.isFinite(t) && Number.isFinite(e);
}
};
x.create = (e) => new x({ checks: [], typeName: X.ZodNumber, coerce: e?.coerce || !1, ...v(e) });
var S = class t extends y {
constructor() {
(super(...arguments), (this.min = this.gte), (this.max = this.lte));
}
_parse(t) {
if (this._def.coerce)
try {
t.data = BigInt(t.data);
} catch {
return this._getInvalidInput(t);
}
if (this._getType(t) !== n.bigint) return this._getInvalidInput(t);
let r,
a = new u();
for (let n of this._def.checks)
n.kind === `min`
? (n.inclusive ? t.data < n.value : t.data <= n.value) &&
((r = this._getOrReturnCtx(t, r)),
l(r, {
code: i.too_small,
type: `bigint`,
minimum: n.value,
inclusive: n.inclusive,
message: n.message,
}),
a.dirty())
: n.kind === `max`
? (n.inclusive ? t.data > n.value : t.data >= n.value) &&
((r = this._getOrReturnCtx(t, r)),
l(r, {
code: i.too_big,
type: `bigint`,
maximum: n.value,
inclusive: n.inclusive,
message: n.message,
}),
a.dirty())
: n.kind === `multipleOf`
? t.data % n.value !== BigInt(0) &&
((r = this._getOrReturnCtx(t, r)),
l(r, { code: i.not_multiple_of, multipleOf: n.value, message: n.message }),
a.dirty())
: e.assertNever(n);
return { status: a.value, value: t.data };
}
_getInvalidInput(e) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.bigint, received: t.parsedType }), d);
}
gte(e, t) {
return this.setLimit(`min`, e, !0, g.toString(t));
}
gt(e, t) {
return this.setLimit(`min`, e, !1, g.toString(t));
}
lte(e, t) {
return this.setLimit(`max`, e, !0, g.toString(t));
}
lt(e, t) {
return this.setLimit(`max`, e, !1, g.toString(t));
}
setLimit(e, n, r, i) {
return new t({
...this._def,
checks: [...this._def.checks, { kind: e, value: n, inclusive: r, message: g.toString(i) }],
});
}
_addCheck(e) {
return new t({ ...this._def, checks: [...this._def.checks, e] });
}
positive(e) {
return this._addCheck({ kind: `min`, value: BigInt(0), inclusive: !1, message: g.toString(e) });
}
negative(e) {
return this._addCheck({ kind: `max`, value: BigInt(0), inclusive: !1, message: g.toString(e) });
}
nonpositive(e) {
return this._addCheck({ kind: `max`, value: BigInt(0), inclusive: !0, message: g.toString(e) });
}
nonnegative(e) {
return this._addCheck({ kind: `min`, value: BigInt(0), inclusive: !0, message: g.toString(e) });
}
multipleOf(e, t) {
return this._addCheck({ kind: `multipleOf`, value: e, message: g.toString(t) });
}
get minValue() {
let e = null;
for (let t of this._def.checks)
t.kind === `min` && (e === null || t.value > e) && (e = t.value);
return e;
}
get maxValue() {
let e = null;
for (let t of this._def.checks)
t.kind === `max` && (e === null || t.value < e) && (e = t.value);
return e;
}
};
S.create = (e) => new S({ checks: [], typeName: X.ZodBigInt, coerce: e?.coerce ?? !1, ...v(e) });
var C = class extends y {
_parse(e) {
if ((this._def.coerce && (e.data = !!e.data), this._getType(e) !== n.boolean)) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.boolean, received: t.parsedType }), d);
}
return p(e.data);
}
};
C.create = (e) => new C({ typeName: X.ZodBoolean, coerce: e?.coerce || !1, ...v(e) });
var w = class t extends y {
_parse(t) {
if ((this._def.coerce && (t.data = new Date(t.data)), this._getType(t) !== n.date)) {
let e = this._getOrReturnCtx(t);
return (l(e, { code: i.invalid_type, expected: n.date, received: e.parsedType }), d);
}
if (Number.isNaN(t.data.getTime()))
return (l(this._getOrReturnCtx(t), { code: i.invalid_date }), d);
let r = new u(),
a;
for (let n of this._def.checks)
n.kind === `min`
? t.data.getTime() < n.value &&
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.too_small,
message: n.message,
inclusive: !0,
exact: !1,
minimum: n.value,
type: `date`,
}),
r.dirty())
: n.kind === `max`
? t.data.getTime() > n.value &&
((a = this._getOrReturnCtx(t, a)),
l(a, {
code: i.too_big,
message: n.message,
inclusive: !0,
exact: !1,
maximum: n.value,
type: `date`,
}),
r.dirty())
: e.assertNever(n);
return { status: r.value, value: new Date(t.data.getTime()) };
}
_addCheck(e) {
return new t({ ...this._def, checks: [...this._def.checks, e] });
}
min(e, t) {
return this._addCheck({ kind: `min`, value: e.getTime(), message: g.toString(t) });
}
max(e, t) {
return this._addCheck({ kind: `max`, value: e.getTime(), message: g.toString(t) });
}
get minDate() {
let e = null;
for (let t of this._def.checks)
t.kind === `min` && (e === null || t.value > e) && (e = t.value);
return e == null ? null : new Date(e);
}
get maxDate() {
let e = null;
for (let t of this._def.checks)
t.kind === `max` && (e === null || t.value < e) && (e = t.value);
return e == null ? null : new Date(e);
}
};
w.create = (e) => new w({ checks: [], coerce: e?.coerce || !1, typeName: X.ZodDate, ...v(e) });
var T = class extends y {
_parse(e) {
if (this._getType(e) !== n.symbol) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.symbol, received: t.parsedType }), d);
}
return p(e.data);
}
};
T.create = (e) => new T({ typeName: X.ZodSymbol, ...v(e) });
var E = class extends y {
_parse(e) {
if (this._getType(e) !== n.undefined) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.undefined, received: t.parsedType }), d);
}
return p(e.data);
}
};
E.create = (e) => new E({ typeName: X.ZodUndefined, ...v(e) });
var D = class extends y {
_parse(e) {
if (this._getType(e) !== n.null) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.null, received: t.parsedType }), d);
}
return p(e.data);
}
};
D.create = (e) => new D({ typeName: X.ZodNull, ...v(e) });
var O = class extends y {
constructor() {
(super(...arguments), (this._any = !0));
}
_parse(e) {
return p(e.data);
}
};
O.create = (e) => new O({ typeName: X.ZodAny, ...v(e) });
var k = class extends y {
constructor() {
(super(...arguments), (this._unknown = !0));
}
_parse(e) {
return p(e.data);
}
};
k.create = (e) => new k({ typeName: X.ZodUnknown, ...v(e) });
var A = class extends y {
_parse(e) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.never, received: t.parsedType }), d);
}
};
A.create = (e) => new A({ typeName: X.ZodNever, ...v(e) });
var Oe = class extends y {
_parse(e) {
if (this._getType(e) !== n.undefined) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.void, received: t.parsedType }), d);
}
return p(e.data);
}
};
Oe.create = (e) => new Oe({ typeName: X.ZodVoid, ...v(e) });
var j = class e extends y {
_parse(e) {
let { ctx: t, status: r } = this._processInputParams(e),
a = this._def;
if (t.parsedType !== n.array)
return (l(t, { code: i.invalid_type, expected: n.array, received: t.parsedType }), d);
if (a.exactLength !== null) {
let e = t.data.length > a.exactLength.value,
n = t.data.length < a.exactLength.value;
(e || n) &&
(l(t, {
code: e ? i.too_big : i.too_small,
minimum: n ? a.exactLength.value : void 0,
maximum: e ? a.exactLength.value : void 0,
type: `array`,
inclusive: !0,
exact: !0,
message: a.exactLength.message,
}),
r.dirty());
}
if (
(a.minLength !== null &&
t.data.length < a.minLength.value &&
(l(t, {
code: i.too_small,
minimum: a.minLength.value,
type: `array`,
inclusive: !0,
exact: !1,
message: a.minLength.message,
}),
r.dirty()),
a.maxLength !== null &&
t.data.length > a.maxLength.value &&
(l(t, {
code: i.too_big,
maximum: a.maxLength.value,
type: `array`,
inclusive: !0,
exact: !1,
message: a.maxLength.message,
}),
r.dirty()),
t.common.async)
)
return Promise.all(
[...t.data].map((e, n) => a.type._parseAsync(new _(t, e, t.path, n))),
).then((e) => u.mergeArray(r, e));
let o = [...t.data].map((e, n) => a.type._parseSync(new _(t, e, t.path, n)));
return u.mergeArray(r, o);
}
get element() {
return this._def.type;
}
min(t, n) {
return new e({ ...this._def, minLength: { value: t, message: g.toString(n) } });
}
max(t, n) {
return new e({ ...this._def, maxLength: { value: t, message: g.toString(n) } });
}
length(t, n) {
return new e({ ...this._def, exactLength: { value: t, message: g.toString(n) } });
}
nonempty(e) {
return this.min(1, e);
}
};
j.create = (e, t) =>
new j({
type: e,
minLength: null,
maxLength: null,
exactLength: null,
typeName: X.ZodArray,
...v(t),
});
function M(e) {
if (e instanceof N) {
let t = {};
for (let n in e.shape) {
let r = e.shape[n];
t[n] = W.create(M(r));
}
return new N({ ...e._def, shape: () => t });
} else if (e instanceof j) return new j({ ...e._def, type: M(e.element) });
else if (e instanceof W) return W.create(M(e.unwrap()));
else if (e instanceof G) return G.create(M(e.unwrap()));
else if (e instanceof L) return L.create(e.items.map((e) => M(e)));
else return e;
}
var N = class t extends y {
constructor() {
(super(...arguments),
(this._cached = null),
(this.nonstrict = this.passthrough),
(this.augment = this.extend));
}
_getCached() {
if (this._cached !== null) return this._cached;
let t = this._def.shape(),
n = e.objectKeys(t);
return ((this._cached = { shape: t, keys: n }), this._cached);
}
_parse(e) {
if (this._getType(e) !== n.object) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.object, received: t.parsedType }), d);
}
let { status: t, ctx: r } = this._processInputParams(e),
{ shape: a, keys: o } = this._getCached(),
s = [];
if (!(this._def.catchall instanceof A && this._def.unknownKeys === `strip`))
for (let e in r.data) o.includes(e) || s.push(e);
let c = [];
for (let e of o) {
let t = a[e],
n = r.data[e];
c.push({
key: { status: `valid`, value: e },
value: t._parse(new _(r, n, r.path, e)),
alwaysSet: e in r.data,
});
}
if (this._def.catchall instanceof A) {
let e = this._def.unknownKeys;
if (e === `passthrough`)
for (let e of s)
c.push({
key: { status: `valid`, value: e },
value: { status: `valid`, value: r.data[e] },
});
else if (e === `strict`)
s.length > 0 && (l(r, { code: i.unrecognized_keys, keys: s }), t.dirty());
else if (e !== `strip`) throw Error(`Internal ZodObject error: invalid unknownKeys value.`);
} else {
let e = this._def.catchall;
for (let t of s) {
let n = r.data[t];
c.push({
key: { status: `valid`, value: t },
value: e._parse(new _(r, n, r.path, t)),
alwaysSet: t in r.data,
});
}
}
return r.common.async
? Promise.resolve()
.then(async () => {
let e = [];
for (let t of c) {
let n = await t.key,
r = await t.value;
e.push({ key: n, value: r, alwaysSet: t.alwaysSet });
}
return e;
})
.then((e) => u.mergeObjectSync(t, e))
: u.mergeObjectSync(t, c);
}
get shape() {
return this._def.shape();
}
strict(e) {
return (
g.errToObj,
new t({
...this._def,
unknownKeys: `strict`,
...(e === void 0
? {}
: {
errorMap: (t, n) => {
let r = this._def.errorMap?.(t, n).message ?? n.defaultError;
return t.code === `unrecognized_keys`
? { message: g.errToObj(e).message ?? r }
: { message: r };
},
}),
})
);
}
strip() {
return new t({ ...this._def, unknownKeys: `strip` });
}
passthrough() {
return new t({ ...this._def, unknownKeys: `passthrough` });
}
extend(e) {
return new t({ ...this._def, shape: () => ({ ...this._def.shape(), ...e }) });
}
merge(e) {
return new t({
unknownKeys: e._def.unknownKeys,
catchall: e._def.catchall,
shape: () => ({ ...this._def.shape(), ...e._def.shape() }),
typeName: X.ZodObject,
});
}
setKey(e, t) {
return this.augment({ [e]: t });
}
catchall(e) {
return new t({ ...this._def, catchall: e });
}
pick(n) {
let r = {};
for (let t of e.objectKeys(n)) n[t] && this.shape[t] && (r[t] = this.shape[t]);
return new t({ ...this._def, shape: () => r });
}
omit(n) {
let r = {};
for (let t of e.objectKeys(this.shape)) n[t] || (r[t] = this.shape[t]);
return new t({ ...this._def, shape: () => r });
}
deepPartial() {
return M(this);
}
partial(n) {
let r = {};
for (let t of e.objectKeys(this.shape)) {
let e = this.shape[t];
n && !n[t] ? (r[t] = e) : (r[t] = e.optional());
}
return new t({ ...this._def, shape: () => r });
}
required(n) {
let r = {};
for (let t of e.objectKeys(this.shape))
if (n && !n[t]) r[t] = this.shape[t];
else {
let e = this.shape[t];
for (; e instanceof W;) e = e._def.innerType;
r[t] = e;
}
return new t({ ...this._def, shape: () => r });
}
keyof() {
return Fe(e.objectKeys(this.shape));
}
};
((N.create = (e, t) =>
new N({
shape: () => e,
unknownKeys: `strip`,
catchall: A.create(),
typeName: X.ZodObject,
...v(t),
})),
(N.strictCreate = (e, t) =>
new N({
shape: () => e,
unknownKeys: `strict`,
catchall: A.create(),
typeName: X.ZodObject,
...v(t),
})),
(N.lazycreate = (e, t) =>
new N({
shape: e,
unknownKeys: `strip`,
catchall: A.create(),
typeName: X.ZodObject,
...v(t),
})));
var P = class extends y {
_parse(e) {
let { ctx: t } = this._processInputParams(e),
n = this._def.options;
function r(e) {
for (let t of e) if (t.result.status === `valid`) return t.result;
for (let n of e)
if (n.result.status === `dirty`)
return (t.common.issues.push(...n.ctx.common.issues), n.result);
let n = e.map((e) => new a(e.ctx.common.issues));
return (l(t, { code: i.invalid_union, unionErrors: n }), d);
}
if (t.common.async)
return Promise.all(
n.map(async (e) => {
let n = { ...t, common: { ...t.common, issues: [] }, parent: null };
return { result: await e._parseAsync({ data: t.data, path: t.path, parent: n }), ctx: n };
}),
).then(r);
{
let e,
r = [];
for (let i of n) {
let n = { ...t, common: { ...t.common, issues: [] }, parent: null },
a = i._parseSync({ data: t.data, path: t.path, parent: n });
if (a.status === `valid`) return a;
(a.status === `dirty` && !e && (e = { result: a, ctx: n }),
n.common.issues.length && r.push(n.common.issues));
}
if (e) return (t.common.issues.push(...e.ctx.common.issues), e.result);
let o = r.map((e) => new a(e));
return (l(t, { code: i.invalid_union, unionErrors: o }), d);
}
}
get options() {
return this._def.options;
}
};
P.create = (e, t) => new P({ options: e, typeName: X.ZodUnion, ...v(t) });
const F = (t) =>
t instanceof R
? F(t.schema)
: t instanceof U
? F(t.innerType())
: t instanceof z
? [t.value]
: t instanceof B
? t.options
: t instanceof V
? e.objectValues(t.enum)
: t instanceof K
? F(t._def.innerType)
: t instanceof E
? [void 0]
: t instanceof D
? [null]
: t instanceof W
? [void 0, ...F(t.unwrap())]
: t instanceof G
? [null, ...F(t.unwrap())]
: t instanceof Ie || t instanceof Y
? F(t.unwrap())
: t instanceof q
? F(t._def.innerType)
: [];
var ke = class e extends y {
_parse(e) {
let { ctx: t } = this._processInputParams(e);
if (t.parsedType !== n.object)
return (l(t, { code: i.invalid_type, expected: n.object, received: t.parsedType }), d);
let r = this.discriminator,
a = t.data[r],
o = this.optionsMap.get(a);
return o
? t.common.async
? o._parseAsync({ data: t.data, path: t.path, parent: t })
: o._parseSync({ data: t.data, path: t.path, parent: t })
: (l(t, {
code: i.invalid_union_discriminator,
options: Array.from(this.optionsMap.keys()),
path: [r],
}),
d);
}
get discriminator() {
return this._def.discriminator;
}
get options() {
return this._def.options;
}
get optionsMap() {
return this._def.optionsMap;
}
static create(t, n, r) {
let i = new Map();
for (let e of n) {
let n = F(e.shape[t]);
if (!n.length)
throw Error(
`A discriminator value for key \`${t}\` could not be extracted from all schema options`,
);
for (let r of n) {
if (i.has(r))
throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);
i.set(r, e);
}
}
return new e({
typeName: X.ZodDiscriminatedUnion,
discriminator: t,
options: n,
optionsMap: i,
...v(r),
});
}
};
function Ae(t, i) {
let a = r(t),
o = r(i);
if (t === i) return { valid: !0, data: t };
if (a === n.object && o === n.object) {
let n = e.objectKeys(i),
r = e.objectKeys(t).filter((e) => n.indexOf(e) !== -1),
a = { ...t, ...i };
for (let e of r) {
let n = Ae(t[e], i[e]);
if (!n.valid) return { valid: !1 };
a[e] = n.data;
}
return { valid: !0, data: a };
} else if (a === n.array && o === n.array) {
if (t.length !== i.length) return { valid: !1 };
let e = [];
for (let n = 0; n < t.length; n++) {
let r = t[n],
a = i[n],
o = Ae(r, a);
if (!o.valid) return { valid: !1 };
e.push(o.data);
}
return { valid: !0, data: e };
} else if (a === n.date && o === n.date && +t == +i) return { valid: !0, data: t };
else return { valid: !1 };
}
var I = class extends y {
_parse(e) {
let { status: t, ctx: n } = this._processInputParams(e),
r = (e, r) => {
if (te(e) || te(r)) return d;
let a = Ae(e.value, r.value);
return a.valid
? ((ne(e) || ne(r)) && t.dirty(), { status: t.value, value: a.data })
: (l(n, { code: i.invalid_intersection_types }), d);
};
return n.common.async
? Promise.all([
this._def.left._parseAsync({ data: n.data, path: n.path, parent: n }),
this._def.right._parseAsync({ data: n.data, path: n.path, parent: n }),
]).then(([e, t]) => r(e, t))
: r(
this._def.left._parseSync({ data: n.data, path: n.path, parent: n }),
this._def.right._parseSync({ data: n.data, path: n.path, parent: n }),
);
}
};
I.create = (e, t, n) => new I({ left: e, right: t, typeName: X.ZodIntersection, ...v(n) });
var L = class e extends y {
_parse(e) {
let { status: t, ctx: r } = this._processInputParams(e);
if (r.parsedType !== n.array)
return (l(r, { code: i.invalid_type, expected: n.array, received: r.parsedType }), d);
if (r.data.length < this._def.items.length)
return (
l(r, {
code: i.too_small,
minimum: this._def.items.length,
inclusive: !0,
exact: !1,
type: `array`,
}),
d
);
!this._def.rest &&
r.data.length > this._def.items.length &&
(l(r, {
code: i.too_big,
maximum: this._def.items.length,
inclusive: !0,
exact: !1,
type: `array`,
}),
t.dirty());
let a = [...r.data]
.map((e, t) => {
let n = this._def.items[t] || this._def.rest;
return n ? n._parse(new _(r, e, r.path, t)) : null;
})
.filter((e) => !!e);
return r.common.async ? Promise.all(a).then((e) => u.mergeArray(t, e)) : u.mergeArray(t, a);
}
get items() {
return this._def.items;
}
rest(t) {
return new e({ ...this._def, rest: t });
}
};
L.create = (e, t) => {
if (!Array.isArray(e)) throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);
return new L({ items: e, typeName: X.ZodTuple, rest: null, ...v(t) });
};
var je = class e extends y {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(e) {
let { status: t, ctx: r } = this._processInputParams(e);
if (r.parsedType !== n.object)
return (l(r, { code: i.invalid_type, expected: n.object, received: r.parsedType }), d);
let a = [],
o = this._def.keyType,
s = this._def.valueType;
for (let e in r.data)
a.push({
key: o._parse(new _(r, e, r.path, e)),
value: s._parse(new _(r, r.data[e], r.path, e)),
alwaysSet: e in r.data,
});
return r.common.async ? u.mergeObjectAsync(t, a) : u.mergeObjectSync(t, a);
}
get element() {
return this._def.valueType;
}
static create(t, n, r) {
return n instanceof y
? new e({ keyType: t, valueType: n, typeName: X.ZodRecord, ...v(r) })
: new e({ keyType: b.create(), valueType: t, typeName: X.ZodRecord, ...v(n) });
}
},
Me = class extends y {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(e) {
let { status: t, ctx: r } = this._processInputParams(e);
if (r.parsedType !== n.map)
return (l(r, { code: i.invalid_type, expected: n.map, received: r.parsedType }), d);
let a = this._def.keyType,
o = this._def.valueType,
s = [...r.data.entries()].map(([e, t], n) => ({
key: a._parse(new _(r, e, r.path, [n, `key`])),
value: o._parse(new _(r, t, r.path, [n, `value`])),
}));
if (r.common.async) {
let e = new Map();
return Promise.resolve().then(async () => {
for (let n of s) {
let r = await n.key,
i = await n.value;
if (r.status === `aborted` || i.status === `aborted`) return d;
((r.status === `dirty` || i.status === `dirty`) && t.dirty(), e.set(r.value, i.value));
}
return { status: t.value, value: e };
});
} else {
let e = new Map();
for (let n of s) {
let r = n.key,
i = n.value;
if (r.status === `aborted` || i.status === `aborted`) return d;
((r.status === `dirty` || i.status === `dirty`) && t.dirty(), e.set(r.value, i.value));
}
return { status: t.value, value: e };
}
}
};
Me.create = (e, t, n) => new Me({ valueType: t, keyType: e, typeName: X.ZodMap, ...v(n) });
var Ne = class e extends y {
_parse(e) {
let { status: t, ctx: r } = this._processInputParams(e);
if (r.parsedType !== n.set)
return (l(r, { code: i.invalid_type, expected: n.set, received: r.parsedType }), d);
let a = this._def;
(a.minSize !== null &&
r.data.size < a.minSize.value &&
(l(r, {
code: i.too_small,
minimum: a.minSize.value,
type: `set`,
inclusive: !0,
exact: !1,
message: a.minSize.message,
}),
t.dirty()),
a.maxSize !== null &&
r.data.size > a.maxSize.value &&
(l(r, {
code: i.too_big,
maximum: a.maxSize.value,
type: `set`,
inclusive: !0,
exact: !1,
message: a.maxSize.message,
}),
t.dirty()));
let o = this._def.valueType;
function s(e) {
let n = new Set();
for (let r of e) {
if (r.status === `aborted`) return d;
(r.status === `dirty` && t.dirty(), n.add(r.value));
}
return { status: t.value, value: n };
}
let c = [...r.data.values()].map((e, t) => o._parse(new _(r, e, r.path, t)));
return r.common.async ? Promise.all(c).then((e) => s(e)) : s(c);
}
min(t, n) {
return new e({ ...this._def, minSize: { value: t, message: g.toString(n) } });
}
max(t, n) {
return new e({ ...this._def, maxSize: { value: t, message: g.toString(n) } });
}
size(e, t) {
return this.min(e, t).max(e, t);
}
nonempty(e) {
return this.min(1, e);
}
};
Ne.create = (e, t) =>
new Ne({ valueType: e, minSize: null, maxSize: null, typeName: X.ZodSet, ...v(t) });
var Pe = class e extends y {
constructor() {
(super(...arguments), (this.validate = this.implement));
}
_parse(e) {
let { ctx: t } = this._processInputParams(e);
if (t.parsedType !== n.function)
return (l(t, { code: i.invalid_type, expected: n.function, received: t.parsedType }), d);
function r(e, n) {
return ee({
data: e,
path: t.path,
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, c(), o].filter((e) => !!e),
issueData: { code: i.invalid_arguments, argumentsError: n },
});
}
function s(e, n) {
return ee({
data: e,
path: t.path,
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, c(), o].filter((e) => !!e),
issueData: { code: i.invalid_return_type, returnTypeError: n },
});
}
let u = { errorMap: t.common.contextualErrorMap },
f = t.data;
if (this._def.returns instanceof H) {
let e = this;
return p(async function (...t) {
let n = new a([]),
i = await e._def.args.parseAsync(t, u).catch((e) => {
throw (n.addIssue(r(t, e)), n);
}),
o = await Reflect.apply(f, this, i);
return await e._def.returns._def.type.parseAsync(o, u).catch((e) => {
throw (n.addIssue(s(o, e)), n);
});
});
} else {
let e = this;
return p(function (...t) {
let n = e._def.args.safeParse(t, u);
if (!n.success) throw new a([r(t, n.error)]);
let i = Reflect.apply(f, this, n.data),
o = e._def.returns.safeParse(i, u);
if (!o.success) throw new a([s(i, o.error)]);
return o.data;
});
}
}
parameters() {
return this._def.args;
}
returnType() {
return this._def.returns;
}
args(...t) {
return new e({ ...this._def, args: L.create(t).rest(k.create()) });
}
returns(t) {
return new e({ ...this._def, returns: t });
}
implement(e) {
return this.parse(e);
}
strictImplement(e) {
return this.parse(e);
}
static create(t, n, r) {
return new e({
args: t || L.create([]).rest(k.create()),
returns: n || k.create(),
typeName: X.ZodFunction,
...v(r),
});
}
},
R = class extends y {
get schema() {
return this._def.getter();
}
_parse(e) {
let { ctx: t } = this._processInputParams(e);
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
}
};
R.create = (e, t) => new R({ getter: e, typeName: X.ZodLazy, ...v(t) });
var z = class extends y {
_parse(e) {
if (e.data !== this._def.value) {
let t = this._getOrReturnCtx(e);
return (l(t, { received: t.data, code: i.invalid_literal, expected: this._def.value }), d);
}
return { status: `valid`, value: e.data };
}
get value() {
return this._def.value;
}
};
z.create = (e, t) => new z({ value: e, typeName: X.ZodLiteral, ...v(t) });
function Fe(e, t) {
return new B({ values: e, typeName: X.ZodEnum, ...v(t) });
}
var B = class t extends y {
_parse(t) {
if (typeof t.data != `string`) {
let n = this._getOrReturnCtx(t),
r = this._def.values;
return (l(n, { expected: e.joinValues(r), received: n.parsedType, code: i.invalid_type }), d);
}
if (((this._cache ||= new Set(this._def.values)), !this._cache.has(t.data))) {
let e = this._getOrReturnCtx(t),
n = this._def.values;
return (l(e, { received: e.data, code: i.invalid_enum_value, options: n }), d);
}
return p(t.data);
}
get options() {
return this._def.values;
}
get enum() {
let e = {};
for (let t of this._def.values) e[t] = t;
return e;
}
get Values() {
let e = {};
for (let t of this._def.values) e[t] = t;
return e;
}
get Enum() {
let e = {};
for (let t of this._def.values) e[t] = t;
return e;
}
extract(e, n = this._def) {
return t.create(e, { ...this._def, ...n });
}
exclude(e, n = this._def) {
return t.create(
this.options.filter((t) => !e.includes(t)),
{ ...this._def, ...n },
);
}
};
B.create = Fe;
var V = class extends y {
_parse(t) {
let r = e.getValidEnumValues(this._def.values),
a = this._getOrReturnCtx(t);
if (a.parsedType !== n.string && a.parsedType !== n.number) {
let t = e.objectValues(r);
return (l(a, { expected: e.joinValues(t), received: a.parsedType, code: i.invalid_type }), d);
}
if (
((this._cache ||= new Set(e.getValidEnumValues(this._def.values))), !this._cache.has(t.data))
) {
let t = e.objectValues(r);
return (l(a, { received: a.data, code: i.invalid_enum_value, options: t }), d);
}
return p(t.data);
}
get enum() {
return this._def.values;
}
};
V.create = (e, t) => new V({ values: e, typeName: X.ZodNativeEnum, ...v(t) });
var H = class extends y {
unwrap() {
return this._def.type;
}
_parse(e) {
let { ctx: t } = this._processInputParams(e);
return t.parsedType !== n.promise && t.common.async === !1
? (l(t, { code: i.invalid_type, expected: n.promise, received: t.parsedType }), d)
: p(
(t.parsedType === n.promise ? t.data : Promise.resolve(t.data)).then((e) =>
this._def.type.parseAsync(e, { path: t.path, errorMap: t.common.contextualErrorMap }),
),
);
}
};
H.create = (e, t) => new H({ type: e, typeName: X.ZodPromise, ...v(t) });
var U = class extends y {
innerType() {
return this._def.schema;
}
sourceType() {
return this._def.schema._def.typeName === X.ZodEffects
? this._def.schema.sourceType()
: this._def.schema;
}
_parse(t) {
let { status: n, ctx: r } = this._processInputParams(t),
i = this._def.effect || null,
a = {
addIssue: (e) => {
(l(r, e), e.fatal ? n.abort() : n.dirty());
},
get path() {
return r.path;
},
};
if (((a.addIssue = a.addIssue.bind(a)), i.type === `preprocess`)) {
let e = i.transform(r.data, a);
if (r.common.async)
return Promise.resolve(e).then(async (e) => {
if (n.value === `aborted`) return d;
let t = await this._def.schema._parseAsync({ data: e, path: r.path, parent: r });
return t.status === `aborted`
? d
: t.status === `dirty` || n.value === `dirty`
? f(t.value)
: t;
});
{
if (n.value === `aborted`) return d;
let t = this._def.schema._parseSync({ data: e, path: r.path, parent: r });
return t.status === `aborted`
? d
: t.status === `dirty` || n.value === `dirty`
? f(t.value)
: t;
}
}
if (i.type === `refinement`) {
let e = (e) => {
let t = i.refinement(e, a);
if (r.common.async) return Promise.resolve(t);
if (t instanceof Promise)
throw Error(
`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`,
);
return e;
};
if (r.common.async === !1) {
let t = this._def.schema._parseSync({ data: r.data, path: r.path, parent: r });
return t.status === `aborted`
? d
: (t.status === `dirty` && n.dirty(), e(t.value), { status: n.value, value: t.value });
} else
return this._def.schema
._parseAsync({ data: r.data, path: r.path, parent: r })
.then((t) =>
t.status === `aborted`
? d
: (t.status === `dirty` && n.dirty(),
e(t.value).then(() => ({ status: n.value, value: t.value }))),
);
}
if (i.type === `transform`)
if (r.common.async === !1) {
let e = this._def.schema._parseSync({ data: r.data, path: r.path, parent: r });
if (!m(e)) return d;
let t = i.transform(e.value, a);
if (t instanceof Promise)
throw Error(
`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`,
);
return { status: n.value, value: t };
} else
return this._def.schema
._parseAsync({ data: r.data, path: r.path, parent: r })
.then((e) =>
m(e)
? Promise.resolve(i.transform(e.value, a)).then((e) => ({
status: n.value,
value: e,
}))
: d,
);
e.assertNever(i);
}
};
((U.create = (e, t, n) => new U({ schema: e, typeName: X.ZodEffects, effect: t, ...v(n) })),
(U.createWithPreprocess = (e, t, n) =>
new U({
schema: t,
effect: { type: `preprocess`, transform: e },
typeName: X.ZodEffects,
...v(n),
})));
var W = class extends y {
_parse(e) {
return this._getType(e) === n.undefined ? p(void 0) : this._def.innerType._parse(e);
}
unwrap() {
return this._def.innerType;
}
};
W.create = (e, t) => new W({ innerType: e, typeName: X.ZodOptional, ...v(t) });
var G = class extends y {
_parse(e) {
return this._getType(e) === n.null ? p(null) : this._def.innerType._parse(e);
}
unwrap() {
return this._def.innerType;
}
};
G.create = (e, t) => new G({ innerType: e, typeName: X.ZodNullable, ...v(t) });
var K = class extends y {
_parse(e) {
let { ctx: t } = this._processInputParams(e),
r = t.data;
return (
t.parsedType === n.undefined && (r = this._def.defaultValue()),
this._def.innerType._parse({ data: r, path: t.path, parent: t })
);
}
removeDefault() {
return this._def.innerType;
}
};
K.create = (e, t) =>
new K({
innerType: e,
typeName: X.ZodDefault,
defaultValue: typeof t.default == `function` ? t.default : () => t.default,
...v(t),
});
var q = class extends y {
_parse(e) {
let { ctx: t } = this._processInputParams(e),
n = { ...t, common: { ...t.common, issues: [] } },
r = this._def.innerType._parse({ data: n.data, path: n.path, parent: { ...n } });
return h(r)
? r.then((e) => ({
status: `valid`,
value:
e.status === `valid`
? e.value
: this._def.catchValue({
get error() {
return new a(n.common.issues);
},
input: n.data,
}),
}))
: {
status: `valid`,
value:
r.status === `valid`
? r.value
: this._def.catchValue({
get error() {
return new a(n.common.issues);
},
input: n.data,
}),
};
}
removeCatch() {
return this._def.innerType;
}
};
q.create = (e, t) =>
new q({
innerType: e,
typeName: X.ZodCatch,
catchValue: typeof t.catch == `function` ? t.catch : () => t.catch,
...v(t),
});
var J = class extends y {
_parse(e) {
if (this._getType(e) !== n.nan) {
let t = this._getOrReturnCtx(e);
return (l(t, { code: i.invalid_type, expected: n.nan, received: t.parsedType }), d);
}
return { status: `valid`, value: e.data };
}
};
J.create = (e) => new J({ typeName: X.ZodNaN, ...v(e) });
var Ie = class extends y {
_parse(e) {
let { ctx: t } = this._processInputParams(e),
n = t.data;
return this._def.type._parse({ data: n, path: t.path, parent: t });
}
unwrap() {
return this._def.type;
}
},
Le = class e extends y {
_parse(e) {
let { status: t, ctx: n } = this._processInputParams(e);
if (n.common.async)
return (async () => {
let e = await this._def.in._parseAsync({ data: n.data, path: n.path, parent: n });
return e.status === `aborted`
? d
: e.status === `dirty`
? (t.dirty(), f(e.value))
: this._def.out._parseAsync({ data: e.value, path: n.path, parent: n });
})();
{
let e = this._def.in._parseSync({ data: n.data, path: n.path, parent: n });
return e.status === `aborted`
? d
: e.status === `dirty`
? (t.dirty(), { status: `dirty`, value: e.value })
: this._def.out._parseSync({ data: e.value, path: n.path, parent: n });
}
}
static create(t, n) {
return new e({ in: t, out: n, typeName: X.ZodPipeline });
}
},
Y = class extends y {
_parse(e) {
let t = this._def.innerType._parse(e),
n = (e) => (m(e) && (e.value = Object.freeze(e.value)), e);
return h(t) ? t.then((e) => n(e)) : n(t);
}
unwrap() {
return this._def.innerType;
}
};
((Y.create = (e, t) => new Y({ innerType: e, typeName: X.ZodReadonly, ...v(t) })), N.lazycreate);
var X;
(function (e) {
((e.ZodString = `ZodString`),
(e.ZodNumber = `ZodNumber`),
(e.ZodNaN = `ZodNaN`),
(e.ZodBigInt = `ZodBigInt`),
(e.ZodBoolean = `ZodBoolean`),
(e.ZodDate = `ZodDate`),
(e.ZodSymbol = `ZodSymbol`),
(e.ZodUndefined = `ZodUndefined`),
(e.ZodNull = `ZodNull`),
(e.ZodAny = `ZodAny`),
(e.ZodUnknown = `ZodUnknown`),
(e.ZodNever = `ZodNever`),
(e.ZodVoid = `ZodVoid`),
(e.ZodArray = `ZodArray`),
(e.ZodObject = `ZodObject`),
(e.ZodUnion = `ZodUnion`),
(e.ZodDiscriminatedUnion = `ZodDiscriminatedUnion`),
(e.ZodIntersection = `ZodIntersection`),
(e.ZodTuple = `ZodTuple`),
(e.ZodRecord = `ZodRecord`),
(e.ZodMap = `ZodMap`),
(e.ZodSet = `ZodSet`),
(e.ZodFunction = `ZodFunction`),
(e.ZodLazy = `ZodLazy`),
(e.ZodLiteral = `ZodLiteral`),
(e.ZodEnum = `ZodEnum`),
(e.ZodEffects = `ZodEffects`),
(e.ZodNativeEnum = `ZodNativeEnum`),
(e.ZodOptional = `ZodOptional`),
(e.ZodNullable = `ZodNullable`),
(e.ZodDefault = `ZodDefault`),
(e.ZodCatch = `ZodCatch`),
(e.ZodPromise = `ZodPromise`),
(e.ZodBranded = `ZodBranded`),
(e.ZodPipeline = `ZodPipeline`),
(e.ZodReadonly = `ZodReadonly`));
})((X ||= {}));
const Z = b.create,
Q = x.create;
(J.create, S.create, C.create);
const Re = w.create;
(T.create, E.create, D.create, O.create, k.create, A.create, Oe.create);
const $ = j.create,
ze = N.create;
(N.strictCreate,
P.create,
ke.create,
I.create,
L.create,
je.create,
Me.create,
Ne.create,
Pe.create,
R.create,
z.create);
const Be = B.create;
(V.create, H.create, U.create, W.create, G.create, U.createWithPreprocess, Le.create);
const Ve = ze({
id: Q(),
created: Re(),
title: Z().min(1).max(100),
type: Be([`jpg`, `png`]),
size: Q(),
url: Z().url(),
}),
He = ze({
id: Q(),
stars: Q().min(0).max(5),
title: Z().min(1).max(100),
text: Z().min(1).max(1e3),
images: $(Ve),
});
ze({
id: Q(),
created: Re(),
title: Z().min(1).max(100),
brand: Z().min(1).max(30),
description: Z().min(1).max(500),
price: Q().min(1).max(1e4),
discount: Q().min(1).max(100).nullable(),
quantity: Q().min(0).max(10),
tags: $(Z().min(1).max(30)),
images: $(Ve),
ratings: $(He),
}).parse({});