UNPKG

@picovoice/leopard-react

Version:

React hook for Leopard Web SDK

1 lines 760 kB
import{useState as A,useRef as I,useCallback as g,useEffect as C}from"react";import{WebVoiceProcessor as B}from"@picovoice/web-voice-processor";function Q(A,I,g,C,B,Q,E){try{var i=A[Q](E),G=i.value}catch(A){return void g(A)}i.done?I(G):Promise.resolve(G).then(C,B)}function E(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var E=A.apply(I,g);function i(A){Q(E,C,B,i,G,"next",A)}function G(A){Q(E,C,B,i,G,"throw",A)}i(void 0)}))}}function i(A,I){(null==I||I>A.length)&&(I=A.length);for(var g=0,C=new Array(I);g<I;g++)C[g]=A[g];return C}function G(A,I){return function(A){if(Array.isArray(A))return A}(A)||function(A,I){var g=null==A?null:"undefined"!=typeof Symbol&&A[Symbol.iterator]||A["@@iterator"];if(null!=g){var C,B,Q,E,i=[],G=!0,o=!1;try{if(Q=(g=g.call(A)).next,0===I){if(Object(g)!==g)return;G=!1}else for(;!(G=(C=Q.call(g)).done)&&(i.push(C.value),i.length!==I);G=!0);}catch(A){o=!0,B=A}finally{try{if(!G&&null!=g.return&&(E=g.return(),Object(E)!==E))return}finally{if(o)throw B}}return i}}(A,I)||function(A,I){if(A){if("string"==typeof A)return i(A,I);var g=Object.prototype.toString.call(A).slice(8,-1);return"Object"===g&&A.constructor&&(g=A.constructor.name),"Map"===g||"Set"===g?Array.from(A):"Arguments"===g||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g)?i(A,I):void 0}}(A,I)||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(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var R={exports:{}},w={exports:{}};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}(w);var F=w.exports;!function(A){var I=F.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},Q=Object.prototype,E=Q.hasOwnProperty,i=Object.defineProperty||function(A,I,g){A[I]=g.value},G="function"==typeof Symbol?Symbol:{},o=G.iterator||"@@iterator",R=G.asyncIterator||"@@asyncIterator",w=G.toStringTag||"@@toStringTag";function F(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{F({},"")}catch(C){F=function(A,I,g){return A[I]=g}}function c(A,I,g,C){var B=I&&I.prototype instanceof U?I:U,Q=Object.create(B.prototype),E=new K(C||[]);return i(Q,"_invoke",{value:M(A,g,E)}),Q}function y(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=c;var D="suspendedStart",h="suspendedYield",s="executing",Z="completed",l={};function U(){}function a(){}function d(){}var N={};F(N,o,(function(){return this}));var Y=Object.getPrototypeOf,b=Y&&Y(Y(V([])));b&&b!==Q&&E.call(b,o)&&(N=b);var S=d.prototype=U.prototype=Object.create(N);function J(A){["next","throw","return"].forEach((function(I){F(A,I,(function(A){return this._invoke(I,A)}))}))}function n(A,g){function C(B,Q,i,G){var o=y(A[B],A,Q);if("throw"!==o.type){var R=o.arg,w=R.value;return w&&"object"==I(w)&&E.call(w,"__await")?g.resolve(w.__await).then((function(A){C("next",A,i,G)}),(function(A){C("throw",A,i,G)})):g.resolve(w).then((function(A){R.value=A,i(R)}),(function(A){return C("throw",A,i,G)}))}G(o.arg)}var B;i(this,"_invoke",{value:function(A,I){function Q(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(Q,Q):Q()}})}function M(A,I,g){var B=D;return function(Q,E){if(B===s)throw new Error("Generator is already running");if(B===Z){if("throw"===Q)throw E;return{value:C,done:!0}}for(g.method=Q,g.arg=E;;){var i=g.delegate;if(i){var G=H(i,g);if(G){if(G===l)continue;return G}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===D)throw B=Z,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=s;var o=y(A,I,g);if("normal"===o.type){if(B=g.done?Z:h,o.arg===l)continue;return{value:o.arg,done:g.done}}"throw"===o.type&&(B=Z,g.method="throw",g.arg=o.arg)}}}function H(A,I){var g=I.method,B=A.iterator[g];if(B===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=C,H(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),l;var Q=y(B,A.iterator,I.arg);if("throw"===Q.type)return I.method="throw",I.arg=Q.arg,I.delegate=null,l;var E=Q.arg;return E?E.done?(I[A.resultName]=E.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,l):E:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,l)}function t(A){var I={tryLoc:A[0]};1 in A&&(I.catchLoc=A[1]),2 in A&&(I.finallyLoc=A[2],I.afterLoc=A[3]),this.tryEntries.push(I)}function k(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function K(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(t,this),this.reset(!0)}function V(A){if(A||""===A){var g=A[o];if(g)return g.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var B=-1,Q=function I(){for(;++B<A.length;)if(E.call(A,B))return I.value=A[B],I.done=!1,I;return I.value=C,I.done=!0,I};return Q.next=Q}}throw new TypeError(I(A)+" is not iterable")}return a.prototype=d,i(S,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:a,configurable:!0}),a.displayName=F(d,w,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===a||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,d):(A.__proto__=d,F(A,w,"GeneratorFunction")),A.prototype=Object.create(S),A},B.awrap=function(A){return{__await:A}},J(n.prototype),F(n.prototype,R,(function(){return this})),B.AsyncIterator=n,B.async=function(A,I,g,C,Q){void 0===Q&&(Q=Promise);var E=new n(c(A,I,g,C),Q);return B.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},J(S),F(S,w,"Generator"),F(S,o,(function(){return this})),F(S,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=V,K.prototype={constructor:K,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=C,this.done=!1,this.delegate=null,this.method="next",this.arg=C,this.tryEntries.forEach(k),!A)for(var I in this)"t"===I.charAt(0)&&E.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=C)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var I=this;function g(g,B){return i.type="throw",i.arg=A,I.next=g,B&&(I.method="next",I.arg=C),!!B}for(var B=this.tryEntries.length-1;B>=0;--B){var Q=this.tryEntries[B],i=Q.completion;if("root"===Q.tryLoc)return g("end");if(Q.tryLoc<=this.prev){var G=E.call(Q,"catchLoc"),o=E.call(Q,"finallyLoc");if(G&&o){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0);if(this.prev<Q.finallyLoc)return g(Q.finallyLoc)}else if(G){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0)}else{if(!o)throw new Error("try statement without catch or finally");if(this.prev<Q.finallyLoc)return g(Q.finallyLoc)}}}},abrupt:function(A,I){for(var g=this.tryEntries.length-1;g>=0;--g){var C=this.tryEntries[g];if(C.tryLoc<=this.prev&&E.call(C,"finallyLoc")&&this.prev<C.finallyLoc){var B=C;break}}B&&("break"===A||"continue"===A)&&B.tryLoc<=I&&I<=B.finallyLoc&&(B=null);var Q=B?B.completion:{};return Q.type=A,Q.arg=I,B?(this.method="next",this.next=B.finallyLoc,l):this.complete(Q)},complete:function(A,I){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&I&&(this.next=I),l},finish:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.finallyLoc===A)return this.complete(g.completion,g.afterLoc),k(g),l}},catch:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.tryLoc===A){var C=g.completion;if("throw"===C.type){var B=C.arg;k(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:V(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),l}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(R);var c=(0,R.exports)(),y=c;try{regeneratorRuntime=c}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=c:Function("r","regeneratorRuntime = r")(c)}var D=o(y);function h(A,I,g,C,B,Q,E){try{var i=A[Q](E),G=i.value}catch(A){return void g(A)}i.done?I(G):Promise.resolve(G).then(C,B)}function s(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var Q=A.apply(I,g);function E(A){h(Q,C,B,E,i,"next",A)}function i(A){h(Q,C,B,E,i,"throw",A)}E(void 0)}))}}function Z(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function l(A){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},l(A)}function U(A){var I=function(A,I){if("object"!==l(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==l(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===l(I)?I:String(I)}function a(A,I){for(var g=0;g<I.length;g++){var C=I[g];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(A,U(C.key),C)}}function d(A,I,g){return I&&a(A.prototype,I),g&&a(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function N(A,I,g){return(I=U(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}var Y={},b={get exports(){return Y},set exports(A){Y=A}},S={};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}({get exports(){return S},set exports(A){S=A}}),function(A){var I=S.default;function g(){A.exports=g=function(){return C},A.exports.__esModule=!0,A.exports.default=A.exports;var C={},B=Object.prototype,Q=B.hasOwnProperty,E=Object.defineProperty||function(A,I,g){A[I]=g.value},i="function"==typeof Symbol?Symbol:{},G=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",R=i.toStringTag||"@@toStringTag";function w(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{w({},"")}catch(A){w=function(A,I,g){return A[I]=g}}function F(A,I,g,C){var B=I&&I.prototype instanceof D?I:D,Q=Object.create(B.prototype),i=new n(C||[]);return E(Q,"_invoke",{value:Y(A,g,i)}),Q}function c(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}C.wrap=F;var y={};function D(){}function h(){}function s(){}var Z={};w(Z,G,(function(){return this}));var l=Object.getPrototypeOf,U=l&&l(l(M([])));U&&U!==B&&Q.call(U,G)&&(Z=U);var a=s.prototype=D.prototype=Object.create(Z);function d(A){["next","throw","return"].forEach((function(I){w(A,I,(function(A){return this._invoke(I,A)}))}))}function N(A,g){function C(B,E,i,G){var o=c(A[B],A,E);if("throw"!==o.type){var R=o.arg,w=R.value;return w&&"object"==I(w)&&Q.call(w,"__await")?g.resolve(w.__await).then((function(A){C("next",A,i,G)}),(function(A){C("throw",A,i,G)})):g.resolve(w).then((function(A){R.value=A,i(R)}),(function(A){return C("throw",A,i,G)}))}G(o.arg)}var B;E(this,"_invoke",{value:function(A,I){function Q(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(Q,Q):Q()}})}function Y(A,I,g){var C="suspendedStart";return function(B,Q){if("executing"===C)throw new Error("Generator is already running");if("completed"===C){if("throw"===B)throw Q;return H()}for(g.method=B,g.arg=Q;;){var E=g.delegate;if(E){var i=b(E,g);if(i){if(i===y)continue;return i}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if("suspendedStart"===C)throw C="completed",g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);C="executing";var G=c(A,I,g);if("normal"===G.type){if(C=g.done?"completed":"suspendedYield",G.arg===y)continue;return{value:G.arg,done:g.done}}"throw"===G.type&&(C="completed",g.method="throw",g.arg=G.arg)}}}function b(A,I){var g=I.method,C=A.iterator[g];if(void 0===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=void 0,b(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),y;var B=c(C,A.iterator,I.arg);if("throw"===B.type)return I.method="throw",I.arg=B.arg,I.delegate=null,y;var Q=B.arg;return Q?Q.done?(I[A.resultName]=Q.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=void 0),I.delegate=null,y):Q:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,y)}function S(A){var I={tryLoc:A[0]};1 in A&&(I.catchLoc=A[1]),2 in A&&(I.finallyLoc=A[2],I.afterLoc=A[3]),this.tryEntries.push(I)}function J(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function n(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(S,this),this.reset(!0)}function M(A){if(A){var I=A[G];if(I)return I.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var g=-1,C=function I(){for(;++g<A.length;)if(Q.call(A,g))return I.value=A[g],I.done=!1,I;return I.value=void 0,I.done=!0,I};return C.next=C}}return{next:H}}function H(){return{value:void 0,done:!0}}return h.prototype=s,E(a,"constructor",{value:s,configurable:!0}),E(s,"constructor",{value:h,configurable:!0}),h.displayName=w(s,R,"GeneratorFunction"),C.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===h||"GeneratorFunction"===(I.displayName||I.name))},C.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,s):(A.__proto__=s,w(A,R,"GeneratorFunction")),A.prototype=Object.create(a),A},C.awrap=function(A){return{__await:A}},d(N.prototype),w(N.prototype,o,(function(){return this})),C.AsyncIterator=N,C.async=function(A,I,g,B,Q){void 0===Q&&(Q=Promise);var E=new N(F(A,I,g,B),Q);return C.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},d(a),w(a,R,"Generator"),w(a,G,(function(){return this})),w(a,"toString",(function(){return"[object Generator]"})),C.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},C.values=M,n.prototype={constructor:n,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(J),!A)for(var I in this)"t"===I.charAt(0)&&Q.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=void 0)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var I=this;function g(g,C){return E.type="throw",E.arg=A,I.next=g,C&&(I.method="next",I.arg=void 0),!!C}for(var C=this.tryEntries.length-1;C>=0;--C){var B=this.tryEntries[C],E=B.completion;if("root"===B.tryLoc)return g("end");if(B.tryLoc<=this.prev){var i=Q.call(B,"catchLoc"),G=Q.call(B,"finallyLoc");if(i&&G){if(this.prev<B.catchLoc)return g(B.catchLoc,!0);if(this.prev<B.finallyLoc)return g(B.finallyLoc)}else if(i){if(this.prev<B.catchLoc)return g(B.catchLoc,!0)}else{if(!G)throw new Error("try statement without catch or finally");if(this.prev<B.finallyLoc)return g(B.finallyLoc)}}}},abrupt:function(A,I){for(var g=this.tryEntries.length-1;g>=0;--g){var C=this.tryEntries[g];if(C.tryLoc<=this.prev&&Q.call(C,"finallyLoc")&&this.prev<C.finallyLoc){var B=C;break}}B&&("break"===A||"continue"===A)&&B.tryLoc<=I&&I<=B.finallyLoc&&(B=null);var E=B?B.completion:{};return E.type=A,E.arg=I,B?(this.method="next",this.next=B.finallyLoc,y):this.complete(E)},complete:function(A,I){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&I&&(this.next=I),y},finish:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.finallyLoc===A)return this.complete(g.completion,g.afterLoc),J(g),y}},catch:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.tryLoc===A){var C=g.completion;if("throw"===C.type){var B=C.arg;J(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:M(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=void 0),y}},C}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(b);var J=Y(),n=J;try{regeneratorRuntime=J}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=J:Function("r","regeneratorRuntime = r")(J)}const M=new Error("request for lock canceled");var H=function(A,I,g,C){return new(g||(g=Promise))((function(B,Q){function E(A){try{G(C.next(A))}catch(A){Q(A)}}function i(A){try{G(C.throw(A))}catch(A){Q(A)}}function G(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(E,i)}G((C=C.apply(A,I||[])).next())}))};class t{constructor(A,I=M){this._value=A,this._cancelError=I,this._weightedQueues=[],this._weightedWaiters=[]}acquire(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);return new Promise(((I,g)=>{this._weightedQueues[A-1]||(this._weightedQueues[A-1]=[]),this._weightedQueues[A-1].push({resolve:I,reject:g}),this._dispatch()}))}runExclusive(A,I=1){return H(this,void 0,void 0,(function*(){const[g,C]=yield this.acquire(I);try{return yield A(g)}finally{C()}}))}waitForUnlock(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);return new Promise((I=>{this._weightedWaiters[A-1]||(this._weightedWaiters[A-1]=[]),this._weightedWaiters[A-1].push(I),this._dispatch()}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(A){this._value=A,this._dispatch()}release(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);this._value+=A,this._dispatch()}cancel(){this._weightedQueues.forEach((A=>A.forEach((A=>A.reject(this._cancelError))))),this._weightedQueues=[]}_dispatch(){var A;for(let I=this._value;I>0;I--){const g=null===(A=this._weightedQueues[I-1])||void 0===A?void 0:A.shift();if(!g)continue;const C=this._value,B=I;this._value-=I,I=this._value+1,g.resolve([C,this._newReleaser(B)])}this._drainUnlockWaiters()}_newReleaser(A){let I=!1;return()=>{I||(I=!0,this.release(A))}}_drainUnlockWaiters(){for(let A=this._value;A>0;A--)this._weightedWaiters[A-1]&&(this._weightedWaiters[A-1].forEach((A=>A())),this._weightedWaiters[A-1]=[])}}var k=function(A,I,g,C){return new(g||(g=Promise))((function(B,Q){function E(A){try{G(C.next(A))}catch(A){Q(A)}}function i(A){try{G(C.throw(A))}catch(A){Q(A)}}function G(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(E,i)}G((C=C.apply(A,I||[])).next())}))};class K{constructor(A){this._semaphore=new t(1,A)}acquire(){return k(this,void 0,void 0,(function*(){const[,A]=yield this._semaphore.acquire();return A}))}runExclusive(A){return this._semaphore.runExclusive((()=>A()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const V=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]));function e(A,I,g,C,B,Q,E){try{var i=A[Q](E),G=i.value}catch(A){return void g(A)}i.done?I(G):Promise.resolve(G).then(C,B)}function m(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var Q=A.apply(I,g);function E(A){e(Q,C,B,E,i,"next",A)}function i(A){e(Q,C,B,E,i,"throw",A)}E(void 0)}))}}function X(A){var I={exports:{}};return A(I,I.exports),I.exports}var r=X((function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports})),W=X((function(A){var I=r.default;function g(){A.exports=g=function(){return C},A.exports.__esModule=!0,A.exports.default=A.exports;var C={},B=Object.prototype,Q=B.hasOwnProperty,E=Object.defineProperty||function(A,I,g){A[I]=g.value},i="function"==typeof Symbol?Symbol:{},G=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",R=i.toStringTag||"@@toStringTag";function w(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{w({},"")}catch(A){w=function(A,I,g){return A[I]=g}}function F(A,I,g,C){var B=I&&I.prototype instanceof D?I:D,Q=Object.create(B.prototype),i=new n(C||[]);return E(Q,"_invoke",{value:Y(A,g,i)}),Q}function c(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}C.wrap=F;var y={};function D(){}function h(){}function s(){}var Z={};w(Z,G,(function(){return this}));var l=Object.getPrototypeOf,U=l&&l(l(M([])));U&&U!==B&&Q.call(U,G)&&(Z=U);var a=s.prototype=D.prototype=Object.create(Z);function d(A){["next","throw","return"].forEach((function(I){w(A,I,(function(A){return this._invoke(I,A)}))}))}function N(A,g){function C(B,E,i,G){var o=c(A[B],A,E);if("throw"!==o.type){var R=o.arg,w=R.value;return w&&"object"==I(w)&&Q.call(w,"__await")?g.resolve(w.__await).then((function(A){C("next",A,i,G)}),(function(A){C("throw",A,i,G)})):g.resolve(w).then((function(A){R.value=A,i(R)}),(function(A){return C("throw",A,i,G)}))}G(o.arg)}var B;E(this,"_invoke",{value:function(A,I){function Q(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(Q,Q):Q()}})}function Y(A,I,g){var C="suspendedStart";return function(B,Q){if("executing"===C)throw new Error("Generator is already running");if("completed"===C){if("throw"===B)throw Q;return H()}for(g.method=B,g.arg=Q;;){var E=g.delegate;if(E){var i=b(E,g);if(i){if(i===y)continue;return i}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if("suspendedStart"===C)throw C="completed",g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);C="executing";var G=c(A,I,g);if("normal"===G.type){if(C=g.done?"completed":"suspendedYield",G.arg===y)continue;return{value:G.arg,done:g.done}}"throw"===G.type&&(C="completed",g.method="throw",g.arg=G.arg)}}}function b(A,I){var g=I.method,C=A.iterator[g];if(void 0===C)return I.delegate=null,"throw"===g&&A.iterator.return&&(I.method="return",I.arg=void 0,b(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),y;var B=c(C,A.iterator,I.arg);if("throw"===B.type)return I.method="throw",I.arg=B.arg,I.delegate=null,y;var Q=B.arg;return Q?Q.done?(I[A.resultName]=Q.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=void 0),I.delegate=null,y):Q:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,y)}function S(A){var I={tryLoc:A[0]};1 in A&&(I.catchLoc=A[1]),2 in A&&(I.finallyLoc=A[2],I.afterLoc=A[3]),this.tryEntries.push(I)}function J(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function n(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(S,this),this.reset(!0)}function M(A){if(A){var I=A[G];if(I)return I.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var g=-1,C=function I(){for(;++g<A.length;)if(Q.call(A,g))return I.value=A[g],I.done=!1,I;return I.value=void 0,I.done=!0,I};return C.next=C}}return{next:H}}function H(){return{value:void 0,done:!0}}return h.prototype=s,E(a,"constructor",{value:s,configurable:!0}),E(s,"constructor",{value:h,configurable:!0}),h.displayName=w(s,R,"GeneratorFunction"),C.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===h||"GeneratorFunction"===(I.displayName||I.name))},C.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,s):(A.__proto__=s,w(A,R,"GeneratorFunction")),A.prototype=Object.create(a),A},C.awrap=function(A){return{__await:A}},d(N.prototype),w(N.prototype,o,(function(){return this})),C.AsyncIterator=N,C.async=function(A,I,g,B,Q){void 0===Q&&(Q=Promise);var E=new N(F(A,I,g,B),Q);return C.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},d(a),w(a,R,"Generator"),w(a,G,(function(){return this})),w(a,"toString",(function(){return"[object Generator]"})),C.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},C.values=M,n.prototype={constructor:n,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(J),!A)for(var I in this)"t"===I.charAt(0)&&Q.call(this,I)&&!isNaN(+I.slice(1))&&(this[I]=void 0)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var I=this;function g(g,C){return E.type="throw",E.arg=A,I.next=g,C&&(I.method="next",I.arg=void 0),!!C}for(var C=this.tryEntries.length-1;C>=0;--C){var B=this.tryEntries[C],E=B.completion;if("root"===B.tryLoc)return g("end");if(B.tryLoc<=this.prev){var i=Q.call(B,"catchLoc"),G=Q.call(B,"finallyLoc");if(i&&G){if(this.prev<B.catchLoc)return g(B.catchLoc,!0);if(this.prev<B.finallyLoc)return g(B.finallyLoc)}else if(i){if(this.prev<B.catchLoc)return g(B.catchLoc,!0)}else{if(!G)throw new Error("try statement without catch or finally");if(this.prev<B.finallyLoc)return g(B.finallyLoc)}}}},abrupt:function(A,I){for(var g=this.tryEntries.length-1;g>=0;--g){var C=this.tryEntries[g];if(C.tryLoc<=this.prev&&Q.call(C,"finallyLoc")&&this.prev<C.finallyLoc){var B=C;break}}B&&("break"===A||"continue"===A)&&B.tryLoc<=I&&I<=B.finallyLoc&&(B=null);var E=B?B.completion:{};return E.type=A,E.arg=I,B?(this.method="next",this.next=B.finallyLoc,y):this.complete(E)},complete:function(A,I){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&I&&(this.next=I),y},finish:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.finallyLoc===A)return this.complete(g.completion,g.afterLoc),J(g),y}},catch:function(A){for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I];if(g.tryLoc===A){var C=g.completion;if("throw"===C.type){var B=C.arg;J(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:M(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=void 0),y}},C}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports})),L=W(),u=L;try{regeneratorRuntime=L}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=L:Function("r","regeneratorRuntime = r")(L)}const j=new WeakMap;function p(A,I){return new Proxy(A,{get:(A,g)=>I(A[g])})}class f{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let A=this.getState();if(0!==A)throw new Error(`Invalid async state ${A}, expected 0.`)}wrapImportFn(A){return(...I)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let g=A(...I);if(!(C=g)||"object"!=typeof C&&"function"!=typeof C||"function"!=typeof C.then)return g;var C;this.exports.asyncify_start_unwind(16),this.value=g}}wrapModuleImports(A){return p(A,(A=>"function"==typeof A?this.wrapImportFn(A):A))}wrapImports(A){if(void 0!==A)return p(A,((A=Object.create(null))=>this.wrapModuleImports(A)))}wrapExportFn(A){let I=j.get(A);return void 0!==I||(I=async(...I)=>{this.assertNoneState();let g=A(...I);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),g=A();return this.assertNoneState(),g},j.set(A,I)),I}wrapExports(A){let I=Object.create(null);for(let g in A){let C=A[g];"function"!=typeof C||g.startsWith("asyncify_")||(C=this.wrapExportFn(C)),Object.defineProperty(I,g,{enumerable:!0,value:C})}return j.set(A,I),I}init(A,I){const{exports:g}=A,C=g.memory||I.env&&I.env.memory;new Int32Array(C.buffer,16).set([24,1024]),this.exports=this.wrapExports(g),Object.setPrototypeOf(A,v.prototype)}}class v extends WebAssembly.Instance{constructor(A,I){let g=new f;super(A,g.wrapImports(I)),g.init(this,I)}get exports(){return j.get(super.exports)}}async function P(A,I){let g=new f,C=await WebAssembly.instantiate(A,g.wrapImports(I));return g.init(C instanceof WebAssembly.Instance?C:C.instance,I),C}async function z(A,I){let g=new f,C=await WebAssembly.instantiateStreaming(A,g.wrapImports(I));return g.init(C.instance,I),C}function x(A){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},x(A)}function T(A){var I=function(A,I){if("object"!==x(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==x(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===x(I)?I:String(I)}function q(A,I,g){return(I=T(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function O(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function _(A,I){for(var g=0;g<I.length;g++){var C=I[g];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(A,T(C.key),C)}}function $(A,I,g){return I&&_(A.prototype,I),g&&_(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function AA(A){if(void 0===A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}function IA(A,I){return IA=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,I){return A.__proto__=I,A},IA(A,I)}function gA(A,I){if("function"!=typeof I&&null!==I)throw new TypeError("Super expression must either be null or a function");A.prototype=Object.create(I&&I.prototype,{constructor:{value:A,writable:!0,configurable:!0}}),Object.defineProperty(A,"prototype",{writable:!1}),I&&IA(A,I)}function CA(A,I){if(I&&("object"===x(I)||"function"==typeof I))return I;if(void 0!==I)throw new TypeError("Derived constructors may only return object or undefined");return AA(A)}function BA(A){return BA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(A){return A.__proto__||Object.getPrototypeOf(A)},BA(A)}function QA(A,I){var g=Object.keys(A);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(A);I&&(C=C.filter((function(I){return Object.getOwnPropertyDescriptor(A,I).enumerable}))),g.push.apply(g,C)}return g}Object.defineProperty(v.prototype,"exports",{enumerable:!0});var EA=function(){function A(){O(this,A),q(this,"_path",void 0),q(this,"_meta",void 0)}return $(A,[{key:"meta",get:function(){if(void 0!==this._meta)return function(A){for(var I=1;I<arguments.length;I++){var g=null!=arguments[I]?arguments[I]:{};I%2?QA(Object(g),!0).forEach((function(I){q(A,I,g[I])})):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(g)):QA(Object(g)).forEach((function(I){Object.defineProperty(A,I,Object.getOwnPropertyDescriptor(g,I))}))}return A}({version:0},this._meta)}}],[{key:"getPtr",value:function(I){return A._filePtrs.get(I)}},{key:"setPtr",value:function(I,g){A._filePtrs.set(I,g)}},{key:"removePtr",value:function(I){A._filePtrs.delete(I)}}]),A}();function iA(A){var I=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var g,C=BA(A);if(I){var B=BA(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return CA(this,g)}}q(EA,"_filePtrs",new Map);var GA="pv_file";var oA=function(A){gA(E,EA);var I,g,C,B,Q=iA(E);function E(A,I,g,C){var B;return O(this,E),q(AA(B=Q.call(this)),"_pageSize",65536),q(AA(B),"_db",void 0),q(AA(B),"_mode",void 0),q(AA(B),"_pagePtr",0),q(AA(B),"_pageOffset",0),B._path=A,B._meta=I,B._db=g,B._mode=C,B}return $(E,[{key:"close",value:(B=m(u.mark((function A(){return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:this._db.close();case 1:case"end":return A.stop()}}),A,this)}))),function(){return B.apply(this,arguments)})},{key:"read",value:(C=m(u.mark((function A(I,g){var C=this;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.abrupt("return",new Promise((function(A,B){if(C.exists()){if(C._isEOF){var Q=new Error("EOF");return Q.name="EndOfFile",void B(Q)}var i=0,G=Math.min(I*g,C._meta.size),o=G-G%I,R=new Uint8Array(o),w=IDBKeyRange.bound("".concat(C._path,"-").concat(E.createPage(C._pagePtr)),"".concat(C._path,"-").concat(E.createPage(C._meta.numPages))),F=C._store,c=F.openCursor(w);c.onsuccess=function(){var A=c.result;if(A&&!C._isEOF){var I=Math.min(o-i,A.value.length-C._pageOffset);R.set(A.value.slice(C._pageOffset,C._pageOffset+I),i),i+=I,C._pageOffset+=I,C._pageOffset===C._pageSize&&(C._pagePtr+=1,C._pageOffset=0),i<o&&A.continue()}},F.transaction.onerror=function(){B(F.transaction.error)},F.transaction.oncomplete=function(){A(R.slice(0,i))}}else B(new Error("'".concat(C._path,"' doesn't exist.")))})));case 1:case"end":return A.stop()}}),A)}))),function(A,I){return C.apply(this,arguments)})},{key:"write",value:(g=m(u.mark((function A(I){var g,C=this,B=arguments;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return g=B.length>1&&void 0!==B[1]?B[1]:1,A.abrupt("return",new Promise(function(){var A=m(u.mark((function A(B,Q){var i,G,o,R,w,F,c,y,D;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:if("readonly"!==C._mode){A.next=3;break}return Q(new Error("Instance is readonly mode only.")),A.abrupt("return");case 3:if(!("number"!=typeof g&&g<=0)){A.next=6;break}return Q(new Error("Version should be a positive number")),A.abrupt("return");case 6:return i=C._store,G=function(){return new Promise((function(A){var I=i.get("".concat(C._path,"-").concat(E.createPage(C._pagePtr)));I.onsuccess=function(){void 0!==I.result?A(I.result.slice(0,C._pageOffset)):A(new Uint8Array(0))}}))},A.next=10,G();case 10:for(o=A.sent,(R=new Uint8Array(o.length+I.length)).set(o),R.set(I,o.length),w=C._pagePtr*C._pageSize+R.length,F={size:w,numPages:Math.ceil(w/C._pageSize),version:g},i.put(F,C._path),c=Math.ceil(R.length/C._pageSize),y=0;y<c;y++)i.put(R.slice(y*C._pageSize,(y+1)*C._pageSize),"".concat(C._path,"-").concat(E.createPage(C._pagePtr+y)));C.exists()&&F.numPages<C._meta.numPages&&(D=IDBKeyRange.bound("".concat(C._path,"-").concat(E.createPage(F.numPages)),"".concat(C._path,"-").concat(E.createPage(C._meta.numPages)),!0),i.delete(D)),i.transaction.onerror=function(){Q(i.transaction.error)},i.transaction.oncomplete=function(){C._meta=F,C.seek(0,2),B()};case 22:case"end":return A.stop()}}),A)})));return function(I,g){return A.apply(this,arguments)}}()));case 2:case"end":return A.stop()}}),A)}))),function(A){return g.apply(this,arguments)})},{key:"seek",value:function(A,I){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(A<0){var g=new Error("EOF");throw g.name="EndOfFile",g}var C;if(0===I)C=Math.min(A,this._meta.size);else if(1===I){var B=this._pageSize*this._pagePtr+this._pageOffset;C=Math.min(B+A,this._meta.size)}else{if(2!==I)throw new Error("Invalid operation: ".concat(I,"."));C=Math.min(this._meta.size+A,this._meta.size)}this._pageOffset=C%this._pageSize,this._pagePtr=Math.floor(C/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:(I=m(u.mark((function A(){var I=this;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.abrupt("return",new Promise(function(){var A=m(u.mark((function A(g,C){var B,Q,i,G;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:B=I._meta.numPages,Q=IDBKeyRange.bound(I._path,"".concat(I._path,"-").concat(E.createPage(B))),i=I._store,(G=i.delete(Q)).onerror=function(){C(G.error)},G.onsuccess=function(){I._meta=void 0,I._pageOffset=0,I._pagePtr=0,g()};case 6:case"end":return A.stop()}}),A)})));return function(I,g){return A.apply(this,arguments)}}()));case 1:case"end":return A.stop()}}),A)}))),function(){return I.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(GA,this._mode).objectStore(GA)}}],[{key:"open",value:function(A,I){if(!self.indexedDB){var g=new Error("IndexedDB is not supported");throw g.name="IndexedDBNotSupported",g}return new Promise(function(){var g=m(u.mark((function g(C,B){var Q,i,G;return u.wrap((function(g){for(;;)switch(g.prev=g.next){case 0:return g.prev=0,g.next=3,new Promise((function(A,I){var g=self.indexedDB.open("pv_db",3);g.onerror=function(){I(g.error)},g.onsuccess=function(){A(g.result)},g.onupgradeneeded=function(){g.result.objectStoreNames.contains(GA)||g.result.createObjectStore(GA)}}));case 3:Q=g.sent,(i=Q.transaction(GA,"readwrite").objectStore(GA).get(A)).onerror=function(){B(i.error)},i.onsuccess=function(){var g=i.result,G=I.includes("r")?"readonly":"readwrite";if(void 0===g&&"readonly"===G){var o=new Error("'".concat(A,"' doesn't exist."));return o.name="FileNotExists",void B(o)}var R=new E(A,g,Q,G);I.includes("a")&&R.seek(0,2),C(R)},g.next=12;break;case 9:g.prev=9,g.t0=g.catch(0),"InvalidStateError"===g.t0.name?((G=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",B(G)):B(g.t0);case 12:case"end":return g.stop()}}),g,null,[[0,9]])})));return function(A,I){return g.apply(this,arguments)}}())}},{key:"createPage",value:function(A){return("000"+A).slice(-4)}}]),E}();function RA(A){var I=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var g,C=BA(A);if(I){var B=BA(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return CA(this,g)}}var wA=function(A){gA(C,EA);var I,g=RA(C);function C(A,I,B,Q){var E;return O(this,C),q(AA(E=g.call(this)),"_pos",0),q(AA(E),"_mode",void 0),E._path=A,E._meta=I,E._mode=Q,E}return $(C,[{key:"close",value:function(){}},{key:"read",value:function(A,I){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var g=new Error("EOF");throw g.name="EndOfFile",g}var C=Math.min(A*I,this._file.length-this._pos),B=C-C%A,Q=new Uint8Array(B);return Q.set(this._file.slice(this._pos,this._pos+B),0),this._pos+=B,Q}},{key:"write",value:function(A){var I=new Uint8Array(this._pos+A.length);void 0!==this._file?(I.set(this._file.slice(0,this._pos)),I.set(A,this._pos)):I.set(A),this._file=I,this._pos+=A.length}},{key:"seek",value:function(A,I){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(A<0){var g=new Error("EOF");throw g.name="EndOfFile",g}var C;if(0===I)C=Math.min(A,this._file.length);else if(1===I)C=Math.min(this._pos+A,this._file.length);else{if(2!==I)throw new Error("Invalid operation: ".concat(I,"."));C=Math.min(this._file.length+A,this._file.length)}this._pos=C}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:(I=m(u.mark((function A(){return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:C._memFiles.delete(this._path),this._file=void 0,this._pos=0;case 3:case"end":return A.stop()}}),A,this)}))),function(){return I.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return C._memFiles.get(this._path)},set:function(A){C._memFiles.set(this._path,A)}}],[{key:"open",value:function(A,I){var g=C._memFiles.get(A),B=I.includes("r")?"readonly":"readwrite";if(void 0===g&&"readonly"===B){var Q=new Error("'".concat(A,"' doesn't exist."));throw Q.name="FileNotExists",Q}var E=new C(A,void 0,void 0,B);return I.includes("a")&&E.seek(0,2),E}}]),C}();function FA(A,I){var g=Object.keys(A);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(A);I&&(C=C.filter((function(I){return Object.getOwnPropertyDescriptor(A,I).enumerable}))),g.push.apply(g,C)}return g}function cA(A){for(var I=1;I<arguments.length;I++){var g=null!=arguments[I]?arguments[I]:{};I%2?FA(Object(g),!0).forEach((function(I){q(A,I,g[I])})):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(g)):FA(Object(g)).forEach((function(I){Object.defineProperty(A,I,Object.getOwnPropertyDescriptor(g,I))}))}return A}function yA(A,I){var g="undefined"!=typeof Symbol&&A[Symbol.iterator]||A["@@iterator"];if(!g){if(Array.isArray(A)||(g=function(A,I){if(!A)return;if("string"==typeof A)return DA(A,I);var g=Object.prototype.toString.call(A).slice(8,-1);"Object"===g&&A.constructor&&(g=A.constructor.name);if("Map"===g||"Set"===g)return Array.from(A);if("Arguments"===g||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g))return DA(A,I)}(A))||I&&A&&"number"==typeof A.length){g&&(A=g);var C=0,B=function(){};return{s:B,n:function(){return C>=A.length?{done:!0}:{done:!1,value:A[C++]}},e:function(A){throw A},f:B}}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 Q,E=!0,i=!1;return{s:function(){g=g.call(A)},n:function(){var A=g.next();return E=A.done,A},e:function(A){i=!0,Q=A},f:function(){try{E||null==g.return||g.return()}finally{if(i)throw Q}}}}function DA(A,I){(null==I||I>A.length)&&(I=A.length);for(var g=0,C=new Array(I);g<I;g++)C[g]=A[g];return C}function hA(A,I){for(var g=I;0!==A[g];)g++;return new TextDecoder("utf-8").decode(A.subarray(I,g))}function sA(A){for(var I=atob(A),g=new Uint8Array(I.length),C=0;C<I.length;C++)g[C]=I.charCodeAt(C);return g}function ZA(A){var I,g={},C=yA(A.split("\r\n"));try{for(C.s();!(I=C.n()).done;){var B=I.value.split(": ");""!==B[0]&&(g[B[0]]=B[1])}}catch(A){C.e(A)}finally{C.f()}return g}function lA(A){return UA.apply(this,arguments)}function UA(){return UA=m(u.mark((function A(I){var g,C,B,Q,E,i,G=arguments;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return g=G.length>1&&void 0!==G[1]?G[1]:{},C=G.length>2&&void 0!==G[2]?G[2]:5e3,B=new AbortController,Q=cA(cA({},g),{},{signal:B.signal}),E=setTimeout((function(){B.abort()}),C),A.next=7,fetch(I,Q);case 7:return i=A.sent,clearTimeout(E),A.abrupt("return",i);case 10:case"end":return A.stop()}}),A)}))),UA.apply(this,arguments)}function aA(A,I){return dA.apply(this,arguments)}function dA(){return(dA=m(u.mark((function A(I,g){var C;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.prev=0,A.next=3,oA.open(I,g);case 3:return A.abrupt("return",A.sent);case 6:if(A.prev=6,A.t0=A.catch(0),"IndexedDBNotSupported"===A.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==A.t0.name&&console.warn("Unable to access IndexedDB (".concat(A.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){A.next=16;break}if("FileNotExists"!==A.t0.name){A.next=12;break}throw A.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(C=new Error("Failed to start PvFile: ".concat(A.t0.toString()))).name="PvFileNotSupported",C;case 16:return A.abrupt("return",wA.open(I,g));case 17:case"end":return A.stop()}}),A,null,[[0,6]])})))).apply(this,arguments)}function NA(A,I,g,C){return YA.apply(this,arguments)}function YA(){return(YA=m(u.mark((function A(I,g,C,B){var Q;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,aA(I,"w");case 2:if(Q=A.sent,!(C||void 0===Q.meta||B>Q.meta.version)){A.next=6;break}return A.next=6,Q.write(sA(g),B);case 6:case"end":return A.stop()}}),A)})))).apply(this,arguments)}q(wA,"_memFiles",new Map);var bA=5e3,SA=2;function JA(A,I,g,C,B){return nA.apply(this,arguments)}function nA(){return(nA=m(u.mark((function A(I,g,C,B,Q){var E,i,G,o,R,w,F,c;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,aA(I,"w");case 2:if(E=A.sent,!(C||void 0===E.meta||B>E.meta.version)){A.next=43;break}if(!(Q<0)){A.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:i=SA,G=function(A){return new Promise((function(I){setTimeout(I,A)}))},o=Q+1,R=null;case 10:if(!(o>0)){A.next=38;break}return R=null,A.prev=12,A.next=15,fetch(g,{cache:"no-cache"});case 15:if(!(w=A.sent).ok){A.next=23;break}return A.next=19,w.arrayBuffer();case 19:return F=A.sent,A.next=22,E.write(new Uint8Array(F),B);case 22:return A.abrupt("return");case 23:return A.next=25,w.text();case 25:c=A.sent,R=new Error("Error response returned while fetching model from '".concat(g,"': ").concat(c)),A.next=32;break;case 29:A.prev=29,A.t0=A.catch(12),R=new Error("Failed to fetch model from '".concat(g,"': ").concat(A.t0.message));case 32:return o--,A.next=35,G(i);case 35:i=Math.min(bA,i*SA),A.next=10;break;case 38:if(null===R){A.next=42;break}throw R;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(g,"'"));case 43:case"end":return A.stop()}}),A,null,[[12,29]])})))).apply(this,arguments)}function MA(A){return HA.apply(this,arguments)}function HA(){return(HA=m(u.mark((function A(I){var g,C,B,Q,E,i,G,o,R;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:if(null!=I){A.next=2;break}throw new Error("The model is undefined / empty");case 2:if(g=I.base64,C=I.publicPath,B=I.customWritePath,Q=I.forceWrite,E=void 0!==Q&&Q,i=I.version,G=void 0===i?1:i,o=I.numFetchRetries,R=void 0===o?0:o,null!=B){A.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==g){A.next=10;break}return A.next=8,NA(B,g,E,G);case 8:case 13:A.next=16;break;case 10:if(null==C){A.next=15;break}return A.next=13,JA(B,C,E,G,R);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return A.abrupt("return",B);case 17:case"end":return A.stop()}}),A)})))).apply(this,arguments)}var tA={args_get:function(A){return 0},args_sizes_get:function(A){return 0},environ_get:function(A){return 0},environ_sizes_get:function(A){return 0},clock_res_get:function(A){return 0},clock_time_get:function(A){return 0},fd_advise:function(A){return 0},fd_allocate:function(A){return 0},fd_close:function(A){return 0},fd_datasync:function(A){return 0},fd_fdstat_get:function(A){return 0},fd_fdstat_set_flags:function(A){return 0},fd_fdstat_set_rights:function(A){return 0},fd_filestat_get:function(A){return 0},fd_filestat_set_size:function(A){return 0},fd_filestat_set_times:function(A){return 0},fd_pread:function(A){return 0},fd_prestat_get:function(A){return 0},fd_prestat_dir_name:function(A){return 0},fd_pwrite:function(A){return 0},fd_read:function(A){return 0},fd_readdir:function(A){return 0},fd_renumber:function(A){return 0},fd_seek:function(A){return 0},fd_sync:function(A){return 0},fd_tell:function(A){return 0},fd_write:function(A){return 0},path_create_directory:function(A){return 0},path_filestat_get:function(A){return 0},path_filestat_set_times:function(A){return 0},path_link:function(A){return 0},path_open:function(A){return 0},path_readlink:function(A){return 0},path_remove_directory:function(A){return 0},path_rename:function(A){return 0},path_symlink:function(A){return 0},path_unlink_file:function(A){return 0},poll_oneoff:function(A){return 0},proc_exit:function(A){return 0},proc_raise:function(A){return 0},sched_yield:function(A){return 0},random_get:function(A){return 0},sock_recv:function(A){return 0},sock_send:function(A){return 0},sock_shutdown:function(A){return 0}};function kA(A,I,g){return KA.apply(this,arguments)}function KA(){return KA=m(u.mark((function A(I,g,C){var B,Q,E,i,G,o,R,w,F,c,y,D,h,s,Z,l,U,a,d,N,Y;return u.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:if(B=new Uint8Array(I.buffer),Q=new Int32Array(I.buffer),E=function(A){console.log(hA(B,A))},i=function(A,I,g){if(0===A){var C=hA(B,g);throw new Error("assertion failed at line ".concat(I,' in "').concat(C,'"'))}},G=function(){return Date.now()/1e3},o=function(){var A=m(u.mark((function A(I,g,E,i,G,o,R,w,F){var c,y,D,h,s,Z,l,U,a,d,N;return u.wrap((function(A){for(