{"version":3,"file":"file.mjs","names":[],"sources":["../src/file.ts"],"sourcesContent":["/**\n * Read an expected JSON type File.\n *\n * Probably paired with:\n *  <input type='file' accept='application/JSON' ... />\n */\nexport async function readJSONFile(file: File): Promise<unknown> {\n  const text = await new Promise<string>((resolve, reject) => {\n    const reader = new FileReader();\n    reader.addEventListener('load', function () {\n      resolve(reader.result as string);\n    });\n\n    reader.addEventListener('error', reject);\n    reader.readAsText(file);\n  });\n\n  // Parsed here rather than in the load listener, where a throw never reaches\n  // the promise and leaves it pending.\n  return JSON.parse(text);\n}\n\nconst MimeTypeToExtensionMap = Object.freeze({\n  'image/png': 'png',\n  'image/jpeg': 'jpg',\n  'image/gif': 'gif',\n  'image/webp': 'webp',\n  'image/x-icon': 'ico',\n  'image/vnd.microsoft.icon': 'ico',\n} as const);\n\nexport type SupportedMimeType = keyof typeof MimeTypeToExtensionMap;\n\nexport const extension = (mimeType: SupportedMimeType): string => {\n  return MimeTypeToExtensionMap[mimeType];\n};\n"],"mappings":";;;;;;;AAMA,eAAsB,aAAa,MAA8B;CAC/D,MAAM,OAAO,MAAM,IAAI,SAAiB,SAAS,WAAW;EAC1D,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,iBAAiB,QAAQ,WAAY;GAC1C,QAAQ,OAAO,MAAgB;EACjC,CAAC;EAED,OAAO,iBAAiB,SAAS,MAAM;EACvC,OAAO,WAAW,IAAI;CACxB,CAAC;CAID,OAAO,KAAK,MAAM,IAAI;AACxB;AAEA,MAAM,yBAAyB,OAAO,OAAO;CAC3C,aAAa;CACb,cAAc;CACd,aAAa;CACb,cAAc;CACd,gBAAgB;CAChB,4BAA4B;AAC9B,CAAU;AAIV,MAAa,aAAa,aAAwC;CAChE,OAAO,uBAAuB;AAChC"}