import { parseJsonc } from "../common.js";
import { parse } from "../toml.js";
import { parseSingleYaml, parseYaml } from "../yaml.js";
import JSON5 from "json5";
import { z } from "zod/v4";

//#region lib/util/schema-utils/v4.ts
const Json = z.string().transform((str, ctx) => {
	try {
		return JSON.parse(str);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid JSON"
		});
		return z.NEVER;
	}
});
const Json5 = z.string().transform((str, ctx) => {
	try {
		return JSON5.parse(str);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid JSON5"
		});
		return z.NEVER;
	}
});
const Jsonc = z.string().transform((str, ctx) => {
	try {
		return parseJsonc(str);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid JSONC"
		});
		return z.NEVER;
	}
});
const Yaml = z.string().transform((str, ctx) => {
	try {
		return parseSingleYaml(str);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid YAML"
		});
		return z.NEVER;
	}
});
const MultidocYaml = z.string().transform((str, ctx) => {
	try {
		return parseYaml(str);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid YAML"
		});
		return z.NEVER;
	}
});
const Toml = z.string().transform((str, ctx) => {
	try {
		return parse(str);
	} catch {
		ctx.addIssue({
			code: "custom",
			message: "Invalid TOML"
		});
		return z.NEVER;
	}
});

//#endregion
export { Json };
//# sourceMappingURL=v4.js.map