(function(u,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(u=typeof globalThis<"u"?globalThis:u||self,c(u.Ctxz={}))})(this,function(u){"use strict";function c(){return!!globalThis.AudioWorklet&&!!globalThis.AudioWorkletNode}class l extends EventTarget{static registeredContexts=new Set;constructor(e,n){super(),this.workletNode=new AudioWorkletNode(e,"ctxz-denoiser-worklet-processor",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1]}),this.workletNode.port.addEventListener("message",this.handleMessageEvent.bind(this)),this.workletNode.port.start()}static async create(e,n,t,r,a,o,s,y){if(!c())throw new Error("\u4E0D\u652F\u6301AudioWorklet");if(e.state==="closed")throw new Error("\u97F3\u9891\u4E0A\u4E0B\u6587\u5DF2\u5173\u95ED");if(!l.registeredContexts.has(e)){const w=new Blob([` !function(){"use strict";var e={exports:{}};!function(e,t){var n,r=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e){var t,r,a;e=e||{},"function"==typeof AudioWorkletGlobalScope&&(t=globalThis.Module),t||(t=void 0!==e?e:{}),t.ready=new Promise((function(e,t){r=e,a=t}));var i,o=Object.assign({},t),u="./this.program",s="object"==typeof window,c="function"==typeof importScripts,l="function"==typeof AudioWorkletGlobalScope,f="";s||c?(c?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),n&&(f=n),f=0!==f.indexOf("blob:")?f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):"",c&&(i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})):l&&Object.assign(globalThis,{performance:{start:Date.now(),now:function(){return Date.now()-performance.start}}});var h,d=t.print||console.log.bind(console),p=t.printErr||console.warn.bind(console);Object.assign(t,o),o=null,t.thisProgram&&(u=t.thisProgram),t.wasmBinary&&(h=t.wasmBinary),t.noExitRuntime,"object"!=typeof WebAssembly&&$("no native wasm support detected");var m,v=!1,g="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function y(e,t,n){var r=t+n;for(n=t;e[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|i<<6|o:(7&a)<<18|i<<12|o<<6|63&e[t++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function b(e,t,n,r){if(0=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++a)),127>=i){if(n>=r)break;t[n++]=i}else{if(2047>=i){if(n+1>=r)break;t[n++]=192|i>>6}else{if(65535>=i){if(n+2>=r)break;t[n++]=224|i>>12}else{if(n+3>=r)break;t[n++]=240|i>>18,t[n++]=128|i>>12&63}t[n++]=128|i>>6&63}t[n++]=128|63&i}}t[n]=0}}function w(e){for(var t=0,n=0;n=r&&(r=65536+((1023&r)<<10)|1023&e.charCodeAt(++n)),127>=r?++t:t=2047>=r?t+2:65535>=r?t+3:t+4}return t}var A,T,C,k,_,D,P,E,O,S="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function W(e,t){for(var n=e>>1,r=n+t/2;!(n>=r)&&_[n];)++n;if(32<(n<<=1)-e&&S)return S.decode(C.subarray(e,n));for(n="",r=0;!(r>=t/2);++r){var a=k[e+2*r>>1];if(0==a)break;n+=String.fromCharCode(a)}return n}function F(e,t,n){if(void 0===n&&(n=2147483647),2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var a=0;a>1]=e.charCodeAt(a),t+=2;return k[t>>1]=0,t-r}function M(e){return 2*e.length}function j(e,t){for(var n=0,r="";!(n>=t/4);){var a=D[e+4*n>>2];if(0==a)break;++n,65536<=a?(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a)):r+=String.fromCharCode(a)}return r}function R(e,t,n){if(void 0===n&&(n=2147483647),4>n)return 0;var r=t;n=r+n-4;for(var a=0;a=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++a)),D[t>>2]=i,(t+=4)+4>n)break}return D[t>>2]=0,t-r}function N(e){for(var t=0,n=0;n=r&&++n,t+=4}return t}function I(){var e=m.buffer;A=e,t.HEAP8=T=new Int8Array(e),t.HEAP16=k=new Int16Array(e),t.HEAP32=D=new Int32Array(e),t.HEAPU8=C=new Uint8Array(e),t.HEAPU16=_=new Uint16Array(e),t.HEAPU32=P=new Uint32Array(e),t.HEAPF32=E=new Float32Array(e),t.HEAPF64=O=new Float64Array(e)}var U,B=[],Y=[],x=[];function H(){var e=t.preRun.shift();B.unshift(e)}var V,L=0,z=null;function $(e){throw t.onAbort&&t.onAbort(e),p(e="Aborted("+e+")"),v=!0,e=new WebAssembly.RuntimeError(e+". Build with -s ASSERTIONS=1 for more info."),a(e),e}function G(){return V.startsWith("data:application/octet-stream;base64,")}if(t.preloadedImages={},t.preloadedAudios={},V="audio_denoiser.wasm",!G()){var q=V;V=t.locateFile?t.locateFile(q,f):f+q}function J(){var e=V;try{if(e==V&&h)return new Uint8Array(h);if(i)return i(e);throw"both async and sync fetching of the wasm failed"}catch(e){$(e)}}function X(e){for(;0=K.length&&(K.length=e+1),K[e]=t=U.get(e)),t}function Q(e){this.ea=e-16,this.Xa=function(e){D[this.ea+4>>2]=e},this.Ra=function(e){D[this.ea+8>>2]=e},this.Sa=function(){D[this.ea>>2]=0},this.Pa=function(){T[this.ea+12>>0]=0},this.Ua=function(){T[this.ea+13>>0]=0},this.Na=function(e,t){this.Xa(e),this.Ra(t),this.Sa(),this.Pa(),this.Ua()}}var ee={};function te(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function ne(e){return this.fromWireType(P[e>>2])}var re={},ae={},ie={};function oe(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&57>=t?"_"+e:e}function ue(e,t){return e=oe(e),function(){return t.apply(this,arguments)}}function se(e){var t=Error,n=ue(e,(function(t){this.name=e,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\\n"+t.replace(/^Error(:[^\\n]*)?\\n/,""))}));return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},n}var ce=void 0;function le(e){throw new ce(e)}function fe(e,t,n){function r(t){(t=n(t)).length!==e.length&&le("Mismatched type converter count");for(var r=0;re,e):(we=new FinalizationRegistry((e=>{Te(e.ca)})),Ae=e=>{we.unregister(e)},(Se=e=>{var t=e.ca;return t.ga&&we.register(e,{ca:t},e),e})(e))}function We(){}function Fe(e,t,n){if(void 0===e[t].ma){var r=e[t];e[t]=function(){return e[t].ma.hasOwnProperty(arguments.length)||ge("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].ma+")!"),e[t].ma[arguments.length].apply(this,arguments)},e[t].ma=[],e[t].ma[r.va]=r}}function Me(e,n){t.hasOwnProperty(e)?(ge("Cannot register public name '"+e+"' twice"),Fe(t,e,e),t.hasOwnProperty(void 0)&&ge("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),t[e].ma[void 0]=n):t[e]=n}function je(e,t,n,r,a,i,o,u){this.name=e,this.constructor=t,this.na=n,this.ja=r,this.la=a,this.Va=i,this.ua=o,this.Qa=u,this.$a=[]}function Re(e,t,n){for(;t!==n;)t.ua||ge("Expected null or instance of "+n.name+", got an instance of "+t.name),e=t.ua(e),t=t.la;return e}function Ne(e,t){return null===t?(this.Fa&&ge("null is not a valid "+this.name),0):(t.ca||ge('Cannot pass "'+et(t)+'" as a '+this.name),t.ca.ea||ge("Cannot pass deleted object as a pointer of type "+this.name),Re(t.ca.ea,t.ca.fa.da,this.da))}function Ie(e,t){if(null===t){if(this.Fa&&ge("null is not a valid "+this.name),this.xa){var n=this.sa();return null!==e&&e.push(this.ja,n),n}return 0}if(t.ca||ge('Cannot pass "'+et(t)+'" as a '+this.name),t.ca.ea||ge("Cannot pass deleted object as a pointer of type "+this.name),!this.wa&&t.ca.fa.wa&&ge("Cannot convert argument of type "+(t.ca.ka?t.ca.ka.name:t.ca.fa.name)+" to parameter type "+this.name),n=Re(t.ca.ea,t.ca.fa.da,this.da),this.xa)switch(void 0===t.ca.ga&&ge("Passing raw pointer to smart pointer is illegal"),this.bb){case 0:t.ca.ka===this?n=t.ca.ga:ge("Cannot convert argument of type "+(t.ca.ka?t.ca.ka.name:t.ca.fa.name)+" to parameter type "+this.name);break;case 1:n=t.ca.ga;break;case 2:if(t.ca.ka===this)n=t.ca.ga;else{var r=t.clone();n=this.ab(n,Ke((function(){r.delete()}))),null!==e&&e.push(this.ja,n)}break;default:ge("Unsupporting sharing policy")}return n}function Ue(e,t){return null===t?(this.Fa&&ge("null is not a valid "+this.name),0):(t.ca||ge('Cannot pass "'+et(t)+'" as a '+this.name),t.ca.ea||ge("Cannot pass deleted object as a pointer of type "+this.name),t.ca.fa.wa&&ge("Cannot convert argument of type "+t.ca.fa.name+" to parameter type "+this.name),Re(t.ca.ea,t.ca.fa.da,this.da))}function Be(e,t,n,r){this.name=e,this.da=t,this.Fa=n,this.wa=r,this.xa=!1,this.ja=this.ab=this.sa=this.Ma=this.bb=this.Za=void 0,void 0!==t.la?this.toWireType=Ie:(this.toWireType=r?Ne:Ue,this.ia=null)}function Ye(e,n){var r=(e=me(e)).includes("j")?function(e,n){var r=[];return function(){if(r.length=0,Object.assign(r,arguments),e.includes("j")){var a=t["dynCall_"+e];a=r&&r.length?a.apply(null,[n].concat(r)):a.call(null,n)}else a=Z(n).apply(null,r);return a}}(e,n):Z(n);return"function"!=typeof r&&ge("unknown function pointer with signature "+e+": "+n),r}var xe=void 0;function He(e){var t=me(e=At(e));return wt(e),t}function Ve(e,t){var n=[],r={};throw t.forEach((function e(t){r[t]||ae[t]||(ie[t]?ie[t].forEach(e):(n.push(t),r[t]=!0))})),new xe(e+": "+n.map(He).join([", "]))}function Le(e,t){for(var n=[],r=0;r>2)+r]);return n}function ze(e,t,n,r,a){var i=t.length;2>i&&ge("argTypes array size mismatch! Must at least get return value and 'this' types!");var o=null!==t[1]&&null!==n,u=!1;for(n=1;n>2])};case 3:return function(e){return this.fromWireType(O[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function nt(e,t,n){switch(t){case 0:return n?function(e){return T[e]}:function(e){return C[e]};case 1:return n?function(e){return k[e>>1]}:function(e){return _[e>>1]};case 2:return n?function(e){return D[e>>2]}:function(e){return P[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var rt,at={};rt=()=>performance.now();var it={};function ot(){if(!ut){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:u||"./this.program"};for(e in it)void 0===it[e]?delete t[e]:t[e]=it[e];var n=[];for(e in t)n.push(e+"="+t[e]);ut=n}return ut}var ut,st=[null,[],[]],ct={};function lt(e){return 0==e%4&&(0!=e%100||0==e%400)}function ft(e,t){for(var n=0,r=0;r<=t;n+=e[r++]);return n}var ht=[31,29,31,30,31,30,31,31,30,31,30,31],dt=[31,28,31,30,31,30,31,31,30,31,30,31];function pt(e,t){for(e=new Date(e.getTime());0r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function mt(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.lengthe?-1:0=o(n,e)?0>=o(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var c=D[r+40>>2];for(var l in r={fb:D[r>>2],eb:D[r+4>>2],ya:D[r+8>>2],ta:D[r+12>>2],qa:D[r+16>>2],ha:D[r+20>>2],za:D[r+24>>2],Aa:D[r+28>>2],lb:D[r+32>>2],cb:D[r+36>>2],gb:c&&c?y(C,c,void 0):""},n=n?y(C,n,void 0):"",c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(l,"g"),c[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),h="January February March April May June July August September October November December".split(" ");for(l in c={"%a":function(e){return f[e.za].substring(0,3)},"%A":function(e){return f[e.za]},"%b":function(e){return h[e.qa].substring(0,3)},"%B":function(e){return h[e.qa]},"%C":function(e){return i((e.ha+1900)/100|0,2)},"%d":function(e){return i(e.ta,2)},"%e":function(e){return a(e.ta,2," ")},"%g":function(e){return s(e).toString().substring(2)},"%G":function(e){return s(e)},"%H":function(e){return i(e.ya,2)},"%I":function(e){return 0==(e=e.ya)?e=12:12e.ya?"AM":"PM"},"%S":function(e){return i(e.fb,2)},"%t":function(){return"\\t"},"%u":function(e){return e.za||7},"%U":function(e){var t=new Date(e.ha+1900,0,1),n=0===t.getDay()?t:pt(t,7-t.getDay());return 0>o(n,e=new Date(e.ha+1900,e.qa,e.ta))?i(Math.ceil((31-n.getDate()+(ft(lt(e.getFullYear())?ht:dt,e.getMonth()-1)-31)+e.getDate())/7),2):0===o(n,t)?"01":"00"},"%V":function(e){var t=new Date(e.ha+1901,0,4),n=u(new Date(e.ha+1900,0,4));t=u(t);var r=pt(new Date(e.ha+1900,0,1),e.Aa);return 0>o(r,n)?"53":0>=o(t,r)?"01":i(Math.ceil((n.getFullYear()o(n,e=new Date(e.ha+1900,e.qa,e.ta))?i(Math.ceil((31-n.getDate()+(ft(lt(e.getFullYear())?ht:dt,e.getMonth()-1)-31)+e.getDate())/7),2):0===o(n,t)?"01":"00"},"%y":function(e){return(e.ha+1900).toString().substring(2)},"%Y":function(e){return e.ha+1900},"%z":function(e){var t=0<=(e=e.cb);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.gb},"%%":function(){return"%"}},n=n.replace(/%%/g,"\\0\\0"),c)n.includes(l)&&(n=n.replace(new RegExp(l,"g"),c[l](r)));return l=function(e){var t=Array(w(e)+1);return b(e,t,0,t.length),t}(n=n.replace(/\\0\\0/g,"%")),l.length>t?0:(T.set(l,e),l.length-1)}ce=t.InternalError=se("InternalError");for(var vt=Array(256),gt=0;256>gt;++gt)vt[gt]=String.fromCharCode(gt);pe=vt,ve=t.BindingError=se("BindingError"),We.prototype.isAliasOf=function(e){if(!(this instanceof We&&e instanceof We))return!1;var t=this.ca.fa.da,n=this.ca.ea,r=e.ca.fa.da;for(e=e.ca.ea;t.la;)n=t.ua(n),t=t.la;for(;r.la;)e=r.ua(e),r=r.la;return t===r&&n===e},We.prototype.clone=function(){if(this.ca.ea||be(this),this.ca.ra)return this.ca.count.value+=1,this;var e=Se,t=Object,n=t.create,r=Object.getPrototypeOf(this),a=this.ca;return(e=e(n.call(t,r,{ca:{value:{count:a.count,pa:a.pa,ra:a.ra,ea:a.ea,fa:a.fa,ga:a.ga,ka:a.ka}}}))).ca.count.value+=1,e.ca.pa=!1,e},We.prototype.delete=function(){this.ca.ea||be(this),this.ca.pa&&!this.ca.ra&&ge("Object already scheduled for deletion"),Ae(this),Te(this.ca),this.ca.ra||(this.ca.ga=void 0,this.ca.ea=void 0)},We.prototype.isDeleted=function(){return!this.ca.ea},We.prototype.deleteLater=function(){return this.ca.ea||be(this),this.ca.pa&&!this.ca.ra&&ge("Object already scheduled for deletion"),_e.push(this),1===_e.length&&Pe&&Pe(De),this.ca.pa=!0,this},t.getInheritedInstanceCount=function(){return Object.keys(Ee).length},t.getLiveInheritedInstances=function(){var e,t=[];for(e in Ee)Ee.hasOwnProperty(e)&&t.push(Ee[e]);return t},t.flushPendingDeletes=De,t.setDelayFunction=function(e){Pe=e,_e.length&&Pe&&Pe(De)},Be.prototype.Wa=function(e){return this.Ma&&(e=this.Ma(e)),e},Be.prototype.Ka=function(e){this.ja&&this.ja(e)},Be.prototype.argPackAdvance=8,Be.prototype.readValueFromPointer=ne,Be.prototype.deleteObject=function(e){null!==e&&e.delete()},Be.prototype.fromWireType=function(e){function t(){return this.xa?Oe(this.da.na,{fa:this.Za,ea:n,ka:this,ga:e}):Oe(this.da.na,{fa:this,ea:e})}var n=this.Wa(e);if(!n)return this.Ka(e),null;var r=function(e,t){for(void 0===t&&ge("ptr should not be undefined");e.la;)t=e.ua(t),e=e.la;return Ee[t]}(this.da,n);if(void 0!==r)return 0===r.ca.count.value?(r.ca.ea=n,r.ca.ga=e,r.clone()):(r=r.clone(),this.Ka(e),r);if(r=this.da.Va(n),!(r=ke[r]))return t.call(this);r=this.wa?r.Oa:r.pointerType;var a=Ce(n,this.da,r.da);return null===a?t.call(this):this.xa?Oe(r.da.na,{fa:r,ea:a,ka:this,ga:e}):Oe(r.da.na,{fa:r,ea:a})},xe=t.UnboundTypeError=se("UnboundTypeError"),t.count_emval_handles=function(){for(var e=0,t=5;ta.fromWireType(i(o,e)),t.write=(e,t)=>{var n=[];s(c,e,u.toWireType(n,t)),te(n)}})),[{name:t.name,fromWireType:function(e){for(var t=Array(r),a=0;a>i])},ia:null})},w:function(e,n,r,a,i,o,u,s,c,l,f,h,d){f=me(f),o=Ye(i,o),s&&(s=Ye(u,s)),l&&(l=Ye(c,l)),d=Ye(h,d);var p=oe(f);Me(p,(function(){Ve("Cannot construct "+f+" due to unbound types",[a])})),fe([e,n,r],a?[a]:[],(function(n){if(n=n[0],a)var r=n.da,i=r.na;else i=We.prototype;n=ue(p,(function(){if(Object.getPrototypeOf(this)!==u)throw new ve("Use 'new' to construct "+f);if(void 0===c.oa)throw new ve(f+" has no accessible constructor");var e=c.oa[arguments.length];if(void 0===e)throw new ve("Tried to invoke ctor of "+f+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(c.oa).toString()+") parameters instead!");return e.apply(this,arguments)}));var u=Object.create(i,{constructor:{value:n}});n.prototype=u;var c=new je(f,n,u,d,r,o,s,l);r=new Be(f,c,!0,!1),i=new Be(f+"*",c,!1,!1);var h=new Be(f+" const*",c,!1,!0);return ke[e]={pointerType:i,Oa:h},function(e,n){t.hasOwnProperty(e)||le("Replacing nonexistant public symbol"),t[e]=n,t[e].va=void 0}(p,n),[r,i,h]}))},t:function(e,t,n,r,a,i){0{Ve("Cannot construct "+e.name+" due to unbound types",o)},fe([],o,(function(r){return r.splice(1,0,null),e.da.oa[t-1]=ze(n,r,null,a,i),[]})),[]}))},l:function(e,t,n,r,a,i,o,u){var s=Le(n,r);t=me(t),i=Ye(a,i),fe([],[e],(function(e){function r(){Ve("Cannot call "+a+" due to unbound types",s)}var a=(e=e[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),u&&e.da.$a.push(t);var c=e.da.na,l=c[t];return void 0===l||void 0===l.ma&&l.className!==e.name&&l.va===n-2?(r.va=n-2,r.className=e.name,c[t]=r):(Fe(c,t,a),c[t].ma[n-2]=r),fe([],s,(function(r){return r=ze(a,r,e,i,o),void 0===c[t].ma?(r.va=n-2,c[t]=r):c[t].ma[n-2]=r,[]})),[]}))},m:function(e,t,n,r,a,i,o,u,s,c){t=me(t),a=Ye(r,a),fe([],[e],(function(e){var r=(e=e[0]).name+"."+t,l={get:function(){Ve("Cannot access "+r+" due to unbound types",[n,o])},enumerable:!0,configurable:!0};return l.set=s?()=>{Ve("Cannot access "+r+" due to unbound types",[n,o])}:()=>{ge(r+" is a read-only property")},Object.defineProperty(e.da.na,t,l),fe([],s?[n,o]:[n],(function(n){var o=n[0],l={get:function(){var t=$e(this,e,r+" getter");return o.fromWireType(a(i,t))},enumerable:!0};if(s){s=Ye(u,s);var f=n[1];l.set=function(t){var n=$e(this,e,r+" setter"),a=[];s(c,n,f.toWireType(a,t)),te(a)}}return Object.defineProperty(e.da.na,t,l),[]})),[]}))},J:function(e,t){ye(e,{name:t=me(t),fromWireType:function(e){var t=Xe(e);return Je(e),t},toWireType:function(e,t){return Ke(t)},argPackAdvance:8,readValueFromPointer:ne,ia:null})},M:function(e,t,n,r){function a(){}n=de(n),t=me(t),a.values={},ye(e,{name:t,constructor:a,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:Ze(t,n,r),ia:null}),Me(t,a)},n:function(e,t,n){var r=Qe(e,"enum");t=me(t),e=r.constructor,r=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:ue(r.name+"_"+t,(function(){}))}}),e.values[n]=r,e[t]=r},u:function(e,t,n){n=de(n),ye(e,{name:t=me(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:tt(t,n),ia:null})},i:function(e,t,n,r,a){t=me(t),-1===a&&(a=4294967295),a=de(n);var i=e=>e;if(0===r){var o=32-8*n;i=e=>e<>>o}n=t.includes("unsigned")?function(e,t){return t>>>0}:function(e,t){return t},ye(e,{name:t,fromWireType:i,toWireType:n,argPackAdvance:8,readValueFromPointer:nt(t,a,0!==r),ia:null})},g:function(e,t,n){function r(e){var t=P;return new a(A,t[1+(e>>=2)],t[e])}var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];ye(e,{name:n=me(n),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{Ya:!0})},v:function(e,t){var n="std::string"===(t=me(t));ye(e,{name:t,fromWireType:function(e){var t=P[e>>2];if(n)for(var r=e+4,a=0;a<=t;++a){var i=e+4+a;if(a==t||0==C[i]){if(r=r?y(C,r,i-r):"",void 0===o)var o=r;else o+=String.fromCharCode(0),o+=r;r=i+1}}else{for(o=Array(t),a=0;aw(t):()=>t.length)(),i=bt(4+a+1);if(P[i>>2]=a,n&&r)b(t,C,i+4,a+1);else if(r)for(r=0;r_,u=1;else 4===t&&(r=j,a=R,i=N,o=()=>P,u=2);ye(e,{name:n,fromWireType:function(e){for(var n,a=P[e>>2],i=o(),s=e+4,c=0;c<=a;++c){var l=e+4+c*t;c!=a&&0!=i[l>>u]||(s=r(s,l-s),void 0===n?n=s:(n+=String.fromCharCode(0),n+=s),s=l+t)}return wt(e),n},toWireType:function(e,r){"string"!=typeof r&&ge("Cannot pass non-string to C++ string type "+n);var o=i(r),s=bt(4+o+t);return P[s>>2]=o>>u,a(r,s+4,o+t),null!==e&&e.push(wt,s),s},argPackAdvance:8,readValueFromPointer:ne,ia:function(e){wt(e)}})},O:function(e,t,n,r,a,i){ee[e]={name:me(t),sa:Ye(n,r),ja:Ye(a,i),elements:[]}},r:function(e,t,n,r,a,i,o,u,s){ee[e].elements.push({Ea:t,Ca:Ye(n,r),Da:a,Ia:i,Ha:Ye(o,u),Ja:s})},Q:function(e,t,n,r,a,i){he[e]={name:me(t),sa:Ye(n,r),ja:Ye(a,i),La:[]}},o:function(e,t,n,r,a,i,o,u,s,c){he[e].La.push({Ta:me(t),Ea:n,Ca:Ye(r,a),Da:i,Ia:o,Ha:Ye(u,s),Ja:c})},L:function(e,t){ye(e,{kb:!0,name:t=me(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},f:function(e,t,n){e=Xe(e),t=Qe(t,"emval::as");var r=[],a=Ke(r);return D[n>>2]=a,t.toWireType(r,e)},a:Je,d:function(e,t){return Ke((e=Xe(e))[t=Xe(t)])},x:function(e){4>2]=28,-1;e=rt()}return D[t>>2]=e/1e3|0,D[t+4>>2]=e%1e3*1e6|0,0},I:function(e,t,n){C.copyWithin(e,t,t+n)},p:function(e){var t=C.length;if(2147483648<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math;r=Math.max(e,r),a=a.min.call(a,2147483648,r+(65536-r%65536)%65536);e:{try{m.grow(a-A.byteLength+65535>>>16),I();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},D:function(e,t){var n=0;return ot().forEach((function(r,a){var i=t+n;for(a=D[e+4*a>>2]=i,i=0;i>0]=r.charCodeAt(i);T[a>>0]=0,n+=r.length+1})),0},E:function(e,t){var n=ot();D[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),D[t>>2]=r,0},H:function(){return 0},F:function(e,t,n,r){return e=ct.jb(e),t=ct.hb(e,t,n),D[r>>2]=t,0},z:function(){},s:function(e,t,n,r){for(var a=0,i=0;i>2],u=D[t+4>>2];t+=8;for(var s=0;s>2]=a,0},B:function(){},C:function(e,t,n,r){return mt(e,t,n,r)}};!function(){function e(e){t.asm=e.exports,m=t.asm.R,I(),U=t.asm.V,Y.unshift(t.asm.S),L--,t.monitorRunDependencies&&t.monitorRunDependencies(L),0==L&&z&&(e=z,z=null,e())}function n(t){e(t.instance)}function r(e){return(h||!s&&!c||"function"!=typeof fetch?Promise.resolve().then((function(){return J()})):fetch(V,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+V+"'";return e.arrayBuffer()})).catch((function(){return J()}))).then((function(e){return WebAssembly.instantiate(e,i)})).then((function(e){return e})).then(e,(function(e){p("failed to asynchronously prepare wasm: "+e),$(e)}))}var i={a:yt};if(L++,t.monitorRunDependencies&&t.monitorRunDependencies(L),t.instantiateWasm)try{return t.instantiateWasm(i,e)}catch(e){return p("Module.instantiateWasm callback failed with error: "+e),!1}(h||"function"!=typeof WebAssembly.instantiateStreaming||G()||"function"!=typeof fetch?r(n):fetch(V,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,i).then(n,(function(e){return p("wasm streaming compile failed: "+e),p("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a)}(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.S).apply(null,arguments)};var bt=t._malloc=function(){return(bt=t._malloc=t.asm.T).apply(null,arguments)},wt=t._free=function(){return(wt=t._free=t.asm.U).apply(null,arguments)},At=t.___getTypeName=function(){return(At=t.___getTypeName=t.asm.W).apply(null,arguments)};t.___embind_register_native_and_builtin_types=function(){return(t.___embind_register_native_and_builtin_types=t.asm.X).apply(null,arguments)};var Tt,Ct=t.___errno_location=function(){return(Ct=t.___errno_location=t.asm.Y).apply(null,arguments)};function kt(){function e(){if(!Tt&&(Tt=!0,t.calledRun=!0,!v)){if(X(Y),r(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var e=t.postRun.shift();x.unshift(e)}X(x)}}if(!(0=this.bufferTime*sampleRate&&(this.dumpBundleFrameCount=0,this.dump())),this.frameCount+=r.length;const a=sampleRate/2;for(;this.frameCount>=a;)this.uploadStats(),this.frameCount-=a}catch(e){r.set(n),this.log("error",\`[ai-denoiser-worklet] detect error from wasm: \${e}\`)}else r.set(n);return!0}log(e,t){this.port.postMessage({event:"log",level:e,message:t})}getValue(){var e;const t=this.enabled?null===(e=this.kernel)||void 0===e?void 0:e.value:1;this.port.postMessage({event:"getValue",value:t})}getLevel(){var e;const t=this.enabled?null===(e=this.kernel)||void 0===e?void 0:e.level:1;this.port.postMessage({event:"getLevel",level:t})}enable(){this.enabled||(this.enabled=!0,this.log("debug","[ai-denoiser-worklet] denoiser was enabled")),this.port.postMessage({event:"enable"})}disable(){this.enabled&&(this.enabled=!1,this.isDumping&&(this.dump(),this.endDump()),this.reset(),this.log("debug","[ai-denoiser-worklet] denoiser was disabled")),this.port.postMessage({event:"disable"})}startDump(){this.isDumping?this.log("debug","[ai-denoiser-worklet] dump has already started"):(this.isDumping=!0,this.dumpBundleNumCount=0,this.dumpBundleFrameCount=0,this.dump(),this.log("debug","[ai-denoiser-worklet] dump started"))}dump(){if(this.kernel){const e=this.kernel.dump(this.bufferTime),t=new Float32Array(e[0].numberOfFrames),n=new Float32Array(e[1].numberOfFrames),r=new Float32Array(e[2].numberOfFrames);t.set(e[0].getChannelData(0)),n.set(e[1].getChannelData(0)),r.set(e[2].getChannelData(0)),e[0].delete(),e[1].delete(),e[2].delete();const a=i(t),o=i(n),u=i(r);this.log("debug",\`[ai-denoiser-worklet] dump: input \${a.length*Int16Array.BYTES_PER_ELEMENT} bytes, nsOut \${o.length*Int16Array.BYTES_PER_ELEMENT} bytes, agcOut \${u.length*Int16Array.BYTES_PER_ELEMENT} bytes\`),this.port.postMessage({event:"dump",dump:{input:a,nsOut:o,agcOut:u},lts:Date.now()},[a.buffer,o.buffer,u.buffer]),this.dumpBundleNumCount+=1,this.dumpBundleNumCount>=this.dumpBundleNums&&this.endDump()}}endDump(){this.isDumping?(this.isDumping=!1,this.log("debug","[ai-denoiser-worklet] dump ended")):this.log("debug","[ai-denoiser-worklet] dump has already ended"),this.port.postMessage({evnet:"dumpend"})}setParameters(e){this.kernel&&(this.kernel.setNsParams(e),this.log("debug",\`[ai-denoiser-worklet] set ns params \${JSON.stringify(e)}\`)),this.port.postMessage({event:"setParameters"})}setAgcParameters(e){this.kernel&&(this.kernel.setAgcParams(e),this.log("debug",\`[ai-denoiser-worklet] set agc params \${JSON.stringify(e)}\`)),this.port.postMessage({event:"setAgcParameters"})}initialize(e,n,r,a,i,o){t({wasmBinary:e}).then((e=>{this.module=e,this.buffer=new e.AudioBuffer(1,128),this.kernel=new e.AudioDenoiser(sampleRate,n,r,a),this.lastStatus=e.AudioDenoiserStatus.UNCERTAIN,this.bufferTime=a,this.dumpBundleNums=i,this.threshold=o,this.log("debug",\`[ai-denoiser-worklet] kernel version: \${this.kernel.version}-\${this.kernel.buildInfo}, options: {sampleRate: \${sampleRate}, enabled: \${n}, agc: \${r}, bufferTime: \${a}, dumpBundleNums: \${i}, threshold: \${o}}\`),this.port.postMessage({event:"initialize"})})).catch((e=>{this.port.postMessage({event:"initialize",error:e})}))}reset(){var e,t;null===(e=this.kernel)||void 0===e||e.reset(),this.lastStatus=null===(t=this.module)||void 0===t?void 0:t.AudioDenoiserStatus.UNCERTAIN}destroy(){var e,t;this.module=void 0,null===(e=this.buffer)||void 0===e||e.delete(),this.buffer=void 0,null===(t=this.kernel)||void 0===t||t.delete(),this.kernel=void 0,this.lastStatus=void 0,this.log("debug","[ai-denoiser-worklet] denoiser was destroyed"),this.port.postMessage({event:"destroy"})}uploadStats(){if(!this.kernel)return;const e=this.kernel.getStats();this.port.postMessage({event:"stats",stats:{ebn:e.energy_bf_ns,ean:e.energy_af_ns,ns:e.ns_state,vl:e.vad_loss}}),this.threshold>0&&e.elapsed_time>this.threshold&&this.port.postMessage({event:"overload",elpasedTime:e.elapsed_time})}onStatusChange(e){var t;let n="UNKNOWN",r="debug";const a=null===(t=this.module)||void 0===t?void 0:t.AudioDenoiserStatus;a&&(e===a.UNCERTAIN?n="UNCERTAIN":e===a.NORMAL?n="NORMAL":e===a.DANGLY?n="DANGLY":e===a.STRONGBAD?(n="STRONGBAD",r="warning"):e===a.NOINPUT?(n="NOINPUT",r="warning"):e===a.NOOUTPUT&&(n="NOOUTPUT",r="warning")),this.log(r,\`[ai-denoiser-worklet] kernel status changed to \${n}\`)}handleMessageEvent(e){const t=e.data,n=t.event;"getValue"===n?this.getValue():"getLevel"===n?this.getLevel():"enable"===n?this.enable():"disable"===n?this.disable():"dump"===n?this.startDump():"setParameters"===n?this.setParameters(t.parameters):"setAgcParameters"===n?this.setAgcParameters(t.agcParameters):"initialize"===n?this.initialize(t.wasmSource,t.enabled,t.agc,t.bufferTime,t.dumpBundleNums,t.threshold):"destroy"===n&&this.destroy()}}registerProcessor("ctxz-denoiser-worklet-processor",o)}(); `],{type:"text/javascript"}),m=URL.createObjectURL(w);await e.audioWorklet.addModule(m),setTimeout(()=>URL.revokeObjectURL(m),0),l.registeredContexts.add(e),e.addEventListener("statechange",function b(){e.state==="closed"&&(l.registeredContexts.delete(e),e.removeEventListener("statechange",b))})}const p=new l(e,y);return await p.initialize(n,t,r,a,o,s),p}get node(){return this.workletNode}async getValue(){return(await this.requestResponse({event:"getValue"})).value}async getLevel(){return(await this.requestResponse({event:"getLevel"})).level}enable(){return this.requestResponse({event:"enable"})}disable(){return this.requestResponse({event:"disable"})}dump(){this.workletNode.port.postMessage({event:"dump"})}setParameters(e){return this.requestResponse({event:"setParameters",parameters:e})}setAgcParameters(e){return this.requestResponse({event:"setAgcParameters",agcParameters:e})}destroy(){return this.requestResponse({event:"destroy"})}initialize(e,n,t,r,a,o){return this.requestResponse({event:"initialize",wasmSource:e,enabled:n,agc:t,bufferTime:r,dumpBundleNums:a,threshold:o})}handleMessageEvent(e){const n=e.data,t=n.event;t==="stats"?this.dispatchEvent(new CustomEvent("stats",{detail:{stats:n.stats}})):t==="log"?console.log("\u6253\u5370\u65E5\u5FD7",n):t==="overload"?this.dispatchEvent(new CustomEvent("overload",{detail:{elapsedTime:n.elapsedTime}})):t==="dump"?this.dispatchEvent(new CustomEvent("dump",{detail:{dump:n.dump,lts:n.lts}})):t==="dumpend"?this.dispatchEvent(new CustomEvent("dumpend")):console.log(e)}requestResponse(e,n=[]){return new Promise((t,r)=>{const a=this.workletNode.port;a.addEventListener("message",function o(s){s.data.event===e.event&&(a.removeEventListener("message",o),s.data.error?r(s.data.error):t(s.data))}),a.postMessage(e,n),a.start()})}}async function g(d){const e=await(async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])))(),n=`${d}/${e?"denoiser-wasm-simd.wasm":"denoiser-wasm.wasm"}`,t=await fetch(n);if(!t.ok)throw new Error(`\u52A0\u8F7DWASM\u811A\u672C\u5931\u8D25,\u54CD\u5E94\u72B6\u6001:${t.status}`);return t}class v{constructor(e){this.params=e,this.wasmSource=g(e.assetsPath).then(n=>n.arrayBuffer()),this._events={}}async init(){const{context:e,ains:n,agc:t,bufferTime:r,dumpBundleNums:a,threshold:o}=this.params;if(!this.checkCompatibility())throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u65E0\u6CD5\u5D4C\u5165\u964D\u566A\u529F\u80FD");return this.ctxzAudioWorkletNode=await this.wasmSource.then(s=>l.create(e,s,n,t,r,a,o)).then(s=>this.setup(s)),this.ctxzAudioWorkletNode}connect(e,n){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");const t=this.ctxzAudioWorkletNode.node;return e.connect(t),t}disconnect(){const e=this.ctxzAudioWorkletNode.node;this.lastNode&&(this.lastNode.disconnect(e),this.lastNode=null)}get node(){return this.ctxzAudioWorkletNode.node}getListeners(e){return this._events[e]?this._events[e].map(n=>n.listener):[]}on(e,n){this._events[e]||(this._events[e]=[]);const t=this._events[e];this._indexOfListener(t,n)===-1&&t.push({listener:n,once:!1})}once(e,n){this._events[e]||(this._events[e]=[]);const t=this._events[e];this._indexOfListener(t,n)===-1&&t.push({listener:n,once:!0})}off(e,n){if(!this._events[e])return;const t=this._events[e],r=this._indexOfListener(t,n);r!==-1&&t.splice(r,1),this._events[e].length===0&&delete this._events[e]}removeAllListeners(e){e?delete this._events[e]:this._events={}}emit(e){this._events[e]||(this._events[e]=[]);const n=this._events[e].map(o=>o);for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a1?n-1:0),r=1;r{this.emit(e,...t,a,o)})}emitAsPromiseNoResponse(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;rthis.emitAsPromiseNoResponse("dumpend")),e.addEventListener("overload",this.handleOverloadEvent.bind(this)),e}handleOverloadEvent(e){const n=e.detail.elapsedTime;this.emitAsPromiseNoResponse("overload",n)}setLevel(e){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");if(e==h.SOFT)return this.ctxzAudioWorkletNode.setParameters({lowerBound:.08,lowerMask:.05,statisticalBound:.05,finalLowerMask:.03});if(e==h.AGGRESSIVE)return this.ctxzAudioWorkletNode.setParameters({lowerBound:.01,lowerMask:.01,statisticalBound:0,finalLowerMask:.008});throw new Error("\u672A\u77E5\u7B49\u7EA7")}setMode(e){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");if(e==f.STATIONARY_NS)return this.ctxzAudioWorkletNode.setParameters({nsRoute:0});if(e==f.NSNG)return this.ctxzAudioWorkletNode.setParameters({nsRoute:2});throw new Error("\u672A\u77E5\u6A21\u5F0F")}enable(){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");return this.ctxzAudioWorkletNode.enable()}disable(){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");return this.ctxzAudioWorkletNode.disable()}dump(){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");return this.ctxzAudioWorkletNode.dump()}destroy(){if(!this.ctxzAudioWorkletNode)throw new Error("\u97F3\u9891\u8282\u70B9\u672A\u521D\u59CB\u5316");return this.ctxzAudioWorkletNode.destroy()}checkCompatibility(){try{return c()&&!!globalThis.WebAssembly&&!!globalThis.WebAssembly.compile}catch{return!1}}}const f={NSNG:"NSNG",STATIONARY_NS:"STATIONARY_NS"},h={SOFT:"SOFT",AGGRESSIVE:"AGGRESSIVE"};u.AIDenoiser=v,u.AIDenoiserProcessorLevel=h,u.AIDenoiserProcessorMode=f});