UNPKG

@zoom/meetingsdk

Version:
28 lines 134 kB
!function(t){var e={};function s(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(i,r,function(e){return t[e]}.bind(null,r));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=10)}([function(t,e,s){"use strict";s.d(e,"e",(function(){return i})),s.d(e,"i",(function(){return r})),s.d(e,"a",(function(){return n})),s.d(e,"d",(function(){return a})),s.d(e,"f",(function(){return o})),s.d(e,"c",(function(){return h})),s.d(e,"b",(function(){return u})),s.d(e,"g",(function(){return l})),s.d(e,"j",(function(){return c})),s.d(e,"h",(function(){return f}));const i=30,r=35,n=48,a=57,o=61,h=66.5,u=66.6,l=-26,c=-27,f=-28},function(t,e,s){"use strict";var i=s(0);s(3);new Error;new Map;var r=s(2);function n(t){postMessage({status:i.i,data:t})}function a(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e)return e.postMessage({status:i.a,data:t});postMessage({status:i.a,data:t})}new Map,new class{constructor(){this.ssrcInfoMap=new Map,this.timer=null}updateSSRCInfo(t,e){this.ssrcInfoMap.has(t)||this.ssrcInfoMap.set(t,{firstTime:0,lastTime:0,frames:0,fps:0}),this._calculateFPS(t,e),this._removeZeroFPS()}_calculateFPS(t,e){const s=this.ssrcInfoMap.get(t);if(0===s.frames?s.firstTime=e:s.lastTime=e,s.frames+=1,s.frames>2&&s.frames%5==0&&s.lastTime-s.firstTime>=1e3){const e=Math.floor(1e3/((s.lastTime-s.firstTime)/(s.frames-1)));s.fps!==e&&(this._notifyFPS(t,e),s.fps=e),s.firstTime=s.lastTime,s.frames=1}}_removeZeroFPS(){let t=Date.now();this.ssrcInfoMap.forEach((e,s)=>{const i=this.ssrcInfoMap.get(s);i&&t-i.lastTime>2e3&&(this.ssrcInfoMap.delete(s),this._notifyFPS(s,0))})}_notifyFPS(t,e){postMessage({status:i.b,data:{ssrc:t,fps:e}})}_checkIfNewFrameComing(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.timer=setTimeout(()=>{this._removeZeroFPS(),this.timer=null},2500)}};var o=s(5);const h={WORKLET:1,ENCODE:2,DECODE:3,WORKLET_APM_ONLY:4},u={MUTE:0,UNMUTE:1,LEAVED:2,MUTE_APM_ONLY:3,UNMUTE_APM_ONLY:4};let l,c,f,d,_,A,E,m,S,b,p=0,T=!0;var g=0;var C=!1;var M=null;var w=!1;e.a={WASMTYPE:h,AUDIO_STATE:u,onWasmModuleReady:function(t){if(!t)return console.warn("[AudioWASMAdapter] Module undefined");f=t.cwrap("_Heartbeat","number",["number"]),d=t.cwrap("_MuteUnmuteState","number",["number","number"]),_=t.cwrap("_Switch_Original_Sound","number",["number","boolean","boolean","boolean","boolean"]),A=t.cwrap("_Deliver_Recorded_Data","number",["number","number","number","number","number","number"]),E=t.cwrap("_Switch_Denoise","number",["number","number","number","number"]),m=t.cwrap("_Audio_Init","number",["number","string","string","number","number","boolean","boolean","boolean","number","boolean"]),S=t.cwrap("_Switch_High_Bitrate","number",["number","number"]),b=t.cwrap("_Set_All_Speech_Volume_Level","number",["number"])},setAudioInstanceAndType:function(t,e,s){l=t,e&&(p=e),s&&(c=s)},muteUnmuteState:function(t){if(null!=Object.values(u).find(e=>e==t))return l?void(p!=h.WORKLET_APM_ONLY&&(d(l,t),n("muteUnmuteState: "+t))):n("muteUnmuteState: -1")},switchOriginalSound:function(t,e,s,i){l&&_(l,t,e,s,i)},deliverRecordedData:function(t,e,s,i){l&&A(l,t,e,0,s,i)},switchDenoise:function(t,e){l&&(C=t,E(l,!!t,3,!!e))},audioInit:function(t,e,s,i,r,n,a,o,h,u){return m(t,e,s,i,r,n,a,o,h,u)},setDecoder:function(t){M=t},needCalculateDenoiseOutput:function(){w=!0},switchHighBitrate:function(t){l&&S(l,t)},disableJitterLog:function(){T=!1},setAllSpeechVolume:function(t){l&&b(l,t)},onMonitorLogWASM:function(t,e){if(e<=0)return;const s=Module.HEAPU8.subarray(t,t+e),i=String.fromCharCode.apply(null,s);i&&(!T&&i.includes("JITTER")||(p==h.ENCODE||p==h.DECODE?a(i):p==h.WORKLET?c&&c.port&&a(i,c.port):p==h.WORKLET_APM_ONLY&&c.port&&c.port.postMessage({status:"SPEECH_LOG",data:{log:i}})))},onMuteSpeechWarningWASM:function(){postMessage({status:r.b})},onAudioLevelWASM:function(t,e,s){var i;p!=h.ENCODE&&p!=h.WORKLET_APM_ONLY||1==t&&(0===e&&0===g||(g=e,p===h.ENCODE?postMessage({status:r.a,value:e}):null!==(i=c)&&void 0!==i&&i.port&&c.port.postMessage({status:r.a,data:e})))},onAPMProcessedPCMWASM:function(t,e,s,i){if(!C)return;let r=Module.HEAPF32.subarray(t/4,t/4+e);if(M){if(w){w=!1;let{sumRms:t}=Object(o.a)(r,2),e=Object(o.c)(t);c.port&&c.port.postMessage({status:"AUDIO_LEVEL_R16_DENOISE",level:e})}M.push([r])}}}},function(t,e,s){"use strict";s.d(e,"a",(function(){return i})),s.d(e,"c",(function(){return r})),s.d(e,"b",(function(){return n}));const i=38,r=-51,n=121},function(t,e,s){"use strict";const i=t=>0==(t&t-1);let r=new class{constructor(){this._highFrequencyLogs={},this.fixVersion=""}setInstance(t,e){this._instance=t,this.fixVersion=e}getMessageFromErrorOrEvent(t,e){let s=t;return e instanceof ErrorEvent?(e.filename&&(s+=" File: ".concat(e.filename)),(e.lineno||e.colno)&&(s+=" Line: ".concat(e.lineno,":").concat(e.colno)),e.message&&(s+=" Message: ".concat(e.message)),e.error&&(s+="\nStack: ".concat(e.error.stack))):e instanceof Error?(e.fileName&&(s+=" File: ".concat(e.fileName)),(e.lineNumber||e.columnNumber)&&(s+=" Line: ".concat(e.lineNumber,":").concat(e.columnNumber)),e.message&&(s+=" Message: ".concat(e.message)),e.stack&&(s+=" Stack: ".concat(e.stack)),e.name&&(s+=" Name: ".concat(e.name)),e.constraint&&(s+=" Constraint: ".concat(e.constraint))):e instanceof CloseEvent?(e.code&&(s+=" Code: ".concat(e.code)),e.reason&&(s+=" Reason: ".concat(e.reason)),s+=" wasClean: ".concat(e.wasClean)):e instanceof DOMException?(e.message&&(s+=" Message: ".concat(e.message)),e.name&&(s+=" Name: ".concat(e.name))):s+=e?e.toString():"",s}error(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=this.getMessageFromErrorOrEvent(t,e),this._highFrequencyLogs[t]?this._highFrequencyLogs[t]+=1:this._highFrequencyLogs[t]=1;const s=i(this._highFrequencyLogs[t]);this._instance&&s&&this._instance.error(t,[this.fixVersion])}severityerror(t,e){this._instance&&this._instance.error(JSON.stringify(t),e)}directReport(t,e){var s,i;this._instance&&(e||(e=["MEDIASDK_INFO"]),null===(s=(i=this._instance).directReport)||void 0===s||s.call(i,{msg:t},e))}warn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=this.getMessageFromErrorOrEvent(t,e),this._instance&&this._instance.warn(t)}log(t){this._instance&&this._instance.log(t)}clearHighFrequencyLogs(){this._highFrequencyLogs={}}};e.a=r},function(t,e,s){"use strict";s.d(e,"b",(function(){return r})),s.d(e,"a",(function(){return n}));var i=s(6);class r{constructor(t,e,s){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(this.STATE_READ_READY=0,this.STATE_READ_INDEX=1,this.STATE_WRITE_READY=2,this.STATE_WRITE_INDEX=3,this.STATE_DATA_COUNT=4,this.STATE_CACHE_SIZE=5,this.STATY_READY_NO=0,this.STATY_READY_YES=1,this.sabState=new Uint32Array(t),this.sabBuffer=new Float32Array(e),this.perFrameLength=s,this.writeChannelNumb=r,this.bufferLen=this.sabBuffer.length,this.supportSpecialOptimization=this.bufferLen%s==0,this.bufferIndex=null,this.supportSpecialOptimization){let t=this.bufferLen/s;this.bufferIndex=[];for(let e=0;e<t;e++)this.bufferIndex.push(this.sabBuffer.subarray(e*s,e*s+s))}this.placeBuffer=new Float32Array(this.perFrameLength),this.QUANTUM_SIZE=128,this.CACHE_SIZE_MAX_VALUE=Math.floor(Math.floor(this.bufferLen/this.QUANTUM_SIZE)/2),this.CACHE_SIZE_MIN_VALUE=6,this.CACHE_SIZE_MAX_VALUE<this.CACHE_SIZE_MIN_VALUE&&(this.CACHE_SIZE_MAX_VALUE=this.CACHE_SIZE_MIN_VALUE),this.setCacheSize(this.CACHE_SIZE_MIN_VALUE),this._counter=0,this.onCacheSizeChange=null,this.cacheSizeController=new i.a}getCacheSize(){return Atomics.load(this.sabState,this.STATE_CACHE_SIZE)}setCacheSize(t){t>this.CACHE_SIZE_MAX_VALUE&&(t=this.CACHE_SIZE_MAX_VALUE),t<this.CACHE_SIZE_MIN_VALUE&&(t=this.CACHE_SIZE_MIN_VALUE),this.onCacheSizeChange&&this.cacheSizeController.shouldSendCacheSize(t)&&this.onCacheSizeChange(t),Atomics.store(this.sabState,this.STATE_CACHE_SIZE,t)}setQuantumSize(t){this.QUANTUM_SIZE=t,this.CACHE_SIZE_MAX_VALUE=Math.floor(Math.floor(this.bufferLen/this.QUANTUM_SIZE)/2),this.CACHE_SIZE_MAX_VALUE<this.CACHE_SIZE_MIN_VALUE&&(this.CACHE_SIZE_MAX_VALUE=this.CACHE_SIZE_MIN_VALUE)}isNeedMoreData(){let t=Atomics.load(this.sabState,this.STATE_CACHE_SIZE);return Atomics.load(this.sabState,this.STATE_DATA_COUNT)<t*this.QUANTUM_SIZE}shouldAdjustCacheBuffer(){this._counter>0&&this.setCacheSize(this.getCacheSize()+1)}clear(){this.sabState&&(this.sabState[this.STATE_READ_READY]=0,this.sabState[this.STATE_READ_INDEX]=0,this.sabState[this.STATE_WRITE_READY]=0,this.sabState[this.STATE_WRITE_INDEX]=0,this.sabState[this.STATE_DATA_COUNT]=0),this._counter=0}setWriteReady(){this.sabState[this.STATE_WRITE_READY]=this.STATY_READY_YES}isReady(){return this.sabState[this.STATE_WRITE_READY]&&this.sabState[this.STATE_READ_READY]}getDataCount(){return Atomics.load(this.sabState,this.STATE_DATA_COUNT)}write(t){if(void 0===t[0]||t[0].length*this.writeChannelNumb!==this.perFrameLength)return;let e=this.sabState[this.STATE_READ_READY];return this.sabState[this.STATE_WRITE_READY]||(this.sabState[this.STATE_WRITE_READY]=this.STATY_READY_YES,this.sabState[this.STATE_WRITE_INDEX]=0),e?this.supportSpecialOptimization?this.writeSpecial(t):this.writeNormal(t):void 0}writeNormal(t){let e=this.sabState[this.STATE_WRITE_INDEX];for(let s=0;s<this.writeChannelNumb;s++)for(let i=0;t[s]&&i<t[s].length;i++)this.sabBuffer[(e+i*this.writeChannelNumb+s)%this.bufferLen]=t[s][i];e+=this.perFrameLength,e>=this.bufferLen&&(e-=this.bufferLen),this.sabState[this.STATE_WRITE_INDEX]=e,Atomics.add(this.sabState,this.STATE_DATA_COUNT,this.perFrameLength)}writeSpecial(t){let e=this.sabState[this.STATE_WRITE_INDEX];for(let s=0;s<this.writeChannelNumb;s++)for(let i=0;t[s]&&i<t[s].length;i++)this.bufferIndex[e][i*this.writeChannelNumb+s]=t[s][i];e=(e+1)%this.bufferIndex.length,this.sabState[this.STATE_WRITE_INDEX]=e,Atomics.add(this.sabState,this.STATE_DATA_COUNT,this.perFrameLength)}read(){let t=this.sabState[this.STATE_READ_READY],e=this.sabState[this.STATE_WRITE_READY];if(t||(this.sabState[this.STATE_READ_READY]=this.STATY_READY_YES,this.sabState[this.STATE_READ_INDEX]=0),!e)return null;let s=this.supportSpecialOptimization?this.readSpecial():this.readNormal();return null===s?this.shouldAdjustCacheBuffer():this._counter++,s}readNormal(){let t=this.sabState[this.STATE_READ_INDEX],e=Atomics.load(this.sabState,this.STATE_DATA_COUNT);if(e<this.perFrameLength)return null;if(e>this.bufferLen){let s=Math.ceil((e-this.bufferLen)/this.perFrameLength)+1;t=(s*this.perFrameLength+t)%this.bufferLen,Atomics.sub(this.sabState,this.STATE_DATA_COUNT,s*this.perFrameLength)}let s=null;if(this.bufferLen-t>=this.perFrameLength)s=this.sabBuffer.subarray(t,t+this.perFrameLength);else{let e=this.sabBuffer.subarray(t),i=this.sabBuffer.subarray(0,this.perFrameLength-e.length);s=this.placeBuffer,s.set(e),s.set(i,e.length)}return t+=this.perFrameLength,t>=this.bufferLen&&(t-=this.bufferLen),this.sabState[this.STATE_READ_INDEX]=t,Atomics.sub(this.sabState,this.STATE_DATA_COUNT,this.perFrameLength),s}readSpecial(){let t=this.sabState[this.STATE_READ_INDEX],e=Atomics.load(this.sabState,this.STATE_DATA_COUNT);if(e<this.perFrameLength)return null;if(e>this.bufferLen){let s=Math.ceil((e-this.bufferLen)/this.perFrameLength)+1;t=(s+t)%this.bufferIndex.length,Atomics.sub(this.sabState,this.STATE_DATA_COUNT,s*this.perFrameLength)}let s=this.bufferIndex[t];return t=(t+1)%this.bufferIndex.length,this.sabState[this.STATE_READ_INDEX]=t,Atomics.sub(this.sabState,this.STATE_DATA_COUNT,this.perFrameLength),s}}class n{constructor(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.rframes=t,this.wframes=e,this.writeChannelNumb=s,this.cap=this.lcm(t,e),this.buffer=new Float32Array(this.cap),this.remain=0,this.woffset=0,this.roffset=0}gcd(t,e){return 0===e?t:this.gcd(e,t%e)}lcm(t,e){return t/this.gcd(t,e)*e}push(t){if(null==t[0]||t[0].length*this.writeChannelNumb==this.wframes){for(let e=0;e<this.writeChannelNumb;e++)for(let s=0;s<t[0].length;s++)this.buffer[(this.woffset+s*this.writeChannelNumb+e)%this.cap]=t[e]?t[e][s]:t[0][s];this.woffset+=this.wframes,this.remain+=this.wframes,this.woffset>=this.cap&&(this.woffset=this.woffset%this.cap)}else{var e;console.error("[Audio] critical error in AudioWorklet: data.length:",t.length,"this.woffset:",this.woffset,"this.cap:",this.cap),_workletPrinter&&_workletPrinter.error("critical error in AudioWorklet: ".concat(null===(e=t[0])||void 0===e?void 0:e.length," ").concat(his.writeChannelNumb," ").concat(this.wframes))}}read(){if(!this.hasData())return null;let t=this.buffer.subarray(this.roffset,this.roffset+this.rframes);return this.remain-=this.rframes,this.roffset+=this.rframes,this.roffset>=this.cap&&(this.roffset=this.roffset%this.cap),t}hasData(){return this.remain>=this.rframes}clear(){this.buffer.fill(0),this.remain=0,this.woffset=0,this.roffset=0}}},function(t,e,s){"use strict";s.d(e,"a",(function(){return r})),s.d(e,"b",(function(){return n})),s.d(e,"c",(function(){return a}));s(3);const i=[0,1,2,3,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,9,9,9,9,9,9,9,9,9];function r(t,e){let s=0,i=0;for(let r=0;r<t.length;r+=e){i+=t[r]*t[r];let e=Math.abs(t[r]);e>s&&(s=e)}return s=s>1?1:s,{sumRms:i/t.length/e,absMax:s}}function n(t){if("number"!=typeof t||t<0||t>1)return-1;let e=parseInt(32768*t/1e3);return 0==e&&t>250&&(e=1),i[e]}function a(t){let e=0;return e=t>.1995?15:t>.0794?14:t>.0316?13:t>.0126?12:t>.005?11:t>.002?10:t>79433e-8?9:t>31623e-8?8:t>12589e-8?7:t>50119e-9?6:t>19953e-9?5:t>79433e-10?4:t>31623e-10?3:t>12589e-10?2:t>5.0119e-7?1:0,e}},function(t,e,s){"use strict";s.d(e,"a",(function(){return i}));class i{constructor(){this.cacheSize=0,this.sameCacheSizeCounter=0}shouldSendCacheSize(t){return t===this.cacheSize&&this.sameCacheSizeCounter++,(this.cacheSize!==t||200===this.sameCacheSizeCounter)&&(this.sameCacheSizeCounter=0,this.cacheSize=t,!0)}}},function(t,e,s){"use strict";s.d(e,"a",(function(){return i}));class i{constructor(t){this.messageQueue=[],this.auidoNodePort,this.userAgent="",this.isSafari=!1,this.debug=this.debug.bind(this),this.log=this.log.bind(this),this.warn=this.warn.bind(this),this.error=this.error.bind(this),this.print_=this.print_.bind(this),this.messageHeader=t}setUserAgent(t){this.userAgent=t,this.userAgent.match(/AppleWebKit\/(\d+)\./)&&(this.isSafari=!0)}setAuidoNodePort(t){this.auidoNodePort=t}debug(t){t=this.messageHeader+t;for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this.print_({level:"debug",message:t,data:s})}log(t){t=this.messageHeader+t;for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this.print_({level:"log",message:t,data:s})}warn(t){t=this.messageHeader+t;for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this.print_({level:"warn",message:t,data:s})}error(t){t=this.messageHeader+t;for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this.print_({level:"error",message:t,data:s})}print_(t){if(this.messageQueue.push(t),this.auidoNodePort)for(;this.messageQueue.length;){let t=this.messageQueue.shift();this._postToWorkerPrint(t)}}_postToWorkerPrint(t){this.auidoNodePort&&this.auidoNodePort.postMessage({status:"workletMessage",data:{level:t.level,message:t.message,data:t.data}})}}},,,function(t,e,s){"use strict";s.r(e);var i=s(5),r=s(1),n=s(2),a=s(4),o=s(7),h=!1,u=null,l=null,c=!1,f=!1,d=null,_=!1,A=0,E=0;globalThis._workletPrinter=new o.a("[Audio][Worklet][WebRTC]"),globalThis.AudioWasmAdapter=r.a,globalThis.onWasmModuleReady=function(){_workletPrinter.log("worklet init wasm success");try{r.a.onWasmModuleReady(Module)}catch(t){_workletPrinter.error("error when cwarp"+JSON.stringify(t))}try{u=r.a.audioInit(0,"","",0,0,!0,!0,!0,1,!0)}catch(t){_workletPrinter.error("error when audio init"+JSON.stringify(t))}u?r.a.setAudioInstanceAndType(u,r.a.WASMTYPE.WORKLET_APM_ONLY,d):_workletPrinter.error("audio handle not initialized"),r.a.switchDenoise(c,!1),d.port.postMessage({status:"WASM_INIT_SUCCESS",data:{audio_handle:0!==u}})};class m extends AudioWorkletProcessor{constructor(t){var e,s,i;super(),d=this,this.port.onmessage=this.handleMessage.bind(this),this.encodeCount=0,this.lastRecordTime=0,this.wasmModule=null==t||null===(e=t.processorOptions)||void 0===e?void 0:e.wasmModule,this.inputAudioChannel=(null==t||null===(s=t.processorOptions)||void 0===s?void 0:s.inputAudioChannel)||1,this.initRingBuffer(),null!=t&&null!==(i=t.processorOptions)&&void 0!==i&&i.userAgent&&_workletPrinter.setUserAgent(t.processorOptions.userAgent),_workletPrinter.setAuidoNodePort(this.port),_workletPrinter.log("webrtc worklet init successfully")}initRingBuffer(){this.encoder=new a.a(sampleRate/100*this.inputAudioChannel,128*this.inputAudioChannel,this.inputAudioChannel),this.decoder=new a.a(128*this.inputAudioChannel,sampleRate/100*this.inputAudioChannel),r.a.setDecoder(this.decoder)}handleMessage(t){const{status:e,data:s}=t.data;switch(e){case"stopWorklet":h=!0;break;case"audiowasm":try{this.wasmModule&&initWasm(Module,this.wasmModule)}catch(t){_workletPrinter.error("init WASM failed, error message:"+t.message+t.stack)}break;case"audio_denoise_switch":_workletPrinter.log("change denoise"+s.enable+s.isHeadSet),c=s.enable,this.encoder.clear(),this.decoder.clear(),r.a.switchDenoise(s.enable,s.isHeadSet);break;case"clearBuffer":this.encoder&&this.encoder.clear(),this.decoder&&this.decoder.clear();break;case"checkProcess":globalThis.monitorLOG("PCC"+A),A=0;break;case"clearProcess":A=0}}process(t,e){if(A++,h)return!1;if(!(t[0]&&t[0][0]&&this.encoder))return!0;0%10==1&&_workletPrinter.error("inputs or this.encoder is null, this.encoder: "+!!this.encoder);let s=null,r=null;try{s=t[0],r=e[0],this.encoder.push(s)}catch(t){return _workletPrinter.error("error when set input and output",t),!0}if(c&&!f&&u)try{this.inputData(),this.outputData(r),this.checkAudioProcess(!0)}catch(t){return _workletPrinter.error("Error occurred when do denoise in WebRTC worklet",t),f=!0,!0}else{let t=this.encoder.read();if(null!=t){this.encodeCount++;let{sumRms:e,absMax:s}=Object(i.a)(t,this.inputAudioChannel);if(this.encodeCount%10==0){let t=Object(i.b)(s);0===t&&0===E||(E=t,this.port.postMessage({status:n.a,data:t}))}if(this.encodeCount%100==0){let t=Object(i.c)(e);this.port.postMessage({status:"AUDIO_LEVEL_R16",level:t})}this.encodeCount%1200==0&&this.port.postMessage({status:"SPEECH_LOG",data:{log:"WCL_MCM_AUDIO,,,,{[SPEECHINPUT_R16]},,,,,{[SEND]},,,{[DENOISE]},0,0,0,0,{[CAPTURE]},,{[AEC]},,,{[END]}"}})}this.checkAudioProcess(!1)}return!0}inputData(){let t=this.encoder.read();if(null!==t){if(this.encodeCount++,this.encodeCount%100==0){let{sumRms:e}=Object(i.a)(t,this.inputAudioChannel),s=Object(i.c)(e);this.port.postMessage({status:"AUDIO_LEVEL_R16",level:s}),r.a.needCalculateDenoiseOutput()}l||(l=Module._malloc(this.inputAudioChannel*(4*sampleRate)/100)),Module.HEAPF32.subarray(l/4,l/4+sampleRate/100*this.inputAudioChannel).set(t),r.a.deliverRecordedData(l,sampleRate/100,sampleRate,this.inputAudioChannel)}}outputData(t){let e=this.decoder.read();if(null===e)return _workletPrinter.log("output is null"),!0;if(1===this.inputAudioChannel)for(let s=0;s<t.length;s++)t[s].set(e);else for(let s=0;s<t.length;s++)for(let i=0;t[s]&&i<t[s].length;i++)t[s][i]=e[i*t.length+s]}checkAudioProcess(t){_!=t&&(this.port.postMessage({status:"audio_process_changed",data:!_}),_=t)}}globalThis.monitorLOG=function(t){t&&d.port.postMessage({status:"MONITOR_LOG",data:t})},globalThis.wcl_trace_log=function(t,e){},globalThis.getLogData=function(t,e,s){},globalThis.audio_encode_frame_callback=function(){},registerProcessor("webRTCWorklet",m)}]); //# sourceMappingURL=https://d1cdksi819e9z7.cloudfront.net/sourcemap/js_audio_level_worklet_process.min.js-5d9247edb3a4a99eff37.map var Module = Module || {}; var wasmModule; Module['onRuntimeInitialized'] = function () { globalThis.onWasmModuleReady(); }; Module['onAbort'] = function () { globalThis.onAbort(); }; Module['instantiateWasm'] = function (imports, successCallback) { WebAssembly.instantiate(wasmModule, imports).then(function(result) { if (result.instance) { successCallback(result.instance); } else { successCallback(result); } });return {}; }; function initWasm(module, wasmModuleInput) { let performance = { now() { return Date.now(); } }; wasmModule = wasmModuleInput; var Module = module; var Module=typeof Module!="undefined"?Module:{};var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var POINTER_SIZE=4;var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||20971520;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_MEMORY/65536,"maximum":134217728/65536})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();SOCKFS.root=FS.mount(SOCKFS,{},null);PIPEFS.root=FS.mount(PIPEFS,{},null);callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="audio.simd.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"env":asmLibraryArg,"wasi_snapshot_preview1":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmTable=Module["asm"]["__indirect_function_table"];addOnInit(Module["asm"]["__wasm_call_ctors"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;var ASM_CONSTS={1105068:$0=>{console.log("Audio Version: ",$0)},1105105:($0,$1)=>{send_data($0,$1)},1105128:($0,$1)=>{SAVE_IV($0,$1)},1105146:($0,$1,$2,$3)=>{audio_encode_frame_callback($0,$1,$2,$3)},1105195:($0,$1,$2)=>{Get_ExternalRecord($0,$1,$2)},1105231:()=>{return Date.now()},1105254:($0,$1)=>{update_play_time($0,$1)},1105284:()=>{AudioWasmAdapter.onMuteSpeechWarningWASM()},1105331:($0,$1)=>{AudioWasmAdapter.onMonitorLogWASM($0,$1)},1105374:($0,$1)=>{AudioWasmAdapter.onAudioLevelWASM($0,$1)},1105417:($0,$1,$2)=>{network_quality_callback($0,$1,$2)},1105457:($0,$1,$2,$3)=>{AudioWasmAdapter.onAPMProcessedPCMWASM($0,$1,$2,$3)},1105517:($0,$1,$2,$3)=>{pump_rtp_data($0,$1,$2,$3)},1105552:($0,$1,$2,$3)=>{pump_rtp_data($0,$1,$2,$3)},1105587:($0,$1,$2,$3,$4,$5,$6,$7)=>{responseAudioQosData($0,$1,$2,$3,$4,$5,$6,$7)},1105642:($0,$1,$2,$3,$4)=>{sampleRateLog($0,$1,$2,$3,$4)},1105679:($0,$1,$2,$3,$4)=>{sampleRateLog($0,$1,$2,$3,$4)},1105716:($0,$1,$2,$3,$4,$5,$6,$7)=>{frame_callback($0,$1,$2,$3,$4,$5,$6,$7)},1105768:($0,$1)=>{get_edition($0,$1)},1105793:($0,$1)=>{SAVE_IV($0,$1)},1105811:($0,$1)=>{COMMIT_PRINT($0,$1)},1105833:($0,$1,$2,$3)=>{LOG_OUT_WEBRTC($0,$1,$2,$3)},1105869:($0,$1,$2,$3)=>{LOG_OUT_WEBRTC($0,$1,$2,$3)},1105905:($0,$1,$2,$3)=>{LOG_OUT_WEBRTC($0,$1,$2,$3)},1105941:($0,$1,$2,$3)=>{LOG_OUT_WEBRTC($0,$1,$2,$3)},1105977:($0,$1)=>{LOG_OUT($0,$1)},1105998:($0,$1)=>{wcl_trace_log($0,$1)}};function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function withStackSave(f){var stack=stackSave();var ret=f();stackRestore(stack);return ret}function demangle(func){demangle.recursionGuard=(demangle.recursionGuard|0)+1;if(demangle.recursionGuard>1)return func;return withStackSave(function(){try{var s=func;if(s.startsWith("__Z"))s=s.substr(1);var len=lengthBytesUTF8(s)+1;var buf=stackAlloc(len);stringToUTF8(s,buf,len);var status=stackAlloc(4);var ret=___cxa_demangle(buf,0,0,status);if(HEAP32[status>>2]===0&&ret){return UTF8ToString(ret)}}catch(e){}finally{_free(ret);if(demangle.recursionGuard<2)--demangle.recursionGuard}return func})}function jsStackTrace(){var error=new Error;if(!error.stack){try{throw new Error}catch(e){error=e}if(!error.stack){return"(no stack trace available)"}}return error.stack.toString()}function demangleAll(text){var regex=/\b_Z[\w\d_]+/g;return text.replace(regex,function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"})}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}function ___cxa_allocate_exception(size){return _malloc(size+24)+24}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=prev-1;return prev===1};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer){return HEAPU32[this.excPtr>>2]}var adjusted=this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}var PATH={isAbs:path=>path.charAt(0)==="/",splitPath:filename=>{var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(p=>!!p),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:path=>{if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},join:function(){var paths=Array.prototype.slice.call(arguments);return PATH.normalize(paths.join("/"))},join2:(l,r)=>{return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto=="object"&&typeof crypto["getRandomValues"]=="function"){var randomBuffer=new Uint8Array(1);return()=>{crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else return()=>abort("randomDevice")}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(p=>!!p),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:(from,to)=>{from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")}};function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var TTY={ttys:[],init:function(){},shutdown:function(){},register:function(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open:function(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close:function(stream){stream.tty.ops.fsync(stream.tty)},fsync:function(stream){stream.tty.ops.fsync(stream.tty)},read:function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i<length;i++){var result;try{result=stream.tty.ops.get_char(stream.tty)}catch(e){throw new FS.ErrnoError(29)}if(result===undefined&&bytesRead===0){throw new FS.ErrnoError(6)}if(result===null||result===undefined)break;bytesRead++;buffer[offset+i]=result}if(bytesRead){stream.node.timestamp=Date.now()}return bytesRead},write:function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.put_char){throw new FS.ErrnoError(60)}try{for(var i=0;i<length;i++){stream.tty.ops.put_char(stream.tty,buffer[offset+i])}}catch(e){throw new FS.ErrnoError(29)}if(length){stream.node.timestamp=Date.now()}return i}},default_tty_ops:{get_char:function(tty){if(!tty.input.length){var result=null;if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function mmapAlloc(size){abort()}var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray:function(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage:function(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity<CAPACITY_DOUBLING_MAX?2:1.125)>>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i<size;i++)buffer[offset+i]=contents[position+i]}return size},write:function(stream,buffer,offset,length,position,canOwn){if(buffer.buffer===HEAP8.buffer){canOwn=false}if(!length)return 0;var node=stream.node;node.timestamp=Date.now();if(buffer.subarray&&(!node.contents||node.contents.subarray)){if(canOwn){node.contents=buffer.subarray(offset,offset+length);node.usedBytes=length;return length}else if(node.usedBytes===0&&position===0){node.contents=buffer.slice(offset,offset+length);node.usedBytes=length;return length}else if(position+length<=node.usedBytes){node.contents.set(buffer.subarray(offset,offset+length),position);return length}}MEMFS.expandFileStorage(node,position+length);if(node.contents.subarray&&buffer.subarray){node.contents.set(buffer.subarray(offset,offset+length),position)}else{for(var i=0;i<length;i++){node.contents[position+i]=buffer[offset+i]}}node.usedBytes=Math.max(node.usedBytes,position+length);return length},llseek:function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.usedBytes}}if(position<0){throw new FS.ErrnoError(28)}return position},allocate:function(stream,offset,length){MEMFS.expandFileStorage(stream.node,offset+length);stream.node.usedBytes=Math.max(stream.node.usedBytes,offset+length)},mmap:function(stream,length,position,prot,flags){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}var ptr;var allocated;var contents=stream.node.contents;if(!(flags&2)&&contents.buffer===buffer){allocated=false;ptr=contents.byteOffset}else{if(position>0||position+length<contents.length){if(contents.subarray){contents=contents.subarray(position,position+length)}else{contents=Array.prototype.slice.call(contents,position,position+length)}}allocated=true;ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}HEAP8.set(contents,ptr)}return{ptr:ptr,allocated:allocated}},msync:function(stream,buffer,offset,length,mmapFlags){MEMFS.stream_ops.write(stream,buffer,0,length,offset,false);return 0}}};function asyncLoad(url,onload,onerror,noRunDep){var dep=!noRunDep?getUniqueRunDependency("al "+url):"";readAsync(url,arrayBuffer=>{assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).');onload(new Uint8Array(arrayBuffer));if(dep)removeRunDependency(dep)},event=>{if(onerror){onerror()}else{throw'Loading data file "'+url+'" failed.'}});if(dep)addRunDependency(dep)}var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(path,opts={})=>{path=PATH_FS.resolve(path);if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};opts=Object.assign(defaults,opts);if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=path.split("/").filter(p=>!!p);var current=FS.root;var current_path="/";for(var i=0;i<parts.length;i++){var islast=i===parts.length-1;if(islast&&opts.parent){break}current=FS.lookupNode(current,parts[i]);current_path=PATH.join2(current_path,parts[i]);if(FS.isMountpoint(current)){if(!islast||islast&&opts.follow_mount){current=current.mounted.root}}if(!islast||opts.follow){var count=0;while(FS.isLink(current.mode)){var link=FS.readlink(current_path);current_path=PATH_FS.resolve(PATH.dirname(current_path),link);var lookup=FS.lookupPath(current_path,{recurse_count:opts.recurse_count+1});current=lookup.node;if(count++>40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:node=>{var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:(parentid,name)=>{var hash=0;for(var i=0;i<name.length;i++){hash=(hash<<5)-hash+name.charCodeAt(i)|0}return(parentid+hash>>>0)%FS.nameTable.length},hashAddNode:node=>{var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:node=>{var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:(parent,name)=>{var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:(parent,name,mode,rdev)=>{var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:node=>{FS.hashRemoveNode(node)},isRoot:node=>{return node===node.parent},isMountpoint:node=>{return!!node.mounted},isFile:mode=>{return(mode&61440)===32768},isDir:mode=>{return(mode&61440)===16384},isLink:mode=>{return(mode&61440)===40960},isChrdev:mode=>{return(mode&61440)===8192},isBlkde