trtc-sdk-v5 5.14.2-beta.7 → 5.14.2-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/debug-dialog.js +2 -2
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/chorus/package.json +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/fast-webrtc/fast-webrtc.esm.d.ts +27 -0
- package/plugins/fast-webrtc/fast-webrtc.esm.js +1 -0
- package/plugins/fast-webrtc/fast-webrtc.umd.js +1 -0
- package/plugins/fast-webrtc/package.json +29 -0
- package/plugins/lebplayer/lebplayer.esm.d.ts +27 -0
- package/plugins/lebplayer/lebplayer.esm.js +1 -0
- package/plugins/lebplayer/lebplayer.umd.js +1 -0
- package/plugins/lebplayer/package.json +29 -0
- package/plugins/small-stream-auto-switcher/package.json +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.js +1 -1
- package/plugins/video-decoder/video-decoder.umd.js +1 -1
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.esm.js +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.esm.js +36 -36
- package/trtc.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __create=Object.create,__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropNames=Object.getOwnPropertyNames,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__objRest=(e,t)=>{var r={};for(var n in e)__hasOwnProp.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))t.indexOf(n)<0&&__propIsEnum.call(e,n)&&(r[n]=e[n]);return r},__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__copyProps=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of __getOwnPropNames(t))__hasOwnProp.call(e,o)||o===r||__defProp(e,o,{get:()=>t[o],enumerable:!(n=__getOwnPropDesc(t,o))||n.enumerable});return e},__toESM=(e,t,r)=>(r=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?r:__defProp(r,"default",{value:e,enumerable:!0}),e)),__decorateClass=(e,t,r,n)=>{for(var o,i=n>1?void 0:n?__getOwnPropDesc(t,r):t,s=e.length-1;s>=0;s--)(o=e[s])&&(i=(n?o(t,r,i):o(i))||i);return n&&i&&__defProp(t,r,i),i},__publicField=(e,t,r)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),require_eventemitter3=__commonJS({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(e,t){"use strict";var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function u(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),u.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},u.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},u.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,o,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var u,c,l=this._events[a],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,i),!0;case 6:return l.fn.call(l.context,t,r,o,i,s),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,r);break;case 4:l[c].fn.call(l[c].context,t,r,o);break;default:if(!u)for(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},u.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||a(this,i);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==t||o&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:a(this,i)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new o,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=n,u.EventEmitter=u,void 0!==t&&(t.exports=u)}}),import_eventemitter3=__toESM(require_eventemitter3(),1),instance=Symbol("instance"),abortCtrl=Symbol("abortCtrl"),cacheResult=Symbol("cacheResult"),MiddleState=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,setState.call(e,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},FSMError=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};function thenAble(e){return"object"==typeof e&&e&&"then"in e}var stateDiagram=new Map;function ChangeState(e,t,r={}){return(n,o,i)=>{const s=r.action||o;if(!r.context){const r=stateDiagram.get(n)||[];stateDiagram.has(n)||stateDiagram.set(n,r),r.push({from:e,to:t,action:s})}const a=i.value;i.value=function(...n){let o=this;if(r.context&&(o=FSM.get("function"==typeof r.context?r.context.call(this,...n):r.context)),o.state===t)return r.sync?o[cacheResult]:Promise.resolve(o[cacheResult]);o.state instanceof MiddleState&&o.state.action==r.abortAction&&o.state.abort(o);let i=null;Array.isArray(e)?0==e.length?o.state instanceof MiddleState&&o.state.abort(o):"string"==typeof o.state&&e.includes(o.state)||(i=new FSMError(o._state,`${o.name} ${s} to ${t} failed: current state ${o._state} not from ${e.join("|")}`)):e!==o.state&&(i=new FSMError(o._state,`${o.name} ${s} to ${t} failed: current state ${o._state} not from ${e}`));const u=e=>{if(r.fail&&r.fail.call(this,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(i)return u(i);const c=o.state,l=new MiddleState(c,t,s);setState.call(o,l);const d=e=>{var n;return o[cacheResult]=e,l.aborted||(setState.call(o,t),null===(n=r.success)||void 0===n||n.call(this,o[cacheResult])),e},h=e=>(setState.call(o,c,e),u(e));try{const e=a.apply(this,n);return thenAble(e)?e.then(d).catch(h):r.sync?d(e):Promise.resolve(d(e))}catch(r){return h(new FSMError(o._state,`${o.name} ${s} from ${e} to ${t} failed: ${r}`,r instanceof Error?r:new Error(String(r))))}}}}function Includes(...e){return(t,r,n)=>{const o=n.value,i=r;n.value=function(...t){if(!e.includes(this.state.toString()))throw new FSMError(this.state,`${this.name} ${i} failed: current state ${this.state} not in ${e}`);return o.apply(this,t)}}}var sendDevTools=(()=>{const e="undefined"!=typeof window&&window.__AFSM__,t="undefined"!=typeof importScripts;return e?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:t?(e,t)=>{postMessage({type:e,payload:t})}:()=>{}})();function setState(e,t){const r=this._state;this._state=e;const n=e.toString();e&&this.emit(n,r),this.emit(FSM.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var FSM=class e extends import_eventemitter3.default{constructor(t,r,n){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),n?Object.setPrototypeOf(this,n):n=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);const o=n[instance];o?this.name=o.name+"-"+o.count++:n[instance]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const e=Object.getPrototypeOf(this),t=stateDiagram.get(e)||[];let r=new Set,n=[],o=[];const i=new Set,s=Object.getPrototypeOf(e);stateDiagram.has(s)&&(s.stateDiagram.forEach((e=>r.add(e))),s.allStates.forEach((e=>i.add(e)))),t.forEach((({from:e,to:t,action:r})=>{"string"==typeof e?n.push({from:e,to:t,action:r}):e.length?e.forEach((e=>{n.push({from:e,to:t,action:r})})):o.push({to:t,action:r})})),n.forEach((({from:e,to:t,action:n})=>{i.add(e),i.add(t),i.add(n+"ing"),r.add(`${e} --\x3e ${n}ing : ${n}`),r.add(`${n}ing --\x3e ${t} : ${n} 🟢`),r.add(`${n}ing --\x3e ${e} : ${n} 🔴`)})),o.forEach((({to:e,action:t})=>{r.add(`${t}ing --\x3e ${e} : ${t} 🟢`),i.forEach((n=>{n!==e&&r.add(`${n} --\x3e ${t}ing : ${t}`)}))}));const a=[...r];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:i}}),a}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(t={}){sendDevTools(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){setState.call(this,e)}};FSM.STATECHANGED="stateChanged",FSM.UPDATEAFSM="updateAFSM",FSM.INIT="[*]",FSM.ON="on",FSM.OFF="off",FSM.instances=new Map,FSM.instances2=new WeakMap;var VideoDecoderHard=class extends FSM{constructor(){super(...arguments),__publicField(this,"decoder"),__publicField(this,"config")}async initialize(){this.decoder=new VideoDecoder({output:e=>{this.emit("videoFrame",e)},error:e=>{this.close(),this.emit("error",e)}})}configure(e){this.config=e,this.decoder.configure(__spreadProps(__spreadValues({},e),{codec:this.getCodec(e)}))}getCodec(e){switch(e.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return e.codec}}decode(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){"closed"!==this.decoder.state&&this.decoder.close()}};function WorkerScripts(){var e;self.onmessage=t=>{if("init"===t.data.type){const{canvas:r,wasmScript:n,wasmBinary:o}=t.data,i=null==r?void 0:r.getContext("2d");let s=0,a=0;const u={wasmBinary:o,postRun:()=>{e=new u.VideoDecoder({videoInfo(e,t){s=e,a=t,console.log("video info",e,t)},yuvData(e,t){const n=s*a,o=n>>2;let c=u.HEAPU32[e>>2],l=u.HEAPU32[1+(e>>2)],d=u.HEAPU32[2+(e>>2)],h=u.HEAPU8.subarray(c,c+n),f=u.HEAPU8.subarray(l,l+o),p=u.HEAPU8.subarray(d,d+o);const m=new Uint8Array(n+o+o);m.set(h),m.set(f,n),m.set(p,n+o);const g=new VideoFrame(m,{codedWidth:s,codedHeight:a,format:"I420",timestamp:t});r?(null==i||i.drawImage(g,0,0,r.width,r.height),null==i||i.commit()):self.postMessage({type:"yuvData",videoFrame:g},[g])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+n)()(u)}else if("decode"===t.data.type){const{packet:r}=t.data;null==e||e.decode(r.data,"key"==r.type,r.timestamp)}else if("setCodec"===t.data.type){const{codec:r,format:n,description:o}=t.data;null==e||e.setCodec(r,n,null!=o?o:"")}}}__decorateClass([ChangeState([FSM.INIT,"closed"],"initialized")],VideoDecoderHard.prototype,"initialize",1),__decorateClass([ChangeState("initialized","configured",{sync:!0})],VideoDecoderHard.prototype,"configure",1),__decorateClass([Includes("configured")],VideoDecoderHard.prototype,"decode",1),__decorateClass([ChangeState([],FSM.INIT,{sync:!0})],VideoDecoderHard.prototype,"reset",1),__decorateClass([ChangeState([],"closed",{ignoreError:!0,sync:!0})],VideoDecoderHard.prototype,"close",1);var VideoDecoderSoftBase=class extends FSM{constructor(e,t,r=!1,n,o=!1){super(),this.createModule=e,this.wasmBinary=t,this.workerMode=r,this.canvas=n,this.yuvMode=o,__publicField(this,"worker"),__publicField(this,"decoder"),__publicField(this,"config"),__publicField(this,"module",{}),__publicField(this,"width",0),__publicField(this,"height",0)}async initialize(e){var t;if(this.workerMode){const e=new RegExp("\\{(.+)\\}","s").exec(WorkerScripts.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"text/javascript"})));const r=null==(t=this.canvas)?void 0:t.transferControlToOffscreen(),n=await this.wasmBinary;return console.warn("worker mode",n),this.worker.postMessage({type:"init",canvas:r,wasmScript:this.createModule.toString(),wasmBinary:n},r?[r,n]:[n]),new Promise((e=>{this.worker.onmessage=t=>{if("ready"===t.data.type)delete this.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){const{videoFrame:e}=t.data;this.emit("videoFrame",e)}}}))}const r=this.module;return this.wasmBinary&&(r.wasmBinary=await this.wasmBinary),r.print=e=>console.log(e),r.printErr=e=>console.log(`[JS] ERROR: ${e}`),r.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise((t=>{r.postRun=e=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),t()},e&&Object.assign(r,e),this.createModule(r)}))}configure(e){var t,r,n;this.config=e;const o=this.config.codec.startsWith("avc")?"avc":"hevc",i=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(r=this.decoder)||r.setCodec(o,i,null!=(t=this.config.description)?t:""),null==(n=this.worker)||n.postMessage({type:"setCodec",codec:o,format:i,description:this.config.description})}decode(e){var t,r;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:e}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(e,t){this.width=e,this.height=t;let r={width:e,height:t};this.emit("videoCodecInfo",r)}yuvData(e,t){if(!this.module)return;const r=this.width*this.height,n=r>>2;let o=this.module.HEAPU32[e>>2],i=this.module.HEAPU32[1+(e>>2)],s=this.module.HEAPU32[2+(e>>2)],a=this.module.HEAPU8.subarray(o,o+r),u=this.module.HEAPU8.subarray(i,i+n),c=this.module.HEAPU8.subarray(s,s+n);if(this.yuvMode)return void this.emit("videoFrame",{y:a,u:u,v:c,timestamp:t});const l=new Uint8Array(r+n+n);l.set(a),l.set(u,r),l.set(c,r+n),this.emit("videoFrame",new VideoFrame(l,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}errorInfo(e){let t={errMsg:e};this.emit("error",t)}};__decorateClass([ChangeState([FSM.INIT,"closed"],"initialized")],VideoDecoderSoftBase.prototype,"initialize",1),__decorateClass([ChangeState("initialized","configured",{sync:!0})],VideoDecoderSoftBase.prototype,"configure",1),__decorateClass([ChangeState([],FSM.INIT,{sync:!0})],VideoDecoderSoftBase.prototype,"reset",1),__decorateClass([ChangeState([],"closed",{sync:!0})],VideoDecoderSoftBase.prototype,"close",1);var Module=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return function(t={}){var r,n,o=t;o.ready=new Promise(((e,t)=>{r=e,n=t}));var i,s,a,u=Object.assign({},o),c="./this.program",l="object"==typeof window,d="function"==typeof importScripts,h=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(l||d)&&(d?h=self.location.href:"undefined"!=typeof document&&document.currentScript&&(h=document.currentScript.src),e&&(h=e),h=0!==h.indexOf("blob:")?h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),s=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var f,p=o.print||console.log.bind(console),m=o.printErr||console.error.bind(console);Object.assign(o,u),u=null,o.arguments&&o.arguments,o.thisProgram&&(c=o.thisProgram),o.quit&&o.quit,o.wasmBinary&&(f=o.wasmBinary);var g,v;o.noExitRuntime;"object"!=typeof WebAssembly&&N("no native wasm support detected");var y,_,w,E,S,b,A,T,O,I=!1;var P=[],C=[],R=[];var $=0,D=null,k=null;function M(e){$++,o.monitorRunDependencies&&o.monitorRunDependencies($)}function U(e){if($--,o.monitorRunDependencies&&o.monitorRunDependencies($),0==$&&(null!==D&&(clearInterval(D),D=null),k)){var t=k;k=null,t()}}function N(e){o.onAbort&&o.onAbort(e),m(e="Aborted("+e+")"),I=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}var L,F,B,V;function x(e){return e.startsWith("data:application/octet-stream;base64,")}function j(e){if(e==L&&f)return new Uint8Array(f);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function W(e,t,r){return function(e){return f||!l&&!d||"function"!=typeof fetch?Promise.resolve().then((()=>j(e))):fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>j(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{m("failed to asynchronously prepare wasm: "+e),N(e)}))}x(L="videodec.wasm")||(F=L,L=o.locateFile?o.locateFile(F,h):h+F);var H=e=>{for(;e.length>0;)e.shift()(o)};function G(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){b[this.ptr+4>>2]=e},this.get_type=function(){return b[this.ptr+4>>2]},this.set_destructor=function(e){b[this.ptr+8>>2]=e},this.get_destructor=function(){return b[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,y[this.ptr+12|0]=e},this.get_caught=function(){return 0!=y[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,y[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=y[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){b[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return b[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Qt(this.get_type()))return b[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var z={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=z.isAbs(e),r="/"===e.substr(-1);return(e=z.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=z.splitPath(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=z.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return z.normalize(e.join("/"))},join2:(e,t)=>z.normalize(e+"/"+t)},Q=e=>(Q=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);N("initRandomDevice")})())(e),q={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:ae.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,t=z.isAbs(n)}return(t?"/":"")+(e=z.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=q.resolve(e).substr(1),t=q.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),i=Math.min(n.length,o.length),s=i,a=0;a<i;a++)if(n[a]!==o[a]){s=a;break}var u=[];for(a=s;a<n.length;a++)u.push("..");return(u=u.concat(o.slice(s))).join("/")}},X="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,J=(e,t,r)=>{for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&X)return X.decode(e.subarray(t,o));for(var i="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|u:(7&s)<<18|a<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var c=s-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i},K=[],Y=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t},Z=(e,t,r,n)=>{if(!(n>0))return 0;for(var o=r,i=r+n-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s);if(a<=127){if(r>=i)break;t[r++]=a}else if(a<=2047){if(r+1>=i)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=i)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=i)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-o};function ee(e,t,r){var n=r>0?r:Y(e)+1,o=new Array(n),i=Z(e,o,0,o.length);return t&&(o.length=i),o}var te={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){te.ttys[e]={input:[],output:[],ops:t},ae.registerDevice(e,te.stream_ops)},stream_ops:{open:function(e){var t=te.ttys[e.node.rdev];if(!t)throw new ae.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.get_char)throw new ae.ErrnoError(60);for(var i=0,s=0;s<n;s++){var a;try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new ae.ErrnoError(29)}if(void 0===a&&0===i)throw new ae.ErrnoError(6);if(null==a)break;i++,t[r+s]=a}return i&&(e.node.timestamp=Date.now()),i},write:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.put_char)throw new ae.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,t[r+i])}catch(e){throw new ae.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){return(()=>{if(!K.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;K=ee(e,!0)}return K.shift()})()},put_char:function(e,t){null===t||10===t?(p(J(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(p(J(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,t,r){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(m(J(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(m(J(e.output,0)),e.output=[])}}},re=e=>{N()},ne={ops_table:null,mount:e=>ne.createNode(null,"/",16895,0),createNode(e,t,r,n){if(ae.isBlkdev(r)||ae.isFIFO(r))throw new ae.ErrnoError(63);ne.ops_table||(ne.ops_table={dir:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr,lookup:ne.node_ops.lookup,mknod:ne.node_ops.mknod,rename:ne.node_ops.rename,unlink:ne.node_ops.unlink,rmdir:ne.node_ops.rmdir,readdir:ne.node_ops.readdir,symlink:ne.node_ops.symlink},stream:{llseek:ne.stream_ops.llseek}},file:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr},stream:{llseek:ne.stream_ops.llseek,read:ne.stream_ops.read,write:ne.stream_ops.write,allocate:ne.stream_ops.allocate,mmap:ne.stream_ops.mmap,msync:ne.stream_ops.msync}},link:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr,readlink:ne.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr},stream:ae.chrdev_stream_ops}});var o=ae.createNode(e,t,r,n);return ae.isDir(o.mode)?(o.node_ops=ne.ops_table.dir.node,o.stream_ops=ne.ops_table.dir.stream,o.contents={}):ae.isFile(o.mode)?(o.node_ops=ne.ops_table.file.node,o.stream_ops=ne.ops_table.file.stream,o.usedBytes=0,o.contents=null):ae.isLink(o.mode)?(o.node_ops=ne.ops_table.link.node,o.stream_ops=ne.ops_table.link.stream):ae.isChrdev(o.mode)&&(o.node_ops=ne.ops_table.chrdev.node,o.stream_ops=ne.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var n=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(n.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=ae.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ae.isDir(e.mode)?t.size=4096:ae.isFile(e.mode)?t.size=e.usedBytes:ae.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ne.resizeFileStorage(e,t.size)},lookup(e,t){throw ae.genericErrors[44]},mknod:(e,t,r,n)=>ne.createNode(e,t,r,n),rename(e,t,r){if(ae.isDir(e.mode)){var n;try{n=ae.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new ae.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=ae.lookupNode(e,t);for(var n in r.contents)throw new ae.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var n=ne.createNode(e,t,41471,0);return n.link=r,n},readlink(e){if(!ae.isLink(e.mode))throw new ae.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)t.set(i.subarray(o,o+s),r);else for(var a=0;a<s;a++)t[r+a]=i[o+a];return s},write(e,t,r,n,o,i){if(!n)return 0;var s=e.node;if(s.timestamp=Date.now(),t.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=t.subarray(r,r+n),s.usedBytes=n,n;if(0===s.usedBytes&&0===o)return s.contents=t.slice(r,r+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(t.subarray(r,r+n),o),n}if(ne.expandFileStorage(s,o+n),s.contents.subarray&&t.subarray)s.contents.set(t.subarray(r,r+n),o);else for(var a=0;a<n;a++)s.contents[o+a]=t[r+a];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek(e,t,r){var n=t;if(1===r?n+=e.position:2===r&&ae.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new ae.ErrnoError(28);return n},allocate(e,t,r){ne.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,n,o){if(!ae.isFile(e.node.mode))throw new ae.ErrnoError(43);var i,s,a=e.node.contents;if(2&o||a.buffer!==y.buffer){if((r>0||r+t<a.length)&&(a=a.subarray?a.subarray(r,r+t):Array.prototype.slice.call(a,r,r+t)),s=!0,!(i=re()))throw new ae.ErrnoError(48);y.set(a,i)}else s=!1,i=a.byteOffset;return{ptr:i,allocated:s}},msync:(e,t,r,n,o)=>(ne.stream_ops.write(e,t,0,n,r,!1),0)}},oe=(e,t,r,n)=>{var o=n?"":`al ${e}`;s(e,(r=>{var n;n=`Loading data file "${e}" failed (no arrayBuffer).`,r||N(n),t(new Uint8Array(r)),o&&U()}),(t=>{if(!r)throw`Loading data file "${e}" failed.`;r()})),o&&M()},ie=o.preloadPlugins||[];function se(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ae={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,t={})=>{if(!(e=q.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ae.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),n=ae.root,o="/",i=0;i<r.length;i++){var s=i===r.length-1;if(s&&t.parent)break;if(n=ae.lookupNode(n,r[i]),o=z.join2(o,r[i]),ae.isMountpoint(n)&&(!s||s&&t.follow_mount)&&(n=n.mounted.root),!s||t.follow)for(var a=0;ae.isLink(n.mode);){var u=ae.readlink(o);if(o=q.resolve(z.dirname(o),u),n=ae.lookupPath(o,{recurse_count:t.recurse_count+1}).node,a++>40)throw new ae.ErrnoError(32)}}return{path:o,node:n}},getPath:e=>{for(var t;;){if(ae.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?`${r}/${t}`:r+t:r}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName:(e,t)=>{for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%ae.nameTable.length},hashAddNode:e=>{var t=ae.hashName(e.parent.id,e.name);e.name_next=ae.nameTable[t],ae.nameTable[t]=e},hashRemoveNode:e=>{var t=ae.hashName(e.parent.id,e.name);if(ae.nameTable[t]===e)ae.nameTable[t]=e.name_next;else for(var r=ae.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:(e,t)=>{var r=ae.mayLookup(e);if(r)throw new ae.ErrnoError(r,e);for(var n=ae.hashName(e.id,t),o=ae.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===t)return o}return ae.lookup(e,t)},createNode:(e,t,r,n)=>{var o=new ae.FSNode(e,t,r,n);return ae.hashAddNode(o),o},destroyNode:e=>{ae.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ae.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>{var t=ae.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:(e,t)=>{try{ae.lookupNode(e,t);return 20}catch(e){}return ae.nodePermissions(e,"wx")},mayDelete:(e,t,r)=>{var n;try{n=ae.lookupNode(e,t)}catch(e){return e.errno}var o=ae.nodePermissions(e,"wx");if(o)return o;if(r){if(!ae.isDir(n.mode))return 54;if(ae.isRoot(n)||ae.getPath(n)===ae.cwd())return 10}else if(ae.isDir(n.mode))return 31;return 0},mayOpen:(e,t)=>e?ae.isLink(e.mode)?32:ae.isDir(e.mode)&&("r"!==ae.flagsToPermissionString(t)||512&t)?31:ae.nodePermissions(e,ae.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=ae.MAX_OPEN_FDS;e++)if(!ae.streams[e])return e;throw new ae.ErrnoError(33)},getStreamChecked:e=>{var t=ae.getStream(e);if(!t)throw new ae.ErrnoError(8);return t},getStream:e=>ae.streams[e],createStream:(e,t=-1)=>(ae.FSStream||(ae.FSStream=function(){this.shared={}},ae.FSStream.prototype={},Object.defineProperties(ae.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return!!(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new ae.FSStream,e),-1==t&&(t=ae.nextfd()),e.fd=t,ae.streams[t]=e,e),closeStream:e=>{ae.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ae.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ae.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ae.devices[e]={stream_ops:t}},getDevice:e=>ae.devices[e],getMounts:e=>{for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ae.syncFSRequests++,ae.syncFSRequests>1&&m(`warning: ${ae.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var r=ae.getMounts(ae.root.mount),n=0;function o(e){return ae.syncFSRequests--,t(e)}function i(e){if(e)return i.errored?void 0:(i.errored=!0,o(e));++n>=r.length&&o(null)}r.forEach((t=>{if(!t.type.syncfs)return i(null);t.type.syncfs(t,e,i)}))},mount:(e,t,r)=>{var n,o="/"===r,i=!r;if(o&&ae.root)throw new ae.ErrnoError(10);if(!o&&!i){var s=ae.lookupPath(r,{follow_mount:!1});if(r=s.path,n=s.node,ae.isMountpoint(n))throw new ae.ErrnoError(10);if(!ae.isDir(n.mode))throw new ae.ErrnoError(54)}var a={type:e,opts:t,mountpoint:r,mounts:[]},u=e.mount(a);return u.mount=a,a.root=u,o?ae.root=u:n&&(n.mounted=a,n.mount&&n.mount.mounts.push(a)),u},unmount:e=>{var t=ae.lookupPath(e,{follow_mount:!1});if(!ae.isMountpoint(t.node))throw new ae.ErrnoError(28);var r=t.node,n=r.mounted,o=ae.getMounts(n);Object.keys(ae.nameTable).forEach((e=>{for(var t=ae.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ae.destroyNode(t),t=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,r)=>{var n=ae.lookupPath(e,{parent:!0}).node,o=z.basename(e);if(!o||"."===o||".."===o)throw new ae.ErrnoError(28);var i=ae.mayCreate(n,o);if(i)throw new ae.ErrnoError(i);if(!n.node_ops.mknod)throw new ae.ErrnoError(63);return n.node_ops.mknod(n,o,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ae.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ae.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{ae.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,ae.mknod(e,t,r)),symlink:(e,t)=>{if(!q.resolve(e))throw new ae.ErrnoError(44);var r=ae.lookupPath(t,{parent:!0}).node;if(!r)throw new ae.ErrnoError(44);var n=z.basename(t),o=ae.mayCreate(r,n);if(o)throw new ae.ErrnoError(o);if(!r.node_ops.symlink)throw new ae.ErrnoError(63);return r.node_ops.symlink(r,n,e)},rename:(e,t)=>{var r,n,o=z.dirname(e),i=z.dirname(t),s=z.basename(e),a=z.basename(t);if(r=ae.lookupPath(e,{parent:!0}).node,n=ae.lookupPath(t,{parent:!0}).node,!r||!n)throw new ae.ErrnoError(44);if(r.mount!==n.mount)throw new ae.ErrnoError(75);var u,c=ae.lookupNode(r,s),l=q.relative(e,i);if("."!==l.charAt(0))throw new ae.ErrnoError(28);if("."!==(l=q.relative(t,o)).charAt(0))throw new ae.ErrnoError(55);try{u=ae.lookupNode(n,a)}catch(e){}if(c!==u){var d=ae.isDir(c.mode),h=ae.mayDelete(r,s,d);if(h)throw new ae.ErrnoError(h);if(h=u?ae.mayDelete(n,a,d):ae.mayCreate(n,a))throw new ae.ErrnoError(h);if(!r.node_ops.rename)throw new ae.ErrnoError(63);if(ae.isMountpoint(c)||u&&ae.isMountpoint(u))throw new ae.ErrnoError(10);if(n!==r&&(h=ae.nodePermissions(r,"w")))throw new ae.ErrnoError(h);ae.hashRemoveNode(c);try{r.node_ops.rename(c,n,a)}catch(e){throw e}finally{ae.hashAddNode(c)}}},rmdir:e=>{var t=ae.lookupPath(e,{parent:!0}).node,r=z.basename(e),n=ae.lookupNode(t,r),o=ae.mayDelete(t,r,!0);if(o)throw new ae.ErrnoError(o);if(!t.node_ops.rmdir)throw new ae.ErrnoError(63);if(ae.isMountpoint(n))throw new ae.ErrnoError(10);t.node_ops.rmdir(t,r),ae.destroyNode(n)},readdir:e=>{var t=ae.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ae.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ae.lookupPath(e,{parent:!0}).node;if(!t)throw new ae.ErrnoError(44);var r=z.basename(e),n=ae.lookupNode(t,r),o=ae.mayDelete(t,r,!1);if(o)throw new ae.ErrnoError(o);if(!t.node_ops.unlink)throw new ae.ErrnoError(63);if(ae.isMountpoint(n))throw new ae.ErrnoError(10);t.node_ops.unlink(t,r),ae.destroyNode(n)},readlink:e=>{var t=ae.lookupPath(e).node;if(!t)throw new ae.ErrnoError(44);if(!t.node_ops.readlink)throw new ae.ErrnoError(28);return q.resolve(ae.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var r=ae.lookupPath(e,{follow:!t}).node;if(!r)throw new ae.ErrnoError(44);if(!r.node_ops.getattr)throw new ae.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>ae.stat(e,!0),chmod:(e,t,r)=>{var n;"string"==typeof e?n=ae.lookupPath(e,{follow:!r}).node:n=e;if(!n.node_ops.setattr)throw new ae.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&t|-4096&n.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ae.chmod(e,t,!0)},fchmod:(e,t)=>{var r=ae.getStreamChecked(e);ae.chmod(r.node,t)},chown:(e,t,r,n)=>{var o;"string"==typeof e?o=ae.lookupPath(e,{follow:!n}).node:o=e;if(!o.node_ops.setattr)throw new ae.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,t,r)=>{ae.chown(e,t,r,!0)},fchown:(e,t,r)=>{var n=ae.getStreamChecked(e);ae.chown(n.node,t,r)},truncate:(e,t)=>{if(t<0)throw new ae.ErrnoError(28);var r;"string"==typeof e?r=ae.lookupPath(e,{follow:!0}).node:r=e;if(!r.node_ops.setattr)throw new ae.ErrnoError(63);if(ae.isDir(r.mode))throw new ae.ErrnoError(31);if(!ae.isFile(r.mode))throw new ae.ErrnoError(28);var n=ae.nodePermissions(r,"w");if(n)throw new ae.ErrnoError(n);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var r=ae.getStreamChecked(e);if(!(2097155&r.flags))throw new ae.ErrnoError(28);ae.truncate(r.node,t)},utime:(e,t,r)=>{var n=ae.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(t,r)})},open:(e,t,r)=>{if(""===e)throw new ae.ErrnoError(44);var n;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?function(e){var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error(`Unknown file open mode: ${e}`);return t}(t):t)?4095&r|32768:0,"object"==typeof e)n=e;else{e=z.normalize(e);try{n=ae.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var i=!1;if(64&t)if(n){if(128&t)throw new ae.ErrnoError(20)}else n=ae.mknod(e,r,0),i=!0;if(!n)throw new ae.ErrnoError(44);if(ae.isChrdev(n.mode)&&(t&=-513),65536&t&&!ae.isDir(n.mode))throw new ae.ErrnoError(54);if(!i){var s=ae.mayOpen(n,t);if(s)throw new ae.ErrnoError(s)}512&t&&!i&&ae.truncate(n,0),t&=-131713;var a=ae.createStream({node:n,path:ae.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return a.stream_ops.open&&a.stream_ops.open(a),!o.logReadFiles||1&t||(ae.readFiles||(ae.readFiles={}),e in ae.readFiles||(ae.readFiles[e]=1)),a},close:e=>{if(ae.isClosed(e))throw new ae.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ae.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,r)=>{if(ae.isClosed(e))throw new ae.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ae.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ae.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:(e,t,r,n,o)=>{if(n<0||o<0)throw new ae.ErrnoError(28);if(ae.isClosed(e))throw new ae.ErrnoError(8);if(1==(2097155&e.flags))throw new ae.ErrnoError(8);if(ae.isDir(e.node.mode))throw new ae.ErrnoError(31);if(!e.stream_ops.read)throw new ae.ErrnoError(28);var i=void 0!==o;if(i){if(!e.seekable)throw new ae.ErrnoError(70)}else o=e.position;var s=e.stream_ops.read(e,t,r,n,o);return i||(e.position+=s),s},write:(e,t,r,n,o,i)=>{if(n<0||o<0)throw new ae.ErrnoError(28);if(ae.isClosed(e))throw new ae.ErrnoError(8);if(!(2097155&e.flags))throw new ae.ErrnoError(8);if(ae.isDir(e.node.mode))throw new ae.ErrnoError(31);if(!e.stream_ops.write)throw new ae.ErrnoError(28);e.seekable&&1024&e.flags&&ae.llseek(e,0,2);var s=void 0!==o;if(s){if(!e.seekable)throw new ae.ErrnoError(70)}else o=e.position;var a=e.stream_ops.write(e,t,r,n,o,i);return s||(e.position+=a),a},allocate:(e,t,r)=>{if(ae.isClosed(e))throw new ae.ErrnoError(8);if(t<0||r<=0)throw new ae.ErrnoError(28);if(!(2097155&e.flags))throw new ae.ErrnoError(8);if(!ae.isFile(e.node.mode)&&!ae.isDir(e.node.mode))throw new ae.ErrnoError(43);if(!e.stream_ops.allocate)throw new ae.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:(e,t,r,n,o)=>{if(2&n&&!(2&o)&&2!=(2097155&e.flags))throw new ae.ErrnoError(2);if(1==(2097155&e.flags))throw new ae.ErrnoError(2);if(!e.stream_ops.mmap)throw new ae.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,o)},msync:(e,t,r,n,o)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,o):0,munmap:e=>0,ioctl:(e,t,r)=>{if(!e.stream_ops.ioctl)throw new ae.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:(e,t={})=>{if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error(`Invalid encoding type "${t.encoding}"`);var r,n=ae.open(e,t.flags),o=ae.stat(e).size,i=new Uint8Array(o);return ae.read(n,i,0,o,0),"utf8"===t.encoding?r=J(i,0):"binary"===t.encoding&&(r=i),ae.close(n),r},writeFile:(e,t,r={})=>{r.flags=r.flags||577;var n=ae.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(Y(t)+1),i=Z(t,o,0,o.length);ae.write(n,o,0,i,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ae.write(n,t,0,t.byteLength,void 0,r.canOwn)}ae.close(n)},cwd:()=>ae.currentPath,chdir:e=>{var t=ae.lookupPath(e,{follow:!0});if(null===t.node)throw new ae.ErrnoError(44);if(!ae.isDir(t.node.mode))throw new ae.ErrnoError(54);var r=ae.nodePermissions(t.node,"x");if(r)throw new ae.ErrnoError(r);ae.currentPath=t.path},createDefaultDirectories:()=>{ae.mkdir("/tmp"),ae.mkdir("/home"),ae.mkdir("/home/web_user")},createDefaultDevices:()=>{ae.mkdir("/dev"),ae.registerDevice(ae.makedev(1,3),{read:()=>0,write:(e,t,r,n,o)=>n}),ae.mkdev("/dev/null",ae.makedev(1,3)),te.register(ae.makedev(5,0),te.default_tty_ops),te.register(ae.makedev(6,0),te.default_tty1_ops),ae.mkdev("/dev/tty",ae.makedev(5,0)),ae.mkdev("/dev/tty1",ae.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=Q(e).byteLength),e[--t]);ae.createDevice("/dev","random",r),ae.createDevice("/dev","urandom",r),ae.mkdir("/dev/shm"),ae.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ae.mkdir("/proc");var e=ae.mkdir("/proc/self");ae.mkdir("/proc/self/fd"),ae.mount({mount:()=>{var t=ae.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var r=+t,n=ae.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?ae.createDevice("/dev","stdin",o.stdin):ae.symlink("/dev/tty","/dev/stdin"),o.stdout?ae.createDevice("/dev","stdout",null,o.stdout):ae.symlink("/dev/tty","/dev/stdout"),o.stderr?ae.createDevice("/dev","stderr",null,o.stderr):ae.symlink("/dev/tty1","/dev/stderr");ae.open("/dev/stdin",0),ae.open("/dev/stdout",1),ae.open("/dev/stderr",1)},ensureErrnoError:()=>{ae.ErrnoError||(ae.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ae.ErrnoError.prototype=new Error,ae.ErrnoError.prototype.constructor=ae.ErrnoError,[44].forEach((e=>{ae.genericErrors[e]=new ae.ErrnoError(e),ae.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{ae.ensureErrnoError(),ae.nameTable=new Array(4096),ae.mount(ne,{},"/"),ae.createDefaultDirectories(),ae.createDefaultDevices(),ae.createSpecialDirectories(),ae.filesystems={MEMFS:ne}},init:(e,t,r)=>{ae.init.initialized=!0,ae.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=t||o.stdout,o.stderr=r||o.stderr,ae.createStandardStreams()},quit:()=>{ae.init.initialized=!1;for(var e=0;e<ae.streams.length;e++){var t=ae.streams[e];t&&ae.close(t)}},findObject:(e,t)=>{var r=ae.analyzePath(e,t);return r.exists?r.object:null},analyzePath:(e,t)=>{try{e=(n=ae.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=ae.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=z.basename(e),n=ae.lookupPath(e,{follow:!t}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot="/"===n.path}catch(e){r.error=e.errno}return r},createPath:(e,t,r,n)=>{e="string"==typeof e?e:ae.getPath(e);for(var o=t.split("/").reverse();o.length;){var i=o.pop();if(i){var s=z.join2(e,i);try{ae.mkdir(s)}catch(e){}e=s}}return s},createFile:(e,t,r,n,o)=>{var i=z.join2("string"==typeof e?e:ae.getPath(e),t),s=se(n,o);return ae.create(i,s)},createDataFile:(e,t,r,n,o,i)=>{var s=t;e&&(e="string"==typeof e?e:ae.getPath(e),s=t?z.join2(e,t):e);var a=se(n,o),u=ae.create(s,a);if(r){if("string"==typeof r){for(var c=new Array(r.length),l=0,d=r.length;l<d;++l)c[l]=r.charCodeAt(l);r=c}ae.chmod(u,146|a);var h=ae.open(u,577);ae.write(h,r,0,r.length,0,i),ae.close(h),ae.chmod(u,a)}return u},createDevice:(e,t,r,n)=>{var o=z.join2("string"==typeof e?e:ae.getPath(e),t),i=se(!!r,!!n);ae.createDevice.major||(ae.createDevice.major=64);var s=ae.makedev(ae.createDevice.major++,0);return ae.registerDevice(s,{open:e=>{e.seekable=!1},close:e=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(e,t,n,o,i)=>{for(var s=0,a=0;a<o;a++){var u;try{u=r()}catch(e){throw new ae.ErrnoError(29)}if(void 0===u&&0===s)throw new ae.ErrnoError(6);if(null==u)break;s++,t[n+a]=u}return s&&(e.node.timestamp=Date.now()),s},write:(e,t,r,o,i)=>{for(var s=0;s<o;s++)try{n(t[r+s])}catch(e){throw new ae.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),s}}),ae.mkdev(o,i,s)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!i)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=ee(i(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new ae.ErrnoError(29)}},createLazyFile:(e,t,r,n,o)=>{function i(){this.lengthKnown=!1,this.chunks=[]}if(i.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},i.prototype.setDataGetter=function(e){this.getter=e},i.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,i=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,s=1048576;o||(s=n);var a=this;a.setDataGetter((e=>{var t=e*s,o=(e+1)*s-1;if(o=Math.min(o,n-1),void 0===a.chunks[e]&&(a.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>n-1)throw new Error("only "+n+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",r,!1),n!==s&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+r+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):ee(o.responseText||"",!0)})(t,o)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]})),!i&&n||(s=n=1,n=this.getter(0).length,s=n,p("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=s,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!d)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i;Object.defineProperties(s,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var a={isDevice:!1,contents:s}}else a={isDevice:!1,url:r};var u=ae.createFile(e,t,a,n,o);a.contents?u.contents=a.contents:a.url&&(u.contents=null,u.url=a.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={};function l(e,t,r,n,o){var i=e.node.contents;if(o>=i.length)return 0;var s=Math.min(i.length-o,n);if(i.slice)for(var a=0;a<s;a++)t[r+a]=i[o+a];else for(a=0;a<s;a++)t[r+a]=i.get(o+a);return s}return Object.keys(u.stream_ops).forEach((e=>{var t=u.stream_ops[e];c[e]=function(){return ae.forceLoadFile(u),t.apply(null,arguments)}})),c.read=(e,t,r,n,o)=>(ae.forceLoadFile(u),l(e,t,r,n,o)),c.mmap=(e,t,r,n,o)=>{ae.forceLoadFile(u);var i=re();if(!i)throw new ae.ErrnoError(48);return l(e,y,i,t,r),{ptr:i,allocated:!0}},u.stream_ops=c,u}},ue=(e,t)=>e?J(_,e,t):"",ce={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(z.isAbs(t))return t;var n;-100===e?n=ae.cwd():n=ce.getStreamFromFD(e).path;if(0==t.length){if(!r)throw new ae.ErrnoError(44);return n}return z.join2(n,t)},doStat:function(e,t,r){try{var n=e(t)}catch(e){if(e&&e.node&&z.normalize(t)!==z.normalize(ae.getPath(e.node)))return-54;throw e}S[r>>2]=n.dev,S[r+4>>2]=n.mode,b[r+8>>2]=n.nlink,S[r+12>>2]=n.uid,S[r+16>>2]=n.gid,S[r+20>>2]=n.rdev,V=[n.size>>>0,(B=n.size,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+24>>2]=V[0],S[r+28>>2]=V[1],S[r+32>>2]=4096,S[r+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return V=[Math.floor(o/1e3)>>>0,(B=Math.floor(o/1e3),+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+40>>2]=V[0],S[r+44>>2]=V[1],b[r+48>>2]=o%1e3*1e3,V=[Math.floor(i/1e3)>>>0,(B=Math.floor(i/1e3),+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+56>>2]=V[0],S[r+60>>2]=V[1],b[r+64>>2]=i%1e3*1e3,V=[Math.floor(s/1e3)>>>0,(B=Math.floor(s/1e3),+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+72>>2]=V[0],S[r+76>>2]=V[1],b[r+80>>2]=s%1e3*1e3,V=[n.ino>>>0,(B=n.ino,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+88>>2]=V[0],S[r+92>>2]=V[1],0},doMsync:function(e,t,r,n,o){if(!ae.isFile(t.node.mode))throw new ae.ErrnoError(43);if(2&n)return 0;var i=_.slice(e,e+r);ae.msync(t,i,o,r,n)},varargs:void 0,get:()=>(ce.varargs+=4,S[ce.varargs-4>>2]),getStr:e=>ue(e),getStreamFromFD:function(e){return ae.getStreamChecked(e)}};function le(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var de=void 0;function he(e){for(var t="",r=e;_[r];)t+=de[_[r++]];return t}var fe={},pe={},me={},ge=void 0;function ve(e){throw new ge(e)}var ye=void 0;function _e(e){throw new ye(e)}function we(e,t,r){function n(t){var n=r(t);n.length!==e.length&&_e("Mismatched type converter count");for(var o=0;o<e.length;++o)Ee(e[o],n[o])}e.forEach((function(e){me[e]=t}));var o=new Array(t.length),i=[],s=0;t.forEach(((e,t)=>{pe.hasOwnProperty(e)?o[t]=pe[e]:(i.push(e),fe.hasOwnProperty(e)||(fe[e]=[]),fe[e].push((()=>{o[t]=pe[e],++s===i.length&&n(o)})))})),0===i.length&&n(o)}function Ee(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t,r={}){var n=t.name;if(e||ve(`type "${n}" must have a positive integer typeid pointer`),pe.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;ve(`Cannot register type '${n}' twice`)}if(pe[e]=t,delete me[e],fe.hasOwnProperty(e)){var o=fe[e];delete fe[e],o.forEach((e=>e()))}}(e,t,r)}function Se(e){if(!(this instanceof He))return!1;if(!(e instanceof He))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return t===n&&r===o}function be(e){ve(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Ae=!1;function Te(e){}function Oe(e){e.count.value-=1,0===e.count.value&&function(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}(e)}function Ie(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var n=Ie(e,t,r.baseClass);return null===n?null:r.downcast(n)}var Pe={};function Ce(){return Object.keys(Ue).length}function Re(){var e=[];for(var t in Ue)Ue.hasOwnProperty(t)&&e.push(Ue[t]);return e}var $e=[];function De(){for(;$e.length;){var e=$e.pop();e.$$.deleteScheduled=!1,e.delete()}}var ke=void 0;function Me(e){ke=e,$e.length&&ke&&ke(De)}var Ue={};function Ne(e,t){return t=function(e,t){for(void 0===t&&ve("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),Ue[t]}function Le(e,t){return t.ptrType&&t.ptr||_e("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!==!!t.smartPtr&&_e("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Be(Object.create(e,{$$:{value:t}}))}function Fe(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=Ne(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var n=r.clone();return this.destructor(e),n}function o(){return this.isSmartPointer?Le(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Le(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,s=this.registeredClass.getActualType(t),a=Pe[s];if(!a)return o.call(this);i=this.isConst?a.constPointerType:a.pointerType;var u=Ie(t,this.registeredClass,i.registeredClass);return null===u?o.call(this):this.isSmartPointer?Le(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):Le(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}var Be=function(e){return"undefined"==typeof FinalizationRegistry?(Be=e=>e,e):(Ae=new FinalizationRegistry((e=>{Oe(e.$$)})),Te=e=>Ae.unregister(e),(Be=e=>{var t=e.$$;if(!!t.smartPtr){var r={$$:t};Ae.register(e,r,e)}return e})(e))};function Ve(){if(this.$$.ptr||be(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Be(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t}function xe(){this.$$.ptr||be(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ve("Object already scheduled for deletion"),Te(this),Oe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function je(){return!this.$$.ptr}function We(){return this.$$.ptr||be(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ve("Object already scheduled for deletion"),$e.push(this),1===$e.length&&ke&&ke(De),this.$$.deleteScheduled=!0,this}function He(){}function Ge(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?`_${e}`:e}function ze(e,t){return e=Ge(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Qe(e,t,r){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||ve(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function qe(e,t,r,n,o,i,s,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function Xe(e,t,r){for(;t!==r;)t.upcast||ve(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e}function Je(e,t){if(null===t)return this.isReference&&ve(`null is not a valid ${this.name}`),0;t.$$||ve(`Cannot pass "${wt(t)}" as a ${this.name}`),t.$$.ptr||ve(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Xe(t.$$.ptr,r,this.registeredClass)}function Ke(e,t){var r;if(null===t)return this.isReference&&ve(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||ve(`Cannot pass "${wt(t)}" as a ${this.name}`),t.$$.ptr||ve(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&ve(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var n=t.$$.ptrType.registeredClass;if(r=Xe(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&ve("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:ve(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,_t.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:ve("Unsupporting sharing policy")}return r}function Ye(e,t){if(null===t)return this.isReference&&ve(`null is not a valid ${this.name}`),0;t.$$||ve(`Cannot pass "${wt(t)}" as a ${this.name}`),t.$$.ptr||ve(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&ve(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Xe(t.$$.ptr,r,this.registeredClass)}function Ze(e){return this.fromWireType(S[e>>2])}function et(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function tt(e){this.rawDestructor&&this.rawDestructor(e)}function rt(e){null!==e&&e.delete()}function nt(e,t,r,n,o,i,s,a,u,c,l){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=l,o||void 0!==t.baseClass?this.toWireType=Ke:n?(this.toWireType=Je,this.destructorFunction=null):(this.toWireType=Ye,this.destructorFunction=null)}var ot=[],it=e=>{var t=ot[e];return t||(e>=ot.length&&(ot.length=e+1),ot[e]=t=O.get(e)),t},st=(e,t,r)=>e.includes("j")?((e,t,r)=>{var n=o["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)})(e,t,r):it(t).apply(null,r);function at(e,t){var r,n,o,i=(e=he(e)).includes("j")?(r=e,n=t,o=[],function(){return o.length=0,Object.assign(o,arguments),st(r,n,o)}):it(t);return"function"!=typeof i&&ve(`unknown function pointer with signature ${e}: ${t}`),i}var ut=void 0;function ct(e){var t=zt(e),r=he(t);return Ht(t),r}function lt(e,t){var r=[],n={};throw t.forEach((function e(t){n[t]||pe[t]||(me[t]?me[t].forEach(e):(r.push(t),n[t]=!0))})),new ut(`${e}: `+r.map(ct).join([", "]))}function dt(e,t){for(var r=[],n=0;n<e;n++)r.push(b[t+4*n>>2]);return r}function ht(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function ft(e,t){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var r=ze(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var n=new r,o=e.apply(n,t);return o instanceof Object?o:n}function pt(e,t,r,n,o,i){var s=t.length;s<2&&ve("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var a=null!==t[1]&&null!==r,u=!1,c=1;c<t.length;++c)if(null!==t[c]&&void 0===t[c].destructorFunction){u=!0;break}var l="void"!==t[0].name,d="",h="";for(c=0;c<s-2;++c)d+=(0!==c?", ":"")+"arg"+c,h+=(0!==c?", ":"")+"arg"+c+"Wired";var f=`\n return function ${Ge(e)}(${d}) {\n if (arguments.length !== ${s-2}) {\n throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${s-2} args!');\n }`;u&&(f+="var destructors = [];\n");var p=u?"destructors":"null",m=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],g=[ve,n,o,ht,t[0],t[1]];a&&(f+="var thisWired = classParam.toWireType("+p+", this);\n");for(c=0;c<s-2;++c)f+="var arg"+c+"Wired = argType"+c+".toWireType("+p+", arg"+c+"); // "+t[c+2].name+"\n",m.push("argType"+c),g.push(t[c+2]);if(a&&(h="thisWired"+(h.length>0?", ":"")+h),f+=(l||i?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",u)f+="runDestructors(destructors);\n";else for(c=a?1:2;c<t.length;++c){var v=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(f+=v+"_dtor("+v+"); // "+t[c].name+"\n",m.push(v+"_dtor"),g.push(t[c].destructorFunction))}return l&&(f+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),f+="}\n",m.push(f),ft(Function,m).apply(null,g)}function mt(){this.allocated=[void 0],this.freelist=[]}var gt=new mt;function vt(e){e>=gt.reserved&&0==--gt.get(e).refcount&>.free(e)}function yt(){for(var e=0,t=gt.reserved;t<gt.allocated.length;++t)void 0!==gt.allocated[t]&&++e;return e}var _t={toValue:e=>(e||ve("Cannot use deleted val. handle = "+e),gt.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return gt.allocate({refcount:1,value:e})}}};function wt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Et(e,t){switch(t){case 2:return function(e){return this.fromWireType(A[e>>2])};case 3:return function(e){return this.fromWireType(T[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function St(e,t,r){switch(t){case 0:return r?function(e){return y[e]}:function(e){return _[e]};case 1:return r?function(e){return w[e>>1]}:function(e){return E[e>>1]};case 2:return r?function(e){return S[e>>2]}:function(e){return b[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var bt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,At=(e,t)=>{for(var r=e,n=r>>1,o=n+t/2;!(n>=o)&&E[n];)++n;if((r=n<<1)-e>32&&bt)return bt.decode(_.subarray(e,r));for(var i="",s=0;!(s>=t/2);++s){var a=w[e+2*s>>1];if(0==a)break;i+=String.fromCharCode(a)}return i},Tt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var n=t,o=(r-=2)<2*e.length?r/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);w[t>>1]=s,t+=2}return w[t>>1]=0,t-n},Ot=e=>2*e.length,It=(e,t)=>{for(var r=0,n="";!(r>=t/4);){var o=S[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(o)}return n},Pt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var n=t,o=n+r-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i);if(S[t>>2]=s,(t+=4)+4>o)break}return S[t>>2]=0,t-n},Ct=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&++r,t+=4}return t};var Rt={};var $t=[];var Dt=[];var kt={},Mt=()=>{if(!Mt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var t in kt)void 0===kt[t]?delete e[t]:e[t]=kt[t];var r=[];for(var t in e)r.push(`${t}=${e[t]}`);Mt.strings=r}return Mt.strings};var Ut,Nt,Lt,Ft=function(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ae.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n},Bt=365,Vt=146;Object.defineProperties(Ft.prototype,{read:{get:function(){return(this.mode&Bt)===Bt},set:function(e){e?this.mode|=Bt:this.mode&=-366}},write:{get:function(){return(this.mode&Vt)===Vt},set:function(e){e?this.mode|=Vt:this.mode&=-147}},isFolder:{get:function(){return ae.isDir(this.mode)}},isDevice:{get:function(){return ae.isChrdev(this.mode)}}}),ae.FSNode=Ft,ae.createPreloadedFile=function(e,t,r,n,o,i,s,a,u,c){var l=t?q.resolve(z.join2(e,t)):e;function d(r){function d(r){c&&c(),a||ae.createDataFile(e,t,r,n,o,u),i&&i(),U()}(function(e,t,r,n){"undefined"!=typeof Browser&&Browser.init();var o=!1;return ie.forEach((function(i){o||i.canHandle(t)&&(i.handle(e,t,r,n),o=!0)})),o})(r,l,d,(()=>{s&&s(),U()}))||d(r)}M(),"string"==typeof r?oe(r,(e=>d(e)),s):d(r)},ae.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);de=e}(),ge=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},ye=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},He.prototype.isAliasOf=Se,He.prototype.clone=Ve,He.prototype.delete=xe,He.prototype.isDeleted=je,He.prototype.deleteLater=We,o.getInheritedInstanceCount=Ce,o.getLiveInheritedInstances=Re,o.flushPendingDeletes=De,o.setDelayFunction=Me,nt.prototype.getPointee=et,nt.prototype.destructor=tt,nt.prototype.argPackAdvance=8,nt.prototype.readValueFromPointer=Ze,nt.prototype.deleteObject=rt,nt.prototype.fromWireType=Fe,ut=o.UnboundTypeError=(Ut=Error,(Lt=ze(Nt="UnboundTypeError",(function(e){this.name=Nt,this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(Ut.prototype),Lt.prototype.constructor=Lt,Lt.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},Lt),Object.assign(mt.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),gt.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),gt.reserved=gt.allocated.length,o.count_emval_handles=yt;var xt,jt={p:function(e,t,r){throw new G(e).init(t,r),e},C:function(e,t,r){ce.varargs=r;try{var n=ce.getStreamFromFD(e);switch(t){case 0:return(o=ce.get())<0?-28:ae.createStream(n,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return n.flags;case 4:var o=ce.get();return n.flags|=o,0;case 5:o=ce.get();return w[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return i=28,S[Gt()>>2]=i,-1}}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return-e.errno}var i},w:function(e,t,r,n){ce.varargs=n;try{t=ce.getStr(t),t=ce.calculateAt(e,t);var o=n?ce.get():0;return ae.open(t,r,o).fd}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return-e.errno}},t:function(e,t,r,n,o){},n:function(e,t,r,n,o){var i=le(r);Ee(e,{name:t=he(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?n:o},argPackAdvance:8,readValueFromPointer:function(e){var n;if(1===r)n=y;else if(2===r)n=w;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=S}return this.fromWireType(n[e>>i])},destructorFunction:null})},r:function(e,t,r,n,i,s,a,u,c,l,d,h,f){d=he(d),s=at(i,s),u&&(u=at(a,u)),l&&(l=at(c,l)),f=at(h,f);var p=Ge(d);!function(e,t,r){o.hasOwnProperty(e)?((void 0===r||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[r])&&ve(`Cannot register public name '${e}' twice`),Qe(o,e,e),o.hasOwnProperty(r)&&ve(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),o[e].overloadTable[r]=t):(o[e]=t,void 0!==r&&(o[e].numArguments=r))}(p,(function(){lt(`Cannot construct ${d} due to unbound types`,[n])})),we([e,t,r],n?[n]:[],(function(t){var r,i;t=t[0],i=n?(r=t.registeredClass).instancePrototype:He.prototype;var a=ze(p,(function(){if(Object.getPrototypeOf(this)!==c)throw new ge("Use 'new' to construct "+d);if(void 0===h.constructor_body)throw new ge(d+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new ge(`Tried to invoke ctor of ${d} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,arguments)})),c=Object.create(i,{constructor:{value:a}});a.prototype=c;var h=new qe(d,a,c,f,r,s,u,l);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m=new nt(d,h,!0,!1,!1),g=new nt(d+"*",h,!1,!1,!1),v=new nt(d+" const*",h,!1,!0,!1);return Pe[e]={pointerType:g,constPointerType:v},function(e,t,r){o.hasOwnProperty(e)||_e("Replacing nonexistant public symbol"),void 0!==o[e].overloadTable&&void 0!==r?o[e].overloadTable[r]=t:(o[e]=t,o[e].argCount=r)}(p,a),[m,g,v]}))},q:function(e,t,r,n,o,i){var s=dt(t,r);o=at(n,o),we([],[e],(function(e){var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new ge(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{lt(`Cannot construct ${e.name} due to unbound types`,s)},we([],s,(function(n){return n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=pt(r,n,null,o,i),[]})),[]}))},d:function(e,t,r,n,o,i,s,a,u){var c=dt(r,n);t=he(t),i=at(o,i),we([],[e],(function(e){var n=`${(e=e[0]).name}.${t}`;function o(){lt(`Cannot call ${n} due to unbound types`,c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),a&&e.registeredClass.pureVirtualFunctions.push(t);var l=e.registeredClass.instancePrototype,d=l[t];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===r-2?(o.argCount=r-2,o.className=e.name,l[t]=o):(Qe(l,t,n),l[t].overloadTable[r-2]=o),we([],c,(function(o){var a=pt(n,o,e,i,s,u);return void 0===l[t].overloadTable?(a.argCount=r-2,l[t]=a):l[t].overloadTable[r-2]=a,[]})),[]}))},D:function(e,t){Ee(e,{name:t=he(t),fromWireType:function(e){var t=_t.toValue(e);return vt(e),t},toWireType:function(e,t){return _t.toHandle(t)},argPackAdvance:8,readValueFromPointer:Ze,destructorFunction:null})},k:function(e,t,r){var n=le(r);Ee(e,{name:t=he(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Et(t,n),destructorFunction:null})},c:function(e,t,r,n,o){t=he(t),-1===o&&(o=4294967295);var i=le(r),s=e=>e;if(0===n){var a=32-8*r;s=e=>e<<a>>>a}var u=t.includes("unsigned");Ee(e,{name:t,fromWireType:s,toWireType:u?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:St(t,i,0!==n),destructorFunction:null})},b:function(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=b,r=t[e>>=2],o=t[e+1];return new n(t.buffer,o,r)}Ee(e,{name:r=he(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=he(t));Ee(e,{name:t,fromWireType:function(e){var t,n=b[e>>2],o=e+4;if(r)for(var i=o,s=0;s<=n;++s){var a=o+s;if(s==n||0==_[a]){var u=ue(i,a-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=a+1}}else{var c=new Array(n);for(s=0;s<n;++s)c[s]=String.fromCharCode(_[o+s]);t=c.join("")}return Ht(e),t},toWireType:function(e,t){var n;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||ve("Cannot pass non-string to std::string"),n=r&&o?Y(t):t.length;var i=Wt(4+n+1),s=i+4;if(b[i>>2]=n,r&&o)Z(t,_,s,n+1);else if(o)for(var a=0;a<n;++a){var u=t.charCodeAt(a);u>255&&(Ht(s),ve("String has UTF-16 code units that do not fit in 8 bits")),_[s+a]=u}else for(a=0;a<n;++a)_[s+a]=t[a];return null!==e&&e.push(Ht,i),i},argPackAdvance:8,readValueFromPointer:Ze,destructorFunction:function(e){Ht(e)}})},f:function(e,t,r){var n,o,i,s,a;r=he(r),2===t?(n=At,o=Tt,s=Ot,i=()=>E,a=1):4===t&&(n=It,o=Pt,s=Ct,i=()=>b,a=2),Ee(e,{name:r,fromWireType:function(e){for(var r,o=b[e>>2],s=i(),u=e+4,c=0;c<=o;++c){var l=e+4+c*t;if(c==o||0==s[l>>a]){var d=n(u,l-u);void 0===r?r=d:(r+=String.fromCharCode(0),r+=d),u=l+t}}return Ht(e),r},toWireType:function(e,n){"string"!=typeof n&&ve(`Cannot pass non-string to C++ string type ${r}`);var i=s(n),u=Wt(4+i+t);return b[u>>2]=i>>a,o(n,u+4,i+t),null!==e&&e.push(Ht,u),u},argPackAdvance:8,readValueFromPointer:Ze,destructorFunction:function(e){Ht(e)}})},o:function(e,t){Ee(e,{isVoid:!0,name:t=he(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,n){var o,i;(e=$t[e])(t=_t.toValue(t),r=void 0===(i=Rt[o=r])?he(o):i,null,n)},m:vt,l:function(e,t){var r=function(e,t){for(var r,n,o,i=new Array(e),s=0;s<e;++s)i[s]=(r=b[t+4*s>>2],n="parameter "+s,o=void 0,void 0===(o=pe[r])&&ve(n+" has unknown type "+ct(r)),o);return i}(e,t),n=r[0],o=n.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",i=Dt[o];if(void 0!==i)return i;for(var s=["retType"],a=[n],u="",c=0;c<e-1;++c)u+=(0!==c?", ":"")+"arg"+c,s.push("argType"+c),a.push(r[1+c]);var l="return function "+Ge("methodCaller_"+o)+"(handle, name, destructors, args) {\n",d=0;for(c=0;c<e-1;++c)l+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(d?"+"+d:"")+");\n",d+=r[c+1].argPackAdvance;for(l+=" var rv = handle[name]("+u+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(l+=" argType"+c+".deleteObject(arg"+c+");\n");n.isVoid||(l+=" return retType.toWireType(destructors, rv);\n"),l+="};\n",s.push(l);var h,f,p=ft(Function,s).apply(null,a);return h=p,f=$t.length,$t.push(h),i=f,Dt[o]=i,i},a:()=>{N("")},e:function(){return Date.now()},v:()=>_.length,A:(e,t,r)=>_.copyWithin(e,t,t+r),u:e=>{_.length;N("OOM")},y:(e,t)=>{var r=0;return Mt().forEach((function(n,o){var i=t+r;b[e+4*o>>2]=i,((e,t)=>{for(var r=0;r<e.length;++r)y[0|t++]=e.charCodeAt(r);y[0|t]=0})(n,i),r+=n.length+1})),0},z:(e,t)=>{var r=Mt();b[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),b[t>>2]=n,0},i:function(e){try{var t=ce.getStreamFromFD(e);return ae.close(t),0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},x:function(e,t){try{var r=ce.getStreamFromFD(e),n=r.tty?2:ae.isDir(r.mode)?3:ae.isLink(r.mode)?7:4;return y[t|0]=n,w[t+2>>1]=0,V=[0,(B=0,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[t+8>>2]=V[0],S[t+12>>2]=V[1],V=[0,(B=0,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[t+16>>2]=V[0],S[t+20>>2]=V[1],0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},B:function(e,t,r,n){try{var o=((e,t,r,n)=>{for(var o=0,i=0;i<r;i++){var s=b[t>>2],a=b[t+4>>2];t+=8;var u=ae.read(e,y,s,a,n);if(u<0)return-1;if(o+=u,u<a)break;void 0!==n&&(n+=u)}return o})(ce.getStreamFromFD(e),t,r);return b[n>>2]=o,0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},s:function(e,t,r,n,o){var i,s,a=(s=r)+2097152>>>0<4194305-!!(i=t)?(i>>>0)+4294967296*s:NaN;try{if(isNaN(a))return 61;var u=ce.getStreamFromFD(e);return ae.llseek(u,a,n),V=[u.position>>>0,(B=u.position,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[o>>2]=V[0],S[o+4>>2]=V[1],u.getdents&&0===a&&0===n&&(u.getdents=null),0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},h:function(e,t,r,n){try{var o=((e,t,r,n)=>{for(var o=0,i=0;i<r;i++){var s=b[t>>2],a=b[t+4>>2];t+=8;var u=ae.write(e,y,s,a,n);if(u<0)return-1;o+=u,void 0!==n&&(n+=u)}return o})(ce.getStreamFromFD(e),t,r);return b[n>>2]=o,0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}}},Wt=(function(){var e,t,r,i,s={a:jt};function a(e,t){var r,n,i=e.exports;return g=(v=i).E,r=g.buffer,o.HEAP8=y=new Int8Array(r),o.HEAP16=w=new Int16Array(r),o.HEAP32=S=new Int32Array(r),o.HEAPU8=_=new Uint8Array(r),o.HEAPU16=E=new Uint16Array(r),o.HEAPU32=b=new Uint32Array(r),o.HEAPF32=A=new Float32Array(r),o.HEAPF64=T=new Float64Array(r),O=v.H,n=v.F,C.unshift(n),U(),i}if(M(),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(e){m("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=f,t=L,r=s,i=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||x(t)||"function"!=typeof fetch?W(t,r,i):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(i,(function(e){return m("wasm streaming compile failed: "+e),m("falling back to ArrayBuffer instantiation"),W(t,r,i)}))))).catch(n)}(),e=>(Wt=v.G)(e)),Ht=e=>(Ht=v.I)(e),Gt=()=>(Gt=v.J)(),zt=e=>(zt=v.K)(e),Qt=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=v.L)(),e=>(Qt=v.M)(e));o.dynCall_jiji=(e,t,r,n,i)=>(o.dynCall_jiji=v.N)(e,t,r,n,i),o._ff_h264_cabac_tables=67061;function qt(){function e(){xt||(xt=!0,o.calledRun=!0,I||(o.noFSInit||ae.init.initialized||ae.init(),ae.ignorePermissions=!1,te.init(),H(C),r(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),R.unshift(e);var e;H(R)}()))}$>0||(!function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),P.unshift(e);var e;H(P)}(),$>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(k=function e(){xt||qt(),xt||(k=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return qt(),t.ready}})(),videodec_default=Module,VideoDecoderSoft=class extends VideoDecoderSoftBase{constructor(e){super(videodec_default,(null==e?void 0:e.wasmPath)?fetch(null==e?void 0:e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}},Module2=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return function(t={}){var r,n,o=t;o.ready=new Promise(((e,t)=>{r=e,n=t}));var i,s=Object.assign({},o),a="object"==typeof window,u="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||u)&&(u?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),e&&(c=e),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",u&&(i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var l,d=o.print||console.log.bind(console),h=o.printErr||console.error.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(l=o.wasmBinary);var f,p;o.noExitRuntime;"object"!=typeof WebAssembly&&$("no native wasm support detected");var m,g,v,y,_,w,E,S,b,A=!1;var T=[],O=[],I=[];var P=0,C=null,R=null;function $(e){o.onAbort&&o.onAbort(e),h(e="Aborted("+e+")"),A=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}var D,k;function M(e){return e.startsWith("data:application/octet-stream;base64,")}function U(e){if(e==D&&l)return new Uint8Array(l);if(i)return i(e);throw"both async and sync fetching of the wasm failed"}function N(e,t,r){return function(e){return l||!a&&!u||"function"!=typeof fetch?Promise.resolve().then((()=>U(e))):fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>U(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{h("failed to asynchronously prepare wasm: "+e),$(e)}))}M(D="videodec_simd.wasm")||(k=D,D=o.locateFile?o.locateFile(k,c):c+k);var L=e=>{for(;e.length>0;)e.shift()(o)};function F(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){w[this.ptr+4>>2]=e},this.get_type=function(){return w[this.ptr+4>>2]},this.set_destructor=function(e){w[this.ptr+8>>2]=e},this.get_destructor=function(){return w[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,m[this.ptr+12|0]=e},this.get_caught=function(){return 0!=m[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,m[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=m[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){w[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return w[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Et(this.get_type()))return w[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}function B(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var V=void 0;function x(e){for(var t="",r=e;g[r];)t+=V[g[r++]];return t}var j={},W={},H={},G=void 0;function z(e){throw new G(e)}var Q=void 0;function q(e){throw new Q(e)}function X(e,t,r){function n(t){var n=r(t);n.length!==e.length&&q("Mismatched type converter count");for(var o=0;o<e.length;++o)J(e[o],n[o])}e.forEach((function(e){H[e]=t}));var o=new Array(t.length),i=[],s=0;t.forEach(((e,t)=>{W.hasOwnProperty(e)?o[t]=W[e]:(i.push(e),j.hasOwnProperty(e)||(j[e]=[]),j[e].push((()=>{o[t]=W[e],++s===i.length&&n(o)})))})),0===i.length&&n(o)}function J(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t,r={}){var n=t.name;if(e||z(`type "${n}" must have a positive integer typeid pointer`),W.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;z(`Cannot register type '${n}' twice`)}if(W[e]=t,delete H[e],j.hasOwnProperty(e)){var o=j[e];delete j[e],o.forEach((e=>e()))}}(e,t,r)}function K(e){if(!(this instanceof _e))return!1;if(!(e instanceof _e))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return t===n&&r===o}function Y(e){z(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Z=!1;function ee(e){}function te(e){e.count.value-=1,0===e.count.value&&function(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}(e)}function re(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var n=re(e,t,r.baseClass);return null===n?null:r.downcast(n)}var ne={};function oe(){return Object.keys(le).length}function ie(){var e=[];for(var t in le)le.hasOwnProperty(t)&&e.push(le[t]);return e}var se=[];function ae(){for(;se.length;){var e=se.pop();e.$$.deleteScheduled=!1,e.delete()}}var ue=void 0;function ce(e){ue=e,se.length&&ue&&ue(ae)}var le={};function de(e,t){return t=function(e,t){for(void 0===t&&z("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),le[t]}function he(e,t){return t.ptrType&&t.ptr||q("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!==!!t.smartPtr&&q("Both smartPtrType and smartPtr must be specified"),t.count={value:1},pe(Object.create(e,{$$:{value:t}}))}function fe(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=de(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var n=r.clone();return this.destructor(e),n}function o(){return this.isSmartPointer?he(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):he(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,s=this.registeredClass.getActualType(t),a=ne[s];if(!a)return o.call(this);i=this.isConst?a.constPointerType:a.pointerType;var u=re(t,this.registeredClass,i.registeredClass);return null===u?o.call(this):this.isSmartPointer?he(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):he(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}var pe=function(e){return"undefined"==typeof FinalizationRegistry?(pe=e=>e,e):(Z=new FinalizationRegistry((e=>{te(e.$$)})),ee=e=>Z.unregister(e),(pe=e=>{var t=e.$$;if(!!t.smartPtr){var r={$$:t};Z.register(e,r,e)}return e})(e))};function me(){if(this.$$.ptr||Y(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=pe(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t}function ge(){this.$$.ptr||Y(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&z("Object already scheduled for deletion"),ee(this),te(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function ve(){return!this.$$.ptr}function ye(){return this.$$.ptr||Y(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&z("Object already scheduled for deletion"),se.push(this),1===se.length&&ue&&ue(ae),this.$$.deleteScheduled=!0,this}function _e(){}function we(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?`_${e}`:e}function Ee(e,t){return e=we(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Se(e,t,r){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||z(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function be(e,t,r,n,o,i,s,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function Ae(e,t,r){for(;t!==r;)t.upcast||z(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e}function Te(e,t){if(null===t)return this.isReference&&z(`null is not a valid ${this.name}`),0;t.$$||z(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||z(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Ae(t.$$.ptr,r,this.registeredClass)}function Oe(e,t){var r;if(null===t)return this.isReference&&z(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||z(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||z(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&z(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var n=t.$$.ptrType.registeredClass;if(r=Ae(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&z("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:z(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,qe.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:z("Unsupporting sharing policy")}return r}function Ie(e,t){if(null===t)return this.isReference&&z(`null is not a valid ${this.name}`),0;t.$$||z(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||z(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&z(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Ae(t.$$.ptr,r,this.registeredClass)}function Pe(e){return this.fromWireType(_[e>>2])}function Ce(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function Re(e){this.rawDestructor&&this.rawDestructor(e)}function $e(e){null!==e&&e.delete()}function De(e,t,r,n,o,i,s,a,u,c,l){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=l,o||void 0!==t.baseClass?this.toWireType=Oe:n?(this.toWireType=Te,this.destructorFunction=null):(this.toWireType=Ie,this.destructorFunction=null)}var ke=[],Me=e=>{var t=ke[e];return t||(e>=ke.length&&(ke.length=e+1),ke[e]=t=b.get(e)),t},Ue=(e,t,r)=>e.includes("j")?((e,t,r)=>{var n=o["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)})(e,t,r):Me(t).apply(null,r);function Ne(e,t){var r,n,o,i=(e=x(e)).includes("j")?(r=e,n=t,o=[],function(){return o.length=0,Object.assign(o,arguments),Ue(r,n,o)}):Me(t);return"function"!=typeof i&&z(`unknown function pointer with signature ${e}: ${t}`),i}var Le=void 0;function Fe(e){var t=wt(e),r=x(t);return yt(t),r}function Be(e,t){var r=[],n={};throw t.forEach((function e(t){n[t]||W[t]||(H[t]?H[t].forEach(e):(r.push(t),n[t]=!0))})),new Le(`${e}: `+r.map(Fe).join([", "]))}function Ve(e,t){for(var r=[],n=0;n<e;n++)r.push(w[t+4*n>>2]);return r}function xe(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function je(e,t){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var r=Ee(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var n=new r,o=e.apply(n,t);return o instanceof Object?o:n}function We(e,t,r,n,o,i){var s=t.length;s<2&&z("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var a=null!==t[1]&&null!==r,u=!1,c=1;c<t.length;++c)if(null!==t[c]&&void 0===t[c].destructorFunction){u=!0;break}var l="void"!==t[0].name,d="",h="";for(c=0;c<s-2;++c)d+=(0!==c?", ":"")+"arg"+c,h+=(0!==c?", ":"")+"arg"+c+"Wired";var f=`\n return function ${we(e)}(${d}) {\n if (arguments.length !== ${s-2}) {\n throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${s-2} args!');\n }`;u&&(f+="var destructors = [];\n");var p=u?"destructors":"null",m=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],g=[z,n,o,xe,t[0],t[1]];a&&(f+="var thisWired = classParam.toWireType("+p+", this);\n");for(c=0;c<s-2;++c)f+="var arg"+c+"Wired = argType"+c+".toWireType("+p+", arg"+c+"); // "+t[c+2].name+"\n",m.push("argType"+c),g.push(t[c+2]);if(a&&(h="thisWired"+(h.length>0?", ":"")+h),f+=(l||i?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",u)f+="runDestructors(destructors);\n";else for(c=a?1:2;c<t.length;++c){var v=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(f+=v+"_dtor("+v+"); // "+t[c].name+"\n",m.push(v+"_dtor"),g.push(t[c].destructorFunction))}return l&&(f+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),f+="}\n",m.push(f),je(Function,m).apply(null,g)}function He(){this.allocated=[void 0],this.freelist=[]}var Ge=new He;function ze(e){e>=Ge.reserved&&0==--Ge.get(e).refcount&&Ge.free(e)}function Qe(){for(var e=0,t=Ge.reserved;t<Ge.allocated.length;++t)void 0!==Ge.allocated[t]&&++e;return e}var qe={toValue:e=>(e||z("Cannot use deleted val. handle = "+e),Ge.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Ge.allocate({refcount:1,value:e})}}};function Xe(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Je(e,t){switch(t){case 2:return function(e){return this.fromWireType(E[e>>2])};case 3:return function(e){return this.fromWireType(S[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ke(e,t,r){switch(t){case 0:return r?function(e){return m[e]}:function(e){return g[e]};case 1:return r?function(e){return v[e>>1]}:function(e){return y[e>>1]};case 2:return r?function(e){return _[e>>2]}:function(e){return w[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Ye="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,Ze=(e,t,r)=>{for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&Ye)return Ye.decode(e.subarray(t,o));for(var i="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|u:(7&s)<<18|a<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var c=s-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i},et=(e,t)=>e?Ze(g,e,t):"";var tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,rt=(e,t)=>{for(var r=e,n=r>>1,o=n+t/2;!(n>=o)&&y[n];)++n;if((r=n<<1)-e>32&&tt)return tt.decode(g.subarray(e,r));for(var i="",s=0;!(s>=t/2);++s){var a=v[e+2*s>>1];if(0==a)break;i+=String.fromCharCode(a)}return i},nt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var n=t,o=(r-=2)<2*e.length?r/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);v[t>>1]=s,t+=2}return v[t>>1]=0,t-n},ot=e=>2*e.length,it=(e,t)=>{for(var r=0,n="";!(r>=t/4);){var o=_[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(o)}return n},st=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var n=t,o=n+r-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i);if(_[t>>2]=s,(t+=4)+4>o)break}return _[t>>2]=0,t-n},at=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&++r,t+=4}return t};var ut={};var ct=[];var lt=[];var dt;dt=()=>performance.now();var ht,ft,pt,mt=[null,[],[]];!function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);V=e}(),G=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Q=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},_e.prototype.isAliasOf=K,_e.prototype.clone=me,_e.prototype.delete=ge,_e.prototype.isDeleted=ve,_e.prototype.deleteLater=ye,o.getInheritedInstanceCount=oe,o.getLiveInheritedInstances=ie,o.flushPendingDeletes=ae,o.setDelayFunction=ce,De.prototype.getPointee=Ce,De.prototype.destructor=Re,De.prototype.argPackAdvance=8,De.prototype.readValueFromPointer=Pe,De.prototype.deleteObject=$e,De.prototype.fromWireType=fe,Le=o.UnboundTypeError=(ht=Error,(pt=Ee(ft="UnboundTypeError",(function(e){this.name=ft,this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(ht.prototype),pt.prototype.constructor=pt,pt.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},pt),Object.assign(He.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Ge.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Ge.reserved=Ge.allocated.length,o.count_emval_handles=Qe;var gt,vt={o:function(e,t,r){throw new F(e).init(t,r),e},r:function(e,t,r,n,o){},m:function(e,t,r,n,o){var i=B(r);J(e,{name:t=x(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?n:o},argPackAdvance:8,readValueFromPointer:function(e){var n;if(1===r)n=m;else if(2===r)n=v;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=_}return this.fromWireType(n[e>>i])},destructorFunction:null})},q:function(e,t,r,n,i,s,a,u,c,l,d,h,f){d=x(d),s=Ne(i,s),u&&(u=Ne(a,u)),l&&(l=Ne(c,l)),f=Ne(h,f);var p=we(d);!function(e,t,r){o.hasOwnProperty(e)?((void 0===r||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[r])&&z(`Cannot register public name '${e}' twice`),Se(o,e,e),o.hasOwnProperty(r)&&z(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),o[e].overloadTable[r]=t):(o[e]=t,void 0!==r&&(o[e].numArguments=r))}(p,(function(){Be(`Cannot construct ${d} due to unbound types`,[n])})),X([e,t,r],n?[n]:[],(function(t){var r,i;t=t[0],i=n?(r=t.registeredClass).instancePrototype:_e.prototype;var a=Ee(p,(function(){if(Object.getPrototypeOf(this)!==c)throw new G("Use 'new' to construct "+d);if(void 0===h.constructor_body)throw new G(d+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new G(`Tried to invoke ctor of ${d} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,arguments)})),c=Object.create(i,{constructor:{value:a}});a.prototype=c;var h=new be(d,a,c,f,r,s,u,l);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m=new De(d,h,!0,!1,!1),g=new De(d+"*",h,!1,!1,!1),v=new De(d+" const*",h,!1,!0,!1);return ne[e]={pointerType:g,constPointerType:v},function(e,t,r){o.hasOwnProperty(e)||q("Replacing nonexistant public symbol"),void 0!==o[e].overloadTable&&void 0!==r?o[e].overloadTable[r]=t:(o[e]=t,o[e].argCount=r)}(p,a),[m,g,v]}))},p:function(e,t,r,n,o,i){var s=Ve(t,r);o=Ne(n,o),X([],[e],(function(e){var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new G(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{Be(`Cannot construct ${e.name} due to unbound types`,s)},X([],s,(function(n){return n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=We(r,n,null,o,i),[]})),[]}))},d:function(e,t,r,n,o,i,s,a,u){var c=Ve(r,n);t=x(t),i=Ne(o,i),X([],[e],(function(e){var n=`${(e=e[0]).name}.${t}`;function o(){Be(`Cannot call ${n} due to unbound types`,c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),a&&e.registeredClass.pureVirtualFunctions.push(t);var l=e.registeredClass.instancePrototype,d=l[t];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===r-2?(o.argCount=r-2,o.className=e.name,l[t]=o):(Se(l,t,n),l[t].overloadTable[r-2]=o),X([],c,(function(o){var a=We(n,o,e,i,s,u);return void 0===l[t].overloadTable?(a.argCount=r-2,l[t]=a):l[t].overloadTable[r-2]=a,[]})),[]}))},u:function(e,t){J(e,{name:t=x(t),fromWireType:function(e){var t=qe.toValue(e);return ze(e),t},toWireType:function(e,t){return qe.toHandle(t)},argPackAdvance:8,readValueFromPointer:Pe,destructorFunction:null})},k:function(e,t,r){var n=B(r);J(e,{name:t=x(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Je(t,n),destructorFunction:null})},b:function(e,t,r,n,o){t=x(t),-1===o&&(o=4294967295);var i=B(r),s=e=>e;if(0===n){var a=32-8*r;s=e=>e<<a>>>a}var u=t.includes("unsigned");J(e,{name:t,fromWireType:s,toWireType:u?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:Ke(t,i,0!==n),destructorFunction:null})},a:function(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=w,r=t[e>>=2],o=t[e+1];return new n(t.buffer,o,r)}J(e,{name:r=x(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=x(t));J(e,{name:t,fromWireType:function(e){var t,n=w[e>>2],o=e+4;if(r)for(var i=o,s=0;s<=n;++s){var a=o+s;if(s==n||0==g[a]){var u=et(i,a-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=a+1}}else{var c=new Array(n);for(s=0;s<n;++s)c[s]=String.fromCharCode(g[o+s]);t=c.join("")}return yt(e),t},toWireType:function(e,t){var n;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||z("Cannot pass non-string to std::string"),n=r&&o?(e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t})(t):t.length;var i=_t(4+n+1),s=i+4;if(w[i>>2]=n,r&&o)((e,t,r,n)=>{if(!(n>0))return 0;for(var o=r,i=r+n-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s)),a<=127){if(r>=i)break;t[r++]=a}else if(a<=2047){if(r+1>=i)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=i)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=i)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}t[r]=0})(t,g,s,n+1);else if(o)for(var a=0;a<n;++a){var u=t.charCodeAt(a);u>255&&(yt(s),z("String has UTF-16 code units that do not fit in 8 bits")),g[s+a]=u}else for(a=0;a<n;++a)g[s+a]=t[a];return null!==e&&e.push(yt,i),i},argPackAdvance:8,readValueFromPointer:Pe,destructorFunction:function(e){yt(e)}})},g:function(e,t,r){var n,o,i,s,a;r=x(r),2===t?(n=rt,o=nt,s=ot,i=()=>y,a=1):4===t&&(n=it,o=st,s=at,i=()=>w,a=2),J(e,{name:r,fromWireType:function(e){for(var r,o=w[e>>2],s=i(),u=e+4,c=0;c<=o;++c){var l=e+4+c*t;if(c==o||0==s[l>>a]){var d=n(u,l-u);void 0===r?r=d:(r+=String.fromCharCode(0),r+=d),u=l+t}}return yt(e),r},toWireType:function(e,n){"string"!=typeof n&&z(`Cannot pass non-string to C++ string type ${r}`);var i=s(n),u=_t(4+i+t);return w[u>>2]=i>>a,o(n,u+4,i+t),null!==e&&e.push(yt,u),u},argPackAdvance:8,readValueFromPointer:Pe,destructorFunction:function(e){yt(e)}})},n:function(e,t){J(e,{isVoid:!0,name:t=x(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},e:function(e,t,r,n){var o,i;(e=ct[e])(t=qe.toValue(t),r=void 0===(i=ut[o=r])?x(o):i,null,n)},l:ze,h:function(e,t){var r=function(e,t){for(var r,n,o,i=new Array(e),s=0;s<e;++s)i[s]=(r=w[t+4*s>>2],n="parameter "+s,o=void 0,void 0===(o=W[r])&&z(n+" has unknown type "+Fe(r)),o);return i}(e,t),n=r[0],o=n.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",i=lt[o];if(void 0!==i)return i;for(var s=["retType"],a=[n],u="",c=0;c<e-1;++c)u+=(0!==c?", ":"")+"arg"+c,s.push("argType"+c),a.push(r[1+c]);var l="return function "+we("methodCaller_"+o)+"(handle, name, destructors, args) {\n",d=0;for(c=0;c<e-1;++c)l+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(d?"+"+d:"")+");\n",d+=r[c+1].argPackAdvance;for(l+=" var rv = handle[name]("+u+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(l+=" argType"+c+".deleteObject(arg"+c+");\n");n.isVoid||(l+=" return retType.toWireType(destructors, rv);\n"),l+="};\n",s.push(l);var h,f,p=je(Function,s).apply(null,a);return h=p,f=ct.length,ct.push(h),i=f,lt[o]=i,i},f:()=>{$("")},c:dt,t:(e,t,r)=>g.copyWithin(e,t,t+r),s:e=>{g.length;$("OOM")},i:(e,t,r,n)=>{for(var o,i,s,a=0,u=0;u<r;u++){var c=w[t>>2],l=w[t+4>>2];t+=8;for(var f=0;f<l;f++)o=e,i=g[c+f],s=void 0,s=mt[o],0===i||10===i?((1===o?d:h)(Ze(s,0)),s.length=0):s.push(i);a+=l}return w[n>>2]=a,0}},yt=(function(){var e,t,r,i,s={a:vt};function a(e,t){var r,n,i=e.exports;return f=(p=i).v,r=f.buffer,o.HEAP8=m=new Int8Array(r),o.HEAP16=v=new Int16Array(r),o.HEAP32=_=new Int32Array(r),o.HEAPU8=g=new Uint8Array(r),o.HEAPU16=y=new Uint16Array(r),o.HEAPU32=w=new Uint32Array(r),o.HEAPF32=E=new Float32Array(r),o.HEAPF64=S=new Float64Array(r),b=p.z,n=p.w,O.unshift(n),function(){if(P--,o.monitorRunDependencies&&o.monitorRunDependencies(P),0==P&&(null!==C&&(clearInterval(C),C=null),R)){var e=R;R=null,e()}}(),i}if(P++,o.monitorRunDependencies&&o.monitorRunDependencies(P),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(e){h("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=l,t=D,r=s,i=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||M(t)||"function"!=typeof fetch?N(t,r,i):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(i,(function(e){return h("wasm streaming compile failed: "+e),h("falling back to ArrayBuffer instantiation"),N(t,r,i)}))))).catch(n)}(),e=>(yt=p.x)(e)),_t=e=>(_t=p.y)(e),wt=e=>(wt=p.A)(e),Et=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=p.B)(),e=>(Et=p.C)(e));o.dynCall_jiji=(e,t,r,n,i)=>(o.dynCall_jiji=p.D)(e,t,r,n,i);function St(){function e(){gt||(gt=!0,o.calledRun=!0,A||(L(O),r(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),I.unshift(e);var e;L(I)}()))}P>0||(!function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),T.unshift(e);var e;L(T)}(),P>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(R=function e(){gt||St(),gt||(R=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return St(),t.ready}})(),videodec_simd_default=Module2,VideoDecoderSoftSIMD=class extends VideoDecoderSoftBase{constructor(e){super(videodec_simd_default,(null==e?void 0:e.wasmPath)?fetch(e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}},INNER_EVENT=(e=>(e.ROOM_DESTROY="1",e.JOIN_START="21",e.JOIN_SCHEDULE_SUCCESS="22",e.JOIN_SIGNAL_CONNECTION_START="23",e.JOIN_SIGNAL_CONNECTION_END="24",e.JOIN_SEND_CMD="25",e.JOIN_RECEIVED_CMD_RES="26",e.JOIN_SUCCESS="27",e.JOIN_FAILED="28",e.LEAVE_START="51",e.LEAVE_SEND_CMD="52",e.LEAVE_SUCCESS="53",e.PUBLISH_START="61",e.SEND_FIRST_VIDEO_FRAME="62",e.PUBLISH_FAILED="63",e.SUBSCRIBE_START="81",e.SUBSCRIBE_SUCCESS="82",e.SUBSCRIBE_FAILED="84",e.UNSUBSCRIBE_SUCCESS="83",e.LOCAL_TRACK_CAPTURE_START="101",e.LOCAL_TRACK_CAPTURE_SUCCESS="102",e.LOCAL_TRACK_CAPTURE_FAILED="103",e.LOCAL_TRACK_PUBLISHED="104",e.LOCAL_TRACK_UNPUBLISHED="105",e.LOCAL_TRACK_REPLACED="106",e.SWITCH_DEVICE_SUCCESS="107",e.TRACK_MUTED="108",e.TRACK_UNMUTED="109",e.REMOTE_TRACK_SUBSCRIBED="110",e.REMOTE_TRACK_UNSUBSCRIBED="111",e.LOCAL_TRACK_RECAPTURE="112",e.LOCAL_AUDIO_STARTED="113",e.LOCAL_AUDIO_STOPPED="114",e.REMOTE_AUDIO_STARTED="115",e.REMOTE_AUDIO_STOPPED="116",e.PLAY_TRACK_START="151",e.PLAYER_STATE_CHANGED="152",e.VIDEO_LOADED_DATA="153",e.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",e.AUDIO_CONTEXT_LONG_SUSPENDED="155",e.REMOTE_VIDEO_PLAY_START="156",e.REMOTE_VIDEO_PLAY_FINISH="157",e.SIGNAL_CONNECTION_STATE_CHANGED="201",e.PEER_CONNECTION_STATE_CHANGED="202",e.SINGLE_CONNECTION_STAT="203",e.SPC_RECONNECTED="204",e.HEARTBEAT_REPORT="251",e.RECEIVED_PUBLISHED_USER_LIST="252",e.REMOTE_PUBLISH_STATE_CHANGED="253",e.AUDIO_LEVEL_INTERVAL="260",e.NETWORK_QUALITY="261",e.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",e.QUALITY_LIMITATION_CHANGED="263",e.LOG="264",e.AUDIO_PROCESSOR_DEBUG="265",e.SSO_SWITCH="266",e.SWITCH_ROOM_START="401",e.SWITCH_ROOM_SUCCESS="407",e.SWITCH_ROOM_FAILED="408",e))(INNER_EVENT||{}),version="5.0.0",IS_WORKER="undefined"!=typeof importScripts,IS_WORKLET="undefined"!=typeof registerProcessor,loggerProxy="",BASE_HOST="web.sdk.qcloud.com",BASE_DOC_URL=`https://${BASE_HOST}/trtc/webrtc/doc`,DOC_URL=`${BASE_DOC_URL}/zh-cn/`,LOGGER_DOMAIN="https://yun.tim.qq.com",LOGGER_DOMAIN_OVERSEA="https://apisgp.my-imcloud.com",LOGGER_CMD_TYPE={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},LOG_LEVEL=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(LOG_LEVEL||{}),STORAGE_EXPIRES_TIME=6048e5,videoProfileMap={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},defaultBigVideoProfile=videoProfileMap["480p_2"],defaultSmallVideoProfile=videoProfileMap["120p_2"],NAME={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",RESIZE:"resize",TIME_UPDATE:"timeupdate"},REMOTE_STREAM_TYPE_MAIN=NAME.MAIN,REMOTE_STREAM_TYPE_AUX=NAME.AUXILIARY,STREAM_TYPE_BIG=NAME.BIG,STREAM_TYPE_SMALL=NAME.SMALL,PEERCONNECTION_CONNECTING_TIMEOUT=1e4,LOG_LEVEL_NAME=Object.keys(LOG_LEVEL),MAX_RTT=1e4,__awaiter=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},U32=Symbol(32),U16=Symbol(16),U8=Symbol(8),OPut=class{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return __awaiter(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,r)=>{var n;this.reject=r,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)};this.demand(e,!0)||null===(n=this.pull)||void 0===n||n.call(this,e)}))}))}readU32(){return this.read(U32)}readU16(){return this.read(U16)}readU8(){return this.read(U8)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null;const t=this.buffer.subarray(this.consumed);let r=0;const n=e=>t.length<(r=e);if("number"==typeof this.need){if(n(this.need))return;e=t.subarray(0,r)}else if(this.need===U32){if(n(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===U16){if(n(2))return;e=t[0]<<8|t[1]}else if(this.need===U8){if(n(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(n(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,r)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(n(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,r)),e=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){const t=this.buffer.length,r=t+e;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{const e=new Uint8Array(r);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}};OPut.U32=U32,OPut.U16=U16,OPut.U8=U8;var MSB=128,REST=127,MSBALL=~REST,INT=Math.pow(2,31);function encodeVarint(e){const t=new OPut;for(;e>=128;)t.malloc(1)[0]=255&e|MSB,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function encode(e,t=0){const r=new OPut,n=t<<3;switch(typeof e){case"boolean":const o=r.malloc(2);o[0]=n,o[1]=e?1:0;break;case"number":r.malloc(1)[0]=n,r.write(encodeVarint(e));break;case"string":r.malloc(1)[0]=2|n;const i=(new TextEncoder).encode(e);r.write(encodeVarint(i.length));const s=r.malloc(i.length);for(let e=0;e<i.length;e++)s[e]=i[e];break;case"object":const a=new OPut;if(Array.isArray(e))for(let t=0;t<e.length;t++){const r=encode(e[t],t+1);r&&a.write(r)}else{let t=1;for(const r in e){const n=encode(e[r],t++);n&&a.write(n)}}0===t?a.buffer&&r.write(a.buffer):(r.malloc(1)[0]=2|n,a.buffer&&(r.write(encodeVarint(a.buffer.length)),r.write(a.buffer)))}return r.buffer||new Uint8Array(0)}var Buffer2=class{constructor(){__publicField(this,"buffer"),this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeInt16(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeByte(e){this.buffer.push(255&e)}writeBytes(e){for(let t=0;t<e.length;t++)this.buffer.push(e[t])}};function writUint32(e,t,r){e[r]=t>>>24&255,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function readUint32(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function readUint8(e,t){return e[t]}function readString(e,t,r){return(new TextDecoder).decode(readBytes(e,t,r))}function readBytes(e,t,r){return e.slice(t,t+r)}var seqNumber=0,DELTA=2654435769,ROUNDS=16,LOG_ROUNDS=4,SALT_LEN=2,ZERO_LEN=7;function initSSOPacket(e,t,r,n="AVQualityReportSvc.C2S",o=2e3,i=2,s=30){return{version:o,encryption:i,d2:"",d2Len:0,uinType:s,uin:"",uinLen:0,reqHead:{seqNumber:r,appId:e,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:n,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}function encodeSSOPackage(e,t){const r=new Buffer2,n=initSSOPacket(t,e,seqNumber);seqNumber=seqNumber+1&2147483647,r.writeInt32(0),r.writeInt32(n.version),r.writeByte(n.encryption);const o=(new TextEncoder).encode(n.d2);r.writeInt32(o.length+4),o&&r.writeBytes(o),r.writeByte(n.uinType);const i=(new TextEncoder).encode(n.uin);r.writeInt32(i.length+4),i.length&&r.writeBytes(i);const s=new Buffer2;s.writeInt32(0),s.writeInt32(n.reqHead.seqNumber),s.writeInt32(n.reqHead.appId),s.writeByte(n.reqHead.appId>>>24&255),s.writeByte(n.reqHead.appId>>>16&255),s.writeByte(n.reqHead.appId>>>8&255),s.writeByte(255&n.reqHead.appId);for(let e=4;e<16;e++)s.writeByte(0);const a=(new TextEncoder).encode(n.reqHead.a2);s.writeInt32(a.length+4),a.length&&s.writeBytes(a);const u=(new TextEncoder).encode(n.reqHead.serviceCmd);s.writeInt32(u.length+4),u.length&&s.writeBytes(u);const c=(new TextEncoder).encode(n.reqHead.cookie);s.writeInt32(c.length+4),c.length&&s.writeBytes(c);const l=(new TextEncoder).encode(n.reqHead.imei);s.writeInt32(l.length+4),l.length&&s.writeBytes(l);const d=(new TextEncoder).encode(n.reqHead.ksid);s.writeInt32(d.length+4),d.length&&s.writeBytes(d);const h=(new TextEncoder).encode(n.reqHead.clientVersionInfo);s.writeInt16(h.length+2),h.length&&s.writeBytes(h);const f=s.length;s.data[0]=f>>>24&255,s.data[1]=f>>>16&255,s.data[2]=f>>>8&255,s.data[3]=255&f,isString(e)&&(e=(new TextEncoder).encode(e)),s.writeInt32(e.length+4),e.length&&s.writeBytes(e);let p=new Uint8Array(s.data),m=null;1===n.encryption?m=(new TextEncoder).encode(n.uin):2===n.encryption&&(m=new Uint8Array(16)),m&&(p=encrypt(p,m)),r.writeBytes(p);const g=new Uint8Array(r.data),v=g.length;return g[0]=v>>>24&255,g[1]=v>>>16&255,g[2]=v>>>8&255,g[3]=255&v,g}function encrypt(e,t){const r=e.length;let n=(r+1+SALT_LEN+ZERO_LEN)%8;n&&(n=8-n);const o=new Uint8Array(r+1+SALT_LEN+ZERO_LEN+n);let i=0;const s=new Uint8Array(8),a=new Uint8Array(8),u=new Uint8Array(8);let c=0;s[0]=248&Math.floor(256*Math.random())|n,c=1;for(let e=0;e<n;e++)s[c]=255&Math.floor(256*Math.random()),c+=1;for(let e=0;e<SALT_LEN;)if(c<8&&(s[c]=255&Math.floor(256*Math.random()),c+=1,e+=1),8===c){encryptBlock(s,t,a,u,o,i),i+=8,c=0;for(let e=0;e<8;e++)u[e]=o[i-8+e]}let l=0;for(;l<r;)if(c<8&&(s[c]=e[l],c+=1,l+=1),8===c){encryptBlock(s,t,a,u,o,i),i+=8,c=0;for(let e=0;e<8;e++)u[e]=o[i-8+e]}for(let e=0;e<ZERO_LEN;)if(c<8&&(s[c]=0,c+=1,e+=1),8===c){encryptBlock(s,t,a,u,o,i),i+=8,c=0;for(let e=0;e<8;e++)u[e]=o[i-8+e]}return o}function encryptBlock(e,t,r,n,o,i){for(let t=0;t<8;t++)e[t]^=n[t];teaEncrypt(e,t,o,i);for(let e=0;e<8;e++)o[i+e]^=r[e];for(let t=0;t<8;t++)r[t]=e[t]}function teaEncrypt(e,t,r,n){let o=readUint32(e,0),i=readUint32(e,4);const s=[];for(let e=0;e<4;e++)s[e]=readUint32(t,4*e);let a=0;for(let e=0;e<ROUNDS;e++)a+=DELTA,a>>>=0,o+=(i<<4)+s[0]^i+a^(i>>>5)+s[1],o>>>=0,i+=(o<<4)+s[2]^o+a^(o>>>5)+s[3],i>>>=0;writUint32(r,o,n),writUint32(r,i,n+4)}var baseTimeOffset=0,getNetworkTime=function(){return Date.now()+baseTimeOffset},getTimestamp=function(){const e=new Date;return e.setTime(getNetworkTime()),e.toLocaleString()},formatDate=function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),`${e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${t}`};function getBusibuff(e){const t=decodeSSOPackage(e);return null==t?void 0:t.busiBuff}function decodeSSOPackage(e){try{const t={};let r=0;t.totalLength=readUint32(e,r),r+=4,t.version=readUint32(e,r),r+=4,t.encryption=readUint8(e,r),r+=1,t.uinType=readUint8(e,r),r+=1,t.uinLength=readUint32(e,r),r+=4,t.uin=t.uinLength>4?readString(e,r,t.uinLength-4):"",r+=t.uinLength-4;const n=e.slice(r);if(2===t.encryption){const o=new Uint8Array(16).fill(0);e=decrypt(n,o),t.decrypted=!0,r=0}else e=n,r=0;return t.rspHeadLength=readUint32(e,r),r+=4,t.seqNo=readUint32(e,r),r+=4,t.retCode=readUint32(e,r),r+=4,t.retStrLength=readUint32(e,r),r+=4,t.retStr=t.retStrLength?readString(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=readUint32(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?readString(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=readUint32(e,r),r+=4,t.cookie=t.cookieLength?readString(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=readUint32(e,r),r+=4,t.busiBuffLength=readUint32(e,r),r+=4,t.busiBuff=t.busiBuffLength?readString(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(e){}}function teaDecryptBlock(e,t){let r=e[0]<<24|e[1]<<16|e[2]<<8|e[3],n=e[4]<<24|e[5]<<16|e[6]<<8|e[7];r>>>=0,n>>>=0;let o=DELTA*ROUNDS>>>0;for(let e=0;e<ROUNDS;e++)n-=(r<<LOG_ROUNDS)+t[2]^r+o^(r>>>5)+t[3],n>>>=0,r-=(n<<LOG_ROUNDS)+t[0]^n+o^(n>>>5)+t[1],r>>>=0,o-=DELTA,o>>>=0;return new Uint8Array([r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n])}function decrypt(e,t){let r=0;const n=new Uint8Array(8).fill(0);let o=teaDecryptBlock(new Uint8Array(e.slice(0,8)),t);const i=7&o[0],s=e.length-1-i-SALT_LEN-ZERO_LEN,a=new Uint8Array(s);let u=0,c=n,l=e.slice(0,8);r=8;let d=1;d+=i;for(let n=1;n<=SALT_LEN;)if(d<8)d++,n++;else if(8===d){const n=decryptNextBlock(e,r,c,l,o,t);c=n.ivPreCrypt,l=n.ivCurCrypt,o=n.debiBuf,r=n.bufPos,d=0}let h=s;for(;h>0;)if(d<8)a[u++]=o[d]^c[d],d++,h--;else if(8===d){const n=decryptNextBlock(e,r,c,l,o,t);c=n.ivPreCrypt,l=n.ivCurCrypt,o=n.debiBuf,r=n.bufPos,d=0}for(let n=1;n<=ZERO_LEN;)if(d<8)o[d],c[d],d++,n++;else if(8===d){if(r>=e.length)break;const n=decryptNextBlock(e,r,c,l,o,t);if(!n.success)break;c=n.ivPreCrypt,l=n.ivCurCrypt,o=n.debiBuf,r=n.bufPos,d=0}return a}function decryptNextBlock(e,t,r,n,o,i){if(t+8>e.length)return{success:!1};const s=new Uint8Array(n),a=e.slice(t,t+8),u=new Uint8Array(8);for(let e=0;e<8;e++)u[e]=o[e]^a[e];return{success:!0,ivPreCrypt:s,ivCurCrypt:a,debiBuf:teaDecryptBlock(u,i),bufPos:t+8}}var textDecoder="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function http({url:e,body:t,method:r="POST",timeout:n,priority:o}){return new Promise(((i,s)=>{if("fetch"in window)return fetch(e,{method:r,body:t,priority:o}).then((e=>e.clone().json().then((e=>({data:e})),(()=>e.arrayBuffer().then((e=>({data:getBusibuff(new Uint8Array(e))||(textDecoder?textDecoder.decode(e):e)}))))))).then(i,s);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(4===a.readyState)if(a.status>=200&&a.status<300)try{const e=JSON.parse(a.response);i({data:e})}catch(e){i({data:a.response})}else s({status:a.status,statusText:a.statusText||"request failed!"})},a.timeout=n||5e3,a.open(r,e,!0),a.send(t)}))}var has=Object.prototype.hasOwnProperty,isFunction=e=>"function"==typeof e,isUndefined=e=>void 0===e,isBoolean=e=>"boolean"==typeof e,isPlainObject=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;const r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)};function isEmpty(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(isPlainObject(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(const t in e)if(has.call(e,t))return!1;return!0}return!1}var RETRY_STATE_NOT_START=0,RETRY_STATE_STARTED=1,RETRY_STATE_STOPPED=2;function promiseRetry({retryFunction:e,settings:t,onError:r,onRetrying:n,onRetryFailed:o,onRetrySuccess:i,context:s}){return function(...a){const{retries:u=5,timeout:c=1e3}=t;let l=0,d=-1,h=RETRY_STATE_NOT_START;const f=async(t,p)=>{const m=s||this;try{const r=await e.apply(m,a);l>0&&i&&i.call(this,l),l=0,t(r)}catch(e){const i=()=>{clearTimeout(d),l=0,h=RETRY_STATE_STOPPED,p(e)},s=()=>{h!==RETRY_STATE_STOPPED&&l<(isFunction(u)?u():u)?(l++,h=RETRY_STATE_STARTED,isFunction(n)&&n.call(this,l,i),d=window.setTimeout((()=>{d=-1,f(t,p)}),isFunction(c)?c(l):c)):(i(),isFunction(o)&&o.call(this,e))};isFunction(r)?r.call(this,{error:e,retry:s,reject:p,retryFuncArgs:a,retriedCount:l}):s()}};return new Promise(f)}}var retry_default=promiseRetry,Logger=class e{constructor(e){__publicField(this,"_parentPath"),__publicField(this,"userId"),__publicField(this,"remoteUserId"),__publicField(this,"id"),__publicField(this,"sdkAppId"),__publicField(this,"type"),__publicField(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!isBoolean(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}getFullId(){return this._parentPath&&this.id?`${this._parentPath}-${this.id}`:this._parentPath?this._parentPath:this.id}createChild(t){const r=new e({id:t.id,userId:isUndefined(t.userId)?this.userId:t.userId,sdkAppId:isUndefined(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:isUndefined(t.type)?this.type:t.type,isLocal:isUndefined(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:isUndefined(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}bindParent(e){const t=e.getFullId();this._parentPath!==t&&(this.debug(`bind logger parent: ${e.id}`),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){const r=this.isLocal?this.userId:this.remoteUserId,n=this.getFullId();t.unshift(`[${this.isLocal?"↑":"↓"}${this.type&&"main"!==this.type?"*":""}${n}${r?`|${r}`:""}]`),logger_manager_default.log(e,t,isUndefined(this.userId)||isEmpty(this.userId),this.userId,this.sdkAppId)}info(...e){this.log(2,e)}debug(...e){this.log(1,e)}warn(...e){this.log(3,e)}error(...e){this.log(4,e)}},USER_AGENT="undefined"==typeof navigator?"":navigator.userAgent,isUserAgentMatch=e=>new RegExp(e,"i").test(USER_AGENT),getBrowserVersion=e=>{if(isUserAgentMatch(e)){const t=new RegExp(`${e}\\/([\\d.]+)`),r=USER_AGENT.match(t);if(r&&r[1])return r[1]}return""},getBrowserMajorVersion=e=>{if(isUserAgentMatch(e)){const t=new RegExp(`${e}\\/(\\d+)`),r=USER_AGENT.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},webkitVersionMap=/AppleWebKit\/([\d.]+)/i.exec(USER_AGENT),appleWebkitVersion=webkitVersionMap?parseFloat(webkitVersionMap[1]):NaN,IS_IPAD=isUserAgentMatch("iPad"),IS_IPAD_PRO="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&isUserAgentMatch("Macintosh"),IS_IPHONE=isUserAgentMatch("iPhone")&&!IS_IPAD,IS_IPOD=isUserAgentMatch("iPod"),IS_IOS=IS_IPHONE||IS_IPAD||IS_IPOD||IS_IPAD_PRO,IS_ANDROID=isUserAgentMatch("Android"),ANDROID_VERSION=function(){if(IS_ANDROID){const e=USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){const t=e[1]&&parseFloat(e[1]),r=e[2]&&parseFloat(e[2]);if(t&&r)return parseFloat(`${e[1]}.${e[2]}`);if(t)return t}}return NaN}(),IS_OLD_ANDROID=IS_ANDROID&&isUserAgentMatch("webkit")&&ANDROID_VERSION<2.3,IS_NATIVE_ANDROID=IS_ANDROID&&ANDROID_VERSION<5&&appleWebkitVersion<537,IS_FIREFOX=isUserAgentMatch("Firefox"),FIREFOX_VERSION=getBrowserVersion("Firefox"),FIREFOX_MAJOR_VERSION=getBrowserMajorVersion("Firefox"),IS_EDGE=isUserAgentMatch("Edge"),EDGE_VERSION=getBrowserVersion("Edge"),IS_EDG=isUserAgentMatch("Edg"),EDG_VERSION=getBrowserVersion("Edg"),EDG_MAJOR_VERSION=getBrowserMajorVersion("Edg"),IS_SOGOUM=isUserAgentMatch("SogouMobileBrowser"),SOGOUM_VERSION=getBrowserVersion("SogouMobileBrowser"),IS_SOGOU=isUserAgentMatch("MetaSr\\s"),SOGOU_VERSION=getBrowserVersion("MetaSr\\s"),IS_TBS=isUserAgentMatch("TBS"),TBS_VERSION=getBrowserVersion("TBS"),IS_XWEB=isUserAgentMatch("XWEB"),XWEB_VERSION=getBrowserVersion("XWEB"),IS_IE8=isUserAgentMatch("MSIE\\s8\\.0"),IS_IE=isUserAgentMatch("MSIE\\/\\d+"),IE_VERSION=function(){if(IS_IE){const e=/MSIE\s(\d+)\.\d/.exec(USER_AGENT);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(USER_AGENT)&&/rv:11.0/.test(USER_AGENT)&&(t=11),t}return NaN}(),IS_WECHAT=isUserAgentMatch("(micromessenger|webbrowser)"),WECHAT_VERSION=getBrowserVersion("MicroMessenger"),IS_X5MQQB=!IS_TBS&&isUserAgentMatch("MQQBrowser")&&isUserAgentMatch("COVC"),IS_MQQB=!IS_TBS&&isUserAgentMatch("MQQBrowser")&&!isUserAgentMatch("COVC"),MQQB_VERSION=IS_MQQB||IS_X5MQQB?getBrowserVersion("MQQBrowser"):"",IS_WQQB=!IS_TBS&&isUserAgentMatch(" QQBrowser"),WQQB_VERSION=getBrowserVersion(" QQBrowser"),IS_MACQQB=!IS_TBS&&isUserAgentMatch("QQBrowserLite"),MACQQB_VERSION=getBrowserVersion("QQBrowserLite"),IS_IPADQQB=!IS_TBS&&isUserAgentMatch("MQBHD"),IPADQQB_VERSION=getBrowserVersion("MQBHD"),IS_WIN=isUserAgentMatch("Windows"),IS_MAC=!IS_IOS&&isUserAgentMatch("MAC OS X"),IS_LINUX=!IS_ANDROID&&isUserAgentMatch("Linux"),IS_CHROME_OS=isUserAgentMatch("CrOS"),IS_WX=isUserAgentMatch("MicroMessenger"),IS_UCBROWSER=isUserAgentMatch("UCBrowser"),IS_ELECTRON=isUserAgentMatch("Electron"),IS_MIBROWSER=isUserAgentMatch("MiuiBrowser"),MI_VERSION=getBrowserVersion("MiuiBrowser"),IS_HUAWEIBROWSER=isUserAgentMatch("HuaweiBrowser"),IS_HUAWEI=isUserAgentMatch("Huawei")||isUserAgentMatch("HUAWEI"),IS_HONOR=isUserAgentMatch("Honor")||isUserAgentMatch("HONOR"),HUAWEI_VERSION=getBrowserVersion("HuaweiBrowser"),IS_SAMSUNGBROWSER=isUserAgentMatch("SamsungBrowser"),SAMSUNG_VERSION=getBrowserVersion("SamsungBrowser"),IS_OPPOBROWSER=isUserAgentMatch("HeyTapBrowser"),OPPO_VERSION=getBrowserVersion("HeyTapBrowser"),IS_VIVOBROWSER=isUserAgentMatch("VivoBrowser"),VIVO_VERSION=getBrowserVersion("VivoBrowser"),IS_OPENHARMONY=isUserAgentMatch("OpenHarmony"),OPENHARMONY_VERSION=getBrowserVersion("OpenHarmony"),getChromeMajorVersion=()=>getBrowserMajorVersion("Chrome"),IS_IOS_CHROME=isUserAgentMatch("CriOS"),IS_CHROMIUM_BASE=isUserAgentMatch("Chrome"),IS_CHROME=!IS_EDGE&&!IS_SOGOU&&!IS_SOGOUM&&!IS_TBS&&!IS_XWEB&&!IS_EDG&&!IS_WQQB&&!IS_MIBROWSER&&!IS_HUAWEIBROWSER&&!IS_SAMSUNGBROWSER&&!IS_OPPOBROWSER&&!IS_VIVOBROWSER&&IS_CHROMIUM_BASE,IS_HEADLESS_CHROME=isUserAgentMatch("HeadlessChrome"),CHROME_MAJOR_VERSION=getChromeMajorVersion(),CHROME_VERSION=getBrowserVersion("Chrome"),ELECTRON_MAJOR_VERSION=getBrowserMajorVersion("Electron"),IS_SAFARI=!IS_CHROMIUM_BASE&&!IS_MQQB&&!IS_X5MQQB&&!IS_MACQQB&&!IS_IPADQQB&&isUserAgentMatch("Safari"),SAFARI_VERSION=getBrowserVersion("Version"),IS_ANDROID_WEBVIEW=/Android.*(wv|.0.0.0)/.test(USER_AGENT),IOS_VERSION=(()=>{if(IS_IPAD_PRO)return SAFARI_VERSION;if(IS_IOS){const e=USER_AGENT.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=`.${e[2]}`),t}}return""})(),IOS_MAIN_VERSION=Number(IOS_VERSION.split(".")[0]),IS_IOS_13_OR_14=(()=>{const e=Number(IOS_VERSION.split(".")[0]);return 14===e||13===e})(),IS_LOCAL="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),browserInfo=getBrowserInfo();function getBrowserInfo(){const e=new Map([[IS_FIREFOX,["Firefox",FIREFOX_VERSION]],[IS_EDG,["Edg",EDG_VERSION]],[IS_CHROME,["Chrome",CHROME_VERSION]],[IS_IOS_CHROME,["ChiOS",getBrowserVersion("CriOS")]],[IS_SAFARI&&!IS_IOS_CHROME,["Safari",SAFARI_VERSION]],[IS_TBS,["TBS",TBS_VERSION]],[IS_XWEB,["XWEB",XWEB_VERSION]],[IS_WECHAT&&IS_IPHONE,["WeChat",WECHAT_VERSION]],[IS_WQQB,["QQ(Win)",WQQB_VERSION]],[IS_MQQB,["QQ(Mobile)",MQQB_VERSION]],[IS_X5MQQB,["QQ(Mobile X5)",MQQB_VERSION]],[IS_MACQQB,["QQ(Mac)",MACQQB_VERSION]],[IS_IPADQQB,["QQ(iPad)",IPADQQB_VERSION]],[IS_MIBROWSER,["MI",MI_VERSION]],[IS_HUAWEIBROWSER,["HW",HUAWEI_VERSION]],[IS_SAMSUNGBROWSER,["Samsung",SAMSUNG_VERSION]],[IS_OPPOBROWSER,["OPPO",OPPO_VERSION]],[IS_VIVOBROWSER,["VIVO",VIVO_VERSION]],[IS_EDGE,["EDGE",EDGE_VERSION]],[IS_SOGOUM,["SogouMobile",SOGOUM_VERSION]],[IS_SOGOU,["Sogou",SOGOU_VERSION]]]);let t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}var import_eventemitter32=__toESM(require_eventemitter3(),1),innerEmitter=new import_eventemitter32.default,inner_emitter_default=innerEmitter,inner_event_default=INNER_EVENT,SSOManager=class{constructor(){__publicField(this,"enable",!1),__publicField(this,"ssoFailCount",0),inner_emitter_default.on("22",(({schedule:e})=>{var t;(null==(t=null==e?void 0:e.config)?void 0:t.sso)&&inner_emitter_default.emit("266",{enable:!0})})),inner_emitter_default.on("266",(({enable:e})=>{this.enable=e}))}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&inner_emitter_default.emit("266",{enable:!1})}},sso_manager_default=new SSOManager,LOG_PRE_TAG="%cTRTC%c%s",LOG_PRE_TAG_STYLE="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",LOG_STYLE="display: inline",_LoggerManager=class e{constructor(){__publicField(this,"_isEnableUploadLog",!0),__publicField(this,"_localJoinedUser",new Map),__publicField(this,"_queue",[]),__publicField(this,"_timeoutId",-1),__publicField(this,"_logLevel",1),__publicField(this,"_logLevelToUpload",2),IS_WORKER||IS_WORKLET||(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){inner_emitter_default.on(inner_event_default.JOIN_SCHEDULE_SUCCESS,(({schedule:e})=>{var t;(null==(t=null==e?void 0:e.config)?void 0:t.logLevelToUpload)&&LOG_LEVEL[e.config.logLevelToUpload]&&(this._logLevelToUpload=e.config.logLevelToUpload)})),inner_emitter_default.on(inner_event_default.JOIN_START,(({params:e})=>{this.addJoinedUser({userId:e.userId,sdkAppId:e.sdkAppId}),this.startUpload()})),inner_emitter_default.on(inner_event_default.LEAVE_SUCCESS,(({room:e})=>{this.deleteJoinedUser(e.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){const e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){const r=this._queue[t];if(r.forAllJoinedClients)this._localJoinedUser.forEach((({userId:t,sdkAppId:n})=>{e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:n,logs:[r]})}));else if(isString(r.userId)&&isNumber(r.sdkAppId)){const{userId:t,sdkAppId:n}=r;e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:n,logs:[r]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}async upload(){if(0===this._queue.length||!this._isEnableUploadLog)return;const{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{const t=[...e.values()];for(let e=0;e<t.length;e++){const{userId:r,sdkAppId:n,logs:o}=t[e],i={timestamp:getTimestamp(),sdkAppId:String(n),userId:r,version:version,log:o.map((e=>e.log)).join("\n")},s=JSON.stringify(i),a=sso_manager_default.enable?buildSSOPackage(i,2002,n):s;await this.uploadLogWithRetry(a,n,a instanceof Uint8Array,s),o.forEach((e=>e.uploaded=!0))}}catch(e){}const r=t.filter((e=>!e.uploaded));r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(e,t,r,n){return retry_default({retryFunction:()=>http({url:getLoggerUrl(t,LOGGER_CMD_TYPE.LOG),body:e,timeout:5e3,priority:"low"}).then((e=>{r&&"ok"!==e.data&&(sso_manager_default.handleUploadFailed(),this.uploadLogWithRetry(n,t,!1,n))})),settings:{retries:3,timeout:2e3},onError:({retry:e})=>{e()}})()}getPrefix(e){const t=new Date;return t.setTime(getNetworkTime()),`[${formatDate(t)}] <${LOG_LEVEL[e]}>`}getLogLevel(){return this._logLevel}setLogLevel(e){isUndefined2(LOG_LEVEL[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(isString(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(e){return""}}addLogToQueue(e,t,r=!0,n,o){const i={log:t.reduce(((e,t)=>`${e} ${this.logChunkToString(t)}`.trim()),""),level:e,userId:n,sdkAppId:o,forAllJoinedClients:r};inner_emitter_default.emit(inner_event_default.LOG,{log:i}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(i)}log(t,r,n=!0,o,i){var s;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,n,o,i),t<this._logLevel)return;const a=(null==(s=LOG_LEVEL[t])?void 0:s.toLowerCase())||"info";e.PRINT_LOG_TAG?console[a](LOG_PRE_TAG,LOG_PRE_TAG_STYLE,LOG_STYLE,...r):console[a](...r)}debug(...e){this.log(1,e)}info(...e){this.log(2,e)}warn(...e){this.log(3,e)}error(...e){this.log(4,e)}createLogger(e){if(e.parent instanceof Logger){const t=e,{parent:r}=t,n=__objRest(t,["parent"]),o=new Logger(n);return o.bindParent(r),o}return new Logger(e)}checkURLParam(){const e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;LOG_LEVEL[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};__publicField(_LoggerManager,"PRINT_LOG_TAG",!(IS_IOS||IS_ANDROID||IS_HEADLESS_CHROME));var LoggerManager=_LoggerManager,logger_manager_default=new LoggerManager,isOverseaSdkAppId=e=>Number(e)<14e8,getLoggerUrl=function(e,t){let r;r=loggerProxy||(isOverseaSdkAppId(e)?LOGGER_DOMAIN_OVERSEA:LOGGER_DOMAIN);return`${r}/v5/AVQualityReportSvc/C2S?random=${Math.floor(Math.random()*2**31)}&sdkappid=${e}&cmdtype=${t}`},glog="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},isUndefined2=e=>void 0===e,isString=e=>"string"==typeof e,isNumber=e=>"number"==typeof e,isSetSinkIdSupported="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function performanceNow(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var{toString:toString}=Object.prototype;function buildProtocolBufferJSON(e,t,r,n){let o={data:e,random:Math.floor(Math.random()*2**31),sdkAppId:r};return isUndefined2(n)||(o=__spreadProps(__spreadValues({},o),{gzip:+n})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(o)}}}function buildSSOPackage(e,t,r,n){try{const o=buildProtocolBufferJSON(e,t,r,n);return encodeSSOPackage(encode(o),r)}catch(t){return JSON.stringify(e)}}var _TRTCVideoDecoder=class e{constructor(e){this.core=e,__publicField(this,"contextMap",new Map),__publicField(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(e){return(null==e?void 0:e.track)?`${e.track.userId}${e.track.streamType}`:"*"}getName(){return e.Name}getValidateRule(e){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(e,t){var r;switch(e){case"wasm":const e=!1,n=(null==(r=this.core.assetsPath)?void 0:r.replace(/\/+$/,""))||".";return e?new VideoDecoderSoftSIMD(__spreadProps(__spreadValues({},t),{wasmPath:`${n}/videodec_simd.wasm`})):new VideoDecoderSoft(__spreadProps(__spreadValues({},t),{wasmPath:`${n}/videodec.wasm`}));case"webCodecs":return new VideoDecoderHard;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(e){this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:({frame:e,track:t})=>{var r;return(null==(r=this.decodeProcessorMap.get(t))?void 0:r({frame:e,track:t}))||e},type:3})}decode(e){const{pipe:t,take:r,subscribe:n}=this.core.rx;return({frame:o,track:i})=>{if(i!==e.track||"empty"===o.type)return o;if(this.contextMap.has(i))return this.contextMap.get(i).decode(o);const s=this.core.room.videoManager.createDecodeContext(__spreadProps(__spreadValues({},e),{createDecoder:this.createDecoder}));return t(s.trackDoneOB,r(1),n((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:i})}))),this.contextMap.set(i,s),s.decode(o)}}stop(e){if(null==e?void 0:e.track){const t=this.contextMap.get(e.track);t&&(t.close("stop"),this.report(t,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach(((e,t)=>{e.close("stop"),this.contextMap.delete(t)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(e,t){if(e.isReported)return;e.isReported=!0;const r=performanceNow()-e.startPerformanceTime,{renderFreezeTotal:n,dataFreezeTotal:o}=this.getRemoteTrackFreezeDuration(t,e);let i=`report health data: ${e.track.userId} ${e.track.streamType} ${e.type}+${e.renderer} goodType:${e.goodType} ${e.failedReason?`failedReason: ${e.failedReason}`:""}`;r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(n/r*100),split:1,max:100}),i+=` RENDER_FREEZE_RATE: ${Math.floor(n/r*100)}%`),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(o/r*100),split:1,max:100}),i+=` DATA_FREEZE_RATE: ${Math.floor(o/r*100)}%`),e.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100}),i+=` VIDEO_CONSUME_RENDER_RATE: ${Math.floor(e.decodedFrameCount/e.inputFrameCount*100)}%`),this.core.log.info(i)}addKVReportBeforeExitRoom({room:e}){e===this.core.room&&this.contextMap.forEach(((e,t)=>{this.report(e,t)}))}update(e){const t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(__spreadProps(__spreadValues({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(e,t){const r=this.core.room.badCaseDetector.getDataFreezeMap().get(`${e.userId}_${e.streamType}`),n=this.core.room.badCaseDetector.getRenderFreezeDuration(`${e.userId}_${e.streamType}`);let o=0;return r&&r.durationItemList.forEach((e=>{e.startTime>t.startPerformanceTime&&(o+=e.getDuration())})),{renderFreezeTotal:n,dataFreezeTotal:o}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};__publicField(_TRTCVideoDecoder,"Name","TRTCVideoDecoder");var TRTCVideoDecoder=_TRTCVideoDecoder,index_default=TRTCVideoDecoder;export{index_default as default};export{TRTCVideoDecoder};
|
|
1
|
+
var __create=Object.create,__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropNames=Object.getOwnPropertyNames,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__objRest=(e,t)=>{var r={};for(var n in e)__hasOwnProp.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))t.indexOf(n)<0&&__propIsEnum.call(e,n)&&(r[n]=e[n]);return r},__commonJS=(e,t)=>function(){return t||(0,e[__getOwnPropNames(e)[0]])((t={exports:{}}).exports,t),t.exports},__copyProps=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of __getOwnPropNames(t))__hasOwnProp.call(e,o)||o===r||__defProp(e,o,{get:()=>t[o],enumerable:!(n=__getOwnPropDesc(t,o))||n.enumerable});return e},__toESM=(e,t,r)=>(r=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?r:__defProp(r,"default",{value:e,enumerable:!0}),e)),__decorateClass=(e,t,r,n)=>{for(var o,i=n>1?void 0:n?__getOwnPropDesc(t,r):t,s=e.length-1;s>=0;s--)(o=e[s])&&(i=(n?o(t,r,i):o(i))||i);return n&&i&&__defProp(t,r,i),i},__publicField=(e,t,r)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),require_eventemitter3=__commonJS({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(e,t){"use strict";var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function u(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),u.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},u.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},u.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,o,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var u,c,l=this._events[a],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,i),!0;case 6:return l.fn.call(l.context,t,r,o,i,s),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,r);break;case 4:l[c].fn.call(l[c].context,t,r,o);break;default:if(!u)for(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},u.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||a(this,i);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==t||o&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[i]=1===c.length?c[0]:c:a(this,i)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new o,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=n,u.EventEmitter=u,void 0!==t&&(t.exports=u)}}),import_eventemitter3=__toESM(require_eventemitter3(),1),instance=Symbol("instance"),abortCtrl=Symbol("abortCtrl"),cacheResult=Symbol("cacheResult"),MiddleState=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,setState.call(e,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},FSMError=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};function thenAble(e){return"object"==typeof e&&e&&"then"in e}var stateDiagram=new Map;function ChangeState(e,t,r={}){return(n,o,i)=>{const s=r.action||o;if(!r.context){const r=stateDiagram.get(n)||[];stateDiagram.has(n)||stateDiagram.set(n,r),r.push({from:e,to:t,action:s})}const a=i.value;i.value=function(...n){let o=this;if(r.context&&(o=FSM.get("function"==typeof r.context?r.context.call(this,...n):r.context)),o.state===t)return r.sync?o[cacheResult]:Promise.resolve(o[cacheResult]);o.state instanceof MiddleState&&o.state.action==r.abortAction&&o.state.abort(o);let i=null;Array.isArray(e)?0==e.length?o.state instanceof MiddleState&&o.state.abort(o):"string"==typeof o.state&&e.includes(o.state)||(i=new FSMError(o._state,`${o.name} ${s} to ${t} failed: current state ${o._state} not from ${e.join("|")}`)):e!==o.state&&(i=new FSMError(o._state,`${o.name} ${s} to ${t} failed: current state ${o._state} not from ${e}`));const u=e=>{if(r.fail&&r.fail.call(this,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(i)return u(i);const c=o.state,l=new MiddleState(c,t,s);setState.call(o,l);const d=e=>{var n;return o[cacheResult]=e,l.aborted||(setState.call(o,t),null===(n=r.success)||void 0===n||n.call(this,o[cacheResult])),e},h=e=>(setState.call(o,c,e),u(e));try{const e=a.apply(this,n);return thenAble(e)?e.then(d).catch(h):r.sync?d(e):Promise.resolve(d(e))}catch(r){return h(new FSMError(o._state,`${o.name} ${s} from ${e} to ${t} failed: ${r}`,r instanceof Error?r:new Error(String(r))))}}}}function Includes(...e){return(t,r,n)=>{const o=n.value,i=r;n.value=function(...t){if(!e.includes(this.state.toString()))throw new FSMError(this.state,`${this.name} ${i} failed: current state ${this.state} not in ${e}`);return o.apply(this,t)}}}var sendDevTools=(()=>{const e="undefined"!=typeof window&&window.__AFSM__,t="undefined"!=typeof importScripts;return e?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:t?(e,t)=>{postMessage({type:e,payload:t})}:()=>{}})();function setState(e,t){const r=this._state;this._state=e;const n=e.toString();e&&this.emit(n,r),this.emit(FSM.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var FSM=class e extends import_eventemitter3.default{constructor(t,r,n){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),n?Object.setPrototypeOf(this,n):n=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);const o=n[instance];o?this.name=o.name+"-"+o.count++:n[instance]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){const e=Object.getPrototypeOf(this),t=stateDiagram.get(e)||[];let r=new Set,n=[],o=[];const i=new Set,s=Object.getPrototypeOf(e);stateDiagram.has(s)&&(s.stateDiagram.forEach((e=>r.add(e))),s.allStates.forEach((e=>i.add(e)))),t.forEach((({from:e,to:t,action:r})=>{"string"==typeof e?n.push({from:e,to:t,action:r}):e.length?e.forEach((e=>{n.push({from:e,to:t,action:r})})):o.push({to:t,action:r})})),n.forEach((({from:e,to:t,action:n})=>{i.add(e),i.add(t),i.add(n+"ing"),r.add(`${e} --\x3e ${n}ing : ${n}`),r.add(`${n}ing --\x3e ${t} : ${n} 🟢`),r.add(`${n}ing --\x3e ${e} : ${n} 🔴`)})),o.forEach((({to:e,action:t})=>{r.add(`${t}ing --\x3e ${e} : ${t} 🟢`),i.forEach((n=>{n!==e&&r.add(`${n} --\x3e ${t}ing : ${t}`)}))}));const a=[...r];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:i}}),a}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(t={}){sendDevTools(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){setState.call(this,e)}};FSM.STATECHANGED="stateChanged",FSM.UPDATEAFSM="updateAFSM",FSM.INIT="[*]",FSM.ON="on",FSM.OFF="off",FSM.instances=new Map,FSM.instances2=new WeakMap;var VideoDecoderHard=class extends FSM{constructor(){super(...arguments),__publicField(this,"decoder"),__publicField(this,"config")}async initialize(){this.decoder=new VideoDecoder({output:e=>{this.emit("videoFrame",e)},error:e=>{this.close(),this.emit("error",e)}})}configure(e){this.config=e,this.decoder.configure(__spreadProps(__spreadValues({},e),{codec:this.getCodec(e)}))}getCodec(e){switch(e.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return e.codec}}decode(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){"closed"!==this.decoder.state&&this.decoder.close()}};function WorkerScripts(){var e;self.onmessage=t=>{if("init"===t.data.type){const{canvas:r,wasmScript:n,wasmBinary:o}=t.data,i=null==r?void 0:r.getContext("2d");let s=0,a=0;const u={wasmBinary:o,postRun:()=>{e=new u.VideoDecoder({videoInfo(e,t){s=e,a=t,console.log("video info",e,t)},yuvData(e,t){const n=s*a,o=n>>2;let c=u.HEAPU32[e>>2],l=u.HEAPU32[1+(e>>2)],d=u.HEAPU32[2+(e>>2)],h=u.HEAPU8.subarray(c,c+n),f=u.HEAPU8.subarray(l,l+o),p=u.HEAPU8.subarray(d,d+o);const m=new Uint8Array(n+o+o);m.set(h),m.set(f,n),m.set(p,n+o);const g=new VideoFrame(m,{codedWidth:s,codedHeight:a,format:"I420",timestamp:t});r?(null==i||i.drawImage(g,0,0,r.width,r.height),null==i||i.commit()):self.postMessage({type:"yuvData",videoFrame:g},[g])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+n)()(u)}else if("decode"===t.data.type){const{packet:r}=t.data;null==e||e.decode(r.data,"key"==r.type,r.timestamp)}else if("setCodec"===t.data.type){const{codec:r,format:n,description:o}=t.data;null==e||e.setCodec(r,n,null!=o?o:"")}}}__decorateClass([ChangeState([FSM.INIT,"closed"],"initialized")],VideoDecoderHard.prototype,"initialize",1),__decorateClass([ChangeState("initialized","configured",{sync:!0})],VideoDecoderHard.prototype,"configure",1),__decorateClass([Includes("configured")],VideoDecoderHard.prototype,"decode",1),__decorateClass([ChangeState([],FSM.INIT,{sync:!0})],VideoDecoderHard.prototype,"reset",1),__decorateClass([ChangeState([],"closed",{ignoreError:!0,sync:!0})],VideoDecoderHard.prototype,"close",1);var VideoDecoderSoftBase=class extends FSM{constructor(e,t,r=!1,n,o=!1){super(),this.createModule=e,this.wasmBinary=t,this.workerMode=r,this.canvas=n,this.yuvMode=o,__publicField(this,"worker"),__publicField(this,"decoder"),__publicField(this,"config"),__publicField(this,"module",{}),__publicField(this,"width",0),__publicField(this,"height",0)}async initialize(e){var t;if(this.workerMode){const e=new RegExp("\\{(.+)\\}","s").exec(WorkerScripts.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"text/javascript"})));const r=null==(t=this.canvas)?void 0:t.transferControlToOffscreen(),n=await this.wasmBinary;return console.warn("worker mode",n),this.worker.postMessage({type:"init",canvas:r,wasmScript:this.createModule.toString(),wasmBinary:n},r?[r,n]:[n]),new Promise((e=>{this.worker.onmessage=t=>{if("ready"===t.data.type)delete this.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){const{videoFrame:e}=t.data;this.emit("videoFrame",e)}}}))}const r=this.module;return this.wasmBinary&&(r.wasmBinary=await this.wasmBinary),r.print=e=>console.log(e),r.printErr=e=>console.log(`[JS] ERROR: ${e}`),r.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise((t=>{r.postRun=e=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),t()},e&&Object.assign(r,e),this.createModule(r)}))}configure(e){var t,r,n;this.config=e;const o=this.config.codec.startsWith("avc")?"avc":"hevc",i=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(r=this.decoder)||r.setCodec(o,i,null!=(t=this.config.description)?t:""),null==(n=this.worker)||n.postMessage({type:"setCodec",codec:o,format:i,description:this.config.description})}decode(e){var t,r;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:e}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(e,t){this.width=e,this.height=t;let r={width:e,height:t};this.emit("videoCodecInfo",r)}yuvData(e,t){if(!this.module)return;const r=this.width*this.height,n=r>>2;let o=this.module.HEAPU32[e>>2],i=this.module.HEAPU32[1+(e>>2)],s=this.module.HEAPU32[2+(e>>2)],a=this.module.HEAPU8.subarray(o,o+r),u=this.module.HEAPU8.subarray(i,i+n),c=this.module.HEAPU8.subarray(s,s+n);if(this.yuvMode)return void this.emit("videoFrame",{y:a,u:u,v:c,timestamp:t});const l=new Uint8Array(r+n+n);l.set(a),l.set(u,r),l.set(c,r+n),this.emit("videoFrame",new VideoFrame(l,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}errorInfo(e){let t={errMsg:e};this.emit("error",t)}};__decorateClass([ChangeState([FSM.INIT,"closed"],"initialized")],VideoDecoderSoftBase.prototype,"initialize",1),__decorateClass([ChangeState("initialized","configured",{sync:!0})],VideoDecoderSoftBase.prototype,"configure",1),__decorateClass([ChangeState([],FSM.INIT,{sync:!0})],VideoDecoderSoftBase.prototype,"reset",1),__decorateClass([ChangeState([],"closed",{sync:!0})],VideoDecoderSoftBase.prototype,"close",1);var Module=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return function(t={}){var r,n,o=t;o.ready=new Promise(((e,t)=>{r=e,n=t}));var i,s,a,u=Object.assign({},o),c="./this.program",l="object"==typeof window,d="function"==typeof importScripts,h=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(l||d)&&(d?h=self.location.href:"undefined"!=typeof document&&document.currentScript&&(h=document.currentScript.src),e&&(h=e),h=0!==h.indexOf("blob:")?h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),s=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var f,p=o.print||console.log.bind(console),m=o.printErr||console.error.bind(console);Object.assign(o,u),u=null,o.arguments&&o.arguments,o.thisProgram&&(c=o.thisProgram),o.quit&&o.quit,o.wasmBinary&&(f=o.wasmBinary);var g,v;o.noExitRuntime;"object"!=typeof WebAssembly&&N("no native wasm support detected");var y,_,w,E,S,b,A,T,O,I=!1;var P=[],C=[],R=[];var $=0,D=null,k=null;function M(e){$++,o.monitorRunDependencies&&o.monitorRunDependencies($)}function U(e){if($--,o.monitorRunDependencies&&o.monitorRunDependencies($),0==$&&(null!==D&&(clearInterval(D),D=null),k)){var t=k;k=null,t()}}function N(e){o.onAbort&&o.onAbort(e),m(e="Aborted("+e+")"),I=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}var L,F,B,V;function x(e){return e.startsWith("data:application/octet-stream;base64,")}function j(e){if(e==L&&f)return new Uint8Array(f);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function W(e,t,r){return function(e){return f||!l&&!d||"function"!=typeof fetch?Promise.resolve().then((()=>j(e))):fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>j(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{m("failed to asynchronously prepare wasm: "+e),N(e)}))}x(L="videodec.wasm")||(F=L,L=o.locateFile?o.locateFile(F,h):h+F);var H=e=>{for(;e.length>0;)e.shift()(o)};function G(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){b[this.ptr+4>>2]=e},this.get_type=function(){return b[this.ptr+4>>2]},this.set_destructor=function(e){b[this.ptr+8>>2]=e},this.get_destructor=function(){return b[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,y[this.ptr+12|0]=e},this.get_caught=function(){return 0!=y[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,y[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=y[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){b[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return b[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Qt(this.get_type()))return b[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var z={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,n=e.length-1;n>=0;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=z.isAbs(e),r="/"===e.substr(-1);return(e=z.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=z.splitPath(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=z.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return z.normalize(e.join("/"))},join2:(e,t)=>z.normalize(e+"/"+t)},Q=e=>(Q=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);N("initRandomDevice")})())(e),q={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:ae.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,t=z.isAbs(n)}return(t?"/":"")+(e=z.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=q.resolve(e).substr(1),t=q.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),i=Math.min(n.length,o.length),s=i,a=0;a<i;a++)if(n[a]!==o[a]){s=a;break}var u=[];for(a=s;a<n.length;a++)u.push("..");return(u=u.concat(o.slice(s))).join("/")}},X="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,J=(e,t,r)=>{for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&X)return X.decode(e.subarray(t,o));for(var i="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|u:(7&s)<<18|a<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var c=s-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i},K=[],Y=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t},Z=(e,t,r,n)=>{if(!(n>0))return 0;for(var o=r,i=r+n-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s);if(a<=127){if(r>=i)break;t[r++]=a}else if(a<=2047){if(r+1>=i)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=i)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=i)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-o};function ee(e,t,r){var n=r>0?r:Y(e)+1,o=new Array(n),i=Z(e,o,0,o.length);return t&&(o.length=i),o}var te={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){te.ttys[e]={input:[],output:[],ops:t},ae.registerDevice(e,te.stream_ops)},stream_ops:{open:function(e){var t=te.ttys[e.node.rdev];if(!t)throw new ae.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.get_char)throw new ae.ErrnoError(60);for(var i=0,s=0;s<n;s++){var a;try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new ae.ErrnoError(29)}if(void 0===a&&0===i)throw new ae.ErrnoError(6);if(null==a)break;i++,t[r+s]=a}return i&&(e.node.timestamp=Date.now()),i},write:function(e,t,r,n,o){if(!e.tty||!e.tty.ops.put_char)throw new ae.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,t[r+i])}catch(e){throw new ae.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){return(()=>{if(!K.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;K=ee(e,!0)}return K.shift()})()},put_char:function(e,t){null===t||10===t?(p(J(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(p(J(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,t,r){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(m(J(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(m(J(e.output,0)),e.output=[])}}},re=e=>{N()},ne={ops_table:null,mount:e=>ne.createNode(null,"/",16895,0),createNode(e,t,r,n){if(ae.isBlkdev(r)||ae.isFIFO(r))throw new ae.ErrnoError(63);ne.ops_table||(ne.ops_table={dir:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr,lookup:ne.node_ops.lookup,mknod:ne.node_ops.mknod,rename:ne.node_ops.rename,unlink:ne.node_ops.unlink,rmdir:ne.node_ops.rmdir,readdir:ne.node_ops.readdir,symlink:ne.node_ops.symlink},stream:{llseek:ne.stream_ops.llseek}},file:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr},stream:{llseek:ne.stream_ops.llseek,read:ne.stream_ops.read,write:ne.stream_ops.write,allocate:ne.stream_ops.allocate,mmap:ne.stream_ops.mmap,msync:ne.stream_ops.msync}},link:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr,readlink:ne.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ne.node_ops.getattr,setattr:ne.node_ops.setattr},stream:ae.chrdev_stream_ops}});var o=ae.createNode(e,t,r,n);return ae.isDir(o.mode)?(o.node_ops=ne.ops_table.dir.node,o.stream_ops=ne.ops_table.dir.stream,o.contents={}):ae.isFile(o.mode)?(o.node_ops=ne.ops_table.file.node,o.stream_ops=ne.ops_table.file.stream,o.usedBytes=0,o.contents=null):ae.isLink(o.mode)?(o.node_ops=ne.ops_table.link.node,o.stream_ops=ne.ops_table.link.stream):ae.isChrdev(o.mode)&&(o.node_ops=ne.ops_table.chrdev.node,o.stream_ops=ne.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var n=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(n.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=ae.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ae.isDir(e.mode)?t.size=4096:ae.isFile(e.mode)?t.size=e.usedBytes:ae.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ne.resizeFileStorage(e,t.size)},lookup(e,t){throw ae.genericErrors[44]},mknod:(e,t,r,n)=>ne.createNode(e,t,r,n),rename(e,t,r){if(ae.isDir(e.mode)){var n;try{n=ae.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new ae.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=ae.lookupNode(e,t);for(var n in r.contents)throw new ae.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var n=ne.createNode(e,t,41471,0);return n.link=r,n},readlink(e){if(!ae.isLink(e.mode))throw new ae.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)t.set(i.subarray(o,o+s),r);else for(var a=0;a<s;a++)t[r+a]=i[o+a];return s},write(e,t,r,n,o,i){if(!n)return 0;var s=e.node;if(s.timestamp=Date.now(),t.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=t.subarray(r,r+n),s.usedBytes=n,n;if(0===s.usedBytes&&0===o)return s.contents=t.slice(r,r+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(t.subarray(r,r+n),o),n}if(ne.expandFileStorage(s,o+n),s.contents.subarray&&t.subarray)s.contents.set(t.subarray(r,r+n),o);else for(var a=0;a<n;a++)s.contents[o+a]=t[r+a];return s.usedBytes=Math.max(s.usedBytes,o+n),n},llseek(e,t,r){var n=t;if(1===r?n+=e.position:2===r&&ae.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new ae.ErrnoError(28);return n},allocate(e,t,r){ne.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,n,o){if(!ae.isFile(e.node.mode))throw new ae.ErrnoError(43);var i,s,a=e.node.contents;if(2&o||a.buffer!==y.buffer){if((r>0||r+t<a.length)&&(a=a.subarray?a.subarray(r,r+t):Array.prototype.slice.call(a,r,r+t)),s=!0,!(i=re()))throw new ae.ErrnoError(48);y.set(a,i)}else s=!1,i=a.byteOffset;return{ptr:i,allocated:s}},msync:(e,t,r,n,o)=>(ne.stream_ops.write(e,t,0,n,r,!1),0)}},oe=(e,t,r,n)=>{var o=n?"":`al ${e}`;s(e,(r=>{var n;n=`Loading data file "${e}" failed (no arrayBuffer).`,r||N(n),t(new Uint8Array(r)),o&&U()}),(t=>{if(!r)throw`Loading data file "${e}" failed.`;r()})),o&&M()},ie=o.preloadPlugins||[];function se(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ae={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,t={})=>{if(!(e=q.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ae.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),n=ae.root,o="/",i=0;i<r.length;i++){var s=i===r.length-1;if(s&&t.parent)break;if(n=ae.lookupNode(n,r[i]),o=z.join2(o,r[i]),ae.isMountpoint(n)&&(!s||s&&t.follow_mount)&&(n=n.mounted.root),!s||t.follow)for(var a=0;ae.isLink(n.mode);){var u=ae.readlink(o);if(o=q.resolve(z.dirname(o),u),n=ae.lookupPath(o,{recurse_count:t.recurse_count+1}).node,a++>40)throw new ae.ErrnoError(32)}}return{path:o,node:n}},getPath:e=>{for(var t;;){if(ae.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?`${r}/${t}`:r+t:r}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName:(e,t)=>{for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%ae.nameTable.length},hashAddNode:e=>{var t=ae.hashName(e.parent.id,e.name);e.name_next=ae.nameTable[t],ae.nameTable[t]=e},hashRemoveNode:e=>{var t=ae.hashName(e.parent.id,e.name);if(ae.nameTable[t]===e)ae.nameTable[t]=e.name_next;else for(var r=ae.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:(e,t)=>{var r=ae.mayLookup(e);if(r)throw new ae.ErrnoError(r,e);for(var n=ae.hashName(e.id,t),o=ae.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===t)return o}return ae.lookup(e,t)},createNode:(e,t,r,n)=>{var o=new ae.FSNode(e,t,r,n);return ae.hashAddNode(o),o},destroyNode:e=>{ae.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ae.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>{var t=ae.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:(e,t)=>{try{ae.lookupNode(e,t);return 20}catch(e){}return ae.nodePermissions(e,"wx")},mayDelete:(e,t,r)=>{var n;try{n=ae.lookupNode(e,t)}catch(e){return e.errno}var o=ae.nodePermissions(e,"wx");if(o)return o;if(r){if(!ae.isDir(n.mode))return 54;if(ae.isRoot(n)||ae.getPath(n)===ae.cwd())return 10}else if(ae.isDir(n.mode))return 31;return 0},mayOpen:(e,t)=>e?ae.isLink(e.mode)?32:ae.isDir(e.mode)&&("r"!==ae.flagsToPermissionString(t)||512&t)?31:ae.nodePermissions(e,ae.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=ae.MAX_OPEN_FDS;e++)if(!ae.streams[e])return e;throw new ae.ErrnoError(33)},getStreamChecked:e=>{var t=ae.getStream(e);if(!t)throw new ae.ErrnoError(8);return t},getStream:e=>ae.streams[e],createStream:(e,t=-1)=>(ae.FSStream||(ae.FSStream=function(){this.shared={}},ae.FSStream.prototype={},Object.defineProperties(ae.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return!!(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new ae.FSStream,e),-1==t&&(t=ae.nextfd()),e.fd=t,ae.streams[t]=e,e),closeStream:e=>{ae.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ae.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ae.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ae.devices[e]={stream_ops:t}},getDevice:e=>ae.devices[e],getMounts:e=>{for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ae.syncFSRequests++,ae.syncFSRequests>1&&m(`warning: ${ae.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var r=ae.getMounts(ae.root.mount),n=0;function o(e){return ae.syncFSRequests--,t(e)}function i(e){if(e)return i.errored?void 0:(i.errored=!0,o(e));++n>=r.length&&o(null)}r.forEach((t=>{if(!t.type.syncfs)return i(null);t.type.syncfs(t,e,i)}))},mount:(e,t,r)=>{var n,o="/"===r,i=!r;if(o&&ae.root)throw new ae.ErrnoError(10);if(!o&&!i){var s=ae.lookupPath(r,{follow_mount:!1});if(r=s.path,n=s.node,ae.isMountpoint(n))throw new ae.ErrnoError(10);if(!ae.isDir(n.mode))throw new ae.ErrnoError(54)}var a={type:e,opts:t,mountpoint:r,mounts:[]},u=e.mount(a);return u.mount=a,a.root=u,o?ae.root=u:n&&(n.mounted=a,n.mount&&n.mount.mounts.push(a)),u},unmount:e=>{var t=ae.lookupPath(e,{follow_mount:!1});if(!ae.isMountpoint(t.node))throw new ae.ErrnoError(28);var r=t.node,n=r.mounted,o=ae.getMounts(n);Object.keys(ae.nameTable).forEach((e=>{for(var t=ae.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ae.destroyNode(t),t=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,r)=>{var n=ae.lookupPath(e,{parent:!0}).node,o=z.basename(e);if(!o||"."===o||".."===o)throw new ae.ErrnoError(28);var i=ae.mayCreate(n,o);if(i)throw new ae.ErrnoError(i);if(!n.node_ops.mknod)throw new ae.ErrnoError(63);return n.node_ops.mknod(n,o,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ae.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ae.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{ae.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,ae.mknod(e,t,r)),symlink:(e,t)=>{if(!q.resolve(e))throw new ae.ErrnoError(44);var r=ae.lookupPath(t,{parent:!0}).node;if(!r)throw new ae.ErrnoError(44);var n=z.basename(t),o=ae.mayCreate(r,n);if(o)throw new ae.ErrnoError(o);if(!r.node_ops.symlink)throw new ae.ErrnoError(63);return r.node_ops.symlink(r,n,e)},rename:(e,t)=>{var r,n,o=z.dirname(e),i=z.dirname(t),s=z.basename(e),a=z.basename(t);if(r=ae.lookupPath(e,{parent:!0}).node,n=ae.lookupPath(t,{parent:!0}).node,!r||!n)throw new ae.ErrnoError(44);if(r.mount!==n.mount)throw new ae.ErrnoError(75);var u,c=ae.lookupNode(r,s),l=q.relative(e,i);if("."!==l.charAt(0))throw new ae.ErrnoError(28);if("."!==(l=q.relative(t,o)).charAt(0))throw new ae.ErrnoError(55);try{u=ae.lookupNode(n,a)}catch(e){}if(c!==u){var d=ae.isDir(c.mode),h=ae.mayDelete(r,s,d);if(h)throw new ae.ErrnoError(h);if(h=u?ae.mayDelete(n,a,d):ae.mayCreate(n,a))throw new ae.ErrnoError(h);if(!r.node_ops.rename)throw new ae.ErrnoError(63);if(ae.isMountpoint(c)||u&&ae.isMountpoint(u))throw new ae.ErrnoError(10);if(n!==r&&(h=ae.nodePermissions(r,"w")))throw new ae.ErrnoError(h);ae.hashRemoveNode(c);try{r.node_ops.rename(c,n,a)}catch(e){throw e}finally{ae.hashAddNode(c)}}},rmdir:e=>{var t=ae.lookupPath(e,{parent:!0}).node,r=z.basename(e),n=ae.lookupNode(t,r),o=ae.mayDelete(t,r,!0);if(o)throw new ae.ErrnoError(o);if(!t.node_ops.rmdir)throw new ae.ErrnoError(63);if(ae.isMountpoint(n))throw new ae.ErrnoError(10);t.node_ops.rmdir(t,r),ae.destroyNode(n)},readdir:e=>{var t=ae.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ae.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ae.lookupPath(e,{parent:!0}).node;if(!t)throw new ae.ErrnoError(44);var r=z.basename(e),n=ae.lookupNode(t,r),o=ae.mayDelete(t,r,!1);if(o)throw new ae.ErrnoError(o);if(!t.node_ops.unlink)throw new ae.ErrnoError(63);if(ae.isMountpoint(n))throw new ae.ErrnoError(10);t.node_ops.unlink(t,r),ae.destroyNode(n)},readlink:e=>{var t=ae.lookupPath(e).node;if(!t)throw new ae.ErrnoError(44);if(!t.node_ops.readlink)throw new ae.ErrnoError(28);return q.resolve(ae.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var r=ae.lookupPath(e,{follow:!t}).node;if(!r)throw new ae.ErrnoError(44);if(!r.node_ops.getattr)throw new ae.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>ae.stat(e,!0),chmod:(e,t,r)=>{var n;"string"==typeof e?n=ae.lookupPath(e,{follow:!r}).node:n=e;if(!n.node_ops.setattr)throw new ae.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&t|-4096&n.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ae.chmod(e,t,!0)},fchmod:(e,t)=>{var r=ae.getStreamChecked(e);ae.chmod(r.node,t)},chown:(e,t,r,n)=>{var o;"string"==typeof e?o=ae.lookupPath(e,{follow:!n}).node:o=e;if(!o.node_ops.setattr)throw new ae.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,t,r)=>{ae.chown(e,t,r,!0)},fchown:(e,t,r)=>{var n=ae.getStreamChecked(e);ae.chown(n.node,t,r)},truncate:(e,t)=>{if(t<0)throw new ae.ErrnoError(28);var r;"string"==typeof e?r=ae.lookupPath(e,{follow:!0}).node:r=e;if(!r.node_ops.setattr)throw new ae.ErrnoError(63);if(ae.isDir(r.mode))throw new ae.ErrnoError(31);if(!ae.isFile(r.mode))throw new ae.ErrnoError(28);var n=ae.nodePermissions(r,"w");if(n)throw new ae.ErrnoError(n);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var r=ae.getStreamChecked(e);if(!(2097155&r.flags))throw new ae.ErrnoError(28);ae.truncate(r.node,t)},utime:(e,t,r)=>{var n=ae.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(t,r)})},open:(e,t,r)=>{if(""===e)throw new ae.ErrnoError(44);var n;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?function(e){var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error(`Unknown file open mode: ${e}`);return t}(t):t)?4095&r|32768:0,"object"==typeof e)n=e;else{e=z.normalize(e);try{n=ae.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var i=!1;if(64&t)if(n){if(128&t)throw new ae.ErrnoError(20)}else n=ae.mknod(e,r,0),i=!0;if(!n)throw new ae.ErrnoError(44);if(ae.isChrdev(n.mode)&&(t&=-513),65536&t&&!ae.isDir(n.mode))throw new ae.ErrnoError(54);if(!i){var s=ae.mayOpen(n,t);if(s)throw new ae.ErrnoError(s)}512&t&&!i&&ae.truncate(n,0),t&=-131713;var a=ae.createStream({node:n,path:ae.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return a.stream_ops.open&&a.stream_ops.open(a),!o.logReadFiles||1&t||(ae.readFiles||(ae.readFiles={}),e in ae.readFiles||(ae.readFiles[e]=1)),a},close:e=>{if(ae.isClosed(e))throw new ae.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ae.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,r)=>{if(ae.isClosed(e))throw new ae.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ae.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ae.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:(e,t,r,n,o)=>{if(n<0||o<0)throw new ae.ErrnoError(28);if(ae.isClosed(e))throw new ae.ErrnoError(8);if(1==(2097155&e.flags))throw new ae.ErrnoError(8);if(ae.isDir(e.node.mode))throw new ae.ErrnoError(31);if(!e.stream_ops.read)throw new ae.ErrnoError(28);var i=void 0!==o;if(i){if(!e.seekable)throw new ae.ErrnoError(70)}else o=e.position;var s=e.stream_ops.read(e,t,r,n,o);return i||(e.position+=s),s},write:(e,t,r,n,o,i)=>{if(n<0||o<0)throw new ae.ErrnoError(28);if(ae.isClosed(e))throw new ae.ErrnoError(8);if(!(2097155&e.flags))throw new ae.ErrnoError(8);if(ae.isDir(e.node.mode))throw new ae.ErrnoError(31);if(!e.stream_ops.write)throw new ae.ErrnoError(28);e.seekable&&1024&e.flags&&ae.llseek(e,0,2);var s=void 0!==o;if(s){if(!e.seekable)throw new ae.ErrnoError(70)}else o=e.position;var a=e.stream_ops.write(e,t,r,n,o,i);return s||(e.position+=a),a},allocate:(e,t,r)=>{if(ae.isClosed(e))throw new ae.ErrnoError(8);if(t<0||r<=0)throw new ae.ErrnoError(28);if(!(2097155&e.flags))throw new ae.ErrnoError(8);if(!ae.isFile(e.node.mode)&&!ae.isDir(e.node.mode))throw new ae.ErrnoError(43);if(!e.stream_ops.allocate)throw new ae.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:(e,t,r,n,o)=>{if(2&n&&!(2&o)&&2!=(2097155&e.flags))throw new ae.ErrnoError(2);if(1==(2097155&e.flags))throw new ae.ErrnoError(2);if(!e.stream_ops.mmap)throw new ae.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,o)},msync:(e,t,r,n,o)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,o):0,munmap:e=>0,ioctl:(e,t,r)=>{if(!e.stream_ops.ioctl)throw new ae.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:(e,t={})=>{if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error(`Invalid encoding type "${t.encoding}"`);var r,n=ae.open(e,t.flags),o=ae.stat(e).size,i=new Uint8Array(o);return ae.read(n,i,0,o,0),"utf8"===t.encoding?r=J(i,0):"binary"===t.encoding&&(r=i),ae.close(n),r},writeFile:(e,t,r={})=>{r.flags=r.flags||577;var n=ae.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(Y(t)+1),i=Z(t,o,0,o.length);ae.write(n,o,0,i,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ae.write(n,t,0,t.byteLength,void 0,r.canOwn)}ae.close(n)},cwd:()=>ae.currentPath,chdir:e=>{var t=ae.lookupPath(e,{follow:!0});if(null===t.node)throw new ae.ErrnoError(44);if(!ae.isDir(t.node.mode))throw new ae.ErrnoError(54);var r=ae.nodePermissions(t.node,"x");if(r)throw new ae.ErrnoError(r);ae.currentPath=t.path},createDefaultDirectories:()=>{ae.mkdir("/tmp"),ae.mkdir("/home"),ae.mkdir("/home/web_user")},createDefaultDevices:()=>{ae.mkdir("/dev"),ae.registerDevice(ae.makedev(1,3),{read:()=>0,write:(e,t,r,n,o)=>n}),ae.mkdev("/dev/null",ae.makedev(1,3)),te.register(ae.makedev(5,0),te.default_tty_ops),te.register(ae.makedev(6,0),te.default_tty1_ops),ae.mkdev("/dev/tty",ae.makedev(5,0)),ae.mkdev("/dev/tty1",ae.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=Q(e).byteLength),e[--t]);ae.createDevice("/dev","random",r),ae.createDevice("/dev","urandom",r),ae.mkdir("/dev/shm"),ae.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ae.mkdir("/proc");var e=ae.mkdir("/proc/self");ae.mkdir("/proc/self/fd"),ae.mount({mount:()=>{var t=ae.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var r=+t,n=ae.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>n.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?ae.createDevice("/dev","stdin",o.stdin):ae.symlink("/dev/tty","/dev/stdin"),o.stdout?ae.createDevice("/dev","stdout",null,o.stdout):ae.symlink("/dev/tty","/dev/stdout"),o.stderr?ae.createDevice("/dev","stderr",null,o.stderr):ae.symlink("/dev/tty1","/dev/stderr");ae.open("/dev/stdin",0),ae.open("/dev/stdout",1),ae.open("/dev/stderr",1)},ensureErrnoError:()=>{ae.ErrnoError||(ae.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ae.ErrnoError.prototype=new Error,ae.ErrnoError.prototype.constructor=ae.ErrnoError,[44].forEach((e=>{ae.genericErrors[e]=new ae.ErrnoError(e),ae.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{ae.ensureErrnoError(),ae.nameTable=new Array(4096),ae.mount(ne,{},"/"),ae.createDefaultDirectories(),ae.createDefaultDevices(),ae.createSpecialDirectories(),ae.filesystems={MEMFS:ne}},init:(e,t,r)=>{ae.init.initialized=!0,ae.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=t||o.stdout,o.stderr=r||o.stderr,ae.createStandardStreams()},quit:()=>{ae.init.initialized=!1;for(var e=0;e<ae.streams.length;e++){var t=ae.streams[e];t&&ae.close(t)}},findObject:(e,t)=>{var r=ae.analyzePath(e,t);return r.exists?r.object:null},analyzePath:(e,t)=>{try{e=(n=ae.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=ae.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=z.basename(e),n=ae.lookupPath(e,{follow:!t}),r.exists=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.isRoot="/"===n.path}catch(e){r.error=e.errno}return r},createPath:(e,t,r,n)=>{e="string"==typeof e?e:ae.getPath(e);for(var o=t.split("/").reverse();o.length;){var i=o.pop();if(i){var s=z.join2(e,i);try{ae.mkdir(s)}catch(e){}e=s}}return s},createFile:(e,t,r,n,o)=>{var i=z.join2("string"==typeof e?e:ae.getPath(e),t),s=se(n,o);return ae.create(i,s)},createDataFile:(e,t,r,n,o,i)=>{var s=t;e&&(e="string"==typeof e?e:ae.getPath(e),s=t?z.join2(e,t):e);var a=se(n,o),u=ae.create(s,a);if(r){if("string"==typeof r){for(var c=new Array(r.length),l=0,d=r.length;l<d;++l)c[l]=r.charCodeAt(l);r=c}ae.chmod(u,146|a);var h=ae.open(u,577);ae.write(h,r,0,r.length,0,i),ae.close(h),ae.chmod(u,a)}return u},createDevice:(e,t,r,n)=>{var o=z.join2("string"==typeof e?e:ae.getPath(e),t),i=se(!!r,!!n);ae.createDevice.major||(ae.createDevice.major=64);var s=ae.makedev(ae.createDevice.major++,0);return ae.registerDevice(s,{open:e=>{e.seekable=!1},close:e=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(e,t,n,o,i)=>{for(var s=0,a=0;a<o;a++){var u;try{u=r()}catch(e){throw new ae.ErrnoError(29)}if(void 0===u&&0===s)throw new ae.ErrnoError(6);if(null==u)break;s++,t[n+a]=u}return s&&(e.node.timestamp=Date.now()),s},write:(e,t,r,o,i)=>{for(var s=0;s<o;s++)try{n(t[r+s])}catch(e){throw new ae.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),s}}),ae.mkdev(o,i,s)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!i)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=ee(i(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new ae.ErrnoError(29)}},createLazyFile:(e,t,r,n,o)=>{function i(){this.lengthKnown=!1,this.chunks=[]}if(i.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},i.prototype.setDataGetter=function(e){this.getter=e},i.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,i=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,s=1048576;o||(s=n);var a=this;a.setDataGetter((e=>{var t=e*s,o=(e+1)*s-1;if(o=Math.min(o,n-1),void 0===a.chunks[e]&&(a.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>n-1)throw new Error("only "+n+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",r,!1),n!==s&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+r+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):ee(o.responseText||"",!0)})(t,o)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]})),!i&&n||(s=n=1,n=this.getter(0).length,s=n,p("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=s,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!d)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i;Object.defineProperties(s,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var a={isDevice:!1,contents:s}}else a={isDevice:!1,url:r};var u=ae.createFile(e,t,a,n,o);a.contents?u.contents=a.contents:a.url&&(u.contents=null,u.url=a.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={};function l(e,t,r,n,o){var i=e.node.contents;if(o>=i.length)return 0;var s=Math.min(i.length-o,n);if(i.slice)for(var a=0;a<s;a++)t[r+a]=i[o+a];else for(a=0;a<s;a++)t[r+a]=i.get(o+a);return s}return Object.keys(u.stream_ops).forEach((e=>{var t=u.stream_ops[e];c[e]=function(){return ae.forceLoadFile(u),t.apply(null,arguments)}})),c.read=(e,t,r,n,o)=>(ae.forceLoadFile(u),l(e,t,r,n,o)),c.mmap=(e,t,r,n,o)=>{ae.forceLoadFile(u);var i=re();if(!i)throw new ae.ErrnoError(48);return l(e,y,i,t,r),{ptr:i,allocated:!0}},u.stream_ops=c,u}},ue=(e,t)=>e?J(_,e,t):"",ce={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(z.isAbs(t))return t;var n;-100===e?n=ae.cwd():n=ce.getStreamFromFD(e).path;if(0==t.length){if(!r)throw new ae.ErrnoError(44);return n}return z.join2(n,t)},doStat:function(e,t,r){try{var n=e(t)}catch(e){if(e&&e.node&&z.normalize(t)!==z.normalize(ae.getPath(e.node)))return-54;throw e}S[r>>2]=n.dev,S[r+4>>2]=n.mode,b[r+8>>2]=n.nlink,S[r+12>>2]=n.uid,S[r+16>>2]=n.gid,S[r+20>>2]=n.rdev,V=[n.size>>>0,(B=n.size,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+24>>2]=V[0],S[r+28>>2]=V[1],S[r+32>>2]=4096,S[r+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return V=[Math.floor(o/1e3)>>>0,(B=Math.floor(o/1e3),+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+40>>2]=V[0],S[r+44>>2]=V[1],b[r+48>>2]=o%1e3*1e3,V=[Math.floor(i/1e3)>>>0,(B=Math.floor(i/1e3),+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+56>>2]=V[0],S[r+60>>2]=V[1],b[r+64>>2]=i%1e3*1e3,V=[Math.floor(s/1e3)>>>0,(B=Math.floor(s/1e3),+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+72>>2]=V[0],S[r+76>>2]=V[1],b[r+80>>2]=s%1e3*1e3,V=[n.ino>>>0,(B=n.ino,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[r+88>>2]=V[0],S[r+92>>2]=V[1],0},doMsync:function(e,t,r,n,o){if(!ae.isFile(t.node.mode))throw new ae.ErrnoError(43);if(2&n)return 0;var i=_.slice(e,e+r);ae.msync(t,i,o,r,n)},varargs:void 0,get:()=>(ce.varargs+=4,S[ce.varargs-4>>2]),getStr:e=>ue(e),getStreamFromFD:function(e){return ae.getStreamChecked(e)}};function le(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var de=void 0;function he(e){for(var t="",r=e;_[r];)t+=de[_[r++]];return t}var fe={},pe={},me={},ge=void 0;function ve(e){throw new ge(e)}var ye=void 0;function _e(e){throw new ye(e)}function we(e,t,r){function n(t){var n=r(t);n.length!==e.length&&_e("Mismatched type converter count");for(var o=0;o<e.length;++o)Ee(e[o],n[o])}e.forEach((function(e){me[e]=t}));var o=new Array(t.length),i=[],s=0;t.forEach(((e,t)=>{pe.hasOwnProperty(e)?o[t]=pe[e]:(i.push(e),fe.hasOwnProperty(e)||(fe[e]=[]),fe[e].push((()=>{o[t]=pe[e],++s===i.length&&n(o)})))})),0===i.length&&n(o)}function Ee(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t,r={}){var n=t.name;if(e||ve(`type "${n}" must have a positive integer typeid pointer`),pe.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;ve(`Cannot register type '${n}' twice`)}if(pe[e]=t,delete me[e],fe.hasOwnProperty(e)){var o=fe[e];delete fe[e],o.forEach((e=>e()))}}(e,t,r)}function Se(e){if(!(this instanceof He))return!1;if(!(e instanceof He))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return t===n&&r===o}function be(e){ve(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Ae=!1;function Te(e){}function Oe(e){e.count.value-=1,0===e.count.value&&function(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}(e)}function Ie(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var n=Ie(e,t,r.baseClass);return null===n?null:r.downcast(n)}var Pe={};function Ce(){return Object.keys(Ue).length}function Re(){var e=[];for(var t in Ue)Ue.hasOwnProperty(t)&&e.push(Ue[t]);return e}var $e=[];function De(){for(;$e.length;){var e=$e.pop();e.$$.deleteScheduled=!1,e.delete()}}var ke=void 0;function Me(e){ke=e,$e.length&&ke&&ke(De)}var Ue={};function Ne(e,t){return t=function(e,t){for(void 0===t&&ve("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),Ue[t]}function Le(e,t){return t.ptrType&&t.ptr||_e("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!==!!t.smartPtr&&_e("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Be(Object.create(e,{$$:{value:t}}))}function Fe(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=Ne(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var n=r.clone();return this.destructor(e),n}function o(){return this.isSmartPointer?Le(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Le(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,s=this.registeredClass.getActualType(t),a=Pe[s];if(!a)return o.call(this);i=this.isConst?a.constPointerType:a.pointerType;var u=Ie(t,this.registeredClass,i.registeredClass);return null===u?o.call(this):this.isSmartPointer?Le(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):Le(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}var Be=function(e){return"undefined"==typeof FinalizationRegistry?(Be=e=>e,e):(Ae=new FinalizationRegistry((e=>{Oe(e.$$)})),Te=e=>Ae.unregister(e),(Be=e=>{var t=e.$$;if(!!t.smartPtr){var r={$$:t};Ae.register(e,r,e)}return e})(e))};function Ve(){if(this.$$.ptr||be(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Be(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t}function xe(){this.$$.ptr||be(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ve("Object already scheduled for deletion"),Te(this),Oe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function je(){return!this.$$.ptr}function We(){return this.$$.ptr||be(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ve("Object already scheduled for deletion"),$e.push(this),1===$e.length&&ke&&ke(De),this.$$.deleteScheduled=!0,this}function He(){}function Ge(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?`_${e}`:e}function ze(e,t){return e=Ge(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Qe(e,t,r){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||ve(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function qe(e,t,r,n,o,i,s,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function Xe(e,t,r){for(;t!==r;)t.upcast||ve(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e}function Je(e,t){if(null===t)return this.isReference&&ve(`null is not a valid ${this.name}`),0;t.$$||ve(`Cannot pass "${wt(t)}" as a ${this.name}`),t.$$.ptr||ve(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Xe(t.$$.ptr,r,this.registeredClass)}function Ke(e,t){var r;if(null===t)return this.isReference&&ve(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||ve(`Cannot pass "${wt(t)}" as a ${this.name}`),t.$$.ptr||ve(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&ve(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var n=t.$$.ptrType.registeredClass;if(r=Xe(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&ve("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:ve(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,_t.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:ve("Unsupporting sharing policy")}return r}function Ye(e,t){if(null===t)return this.isReference&&ve(`null is not a valid ${this.name}`),0;t.$$||ve(`Cannot pass "${wt(t)}" as a ${this.name}`),t.$$.ptr||ve(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&ve(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Xe(t.$$.ptr,r,this.registeredClass)}function Ze(e){return this.fromWireType(S[e>>2])}function et(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function tt(e){this.rawDestructor&&this.rawDestructor(e)}function rt(e){null!==e&&e.delete()}function nt(e,t,r,n,o,i,s,a,u,c,l){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=l,o||void 0!==t.baseClass?this.toWireType=Ke:n?(this.toWireType=Je,this.destructorFunction=null):(this.toWireType=Ye,this.destructorFunction=null)}var ot=[],it=e=>{var t=ot[e];return t||(e>=ot.length&&(ot.length=e+1),ot[e]=t=O.get(e)),t},st=(e,t,r)=>e.includes("j")?((e,t,r)=>{var n=o["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)})(e,t,r):it(t).apply(null,r);function at(e,t){var r,n,o,i=(e=he(e)).includes("j")?(r=e,n=t,o=[],function(){return o.length=0,Object.assign(o,arguments),st(r,n,o)}):it(t);return"function"!=typeof i&&ve(`unknown function pointer with signature ${e}: ${t}`),i}var ut=void 0;function ct(e){var t=zt(e),r=he(t);return Ht(t),r}function lt(e,t){var r=[],n={};throw t.forEach((function e(t){n[t]||pe[t]||(me[t]?me[t].forEach(e):(r.push(t),n[t]=!0))})),new ut(`${e}: `+r.map(ct).join([", "]))}function dt(e,t){for(var r=[],n=0;n<e;n++)r.push(b[t+4*n>>2]);return r}function ht(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function ft(e,t){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var r=ze(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var n=new r,o=e.apply(n,t);return o instanceof Object?o:n}function pt(e,t,r,n,o,i){var s=t.length;s<2&&ve("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var a=null!==t[1]&&null!==r,u=!1,c=1;c<t.length;++c)if(null!==t[c]&&void 0===t[c].destructorFunction){u=!0;break}var l="void"!==t[0].name,d="",h="";for(c=0;c<s-2;++c)d+=(0!==c?", ":"")+"arg"+c,h+=(0!==c?", ":"")+"arg"+c+"Wired";var f=`\n return function ${Ge(e)}(${d}) {\n if (arguments.length !== ${s-2}) {\n throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${s-2} args!');\n }`;u&&(f+="var destructors = [];\n");var p=u?"destructors":"null",m=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],g=[ve,n,o,ht,t[0],t[1]];a&&(f+="var thisWired = classParam.toWireType("+p+", this);\n");for(c=0;c<s-2;++c)f+="var arg"+c+"Wired = argType"+c+".toWireType("+p+", arg"+c+"); // "+t[c+2].name+"\n",m.push("argType"+c),g.push(t[c+2]);if(a&&(h="thisWired"+(h.length>0?", ":"")+h),f+=(l||i?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",u)f+="runDestructors(destructors);\n";else for(c=a?1:2;c<t.length;++c){var v=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(f+=v+"_dtor("+v+"); // "+t[c].name+"\n",m.push(v+"_dtor"),g.push(t[c].destructorFunction))}return l&&(f+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),f+="}\n",m.push(f),ft(Function,m).apply(null,g)}function mt(){this.allocated=[void 0],this.freelist=[]}var gt=new mt;function vt(e){e>=gt.reserved&&0==--gt.get(e).refcount&>.free(e)}function yt(){for(var e=0,t=gt.reserved;t<gt.allocated.length;++t)void 0!==gt.allocated[t]&&++e;return e}var _t={toValue:e=>(e||ve("Cannot use deleted val. handle = "+e),gt.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return gt.allocate({refcount:1,value:e})}}};function wt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Et(e,t){switch(t){case 2:return function(e){return this.fromWireType(A[e>>2])};case 3:return function(e){return this.fromWireType(T[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function St(e,t,r){switch(t){case 0:return r?function(e){return y[e]}:function(e){return _[e]};case 1:return r?function(e){return w[e>>1]}:function(e){return E[e>>1]};case 2:return r?function(e){return S[e>>2]}:function(e){return b[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var bt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,At=(e,t)=>{for(var r=e,n=r>>1,o=n+t/2;!(n>=o)&&E[n];)++n;if((r=n<<1)-e>32&&bt)return bt.decode(_.subarray(e,r));for(var i="",s=0;!(s>=t/2);++s){var a=w[e+2*s>>1];if(0==a)break;i+=String.fromCharCode(a)}return i},Tt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var n=t,o=(r-=2)<2*e.length?r/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);w[t>>1]=s,t+=2}return w[t>>1]=0,t-n},Ot=e=>2*e.length,It=(e,t)=>{for(var r=0,n="";!(r>=t/4);){var o=S[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(o)}return n},Pt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var n=t,o=n+r-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i);if(S[t>>2]=s,(t+=4)+4>o)break}return S[t>>2]=0,t-n},Ct=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&++r,t+=4}return t};var Rt={};var $t=[];var Dt=[];var kt={},Mt=()=>{if(!Mt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var t in kt)void 0===kt[t]?delete e[t]:e[t]=kt[t];var r=[];for(var t in e)r.push(`${t}=${e[t]}`);Mt.strings=r}return Mt.strings};var Ut,Nt,Lt,Ft=function(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ae.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n},Bt=365,Vt=146;Object.defineProperties(Ft.prototype,{read:{get:function(){return(this.mode&Bt)===Bt},set:function(e){e?this.mode|=Bt:this.mode&=-366}},write:{get:function(){return(this.mode&Vt)===Vt},set:function(e){e?this.mode|=Vt:this.mode&=-147}},isFolder:{get:function(){return ae.isDir(this.mode)}},isDevice:{get:function(){return ae.isChrdev(this.mode)}}}),ae.FSNode=Ft,ae.createPreloadedFile=function(e,t,r,n,o,i,s,a,u,c){var l=t?q.resolve(z.join2(e,t)):e;function d(r){function d(r){c&&c(),a||ae.createDataFile(e,t,r,n,o,u),i&&i(),U()}(function(e,t,r,n){"undefined"!=typeof Browser&&Browser.init();var o=!1;return ie.forEach((function(i){o||i.canHandle(t)&&(i.handle(e,t,r,n),o=!0)})),o})(r,l,d,(()=>{s&&s(),U()}))||d(r)}M(),"string"==typeof r?oe(r,(e=>d(e)),s):d(r)},ae.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);de=e}(),ge=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},ye=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},He.prototype.isAliasOf=Se,He.prototype.clone=Ve,He.prototype.delete=xe,He.prototype.isDeleted=je,He.prototype.deleteLater=We,o.getInheritedInstanceCount=Ce,o.getLiveInheritedInstances=Re,o.flushPendingDeletes=De,o.setDelayFunction=Me,nt.prototype.getPointee=et,nt.prototype.destructor=tt,nt.prototype.argPackAdvance=8,nt.prototype.readValueFromPointer=Ze,nt.prototype.deleteObject=rt,nt.prototype.fromWireType=Fe,ut=o.UnboundTypeError=(Ut=Error,(Lt=ze(Nt="UnboundTypeError",(function(e){this.name=Nt,this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(Ut.prototype),Lt.prototype.constructor=Lt,Lt.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},Lt),Object.assign(mt.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),gt.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),gt.reserved=gt.allocated.length,o.count_emval_handles=yt;var xt,jt={p:function(e,t,r){throw new G(e).init(t,r),e},C:function(e,t,r){ce.varargs=r;try{var n=ce.getStreamFromFD(e);switch(t){case 0:return(o=ce.get())<0?-28:ae.createStream(n,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return n.flags;case 4:var o=ce.get();return n.flags|=o,0;case 5:o=ce.get();return w[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return i=28,S[Gt()>>2]=i,-1}}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return-e.errno}var i},w:function(e,t,r,n){ce.varargs=n;try{t=ce.getStr(t),t=ce.calculateAt(e,t);var o=n?ce.get():0;return ae.open(t,r,o).fd}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return-e.errno}},t:function(e,t,r,n,o){},n:function(e,t,r,n,o){var i=le(r);Ee(e,{name:t=he(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?n:o},argPackAdvance:8,readValueFromPointer:function(e){var n;if(1===r)n=y;else if(2===r)n=w;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=S}return this.fromWireType(n[e>>i])},destructorFunction:null})},r:function(e,t,r,n,i,s,a,u,c,l,d,h,f){d=he(d),s=at(i,s),u&&(u=at(a,u)),l&&(l=at(c,l)),f=at(h,f);var p=Ge(d);!function(e,t,r){o.hasOwnProperty(e)?((void 0===r||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[r])&&ve(`Cannot register public name '${e}' twice`),Qe(o,e,e),o.hasOwnProperty(r)&&ve(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),o[e].overloadTable[r]=t):(o[e]=t,void 0!==r&&(o[e].numArguments=r))}(p,(function(){lt(`Cannot construct ${d} due to unbound types`,[n])})),we([e,t,r],n?[n]:[],(function(t){var r,i;t=t[0],i=n?(r=t.registeredClass).instancePrototype:He.prototype;var a=ze(p,(function(){if(Object.getPrototypeOf(this)!==c)throw new ge("Use 'new' to construct "+d);if(void 0===h.constructor_body)throw new ge(d+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new ge(`Tried to invoke ctor of ${d} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,arguments)})),c=Object.create(i,{constructor:{value:a}});a.prototype=c;var h=new qe(d,a,c,f,r,s,u,l);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m=new nt(d,h,!0,!1,!1),g=new nt(d+"*",h,!1,!1,!1),v=new nt(d+" const*",h,!1,!0,!1);return Pe[e]={pointerType:g,constPointerType:v},function(e,t,r){o.hasOwnProperty(e)||_e("Replacing nonexistant public symbol"),void 0!==o[e].overloadTable&&void 0!==r?o[e].overloadTable[r]=t:(o[e]=t,o[e].argCount=r)}(p,a),[m,g,v]}))},q:function(e,t,r,n,o,i){var s=dt(t,r);o=at(n,o),we([],[e],(function(e){var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new ge(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{lt(`Cannot construct ${e.name} due to unbound types`,s)},we([],s,(function(n){return n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=pt(r,n,null,o,i),[]})),[]}))},d:function(e,t,r,n,o,i,s,a,u){var c=dt(r,n);t=he(t),i=at(o,i),we([],[e],(function(e){var n=`${(e=e[0]).name}.${t}`;function o(){lt(`Cannot call ${n} due to unbound types`,c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),a&&e.registeredClass.pureVirtualFunctions.push(t);var l=e.registeredClass.instancePrototype,d=l[t];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===r-2?(o.argCount=r-2,o.className=e.name,l[t]=o):(Qe(l,t,n),l[t].overloadTable[r-2]=o),we([],c,(function(o){var a=pt(n,o,e,i,s,u);return void 0===l[t].overloadTable?(a.argCount=r-2,l[t]=a):l[t].overloadTable[r-2]=a,[]})),[]}))},D:function(e,t){Ee(e,{name:t=he(t),fromWireType:function(e){var t=_t.toValue(e);return vt(e),t},toWireType:function(e,t){return _t.toHandle(t)},argPackAdvance:8,readValueFromPointer:Ze,destructorFunction:null})},k:function(e,t,r){var n=le(r);Ee(e,{name:t=he(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Et(t,n),destructorFunction:null})},c:function(e,t,r,n,o){t=he(t),-1===o&&(o=4294967295);var i=le(r),s=e=>e;if(0===n){var a=32-8*r;s=e=>e<<a>>>a}var u=t.includes("unsigned");Ee(e,{name:t,fromWireType:s,toWireType:u?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:St(t,i,0!==n),destructorFunction:null})},b:function(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=b,r=t[e>>=2],o=t[e+1];return new n(t.buffer,o,r)}Ee(e,{name:r=he(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=he(t));Ee(e,{name:t,fromWireType:function(e){var t,n=b[e>>2],o=e+4;if(r)for(var i=o,s=0;s<=n;++s){var a=o+s;if(s==n||0==_[a]){var u=ue(i,a-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=a+1}}else{var c=new Array(n);for(s=0;s<n;++s)c[s]=String.fromCharCode(_[o+s]);t=c.join("")}return Ht(e),t},toWireType:function(e,t){var n;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||ve("Cannot pass non-string to std::string"),n=r&&o?Y(t):t.length;var i=Wt(4+n+1),s=i+4;if(b[i>>2]=n,r&&o)Z(t,_,s,n+1);else if(o)for(var a=0;a<n;++a){var u=t.charCodeAt(a);u>255&&(Ht(s),ve("String has UTF-16 code units that do not fit in 8 bits")),_[s+a]=u}else for(a=0;a<n;++a)_[s+a]=t[a];return null!==e&&e.push(Ht,i),i},argPackAdvance:8,readValueFromPointer:Ze,destructorFunction:function(e){Ht(e)}})},f:function(e,t,r){var n,o,i,s,a;r=he(r),2===t?(n=At,o=Tt,s=Ot,i=()=>E,a=1):4===t&&(n=It,o=Pt,s=Ct,i=()=>b,a=2),Ee(e,{name:r,fromWireType:function(e){for(var r,o=b[e>>2],s=i(),u=e+4,c=0;c<=o;++c){var l=e+4+c*t;if(c==o||0==s[l>>a]){var d=n(u,l-u);void 0===r?r=d:(r+=String.fromCharCode(0),r+=d),u=l+t}}return Ht(e),r},toWireType:function(e,n){"string"!=typeof n&&ve(`Cannot pass non-string to C++ string type ${r}`);var i=s(n),u=Wt(4+i+t);return b[u>>2]=i>>a,o(n,u+4,i+t),null!==e&&e.push(Ht,u),u},argPackAdvance:8,readValueFromPointer:Ze,destructorFunction:function(e){Ht(e)}})},o:function(e,t){Ee(e,{isVoid:!0,name:t=he(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,n){var o,i;(e=$t[e])(t=_t.toValue(t),r=void 0===(i=Rt[o=r])?he(o):i,null,n)},m:vt,l:function(e,t){var r=function(e,t){for(var r,n,o,i=new Array(e),s=0;s<e;++s)i[s]=(r=b[t+4*s>>2],n="parameter "+s,o=void 0,void 0===(o=pe[r])&&ve(n+" has unknown type "+ct(r)),o);return i}(e,t),n=r[0],o=n.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",i=Dt[o];if(void 0!==i)return i;for(var s=["retType"],a=[n],u="",c=0;c<e-1;++c)u+=(0!==c?", ":"")+"arg"+c,s.push("argType"+c),a.push(r[1+c]);var l="return function "+Ge("methodCaller_"+o)+"(handle, name, destructors, args) {\n",d=0;for(c=0;c<e-1;++c)l+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(d?"+"+d:"")+");\n",d+=r[c+1].argPackAdvance;for(l+=" var rv = handle[name]("+u+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(l+=" argType"+c+".deleteObject(arg"+c+");\n");n.isVoid||(l+=" return retType.toWireType(destructors, rv);\n"),l+="};\n",s.push(l);var h,f,p=ft(Function,s).apply(null,a);return h=p,f=$t.length,$t.push(h),i=f,Dt[o]=i,i},a:()=>{N("")},e:function(){return Date.now()},v:()=>_.length,A:(e,t,r)=>_.copyWithin(e,t,t+r),u:e=>{_.length;N("OOM")},y:(e,t)=>{var r=0;return Mt().forEach((function(n,o){var i=t+r;b[e+4*o>>2]=i,((e,t)=>{for(var r=0;r<e.length;++r)y[0|t++]=e.charCodeAt(r);y[0|t]=0})(n,i),r+=n.length+1})),0},z:(e,t)=>{var r=Mt();b[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),b[t>>2]=n,0},i:function(e){try{var t=ce.getStreamFromFD(e);return ae.close(t),0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},x:function(e,t){try{var r=ce.getStreamFromFD(e),n=r.tty?2:ae.isDir(r.mode)?3:ae.isLink(r.mode)?7:4;return y[t|0]=n,w[t+2>>1]=0,V=[0,(B=0,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[t+8>>2]=V[0],S[t+12>>2]=V[1],V=[0,(B=0,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[t+16>>2]=V[0],S[t+20>>2]=V[1],0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},B:function(e,t,r,n){try{var o=((e,t,r,n)=>{for(var o=0,i=0;i<r;i++){var s=b[t>>2],a=b[t+4>>2];t+=8;var u=ae.read(e,y,s,a,n);if(u<0)return-1;if(o+=u,u<a)break;void 0!==n&&(n+=u)}return o})(ce.getStreamFromFD(e),t,r);return b[n>>2]=o,0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},s:function(e,t,r,n,o){var i,s,a=(s=r)+2097152>>>0<4194305-!!(i=t)?(i>>>0)+4294967296*s:NaN;try{if(isNaN(a))return 61;var u=ce.getStreamFromFD(e);return ae.llseek(u,a,n),V=[u.position>>>0,(B=u.position,+Math.abs(B)>=1?B>0?+Math.floor(B/4294967296)>>>0:~~+Math.ceil((B-+(~~B>>>0))/4294967296)>>>0:0)],S[o>>2]=V[0],S[o+4>>2]=V[1],u.getdents&&0===a&&0===n&&(u.getdents=null),0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}},h:function(e,t,r,n){try{var o=((e,t,r,n)=>{for(var o=0,i=0;i<r;i++){var s=b[t>>2],a=b[t+4>>2];t+=8;var u=ae.write(e,y,s,a,n);if(u<0)return-1;o+=u,void 0!==n&&(n+=u)}return o})(ce.getStreamFromFD(e),t,r);return b[n>>2]=o,0}catch(e){if(void 0===ae||"ErrnoError"!==e.name)throw e;return e.errno}}},Wt=(function(){var e,t,r,i,s={a:jt};function a(e,t){var r,n,i=e.exports;return g=(v=i).E,r=g.buffer,o.HEAP8=y=new Int8Array(r),o.HEAP16=w=new Int16Array(r),o.HEAP32=S=new Int32Array(r),o.HEAPU8=_=new Uint8Array(r),o.HEAPU16=E=new Uint16Array(r),o.HEAPU32=b=new Uint32Array(r),o.HEAPF32=A=new Float32Array(r),o.HEAPF64=T=new Float64Array(r),O=v.H,n=v.F,C.unshift(n),U(),i}if(M(),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(e){m("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=f,t=L,r=s,i=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||x(t)||"function"!=typeof fetch?W(t,r,i):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(i,(function(e){return m("wasm streaming compile failed: "+e),m("falling back to ArrayBuffer instantiation"),W(t,r,i)}))))).catch(n)}(),e=>(Wt=v.G)(e)),Ht=e=>(Ht=v.I)(e),Gt=()=>(Gt=v.J)(),zt=e=>(zt=v.K)(e),Qt=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=v.L)(),e=>(Qt=v.M)(e));o.dynCall_jiji=(e,t,r,n,i)=>(o.dynCall_jiji=v.N)(e,t,r,n,i),o._ff_h264_cabac_tables=67061;function qt(){function e(){xt||(xt=!0,o.calledRun=!0,I||(o.noFSInit||ae.init.initialized||ae.init(),ae.ignorePermissions=!1,te.init(),H(C),r(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),R.unshift(e);var e;H(R)}()))}$>0||(!function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),P.unshift(e);var e;H(P)}(),$>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(k=function e(){xt||qt(),xt||(k=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return qt(),t.ready}})(),videodec_default=Module,VideoDecoderSoft=class extends VideoDecoderSoftBase{constructor(e){super(videodec_default,(null==e?void 0:e.wasmPath)?fetch(null==e?void 0:e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}},Module2=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return function(t={}){var r,n,o=t;o.ready=new Promise(((e,t)=>{r=e,n=t}));var i,s=Object.assign({},o),a="object"==typeof window,u="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||u)&&(u?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),e&&(c=e),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",u&&(i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var l,d=o.print||console.log.bind(console),h=o.printErr||console.error.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(l=o.wasmBinary);var f,p;o.noExitRuntime;"object"!=typeof WebAssembly&&$("no native wasm support detected");var m,g,v,y,_,w,E,S,b,A=!1;var T=[],O=[],I=[];var P=0,C=null,R=null;function $(e){o.onAbort&&o.onAbort(e),h(e="Aborted("+e+")"),A=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}var D,k;function M(e){return e.startsWith("data:application/octet-stream;base64,")}function U(e){if(e==D&&l)return new Uint8Array(l);if(i)return i(e);throw"both async and sync fetching of the wasm failed"}function N(e,t,r){return function(e){return l||!a&&!u||"function"!=typeof fetch?Promise.resolve().then((()=>U(e))):fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>U(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{h("failed to asynchronously prepare wasm: "+e),$(e)}))}M(D="videodec_simd.wasm")||(k=D,D=o.locateFile?o.locateFile(k,c):c+k);var L=e=>{for(;e.length>0;)e.shift()(o)};function F(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){w[this.ptr+4>>2]=e},this.get_type=function(){return w[this.ptr+4>>2]},this.set_destructor=function(e){w[this.ptr+8>>2]=e},this.get_destructor=function(){return w[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,m[this.ptr+12|0]=e},this.get_caught=function(){return 0!=m[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,m[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=m[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){w[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return w[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Et(this.get_type()))return w[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}function B(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var V=void 0;function x(e){for(var t="",r=e;g[r];)t+=V[g[r++]];return t}var j={},W={},H={},G=void 0;function z(e){throw new G(e)}var Q=void 0;function q(e){throw new Q(e)}function X(e,t,r){function n(t){var n=r(t);n.length!==e.length&&q("Mismatched type converter count");for(var o=0;o<e.length;++o)J(e[o],n[o])}e.forEach((function(e){H[e]=t}));var o=new Array(t.length),i=[],s=0;t.forEach(((e,t)=>{W.hasOwnProperty(e)?o[t]=W[e]:(i.push(e),j.hasOwnProperty(e)||(j[e]=[]),j[e].push((()=>{o[t]=W[e],++s===i.length&&n(o)})))})),0===i.length&&n(o)}function J(e,t,r={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t,r={}){var n=t.name;if(e||z(`type "${n}" must have a positive integer typeid pointer`),W.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;z(`Cannot register type '${n}' twice`)}if(W[e]=t,delete H[e],j.hasOwnProperty(e)){var o=j[e];delete j[e],o.forEach((e=>e()))}}(e,t,r)}function K(e){if(!(this instanceof _e))return!1;if(!(e instanceof _e))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,n=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return t===n&&r===o}function Y(e){z(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Z=!1;function ee(e){}function te(e){e.count.value-=1,0===e.count.value&&function(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}(e)}function re(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var n=re(e,t,r.baseClass);return null===n?null:r.downcast(n)}var ne={};function oe(){return Object.keys(le).length}function ie(){var e=[];for(var t in le)le.hasOwnProperty(t)&&e.push(le[t]);return e}var se=[];function ae(){for(;se.length;){var e=se.pop();e.$$.deleteScheduled=!1,e.delete()}}var ue=void 0;function ce(e){ue=e,se.length&&ue&&ue(ae)}var le={};function de(e,t){return t=function(e,t){for(void 0===t&&z("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),le[t]}function he(e,t){return t.ptrType&&t.ptr||q("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!==!!t.smartPtr&&q("Both smartPtrType and smartPtr must be specified"),t.count={value:1},pe(Object.create(e,{$$:{value:t}}))}function fe(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=de(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var n=r.clone();return this.destructor(e),n}function o(){return this.isSmartPointer?he(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):he(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,s=this.registeredClass.getActualType(t),a=ne[s];if(!a)return o.call(this);i=this.isConst?a.constPointerType:a.pointerType;var u=re(t,this.registeredClass,i.registeredClass);return null===u?o.call(this):this.isSmartPointer?he(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):he(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}var pe=function(e){return"undefined"==typeof FinalizationRegistry?(pe=e=>e,e):(Z=new FinalizationRegistry((e=>{te(e.$$)})),ee=e=>Z.unregister(e),(pe=e=>{var t=e.$$;if(!!t.smartPtr){var r={$$:t};Z.register(e,r,e)}return e})(e))};function me(){if(this.$$.ptr||Y(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=pe(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t}function ge(){this.$$.ptr||Y(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&z("Object already scheduled for deletion"),ee(this),te(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function ve(){return!this.$$.ptr}function ye(){return this.$$.ptr||Y(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&z("Object already scheduled for deletion"),se.push(this),1===se.length&&ue&&ue(ae),this.$$.deleteScheduled=!0,this}function _e(){}function we(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?`_${e}`:e}function Ee(e,t){return e=we(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Se(e,t,r){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||z(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function be(e,t,r,n,o,i,s,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function Ae(e,t,r){for(;t!==r;)t.upcast||z(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e}function Te(e,t){if(null===t)return this.isReference&&z(`null is not a valid ${this.name}`),0;t.$$||z(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||z(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Ae(t.$$.ptr,r,this.registeredClass)}function Oe(e,t){var r;if(null===t)return this.isReference&&z(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||z(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||z(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&z(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var n=t.$$.ptrType.registeredClass;if(r=Ae(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&z("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:z(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,qe.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:z("Unsupporting sharing policy")}return r}function Ie(e,t){if(null===t)return this.isReference&&z(`null is not a valid ${this.name}`),0;t.$$||z(`Cannot pass "${Xe(t)}" as a ${this.name}`),t.$$.ptr||z(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&z(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return Ae(t.$$.ptr,r,this.registeredClass)}function Pe(e){return this.fromWireType(_[e>>2])}function Ce(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function Re(e){this.rawDestructor&&this.rawDestructor(e)}function $e(e){null!==e&&e.delete()}function De(e,t,r,n,o,i,s,a,u,c,l){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=l,o||void 0!==t.baseClass?this.toWireType=Oe:n?(this.toWireType=Te,this.destructorFunction=null):(this.toWireType=Ie,this.destructorFunction=null)}var ke=[],Me=e=>{var t=ke[e];return t||(e>=ke.length&&(ke.length=e+1),ke[e]=t=b.get(e)),t},Ue=(e,t,r)=>e.includes("j")?((e,t,r)=>{var n=o["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)})(e,t,r):Me(t).apply(null,r);function Ne(e,t){var r,n,o,i=(e=x(e)).includes("j")?(r=e,n=t,o=[],function(){return o.length=0,Object.assign(o,arguments),Ue(r,n,o)}):Me(t);return"function"!=typeof i&&z(`unknown function pointer with signature ${e}: ${t}`),i}var Le=void 0;function Fe(e){var t=wt(e),r=x(t);return yt(t),r}function Be(e,t){var r=[],n={};throw t.forEach((function e(t){n[t]||W[t]||(H[t]?H[t].forEach(e):(r.push(t),n[t]=!0))})),new Le(`${e}: `+r.map(Fe).join([", "]))}function Ve(e,t){for(var r=[],n=0;n<e;n++)r.push(w[t+4*n>>2]);return r}function xe(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function je(e,t){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var r=Ee(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var n=new r,o=e.apply(n,t);return o instanceof Object?o:n}function We(e,t,r,n,o,i){var s=t.length;s<2&&z("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var a=null!==t[1]&&null!==r,u=!1,c=1;c<t.length;++c)if(null!==t[c]&&void 0===t[c].destructorFunction){u=!0;break}var l="void"!==t[0].name,d="",h="";for(c=0;c<s-2;++c)d+=(0!==c?", ":"")+"arg"+c,h+=(0!==c?", ":"")+"arg"+c+"Wired";var f=`\n return function ${we(e)}(${d}) {\n if (arguments.length !== ${s-2}) {\n throwBindingError('function ${e} called with ${arguments.length} arguments, expected ${s-2} args!');\n }`;u&&(f+="var destructors = [];\n");var p=u?"destructors":"null",m=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],g=[z,n,o,xe,t[0],t[1]];a&&(f+="var thisWired = classParam.toWireType("+p+", this);\n");for(c=0;c<s-2;++c)f+="var arg"+c+"Wired = argType"+c+".toWireType("+p+", arg"+c+"); // "+t[c+2].name+"\n",m.push("argType"+c),g.push(t[c+2]);if(a&&(h="thisWired"+(h.length>0?", ":"")+h),f+=(l||i?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",u)f+="runDestructors(destructors);\n";else for(c=a?1:2;c<t.length;++c){var v=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(f+=v+"_dtor("+v+"); // "+t[c].name+"\n",m.push(v+"_dtor"),g.push(t[c].destructorFunction))}return l&&(f+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),f+="}\n",m.push(f),je(Function,m).apply(null,g)}function He(){this.allocated=[void 0],this.freelist=[]}var Ge=new He;function ze(e){e>=Ge.reserved&&0==--Ge.get(e).refcount&&Ge.free(e)}function Qe(){for(var e=0,t=Ge.reserved;t<Ge.allocated.length;++t)void 0!==Ge.allocated[t]&&++e;return e}var qe={toValue:e=>(e||z("Cannot use deleted val. handle = "+e),Ge.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Ge.allocate({refcount:1,value:e})}}};function Xe(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Je(e,t){switch(t){case 2:return function(e){return this.fromWireType(E[e>>2])};case 3:return function(e){return this.fromWireType(S[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ke(e,t,r){switch(t){case 0:return r?function(e){return m[e]}:function(e){return g[e]};case 1:return r?function(e){return v[e>>1]}:function(e){return y[e>>1]};case 2:return r?function(e){return _[e>>2]}:function(e){return w[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Ye="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,Ze=(e,t,r)=>{for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&Ye)return Ye.decode(e.subarray(t,o));for(var i="";t<o;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|u:(7&s)<<18|a<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var c=s-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i},et=(e,t)=>e?Ze(g,e,t):"";var tt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,rt=(e,t)=>{for(var r=e,n=r>>1,o=n+t/2;!(n>=o)&&y[n];)++n;if((r=n<<1)-e>32&&tt)return tt.decode(g.subarray(e,r));for(var i="",s=0;!(s>=t/2);++s){var a=v[e+2*s>>1];if(0==a)break;i+=String.fromCharCode(a)}return i},nt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var n=t,o=(r-=2)<2*e.length?r/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);v[t>>1]=s,t+=2}return v[t>>1]=0,t-n},ot=e=>2*e.length,it=(e,t)=>{for(var r=0,n="";!(r>=t/4);){var o=_[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|1023&i)}else n+=String.fromCharCode(o)}return n},st=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var n=t,o=n+r-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i);if(_[t>>2]=s,(t+=4)+4>o)break}return _[t>>2]=0,t-n},at=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&++r,t+=4}return t};var ut={};var ct=[];var lt=[];var dt;dt=()=>performance.now();var ht,ft,pt,mt=[null,[],[]];!function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);V=e}(),G=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Q=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},_e.prototype.isAliasOf=K,_e.prototype.clone=me,_e.prototype.delete=ge,_e.prototype.isDeleted=ve,_e.prototype.deleteLater=ye,o.getInheritedInstanceCount=oe,o.getLiveInheritedInstances=ie,o.flushPendingDeletes=ae,o.setDelayFunction=ce,De.prototype.getPointee=Ce,De.prototype.destructor=Re,De.prototype.argPackAdvance=8,De.prototype.readValueFromPointer=Pe,De.prototype.deleteObject=$e,De.prototype.fromWireType=fe,Le=o.UnboundTypeError=(ht=Error,(pt=Ee(ft="UnboundTypeError",(function(e){this.name=ft,this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(ht.prototype),pt.prototype.constructor=pt,pt.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},pt),Object.assign(He.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Ge.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Ge.reserved=Ge.allocated.length,o.count_emval_handles=Qe;var gt,vt={o:function(e,t,r){throw new F(e).init(t,r),e},r:function(e,t,r,n,o){},m:function(e,t,r,n,o){var i=B(r);J(e,{name:t=x(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?n:o},argPackAdvance:8,readValueFromPointer:function(e){var n;if(1===r)n=m;else if(2===r)n=v;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=_}return this.fromWireType(n[e>>i])},destructorFunction:null})},q:function(e,t,r,n,i,s,a,u,c,l,d,h,f){d=x(d),s=Ne(i,s),u&&(u=Ne(a,u)),l&&(l=Ne(c,l)),f=Ne(h,f);var p=we(d);!function(e,t,r){o.hasOwnProperty(e)?((void 0===r||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[r])&&z(`Cannot register public name '${e}' twice`),Se(o,e,e),o.hasOwnProperty(r)&&z(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),o[e].overloadTable[r]=t):(o[e]=t,void 0!==r&&(o[e].numArguments=r))}(p,(function(){Be(`Cannot construct ${d} due to unbound types`,[n])})),X([e,t,r],n?[n]:[],(function(t){var r,i;t=t[0],i=n?(r=t.registeredClass).instancePrototype:_e.prototype;var a=Ee(p,(function(){if(Object.getPrototypeOf(this)!==c)throw new G("Use 'new' to construct "+d);if(void 0===h.constructor_body)throw new G(d+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new G(`Tried to invoke ctor of ${d} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,arguments)})),c=Object.create(i,{constructor:{value:a}});a.prototype=c;var h=new be(d,a,c,f,r,s,u,l);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m=new De(d,h,!0,!1,!1),g=new De(d+"*",h,!1,!1,!1),v=new De(d+" const*",h,!1,!0,!1);return ne[e]={pointerType:g,constPointerType:v},function(e,t,r){o.hasOwnProperty(e)||q("Replacing nonexistant public symbol"),void 0!==o[e].overloadTable&&void 0!==r?o[e].overloadTable[r]=t:(o[e]=t,o[e].argCount=r)}(p,a),[m,g,v]}))},p:function(e,t,r,n,o,i){var s=Ve(t,r);o=Ne(n,o),X([],[e],(function(e){var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new G(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{Be(`Cannot construct ${e.name} due to unbound types`,s)},X([],s,(function(n){return n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=We(r,n,null,o,i),[]})),[]}))},d:function(e,t,r,n,o,i,s,a,u){var c=Ve(r,n);t=x(t),i=Ne(o,i),X([],[e],(function(e){var n=`${(e=e[0]).name}.${t}`;function o(){Be(`Cannot call ${n} due to unbound types`,c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),a&&e.registeredClass.pureVirtualFunctions.push(t);var l=e.registeredClass.instancePrototype,d=l[t];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===r-2?(o.argCount=r-2,o.className=e.name,l[t]=o):(Se(l,t,n),l[t].overloadTable[r-2]=o),X([],c,(function(o){var a=We(n,o,e,i,s,u);return void 0===l[t].overloadTable?(a.argCount=r-2,l[t]=a):l[t].overloadTable[r-2]=a,[]})),[]}))},u:function(e,t){J(e,{name:t=x(t),fromWireType:function(e){var t=qe.toValue(e);return ze(e),t},toWireType:function(e,t){return qe.toHandle(t)},argPackAdvance:8,readValueFromPointer:Pe,destructorFunction:null})},k:function(e,t,r){var n=B(r);J(e,{name:t=x(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Je(t,n),destructorFunction:null})},b:function(e,t,r,n,o){t=x(t),-1===o&&(o=4294967295);var i=B(r),s=e=>e;if(0===n){var a=32-8*r;s=e=>e<<a>>>a}var u=t.includes("unsigned");J(e,{name:t,fromWireType:s,toWireType:u?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:Ke(t,i,0!==n),destructorFunction:null})},a:function(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=w,r=t[e>>=2],o=t[e+1];return new n(t.buffer,o,r)}J(e,{name:r=x(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=x(t));J(e,{name:t,fromWireType:function(e){var t,n=w[e>>2],o=e+4;if(r)for(var i=o,s=0;s<=n;++s){var a=o+s;if(s==n||0==g[a]){var u=et(i,a-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=a+1}}else{var c=new Array(n);for(s=0;s<n;++s)c[s]=String.fromCharCode(g[o+s]);t=c.join("")}return yt(e),t},toWireType:function(e,t){var n;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||z("Cannot pass non-string to std::string"),n=r&&o?(e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n<=127?t++:n<=2047?t+=2:n>=55296&&n<=57343?(t+=4,++r):t+=3}return t})(t):t.length;var i=_t(4+n+1),s=i+4;if(w[i>>2]=n,r&&o)((e,t,r,n)=>{if(!(n>0))return 0;for(var o=r,i=r+n-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s)),a<=127){if(r>=i)break;t[r++]=a}else if(a<=2047){if(r+1>=i)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=i)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=i)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}t[r]=0})(t,g,s,n+1);else if(o)for(var a=0;a<n;++a){var u=t.charCodeAt(a);u>255&&(yt(s),z("String has UTF-16 code units that do not fit in 8 bits")),g[s+a]=u}else for(a=0;a<n;++a)g[s+a]=t[a];return null!==e&&e.push(yt,i),i},argPackAdvance:8,readValueFromPointer:Pe,destructorFunction:function(e){yt(e)}})},g:function(e,t,r){var n,o,i,s,a;r=x(r),2===t?(n=rt,o=nt,s=ot,i=()=>y,a=1):4===t&&(n=it,o=st,s=at,i=()=>w,a=2),J(e,{name:r,fromWireType:function(e){for(var r,o=w[e>>2],s=i(),u=e+4,c=0;c<=o;++c){var l=e+4+c*t;if(c==o||0==s[l>>a]){var d=n(u,l-u);void 0===r?r=d:(r+=String.fromCharCode(0),r+=d),u=l+t}}return yt(e),r},toWireType:function(e,n){"string"!=typeof n&&z(`Cannot pass non-string to C++ string type ${r}`);var i=s(n),u=_t(4+i+t);return w[u>>2]=i>>a,o(n,u+4,i+t),null!==e&&e.push(yt,u),u},argPackAdvance:8,readValueFromPointer:Pe,destructorFunction:function(e){yt(e)}})},n:function(e,t){J(e,{isVoid:!0,name:t=x(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},e:function(e,t,r,n){var o,i;(e=ct[e])(t=qe.toValue(t),r=void 0===(i=ut[o=r])?x(o):i,null,n)},l:ze,h:function(e,t){var r=function(e,t){for(var r,n,o,i=new Array(e),s=0;s<e;++s)i[s]=(r=w[t+4*s>>2],n="parameter "+s,o=void 0,void 0===(o=W[r])&&z(n+" has unknown type "+Fe(r)),o);return i}(e,t),n=r[0],o=n.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",i=lt[o];if(void 0!==i)return i;for(var s=["retType"],a=[n],u="",c=0;c<e-1;++c)u+=(0!==c?", ":"")+"arg"+c,s.push("argType"+c),a.push(r[1+c]);var l="return function "+we("methodCaller_"+o)+"(handle, name, destructors, args) {\n",d=0;for(c=0;c<e-1;++c)l+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(d?"+"+d:"")+");\n",d+=r[c+1].argPackAdvance;for(l+=" var rv = handle[name]("+u+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(l+=" argType"+c+".deleteObject(arg"+c+");\n");n.isVoid||(l+=" return retType.toWireType(destructors, rv);\n"),l+="};\n",s.push(l);var h,f,p=je(Function,s).apply(null,a);return h=p,f=ct.length,ct.push(h),i=f,lt[o]=i,i},f:()=>{$("")},c:dt,t:(e,t,r)=>g.copyWithin(e,t,t+r),s:e=>{g.length;$("OOM")},i:(e,t,r,n)=>{for(var o,i,s,a=0,u=0;u<r;u++){var c=w[t>>2],l=w[t+4>>2];t+=8;for(var f=0;f<l;f++)o=e,i=g[c+f],s=void 0,s=mt[o],0===i||10===i?((1===o?d:h)(Ze(s,0)),s.length=0):s.push(i);a+=l}return w[n>>2]=a,0}},yt=(function(){var e,t,r,i,s={a:vt};function a(e,t){var r,n,i=e.exports;return f=(p=i).v,r=f.buffer,o.HEAP8=m=new Int8Array(r),o.HEAP16=v=new Int16Array(r),o.HEAP32=_=new Int32Array(r),o.HEAPU8=g=new Uint8Array(r),o.HEAPU16=y=new Uint16Array(r),o.HEAPU32=w=new Uint32Array(r),o.HEAPF32=E=new Float32Array(r),o.HEAPF64=S=new Float64Array(r),b=p.z,n=p.w,O.unshift(n),function(){if(P--,o.monitorRunDependencies&&o.monitorRunDependencies(P),0==P&&(null!==C&&(clearInterval(C),C=null),R)){var e=R;R=null,e()}}(),i}if(P++,o.monitorRunDependencies&&o.monitorRunDependencies(P),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(e){h("Module.instantiateWasm callback failed with error: "+e),n(e)}(e=l,t=D,r=s,i=function(e){a(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||M(t)||"function"!=typeof fetch?N(t,r,i):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(i,(function(e){return h("wasm streaming compile failed: "+e),h("falling back to ArrayBuffer instantiation"),N(t,r,i)}))))).catch(n)}(),e=>(yt=p.x)(e)),_t=e=>(_t=p.y)(e),wt=e=>(wt=p.A)(e),Et=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=p.B)(),e=>(Et=p.C)(e));o.dynCall_jiji=(e,t,r,n,i)=>(o.dynCall_jiji=p.D)(e,t,r,n,i);function St(){function e(){gt||(gt=!0,o.calledRun=!0,A||(L(O),r(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),I.unshift(e);var e;L(I)}()))}P>0||(!function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),T.unshift(e);var e;L(T)}(),P>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(R=function e(){gt||St(),gt||(R=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return St(),t.ready}})(),videodec_simd_default=Module2,VideoDecoderSoftSIMD=class extends VideoDecoderSoftBase{constructor(e){super(videodec_simd_default,(null==e?void 0:e.wasmPath)?fetch(e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}},INNER_EVENT=(e=>(e.ROOM_DESTROY="1",e.JOIN_START="21",e.JOIN_SCHEDULE_SUCCESS="22",e.JOIN_SIGNAL_CONNECTION_START="23",e.JOIN_SIGNAL_CONNECTION_END="24",e.JOIN_SEND_CMD="25",e.JOIN_RECEIVED_CMD_RES="26",e.JOIN_SUCCESS="27",e.JOIN_FAILED="28",e.LEAVE_START="51",e.LEAVE_SEND_CMD="52",e.LEAVE_SUCCESS="53",e.PUBLISH_START="61",e.SEND_FIRST_VIDEO_FRAME="62",e.PUBLISH_FAILED="63",e.SUBSCRIBE_START="81",e.SUBSCRIBE_SUCCESS="82",e.SUBSCRIBE_FAILED="84",e.UNSUBSCRIBE_SUCCESS="83",e.LOCAL_TRACK_CAPTURE_START="101",e.LOCAL_TRACK_CAPTURE_SUCCESS="102",e.LOCAL_TRACK_CAPTURE_FAILED="103",e.LOCAL_TRACK_PUBLISHED="104",e.LOCAL_TRACK_UNPUBLISHED="105",e.LOCAL_TRACK_REPLACED="106",e.SWITCH_DEVICE_SUCCESS="107",e.TRACK_MUTED="108",e.TRACK_UNMUTED="109",e.REMOTE_TRACK_SUBSCRIBED="110",e.REMOTE_TRACK_UNSUBSCRIBED="111",e.LOCAL_TRACK_RECAPTURE="112",e.LOCAL_AUDIO_STARTED="113",e.LOCAL_AUDIO_STOPPED="114",e.REMOTE_AUDIO_STARTED="115",e.REMOTE_AUDIO_STOPPED="116",e.PLAY_TRACK_START="151",e.PLAYER_STATE_CHANGED="152",e.VIDEO_LOADED_DATA="153",e.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",e.AUDIO_CONTEXT_LONG_SUSPENDED="155",e.REMOTE_VIDEO_PLAY_START="156",e.REMOTE_VIDEO_PLAY_FINISH="157",e.SIGNAL_CONNECTION_STATE_CHANGED="201",e.PEER_CONNECTION_STATE_CHANGED="202",e.SINGLE_CONNECTION_STAT="203",e.SPC_RECONNECTED="204",e.HEARTBEAT_REPORT="251",e.RECEIVED_PUBLISHED_USER_LIST="252",e.REMOTE_PUBLISH_STATE_CHANGED="253",e.AUDIO_LEVEL_INTERVAL="260",e.NETWORK_QUALITY="261",e.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",e.QUALITY_LIMITATION_CHANGED="263",e.LOG="264",e.AUDIO_PROCESSOR_DEBUG="265",e.SSO_SWITCH="266",e.SEI_MESSAGE="267",e.SWITCH_ROOM_START="401",e.SWITCH_ROOM_SUCCESS="407",e.SWITCH_ROOM_FAILED="408",e))(INNER_EVENT||{}),version="5.0.0",IS_WORKER="undefined"!=typeof importScripts,IS_WORKLET="undefined"!=typeof registerProcessor,loggerProxy="",BASE_HOST="web.sdk.qcloud.com",BASE_DOC_URL=`https://${BASE_HOST}/trtc/webrtc/doc`,DOC_URL=`${BASE_DOC_URL}/zh-cn/`,LOGGER_DOMAIN="https://yun.tim.qq.com",LOGGER_DOMAIN_OVERSEA="https://apisgp.my-imcloud.com",LOGGER_CMD_TYPE={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},LOG_LEVEL=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(LOG_LEVEL||{}),STORAGE_EXPIRES_TIME=6048e5,videoProfileMap={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},defaultBigVideoProfile=videoProfileMap["480p_2"],defaultSmallVideoProfile=videoProfileMap["120p_2"],NAME={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADSTART:"loadstart",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",RESIZE:"resize",TIME_UPDATE:"timeupdate"},REMOTE_STREAM_TYPE_MAIN=NAME.MAIN,REMOTE_STREAM_TYPE_AUX=NAME.AUXILIARY,STREAM_TYPE_BIG=NAME.BIG,STREAM_TYPE_SMALL=NAME.SMALL,PEERCONNECTION_CONNECTING_TIMEOUT=1e4,LOG_LEVEL_NAME=Object.keys(LOG_LEVEL),MAX_RTT=1e4,__awaiter=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},U32=Symbol(32),U16=Symbol(16),U8=Symbol(8),OPut=class{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return __awaiter(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,r)=>{var n;this.reject=r,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)};this.demand(e,!0)||null===(n=this.pull)||void 0===n||n.call(this,e)}))}))}readU32(){return this.read(U32)}readU16(){return this.read(U16)}readU8(){return this.read(U8)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null;const t=this.buffer.subarray(this.consumed);let r=0;const n=e=>t.length<(r=e);if("number"==typeof this.need){if(n(this.need))return;e=t.subarray(0,r)}else if(this.need===U32){if(n(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===U16){if(n(2))return;e=t[0]<<8|t[1]}else if(this.need===U8){if(n(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(n(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,r)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(n(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,r)),e=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){const t=this.buffer.length,r=t+e;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{const e=new Uint8Array(r);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}};OPut.U32=U32,OPut.U16=U16,OPut.U8=U8;var MSB=128,REST=127,MSBALL=~REST,INT=Math.pow(2,31);function encodeVarint(e){const t=new OPut;for(;e>=128;)t.malloc(1)[0]=255&e|MSB,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function encode(e,t=0){const r=new OPut,n=t<<3;switch(typeof e){case"boolean":const o=r.malloc(2);o[0]=n,o[1]=e?1:0;break;case"number":r.malloc(1)[0]=n,r.write(encodeVarint(e));break;case"string":r.malloc(1)[0]=2|n;const i=(new TextEncoder).encode(e);r.write(encodeVarint(i.length));const s=r.malloc(i.length);for(let e=0;e<i.length;e++)s[e]=i[e];break;case"object":const a=new OPut;if(Array.isArray(e))for(let t=0;t<e.length;t++){const r=encode(e[t],t+1);r&&a.write(r)}else{let t=1;for(const r in e){const n=encode(e[r],t++);n&&a.write(n)}}0===t?a.buffer&&r.write(a.buffer):(r.malloc(1)[0]=2|n,a.buffer&&(r.write(encodeVarint(a.buffer.length)),r.write(a.buffer)))}return r.buffer||new Uint8Array(0)}var Buffer2=class{constructor(){__publicField(this,"buffer"),this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeInt16(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeByte(e){this.buffer.push(255&e)}writeBytes(e){for(let t=0;t<e.length;t++)this.buffer.push(e[t])}};function writUint32(e,t,r){e[r]=t>>>24&255,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function readUint32(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function readUint8(e,t){return e[t]}function readString(e,t,r){return(new TextDecoder).decode(readBytes(e,t,r))}function readBytes(e,t,r){return e.slice(t,t+r)}var seqNumber=0,DELTA=2654435769,ROUNDS=16,LOG_ROUNDS=4,SALT_LEN=2,ZERO_LEN=7;function initSSOPacket(e,t,r,n="AVQualityReportSvc.C2S",o=2e3,i=2,s=30){return{version:o,encryption:i,d2:"",d2Len:0,uinType:s,uin:"",uinLen:0,reqHead:{seqNumber:r,appId:e,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:n,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}function encodeSSOPackage(e,t){const r=new Buffer2,n=initSSOPacket(t,e,seqNumber);seqNumber=seqNumber+1&2147483647,r.writeInt32(0),r.writeInt32(n.version),r.writeByte(n.encryption);const o=(new TextEncoder).encode(n.d2);r.writeInt32(o.length+4),o&&r.writeBytes(o),r.writeByte(n.uinType);const i=(new TextEncoder).encode(n.uin);r.writeInt32(i.length+4),i.length&&r.writeBytes(i);const s=new Buffer2;s.writeInt32(0),s.writeInt32(n.reqHead.seqNumber),s.writeInt32(n.reqHead.appId),s.writeByte(n.reqHead.appId>>>24&255),s.writeByte(n.reqHead.appId>>>16&255),s.writeByte(n.reqHead.appId>>>8&255),s.writeByte(255&n.reqHead.appId);for(let e=4;e<16;e++)s.writeByte(0);const a=(new TextEncoder).encode(n.reqHead.a2);s.writeInt32(a.length+4),a.length&&s.writeBytes(a);const u=(new TextEncoder).encode(n.reqHead.serviceCmd);s.writeInt32(u.length+4),u.length&&s.writeBytes(u);const c=(new TextEncoder).encode(n.reqHead.cookie);s.writeInt32(c.length+4),c.length&&s.writeBytes(c);const l=(new TextEncoder).encode(n.reqHead.imei);s.writeInt32(l.length+4),l.length&&s.writeBytes(l);const d=(new TextEncoder).encode(n.reqHead.ksid);s.writeInt32(d.length+4),d.length&&s.writeBytes(d);const h=(new TextEncoder).encode(n.reqHead.clientVersionInfo);s.writeInt16(h.length+2),h.length&&s.writeBytes(h);const f=s.length;s.data[0]=f>>>24&255,s.data[1]=f>>>16&255,s.data[2]=f>>>8&255,s.data[3]=255&f,isString(e)&&(e=(new TextEncoder).encode(e)),s.writeInt32(e.length+4),e.length&&s.writeBytes(e);let p=new Uint8Array(s.data),m=null;1===n.encryption?m=(new TextEncoder).encode(n.uin):2===n.encryption&&(m=new Uint8Array(16)),m&&(p=encrypt(p,m)),r.writeBytes(p);const g=new Uint8Array(r.data),v=g.length;return g[0]=v>>>24&255,g[1]=v>>>16&255,g[2]=v>>>8&255,g[3]=255&v,g}function encrypt(e,t){const r=e.length;let n=(r+1+SALT_LEN+ZERO_LEN)%8;n&&(n=8-n);const o=new Uint8Array(r+1+SALT_LEN+ZERO_LEN+n);let i=0;const s=new Uint8Array(8),a=new Uint8Array(8),u=new Uint8Array(8);let c=0;s[0]=248&Math.floor(256*Math.random())|n,c=1;for(let e=0;e<n;e++)s[c]=255&Math.floor(256*Math.random()),c+=1;for(let e=0;e<SALT_LEN;)if(c<8&&(s[c]=255&Math.floor(256*Math.random()),c+=1,e+=1),8===c){encryptBlock(s,t,a,u,o,i),i+=8,c=0;for(let e=0;e<8;e++)u[e]=o[i-8+e]}let l=0;for(;l<r;)if(c<8&&(s[c]=e[l],c+=1,l+=1),8===c){encryptBlock(s,t,a,u,o,i),i+=8,c=0;for(let e=0;e<8;e++)u[e]=o[i-8+e]}for(let e=0;e<ZERO_LEN;)if(c<8&&(s[c]=0,c+=1,e+=1),8===c){encryptBlock(s,t,a,u,o,i),i+=8,c=0;for(let e=0;e<8;e++)u[e]=o[i-8+e]}return o}function encryptBlock(e,t,r,n,o,i){for(let t=0;t<8;t++)e[t]^=n[t];teaEncrypt(e,t,o,i);for(let e=0;e<8;e++)o[i+e]^=r[e];for(let t=0;t<8;t++)r[t]=e[t]}function teaEncrypt(e,t,r,n){let o=readUint32(e,0),i=readUint32(e,4);const s=[];for(let e=0;e<4;e++)s[e]=readUint32(t,4*e);let a=0;for(let e=0;e<ROUNDS;e++)a+=DELTA,a>>>=0,o+=(i<<4)+s[0]^i+a^(i>>>5)+s[1],o>>>=0,i+=(o<<4)+s[2]^o+a^(o>>>5)+s[3],i>>>=0;writUint32(r,o,n),writUint32(r,i,n+4)}var baseTimeOffset=0,getNetworkTime=function(){return Date.now()+baseTimeOffset},getTimestamp=function(){const e=new Date;return e.setTime(getNetworkTime()),e.toLocaleString()},formatDate=function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),`${e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${t}`};function getBusibuff(e){const t=decodeSSOPackage(e);return null==t?void 0:t.busiBuff}function decodeSSOPackage(e){try{const t={};let r=0;t.totalLength=readUint32(e,r),r+=4,t.version=readUint32(e,r),r+=4,t.encryption=readUint8(e,r),r+=1,t.uinType=readUint8(e,r),r+=1,t.uinLength=readUint32(e,r),r+=4,t.uin=t.uinLength>4?readString(e,r,t.uinLength-4):"",r+=t.uinLength-4;const n=e.slice(r);if(2===t.encryption){const o=new Uint8Array(16).fill(0);e=decrypt(n,o),t.decrypted=!0,r=0}else e=n,r=0;return t.rspHeadLength=readUint32(e,r),r+=4,t.seqNo=readUint32(e,r),r+=4,t.retCode=readUint32(e,r),r+=4,t.retStrLength=readUint32(e,r),r+=4,t.retStr=t.retStrLength?readString(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=readUint32(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?readString(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=readUint32(e,r),r+=4,t.cookie=t.cookieLength?readString(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=readUint32(e,r),r+=4,t.busiBuffLength=readUint32(e,r),r+=4,t.busiBuff=t.busiBuffLength?readString(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(e){}}function teaDecryptBlock(e,t){let r=e[0]<<24|e[1]<<16|e[2]<<8|e[3],n=e[4]<<24|e[5]<<16|e[6]<<8|e[7];r>>>=0,n>>>=0;let o=DELTA*ROUNDS>>>0;for(let e=0;e<ROUNDS;e++)n-=(r<<LOG_ROUNDS)+t[2]^r+o^(r>>>5)+t[3],n>>>=0,r-=(n<<LOG_ROUNDS)+t[0]^n+o^(n>>>5)+t[1],r>>>=0,o-=DELTA,o>>>=0;return new Uint8Array([r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n])}function decrypt(e,t){let r=0;const n=new Uint8Array(8).fill(0);let o=teaDecryptBlock(new Uint8Array(e.slice(0,8)),t);const i=7&o[0],s=e.length-1-i-SALT_LEN-ZERO_LEN,a=new Uint8Array(s);let u=0,c=n,l=e.slice(0,8);r=8;let d=1;d+=i;for(let n=1;n<=SALT_LEN;)if(d<8)d++,n++;else if(8===d){const n=decryptNextBlock(e,r,c,l,o,t);c=n.ivPreCrypt,l=n.ivCurCrypt,o=n.debiBuf,r=n.bufPos,d=0}let h=s;for(;h>0;)if(d<8)a[u++]=o[d]^c[d],d++,h--;else if(8===d){const n=decryptNextBlock(e,r,c,l,o,t);c=n.ivPreCrypt,l=n.ivCurCrypt,o=n.debiBuf,r=n.bufPos,d=0}for(let n=1;n<=ZERO_LEN;)if(d<8)o[d],c[d],d++,n++;else if(8===d){if(r>=e.length)break;const n=decryptNextBlock(e,r,c,l,o,t);if(!n.success)break;c=n.ivPreCrypt,l=n.ivCurCrypt,o=n.debiBuf,r=n.bufPos,d=0}return a}function decryptNextBlock(e,t,r,n,o,i){if(t+8>e.length)return{success:!1};const s=new Uint8Array(n),a=e.slice(t,t+8),u=new Uint8Array(8);for(let e=0;e<8;e++)u[e]=o[e]^a[e];return{success:!0,ivPreCrypt:s,ivCurCrypt:a,debiBuf:teaDecryptBlock(u,i),bufPos:t+8}}var textDecoder="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function http({url:e,body:t,method:r="POST",timeout:n,priority:o}){return new Promise(((i,s)=>{if("fetch"in window)return fetch(e,{method:r,body:t,priority:o}).then((e=>e.clone().json().then((e=>({data:e})),(()=>e.arrayBuffer().then((e=>({data:getBusibuff(new Uint8Array(e))||(textDecoder?textDecoder.decode(e):e)}))))))).then(i,s);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(4===a.readyState)if(a.status>=200&&a.status<300)try{const e=JSON.parse(a.response);i({data:e})}catch(e){i({data:a.response})}else s({status:a.status,statusText:a.statusText||"request failed!"})},a.timeout=n||5e3,a.open(r,e,!0),a.send(t)}))}var has=Object.prototype.hasOwnProperty,isFunction=e=>"function"==typeof e,isUndefined=e=>void 0===e,isBoolean=e=>"boolean"==typeof e,isPlainObject=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;const r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)};function isEmpty(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(isPlainObject(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(const t in e)if(has.call(e,t))return!1;return!0}return!1}var RETRY_STATE_NOT_START=0,RETRY_STATE_STARTED=1,RETRY_STATE_STOPPED=2;function promiseRetry({retryFunction:e,settings:t,onError:r,onRetrying:n,onRetryFailed:o,onRetrySuccess:i,context:s}){return function(...a){const{retries:u=5,timeout:c=1e3}=t;let l=0,d=-1,h=RETRY_STATE_NOT_START;const f=async(t,p)=>{const m=s||this;try{const r=await e.apply(m,a);l>0&&i&&i.call(this,l),l=0,t(r)}catch(e){const i=()=>{clearTimeout(d),l=0,h=RETRY_STATE_STOPPED,p(e)},s=()=>{h!==RETRY_STATE_STOPPED&&l<(isFunction(u)?u():u)?(l++,h=RETRY_STATE_STARTED,isFunction(n)&&n.call(this,l,i),d=window.setTimeout((()=>{d=-1,f(t,p)}),isFunction(c)?c(l):c)):(i(),isFunction(o)&&o.call(this,e))};isFunction(r)?r.call(this,{error:e,retry:s,reject:p,retryFuncArgs:a,retriedCount:l}):s()}};return new Promise(f)}}var retry_default=promiseRetry,Logger=class e{constructor(e){__publicField(this,"_parentPath"),__publicField(this,"userId"),__publicField(this,"remoteUserId"),__publicField(this,"id"),__publicField(this,"sdkAppId"),__publicField(this,"type"),__publicField(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!isBoolean(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}getFullId(){return this._parentPath&&this.id?`${this._parentPath}-${this.id}`:this._parentPath?this._parentPath:this.id}createChild(t){const r=new e({id:t.id,userId:isUndefined(t.userId)?this.userId:t.userId,sdkAppId:isUndefined(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:isUndefined(t.type)?this.type:t.type,isLocal:isUndefined(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:isUndefined(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}bindParent(e){const t=e.getFullId();this._parentPath!==t&&(this.debug(`bind logger parent: ${e.id}`),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){const r=this.isLocal?this.userId:this.remoteUserId,n=this.getFullId();t.unshift(`[${this.isLocal?"↑":"↓"}${this.type&&"main"!==this.type?"*":""}${n}${r?`|${r}`:""}]`),logger_manager_default.log(e,t,isUndefined(this.userId)||isEmpty(this.userId),this.userId,this.sdkAppId)}info(...e){this.log(2,e)}debug(...e){this.log(1,e)}warn(...e){this.log(3,e)}error(...e){this.log(4,e)}},USER_AGENT="undefined"==typeof navigator?"":navigator.userAgent,isUserAgentMatch=e=>new RegExp(e,"i").test(USER_AGENT),getBrowserVersion=e=>{if(isUserAgentMatch(e)){const t=new RegExp(`${e}\\/([\\d.]+)`),r=USER_AGENT.match(t);if(r&&r[1])return r[1]}return""},getBrowserMajorVersion=e=>{if(isUserAgentMatch(e)){const t=new RegExp(`${e}\\/(\\d+)`),r=USER_AGENT.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},webkitVersionMap=/AppleWebKit\/([\d.]+)/i.exec(USER_AGENT),appleWebkitVersion=webkitVersionMap?parseFloat(webkitVersionMap[1]):NaN,IS_IPAD=isUserAgentMatch("iPad"),IS_IPAD_PRO="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&isUserAgentMatch("Macintosh"),IS_IPHONE=isUserAgentMatch("iPhone")&&!IS_IPAD,IS_IPOD=isUserAgentMatch("iPod"),IS_IOS=IS_IPHONE||IS_IPAD||IS_IPOD||IS_IPAD_PRO,IS_ANDROID=isUserAgentMatch("Android"),ANDROID_VERSION=function(){if(IS_ANDROID){const e=USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){const t=e[1]&&parseFloat(e[1]),r=e[2]&&parseFloat(e[2]);if(t&&r)return parseFloat(`${e[1]}.${e[2]}`);if(t)return t}}return NaN}(),IS_OLD_ANDROID=IS_ANDROID&&isUserAgentMatch("webkit")&&ANDROID_VERSION<2.3,IS_NATIVE_ANDROID=IS_ANDROID&&ANDROID_VERSION<5&&appleWebkitVersion<537,IS_FIREFOX=isUserAgentMatch("Firefox"),FIREFOX_VERSION=getBrowserVersion("Firefox"),FIREFOX_MAJOR_VERSION=getBrowserMajorVersion("Firefox"),IS_EDGE=isUserAgentMatch("Edge"),EDGE_VERSION=getBrowserVersion("Edge"),IS_EDG=isUserAgentMatch("Edg"),EDG_VERSION=getBrowserVersion("Edg"),EDG_MAJOR_VERSION=getBrowserMajorVersion("Edg"),IS_SOGOUM=isUserAgentMatch("SogouMobileBrowser"),SOGOUM_VERSION=getBrowserVersion("SogouMobileBrowser"),IS_SOGOU=isUserAgentMatch("MetaSr\\s"),SOGOU_VERSION=getBrowserVersion("MetaSr\\s"),IS_TBS=isUserAgentMatch("TBS"),TBS_VERSION=getBrowserVersion("TBS"),IS_XWEB=isUserAgentMatch("XWEB"),XWEB_VERSION=getBrowserVersion("XWEB"),IS_IE8=isUserAgentMatch("MSIE\\s8\\.0"),IS_IE=isUserAgentMatch("MSIE\\/\\d+"),IE_VERSION=function(){if(IS_IE){const e=/MSIE\s(\d+)\.\d/.exec(USER_AGENT);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(USER_AGENT)&&/rv:11.0/.test(USER_AGENT)&&(t=11),t}return NaN}(),IS_WECHAT=isUserAgentMatch("(micromessenger|webbrowser)"),WECHAT_VERSION=getBrowserVersion("MicroMessenger"),IS_X5MQQB=!IS_TBS&&isUserAgentMatch("MQQBrowser")&&isUserAgentMatch("COVC"),IS_MQQB=!IS_TBS&&isUserAgentMatch("MQQBrowser")&&!isUserAgentMatch("COVC"),MQQB_VERSION=IS_MQQB||IS_X5MQQB?getBrowserVersion("MQQBrowser"):"",IS_WQQB=!IS_TBS&&isUserAgentMatch(" QQBrowser"),WQQB_VERSION=getBrowserVersion(" QQBrowser"),IS_MACQQB=!IS_TBS&&isUserAgentMatch("QQBrowserLite"),MACQQB_VERSION=getBrowserVersion("QQBrowserLite"),IS_IPADQQB=!IS_TBS&&isUserAgentMatch("MQBHD"),IPADQQB_VERSION=getBrowserVersion("MQBHD"),IS_WIN=isUserAgentMatch("Windows"),IS_MAC=!IS_IOS&&isUserAgentMatch("MAC OS X"),IS_LINUX=!IS_ANDROID&&isUserAgentMatch("Linux"),IS_CHROME_OS=isUserAgentMatch("CrOS"),IS_WX=isUserAgentMatch("MicroMessenger"),IS_UCBROWSER=isUserAgentMatch("UCBrowser"),IS_ELECTRON=isUserAgentMatch("Electron"),IS_MIBROWSER=isUserAgentMatch("MiuiBrowser"),MI_VERSION=getBrowserVersion("MiuiBrowser"),IS_HUAWEIBROWSER=isUserAgentMatch("HuaweiBrowser"),IS_HUAWEI=isUserAgentMatch("Huawei")||isUserAgentMatch("HUAWEI"),IS_HONOR=isUserAgentMatch("Honor")||isUserAgentMatch("HONOR"),HUAWEI_VERSION=getBrowserVersion("HuaweiBrowser"),IS_SAMSUNGBROWSER=isUserAgentMatch("SamsungBrowser"),SAMSUNG_VERSION=getBrowserVersion("SamsungBrowser"),IS_OPPOBROWSER=isUserAgentMatch("HeyTapBrowser"),OPPO_VERSION=getBrowserVersion("HeyTapBrowser"),IS_VIVOBROWSER=isUserAgentMatch("VivoBrowser"),VIVO_VERSION=getBrowserVersion("VivoBrowser"),IS_OPENHARMONY=isUserAgentMatch("OpenHarmony"),OPENHARMONY_VERSION=getBrowserVersion("OpenHarmony"),getChromeMajorVersion=()=>getBrowserMajorVersion("Chrome"),IS_IOS_CHROME=isUserAgentMatch("CriOS"),IS_CHROMIUM_BASE=isUserAgentMatch("Chrome"),IS_CHROME=!IS_EDGE&&!IS_SOGOU&&!IS_SOGOUM&&!IS_TBS&&!IS_XWEB&&!IS_EDG&&!IS_WQQB&&!IS_MIBROWSER&&!IS_HUAWEIBROWSER&&!IS_SAMSUNGBROWSER&&!IS_OPPOBROWSER&&!IS_VIVOBROWSER&&IS_CHROMIUM_BASE,IS_HEADLESS_CHROME=isUserAgentMatch("HeadlessChrome"),CHROME_MAJOR_VERSION=getChromeMajorVersion(),CHROME_VERSION=getBrowserVersion("Chrome"),ELECTRON_MAJOR_VERSION=getBrowserMajorVersion("Electron"),IS_SAFARI=!IS_CHROMIUM_BASE&&!IS_MQQB&&!IS_X5MQQB&&!IS_MACQQB&&!IS_IPADQQB&&isUserAgentMatch("Safari"),SAFARI_VERSION=getBrowserVersion("Version"),IS_ANDROID_WEBVIEW=/Android.*(wv|.0.0.0)/.test(USER_AGENT),IOS_VERSION=(()=>{if(IS_IPAD_PRO)return SAFARI_VERSION;if(IS_IOS){const e=USER_AGENT.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=`.${e[2]}`),t}}return""})(),IOS_MAIN_VERSION=Number(IOS_VERSION.split(".")[0]),IS_IOS_13_OR_14=(()=>{const e=Number(IOS_VERSION.split(".")[0]);return 14===e||13===e})(),IS_LOCAL="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),browserInfo=getBrowserInfo();function getBrowserInfo(){const e=new Map([[IS_FIREFOX,["Firefox",FIREFOX_VERSION]],[IS_EDG,["Edg",EDG_VERSION]],[IS_CHROME,["Chrome",CHROME_VERSION]],[IS_IOS_CHROME,["ChiOS",getBrowserVersion("CriOS")]],[IS_SAFARI&&!IS_IOS_CHROME,["Safari",SAFARI_VERSION]],[IS_TBS,["TBS",TBS_VERSION]],[IS_XWEB,["XWEB",XWEB_VERSION]],[IS_WECHAT&&IS_IPHONE,["WeChat",WECHAT_VERSION]],[IS_WQQB,["QQ(Win)",WQQB_VERSION]],[IS_MQQB,["QQ(Mobile)",MQQB_VERSION]],[IS_X5MQQB,["QQ(Mobile X5)",MQQB_VERSION]],[IS_MACQQB,["QQ(Mac)",MACQQB_VERSION]],[IS_IPADQQB,["QQ(iPad)",IPADQQB_VERSION]],[IS_MIBROWSER,["MI",MI_VERSION]],[IS_HUAWEIBROWSER,["HW",HUAWEI_VERSION]],[IS_SAMSUNGBROWSER,["Samsung",SAMSUNG_VERSION]],[IS_OPPOBROWSER,["OPPO",OPPO_VERSION]],[IS_VIVOBROWSER,["VIVO",VIVO_VERSION]],[IS_EDGE,["EDGE",EDGE_VERSION]],[IS_SOGOUM,["SogouMobile",SOGOUM_VERSION]],[IS_SOGOU,["Sogou",SOGOU_VERSION]]]);let t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}var import_eventemitter32=__toESM(require_eventemitter3(),1),innerEmitter=new import_eventemitter32.default,inner_emitter_default=innerEmitter,inner_event_default=INNER_EVENT,SSOManager=class{constructor(){__publicField(this,"enable",!1),__publicField(this,"ssoFailCount",0),inner_emitter_default.on("22",(({schedule:e})=>{var t;(null==(t=null==e?void 0:e.config)?void 0:t.sso)&&inner_emitter_default.emit("266",{enable:!0})})),inner_emitter_default.on("266",(({enable:e})=>{this.enable=e}))}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&inner_emitter_default.emit("266",{enable:!1})}},sso_manager_default=new SSOManager,LOG_PRE_TAG="%cTRTC%c%s",LOG_PRE_TAG_STYLE="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",LOG_STYLE="display: inline",_LoggerManager=class e{constructor(){__publicField(this,"_isEnableUploadLog",!0),__publicField(this,"_localJoinedUser",new Map),__publicField(this,"_queue",[]),__publicField(this,"_timeoutId",-1),__publicField(this,"_logLevel",1),__publicField(this,"_logLevelToUpload",2),IS_WORKER||IS_WORKLET||(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){inner_emitter_default.on(inner_event_default.JOIN_SCHEDULE_SUCCESS,(({schedule:e})=>{var t;(null==(t=null==e?void 0:e.config)?void 0:t.logLevelToUpload)&&LOG_LEVEL[e.config.logLevelToUpload]&&(this._logLevelToUpload=e.config.logLevelToUpload)})),inner_emitter_default.on(inner_event_default.JOIN_START,(({params:e})=>{this.addJoinedUser({userId:e.userId,sdkAppId:e.sdkAppId}),this.startUpload()})),inner_emitter_default.on(inner_event_default.LEAVE_SUCCESS,(({room:e})=>{this.deleteJoinedUser(e.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){const e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){const r=this._queue[t];if(r.forAllJoinedClients)this._localJoinedUser.forEach((({userId:t,sdkAppId:n})=>{e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:n,logs:[r]})}));else if(isString(r.userId)&&isNumber(r.sdkAppId)){const{userId:t,sdkAppId:n}=r;e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:n,logs:[r]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}async upload(){if(0===this._queue.length||!this._isEnableUploadLog)return;const{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{const t=[...e.values()];for(let e=0;e<t.length;e++){const{userId:r,sdkAppId:n,logs:o}=t[e],i={timestamp:getTimestamp(),sdkAppId:String(n),userId:r,version:version,log:o.map((e=>e.log)).join("\n")},s=JSON.stringify(i),a=sso_manager_default.enable?buildSSOPackage(i,2002,n):s;await this.uploadLogWithRetry(a,n,a instanceof Uint8Array,s),o.forEach((e=>e.uploaded=!0))}}catch(e){}const r=t.filter((e=>!e.uploaded));r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(e,t,r,n){return retry_default({retryFunction:()=>http({url:getLoggerUrl(t,LOGGER_CMD_TYPE.LOG),body:e,timeout:5e3,priority:"low"}).then((e=>{r&&"ok"!==e.data&&(sso_manager_default.handleUploadFailed(),this.uploadLogWithRetry(n,t,!1,n))})),settings:{retries:3,timeout:2e3},onError:({retry:e})=>{e()}})()}getPrefix(e){const t=new Date;return t.setTime(getNetworkTime()),`[${formatDate(t)}] <${LOG_LEVEL[e]}>`}getLogLevel(){return this._logLevel}setLogLevel(e){isUndefined2(LOG_LEVEL[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(isString(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(e){return""}}addLogToQueue(e,t,r=!0,n,o){const i={log:t.reduce(((e,t)=>`${e} ${this.logChunkToString(t)}`.trim()),""),level:e,userId:n,sdkAppId:o,forAllJoinedClients:r};inner_emitter_default.emit(inner_event_default.LOG,{log:i}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(i)}log(t,r,n=!0,o,i){var s;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,n,o,i),t<this._logLevel)return;const a=(null==(s=LOG_LEVEL[t])?void 0:s.toLowerCase())||"info";e.PRINT_LOG_TAG?console[a](LOG_PRE_TAG,LOG_PRE_TAG_STYLE,LOG_STYLE,...r):console[a](...r)}debug(...e){this.log(1,e)}info(...e){this.log(2,e)}warn(...e){this.log(3,e)}error(...e){this.log(4,e)}createLogger(e){if(e.parent instanceof Logger){const t=e,{parent:r}=t,n=__objRest(t,["parent"]),o=new Logger(n);return o.bindParent(r),o}return new Logger(e)}checkURLParam(){const e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;LOG_LEVEL[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};__publicField(_LoggerManager,"PRINT_LOG_TAG",!(IS_IOS||IS_ANDROID||IS_HEADLESS_CHROME));var LoggerManager=_LoggerManager,logger_manager_default=new LoggerManager,isOverseaSdkAppId=e=>Number(e)<14e8,getLoggerUrl=function(e,t){let r;r=loggerProxy||(isOverseaSdkAppId(e)?LOGGER_DOMAIN_OVERSEA:LOGGER_DOMAIN);return`${r}/v5/AVQualityReportSvc/C2S?random=${Math.floor(Math.random()*2**31)}&sdkappid=${e}&cmdtype=${t}`},glog="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},isUndefined2=e=>void 0===e,isString=e=>"string"==typeof e,isNumber=e=>"number"==typeof e,isSetSinkIdSupported="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function performanceNow(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var{toString:toString}=Object.prototype;function buildProtocolBufferJSON(e,t,r,n){let o={data:e,random:Math.floor(Math.random()*2**31),sdkAppId:r};return isUndefined2(n)||(o=__spreadProps(__spreadValues({},o),{gzip:+n})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(o)}}}function buildSSOPackage(e,t,r,n){try{const o=buildProtocolBufferJSON(e,t,r,n);return encodeSSOPackage(encode(o),r)}catch(t){return JSON.stringify(e)}}var _TRTCVideoDecoder=class e{constructor(e){this.core=e,__publicField(this,"contextMap",new Map),__publicField(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(e){return(null==e?void 0:e.track)?`${e.track.userId}${e.track.streamType}`:"*"}getName(){return e.Name}getValidateRule(e){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(e,t){var r;switch(e){case"wasm":const e=!1,n=(null==(r=this.core.assetsPath)?void 0:r.replace(/\/+$/,""))||".";return e?new VideoDecoderSoftSIMD(__spreadProps(__spreadValues({},t),{wasmPath:`${n}/videodec_simd.wasm`})):new VideoDecoderSoft(__spreadProps(__spreadValues({},t),{wasmPath:`${n}/videodec.wasm`}));case"webCodecs":return new VideoDecoderHard;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(e){this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:({frame:e,track:t})=>{var r;return(null==(r=this.decodeProcessorMap.get(t))?void 0:r({frame:e,track:t}))||e},type:3})}decode(e){const{pipe:t,take:r,subscribe:n}=this.core.rx;return({frame:o,track:i})=>{if(i!==e.track||"empty"===o.type)return o;if(this.contextMap.has(i))return this.contextMap.get(i).decode(o);const s=this.core.room.videoManager.createDecodeContext(__spreadProps(__spreadValues({},e),{createDecoder:this.createDecoder}));return t(s.trackDoneOB,r(1),n((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:i})}))),this.contextMap.set(i,s),s.decode(o)}}stop(e){if(null==e?void 0:e.track){const t=this.contextMap.get(e.track);t&&(t.close("stop"),this.report(t,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach(((e,t)=>{e.close("stop"),this.contextMap.delete(t)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(e,t){if(e.isReported)return;e.isReported=!0;const r=performanceNow()-e.startPerformanceTime,{renderFreezeTotal:n,dataFreezeTotal:o}=this.getRemoteTrackFreezeDuration(t,e);let i=`report health data: ${e.track.userId} ${e.track.streamType} ${e.type}+${e.renderer} goodType:${e.goodType} ${e.failedReason?`failedReason: ${e.failedReason}`:""}`;r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(n/r*100),split:1,max:100}),i+=` RENDER_FREEZE_RATE: ${Math.floor(n/r*100)}%`),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(o/r*100),split:1,max:100}),i+=` DATA_FREEZE_RATE: ${Math.floor(o/r*100)}%`),e.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100}),i+=` VIDEO_CONSUME_RENDER_RATE: ${Math.floor(e.decodedFrameCount/e.inputFrameCount*100)}%`),this.core.log.info(i)}addKVReportBeforeExitRoom({room:e}){e===this.core.room&&this.contextMap.forEach(((e,t)=>{this.report(e,t)}))}update(e){const t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(__spreadProps(__spreadValues({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(e,t){const r=this.core.room.badCaseDetector.getDataFreezeMap().get(`${e.userId}_${e.streamType}`),n=this.core.room.badCaseDetector.getRenderFreezeDuration(`${e.userId}_${e.streamType}`);let o=0;return r&&r.durationItemList.forEach((e=>{e.startTime>t.startPerformanceTime&&(o+=e.getDuration())})),{renderFreezeTotal:n,dataFreezeTotal:o}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};__publicField(_TRTCVideoDecoder,"Name","TRTCVideoDecoder");var TRTCVideoDecoder=_TRTCVideoDecoder,index_default=TRTCVideoDecoder;export{index_default as default};export{TRTCVideoDecoder};
|