UNPKG

@picovoice/leopard-react

Version:

React hook for Leopard Web SDK

1 lines 3.2 MB
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 c(A,I,g,C,B,c,l){try{var d=A[c](l),Z=d.value}catch(A){return void g(A)}d.done?I(Z):Promise.resolve(Z).then(C,B)}function l(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var l=A.apply(I,g);function d(A){c(l,C,B,d,Z,"next",A)}function Z(A){c(l,C,B,d,Z,"throw",A)}d(void 0)}))}}function d(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 Z(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,c,l,d=[],Z=!0,i=!1;try{if(c=(g=g.call(A)).next,0===I){if(Object(g)!==g)return;Z=!1}else for(;!(Z=(C=c.call(g)).done)&&(d.push(C.value),d.length!==I);Z=!0);}catch(A){i=!0,B=A}finally{try{if(!Z&&null!=g.return&&(l=g.return(),Object(l)!==l))return}finally{if(i)throw B}}return d}}(A,I)||function(A,I){if(A){if("string"==typeof A)return d(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)?d(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 i(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var G={exports:{}},b={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}(b);var Q=b.exports;!function(A){var I=Q.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",G=Z.asyncIterator||"@@asyncIterator",b=Z.toStringTag||"@@toStringTag";function Q(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{Q({},"")}catch(C){Q=function(A,I,g){return A[I]=g}}function X(A,I,g,C){var B=I&&I.prototype instanceof n?I:n,c=Object.create(B.prototype),l=new H(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function E(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=X;var m="suspendedStart",y="suspendedYield",o="executing",a="completed",s={};function n(){}function R(){}function V(){}var F={};Q(F,i,(function(){return this}));var h=Object.getPrototypeOf,Y=h&&h(h(p([])));Y&&Y!==c&&l.call(Y,i)&&(F=Y);var t=V.prototype=n.prototype=Object.create(F);function W(A){["next","throw","return"].forEach((function(I){Q(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=E(A[B],A,c);if("throw"!==i.type){var G=i.arg,b=G.value;return b&&"object"==I(b)&&l.call(b,"__await")?g.resolve(b.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(b).then((function(A){G.value=A,d(G)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=m;return function(c,l){if(B===o)throw new Error("Generator is already running");if(B===a){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===s)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===m)throw B=a,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=o;var i=E(A,I,g);if("normal"===i.type){if(B=g.done?a:y,i.arg===s)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=a,g.method="throw",g.arg=i.arg)}}}function J(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,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),s;var c=E(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,s;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,s):l:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,s)}function w(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 H(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(w,this),this.reset(!0)}function p(A){if(A||""===A){var g=A[i];if(g)return g.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var B=-1,c=function I(){for(;++B<A.length;)if(l.call(A,B))return I.value=A[B],I.done=!1,I;return I.value=C,I.done=!0,I};return c.next=c}}throw new TypeError(I(A)+" is not iterable")}return R.prototype=V,d(t,"constructor",{value:V,configurable:!0}),d(V,"constructor",{value:R,configurable:!0}),R.displayName=Q(V,b,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===R||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,V):(A.__proto__=V,Q(A,b,"GeneratorFunction")),A.prototype=Object.create(t),A},B.awrap=function(A){return{__await:A}},W(u.prototype),Q(u.prototype,G,(function(){return this})),B.AsyncIterator=u,B.async=function(A,I,g,C,c){void 0===c&&(c=Promise);var l=new u(X(A,I,g,C),c);return B.isGeneratorFunction(I)?l:l.next().then((function(A){return A.done?A.value:l.next()}))},W(t),Q(t,b,"Generator"),Q(t,i,(function(){return this})),Q(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=p,H.prototype={constructor:H,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(N),!A)for(var I in this)"t"===I.charAt(0)&&l.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 d.type="throw",d.arg=A,I.next=g,B&&(I.method="next",I.arg=C),!!B}for(var B=this.tryEntries.length-1;B>=0;--B){var c=this.tryEntries[B],d=c.completion;if("root"===c.tryLoc)return g("end");if(c.tryLoc<=this.prev){var Z=l.call(c,"catchLoc"),i=l.call(c,"finallyLoc");if(Z&&i){if(this.prev<c.catchLoc)return g(c.catchLoc,!0);if(this.prev<c.finallyLoc)return g(c.finallyLoc)}else if(Z){if(this.prev<c.catchLoc)return g(c.catchLoc,!0)}else{if(!i)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return g(c.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&&l.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 c=B?B.completion:{};return c.type=A,c.arg=I,B?(this.method="next",this.next=B.finallyLoc,s):this.complete(c)},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),s},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),s}},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:p(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),s}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(G);var X=(0,G.exports)(),E=X;try{regeneratorRuntime=X}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=X:Function("r","regeneratorRuntime = r")(X)}var m=i(E);function y(A,I,g,C,B,c,l){try{var d=A[c](l),Z=d.value}catch(A){return void g(A)}d.done?I(Z):Promise.resolve(Z).then(C,B)}function o(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var c=A.apply(I,g);function l(A){y(c,C,B,l,d,"next",A)}function d(A){y(c,C,B,l,d,"throw",A)}l(void 0)}))}}function a(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function s(A){return s="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},s(A)}function n(A){var I=function(A,I){if("object"!==s(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==s(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===s(I)?I:String(I)}function R(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,n(C.key),C)}}function V(A,I,g){return I&&R(A.prototype,I),g&&R(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function F(A,I,g){return(I=n(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}var h={},Y={get exports(){return h},set exports(A){h=A}},t={};!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 t},set exports(A){t=A}}),function(A){var I=t.default;function g(){A.exports=g=function(){return C},A.exports.__esModule=!0,A.exports.default=A.exports;var C={},B=Object.prototype,c=B.hasOwnProperty,l=Object.defineProperty||function(A,I,g){A[I]=g.value},d="function"==typeof Symbol?Symbol:{},Z=d.iterator||"@@iterator",i=d.asyncIterator||"@@asyncIterator",G=d.toStringTag||"@@toStringTag";function b(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{b({},"")}catch(A){b=function(A,I,g){return A[I]=g}}function Q(A,I,g,C){var B=I&&I.prototype instanceof m?I:m,c=Object.create(B.prototype),d=new u(C||[]);return l(c,"_invoke",{value:h(A,g,d)}),c}function X(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}C.wrap=Q;var E={};function m(){}function y(){}function o(){}var a={};b(a,Z,(function(){return this}));var s=Object.getPrototypeOf,n=s&&s(s(e([])));n&&n!==B&&c.call(n,Z)&&(a=n);var R=o.prototype=m.prototype=Object.create(a);function V(A){["next","throw","return"].forEach((function(I){b(A,I,(function(A){return this._invoke(I,A)}))}))}function F(A,g){function C(B,l,d,Z){var i=X(A[B],A,l);if("throw"!==i.type){var G=i.arg,b=G.value;return b&&"object"==I(b)&&c.call(b,"__await")?g.resolve(b.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(b).then((function(A){G.value=A,d(G)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;l(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function h(A,I,g){var C="suspendedStart";return function(B,c){if("executing"===C)throw new Error("Generator is already running");if("completed"===C){if("throw"===B)throw c;return J()}for(g.method=B,g.arg=c;;){var l=g.delegate;if(l){var d=Y(l,g);if(d){if(d===E)continue;return d}}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 Z=X(A,I,g);if("normal"===Z.type){if(C=g.done?"completed":"suspendedYield",Z.arg===E)continue;return{value:Z.arg,done:g.done}}"throw"===Z.type&&(C="completed",g.method="throw",g.arg=Z.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")),E;var B=X(C,A.iterator,I.arg);if("throw"===B.type)return I.method="throw",I.arg=B.arg,I.delegate=null,E;var c=B.arg;return c?c.done?(I[A.resultName]=c.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=void 0),I.delegate=null,E):c:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,E)}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 W(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function u(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(t,this),this.reset(!0)}function e(A){if(A){var I=A[Z];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(c.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:J}}function J(){return{value:void 0,done:!0}}return y.prototype=o,l(R,"constructor",{value:o,configurable:!0}),l(o,"constructor",{value:y,configurable:!0}),y.displayName=b(o,G,"GeneratorFunction"),C.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===y||"GeneratorFunction"===(I.displayName||I.name))},C.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,o):(A.__proto__=o,b(A,G,"GeneratorFunction")),A.prototype=Object.create(R),A},C.awrap=function(A){return{__await:A}},V(F.prototype),b(F.prototype,i,(function(){return this})),C.AsyncIterator=F,C.async=function(A,I,g,B,c){void 0===c&&(c=Promise);var l=new F(Q(A,I,g,B),c);return C.isGeneratorFunction(I)?l:l.next().then((function(A){return A.done?A.value:l.next()}))},V(R),b(R,G,"Generator"),b(R,Z,(function(){return this})),b(R,"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=e,u.prototype={constructor:u,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(W),!A)for(var I in this)"t"===I.charAt(0)&&c.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 l.type="throw",l.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],l=B.completion;if("root"===B.tryLoc)return g("end");if(B.tryLoc<=this.prev){var d=c.call(B,"catchLoc"),Z=c.call(B,"finallyLoc");if(d&&Z){if(this.prev<B.catchLoc)return g(B.catchLoc,!0);if(this.prev<B.finallyLoc)return g(B.finallyLoc)}else if(d){if(this.prev<B.catchLoc)return g(B.catchLoc,!0)}else{if(!Z)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&&c.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 l=B?B.completion:{};return l.type=A,l.arg=I,B?(this.method="next",this.next=B.finallyLoc,E):this.complete(l)},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),E},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),W(g),E}},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;W(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:e(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=void 0),E}},C}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(Y);var W=h(),u=W;try{regeneratorRuntime=W}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=W:Function("r","regeneratorRuntime = r")(W)}const e=new Error("request for lock canceled");var J=function(A,I,g,C){return new(g||(g=Promise))((function(B,c){function l(A){try{Z(C.next(A))}catch(A){c(A)}}function d(A){try{Z(C.throw(A))}catch(A){c(A)}}function Z(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(l,d)}Z((C=C.apply(A,I||[])).next())}))};class w{constructor(A,I=e){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 N=function(A,I,g,C){return new(g||(g=Promise))((function(B,c){function l(A){try{Z(C.next(A))}catch(A){c(A)}}function d(A){try{Z(C.throw(A))}catch(A){c(A)}}function Z(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(l,d)}Z((C=C.apply(A,I||[])).next())}))};class H{constructor(A){this._semaphore=new w(1,A)}acquire(){return N(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 p=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 M(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var S={exports:{}},k={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}(k);var U=k.exports;!function(A){var I=U.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",G=Z.asyncIterator||"@@asyncIterator",b=Z.toStringTag||"@@toStringTag";function Q(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{Q({},"")}catch(C){Q=function(A,I,g){return A[I]=g}}function X(A,I,g,C){var B=I&&I.prototype instanceof n?I:n,c=Object.create(B.prototype),l=new H(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function E(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=X;var m="suspendedStart",y="suspendedYield",o="executing",a="completed",s={};function n(){}function R(){}function V(){}var F={};Q(F,i,(function(){return this}));var h=Object.getPrototypeOf,Y=h&&h(h(p([])));Y&&Y!==c&&l.call(Y,i)&&(F=Y);var t=V.prototype=n.prototype=Object.create(F);function W(A){["next","throw","return"].forEach((function(I){Q(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=E(A[B],A,c);if("throw"!==i.type){var G=i.arg,b=G.value;return b&&"object"==I(b)&&l.call(b,"__await")?g.resolve(b.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(b).then((function(A){G.value=A,d(G)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=m;return function(c,l){if(B===o)throw new Error("Generator is already running");if(B===a){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===s)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===m)throw B=a,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=o;var i=E(A,I,g);if("normal"===i.type){if(B=g.done?a:y,i.arg===s)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=a,g.method="throw",g.arg=i.arg)}}}function J(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,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),s;var c=E(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,s;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,s):l:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,s)}function w(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 H(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(w,this),this.reset(!0)}function p(A){if(A||""===A){var g=A[i];if(g)return g.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var B=-1,c=function I(){for(;++B<A.length;)if(l.call(A,B))return I.value=A[B],I.done=!1,I;return I.value=C,I.done=!0,I};return c.next=c}}throw new TypeError(I(A)+" is not iterable")}return R.prototype=V,d(t,"constructor",{value:V,configurable:!0}),d(V,"constructor",{value:R,configurable:!0}),R.displayName=Q(V,b,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===R||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,V):(A.__proto__=V,Q(A,b,"GeneratorFunction")),A.prototype=Object.create(t),A},B.awrap=function(A){return{__await:A}},W(u.prototype),Q(u.prototype,G,(function(){return this})),B.AsyncIterator=u,B.async=function(A,I,g,C,c){void 0===c&&(c=Promise);var l=new u(X(A,I,g,C),c);return B.isGeneratorFunction(I)?l:l.next().then((function(A){return A.done?A.value:l.next()}))},W(t),Q(t,b,"Generator"),Q(t,i,(function(){return this})),Q(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=p,H.prototype={constructor:H,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(N),!A)for(var I in this)"t"===I.charAt(0)&&l.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 d.type="throw",d.arg=A,I.next=g,B&&(I.method="next",I.arg=C),!!B}for(var B=this.tryEntries.length-1;B>=0;--B){var c=this.tryEntries[B],d=c.completion;if("root"===c.tryLoc)return g("end");if(c.tryLoc<=this.prev){var Z=l.call(c,"catchLoc"),i=l.call(c,"finallyLoc");if(Z&&i){if(this.prev<c.catchLoc)return g(c.catchLoc,!0);if(this.prev<c.finallyLoc)return g(c.finallyLoc)}else if(Z){if(this.prev<c.catchLoc)return g(c.catchLoc,!0)}else{if(!i)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return g(c.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&&l.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 c=B?B.completion:{};return c.type=A,c.arg=I,B?(this.method="next",this.next=B.finallyLoc,s):this.complete(c)},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),s},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),s}},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:p(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),s}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(S);var K=(0,S.exports)(),r=K;try{regeneratorRuntime=K}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=K:Function("r","regeneratorRuntime = r")(K)}var D=M(r);function x(A,I,g,C){return new(g||(g=Promise))((function(B,c){function l(A){try{Z(C.next(A))}catch(A){c(A)}}function d(A){try{Z(C.throw(A))}catch(A){c(A)}}function Z(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(l,d)}Z((C=C.apply(A,I||[])).next())}))}function z(A,I){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,I){return A.__proto__=I,A},z(A,I)}function f(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&&z(A,I)}function j(A){return j="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},j(A)}function v(A,I){if(I&&("object"===j(I)||"function"==typeof I))return I;if(void 0!==I)throw new TypeError("Derived constructors may only return object or undefined");return function(A){if(void 0===A)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}(A)}function L(A){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(A){return A.__proto__||Object.getPrototypeOf(A)},L(A)}function T(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function O(A){var I=function(A,I){if("object"!==j(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==j(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===j(I)?I:String(I)}function P(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,O(C.key),C)}}function _(A,I,g){return I&&P(A.prototype,I),g&&P(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}var q=function(){function A(){T(this,A),this._path=""}return _(A,[{key:"meta",get:function(){if(void 0!==this._meta)return Object.assign({version:0},this._meta)}},{key:"pageSize",get:function(){}}],[{key:"getPtr",value:function(I){if(A._filePtrs.has(I))return A._filePtrs.get(I);throw new Error("File instance not found.")}},{key:"setPtr",value:function(I,g){A._filePtrs.set(I,g)}},{key:"removePtr",value:function(I){A._filePtrs.delete(I)}}]),A}();function $(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=L(A);if(I){var B=L(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return v(this,g)}}q._filePtrs=new Map;var AA="pv_file";var IA=function(){function A(){T(this,A),this._pos=0,this._data=new Uint8Array}return _(A,[{key:"get",value:function(A){if(!(this._pos>=this._data.length)){var I=this._data.slice(this._pos,this._pos+A);return this._pos+=A,I}}},{key:"set",value:function(A,I){this._pos=A,this._data=I}},{key:"clear",value:function(){this._pos=0,this._data=new Uint8Array}}]),A}(),gA=function(A){f(g,q);var I=$(g);function g(A,C,B,c){var l;return T(this,g),(l=I.call(this))._pageSize=524288,l._pagePtr=0,l._pageOffset=0,l._path=A,l._meta=C,l._db=B,l._mode=c,l._cache=new IA,l}return _(g,[{key:"pageSize",get:function(){return this._pageSize}},{key:"close",value:function(){return x(this,void 0,void 0,D.mark((function A(){return D.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:this._db.close();case 1:case"end":return A.stop()}}),A,this)})))}},{key:"read",value:function(A,I){return x(this,void 0,void 0,D.mark((function C(){var B=this;return D.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.abrupt("return",new Promise((function(C,c){if(B.exists()){if(B._isEOF){var l=new Error("EOF");return l.name="EndOfFile",void c(l)}var d=0,Z=Math.min(A*I,B._meta.size),i=Z-Z%A,G=new Uint8Array(i),b=B._cache.get(i);if(b){if(d+=b.length,B._pageOffset+=b.length,B._pageOffset===B._pageSize&&(B._pagePtr+=1,B._pageOffset=0),i===d)return void C(b);G.set(b)}var Q=IDBKeyRange.bound("".concat(B._path,"-").concat(g.createPage(B._pagePtr)),"".concat(B._path,"-").concat(g.createPage(B._pagePtr+Math.floor(i/B._pageSize)+1))),X=B._store,E=X.openCursor(Q);E.onsuccess=function(){var A,I,g=E.result;if(g&&!B._isEOF){var C=Math.min(i-d,g.value.length-B._pageOffset);G.set(g.value.slice(B._pageOffset,B._pageOffset+C),d),d+=C,B._pageOffset+=C,B._pageOffset===B._pageSize&&(B._pagePtr+=1,B._pageOffset=0),d<i?g.continue():(0!==B._pageOffset?B._cache.set(B._pageOffset,g.value):B._cache.clear(),(null===(A=X.transaction)||void 0===A?void 0:A.commit)&&(null===(I=X.transaction)||void 0===I||I.commit()))}},X.transaction.onerror=function(){c(X.transaction.error)},X.transaction.oncomplete=function(){C(G.slice(0,d))}}else c(new Error("'".concat(B._path,"' doesn't exist.")))})));case 1:case"end":return C.stop()}}),C)})))}},{key:"write",value:function(A){var I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return x(this,void 0,void 0,D.mark((function C(){var B=this;return D.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.abrupt("return",new Promise((function(C,c){return x(B,void 0,void 0,D.mark((function B(){var l,d,Z,i,G,b,Q,X,E,m,y,o=this;return D.wrap((function(B){for(;;)switch(B.prev=B.next){case 0:if("readonly"!==this._mode){B.next=3;break}return c(new Error("Instance is readonly mode only.")),B.abrupt("return");case 3:if(!("number"!=typeof I&&I<=0)){B.next=6;break}return c(new Error("Version should be a positive number")),B.abrupt("return");case 6:return Z=this._store,i=function(){return new Promise((function(A){var I=Z.get("".concat(o._path,"-").concat(g.createPage(o._pagePtr)));I.onsuccess=function(){void 0!==I.result?A(I.result.slice(0,o._pageOffset)):A(new Uint8Array(0))}}))},B.next=10,i();case 10:for(G=B.sent,(b=new Uint8Array(G.length+A.length)).set(G),b.set(A,G.length),Q=this._pagePtr*this._pageSize+b.length,X={size:Q,numPages:Math.ceil(Q/this._pageSize),version:I,pageSize:this._pageSize},Z.put(X,this._path),E=Math.ceil(b.length/this._pageSize),m=0;m<E;m++)Z.put(b.slice(m*this._pageSize,(m+1)*this._pageSize),"".concat(this._path,"-").concat(g.createPage(this._pagePtr+m)));this.exists()&&X.numPages<this._meta.numPages&&(y=IDBKeyRange.bound("".concat(this._path,"-").concat(g.createPage(X.numPages)),"".concat(this._path,"-").concat(g.createPage(this._meta.numPages)),!0),Z.delete(y)),(null===(l=Z.transaction)||void 0===l?void 0:l.commit)&&(null===(d=Z.transaction)||void 0===d||d.commit()),Z.transaction.onerror=function(){c(Z.transaction.error)},Z.transaction.oncomplete=function(){o._meta=X,o.seek(0,2),C()};case 23:case"end":return B.stop()}}),B,this)})))})));case 1:case"end":return C.stop()}}),C)})))}},{key:"seek",value:function(A,I){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(!this.exists())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),this._cache.clear()}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:function(){return x(this,void 0,void 0,D.mark((function A(){var I=this;return D.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.abrupt("return",new Promise((function(A,C){return x(I,void 0,void 0,D.mark((function I(){var B,c,l,d,Z=this;return D.wrap((function(I){for(;;)switch(I.prev=I.next){case 0:if(this.exists()){I.next=3;break}return C(new Error("ENOENT")),I.abrupt("return");case 3:B=this._meta.numPages,c=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(g.createPage(B))),l=this._store,(d=l.delete(c)).onerror=function(){C(d.error)},d.onsuccess=function(){Z._meta=void 0,Z._pageOffset=0,Z._pagePtr=0,A()};case 9:case"end":return I.stop()}}),I,this)})))})));case 1:case"end":return A.stop()}}),A)})))}},{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(AA,this._mode).objectStore(AA)}}],[{key:"open",value:function(A,I){var C=this;if(!self.indexedDB){var B=new Error("IndexedDB is not supported");throw B.name="IndexedDBNotSupported",B}return new Promise((function(B,c){return x(C,void 0,void 0,D.mark((function C(){var l,d,Z;return D.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.prev=0,C.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(AA)||g.result.createObjectStore(AA)}}));case 3:l=C.sent,(d=l.transaction(AA,"readwrite").objectStore(AA).get(A)).onerror=function(){c(d.error)},d.onsuccess=function(){var C=d.result,Z=I.includes("r")?"readonly":"readwrite";if(void 0===C&&"readonly"===Z){var i=new Error("'".concat(A,"' doesn't exist."));return i.name="FileNotExists",void c(i)}var G=new g(A,C,l,Z);I.includes("a")&&G.seek(0,2),B(G)},C.next=12;break;case 9:C.prev=9,C.t0=C.catch(0),"InvalidStateError"===C.t0.name?((Z=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",c(Z)):c(C.t0);case 12:case"end":return C.stop()}}),C,null,[[0,9]])})))}))}},{key:"createPage",value:function(A){return("00000"+A).slice(-6)}}]),g}();function CA(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=L(A);if(I){var B=L(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return v(this,g)}}var BA=function(A){f(g,q);var I=CA(g);function g(A,C,B,c){var l;return T(this,g),(l=I.call(this))._pos=0,l._path=A,l._meta=C,l._mode=c,l}return _(g,[{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,c=new Uint8Array(B);return c.set(this._file.slice(this._pos,this._pos+B),0),this._pos+=B,c}},{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(!this.exists())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:function(){return x(this,void 0,void 0,D.mark((function A(){return D.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:if(this.exists()){A.next=2;break}throw new Error("ENOENT");case 2:g._memFiles.delete(this._path),this._pos=0;case 4:case"end":return A.stop()}}),A,this)})))}},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return g._memFiles.get(this._path)},set:function(A){g._memFiles.set(this._path,A)}}],[{key:"open",value:function(A,I){var C=g._memFiles.get(A),B=I.includes("r")?"readonly":"readwrite";if(void 0===C&&"readonly"===B){var c=new Error("'".concat(A,"' doesn't exist."));throw c.name="FileNotExists",c}var l=new g(A,void 0,void 0,B);return I.includes("a")&&l.seek(0,2),l}}]),g}();function cA(A,I){for(var g=I;0!==A[g];)g++;return new TextDecoder("utf-8").decode(A.slice(I,g))}function lA(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){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 ZA(A,I){return x(this,void 0,void 0,D.mark((function g(){var C;return D.wrap((function(g){for(;;)switch(g.prev=g.next){case 0:return g.prev=0,g.next=3,gA.open(A,I);case 3:return g.abrupt("return",g.sent);case 6:if(g.prev=6,g.t0=g.catch(0),"IndexedDBNotSupported"===g.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==g.t0.name&&console.warn("Unable to access IndexedDB (".concat(g.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){g.next=16;break}if("FileNotExists"!==g.t0.name){g.next=12;break}throw g.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(C=new Error("Failed to start PvFile: ".concat(g.t0.toString()))).name="PvFileNotSupported",C;case 16:return g.abrupt("return",BA.open(A,I));case 17:case"end":return g.stop()}}),g,null,[[0,6]])})))}function iA(A,I,g,C){return x(this,void 0,void 0,D.mark((function B(){var c;return D.wrap((function(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,ZA(A,"w");case 2:if(c=B.sent,!(g||void 0===c.meta||C>c.meta.version||c.meta.pageSize!==c.pageSize)){B.next=6;break}return B.next=6,c.write(lA(I),C);case 6:case"end":return B.stop()}}),B)})))}BA._memFiles=new Map;var GA=5e3,bA=2;function QA(A,I,g,C,B){return x(this,void 0,void 0,D.mark((function c(){var l,d,Z,i,G,b,Q,X;return D.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,ZA(A,"w");case 2:if(l=c.sent,!(g||void 0===l.meta||C>l.meta.version||l.meta.pageSize!==l.pageSize)){c.next=43;break}if(!(B<0)){c.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:d=bA,Z=function(A){return new Promise((function(I){setTimeout(I,A)}))},i=B+1,G=null;case 10:if(!(i>0)){c.next=38;break}return G=null,c.prev=12,c.next=15,fetch(I,{cache:"no-cache"});case 15:if(!(b=c.sent).ok){c.next=23;break}return c.next=19,b.arrayBuffer();case 19:return Q=c.sent,c.next=22,l.write(new Uint8Array(Q),C);case 22:return c.abrupt("return");case 23:return c.next=25,b.text();case 25:X=c.sent,G=new Error("Error response returned while fetching model from '".concat(I,"': ").concat(X)),c.next=32;break;case 29:c.prev=29,c.t0=c.catch(12),G=new Error("Failed to fetch model from '".concat(I,"': ").concat(c.t0.message));case 32:return i--,c.next=35,Z(d);case 35:d=Math.min(GA,d*bA),c.next=10;break;case 38:if(null===G){c.next=42;break}throw G;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(I,"'"));case 43:case"end":return c.stop()}}),c,null,[[12,29]])})))}function XA(A){return x(this,void 0,void 0,D.mark((function I(){var g,C,B,c,l,d,Z,i,G;return D.wrap((function(I){for(;;)switch(I.prev=I.next){case 0:if(null!=A){I.next=2;break}throw new Error("The model is undefined / empty");case 2:if(g=A.base64,C=A.publicPath,B=A.customWritePath,c=A.forceWrite,l=void 0!==c&&c,d=A.version,Z=void 0===d?1:d,i=A.numFetchRetries,G=void 0===i?0:i,null!=B){I.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==g){I.next=10;break}return I.next=8,iA(B,g,l,Z);case 8:case 13:I.next=16;break;case 10:if(null==C){I.next=15;break}return I.next=13,QA(B,C,l,Z,G);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return I.abrupt("return",B);case 17:case"end":return I.stop()}}),I)})))}function EA(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 mA(A,I){if(A){if("string"==typeof A)return EA(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)?EA(A,I):void 0}}function yA(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,c,l,d=[],Z=!0,i=!1;try{if(c=(g=g.call(A)).next,0===I){if(Object(g)!==g)return;Z=!1}else for(;!(Z=(C=c.call(g)).done)&&(d.push(C.value),d.length!==I);Z=!0);}catch(A){i=!0,B=A}finally{try{if(!Z&&null!=g.return&&(l=g.return(),Object(l)!==l))return}finally{if(i)throw B}}return d}}(A,I)||mA(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.")}()}var oA,aA,sA,nA=(aA="undefined"!=typeof document?null===(oA=document.currentScript)||void 0===oA?void 0:oA.src:void 0,function(){var A,I,g=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},C=new Promise((function(g,C){A=g,I=C})),B="object"==("undefined"==typeof window?"undefined":s(window)),c="function"==typeof importScripts;function l(A){return l="function"==typeof Symbol&&"symbol"==s(Symbol.iterator)?function(A){return s(A)}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":s(A)},l(A)}function d(A){var I=function(A,I){if("object"!=l(A)||!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:I+""}function Z(A,I,g){return(I=d(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function i(A,I,g,C,B,c,l){try{var d=A[c](l),Z=d.value}catch(A){return void g(A)}d.done?I(Z):Promise.resolve(Z).then(C,B)}function G(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var c=A.apply(I,g);function l(A){i(c,C,B,l,d,"next",A)}function d(A){i(c,C,B,l,d,"throw",A)}l(void 0)}))}}function b(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}"object"==("undefined"==typeof process?"undefined":s(process))&&"object"==s(process.versions)&&process.versions.node;var Q={exports:{}},X={exports:{}};!function(A){function I(g){return A.exports=I="function"==typeof Symbol&&"symbol"==s(Symbol.iterator)?function(A){return s(A)}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":s(A)},A.exports.__esModule=!0,A.exports.default=A.exports,I(g)}A.exports=I,A.exports.__esModule=!0,A.exports.default=A.exports}(X);var E=X.exports;b(E),function(A){var I=E.default;function g(){A.exports=g=function(){return B},A.exports.__esModule=!0,A.exports.default=A.exports;var C,B={},c=Object.prototype,l=c.hasOwnProperty,d=Object.defineProperty||function(A,I,g){A[I]=g.value},Z="function"==typeof Symbol?Symbol:{},i=Z.iterator||"@@iterator",G=Z.asyncIterator||"@@asyncIterator",b=Z.toStringTag||"@@toStringTag";function Q(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{Q({},"")}catch(C){Q=function(A,I,g){return A[I]=g}}function X(A,I,g,C){var B=I&&I.prototype instanceof n?I:n,c=Object.create(B.prototype),l=new H(C||[]);return d(c,"_invoke",{value:e(A,g,l)}),c}function E(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=X;var m="suspendedStart",y="suspendedYield",o="executing",a="completed",s={};function n(){}function R(){}function V(){}var F={};Q(F,i,(function(){return this}));var h=Object.getPrototypeOf,Y=h&&h(h(p([])));Y&&Y!==c&&l.call(Y,i)&&(F=Y);var t=V.prototype=n.prototype=Object.create(F);function W(A){["next","throw","return"].forEach((function(I){Q(A,I,(function(A){return this._invoke(I,A)}))}))}function u(A,g){function C(B,c,d,Z){var i=E(A[B],A,c);if("throw"!==i.type){var G=i.arg,b=G.value;return b&&"object"==I(b)&&l.call(b,"__await")?g.resolve(b.__await).then((function(A){C("next",A,d,Z)}),(function(A){C("throw",A,d,Z)})):g.resolve(b).then((function(A){G.value=A,d(G)}),(function(A){return C("throw",A,d,Z)}))}Z(i.arg)}var B;d(this,"_invoke",{value:function(A,I){function c(){return new g((function(g,B){C(A,I,g,B)}))}return B=B?B.then(c,c):c()}})}function e(A,I,g){var B=m;return function(c,l){if(B===o)throw Error("Generator is already running");if(B===a){if("throw"===c)throw l;return{value:C,done:!0}}for(g.method=c,g.arg=l;;){var d=g.delegate;if(d){var Z=J(d,g);if(Z){if(Z===s)continue;return Z}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===m)throw B=a,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=o;var i=E(A,I,g);if("normal"===i.type){if(B=g.done?a:y,i.arg===s)continue;return{value:i.arg,done:g.done}}"throw"===i.type&&(B=a,g.method="throw",g.arg=i.arg)}}}function J(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,J(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),s;var c=E(B,A.iterator,I.arg);if("throw"===c.type)return I.method="throw",I.arg=c.arg,I.delegate=null,s;var l=c.arg;return l?l.done?(I[A.resultName]=l.value,I.next=A.nextLoc,"return"!==I.method&&(I.method="next",I.arg=C),I.delegate=null,s):l:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,s)}function w(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 H(A){this.tryEntries=[{tryLoc:"roo