import { ZodParsedType, getParsedType, util } from "./helpers/util.js";
import { ZodError, ZodIssueCode } from "./ZodError.js";
import en_default from "./locales/en.js";
import { getErrorMap } from "./errors.js";
import { DIRTY, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue } from "./helpers/parseUtil.js";
import { errorUtil } from "./helpers/errorUtil.js";
var ParseInputLazyPath = class {
	constructor(m, U, W, G) {
		this._cachedPath = [], this.parent = m, this.data = U, this._path = W, this._key = G;
	}
	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;
	}
}, handleResult = (m, U) => {
	if (isValid(U)) return {
		success: !0,
		data: U.value
	};
	if (!m.common.issues.length) throw Error("Validation failed but no issues detected.");
	return {
		success: !1,
		get error() {
			return this._error ||= new ZodError(m.common.issues), this._error;
		}
	};
};
function processCreateParams(m) {
	if (!m) return {};
	let { errorMap: U, invalid_type_error: W, required_error: G, description: K } = m;
	if (U && (W || G)) throw Error("Can't use \"invalid_type_error\" or \"required_error\" in conjunction with custom error map.");
	return U ? {
		errorMap: U,
		description: K
	} : {
		errorMap: (U, K) => {
			let { message: q } = m;
			return U.code === "invalid_enum_value" ? { message: q ?? K.defaultError } : K.data === void 0 ? { message: q ?? G ?? K.defaultError } : U.code === "invalid_type" ? { message: q ?? W ?? K.defaultError } : { message: K.defaultError };
		},
		description: K
	};
}
var ZodType = class {
	get description() {
		return this._def.description;
	}
	_getType(m) {
		return getParsedType(m.data);
	}
	_getOrReturnCtx(m, W) {
		return W || {
			common: m.parent.common,
			data: m.data,
			parsedType: getParsedType(m.data),
			schemaErrorMap: this._def.errorMap,
			path: m.path,
			parent: m.parent
		};
	}
	_processInputParams(m) {
		return {
			status: new ParseStatus(),
			ctx: {
				common: m.parent.common,
				data: m.data,
				parsedType: getParsedType(m.data),
				schemaErrorMap: this._def.errorMap,
				path: m.path,
				parent: m.parent
			}
		};
	}
	_parseSync(m) {
		let U = this._parse(m);
		if (isAsync(U)) throw Error("Synchronous parse encountered promise.");
		return U;
	}
	_parseAsync(m) {
		let U = this._parse(m);
		return Promise.resolve(U);
	}
	parse(m, U) {
		let W = this.safeParse(m, U);
		if (W.success) return W.data;
		throw W.error;
	}
	safeParse(m, W) {
		let G = {
			common: {
				issues: [],
				async: W?.async ?? !1,
				contextualErrorMap: W?.errorMap
			},
			path: W?.path || [],
			schemaErrorMap: this._def.errorMap,
			parent: null,
			data: m,
			parsedType: getParsedType(m)
		};
		return handleResult(G, this._parseSync({
			data: m,
			path: G.path,
			parent: G
		}));
	}
	"~validate"(m) {
		let W = {
			common: {
				issues: [],
				async: !!this["~standard"].async
			},
			path: [],
			schemaErrorMap: this._def.errorMap,
			parent: null,
			data: m,
			parsedType: getParsedType(m)
		};
		if (!this["~standard"].async) try {
			let U = this._parseSync({
				data: m,
				path: [],
				parent: W
			});
			return isValid(U) ? { value: U.value } : { issues: W.common.issues };
		} catch (m) {
			m?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), W.common = {
				issues: [],
				async: !0
			};
		}
		return this._parseAsync({
			data: m,
			path: [],
			parent: W
		}).then((m) => isValid(m) ? { value: m.value } : { issues: W.common.issues });
	}
	async parseAsync(m, U) {
		let W = await this.safeParseAsync(m, U);
		if (W.success) return W.data;
		throw W.error;
	}
	async safeParseAsync(m, W) {
		let G = {
			common: {
				issues: [],
				contextualErrorMap: W?.errorMap,
				async: !0
			},
			path: W?.path || [],
			schemaErrorMap: this._def.errorMap,
			parent: null,
			data: m,
			parsedType: getParsedType(m)
		}, K = this._parse({
			data: m,
			path: G.path,
			parent: G
		});
		return handleResult(G, await (isAsync(K) ? K : Promise.resolve(K)));
	}
	refine(m, U) {
		let W = (m) => typeof U == "string" || U === void 0 ? { message: U } : typeof U == "function" ? U(m) : U;
		return this._refinement((U, G) => {
			let q = m(U), J = () => G.addIssue({
				code: ZodIssueCode.custom,
				...W(U)
			});
			return typeof Promise < "u" && q instanceof Promise ? q.then((m) => m ? !0 : (J(), !1)) : q ? !0 : (J(), !1);
		});
	}
	refinement(m, U) {
		return this._refinement((W, G) => m(W) ? !0 : (G.addIssue(typeof U == "function" ? U(W, G) : U), !1));
	}
	_refinement(m) {
		return new ZodEffects({
			schema: this,
			typeName: ZodFirstPartyTypeKind.ZodEffects,
			effect: {
				type: "refinement",
				refinement: m
			}
		});
	}
	superRefine(m) {
		return this._refinement(m);
	}
	constructor(m) {
		this.spa = this.safeParseAsync, this._def = m, 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: (m) => this["~validate"](m)
		};
	}
	optional() {
		return ZodOptional.create(this, this._def);
	}
	nullable() {
		return ZodNullable.create(this, this._def);
	}
	nullish() {
		return this.nullable().optional();
	}
	array() {
		return ZodArray.create(this);
	}
	promise() {
		return ZodPromise.create(this, this._def);
	}
	or(m) {
		return ZodUnion.create([this, m], this._def);
	}
	and(m) {
		return ZodIntersection.create(this, m, this._def);
	}
	transform(m) {
		return new ZodEffects({
			...processCreateParams(this._def),
			schema: this,
			typeName: ZodFirstPartyTypeKind.ZodEffects,
			effect: {
				type: "transform",
				transform: m
			}
		});
	}
	default(m) {
		let U = typeof m == "function" ? m : () => m;
		return new ZodDefault({
			...processCreateParams(this._def),
			innerType: this,
			defaultValue: U,
			typeName: ZodFirstPartyTypeKind.ZodDefault
		});
	}
	brand() {
		return new ZodBranded({
			typeName: ZodFirstPartyTypeKind.ZodBranded,
			type: this,
			...processCreateParams(this._def)
		});
	}
	catch(m) {
		let U = typeof m == "function" ? m : () => m;
		return new ZodCatch({
			...processCreateParams(this._def),
			innerType: this,
			catchValue: U,
			typeName: ZodFirstPartyTypeKind.ZodCatch
		});
	}
	describe(m) {
		let U = this.constructor;
		return new U({
			...this._def,
			description: m
		});
	}
	pipe(m) {
		return ZodPipeline.create(this, m);
	}
	readonly() {
		return ZodReadonly.create(this);
	}
	isOptional() {
		return this.safeParse(void 0).success;
	}
	isNullable() {
		return this.safeParse(null).success;
	}
}, cuidRegex = /^c[^\s-]{8,}$/i, cuid2Regex = /^[0-9a-z]+$/, ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i, uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, nanoidRegex = /^[a-z0-9_-]{21}$/i, jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, _emojiRegex = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", emojiRegex, ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, dateRegexSource = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", dateRegex = /* @__PURE__ */ RegExp(`^${dateRegexSource}$`);
function timeRegexSource(m) {
	let U = "[0-5]\\d";
	m.precision ? U = `${U}\\.\\d{${m.precision}}` : m.precision ?? (U = `${U}(\\.\\d+)?`);
	let W = m.precision ? "+" : "?";
	return `([01]\\d|2[0-3]):[0-5]\\d(:${U})${W}`;
}
function timeRegex(m) {
	return /* @__PURE__ */ RegExp(`^${timeRegexSource(m)}$`);
}
function datetimeRegex(m) {
	let U = `${dateRegexSource}T${timeRegexSource(m)}`, W = [];
	return W.push(m.local ? "Z?" : "Z"), m.offset && W.push("([+-]\\d{2}:?\\d{2})"), U = `${U}(${W.join("|")})`, /* @__PURE__ */ RegExp(`^${U}$`);
}
function isValidIP(m, U) {
	return !!((U === "v4" || !U) && ipv4Regex.test(m) || (U === "v6" || !U) && ipv6Regex.test(m));
}
function isValidJWT(m, U) {
	if (!jwtRegex.test(m)) return !1;
	try {
		let [W] = m.split(".");
		if (!W) return !1;
		let G = W.replace(/-/g, "+").replace(/_/g, "/").padEnd(W.length + (4 - W.length % 4) % 4, "="), K = JSON.parse(atob(G));
		return !(typeof K != "object" || !K || "typ" in K && K?.typ !== "JWT" || !K.alg || U && K.alg !== U);
	} catch {
		return !1;
	}
}
function isValidCidr(m, U) {
	return !!((U === "v4" || !U) && ipv4CidrRegex.test(m) || (U === "v6" || !U) && ipv6CidrRegex.test(m));
}
var ZodString = class U extends ZodType {
	_parse(U) {
		if (this._def.coerce && (U.data = String(U.data)), this._getType(U) !== ZodParsedType.string) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.string,
				received: W.parsedType
			}), INVALID;
		}
		let G = new ParseStatus(), q;
		for (let m of this._def.checks) if (m.kind === "min") U.data.length < m.value && (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.too_small,
			minimum: m.value,
			type: "string",
			inclusive: !0,
			exact: !1,
			message: m.message
		}), G.dirty());
		else if (m.kind === "max") U.data.length > m.value && (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.too_big,
			maximum: m.value,
			type: "string",
			inclusive: !0,
			exact: !1,
			message: m.message
		}), G.dirty());
		else if (m.kind === "length") {
			let W = U.data.length > m.value, J = U.data.length < m.value;
			(W || J) && (q = this._getOrReturnCtx(U, q), W ? addIssueToContext(q, {
				code: ZodIssueCode.too_big,
				maximum: m.value,
				type: "string",
				inclusive: !0,
				exact: !0,
				message: m.message
			}) : J && addIssueToContext(q, {
				code: ZodIssueCode.too_small,
				minimum: m.value,
				type: "string",
				inclusive: !0,
				exact: !0,
				message: m.message
			}), G.dirty());
		} else if (m.kind === "email") emailRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "email",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "emoji") emojiRegex ||= new RegExp(_emojiRegex, "u"), emojiRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "emoji",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "uuid") uuidRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "uuid",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "nanoid") nanoidRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "nanoid",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "cuid") cuidRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "cuid",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "cuid2") cuid2Regex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "cuid2",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "ulid") ulidRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "ulid",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty());
		else if (m.kind === "url") try {
			new URL(U.data);
		} catch {
			q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
				validation: "url",
				code: ZodIssueCode.invalid_string,
				message: m.message
			}), G.dirty();
		}
		else m.kind === "regex" ? (m.regex.lastIndex = 0, m.regex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "regex",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty())) : m.kind === "trim" ? U.data = U.data.trim() : m.kind === "includes" ? U.data.includes(m.value, m.position) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.invalid_string,
			validation: {
				includes: m.value,
				position: m.position
			},
			message: m.message
		}), G.dirty()) : m.kind === "toLowerCase" ? U.data = U.data.toLowerCase() : m.kind === "toUpperCase" ? U.data = U.data.toUpperCase() : m.kind === "startsWith" ? U.data.startsWith(m.value) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.invalid_string,
			validation: { startsWith: m.value },
			message: m.message
		}), G.dirty()) : m.kind === "endsWith" ? U.data.endsWith(m.value) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.invalid_string,
			validation: { endsWith: m.value },
			message: m.message
		}), G.dirty()) : m.kind === "datetime" ? datetimeRegex(m).test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.invalid_string,
			validation: "datetime",
			message: m.message
		}), G.dirty()) : m.kind === "date" ? dateRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.invalid_string,
			validation: "date",
			message: m.message
		}), G.dirty()) : m.kind === "time" ? timeRegex(m).test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.invalid_string,
			validation: "time",
			message: m.message
		}), G.dirty()) : m.kind === "duration" ? durationRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "duration",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty()) : m.kind === "ip" ? isValidIP(U.data, m.version) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "ip",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty()) : m.kind === "jwt" ? isValidJWT(U.data, m.alg) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "jwt",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty()) : m.kind === "cidr" ? isValidCidr(U.data, m.version) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "cidr",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty()) : m.kind === "base64" ? base64Regex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "base64",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty()) : m.kind === "base64url" ? base64urlRegex.test(U.data) || (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			validation: "base64url",
			code: ZodIssueCode.invalid_string,
			message: m.message
		}), G.dirty()) : util.assertNever(m);
		return {
			status: G.value,
			value: U.data
		};
	}
	_regex(m, U, W) {
		return this.refinement((U) => m.test(U), {
			validation: U,
			code: ZodIssueCode.invalid_string,
			...errorUtil.errToObj(W)
		});
	}
	_addCheck(m) {
		return new U({
			...this._def,
			checks: [...this._def.checks, m]
		});
	}
	email(m) {
		return this._addCheck({
			kind: "email",
			...errorUtil.errToObj(m)
		});
	}
	url(m) {
		return this._addCheck({
			kind: "url",
			...errorUtil.errToObj(m)
		});
	}
	emoji(m) {
		return this._addCheck({
			kind: "emoji",
			...errorUtil.errToObj(m)
		});
	}
	uuid(m) {
		return this._addCheck({
			kind: "uuid",
			...errorUtil.errToObj(m)
		});
	}
	nanoid(m) {
		return this._addCheck({
			kind: "nanoid",
			...errorUtil.errToObj(m)
		});
	}
	cuid(m) {
		return this._addCheck({
			kind: "cuid",
			...errorUtil.errToObj(m)
		});
	}
	cuid2(m) {
		return this._addCheck({
			kind: "cuid2",
			...errorUtil.errToObj(m)
		});
	}
	ulid(m) {
		return this._addCheck({
			kind: "ulid",
			...errorUtil.errToObj(m)
		});
	}
	base64(m) {
		return this._addCheck({
			kind: "base64",
			...errorUtil.errToObj(m)
		});
	}
	base64url(m) {
		return this._addCheck({
			kind: "base64url",
			...errorUtil.errToObj(m)
		});
	}
	jwt(m) {
		return this._addCheck({
			kind: "jwt",
			...errorUtil.errToObj(m)
		});
	}
	ip(m) {
		return this._addCheck({
			kind: "ip",
			...errorUtil.errToObj(m)
		});
	}
	cidr(m) {
		return this._addCheck({
			kind: "cidr",
			...errorUtil.errToObj(m)
		});
	}
	datetime(m) {
		return typeof m == "string" ? this._addCheck({
			kind: "datetime",
			precision: null,
			offset: !1,
			local: !1,
			message: m
		}) : this._addCheck({
			kind: "datetime",
			precision: m?.precision === void 0 ? null : m?.precision,
			offset: m?.offset ?? !1,
			local: m?.local ?? !1,
			...errorUtil.errToObj(m?.message)
		});
	}
	date(m) {
		return this._addCheck({
			kind: "date",
			message: m
		});
	}
	time(m) {
		return typeof m == "string" ? this._addCheck({
			kind: "time",
			precision: null,
			message: m
		}) : this._addCheck({
			kind: "time",
			precision: m?.precision === void 0 ? null : m?.precision,
			...errorUtil.errToObj(m?.message)
		});
	}
	duration(m) {
		return this._addCheck({
			kind: "duration",
			...errorUtil.errToObj(m)
		});
	}
	regex(m, U) {
		return this._addCheck({
			kind: "regex",
			regex: m,
			...errorUtil.errToObj(U)
		});
	}
	includes(m, U) {
		return this._addCheck({
			kind: "includes",
			value: m,
			position: U?.position,
			...errorUtil.errToObj(U?.message)
		});
	}
	startsWith(m, U) {
		return this._addCheck({
			kind: "startsWith",
			value: m,
			...errorUtil.errToObj(U)
		});
	}
	endsWith(m, U) {
		return this._addCheck({
			kind: "endsWith",
			value: m,
			...errorUtil.errToObj(U)
		});
	}
	min(m, U) {
		return this._addCheck({
			kind: "min",
			value: m,
			...errorUtil.errToObj(U)
		});
	}
	max(m, U) {
		return this._addCheck({
			kind: "max",
			value: m,
			...errorUtil.errToObj(U)
		});
	}
	length(m, U) {
		return this._addCheck({
			kind: "length",
			value: m,
			...errorUtil.errToObj(U)
		});
	}
	nonempty(m) {
		return this.min(1, errorUtil.errToObj(m));
	}
	trim() {
		return new U({
			...this._def,
			checks: [...this._def.checks, { kind: "trim" }]
		});
	}
	toLowerCase() {
		return new U({
			...this._def,
			checks: [...this._def.checks, { kind: "toLowerCase" }]
		});
	}
	toUpperCase() {
		return new U({
			...this._def,
			checks: [...this._def.checks, { kind: "toUpperCase" }]
		});
	}
	get isDatetime() {
		return !!this._def.checks.find((m) => m.kind === "datetime");
	}
	get isDate() {
		return !!this._def.checks.find((m) => m.kind === "date");
	}
	get isTime() {
		return !!this._def.checks.find((m) => m.kind === "time");
	}
	get isDuration() {
		return !!this._def.checks.find((m) => m.kind === "duration");
	}
	get isEmail() {
		return !!this._def.checks.find((m) => m.kind === "email");
	}
	get isURL() {
		return !!this._def.checks.find((m) => m.kind === "url");
	}
	get isEmoji() {
		return !!this._def.checks.find((m) => m.kind === "emoji");
	}
	get isUUID() {
		return !!this._def.checks.find((m) => m.kind === "uuid");
	}
	get isNANOID() {
		return !!this._def.checks.find((m) => m.kind === "nanoid");
	}
	get isCUID() {
		return !!this._def.checks.find((m) => m.kind === "cuid");
	}
	get isCUID2() {
		return !!this._def.checks.find((m) => m.kind === "cuid2");
	}
	get isULID() {
		return !!this._def.checks.find((m) => m.kind === "ulid");
	}
	get isIP() {
		return !!this._def.checks.find((m) => m.kind === "ip");
	}
	get isCIDR() {
		return !!this._def.checks.find((m) => m.kind === "cidr");
	}
	get isBase64() {
		return !!this._def.checks.find((m) => m.kind === "base64");
	}
	get isBase64url() {
		return !!this._def.checks.find((m) => m.kind === "base64url");
	}
	get minLength() {
		let m = null;
		for (let U of this._def.checks) U.kind === "min" && (m === null || U.value > m) && (m = U.value);
		return m;
	}
	get maxLength() {
		let m = null;
		for (let U of this._def.checks) U.kind === "max" && (m === null || U.value < m) && (m = U.value);
		return m;
	}
};
ZodString.create = (m) => new ZodString({
	checks: [],
	typeName: ZodFirstPartyTypeKind.ZodString,
	coerce: m?.coerce ?? !1,
	...processCreateParams(m)
});
function floatSafeRemainder(m, U) {
	let W = (m.toString().split(".")[1] || "").length, G = (U.toString().split(".")[1] || "").length, K = W > G ? W : G;
	return Number.parseInt(m.toFixed(K).replace(".", "")) % Number.parseInt(U.toFixed(K).replace(".", "")) / 10 ** K;
}
var ZodNumber = class U extends ZodType {
	constructor() {
		super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
	}
	_parse(U) {
		if (this._def.coerce && (U.data = Number(U.data)), this._getType(U) !== ZodParsedType.number) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.number,
				received: W.parsedType
			}), INVALID;
		}
		let G, q = new ParseStatus();
		for (let m of this._def.checks) m.kind === "int" ? util.isInteger(U.data) || (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.invalid_type,
			expected: "integer",
			received: "float",
			message: m.message
		}), q.dirty()) : m.kind === "min" ? (m.inclusive ? U.data < m.value : U.data <= m.value) && (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.too_small,
			minimum: m.value,
			type: "number",
			inclusive: m.inclusive,
			exact: !1,
			message: m.message
		}), q.dirty()) : m.kind === "max" ? (m.inclusive ? U.data > m.value : U.data >= m.value) && (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.too_big,
			maximum: m.value,
			type: "number",
			inclusive: m.inclusive,
			exact: !1,
			message: m.message
		}), q.dirty()) : m.kind === "multipleOf" ? floatSafeRemainder(U.data, m.value) !== 0 && (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.not_multiple_of,
			multipleOf: m.value,
			message: m.message
		}), q.dirty()) : m.kind === "finite" ? Number.isFinite(U.data) || (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.not_finite,
			message: m.message
		}), q.dirty()) : util.assertNever(m);
		return {
			status: q.value,
			value: U.data
		};
	}
	gte(m, U) {
		return this.setLimit("min", m, !0, errorUtil.toString(U));
	}
	gt(m, U) {
		return this.setLimit("min", m, !1, errorUtil.toString(U));
	}
	lte(m, U) {
		return this.setLimit("max", m, !0, errorUtil.toString(U));
	}
	lt(m, U) {
		return this.setLimit("max", m, !1, errorUtil.toString(U));
	}
	setLimit(m, W, G, K) {
		return new U({
			...this._def,
			checks: [...this._def.checks, {
				kind: m,
				value: W,
				inclusive: G,
				message: errorUtil.toString(K)
			}]
		});
	}
	_addCheck(m) {
		return new U({
			...this._def,
			checks: [...this._def.checks, m]
		});
	}
	int(m) {
		return this._addCheck({
			kind: "int",
			message: errorUtil.toString(m)
		});
	}
	positive(m) {
		return this._addCheck({
			kind: "min",
			value: 0,
			inclusive: !1,
			message: errorUtil.toString(m)
		});
	}
	negative(m) {
		return this._addCheck({
			kind: "max",
			value: 0,
			inclusive: !1,
			message: errorUtil.toString(m)
		});
	}
	nonpositive(m) {
		return this._addCheck({
			kind: "max",
			value: 0,
			inclusive: !0,
			message: errorUtil.toString(m)
		});
	}
	nonnegative(m) {
		return this._addCheck({
			kind: "min",
			value: 0,
			inclusive: !0,
			message: errorUtil.toString(m)
		});
	}
	multipleOf(m, U) {
		return this._addCheck({
			kind: "multipleOf",
			value: m,
			message: errorUtil.toString(U)
		});
	}
	finite(m) {
		return this._addCheck({
			kind: "finite",
			message: errorUtil.toString(m)
		});
	}
	safe(m) {
		return this._addCheck({
			kind: "min",
			inclusive: !0,
			value: -(2 ** 53 - 1),
			message: errorUtil.toString(m)
		})._addCheck({
			kind: "max",
			inclusive: !0,
			value: 2 ** 53 - 1,
			message: errorUtil.toString(m)
		});
	}
	get minValue() {
		let m = null;
		for (let U of this._def.checks) U.kind === "min" && (m === null || U.value > m) && (m = U.value);
		return m;
	}
	get maxValue() {
		let m = null;
		for (let U of this._def.checks) U.kind === "max" && (m === null || U.value < m) && (m = U.value);
		return m;
	}
	get isInt() {
		return !!this._def.checks.find((m) => m.kind === "int" || m.kind === "multipleOf" && util.isInteger(m.value));
	}
	get isFinite() {
		let m = null, U = null;
		for (let W of this._def.checks) if (W.kind === "finite" || W.kind === "int" || W.kind === "multipleOf") return !0;
		else W.kind === "min" ? (U === null || W.value > U) && (U = W.value) : W.kind === "max" && (m === null || W.value < m) && (m = W.value);
		return Number.isFinite(U) && Number.isFinite(m);
	}
};
ZodNumber.create = (m) => new ZodNumber({
	checks: [],
	typeName: ZodFirstPartyTypeKind.ZodNumber,
	coerce: m?.coerce || !1,
	...processCreateParams(m)
});
var ZodBigInt = class U extends ZodType {
	constructor() {
		super(...arguments), this.min = this.gte, this.max = this.lte;
	}
	_parse(U) {
		if (this._def.coerce) try {
			U.data = BigInt(U.data);
		} catch {
			return this._getInvalidInput(U);
		}
		if (this._getType(U) !== ZodParsedType.bigint) return this._getInvalidInput(U);
		let G, q = new ParseStatus();
		for (let m of this._def.checks) m.kind === "min" ? (m.inclusive ? U.data < m.value : U.data <= m.value) && (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.too_small,
			type: "bigint",
			minimum: m.value,
			inclusive: m.inclusive,
			message: m.message
		}), q.dirty()) : m.kind === "max" ? (m.inclusive ? U.data > m.value : U.data >= m.value) && (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.too_big,
			type: "bigint",
			maximum: m.value,
			inclusive: m.inclusive,
			message: m.message
		}), q.dirty()) : m.kind === "multipleOf" ? U.data % m.value !== BigInt(0) && (G = this._getOrReturnCtx(U, G), addIssueToContext(G, {
			code: ZodIssueCode.not_multiple_of,
			multipleOf: m.value,
			message: m.message
		}), q.dirty()) : util.assertNever(m);
		return {
			status: q.value,
			value: U.data
		};
	}
	_getInvalidInput(U) {
		let W = this._getOrReturnCtx(U);
		return addIssueToContext(W, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.bigint,
			received: W.parsedType
		}), INVALID;
	}
	gte(m, U) {
		return this.setLimit("min", m, !0, errorUtil.toString(U));
	}
	gt(m, U) {
		return this.setLimit("min", m, !1, errorUtil.toString(U));
	}
	lte(m, U) {
		return this.setLimit("max", m, !0, errorUtil.toString(U));
	}
	lt(m, U) {
		return this.setLimit("max", m, !1, errorUtil.toString(U));
	}
	setLimit(m, W, G, K) {
		return new U({
			...this._def,
			checks: [...this._def.checks, {
				kind: m,
				value: W,
				inclusive: G,
				message: errorUtil.toString(K)
			}]
		});
	}
	_addCheck(m) {
		return new U({
			...this._def,
			checks: [...this._def.checks, m]
		});
	}
	positive(m) {
		return this._addCheck({
			kind: "min",
			value: BigInt(0),
			inclusive: !1,
			message: errorUtil.toString(m)
		});
	}
	negative(m) {
		return this._addCheck({
			kind: "max",
			value: BigInt(0),
			inclusive: !1,
			message: errorUtil.toString(m)
		});
	}
	nonpositive(m) {
		return this._addCheck({
			kind: "max",
			value: BigInt(0),
			inclusive: !0,
			message: errorUtil.toString(m)
		});
	}
	nonnegative(m) {
		return this._addCheck({
			kind: "min",
			value: BigInt(0),
			inclusive: !0,
			message: errorUtil.toString(m)
		});
	}
	multipleOf(m, U) {
		return this._addCheck({
			kind: "multipleOf",
			value: m,
			message: errorUtil.toString(U)
		});
	}
	get minValue() {
		let m = null;
		for (let U of this._def.checks) U.kind === "min" && (m === null || U.value > m) && (m = U.value);
		return m;
	}
	get maxValue() {
		let m = null;
		for (let U of this._def.checks) U.kind === "max" && (m === null || U.value < m) && (m = U.value);
		return m;
	}
};
ZodBigInt.create = (m) => new ZodBigInt({
	checks: [],
	typeName: ZodFirstPartyTypeKind.ZodBigInt,
	coerce: m?.coerce ?? !1,
	...processCreateParams(m)
});
var ZodBoolean = class extends ZodType {
	_parse(U) {
		if (this._def.coerce && (U.data = !!U.data), this._getType(U) !== ZodParsedType.boolean) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.boolean,
				received: W.parsedType
			}), INVALID;
		}
		return OK(U.data);
	}
};
ZodBoolean.create = (m) => new ZodBoolean({
	typeName: ZodFirstPartyTypeKind.ZodBoolean,
	coerce: m?.coerce || !1,
	...processCreateParams(m)
});
var ZodDate = class U extends ZodType {
	_parse(U) {
		if (this._def.coerce && (U.data = new Date(U.data)), this._getType(U) !== ZodParsedType.date) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.date,
				received: W.parsedType
			}), INVALID;
		}
		if (Number.isNaN(U.data.getTime())) return addIssueToContext(this._getOrReturnCtx(U), { code: ZodIssueCode.invalid_date }), INVALID;
		let G = new ParseStatus(), q;
		for (let m of this._def.checks) m.kind === "min" ? U.data.getTime() < m.value && (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.too_small,
			message: m.message,
			inclusive: !0,
			exact: !1,
			minimum: m.value,
			type: "date"
		}), G.dirty()) : m.kind === "max" ? U.data.getTime() > m.value && (q = this._getOrReturnCtx(U, q), addIssueToContext(q, {
			code: ZodIssueCode.too_big,
			message: m.message,
			inclusive: !0,
			exact: !1,
			maximum: m.value,
			type: "date"
		}), G.dirty()) : util.assertNever(m);
		return {
			status: G.value,
			value: new Date(U.data.getTime())
		};
	}
	_addCheck(m) {
		return new U({
			...this._def,
			checks: [...this._def.checks, m]
		});
	}
	min(m, U) {
		return this._addCheck({
			kind: "min",
			value: m.getTime(),
			message: errorUtil.toString(U)
		});
	}
	max(m, U) {
		return this._addCheck({
			kind: "max",
			value: m.getTime(),
			message: errorUtil.toString(U)
		});
	}
	get minDate() {
		let m = null;
		for (let U of this._def.checks) U.kind === "min" && (m === null || U.value > m) && (m = U.value);
		return m == null ? null : new Date(m);
	}
	get maxDate() {
		let m = null;
		for (let U of this._def.checks) U.kind === "max" && (m === null || U.value < m) && (m = U.value);
		return m == null ? null : new Date(m);
	}
};
ZodDate.create = (m) => new ZodDate({
	checks: [],
	coerce: m?.coerce || !1,
	typeName: ZodFirstPartyTypeKind.ZodDate,
	...processCreateParams(m)
});
var ZodSymbol = class extends ZodType {
	_parse(U) {
		if (this._getType(U) !== ZodParsedType.symbol) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.symbol,
				received: W.parsedType
			}), INVALID;
		}
		return OK(U.data);
	}
};
ZodSymbol.create = (m) => new ZodSymbol({
	typeName: ZodFirstPartyTypeKind.ZodSymbol,
	...processCreateParams(m)
});
var ZodUndefined = class extends ZodType {
	_parse(U) {
		if (this._getType(U) !== ZodParsedType.undefined) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.undefined,
				received: W.parsedType
			}), INVALID;
		}
		return OK(U.data);
	}
};
ZodUndefined.create = (m) => new ZodUndefined({
	typeName: ZodFirstPartyTypeKind.ZodUndefined,
	...processCreateParams(m)
});
var ZodNull = class extends ZodType {
	_parse(U) {
		if (this._getType(U) !== ZodParsedType.null) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.null,
				received: W.parsedType
			}), INVALID;
		}
		return OK(U.data);
	}
};
ZodNull.create = (m) => new ZodNull({
	typeName: ZodFirstPartyTypeKind.ZodNull,
	...processCreateParams(m)
});
var ZodAny = class extends ZodType {
	constructor() {
		super(...arguments), this._any = !0;
	}
	_parse(m) {
		return OK(m.data);
	}
};
ZodAny.create = (m) => new ZodAny({
	typeName: ZodFirstPartyTypeKind.ZodAny,
	...processCreateParams(m)
});
var ZodUnknown = class extends ZodType {
	constructor() {
		super(...arguments), this._unknown = !0;
	}
	_parse(m) {
		return OK(m.data);
	}
};
ZodUnknown.create = (m) => new ZodUnknown({
	typeName: ZodFirstPartyTypeKind.ZodUnknown,
	...processCreateParams(m)
});
var ZodNever = class extends ZodType {
	_parse(U) {
		let W = this._getOrReturnCtx(U);
		return addIssueToContext(W, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.never,
			received: W.parsedType
		}), INVALID;
	}
};
ZodNever.create = (m) => new ZodNever({
	typeName: ZodFirstPartyTypeKind.ZodNever,
	...processCreateParams(m)
});
var ZodVoid = class extends ZodType {
	_parse(U) {
		if (this._getType(U) !== ZodParsedType.undefined) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.void,
				received: W.parsedType
			}), INVALID;
		}
		return OK(U.data);
	}
};
ZodVoid.create = (m) => new ZodVoid({
	typeName: ZodFirstPartyTypeKind.ZodVoid,
	...processCreateParams(m)
});
var ZodArray = class U extends ZodType {
	_parse(U) {
		let { ctx: W, status: G } = this._processInputParams(U), q = this._def;
		if (W.parsedType !== ZodParsedType.array) return addIssueToContext(W, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.array,
			received: W.parsedType
		}), INVALID;
		if (q.exactLength !== null) {
			let m = W.data.length > q.exactLength.value, U = W.data.length < q.exactLength.value;
			(m || U) && (addIssueToContext(W, {
				code: m ? ZodIssueCode.too_big : ZodIssueCode.too_small,
				minimum: U ? q.exactLength.value : void 0,
				maximum: m ? q.exactLength.value : void 0,
				type: "array",
				inclusive: !0,
				exact: !0,
				message: q.exactLength.message
			}), G.dirty());
		}
		if (q.minLength !== null && W.data.length < q.minLength.value && (addIssueToContext(W, {
			code: ZodIssueCode.too_small,
			minimum: q.minLength.value,
			type: "array",
			inclusive: !0,
			exact: !1,
			message: q.minLength.message
		}), G.dirty()), q.maxLength !== null && W.data.length > q.maxLength.value && (addIssueToContext(W, {
			code: ZodIssueCode.too_big,
			maximum: q.maxLength.value,
			type: "array",
			inclusive: !0,
			exact: !1,
			message: q.maxLength.message
		}), G.dirty()), W.common.async) return Promise.all([...W.data].map((m, U) => q.type._parseAsync(new ParseInputLazyPath(W, m, W.path, U)))).then((m) => ParseStatus.mergeArray(G, m));
		let J = [...W.data].map((m, U) => q.type._parseSync(new ParseInputLazyPath(W, m, W.path, U)));
		return ParseStatus.mergeArray(G, J);
	}
	get element() {
		return this._def.type;
	}
	min(m, W) {
		return new U({
			...this._def,
			minLength: {
				value: m,
				message: errorUtil.toString(W)
			}
		});
	}
	max(m, W) {
		return new U({
			...this._def,
			maxLength: {
				value: m,
				message: errorUtil.toString(W)
			}
		});
	}
	length(m, W) {
		return new U({
			...this._def,
			exactLength: {
				value: m,
				message: errorUtil.toString(W)
			}
		});
	}
	nonempty(m) {
		return this.min(1, m);
	}
};
ZodArray.create = (m, U) => new ZodArray({
	type: m,
	minLength: null,
	maxLength: null,
	exactLength: null,
	typeName: ZodFirstPartyTypeKind.ZodArray,
	...processCreateParams(U)
});
function deepPartialify(m) {
	if (m instanceof ZodObject) {
		let U = {};
		for (let W in m.shape) {
			let G = m.shape[W];
			U[W] = ZodOptional.create(deepPartialify(G));
		}
		return new ZodObject({
			...m._def,
			shape: () => U
		});
	} else if (m instanceof ZodArray) return new ZodArray({
		...m._def,
		type: deepPartialify(m.element)
	});
	else if (m instanceof ZodOptional) return ZodOptional.create(deepPartialify(m.unwrap()));
	else if (m instanceof ZodNullable) return ZodNullable.create(deepPartialify(m.unwrap()));
	else if (m instanceof ZodTuple) return ZodTuple.create(m.items.map((m) => deepPartialify(m)));
	else return m;
}
var ZodObject = class U extends ZodType {
	constructor() {
		super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
	}
	_getCached() {
		if (this._cached !== null) return this._cached;
		let m = this._def.shape();
		return this._cached = {
			shape: m,
			keys: util.objectKeys(m)
		}, this._cached;
	}
	_parse(U) {
		if (this._getType(U) !== ZodParsedType.object) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.object,
				received: W.parsedType
			}), INVALID;
		}
		let { status: W, ctx: G } = this._processInputParams(U), { shape: q, keys: J } = this._getCached(), Y = [];
		if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) for (let m in G.data) J.includes(m) || Y.push(m);
		let X = [];
		for (let m of J) {
			let U = q[m], W = G.data[m];
			X.push({
				key: {
					status: "valid",
					value: m
				},
				value: U._parse(new ParseInputLazyPath(G, W, G.path, m)),
				alwaysSet: m in G.data
			});
		}
		if (this._def.catchall instanceof ZodNever) {
			let m = this._def.unknownKeys;
			if (m === "passthrough") for (let m of Y) X.push({
				key: {
					status: "valid",
					value: m
				},
				value: {
					status: "valid",
					value: G.data[m]
				}
			});
			else if (m === "strict") Y.length > 0 && (addIssueToContext(G, {
				code: ZodIssueCode.unrecognized_keys,
				keys: Y
			}), W.dirty());
			else if (m !== "strip") throw Error("Internal ZodObject error: invalid unknownKeys value.");
		} else {
			let m = this._def.catchall;
			for (let U of Y) {
				let W = G.data[U];
				X.push({
					key: {
						status: "valid",
						value: U
					},
					value: m._parse(new ParseInputLazyPath(G, W, G.path, U)),
					alwaysSet: U in G.data
				});
			}
		}
		return G.common.async ? Promise.resolve().then(async () => {
			let m = [];
			for (let U of X) {
				let W = await U.key, G = await U.value;
				m.push({
					key: W,
					value: G,
					alwaysSet: U.alwaysSet
				});
			}
			return m;
		}).then((m) => ParseStatus.mergeObjectSync(W, m)) : ParseStatus.mergeObjectSync(W, X);
	}
	get shape() {
		return this._def.shape();
	}
	strict(m) {
		return errorUtil.errToObj, new U({
			...this._def,
			unknownKeys: "strict",
			...m === void 0 ? {} : { errorMap: (U, W) => {
				let G = this._def.errorMap?.(U, W).message ?? W.defaultError;
				return U.code === "unrecognized_keys" ? { message: errorUtil.errToObj(m).message ?? G } : { message: G };
			} }
		});
	}
	strip() {
		return new U({
			...this._def,
			unknownKeys: "strip"
		});
	}
	passthrough() {
		return new U({
			...this._def,
			unknownKeys: "passthrough"
		});
	}
	extend(m) {
		return new U({
			...this._def,
			shape: () => ({
				...this._def.shape(),
				...m
			})
		});
	}
	merge(m) {
		return new U({
			unknownKeys: m._def.unknownKeys,
			catchall: m._def.catchall,
			shape: () => ({
				...this._def.shape(),
				...m._def.shape()
			}),
			typeName: ZodFirstPartyTypeKind.ZodObject
		});
	}
	setKey(m, U) {
		return this.augment({ [m]: U });
	}
	catchall(m) {
		return new U({
			...this._def,
			catchall: m
		});
	}
	pick(m) {
		let G = {};
		for (let U of util.objectKeys(m)) m[U] && this.shape[U] && (G[U] = this.shape[U]);
		return new U({
			...this._def,
			shape: () => G
		});
	}
	omit(m) {
		let G = {};
		for (let U of util.objectKeys(this.shape)) m[U] || (G[U] = this.shape[U]);
		return new U({
			...this._def,
			shape: () => G
		});
	}
	deepPartial() {
		return deepPartialify(this);
	}
	partial(m) {
		let G = {};
		for (let U of util.objectKeys(this.shape)) {
			let W = this.shape[U];
			m && !m[U] ? G[U] = W : G[U] = W.optional();
		}
		return new U({
			...this._def,
			shape: () => G
		});
	}
	required(m) {
		let G = {};
		for (let U of util.objectKeys(this.shape)) if (m && !m[U]) G[U] = this.shape[U];
		else {
			let m = this.shape[U];
			for (; m instanceof ZodOptional;) m = m._def.innerType;
			G[U] = m;
		}
		return new U({
			...this._def,
			shape: () => G
		});
	}
	keyof() {
		return createZodEnum(util.objectKeys(this.shape));
	}
};
ZodObject.create = (m, U) => new ZodObject({
	shape: () => m,
	unknownKeys: "strip",
	catchall: ZodNever.create(),
	typeName: ZodFirstPartyTypeKind.ZodObject,
	...processCreateParams(U)
}), ZodObject.strictCreate = (m, U) => new ZodObject({
	shape: () => m,
	unknownKeys: "strict",
	catchall: ZodNever.create(),
	typeName: ZodFirstPartyTypeKind.ZodObject,
	...processCreateParams(U)
}), ZodObject.lazycreate = (m, U) => new ZodObject({
	shape: m,
	unknownKeys: "strip",
	catchall: ZodNever.create(),
	typeName: ZodFirstPartyTypeKind.ZodObject,
	...processCreateParams(U)
});
var ZodUnion = class extends ZodType {
	_parse(m) {
		let { ctx: U } = this._processInputParams(m), W = this._def.options;
		function q(m) {
			for (let U of m) if (U.result.status === "valid") return U.result;
			for (let W of m) if (W.result.status === "dirty") return U.common.issues.push(...W.ctx.common.issues), W.result;
			let W = m.map((m) => new ZodError(m.ctx.common.issues));
			return addIssueToContext(U, {
				code: ZodIssueCode.invalid_union,
				unionErrors: W
			}), INVALID;
		}
		if (U.common.async) return Promise.all(W.map(async (m) => {
			let W = {
				...U,
				common: {
					...U.common,
					issues: []
				},
				parent: null
			};
			return {
				result: await m._parseAsync({
					data: U.data,
					path: U.path,
					parent: W
				}),
				ctx: W
			};
		})).then(q);
		{
			let m, q = [];
			for (let G of W) {
				let W = {
					...U,
					common: {
						...U.common,
						issues: []
					},
					parent: null
				}, K = G._parseSync({
					data: U.data,
					path: U.path,
					parent: W
				});
				if (K.status === "valid") return K;
				K.status === "dirty" && !m && (m = {
					result: K,
					ctx: W
				}), W.common.issues.length && q.push(W.common.issues);
			}
			if (m) return U.common.issues.push(...m.ctx.common.issues), m.result;
			let J = q.map((m) => new ZodError(m));
			return addIssueToContext(U, {
				code: ZodIssueCode.invalid_union,
				unionErrors: J
			}), INVALID;
		}
	}
	get options() {
		return this._def.options;
	}
};
ZodUnion.create = (m, U) => new ZodUnion({
	options: m,
	typeName: ZodFirstPartyTypeKind.ZodUnion,
	...processCreateParams(U)
});
var getDiscriminator = (m) => m instanceof ZodLazy ? getDiscriminator(m.schema) : m instanceof ZodEffects ? getDiscriminator(m.innerType()) : m instanceof ZodLiteral ? [m.value] : m instanceof ZodEnum ? m.options : m instanceof ZodNativeEnum ? util.objectValues(m.enum) : m instanceof ZodDefault ? getDiscriminator(m._def.innerType) : m instanceof ZodUndefined ? [void 0] : m instanceof ZodNull ? [null] : m instanceof ZodOptional ? [void 0, ...getDiscriminator(m.unwrap())] : m instanceof ZodNullable ? [null, ...getDiscriminator(m.unwrap())] : m instanceof ZodBranded || m instanceof ZodReadonly ? getDiscriminator(m.unwrap()) : m instanceof ZodCatch ? getDiscriminator(m._def.innerType) : [], ZodDiscriminatedUnion = class U extends ZodType {
	_parse(U) {
		let { ctx: W } = this._processInputParams(U);
		if (W.parsedType !== ZodParsedType.object) return addIssueToContext(W, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.object,
			received: W.parsedType
		}), INVALID;
		let G = this.discriminator, q = W.data[G], J = this.optionsMap.get(q);
		return J ? W.common.async ? J._parseAsync({
			data: W.data,
			path: W.path,
			parent: W
		}) : J._parseSync({
			data: W.data,
			path: W.path,
			parent: W
		}) : (addIssueToContext(W, {
			code: ZodIssueCode.invalid_union_discriminator,
			options: Array.from(this.optionsMap.keys()),
			path: [G]
		}), INVALID);
	}
	get discriminator() {
		return this._def.discriminator;
	}
	get options() {
		return this._def.options;
	}
	get optionsMap() {
		return this._def.optionsMap;
	}
	static create(m, W, G) {
		let K = /* @__PURE__ */ new Map();
		for (let U of W) {
			let W = getDiscriminator(U.shape[m]);
			if (!W.length) throw Error(`A discriminator value for key \`${m}\` could not be extracted from all schema options`);
			for (let G of W) {
				if (K.has(G)) throw Error(`Discriminator property ${String(m)} has duplicate value ${String(G)}`);
				K.set(G, U);
			}
		}
		return new U({
			typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
			discriminator: m,
			options: W,
			optionsMap: K,
			...processCreateParams(G)
		});
	}
};
function mergeValues(G, K) {
	let q = getParsedType(G), J = getParsedType(K);
	if (G === K) return {
		valid: !0,
		data: G
	};
	if (q === ZodParsedType.object && J === ZodParsedType.object) {
		let m = util.objectKeys(K), U = util.objectKeys(G).filter((U) => m.indexOf(U) !== -1), q = {
			...G,
			...K
		};
		for (let m of U) {
			let U = mergeValues(G[m], K[m]);
			if (!U.valid) return { valid: !1 };
			q[m] = U.data;
		}
		return {
			valid: !0,
			data: q
		};
	} else if (q === ZodParsedType.array && J === ZodParsedType.array) {
		if (G.length !== K.length) return { valid: !1 };
		let m = [];
		for (let U = 0; U < G.length; U++) {
			let W = G[U], q = K[U], J = mergeValues(W, q);
			if (!J.valid) return { valid: !1 };
			m.push(J.data);
		}
		return {
			valid: !0,
			data: m
		};
	} else if (q === ZodParsedType.date && J === ZodParsedType.date && +G == +K) return {
		valid: !0,
		data: G
	};
	else return { valid: !1 };
}
var ZodIntersection = class extends ZodType {
	_parse(m) {
		let { status: U, ctx: W } = this._processInputParams(m), G = (m, G) => {
			if (isAborted(m) || isAborted(G)) return INVALID;
			let q = mergeValues(m.value, G.value);
			return q.valid ? ((isDirty(m) || isDirty(G)) && U.dirty(), {
				status: U.value,
				value: q.data
			}) : (addIssueToContext(W, { code: ZodIssueCode.invalid_intersection_types }), INVALID);
		};
		return W.common.async ? Promise.all([this._def.left._parseAsync({
			data: W.data,
			path: W.path,
			parent: W
		}), this._def.right._parseAsync({
			data: W.data,
			path: W.path,
			parent: W
		})]).then(([m, U]) => G(m, U)) : G(this._def.left._parseSync({
			data: W.data,
			path: W.path,
			parent: W
		}), this._def.right._parseSync({
			data: W.data,
			path: W.path,
			parent: W
		}));
	}
};
ZodIntersection.create = (m, U, W) => new ZodIntersection({
	left: m,
	right: U,
	typeName: ZodFirstPartyTypeKind.ZodIntersection,
	...processCreateParams(W)
});
var ZodTuple = class U extends ZodType {
	_parse(U) {
		let { status: W, ctx: G } = this._processInputParams(U);
		if (G.parsedType !== ZodParsedType.array) return addIssueToContext(G, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.array,
			received: G.parsedType
		}), INVALID;
		if (G.data.length < this._def.items.length) return addIssueToContext(G, {
			code: ZodIssueCode.too_small,
			minimum: this._def.items.length,
			inclusive: !0,
			exact: !1,
			type: "array"
		}), INVALID;
		!this._def.rest && G.data.length > this._def.items.length && (addIssueToContext(G, {
			code: ZodIssueCode.too_big,
			maximum: this._def.items.length,
			inclusive: !0,
			exact: !1,
			type: "array"
		}), W.dirty());
		let q = [...G.data].map((m, U) => {
			let W = this._def.items[U] || this._def.rest;
			return W ? W._parse(new ParseInputLazyPath(G, m, G.path, U)) : null;
		}).filter((m) => !!m);
		return G.common.async ? Promise.all(q).then((m) => ParseStatus.mergeArray(W, m)) : ParseStatus.mergeArray(W, q);
	}
	get items() {
		return this._def.items;
	}
	rest(m) {
		return new U({
			...this._def,
			rest: m
		});
	}
};
ZodTuple.create = (m, U) => {
	if (!Array.isArray(m)) throw Error("You must pass an array of schemas to z.tuple([ ... ])");
	return new ZodTuple({
		items: m,
		typeName: ZodFirstPartyTypeKind.ZodTuple,
		rest: null,
		...processCreateParams(U)
	});
};
var ZodRecord = class U extends ZodType {
	get keySchema() {
		return this._def.keyType;
	}
	get valueSchema() {
		return this._def.valueType;
	}
	_parse(U) {
		let { status: W, ctx: G } = this._processInputParams(U);
		if (G.parsedType !== ZodParsedType.object) return addIssueToContext(G, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.object,
			received: G.parsedType
		}), INVALID;
		let q = [], J = this._def.keyType, Y = this._def.valueType;
		for (let m in G.data) q.push({
			key: J._parse(new ParseInputLazyPath(G, m, G.path, m)),
			value: Y._parse(new ParseInputLazyPath(G, G.data[m], G.path, m)),
			alwaysSet: m in G.data
		});
		return G.common.async ? ParseStatus.mergeObjectAsync(W, q) : ParseStatus.mergeObjectSync(W, q);
	}
	get element() {
		return this._def.valueType;
	}
	static create(m, W, G) {
		return W instanceof ZodType ? new U({
			keyType: m,
			valueType: W,
			typeName: ZodFirstPartyTypeKind.ZodRecord,
			...processCreateParams(G)
		}) : new U({
			keyType: ZodString.create(),
			valueType: m,
			typeName: ZodFirstPartyTypeKind.ZodRecord,
			...processCreateParams(W)
		});
	}
}, ZodMap = class extends ZodType {
	get keySchema() {
		return this._def.keyType;
	}
	get valueSchema() {
		return this._def.valueType;
	}
	_parse(U) {
		let { status: W, ctx: G } = this._processInputParams(U);
		if (G.parsedType !== ZodParsedType.map) return addIssueToContext(G, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.map,
			received: G.parsedType
		}), INVALID;
		let q = this._def.keyType, J = this._def.valueType, Y = [...G.data.entries()].map(([m, U], W) => ({
			key: q._parse(new ParseInputLazyPath(G, m, G.path, [W, "key"])),
			value: J._parse(new ParseInputLazyPath(G, U, G.path, [W, "value"]))
		}));
		if (G.common.async) {
			let m = /* @__PURE__ */ new Map();
			return Promise.resolve().then(async () => {
				for (let U of Y) {
					let G = await U.key, K = await U.value;
					if (G.status === "aborted" || K.status === "aborted") return INVALID;
					(G.status === "dirty" || K.status === "dirty") && W.dirty(), m.set(G.value, K.value);
				}
				return {
					status: W.value,
					value: m
				};
			});
		} else {
			let m = /* @__PURE__ */ new Map();
			for (let U of Y) {
				let G = U.key, K = U.value;
				if (G.status === "aborted" || K.status === "aborted") return INVALID;
				(G.status === "dirty" || K.status === "dirty") && W.dirty(), m.set(G.value, K.value);
			}
			return {
				status: W.value,
				value: m
			};
		}
	}
};
ZodMap.create = (m, U, W) => new ZodMap({
	valueType: U,
	keyType: m,
	typeName: ZodFirstPartyTypeKind.ZodMap,
	...processCreateParams(W)
});
var ZodSet = class U extends ZodType {
	_parse(U) {
		let { status: W, ctx: G } = this._processInputParams(U);
		if (G.parsedType !== ZodParsedType.set) return addIssueToContext(G, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.set,
			received: G.parsedType
		}), INVALID;
		let q = this._def;
		q.minSize !== null && G.data.size < q.minSize.value && (addIssueToContext(G, {
			code: ZodIssueCode.too_small,
			minimum: q.minSize.value,
			type: "set",
			inclusive: !0,
			exact: !1,
			message: q.minSize.message
		}), W.dirty()), q.maxSize !== null && G.data.size > q.maxSize.value && (addIssueToContext(G, {
			code: ZodIssueCode.too_big,
			maximum: q.maxSize.value,
			type: "set",
			inclusive: !0,
			exact: !1,
			message: q.maxSize.message
		}), W.dirty());
		let J = this._def.valueType;
		function Y(m) {
			let U = /* @__PURE__ */ new Set();
			for (let G of m) {
				if (G.status === "aborted") return INVALID;
				G.status === "dirty" && W.dirty(), U.add(G.value);
			}
			return {
				status: W.value,
				value: U
			};
		}
		let X = [...G.data.values()].map((m, U) => J._parse(new ParseInputLazyPath(G, m, G.path, U)));
		return G.common.async ? Promise.all(X).then((m) => Y(m)) : Y(X);
	}
	min(m, W) {
		return new U({
			...this._def,
			minSize: {
				value: m,
				message: errorUtil.toString(W)
			}
		});
	}
	max(m, W) {
		return new U({
			...this._def,
			maxSize: {
				value: m,
				message: errorUtil.toString(W)
			}
		});
	}
	size(m, U) {
		return this.min(m, U).max(m, U);
	}
	nonempty(m) {
		return this.min(1, m);
	}
};
ZodSet.create = (m, U) => new ZodSet({
	valueType: m,
	minSize: null,
	maxSize: null,
	typeName: ZodFirstPartyTypeKind.ZodSet,
	...processCreateParams(U)
});
var ZodFunction = class U extends ZodType {
	constructor() {
		super(...arguments), this.validate = this.implement;
	}
	_parse(U) {
		let { ctx: W } = this._processInputParams(U);
		if (W.parsedType !== ZodParsedType.function) return addIssueToContext(W, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.function,
			received: W.parsedType
		}), INVALID;
		function Y(m, U) {
			return makeIssue({
				data: m,
				path: W.path,
				errorMaps: [
					W.common.contextualErrorMap,
					W.schemaErrorMap,
					getErrorMap(),
					en_default
				].filter((m) => !!m),
				issueData: {
					code: ZodIssueCode.invalid_arguments,
					argumentsError: U
				}
			});
		}
		function Z(m, U) {
			return makeIssue({
				data: m,
				path: W.path,
				errorMaps: [
					W.common.contextualErrorMap,
					W.schemaErrorMap,
					getErrorMap(),
					en_default
				].filter((m) => !!m),
				issueData: {
					code: ZodIssueCode.invalid_return_type,
					returnTypeError: U
				}
			});
		}
		let Q = { errorMap: W.common.contextualErrorMap }, $ = W.data;
		if (this._def.returns instanceof ZodPromise) {
			let m = this;
			return OK(async function(...U) {
				let W = new ZodError([]), K = await m._def.args.parseAsync(U, Q).catch((m) => {
					throw W.addIssue(Y(U, m)), W;
				}), q = await Reflect.apply($, this, K);
				return await m._def.returns._def.type.parseAsync(q, Q).catch((m) => {
					throw W.addIssue(Z(q, m)), W;
				});
			});
		} else {
			let m = this;
			return OK(function(...U) {
				let W = m._def.args.safeParse(U, Q);
				if (!W.success) throw new ZodError([Y(U, W.error)]);
				let K = Reflect.apply($, this, W.data), q = m._def.returns.safeParse(K, Q);
				if (!q.success) throw new ZodError([Z(K, q.error)]);
				return q.data;
			});
		}
	}
	parameters() {
		return this._def.args;
	}
	returnType() {
		return this._def.returns;
	}
	args(...m) {
		return new U({
			...this._def,
			args: ZodTuple.create(m).rest(ZodUnknown.create())
		});
	}
	returns(m) {
		return new U({
			...this._def,
			returns: m
		});
	}
	implement(m) {
		return this.parse(m);
	}
	strictImplement(m) {
		return this.parse(m);
	}
	static create(m, W, G) {
		return new U({
			args: m || ZodTuple.create([]).rest(ZodUnknown.create()),
			returns: W || ZodUnknown.create(),
			typeName: ZodFirstPartyTypeKind.ZodFunction,
			...processCreateParams(G)
		});
	}
}, ZodLazy = class extends ZodType {
	get schema() {
		return this._def.getter();
	}
	_parse(m) {
		let { ctx: U } = this._processInputParams(m);
		return this._def.getter()._parse({
			data: U.data,
			path: U.path,
			parent: U
		});
	}
};
ZodLazy.create = (m, U) => new ZodLazy({
	getter: m,
	typeName: ZodFirstPartyTypeKind.ZodLazy,
	...processCreateParams(U)
});
var ZodLiteral = class extends ZodType {
	_parse(m) {
		if (m.data !== this._def.value) {
			let U = this._getOrReturnCtx(m);
			return addIssueToContext(U, {
				received: U.data,
				code: ZodIssueCode.invalid_literal,
				expected: this._def.value
			}), INVALID;
		}
		return {
			status: "valid",
			value: m.data
		};
	}
	get value() {
		return this._def.value;
	}
};
ZodLiteral.create = (m, U) => new ZodLiteral({
	value: m,
	typeName: ZodFirstPartyTypeKind.ZodLiteral,
	...processCreateParams(U)
});
function createZodEnum(m, U) {
	return new ZodEnum({
		values: m,
		typeName: ZodFirstPartyTypeKind.ZodEnum,
		...processCreateParams(U)
	});
}
var ZodEnum = class m extends ZodType {
	_parse(m) {
		if (typeof m.data != "string") {
			let U = this._getOrReturnCtx(m), G = this._def.values;
			return addIssueToContext(U, {
				expected: util.joinValues(G),
				received: U.parsedType,
				code: ZodIssueCode.invalid_type
			}), INVALID;
		}
		if (this._cache ||= new Set(this._def.values), !this._cache.has(m.data)) {
			let U = this._getOrReturnCtx(m), W = this._def.values;
			return addIssueToContext(U, {
				received: U.data,
				code: ZodIssueCode.invalid_enum_value,
				options: W
			}), INVALID;
		}
		return OK(m.data);
	}
	get options() {
		return this._def.values;
	}
	get enum() {
		let m = {};
		for (let U of this._def.values) m[U] = U;
		return m;
	}
	get Values() {
		let m = {};
		for (let U of this._def.values) m[U] = U;
		return m;
	}
	get Enum() {
		let m = {};
		for (let U of this._def.values) m[U] = U;
		return m;
	}
	extract(U, W = this._def) {
		return m.create(U, {
			...this._def,
			...W
		});
	}
	exclude(U, W = this._def) {
		return m.create(this.options.filter((m) => !U.includes(m)), {
			...this._def,
			...W
		});
	}
};
ZodEnum.create = createZodEnum;
var ZodNativeEnum = class extends ZodType {
	_parse(U) {
		let G = util.getValidEnumValues(this._def.values), q = this._getOrReturnCtx(U);
		if (q.parsedType !== ZodParsedType.string && q.parsedType !== ZodParsedType.number) {
			let m = util.objectValues(G);
			return addIssueToContext(q, {
				expected: util.joinValues(m),
				received: q.parsedType,
				code: ZodIssueCode.invalid_type
			}), INVALID;
		}
		if (this._cache ||= new Set(util.getValidEnumValues(this._def.values)), !this._cache.has(U.data)) {
			let m = util.objectValues(G);
			return addIssueToContext(q, {
				received: q.data,
				code: ZodIssueCode.invalid_enum_value,
				options: m
			}), INVALID;
		}
		return OK(U.data);
	}
	get enum() {
		return this._def.values;
	}
};
ZodNativeEnum.create = (m, U) => new ZodNativeEnum({
	values: m,
	typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
	...processCreateParams(U)
});
var ZodPromise = class extends ZodType {
	unwrap() {
		return this._def.type;
	}
	_parse(U) {
		let { ctx: W } = this._processInputParams(U);
		return W.parsedType !== ZodParsedType.promise && W.common.async === !1 ? (addIssueToContext(W, {
			code: ZodIssueCode.invalid_type,
			expected: ZodParsedType.promise,
			received: W.parsedType
		}), INVALID) : OK((W.parsedType === ZodParsedType.promise ? W.data : Promise.resolve(W.data)).then((m) => this._def.type.parseAsync(m, {
			path: W.path,
			errorMap: W.common.contextualErrorMap
		})));
	}
};
ZodPromise.create = (m, U) => new ZodPromise({
	type: m,
	typeName: ZodFirstPartyTypeKind.ZodPromise,
	...processCreateParams(U)
});
var ZodEffects = class extends ZodType {
	innerType() {
		return this._def.schema;
	}
	sourceType() {
		return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
	}
	_parse(m) {
		let { status: U, ctx: G } = this._processInputParams(m), K = this._def.effect || null, q = {
			addIssue: (m) => {
				addIssueToContext(G, m), m.fatal ? U.abort() : U.dirty();
			},
			get path() {
				return G.path;
			}
		};
		if (q.addIssue = q.addIssue.bind(q), K.type === "preprocess") {
			let m = K.transform(G.data, q);
			if (G.common.async) return Promise.resolve(m).then(async (m) => {
				if (U.value === "aborted") return INVALID;
				let W = await this._def.schema._parseAsync({
					data: m,
					path: G.path,
					parent: G
				});
				return W.status === "aborted" ? INVALID : W.status === "dirty" || U.value === "dirty" ? DIRTY(W.value) : W;
			});
			{
				if (U.value === "aborted") return INVALID;
				let W = this._def.schema._parseSync({
					data: m,
					path: G.path,
					parent: G
				});
				return W.status === "aborted" ? INVALID : W.status === "dirty" || U.value === "dirty" ? DIRTY(W.value) : W;
			}
		}
		if (K.type === "refinement") {
			let m = (m) => {
				let U = K.refinement(m, q);
				if (G.common.async) return Promise.resolve(U);
				if (U instanceof Promise) throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
				return m;
			};
			if (G.common.async === !1) {
				let W = this._def.schema._parseSync({
					data: G.data,
					path: G.path,
					parent: G
				});
				return W.status === "aborted" ? INVALID : (W.status === "dirty" && U.dirty(), m(W.value), {
					status: U.value,
					value: W.value
				});
			} else return this._def.schema._parseAsync({
				data: G.data,
				path: G.path,
				parent: G
			}).then((W) => W.status === "aborted" ? INVALID : (W.status === "dirty" && U.dirty(), m(W.value).then(() => ({
				status: U.value,
				value: W.value
			}))));
		}
		if (K.type === "transform") if (G.common.async === !1) {
			let m = this._def.schema._parseSync({
				data: G.data,
				path: G.path,
				parent: G
			});
			if (!isValid(m)) return INVALID;
			let W = K.transform(m.value, q);
			if (W instanceof Promise) throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
			return {
				status: U.value,
				value: W
			};
		} else return this._def.schema._parseAsync({
			data: G.data,
			path: G.path,
			parent: G
		}).then((m) => isValid(m) ? Promise.resolve(K.transform(m.value, q)).then((m) => ({
			status: U.value,
			value: m
		})) : INVALID);
		util.assertNever(K);
	}
};
ZodEffects.create = (m, U, W) => new ZodEffects({
	schema: m,
	typeName: ZodFirstPartyTypeKind.ZodEffects,
	effect: U,
	...processCreateParams(W)
}), ZodEffects.createWithPreprocess = (m, U, W) => new ZodEffects({
	schema: U,
	effect: {
		type: "preprocess",
		transform: m
	},
	typeName: ZodFirstPartyTypeKind.ZodEffects,
	...processCreateParams(W)
});
var ZodOptional = class extends ZodType {
	_parse(U) {
		return this._getType(U) === ZodParsedType.undefined ? OK(void 0) : this._def.innerType._parse(U);
	}
	unwrap() {
		return this._def.innerType;
	}
};
ZodOptional.create = (m, U) => new ZodOptional({
	innerType: m,
	typeName: ZodFirstPartyTypeKind.ZodOptional,
	...processCreateParams(U)
});
var ZodNullable = class extends ZodType {
	_parse(U) {
		return this._getType(U) === ZodParsedType.null ? OK(null) : this._def.innerType._parse(U);
	}
	unwrap() {
		return this._def.innerType;
	}
};
ZodNullable.create = (m, U) => new ZodNullable({
	innerType: m,
	typeName: ZodFirstPartyTypeKind.ZodNullable,
	...processCreateParams(U)
});
var ZodDefault = class extends ZodType {
	_parse(U) {
		let { ctx: W } = this._processInputParams(U), G = W.data;
		return W.parsedType === ZodParsedType.undefined && (G = this._def.defaultValue()), this._def.innerType._parse({
			data: G,
			path: W.path,
			parent: W
		});
	}
	removeDefault() {
		return this._def.innerType;
	}
};
ZodDefault.create = (m, U) => new ZodDefault({
	innerType: m,
	typeName: ZodFirstPartyTypeKind.ZodDefault,
	defaultValue: typeof U.default == "function" ? U.default : () => U.default,
	...processCreateParams(U)
});
var ZodCatch = class extends ZodType {
	_parse(m) {
		let { ctx: U } = this._processInputParams(m), W = {
			...U,
			common: {
				...U.common,
				issues: []
			}
		}, K = this._def.innerType._parse({
			data: W.data,
			path: W.path,
			parent: { ...W }
		});
		return isAsync(K) ? K.then((m) => ({
			status: "valid",
			value: m.status === "valid" ? m.value : this._def.catchValue({
				get error() {
					return new ZodError(W.common.issues);
				},
				input: W.data
			})
		})) : {
			status: "valid",
			value: K.status === "valid" ? K.value : this._def.catchValue({
				get error() {
					return new ZodError(W.common.issues);
				},
				input: W.data
			})
		};
	}
	removeCatch() {
		return this._def.innerType;
	}
};
ZodCatch.create = (m, U) => new ZodCatch({
	innerType: m,
	typeName: ZodFirstPartyTypeKind.ZodCatch,
	catchValue: typeof U.catch == "function" ? U.catch : () => U.catch,
	...processCreateParams(U)
});
var ZodNaN = class extends ZodType {
	_parse(U) {
		if (this._getType(U) !== ZodParsedType.nan) {
			let W = this._getOrReturnCtx(U);
			return addIssueToContext(W, {
				code: ZodIssueCode.invalid_type,
				expected: ZodParsedType.nan,
				received: W.parsedType
			}), INVALID;
		}
		return {
			status: "valid",
			value: U.data
		};
	}
};
ZodNaN.create = (m) => new ZodNaN({
	typeName: ZodFirstPartyTypeKind.ZodNaN,
	...processCreateParams(m)
});
var ZodBranded = class extends ZodType {
	_parse(m) {
		let { ctx: U } = this._processInputParams(m), W = U.data;
		return this._def.type._parse({
			data: W,
			path: U.path,
			parent: U
		});
	}
	unwrap() {
		return this._def.type;
	}
}, ZodPipeline = class m extends ZodType {
	_parse(m) {
		let { status: U, ctx: W } = this._processInputParams(m);
		if (W.common.async) return (async () => {
			let m = await this._def.in._parseAsync({
				data: W.data,
				path: W.path,
				parent: W
			});
			return m.status === "aborted" ? INVALID : m.status === "dirty" ? (U.dirty(), DIRTY(m.value)) : this._def.out._parseAsync({
				data: m.value,
				path: W.path,
				parent: W
			});
		})();
		{
			let m = this._def.in._parseSync({
				data: W.data,
				path: W.path,
				parent: W
			});
			return m.status === "aborted" ? INVALID : m.status === "dirty" ? (U.dirty(), {
				status: "dirty",
				value: m.value
			}) : this._def.out._parseSync({
				data: m.value,
				path: W.path,
				parent: W
			});
		}
	}
	static create(U, W) {
		return new m({
			in: U,
			out: W,
			typeName: ZodFirstPartyTypeKind.ZodPipeline
		});
	}
}, ZodReadonly = class extends ZodType {
	_parse(m) {
		let U = this._def.innerType._parse(m), W = (m) => (isValid(m) && (m.value = Object.freeze(m.value)), m);
		return isAsync(U) ? U.then((m) => W(m)) : W(U);
	}
	unwrap() {
		return this._def.innerType;
	}
};
ZodReadonly.create = (m, U) => new ZodReadonly({
	innerType: m,
	typeName: ZodFirstPartyTypeKind.ZodReadonly,
	...processCreateParams(U)
}), ZodObject.lazycreate;
var ZodFirstPartyTypeKind;
(function(m) {
	m.ZodString = "ZodString", m.ZodNumber = "ZodNumber", m.ZodNaN = "ZodNaN", m.ZodBigInt = "ZodBigInt", m.ZodBoolean = "ZodBoolean", m.ZodDate = "ZodDate", m.ZodSymbol = "ZodSymbol", m.ZodUndefined = "ZodUndefined", m.ZodNull = "ZodNull", m.ZodAny = "ZodAny", m.ZodUnknown = "ZodUnknown", m.ZodNever = "ZodNever", m.ZodVoid = "ZodVoid", m.ZodArray = "ZodArray", m.ZodObject = "ZodObject", m.ZodUnion = "ZodUnion", m.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", m.ZodIntersection = "ZodIntersection", m.ZodTuple = "ZodTuple", m.ZodRecord = "ZodRecord", m.ZodMap = "ZodMap", m.ZodSet = "ZodSet", m.ZodFunction = "ZodFunction", m.ZodLazy = "ZodLazy", m.ZodLiteral = "ZodLiteral", m.ZodEnum = "ZodEnum", m.ZodEffects = "ZodEffects", m.ZodNativeEnum = "ZodNativeEnum", m.ZodOptional = "ZodOptional", m.ZodNullable = "ZodNullable", m.ZodDefault = "ZodDefault", m.ZodCatch = "ZodCatch", m.ZodPromise = "ZodPromise", m.ZodBranded = "ZodBranded", m.ZodPipeline = "ZodPipeline", m.ZodReadonly = "ZodReadonly";
})(ZodFirstPartyTypeKind ||= {}), ZodString.create, ZodNumber.create, ZodNaN.create, ZodBigInt.create, ZodBoolean.create, ZodDate.create, ZodSymbol.create, ZodUndefined.create, ZodNull.create, ZodAny.create, ZodUnknown.create, ZodNever.create, ZodVoid.create, ZodArray.create, ZodObject.create, ZodObject.strictCreate, ZodUnion.create, ZodDiscriminatedUnion.create, ZodIntersection.create, ZodTuple.create, ZodRecord.create, ZodMap.create, ZodSet.create, ZodFunction.create, ZodLazy.create, ZodLiteral.create, ZodEnum.create, ZodNativeEnum.create, ZodPromise.create, ZodEffects.create, ZodOptional.create, ZodNullable.create, ZodEffects.createWithPreprocess, ZodPipeline.create;
export { ZodFirstPartyTypeKind };
