import * as fs from "fs";

const zodPath = "src/lib/client/zod.gen.ts";
let content = fs.readFileSync(zodPath, "utf8");
// Replace only for the upload schema
const zodTarget = "upload_file: z.string";
while (content.includes(zodTarget)) {
    content = content.replace(zodTarget, "upload_file: z.any");
}
fs.writeFileSync(zodPath, content);
console.log("✅ Fixed zod schema for upload_file");

const utilsPath = "src/lib/client/client/utils.ts";
content = fs.readFileSync(utilsPath, "utf8");

const utilsTarget = "@ts-expect-error";
while (content.includes(utilsTarget)) {
    content = content.replace(utilsTarget, "@ts-ignore");
}
content = content.replace(
    "...(mergedHeaders[key] ?? []),",
    "...(mergedHeaders[key] ?? []) as any,"
);
fs.writeFileSync(utilsPath, content);
console.log("✅ Fixed utils.ts");
