

const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
const require_ZodValidationError = require('../error/ZodValidationError.js');
require('../error/index.js');
let zod = require("zod");
zod = require_rolldown_runtime.__toESM(zod);

//#region src/utils/zod.ts
function zParseWithErrorHandling(schema, data, customErrorMessage) {
	const parseResult = schema.safeParse(data);
	if (!parseResult.success) throw new require_ZodValidationError.ZodValidationError(customErrorMessage ?? `Error validating schema with data ${JSON.stringify(data)}`, parseResult.error);
	return parseResult.data;
}
const zUniqueArray = (item) => zod.z.array(item).refine((a) => new Set(a).size === a.length, "Array must have unique values");
const zOptionalToUndefined = (item) => zod.z.optional(item.transform(() => void 0));
const zBase64Url = zod.z.string().regex(/[a-zA-Z0-9_-]+/, "Must be a base64url string");

//#endregion
exports.zBase64Url = zBase64Url;
exports.zOptionalToUndefined = zOptionalToUndefined;
exports.zParseWithErrorHandling = zParseWithErrorHandling;
exports.zUniqueArray = zUniqueArray;