/**
 * The platform's image rule (PDF p.22 / p.26 / p.42): JPG, PNG or WEBP, at most
 * 10 MB each — the same as the server's `ImageUploadRules::image()`
 * (`mimes:jpg,jpeg,png,webp`, `max:10240`), which every opportunity, event and
 * completion-gallery image goes through.
 */
export const IMAGE_UPLOAD_TYPES = ["image/jpeg", "image/png", "image/webp"] as const;
export const IMAGE_UPLOAD_ACCEPT = IMAGE_UPLOAD_TYPES.join(",");
export const IMAGE_UPLOAD_MAX_BYTES = 10 * 1024 * 1024;

/** Whether one picked file passes the type and size rule. */
export function isAllowedImageUpload(file: File): boolean {
  return (
    (IMAGE_UPLOAD_TYPES as readonly string[]).includes(file.type) &&
    file.size <= IMAGE_UPLOAD_MAX_BYTES
  );
}
