import { z } from "@hono/zod-openapi";

//#region src/domains/run/types/chat.ts
const ImageUrlSchema = z.union([z.httpUrl(), z.string().regex(/^data:image\/(png|jpeg|jpg|webp);base64,/, "Image must be PNG, JPEG, or WebP format (GIF not supported by all providers)").refine((val) => {
	const base64Part = val.split(",")[1];
	return /^[A-Za-z0-9+/]+={0,2}$/.test(base64Part ?? "");
}, "Invalid base64 data in image data URI")]);
/** OpenAI-specific image detail level. Has no effect on other providers. */
const ImageDetailEnum = [
	"auto",
	"low",
	"high"
];
const ImageDetailSchema = z.enum(ImageDetailEnum);
const ImageContentItemSchema = z.object({
	type: z.literal("image_url"),
	image_url: z.object({
		url: ImageUrlSchema,
		detail: ImageDetailSchema.optional()
	})
});

//#endregion
export { ImageContentItemSchema, ImageDetailEnum, ImageDetailSchema, ImageUrlSchema };