trtc-sdk-v5 5.15.0-beta.7 → 5.15.0-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 +2 -6
- package/package.json +1 -1
- package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
- package/plugins/cdn-streaming/cdn-streaming.umd.js +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/chorus/chorus.esm.d.ts +2 -0
- package/plugins/chorus/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.d.ts +2 -0
- 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/small-stream-auto-switcher/package.json +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.d.ts +2 -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/video-mixer/video-mixer.esm.d.ts +0 -2
- package/plugins/video-effect/video-mixer/video-mixer.esm.js +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.esm.js +35 -39
- package/trtc.js +1 -1
- package/plugins/fast-webrtc/fast-webrtc.esm.d.ts +0 -27
- package/plugins/fast-webrtc/fast-webrtc.esm.js +0 -1
- package/plugins/fast-webrtc/fast-webrtc.umd.js +0 -1
- package/plugins/fast-webrtc/package.json +0 -29
- package/plugins/lebplayer/lebplayer.esm.d.ts +0 -260
- package/plugins/lebplayer/lebplayer.esm.js +0 -1
- package/plugins/lebplayer/lebplayer.umd.js +0 -1
- package/plugins/lebplayer/package.json +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTCVideoDecoder=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function r(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function s(e){t(a,o,i,s,u,"next",e)}function u(e){t(a,o,i,s,u,"throw",e)}s(void 0)}))}}function n(e,t,r){return t=c(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,r||[],c(e).constructor):t.apply(e,r))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=g(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function u(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),s=new D(n||[]);return o(a,"_invoke",{value:C(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",v="executing",m="completed",y={};function g(){}function w(){}function E(){}var b={};c(b,a,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(L([])));k&&k!==r&&n.call(k,a)&&(b=k);var T=E.prototype=g.prototype=Object.create(b);function A(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,i,a,s){var u=l(e[o],e,i);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function C(t,r,n){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var u=P(s,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var c=l(t,r,n);if("normal"===c.type){if(o=n.done?m:p,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=m,n.method="throw",n.arg=c.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return w.prototype=E,o(T,"constructor",{value:E,configurable:!0}),o(E,"constructor",{value:w,configurable:!0}),w.displayName=c(E,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,c(e,u,"GeneratorFunction")),e.prototype=Object.create(T),e},t.awrap=function(e){return{__await:e}},A(S.prototype),c(S.prototype,s,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new S(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(T),c(T,u,"Generator"),c(T,a,(function(){return this})),c(T,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t);else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||g(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function g(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function w(e){var t="function"==typeof Map?new Map:void 0;return w=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&h(o,r.prototype),o}(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},w(e)}var E,b,_=Object.create,k=Object.defineProperty,T=Object.defineProperties,A=Object.getOwnPropertyDescriptor,S=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,O=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,L=function(e,t,r){return t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},R=function(e,t){for(var r in t||(t={}))I.call(t,r)&&L(e,r,t[r]);if(P){var n,o=s(P(t));try{for(o.s();!(n=o.n()).done;){r=n.value;D.call(t,r)&&L(e,r,t[r])}}catch(e){o.e(e)}finally{o.f()}}return e},x=function(e,t){return T(e,S(t))},M=function(e,t,r){return r=null!=e?_(O(e)):{},function(e,t,r,n){if(t&&"object"===y(t)||"function"==typeof t){var o,i=s(C(t));try{var a=function(){var i=o.value;I.call(e,i)||i===r||k(e,i,{get:function(){return t[i]},enumerable:!(n=A(t,i))||n.enumerable})};for(i.s();!(o=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}}return e}(k(r,"default",{value:e,enumerable:!0}),e)},U=function(e,t,r,n){for(var o,i=A(t,r),a=e.length-1;a>=0;a--)(o=e[a])&&(i=o(t,r,i)||i);return i&&k(t,r,i),i},F=function(e,t,r){return L(e,"symbol"!==y(t)?t+"":t,r)},j=(E={"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js":function(e,t){var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function s(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,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},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,a){var s=n?n+e:e;if(!this._events[s])return!1;var u,c,f=this._events[s],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,i),!0;case 6:return f.fn.call(f.context,t,r,o,i,a),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var d,h=f.length;for(c=0;c<h;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,r);break;case 4:f[c].fn.call(f[c].context,t,r,o);break;default:if(!u)for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];f[c].fn.apply(f[c].context,u)}}return!0},u.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return a(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 s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var u=0,c=[],f=a.length;u<f;u++)(a[u].fn!==t||o&&!a[u].once||r&&a[u].context!==r)&&c.push(a[u]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(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)}},function(){return b||(0,E[C(E)[0]])((b={exports:{}}).exports,b),b.exports}),N=M(j()),B=Symbol("instance"),$=Symbol("cacheResult"),H=function(){return a((function e(t,r,n){o(this,e),this.oldState=t,this.newState=r,this.action=n,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,J.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),z=function(e){function t(e,r,i){var a;return o(this,t),(a=n(this,t,[r])).state=e,a.message=r,a.cause=i,a}return f(t,e),a(t)}(w(Error));var W=new Map;function V(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n,o,i){var a=r.action||o;if(!r.context){var s=W.get(n)||[];W.has(n)||W.set(n,s),s.push({from:e,to:t,action:a})}var u=i.value;i.value=function(){for(var n,o=this,i=this,s=arguments.length,c=new Array(s),f=0;f<s;f++)c[f]=arguments[f];r.context&&(i=K.get("function"==typeof r.context?(n=r.context).call.apply(n,[this].concat(c)):r.context));if(i.state===t)return r.sync?i[$]:Promise.resolve(i[$]);i.state instanceof H&&i.state.action==r.abortAction&&i.state.abort(i);var l=null;Array.isArray(e)?0==e.length?i.state instanceof H&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(l=new z(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new z(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));var d=function(e){if(r.fail&&r.fail.call(o,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);var h=i.state,p=new H(h,t,a);J.call(i,p);var v,m=function(e){var n;return i[$]=e,p.aborted||(J.call(i,t),null===(n=r.success)||void 0===n||n.call(o,i[$])),e},g=function(e){return J.call(i,h,e),d(e)};try{var w=u.apply(this,c);return"object"===y(v=w)&&v&&"then"in v?w.then(m).catch(g):r.sync?m(w):Promise.resolve(m(w))}catch(r){return g(new z(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(r),r instanceof Error?r:new Error(String(r))))}}}}var q,G,Q=(q="undefined"!=typeof window&&window.__AFSM__,G="undefined"!=typeof importScripts,q?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:G?function(e,t){postMessage({type:e,payload:t})}:function(){});function J(e,t){var r=this._state;this._state=e;var n=e.toString();e&&this.emit(n,r),this.emit(K.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var K=function(e){function t(e,r,i){var a;o(this,t),(a=n(this,t)).name=e,a.groupName=r,a._state=t.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(a,i):i=Object.getPrototypeOf(a),r||(a.groupName=a.constructor.name);var s=i[B];return s?a.name=s.name+"-"+s.count++:i[B]={name:a.name,count:0},a.updateDevTools({diagram:a.stateDiagram}),a}return f(t,e),a(t,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=W.get(e)||[],r=new Set,n=[],o=[],i=new Set,a=Object.getPrototypeOf(e);W.has(a)&&(a.stateDiagram.forEach((function(e){return r.add(e)})),a.allStates.forEach((function(e){return i.add(e)}))),t.forEach((function(e){var t=e.from,r=e.to,i=e.action;"string"==typeof t?n.push({from:t,to:r,action:i}):t.length?t.forEach((function(e){n.push({from:e,to:r,action:i})})):o.push({to:r,action:i})})),n.forEach((function(e){var t=e.from,n=e.to,o=e.action;i.add(t),i.add(n),i.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(n," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((function(e){var t=e.to,n=e.action;r.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🟢")),i.forEach((function(e){e!==t&&r.add("".concat(e," --\x3e ").concat(n,"ing : ").concat(n))}))}));var s=v(r);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:i}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Q(t.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){J.call(this,e)}}],[{key:"get",value:function(e){var r;return"string"==typeof e?(r=t.instances.get(e))||t.instances.set(e,r=new t(e,void 0,Object.create(t.prototype))):(r=t.instances2.get(e))||t.instances2.set(e,r=new t(e.constructor.name,void 0,Object.create(t.prototype))),r}},{key:"getState",value:function(e){var r;return null===(r=t.get(e))||void 0===r?void 0:r.state}}])}(N.default);K.STATECHANGED="stateChanged",K.UPDATEAFSM="updateAFSM",K.INIT="[*]",K.ON="on",K.OFF="off",K.instances=new Map,K.instances2=new WeakMap;var X=function(e){function t(){var e;return o(this,t),e=n(this,t,arguments),F(e,"decoder"),F(e,"config"),e}return f(t,e),a(t,[{key:"initialize",value:(i=r(d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.decoder=new VideoDecoder({output:function(e){t.emit("videoFrame",e)},error:function(e){t.close(),t.emit("error",e)}});case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"configure",value:function(e){this.config=e,this.decoder.configure(x(R({},e),{codec:this.getCodec(e)}))}},{key:"getCodec",value:function(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}}},{key:"decode",value:function(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}},{key:"flush",value:function(){this.decoder.flush()}},{key:"reset",value:function(){this.decoder.reset()}},{key:"close",value:function(){"closed"!==this.decoder.state&&this.decoder.close()}}]);var i}(K);function Y(){var e;self.onmessage=function(t){if("init"===t.data.type){var r=t.data,n=r.canvas,o=r.wasmScript,i=r.wasmBinary,a=null==n?void 0:n.getContext("2d"),s=0,u=0,c={wasmBinary:i,postRun:function(){e=new c.VideoDecoder({videoInfo:function(e,t){s=e,u=t,console.log("video info",e,t)},yuvData:function(e,t){var r=s*u,o=r>>2,i=c.HEAPU32[e>>2],f=c.HEAPU32[1+(e>>2)],l=c.HEAPU32[2+(e>>2)],d=c.HEAPU8.subarray(i,i+r),h=c.HEAPU8.subarray(f,f+o),p=c.HEAPU8.subarray(l,l+o),v=new Uint8Array(r+o+o);v.set(d),v.set(h,r),v.set(p,r+o);var m=new VideoFrame(v,{codedWidth:s,codedHeight:u,format:"I420",timestamp:t});n?(null==a||a.drawImage(m,0,0,n.width,n.height),null==a||a.commit()):self.postMessage({type:"yuvData",videoFrame:m},[m])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+o)()(c)}else if("decode"===t.data.type){var f=t.data.packet;null==e||e.decode(f.data,"key"==f.type,f.timestamp)}else if("setCodec"===t.data.type){var l=t.data,d=l.codec,h=l.format,p=l.description;null==e||e.setCodec(d,h,null!=p?p:"")}}}U([V([K.INIT,"closed"],"initialized")],X.prototype,"initialize"),U([V("initialized","configured",{sync:!0})],X.prototype,"configure"),U([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){var o=n.value,i=r;n.value=function(){if(!t.includes(this.state.toString()))throw new z(this.state,"".concat(this.name," ").concat(i," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return o.apply(this,r)}}}("configured")],X.prototype,"decode"),U([V([],K.INIT,{sync:!0})],X.prototype,"reset"),U([V([],"closed",{ignoreError:!0,sync:!0})],X.prototype,"close");var Z=function(e){function t(e,r){var i,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3?arguments[3]:void 0,u=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return o(this,t),(i=n(this,t)).createModule=e,i.wasmBinary=r,i.workerMode=a,i.canvas=s,i.yuvMode=u,F(i,"worker"),F(i,"decoder"),F(i,"config"),F(i,"module",{}),F(i,"width",0),F(i,"height",0),i}return f(t,e),a(t,[{key:"initialize",value:(i=r(d().mark((function e(t){var r,n,o,i,a,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.workerMode){e.next=10;break}return n=new RegExp("\\{(.+)\\}","s").exec(Y.toString())[1],this.worker=new Worker(URL.createObjectURL(new Blob([n],{type:"text/javascript"}))),o=null==(r=this.canvas)?void 0:r.transferControlToOffscreen(),e.next=6,this.wasmBinary;case 6:return i=e.sent,console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:o,wasmScript:this.createModule.toString(),wasmBinary:i},o?[o,i]:[i]),e.abrupt("return",new Promise((function(e){s.worker.onmessage=function(t){if("ready"===t.data.type)delete s.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){var r=t.data.videoFrame;s.emit("videoFrame",r)}}})));case 10:if(a=this.module,!this.wasmBinary){e.next=15;break}return e.next=14,this.wasmBinary;case 14:a.wasmBinary=e.sent;case 15:return a.print=function(e){return console.log(e)},a.printErr=function(e){return console.log("[JS] ERROR: ".concat(e))},a.onAbort=function(){return console.log("[JS] FATAL: WASM ABORTED")},e.abrupt("return",new Promise((function(e){a.postRun=function(t){s.decoder=new s.module.VideoDecoder(s),console.log("video soft decoder initialize success"),e()},t&&Object.assign(a,t),s.createModule(a)})));case 19:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"configure",value:function(e){var t,r,n;this.config=e;var 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})}},{key:"decode",value:function(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}))}},{key:"flush",value:function(){}},{key:"reset",value:function(){this.config=void 0,this.decoder&&this.decoder.clear()}},{key:"close",value:function(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}},{key:"videoInfo",value:function(e,t){this.width=e,this.height=t;var r={width:e,height:t};this.emit("videoCodecInfo",r)}},{key:"yuvData",value:function(e,t){if(this.module){var r=this.width*this.height,n=r>>2,o=this.module.HEAPU32[e>>2],i=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+r),u=this.module.HEAPU8.subarray(i,i+n),c=this.module.HEAPU8.subarray(a,a+n);if(this.yuvMode)this.emit("videoFrame",{y:s,u:u,v:c,timestamp:t});else{var f=new Uint8Array(r+n+n);f.set(s),f.set(u,r),f.set(c,r+n),this.emit("videoFrame",new VideoFrame(f,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}}}},{key:"errorInfo",value:function(e){var t={errMsg:e};this.emit("error",t)}}]);var i}(K);U([V([K.INIT,"closed"],"initialized")],Z.prototype,"initialize"),U([V("initialized","configured",{sync:!0})],Z.prototype,"configure"),U([V([],K.INIT,{sync:!0})],Z.prototype,"reset"),U([V([],"closed",{sync:!0})],Z.prototype,"close");var ee,te=(ee="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r;i.ready=new Promise((function(r,n){e=r,t=n}));var s=Object.assign({},i),c="./this.program",l="object"==("undefined"==typeof window?"undefined":y(window)),d="function"==typeof importScripts;"object"==("undefined"==typeof process?"undefined":y(process))&&"object"==y(process.versions)&&process.versions.node;var h,p,v,m="";(l||d)&&(d?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),ee&&(m=ee),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",h=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(v=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),p=function(e,t,r){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var g,E,b,_=i.print||console.log.bind(console),k=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(c=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(g=i.wasmBinary),i.noExitRuntime,"object"!=("undefined"==typeof WebAssembly?"undefined":y(WebAssembly))&&G("no native wasm support detected");var T,A,S,C,P,O,I,D,L,R=!1,x=[],M=[],U=[];function F(e){x.unshift(e)}function j(e){U.unshift(e)}var N,B,$,H,z=0,W=null;function V(e){z++,i.monitorRunDependencies&&i.monitorRunDependencies(z)}function q(e){if(z--,i.monitorRunDependencies&&i.monitorRunDependencies(z),0==z&&W){var t=W;W=null,t()}}function G(e){i.onAbort&&i.onAbort(e),k(e="Aborted("+e+")"),R=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw t(r),r}function Q(e){return e.startsWith("data:application/octet-stream;base64,")}function J(e){if(e==N&&g)return new Uint8Array(g);if(v)return v(e);throw"both async and sync fetching of the wasm failed"}function K(e,t,r){return function(e){return g||!l&&!d||"function"!=typeof fetch?Promise.resolve().then((function(){return J(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return J(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(r,(function(e){k("failed to asynchronously prepare wasm: "+e),G(e)}))}Q(N="videodec.wasm")||(B=N,N=i.locateFile?i.locateFile(B,m):m+B);var X=function(e){for(;e.length>0;)e.shift()(i)};function Y(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){O[this.ptr+4>>2]=e},this.get_type=function(){return O[this.ptr+4>>2]},this.set_destructor=function(e){O[this.ptr+8>>2]=e},this.get_destructor=function(){return O[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,T[this.ptr+12|0]=e},this.get_caught=function(){return 0!=T[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,T[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=T[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){O[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return O[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Zt(this.get_type()))return O[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var Z={isAbs:function(e){return"/"===e.charAt(0)},splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(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:function(e){var t=Z.isAbs(e),r="/"===e.substr(-1);return(e=Z.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:function(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:function(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:function(e,t){return Z.normalize(e+"/"+t)}},te=function(e){return(te=function(){if("object"==("undefined"==typeof crypto?"undefined":y(crypto))&&"function"==typeof crypto.getRandomValues)return function(e){return crypto.getRandomValues(e)};G("initRandomDevice")}())(e)},re={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:ve.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((function(e){return!!e})),!t).join("/"))||"."},relative:function(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=re.resolve(e).substr(1),t=re.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),i=Math.min(n.length,o.length),a=i,s=0;s<i;s++)if(n[s]!==o[s]){a=s;break}var u=[];for(s=a;s<n.length;s++)u.push("..");return(u=u.concat(o.slice(a))).join("/")}},ne="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,oe=function(e,t,r){for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&ne)return ne.decode(e.subarray(t,o));for(var i="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var u=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i},ie=[],ae=function(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},se=function(e,t,r,n){if(!(n>0))return 0;for(var o=r,i=r+n-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(r>=i)break;t[r++]=s}else if(s<=2047){if(r+1>=i)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=i)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=i)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o};function ue(e,t,r){var n=ae(e)+1,o=new Array(n),i=se(e,o,0,o.length);return o.length=i,o}var ce={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){ce.ttys[e]={input:[],output:[],ops:t},ve.registerDevice(e,ce.stream_ops)},stream_ops:{open:function(e){var t=ce.ttys[e.node.rdev];if(!t)throw new ve.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 ve.ErrnoError(60);for(var i=0,a=0;a<n;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new ve.ErrnoError(29)}if(void 0===s&&0===i)throw new ve.ErrnoError(6);if(null==s)break;i++,t[r+a]=s}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 ve.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,t[r+i])}catch(e){throw new ve.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){return function(){if(!ie.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;ie=ue(e)}return ie.shift()}()},put_char:function(e,t){null===t||10===t?(_(oe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(_(oe(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?(k(oe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(k(oe(e.output,0)),e.output=[])}}},fe=function(e){G()},le={ops_table:null,mount:function(e){return le.createNode(null,"/",16895,0)},createNode:function(e,t,r,n){if(ve.isBlkdev(r)||ve.isFIFO(r))throw new ve.ErrnoError(63);le.ops_table||(le.ops_table={dir:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,lookup:le.node_ops.lookup,mknod:le.node_ops.mknod,rename:le.node_ops.rename,unlink:le.node_ops.unlink,rmdir:le.node_ops.rmdir,readdir:le.node_ops.readdir,symlink:le.node_ops.symlink},stream:{llseek:le.stream_ops.llseek}},file:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:{llseek:le.stream_ops.llseek,read:le.stream_ops.read,write:le.stream_ops.write,allocate:le.stream_ops.allocate,mmap:le.stream_ops.mmap,msync:le.stream_ops.msync}},link:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,readlink:le.node_ops.readlink},stream:{}},chrdev:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:ve.chrdev_stream_ops}});var o=ve.createNode(e,t,r,n);return ve.isDir(o.mode)?(o.node_ops=le.ops_table.dir.node,o.stream_ops=le.ops_table.dir.stream,o.contents={}):ve.isFile(o.mode)?(o.node_ops=le.ops_table.file.node,o.stream_ops=le.ops_table.file.stream,o.usedBytes=0,o.contents=null):ve.isLink(o.mode)?(o.node_ops=le.ops_table.link.node,o.stream_ops=le.ops_table.link.stream):ve.isChrdev(o.mode)&&(o.node_ops=le.ops_table.chrdev.node,o.stream_ops=le.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(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:function(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:function(e){var t={};return t.dev=ve.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,ve.isDir(e.mode)?t.size=4096:ve.isFile(e.mode)?t.size=e.usedBytes:ve.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:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&le.resizeFileStorage(e,t.size)},lookup:function(e,t){throw ve.genericErrors[44]},mknod:function(e,t,r,n){return le.createNode(e,t,r,n)},rename:function(e,t,r){if(ve.isDir(e.mode)){var n;try{n=ve.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new ve.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:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){var r=ve.lookupNode(e,t);for(var n in r.contents)throw new ve.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink:function(e,t,r){var n=le.createNode(e,t,41471,0);return n.link=r,n},readlink:function(e){if(!ve.isLink(e.mode))throw new ve.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,r,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(a>8&&i.subarray)t.set(i.subarray(o,o+a),r);else for(var s=0;s<a;s++)t[r+s]=i[o+s];return a},write:function(e,t,r,n,o,i){if(!n)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(i)return a.contents=t.subarray(r,r+n),a.usedBytes=n,n;if(0===a.usedBytes&&0===o)return a.contents=t.slice(r,r+n),a.usedBytes=n,n;if(o+n<=a.usedBytes)return a.contents.set(t.subarray(r,r+n),o),n}if(le.expandFileStorage(a,o+n),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(r,r+n),o);else for(var s=0;s<n;s++)a.contents[o+s]=t[r+s];return a.usedBytes=Math.max(a.usedBytes,o+n),n},llseek:function(e,t,r){var n=t;if(1===r?n+=e.position:2===r&&ve.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new ve.ErrnoError(28);return n},allocate:function(e,t,r){le.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap:function(e,t,r,n,o){if(!ve.isFile(e.node.mode))throw new ve.ErrnoError(43);var i,a,s=e.node.contents;if(2&o||s.buffer!==T.buffer){if((r>0||r+t<s.length)&&(s=s.subarray?s.subarray(r,r+t):Array.prototype.slice.call(s,r,r+t)),a=!0,!(i=fe()))throw new ve.ErrnoError(48);T.set(s,i)}else a=!1,i=s.byteOffset;return{ptr:i,allocated:a}},msync:function(e,t,r,n,o){return le.stream_ops.write(e,t,0,n,r,!1),0}}},de=function(e,t,r,n){var o="al ".concat(e);p(e,(function(r){var n,i;n=r,i='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),n||G(i),t(new Uint8Array(r)),o&&q()}),(function(t){if(!r)throw'Loading data file "'.concat(e,'" failed.');r()})),o&&V()},he=i.preloadPlugins||[];function pe(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ve={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=re.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ve.ErrnoError(32);for(var r=e.split("/").filter((function(e){return!!e})),n=ve.root,o="/",i=0;i<r.length;i++){var a=i===r.length-1;if(a&&t.parent)break;if(n=ve.lookupNode(n,r[i]),o=Z.join2(o,r[i]),ve.isMountpoint(n)&&(!a||a&&t.follow_mount)&&(n=n.mounted.root),!a||t.follow)for(var s=0;ve.isLink(n.mode);){var u=ve.readlink(o);if(o=re.resolve(Z.dirname(o),u),n=ve.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new ve.ErrnoError(32)}}return{path:o,node:n}},getPath:function(e){for(var t;;){if(ve.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:function(e,t){for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%ve.nameTable.length},hashAddNode:function(e){var t=ve.hashName(e.parent.id,e.name);e.name_next=ve.nameTable[t],ve.nameTable[t]=e},hashRemoveNode:function(e){var t=ve.hashName(e.parent.id,e.name);if(ve.nameTable[t]===e)ve.nameTable[t]=e.name_next;else for(var r=ve.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:function(e,t){var r=ve.mayLookup(e);if(r)throw new ve.ErrnoError(r,e);for(var n=ve.hashName(e.id,t),o=ve.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===t)return o}return ve.lookup(e,t)},createNode:function(e,t,r,n){var o=new ve.FSNode(e,t,r,n);return ve.hashAddNode(o),o},destroyNode:function(e){ve.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return!(49152&~e)},flagsToPermissionString:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:function(e,t){return ve.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2},mayLookup:function(e){var t=ve.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:function(e,t){try{return ve.lookupNode(e,t),20}catch(e){}return ve.nodePermissions(e,"wx")},mayDelete:function(e,t,r){var n;try{n=ve.lookupNode(e,t)}catch(e){return e.errno}var o=ve.nodePermissions(e,"wx");if(o)return o;if(r){if(!ve.isDir(n.mode))return 54;if(ve.isRoot(n)||ve.getPath(n)===ve.cwd())return 10}else if(ve.isDir(n.mode))return 31;return 0},mayOpen:function(e,t){return e?ve.isLink(e.mode)?32:ve.isDir(e.mode)&&("r"!==ve.flagsToPermissionString(t)||512&t)?31:ve.nodePermissions(e,ve.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd:function(){for(var e=0;e<=ve.MAX_OPEN_FDS;e++)if(!ve.streams[e])return e;throw new ve.ErrnoError(33)},getStreamChecked:function(e){var t=ve.getStream(e);if(!t)throw new ve.ErrnoError(8);return t},getStream:function(e){return ve.streams[e]},createStream:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return ve.FSStream||(ve.FSStream=function(){this.shared={}},ve.FSStream.prototype={},Object.defineProperties(ve.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return!!(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new ve.FSStream,e),-1==t&&(t=ve.nextfd()),e.fd=t,ve.streams[t]=e,e},closeStream:function(e){ve.streams[e]=null},chrdev_stream_ops:{open:function(e){var t=ve.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new ve.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,t){return e<<8|t},registerDevice:function(e,t){ve.devices[e]={stream_ops:t}},getDevice:function(e){return ve.devices[e]},getMounts:function(e){for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:function(e,t){"function"==typeof e&&(t=e,e=!1),ve.syncFSRequests++,ve.syncFSRequests>1&&k("warning: ".concat(ve.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=ve.getMounts(ve.root.mount),n=0;function o(e){return ve.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((function(t){if(!t.type.syncfs)return i(null);t.type.syncfs(t,e,i)}))},mount:function(e,t,r){var n,o="/"===r,i=!r;if(o&&ve.root)throw new ve.ErrnoError(10);if(!o&&!i){var a=ve.lookupPath(r,{follow_mount:!1});if(r=a.path,n=a.node,ve.isMountpoint(n))throw new ve.ErrnoError(10);if(!ve.isDir(n.mode))throw new ve.ErrnoError(54)}var s={type:e,opts:t,mountpoint:r,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,o?ve.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount:function(e){var t=ve.lookupPath(e,{follow_mount:!1});if(!ve.isMountpoint(t.node))throw new ve.ErrnoError(28);var r=t.node,n=r.mounted,o=ve.getMounts(n);Object.keys(ve.nameTable).forEach((function(e){for(var t=ve.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ve.destroyNode(t),t=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var n=ve.lookupPath(e,{parent:!0}).node,o=Z.basename(e);if(!o||"."===o||".."===o)throw new ve.ErrnoError(28);var i=ve.mayCreate(n,o);if(i)throw new ve.ErrnoError(i);if(!n.node_ops.mknod)throw new ve.ErrnoError(63);return n.node_ops.mknod(n,o,t,r)},create:function(e,t){return t=void 0!==t?t:438,t&=4095,t|=32768,ve.mknod(e,t,0)},mkdir:function(e,t){return t=void 0!==t?t:511,t&=1023,t|=16384,ve.mknod(e,t,0)},mkdirTree:function(e,t){for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{ve.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:function(e,t,r){return void 0===r&&(r=t,t=438),t|=8192,ve.mknod(e,t,r)},symlink:function(e,t){if(!re.resolve(e))throw new ve.ErrnoError(44);var r=ve.lookupPath(t,{parent:!0}).node;if(!r)throw new ve.ErrnoError(44);var n=Z.basename(t),o=ve.mayCreate(r,n);if(o)throw new ve.ErrnoError(o);if(!r.node_ops.symlink)throw new ve.ErrnoError(63);return r.node_ops.symlink(r,n,e)},rename:function(e,t){var r,n,o=Z.dirname(e),i=Z.dirname(t),a=Z.basename(e),s=Z.basename(t);if(r=ve.lookupPath(e,{parent:!0}).node,n=ve.lookupPath(t,{parent:!0}).node,!r||!n)throw new ve.ErrnoError(44);if(r.mount!==n.mount)throw new ve.ErrnoError(75);var u,c=ve.lookupNode(r,a),f=re.relative(e,i);if("."!==f.charAt(0))throw new ve.ErrnoError(28);if("."!==(f=re.relative(t,o)).charAt(0))throw new ve.ErrnoError(55);try{u=ve.lookupNode(n,s)}catch(e){}if(c!==u){var l=ve.isDir(c.mode),d=ve.mayDelete(r,a,l);if(d)throw new ve.ErrnoError(d);if(d=u?ve.mayDelete(n,s,l):ve.mayCreate(n,s))throw new ve.ErrnoError(d);if(!r.node_ops.rename)throw new ve.ErrnoError(63);if(ve.isMountpoint(c)||u&&ve.isMountpoint(u))throw new ve.ErrnoError(10);if(n!==r&&(d=ve.nodePermissions(r,"w")))throw new ve.ErrnoError(d);ve.hashRemoveNode(c);try{r.node_ops.rename(c,n,s)}catch(e){throw e}finally{ve.hashAddNode(c)}}},rmdir:function(e){var t=ve.lookupPath(e,{parent:!0}).node,r=Z.basename(e),n=ve.lookupNode(t,r),o=ve.mayDelete(t,r,!0);if(o)throw new ve.ErrnoError(o);if(!t.node_ops.rmdir)throw new ve.ErrnoError(63);if(ve.isMountpoint(n))throw new ve.ErrnoError(10);t.node_ops.rmdir(t,r),ve.destroyNode(n)},readdir:function(e){var t=ve.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ve.ErrnoError(54);return t.node_ops.readdir(t)},unlink:function(e){var t=ve.lookupPath(e,{parent:!0}).node;if(!t)throw new ve.ErrnoError(44);var r=Z.basename(e),n=ve.lookupNode(t,r),o=ve.mayDelete(t,r,!1);if(o)throw new ve.ErrnoError(o);if(!t.node_ops.unlink)throw new ve.ErrnoError(63);if(ve.isMountpoint(n))throw new ve.ErrnoError(10);t.node_ops.unlink(t,r),ve.destroyNode(n)},readlink:function(e){var t=ve.lookupPath(e).node;if(!t)throw new ve.ErrnoError(44);if(!t.node_ops.readlink)throw new ve.ErrnoError(28);return re.resolve(ve.getPath(t.parent),t.node_ops.readlink(t))},stat:function(e,t){var r=ve.lookupPath(e,{follow:!t}).node;if(!r)throw new ve.ErrnoError(44);if(!r.node_ops.getattr)throw new ve.ErrnoError(63);return r.node_ops.getattr(r)},lstat:function(e){return ve.stat(e,!0)},chmod:function(e,t,r){var n;if(!(n="string"==typeof e?ve.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&t|-4096&n.mode,timestamp:Date.now()})},lchmod:function(e,t){ve.chmod(e,t,!0)},fchmod:function(e,t){var r=ve.getStreamChecked(e);ve.chmod(r.node,t)},chown:function(e,t,r,n){var o;if(!(o="string"==typeof e?ve.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(e,t,r){ve.chown(e,t,r,!0)},fchown:function(e,t,r){var n=ve.getStreamChecked(e);ve.chown(n.node,t,r)},truncate:function(e,t){if(t<0)throw new ve.ErrnoError(28);var r;if(!(r="string"==typeof e?ve.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);if(ve.isDir(r.mode))throw new ve.ErrnoError(31);if(!ve.isFile(r.mode))throw new ve.ErrnoError(28);var n=ve.nodePermissions(r,"w");if(n)throw new ve.ErrnoError(n);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:function(e,t){var r=ve.getStreamChecked(e);if(!(2097155&r.flags))throw new ve.ErrnoError(28);ve.truncate(r.node,t)},utime:function(e,t,r){var n=ve.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(t,r)})},open:function(e,t,r){if(""===e)throw new ve.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: ".concat(e));return t}(t):t)?4095&r|32768:0,"object"==y(e))n=e;else{e=Z.normalize(e);try{n=ve.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var o=!1;if(64&t)if(n){if(128&t)throw new ve.ErrnoError(20)}else n=ve.mknod(e,r,0),o=!0;if(!n)throw new ve.ErrnoError(44);if(ve.isChrdev(n.mode)&&(t&=-513),65536&t&&!ve.isDir(n.mode))throw new ve.ErrnoError(54);if(!o){var a=ve.mayOpen(n,t);if(a)throw new ve.ErrnoError(a)}512&t&&!o&&ve.truncate(n,0),t&=-131713;var s=ve.createStream({node:n,path:ve.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!i.logReadFiles||1&t||(ve.readFiles||(ve.readFiles={}),e in ve.readFiles||(ve.readFiles[e]=1)),s},close:function(e){if(ve.isClosed(e))throw new ve.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ve.closeStream(e.fd)}e.fd=null},isClosed:function(e){return null===e.fd},llseek:function(e,t,r){if(ve.isClosed(e))throw new ve.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ve.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ve.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:function(e,t,r,n,o){if(n<0||o<0)throw new ve.ErrnoError(28);if(ve.isClosed(e))throw new ve.ErrnoError(8);if(1==(2097155&e.flags))throw new ve.ErrnoError(8);if(ve.isDir(e.node.mode))throw new ve.ErrnoError(31);if(!e.stream_ops.read)throw new ve.ErrnoError(28);var i=void 0!==o;if(i){if(!e.seekable)throw new ve.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,t,r,n,o);return i||(e.position+=a),a},write:function(e,t,r,n,o,i){if(n<0||o<0)throw new ve.ErrnoError(28);if(ve.isClosed(e))throw new ve.ErrnoError(8);if(!(2097155&e.flags))throw new ve.ErrnoError(8);if(ve.isDir(e.node.mode))throw new ve.ErrnoError(31);if(!e.stream_ops.write)throw new ve.ErrnoError(28);e.seekable&&1024&e.flags&&ve.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new ve.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,r,n,o,i);return a||(e.position+=s),s},allocate:function(e,t,r){if(ve.isClosed(e))throw new ve.ErrnoError(8);if(t<0||r<=0)throw new ve.ErrnoError(28);if(!(2097155&e.flags))throw new ve.ErrnoError(8);if(!ve.isFile(e.node.mode)&&!ve.isDir(e.node.mode))throw new ve.ErrnoError(43);if(!e.stream_ops.allocate)throw new ve.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,o){if(2&n&&!(2&o)&&2!=(2097155&e.flags))throw new ve.ErrnoError(2);if(1==(2097155&e.flags))throw new ve.ErrnoError(2);if(!e.stream_ops.mmap)throw new ve.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,o)},msync:function(e,t,r,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,o):0},munmap:function(e){return 0},ioctl:function(e,t,r){if(!e.stream_ops.ioctl)throw new ve.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw new Error('Invalid encoding type "'.concat(r.encoding,'"'));var n=ve.open(e,r.flags),o=ve.stat(e).size,i=new Uint8Array(o);return ve.read(n,i,0,o,0),"utf8"===r.encoding?t=oe(i,0):"binary"===r.encoding&&(t=i),ve.close(n),t},writeFile:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var n=ve.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(ae(t)+1),i=se(t,o,0,o.length);ve.write(n,o,0,i,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ve.write(n,t,0,t.byteLength,void 0,r.canOwn)}ve.close(n)},cwd:function(){return ve.currentPath},chdir:function(e){var t=ve.lookupPath(e,{follow:!0});if(null===t.node)throw new ve.ErrnoError(44);if(!ve.isDir(t.node.mode))throw new ve.ErrnoError(54);var r=ve.nodePermissions(t.node,"x");if(r)throw new ve.ErrnoError(r);ve.currentPath=t.path},createDefaultDirectories:function(){ve.mkdir("/tmp"),ve.mkdir("/home"),ve.mkdir("/home/web_user")},createDefaultDevices:function(){ve.mkdir("/dev"),ve.registerDevice(ve.makedev(1,3),{read:function(){return 0},write:function(e,t,r,n,o){return n}}),ve.mkdev("/dev/null",ve.makedev(1,3)),ce.register(ve.makedev(5,0),ce.default_tty_ops),ce.register(ve.makedev(6,0),ce.default_tty1_ops),ve.mkdev("/dev/tty",ve.makedev(5,0)),ve.mkdev("/dev/tty1",ve.makedev(6,0));var e=new Uint8Array(1024),t=0,r=function(){return 0===t&&(t=te(e).byteLength),e[--t]};ve.createDevice("/dev","random",r),ve.createDevice("/dev","urandom",r),ve.mkdir("/dev/shm"),ve.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){ve.mkdir("/proc");var e=ve.mkdir("/proc/self");ve.mkdir("/proc/self/fd"),ve.mount({mount:function(){var t=ve.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=+t,n=ve.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return n.path}}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:function(){i.stdin?ve.createDevice("/dev","stdin",i.stdin):ve.symlink("/dev/tty","/dev/stdin"),i.stdout?ve.createDevice("/dev","stdout",null,i.stdout):ve.symlink("/dev/tty","/dev/stdout"),i.stderr?ve.createDevice("/dev","stderr",null,i.stderr):ve.symlink("/dev/tty1","/dev/stderr"),ve.open("/dev/stdin",0),ve.open("/dev/stdout",1),ve.open("/dev/stderr",1)},ensureErrnoError:function(){ve.ErrnoError||(ve.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ve.ErrnoError.prototype=new Error,ve.ErrnoError.prototype.constructor=ve.ErrnoError,[44].forEach((function(e){ve.genericErrors[e]=new ve.ErrnoError(e),ve.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:function(){ve.ensureErrnoError(),ve.nameTable=new Array(4096),ve.mount(le,{},"/"),ve.createDefaultDirectories(),ve.createDefaultDevices(),ve.createSpecialDirectories(),ve.filesystems={MEMFS:le}},init:function(e,t,r){ve.init.initialized=!0,ve.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,ve.createStandardStreams()},quit:function(){ve.init.initialized=!1;for(var e=0;e<ve.streams.length;e++){var t=ve.streams[e];t&&ve.close(t)}},findObject:function(e,t){var r=ve.analyzePath(e,t);return r.exists?r.object:null},analyzePath:function(e,t){try{e=(n=ve.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=ve.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=Z.basename(e),n=ve.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:function(e,t,r,n){e="string"==typeof e?e:ve.getPath(e);for(var o=t.split("/").reverse();o.length;){var i=o.pop();if(i){var a=Z.join2(e,i);try{ve.mkdir(a)}catch(e){}e=a}}return a},createFile:function(e,t,r,n,o){var i=Z.join2("string"==typeof e?e:ve.getPath(e),t),a=pe(n,o);return ve.create(i,a)},createDataFile:function(e,t,r,n,o,i){var a=t;e&&(e="string"==typeof e?e:ve.getPath(e),a=t?Z.join2(e,t):e);var s=pe(n,o),u=ve.create(a,s);if(r){if("string"==typeof r){for(var c=new Array(r.length),f=0,l=r.length;f<l;++f)c[f]=r.charCodeAt(f);r=c}ve.chmod(u,146|s);var d=ve.open(u,577);ve.write(d,r,0,r.length,0,i),ve.close(d),ve.chmod(u,s)}return u},createDevice:function(e,t,r,n){var o=Z.join2("string"==typeof e?e:ve.getPath(e),t),i=pe(!!r,!!n);ve.createDevice.major||(ve.createDevice.major=64);var a=ve.makedev(ve.createDevice.major++,0);return ve.registerDevice(a,{open:function(e){e.seekable=!1},close:function(e){n&&n.buffer&&n.buffer.length&&n(10)},read:function(e,t,n,o,i){for(var a=0,s=0;s<o;s++){var u;try{u=r()}catch(e){throw new ve.ErrnoError(29)}if(void 0===u&&0===a)throw new ve.ErrnoError(6);if(null==u)break;a++,t[n+s]=u}return a&&(e.node.timestamp=Date.now()),a},write:function(e,t,r,o,i){for(var a=0;a<o;a++)try{n(t[r+a])}catch(e){throw new ve.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),ve.mkdev(o,i,a)},forceLoadFile:function(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(!h)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=ue(h(e.url)),e.usedBytes=e.contents.length}catch(e){throw new ve.ErrnoError(29)}},createLazyFile:function(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,a=1048576;o||(a=n);var s=this;s.setDataGetter((function(e){var t=e*a,o=(e+1)*a-1;if(o=Math.min(o,n-1),void 0===s.chunks[e]&&(s.chunks[e]=function(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!==a&&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||[]):ue(o.responseText||"")}(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!i&&n||(a=n=1,n=this.getter(0).length,a=n,_("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=a,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 a=new i;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:r};var u=ve.createFile(e,t,s,n,o);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={};function f(e,t,r,n,o){var i=e.node.contents;if(o>=i.length)return 0;var a=Math.min(i.length-o,n);if(i.slice)for(var s=0;s<a;s++)t[r+s]=i[o+s];else for(s=0;s<a;s++)t[r+s]=i.get(o+s);return a}return Object.keys(u.stream_ops).forEach((function(e){var t=u.stream_ops[e];c[e]=function(){return ve.forceLoadFile(u),t.apply(null,arguments)}})),c.read=function(e,t,r,n,o){return ve.forceLoadFile(u),f(e,t,r,n,o)},c.mmap=function(e,t,r,n,o){ve.forceLoadFile(u);var i=fe();if(!i)throw new ve.ErrnoError(48);return f(e,T,i,t,r),{ptr:i,allocated:!0}},u.stream_ops=c,u}},me=function(e,t){return e?oe(A,e,t):""},ye={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(Z.isAbs(t))return t;var n;if(n=-100===e?ve.cwd():ye.getStreamFromFD(e).path,0==t.length){if(!r)throw new ve.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(ve.getPath(e.node)))return-54;throw e}P[r>>2]=n.dev,P[r+4>>2]=n.mode,O[r+8>>2]=n.nlink,P[r+12>>2]=n.uid,P[r+16>>2]=n.gid,P[r+20>>2]=n.rdev,H=[n.size>>>0,($=n.size,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+24>>2]=H[0],P[r+28>>2]=H[1],P[r+32>>2]=4096,P[r+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),a=n.ctime.getTime();return H=[Math.floor(o/1e3)>>>0,($=Math.floor(o/1e3),+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+40>>2]=H[0],P[r+44>>2]=H[1],O[r+48>>2]=o%1e3*1e3,H=[Math.floor(i/1e3)>>>0,($=Math.floor(i/1e3),+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+56>>2]=H[0],P[r+60>>2]=H[1],O[r+64>>2]=i%1e3*1e3,H=[Math.floor(a/1e3)>>>0,($=Math.floor(a/1e3),+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+72>>2]=H[0],P[r+76>>2]=H[1],O[r+80>>2]=a%1e3*1e3,H=[n.ino>>>0,($=n.ino,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+88>>2]=H[0],P[r+92>>2]=H[1],0},doMsync:function(e,t,r,n,o){if(!ve.isFile(t.node.mode))throw new ve.ErrnoError(43);if(2&n)return 0;var i=A.slice(e,e+r);ve.msync(t,i,o,r,n)},varargs:void 0,get:function(){return ye.varargs+=4,P[ye.varargs-4>>2]},getStr:function(e){return me(e)},getStreamFromFD:function(e){return ve.getStreamChecked(e)}};function ge(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: ".concat(e))}}var we=void 0;function Ee(e){for(var t="",r=e;A[r];)t+=we[A[r++]];return t}var be={},_e={},ke={},Te=void 0;function Ae(e){throw new Te(e)}var Se=void 0;function Ce(e){throw new Se(e)}function Pe(e,t,r){function n(t){var n=r(t);n.length!==e.length&&Ce("Mismatched type converter count");for(var o=0;o<e.length;++o)Oe(e[o],n[o])}e.forEach((function(e){ke[e]=t}));var o=new Array(t.length),i=[],a=0;t.forEach((function(e,t){_e.hasOwnProperty(e)?o[t]=_e[e]:(i.push(e),be.hasOwnProperty(e)||(be[e]=[]),be[e].push((function(){o[t]=_e[e],++a===i.length&&n(o)})))})),0===i.length&&n(o)}function Oe(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.name;if(e||Ae('type "'.concat(n,'" must have a positive integer typeid pointer')),_e.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;Ae("Cannot register type '".concat(n,"' twice"))}if(_e[e]=t,delete ke[e],be.hasOwnProperty(e)){var o=be[e];delete be[e],o.forEach((function(e){return e()}))}}(e,t,r)}function Ie(e){if(!(this instanceof Ye))return!1;if(!(e instanceof Ye))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 De(e){Ae(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Le=!1;function Re(e){}function xe(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 Me(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var n=Me(e,t,r.baseClass);return null===n?null:r.downcast(n)}var Ue={};function Fe(){return Object.keys(ze).length}function je(){var e=[];for(var t in ze)ze.hasOwnProperty(t)&&e.push(ze[t]);return e}var Ne=[];function Be(){for(;Ne.length;){var e=Ne.pop();e.$$.deleteScheduled=!1,e.delete()}}var $e=void 0;function He(e){$e=e,Ne.length&&$e&&$e(Be)}var ze={};function We(e,t){return t=function(e,t){for(void 0===t&&Ae("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),ze[t]}function Ve(e,t){return t.ptrType&&t.ptr||Ce("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&Ce("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ge(Object.create(e,{$$:{value:t}}))}function qe(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=We(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?Ve(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Ve(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,a=this.registeredClass.getActualType(t),s=Ue[a];if(!s)return o.call(this);i=this.isConst?s.constPointerType:s.pointerType;var u=Me(t,this.registeredClass,i.registeredClass);return null===u?o.call(this):this.isSmartPointer?Ve(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):Ve(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}var Ge=function(e){return"undefined"==typeof FinalizationRegistry?(Ge=function(e){return e},e):(Le=new FinalizationRegistry((function(e){xe(e.$$)})),Re=function(e){return Le.unregister(e)},(Ge=function(e){var t=e.$$;if(t.smartPtr){var r={$$:t};Le.register(e,r,e)}return e})(e))};function Qe(){if(this.$$.ptr||De(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Ge(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 Je(){this.$$.ptr||De(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Ae("Object already scheduled for deletion"),Re(this),xe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Ke(){return!this.$$.ptr}function Xe(){return this.$$.ptr||De(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Ae("Object already scheduled for deletion"),Ne.push(this),1===Ne.length&&$e&&$e(Be),this.$$.deleteScheduled=!0,this}function Ye(){}function Ze(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_".concat(e):e}function et(e,t){return u({},e=Ze(e),(function(){return t.apply(this,arguments)}))[e]}function tt(e,t,r){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||Ae("Function '".concat(r,"' called with an invalid number of arguments (").concat(arguments.length,") - expects one of (").concat(e[t].overloadTable,")!")),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function rt(e,t,r,n,o,i,a,s){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function nt(e,t,r){for(;t!==r;)t.upcast||Ae("Expected null or instance of ".concat(r.name,", got an instance of ").concat(t.name)),e=t.upcast(e),t=t.baseClass;return e}function ot(e,t){if(null===t)return this.isReference&&Ae("null is not a valid ".concat(this.name)),0;t.$$||Ae('Cannot pass "'.concat(Pt(t),'" as a ').concat(this.name)),t.$$.ptr||Ae("Cannot pass deleted object as a pointer of type ".concat(this.name));var r=t.$$.ptrType.registeredClass;return nt(t.$$.ptr,r,this.registeredClass)}function it(e,t){var r;if(null===t)return this.isReference&&Ae("null is not a valid ".concat(this.name)),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||Ae('Cannot pass "'.concat(Pt(t),'" as a ').concat(this.name)),t.$$.ptr||Ae("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&t.$$.ptrType.isConst&&Ae("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));var n=t.$$.ptrType.registeredClass;if(r=nt(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&Ae("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:Ae("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(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,Ct.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:Ae("Unsupporting sharing policy")}return r}function at(e,t){if(null===t)return this.isReference&&Ae("null is not a valid ".concat(this.name)),0;t.$$||Ae('Cannot pass "'.concat(Pt(t),'" as a ').concat(this.name)),t.$$.ptr||Ae("Cannot pass deleted object as a pointer of type ".concat(this.name)),t.$$.ptrType.isConst&&Ae("Cannot convert argument of type ".concat(t.$$.ptrType.name," to parameter type ").concat(this.name));var r=t.$$.ptrType.registeredClass;return nt(t.$$.ptr,r,this.registeredClass)}function st(e){return this.fromWireType(P[e>>2])}function ut(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function ct(e){this.rawDestructor&&this.rawDestructor(e)}function ft(e){null!==e&&e.delete()}function lt(e,t,r,n,o,i,a,s,u,c,f){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=f,o||void 0!==t.baseClass?this.toWireType=it:n?(this.toWireType=ot,this.destructorFunction=null):(this.toWireType=at,this.destructorFunction=null)}var dt=[],ht=function(e){var t=dt[e];return t||(e>=dt.length&&(dt.length=e+1),dt[e]=t=L.get(e)),t},pt=function(e,t,r){return e.includes("j")?function(e,t,r){var n=i["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)}(e,t,r):ht(t).apply(null,r)};function vt(e,t){var r,n,o,i=(e=Ee(e)).includes("j")?(r=e,n=t,o=[],function(){return o.length=0,Object.assign(o,arguments),pt(r,n,o)}):ht(t);return"function"!=typeof i&&Ae("unknown function pointer with signature ".concat(e,": ").concat(t)),i}var mt=void 0;function yt(e){var t=Xt(e),r=Ee(t);return Jt(t),r}function gt(e,t){var r=[],n={};throw t.forEach((function e(t){n[t]||_e[t]||(ke[t]?ke[t].forEach(e):(r.push(t),n[t]=!0))})),new mt("".concat(e,": ")+r.map(yt).join([", "]))}function wt(e,t){for(var r=[],n=0;n<e;n++)r.push(O[t+4*n>>2]);return r}function Et(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function bt(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(y(e)," which is not a function"));var r=et(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var n=new r,o=e.apply(n,t);return o instanceof Object?o:n}function _t(e,t,r,n,o,i){var a=t.length;a<2&&Ae("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=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 f="void"!==t[0].name,l="",d="";for(c=0;c<a-2;++c)l+=(0!==c?", ":"")+"arg"+c,d+=(0!==c?", ":"")+"arg"+c+"Wired";var h="\n return function ".concat(Ze(e),"(").concat(l,") {\n if (arguments.length !== ").concat(a-2,") {\n throwBindingError('function ").concat(e," called with ").concat(arguments.length," arguments, expected ").concat(a-2," args!');\n }");u&&(h+="var destructors = [];\n");var p=u?"destructors":"null",v=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],m=[Ae,n,o,Et,t[0],t[1]];for(s&&(h+="var thisWired = classParam.toWireType("+p+", this);\n"),c=0;c<a-2;++c)h+="var arg"+c+"Wired = argType"+c+".toWireType("+p+", arg"+c+"); // "+t[c+2].name+"\n",v.push("argType"+c),m.push(t[c+2]);if(s&&(d="thisWired"+(d.length>0?", ":"")+d),h+=(f||i?"var rv = ":"")+"invoker(fn"+(d.length>0?", ":"")+d+");\n",u)h+="runDestructors(destructors);\n";else for(c=s?1:2;c<t.length;++c){var y=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(h+=y+"_dtor("+y+"); // "+t[c].name+"\n",v.push(y+"_dtor"),m.push(t[c].destructorFunction))}return f&&(h+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),h+="}\n",v.push(h),bt(Function,v).apply(null,m)}function kt(){this.allocated=[void 0],this.freelist=[]}var Tt=new kt;function At(e){e>=Tt.reserved&&0==--Tt.get(e).refcount&&Tt.free(e)}function St(){for(var e=0,t=Tt.reserved;t<Tt.allocated.length;++t)void 0!==Tt.allocated[t]&&++e;return e}var Ct={toValue:function(e){return e||Ae("Cannot use deleted val. handle = "+e),Tt.get(e).value},toHandle:function(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Tt.allocate({refcount:1,value:e})}}};function Pt(e){if(null===e)return"null";var t=y(e);return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Ot(e,t){switch(t){case 2:return function(e){return this.fromWireType(I[e>>2])};case 3:return function(e){return this.fromWireType(D[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function It(e,t,r){switch(t){case 0:return r?function(e){return T[e]}:function(e){return A[e]};case 1:return r?function(e){return S[e>>1]}:function(e){return C[e>>1]};case 2:return r?function(e){return P[e>>2]}:function(e){return O[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Dt,Lt,Rt,xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Mt=function(e,t){for(var r=e,n=r>>1,o=n+t/2;!(n>=o)&&C[n];)++n;if((r=n<<1)-e>32&&xt)return xt.decode(A.subarray(e,r));for(var i="",a=0;!(a>=t/2);++a){var s=S[e+2*a>>1];if(0==s)break;i+=String.fromCharCode(s)}return i},Ut=function(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 a=e.charCodeAt(i);S[t>>1]=a,t+=2}return S[t>>1]=0,t-n},Ft=function(e){return 2*e.length},jt=function(e,t){for(var r=0,n="";!(r>=t/4);){var o=P[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},Nt=function(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 a=e.charCodeAt(i);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i)),P[t>>2]=a,(t+=4)+4>o)break}return P[t>>2]=0,t-n},Bt=function(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},$t={},Ht=[],zt=[],Wt={},Vt=function(){if(!Vt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==("undefined"==typeof navigator?"undefined":y(navigator))&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var t in Wt)void 0===Wt[t]?delete e[t]:e[t]=Wt[t];var r=[];for(var t in e)r.push("".concat(t,"=").concat(e[t]));Vt.strings=r}return Vt.strings},qt=function(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ve.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n};Object.defineProperties(qt.prototype,{read:{get:function(){return!(365&~this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return!(146&~this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ve.isDir(this.mode)}},isDevice:{get:function(){return ve.isChrdev(this.mode)}}}),ve.FSNode=qt,ve.createPreloadedFile=function(e,t,r,n,o,i,a,s,u,c){var f=t?re.resolve(Z.join2(e,t)):e;function l(r){function l(r){c&&c(),s||ve.createDataFile(e,t,r,n,o,u),i&&i(),q()}(function(e,t,r,n){"undefined"!=typeof Browser&&Browser.init();var o=!1;return he.forEach((function(i){o||i.canHandle(t)&&(i.handle(e,t,r,n),o=!0)})),o})(r,f,l,(function(){a&&a(),q()}))||l(r)}V(),"string"==typeof r?de(r,(function(e){return l(e)}),a):l(r)},ve.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);we=e}(),Te=i.BindingError=function(e){function t(e){var r;return o(this,t),(r=n(this,t,[e])).name="BindingError",r}return f(t,e),a(t)}(w(Error)),Se=i.InternalError=function(e){function t(e){var r;return o(this,t),(r=n(this,t,[e])).name="InternalError",r}return f(t,e),a(t)}(w(Error)),Ye.prototype.isAliasOf=Ie,Ye.prototype.clone=Qe,Ye.prototype.delete=Je,Ye.prototype.isDeleted=Ke,Ye.prototype.deleteLater=Xe,i.getInheritedInstanceCount=Fe,i.getLiveInheritedInstances=je,i.flushPendingDeletes=Be,i.setDelayFunction=He,lt.prototype.getPointee=ut,lt.prototype.destructor=ct,lt.prototype.argPackAdvance=8,lt.prototype.readValueFromPointer=st,lt.prototype.deleteObject=ft,lt.prototype.fromWireType=qe,mt=i.UnboundTypeError=(Dt=Error,(Rt=et(Lt="UnboundTypeError",(function(e){this.name=Lt,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(Dt.prototype),Rt.prototype.constructor=Rt,Rt.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},Rt),Object.assign(kt.prototype,{get:function(e){return this.allocated[e]},has:function(e){return void 0!==this.allocated[e]},allocate:function(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free:function(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Tt.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Tt.reserved=Tt.allocated.length,i.count_emval_handles=St;var Gt={p:function(e,t,r){throw new Y(e).init(t,r),e},C:function(e,t,r){ye.varargs=r;try{var n=ye.getStreamFromFD(e);switch(t){case 0:return(o=ye.get())<0?-28:ve.createStream(n,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return n.flags;case 4:var o=ye.get();return n.flags|=o,0;case 5:return o=ye.get(),S[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return i=28,P[Kt()>>2]=i,-1}}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return-e.errno}var i},w:function(e,t,r,n){ye.varargs=n;try{t=ye.getStr(t),t=ye.calculateAt(e,t);var o=n?ye.get():0;return ve.open(t,r,o).fd}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return-e.errno}},t:function(e,t,r,n,o){},n:function(e,t,r,n,o){var i=ge(r);Oe(e,{name:t=Ee(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=T;else if(2===r)n=S;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=P}return this.fromWireType(n[e>>i])},destructorFunction:null})},r:function(e,t,r,n,o,a,s,u,c,f,l,d,h){l=Ee(l),a=vt(o,a),u&&(u=vt(s,u)),f&&(f=vt(c,f)),h=vt(d,h);var p=Ze(l);!function(e,t,r){i.hasOwnProperty(e)?(Ae("Cannot register public name '".concat(e,"' twice")),tt(i,e,e),i.hasOwnProperty(r)&&Ae("Cannot register multiple overloads of a function with the same number of arguments (".concat(r,")!")),i[e].overloadTable[r]=t):i[e]=t}(p,(function(){gt("Cannot construct ".concat(l," due to unbound types"),[n])})),Pe([e,t,r],n?[n]:[],(function(t){var r,o;t=t[0],o=n?(r=t.registeredClass).instancePrototype:Ye.prototype;var s=et(p,(function(){if(Object.getPrototypeOf(this)!==c)throw new Te("Use 'new' to construct "+l);if(void 0===d.constructor_body)throw new Te(l+" has no accessible constructor");var e=d.constructor_body[arguments.length];if(void 0===e)throw new Te("Tried to invoke ctor of ".concat(l," with invalid number of parameters (").concat(arguments.length,") - expected (").concat(Object.keys(d.constructor_body).toString(),") parameters instead!"));return e.apply(this,arguments)})),c=Object.create(o,{constructor:{value:s}});s.prototype=c;var d=new rt(l,s,c,h,r,a,u,f);d.baseClass&&(void 0===d.baseClass.__derivedClasses&&(d.baseClass.__derivedClasses=[]),d.baseClass.__derivedClasses.push(d));var v=new lt(l,d,!0,!1,!1),m=new lt(l+"*",d,!1,!1,!1),y=new lt(l+" const*",d,!1,!0,!1);return Ue[e]={pointerType:m,constPointerType:y},function(e,t,r){i.hasOwnProperty(e)||Ce("Replacing nonexistant public symbol"),void 0!==i[e].overloadTable&&void 0!==r||(i[e]=t,i[e].argCount=r)}(p,s),[v,m,y]}))},q:function(e,t,r,n,o,i){var a=wt(t,r);o=vt(n,o),Pe([],[e],(function(e){e=e[0];var r="constructor ".concat(e.name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new Te("Cannot register multiple constructors with identical number of parameters (".concat(t-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[t-1]=function(){gt("Cannot construct ".concat(e.name," due to unbound types"),a)},Pe([],a,(function(n){return n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=_t(r,n,null,o,i),[]})),[]}))},d:function(e,t,r,n,o,i,a,s,u){var c=wt(r,n);t=Ee(t),i=vt(o,i),Pe([],[e],(function(e){e=e[0];var n="".concat(e.name,".").concat(t);function o(){gt("Cannot call ".concat(n," due to unbound types"),c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var f=e.registeredClass.instancePrototype,l=f[t];return void 0===l||void 0===l.overloadTable&&l.className!==e.name&&l.argCount===r-2?(o.argCount=r-2,o.className=e.name,f[t]=o):(tt(f,t,n),f[t].overloadTable[r-2]=o),Pe([],c,(function(o){var s=_t(n,o,e,i,a,u);return void 0===f[t].overloadTable?(s.argCount=r-2,f[t]=s):f[t].overloadTable[r-2]=s,[]})),[]}))},D:function(e,t){Oe(e,{name:t=Ee(t),fromWireType:function(e){var t=Ct.toValue(e);return At(e),t},toWireType:function(e,t){return Ct.toHandle(t)},argPackAdvance:8,readValueFromPointer:st,destructorFunction:null})},k:function(e,t,r){var n=ge(r);Oe(e,{name:t=Ee(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Ot(t,n),destructorFunction:null})},c:function(e,t,r,n,o){t=Ee(t);var i=ge(r),a=function(e){return e};if(0===n){var s=32-8*r;a=function(e){return e<<s>>>s}}var u=t.includes("unsigned");Oe(e,{name:t,fromWireType:a,toWireType:u?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:It(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=O,r=t[e>>=2],o=t[e+1];return new n(t.buffer,o,r)}Oe(e,{name:r=Ee(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=Ee(t));Oe(e,{name:t,fromWireType:function(e){var t,n=O[e>>2],o=e+4;if(r)for(var i=o,a=0;a<=n;++a){var s=o+a;if(a==n||0==A[s]){var u=me(i,s-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=s+1}}else{var c=new Array(n);for(a=0;a<n;++a)c[a]=String.fromCharCode(A[o+a]);t=c.join("")}return Jt(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||Ae("Cannot pass non-string to std::string"),n=r&&o?ae(t):t.length;var i=Qt(4+n+1),a=i+4;if(O[i>>2]=n,r&&o)se(t,A,a,n+1);else if(o)for(var s=0;s<n;++s){var u=t.charCodeAt(s);u>255&&(Jt(a),Ae("String has UTF-16 code units that do not fit in 8 bits")),A[a+s]=u}else for(s=0;s<n;++s)A[a+s]=t[s];return null!==e&&e.push(Jt,i),i},argPackAdvance:8,readValueFromPointer:st,destructorFunction:function(e){Jt(e)}})},f:function(e,t,r){var n,o,i,a,s;r=Ee(r),2===t?(n=Mt,o=Ut,a=Ft,i=function(){return C},s=1):4===t&&(n=jt,o=Nt,a=Bt,i=function(){return O},s=2),Oe(e,{name:r,fromWireType:function(e){for(var r,o=O[e>>2],a=i(),u=e+4,c=0;c<=o;++c){var f=e+4+c*t;if(c==o||0==a[f>>s]){var l=n(u,f-u);void 0===r?r=l:(r+=String.fromCharCode(0),r+=l),u=f+t}}return Jt(e),r},toWireType:function(e,n){"string"!=typeof n&&Ae("Cannot pass non-string to C++ string type ".concat(r));var i=a(n),u=Qt(4+i+t);return O[u>>2]=i>>s,o(n,u+4,i+t),null!==e&&e.push(Jt,u),u},argPackAdvance:8,readValueFromPointer:st,destructorFunction:function(e){Jt(e)}})},o:function(e,t){Oe(e,{isVoid:!0,name:t=Ee(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,n){var o,i;(e=Ht[e])(t=Ct.toValue(t),r=void 0===(i=$t[o=r])?Ee(o):i,null,n)},m:At,l:function(e,t){var r=function(e,t){for(var r,n,o,i=new Array(e),a=0;a<e;++a)i[a]=(r=O[t+4*a>>2],n="parameter "+a,o=void 0,void 0===(o=_e[r])&&Ae(n+" has unknown type "+yt(r)),o);return i}(e,t),n=r[0],o=n.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",i=zt[o];if(void 0!==i)return i;for(var a=["retType"],s=[n],u="",c=0;c<e-1;++c)u+=(0!==c?", ":"")+"arg"+c,a.push("argType"+c),s.push(r[1+c]);var f="return function "+Ze("methodCaller_"+o)+"(handle, name, destructors, args) {\n",l=0;for(c=0;c<e-1;++c)f+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(l?"+"+l:"")+");\n",l+=r[c+1].argPackAdvance;for(f+=" var rv = handle[name]("+u+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(f+=" argType"+c+".deleteObject(arg"+c+");\n");n.isVoid||(f+=" return retType.toWireType(destructors, rv);\n"),f+="};\n",a.push(f);var d,h,p=bt(Function,a).apply(null,s);return d=p,h=Ht.length,Ht.push(d),i=h,zt[o]=i,i},a:function(){G("")},e:function(){return Date.now()},v:function(){return A.length},A:function(e,t,r){return A.copyWithin(e,t,t+r)},u:function(e){A.length,G("OOM")},y:function(e,t){var r=0;return Vt().forEach((function(n,o){var i=t+r;O[e+4*o>>2]=i,function(e,t){for(var r=0;r<e.length;++r)T[0|t++]=e.charCodeAt(r);T[0|t]=0}(n,i),r+=n.length+1})),0},z:function(e,t){var r=Vt();O[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),O[t>>2]=n,0},i:function(e){try{var t=ye.getStreamFromFD(e);return ve.close(t),0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},x:function(e,t){try{var r=ye.getStreamFromFD(e),n=r.tty?2:ve.isDir(r.mode)?3:ve.isLink(r.mode)?7:4;return T[0|t]=n,S[t+2>>1]=0,H=[0,($=0,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[t+8>>2]=H[0],P[t+12>>2]=H[1],H=[0,($=0,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[t+16>>2]=H[0],P[t+20>>2]=H[1],0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},B:function(e,t,r,n){try{var o=function(e,t,r,n){for(var o=0,i=0;i<r;i++){var a=O[t>>2],s=O[t+4>>2];t+=8;var u=ve.read(e,T,a,s,n);if(u<0)return-1;if(o+=u,u<s)break}return o}(ye.getStreamFromFD(e),t,r);return O[n>>2]=o,0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},s:function(e,t,r,n,o){var i,a,s=(a=r)+2097152>>>0<4194305-!!(i=t)?(i>>>0)+4294967296*a:NaN;try{if(isNaN(s))return 61;var u=ye.getStreamFromFD(e);return ve.llseek(u,s,n),H=[u.position>>>0,($=u.position,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[o>>2]=H[0],P[o+4>>2]=H[1],u.getdents&&0===s&&0===n&&(u.getdents=null),0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},h:function(e,t,r,n){try{var o=function(e,t,r,n){for(var o=0,i=0;i<r;i++){var a=O[t>>2],s=O[t+4>>2];t+=8;var u=ve.write(e,T,a,s,n);if(u<0)return-1;o+=u}return o}(ye.getStreamFromFD(e),t,r);return O[n>>2]=o,0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}}};!function(){var e,r,n,o,a={a:Gt};function s(e,t){var r,n=e.exports;return E=(b=n).E,r=E.buffer,i.HEAP8=T=new Int8Array(r),i.HEAP16=S=new Int16Array(r),i.HEAP32=P=new Int32Array(r),i.HEAPU8=A=new Uint8Array(r),i.HEAPU16=C=new Uint16Array(r),i.HEAPU32=O=new Uint32Array(r),i.HEAPF32=I=new Float32Array(r),i.HEAPF64=D=new Float64Array(r),L=b.H,function(e){M.unshift(e)}(b.F),q(),n}if(V(),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(e){k("Module.instantiateWasm callback failed with error: "+e),t(e)}(e=g,r=N,n=a,o=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||Q(r)||"function"!=typeof fetch?K(r,n,o):fetch(r,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(o,(function(e){return k("wasm streaming compile failed: "+e),k("falling back to ArrayBuffer instantiation"),K(r,n,o)}))}))).catch(t)}();var Qt=function(e){return(Qt=b.G)(e)},Jt=function(e){return(Jt=b.I)(e)},Kt=function(){return(Kt=b.J)()},Xt=function(e){return(Xt=b.K)(e)};i.__embind_initialize_bindings=function(){return(i.__embind_initialize_bindings=b.L)()};var Yt,Zt=function(e){return(Zt=b.M)(e)};function er(){function t(){Yt||(Yt=!0,i.calledRun=!0,R||(i.noFSInit||ve.init.initialized||ve.init(),ve.ignorePermissions=!1,X(M),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)j(i.postRun.shift());X(U)}()))}z>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)F(i.preRun.shift());X(x)}(),z>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),t()}),1)):t()))}if(i.dynCall_jiji=function(e,t,r,n,o){return(i.dynCall_jiji=b.N)(e,t,r,n,o)},i._ff_h264_cabac_tables=67061,W=function e(){Yt||er(),Yt||(W=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return er(),r.ready}),re=te,ne=function(e){function t(e){return o(this,t),n(this,t,[re,(null==e?void 0:e.wasmPath)?fetch(null==e?void 0:e.wasmPath).then((function(e){return e.arrayBuffer()})):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode])}return f(t,e),a(t)}(Z),oe=(function(){var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0}(),function(e){return 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}(oe||{})),ie="undefined"!=typeof importScripts,ae="undefined"!=typeof registerProcessor,se="jssdk_log",ue=function(e){return 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}(ue||{}),ce=function(e,t,r,n){return new(r||(r=Promise))((function(t,o){function i(e){try{s(n.next(e))}catch(e){o(e)}}function a(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,a)}s((n=n.apply(e,[])).next())}))},fe=Symbol(32),le=Symbol(16),de=Symbol(8),he=function(){return a((function e(t){o(this,e),this.g=t,this.consumed=0,t&&(this.need=t.next().value)}),[{key:"setG",value:function(e){this.g=e,this.demand(e.next().value,!0)}},{key:"consume",value:function(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}},{key:"demand",value:function(e,t){return t&&this.consume(),this.need=e,this.flush()}},{key:"read",value:function(e){return ce(this,0,void 0,d().mark((function t(){var r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.lastReadPromise){t.next=3;break}return t.next=3,this.lastReadPromise;case 3:return t.abrupt("return",this.lastReadPromise=new Promise((function(t,n){var o;r.reject=n,r.resolve=function(e){delete r.lastReadPromise,delete r.resolve,delete r.need,t(e)},r.demand(e,!0)||null===(o=r.pull)||void 0===o||o.call(r,e)})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"readU32",value:function(){return this.read(fe)}},{key:"readU16",value:function(){return this.read(le)}},{key:"readU8",value:function(){return this.read(de)}},{key:"close",value:function(){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}},{key:"flush",value:function(){if(this.buffer&&this.need){var e=null,t=this.buffer.subarray(this.consumed),r=0,n=function(e){return t.length<(r=e)};if("number"==typeof this.need){if(n(this.need))return;e=t.subarray(0,r)}else if(this.need===fe){if(n(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===le){if(n(2))return;e=t[0]<<8|t[1]}else if(this.need===de){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}}},{key:"write",value:function(e){var t=this;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((function(e){return t.pull=e}));this.flush()}},{key:"writeU32",value:function(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}},{key:"writeU16",value:function(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}},{key:"writeU8",value:function(e){this.malloc(1)[0]=e,this.flush()}},{key:"malloc",value:function(e){if(this.buffer){var 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{var n=new Uint8Array(r);n.set(this.buffer),this.buffer=n}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}}])}();he.U32=fe,he.U16=le,he.U8=de;function pe(e){for(var t=new he;e>=128;)t.malloc(1)[0]=255&e|128,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function ve(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new he,n=t<<3;switch(y(e)){case"boolean":var o=r.malloc(2);o[0]=n,o[1]=e?1:0;break;case"number":r.malloc(1)[0]=n,r.write(pe(e));break;case"string":r.malloc(1)[0]=2|n;var i=(new TextEncoder).encode(e);r.write(pe(i.length));for(var a=r.malloc(i.length),s=0;s<i.length;s++)a[s]=i[s];break;case"object":var u=new he;if(Array.isArray(e))for(var c=0;c<e.length;c++){var f=ve(e[c],c+1);f&&u.write(f)}else{var l=1;for(var d in e){var h=ve(e[d],l++);h&&u.write(h)}}0===t?u.buffer&&r.write(u.buffer):(r.malloc(1)[0]=2|n,u.buffer&&(r.write(pe(u.buffer.length)),r.write(u.buffer)))}return r.buffer||new Uint8Array(0)}var me=function(){return a((function e(){o(this,e),F(this,"buffer"),this.buffer=[]}),[{key:"data",get:function(){return this.buffer}},{key:"length",get:function(){return this.buffer.length}},{key:"writeInt32",value:function(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}},{key:"writeInt16",value:function(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}},{key:"writeByte",value:function(e){this.buffer.push(255&e)}},{key:"writeBytes",value:function(e){for(var t=0;t<e.length;t++)this.buffer.push(e[t])}}])}();function ye(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 ge(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function we(e,t){return e[t]}function Ee(e,t,r){return(new TextDecoder).decode(function(e,t,r){return e.slice(t,t+r)}(e,t,r))}var be=0,_e=2654435769;function ke(e,t){var r=new me,n=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,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}}(t,e,be);be=be+1&2147483647,r.writeInt32(0),r.writeInt32(n.version),r.writeByte(n.encryption);var o=(new TextEncoder).encode(n.d2);r.writeInt32(o.length+4),o&&r.writeBytes(o),r.writeByte(n.uinType);var i=(new TextEncoder).encode(n.uin);r.writeInt32(i.length+4),i.length&&r.writeBytes(i);var a=new me;a.writeInt32(0),a.writeInt32(n.reqHead.seqNumber),a.writeInt32(n.reqHead.appId),a.writeByte(n.reqHead.appId>>>24&255),a.writeByte(n.reqHead.appId>>>16&255),a.writeByte(n.reqHead.appId>>>8&255),a.writeByte(255&n.reqHead.appId);for(var s=4;s<16;s++)a.writeByte(0);var u=(new TextEncoder).encode(n.reqHead.a2);a.writeInt32(u.length+4),u.length&&a.writeBytes(u);var c=(new TextEncoder).encode(n.reqHead.serviceCmd);a.writeInt32(c.length+4),c.length&&a.writeBytes(c);var f=(new TextEncoder).encode(n.reqHead.cookie);a.writeInt32(f.length+4),f.length&&a.writeBytes(f);var l=(new TextEncoder).encode(n.reqHead.imei);a.writeInt32(l.length+4),l.length&&a.writeBytes(l);var d=(new TextEncoder).encode(n.reqHead.ksid);a.writeInt32(d.length+4),d.length&&a.writeBytes(d);var h=(new TextEncoder).encode(n.reqHead.clientVersionInfo);a.writeInt16(h.length+2),h.length&&a.writeBytes(h);var p=a.length;a.data[0]=p>>>24&255,a.data[1]=p>>>16&255,a.data[2]=p>>>8&255,a.data[3]=255&p,Gt(e)&&(e=(new TextEncoder).encode(e)),a.writeInt32(e.length+4),e.length&&a.writeBytes(e);var v=new Uint8Array(a.data),m=null;1===n.encryption?m=(new TextEncoder).encode(n.uin):2===n.encryption&&(m=new Uint8Array(16)),m&&(v=function(e,t){var r=e.length,n=(r+1+2+7)%8;n&&(n=8-n);var o=new Uint8Array(r+1+2+7+n),i=0,a=new Uint8Array(8),s=new Uint8Array(8),u=new Uint8Array(8),c=0;a[0]=248&Math.floor(256*Math.random())|n,c=1;for(var f=0;f<n;f++)a[c]=255&Math.floor(256*Math.random()),c+=1;for(var l=0;l<2;)if(c<8&&(a[c]=255&Math.floor(256*Math.random()),c+=1,l+=1),8===c){Te(a,t,s,u,o,i),i+=8,c=0;for(var d=0;d<8;d++)u[d]=o[i-8+d]}var h=0;for(;h<r;)if(c<8&&(a[c]=e[h],c+=1,h+=1),8===c){Te(a,t,s,u,o,i),i+=8,c=0;for(var p=0;p<8;p++)u[p]=o[i-8+p]}for(var v=0;v<7;)if(c<8&&(a[c]=0,c+=1,v+=1),8===c){Te(a,t,s,u,o,i),i+=8,c=0;for(var m=0;m<8;m++)u[m]=o[i-8+m]}return o}(v,m)),r.writeBytes(v);var y=new Uint8Array(r.data),g=y.length;return y[0]=g>>>24&255,y[1]=g>>>16&255,y[2]=g>>>8&255,y[3]=255&g,y}function Te(e,t,r,n,o,i){for(var a=0;a<8;a++)e[a]^=n[a];!function(e,t,r,n){for(var o=ge(e,0),i=ge(e,4),a=[],s=0;s<4;s++)a[s]=ge(t,4*s);for(var u=0,c=0;c<16;c++)u+=_e,u>>>=0,o+=(i<<4)+a[0]^i+u^(i>>>5)+a[1],i+=((o>>>=0)<<4)+a[2]^o+u^(o>>>5)+a[3],i>>>=0;ye(r,o,n),ye(r,i,n+4)}(e,t,o,i);for(var s=0;s<8;s++)o[i+s]^=r[s];for(var u=0;u<8;u++)r[u]=e[u]}var Ae=function(){return Date.now()+0};function Se(e){var t=function(e){try{var t={},r=0;t.totalLength=ge(e,r),r+=4,t.version=ge(e,r),r+=4,t.encryption=we(e,r),r+=1,t.uinType=we(e,r),r+=1,t.uinLength=ge(e,r),r+=4,t.uin=t.uinLength>4?Ee(e,r,t.uinLength-4):"",r+=t.uinLength-4;var n=e.slice(r);if(2===t.encryption){var o=function(e,t){var r=0,n=new Uint8Array(8).fill(0),o=Ce(new Uint8Array(e.slice(0,8)),t),i=7&o[0],a=e.length-1-i-2-7,s=new Uint8Array(a),u=0,c=n,f=e.slice(0,8);r=8;var l=1;l+=i;for(var d=1;d<=2;)if(l<8)l++,d++;else if(8===l){var h=Pe(e,r,c,f,o,t);c=h.ivPreCrypt,f=h.ivCurCrypt,o=h.debiBuf,r=h.bufPos,l=0}var p=a;for(;p>0;)if(l<8)s[u++]=o[l]^c[l],l++,p--;else if(8===l){var v=Pe(e,r,c,f,o,t);c=v.ivPreCrypt,f=v.ivCurCrypt,o=v.debiBuf,r=v.bufPos,l=0}for(var m=1;m<=7;)if(l<8)o[l],c[l],l++,m++;else if(8===l){if(r>=e.length)break;var y=Pe(e,r,c,f,o,t);if(!y.success)break;c=y.ivPreCrypt,f=y.ivCurCrypt,o=y.debiBuf,r=y.bufPos,l=0}return s}(n,new Uint8Array(16).fill(0));e=o,t.decrypted=!0,r=0}else e=n,r=0;return t.rspHeadLength=ge(e,r),r+=4,t.seqNo=ge(e,r),r+=4,t.retCode=ge(e,r),r+=4,t.retStrLength=ge(e,r),r+=4,t.retStr=t.retStrLength?Ee(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=ge(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?Ee(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=ge(e,r),r+=4,t.cookie=t.cookieLength?Ee(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=ge(e,r),r+=4,t.busiBuffLength=ge(e,r),r+=4,t.busiBuff=t.busiBuffLength?Ee(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(e){}}(e);return null==t?void 0:t.busiBuff}function Ce(e,t){var 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;for(var o=3816266640,i=0;i<16;i++)n-=(r<<4)+t[2]^r+o^(r>>>5)+t[3],r-=((n>>>=0)<<4)+t[0]^n+o^(n>>>5)+t[1],r>>>=0,o-=_e,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 Pe(e,t,r,n,o,i){if(t+8>e.length)return{success:!1};for(var a=new Uint8Array(n),s=e.slice(t,t+8),u=new Uint8Array(8),c=0;c<8;c++)u[c]=o[c]^s[c];return{success:!0,ivPreCrypt:a,ivCurCrypt:s,debiBuf:Ce(u,i),bufPos:t+8}}var Oe="undefined"!=typeof TextDecoder?new TextDecoder:void 0;var Ie=Object.prototype.hasOwnProperty,De=function(e){return"function"==typeof e},Le=function(e){return void 0===e};function Re(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(function(e){if(!e||"object"!==y(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var 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)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(Ie.call(e,t))return!1;return!0}return!1}var xe=function(e){var t=e.retryFunction,n=e.settings,o=e.onError,i=e.onRetrying,a=e.onRetryFailed,s=e.onRetrySuccess,u=e.context;return function(){for(var e=this,c=arguments.length,f=new Array(c),l=0;l<c;l++)f[l]=arguments[l];var h=n.retries,p=void 0===h?5:h,v=n.timeout,m=void 0===v?1e3:v,y=0,g=-1,w=0,E=function(){var n=r(d().mark((function r(n,c){var l,h,v,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return l=u||e,r.prev=1,r.next=4,t.apply(l,f);case 4:h=r.sent,y>0&&s&&s.call(e,y),y=0,n(h),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),v=function(){clearTimeout(g),y=0,w=2,c(r.t0)},b=function(){2!==w&&y<(De(p)?p():p)?(y++,w=1,De(i)&&i.call(e,y,v),g=window.setTimeout((function(){g=-1,E(n,c)}),De(m)?m(y):m)):(v(),De(a)&&a.call(e,r.t0))},De(o)?o.call(e,{error:r.t0,retry:b,reject:c,retryFuncArgs:f,retriedCount:y}):b();case 15:case"end":return r.stop()}}),r,null,[[1,10]])})));return function(e,t){return n.apply(this,arguments)}}();return new Promise(E)}},Me=function(){function e(t){o(this,e),F(this,"_parentPath"),F(this,"userId"),F(this,"remoteUserId"),F(this,"id"),F(this,"sdkAppId"),F(this,"type"),F(this,"isLocal"),this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal="boolean"!=typeof t.isLocal||t.isLocal,this.type=this.isLocal?"":t.type}return a(e,[{key:"getFullId",value:function(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}},{key:"createChild",value:function(t){var r=new e({id:t.id,userId:Le(t.userId)?this.userId:t.userId,sdkAppId:Le(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:Le(t.type)?this.type:t.type,isLocal:Le(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:Le(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}},{key:"bindParent",value:function(e){var t=e.getFullId();this._parentPath!==t&&(this.debug("bind logger parent: ".concat(e.id)),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}},{key:"setUserId",value:function(e){this.userId=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId=e}},{key:"log",value:function(e,t){var r=this.isLocal?this.userId:this.remoteUserId,n=this.getFullId();t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(n).concat(r?"|".concat(r):"","]")),Wt.log(e,t,Le(this.userId)||Re(this.userId),this.userId,this.sdkAppId)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}}])}(),Ue="undefined"==typeof navigator?"":navigator.userAgent,Fe=function(e){return new RegExp(e,"i").test(Ue)},je=function(e){if(Fe(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=Ue.match(t);if(r&&r[1])return r[1]}return""},Ne=function(e){if(Fe(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),r=Ue.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},Be=/AppleWebKit\/([\d.]+)/i.exec(Ue);Be&&parseFloat(Be[1]);var $e=Fe("iPad"),He="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&Fe("Macintosh"),ze=Fe("iPhone")&&!$e,We=Fe("iPod"),Ve=ze||$e||We||He,qe=Fe("Android");!function(){if(qe){var e=Ue.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){var t=e[1]&&parseFloat(e[1]),r=e[2]&&parseFloat(e[2]);if(t&&r)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}}();qe&&Fe("webkit");var Ge=Fe("Firefox"),Qe=je("Firefox");Ne("Firefox");var Je=Fe("Edge"),Ke=je("Edge"),Xe=Fe("Edg"),Ye=je("Edg");Ne("Edg");var Ze=Fe("SogouMobileBrowser"),et=je("SogouMobileBrowser"),tt=Fe("MetaSr\\s"),rt=je("MetaSr\\s"),nt=Fe("TBS"),ot=je("TBS"),it=Fe("XWEB"),at=je("XWEB");Fe("MSIE\\s8\\.0");var st=Fe("MSIE\\/\\d+");!function(){if(st){var e=/MSIE\s(\d+)\.\d/.exec(Ue),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(Ue)&&/rv:11.0/.test(Ue)&&(t=11),t}}();var ut=Fe("(micromessenger|webbrowser)"),ct=je("MicroMessenger"),ft=!nt&&Fe("MQQBrowser")&&Fe("COVC"),lt=!nt&&Fe("MQQBrowser")&&!Fe("COVC"),dt=lt||ft?je("MQQBrowser"):"",ht=!nt&&Fe(" QQBrowser"),pt=je(" QQBrowser"),vt=!nt&&Fe("QQBrowserLite"),mt=je("QQBrowserLite"),yt=!nt&&Fe("MQBHD"),gt=je("MQBHD");Fe("Windows"),!Ve&&Fe("MAC OS X"),!qe&&Fe("Linux"),Fe("CrOS"),Fe("MicroMessenger"),Fe("UCBrowser"),Fe("Electron");var wt=Fe("MiuiBrowser"),Et=je("MiuiBrowser"),bt=Fe("HuaweiBrowser");Fe("Huawei")||Fe("HUAWEI"),Fe("Honor")||Fe("HONOR");var _t=je("HuaweiBrowser"),kt=Fe("SamsungBrowser"),Tt=je("SamsungBrowser"),At=Fe("HeyTapBrowser"),St=je("HeyTapBrowser"),Ct=Fe("VivoBrowser"),Pt=je("VivoBrowser");Fe("OpenHarmony"),je("OpenHarmony");var Ot=Fe("CriOS"),It=Fe("Chrome"),Dt=!Je&&!tt&&!Ze&&!nt&&!it&&!Xe&&!ht&&!wt&&!bt&&!kt&&!At&&!Ct&&It,Lt=Fe("HeadlessChrome");Ne("Chrome");var Rt=je("Chrome");Ne("Electron");var xt=!It&&!lt&&!ft&&!vt&&!yt&&Fe("Safari"),Mt=je("Version"),Ut=function(){if(He)return Mt;if(Ve){var e=Ue.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}();Number(Ut.split(".")[0]),Number(Ut.split(".")[0]),function(){var e=new Map([[Ge,["Firefox",Qe]],[Xe,["Edg",Ye]],[Dt,["Chrome",Rt]],[Ot,["ChiOS",je("CriOS")]],[xt&&!Ot,["Safari",Mt]],[nt,["TBS",ot]],[it,["XWEB",at]],[ut&&ze,["WeChat",ct]],[ht,["QQ(Win)",pt]],[lt,["QQ(Mobile)",dt]],[ft,["QQ(Mobile X5)",dt]],[vt,["QQ(Mac)",mt]],[yt,["QQ(iPad)",gt]],[wt,["MI",Et]],[bt,["HW",_t]],[kt,["Samsung",Tt]],[At,["OPPO",St]],[Ct,["VIVO",Pt]],[Je,["EDGE",Ke]],[Ze,["SogouMobile",et]],[tt,["Sogou",rt]]]),t="unknown",r="unknown";if(e.has(!0)){var n=p(e.get(!0),2);t=n[0],r=n[1]}}();var Ft=new(M(j()).default),jt=oe,Nt=new(function(){return a((function e(){var t=this;o(this,e),F(this,"enable",!1),F(this,"ssoFailCount",0),Ft.on("22",(function(e){var t,r=e.schedule;(null==(t=null==r?void 0:r.config)?void 0:t.sso)&&Ft.emit("266",{enable:!0})})),Ft.on("266",(function(e){var r=e.enable;t.enable=r}))}),[{key:"handleUploadFailed",value:function(){this.ssoFailCount++,this.ssoFailCount>3&&Ft.emit("266",{enable:!1})}}])}()),Bt="%cTRTC%c%s",$t="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",Ht="display: inline",zt=function(){function e(){o(this,e),F(this,"_isEnableUploadLog",!0),F(this,"_localJoinedUser",new Map),F(this,"_queue",[]),F(this,"_timeoutId",-1),F(this,"_logLevel",1),F(this,"_logLevelToUpload",2),ie||ae||(this.checkURLParam(),this.installEvents())}return a(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;Ft.on(jt.JOIN_SCHEDULE_SUCCESS,(function(t){var r,n=t.schedule;(null==(r=null==n?void 0:n.config)?void 0:r.logLevelToUpload)&&ue[n.config.logLevelToUpload]&&(e._logLevelToUpload=n.config.logLevelToUpload)})),Ft.on(jt.JOIN_START,(function(t){var r=t.params;e.addJoinedUser({userId:r.userId,sdkAppId:r.sdkAppId}),e.startUpload()})),Ft.on(jt.LEAVE_SUCCESS,(function(t){var r=t.room;e.deleteJoinedUser(r.userId)}))}},{key:"startUpload",value:function(){-1===this._timeoutId&&this.uploadInterval()}},{key:"addJoinedUser",value:function(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}},{key:"deleteJoinedUser",value:function(e){this._localJoinedUser.delete(e)}},{key:"uploadInterval",value:function(){var e=this;this.upload().catch((function(){})),this._timeoutId=window.setTimeout((function(){return e.uploadInterval()}),5e3)}},{key:"getLogsToUpload",value:function(){var e=this,t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return t;for(var r=0,n=function(){if(50===r)return 1;var n=e._queue[r];if(n.forAllJoinedClients)e._localJoinedUser.forEach((function(e){var r=e.userId,o=e.sdkAppId;t.map.has(r)?t.map.get(r).logs.push(n):t.map.set(r,{userId:r,sdkAppId:o,logs:[n]})}));else if(Gt(n.userId)&&Qt(n.sdkAppId)){var o=n.userId,i=n.sdkAppId;t.map.has(o)?t.map.get(o).logs.push(n):t.map.set(o,{userId:o,sdkAppId:i,logs:[n]})}};r<this._queue.length&&!n();r++);return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,r)),t}},{key:"upload",value:(t=r(d().mark((function e(){var t,r,n,o,i,a,s,u,c,f,l,h,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.length&&this._isEnableUploadLog){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),r=t.map,n=t.splicedQueue,0!==r.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,o=v(r.values()),i=0;case 8:if(!(i<o.length)){e.next=19;break}return a=o[i],s=a.userId,u=a.sdkAppId,c=a.logs,f={timestamp:(d=void 0,d=new Date,d.setTime(Ae()),d.toLocaleString()),sdkAppId:String(u),userId:s,version:"5.0.0",log:c.map((function(e){return e.log})).join("\n")},l=JSON.stringify(f),h=Nt.enable?Jt(f,2002,u):l,e.next=15,this.uploadLogWithRetry(h,u,h instanceof Uint8Array,l);case 15:c.forEach((function(e){return e.uploaded=!0}));case 16:i++,e.next=8;break;case 19:e.next=23;break;case 21:e.prev=21,e.t0=e.catch(5);case 23:(p=n.filter((function(e){return!e.uploaded}))).length>0&&(this._queue=p.concat(this._queue));case 25:case"end":return e.stop()}var d}),e,this,[[5,21]])}))),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(e,t,r,n){var o=this;return xe({retryFunction:function(){return(i={url:Vt(t,se),body:e,timeout:5e3,priority:"low"},a=i.url,s=i.body,u=i.method,c=void 0===u?"POST":u,f=i.timeout,l=i.priority,new Promise((function(e,t){if("fetch"in window)return fetch(a,{method:c,body:s,priority:l}).then((function(e){return e.clone().json().then((function(e){return{data:e}}),(function(){return e.arrayBuffer().then((function(e){return{data:Se(new Uint8Array(e))||(Oe?Oe.decode(e):e)}}))}))})).then(e,t);var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState)if(r.status>=200&&r.status<300)try{var n=JSON.parse(r.response);e({data:n})}catch(t){e({data:r.response})}else t({status:r.status,statusText:r.statusText||"request failed!"})},r.timeout=f||5e3,r.open(c,a,!0),r.send(s)}))).then((function(e){r&&"ok"!==e.data&&(Nt.handleUploadFailed(),o.uploadLogWithRetry(n,t,!1,n))}));var i,a,s,u,c,f,l},settings:{retries:3,timeout:2e3},onError:function(e){(0,e.retry)()}})()}},{key:"getPrefix",value:function(e){var t,r,n=new Date;return n.setTime(Ae()),"[".concat((t=n,r=String(t.getMilliseconds()),"padStart"in String.prototype&&(r=r.toString().padStart(3,"0")),"".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r)),"] <").concat(ue[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){qt(ue[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}},{key:"enableUploadLog",value:function(){this._isEnableUploadLog=!0}},{key:"disableUploadLog",value:function(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}},{key:"logChunkToString",value:function(e){if(Gt(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(e){return""}}},{key:"addLogToQueue",value:function(e,t){var r=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a={log:t.reduce((function(e,t){return"".concat(e," ").concat(r.logChunkToString(t)).trim()}),""),level:e,userId:o,sdkAppId:i,forAllJoinedClients:n};Ft.emit(jt.LOG,{log:a}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(a)}},{key:"log",value:function(t,r){var n,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,o,i,a),!(t<this._logLevel)){var s,u,c=(null==(n=ue[t])?void 0:n.toLowerCase())||"info";if(e.PRINT_LOG_TAG)(s=console)[c].apply(s,[Bt,$t,Ht].concat(v(r)));else(u=console)[c].apply(u,v(r))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}},{key:"createLogger",value:function(e){if(e.parent instanceof Me){var t=e,r=t.parent,n=function(e,t){var r={};for(var n in e)I.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&P){var o,i=s(P(e));try{for(i.s();!(o=i.n()).done;)n=o.value,t.indexOf(n)<0&&D.call(e,n)&&(r[n]=e[n])}catch(e){i.e(e)}finally{i.f()}}return r}(t,["parent"]),o=new Me(n);return o.bindParent(r),o}return new Me(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;ue[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}]);var t}();F(zt,"PRINT_LOG_TAG",!(Ve||qe||Lt));var Wt=new zt,Vt=function(e,t){var r;r=function(e){return Number(e)<14e8}(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var n=Math.floor(Math.random()*Math.pow(2,31));return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(n,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},qt=function(e){return void 0===e},Gt=function(e){return"string"==typeof e},Qt=function(e){return"number"==typeof e};function Jt(e,t,r,n){try{var o=function(e,t,r,n){var o={data:e,random:Math.floor(Math.random()*Math.pow(2,31)),sdkAppId:r};return qt(n)||(o=x(R({},o),{gzip:NaN})),{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)}}}(e,t,r,n);return ke(ve(o),r)}catch(t){return JSON.stringify(e)}}var Kt=function(){function e(t){o(this,e),this.core=t,F(this,"contextMap",new Map),F(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}return a(e,[{key:"getAlias",value:function(){return"videoDecoder"}},{key:"getGroup",value:function(e){return(null==e?void 0:e.track)?"".concat(e.track.userId).concat(e.track.streamType):"*"}},{key:"getName",value:function(){return e.Name}},{key:"getValidateRule",value:function(e){return{type:this.core.enums.BASIC_TYPE.Object}}},{key:"createDecoder",value:function(e,t){var r;switch(e){case"wasm":var n=(null==(r=this.core.assetsPath)?void 0:r.replace(/\/+$/,""))||".";return new ne(x(R({},t),{wasmPath:"".concat(n,"/videodec.wasm")}));case"webCodecs":return new X;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}},{key:"start",value:function(e){var t=this;this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:function(e){var r,n=e.frame,o=e.track;return(null==(r=t.decodeProcessorMap.get(o))?void 0:r({frame:n,track:o}))||n},type:3})}},{key:"decode",value:function(e){var t=this,r=this.core.rx,n=r.pipe,o=r.take,i=r.subscribe;return function(r){var a=r.frame,s=r.track;if(s!==e.track||"empty"===a.type)return a;if(t.contextMap.has(s))return t.contextMap.get(s).decode(a);var u=t.core.room.videoManager.createDecodeContext(x(R({},e),{createDecoder:t.createDecoder}));return n(u.trackDoneOB,o(1),i((function(){t.core.clearStarted(t,t.getGroup(e)),t.stop({track:s})}))),t.contextMap.set(s,u),u.decode(a)}}},{key:"stop",value:function(e){var t=this;if(null==e?void 0:e.track){var r=this.contextMap.get(e.track);r&&(r.close("stop"),this.report(r,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach((function(e,r){e.close("stop"),t.contextMap.delete(r)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}},{key:"report",value:function(e,t){if(!e.isReported){e.isReported=!0;var r=(performance&&performance.now?Math.floor(performance.now()):Date.now())-e.startPerformanceTime,n=this.getRemoteTrackFreezeDuration(t,e),o=n.renderFreezeTotal,i=n.dataFreezeTotal,a="report health data: ".concat(e.track.userId," ").concat(e.track.streamType," ").concat(e.type,"+").concat(e.renderer," goodType:").concat(e.goodType," ").concat(e.failedReason?"failedReason: ".concat(e.failedReason):"");r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(o/r*100),split:1,max:100}),a+=" RENDER_FREEZE_RATE: ".concat(Math.floor(o/r*100),"%")),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(i/r*100),split:1,max:100}),a+=" DATA_FREEZE_RATE: ".concat(Math.floor(i/r*100),"%")),e.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100}),a+=" VIDEO_CONSUME_RENDER_RATE: ".concat(Math.floor(e.decodedFrameCount/e.inputFrameCount*100),"%")),this.core.log.info(a)}}},{key:"addKVReportBeforeExitRoom",value:function(e){var t=this;e.room===this.core.room&&this.contextMap.forEach((function(e,r){t.report(e,r)}))}},{key:"update",value:function(e){var t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(x(R({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}},{key:"getRemoteTrackFreezeDuration",value:function(e,t){var r=this.core.room.badCaseDetector.getDataFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),n=this.core.room.badCaseDetector.getRenderFreezeDuration("".concat(e.userId,"_").concat(e.streamType)),o=0;return r&&r.durationItemList.forEach((function(e){e.startTime>t.startPerformanceTime&&(o+=e.getDuration())})),{renderFreezeTotal:n,dataFreezeTotal:o}}},{key:"destroy",value:function(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}}])}();return F(Kt,"Name","TRTCVideoDecoder"),Kt}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTCVideoDecoder=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function r(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function s(e){t(a,o,i,s,u,"next",e)}function u(e){t(a,o,i,s,u,"throw",e)}s(void 0)}))}}function n(e,t,r){return t=c(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,r||[],c(e).constructor):t.apply(e,r))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=g(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function u(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(){d=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),s=new D(n||[]);return o(a,"_invoke",{value:C(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",v="executing",m="completed",y={};function g(){}function w(){}function E(){}var b={};c(b,a,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(L([])));k&&k!==r&&n.call(k,a)&&(b=k);var T=E.prototype=g.prototype=Object.create(b);function A(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,i,a,s){var u=l(e[o],e,i);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function C(t,r,n){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var u=P(s,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var c=l(t,r,n);if("normal"===c.type){if(o=n.done?m:p,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=m,n.method="throw",n.arg=c.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return w.prototype=E,o(T,"constructor",{value:E,configurable:!0}),o(E,"constructor",{value:w,configurable:!0}),w.displayName=c(E,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,c(e,u,"GeneratorFunction")),e.prototype=Object.create(T),e},t.awrap=function(e){return{__await:e}},A(S.prototype),c(S.prototype,s,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new S(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},A(T),c(T,u,"Generator"),c(T,a,(function(){return this})),c(T,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t);else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||g(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function g(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function w(e){var t="function"==typeof Map?new Map:void 0;return w=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&h(o,r.prototype),o}(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},w(e)}var E,b,_=Object.create,k=Object.defineProperty,T=Object.defineProperties,A=Object.getOwnPropertyDescriptor,S=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,O=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,L=function(e,t,r){return t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},R=function(e,t){for(var r in t||(t={}))I.call(t,r)&&L(e,r,t[r]);if(P){var n,o=s(P(t));try{for(o.s();!(n=o.n()).done;){r=n.value;D.call(t,r)&&L(e,r,t[r])}}catch(e){o.e(e)}finally{o.f()}}return e},x=function(e,t){return T(e,S(t))},M=function(e,t,r){return r=null!=e?_(O(e)):{},function(e,t,r,n){if(t&&"object"===y(t)||"function"==typeof t){var o,i=s(C(t));try{var a=function(){var i=o.value;I.call(e,i)||i===r||k(e,i,{get:function(){return t[i]},enumerable:!(n=A(t,i))||n.enumerable})};for(i.s();!(o=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}}return e}(k(r,"default",{value:e,enumerable:!0}),e)},U=function(e,t,r,n){for(var o,i=A(t,r),a=e.length-1;a>=0;a--)(o=e[a])&&(i=o(t,r,i)||i);return i&&k(t,r,i),i},F=function(e,t,r){return L(e,"symbol"!==y(t)?t+"":t,r)},j=(E={"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js":function(e,t){var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function s(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,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},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,a){var s=n?n+e:e;if(!this._events[s])return!1;var u,c,f=this._events[s],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,i),!0;case 6:return f.fn.call(f.context,t,r,o,i,a),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var d,h=f.length;for(c=0;c<h;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,r);break;case 4:f[c].fn.call(f[c].context,t,r,o);break;default:if(!u)for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];f[c].fn.apply(f[c].context,u)}}return!0},u.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return a(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 s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var u=0,c=[],f=a.length;u<f;u++)(a[u].fn!==t||o&&!a[u].once||r&&a[u].context!==r)&&c.push(a[u]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(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)}},function(){return b||(0,E[C(E)[0]])((b={exports:{}}).exports,b),b.exports}),N=M(j()),B=Symbol("instance"),$=Symbol("cacheResult"),H=function(){return a((function e(t,r,n){o(this,e),this.oldState=t,this.newState=r,this.action=n,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,J.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),z=function(e){function t(e,r,i){var a;return o(this,t),(a=n(this,t,[r])).state=e,a.message=r,a.cause=i,a}return f(t,e),a(t)}(w(Error));var W=new Map;function V(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n,o,i){var a=r.action||o;if(!r.context){var s=W.get(n)||[];W.has(n)||W.set(n,s),s.push({from:e,to:t,action:a})}var u=i.value;i.value=function(){for(var n,o=this,i=this,s=arguments.length,c=new Array(s),f=0;f<s;f++)c[f]=arguments[f];r.context&&(i=K.get("function"==typeof r.context?(n=r.context).call.apply(n,[this].concat(c)):r.context));if(i.state===t)return r.sync?i[$]:Promise.resolve(i[$]);i.state instanceof H&&i.state.action==r.abortAction&&i.state.abort(i);var l=null;Array.isArray(e)?0==e.length?i.state instanceof H&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(l=new z(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new z(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));var d=function(e){if(r.fail&&r.fail.call(o,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);var h=i.state,p=new H(h,t,a);J.call(i,p);var v,m=function(e){var n;return i[$]=e,p.aborted||(J.call(i,t),null===(n=r.success)||void 0===n||n.call(o,i[$])),e},g=function(e){return J.call(i,h,e),d(e)};try{var w=u.apply(this,c);return"object"===y(v=w)&&v&&"then"in v?w.then(m).catch(g):r.sync?m(w):Promise.resolve(m(w))}catch(r){return g(new z(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(r),r instanceof Error?r:new Error(String(r))))}}}}var q,G,Q=(q="undefined"!=typeof window&&window.__AFSM__,G="undefined"!=typeof importScripts,q?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:G?function(e,t){postMessage({type:e,payload:t})}:function(){});function J(e,t){var r=this._state;this._state=e;var n=e.toString();e&&this.emit(n,r),this.emit(K.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var K=function(e){function t(e,r,i){var a;o(this,t),(a=n(this,t)).name=e,a.groupName=r,a._state=t.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(a,i):i=Object.getPrototypeOf(a),r||(a.groupName=a.constructor.name);var s=i[B];return s?a.name=s.name+"-"+s.count++:i[B]={name:a.name,count:0},a.updateDevTools({diagram:a.stateDiagram}),a}return f(t,e),a(t,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=W.get(e)||[],r=new Set,n=[],o=[],i=new Set,a=Object.getPrototypeOf(e);W.has(a)&&(a.stateDiagram.forEach((function(e){return r.add(e)})),a.allStates.forEach((function(e){return i.add(e)}))),t.forEach((function(e){var t=e.from,r=e.to,i=e.action;"string"==typeof t?n.push({from:t,to:r,action:i}):t.length?t.forEach((function(e){n.push({from:e,to:r,action:i})})):o.push({to:r,action:i})})),n.forEach((function(e){var t=e.from,n=e.to,o=e.action;i.add(t),i.add(n),i.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(n," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((function(e){var t=e.to,n=e.action;r.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🟢")),i.forEach((function(e){e!==t&&r.add("".concat(e," --\x3e ").concat(n,"ing : ").concat(n))}))}));var s=v(r);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:i}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Q(t.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){J.call(this,e)}}],[{key:"get",value:function(e){var r;return"string"==typeof e?(r=t.instances.get(e))||t.instances.set(e,r=new t(e,void 0,Object.create(t.prototype))):(r=t.instances2.get(e))||t.instances2.set(e,r=new t(e.constructor.name,void 0,Object.create(t.prototype))),r}},{key:"getState",value:function(e){var r;return null===(r=t.get(e))||void 0===r?void 0:r.state}}])}(N.default);K.STATECHANGED="stateChanged",K.UPDATEAFSM="updateAFSM",K.INIT="[*]",K.ON="on",K.OFF="off",K.instances=new Map,K.instances2=new WeakMap;var X=function(e){function t(){var e;return o(this,t),e=n(this,t,arguments),F(e,"decoder"),F(e,"config"),e}return f(t,e),a(t,[{key:"initialize",value:(i=r(d().mark((function e(){var t=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.decoder=new VideoDecoder({output:function(e){t.emit("videoFrame",e)},error:function(e){t.close(),t.emit("error",e)}});case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"configure",value:function(e){this.config=e,this.decoder.configure(x(R({},e),{codec:this.getCodec(e)}))}},{key:"getCodec",value:function(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}}},{key:"decode",value:function(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}},{key:"flush",value:function(){this.decoder.flush()}},{key:"reset",value:function(){this.decoder.reset()}},{key:"close",value:function(){"closed"!==this.decoder.state&&this.decoder.close()}}]);var i}(K);function Y(){var e;self.onmessage=function(t){if("init"===t.data.type){var r=t.data,n=r.canvas,o=r.wasmScript,i=r.wasmBinary,a=null==n?void 0:n.getContext("2d"),s=0,u=0,c={wasmBinary:i,postRun:function(){e=new c.VideoDecoder({videoInfo:function(e,t){s=e,u=t,console.log("video info",e,t)},yuvData:function(e,t){var r=s*u,o=r>>2,i=c.HEAPU32[e>>2],f=c.HEAPU32[1+(e>>2)],l=c.HEAPU32[2+(e>>2)],d=c.HEAPU8.subarray(i,i+r),h=c.HEAPU8.subarray(f,f+o),p=c.HEAPU8.subarray(l,l+o),v=new Uint8Array(r+o+o);v.set(d),v.set(h,r),v.set(p,r+o);var m=new VideoFrame(v,{codedWidth:s,codedHeight:u,format:"I420",timestamp:t});n?(null==a||a.drawImage(m,0,0,n.width,n.height),null==a||a.commit()):self.postMessage({type:"yuvData",videoFrame:m},[m])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+o)()(c)}else if("decode"===t.data.type){var f=t.data.packet;null==e||e.decode(f.data,"key"==f.type,f.timestamp)}else if("setCodec"===t.data.type){var l=t.data,d=l.codec,h=l.format,p=l.description;null==e||e.setCodec(d,h,null!=p?p:"")}}}U([V([K.INIT,"closed"],"initialized")],X.prototype,"initialize"),U([V("initialized","configured",{sync:!0})],X.prototype,"configure"),U([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){var o=n.value,i=r;n.value=function(){if(!t.includes(this.state.toString()))throw new z(this.state,"".concat(this.name," ").concat(i," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return o.apply(this,r)}}}("configured")],X.prototype,"decode"),U([V([],K.INIT,{sync:!0})],X.prototype,"reset"),U([V([],"closed",{ignoreError:!0,sync:!0})],X.prototype,"close");var Z=function(e){function t(e,r){var i,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3?arguments[3]:void 0,u=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return o(this,t),(i=n(this,t)).createModule=e,i.wasmBinary=r,i.workerMode=a,i.canvas=s,i.yuvMode=u,F(i,"worker"),F(i,"decoder"),F(i,"config"),F(i,"module",{}),F(i,"width",0),F(i,"height",0),i}return f(t,e),a(t,[{key:"initialize",value:(i=r(d().mark((function e(t){var r,n,o,i,a,s=this;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.workerMode){e.next=10;break}return n=new RegExp("\\{(.+)\\}","s").exec(Y.toString())[1],this.worker=new Worker(URL.createObjectURL(new Blob([n],{type:"text/javascript"}))),o=null==(r=this.canvas)?void 0:r.transferControlToOffscreen(),e.next=6,this.wasmBinary;case 6:return i=e.sent,console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:o,wasmScript:this.createModule.toString(),wasmBinary:i},o?[o,i]:[i]),e.abrupt("return",new Promise((function(e){s.worker.onmessage=function(t){if("ready"===t.data.type)delete s.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){var r=t.data.videoFrame;s.emit("videoFrame",r)}}})));case 10:if(a=this.module,!this.wasmBinary){e.next=15;break}return e.next=14,this.wasmBinary;case 14:a.wasmBinary=e.sent;case 15:return a.print=function(e){return console.log(e)},a.printErr=function(e){return console.log("[JS] ERROR: ".concat(e))},a.onAbort=function(){return console.log("[JS] FATAL: WASM ABORTED")},e.abrupt("return",new Promise((function(e){a.postRun=function(t){s.decoder=new s.module.VideoDecoder(s),console.log("video soft decoder initialize success"),e()},t&&Object.assign(a,t),s.createModule(a)})));case 19:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"configure",value:function(e){var t,r,n;this.config=e;var 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})}},{key:"decode",value:function(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}))}},{key:"flush",value:function(){}},{key:"reset",value:function(){this.config=void 0,this.decoder&&this.decoder.clear()}},{key:"close",value:function(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}},{key:"videoInfo",value:function(e,t){this.width=e,this.height=t;var r={width:e,height:t};this.emit("videoCodecInfo",r)}},{key:"yuvData",value:function(e,t){if(this.module){var r=this.width*this.height,n=r>>2,o=this.module.HEAPU32[e>>2],i=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+r),u=this.module.HEAPU8.subarray(i,i+n),c=this.module.HEAPU8.subarray(a,a+n);if(this.yuvMode)this.emit("videoFrame",{y:s,u:u,v:c,timestamp:t});else{var f=new Uint8Array(r+n+n);f.set(s),f.set(u,r),f.set(c,r+n),this.emit("videoFrame",new VideoFrame(f,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}}}},{key:"errorInfo",value:function(e){var t={errMsg:e};this.emit("error",t)}}]);var i}(K);U([V([K.INIT,"closed"],"initialized")],Z.prototype,"initialize"),U([V("initialized","configured",{sync:!0})],Z.prototype,"configure"),U([V([],K.INIT,{sync:!0})],Z.prototype,"reset"),U([V([],"closed",{sync:!0})],Z.prototype,"close");var ee,te=(ee="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r;i.ready=new Promise((function(r,n){e=r,t=n}));var s=Object.assign({},i),c="./this.program",l="object"==("undefined"==typeof window?"undefined":y(window)),d="function"==typeof importScripts;"object"==("undefined"==typeof process?"undefined":y(process))&&"object"==y(process.versions)&&process.versions.node;var h,p,v,m="";(l||d)&&(d?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),ee&&(m=ee),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",h=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(v=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),p=function(e,t,r){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var g,E,b,_=i.print||console.log.bind(console),k=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(c=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(g=i.wasmBinary),i.noExitRuntime,"object"!=("undefined"==typeof WebAssembly?"undefined":y(WebAssembly))&&G("no native wasm support detected");var T,A,S,C,P,O,I,D,L,R=!1,x=[],M=[],U=[];function F(e){x.unshift(e)}function j(e){U.unshift(e)}var N,B,$,H,z=0,W=null;function V(e){z++,i.monitorRunDependencies&&i.monitorRunDependencies(z)}function q(e){if(z--,i.monitorRunDependencies&&i.monitorRunDependencies(z),0==z&&W){var t=W;W=null,t()}}function G(e){i.onAbort&&i.onAbort(e),k(e="Aborted("+e+")"),R=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw t(r),r}function Q(e){return e.startsWith("data:application/octet-stream;base64,")}function J(e){if(e==N&&g)return new Uint8Array(g);if(v)return v(e);throw"both async and sync fetching of the wasm failed"}function K(e,t,r){return function(e){return g||!l&&!d||"function"!=typeof fetch?Promise.resolve().then((function(){return J(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return J(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(r,(function(e){k("failed to asynchronously prepare wasm: "+e),G(e)}))}Q(N="videodec.wasm")||(B=N,N=i.locateFile?i.locateFile(B,m):m+B);var X=function(e){for(;e.length>0;)e.shift()(i)};function Y(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){O[this.ptr+4>>2]=e},this.get_type=function(){return O[this.ptr+4>>2]},this.set_destructor=function(e){O[this.ptr+8>>2]=e},this.get_destructor=function(){return O[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,T[this.ptr+12|0]=e},this.get_caught=function(){return 0!=T[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,T[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=T[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){O[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return O[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Zt(this.get_type()))return O[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var Z={isAbs:function(e){return"/"===e.charAt(0)},splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(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:function(e){var t=Z.isAbs(e),r="/"===e.substr(-1);return(e=Z.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:function(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:function(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:function(e,t){return Z.normalize(e+"/"+t)}},te=function(e){return(te=function(){if("object"==("undefined"==typeof crypto?"undefined":y(crypto))&&"function"==typeof crypto.getRandomValues)return function(e){return crypto.getRandomValues(e)};G("initRandomDevice")}())(e)},re={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:ve.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((function(e){return!!e})),!t).join("/"))||"."},relative:function(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=re.resolve(e).substr(1),t=re.resolve(t).substr(1);for(var n=r(e.split("/")),o=r(t.split("/")),i=Math.min(n.length,o.length),a=i,s=0;s<i;s++)if(n[s]!==o[s]){a=s;break}var u=[];for(s=a;s<n.length;s++)u.push("..");return(u=u.concat(o.slice(a))).join("/")}},ne="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,oe=function(e,t,r){for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&ne)return ne.decode(e.subarray(t,o));for(var i="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var u=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i},ie=[],ae=function(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},se=function(e,t,r,n){if(!(n>0))return 0;for(var o=r,i=r+n-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(r>=i)break;t[r++]=s}else if(s<=2047){if(r+1>=i)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=i)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=i)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o};function ue(e,t,r){var n=ae(e)+1,o=new Array(n),i=se(e,o,0,o.length);return o.length=i,o}var ce={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){ce.ttys[e]={input:[],output:[],ops:t},ve.registerDevice(e,ce.stream_ops)},stream_ops:{open:function(e){var t=ce.ttys[e.node.rdev];if(!t)throw new ve.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 ve.ErrnoError(60);for(var i=0,a=0;a<n;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new ve.ErrnoError(29)}if(void 0===s&&0===i)throw new ve.ErrnoError(6);if(null==s)break;i++,t[r+a]=s}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 ve.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,t[r+i])}catch(e){throw new ve.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){return function(){if(!ie.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;ie=ue(e)}return ie.shift()}()},put_char:function(e,t){null===t||10===t?(_(oe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(_(oe(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?(k(oe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(k(oe(e.output,0)),e.output=[])}}},fe=function(e){G()},le={ops_table:null,mount:function(e){return le.createNode(null,"/",16895,0)},createNode:function(e,t,r,n){if(ve.isBlkdev(r)||ve.isFIFO(r))throw new ve.ErrnoError(63);le.ops_table||(le.ops_table={dir:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,lookup:le.node_ops.lookup,mknod:le.node_ops.mknod,rename:le.node_ops.rename,unlink:le.node_ops.unlink,rmdir:le.node_ops.rmdir,readdir:le.node_ops.readdir,symlink:le.node_ops.symlink},stream:{llseek:le.stream_ops.llseek}},file:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:{llseek:le.stream_ops.llseek,read:le.stream_ops.read,write:le.stream_ops.write,allocate:le.stream_ops.allocate,mmap:le.stream_ops.mmap,msync:le.stream_ops.msync}},link:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr,readlink:le.node_ops.readlink},stream:{}},chrdev:{node:{getattr:le.node_ops.getattr,setattr:le.node_ops.setattr},stream:ve.chrdev_stream_ops}});var o=ve.createNode(e,t,r,n);return ve.isDir(o.mode)?(o.node_ops=le.ops_table.dir.node,o.stream_ops=le.ops_table.dir.stream,o.contents={}):ve.isFile(o.mode)?(o.node_ops=le.ops_table.file.node,o.stream_ops=le.ops_table.file.stream,o.usedBytes=0,o.contents=null):ve.isLink(o.mode)?(o.node_ops=le.ops_table.link.node,o.stream_ops=le.ops_table.link.stream):ve.isChrdev(o.mode)&&(o.node_ops=le.ops_table.chrdev.node,o.stream_ops=le.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(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:function(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:function(e){var t={};return t.dev=ve.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,ve.isDir(e.mode)?t.size=4096:ve.isFile(e.mode)?t.size=e.usedBytes:ve.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:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&le.resizeFileStorage(e,t.size)},lookup:function(e,t){throw ve.genericErrors[44]},mknod:function(e,t,r,n){return le.createNode(e,t,r,n)},rename:function(e,t,r){if(ve.isDir(e.mode)){var n;try{n=ve.lookupNode(t,r)}catch(e){}if(n)for(var o in n.contents)throw new ve.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:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){var r=ve.lookupNode(e,t);for(var n in r.contents)throw new ve.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink:function(e,t,r){var n=le.createNode(e,t,41471,0);return n.link=r,n},readlink:function(e){if(!ve.isLink(e.mode))throw new ve.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,r,n,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(a>8&&i.subarray)t.set(i.subarray(o,o+a),r);else for(var s=0;s<a;s++)t[r+s]=i[o+s];return a},write:function(e,t,r,n,o,i){if(!n)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(i)return a.contents=t.subarray(r,r+n),a.usedBytes=n,n;if(0===a.usedBytes&&0===o)return a.contents=t.slice(r,r+n),a.usedBytes=n,n;if(o+n<=a.usedBytes)return a.contents.set(t.subarray(r,r+n),o),n}if(le.expandFileStorage(a,o+n),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(r,r+n),o);else for(var s=0;s<n;s++)a.contents[o+s]=t[r+s];return a.usedBytes=Math.max(a.usedBytes,o+n),n},llseek:function(e,t,r){var n=t;if(1===r?n+=e.position:2===r&&ve.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new ve.ErrnoError(28);return n},allocate:function(e,t,r){le.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap:function(e,t,r,n,o){if(!ve.isFile(e.node.mode))throw new ve.ErrnoError(43);var i,a,s=e.node.contents;if(2&o||s.buffer!==T.buffer){if((r>0||r+t<s.length)&&(s=s.subarray?s.subarray(r,r+t):Array.prototype.slice.call(s,r,r+t)),a=!0,!(i=fe()))throw new ve.ErrnoError(48);T.set(s,i)}else a=!1,i=s.byteOffset;return{ptr:i,allocated:a}},msync:function(e,t,r,n,o){return le.stream_ops.write(e,t,0,n,r,!1),0}}},de=function(e,t,r,n){var o="al ".concat(e);p(e,(function(r){var n,i;n=r,i='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),n||G(i),t(new Uint8Array(r)),o&&q()}),(function(t){if(!r)throw'Loading data file "'.concat(e,'" failed.');r()})),o&&V()},he=i.preloadPlugins||[];function pe(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ve={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=re.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ve.ErrnoError(32);for(var r=e.split("/").filter((function(e){return!!e})),n=ve.root,o="/",i=0;i<r.length;i++){var a=i===r.length-1;if(a&&t.parent)break;if(n=ve.lookupNode(n,r[i]),o=Z.join2(o,r[i]),ve.isMountpoint(n)&&(!a||a&&t.follow_mount)&&(n=n.mounted.root),!a||t.follow)for(var s=0;ve.isLink(n.mode);){var u=ve.readlink(o);if(o=re.resolve(Z.dirname(o),u),n=ve.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new ve.ErrnoError(32)}}return{path:o,node:n}},getPath:function(e){for(var t;;){if(ve.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:function(e,t){for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%ve.nameTable.length},hashAddNode:function(e){var t=ve.hashName(e.parent.id,e.name);e.name_next=ve.nameTable[t],ve.nameTable[t]=e},hashRemoveNode:function(e){var t=ve.hashName(e.parent.id,e.name);if(ve.nameTable[t]===e)ve.nameTable[t]=e.name_next;else for(var r=ve.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:function(e,t){var r=ve.mayLookup(e);if(r)throw new ve.ErrnoError(r,e);for(var n=ve.hashName(e.id,t),o=ve.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===t)return o}return ve.lookup(e,t)},createNode:function(e,t,r,n){var o=new ve.FSNode(e,t,r,n);return ve.hashAddNode(o),o},destroyNode:function(e){ve.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return!(49152&~e)},flagsToPermissionString:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:function(e,t){return ve.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2},mayLookup:function(e){var t=ve.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:function(e,t){try{return ve.lookupNode(e,t),20}catch(e){}return ve.nodePermissions(e,"wx")},mayDelete:function(e,t,r){var n;try{n=ve.lookupNode(e,t)}catch(e){return e.errno}var o=ve.nodePermissions(e,"wx");if(o)return o;if(r){if(!ve.isDir(n.mode))return 54;if(ve.isRoot(n)||ve.getPath(n)===ve.cwd())return 10}else if(ve.isDir(n.mode))return 31;return 0},mayOpen:function(e,t){return e?ve.isLink(e.mode)?32:ve.isDir(e.mode)&&("r"!==ve.flagsToPermissionString(t)||512&t)?31:ve.nodePermissions(e,ve.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd:function(){for(var e=0;e<=ve.MAX_OPEN_FDS;e++)if(!ve.streams[e])return e;throw new ve.ErrnoError(33)},getStreamChecked:function(e){var t=ve.getStream(e);if(!t)throw new ve.ErrnoError(8);return t},getStream:function(e){return ve.streams[e]},createStream:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return ve.FSStream||(ve.FSStream=function(){this.shared={}},ve.FSStream.prototype={},Object.defineProperties(ve.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return!!(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new ve.FSStream,e),-1==t&&(t=ve.nextfd()),e.fd=t,ve.streams[t]=e,e},closeStream:function(e){ve.streams[e]=null},chrdev_stream_ops:{open:function(e){var t=ve.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new ve.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,t){return e<<8|t},registerDevice:function(e,t){ve.devices[e]={stream_ops:t}},getDevice:function(e){return ve.devices[e]},getMounts:function(e){for(var t=[],r=[e];r.length;){var n=r.pop();t.push(n),r.push.apply(r,n.mounts)}return t},syncfs:function(e,t){"function"==typeof e&&(t=e,e=!1),ve.syncFSRequests++,ve.syncFSRequests>1&&k("warning: ".concat(ve.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=ve.getMounts(ve.root.mount),n=0;function o(e){return ve.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((function(t){if(!t.type.syncfs)return i(null);t.type.syncfs(t,e,i)}))},mount:function(e,t,r){var n,o="/"===r,i=!r;if(o&&ve.root)throw new ve.ErrnoError(10);if(!o&&!i){var a=ve.lookupPath(r,{follow_mount:!1});if(r=a.path,n=a.node,ve.isMountpoint(n))throw new ve.ErrnoError(10);if(!ve.isDir(n.mode))throw new ve.ErrnoError(54)}var s={type:e,opts:t,mountpoint:r,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,o?ve.root=u:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),u},unmount:function(e){var t=ve.lookupPath(e,{follow_mount:!1});if(!ve.isMountpoint(t.node))throw new ve.ErrnoError(28);var r=t.node,n=r.mounted,o=ve.getMounts(n);Object.keys(ve.nameTable).forEach((function(e){for(var t=ve.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ve.destroyNode(t),t=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var n=ve.lookupPath(e,{parent:!0}).node,o=Z.basename(e);if(!o||"."===o||".."===o)throw new ve.ErrnoError(28);var i=ve.mayCreate(n,o);if(i)throw new ve.ErrnoError(i);if(!n.node_ops.mknod)throw new ve.ErrnoError(63);return n.node_ops.mknod(n,o,t,r)},create:function(e,t){return t=void 0!==t?t:438,t&=4095,t|=32768,ve.mknod(e,t,0)},mkdir:function(e,t){return t=void 0!==t?t:511,t&=1023,t|=16384,ve.mknod(e,t,0)},mkdirTree:function(e,t){for(var r=e.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{ve.mkdir(n,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:function(e,t,r){return void 0===r&&(r=t,t=438),t|=8192,ve.mknod(e,t,r)},symlink:function(e,t){if(!re.resolve(e))throw new ve.ErrnoError(44);var r=ve.lookupPath(t,{parent:!0}).node;if(!r)throw new ve.ErrnoError(44);var n=Z.basename(t),o=ve.mayCreate(r,n);if(o)throw new ve.ErrnoError(o);if(!r.node_ops.symlink)throw new ve.ErrnoError(63);return r.node_ops.symlink(r,n,e)},rename:function(e,t){var r,n,o=Z.dirname(e),i=Z.dirname(t),a=Z.basename(e),s=Z.basename(t);if(r=ve.lookupPath(e,{parent:!0}).node,n=ve.lookupPath(t,{parent:!0}).node,!r||!n)throw new ve.ErrnoError(44);if(r.mount!==n.mount)throw new ve.ErrnoError(75);var u,c=ve.lookupNode(r,a),f=re.relative(e,i);if("."!==f.charAt(0))throw new ve.ErrnoError(28);if("."!==(f=re.relative(t,o)).charAt(0))throw new ve.ErrnoError(55);try{u=ve.lookupNode(n,s)}catch(e){}if(c!==u){var l=ve.isDir(c.mode),d=ve.mayDelete(r,a,l);if(d)throw new ve.ErrnoError(d);if(d=u?ve.mayDelete(n,s,l):ve.mayCreate(n,s))throw new ve.ErrnoError(d);if(!r.node_ops.rename)throw new ve.ErrnoError(63);if(ve.isMountpoint(c)||u&&ve.isMountpoint(u))throw new ve.ErrnoError(10);if(n!==r&&(d=ve.nodePermissions(r,"w")))throw new ve.ErrnoError(d);ve.hashRemoveNode(c);try{r.node_ops.rename(c,n,s)}catch(e){throw e}finally{ve.hashAddNode(c)}}},rmdir:function(e){var t=ve.lookupPath(e,{parent:!0}).node,r=Z.basename(e),n=ve.lookupNode(t,r),o=ve.mayDelete(t,r,!0);if(o)throw new ve.ErrnoError(o);if(!t.node_ops.rmdir)throw new ve.ErrnoError(63);if(ve.isMountpoint(n))throw new ve.ErrnoError(10);t.node_ops.rmdir(t,r),ve.destroyNode(n)},readdir:function(e){var t=ve.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ve.ErrnoError(54);return t.node_ops.readdir(t)},unlink:function(e){var t=ve.lookupPath(e,{parent:!0}).node;if(!t)throw new ve.ErrnoError(44);var r=Z.basename(e),n=ve.lookupNode(t,r),o=ve.mayDelete(t,r,!1);if(o)throw new ve.ErrnoError(o);if(!t.node_ops.unlink)throw new ve.ErrnoError(63);if(ve.isMountpoint(n))throw new ve.ErrnoError(10);t.node_ops.unlink(t,r),ve.destroyNode(n)},readlink:function(e){var t=ve.lookupPath(e).node;if(!t)throw new ve.ErrnoError(44);if(!t.node_ops.readlink)throw new ve.ErrnoError(28);return re.resolve(ve.getPath(t.parent),t.node_ops.readlink(t))},stat:function(e,t){var r=ve.lookupPath(e,{follow:!t}).node;if(!r)throw new ve.ErrnoError(44);if(!r.node_ops.getattr)throw new ve.ErrnoError(63);return r.node_ops.getattr(r)},lstat:function(e){return ve.stat(e,!0)},chmod:function(e,t,r){var n;if(!(n="string"==typeof e?ve.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&t|-4096&n.mode,timestamp:Date.now()})},lchmod:function(e,t){ve.chmod(e,t,!0)},fchmod:function(e,t){var r=ve.getStreamChecked(e);ve.chmod(r.node,t)},chown:function(e,t,r,n){var o;if(!(o="string"==typeof e?ve.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(e,t,r){ve.chown(e,t,r,!0)},fchown:function(e,t,r){var n=ve.getStreamChecked(e);ve.chown(n.node,t,r)},truncate:function(e,t){if(t<0)throw new ve.ErrnoError(28);var r;if(!(r="string"==typeof e?ve.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ve.ErrnoError(63);if(ve.isDir(r.mode))throw new ve.ErrnoError(31);if(!ve.isFile(r.mode))throw new ve.ErrnoError(28);var n=ve.nodePermissions(r,"w");if(n)throw new ve.ErrnoError(n);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:function(e,t){var r=ve.getStreamChecked(e);if(!(2097155&r.flags))throw new ve.ErrnoError(28);ve.truncate(r.node,t)},utime:function(e,t,r){var n=ve.lookupPath(e,{follow:!0}).node;n.node_ops.setattr(n,{timestamp:Math.max(t,r)})},open:function(e,t,r){if(""===e)throw new ve.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: ".concat(e));return t}(t):t)?4095&r|32768:0,"object"==y(e))n=e;else{e=Z.normalize(e);try{n=ve.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var o=!1;if(64&t)if(n){if(128&t)throw new ve.ErrnoError(20)}else n=ve.mknod(e,r,0),o=!0;if(!n)throw new ve.ErrnoError(44);if(ve.isChrdev(n.mode)&&(t&=-513),65536&t&&!ve.isDir(n.mode))throw new ve.ErrnoError(54);if(!o){var a=ve.mayOpen(n,t);if(a)throw new ve.ErrnoError(a)}512&t&&!o&&ve.truncate(n,0),t&=-131713;var s=ve.createStream({node:n,path:ve.getPath(n),flags:t,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!i.logReadFiles||1&t||(ve.readFiles||(ve.readFiles={}),e in ve.readFiles||(ve.readFiles[e]=1)),s},close:function(e){if(ve.isClosed(e))throw new ve.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ve.closeStream(e.fd)}e.fd=null},isClosed:function(e){return null===e.fd},llseek:function(e,t,r){if(ve.isClosed(e))throw new ve.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ve.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ve.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:function(e,t,r,n,o){if(n<0||o<0)throw new ve.ErrnoError(28);if(ve.isClosed(e))throw new ve.ErrnoError(8);if(1==(2097155&e.flags))throw new ve.ErrnoError(8);if(ve.isDir(e.node.mode))throw new ve.ErrnoError(31);if(!e.stream_ops.read)throw new ve.ErrnoError(28);var i=void 0!==o;if(i){if(!e.seekable)throw new ve.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,t,r,n,o);return i||(e.position+=a),a},write:function(e,t,r,n,o,i){if(n<0||o<0)throw new ve.ErrnoError(28);if(ve.isClosed(e))throw new ve.ErrnoError(8);if(!(2097155&e.flags))throw new ve.ErrnoError(8);if(ve.isDir(e.node.mode))throw new ve.ErrnoError(31);if(!e.stream_ops.write)throw new ve.ErrnoError(28);e.seekable&&1024&e.flags&&ve.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new ve.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,r,n,o,i);return a||(e.position+=s),s},allocate:function(e,t,r){if(ve.isClosed(e))throw new ve.ErrnoError(8);if(t<0||r<=0)throw new ve.ErrnoError(28);if(!(2097155&e.flags))throw new ve.ErrnoError(8);if(!ve.isFile(e.node.mode)&&!ve.isDir(e.node.mode))throw new ve.ErrnoError(43);if(!e.stream_ops.allocate)throw new ve.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,o){if(2&n&&!(2&o)&&2!=(2097155&e.flags))throw new ve.ErrnoError(2);if(1==(2097155&e.flags))throw new ve.ErrnoError(2);if(!e.stream_ops.mmap)throw new ve.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,o)},msync:function(e,t,r,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,o):0},munmap:function(e){return 0},ioctl:function(e,t,r){if(!e.stream_ops.ioctl)throw new ve.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(r.flags=r.flags||0,r.encoding=r.encoding||"binary","utf8"!==r.encoding&&"binary"!==r.encoding)throw new Error('Invalid encoding type "'.concat(r.encoding,'"'));var n=ve.open(e,r.flags),o=ve.stat(e).size,i=new Uint8Array(o);return ve.read(n,i,0,o,0),"utf8"===r.encoding?t=oe(i,0):"binary"===r.encoding&&(t=i),ve.close(n),t},writeFile:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var n=ve.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(ae(t)+1),i=se(t,o,0,o.length);ve.write(n,o,0,i,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ve.write(n,t,0,t.byteLength,void 0,r.canOwn)}ve.close(n)},cwd:function(){return ve.currentPath},chdir:function(e){var t=ve.lookupPath(e,{follow:!0});if(null===t.node)throw new ve.ErrnoError(44);if(!ve.isDir(t.node.mode))throw new ve.ErrnoError(54);var r=ve.nodePermissions(t.node,"x");if(r)throw new ve.ErrnoError(r);ve.currentPath=t.path},createDefaultDirectories:function(){ve.mkdir("/tmp"),ve.mkdir("/home"),ve.mkdir("/home/web_user")},createDefaultDevices:function(){ve.mkdir("/dev"),ve.registerDevice(ve.makedev(1,3),{read:function(){return 0},write:function(e,t,r,n,o){return n}}),ve.mkdev("/dev/null",ve.makedev(1,3)),ce.register(ve.makedev(5,0),ce.default_tty_ops),ce.register(ve.makedev(6,0),ce.default_tty1_ops),ve.mkdev("/dev/tty",ve.makedev(5,0)),ve.mkdev("/dev/tty1",ve.makedev(6,0));var e=new Uint8Array(1024),t=0,r=function(){return 0===t&&(t=te(e).byteLength),e[--t]};ve.createDevice("/dev","random",r),ve.createDevice("/dev","urandom",r),ve.mkdir("/dev/shm"),ve.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){ve.mkdir("/proc");var e=ve.mkdir("/proc/self");ve.mkdir("/proc/self/fd"),ve.mount({mount:function(){var t=ve.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=+t,n=ve.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return n.path}}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:function(){i.stdin?ve.createDevice("/dev","stdin",i.stdin):ve.symlink("/dev/tty","/dev/stdin"),i.stdout?ve.createDevice("/dev","stdout",null,i.stdout):ve.symlink("/dev/tty","/dev/stdout"),i.stderr?ve.createDevice("/dev","stderr",null,i.stderr):ve.symlink("/dev/tty1","/dev/stderr"),ve.open("/dev/stdin",0),ve.open("/dev/stdout",1),ve.open("/dev/stderr",1)},ensureErrnoError:function(){ve.ErrnoError||(ve.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ve.ErrnoError.prototype=new Error,ve.ErrnoError.prototype.constructor=ve.ErrnoError,[44].forEach((function(e){ve.genericErrors[e]=new ve.ErrnoError(e),ve.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:function(){ve.ensureErrnoError(),ve.nameTable=new Array(4096),ve.mount(le,{},"/"),ve.createDefaultDirectories(),ve.createDefaultDevices(),ve.createSpecialDirectories(),ve.filesystems={MEMFS:le}},init:function(e,t,r){ve.init.initialized=!0,ve.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,ve.createStandardStreams()},quit:function(){ve.init.initialized=!1;for(var e=0;e<ve.streams.length;e++){var t=ve.streams[e];t&&ve.close(t)}},findObject:function(e,t){var r=ve.analyzePath(e,t);return r.exists?r.object:null},analyzePath:function(e,t){try{e=(n=ve.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=ve.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=n.path,r.parentObject=n.node,r.name=Z.basename(e),n=ve.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:function(e,t,r,n){e="string"==typeof e?e:ve.getPath(e);for(var o=t.split("/").reverse();o.length;){var i=o.pop();if(i){var a=Z.join2(e,i);try{ve.mkdir(a)}catch(e){}e=a}}return a},createFile:function(e,t,r,n,o){var i=Z.join2("string"==typeof e?e:ve.getPath(e),t),a=pe(n,o);return ve.create(i,a)},createDataFile:function(e,t,r,n,o,i){var a=t;e&&(e="string"==typeof e?e:ve.getPath(e),a=t?Z.join2(e,t):e);var s=pe(n,o),u=ve.create(a,s);if(r){if("string"==typeof r){for(var c=new Array(r.length),f=0,l=r.length;f<l;++f)c[f]=r.charCodeAt(f);r=c}ve.chmod(u,146|s);var d=ve.open(u,577);ve.write(d,r,0,r.length,0,i),ve.close(d),ve.chmod(u,s)}return u},createDevice:function(e,t,r,n){var o=Z.join2("string"==typeof e?e:ve.getPath(e),t),i=pe(!!r,!!n);ve.createDevice.major||(ve.createDevice.major=64);var a=ve.makedev(ve.createDevice.major++,0);return ve.registerDevice(a,{open:function(e){e.seekable=!1},close:function(e){n&&n.buffer&&n.buffer.length&&n(10)},read:function(e,t,n,o,i){for(var a=0,s=0;s<o;s++){var u;try{u=r()}catch(e){throw new ve.ErrnoError(29)}if(void 0===u&&0===a)throw new ve.ErrnoError(6);if(null==u)break;a++,t[n+s]=u}return a&&(e.node.timestamp=Date.now()),a},write:function(e,t,r,o,i){for(var a=0;a<o;a++)try{n(t[r+a])}catch(e){throw new ve.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),ve.mkdev(o,i,a)},forceLoadFile:function(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(!h)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=ue(h(e.url)),e.usedBytes=e.contents.length}catch(e){throw new ve.ErrnoError(29)}},createLazyFile:function(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,a=1048576;o||(a=n);var s=this;s.setDataGetter((function(e){var t=e*a,o=(e+1)*a-1;if(o=Math.min(o,n-1),void 0===s.chunks[e]&&(s.chunks[e]=function(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!==a&&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||[]):ue(o.responseText||"")}(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!i&&n||(a=n=1,n=this.getter(0).length,a=n,_("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=n,this._chunkSize=a,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 a=new i;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:r};var u=ve.createFile(e,t,s,n,o);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={};function f(e,t,r,n,o){var i=e.node.contents;if(o>=i.length)return 0;var a=Math.min(i.length-o,n);if(i.slice)for(var s=0;s<a;s++)t[r+s]=i[o+s];else for(s=0;s<a;s++)t[r+s]=i.get(o+s);return a}return Object.keys(u.stream_ops).forEach((function(e){var t=u.stream_ops[e];c[e]=function(){return ve.forceLoadFile(u),t.apply(null,arguments)}})),c.read=function(e,t,r,n,o){return ve.forceLoadFile(u),f(e,t,r,n,o)},c.mmap=function(e,t,r,n,o){ve.forceLoadFile(u);var i=fe();if(!i)throw new ve.ErrnoError(48);return f(e,T,i,t,r),{ptr:i,allocated:!0}},u.stream_ops=c,u}},me=function(e,t){return e?oe(A,e,t):""},ye={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(Z.isAbs(t))return t;var n;if(n=-100===e?ve.cwd():ye.getStreamFromFD(e).path,0==t.length){if(!r)throw new ve.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(ve.getPath(e.node)))return-54;throw e}P[r>>2]=n.dev,P[r+4>>2]=n.mode,O[r+8>>2]=n.nlink,P[r+12>>2]=n.uid,P[r+16>>2]=n.gid,P[r+20>>2]=n.rdev,H=[n.size>>>0,($=n.size,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+24>>2]=H[0],P[r+28>>2]=H[1],P[r+32>>2]=4096,P[r+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),a=n.ctime.getTime();return H=[Math.floor(o/1e3)>>>0,($=Math.floor(o/1e3),+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+40>>2]=H[0],P[r+44>>2]=H[1],O[r+48>>2]=o%1e3*1e3,H=[Math.floor(i/1e3)>>>0,($=Math.floor(i/1e3),+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+56>>2]=H[0],P[r+60>>2]=H[1],O[r+64>>2]=i%1e3*1e3,H=[Math.floor(a/1e3)>>>0,($=Math.floor(a/1e3),+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+72>>2]=H[0],P[r+76>>2]=H[1],O[r+80>>2]=a%1e3*1e3,H=[n.ino>>>0,($=n.ino,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[r+88>>2]=H[0],P[r+92>>2]=H[1],0},doMsync:function(e,t,r,n,o){if(!ve.isFile(t.node.mode))throw new ve.ErrnoError(43);if(2&n)return 0;var i=A.slice(e,e+r);ve.msync(t,i,o,r,n)},varargs:void 0,get:function(){return ye.varargs+=4,P[ye.varargs-4>>2]},getStr:function(e){return me(e)},getStreamFromFD:function(e){return ve.getStreamChecked(e)}};function ge(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: ".concat(e))}}var we=void 0;function Ee(e){for(var t="",r=e;A[r];)t+=we[A[r++]];return t}var be={},_e={},ke={},Te=void 0;function Ae(e){throw new Te(e)}var Se=void 0;function Ce(e){throw new Se(e)}function Pe(e,t,r){function n(t){var n=r(t);n.length!==e.length&&Ce("Mismatched type converter count");for(var o=0;o<e.length;++o)Oe(e[o],n[o])}e.forEach((function(e){ke[e]=t}));var o=new Array(t.length),i=[],a=0;t.forEach((function(e,t){_e.hasOwnProperty(e)?o[t]=_e[e]:(i.push(e),be.hasOwnProperty(e)||(be[e]=[]),be[e].push((function(){o[t]=_e[e],++a===i.length&&n(o)})))})),0===i.length&&n(o)}function Oe(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=t.name;if(e||Ae('type "'.concat(n,'" must have a positive integer typeid pointer')),_e.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;Ae("Cannot register type '".concat(n,"' twice"))}if(_e[e]=t,delete ke[e],be.hasOwnProperty(e)){var o=be[e];delete be[e],o.forEach((function(e){return e()}))}}(e,t,r)}function Ie(e){if(!(this instanceof Ye))return!1;if(!(e instanceof Ye))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 De(e){Ae(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Le=!1;function Re(e){}function xe(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 Me(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var n=Me(e,t,r.baseClass);return null===n?null:r.downcast(n)}var Ue={};function Fe(){return Object.keys(ze).length}function je(){var e=[];for(var t in ze)ze.hasOwnProperty(t)&&e.push(ze[t]);return e}var Ne=[];function Be(){for(;Ne.length;){var e=Ne.pop();e.$$.deleteScheduled=!1,e.delete()}}var $e=void 0;function He(e){$e=e,Ne.length&&$e&&$e(Be)}var ze={};function We(e,t){return t=function(e,t){for(void 0===t&&Ae("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),ze[t]}function Ve(e,t){return t.ptrType&&t.ptr||Ce("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&Ce("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ge(Object.create(e,{$$:{value:t}}))}function qe(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=We(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?Ve(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Ve(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i,a=this.registeredClass.getActualType(t),s=Ue[a];if(!s)return o.call(this);i=this.isConst?s.constPointerType:s.pointerType;var u=Me(t,this.registeredClass,i.registeredClass);return null===u?o.call(this):this.isSmartPointer?Ve(i.registeredClass.instancePrototype,{ptrType:i,ptr:u,smartPtrType:this,smartPtr:e}):Ve(i.registeredClass.instancePrototype,{ptrType:i,ptr:u})}var Ge=function(e){return"undefined"==typeof FinalizationRegistry?(Ge=function(e){return e},e):(Le=new FinalizationRegistry((function(e){xe(e.$$)})),Re=function(e){return Le.unregister(e)},(Ge=function(e){var t=e.$$;if(t.smartPtr){var r={$$:t};Le.register(e,r,e)}return e})(e))};function Qe(){if(this.$$.ptr||De(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Ge(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 Je(){this.$$.ptr||De(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Ae("Object already scheduled for deletion"),Re(this),xe(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Ke(){return!this.$$.ptr}function Xe(){return this.$$.ptr||De(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Ae("Object already scheduled for deletion"),Ne.push(this),1===Ne.length&&$e&&$e(Be),this.$$.deleteScheduled=!0,this}function Ye(){}function Ze(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_".concat(e):e}function et(e,t){return u({},e=Ze(e),(function(){return t.apply(this,arguments)}))[e]}function tt(e,t,r){if(void 0===e[t].overloadTable){var n=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||Ae("Function '".concat(r,"' called with an invalid number of arguments (").concat(arguments.length,") - expects one of (").concat(e[t].overloadTable,")!")),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[n.argCount]=n}}function rt(e,t,r,n,o,i,a,s){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function nt(e,t,r){for(;t!==r;)t.upcast||Ae("Expected null or instance of ".concat(r.name,", got an instance of ").concat(t.name)),e=t.upcast(e),t=t.baseClass;return e}function ot(e,t){if(null===t)return this.isReference&&Ae("null is not a valid ".concat(this.name)),0;t.$$||Ae('Cannot pass "'.concat(Pt(t),'" as a ').concat(this.name)),t.$$.ptr||Ae("Cannot pass deleted object as a pointer of type ".concat(this.name));var r=t.$$.ptrType.registeredClass;return nt(t.$$.ptr,r,this.registeredClass)}function it(e,t){var r;if(null===t)return this.isReference&&Ae("null is not a valid ".concat(this.name)),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||Ae('Cannot pass "'.concat(Pt(t),'" as a ').concat(this.name)),t.$$.ptr||Ae("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&t.$$.ptrType.isConst&&Ae("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));var n=t.$$.ptrType.registeredClass;if(r=nt(t.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&Ae("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:Ae("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(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,Ct.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:Ae("Unsupporting sharing policy")}return r}function at(e,t){if(null===t)return this.isReference&&Ae("null is not a valid ".concat(this.name)),0;t.$$||Ae('Cannot pass "'.concat(Pt(t),'" as a ').concat(this.name)),t.$$.ptr||Ae("Cannot pass deleted object as a pointer of type ".concat(this.name)),t.$$.ptrType.isConst&&Ae("Cannot convert argument of type ".concat(t.$$.ptrType.name," to parameter type ").concat(this.name));var r=t.$$.ptrType.registeredClass;return nt(t.$$.ptr,r,this.registeredClass)}function st(e){return this.fromWireType(P[e>>2])}function ut(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function ct(e){this.rawDestructor&&this.rawDestructor(e)}function ft(e){null!==e&&e.delete()}function lt(e,t,r,n,o,i,a,s,u,c,f){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=c,this.rawDestructor=f,o||void 0!==t.baseClass?this.toWireType=it:n?(this.toWireType=ot,this.destructorFunction=null):(this.toWireType=at,this.destructorFunction=null)}var dt=[],ht=function(e){var t=dt[e];return t||(e>=dt.length&&(dt.length=e+1),dt[e]=t=L.get(e)),t},pt=function(e,t,r){return e.includes("j")?function(e,t,r){var n=i["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)}(e,t,r):ht(t).apply(null,r)};function vt(e,t){var r,n,o,i=(e=Ee(e)).includes("j")?(r=e,n=t,o=[],function(){return o.length=0,Object.assign(o,arguments),pt(r,n,o)}):ht(t);return"function"!=typeof i&&Ae("unknown function pointer with signature ".concat(e,": ").concat(t)),i}var mt=void 0;function yt(e){var t=Xt(e),r=Ee(t);return Jt(t),r}function gt(e,t){var r=[],n={};throw t.forEach((function e(t){n[t]||_e[t]||(ke[t]?ke[t].forEach(e):(r.push(t),n[t]=!0))})),new mt("".concat(e,": ")+r.map(yt).join([", "]))}function wt(e,t){for(var r=[],n=0;n<e;n++)r.push(O[t+4*n>>2]);return r}function Et(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function bt(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(y(e)," which is not a function"));var r=et(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var n=new r,o=e.apply(n,t);return o instanceof Object?o:n}function _t(e,t,r,n,o,i){var a=t.length;a<2&&Ae("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=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 f="void"!==t[0].name,l="",d="";for(c=0;c<a-2;++c)l+=(0!==c?", ":"")+"arg"+c,d+=(0!==c?", ":"")+"arg"+c+"Wired";var h="\n return function ".concat(Ze(e),"(").concat(l,") {\n if (arguments.length !== ").concat(a-2,") {\n throwBindingError('function ").concat(e," called with ").concat(arguments.length," arguments, expected ").concat(a-2," args!');\n }");u&&(h+="var destructors = [];\n");var p=u?"destructors":"null",v=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],m=[Ae,n,o,Et,t[0],t[1]];for(s&&(h+="var thisWired = classParam.toWireType("+p+", this);\n"),c=0;c<a-2;++c)h+="var arg"+c+"Wired = argType"+c+".toWireType("+p+", arg"+c+"); // "+t[c+2].name+"\n",v.push("argType"+c),m.push(t[c+2]);if(s&&(d="thisWired"+(d.length>0?", ":"")+d),h+=(f||i?"var rv = ":"")+"invoker(fn"+(d.length>0?", ":"")+d+");\n",u)h+="runDestructors(destructors);\n";else for(c=s?1:2;c<t.length;++c){var y=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(h+=y+"_dtor("+y+"); // "+t[c].name+"\n",v.push(y+"_dtor"),m.push(t[c].destructorFunction))}return f&&(h+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),h+="}\n",v.push(h),bt(Function,v).apply(null,m)}function kt(){this.allocated=[void 0],this.freelist=[]}var Tt=new kt;function At(e){e>=Tt.reserved&&0==--Tt.get(e).refcount&&Tt.free(e)}function St(){for(var e=0,t=Tt.reserved;t<Tt.allocated.length;++t)void 0!==Tt.allocated[t]&&++e;return e}var Ct={toValue:function(e){return e||Ae("Cannot use deleted val. handle = "+e),Tt.get(e).value},toHandle:function(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Tt.allocate({refcount:1,value:e})}}};function Pt(e){if(null===e)return"null";var t=y(e);return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Ot(e,t){switch(t){case 2:return function(e){return this.fromWireType(I[e>>2])};case 3:return function(e){return this.fromWireType(D[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function It(e,t,r){switch(t){case 0:return r?function(e){return T[e]}:function(e){return A[e]};case 1:return r?function(e){return S[e>>1]}:function(e){return C[e>>1]};case 2:return r?function(e){return P[e>>2]}:function(e){return O[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Dt,Lt,Rt,xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Mt=function(e,t){for(var r=e,n=r>>1,o=n+t/2;!(n>=o)&&C[n];)++n;if((r=n<<1)-e>32&&xt)return xt.decode(A.subarray(e,r));for(var i="",a=0;!(a>=t/2);++a){var s=S[e+2*a>>1];if(0==s)break;i+=String.fromCharCode(s)}return i},Ut=function(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 a=e.charCodeAt(i);S[t>>1]=a,t+=2}return S[t>>1]=0,t-n},Ft=function(e){return 2*e.length},jt=function(e,t){for(var r=0,n="";!(r>=t/4);){var o=P[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},Nt=function(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 a=e.charCodeAt(i);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i)),P[t>>2]=a,(t+=4)+4>o)break}return P[t>>2]=0,t-n},Bt=function(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},$t={},Ht=[],zt=[],Wt={},Vt=function(){if(!Vt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==("undefined"==typeof navigator?"undefined":y(navigator))&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var t in Wt)void 0===Wt[t]?delete e[t]:e[t]=Wt[t];var r=[];for(var t in e)r.push("".concat(t,"=").concat(e[t]));Vt.strings=r}return Vt.strings},qt=function(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ve.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n};Object.defineProperties(qt.prototype,{read:{get:function(){return!(365&~this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return!(146&~this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ve.isDir(this.mode)}},isDevice:{get:function(){return ve.isChrdev(this.mode)}}}),ve.FSNode=qt,ve.createPreloadedFile=function(e,t,r,n,o,i,a,s,u,c){var f=t?re.resolve(Z.join2(e,t)):e;function l(r){function l(r){c&&c(),s||ve.createDataFile(e,t,r,n,o,u),i&&i(),q()}(function(e,t,r,n){"undefined"!=typeof Browser&&Browser.init();var o=!1;return he.forEach((function(i){o||i.canHandle(t)&&(i.handle(e,t,r,n),o=!0)})),o})(r,f,l,(function(){a&&a(),q()}))||l(r)}V(),"string"==typeof r?de(r,(function(e){return l(e)}),a):l(r)},ve.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);we=e}(),Te=i.BindingError=function(e){function t(e){var r;return o(this,t),(r=n(this,t,[e])).name="BindingError",r}return f(t,e),a(t)}(w(Error)),Se=i.InternalError=function(e){function t(e){var r;return o(this,t),(r=n(this,t,[e])).name="InternalError",r}return f(t,e),a(t)}(w(Error)),Ye.prototype.isAliasOf=Ie,Ye.prototype.clone=Qe,Ye.prototype.delete=Je,Ye.prototype.isDeleted=Ke,Ye.prototype.deleteLater=Xe,i.getInheritedInstanceCount=Fe,i.getLiveInheritedInstances=je,i.flushPendingDeletes=Be,i.setDelayFunction=He,lt.prototype.getPointee=ut,lt.prototype.destructor=ct,lt.prototype.argPackAdvance=8,lt.prototype.readValueFromPointer=st,lt.prototype.deleteObject=ft,lt.prototype.fromWireType=qe,mt=i.UnboundTypeError=(Dt=Error,(Rt=et(Lt="UnboundTypeError",(function(e){this.name=Lt,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(Dt.prototype),Rt.prototype.constructor=Rt,Rt.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},Rt),Object.assign(kt.prototype,{get:function(e){return this.allocated[e]},has:function(e){return void 0!==this.allocated[e]},allocate:function(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free:function(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Tt.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Tt.reserved=Tt.allocated.length,i.count_emval_handles=St;var Gt={p:function(e,t,r){throw new Y(e).init(t,r),e},C:function(e,t,r){ye.varargs=r;try{var n=ye.getStreamFromFD(e);switch(t){case 0:return(o=ye.get())<0?-28:ve.createStream(n,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return n.flags;case 4:var o=ye.get();return n.flags|=o,0;case 5:return o=ye.get(),S[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return i=28,P[Kt()>>2]=i,-1}}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return-e.errno}var i},w:function(e,t,r,n){ye.varargs=n;try{t=ye.getStr(t),t=ye.calculateAt(e,t);var o=n?ye.get():0;return ve.open(t,r,o).fd}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return-e.errno}},t:function(e,t,r,n,o){},n:function(e,t,r,n,o){var i=ge(r);Oe(e,{name:t=Ee(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=T;else if(2===r)n=S;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);n=P}return this.fromWireType(n[e>>i])},destructorFunction:null})},r:function(e,t,r,n,o,a,s,u,c,f,l,d,h){l=Ee(l),a=vt(o,a),u&&(u=vt(s,u)),f&&(f=vt(c,f)),h=vt(d,h);var p=Ze(l);!function(e,t,r){i.hasOwnProperty(e)?(Ae("Cannot register public name '".concat(e,"' twice")),tt(i,e,e),i.hasOwnProperty(r)&&Ae("Cannot register multiple overloads of a function with the same number of arguments (".concat(r,")!")),i[e].overloadTable[r]=t):i[e]=t}(p,(function(){gt("Cannot construct ".concat(l," due to unbound types"),[n])})),Pe([e,t,r],n?[n]:[],(function(t){var r,o;t=t[0],o=n?(r=t.registeredClass).instancePrototype:Ye.prototype;var s=et(p,(function(){if(Object.getPrototypeOf(this)!==c)throw new Te("Use 'new' to construct "+l);if(void 0===d.constructor_body)throw new Te(l+" has no accessible constructor");var e=d.constructor_body[arguments.length];if(void 0===e)throw new Te("Tried to invoke ctor of ".concat(l," with invalid number of parameters (").concat(arguments.length,") - expected (").concat(Object.keys(d.constructor_body).toString(),") parameters instead!"));return e.apply(this,arguments)})),c=Object.create(o,{constructor:{value:s}});s.prototype=c;var d=new rt(l,s,c,h,r,a,u,f);d.baseClass&&(void 0===d.baseClass.__derivedClasses&&(d.baseClass.__derivedClasses=[]),d.baseClass.__derivedClasses.push(d));var v=new lt(l,d,!0,!1,!1),m=new lt(l+"*",d,!1,!1,!1),y=new lt(l+" const*",d,!1,!0,!1);return Ue[e]={pointerType:m,constPointerType:y},function(e,t,r){i.hasOwnProperty(e)||Ce("Replacing nonexistant public symbol"),void 0!==i[e].overloadTable&&void 0!==r||(i[e]=t,i[e].argCount=r)}(p,s),[v,m,y]}))},q:function(e,t,r,n,o,i){var a=wt(t,r);o=vt(n,o),Pe([],[e],(function(e){e=e[0];var r="constructor ".concat(e.name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new Te("Cannot register multiple constructors with identical number of parameters (".concat(t-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[t-1]=function(){gt("Cannot construct ".concat(e.name," due to unbound types"),a)},Pe([],a,(function(n){return n.splice(1,0,null),e.registeredClass.constructor_body[t-1]=_t(r,n,null,o,i),[]})),[]}))},d:function(e,t,r,n,o,i,a,s,u){var c=wt(r,n);t=Ee(t),i=vt(o,i),Pe([],[e],(function(e){e=e[0];var n="".concat(e.name,".").concat(t);function o(){gt("Cannot call ".concat(n," due to unbound types"),c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var f=e.registeredClass.instancePrototype,l=f[t];return void 0===l||void 0===l.overloadTable&&l.className!==e.name&&l.argCount===r-2?(o.argCount=r-2,o.className=e.name,f[t]=o):(tt(f,t,n),f[t].overloadTable[r-2]=o),Pe([],c,(function(o){var s=_t(n,o,e,i,a,u);return void 0===f[t].overloadTable?(s.argCount=r-2,f[t]=s):f[t].overloadTable[r-2]=s,[]})),[]}))},D:function(e,t){Oe(e,{name:t=Ee(t),fromWireType:function(e){var t=Ct.toValue(e);return At(e),t},toWireType:function(e,t){return Ct.toHandle(t)},argPackAdvance:8,readValueFromPointer:st,destructorFunction:null})},k:function(e,t,r){var n=ge(r);Oe(e,{name:t=Ee(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Ot(t,n),destructorFunction:null})},c:function(e,t,r,n,o){t=Ee(t);var i=ge(r),a=function(e){return e};if(0===n){var s=32-8*r;a=function(e){return e<<s>>>s}}var u=t.includes("unsigned");Oe(e,{name:t,fromWireType:a,toWireType:u?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:It(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=O,r=t[e>>=2],o=t[e+1];return new n(t.buffer,o,r)}Oe(e,{name:r=Ee(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=Ee(t));Oe(e,{name:t,fromWireType:function(e){var t,n=O[e>>2],o=e+4;if(r)for(var i=o,a=0;a<=n;++a){var s=o+a;if(a==n||0==A[s]){var u=me(i,s-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=s+1}}else{var c=new Array(n);for(a=0;a<n;++a)c[a]=String.fromCharCode(A[o+a]);t=c.join("")}return Jt(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||Ae("Cannot pass non-string to std::string"),n=r&&o?ae(t):t.length;var i=Qt(4+n+1),a=i+4;if(O[i>>2]=n,r&&o)se(t,A,a,n+1);else if(o)for(var s=0;s<n;++s){var u=t.charCodeAt(s);u>255&&(Jt(a),Ae("String has UTF-16 code units that do not fit in 8 bits")),A[a+s]=u}else for(s=0;s<n;++s)A[a+s]=t[s];return null!==e&&e.push(Jt,i),i},argPackAdvance:8,readValueFromPointer:st,destructorFunction:function(e){Jt(e)}})},f:function(e,t,r){var n,o,i,a,s;r=Ee(r),2===t?(n=Mt,o=Ut,a=Ft,i=function(){return C},s=1):4===t&&(n=jt,o=Nt,a=Bt,i=function(){return O},s=2),Oe(e,{name:r,fromWireType:function(e){for(var r,o=O[e>>2],a=i(),u=e+4,c=0;c<=o;++c){var f=e+4+c*t;if(c==o||0==a[f>>s]){var l=n(u,f-u);void 0===r?r=l:(r+=String.fromCharCode(0),r+=l),u=f+t}}return Jt(e),r},toWireType:function(e,n){"string"!=typeof n&&Ae("Cannot pass non-string to C++ string type ".concat(r));var i=a(n),u=Qt(4+i+t);return O[u>>2]=i>>s,o(n,u+4,i+t),null!==e&&e.push(Jt,u),u},argPackAdvance:8,readValueFromPointer:st,destructorFunction:function(e){Jt(e)}})},o:function(e,t){Oe(e,{isVoid:!0,name:t=Ee(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,n){var o,i;(e=Ht[e])(t=Ct.toValue(t),r=void 0===(i=$t[o=r])?Ee(o):i,null,n)},m:At,l:function(e,t){var r=function(e,t){for(var r,n,o,i=new Array(e),a=0;a<e;++a)i[a]=(r=O[t+4*a>>2],n="parameter "+a,o=void 0,void 0===(o=_e[r])&&Ae(n+" has unknown type "+yt(r)),o);return i}(e,t),n=r[0],o=n.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",i=zt[o];if(void 0!==i)return i;for(var a=["retType"],s=[n],u="",c=0;c<e-1;++c)u+=(0!==c?", ":"")+"arg"+c,a.push("argType"+c),s.push(r[1+c]);var f="return function "+Ze("methodCaller_"+o)+"(handle, name, destructors, args) {\n",l=0;for(c=0;c<e-1;++c)f+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(l?"+"+l:"")+");\n",l+=r[c+1].argPackAdvance;for(f+=" var rv = handle[name]("+u+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(f+=" argType"+c+".deleteObject(arg"+c+");\n");n.isVoid||(f+=" return retType.toWireType(destructors, rv);\n"),f+="};\n",a.push(f);var d,h,p=bt(Function,a).apply(null,s);return d=p,h=Ht.length,Ht.push(d),i=h,zt[o]=i,i},a:function(){G("")},e:function(){return Date.now()},v:function(){return A.length},A:function(e,t,r){return A.copyWithin(e,t,t+r)},u:function(e){A.length,G("OOM")},y:function(e,t){var r=0;return Vt().forEach((function(n,o){var i=t+r;O[e+4*o>>2]=i,function(e,t){for(var r=0;r<e.length;++r)T[0|t++]=e.charCodeAt(r);T[0|t]=0}(n,i),r+=n.length+1})),0},z:function(e,t){var r=Vt();O[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),O[t>>2]=n,0},i:function(e){try{var t=ye.getStreamFromFD(e);return ve.close(t),0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},x:function(e,t){try{var r=ye.getStreamFromFD(e),n=r.tty?2:ve.isDir(r.mode)?3:ve.isLink(r.mode)?7:4;return T[0|t]=n,S[t+2>>1]=0,H=[0,($=0,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[t+8>>2]=H[0],P[t+12>>2]=H[1],H=[0,($=0,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[t+16>>2]=H[0],P[t+20>>2]=H[1],0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},B:function(e,t,r,n){try{var o=function(e,t,r,n){for(var o=0,i=0;i<r;i++){var a=O[t>>2],s=O[t+4>>2];t+=8;var u=ve.read(e,T,a,s,n);if(u<0)return-1;if(o+=u,u<s)break}return o}(ye.getStreamFromFD(e),t,r);return O[n>>2]=o,0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},s:function(e,t,r,n,o){var i,a,s=(a=r)+2097152>>>0<4194305-!!(i=t)?(i>>>0)+4294967296*a:NaN;try{if(isNaN(s))return 61;var u=ye.getStreamFromFD(e);return ve.llseek(u,s,n),H=[u.position>>>0,($=u.position,+Math.abs($)>=1?$>0?+Math.floor($/4294967296)>>>0:~~+Math.ceil(($-+(~~$>>>0))/4294967296)>>>0:0)],P[o>>2]=H[0],P[o+4>>2]=H[1],u.getdents&&0===s&&0===n&&(u.getdents=null),0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}},h:function(e,t,r,n){try{var o=function(e,t,r,n){for(var o=0,i=0;i<r;i++){var a=O[t>>2],s=O[t+4>>2];t+=8;var u=ve.write(e,T,a,s,n);if(u<0)return-1;o+=u}return o}(ye.getStreamFromFD(e),t,r);return O[n>>2]=o,0}catch(e){if(void 0===ve||"ErrnoError"!==e.name)throw e;return e.errno}}};!function(){var e,r,n,o,a={a:Gt};function s(e,t){var r,n=e.exports;return E=(b=n).E,r=E.buffer,i.HEAP8=T=new Int8Array(r),i.HEAP16=S=new Int16Array(r),i.HEAP32=P=new Int32Array(r),i.HEAPU8=A=new Uint8Array(r),i.HEAPU16=C=new Uint16Array(r),i.HEAPU32=O=new Uint32Array(r),i.HEAPF32=I=new Float32Array(r),i.HEAPF64=D=new Float64Array(r),L=b.H,function(e){M.unshift(e)}(b.F),q(),n}if(V(),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(e){k("Module.instantiateWasm callback failed with error: "+e),t(e)}(e=g,r=N,n=a,o=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||Q(r)||"function"!=typeof fetch?K(r,n,o):fetch(r,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(o,(function(e){return k("wasm streaming compile failed: "+e),k("falling back to ArrayBuffer instantiation"),K(r,n,o)}))}))).catch(t)}();var Qt=function(e){return(Qt=b.G)(e)},Jt=function(e){return(Jt=b.I)(e)},Kt=function(){return(Kt=b.J)()},Xt=function(e){return(Xt=b.K)(e)};i.__embind_initialize_bindings=function(){return(i.__embind_initialize_bindings=b.L)()};var Yt,Zt=function(e){return(Zt=b.M)(e)};function er(){function t(){Yt||(Yt=!0,i.calledRun=!0,R||(i.noFSInit||ve.init.initialized||ve.init(),ve.ignorePermissions=!1,X(M),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)j(i.postRun.shift());X(U)}()))}z>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)F(i.preRun.shift());X(x)}(),z>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),t()}),1)):t()))}if(i.dynCall_jiji=function(e,t,r,n,o){return(i.dynCall_jiji=b.N)(e,t,r,n,o)},i._ff_h264_cabac_tables=67061,W=function e(){Yt||er(),Yt||(W=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return er(),r.ready}),re=te,ne=function(e){function t(e){return o(this,t),n(this,t,[re,(null==e?void 0:e.wasmPath)?fetch(null==e?void 0:e.wasmPath).then((function(e){return e.arrayBuffer()})):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode])}return f(t,e),a(t)}(Z),oe=(function(){var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0}(),function(e){return 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}(oe||{})),ie="undefined"!=typeof importScripts,ae="undefined"!=typeof registerProcessor,se="jssdk_log",ue=function(e){return 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}(ue||{}),ce=function(e,t,r,n){return new(r||(r=Promise))((function(t,o){function i(e){try{s(n.next(e))}catch(e){o(e)}}function a(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,a)}s((n=n.apply(e,[])).next())}))},fe=Symbol(32),le=Symbol(16),de=Symbol(8),he=function(){return a((function e(t){o(this,e),this.g=t,this.consumed=0,t&&(this.need=t.next().value)}),[{key:"setG",value:function(e){this.g=e,this.demand(e.next().value,!0)}},{key:"consume",value:function(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}},{key:"demand",value:function(e,t){return t&&this.consume(),this.need=e,this.flush()}},{key:"read",value:function(e){return ce(this,0,void 0,d().mark((function t(){var r=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.lastReadPromise){t.next=3;break}return t.next=3,this.lastReadPromise;case 3:return t.abrupt("return",this.lastReadPromise=new Promise((function(t,n){var o;r.reject=n,r.resolve=function(e){delete r.lastReadPromise,delete r.resolve,delete r.need,t(e)},r.demand(e,!0)||null===(o=r.pull)||void 0===o||o.call(r,e)})));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"readU32",value:function(){return this.read(fe)}},{key:"readU16",value:function(){return this.read(le)}},{key:"readU8",value:function(){return this.read(de)}},{key:"close",value:function(){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}},{key:"flush",value:function(){if(this.buffer&&this.need){var e=null,t=this.buffer.subarray(this.consumed),r=0,n=function(e){return t.length<(r=e)};if("number"==typeof this.need){if(n(this.need))return;e=t.subarray(0,r)}else if(this.need===fe){if(n(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===le){if(n(2))return;e=t[0]<<8|t[1]}else if(this.need===de){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}}},{key:"write",value:function(e){var t=this;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((function(e){return t.pull=e}));this.flush()}},{key:"writeU32",value:function(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}},{key:"writeU16",value:function(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}},{key:"writeU8",value:function(e){this.malloc(1)[0]=e,this.flush()}},{key:"malloc",value:function(e){if(this.buffer){var 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{var n=new Uint8Array(r);n.set(this.buffer),this.buffer=n}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}}])}();he.U32=fe,he.U16=le,he.U8=de;function pe(e){for(var t=new he;e>=128;)t.malloc(1)[0]=255&e|128,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function ve(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new he,n=t<<3;switch(y(e)){case"boolean":var o=r.malloc(2);o[0]=n,o[1]=e?1:0;break;case"number":r.malloc(1)[0]=n,r.write(pe(e));break;case"string":r.malloc(1)[0]=2|n;var i=(new TextEncoder).encode(e);r.write(pe(i.length));for(var a=r.malloc(i.length),s=0;s<i.length;s++)a[s]=i[s];break;case"object":var u=new he;if(Array.isArray(e))for(var c=0;c<e.length;c++){var f=ve(e[c],c+1);f&&u.write(f)}else{var l=1;for(var d in e){var h=ve(e[d],l++);h&&u.write(h)}}0===t?u.buffer&&r.write(u.buffer):(r.malloc(1)[0]=2|n,u.buffer&&(r.write(pe(u.buffer.length)),r.write(u.buffer)))}return r.buffer||new Uint8Array(0)}var me=function(){return a((function e(){o(this,e),F(this,"buffer"),this.buffer=[]}),[{key:"data",get:function(){return this.buffer}},{key:"length",get:function(){return this.buffer.length}},{key:"writeInt32",value:function(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}},{key:"writeInt16",value:function(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}},{key:"writeByte",value:function(e){this.buffer.push(255&e)}},{key:"writeBytes",value:function(e){for(var t=0;t<e.length;t++)this.buffer.push(e[t])}}])}();function ye(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 ge(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function we(e,t){return e[t]}function Ee(e,t,r){return(new TextDecoder).decode(function(e,t,r){return e.slice(t,t+r)}(e,t,r))}var be=0,_e=2654435769;function ke(e,t){var r=new me,n=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,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}}(t,e,be);be=be+1&2147483647,r.writeInt32(0),r.writeInt32(n.version),r.writeByte(n.encryption);var o=(new TextEncoder).encode(n.d2);r.writeInt32(o.length+4),o&&r.writeBytes(o),r.writeByte(n.uinType);var i=(new TextEncoder).encode(n.uin);r.writeInt32(i.length+4),i.length&&r.writeBytes(i);var a=new me;a.writeInt32(0),a.writeInt32(n.reqHead.seqNumber),a.writeInt32(n.reqHead.appId),a.writeByte(n.reqHead.appId>>>24&255),a.writeByte(n.reqHead.appId>>>16&255),a.writeByte(n.reqHead.appId>>>8&255),a.writeByte(255&n.reqHead.appId);for(var s=4;s<16;s++)a.writeByte(0);var u=(new TextEncoder).encode(n.reqHead.a2);a.writeInt32(u.length+4),u.length&&a.writeBytes(u);var c=(new TextEncoder).encode(n.reqHead.serviceCmd);a.writeInt32(c.length+4),c.length&&a.writeBytes(c);var f=(new TextEncoder).encode(n.reqHead.cookie);a.writeInt32(f.length+4),f.length&&a.writeBytes(f);var l=(new TextEncoder).encode(n.reqHead.imei);a.writeInt32(l.length+4),l.length&&a.writeBytes(l);var d=(new TextEncoder).encode(n.reqHead.ksid);a.writeInt32(d.length+4),d.length&&a.writeBytes(d);var h=(new TextEncoder).encode(n.reqHead.clientVersionInfo);a.writeInt16(h.length+2),h.length&&a.writeBytes(h);var p=a.length;a.data[0]=p>>>24&255,a.data[1]=p>>>16&255,a.data[2]=p>>>8&255,a.data[3]=255&p,Gt(e)&&(e=(new TextEncoder).encode(e)),a.writeInt32(e.length+4),e.length&&a.writeBytes(e);var v=new Uint8Array(a.data),m=null;1===n.encryption?m=(new TextEncoder).encode(n.uin):2===n.encryption&&(m=new Uint8Array(16)),m&&(v=function(e,t){var r=e.length,n=(r+1+2+7)%8;n&&(n=8-n);var o=new Uint8Array(r+1+2+7+n),i=0,a=new Uint8Array(8),s=new Uint8Array(8),u=new Uint8Array(8),c=0;a[0]=248&Math.floor(256*Math.random())|n,c=1;for(var f=0;f<n;f++)a[c]=255&Math.floor(256*Math.random()),c+=1;for(var l=0;l<2;)if(c<8&&(a[c]=255&Math.floor(256*Math.random()),c+=1,l+=1),8===c){Te(a,t,s,u,o,i),i+=8,c=0;for(var d=0;d<8;d++)u[d]=o[i-8+d]}var h=0;for(;h<r;)if(c<8&&(a[c]=e[h],c+=1,h+=1),8===c){Te(a,t,s,u,o,i),i+=8,c=0;for(var p=0;p<8;p++)u[p]=o[i-8+p]}for(var v=0;v<7;)if(c<8&&(a[c]=0,c+=1,v+=1),8===c){Te(a,t,s,u,o,i),i+=8,c=0;for(var m=0;m<8;m++)u[m]=o[i-8+m]}return o}(v,m)),r.writeBytes(v);var y=new Uint8Array(r.data),g=y.length;return y[0]=g>>>24&255,y[1]=g>>>16&255,y[2]=g>>>8&255,y[3]=255&g,y}function Te(e,t,r,n,o,i){for(var a=0;a<8;a++)e[a]^=n[a];!function(e,t,r,n){for(var o=ge(e,0),i=ge(e,4),a=[],s=0;s<4;s++)a[s]=ge(t,4*s);for(var u=0,c=0;c<16;c++)u+=_e,u>>>=0,o+=(i<<4)+a[0]^i+u^(i>>>5)+a[1],i+=((o>>>=0)<<4)+a[2]^o+u^(o>>>5)+a[3],i>>>=0;ye(r,o,n),ye(r,i,n+4)}(e,t,o,i);for(var s=0;s<8;s++)o[i+s]^=r[s];for(var u=0;u<8;u++)r[u]=e[u]}var Ae=function(){return Date.now()+0};function Se(e){var t=function(e){try{var t={},r=0;t.totalLength=ge(e,r),r+=4,t.version=ge(e,r),r+=4,t.encryption=we(e,r),r+=1,t.uinType=we(e,r),r+=1,t.uinLength=ge(e,r),r+=4,t.uin=t.uinLength>4?Ee(e,r,t.uinLength-4):"",r+=t.uinLength-4;var n=e.slice(r);if(2===t.encryption){var o=function(e,t){var r=0,n=new Uint8Array(8).fill(0),o=Ce(new Uint8Array(e.slice(0,8)),t),i=7&o[0],a=e.length-1-i-2-7,s=new Uint8Array(a),u=0,c=n,f=e.slice(0,8);r=8;var l=1;l+=i;for(var d=1;d<=2;)if(l<8)l++,d++;else if(8===l){var h=Pe(e,r,c,f,o,t);c=h.ivPreCrypt,f=h.ivCurCrypt,o=h.debiBuf,r=h.bufPos,l=0}var p=a;for(;p>0;)if(l<8)s[u++]=o[l]^c[l],l++,p--;else if(8===l){var v=Pe(e,r,c,f,o,t);c=v.ivPreCrypt,f=v.ivCurCrypt,o=v.debiBuf,r=v.bufPos,l=0}for(var m=1;m<=7;)if(l<8)o[l],c[l],l++,m++;else if(8===l){if(r>=e.length)break;var y=Pe(e,r,c,f,o,t);if(!y.success)break;c=y.ivPreCrypt,f=y.ivCurCrypt,o=y.debiBuf,r=y.bufPos,l=0}return s}(n,new Uint8Array(16).fill(0));e=o,t.decrypted=!0,r=0}else e=n,r=0;return t.rspHeadLength=ge(e,r),r+=4,t.seqNo=ge(e,r),r+=4,t.retCode=ge(e,r),r+=4,t.retStrLength=ge(e,r),r+=4,t.retStr=t.retStrLength?Ee(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=ge(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?Ee(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=ge(e,r),r+=4,t.cookie=t.cookieLength?Ee(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=ge(e,r),r+=4,t.busiBuffLength=ge(e,r),r+=4,t.busiBuff=t.busiBuffLength?Ee(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(e){}}(e);return null==t?void 0:t.busiBuff}function Ce(e,t){var 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;for(var o=3816266640,i=0;i<16;i++)n-=(r<<4)+t[2]^r+o^(r>>>5)+t[3],r-=((n>>>=0)<<4)+t[0]^n+o^(n>>>5)+t[1],r>>>=0,o-=_e,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 Pe(e,t,r,n,o,i){if(t+8>e.length)return{success:!1};for(var a=new Uint8Array(n),s=e.slice(t,t+8),u=new Uint8Array(8),c=0;c<8;c++)u[c]=o[c]^s[c];return{success:!0,ivPreCrypt:a,ivCurCrypt:s,debiBuf:Ce(u,i),bufPos:t+8}}var Oe="undefined"!=typeof TextDecoder?new TextDecoder:void 0;var Ie=Object.prototype.hasOwnProperty,De=function(e){return"function"==typeof e},Le=function(e){return void 0===e};function Re(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(function(e){if(!e||"object"!==y(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var 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)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(Ie.call(e,t))return!1;return!0}return!1}var xe=function(e){var t=e.retryFunction,n=e.settings,o=e.onError,i=e.onRetrying,a=e.onRetryFailed,s=e.onRetrySuccess,u=e.context;return function(){for(var e=this,c=arguments.length,f=new Array(c),l=0;l<c;l++)f[l]=arguments[l];var h=n.retries,p=void 0===h?5:h,v=n.timeout,m=void 0===v?1e3:v,y=0,g=-1,w=0,E=function(){var n=r(d().mark((function r(n,c){var l,h,v,b;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return l=u||e,r.prev=1,r.next=4,t.apply(l,f);case 4:h=r.sent,y>0&&s&&s.call(e,y),y=0,n(h),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),v=function(){clearTimeout(g),y=0,w=2,c(r.t0)},b=function(){2!==w&&y<(De(p)?p():p)?(y++,w=1,De(i)&&i.call(e,y,v),g=window.setTimeout((function(){g=-1,E(n,c)}),De(m)?m(y):m)):(v(),De(a)&&a.call(e,r.t0))},De(o)?o.call(e,{error:r.t0,retry:b,reject:c,retryFuncArgs:f,retriedCount:y}):b();case 15:case"end":return r.stop()}}),r,null,[[1,10]])})));return function(e,t){return n.apply(this,arguments)}}();return new Promise(E)}},Me=function(){function e(t){o(this,e),F(this,"_parentPath"),F(this,"userId"),F(this,"remoteUserId"),F(this,"id"),F(this,"sdkAppId"),F(this,"type"),F(this,"isLocal"),this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal="boolean"!=typeof t.isLocal||t.isLocal,this.type=this.isLocal?"":t.type}return a(e,[{key:"getFullId",value:function(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}},{key:"createChild",value:function(t){var r=new e({id:t.id,userId:Le(t.userId)?this.userId:t.userId,sdkAppId:Le(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:Le(t.type)?this.type:t.type,isLocal:Le(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:Le(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}},{key:"bindParent",value:function(e){var t=e.getFullId();this._parentPath!==t&&(this.debug("bind logger parent: ".concat(e.id)),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}},{key:"setUserId",value:function(e){this.userId=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId=e}},{key:"log",value:function(e,t){var r=this.isLocal?this.userId:this.remoteUserId,n=this.getFullId();t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(n).concat(r?"|".concat(r):"","]")),Wt.log(e,t,Le(this.userId)||Re(this.userId),this.userId,this.sdkAppId)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}}])}(),Ue="undefined"==typeof navigator?"":navigator.userAgent,Fe=function(e){return new RegExp(e,"i").test(Ue)},je=function(e){if(Fe(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=Ue.match(t);if(r&&r[1])return r[1]}return""},Ne=function(e){if(Fe(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),r=Ue.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},Be=/AppleWebKit\/([\d.]+)/i.exec(Ue);Be&&parseFloat(Be[1]);var $e=Fe("iPad"),He="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&Fe("Macintosh"),ze=Fe("iPhone")&&!$e,We=Fe("iPod"),Ve=ze||$e||We||He,qe=Fe("Android");!function(){if(qe){var e=Ue.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){var t=e[1]&&parseFloat(e[1]),r=e[2]&&parseFloat(e[2]);if(t&&r)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}}();qe&&Fe("webkit");var Ge=Fe("Firefox"),Qe=je("Firefox");Ne("Firefox");var Je=Fe("Edge"),Ke=je("Edge"),Xe=Fe("Edg"),Ye=je("Edg");Ne("Edg");var Ze=Fe("SogouMobileBrowser"),et=je("SogouMobileBrowser"),tt=Fe("MetaSr\\s"),rt=je("MetaSr\\s"),nt=Fe("TBS"),ot=je("TBS"),it=Fe("XWEB"),at=je("XWEB");Fe("MSIE\\s8\\.0");var st=Fe("MSIE\\/\\d+");!function(){if(st){var e=/MSIE\s(\d+)\.\d/.exec(Ue),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(Ue)&&/rv:11.0/.test(Ue)&&(t=11),t}}();var ut=Fe("(micromessenger|webbrowser)"),ct=je("MicroMessenger"),ft=!nt&&Fe("MQQBrowser")&&Fe("COVC"),lt=!nt&&Fe("MQQBrowser")&&!Fe("COVC"),dt=lt||ft?je("MQQBrowser"):"",ht=!nt&&Fe(" QQBrowser"),pt=je(" QQBrowser"),vt=!nt&&Fe("QQBrowserLite"),mt=je("QQBrowserLite"),yt=!nt&&Fe("MQBHD"),gt=je("MQBHD");Fe("Windows"),!Ve&&Fe("MAC OS X"),!qe&&Fe("Linux"),Fe("CrOS"),Fe("MicroMessenger"),Fe("UCBrowser"),Fe("Electron");var wt=Fe("MiuiBrowser"),Et=je("MiuiBrowser"),bt=Fe("HuaweiBrowser");Fe("Huawei")||Fe("HUAWEI"),Fe("Honor")||Fe("HONOR");var _t=je("HuaweiBrowser"),kt=Fe("SamsungBrowser"),Tt=je("SamsungBrowser"),At=Fe("HeyTapBrowser"),St=je("HeyTapBrowser"),Ct=Fe("VivoBrowser"),Pt=je("VivoBrowser");Fe("OpenHarmony"),je("OpenHarmony");var Ot=Fe("CriOS"),It=Fe("Chrome"),Dt=!Je&&!tt&&!Ze&&!nt&&!it&&!Xe&&!ht&&!wt&&!bt&&!kt&&!At&&!Ct&&It,Lt=Fe("HeadlessChrome");Ne("Chrome");var Rt=je("Chrome");Ne("Electron");var xt=!It&&!lt&&!ft&&!vt&&!yt&&Fe("Safari"),Mt=je("Version"),Ut=function(){if(He)return Mt;if(Ve){var e=Ue.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}();Number(Ut.split(".")[0]),Number(Ut.split(".")[0]),function(){var e=new Map([[Ge,["Firefox",Qe]],[Xe,["Edg",Ye]],[Dt,["Chrome",Rt]],[Ot,["ChiOS",je("CriOS")]],[xt&&!Ot,["Safari",Mt]],[nt,["TBS",ot]],[it,["XWEB",at]],[ut&&ze,["WeChat",ct]],[ht,["QQ(Win)",pt]],[lt,["QQ(Mobile)",dt]],[ft,["QQ(Mobile X5)",dt]],[vt,["QQ(Mac)",mt]],[yt,["QQ(iPad)",gt]],[wt,["MI",Et]],[bt,["HW",_t]],[kt,["Samsung",Tt]],[At,["OPPO",St]],[Ct,["VIVO",Pt]],[Je,["EDGE",Ke]],[Ze,["SogouMobile",et]],[tt,["Sogou",rt]]]),t="unknown",r="unknown";if(e.has(!0)){var n=p(e.get(!0),2);t=n[0],r=n[1]}}();var Ft=new(M(j()).default),jt=oe,Nt=new(function(){return a((function e(){var t=this;o(this,e),F(this,"enable",!1),F(this,"ssoFailCount",0),Ft.on("22",(function(e){var t,r=e.schedule;(null==(t=null==r?void 0:r.config)?void 0:t.sso)&&Ft.emit("266",{enable:!0})})),Ft.on("266",(function(e){var r=e.enable;t.enable=r}))}),[{key:"handleUploadFailed",value:function(){this.ssoFailCount++,this.ssoFailCount>3&&Ft.emit("266",{enable:!1})}}])}()),Bt="%cTRTC%c%s",$t="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",Ht="display: inline",zt=function(){function e(){o(this,e),F(this,"_isEnableUploadLog",!0),F(this,"_localJoinedUser",new Map),F(this,"_queue",[]),F(this,"_timeoutId",-1),F(this,"_logLevel",1),F(this,"_logLevelToUpload",2),ie||ae||(this.checkURLParam(),this.installEvents())}return a(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;Ft.on(jt.JOIN_SCHEDULE_SUCCESS,(function(t){var r,n=t.schedule;(null==(r=null==n?void 0:n.config)?void 0:r.logLevelToUpload)&&ue[n.config.logLevelToUpload]&&(e._logLevelToUpload=n.config.logLevelToUpload)})),Ft.on(jt.JOIN_START,(function(t){var r=t.params;e.addJoinedUser({userId:r.userId,sdkAppId:r.sdkAppId}),e.startUpload()})),Ft.on(jt.LEAVE_SUCCESS,(function(t){var r=t.room;e.deleteJoinedUser(r.userId)}))}},{key:"startUpload",value:function(){-1===this._timeoutId&&this.uploadInterval()}},{key:"addJoinedUser",value:function(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}},{key:"deleteJoinedUser",value:function(e){this._localJoinedUser.delete(e)}},{key:"uploadInterval",value:function(){var e=this;this.upload().catch((function(){})),this._timeoutId=window.setTimeout((function(){return e.uploadInterval()}),5e3)}},{key:"getLogsToUpload",value:function(){var e=this,t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return t;for(var r=0,n=function(){if(50===r)return 1;var n=e._queue[r];if(n.forAllJoinedClients)e._localJoinedUser.forEach((function(e){var r=e.userId,o=e.sdkAppId;t.map.has(r)?t.map.get(r).logs.push(n):t.map.set(r,{userId:r,sdkAppId:o,logs:[n]})}));else if(Gt(n.userId)&&Qt(n.sdkAppId)){var o=n.userId,i=n.sdkAppId;t.map.has(o)?t.map.get(o).logs.push(n):t.map.set(o,{userId:o,sdkAppId:i,logs:[n]})}};r<this._queue.length&&!n();r++);return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,r)),t}},{key:"upload",value:(t=r(d().mark((function e(){var t,r,n,o,i,a,s,u,c,f,l,h,p;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.length&&this._isEnableUploadLog){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),r=t.map,n=t.splicedQueue,0!==r.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,o=v(r.values()),i=0;case 8:if(!(i<o.length)){e.next=19;break}return a=o[i],s=a.userId,u=a.sdkAppId,c=a.logs,f={timestamp:(d=void 0,d=new Date,d.setTime(Ae()),d.toLocaleString()),sdkAppId:String(u),userId:s,version:"5.0.0",log:c.map((function(e){return e.log})).join("\n")},l=JSON.stringify(f),h=Nt.enable?Jt(f,2002,u):l,e.next=15,this.uploadLogWithRetry(h,u,h instanceof Uint8Array,l);case 15:c.forEach((function(e){return e.uploaded=!0}));case 16:i++,e.next=8;break;case 19:e.next=23;break;case 21:e.prev=21,e.t0=e.catch(5);case 23:(p=n.filter((function(e){return!e.uploaded}))).length>0&&(this._queue=p.concat(this._queue));case 25:case"end":return e.stop()}var d}),e,this,[[5,21]])}))),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(e,t,r,n){var o=this;return xe({retryFunction:function(){return(i={url:Vt(t,se),body:e,timeout:5e3,priority:"low"},a=i.url,s=i.body,u=i.method,c=void 0===u?"POST":u,f=i.timeout,l=i.priority,new Promise((function(e,t){if("fetch"in window)return fetch(a,{method:c,body:s,priority:l}).then((function(e){return e.clone().json().then((function(e){return{data:e}}),(function(){return e.arrayBuffer().then((function(e){return{data:Se(new Uint8Array(e))||(Oe?Oe.decode(e):e)}}))}))})).then(e,t);var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState)if(r.status>=200&&r.status<300)try{var n=JSON.parse(r.response);e({data:n})}catch(t){e({data:r.response})}else t({status:r.status,statusText:r.statusText||"request failed!"})},r.timeout=f||5e3,r.open(c,a,!0),r.send(s)}))).then((function(e){r&&"ok"!==e.data&&(Nt.handleUploadFailed(),o.uploadLogWithRetry(n,t,!1,n))}));var i,a,s,u,c,f,l},settings:{retries:3,timeout:2e3},onError:function(e){(0,e.retry)()}})()}},{key:"getPrefix",value:function(e){var t,r,n=new Date;return n.setTime(Ae()),"[".concat((t=n,r=String(t.getMilliseconds()),"padStart"in String.prototype&&(r=r.toString().padStart(3,"0")),"".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r)),"] <").concat(ue[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){qt(ue[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}},{key:"enableUploadLog",value:function(){this._isEnableUploadLog=!0}},{key:"disableUploadLog",value:function(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}},{key:"logChunkToString",value:function(e){if(Gt(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(e){return""}}},{key:"addLogToQueue",value:function(e,t){var r=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a={log:t.reduce((function(e,t){return"".concat(e," ").concat(r.logChunkToString(t)).trim()}),""),level:e,userId:o,sdkAppId:i,forAllJoinedClients:n};Ft.emit(jt.LOG,{log:a}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(a)}},{key:"log",value:function(t,r){var n,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,o,i,a),!(t<this._logLevel)){var s,u,c=(null==(n=ue[t])?void 0:n.toLowerCase())||"info";if(e.PRINT_LOG_TAG)(s=console)[c].apply(s,[Bt,$t,Ht].concat(v(r)));else(u=console)[c].apply(u,v(r))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}},{key:"createLogger",value:function(e){if(e.parent instanceof Me){var t=e,r=t.parent,n=function(e,t){var r={};for(var n in e)I.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&P){var o,i=s(P(e));try{for(i.s();!(o=i.n()).done;)n=o.value,t.indexOf(n)<0&&D.call(e,n)&&(r[n]=e[n])}catch(e){i.e(e)}finally{i.f()}}return r}(t,["parent"]),o=new Me(n);return o.bindParent(r),o}return new Me(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;ue[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}]);var t}();F(zt,"PRINT_LOG_TAG",!(Ve||qe||Lt));var Wt=new zt,Vt=function(e,t){var r;r=function(e){return Number(e)<14e8}(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var n=Math.floor(Math.random()*Math.pow(2,31));return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(n,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},qt=function(e){return void 0===e},Gt=function(e){return"string"==typeof e},Qt=function(e){return"number"==typeof e};function Jt(e,t,r,n){try{var o=function(e,t,r,n){var o={data:e,random:Math.floor(Math.random()*Math.pow(2,31)),sdkAppId:r};return qt(n)||(o=x(R({},o),{gzip:NaN})),{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)}}}(e,t,r,n);return ke(ve(o),r)}catch(t){return JSON.stringify(e)}}var Kt=function(){function e(t){o(this,e),this.core=t,F(this,"contextMap",new Map),F(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}return a(e,[{key:"getAlias",value:function(){return"videoDecoder"}},{key:"getGroup",value:function(e){return(null==e?void 0:e.track)?"".concat(e.track.userId).concat(e.track.streamType):"*"}},{key:"getName",value:function(){return e.Name}},{key:"getValidateRule",value:function(e){return{type:this.core.enums.BASIC_TYPE.Object}}},{key:"createDecoder",value:function(e,t){var r;switch(e){case"wasm":var n=(null==(r=this.core.assetsPath)?void 0:r.replace(/\/+$/,""))||".";return new ne(x(R({},t),{wasmPath:"".concat(n,"/videodec.wasm")}));case"webCodecs":return new X;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}},{key:"start",value:function(e){var t=this;this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:function(e){var r,n=e.frame,o=e.track;return(null==(r=t.decodeProcessorMap.get(o))?void 0:r({frame:n,track:o}))||n},type:3})}},{key:"decode",value:function(e){var t=this,r=this.core.rx,n=r.pipe,o=r.take,i=r.subscribe;return function(r){var a=r.frame,s=r.track;if(s!==e.track||"empty"===a.type)return a;if(t.contextMap.has(s))return t.contextMap.get(s).decode(a);var u=t.core.room.videoManager.createDecodeContext(x(R({},e),{createDecoder:t.createDecoder}));return n(u.trackDoneOB,o(1),i((function(){t.core.clearStarted(t,t.getGroup(e)),t.stop({track:s})}))),t.contextMap.set(s,u),u.decode(a)}}},{key:"stop",value:function(e){var t=this;if(null==e?void 0:e.track){var r=this.contextMap.get(e.track);r&&(r.close("stop"),this.report(r,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach((function(e,r){e.close("stop"),t.contextMap.delete(r)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}},{key:"report",value:function(e,t){if(!e.isReported){e.isReported=!0;var r=(performance&&performance.now?Math.floor(performance.now()):Date.now())-e.startPerformanceTime,n=this.getRemoteTrackFreezeDuration(t,e),o=n.renderFreezeTotal,i=n.dataFreezeTotal,a="report health data: ".concat(e.track.userId," ").concat(e.track.streamType," ").concat(e.type,"+").concat(e.renderer," goodType:").concat(e.goodType," ").concat(e.failedReason?"failedReason: ".concat(e.failedReason):"");r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(o/r*100),split:1,max:100}),a+=" RENDER_FREEZE_RATE: ".concat(Math.floor(o/r*100),"%")),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(i/r*100),split:1,max:100}),a+=" DATA_FREEZE_RATE: ".concat(Math.floor(i/r*100),"%")),e.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100}),a+=" VIDEO_CONSUME_RENDER_RATE: ".concat(Math.floor(e.decodedFrameCount/e.inputFrameCount*100),"%")),this.core.log.info(a)}}},{key:"addKVReportBeforeExitRoom",value:function(e){var t=this;e.room===this.core.room&&this.contextMap.forEach((function(e,r){t.report(e,r)}))}},{key:"update",value:function(e){var t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(x(R({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}},{key:"getRemoteTrackFreezeDuration",value:function(e,t){var r=this.core.room.badCaseDetector.getDataFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),n=this.core.room.badCaseDetector.getRenderFreezeDuration("".concat(e.userId,"_").concat(e.streamType)),o=0;return r&&r.durationItemList.forEach((function(e){e.startTime>t.startPerformanceTime&&(o+=e.getDuration())})),{renderFreezeTotal:n,dataFreezeTotal:o}}},{key:"destroy",value:function(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}}])}();return F(Kt,"Name","TRTCVideoDecoder"),Kt}));
|