(function(){"use strict";var e=typeof e<"u"?e:{};(function(t,r){typeof exports=="object"&&typeof module=="object"?module.exports=r():typeof define=="function"&&define.amd?define([],r):typeof exports=="object"?exports.DecoderWorker=r():t.DecoderWorker=r()})(typeof self<"u"?self:void 0,function(){return function(t){var r={};function n(i){if(r[i])return r[i].exports;var o=r[i]={i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(i,o,c){n.o(i,o)||Object.defineProperty(i,o,{enumerable:!0,get:c})},n.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},n.t=function(i,o){if(1&o&&(i=n(i)),8&o||4&o&&typeof i=="object"&&i&&i.__esModule)return i;var c=Object.create(null);if(n.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:i}),2&o&&typeof i!="string")for(var f in i)n.d(c,f,function(a){return i[a]}.bind(null,f));return c},n.n=function(i){var o=i&&i.__esModule?function(){return i.default}:function(){return i};return n.d(o,"a",o),o},n.o=function(i,o){return Object.prototype.hasOwnProperty.call(i,o)},n.p="",n(n.s=0)}([function(t,r,n){(function(i){var o,c,f=new Promise(function(s){c=s});i.onmessage=function(s){f.then(function(){switch(s.data.command){case"decode":o&&o.decode(s.data.pages);break;case"done":o&&(o.sendLastBuffer(),i.close());break;case"init":o=new a(s.data,e)}})};var a=function(s,u){if(!u)throw new Error("Module with exports required to initialize a decoder instance");this.mainReady=f,this.config=Object.assign({bufferLength:4096,decoderSampleRate:48e3,outputBufferSampleRate:48e3,resampleQuality:3},s),this._opus_decoder_create=u._opus_decoder_create,this._opus_decoder_destroy=u._opus_decoder_destroy,this._speex_resampler_process_interleaved_float=u._speex_resampler_process_interleaved_float,this._speex_resampler_init=u._speex_resampler_init,this._speex_resampler_destroy=u._speex_resampler_destroy,this._opus_decode_float=u._opus_decode_float,this._free=u._free,this._malloc=u._malloc,this.HEAPU8=u.HEAPU8,this.HEAP32=u.HEAP32,this.HEAPF32=u.HEAPF32,this.outputBuffers=[]};a.prototype.decode=function(s){var u=new DataView(s.buffer);this.getPageBoundaries(u).map(function(p){var _=u.getUint8(p+5,!0),B=u.getUint32(p+18,!0);if(2&_&&(this.numberOfChannels=u.getUint8(p+37,!0),this.init()),B>1){for(var M=u.getUint8(p+26,!0),T=p+27+M,j=0;j>2]=J,this.HEAP32[this.resampleOutputLengthPointer>>2]=Z,this._speex_resampler_process_interleaved_float(this.resampler,this.decoderOutputPointer,this.decoderOutputLengthPointer,this.resampleOutputBufferPointer,this.resampleOutputLengthPointer),this.sendToOutputBuffers(this.HEAPF32.subarray(this.resampleOutputBufferPointer>>2,(this.resampleOutputBufferPointer>>2)+Z*this.numberOfChannels)),this.decoderBufferIndex=0}}4&_&&this.sendLastBuffer()}},this)},a.prototype.getPageBoundaries=function(s){for(var u=[],p=0;p1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),typeof module<"u"&&(module.exports=e),process.on("uncaughtException",function(t){if(!(t instanceof Re))throw t}),process.on("unhandledRejection",function(t){throw t}),e.inspect=function(){return"[Emscripten Module object]"}):(W||w)&&(w?l=self.location.href:typeof document<"u"&&document.currentScript&&(l=document.currentScript.src),l.indexOf("blob:")!==0?l=l.substr(0,l.replace(/[?#].*/,"").lastIndexOf("/")+1):l="",U=function(t){var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(null),r.responseText},w&&(I=function(t){var r=new XMLHttpRequest;return r.open("GET",t,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),S=function(t,r,n){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){if(i.status==200||i.status==0&&i.response){r(i.response);return}n()},i.onerror=n,i.send(null)});var te=e.print||console.log.bind(console),v=e.printErr||console.warn.bind(console);for(h in O)O.hasOwnProperty(h)&&(e[h]=O[h]);O=null,e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.quit&&e.quit;var R;e.wasmBinary&&(R=e.wasmBinary),e.noExitRuntime,typeof WebAssembly!="object"&&b("no native wasm support detected");var N,q=!1;function re(t,r){t||b("Assertion failed: "+r)}var z=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(t,r,n){for(var i=r+n,o=r;t[o]&&!(o>=i);)++o;if(o-r>16&&t.subarray&&z)return z.decode(t.subarray(r,o));for(var c="";r>10,56320|u&1023)}}return c}function ne(t,r){return t?k(P,t,r):""}var P,A;function ie(t){e.HEAP8=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=A=new Int32Array(t),e.HEAPU8=P=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}e.INITIAL_MEMORY;var C,G=[],V=[],X=[];function oe(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)fe(e.preRun.shift());H(G)}function se(){H(V)}function ue(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)ce(e.postRun.shift());H(X)}function fe(t){G.unshift(t)}function ae(t){V.unshift(t)}function ce(t){X.unshift(t)}var m=0,x=null;function de(t){m++,e.monitorRunDependencies&&e.monitorRunDependencies(m)}function pe(t){if(m--,e.monitorRunDependencies&&e.monitorRunDependencies(m),m==0&&x){var r=x;x=null,r()}}e.preloadedImages={},e.preloadedAudios={};function b(t){e.onAbort&&e.onAbort(t),t="Aborted("+t+")",v(t),q=!0,t+=". Build with -s ASSERTIONS=1 for more info.";var r=new WebAssembly.RuntimeError(t);throw r}var le="data:application/octet-stream;base64,";function Q(t){return t.startsWith(le)}function Y(t){return t.startsWith("file://")}var d;d="decoderWorker.min.wasm",Q(d)||(d=ee(d));function K(t){try{if(t==d&&R)return new Uint8Array(R);if(I)return I(t);throw"both async and sync fetching of the wasm failed"}catch(r){b(r)}}function he(){if(!R&&(W||w)){if(typeof fetch=="function"&&!Y(d))return fetch(d,{credentials:"same-origin"}).then(function(t){if(!t.ok)throw"failed to load wasm binary file at '"+d+"'";return t.arrayBuffer()}).catch(function(){return K(d)});if(S)return new Promise(function(t,r){S(d,function(n){t(new Uint8Array(n))},r)})}return Promise.resolve().then(function(){return K(d)})}function me(){var t={a:we};function r(f,a){var s=f.exports;e.asm=s,N=e.asm.g,ie(N.buffer),C=e.asm.q,ae(e.asm.h),pe()}de();function n(f){r(f.instance)}function i(f){return he().then(function(a){return WebAssembly.instantiate(a,t)}).then(function(a){return a}).then(f,function(a){v("failed to asynchronously prepare wasm: "+a),b(a)})}function o(){return!R&&typeof WebAssembly.instantiateStreaming=="function"&&!Q(d)&&!Y(d)&&typeof fetch=="function"?fetch(d,{credentials:"same-origin"}).then(function(f){var a=WebAssembly.instantiateStreaming(f,t);return a.then(n,function(s){return v("wasm streaming compile failed: "+s),v("falling back to ArrayBuffer instantiation"),i(n)})}):i(n)}if(e.instantiateWasm)try{var c=e.instantiateWasm(t,r);return c}catch(f){return v("Module.instantiateWasm callback failed with error: "+f),!1}return o(),{}}function H(t){for(;t.length>0;){var r=t.shift();if(typeof r=="function"){r(e);continue}var n=r.func;typeof n=="number"?r.arg===void 0?C.get(n)():C.get(n)(r.arg):n(r.arg===void 0?null:r.arg)}}function _e(){b("")}function ye(t,r,n){P.copyWithin(t,r,r+n)}function ge(t){b("OOM")}function ve(t){P.length,ge()}var E={mappings:{},buffers:[null,[],[]],printChar:function(t,r){var n=E.buffers[t];r===0||r===10?((t===1?te:v)(k(n,0)),n.length=0):n.push(r)},varargs:void 0,get:function(){E.varargs+=4;var t=A[E.varargs-4>>2];return t},getStr:function(t){var r=ne(t);return r},get64:function(t,r){return t}};function be(t){return 0}function Be(t,r,n,i,o){}function Oe(t,r,n,i){for(var o=0,c=0;c>2],a=A[r+(c*8+4)>>2],s=0;s>2]=o,0}var we={c:_e,e:ye,f:ve,d:be,b:Be,a:Oe};me(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.h).apply(null,arguments)},e._opus_decoder_create=function(){return(e._opus_decoder_create=e.asm.i).apply(null,arguments)},e._opus_decode_float=function(){return(e._opus_decode_float=e.asm.j).apply(null,arguments)},e._opus_decoder_destroy=function(){return(e._opus_decoder_destroy=e.asm.k).apply(null,arguments)},e._speex_resampler_init=function(){return(e._speex_resampler_init=e.asm.l).apply(null,arguments)},e._speex_resampler_destroy=function(){return(e._speex_resampler_destroy=e.asm.m).apply(null,arguments)},e._speex_resampler_process_interleaved_float=function(){return(e._speex_resampler_process_interleaved_float=e.asm.n).apply(null,arguments)},e._malloc=function(){return(e._malloc=e.asm.o).apply(null,arguments)},e._free=function(){return(e._free=e.asm.p).apply(null,arguments)};var L;function Re(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}x=function t(){L||F(),L||(x=t)};function F(t){if(m>0||(oe(),m>0))return;function r(){L||(L=!0,e.calledRun=!0,!q&&(se(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),ue()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),r()},1)):r()}if(e.run=F,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();F()})();