!function(){const e="https://unpkg.com/@ffmpeg/core@0.12.9/dist/umd/ffmpeg-core.js";var t,r;(r=t||(t={})).LOAD="LOAD",r.EXEC="EXEC",r.FFPROBE="FFPROBE",r.WRITE_FILE="WRITE_FILE",r.READ_FILE="READ_FILE",r.DELETE_FILE="DELETE_FILE",r.RENAME="RENAME",r.CREATE_DIR="CREATE_DIR",r.LIST_DIR="LIST_DIR",r.DELETE_DIR="DELETE_DIR",r.ERROR="ERROR",r.DOWNLOAD="DOWNLOAD",r.PROGRESS="PROGRESS",r.LOG="LOG",r.MOUNT="MOUNT",r.UNMOUNT="UNMOUNT";const a=new Error("unknown message type"),s=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),o=new Error("failed to import ffmpeg-core.js");let E;self.onmessage=async({data:{id:r,type:n,data:c}})=>{const i=[];let R;try{if(n!==t.LOAD&&!E)throw s;switch(n){case t.LOAD:R=await(async({coreURL:r,wasmURL:a,workerURL:s})=>{const n=!E;try{r||(r=e),importScripts(r)}catch{if((!r||r===e)&&(r=e.replace("/umd/","/esm/")),self.createFFmpegCore=(await import(r)).default,!self.createFFmpegCore)throw o}const c=r,i=a||r.replace(/.js$/g,".wasm"),R=s||r.replace(/.js$/g,".worker.js");return E=await self.createFFmpegCore({mainScriptUrlOrBlob:`${c}#${btoa(JSON.stringify({wasmURL:i,workerURL:R}))}`}),E.setLogger(e=>self.postMessage({type:t.LOG,data:e})),E.setProgress(e=>self.postMessage({type:t.PROGRESS,data:e})),n})(c);break;case t.EXEC:R=(({args:e,timeout:t=-1})=>{E.setTimeout(t),E.exec(...e);const r=E.ret;return E.reset(),r})(c);break;case t.FFPROBE:R=(({args:e,timeout:t=-1})=>{E.setTimeout(t),E.ffprobe(...e);const r=E.ret;return E.reset(),r})(c);break;case t.WRITE_FILE:R=(({path:e,data:t})=>(E.FS.writeFile(e,t),!0))(c);break;case t.READ_FILE:R=(({path:e,encoding:t})=>E.FS.readFile(e,{encoding:t}))(c);break;case t.DELETE_FILE:R=(({path:e})=>(E.FS.unlink(e),!0))(c);break;case t.RENAME:R=(({oldPath:e,newPath:t})=>(E.FS.rename(e,t),!0))(c);break;case t.CREATE_DIR:R=(({path:e})=>(E.FS.mkdir(e),!0))(c);break;case t.LIST_DIR:R=(({path:e})=>{const t=E.FS.readdir(e),r=[];for(const a of t){const t=E.FS.stat(`${e}/${a}`),s=E.FS.isDir(t.mode);r.push({name:a,isDir:s})}return r})(c);break;case t.DELETE_DIR:R=(({path:e})=>(E.FS.rmdir(e),!0))(c);break;case t.MOUNT:R=(({fsType:e,options:t,mountPoint:r})=>{const a=e,s=E.FS.filesystems[a];return!!s&&(E.FS.mount(s,t,r),!0)})(c);break;case t.UNMOUNT:R=(({mountPoint:e})=>(E.FS.unmount(e),!0))(c);break;default:throw a}}catch(e){return void self.postMessage({id:r,type:t.ERROR,data:e.toString()})}R instanceof Uint8Array&&i.push(R.buffer),self.postMessage({id:r,type:n,data:R},i)}}();