opus-codec-worker 2.0.0 → 2.0.1
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/package.json +1 -1
- package/worker.js +1 -1
- package/worklet/worklet.js +1 -1
package/package.json
CHANGED
package/worker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see worker.js.LICENSE.txt */
|
|
2
|
-
(()=>{var e,t,r={178(){},306(){}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&r;("object"==typeof s||"function"==typeof s)&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,o.d(i,a),i},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e;function t(e){return t="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},t(e)}function r(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,r,n){return(r=function(e){var r=function(e){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function s(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var s=n&&n.prototype instanceof c?n:c,l=Object.create(s.prototype);return u(l,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,u=e,h.n=r,a}};function d(r,n){for(s=r,u=n,t=0;!f&&c&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,u=p;(t=s<2?e:u)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function l(){}function f(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(u(t={},n,function(){return this}),t),d=f.prototype=c.prototype=Object.create(h);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,u(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,u(d,"constructor",f),u(f,"constructor",l),l.displayName="GeneratorFunction",u(f,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:p}})()}function u(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}u=function(e,t,r,n){function i(t,r){u(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},u(e,t,r,n)}function c(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 l(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){c(i,n,o,a,s,"next",e)}function s(e){c(i,n,o,a,s,"throw",e)}a(void 0)})}}function f(e){return h.apply(this,arguments)}function h(){return(h=l(s().m(function e(t){var r,n,i,a,u,c,l,f;return s().w(function(e){for(;;)switch(e.n){case 0:if(r=t.wasmFileHref,n=t.importObject,!("process"in globalThis)||"nodejs"!==process.env.RUNTIME){e.n=4;break}return e.n=1,Promise.resolve().then(o.t.bind(o,306,19));case 1:return a=e.v,e.n=2,Promise.resolve().then(o.t.bind(o,178,19));case 2:return u=e.v,c=u.resolve("/","index.wasm"),e.n=3,a.promises.readFile(c);case 3:l=e.v,i=WebAssembly.instantiate(l,n),e.n=8;break;case 4:if("string"==typeof r){e.n=5;break}throw new Error("Invalid wasmFileHref");case 5:return e.n=6,fetch(r);case 6:return f=e.v,e.n=7,WebAssembly.instantiateStreaming(f,n);case 7:i=e.v;case 8:return e.a(2,i)}},e)}))).apply(this,arguments)}function d(){return d=l(s().m(function e(){var t,n,o,a,u,c,l,h,d,p=arguments;return s().w(function(e){for(;;)switch(e.n){case 0:n=(p.length>0&&void 0!==p[0]?p[0]:{}).wasmFileHref,o={},a=s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.n){case 0:t=c[u],o[t]=function(e){return console.log("[%s] called with %o",t,e),0};case 1:return e.a(2)}},e)}),u=0,c=["args_get","args_sizes_get","fd_close","fd_seek","fd_write","proc_exit"];case 1:if(!(u<c.length)){e.n=3;break}return e.d(r(a()),2);case 2:u++,e.n=1;break;case 3:return l={wasi_snapshot_preview1:o},e.n=4,f({wasmFileHref:n,importObject:l});case 4:if(h=e.v,null!==(d=null!==(t=h.instance.exports.memory)&&void 0!==t?t:null)){e.n=5;break}throw new Error("Memory was expected to be imported but is null");case 5:return e.a(2,i(i({},h.instance.exports),{},{memory:d}))}},e)})),d.apply(this,arguments)}!function(e){e[e.CreateEncoder=0]="CreateEncoder",e[e.CreateDecoder=1]="CreateDecoder",e[e.EncodeFloat=2]="EncodeFloat",e[e.DecodeFloat=3]="DecodeFloat",e[e.DestroyEncoder=4]="DestroyEncoder",e[e.InitializeWorker=5]="InitializeWorker",e[e.DestroyDecoder=6]="DestroyDecoder",e[e.OpusGetRequest=7]="OpusGetRequest",e[e.OpusSetRequest=8]="OpusSetRequest"}(e||(e={}));const p=function(){return d.apply(this,arguments)};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 v(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,b(n.key),n)}}function b(e){var t=function(e){if("object"!=y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==y(t)?t:t+""}function m(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function w(e,t){return e.get(_(e,t))}function g(e,t,r){return e.set(_(e,t),r),r}function _(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var S=new WeakMap,E=new WeakMap,P=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),m(this,S,void 0),m(this,E,void 0),g(S,this,t),g(E,this,t.malloc(t.originalRuntime().size_of_int()))},(t=[{key:"value",value:function(){if(4!==w(S,this).originalRuntime().size_of_int())throw new Error("invalid integer byte size");return w(S,this).view().getInt32(w(E,this),!0)}},{key:"set",value:function(e){w(S,this).view().setInt32(w(E,this),e,!0)}},{key:"size",value:function(){return w(S,this).originalRuntime().size_of_int()}},{key:"offset",value:function(){if(0===w(E,this))throw new Error("Integer has been destroyed");return w(E,this)}},{key:"destroy",value:function(){w(S,this).free(w(E,this)),g(E,this,0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function k(e){return k="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},k(e)}function T(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){if(Object(r)!==r)return;u=!1}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)||O(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 O(e,t){if(e){if("string"==typeof e)return I(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function I(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 R(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,j(n.key),n)}}function j(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=k(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}function G(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function A(e,t){return e.get(D(e,t))}function D(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var F=new WeakMap,C=new WeakMap,x=function(){return e=function e(t){var r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),G(this,F,void 0),G(this,C,new Map),n=t,(r=F).set(D(r,this),n)},t=[{key:"originalRuntime",value:function(){return A(F,this)}},{key:"subarray",value:function(e,t){return new Uint8Array(A(F,this).memory.buffer,e,t-e)}},{key:"free",value:function(e){A(C,this).delete(e),A(F,this).free(e)}},{key:"view",value:function(){return new DataView(A(F,this).memory.buffer)}},{key:"malloc",value:function(e){var t,r=A(F,this).malloc(e);if(!r)throw new Error("Failed to allocate ".concat(e," bytes"));var n=null!==(t=(new Error).stack)&&void 0!==t?t:null;return A(C,this).set(r,n),r}},{key:Symbol.dispose,value:function(){var e,t=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=O(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}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 o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(A(C,this));try{for(t.s();!(e=t.n()).done;){var r=T(e.value,2),n=r[0],o=r[1];throw new Error("Memory leak detected at offset ".concat(n,"\nAllocation stack:\n").concat(o))}}catch(e){t.e(e)}finally{t.f()}}}],t&&R(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function B(e){return B="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},B(e)}function L(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,U(n.key),n)}}function U(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}function M(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function N(e,t){return e.get(q(e,t))}function W(e,t,r){return e.set(q(e,t),r),r}function q(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var z=new WeakMap,H=new WeakMap,V=new WeakMap,X=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),M(this,z,void 0),M(this,H,void 0),M(this,V,void 0),W(V,this,t),W(H,this,r),W(z,this,t.malloc(r))},(t=[{key:"offset",value:function(){return N(z,this)}},{key:"data",value:function(){return N(V,this).subarray(N(z,this),N(z,this)+N(H,this))}},{key:"size",value:function(){return N(H,this)}},{key:"destroy",value:function(){N(V,this).free(N(z,this)),W(z,this,0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&L(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,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 $(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 K(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,J(n.key),n)}}function J(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}function Q(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Z(e,t){return e.get(ee(e,t))}function ee(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var te=new WeakMap,re=new WeakMap,ne=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Q(this,te,new Set),Q(this,re,!1)},(t=[{key:"add",value:function(e){Z(te,this).add(e)}},{key:"destroy",value:function(){if(Z(re,this))throw new Error("ResourcesHolder already destroyed");var e,t,r,n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return $(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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}}}}(Z(te,this));try{for(n.s();!(e=n.n()).done;)e.value.destroy()}catch(e){n.e(e)}finally{n.f()}Z(te,this).clear(),r=this,(t=re).set(ee(t,r),!0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&K(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();class oe extends Error{constructor(e){super(e)}}function ie({name:e,value:t,validations:r}){const n=new Array;if(r.integer&&!Number.isSafeInteger(t)&&n.push("It must be an integer."),t>r.max&&n.push(`It must be up to ${r.max}.`),t<r.min&&n.push(`It must be at least ${r.min}.`),n.length>0)throw new oe([`"${t}" is not a valid value for ${e}. It failed to following validations:\n`,...n.map(e=>`\t- ${e}`)].join(""));return t}var ae,se,ue,ce,le,fe,he,de,pe,ye,ve,be,me,we,ge,_e=function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},Se=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};const Ee=4294967295;class Pe{constructor({frameSize:e,frameCacheSize:t=0,preallocateFrameCount:r=10,TypedArrayConstructor:n}){if(ae.add(this),se.set(this,void 0),ue.set(this,void 0),ce.set(this,void 0),le.set(this,void 0),fe.set(this,void 0),he.set(this,void 0),de.set(this,void 0),_e(this,le,ie({value:e,name:"Frame Size",validations:{min:1,integer:!0,max:Ee}}),"f"),_e(this,ue,ie({value:r,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:Ee}}),"f"),_e(this,ce,ie({value:t,name:"Frame Cache Size",validations:{min:0,integer:!1,max:Ee}}),"f"),!("BYTES_PER_ELEMENT"in n))throw new oe("TypedArrayConstructor must be a typed array");_e(this,he,0,"f"),_e(this,de,0,"f"),_e(this,se,n,"f"),_e(this,fe,new ArrayBuffer(Se(this,ae,"m",ge).call(this)),"f")}empty(){return Se(this,ae,"m",ve).call(this)<Se(this,le,"f")}peek(){return Se(this,ae,"m",pe).call(this)}write(e){Se(this,ae,"m",we).call(this,e.length),Se(this,ae,"m",pe).call(this).subarray(Se(this,de,"f"),Se(this,de,"f")+e.length).set(e),_e(this,de,Se(this,de,"f")+e.length,"f")}remainingFrames(){return Math.floor(Se(this,ae,"m",ye).call(this))}drain(){return Se(this,ae,"m",me).call(this,Se(this,ae,"m",ve).call(this))}read(){return Se(this,ae,"m",me).call(this,Se(this,le,"f"))}get[(se=new WeakMap,ue=new WeakMap,ce=new WeakMap,le=new WeakMap,fe=new WeakMap,he=new WeakMap,de=new WeakMap,ae=new WeakSet,pe=function(){return new(Se(this,se,"f"))(Se(this,fe,"f"))},ye=function(){return Se(this,ae,"m",ve).call(this)/Se(this,le,"f")},ve=function(){return Se(this,de,"f")-Se(this,he,"f")},be=function(){return Se(this,ce,"f")>0&&Se(this,ae,"m",ye).call(this)>=Se(this,ce,"f")},me=function(e){if(!e)return null;if(Se(this,ae,"m",ve).call(this)<e)return null;let t=Se(this,ae,"m",pe).call(this).subarray(Se(this,he,"f"),Se(this,he,"f")+e);if(_e(this,he,Se(this,he,"f")+e,"f"),Se(this,he,"f")===Se(this,de,"f")&&(_e(this,de,0,"f"),_e(this,he,0,"f")),Se(this,ae,"m",be).call(this)){const e=this.drain();e&&(t=t.slice(0),this.write(e))}return t},we=function(e){const t=e*Se(this,se,"f").BYTES_PER_ELEMENT;if(Se(this,ae,"m",pe).call(this).length-Se(this,de,"f")<=e){const e=Se(this,fe,"f");_e(this,fe,new ArrayBuffer(e.byteLength+t+Se(this,ae,"m",ge).call(this)),"f"),Se(this,ae,"m",pe).call(this).set(new(Se(this,se,"f"))(e))}return Se(this,ae,"m",pe).call(this).subarray(Se(this,he,"f"),Se(this,he,"f")+Se(this,le,"f"))},ge=function(){return Se(this,le,"f")*Se(this,se,"f").BYTES_PER_ELEMENT*Se(this,ue,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let e;do{e=this.read(),null!==e&&(yield e)}while(null!==e)}}class ke extends Pe{constructor(e,t={}){super(Object.assign(Object.assign({},t),{frameSize:e,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;const Te=0;function Oe(e){return Oe="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},Oe(e)}function Ie(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,Re(n.key),n)}}function Re(e){var t=function(e){if("object"!=Oe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Oe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Oe(t)?t:t+""}function je(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ge(e,t){return e.get(De(e,t))}function Ae(e,t,r){return e.set(De(e,t),r),r}function De(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var Fe=new WeakMap,Ce=new WeakMap,xe=new WeakMap,Be=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),je(this,Fe,void 0),je(this,Ce,void 0),je(this,xe,void 0),Ae(Ce,this,t),Ae(xe,this,new P(t)),Ae(Fe,this,r)},(t=[{key:"setComplexity",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_complexity(Ge(Fe,this),e)===Te}},{key:"getComplexity",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_complexity(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_COMPLEXITY");return Ge(xe,this).value()}},{key:"setBitrate",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_bitrate(Ge(Fe,this),e)===Te}},{key:"getBitrate",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_bitrate(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_BITRATE");return Ge(xe,this).value()}},{key:"setVbr",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_vbr(Ge(Fe,this),e)===Te}},{key:"getVbr",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_vbr(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_VBR");return Ge(xe,this).value()}},{key:"setVbrConstraint",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_vbr_constraint(Ge(Fe,this),e)===Te}},{key:"getVbrConstraint",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_vbr_constraint(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_VBR_CONSTRAINT");return Ge(xe,this).value()}},{key:"setForceChannels",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_force_channels(Ge(Fe,this),e)===Te}},{key:"getForceChannels",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_force_channels(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_FORCE_CHANNELS");return Ge(xe,this).value()}},{key:"setMaxBandwidth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_max_bandwidth(Ge(Fe,this),e)===Te}},{key:"getMaxBandwidth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_max_bandwidth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_MAX_BANDWIDTH");return Ge(xe,this).value()}},{key:"setBandwidth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_bandwidth(Ge(Fe,this),e)===Te}},{key:"setSignal",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_signal(Ge(Fe,this),e)===Te}},{key:"getSignal",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_signal(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_SIGNAL");return Ge(xe,this).value()}},{key:"setApplication",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_application(Ge(Fe,this),e)===Te}},{key:"getApplication",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_application(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_APPLICATION");return Ge(xe,this).value()}},{key:"getLookahead",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_lookahead(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LOOKAHEAD");return Ge(xe,this).value()}},{key:"setInbandFec",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_inband_fec(Ge(Fe,this),e)===Te}},{key:"getInbandFec",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_inband_fec(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_INBAND_FEC");return Ge(xe,this).value()}},{key:"setPacketLossperc",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_packet_loss_perc(Ge(Fe,this),e)===Te}},{key:"getPacketLossperc",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_packet_loss_perc(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PACKET_LOSS_PERC");return Ge(xe,this).value()}},{key:"setDtx",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_dtx(Ge(Fe,this),e)===Te}},{key:"getDtx",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_dtx(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_DTX");return Ge(xe,this).value()}},{key:"setLsbDepth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_lsb_depth(Ge(Fe,this),e)===Te}},{key:"getLsbDepth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_lsb_depth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LSB_DEPTH");return Ge(xe,this).value()}},{key:"setExpertFrameduration",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_expert_frame_duration(Ge(Fe,this),e)===Te}},{key:"getExpertFrameduration",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_expert_frame_duration(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_EXPERT_FRAME_DURATION");return Ge(xe,this).value()}},{key:"setPredictionDisabled",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_prediction_disabled(Ge(Fe,this),e)===Te}},{key:"getPredictionDisabled",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_prediction_disabled(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PREDICTION_DISABLED");return Ge(xe,this).value()}},{key:"getBandwidth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_bandwidth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_BANDWIDTH");return Ge(xe,this).value()}},{key:"getSampleRate",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_sample_rate(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_SAMPLE_RATE");return Ge(xe,this).value()}},{key:"setPhaseInversiondisabled",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_phase_inversion_disabled(Ge(Fe,this),e)===Te}},{key:"getPhaseInversiondisabled",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_phase_inversion_disabled(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PHASE_INVERSION_DISABLED");return Ge(xe,this).value()}},{key:"getInDtx",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_in_dtx(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_IN_DTX");return Ge(xe,this).value()}},{key:"setGain",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_gain(Ge(Fe,this),e)===Te}},{key:"getGain",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_gain(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_GAIN");return Ge(xe,this).value()}},{key:"getLastPacketduration",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_last_packet_duration(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LAST_PACKET_DURATION");return Ge(xe,this).value()}},{key:"getPitch",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_pitch(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PITCH");return Ge(xe,this).value()}},{key:"destroy",value:function(){Ge(xe,this).destroy()}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&Ie(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function Le(e){return Le="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},Le(e)}function Ue(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,Me(n.key),n)}}function Me(e){var t=function(e){if("object"!=Le(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Le(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Le(t)?t:t+""}function Ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ne=function(){return!!e})()}function We(){return We="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=qe(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},We.apply(null,arguments)}function qe(e){return qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},qe(e)}function ze(e,t){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ze(e,t)}function He(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ve(e,t){return e.get(Ye(e,t))}function Xe(e,t,r){return e.set(Ye(e,t),r),r}function Ye(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var $e=new WeakMap,Ke=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,et=new WeakMap,tt=function(e){function t(e,r,n,o,i,a){var s;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),!i)throw new Error("Output buffer length must be more than 0");var u=new P(e),c=e.originalRuntime().opus_encoder_create(r,n,o,u.offset());if(He(s=function(e,t,r){return t=qe(t),function(e,t){if(t&&("object"==Le(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,Ne()?Reflect.construct(t,r||[],qe(e).constructor):t.apply(e,r))}(this,t,[e,c]),$e,void 0),He(s,Ke,void 0),He(s,Je,void 0),He(s,Qe,void 0),He(s,Ze,void 0),He(s,et,void 0),Xe(et,s,new ne),Xe($e,s,u),Xe(Ke,s,e),Xe(Ze,s,new X(e,a)),Xe(Qe,s,new X(e,i)),Ve(et,s).add(Ve(Qe,s)),Ve(et,s).add(Ve(Ze,s)),Ve(et,s).add(Ve($e,s)),Xe(Je,s,c),u.value()<0)throw s.destroy(),new Error("Failed to create encoder");return s}return function(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&&ze(e,t)}(t,e),r=t,n=[{key:"encoded",value:function(){return Ve(Qe,this).data()}},{key:"encodeFloat",value:function(e,t,r){if(r>Ve(Qe,this).size())throw new Error("encoded buffer length is ".concat(Ve(Qe,this).size(),", but maxDataBytes is ").concat(r));Ve(Ze,this).data().set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var n=Ve(Ke,this).originalRuntime().opus_encode_float(Ve(Je,this),Ve(Ze,this).offset(),t,Ve(Qe,this).offset(),r);if(n<0)throw new Error("Failed to encode float: ".concat(n));return n}},{key:"destroy",value:function(){var e,r,n;(e=t,r=this,"function"==typeof(n=We(qe(1&3?e.prototype:e),"destroy",r))?function(e){return n.apply(r,e)}:n)([]),Ve(et,this).destroy(),Ve(Ke,this).originalRuntime().opus_encoder_destroy(Ve(Je,this))}},{key:Symbol.dispose,value:function(){this.destroy()}}],n&&Ue(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Be);function rt(e){return rt="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},rt(e)}function nt(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,ot(n.key),n)}}function ot(e){var t=function(e){if("object"!=rt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=rt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==rt(t)?t:t+""}function it(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function at(e,t){return e.get(ut(e,t))}function st(e,t,r){return e.set(ut(e,t),r),r}function ut(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var ct,lt=new WeakMap,ft=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,yt=new WeakMap,vt=new WeakMap,bt=function(){return e=function e(t,r,n,o){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),it(this,lt,void 0),it(this,ft,void 0),it(this,ht,void 0),it(this,dt,void 0),it(this,pt,void 0),it(this,yt,void 0),it(this,vt,null),st(yt,this,o),st(dt,this,t),st(ht,this,new ne),st(lt,this,new P(t)),at(ht,this).add(at(lt,this)),st(ft,this,t.originalRuntime().opus_decoder_create(r,n,at(lt,this).offset())),!at(ft,this)||at(lt,this).value()<0)throw new Error("Failed to create decoder");st(pt,this,new X(t,at(yt,this)*n*Float32Array.BYTES_PER_ELEMENT)),at(ht,this).add(at(pt,this))},t=[{key:"decodeFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=at(vt,this);r||(r=new X(at(dt,this),e.byteLength)),r.data().byteLength<e.byteLength&&(r.destroy(),r=new X(at(dt,this),e.byteLength)),r.data().set(e),st(vt,this,r);var n=at(dt,this).originalRuntime().opus_decode_float(at(ft,this),r.offset(),e.byteLength,at(pt,this).offset(),at(yt,this),t);if(n<0)throw new Error("Failed to decode float");return n}},{key:"decoded",value:function(){var e=at(pt,this).data();return new Float32Array(e.buffer,e.byteOffset,e.byteLength/Float32Array.BYTES_PER_ELEMENT)}},{key:"destroy",value:function(){var e;at(dt,this).originalRuntime().opus_decoder_destroy(at(ft,this)),at(ht,this).destroy(),null===(e=at(vt,this))||void 0===e||e.destroy()}},{key:Symbol.dispose,value:function(){this.destroy()}}],t&&nt(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function mt(e,t){var r;switch(t.type){case ct.SetComplexity:r=e.setComplexity(t.value);break;case ct.SetBitrate:r=e.setBitrate(t.value);break;case ct.SetVbr:r=e.setVbr(t.value);break;case ct.SetVbrConstraint:r=e.setVbrConstraint(t.value);break;case ct.SetForceChannels:r=e.setForceChannels(t.value);break;case ct.SetMaxBandwidth:r=e.setMaxBandwidth(t.value);break;case ct.SetBandwidth:r=e.setBandwidth(t.value);break;case ct.SetSignal:r=e.setSignal(t.value);break;case ct.SetApplication:r=e.setApplication(t.value);break;case ct.SetInbandFec:r=e.setInbandFec(t.value);break;case ct.SetPacketLossperc:r=e.setPacketLossperc(t.value);break;case ct.SetDtx:r=e.setDtx(t.value);break;case ct.SetLsbDepth:r=e.setLsbDepth(t.value);break;case ct.SetExpertFrameduration:r=e.setExpertFrameduration(t.value);break;case ct.SetPredictionDisabled:r=e.setPredictionDisabled(t.value);break;case ct.SetPhaseInversiondisabled:r=e.setPhaseInversiondisabled(t.value);break;case ct.SetGain:r=e.setGain(t.value)}return r}function wt(e,t){var r;switch(t.type){case ct.GetComplexity:r=e.getComplexity();break;case ct.GetBitrate:r=e.getBitrate();break;case ct.GetVbr:r=e.getVbr();break;case ct.GetVbrConstraint:r=e.getVbrConstraint();break;case ct.GetForceChannels:r=e.getForceChannels();break;case ct.GetMaxBandwidth:r=e.getMaxBandwidth();break;case ct.GetSignal:r=e.getSignal();break;case ct.GetApplication:r=e.getApplication();break;case ct.GetLookahead:r=e.getLookahead();break;case ct.GetInbandFec:r=e.getInbandFec();break;case ct.GetPacketLossperc:r=e.getPacketLossperc();break;case ct.GetDtx:r=e.getDtx();break;case ct.GetLsbDepth:r=e.getLsbDepth();break;case ct.GetExpertFrameduration:r=e.getExpertFrameduration();break;case ct.GetPredictionDisabled:r=e.getPredictionDisabled();break;case ct.GetBandwidth:r=e.getBandwidth();break;case ct.GetSampleRate:r=e.getSampleRate();break;case ct.GetPhaseInversiondisabled:r=e.getPhaseInversiondisabled();break;case ct.GetInDtx:r=e.getInDtx();break;case ct.GetGain:r=e.getGain();break;case ct.GetLastPacketduration:r=e.getLastPacketduration();break;case ct.GetPitch:r=e.getPitch()}return r}function gt(e){return gt="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},gt(e)}function _t(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,St(n.key),n)}}function St(e){var t=function(e){if("object"!=gt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=gt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gt(t)?t:t+""}function Et(e,t,r){Pt(e,t),t.set(e,r)}function Pt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function kt(e,t){return e.get(Ot(e,t))}function Tt(e,t,r){return e.set(Ot(e,t),r),r}function Ot(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}!function(e){e.SetComplexity="OPUS_SET_COMPLEXITY",e.GetComplexity="OPUS_GET_COMPLEXITY",e.SetBitrate="OPUS_SET_BITRATE",e.GetBitrate="OPUS_GET_BITRATE",e.SetVbr="OPUS_SET_VBR",e.GetVbr="OPUS_GET_VBR",e.SetVbrConstraint="OPUS_SET_VBR_CONSTRAINT",e.GetVbrConstraint="OPUS_GET_VBR_CONSTRAINT",e.SetForceChannels="OPUS_SET_FORCE_CHANNELS",e.GetForceChannels="OPUS_GET_FORCE_CHANNELS",e.SetMaxBandwidth="OPUS_SET_MAX_BANDWIDTH",e.GetMaxBandwidth="OPUS_GET_MAX_BANDWIDTH",e.SetBandwidth="OPUS_SET_BANDWIDTH",e.SetSignal="OPUS_SET_SIGNAL",e.GetSignal="OPUS_GET_SIGNAL",e.SetApplication="OPUS_SET_APPLICATION",e.GetApplication="OPUS_GET_APPLICATION",e.GetLookahead="OPUS_GET_LOOKAHEAD",e.SetInbandFec="OPUS_SET_INBAND_FEC",e.GetInbandFec="OPUS_GET_INBAND_FEC",e.SetPacketLossperc="OPUS_SET_PACKET_LOSS_PERC",e.GetPacketLossperc="OPUS_GET_PACKET_LOSS_PERC",e.SetDtx="OPUS_SET_DTX",e.GetDtx="OPUS_GET_DTX",e.SetLsbDepth="OPUS_SET_LSB_DEPTH",e.GetLsbDepth="OPUS_GET_LSB_DEPTH",e.SetExpertFrameduration="OPUS_SET_EXPERT_FRAME_DURATION",e.GetExpertFrameduration="OPUS_GET_EXPERT_FRAME_DURATION",e.SetPredictionDisabled="OPUS_SET_PREDICTION_DISABLED",e.GetPredictionDisabled="OPUS_GET_PREDICTION_DISABLED",e.GetBandwidth="OPUS_GET_BANDWIDTH",e.GetSampleRate="OPUS_GET_SAMPLE_RATE",e.SetPhaseInversiondisabled="OPUS_SET_PHASE_INVERSION_DISABLED",e.GetPhaseInversiondisabled="OPUS_GET_PHASE_INVERSION_DISABLED",e.GetInDtx="OPUS_GET_IN_DTX",e.SetGain="OPUS_SET_GAIN",e.GetGain="OPUS_GET_GAIN",e.GetLastPacketduration="OPUS_GET_LAST_PACKET_DURATION",e.GetPitch="OPUS_GET_PITCH"}(ct||(ct={}));var It=new WeakMap,Rt=new WeakMap,jt=new WeakSet,Gt=function(){return e=function e(t){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Pt(this,r=jt),r.add(this),Et(this,It,void 0),Et(this,Rt,void 0),Tt(It,this,t),Tt(Rt,this,{decoders:new Map,encoders:new Map})},t=[{key:"sendResponse",value:function(e){return postMessage(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])}},{key:"onRequest",value:function(e){try{Ot(jt,this,Dt).call(this,e)}catch(r){var t=new Array;"object"===gt(r)&&null!==r&&"message"in r&&"string"==typeof r.message?t.push(r.message):t.push("Unknown error: ".concat(r)),this.sendResponse({requestId:e.requestId,failures:t})}}}],t&&_t(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function At(e,t){var r,n,o,i=null!==(r=kt(Rt,this).encoders.get(e))&&void 0!==r?r:null;if(null===i){var a=new tt(kt(It,this),t.sampleRate,t.channels,t.application,t.outBufferLength,t.pcmBufferLength);i={options:t,id:e,ringBuffer:new ke(t.pcmBufferLength/Float32Array.BYTES_PER_ELEMENT),encoder:a},kt(Rt,this).encoders.set(e,i)}else if(o=t,(n=i.options).application!==o.application||n.channels!==o.channels||n.outBufferLength!==o.outBufferLength||n.pcmBufferLength!==o.pcmBufferLength||n.sampleRate!==o.sampleRate)throw new Error("Encoder with same id but different options already exists");return i}function Dt(t){var r=kt(It,this),n=kt(Rt,this),o=n.encoders,i=n.decoders;switch(t.type){case e.CreateEncoder:this.sendResponse({requestId:t.requestId,value:Ot(jt,this,At).call(this,t.encoderId,t.data).id});break;case e.CreateDecoder:var a,s=null!==(a=i.get(t.decoderId))&&void 0!==a?a:null;if(null===s)s={sampleRate:t.data.sampleRate,channels:t.data.channels,frameSize:t.data.frameSize,decoder:new bt(r,t.data.sampleRate,t.data.channels,t.data.frameSize)};else if(s.sampleRate!==t.data.sampleRate||s.channels!==t.data.channels||s.frameSize!==t.data.frameSize)throw new Error("Decoder with same id but different options already exists");i.set(t.decoderId,s),this.sendResponse({requestId:t.requestId,value:t.decoderId});break;case e.DestroyEncoder:var u,c=null!==(u=o.get(t.data.encoderId))&&void 0!==u?u:null;null!==c&&(o.delete(t.data.encoderId),c.encoder.destroy()),this.sendResponse(c?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:["Failed to find encoder with id: ".concat(t.data)]});break;case e.DestroyDecoder:var l,f=null!==(l=i.get(t.data.decoderId))&&void 0!==l?l:null;null!==f&&(i.delete(t.data.decoderId),f.decoder.destroy()),this.sendResponse(f?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:["Failed to find decoder with id: ".concat(t.data.decoderId)]});break;case e.EncodeFloat:var h,d=o.get(t.data.encoderId);if(!d)throw new Error("Failed to get encoder");var p=null===t.data.input;t.data.input&&d.ringBuffer.write(t.data.input.pcm);var y=null!==(h=d.ringBuffer.read())&&void 0!==h?h:p?d.ringBuffer.drain():null;if(null===y){this.sendResponse({requestId:t.requestId,value:{encoded:null}});break}var v=d.encoder.encodeFloat(y,y.length,t.data.maxDataBytes),b={buffer:new ArrayBuffer(v),duration:v/d.options.sampleRate};new Uint8Array(b.buffer).set(d.encoder.encoded().subarray(0,v)),this.sendResponse({requestId:t.requestId,value:{encoded:b}},[b.buffer]);break;case e.DecodeFloat:var m,w,g=null!==(m=i.get(t.data.decoderId))&&void 0!==m?m:null;if(null===g)throw new Error("No decoder found for decoder id: ".concat(t.data.decoderId));var _=g.decoder,S=_.decodeFloat(new Uint8Array(t.data.encoded),t.data.decodeFec);w=_.decoded().slice(0,S),this.sendResponse({requestId:t.requestId,value:{decoded:w.buffer}},null!==w?[w.buffer]:[]);break;case e.OpusSetRequest:var E=o.get(t.data.encoderId);this.sendResponse(null!=E&&E.encoder?{value:mt(E.encoder,t.data),requestId:t.requestId}:{requestId:t.requestId,failures:["No encoder found for: ".concat(t.data.encoderId)]});break;case e.OpusGetRequest:var P,k=null!==(P=o.get(t.data.encoderId))&&void 0!==P?P:null;if(null===k)throw new Error("No encoder found for: ".concat(t.data.encoderId));this.sendResponse({value:wt(k.encoder,t.data),requestId:t.requestId})}}function Ft(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Ct(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,u=e,h.n=r,a}};function d(r,n){for(s=r,u=n,t=0;!f&&c&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,u=p;(t=s<2?e:u)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(Ct(t={},n,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ct(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,Ct(f,"constructor",c),Ct(c,"constructor",u),u.displayName="GeneratorFunction",Ct(c,o,"GeneratorFunction"),Ct(f),Ct(f,o,"Generator"),Ct(f,n,function(){return this}),Ct(f,"toString",function(){return"[object Generator]"}),(Ft=function(){return{w:i,m:h}})()}function Ct(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Ct=function(e,t,r,n){function i(t,r){Ct(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},Ct(e,t,r,n)}function xt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Bt(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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 Bt(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 Lt(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)}var Ut={queue:new Set},Mt=function(){var t,r=(t=Ft().m(function t(r){var n,o,i,a,s,u,c,l,f,h,d;return Ft().w(function(t){for(;;)switch(t.p=t.n){case 0:if("queue"in Ut){t.n=1;break}return Ut.onRequest(r),t.a(2);case 1:u=r.type,t.n=u===e.InitializeWorker?2:11;break;case 2:return n=Ut.queue,c=Gt,l=x,t.n=3,p({wasmFileHref:r.data.wasmFileHref});case 3:f=t.v,h=new l(f),o=new c(h),Ut=o,i=xt(n),t.p=4,i.s();case 5:if((a=i.n()).done){t.n=7;break}return s=a.value,t.n=6,Mt(s);case 6:t.n=5;break;case 7:t.n=9;break;case 8:t.p=8,d=t.v,i.e(d);case 9:return t.p=9,i.f(),t.f(9);case 10:return n.clear(),Ut.sendResponse({requestId:r.requestId,value:null}),t.a(3,12);case 11:return Ut.queue.add(r),t.a(3,12);case 12:return t.a(2)}},t,null,[[4,8,9,10]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(e){Lt(i,n,o,a,s,"next",e)}function s(e){Lt(i,n,o,a,s,"throw",e)}a(void 0)})});return function(e){return r.apply(this,arguments)}}(),Nt=Promise.resolve();onmessage=function(e){var t=e.data;Nt=Nt.then(function(){return Mt(t)}).catch(function(e){console.error("failed to process request: %o",{request:t,reason:e})})}})()})();
|
|
2
|
+
(()=>{var e,t,r={178(){},306(){}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&r;("object"==typeof s||"function"==typeof s)&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,o.d(i,a),i},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e;function t(e){return t="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},t(e)}function r(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,r,n){return(r=function(e){var r=function(e){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function s(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var s=n&&n.prototype instanceof c?n:c,l=Object.create(s.prototype);return u(l,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,u=e,h.n=r,a}};function d(r,n){for(s=r,u=n,t=0;!f&&c&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,u=p;(t=s<2?e:u)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function l(){}function f(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(u(t={},n,function(){return this}),t),d=f.prototype=c.prototype=Object.create(h);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,u(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,u(d,"constructor",f),u(f,"constructor",l),l.displayName="GeneratorFunction",u(f,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:p}})()}function u(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}u=function(e,t,r,n){function i(t,r){u(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},u(e,t,r,n)}function c(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 l(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){c(i,n,o,a,s,"next",e)}function s(e){c(i,n,o,a,s,"throw",e)}a(void 0)})}}function f(e){return h.apply(this,arguments)}function h(){return(h=l(s().m(function e(t){var r,n,i,a,u,c,l,f;return s().w(function(e){for(;;)switch(e.n){case 0:if(r=t.wasmFileHref,n=t.importObject,!("process"in globalThis)||"nodejs"!==process.env.RUNTIME){e.n=4;break}return e.n=1,Promise.resolve().then(o.t.bind(o,306,19));case 1:return a=e.v,e.n=2,Promise.resolve().then(o.t.bind(o,178,19));case 2:return u=e.v,c=u.resolve("/","index.wasm"),e.n=3,a.promises.readFile(c);case 3:l=e.v,i=WebAssembly.instantiate(l,n),e.n=8;break;case 4:if("string"==typeof r){e.n=5;break}throw new Error("Invalid wasmFileHref");case 5:return e.n=6,fetch(r);case 6:return f=e.v,e.n=7,WebAssembly.instantiateStreaming(f,n);case 7:i=e.v;case 8:return e.a(2,i)}},e)}))).apply(this,arguments)}function d(){return d=l(s().m(function e(){var t,n,o,a,u,c,l,h,d,p=arguments;return s().w(function(e){for(;;)switch(e.n){case 0:n=(p.length>0&&void 0!==p[0]?p[0]:{}).wasmFileHref,o={proc_exit:function(e){throw console.log("WASI proc_exit called with code:",e),new Error("WASI exit with code: ".concat(e))}},a=s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.n){case 0:t=c[u],o[t]=function(e){return console.log("[%s] called with %o",t,e),0};case 1:return e.a(2)}},e)}),u=0,c=["args_get","args_sizes_get","fd_close","fd_seek","fd_write","fd_fdstat_get","fd_prestat_get","fd_prestat_dir_name"];case 1:if(!(u<c.length)){e.n=3;break}return e.d(r(a()),2);case 2:u++,e.n=1;break;case 3:return l={wasi_snapshot_preview1:o},e.n=4,f({wasmFileHref:n,importObject:l});case 4:if(h=e.v,null!==(d=null!==(t=h.instance.exports.memory)&&void 0!==t?t:null)){e.n=5;break}throw new Error("Memory was expected to be imported but is null");case 5:return e.a(2,i(i({},h.instance.exports),{},{memory:d}))}},e)})),d.apply(this,arguments)}!function(e){e[e.CreateEncoder=0]="CreateEncoder",e[e.CreateDecoder=1]="CreateDecoder",e[e.EncodeFloat=2]="EncodeFloat",e[e.DecodeFloat=3]="DecodeFloat",e[e.DestroyEncoder=4]="DestroyEncoder",e[e.InitializeWorker=5]="InitializeWorker",e[e.DestroyDecoder=6]="DestroyDecoder",e[e.OpusGetRequest=7]="OpusGetRequest",e[e.OpusSetRequest=8]="OpusSetRequest"}(e||(e={}));const p=function(){return d.apply(this,arguments)};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 v(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,b(n.key),n)}}function b(e){var t=function(e){if("object"!=y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==y(t)?t:t+""}function m(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function w(e,t){return e.get(_(e,t))}function g(e,t,r){return e.set(_(e,t),r),r}function _(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var S=new WeakMap,E=new WeakMap,P=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),m(this,S,void 0),m(this,E,void 0),g(S,this,t),g(E,this,t.malloc(t.originalRuntime().size_of_int()))},(t=[{key:"value",value:function(){if(4!==w(S,this).originalRuntime().size_of_int())throw new Error("invalid integer byte size");return w(S,this).view().getInt32(w(E,this),!0)}},{key:"set",value:function(e){w(S,this).view().setInt32(w(E,this),e,!0)}},{key:"size",value:function(){return w(S,this).originalRuntime().size_of_int()}},{key:"offset",value:function(){if(0===w(E,this))throw new Error("Integer has been destroyed");return w(E,this)}},{key:"destroy",value:function(){w(S,this).free(w(E,this)),g(E,this,0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function k(e){return k="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},k(e)}function T(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){if(Object(r)!==r)return;u=!1}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)||O(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 O(e,t){if(e){if("string"==typeof e)return I(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function I(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 R(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,j(n.key),n)}}function j(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=k(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}function G(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function A(e,t){return e.get(D(e,t))}function D(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var F=new WeakMap,C=new WeakMap,x=function(){return e=function e(t){var r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),G(this,F,void 0),G(this,C,new Map),n=t,(r=F).set(D(r,this),n)},t=[{key:"originalRuntime",value:function(){return A(F,this)}},{key:"subarray",value:function(e,t){return new Uint8Array(A(F,this).memory.buffer,e,t-e)}},{key:"free",value:function(e){A(C,this).delete(e),A(F,this).free(e)}},{key:"view",value:function(){return new DataView(A(F,this).memory.buffer)}},{key:"malloc",value:function(e){var t,r=A(F,this).malloc(e);if(!r)throw new Error("Failed to allocate ".concat(e," bytes"));var n=null!==(t=(new Error).stack)&&void 0!==t?t:null;return A(C,this).set(r,n),r}},{key:Symbol.dispose,value:function(){var e,t=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=O(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}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 o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(A(C,this));try{for(t.s();!(e=t.n()).done;){var r=T(e.value,2),n=r[0],o=r[1];throw new Error("Memory leak detected at offset ".concat(n,"\nAllocation stack:\n").concat(o))}}catch(e){t.e(e)}finally{t.f()}}}],t&&R(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function B(e){return B="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},B(e)}function L(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,U(n.key),n)}}function U(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}function M(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function N(e,t){return e.get(q(e,t))}function W(e,t,r){return e.set(q(e,t),r),r}function q(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var z=new WeakMap,H=new WeakMap,V=new WeakMap,X=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),M(this,z,void 0),M(this,H,void 0),M(this,V,void 0),W(V,this,t),W(H,this,r),W(z,this,t.malloc(r))},(t=[{key:"offset",value:function(){return N(z,this)}},{key:"data",value:function(){return N(V,this).subarray(N(z,this),N(z,this)+N(H,this))}},{key:"size",value:function(){return N(H,this)}},{key:"destroy",value:function(){N(V,this).free(N(z,this)),W(z,this,0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&L(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,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 $(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 K(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,J(n.key),n)}}function J(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}function Q(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Z(e,t){return e.get(ee(e,t))}function ee(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var te=new WeakMap,re=new WeakMap,ne=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Q(this,te,new Set),Q(this,re,!1)},(t=[{key:"add",value:function(e){Z(te,this).add(e)}},{key:"destroy",value:function(){if(Z(re,this))throw new Error("ResourcesHolder already destroyed");var e,t,r,n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return $(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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}}}}(Z(te,this));try{for(n.s();!(e=n.n()).done;)e.value.destroy()}catch(e){n.e(e)}finally{n.f()}Z(te,this).clear(),r=this,(t=re).set(ee(t,r),!0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&K(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();class oe extends Error{constructor(e){super(e)}}function ie({name:e,value:t,validations:r}){const n=new Array;if(r.integer&&!Number.isSafeInteger(t)&&n.push("It must be an integer."),t>r.max&&n.push(`It must be up to ${r.max}.`),t<r.min&&n.push(`It must be at least ${r.min}.`),n.length>0)throw new oe([`"${t}" is not a valid value for ${e}. It failed to following validations:\n`,...n.map(e=>`\t- ${e}`)].join(""));return t}var ae,se,ue,ce,le,fe,he,de,pe,ye,ve,be,me,we,ge,_e=function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},Se=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};const Ee=4294967295;class Pe{constructor({frameSize:e,frameCacheSize:t=0,preallocateFrameCount:r=10,TypedArrayConstructor:n}){if(ae.add(this),se.set(this,void 0),ue.set(this,void 0),ce.set(this,void 0),le.set(this,void 0),fe.set(this,void 0),he.set(this,void 0),de.set(this,void 0),_e(this,le,ie({value:e,name:"Frame Size",validations:{min:1,integer:!0,max:Ee}}),"f"),_e(this,ue,ie({value:r,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:Ee}}),"f"),_e(this,ce,ie({value:t,name:"Frame Cache Size",validations:{min:0,integer:!1,max:Ee}}),"f"),!("BYTES_PER_ELEMENT"in n))throw new oe("TypedArrayConstructor must be a typed array");_e(this,he,0,"f"),_e(this,de,0,"f"),_e(this,se,n,"f"),_e(this,fe,new ArrayBuffer(Se(this,ae,"m",ge).call(this)),"f")}empty(){return Se(this,ae,"m",ve).call(this)<Se(this,le,"f")}peek(){return Se(this,ae,"m",pe).call(this)}write(e){Se(this,ae,"m",we).call(this,e.length),Se(this,ae,"m",pe).call(this).subarray(Se(this,de,"f"),Se(this,de,"f")+e.length).set(e),_e(this,de,Se(this,de,"f")+e.length,"f")}remainingFrames(){return Math.floor(Se(this,ae,"m",ye).call(this))}drain(){return Se(this,ae,"m",me).call(this,Se(this,ae,"m",ve).call(this))}read(){return Se(this,ae,"m",me).call(this,Se(this,le,"f"))}get[(se=new WeakMap,ue=new WeakMap,ce=new WeakMap,le=new WeakMap,fe=new WeakMap,he=new WeakMap,de=new WeakMap,ae=new WeakSet,pe=function(){return new(Se(this,se,"f"))(Se(this,fe,"f"))},ye=function(){return Se(this,ae,"m",ve).call(this)/Se(this,le,"f")},ve=function(){return Se(this,de,"f")-Se(this,he,"f")},be=function(){return Se(this,ce,"f")>0&&Se(this,ae,"m",ye).call(this)>=Se(this,ce,"f")},me=function(e){if(!e)return null;if(Se(this,ae,"m",ve).call(this)<e)return null;let t=Se(this,ae,"m",pe).call(this).subarray(Se(this,he,"f"),Se(this,he,"f")+e);if(_e(this,he,Se(this,he,"f")+e,"f"),Se(this,he,"f")===Se(this,de,"f")&&(_e(this,de,0,"f"),_e(this,he,0,"f")),Se(this,ae,"m",be).call(this)){const e=this.drain();e&&(t=t.slice(0),this.write(e))}return t},we=function(e){const t=e*Se(this,se,"f").BYTES_PER_ELEMENT;if(Se(this,ae,"m",pe).call(this).length-Se(this,de,"f")<=e){const e=Se(this,fe,"f");_e(this,fe,new ArrayBuffer(e.byteLength+t+Se(this,ae,"m",ge).call(this)),"f"),Se(this,ae,"m",pe).call(this).set(new(Se(this,se,"f"))(e))}return Se(this,ae,"m",pe).call(this).subarray(Se(this,he,"f"),Se(this,he,"f")+Se(this,le,"f"))},ge=function(){return Se(this,le,"f")*Se(this,se,"f").BYTES_PER_ELEMENT*Se(this,ue,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let e;do{e=this.read(),null!==e&&(yield e)}while(null!==e)}}class ke extends Pe{constructor(e,t={}){super(Object.assign(Object.assign({},t),{frameSize:e,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;const Te=0;function Oe(e){return Oe="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},Oe(e)}function Ie(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,Re(n.key),n)}}function Re(e){var t=function(e){if("object"!=Oe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Oe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Oe(t)?t:t+""}function je(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ge(e,t){return e.get(De(e,t))}function Ae(e,t,r){return e.set(De(e,t),r),r}function De(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var Fe=new WeakMap,Ce=new WeakMap,xe=new WeakMap,Be=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),je(this,Fe,void 0),je(this,Ce,void 0),je(this,xe,void 0),Ae(Ce,this,t),Ae(xe,this,new P(t)),Ae(Fe,this,r)},(t=[{key:"setComplexity",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_complexity(Ge(Fe,this),e)===Te}},{key:"getComplexity",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_complexity(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_COMPLEXITY");return Ge(xe,this).value()}},{key:"setBitrate",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_bitrate(Ge(Fe,this),e)===Te}},{key:"getBitrate",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_bitrate(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_BITRATE");return Ge(xe,this).value()}},{key:"setVbr",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_vbr(Ge(Fe,this),e)===Te}},{key:"getVbr",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_vbr(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_VBR");return Ge(xe,this).value()}},{key:"setVbrConstraint",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_vbr_constraint(Ge(Fe,this),e)===Te}},{key:"getVbrConstraint",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_vbr_constraint(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_VBR_CONSTRAINT");return Ge(xe,this).value()}},{key:"setForceChannels",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_force_channels(Ge(Fe,this),e)===Te}},{key:"getForceChannels",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_force_channels(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_FORCE_CHANNELS");return Ge(xe,this).value()}},{key:"setMaxBandwidth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_max_bandwidth(Ge(Fe,this),e)===Te}},{key:"getMaxBandwidth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_max_bandwidth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_MAX_BANDWIDTH");return Ge(xe,this).value()}},{key:"setBandwidth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_bandwidth(Ge(Fe,this),e)===Te}},{key:"setSignal",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_signal(Ge(Fe,this),e)===Te}},{key:"getSignal",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_signal(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_SIGNAL");return Ge(xe,this).value()}},{key:"setApplication",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_application(Ge(Fe,this),e)===Te}},{key:"getApplication",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_application(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_APPLICATION");return Ge(xe,this).value()}},{key:"getLookahead",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_lookahead(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LOOKAHEAD");return Ge(xe,this).value()}},{key:"setInbandFec",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_inband_fec(Ge(Fe,this),e)===Te}},{key:"getInbandFec",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_inband_fec(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_INBAND_FEC");return Ge(xe,this).value()}},{key:"setPacketLossperc",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_packet_loss_perc(Ge(Fe,this),e)===Te}},{key:"getPacketLossperc",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_packet_loss_perc(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PACKET_LOSS_PERC");return Ge(xe,this).value()}},{key:"setDtx",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_dtx(Ge(Fe,this),e)===Te}},{key:"getDtx",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_dtx(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_DTX");return Ge(xe,this).value()}},{key:"setLsbDepth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_lsb_depth(Ge(Fe,this),e)===Te}},{key:"getLsbDepth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_lsb_depth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LSB_DEPTH");return Ge(xe,this).value()}},{key:"setExpertFrameduration",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_expert_frame_duration(Ge(Fe,this),e)===Te}},{key:"getExpertFrameduration",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_expert_frame_duration(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_EXPERT_FRAME_DURATION");return Ge(xe,this).value()}},{key:"setPredictionDisabled",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_prediction_disabled(Ge(Fe,this),e)===Te}},{key:"getPredictionDisabled",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_prediction_disabled(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PREDICTION_DISABLED");return Ge(xe,this).value()}},{key:"getBandwidth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_bandwidth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_BANDWIDTH");return Ge(xe,this).value()}},{key:"getSampleRate",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_sample_rate(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_SAMPLE_RATE");return Ge(xe,this).value()}},{key:"setPhaseInversiondisabled",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_phase_inversion_disabled(Ge(Fe,this),e)===Te}},{key:"getPhaseInversiondisabled",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_phase_inversion_disabled(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PHASE_INVERSION_DISABLED");return Ge(xe,this).value()}},{key:"getInDtx",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_in_dtx(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_IN_DTX");return Ge(xe,this).value()}},{key:"setGain",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_gain(Ge(Fe,this),e)===Te}},{key:"getGain",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_gain(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_GAIN");return Ge(xe,this).value()}},{key:"getLastPacketduration",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_last_packet_duration(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LAST_PACKET_DURATION");return Ge(xe,this).value()}},{key:"getPitch",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_pitch(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PITCH");return Ge(xe,this).value()}},{key:"destroy",value:function(){Ge(xe,this).destroy()}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&Ie(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function Le(e){return Le="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},Le(e)}function Ue(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,Me(n.key),n)}}function Me(e){var t=function(e){if("object"!=Le(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Le(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Le(t)?t:t+""}function Ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ne=function(){return!!e})()}function We(){return We="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=qe(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},We.apply(null,arguments)}function qe(e){return qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},qe(e)}function ze(e,t){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ze(e,t)}function He(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ve(e,t){return e.get(Ye(e,t))}function Xe(e,t,r){return e.set(Ye(e,t),r),r}function Ye(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var $e=new WeakMap,Ke=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,et=new WeakMap,tt=function(e){function t(e,r,n,o,i,a){var s;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),!i)throw new Error("Output buffer length must be more than 0");var u=new P(e),c=e.originalRuntime().opus_encoder_create(r,n,o,u.offset());if(He(s=function(e,t,r){return t=qe(t),function(e,t){if(t&&("object"==Le(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,Ne()?Reflect.construct(t,r||[],qe(e).constructor):t.apply(e,r))}(this,t,[e,c]),$e,void 0),He(s,Ke,void 0),He(s,Je,void 0),He(s,Qe,void 0),He(s,Ze,void 0),He(s,et,void 0),Xe(et,s,new ne),Xe($e,s,u),Xe(Ke,s,e),Xe(Ze,s,new X(e,a)),Xe(Qe,s,new X(e,i)),Ve(et,s).add(Ve(Qe,s)),Ve(et,s).add(Ve(Ze,s)),Ve(et,s).add(Ve($e,s)),Xe(Je,s,c),u.value()<0)throw s.destroy(),new Error("Failed to create encoder");return s}return function(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&&ze(e,t)}(t,e),r=t,n=[{key:"encoded",value:function(){return Ve(Qe,this).data()}},{key:"encodeFloat",value:function(e,t,r){if(r>Ve(Qe,this).size())throw new Error("encoded buffer length is ".concat(Ve(Qe,this).size(),", but maxDataBytes is ").concat(r));Ve(Ze,this).data().set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var n=Ve(Ke,this).originalRuntime().opus_encode_float(Ve(Je,this),Ve(Ze,this).offset(),t,Ve(Qe,this).offset(),r);if(n<0)throw new Error("Failed to encode float: ".concat(n));return n}},{key:"destroy",value:function(){var e,r,n;(e=t,r=this,"function"==typeof(n=We(qe(1&3?e.prototype:e),"destroy",r))?function(e){return n.apply(r,e)}:n)([]),Ve(et,this).destroy(),Ve(Ke,this).originalRuntime().opus_encoder_destroy(Ve(Je,this))}},{key:Symbol.dispose,value:function(){this.destroy()}}],n&&Ue(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Be);function rt(e){return rt="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},rt(e)}function nt(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,ot(n.key),n)}}function ot(e){var t=function(e){if("object"!=rt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=rt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==rt(t)?t:t+""}function it(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function at(e,t){return e.get(ut(e,t))}function st(e,t,r){return e.set(ut(e,t),r),r}function ut(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var ct,lt=new WeakMap,ft=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,yt=new WeakMap,vt=new WeakMap,bt=function(){return e=function e(t,r,n,o){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),it(this,lt,void 0),it(this,ft,void 0),it(this,ht,void 0),it(this,dt,void 0),it(this,pt,void 0),it(this,yt,void 0),it(this,vt,null),st(yt,this,o),st(dt,this,t),st(ht,this,new ne),st(lt,this,new P(t)),at(ht,this).add(at(lt,this)),st(ft,this,t.originalRuntime().opus_decoder_create(r,n,at(lt,this).offset())),!at(ft,this)||at(lt,this).value()<0)throw new Error("Failed to create decoder");st(pt,this,new X(t,at(yt,this)*n*Float32Array.BYTES_PER_ELEMENT)),at(ht,this).add(at(pt,this))},t=[{key:"decodeFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=at(vt,this);r||(r=new X(at(dt,this),e.byteLength)),r.data().byteLength<e.byteLength&&(r.destroy(),r=new X(at(dt,this),e.byteLength)),r.data().set(e),st(vt,this,r);var n=at(dt,this).originalRuntime().opus_decode_float(at(ft,this),r.offset(),e.byteLength,at(pt,this).offset(),at(yt,this),t);if(n<0)throw new Error("Failed to decode float");return n}},{key:"decoded",value:function(){var e=at(pt,this).data();return new Float32Array(e.buffer,e.byteOffset,e.byteLength/Float32Array.BYTES_PER_ELEMENT)}},{key:"destroy",value:function(){var e;at(dt,this).originalRuntime().opus_decoder_destroy(at(ft,this)),at(ht,this).destroy(),null===(e=at(vt,this))||void 0===e||e.destroy()}},{key:Symbol.dispose,value:function(){this.destroy()}}],t&&nt(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function mt(e,t){var r;switch(t.type){case ct.SetComplexity:r=e.setComplexity(t.value);break;case ct.SetBitrate:r=e.setBitrate(t.value);break;case ct.SetVbr:r=e.setVbr(t.value);break;case ct.SetVbrConstraint:r=e.setVbrConstraint(t.value);break;case ct.SetForceChannels:r=e.setForceChannels(t.value);break;case ct.SetMaxBandwidth:r=e.setMaxBandwidth(t.value);break;case ct.SetBandwidth:r=e.setBandwidth(t.value);break;case ct.SetSignal:r=e.setSignal(t.value);break;case ct.SetApplication:r=e.setApplication(t.value);break;case ct.SetInbandFec:r=e.setInbandFec(t.value);break;case ct.SetPacketLossperc:r=e.setPacketLossperc(t.value);break;case ct.SetDtx:r=e.setDtx(t.value);break;case ct.SetLsbDepth:r=e.setLsbDepth(t.value);break;case ct.SetExpertFrameduration:r=e.setExpertFrameduration(t.value);break;case ct.SetPredictionDisabled:r=e.setPredictionDisabled(t.value);break;case ct.SetPhaseInversiondisabled:r=e.setPhaseInversiondisabled(t.value);break;case ct.SetGain:r=e.setGain(t.value)}return r}function wt(e,t){var r;switch(t.type){case ct.GetComplexity:r=e.getComplexity();break;case ct.GetBitrate:r=e.getBitrate();break;case ct.GetVbr:r=e.getVbr();break;case ct.GetVbrConstraint:r=e.getVbrConstraint();break;case ct.GetForceChannels:r=e.getForceChannels();break;case ct.GetMaxBandwidth:r=e.getMaxBandwidth();break;case ct.GetSignal:r=e.getSignal();break;case ct.GetApplication:r=e.getApplication();break;case ct.GetLookahead:r=e.getLookahead();break;case ct.GetInbandFec:r=e.getInbandFec();break;case ct.GetPacketLossperc:r=e.getPacketLossperc();break;case ct.GetDtx:r=e.getDtx();break;case ct.GetLsbDepth:r=e.getLsbDepth();break;case ct.GetExpertFrameduration:r=e.getExpertFrameduration();break;case ct.GetPredictionDisabled:r=e.getPredictionDisabled();break;case ct.GetBandwidth:r=e.getBandwidth();break;case ct.GetSampleRate:r=e.getSampleRate();break;case ct.GetPhaseInversiondisabled:r=e.getPhaseInversiondisabled();break;case ct.GetInDtx:r=e.getInDtx();break;case ct.GetGain:r=e.getGain();break;case ct.GetLastPacketduration:r=e.getLastPacketduration();break;case ct.GetPitch:r=e.getPitch()}return r}function gt(e){return gt="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},gt(e)}function _t(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,St(n.key),n)}}function St(e){var t=function(e){if("object"!=gt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=gt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gt(t)?t:t+""}function Et(e,t,r){Pt(e,t),t.set(e,r)}function Pt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function kt(e,t){return e.get(Ot(e,t))}function Tt(e,t,r){return e.set(Ot(e,t),r),r}function Ot(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}!function(e){e.SetComplexity="OPUS_SET_COMPLEXITY",e.GetComplexity="OPUS_GET_COMPLEXITY",e.SetBitrate="OPUS_SET_BITRATE",e.GetBitrate="OPUS_GET_BITRATE",e.SetVbr="OPUS_SET_VBR",e.GetVbr="OPUS_GET_VBR",e.SetVbrConstraint="OPUS_SET_VBR_CONSTRAINT",e.GetVbrConstraint="OPUS_GET_VBR_CONSTRAINT",e.SetForceChannels="OPUS_SET_FORCE_CHANNELS",e.GetForceChannels="OPUS_GET_FORCE_CHANNELS",e.SetMaxBandwidth="OPUS_SET_MAX_BANDWIDTH",e.GetMaxBandwidth="OPUS_GET_MAX_BANDWIDTH",e.SetBandwidth="OPUS_SET_BANDWIDTH",e.SetSignal="OPUS_SET_SIGNAL",e.GetSignal="OPUS_GET_SIGNAL",e.SetApplication="OPUS_SET_APPLICATION",e.GetApplication="OPUS_GET_APPLICATION",e.GetLookahead="OPUS_GET_LOOKAHEAD",e.SetInbandFec="OPUS_SET_INBAND_FEC",e.GetInbandFec="OPUS_GET_INBAND_FEC",e.SetPacketLossperc="OPUS_SET_PACKET_LOSS_PERC",e.GetPacketLossperc="OPUS_GET_PACKET_LOSS_PERC",e.SetDtx="OPUS_SET_DTX",e.GetDtx="OPUS_GET_DTX",e.SetLsbDepth="OPUS_SET_LSB_DEPTH",e.GetLsbDepth="OPUS_GET_LSB_DEPTH",e.SetExpertFrameduration="OPUS_SET_EXPERT_FRAME_DURATION",e.GetExpertFrameduration="OPUS_GET_EXPERT_FRAME_DURATION",e.SetPredictionDisabled="OPUS_SET_PREDICTION_DISABLED",e.GetPredictionDisabled="OPUS_GET_PREDICTION_DISABLED",e.GetBandwidth="OPUS_GET_BANDWIDTH",e.GetSampleRate="OPUS_GET_SAMPLE_RATE",e.SetPhaseInversiondisabled="OPUS_SET_PHASE_INVERSION_DISABLED",e.GetPhaseInversiondisabled="OPUS_GET_PHASE_INVERSION_DISABLED",e.GetInDtx="OPUS_GET_IN_DTX",e.SetGain="OPUS_SET_GAIN",e.GetGain="OPUS_GET_GAIN",e.GetLastPacketduration="OPUS_GET_LAST_PACKET_DURATION",e.GetPitch="OPUS_GET_PITCH"}(ct||(ct={}));var It=new WeakMap,Rt=new WeakMap,jt=new WeakSet,Gt=function(){return e=function e(t){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Pt(this,r=jt),r.add(this),Et(this,It,void 0),Et(this,Rt,void 0),Tt(It,this,t),Tt(Rt,this,{decoders:new Map,encoders:new Map})},t=[{key:"sendResponse",value:function(e){return postMessage(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])}},{key:"onRequest",value:function(e){try{Ot(jt,this,Dt).call(this,e)}catch(r){var t=new Array;"object"===gt(r)&&null!==r&&"message"in r&&"string"==typeof r.message?t.push(r.message):t.push("Unknown error: ".concat(r)),this.sendResponse({requestId:e.requestId,failures:t})}}}],t&&_t(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function At(e,t){var r,n,o,i=null!==(r=kt(Rt,this).encoders.get(e))&&void 0!==r?r:null;if(null===i){var a=new tt(kt(It,this),t.sampleRate,t.channels,t.application,t.outBufferLength,t.pcmBufferLength);i={options:t,id:e,ringBuffer:new ke(t.pcmBufferLength/Float32Array.BYTES_PER_ELEMENT),encoder:a},kt(Rt,this).encoders.set(e,i)}else if(o=t,(n=i.options).application!==o.application||n.channels!==o.channels||n.outBufferLength!==o.outBufferLength||n.pcmBufferLength!==o.pcmBufferLength||n.sampleRate!==o.sampleRate)throw new Error("Encoder with same id but different options already exists");return i}function Dt(t){var r=kt(It,this),n=kt(Rt,this),o=n.encoders,i=n.decoders;switch(t.type){case e.CreateEncoder:this.sendResponse({requestId:t.requestId,value:Ot(jt,this,At).call(this,t.encoderId,t.data).id});break;case e.CreateDecoder:var a,s=null!==(a=i.get(t.decoderId))&&void 0!==a?a:null;if(null===s)s={sampleRate:t.data.sampleRate,channels:t.data.channels,frameSize:t.data.frameSize,decoder:new bt(r,t.data.sampleRate,t.data.channels,t.data.frameSize)};else if(s.sampleRate!==t.data.sampleRate||s.channels!==t.data.channels||s.frameSize!==t.data.frameSize)throw new Error("Decoder with same id but different options already exists");i.set(t.decoderId,s),this.sendResponse({requestId:t.requestId,value:t.decoderId});break;case e.DestroyEncoder:var u,c=null!==(u=o.get(t.data.encoderId))&&void 0!==u?u:null;null!==c&&(o.delete(t.data.encoderId),c.encoder.destroy()),this.sendResponse(c?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:["Failed to find encoder with id: ".concat(t.data)]});break;case e.DestroyDecoder:var l,f=null!==(l=i.get(t.data.decoderId))&&void 0!==l?l:null;null!==f&&(i.delete(t.data.decoderId),f.decoder.destroy()),this.sendResponse(f?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:["Failed to find decoder with id: ".concat(t.data.decoderId)]});break;case e.EncodeFloat:var h,d=o.get(t.data.encoderId);if(!d)throw new Error("Failed to get encoder");var p=null===t.data.input;t.data.input&&d.ringBuffer.write(t.data.input.pcm);var y=null!==(h=d.ringBuffer.read())&&void 0!==h?h:p?d.ringBuffer.drain():null;if(null===y){this.sendResponse({requestId:t.requestId,value:{encoded:null}});break}var v=d.encoder.encodeFloat(y,y.length,t.data.maxDataBytes),b={buffer:new ArrayBuffer(v),duration:v/d.options.sampleRate};new Uint8Array(b.buffer).set(d.encoder.encoded().subarray(0,v)),this.sendResponse({requestId:t.requestId,value:{encoded:b}},[b.buffer]);break;case e.DecodeFloat:var m,w,g=null!==(m=i.get(t.data.decoderId))&&void 0!==m?m:null;if(null===g)throw new Error("No decoder found for decoder id: ".concat(t.data.decoderId));var _=g.decoder,S=_.decodeFloat(new Uint8Array(t.data.encoded),t.data.decodeFec);w=_.decoded().slice(0,S),this.sendResponse({requestId:t.requestId,value:{decoded:w.buffer}},null!==w?[w.buffer]:[]);break;case e.OpusSetRequest:var E=o.get(t.data.encoderId);this.sendResponse(null!=E&&E.encoder?{value:mt(E.encoder,t.data),requestId:t.requestId}:{requestId:t.requestId,failures:["No encoder found for: ".concat(t.data.encoderId)]});break;case e.OpusGetRequest:var P,k=null!==(P=o.get(t.data.encoderId))&&void 0!==P?P:null;if(null===k)throw new Error("No encoder found for: ".concat(t.data.encoderId));this.sendResponse({value:wt(k.encoder,t.data),requestId:t.requestId})}}function Ft(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Ct(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,u=e,h.n=r,a}};function d(r,n){for(s=r,u=n,t=0;!f&&c&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,u=p;(t=s<2?e:u)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(Ct(t={},n,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ct(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,Ct(f,"constructor",c),Ct(c,"constructor",u),u.displayName="GeneratorFunction",Ct(c,o,"GeneratorFunction"),Ct(f),Ct(f,o,"Generator"),Ct(f,n,function(){return this}),Ct(f,"toString",function(){return"[object Generator]"}),(Ft=function(){return{w:i,m:h}})()}function Ct(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Ct=function(e,t,r,n){function i(t,r){Ct(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},Ct(e,t,r,n)}function xt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Bt(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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 Bt(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 Lt(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)}var Ut={queue:new Set},Mt=function(){var t,r=(t=Ft().m(function t(r){var n,o,i,a,s,u,c,l,f,h,d;return Ft().w(function(t){for(;;)switch(t.p=t.n){case 0:if("queue"in Ut){t.n=1;break}return Ut.onRequest(r),t.a(2);case 1:u=r.type,t.n=u===e.InitializeWorker?2:11;break;case 2:return n=Ut.queue,c=Gt,l=x,t.n=3,p({wasmFileHref:r.data.wasmFileHref});case 3:f=t.v,h=new l(f),o=new c(h),Ut=o,i=xt(n),t.p=4,i.s();case 5:if((a=i.n()).done){t.n=7;break}return s=a.value,t.n=6,Mt(s);case 6:t.n=5;break;case 7:t.n=9;break;case 8:t.p=8,d=t.v,i.e(d);case 9:return t.p=9,i.f(),t.f(9);case 10:return n.clear(),Ut.sendResponse({requestId:r.requestId,value:null}),t.a(3,12);case 11:return Ut.queue.add(r),t.a(3,12);case 12:return t.a(2)}},t,null,[[4,8,9,10]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(e){Lt(i,n,o,a,s,"next",e)}function s(e){Lt(i,n,o,a,s,"throw",e)}a(void 0)})});return function(e){return r.apply(this,arguments)}}(),Nt=Promise.resolve();onmessage=function(e){var t=e.data;Nt=Nt.then(function(){return Mt(t)}).catch(function(e){console.error("failed to process request: %o",{request:t,reason:e})})}})()})();
|
package/worklet/worklet.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";class t extends Error{constructor(t){super(t)}}function e({name:e,value:r,validations:n}){const i=new Array;if(n.integer&&!Number.isSafeInteger(r)&&i.push("It must be an integer."),r>n.max&&i.push(`It must be up to ${n.max}.`),r<n.min&&i.push(`It must be at least ${n.min}.`),i.length>0)throw new t([`"${r}" is not a valid value for ${e}. It failed to following validations:\n`,...i.map(t=>`\t- ${t}`)].join(""));return r}var r,n,i,o,a,s,u,l,f,c,h,p,y,m,w,v=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},b=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};const d=4294967295;class g{constructor({frameSize:f,frameCacheSize:c=0,preallocateFrameCount:h=10,TypedArrayConstructor:p}){if(r.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,void 0),s.set(this,void 0),u.set(this,void 0),l.set(this,void 0),v(this,a,e({value:f,name:"Frame Size",validations:{min:1,integer:!0,max:d}}),"f"),v(this,i,e({value:h,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:d}}),"f"),v(this,o,e({value:c,name:"Frame Cache Size",validations:{min:0,integer:!1,max:d}}),"f"),!("BYTES_PER_ELEMENT"in p))throw new t("TypedArrayConstructor must be a typed array");v(this,u,0,"f"),v(this,l,0,"f"),v(this,n,p,"f"),v(this,s,new ArrayBuffer(b(this,r,"m",w).call(this)),"f")}empty(){return b(this,r,"m",h).call(this)<b(this,a,"f")}peek(){return b(this,r,"m",f).call(this)}write(t){b(this,r,"m",m).call(this,t.length),b(this,r,"m",f).call(this).subarray(b(this,l,"f"),b(this,l,"f")+t.length).set(t),v(this,l,b(this,l,"f")+t.length,"f")}remainingFrames(){return Math.floor(b(this,r,"m",c).call(this))}drain(){return b(this,r,"m",y).call(this,b(this,r,"m",h).call(this))}read(){return b(this,r,"m",y).call(this,b(this,a,"f"))}get[(n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,s=new WeakMap,u=new WeakMap,l=new WeakMap,r=new WeakSet,f=function(){return new(b(this,n,"f"))(b(this,s,"f"))},c=function(){return b(this,r,"m",h).call(this)/b(this,a,"f")},h=function(){return b(this,l,"f")-b(this,u,"f")},p=function(){return b(this,o,"f")>0&&b(this,r,"m",c).call(this)>=b(this,o,"f")},y=function(t){if(!t)return null;if(b(this,r,"m",h).call(this)<t)return null;let e=b(this,r,"m",f).call(this).subarray(b(this,u,"f"),b(this,u,"f")+t);if(v(this,u,b(this,u,"f")+t,"f"),b(this,u,"f")===b(this,l,"f")&&(v(this,l,0,"f"),v(this,u,0,"f")),b(this,r,"m",p).call(this)){const t=this.drain();t&&(e=e.slice(0),this.write(t))}return e},m=function(t){const e=t*b(this,n,"f").BYTES_PER_ELEMENT;if(b(this,r,"m",f).call(this).length-b(this,l,"f")<=t){const t=b(this,s,"f");v(this,s,new ArrayBuffer(t.byteLength+e+b(this,r,"m",w).call(this)),"f"),b(this,r,"m",f).call(this).set(new(b(this,n,"f"))(t))}return b(this,r,"m",f).call(this).subarray(b(this,u,"f"),b(this,u,"f")+b(this,a,"f"))},w=function(){return b(this,a,"f")*b(this,n,"f").BYTES_PER_ELEMENT*b(this,i,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let t;do{t=this.read(),null!==t&&(yield t)}while(null!==t)}}class S extends g{constructor(t,e={}){super(Object.assign(Object.assign({},e),{frameSize:t,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}function E(t){return E="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},E(t)}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 j(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,k(n.key),n)}}function k(t){var e=function(t){if("object"!=E(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==E(e)?e:e+""}function M(t,e){return t.get(P(t,e))}function P(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;var C,O,W,A=new WeakMap,z=function(){return t=function t(e,r){var n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,A,void 0),n=A,i=new Array,n.set(P(n,this),i);for(var o=0;o<r;o++)M(A,this).push(new S(e,{frameCacheSize:20}))},(e=[{key:"write",value:function(t){if(t.length!==M(A,this).length)throw new Error("Expected ".concat(M(A,this).length," channels, but got ").concat(t.length));for(var e=0;e<t.length;e++)M(A,this)[e].write(t[e])}},{key:"read",value:function(){for(var t=[],e=0;e<M(A,this).length;e++){var r=M(A,this)[e].read();if(null===r)return null;t.push(r.slice(0))}return t}},{key:"remainingFrames",value:function(){var t,e=[],r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return T(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?T(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 o,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,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(M(A,this));try{for(r.s();!(t=r.n()).done;){var n=t.value;e.push(n.remainingFrames())}}catch(t){r.e(t)}finally{r.f()}return e}},{key:"drain",value:function(){for(var t=[],e=0;e<M(A,this).length;e++){var r=M(A,this)[e].drain();if(null===r)return null;t.push(r.slice(0))}return t.length?t:null}}])&&j(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),_=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},x=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};function F(t,e){return t===e}new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap;class I{constructor(t,e=F){C.set(this,void 0),O.set(this,void 0),W.set(this,void 0),_(this,W,null,"f"),_(this,C,t,"f"),_(this,O,e,"f")}get(t){const e=x(this,W,"f");if(e&&x(this,O,"f").call(this,e.key,t))return e.value;const r=x(this,C,"f").call(this,t);return _(this,W,{key:t,value:r},"f"),r}}function B(t){return B="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},B(t)}function R(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 $(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,D(n.key),n)}}function L(t){var e="function"==typeof Map?new Map:void 0;return L=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(N())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&Y(i,r.prototype),i}(t,arguments,q(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Y(r,t)},L(t)}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(N=function(){return!!t})()}function Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function D(t){var e=function(t){if("object"!=B(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}function U(t,e,r){G(t,e),e.set(t,r)}function G(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function H(t,e){return t.get(J(t,e))}function J(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}C=new WeakMap,O=new WeakMap,W=new WeakMap;var K=new WeakMap,Q=new WeakMap,V=new WeakSet,X=function(t){function e(){var t,r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=q(e),function(t,e){if(e&&("object"==B(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,N()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}(this,e),G(r=t,n=V),n.add(r),U(t,K,new I(function(t){var e=t.frameSize,r=t.channelCount;return new z(e,r)},function(t,e){return t.frameSize===e.frameSize&&t.channelCount===e.channelCount})),U(t,Q,!0),function(t,e,r){(e=D(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(t,"onMessage",function(e){e.data&&e.data.stop&&function(t,e){t.set(J(t,e),!1)}(Q,t)}),t.port.addEventListener("message",t.onMessage),t.port.start(),t}return function(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&&Y(t,e)}(e,t),r=e,i=[{key:"parameterDescriptors",get:function(){return[{name:"frameSize"},{name:"channelCount"},{name:"queueFrameCount"}]}}],(n=[{key:"process",value:function(t,e,r){var n,i,o,a=J(V,this,Z).call(this,"frameSize",r),s=J(V,this,Z).call(this,"channelCount",r),u=J(V,this,Z).call(this,"queueFrameCount",r),l=H(K,this).get({frameSize:a,channelCount:s}),f=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return R(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 o,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,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(f.s();!(n=f.n()).done;){var c=n.value;c.length&&l.write(c)}}catch(t){f.e(t)}finally{f.f()}if(l.remainingFrames().some(function(t){return t<u}))return H(Q,this);do{null!==(i=l.read())&&this.port.postMessage({samples:i},i.map(function(t){return t.buffer}))}while(null!==i);if(!H(Q,this))do{null!==(o=l.drain())&&this.port.postMessage({samples:o})}while(null!==o);return H(Q,this)}}])&&$(r.prototype,n),i&&$(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(L(AudioWorkletProcessor));function Z(t,e){var r=e[t];if(!r||0===r.length)throw new Error("Parameter ".concat(t," is missing"));return r[0]}registerProcessor("default-audio-processor",X)})();
|
|
1
|
+
(()=>{"use strict";class t extends Error{constructor(t){super(t)}}function e({name:e,value:r,validations:n}){const i=new Array;if(n.integer&&!Number.isSafeInteger(r)&&i.push("It must be an integer."),r>n.max&&i.push(`It must be up to ${n.max}.`),r<n.min&&i.push(`It must be at least ${n.min}.`),i.length>0)throw new t([`"${r}" is not a valid value for ${e}. It failed to following validations:\n`,...i.map(t=>`\t- ${t}`)].join(""));return r}var r,n,i,o,a,s,u,l,f,c,h,p,y,m,w,v=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},b=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};const d=4294967295;class g{constructor({frameSize:f,frameCacheSize:c=0,preallocateFrameCount:h=10,TypedArrayConstructor:p}){if(r.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,void 0),s.set(this,void 0),u.set(this,void 0),l.set(this,void 0),v(this,a,e({value:f,name:"Frame Size",validations:{min:1,integer:!0,max:d}}),"f"),v(this,i,e({value:h,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:d}}),"f"),v(this,o,e({value:c,name:"Frame Cache Size",validations:{min:0,integer:!1,max:d}}),"f"),!("BYTES_PER_ELEMENT"in p))throw new t("TypedArrayConstructor must be a typed array");v(this,u,0,"f"),v(this,l,0,"f"),v(this,n,p,"f"),v(this,s,new ArrayBuffer(b(this,r,"m",w).call(this)),"f")}empty(){return b(this,r,"m",h).call(this)<b(this,a,"f")}peek(){return b(this,r,"m",f).call(this)}write(t){b(this,r,"m",m).call(this,t.length),b(this,r,"m",f).call(this).subarray(b(this,l,"f"),b(this,l,"f")+t.length).set(t),v(this,l,b(this,l,"f")+t.length,"f")}remainingFrames(){return Math.floor(b(this,r,"m",c).call(this))}drain(){return b(this,r,"m",y).call(this,b(this,r,"m",h).call(this))}read(){return b(this,r,"m",y).call(this,b(this,a,"f"))}get[(n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,s=new WeakMap,u=new WeakMap,l=new WeakMap,r=new WeakSet,f=function(){return new(b(this,n,"f"))(b(this,s,"f"))},c=function(){return b(this,r,"m",h).call(this)/b(this,a,"f")},h=function(){return b(this,l,"f")-b(this,u,"f")},p=function(){return b(this,o,"f")>0&&b(this,r,"m",c).call(this)>=b(this,o,"f")},y=function(t){if(!t)return null;if(b(this,r,"m",h).call(this)<t)return null;let e=b(this,r,"m",f).call(this).subarray(b(this,u,"f"),b(this,u,"f")+t);if(v(this,u,b(this,u,"f")+t,"f"),b(this,u,"f")===b(this,l,"f")&&(v(this,l,0,"f"),v(this,u,0,"f")),b(this,r,"m",p).call(this)){const t=this.drain();t&&(e=e.slice(0),this.write(t))}return e},m=function(t){const e=t*b(this,n,"f").BYTES_PER_ELEMENT;if(b(this,r,"m",f).call(this).length-b(this,l,"f")<=t){const t=b(this,s,"f");v(this,s,new ArrayBuffer(t.byteLength+e+b(this,r,"m",w).call(this)),"f"),b(this,r,"m",f).call(this).set(new(b(this,n,"f"))(t))}return b(this,r,"m",f).call(this).subarray(b(this,u,"f"),b(this,u,"f")+b(this,a,"f"))},w=function(){return b(this,a,"f")*b(this,n,"f").BYTES_PER_ELEMENT*b(this,i,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let t;do{t=this.read(),null!==t&&(yield t)}while(null!==t)}}class S extends g{constructor(t,e={}){super(Object.assign(Object.assign({},e),{frameSize:t,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}function E(t){return E="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},E(t)}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 j(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,k(n.key),n)}}function k(t){var e=function(t){if("object"!=E(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==E(e)?e:e+""}function M(t,e){return t.get(P(t,e))}function P(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;var C,O,W,A=new WeakMap,z=function(){return t=function t(e,r){var n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,A,void 0),n=A,i=new Array,n.set(P(n,this),i);for(var o=0;o<r;o++)M(A,this).push(new S(e,{frameCacheSize:20}))},(e=[{key:"write",value:function(t){if(t.length!==M(A,this).length)throw new Error("Expected ".concat(M(A,this).length," channels, but got ").concat(t.length));for(var e=0;e<t.length;e++)M(A,this)[e].write(t[e])}},{key:"read",value:function(){for(var t=[],e=0;e<M(A,this).length;e++){var r=M(A,this)[e].read();if(null===r)return null;t.push(r.slice(0))}return t}},{key:"remainingFrames",value:function(){var t,e=[],r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return T(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?T(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 o,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,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(M(A,this));try{for(r.s();!(t=r.n()).done;){var n=t.value;e.push(n.remainingFrames())}}catch(t){r.e(t)}finally{r.f()}return e}},{key:"drain",value:function(){for(var t=[],e=0;e<M(A,this).length;e++){var r=M(A,this)[e].drain();if(null===r)return null;t.push(r.slice(0))}return t.length?t:null}}])&&j(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),_=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},x=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};function F(t,e){return t===e}new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap;class I{constructor(t,e=F){C.set(this,void 0),O.set(this,void 0),W.set(this,void 0),_(this,W,null,"f"),_(this,C,t,"f"),_(this,O,e,"f")}get(t){const e=x(this,W,"f");if(e&&x(this,O,"f").call(this,e.key,t))return e.value;const r=x(this,C,"f").call(this,t);return _(this,W,{key:t,value:r},"f"),r}}function B(t){return B="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},B(t)}function R(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 $(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,D(n.key),n)}}function L(t){var e="function"==typeof Map?new Map:void 0;return L=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(N())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&Y(i,r.prototype),i}(t,arguments,q(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Y(r,t)},L(t)}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(N=function(){return!!t})()}function Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function D(t){var e=function(t){if("object"!=B(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}function U(t,e,r){G(t,e),e.set(t,r)}function G(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function H(t,e){return t.get(J(t,e))}function J(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}C=new WeakMap,O=new WeakMap,W=new WeakMap;var K=new WeakMap,Q=new WeakMap,V=new WeakSet,X=function(t){function e(){var t,r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=q(e),function(t,e){if(e&&("object"==B(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,N()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}(this,e),G(r=t,n=V),n.add(r),U(t,K,new I(function(t){var e=t.frameSize,r=t.channelCount;return new z(e,r)},function(t,e){return t.frameSize===e.frameSize&&t.channelCount===e.channelCount})),U(t,Q,!0),function(t,e,r){(e=D(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(t,"onMessage",function(e){e.data&&e.data.stop&&function(t,e){t.set(J(t,e),!1)}(Q,t)}),t.port.addEventListener("message",t.onMessage),t.port.start(),t}return function(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&&Y(t,e)}(e,t),r=e,i=[{key:"parameterDescriptors",get:function(){return[{name:"frameSize"},{name:"channelCount"},{name:"queueFrameCount"}]}}],(n=[{key:"process",value:function(t,e,r){var n,i,o,a=J(V,this,Z).call(this,"frameSize",r),s=J(V,this,Z).call(this,"channelCount",r),u=J(V,this,Z).call(this,"queueFrameCount",r),l=H(K,this).get({frameSize:a,channelCount:s}),f=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return R(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 o,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,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(f.s();!(n=f.n()).done;){var c=n.value;c.length&&l.write(c.slice(0,s))}}catch(t){f.e(t)}finally{f.f()}if(l.remainingFrames().some(function(t){return t<u}))return H(Q,this);do{null!==(i=l.read())&&this.port.postMessage({samples:i},i.map(function(t){return t.buffer}))}while(null!==i);if(!H(Q,this))do{null!==(o=l.drain())&&this.port.postMessage({samples:o})}while(null!==o);return H(Q,this)}}])&&$(r.prototype,n),i&&$(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(L(AudioWorkletProcessor));function Z(t,e){var r=e[t];if(!r||0===r.length)throw new Error("Parameter ".concat(t," is missing"));return r[0]}registerProcessor("default-audio-processor",X)})();
|