import { msg, str } from '@lit/localize';
/**
 * This entire file was copied from shreddit
 * I removed some parts of it that were too "shreddit post creation" focused, but kept the original code style
 * Eventually we will remove it in favour of faceplate-ui image upload component, but for now we have this
 */
const KILOBYTE = 1024;
const MEGABYTE = KILOBYTE * KILOBYTE;
const GIGABYTE = KILOBYTE * MEGABYTE;
const MAX_IMAGE_FILE_SIZE = 20 * MEGABYTE; // 20MB
const MAX_GIF_FILE_SIZE = 40 * MEGABYTE; // 40MB
const MAX_VIDEO_FILE_SIZE = 1 * GIGABYTE; // 1GB
// TODO(ADE-7032): Rename to validateMediaFileSize
export function validateImageFileSize(file) {
    const mimetype = file.type;
    if (mimetype === 'image/gif' && file.size > MAX_GIF_FILE_SIZE) {
        return {
            valid: false,
            error: msg(str `Upload failed, GIF size should be less than ${Math.floor(MAX_GIF_FILE_SIZE / MEGABYTE)}MB.`, {
                desc: 'Error: gif size limit exceeded',
            }),
            reason: 'IMAGE_SIZE_LIMIT_EXCEEDED_ERROR',
        };
    }
    if (mimetype.includes('image/') && mimetype !== 'image/gif' && file.size > MAX_IMAGE_FILE_SIZE) {
        return {
            valid: false,
            error: msg(str `Upload failed, Image size should be less than ${Math.floor(MAX_IMAGE_FILE_SIZE / MEGABYTE)}MB.`, {
                desc: 'Error: image size limit exceeded',
            }),
            reason: 'IMAGE_SIZE_LIMIT_EXCEEDED_ERROR',
        };
    }
    if (mimetype.includes('video/') && file.size > MAX_VIDEO_FILE_SIZE) {
        return {
            valid: false,
            error: msg(str `Upload failed, Video size should be less than ${Math.floor(MAX_VIDEO_FILE_SIZE / GIGABYTE)}GB.`, {
                desc: 'Error: video size limit exceeded',
            }),
            reason: 'VIDEO_SIZE_LIMIT_EXCEEDED_ERROR',
        };
    }
    return {
        valid: true,
        error: null,
    };
}
//# sourceMappingURL=validate-image-size.js.map