// TODO [ro] the encoding seems wrong.
// The following is an example of readable file from temp location
// This is the file objects returned by FilePicker.files
// {
//  "name": "small.png",
//  "extension": "png",
//  "type": "image/png",
//  "size": 5704,
//  "encoding": "text",
//  "$superblocksId": "uppy-small_png-1e-image_png-5704-1674601389293"
// }
export function isReadableFile(f) {
    if (!f || typeof f !== 'object' || Array.isArray(f)) {
        return false;
    }
    const entries = Object.entries(f);
    if (entries.length === 0) {
        return false;
    }
    return Object.entries(f).every(([key, value]) => {
        switch (key) {
            case 'name':
            case 'extension':
            case 'type':
            case 'encoding':
            case '$superblocksId':
                return typeof value === 'string';
            case 'size':
                return typeof value === 'number';
            case 'previewUrl':
            case 'path':
                return typeof value === 'string' || typeof value === 'undefined';
            default:
                return false;
        }
    });
}
// This is used to determine if the object is a valid custom file object
// it has to have name, contents, and type
export function isReadableFileConstructor(f) {
    if (!f || typeof f !== 'object') {
        return false;
    }
    return Object.entries(f).every(([key, value]) => {
        switch (key) {
            case 'name':
            case 'contents':
                // @ts-ignore contents might be string or Buffer.toJSON()
                // Buffer.toJSON() is determined by 'type' === 'Buffer'
                // This supports passing Buffer to contents
                // {
                //   name: 'filename',
                //   contents: {{Step2.output}},
                //   type: 'filetype
                // }
                return typeof value === 'string' || value['type'] === 'Buffer';
            case 'type':
                return typeof value === 'string';
            default:
                return false;
        }
    });
}
//# sourceMappingURL=file.js.map