import{g as n}from"./chunk-J476KISY.js";var o=class r{static{this.mimeTypes={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",odt:"application/vnd.oasis.opendocument.text",txt:"text/plain",csv:"text/csv",other:"application/octet-stream"}}static{this.imgMimeTypes=[this.mimeTypes.jpg,this.mimeTypes.jpeg,this.mimeTypes.png]}static{this.documentMimeTypes=[this.mimeTypes.docx,this.mimeTypes.odt]}static getMimeType(t){let e=t.split(".").pop()?.toLowerCase();return e&&this.mimeTypes[e]?this.mimeTypes[e]:"application/octet-stream"}static isImage(t){return t?this.imgMimeTypes.indexOf(t)>-1:!1}static isPDF(t){return t?t===this.mimeTypes.pdf:!1}static isDocument(t){return t?this.documentMimeTypes.indexOf(t)>-1:!1}static isSheet(t){return t?t===this.mimeTypes.xlsx:!1}static isCSV(t){return t?t===this.mimeTypes.csv:!1}static isText(t){return t?t===this.mimeTypes.txt:!1}static isOther(t){return t?t===this.mimeTypes.other:!1}static getFileType(t){return r.isPDF(t)?"pdf":r.isImage(t)?"image":r.isDocument(t)?"docx":r.isSheet(t)?"xlsx":r.isCSV(t)?"csv":"other"}static downloadFileFromUrl(t,e){if(!t)return;let i=document.createElement("a");i.href=t,i.download=e??"",i.click()}static downloadFileFromData(t,e){let i=r.createBlobUrl(t,e);i&&this.downloadFileFromUrl(i,e)}static createBlobUrl(t,e){var i=r.getMimeType(e);return URL.createObjectURL(new Blob([t],{type:i}))}static fileToByteArray(t){return n(this,null,function*(){return new Uint8Array(yield t.arrayBuffer())})}static fileToBase64(t){return n(this,null,function*(){let e=yield this.fileToByteArray(t),i="",a=32768;for(let s=0;s<e.length;s+=a){let c=e.subarray(s,s+a);i+=String.fromCharCode(...c)}return btoa(i)})}static arrayBufferToBase64(t){let e="",i=new Uint8Array(t),a=i.byteLength;for(let s=0;s<a;s++)e+=String.fromCharCode(i[s]);return btoa(e)}static tryDetectMimeType(t,e="application/octet-stream"){let i={"/9j/":"image/jpeg",iVBORw0KGgo:"image/png",R0lGOD:"image/gif",JVBERi0:"application/pdf"};for(let[a,s]of Object.entries(i))if(t.startsWith(a))return s;return e}};export{o as a};
