import { g as getFileBackgroundColor, a as getFileColor, b as getFileExtensionTitle, c as getFileIcon } from './file-metadata-BwF9vTXN.js';

/**
 *
 * @param file
 */
function createFileInfo(file) {
    const limeFile = {
        id: crypto.randomUUID(),
        filename: file.name,
        contentType: file.type,
        size: file.size,
        fileContent: file,
    };
    limeFile.icon = {
        name: getFileIcon(limeFile),
        title: getFileExtensionTitle(limeFile),
        color: getFileColor(limeFile),
        backgroundColor: getFileBackgroundColor(limeFile),
    };
    return limeFile;
}
/**
 *
 * @param file
 * @param accept
 */
function isTypeAccepted(file, accept) {
    if (accept === undefined || accept === '*') {
        return true;
    }
    const acceptList = accept.split(',').map((raw) => raw.trim());
    return acceptList.some((acceptedType) => {
        if (acceptedType === file.contentType) {
            return true;
        }
        if (acceptedType.endsWith('/*')) {
            const baseType = acceptedType.split('/')[0];
            return file.contentType.startsWith(`${baseType}/`);
        }
        if (acceptedType.startsWith('.')) {
            const fileType = acceptedType.split('.')[1];
            return file.contentType.endsWith(`/${fileType}`);
        }
    });
}

export { createFileInfo as c, isTypeAccepted as i };
