@picovoice/rhino-react
Version:
React component for Rhino Web SDK
1 lines • 736 kB
JavaScript
import{useRef as A,useState as I,useCallback as g,useEffect as C}from"react";import{WebVoiceProcessor as B}from"@picovoice/web-voice-processor";function Q(A){return Q="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},Q(A)}function E(A){var I=function(A,I){if("object"!==Q(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==Q(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===Q(I)?I:String(I)}function i(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 G(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var Q=A.apply(I,g);function E(A){i(Q,C,B,E,G,"next",A)}function G(A){i(Q,C,B,E,G,"throw",A)}E(void 0)}))}}function R(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 o(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,R=!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){R=!0,B=A}finally{try{if(!G&&null!=g.return&&(E=g.return(),Object(E)!==E))return}finally{if(R)throw B}}return i}}(A,I)||function(A,I){if(A){if("string"==typeof A)return R(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)?R(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 c(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var w={exports:{}},s={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}(s);var F=s.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:{},R=G.iterator||"@@iterator",o=G.asyncIterator||"@@asyncIterator",c=G.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(C){w=function(A,I,g){return A[I]=g}}function s(A,I,g,C){var B=I&&I.prototype instanceof a?I:a,Q=Object.create(B.prototype),E=new V(C||[]);return i(Q,"_invoke",{value:m(A,g,E)}),Q}function F(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=s;var y="suspendedStart",l="suspendedYield",h="executing",Z="completed",D={};function a(){}function d(){}function b(){}var U={};w(U,R,(function(){return this}));var N=Object.getPrototypeOf,Y=N&&N(N(J([])));Y&&Y!==Q&&E.call(Y,R)&&(U=Y);var t=b.prototype=a.prototype=Object.create(U);function n(A){["next","throw","return"].forEach((function(I){w(A,I,(function(A){return this._invoke(I,A)}))}))}function S(A,g){function C(B,Q,i,G){var R=F(A[B],A,Q);if("throw"!==R.type){var o=R.arg,c=o.value;return c&&"object"==I(c)&&E.call(c,"__await")?g.resolve(c.__await).then((function(A){C("next",A,i,G)}),(function(A){C("throw",A,i,G)})):g.resolve(c).then((function(A){o.value=A,i(o)}),(function(A){return C("throw",A,i,G)}))}G(R.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=y;return function(Q,E){if(B===h)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=e(i,g);if(G){if(G===D)continue;return G}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===y)throw B=Z,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=h;var R=F(A,I,g);if("normal"===R.type){if(B=g.done?Z:l,R.arg===D)continue;return{value:R.arg,done:g.done}}"throw"===R.type&&(B=Z,g.method="throw",g.arg=R.arg)}}}function e(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,e(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),D;var Q=F(B,A.iterator,I.arg);if("throw"===Q.type)return I.method="throw",I.arg=Q.arg,I.delegate=null,D;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,D):E:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,D)}function H(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 M(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function V(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(H,this),this.reset(!0)}function J(A){if(A||""===A){var g=A[R];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 d.prototype=b,i(t,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:d,configurable:!0}),d.displayName=w(b,c,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===d||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,b):(A.__proto__=b,w(A,c,"GeneratorFunction")),A.prototype=Object.create(t),A},B.awrap=function(A){return{__await:A}},n(S.prototype),w(S.prototype,o,(function(){return this})),B.AsyncIterator=S,B.async=function(A,I,g,C,Q){void 0===Q&&(Q=Promise);var E=new S(s(A,I,g,C),Q);return B.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},n(t),w(t,c,"Generator"),w(t,R,(function(){return this})),w(t,"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=J,V.prototype={constructor:V,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(M),!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"),R=E.call(Q,"finallyLoc");if(G&&R){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(!R)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,D):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),D},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),M(g),D}},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;M(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:J(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),D}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(w);var y=(0,w.exports)(),l=y;try{regeneratorRuntime=y}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=y:Function("r","regeneratorRuntime = r")(y)}var h=c(l);function Z(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 D(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var Q=A.apply(I,g);function E(A){Z(Q,C,B,E,i,"next",A)}function i(A){Z(Q,C,B,E,i,"throw",A)}E(void 0)}))}}function a(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function d(A){return d="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},d(A)}function b(A){var I=function(A,I){if("object"!==d(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==d(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===d(I)?I:String(I)}function U(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,b(C.key),C)}}function N(A,I,g){return I&&U(A.prototype,I),g&&U(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function Y(A,I,g){return(I=b(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function t(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var n={exports:{}},S={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}(S);var m=S.exports;!function(A){var I=m.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:{},R=G.iterator||"@@iterator",o=G.asyncIterator||"@@asyncIterator",c=G.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(C){w=function(A,I,g){return A[I]=g}}function s(A,I,g,C){var B=I&&I.prototype instanceof a?I:a,Q=Object.create(B.prototype),E=new V(C||[]);return i(Q,"_invoke",{value:m(A,g,E)}),Q}function F(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=s;var y="suspendedStart",l="suspendedYield",h="executing",Z="completed",D={};function a(){}function d(){}function b(){}var U={};w(U,R,(function(){return this}));var N=Object.getPrototypeOf,Y=N&&N(N(J([])));Y&&Y!==Q&&E.call(Y,R)&&(U=Y);var t=b.prototype=a.prototype=Object.create(U);function n(A){["next","throw","return"].forEach((function(I){w(A,I,(function(A){return this._invoke(I,A)}))}))}function S(A,g){function C(B,Q,i,G){var R=F(A[B],A,Q);if("throw"!==R.type){var o=R.arg,c=o.value;return c&&"object"==I(c)&&E.call(c,"__await")?g.resolve(c.__await).then((function(A){C("next",A,i,G)}),(function(A){C("throw",A,i,G)})):g.resolve(c).then((function(A){o.value=A,i(o)}),(function(A){return C("throw",A,i,G)}))}G(R.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=y;return function(Q,E){if(B===h)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=e(i,g);if(G){if(G===D)continue;return G}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===y)throw B=Z,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=h;var R=F(A,I,g);if("normal"===R.type){if(B=g.done?Z:l,R.arg===D)continue;return{value:R.arg,done:g.done}}"throw"===R.type&&(B=Z,g.method="throw",g.arg=R.arg)}}}function e(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,e(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),D;var Q=F(B,A.iterator,I.arg);if("throw"===Q.type)return I.method="throw",I.arg=Q.arg,I.delegate=null,D;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,D):E:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,D)}function H(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 M(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function V(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(H,this),this.reset(!0)}function J(A){if(A||""===A){var g=A[R];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 d.prototype=b,i(t,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:d,configurable:!0}),d.displayName=w(b,c,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===d||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,b):(A.__proto__=b,w(A,c,"GeneratorFunction")),A.prototype=Object.create(t),A},B.awrap=function(A){return{__await:A}},n(S.prototype),w(S.prototype,o,(function(){return this})),B.AsyncIterator=S,B.async=function(A,I,g,C,Q){void 0===Q&&(Q=Promise);var E=new S(s(A,I,g,C),Q);return B.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},n(t),w(t,c,"Generator"),w(t,R,(function(){return this})),w(t,"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=J,V.prototype={constructor:V,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(M),!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"),R=E.call(Q,"finallyLoc");if(G&&R){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(!R)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,D):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),D},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),M(g),D}},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;M(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:J(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),D}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(n);var e=(0,n.exports)(),H=e;try{regeneratorRuntime=e}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}var M=t(H);const V=new Error("request for lock canceled");var J=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,I=V){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 J(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 X=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 k(1,A)}acquire(){return X(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()}}function r(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 W(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var Q=A.apply(I,g);function E(A){r(Q,C,B,E,i,"next",A)}function i(A){r(Q,C,B,E,i,"throw",A)}E(void 0)}))}}function u(A){var I={exports:{}};return A(I,I.exports),I.exports}var L=u((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})),j=u((function(A){var I=L.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",R=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function c(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{c({},"")}catch(A){c=function(A,I,g){return A[I]=g}}function w(A,I,g,C){var B=I&&I.prototype instanceof y?I:y,Q=Object.create(B.prototype),i=new S(C||[]);return E(Q,"_invoke",{value:N(A,g,i)}),Q}function s(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}C.wrap=w;var F={};function y(){}function l(){}function h(){}var Z={};c(Z,G,(function(){return this}));var D=Object.getPrototypeOf,a=D&&D(D(m([])));a&&a!==B&&Q.call(a,G)&&(Z=a);var d=h.prototype=y.prototype=Object.create(Z);function b(A){["next","throw","return"].forEach((function(I){c(A,I,(function(A){return this._invoke(I,A)}))}))}function U(A,g){function C(B,E,i,G){var R=s(A[B],A,E);if("throw"!==R.type){var o=R.arg,c=o.value;return c&&"object"==I(c)&&Q.call(c,"__await")?g.resolve(c.__await).then((function(A){C("next",A,i,G)}),(function(A){C("throw",A,i,G)})):g.resolve(c).then((function(A){o.value=A,i(o)}),(function(A){return C("throw",A,i,G)}))}G(R.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 N(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 e()}for(g.method=B,g.arg=Q;;){var E=g.delegate;if(E){var i=Y(E,g);if(i){if(i===F)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=s(A,I,g);if("normal"===G.type){if(C=g.done?"completed":"suspendedYield",G.arg===F)continue;return{value:G.arg,done:g.done}}"throw"===G.type&&(C="completed",g.method="throw",g.arg=G.arg)}}}function Y(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,Y(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),F;var B=s(C,A.iterator,I.arg);if("throw"===B.type)return I.method="throw",I.arg=B.arg,I.delegate=null,F;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,F):Q:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,F)}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 n(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function S(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(t,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:e}}function e(){return{value:void 0,done:!0}}return l.prototype=h,E(d,"constructor",{value:h,configurable:!0}),E(h,"constructor",{value:l,configurable:!0}),l.displayName=c(h,o,"GeneratorFunction"),C.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===l||"GeneratorFunction"===(I.displayName||I.name))},C.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,h):(A.__proto__=h,c(A,o,"GeneratorFunction")),A.prototype=Object.create(d),A},C.awrap=function(A){return{__await:A}},b(U.prototype),c(U.prototype,R,(function(){return this})),C.AsyncIterator=U,C.async=function(A,I,g,B,Q){void 0===Q&&(Q=Promise);var E=new U(w(A,I,g,B),Q);return C.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},b(d),c(d,o,"Generator"),c(d,G,(function(){return this})),c(d,"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,S.prototype={constructor:S,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(n),!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,F):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),F},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),n(g),F}},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;n(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),F}},C}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports})),p=j(),f=p;try{regeneratorRuntime=p}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=p:Function("r","regeneratorRuntime = r")(p)}const v=new WeakMap;function z(A,I){return new Proxy(A,{get:(A,g)=>I(A[g])})}class x{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 z(A,(A=>"function"==typeof A?this.wrapImportFn(A):A))}wrapImports(A){if(void 0!==A)return z(A,((A=Object.create(null))=>this.wrapModuleImports(A)))}wrapExportFn(A){let I=v.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},v.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 v.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,T.prototype)}}class T extends WebAssembly.Instance{constructor(A,I){let g=new x;super(A,g.wrapImports(I)),g.init(this,I)}get exports(){return v.get(super.exports)}}async function P(A,I){let g=new x,C=await WebAssembly.instantiate(A,g.wrapImports(I));return g.init(C instanceof WebAssembly.Instance?C:C.instance,I),C}async function O(A,I){let g=new x,C=await WebAssembly.instantiateStreaming(A,g.wrapImports(I));return g.init(C.instance,I),C}function q(A){return q="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},q(A)}function _(A){var I=function(A,I){if("object"!==q(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==q(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===q(I)?I:String(I)}function $(A,I,g){return(I=_(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function AA(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function IA(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,_(C.key),C)}}function gA(A,I,g){return I&&IA(A.prototype,I),g&&IA(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function CA(A){if(void 0===A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}function BA(A,I){return BA=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,I){return A.__proto__=I,A},BA(A,I)}function QA(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&&BA(A,I)}function EA(A,I){if(I&&("object"===q(I)||"function"==typeof I))return I;if(void 0!==I)throw new TypeError("Derived constructors may only return object or undefined");return CA(A)}function iA(A){return iA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(A){return A.__proto__||Object.getPrototypeOf(A)},iA(A)}function GA(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(T.prototype,"exports",{enumerable:!0});var RA=function(){function A(){AA(this,A),$(this,"_path",void 0),$(this,"_meta",void 0)}return gA(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?GA(Object(g),!0).forEach((function(I){$(A,I,g[I])})):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(g)):GA(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 oA(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=iA(A);if(I){var B=iA(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return EA(this,g)}}$(RA,"_filePtrs",new Map);var cA="pv_file";var wA=function(A){QA(E,RA);var I,g,C,B,Q=oA(E);function E(A,I,g,C){var B;return AA(this,E),$(CA(B=Q.call(this)),"_pageSize",65536),$(CA(B),"_db",void 0),$(CA(B),"_mode",void 0),$(CA(B),"_pagePtr",0),$(CA(B),"_pageOffset",0),B._path=A,B._meta=I,B._db=g,B._mode=C,B}return gA(E,[{key:"close",value:(B=W(f.mark((function A(){return f.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=W(f.mark((function A(I,g){var C=this;return f.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),R=G-G%I,o=new Uint8Array(R),c=IDBKeyRange.bound("".concat(C._path,"-").concat(E.createPage(C._pagePtr)),"".concat(C._path,"-").concat(E.createPage(C._meta.numPages))),w=C._store,s=w.openCursor(c);s.onsuccess=function(){var A=s.result;if(A&&!C._isEOF){var I=Math.min(R-i,A.value.length-C._pageOffset);o.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<R&&A.continue()}},w.transaction.onerror=function(){B(w.transaction.error)},w.transaction.oncomplete=function(){A(o.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=W(f.mark((function A(I){var g,C=this,B=arguments;return f.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=W(f.mark((function A(B,Q){var i,G,R,o,c,w,s,F,y;return f.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(R=A.sent,(o=new Uint8Array(R.length+I.length)).set(R),o.set(I,R.length),c=C._pagePtr*C._pageSize+o.length,w={size:c,numPages:Math.ceil(c/C._pageSize),version:g},i.put(w,C._path),s=Math.ceil(o.length/C._pageSize),F=0;F<s;F++)i.put(o.slice(F*C._pageSize,(F+1)*C._pageSize),"".concat(C._path,"-").concat(E.createPage(C._pagePtr+F)));C.exists()&&w.numPages<C._meta.numPages&&(y=IDBKeyRange.bound("".concat(C._path,"-").concat(E.createPage(w.numPages)),"".concat(C._path,"-").concat(E.createPage(C._meta.numPages)),!0),i.delete(y)),i.transaction.onerror=function(){Q(i.transaction.error)},i.transaction.oncomplete=function(){C._meta=w,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=W(f.mark((function A(){var I=this;return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.abrupt("return",new Promise(function(){var A=W(f.mark((function A(g,C){var B,Q,i,G;return f.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(cA,this._mode).objectStore(cA)}}],[{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=W(f.mark((function g(C,B){var Q,i,G;return f.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(cA)||g.result.createObjectStore(cA)}}));case 3:Q=g.sent,(i=Q.transaction(cA,"readwrite").objectStore(cA).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 R=new Error("'".concat(A,"' doesn't exist."));return R.name="FileNotExists",void B(R)}var o=new E(A,g,Q,G);I.includes("a")&&o.seek(0,2),C(o)},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 sA(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=iA(A);if(I){var B=iA(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return EA(this,g)}}var FA=function(A){QA(C,RA);var I,g=sA(C);function C(A,I,B,Q){var E;return AA(this,C),$(CA(E=g.call(this)),"_pos",0),$(CA(E),"_mode",void 0),E._path=A,E._meta=I,E._mode=Q,E}return gA(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=W(f.mark((function A(){return f.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 yA(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 lA(A){for(var I=1;I<arguments.length;I++){var g=null!=arguments[I]?arguments[I]:{};I%2?yA(Object(g),!0).forEach((function(I){$(A,I,g[I])})):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(g)):yA(Object(g)).forEach((function(I){Object.defineProperty(A,I,Object.getOwnPropertyDescriptor(g,I))}))}return A}function hA(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 ZA(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 ZA(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 ZA(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 DA(A,I){for(var g=I;0!==A[g];)g++;return new TextDecoder("utf-8").decode(A.subarray(I,g))}function aA(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 dA(A){var I,g={},C=hA(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 bA(A){return UA.apply(this,arguments)}function UA(){return UA=W(f.mark((function A(I){var g,C,B,Q,E,i,G=arguments;return f.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=lA(lA({},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 NA(A){if("string"!=typeof A)return!1;var I=A.trim();if(""===I)return!1;try{return btoa(atob(I))===I}catch(A){return!1}}function YA(A,I){return tA.apply(this,arguments)}function tA(){return(tA=W(f.mark((function A(I,g){var C;return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.prev=0,A.next=3,wA.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",FA.open(I,g));case 17:case"end":return A.stop()}}),A,null,[[0,6]])})))).apply(this,arguments)}function nA(A,I,g,C){return SA.apply(this,arguments)}function SA(){return(SA=W(f.mark((function A(I,g,C,B){var Q;return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,YA(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(aA(g),B);case 6:case"end":return A.stop()}}),A)})))).apply(this,arguments)}$(FA,"_memFiles",new Map);var mA=5e3,eA=2;function HA(A,I,g,C,B){return MA.apply(this,arguments)}function MA(){return(MA=W(f.mark((function A(I,g,C,B,Q){var E,i,G,R,o,c,w,s;return f.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,YA(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=eA,G=function(A){return new Promise((function(I){setTimeout(I,A)}))},R=Q+1,o=null;case 10:if(!(R>0)){A.next=38;break}return o=null,A.prev=12,A.next=15,fetch(g,{cache:"no-cache"});case 15:if(!(c=A.sent).ok){A.next=23;break}return A.next=19,c.arrayBuffer();case 19:return w=A.sent,A.next=22,E.write(new Uint8Array(w),B);case 22:return A.abrupt("return");case 23:return A.next=25,c.text();case 25:s=A.sent,o=new Error("Error response returned while fetching model from '".concat(g,"': ").concat(s)),A.next=32;break;case 29:A.prev=29,A.t0=A.catch(12),o=new Error("Failed to fetch model from '".concat(g,"': ").concat(A.t0.message));case 32:return R--,A.next=35,G(i);case 35:i=Math.min(mA,i*eA),A.next=10;break;case 38:if(null===o){A.next=42;break}throw o;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 VA(A){return JA.apply(this,arguments)}function JA(){return(JA=W(f.mark((function A(I){var g,C,B,Q,E,i,G,R,o;return f.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,R=I.numFetchRetries,o=void 0===R?0:R,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,HA(B,C,E,G,o);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 kA={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 XA(A,I,g){return