import { optimizeImageToWebP, optimizeImages } from "./optimizeImage";
import { optimizeVideoToMp4 } from "./optimizeVideo";

export async function optimizeMediaFile(
  file: File,
  onProgress?: (pct: number) => void
): Promise<File> {
  if (file.type.startsWith("image/")) {
    return optimizeImageToWebP(file);
  }
  if (file.type.startsWith("video/")) {
    return optimizeVideoToMp4(file, onProgress);
  }
  return file;
}

export { optimizeImageToWebP, optimizeImages, optimizeVideoToMp4 };
