{"version":3,"file":"FilePreview-af487ed0.js","sources":["../../../../js/file/shared/utils.ts","../../../../js/file/shared/FilePreview.svelte"],"sourcesContent":["import type { FileData } from \"@gradio/upload\";\n\nexport const prettyBytes = (bytes: number): string => {\n\tlet units = [\"B\", \"KB\", \"MB\", \"GB\", \"PB\"];\n\tlet i = 0;\n\twhile (bytes > 1024) {\n\t\tbytes /= 1024;\n\t\ti++;\n\t}\n\tlet unit = units[i];\n\treturn bytes.toFixed(1) + \" \" + unit;\n};\n\nexport const display_file_name = (value: FileData): string => {\n\tvar str: string;\n\tstr = value.orig_name || value.name;\n\tconst max_length = 30;\n\n\tif (str.length > max_length) {\n\t\tconst truncated_name = str.substring(0, max_length);\n\t\tconst file_extension_index = str.lastIndexOf(\".\");\n\t\tif (file_extension_index !== -1) {\n\t\t\tconst file_extension = str.slice(file_extension_index);\n\t\t\treturn `${truncated_name}..${file_extension}`;\n\t\t}\n\t\treturn truncated_name;\n\t}\n\treturn str;\n};\n\nexport const display_file_size = (value: FileData | FileData[]): string => {\n\tvar total_size = 0;\n\tif (Array.isArray(value)) {\n\t\tfor (var file of value) {\n\t\t\tif (file.size !== undefined) total_size += file.size;\n\t\t}\n\t} else {\n\t\ttotal_size = value.size || 0;\n\t}\n\treturn prettyBytes(total_size);\n};\n","\n\n
\n\t\t\t\t\t\t{display_file_name(file)}\n\t\t\t\t\t | \n\n\t\t\t\t\t\n\t\t\t\t\t\t{#if file.data}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t{@html display_file_size(file)} ⇣\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t{:else}\n\t\t\t\t\t\t\t{$_(\"file.uploading\")}\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t | \n\t\t\t\t