function getEnumValues(f) {
	let j = Object.values(f).filter((f) => typeof f == "number");
	return Object.entries(f).filter(([f, M]) => j.indexOf(+f) === -1).map(([f, j]) => j);
}
function jsonStringifyReplacer(f, j) {
	return typeof j == "bigint" ? j.toString() : j;
}
function cached(f) {
	return { get value() {
		{
			let j = f();
			return Object.defineProperty(this, "value", { value: j }), j;
		}
		throw Error("cached value already set");
	} };
}
function nullish(f) {
	return f == null;
}
function cleanRegex(f) {
	let j = f.startsWith("^") ? 1 : 0, M = f.endsWith("$") ? f.length - 1 : f.length;
	return f.slice(j, M);
}
function floatSafeRemainder(f, j) {
	let M = (f.toString().split(".")[1] || "").length, N = j.toString(), P = (N.split(".")[1] || "").length;
	if (P === 0 && /\d?e-\d?/.test(N)) {
		let f = N.match(/\d?e-(\d?)/);
		f?.[1] && (P = Number.parseInt(f[1]));
	}
	let F = M > P ? M : P;
	return Number.parseInt(f.toFixed(F).replace(".", "")) % Number.parseInt(j.toFixed(F).replace(".", "")) / 10 ** F;
}
var EVALUATING = Symbol("evaluating");
function defineLazy(f, j, M) {
	let N;
	Object.defineProperty(f, j, {
		get() {
			if (N !== EVALUATING) return N === void 0 && (N = EVALUATING, N = M()), N;
		},
		set(M) {
			Object.defineProperty(f, j, { value: M });
		},
		configurable: !0
	});
}
function assignProp(f, j, M) {
	Object.defineProperty(f, j, {
		value: M,
		writable: !0,
		enumerable: !0,
		configurable: !0
	});
}
function mergeDefs(...f) {
	let j = {};
	for (let M of f) {
		let f = Object.getOwnPropertyDescriptors(M);
		Object.assign(j, f);
	}
	return Object.defineProperties({}, j);
}
function esc(f) {
	return JSON.stringify(f);
}
function slugify(f) {
	return f.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (...f) => {};
function isObject(f) {
	return typeof f == "object" && !!f && !Array.isArray(f);
}
const allowsEval = cached(() => {
	if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare")) return !1;
	try {
		return Function(""), !0;
	} catch {
		return !1;
	}
});
function isPlainObject(f) {
	if (isObject(f) === !1) return !1;
	let j = f.constructor;
	if (j === void 0 || typeof j != "function") return !0;
	let M = j.prototype;
	return !(isObject(M) === !1 || Object.prototype.hasOwnProperty.call(M, "isPrototypeOf") === !1);
}
function shallowClone(f) {
	return isPlainObject(f) ? { ...f } : Array.isArray(f) ? [...f] : f;
}
const propertyKeyTypes = new Set([
	"string",
	"number",
	"symbol"
]);
function escapeRegex(f) {
	return f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(f, j, M) {
	let N = new f._zod.constr(j ?? f._zod.def);
	return (!j || M?.parent) && (N._zod.parent = f), N;
}
function normalizeParams(f) {
	let j = f;
	if (!j) return {};
	if (typeof j == "string") return { error: () => j };
	if (j?.message !== void 0) {
		if (j?.error !== void 0) throw Error("Cannot specify both `message` and `error` params");
		j.error = j.message;
	}
	return delete j.message, typeof j.error == "string" ? {
		...j,
		error: () => j.error
	} : j;
}
function optionalKeys(f) {
	return Object.keys(f).filter((j) => f[j]._zod.optin === "optional" && f[j]._zod.optout === "optional");
}
const NUMBER_FORMAT_RANGES = {
	safeint: [-(2 ** 53 - 1), 2 ** 53 - 1],
	int32: [-2147483648, 2147483647],
	uint32: [0, 4294967295],
	float32: [-34028234663852886e22, 34028234663852886e22],
	float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
};
function pick(f, j) {
	let M = f._zod.def, N = M.checks;
	if (N && N.length > 0) throw Error(".pick() cannot be used on object schemas containing refinements");
	return clone(f, mergeDefs(f._zod.def, {
		get shape() {
			let f = {};
			for (let N in j) {
				if (!(N in M.shape)) throw Error(`Unrecognized key: "${N}"`);
				j[N] && (f[N] = M.shape[N]);
			}
			return assignProp(this, "shape", f), f;
		},
		checks: []
	}));
}
function omit(f, j) {
	let M = f._zod.def, N = M.checks;
	if (N && N.length > 0) throw Error(".omit() cannot be used on object schemas containing refinements");
	return clone(f, mergeDefs(f._zod.def, {
		get shape() {
			let N = { ...f._zod.def.shape };
			for (let f in j) {
				if (!(f in M.shape)) throw Error(`Unrecognized key: "${f}"`);
				j[f] && delete N[f];
			}
			return assignProp(this, "shape", N), N;
		},
		checks: []
	}));
}
function extend(f, j) {
	if (!isPlainObject(j)) throw Error("Invalid input to extend: expected a plain object");
	let M = f._zod.def.checks;
	if (M && M.length > 0) {
		let M = f._zod.def.shape;
		for (let f in j) if (Object.getOwnPropertyDescriptor(M, f) !== void 0) throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
	}
	return clone(f, mergeDefs(f._zod.def, { get shape() {
		let M = {
			...f._zod.def.shape,
			...j
		};
		return assignProp(this, "shape", M), M;
	} }));
}
function safeExtend(f, j) {
	if (!isPlainObject(j)) throw Error("Invalid input to safeExtend: expected a plain object");
	return clone(f, mergeDefs(f._zod.def, { get shape() {
		let M = {
			...f._zod.def.shape,
			...j
		};
		return assignProp(this, "shape", M), M;
	} }));
}
function merge(f, j) {
	return clone(f, mergeDefs(f._zod.def, {
		get shape() {
			let M = {
				...f._zod.def.shape,
				...j._zod.def.shape
			};
			return assignProp(this, "shape", M), M;
		},
		get catchall() {
			return j._zod.def.catchall;
		},
		checks: []
	}));
}
function partial(f, j, M) {
	let N = j._zod.def.checks;
	if (N && N.length > 0) throw Error(".partial() cannot be used on object schemas containing refinements");
	return clone(j, mergeDefs(j._zod.def, {
		get shape() {
			let N = j._zod.def.shape, P = { ...N };
			if (M) for (let j in M) {
				if (!(j in N)) throw Error(`Unrecognized key: "${j}"`);
				M[j] && (P[j] = f ? new f({
					type: "optional",
					innerType: N[j]
				}) : N[j]);
			}
			else for (let j in N) P[j] = f ? new f({
				type: "optional",
				innerType: N[j]
			}) : N[j];
			return assignProp(this, "shape", P), P;
		},
		checks: []
	}));
}
function required(f, j, M) {
	return clone(j, mergeDefs(j._zod.def, { get shape() {
		let N = j._zod.def.shape, P = { ...N };
		if (M) for (let j in M) {
			if (!(j in P)) throw Error(`Unrecognized key: "${j}"`);
			M[j] && (P[j] = new f({
				type: "nonoptional",
				innerType: N[j]
			}));
		}
		else for (let j in N) P[j] = new f({
			type: "nonoptional",
			innerType: N[j]
		});
		return assignProp(this, "shape", P), P;
	} }));
}
function aborted(f, j = 0) {
	if (f.aborted === !0) return !0;
	for (let M = j; M < f.issues.length; M++) if (f.issues[M]?.continue !== !0) return !0;
	return !1;
}
function prefixIssues(f, j) {
	return j.map((j) => {
		var M;
		return (M = j).path ?? (M.path = []), j.path.unshift(f), j;
	});
}
function unwrapMessage(f) {
	return typeof f == "string" ? f : f?.message;
}
function finalizeIssue(f, j, M) {
	let N = {
		...f,
		path: f.path ?? []
	};
	return f.message || (N.message = unwrapMessage(f.inst?._zod.def?.error?.(f)) ?? unwrapMessage(j?.error?.(f)) ?? unwrapMessage(M.customError?.(f)) ?? unwrapMessage(M.localeError?.(f)) ?? "Invalid input"), delete N.inst, delete N.continue, j?.reportInput || delete N.input, N;
}
function getLengthableOrigin(f) {
	return Array.isArray(f) ? "array" : typeof f == "string" ? "string" : "unknown";
}
function issue(...f) {
	let [j, M, N] = f;
	return typeof j == "string" ? {
		message: j,
		code: "custom",
		input: M,
		inst: N
	} : { ...j };
}
export { NUMBER_FORMAT_RANGES, aborted, allowsEval, cached, captureStackTrace, cleanRegex, clone, defineLazy, esc, escapeRegex, extend, finalizeIssue, floatSafeRemainder, getEnumValues, getLengthableOrigin, isObject, isPlainObject, issue, jsonStringifyReplacer, merge, mergeDefs, normalizeParams, nullish, omit, optionalKeys, partial, pick, prefixIssues, propertyKeyTypes, required, safeExtend, shallowClone, slugify };
