UNPKG

trtc-sdk-v5

Version:
1 lines 96.1 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TRTCVideoDecoder=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function e(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function s(t){e(a,o,i,s,c,"next",t)}function c(t){e(a,o,i,s,c,"throw",t)}s(void 0)}))}}function n(t,e,r){return e=u(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,l()?Reflect.construct(e,r||[],u(t).constructor):e.apply(t,r))}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,v(n.key),n)}}function a(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=y(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},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(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function c(t,e,r){return(e=v(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(l=function(){return!!t})()}function d(){d=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),s=new F(n||[]);return o(a,"_invoke",{value:S(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",v="executing",m="completed",y={};function g(){}function w(){}function b(){}var E={};u(E,a,(function(){return this}));var k=Object.getPrototypeOf,_=k&&k(k(O([])));_&&_!==r&&n.call(_,a)&&(E=_);var P=b.prototype=g.prototype=Object.create(E);function T(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function C(t,e){function r(o,i,a,s){var c=l(t[o],t,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function S(e,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:t,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===y)continue;return c}}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 u=l(e,r,n);if("normal"===u.type){if(o=n.done?m:p,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,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,e.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[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function D(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function F(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(D,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return w.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=u(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,c,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},T(C.prototype),u(C.prototype,s,(function(){return this})),e.AsyncIterator=C,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new C(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},T(P),u(P,c,"Generator"),u(P,a,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=O,F.prototype={constructor:F,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(x),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return s.type="throw",s.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!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 c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){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"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function p(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||y(e)||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 v(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function y(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&h(o,r.prototype),o}(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},g(t)}var w,b,E=Object.create,k=Object.defineProperty,_=Object.defineProperties,P=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols,A=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,F=function(t,e,r){return e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},O=function(t,e){for(var r in e||(e={}))D.call(e,r)&&F(t,r,e[r]);if(S){var n,o=s(S(e));try{for(o.s();!(n=o.n()).done;){r=n.value;x.call(e,r)&&F(t,r,e[r])}}catch(t){o.e(t)}finally{o.f()}}return t},j=function(t,e){return _(t,T(e))},M=function(t,e,r,n){for(var o,i=P(e,r),a=t.length-1;a>=0;a--)(o=t[a])&&(i=o(e,r,i)||i);return i&&k(e,r,i),i},$=function(t,e,r){return F(t,"symbol"!==m(e)?e+"":e,r)},R=(w={"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js":function(t,e){var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function a(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],s]:t._events[c].push(s):(t._events[c]=s,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new o:delete t._events[e]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),c.prototype.eventNames=function(){var t,e,o=[];if(0===this._eventsCount)return o;for(e in t=this._events)r.call(t,e)&&o.push(n?e.slice(1):e);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},c.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];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},c.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},c.prototype.emit=function(t,e,r,o,i,a){var s=n?n+t:t;if(!this._events[s])return!1;var c,u,f=this._events[s],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(t,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,e),!0;case 3:return f.fn.call(f.context,e,r),!0;case 4:return f.fn.call(f.context,e,r,o),!0;case 5:return f.fn.call(f.context,e,r,o,i),!0;case 6:return f.fn.call(f.context,e,r,o,i,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];f.fn.apply(f.context,c)}else{var d,h=f.length;for(u=0;u<h;u++)switch(f[u].once&&this.removeListener(t,f[u].fn,void 0,!0),l){case 1:f[u].fn.call(f[u].context);break;case 2:f[u].fn.call(f[u].context,e);break;case 3:f[u].fn.call(f[u].context,e,r);break;case 4:f[u].fn.call(f[u].context,e,r,o);break;default:if(!c)for(d=1,c=new Array(l-1);d<l;d++)c[d-1]=arguments[d];f[u].fn.apply(f[u].context,c)}}return!0},c.prototype.on=function(t,e,r){return a(this,t,e,r,!1)},c.prototype.once=function(t,e,r){return a(this,t,e,r,!0)},c.prototype.removeListener=function(t,e,r,o){var i=n?n+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var c=0,u=[],f=a.length;c<f;c++)(a[c].fn!==e||o&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},c.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&s(this,e)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,void 0!==e&&(e.exports=c)}},function(){return b||(0,w[C(w)[0]])((b={exports:{}}).exports,b),b.exports}),L=function(t,e,r){return r=null!=t?E(A(t)):{},function(t,e,r,n){if(e&&"object"===m(e)||"function"==typeof e){var o,i=s(C(e));try{var a=function(){var i=o.value;D.call(t,i)||i===r||k(t,i,{get:function(){return e[i]},enumerable:!(n=P(e,i))||n.enumerable})};for(i.s();!(o=i.n()).done;)a()}catch(t){i.e(t)}finally{i.f()}}return t}(k(r,"default",{value:t,enumerable:!0}),t)}(R()),z=Symbol("instance"),N=Symbol("cacheResult"),I=function(){return a((function t(e,r,n){o(this,t),this.oldState=e,this.newState=r,this.action=n,this.aborted=!1}),[{key:"abort",value:function(t){this.aborted=!0,q.call(t,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),B=function(t){function e(t,r,i){var a;return o(this,e),(a=n(this,e,[r])).state=t,a.message=r,a.cause=i,a}return f(e,t),a(e)}(g(Error));var U=new Map;function W(t,e){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=U.get(n)||[];U.has(n)||U.set(n,s),s.push({from:t,to:e,action:a})}var c=i.value;i.value=function(){for(var n,o=this,i=this,s=arguments.length,u=new Array(s),f=0;f<s;f++)u[f]=arguments[f];r.context&&(i=X.get("function"==typeof r.context?(n=r.context).call.apply(n,[this].concat(u)):r.context));if(i.state===e)return r.sync?i[N]:Promise.resolve(i[N]);i.state instanceof I&&i.state.action==r.abortAction&&i.state.abort(i);var l=null;Array.isArray(t)?0==t.length?i.state instanceof I&&i.state.abort(i):"string"==typeof i.state&&t.includes(i.state)||(l=new B(i._state,"".concat(i.name," ").concat(a," to ").concat(e," failed: current state ").concat(i._state," not from ").concat(t.join("|")))):t!==i.state&&(l=new B(i._state,"".concat(i.name," ").concat(a," to ").concat(e," failed: current state ").concat(i._state," not from ").concat(t)));var d=function(t){if(r.fail&&r.fail.call(o,t),r.sync){if(r.ignoreError)return t;throw t}return r.ignoreError?Promise.resolve(t):Promise.reject(t)};if(l)return d(l);var h=i.state,p=new I(h,e,a);q.call(i,p);var v,y=function(t){var n;return i[N]=t,p.aborted||(q.call(i,e),null===(n=r.success)||void 0===n||n.call(o,i[N])),t},g=function(t){return q.call(i,h,t),d(t)};try{var w=c.apply(this,u);return"object"===m(v=w)&&v&&"then"in v?w.then(y).catch(g):r.sync?y(w):Promise.resolve(y(w))}catch(r){return g(new B(i._state,"".concat(i.name," ").concat(a," from ").concat(t," to ").concat(e," failed: ").concat(r),r instanceof Error?r:new Error(String(r))))}}}}var H,V,G=(H="undefined"!=typeof window&&window.__AFSM__,V="undefined"!=typeof importScripts,H?function(t,e){window.dispatchEvent(new CustomEvent(t,{detail:e}))}:V?function(t,e){postMessage({type:t,payload:e})}:function(){});function q(t,e){var r=this._state;this._state=t;var n=t.toString();t&&this.emit(n,r),this.emit(X.STATECHANGED,t,r,e),this.updateDevTools({value:t,old:r,err:e instanceof Error?e.message:String(e)})}var X=function(t){function e(t,r,i){var a;o(this,e),(a=n(this,e)).name=t,a.groupName=r,a._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(a,i):i=Object.getPrototypeOf(a),r||(a.groupName=a.constructor.name);var s=i[z];return s?a.name=s.name+"-"+s.count++:i[z]={name:a.name,count:0},a.updateDevTools({diagram:a.stateDiagram}),a}return f(e,t),a(e,[{key:"stateDiagram",get:function(){var t=Object.getPrototypeOf(this),e=U.get(t)||[],r=new Set,n=[],o=[],i=new Set,a=Object.getPrototypeOf(t);U.has(a)&&(a.stateDiagram.forEach((function(t){return r.add(t)})),a.allStates.forEach((function(t){return i.add(t)}))),e.forEach((function(t){var e=t.from,r=t.to,i=t.action;"string"==typeof e?n.push({from:e,to:r,action:i}):e.length?e.forEach((function(t){n.push({from:t,to:r,action:i})})):o.push({to:r,action:i})})),n.forEach((function(t){var e=t.from,n=t.to,o=t.action;i.add(e),i.add(n),i.add(o+"ing"),r.add("".concat(e," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(n," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(e," : ").concat(o," 🔴"))})),o.forEach((function(t){var e=t.to,n=t.action;r.add("".concat(n,"ing --\x3e ").concat(e," : ").concat(n," 🟢")),i.forEach((function(t){t!==e&&r.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n))}))}));var s=p(r);return Object.defineProperties(t,{stateDiagram:{value:s},allStates:{value:i}}),s}},{key:"updateDevTools",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};G(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}},{key:"state",get:function(){return this._state},set:function(t){q.call(this,t)}}],[{key:"get",value:function(t){var r;return"string"==typeof t?(r=e.instances.get(t))||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype))):(r=e.instances2.get(t))||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype))),r}},{key:"getState",value:function(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}}])}(L.default);X.STATECHANGED="stateChanged",X.UPDATEAFSM="updateAFSM",X.INIT="[*]",X.ON="on",X.OFF="off",X.instances=new Map,X.instances2=new WeakMap;var K=function(t){function e(){var t;return o(this,e),t=n(this,e,arguments),$(t,"decoder"),$(t,"config"),t}return f(e,t),a(e,[{key:"initialize",value:(i=r(d().mark((function t(){var e=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.decoder=new VideoDecoder({output:function(t){e.emit("videoFrame",t)},error:function(t){e.close(),e.emit("error",t)}});case 1:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"configure",value:function(t){this.config=t,this.decoder.configure(j(O({},t),{codec:this.getCodec(t)}))}},{key:"getCodec",value:function(t){switch(t.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 t.codec}}},{key:"decode",value:function(t){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(t))}},{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}(X);function J(){var t;self.onmessage=function(e){if("init"===e.data.type){var r=e.data,n=r.canvas,o=r.wasmScript,i=r.wasmBinary,a=null==n?void 0:n.getContext("2d"),s=0,c=0,u={wasmBinary:i,postRun:function(){t=new u.VideoDecoder({videoInfo:function(t,e){s=t,c=e,console.log("video info",t,e)},yuvData:function(t,e){var r=s*c,o=r>>2,i=u.HEAPU32[t>>2],f=u.HEAPU32[1+(t>>2)],l=u.HEAPU32[2+(t>>2)],d=u.HEAPU8.subarray(i,i+r),h=u.HEAPU8.subarray(f,f+o),p=u.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:c,format:"I420",timestamp:e});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)()(u)}else if("decode"===e.data.type){var f=e.data.packet;null==t||t.decode(f.data,"key"==f.type,f.timestamp)}else if("setCodec"===e.data.type){var l=e.data,d=l.codec,h=l.format,p=l.description;null==t||t.setCodec(d,h,null!=p?p:"")}}}M([W([X.INIT,"closed"],"initialized")],K.prototype,"initialize"),M([W("initialized","configured",{sync:!0})],K.prototype,"configure"),M([function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(t,r,n){var o=n.value,i=r;n.value=function(){if(!e.includes(this.state.toString()))throw new B(this.state,"".concat(this.name," ").concat(i," failed: current state ").concat(this.state," not in ").concat(e));for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return o.apply(this,r)}}}("configured")],K.prototype,"decode"),M([W([],X.INIT,{sync:!0})],K.prototype,"reset"),M([W([],"closed",{ignoreError:!0,sync:!0})],K.prototype,"close");var Y=function(t){function e(t,r){var i,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3?arguments[3]:void 0,c=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return o(this,e),(i=n(this,e)).createModule=t,i.wasmBinary=r,i.workerMode=a,i.canvas=s,i.yuvMode=c,$(i,"worker"),$(i,"decoder"),$(i,"config"),$(i,"module",{}),$(i,"width",0),$(i,"height",0),i}return f(e,t),a(e,[{key:"initialize",value:(i=r(d().mark((function t(e){var r,n,o,i,a,s=this;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.workerMode){t.next=10;break}return n=new RegExp("\\{(.+)\\}","s").exec(J.toString())[1],this.worker=new Worker(URL.createObjectURL(new Blob([n],{type:"text/javascript"}))),o=null==(r=this.canvas)?void 0:r.transferControlToOffscreen(),t.next=6,this.wasmBinary;case 6:return i=t.sent,console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:o,wasmScript:this.createModule.toString(),wasmBinary:i},o?[o,i]:[i]),t.abrupt("return",new Promise((function(t){s.worker.onmessage=function(e){if("ready"===e.data.type)delete s.wasmBinary,t(),console.warn("worker mode initialize success");else if("yuvData"===e.data.type){var r=e.data.videoFrame;s.emit("videoFrame",r)}}})));case 10:if(a=this.module,!this.wasmBinary){t.next=15;break}return t.next=14,this.wasmBinary;case 14:a.wasmBinary=t.sent;case 15:return a.print=function(t){return console.log(t)},a.printErr=function(t){return console.log("[JS] ERROR: ".concat(t))},a.onAbort=function(){return console.log("[JS] FATAL: WASM ABORTED")},t.abrupt("return",new Promise((function(t){a.postRun=function(e){s.decoder=new s.module.VideoDecoder(s),console.log("video soft decoder initialize success"),t()},e&&Object.assign(a,e),s.createModule(a)})));case 19:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"configure",value:function(t){var e,r,n;this.config=t;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!=(e=this.config.description)?e:""),null==(n=this.worker)||n.postMessage({type:"setCodec",codec:o,format:i,description:this.config.description})}},{key:"decode",value:function(t){var e,r;null==(e=this.decoder)||e.decode(t.data,"key"==t.type,t.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:t}))}},{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(t,e){this.width=t,this.height=e;var r={width:t,height:e};this.emit("videoCodecInfo",r)}},{key:"yuvData",value:function(t,e){if(this.module){var r=this.width*this.height,n=r>>2,o=this.module.HEAPU32[t>>2],i=this.module.HEAPU32[1+(t>>2)],a=this.module.HEAPU32[2+(t>>2)],s=this.module.HEAPU8.subarray(o,o+r),c=this.module.HEAPU8.subarray(i,i+n),u=this.module.HEAPU8.subarray(a,a+n);if(this.yuvMode)this.emit("videoFrame",{y:s,u:c,v:u,timestamp:e});else{var f=new Uint8Array(r+n+n);f.set(s),f.set(c,r),f.set(u,r+n),this.emit("videoFrame",new VideoFrame(f,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:e}))}}}},{key:"errorInfo",value:function(t){var e={errMsg:t};this.emit("error",e)}}]);var i}(X);M([W([X.INIT,"closed"],"initialized")],Y.prototype,"initialize"),M([W("initialized","configured",{sync:!0})],Y.prototype,"configure"),M([W([],X.INIT,{sync:!0})],Y.prototype,"reset"),M([W([],"closed",{sync:!0})],Y.prototype,"close");var Z,Q=(Z="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r;i.ready=new Promise((function(r,n){t=r,e=n}));var s=Object.assign({},i),u="./this.program",l="object"==("undefined"==typeof window?"undefined":m(window)),d="function"==typeof importScripts;"object"==("undefined"==typeof process?"undefined":m(process))&&"object"==m(process.versions)&&process.versions.node;var h,p,v,y="";(l||d)&&(d?y=self.location.href:"undefined"!=typeof document&&document.currentScript&&(y=document.currentScript.src),Z&&(y=Z),y=0!==y.indexOf("blob:")?y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1):"",h=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},d&&(v=function(t){var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),p=function(t,e,r){var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?e(n.response):r()},n.onerror=r,n.send(null)});var w,b,E,k=i.print||console.log.bind(console),_=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(u=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=("undefined"==typeof WebAssembly?"undefined":m(WebAssembly))&&q("no native wasm support detected");var P,T,C,S,A,D,x,F,O,j=!1,M=[],$=[],R=[];function L(t){M.unshift(t)}function z(t){R.unshift(t)}var N,I,B,U,W=0,H=null;function V(t){W++,i.monitorRunDependencies&&i.monitorRunDependencies(W)}function G(t){if(W--,i.monitorRunDependencies&&i.monitorRunDependencies(W),0==W&&H){var e=H;H=null,e()}}function q(t){i.onAbort&&i.onAbort(t),_(t="Aborted("+t+")"),j=!0,t+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(t);throw e(r),r}function X(t){return t.startsWith("data:application/octet-stream;base64,")}function K(t){if(t==N&&w)return new Uint8Array(w);if(v)return v(t);throw"both async and sync fetching of the wasm failed"}function J(t,e,r){return function(t){return w||!l&&!d||"function"!=typeof fetch?Promise.resolve().then((function(){return K(t)})):fetch(t,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()})).catch((function(){return K(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(r,(function(t){_("failed to asynchronously prepare wasm: "+t),q(t)}))}X(N="videodec.wasm")||(I=N,N=i.locateFile?i.locateFile(I,y):y+I);var Y=function(t){for(;t.length>0;)t.shift()(i)};function Q(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){D[this.ptr+4>>2]=t},this.get_type=function(){return D[this.ptr+4>>2]},this.set_destructor=function(t){D[this.ptr+8>>2]=t},this.get_destructor=function(){return D[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,P[this.ptr+12|0]=t},this.get_caught=function(){return 0!=P[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,P[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=P[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){D[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return D[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Qe(this.get_type()))return D[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}var tt={isAbs:function(t){return"/"===t.charAt(0)},splitPath:function(t){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(t).slice(1)},normalizeArray:function(t,e){for(var r=0,n=t.length-1;n>=0;n--){var o=t[n];"."===o?t.splice(n,1):".."===o?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r;r--)t.unshift("..");return t},normalize:function(t){var e=tt.isAbs(t),r="/"===t.substr(-1);return(t=tt.normalizeArray(t.split("/").filter((function(t){return!!t})),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t},dirname:function(t){var e=tt.splitPath(t),r=e[0],n=e[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},basename:function(t){if("/"===t)return"/";var e=(t=(t=tt.normalize(t)).replace(/\/$/,"")).lastIndexOf("/");return-1===e?t:t.substr(e+1)},join:function(){var t=Array.prototype.slice.call(arguments);return tt.normalize(t.join("/"))},join2:function(t,e){return tt.normalize(t+"/"+e)}},et=function(t){return(et=function(){if("object"==("undefined"==typeof crypto?"undefined":m(crypto))&&"function"==typeof crypto.getRandomValues)return function(t){return crypto.getRandomValues(t)};q("initRandomDevice")}())(t)},rt={resolve:function(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:vt.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";t=n+"/"+t,e=tt.isAbs(n)}return(e?"/":"")+(t=tt.normalizeArray(t.split("/").filter((function(t){return!!t})),!e).join("/"))||"."},relative:function(t,e){function r(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=rt.resolve(t).substr(1),e=rt.resolve(e).substr(1);for(var n=r(t.split("/")),o=r(e.split("/")),i=Math.min(n.length,o.length),a=i,s=0;s<i;s++)if(n[s]!==o[s]){a=s;break}var c=[];for(s=a;s<n.length;s++)c.push("..");return(c=c.concat(o.slice(a))).join("/")}},nt="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,ot=function(t,e,r){for(var n=e+r,o=e;t[o]&&!(o>=n);)++o;if(o-e>16&&t.buffer&&nt)return nt.decode(t.subarray(e,o));for(var i="";e<o;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var c=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|c:(7&a)<<18|s<<12|c<<6|63&t[e++])<65536)i+=String.fromCharCode(a);else{var u=a-65536;i+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i},it=[],at=function(t){for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++r):e+=3}return e},st=function(t,e,r,n){if(!(n>0))return 0;for(var o=r,i=r+n-1,a=0;a<t.length;++a){var s=t.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++a)),s<=127){if(r>=i)break;e[r++]=s}else if(s<=2047){if(r+1>=i)break;e[r++]=192|s>>6,e[r++]=128|63&s}else if(s<=65535){if(r+2>=i)break;e[r++]=224|s>>12,e[r++]=128|s>>6&63,e[r++]=128|63&s}else{if(r+3>=i)break;e[r++]=240|s>>18,e[r++]=128|s>>12&63,e[r++]=128|s>>6&63,e[r++]=128|63&s}}return e[r]=0,r-o};function ct(t,e,r){var n=at(t)+1,o=new Array(n),i=st(t,o,0,o.length);return o.length=i,o}var ut={ttys:[],init:function(){},shutdown:function(){},register:function(t,e){ut.ttys[t]={input:[],output:[],ops:e},vt.registerDevice(t,ut.stream_ops)},stream_ops:{open:function(t){var e=ut.ttys[t.node.rdev];if(!e)throw new vt.ErrnoError(43);t.tty=e,t.seekable=!1},close:function(t){t.tty.ops.fsync(t.tty)},fsync:function(t){t.tty.ops.fsync(t.tty)},read:function(t,e,r,n,o){if(!t.tty||!t.tty.ops.get_char)throw new vt.ErrnoError(60);for(var i=0,a=0;a<n;a++){var s;try{s=t.tty.ops.get_char(t.tty)}catch(t){throw new vt.ErrnoError(29)}if(void 0===s&&0===i)throw new vt.ErrnoError(6);if(null==s)break;i++,e[r+a]=s}return i&&(t.node.timestamp=Date.now()),i},write:function(t,e,r,n,o){if(!t.tty||!t.tty.ops.put_char)throw new vt.ErrnoError(60);try{for(var i=0;i<n;i++)t.tty.ops.put_char(t.tty,e[r+i])}catch(t){throw new vt.ErrnoError(29)}return n&&(t.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(t){return function(){if(!it.length){var t=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n"),!t)return null;it=ct(t)}return it.shift()}()},put_char:function(t,e){null===e||10===e?(k(ot(t.output,0)),t.output=[]):0!=e&&t.output.push(e)},fsync:function(t){t.output&&t.output.length>0&&(k(ot(t.output,0)),t.output=[])},ioctl_tcgets:function(t){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(t,e,r){return 0},ioctl_tiocgwinsz:function(t){return[24,80]}},default_tty1_ops:{put_char:function(t,e){null===e||10===e?(_(ot(t.output,0)),t.output=[]):0!=e&&t.output.push(e)},fsync:function(t){t.output&&t.output.length>0&&(_(ot(t.output,0)),t.output=[])}}},ft=function(t){q()},lt={ops_table:null,mount:function(t){return lt.createNode(null,"/",16895,0)},createNode:function(t,e,r,n){if(vt.isBlkdev(r)||vt.isFIFO(r))throw new vt.ErrnoError(63);lt.ops_table||(lt.ops_table={dir:{node:{getattr:lt.node_ops.getattr,setattr:lt.node_ops.setattr,lookup:lt.node_ops.lookup,mknod:lt.node_ops.mknod,rename:lt.node_ops.rename,unlink:lt.node_ops.unlink,rmdir:lt.node_ops.rmdir,readdir:lt.node_ops.readdir,symlink:lt.node_ops.symlink},stream:{llseek:lt.stream_ops.llseek}},file:{node:{getattr:lt.node_ops.getattr,setattr:lt.node_ops.setattr},stream:{llseek:lt.stream_ops.llseek,read:lt.stream_ops.read,write:lt.stream_ops.write,allocate:lt.stream_ops.allocate,mmap:lt.stream_ops.mmap,msync:lt.stream_ops.msync}},link:{node:{getattr:lt.node_ops.getattr,setattr:lt.node_ops.setattr,readlink:lt.node_ops.readlink},stream:{}},chrdev:{node:{getattr:lt.node_ops.getattr,setattr:lt.node_ops.setattr},stream:vt.chrdev_stream_ops}});var o=vt.createNode(t,e,r,n);return vt.isDir(o.mode)?(o.node_ops=lt.ops_table.dir.node,o.stream_ops=lt.ops_table.dir.stream,o.contents={}):vt.isFile(o.mode)?(o.node_ops=lt.ops_table.file.node,o.stream_ops=lt.ops_table.file.stream,o.usedBytes=0,o.contents=null):vt.isLink(o.mode)?(o.node_ops=lt.ops_table.link.node,o.stream_ops=lt.ops_table.link.stream):vt.isChrdev(o.mode)&&(o.node_ops=lt.ops_table.chrdev.node,o.stream_ops=lt.ops_table.chrdev.stream),o.timestamp=Date.now(),t&&(t.contents[e]=o,t.timestamp=o.timestamp),o},getFileDataAsTypedArray:function(t){return t.contents?t.contents.subarray?t.contents.subarray(0,t.usedBytes):new Uint8Array(t.contents):new Uint8Array(0)},expandFileStorage:function(t,e){var r=t.contents?t.contents.length:0;if(!(r>=e)){e=Math.max(e,r*(r<1048576?2:1.125)>>>0),0!=r&&(e=Math.max(e,256));var n=t.contents;t.contents=new Uint8Array(e),t.usedBytes>0&&t.contents.set(n.subarray(0,t.usedBytes),0)}},resizeFileStorage:function(t,e){if(t.usedBytes!=e)if(0==e)t.contents=null,t.usedBytes=0;else{var r=t.contents;t.contents=new Uint8Array(e),r&&t.contents.set(r.subarray(0,Math.min(e,t.usedBytes))),t.usedBytes=e}},node_ops:{getattr:function(t){var e={};return e.dev=vt.isChrdev(t.mode)?t.id:1,e.ino=t.id,e.mode=t.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=t.rdev,vt.isDir(t.mode)?e.size=4096:vt.isFile(t.mode)?e.size=t.usedBytes:vt.isLink(t.mode)?e.size=t.link.length:e.size=0,e.atime=new Date(t.timestamp),e.mtime=new Date(t.timestamp),e.ctime=new Date(t.timestamp),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr:function(t,e){void 0!==e.mode&&(t.mode=e.mode),void 0!==e.timestamp&&(t.timestamp=e.timestamp),void 0!==e.size&&lt.resizeFileStorage(t,e.size)},lookup:function(t,e){throw vt.genericErrors[44]},mknod:function(t,e,r,n){return lt.createNode(t,e,r,n)},rename:function(t,e,r){if(vt.isDir(t.mode)){var n;try{n=vt.lookupNode(e,r)}catch(t){}if(n)for(var o in n.contents)throw new vt.ErrnoError(55)}delete t.parent.contents[t.name],t.parent.timestamp=Date.now(),t.name=r,e.contents[r]=t,e.timestamp=t.parent.timestamp,t.parent=e},unlink:function(t,e){delete t.contents[e],t.timestamp=Date.now()},rmdir:function(t,e){var r=vt.lookupNode(t,e);for(var n in r.contents)throw new vt.ErrnoError(55);delete t.contents[e],t.timestamp=Date.now()},readdir:function(t){var e=[".",".."];for(var r in t.contents)t.contents.hasOwnProperty(r)&&e.push(r);return e},symlink:function(t,e,r){var n=lt.createNode(t,e,41471,0);return n.link=r,n},readlink:function(t){if(!vt.isLink(t.mode))throw new vt.ErrnoError(28);return t.link}},stream_ops:{read:function(t,e,r,n,o){var i=t.node.contents;if(o>=t.node.usedBytes)return 0;var a=Math.min(t.node.usedBytes-o,n);if(a>8&&i.subarray)e.set(i.subarray(o,o+a),r);else for(var s=0;s<a;s++)e[r+s]=i[o+s];return a},write:function(t,e,r,n,o,i){if(!n)return 0;var a=t.node;if(a.timestamp=Date.now(),e.subarray&&(!a.contents||a.contents.subarray)){if(i)return a.contents=e.subarray(r,r+n),a.usedBytes=n,n;if(0===a.usedBytes&&0===o)return a.contents=e.slice(r,r+n),a.usedBytes=n,n;if(o+n<=a.usedBytes)return a.contents.set(e.subarray(r,r+n),o),n}if(lt.expandFileStorage(a,o+n),a.contents.subarray&&e.subarray)a.contents.set(e.subarray(r,r+n),o);else for(var s=0;s<n;s++)a.contents[o+s]=e[r+s];return a.usedBytes=Math.max(a.usedBytes,o+n),n},llseek:function(t,e,r){var n=e;if(1===r?n+=t.position:2===r&&vt.isFile(t.node.mode)&&(n+=t.node.usedBytes),n<0)throw new vt.ErrnoError(28);return n},allocate:function(t,e,r){lt.expandFileStorage(t.node,e+r),t.node.usedBytes=Math.max(t.node.usedBytes,e+r)},mmap:function(t,e,r,n,o){if(!vt.isFile(t.node.mode))throw new vt.ErrnoError(43);var i,a,s=t.node.contents;if(2&o||s.buffer!==P.buffer){if((r>0||r+e<s.length)&&(s=s.subarray?s.subarray(r,r+e):Array.prototype.slice.call(s,r,r+e)),a=!0,!(i=ft()))throw new vt.ErrnoError(48);P.set(s,i)}else a=!1,i=s.byteOffset;return{ptr:i,allocated:a}},msync:function(t,e,r,n,o){return lt.stream_ops.write(t,e,0,n,r,!1),0}}},dt=function(t,e,r,n){var o="al ".concat(t);p(t,(function(r){var n,i;n=r,i='Loading data file "'.concat(t,'" failed (no arrayBuffer).'),n||q(i),e(new Uint8Array(r)),o&&G()}),(function(e){if(!r)throw'Loading data file "'.concat(t,'" failed.');r()})),o&&V()},ht=i.preloadPlugins||[];function pt(t,e){var r=0;return t&&(r|=365),e&&(r|=146),r}var vt={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t=rt.resolve(t)))return{path:"",node:null};if((e=Object.assign({follow_mount:!0,recurse_count:0},e)).recurse_count>8)throw new vt.ErrnoError(32);for(var r=t.split("/").filter((function(t){return!!t})),n=vt.root,o="/",i=0;i<r.length;i++){var a=i===r.length-1;if(a&&e.parent)break;if(n=vt.lookupNode(n,r[i]),o=tt.join2(o,r[i]),vt.isMountpoint(n)&&(!a||a&&e.follow_mount)&&(n=n.mounted.root),!a||e.follow)for(var s=0;vt.isLink(n.mode);){var c=vt.readlink(o);if(o=rt.resolve(tt.dirname(o),c),n=vt.lookupPath(o,{recurse_count:e.recurse_count+1}).node,s++>40)throw new vt.ErrnoError(32)}}return{path:o,node:n}},getPath:function(t){for(var e;;){if(vt.isRoot(t)){var r=t.mount.mountpoint;return e?"/"!==r[r.length-1]?"".concat(r,"/").concat(e):r+e:r}e=e?"".concat(t.name,"/").concat(e):t.name,t=t.parent}},hashName:function(t,e){for(var r=0,n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n)|0;return(t+r>>>0)%vt.nameTable.length},hashAddNode:function(t){var e=vt.hashName(t.parent.id,t.name);t.name_next=vt.nameTable[e],vt.nameTable[e]=t},hashRemoveNode:function(t){var e=vt.hashName(t.parent.id,t.name);if(vt.nameTable[e]===t)vt.nameTable[e]=t.name_next;else for(var r=vt.nameTable[e];r;){if(r.name_next===t){r.name_next=t.name_next;break}r=r.name_next}},lookupNode:function(t,e){var r=vt.mayLookup(t);if(r)throw new vt.ErrnoError(r,t);for(var n=vt.hashName(t.id,e),o=vt.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===t.id&&i===e)return o}return vt.lookup(t,e)},createNode:function(t,e,r,n){var o=new vt.FSNode(t,e,r,n);return vt.hashAddNode(o),o},destroyNode:function(t){vt.hashRemoveNode(t)},isRoot:function(t){return t===t.parent},isMountpoint:function(t){return!!t.mounted},isFile:function(t){return 32768==(61440&t)},isDir:function(t){return 16384==(61440&t)},isLink:function(t){return 40960==(61440&t)},isChrdev:function(t){return 8192==(61440&t)},isBlkdev:function(t){return 24576==(61440&t)},isFIFO:function(t){return 4096==(61440&t)},isSocket:function(t){return!(49152&~t)},flagsToPermissionString:function(t){var e=["r","w","rw"][3&t];return 512&t&&(e+="w"),e},nodePermissions:function(t,e){return vt.ignorePermissions||(!e.includes("r")||292&t.mode)&&(!e.includes("w")||146&t.mode)&&(!e.includes("x")||73&t.mode)?0:2},mayLookup:function(t){var e=vt.nodePermissions(t,"x");return e||(t.node_ops.lookup?0:2)},mayCreate:function(t,e){try{return vt.lookupNode(t,e),20}catch(t){}return vt.nodePermissions(t,"wx")},mayDelete:function(t,e,r){var n;try{n=vt.lookupNode(t,e)}catch(t){return t.errno}var o=vt.nodePermissions(t,"wx");if(o)return o;if(r){if(!vt.isDir(n.mode))return 54;if(vt.isRoot(n)||vt.getPath(n)===vt.cwd())return 10}else if(vt.isDir(n.mode))return 31;return 0},mayOpen:function(t,e){return t?vt.isLink(t.mode)?32:vt.isDir(t.mode)&&("r"!==vt.flagsToPermissionString(e)||512&e)?31:vt.nodePermissions(t,vt.flagsToPermissionString(e)):44},MAX_OPEN_FDS:4096,nextfd:function(){for(var t=0;t<=vt.MAX_OPEN_FDS;t++)if(!vt.streams[t])return t;throw new vt.ErrnoError(33)},getStreamChecked:function(t){var e=vt.getStream(t);if(!e)throw new vt.ErrnoError(8);return e},getStream:function(t){return vt.streams[t]},createStream:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return vt.FSStream||(vt.FSStream=function(){this.shared={}},vt.FSStream.prototype={},Object.defineProperties(vt.FSStream.prototype,{object:{get:function(){return this.node},set:function(t){this.node=t}},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(t){this.shared.flags=t}},position:{get:function(){return this.shared.position},set:function(t){this.shared.position=t}}})),t=Object.assign(new vt.FSStream,t),-1==e&&(e=vt.nextfd()),t.fd=e,vt.streams[e]=t,t},closeStream:function(t){vt.streams[t]=null},chrdev_stream_ops:{open:function(t){var e=vt.getDevice(t.node.rdev);t.stream_ops=e.stream_ops,t.stream_ops.open&&t.stream_ops.open(t)},llseek:function(){throw new vt.ErrnoError(70)}},major:function(t){return t>>8},minor:function(t){return 255&t},makedev:function(t,e){return t<<8|e},registerDevice:function(t,e){vt.devices[t]={stream_ops:e}},getDevice:function(t){return vt.devices[t]},getMounts:function(t){for(var e=[],r=[t];r.length;){var n=r.pop();e.push(n),r.push.apply(r,n.mounts)}return e},syncfs:function(t,e){"function"==typeof t&&(e=t,t=!1),vt.syncFSRequests++,vt.syncFSRequests>1&&_("warning: ".concat(vt.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=vt.getMounts(vt.root.mount),n=0;function o(t){return vt.syncFSRequests--,e(t)}function i(t){if(t)return i.errored?void 0:(i.errored=!0,o(t));++n>=r.length&&o(null)}r.forEach((function(e){if(!e.type.syncfs)return i(null);e.type.syncfs(e,t,i)}))},mount:function(t,e,r){var n,o="/"===r,i=!r;if(o&&vt.root)throw new vt.ErrnoError(10);if(!o&&!i){var a=vt.lookupPath(r,{follow_mount:!1});if(r=a.path,n=a.node,vt.isMountpoint(n))throw new vt.ErrnoError(10);if(!vt.isDir(n.mode))throw new vt.ErrnoError(54)}var s={type:t,opts:e,mountpoint:r,mounts:[]},c=t.mount(s);return c.mount=s,s.root=c,o?vt.root=c:n&&(n.mounted=s,n.mount&&n.mount.mounts.push(s)),c},unmount:function(t){var e=vt.lookupPath(t,{follow_mount:!1});if(!vt.isMountpoint(e.node))throw new vt.ErrnoError(28);var r=e.node,n=r.mounted,o=vt.getMounts(n);Object.keys(vt.nameTable).forEach((function(t){for(var e=vt.nameTable[t];e;){var r=e.name_next;o.includes(e.mount)&&vt.destroyNode(e),e=r}})),r.mounted=null;var i=r.mount.mounts.indexOf(n);r.mount.mounts.splice(i,1)},lookup:function(t,e){return t.node_ops.lookup(t,e)},mknod:function(t,e,r){var n=vt.lookupPath(t,{parent:!0}).node,o=tt.basename(t);if(!o||"."===o||".."===o)throw new vt.ErrnoError(28);var i=vt.mayCreate(n,o);if(i)throw new vt.ErrnoError(i);if(!n.node_ops.mknod)throw new vt.ErrnoError(63);return n.node_ops.mknod(n,o,e,r)},create:function(t,e){return e=void 0!==e?e:438,e&=4095,e|=32768,vt.mknod(t,e,0)},mkdir:function(t,e){return e=void 0!==e?e:511,e&=1023,e|=16384,vt.mknod(t,e,0)},mkdirTree:function(t,e){for(var r=t.split("/"),n="",o=0;o<r.length;++o)if(r[o]){n+="/"+r[o];try{vt.mkdir(n,e)}catch(t){if(20!=t.errno)throw t}}},mkdev:function(t,e,r){return void 0===r&&(r=e,e=438),e|=8192,vt.mknod(t,e,r)},symlink:function(t,e){if(!rt.resolve(t))throw new vt.ErrnoError(44);var r=vt.lookupPath(e,{parent:!0}).node;if(!r)throw new vt.ErrnoError(44);var n=tt.basename(e),o=vt.mayCreate(r,n);if(o)throw new vt.ErrnoError(o);if(!r.node_ops.symlink)throw new vt.ErrnoError(63);return r.node_ops.symlink(r,n,t)},rename:function(t,e){var r,n,o=tt.dirname(t),i=tt.dirname(e),a=tt.basename(t),s=tt.basename(e);if(r=vt.lookupPath(t,{parent:!0}).node,n=vt.lookupPath(e,{parent:!0}).node,!r||!n)throw new vt.ErrnoError(44);if(r.mount!==n.mount)throw new vt.ErrnoError(75);var c,u=vt.lookupNode(r,a),f=rt.relative(t,i);if("."!==f.charAt(0))throw new vt.ErrnoError(28);if("."!==(f=rt.relative(e,o)).charAt(0))throw new vt.ErrnoError(55);try{c=vt.lookupNode(n,s)}catch(t){}if(u!==c){var l=vt.isDir(u.mode),d=vt.mayDelete(r,a,l);if(d)throw new vt.ErrnoError(d);if(d=c?vt.mayDelete(n,s,l):vt.mayCreate(n,s))throw new vt.ErrnoError(d);if(!r.node_ops.rename)throw new vt.ErrnoError(63);if(vt.isMountpoint(u)||c&&vt.isMountpoint(c))throw new vt.ErrnoError(10);if(n!==r&&(d=vt.nodePermissions(r,"w")))throw new vt.ErrnoError(d);vt.hashRemoveNode(u);try{r.node_ops.rename(u,n,s)}catch(t){throw t}finally{vt.hashAddNode(u)}}},rmdir:function(t){var e=vt.lookupPath(t,{parent:!0}).node,r=tt.basename(t),n=vt.lookupNode(e,r),o=vt.mayDelete(e,r,!0);if(o)throw new vt.ErrnoError(o);if(!e.node_ops.rmdir)throw new vt.ErrnoError(63);if(vt.isMountpoint(n))throw new vt.ErrnoError(10);e.node_ops.rmdir(e,r),vt.destroyNode(n)},readdir:function(t){var e=vt.lookupPath(t,{follow:!0}).node;if(!e.node_ops.readdir)throw new vt.ErrnoError(54);return e.node_ops.readdir(e)},unlink:function(t){var e=vt.lookupPath(t,{parent:!0}).node;if(!e)throw new vt.ErrnoError(44);var r=tt.basename(t),n=vt.lookupNode(e,r),o=vt.mayDelete(e,r,!1);if(o)throw new vt.ErrnoError(o);if(!e.node_ops.unlink)throw new vt.ErrnoError(63);if(vt.isMountpoint(n))throw new vt.ErrnoError(10);e.node_ops.unlink(e,r),vt.destroyNode(n)},readlink:function(t){var e=vt.lookupPath(t).node;if(!e)throw new vt.ErrnoError(44);if(!e.node_ops.readlink)throw new vt.ErrnoError(28);return rt.resolve(vt.getPath(e.parent),e.node_ops.readlink(e))},stat:function(t,e){var r=vt.lookupPath(t,{follow:!e}).node;if(!r)throw new vt.ErrnoError(44);if(!r.node_ops.getattr)throw new vt.ErrnoError(63);return r.node_ops.getattr(r)},lstat:function(t){return vt.stat(t,!0)},chmod:function(t,e,r){var n;if(!(n="string"==typeof t?vt.lookupPath(t,{follow:!r}).node:t).node_ops.setattr)throw new vt.ErrnoError(63);n.node_ops.setattr(n,{mode:4095&e|-4096&n.mode,timestamp:Date.now()})},lchmod:function(t,e){vt.chmod(t,e,!0)},fchmod:function(t,e){var r=vt.getStreamChecked(t);vt.chmod(r.node,e)},chown:function(t,e,r,n){var o;if(!(o="string"==typeof t?vt.lookupPath(t,{follow:!n}).node:t).node_ops.setattr)throw new vt.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:function(t,e,r){vt.chown(t,e,r,!0)},fchown:function(t,e,r){var n=vt.getStreamChecked(t);vt.chown(n.node,e,r)},truncate:function(t,e){if(e<0)throw new vt.ErrnoError(28);var r;if(!(r="string"==typeo