@picovoice/cheetah-react
Version:
React hook for Cheetah Web SDK
1 lines • 933 kB
JavaScript
var CheetahReact=function(A,I,g){"use strict";function C(A){return C="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},C(A)}function B(A){var I=function(A,I){if("object"!==C(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var B=g.call(A,I||"default");if("object"!==C(B))return B;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===C(I)?I:String(I)}function Q(A,I,g,C,B,Q,E){try{var i=A[Q](E),w=i.value}catch(A){return void g(A)}i.done?I(w):Promise.resolve(w).then(C,B)}function E(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var E=A.apply(I,g);function i(A){Q(E,C,B,i,w,"next",A)}function w(A){Q(E,C,B,i,w,"throw",A)}i(void 0)}))}}function i(A,I){(null==I||I>A.length)&&(I=A.length);for(var g=0,C=new Array(I);g<I;g++)C[g]=A[g];return C}function w(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=[],w=!0,F=!1;try{if(Q=(g=g.call(A)).next,0===I){if(Object(g)!==g)return;w=!1}else for(;!(w=(C=Q.call(g)).done)&&(i.push(C.value),i.length!==I);w=!0);}catch(A){F=!0,B=A}finally{try{if(!w&&null!=g.return&&(E=g.return(),Object(E)!==E))return}finally{if(F)throw B}}return i}}(A,I)||function(A,I){if(A){if("string"==typeof A)return i(A,I);var g=Object.prototype.toString.call(A).slice(8,-1);return"Object"===g&&A.constructor&&(g=A.constructor.name),"Map"===g||"Set"===g?Array.from(A):"Arguments"===g||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(g)?i(A,I):void 0}}(A,I)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var o={exports:{}},D={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}(D);var R=D.exports;!function(A){var I=R.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},w="function"==typeof Symbol?Symbol:{},F=w.iterator||"@@iterator",o=w.asyncIterator||"@@asyncIterator",D=w.toStringTag||"@@toStringTag";function R(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{R({},"")}catch(C){R=function(A,I,g){return A[I]=g}}function G(A,I,g,C){var B=I&&I.prototype instanceof H?I:H,Q=Object.create(B.prototype),E=new J(C||[]);return i(Q,"_invoke",{value:b(A,g,E)}),Q}function c(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=G;var y="suspendedStart",s="suspendedYield",U="executing",h="completed",N={};function H(){}function M(){}function d(){}var Z={};R(Z,F,(function(){return this}));var Y=Object.getPrototypeOf,a=Y&&Y(Y(K([])));a&&a!==Q&&E.call(a,F)&&(Z=a);var S=d.prototype=H.prototype=Object.create(Z);function l(A){["next","throw","return"].forEach((function(I){R(A,I,(function(A){return this._invoke(I,A)}))}))}function n(A,g){function C(B,Q,i,w){var F=c(A[B],A,Q);if("throw"!==F.type){var o=F.arg,D=o.value;return D&&"object"==I(D)&&E.call(D,"__await")?g.resolve(D.__await).then((function(A){C("next",A,i,w)}),(function(A){C("throw",A,i,w)})):g.resolve(D).then((function(A){o.value=A,i(o)}),(function(A){return C("throw",A,i,w)}))}w(F.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 b(A,I,g){var B=y;return function(Q,E){if(B===U)throw new Error("Generator is already running");if(B===h){if("throw"===Q)throw E;return{value:C,done:!0}}for(g.method=Q,g.arg=E;;){var i=g.delegate;if(i){var w=t(i,g);if(w){if(w===N)continue;return w}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===y)throw B=h,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=U;var F=c(A,I,g);if("normal"===F.type){if(B=g.done?h:s,F.arg===N)continue;return{value:F.arg,done:g.done}}"throw"===F.type&&(B=h,g.method="throw",g.arg=F.arg)}}}function t(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,t(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),N;var Q=c(B,A.iterator,I.arg);if("throw"===Q.type)return I.method="throw",I.arg=Q.arg,I.delegate=null,N;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,N):E:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,N)}function f(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 e(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function J(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(f,this),this.reset(!0)}function K(A){if(A||""===A){var g=A[F];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 M.prototype=d,i(S,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:M,configurable:!0}),M.displayName=R(d,D,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===M||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,d):(A.__proto__=d,R(A,D,"GeneratorFunction")),A.prototype=Object.create(S),A},B.awrap=function(A){return{__await:A}},l(n.prototype),R(n.prototype,o,(function(){return this})),B.AsyncIterator=n,B.async=function(A,I,g,C,Q){void 0===Q&&(Q=Promise);var E=new n(G(A,I,g,C),Q);return B.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},l(S),R(S,D,"Generator"),R(S,F,(function(){return this})),R(S,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=K,J.prototype={constructor:J,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(e),!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 w=E.call(Q,"catchLoc"),F=E.call(Q,"finallyLoc");if(w&&F){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0);if(this.prev<Q.finallyLoc)return g(Q.finallyLoc)}else if(w){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0)}else{if(!F)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,N):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),N},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),e(g),N}},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;e(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:K(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),N}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(o);var G=(0,o.exports)(),c=G;try{regeneratorRuntime=G}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=G:Function("r","regeneratorRuntime = r")(G)}var y=F(c);function s(A,I,g,C,B,Q,E){try{var i=A[Q](E),w=i.value}catch(A){return void g(A)}i.done?I(w):Promise.resolve(w).then(C,B)}function U(A){return function(){var I=this,g=arguments;return new Promise((function(C,B){var Q=A.apply(I,g);function E(A){s(Q,C,B,E,i,"next",A)}function i(A){s(Q,C,B,E,i,"throw",A)}E(void 0)}))}}function h(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function N(A){return N="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},N(A)}function H(A){var I=function(A,I){if("object"!==N(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==N(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===N(I)?I:String(I)}function M(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,H(C.key),C)}}function d(A,I,g){return I&&M(A.prototype,I),g&&M(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}function Z(A,I,g){return(I=H(I))in A?Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}):A[I]=g,A}function Y(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var a={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 l=S.exports;!function(A){var I=l.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},w="function"==typeof Symbol?Symbol:{},F=w.iterator||"@@iterator",o=w.asyncIterator||"@@asyncIterator",D=w.toStringTag||"@@toStringTag";function R(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{R({},"")}catch(C){R=function(A,I,g){return A[I]=g}}function G(A,I,g,C){var B=I&&I.prototype instanceof H?I:H,Q=Object.create(B.prototype),E=new J(C||[]);return i(Q,"_invoke",{value:b(A,g,E)}),Q}function c(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=G;var y="suspendedStart",s="suspendedYield",U="executing",h="completed",N={};function H(){}function M(){}function d(){}var Z={};R(Z,F,(function(){return this}));var Y=Object.getPrototypeOf,a=Y&&Y(Y(K([])));a&&a!==Q&&E.call(a,F)&&(Z=a);var S=d.prototype=H.prototype=Object.create(Z);function l(A){["next","throw","return"].forEach((function(I){R(A,I,(function(A){return this._invoke(I,A)}))}))}function n(A,g){function C(B,Q,i,w){var F=c(A[B],A,Q);if("throw"!==F.type){var o=F.arg,D=o.value;return D&&"object"==I(D)&&E.call(D,"__await")?g.resolve(D.__await).then((function(A){C("next",A,i,w)}),(function(A){C("throw",A,i,w)})):g.resolve(D).then((function(A){o.value=A,i(o)}),(function(A){return C("throw",A,i,w)}))}w(F.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 b(A,I,g){var B=y;return function(Q,E){if(B===U)throw new Error("Generator is already running");if(B===h){if("throw"===Q)throw E;return{value:C,done:!0}}for(g.method=Q,g.arg=E;;){var i=g.delegate;if(i){var w=t(i,g);if(w){if(w===N)continue;return w}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===y)throw B=h,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=U;var F=c(A,I,g);if("normal"===F.type){if(B=g.done?h:s,F.arg===N)continue;return{value:F.arg,done:g.done}}"throw"===F.type&&(B=h,g.method="throw",g.arg=F.arg)}}}function t(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,t(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),N;var Q=c(B,A.iterator,I.arg);if("throw"===Q.type)return I.method="throw",I.arg=Q.arg,I.delegate=null,N;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,N):E:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,N)}function f(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 e(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function J(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(f,this),this.reset(!0)}function K(A){if(A||""===A){var g=A[F];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 M.prototype=d,i(S,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:M,configurable:!0}),M.displayName=R(d,D,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===M||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,d):(A.__proto__=d,R(A,D,"GeneratorFunction")),A.prototype=Object.create(S),A},B.awrap=function(A){return{__await:A}},l(n.prototype),R(n.prototype,o,(function(){return this})),B.AsyncIterator=n,B.async=function(A,I,g,C,Q){void 0===Q&&(Q=Promise);var E=new n(G(A,I,g,C),Q);return B.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},l(S),R(S,D,"Generator"),R(S,F,(function(){return this})),R(S,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=K,J.prototype={constructor:J,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(e),!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 w=E.call(Q,"catchLoc"),F=E.call(Q,"finallyLoc");if(w&&F){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0);if(this.prev<Q.finallyLoc)return g(Q.finallyLoc)}else if(w){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0)}else{if(!F)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,N):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),N},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),e(g),N}},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;e(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:K(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),N}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(a);var n=(0,a.exports)(),b=n;try{regeneratorRuntime=n}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}var t=Y(b);const f=new Error("request for lock canceled");var e=function(A,I,g,C){return new(g||(g=Promise))((function(B,Q){function E(A){try{w(C.next(A))}catch(A){Q(A)}}function i(A){try{w(C.throw(A))}catch(A){Q(A)}}function w(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(E,i)}w((C=C.apply(A,I||[])).next())}))};class J{constructor(A,I=f){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 e(this,void 0,void 0,(function*(){const[g,C]=yield this.acquire(I);try{return yield A(g)}finally{C()}}))}waitForUnlock(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);return new Promise((I=>{this._weightedWaiters[A-1]||(this._weightedWaiters[A-1]=[]),this._weightedWaiters[A-1].push(I),this._dispatch()}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(A){this._value=A,this._dispatch()}release(A=1){if(A<=0)throw new Error(`invalid weight ${A}: must be positive`);this._value+=A,this._dispatch()}cancel(){this._weightedQueues.forEach((A=>A.forEach((A=>A.reject(this._cancelError))))),this._weightedQueues=[]}_dispatch(){var A;for(let I=this._value;I>0;I--){const g=null===(A=this._weightedQueues[I-1])||void 0===A?void 0:A.shift();if(!g)continue;const C=this._value,B=I;this._value-=I,I=this._value+1,g.resolve([C,this._newReleaser(B)])}this._drainUnlockWaiters()}_newReleaser(A){let I=!1;return()=>{I||(I=!0,this.release(A))}}_drainUnlockWaiters(){for(let A=this._value;A>0;A--)this._weightedWaiters[A-1]&&(this._weightedWaiters[A-1].forEach((A=>A())),this._weightedWaiters[A-1]=[])}}var K=function(A,I,g,C){return new(g||(g=Promise))((function(B,Q){function E(A){try{w(C.next(A))}catch(A){Q(A)}}function i(A){try{w(C.throw(A))}catch(A){Q(A)}}function w(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(E,i)}w((C=C.apply(A,I||[])).next())}))};class L{constructor(A){this._semaphore=new J(1,A)}acquire(){return K(this,void 0,void 0,(function*(){const[,A]=yield this._semaphore.acquire();return A}))}runExclusive(A){return this._semaphore.runExclusive((()=>A()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}function k(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}var X={exports:{}},V={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}(V);var r=V.exports;!function(A){var I=r.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},w="function"==typeof Symbol?Symbol:{},F=w.iterator||"@@iterator",o=w.asyncIterator||"@@asyncIterator",D=w.toStringTag||"@@toStringTag";function R(A,I,g){return Object.defineProperty(A,I,{value:g,enumerable:!0,configurable:!0,writable:!0}),A[I]}try{R({},"")}catch(C){R=function(A,I,g){return A[I]=g}}function G(A,I,g,C){var B=I&&I.prototype instanceof H?I:H,Q=Object.create(B.prototype),E=new J(C||[]);return i(Q,"_invoke",{value:b(A,g,E)}),Q}function c(A,I,g){try{return{type:"normal",arg:A.call(I,g)}}catch(A){return{type:"throw",arg:A}}}B.wrap=G;var y="suspendedStart",s="suspendedYield",U="executing",h="completed",N={};function H(){}function M(){}function d(){}var Z={};R(Z,F,(function(){return this}));var Y=Object.getPrototypeOf,a=Y&&Y(Y(K([])));a&&a!==Q&&E.call(a,F)&&(Z=a);var S=d.prototype=H.prototype=Object.create(Z);function l(A){["next","throw","return"].forEach((function(I){R(A,I,(function(A){return this._invoke(I,A)}))}))}function n(A,g){function C(B,Q,i,w){var F=c(A[B],A,Q);if("throw"!==F.type){var o=F.arg,D=o.value;return D&&"object"==I(D)&&E.call(D,"__await")?g.resolve(D.__await).then((function(A){C("next",A,i,w)}),(function(A){C("throw",A,i,w)})):g.resolve(D).then((function(A){o.value=A,i(o)}),(function(A){return C("throw",A,i,w)}))}w(F.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 b(A,I,g){var B=y;return function(Q,E){if(B===U)throw new Error("Generator is already running");if(B===h){if("throw"===Q)throw E;return{value:C,done:!0}}for(g.method=Q,g.arg=E;;){var i=g.delegate;if(i){var w=t(i,g);if(w){if(w===N)continue;return w}}if("next"===g.method)g.sent=g._sent=g.arg;else if("throw"===g.method){if(B===y)throw B=h,g.arg;g.dispatchException(g.arg)}else"return"===g.method&&g.abrupt("return",g.arg);B=U;var F=c(A,I,g);if("normal"===F.type){if(B=g.done?h:s,F.arg===N)continue;return{value:F.arg,done:g.done}}"throw"===F.type&&(B=h,g.method="throw",g.arg=F.arg)}}}function t(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,t(A,I),"throw"===I.method)||"return"!==g&&(I.method="throw",I.arg=new TypeError("The iterator does not provide a '"+g+"' method")),N;var Q=c(B,A.iterator,I.arg);if("throw"===Q.type)return I.method="throw",I.arg=Q.arg,I.delegate=null,N;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,N):E:(I.method="throw",I.arg=new TypeError("iterator result is not an object"),I.delegate=null,N)}function f(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 e(A){var I=A.completion||{};I.type="normal",delete I.arg,A.completion=I}function J(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(f,this),this.reset(!0)}function K(A){if(A||""===A){var g=A[F];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 M.prototype=d,i(S,"constructor",{value:d,configurable:!0}),i(d,"constructor",{value:M,configurable:!0}),M.displayName=R(d,D,"GeneratorFunction"),B.isGeneratorFunction=function(A){var I="function"==typeof A&&A.constructor;return!!I&&(I===M||"GeneratorFunction"===(I.displayName||I.name))},B.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,d):(A.__proto__=d,R(A,D,"GeneratorFunction")),A.prototype=Object.create(S),A},B.awrap=function(A){return{__await:A}},l(n.prototype),R(n.prototype,o,(function(){return this})),B.AsyncIterator=n,B.async=function(A,I,g,C,Q){void 0===Q&&(Q=Promise);var E=new n(G(A,I,g,C),Q);return B.isGeneratorFunction(I)?E:E.next().then((function(A){return A.done?A.value:E.next()}))},l(S),R(S,D,"Generator"),R(S,F,(function(){return this})),R(S,"toString",(function(){return"[object Generator]"})),B.keys=function(A){var I=Object(A),g=[];for(var C in I)g.push(C);return g.reverse(),function A(){for(;g.length;){var C=g.pop();if(C in I)return A.value=C,A.done=!1,A}return A.done=!0,A}},B.values=K,J.prototype={constructor:J,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(e),!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 w=E.call(Q,"catchLoc"),F=E.call(Q,"finallyLoc");if(w&&F){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0);if(this.prev<Q.finallyLoc)return g(Q.finallyLoc)}else if(w){if(this.prev<Q.catchLoc)return g(Q.catchLoc,!0)}else{if(!F)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,N):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),N},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),e(g),N}},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;e(g)}return B}}throw new Error("illegal catch attempt")},delegateYield:function(A,I,g){return this.delegate={iterator:K(A),resultName:I,nextLoc:g},"next"===this.method&&(this.arg=C),N}},B}A.exports=g,A.exports.__esModule=!0,A.exports.default=A.exports}(X);var u=(0,X.exports)(),v=u;try{regeneratorRuntime=u}catch(A){"object"==typeof globalThis?globalThis.regeneratorRuntime=u:Function("r","regeneratorRuntime = r")(u)}var m=k(v);function P(A,I,g,C){return new(g||(g=Promise))((function(B,Q){function E(A){try{w(C.next(A))}catch(A){Q(A)}}function i(A){try{w(C.throw(A))}catch(A){Q(A)}}function w(A){var I;A.done?B(A.value):(I=A.value,I instanceof g?I:new g((function(A){A(I)}))).then(E,i)}w((C=C.apply(A,I||[])).next())}))}const W=new WeakMap;function j(A,I){return new Proxy(A,{get:(A,g)=>I(A[g])})}class z{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 j(A,(A=>"function"==typeof A?this.wrapImportFn(A):A))}wrapImports(A){if(void 0!==A)return j(A,((A=Object.create(null))=>this.wrapModuleImports(A)))}wrapExportFn(A){let I=W.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},W.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 W.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,x.prototype)}}class x extends WebAssembly.Instance{constructor(A,I){let g=new z;super(A,g.wrapImports(I)),g.init(this,I)}get exports(){return W.get(super.exports)}}async function p(A,I){let g=new z,C=await WebAssembly.instantiate(A,g.wrapImports(I));return g.init(C instanceof WebAssembly.Instance?C:C.instance,I),C}async function T(A,I){let g=new z,C=await WebAssembly.instantiateStreaming(A,g.wrapImports(I));return g.init(C.instance,I),C}function O(A,I){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,I){return A.__proto__=I,A},O(A,I)}function q(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&&O(A,I)}function _(A){return _="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)}function $(A,I){if(I&&("object"===_(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 AA(A){return AA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(A){return A.__proto__||Object.getPrototypeOf(A)},AA(A)}function IA(A,I){if(!(A instanceof I))throw new TypeError("Cannot call a class as a function")}function gA(A){var I=function(A,I){if("object"!==_(A)||null===A)return A;var g=A[Symbol.toPrimitive];if(void 0!==g){var C=g.call(A,I||"default");if("object"!==_(C))return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===I?String:Number)(A)}(A,"string");return"symbol"===_(I)?I:String(I)}function CA(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,gA(C.key),C)}}function BA(A,I,g){return I&&CA(A.prototype,I),g&&CA(A,g),Object.defineProperty(A,"prototype",{writable:!1}),A}Object.defineProperty(x.prototype,"exports",{enumerable:!0});var QA=function(){function A(){IA(this,A),this._path=""}return BA(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 EA(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=AA(A);if(I){var B=AA(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return $(this,g)}}QA._filePtrs=new Map;var iA="pv_file";var wA=function(){function A(){IA(this,A),this._pos=0,this._data=new Uint8Array}return BA(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}(),FA=function(A){q(g,A);var I=EA(g);function g(A,C,B,Q){var E;return IA(this,g),(E=I.call(this))._pageSize=524288,E._pagePtr=0,E._pageOffset=0,E._path=A,E._meta=C,E._db=B,E._mode=Q,E._cache=new wA,E}return BA(g,[{key:"pageSize",get:function(){return this._pageSize}},{key:"close",value:function(){return P(this,void 0,void 0,m.mark((function A(){return m.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 P(this,void 0,void 0,m.mark((function C(){var B=this;return m.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.abrupt("return",new Promise((function(C,Q){if(B.exists()){if(B._isEOF){var E=new Error("EOF");return E.name="EndOfFile",void Q(E)}var i=0,w=Math.min(A*I,B._meta.size),F=w-w%A,o=new Uint8Array(F),D=B._cache.get(F);if(D){if(i+=D.length,B._pageOffset+=D.length,B._pageOffset===B._pageSize&&(B._pagePtr+=1,B._pageOffset=0),F===i)return void C(D);o.set(D)}var R=IDBKeyRange.bound("".concat(B._path,"-").concat(g.createPage(B._pagePtr)),"".concat(B._path,"-").concat(g.createPage(B._pagePtr+Math.floor(F/B._pageSize)+1))),G=B._store,c=G.openCursor(R);c.onsuccess=function(){var A,I,g=c.result;if(g&&!B._isEOF){var C=Math.min(F-i,g.value.length-B._pageOffset);o.set(g.value.slice(B._pageOffset,B._pageOffset+C),i),i+=C,B._pageOffset+=C,B._pageOffset===B._pageSize&&(B._pagePtr+=1,B._pageOffset=0),i<F?g.continue():(0!==B._pageOffset?B._cache.set(B._pageOffset,g.value):B._cache.clear(),(null===(A=G.transaction)||void 0===A?void 0:A.commit)&&(null===(I=G.transaction)||void 0===I||I.commit()))}},G.transaction.onerror=function(){Q(G.transaction.error)},G.transaction.oncomplete=function(){C(o.slice(0,i))}}else Q(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 P(this,void 0,void 0,m.mark((function C(){var B=this;return m.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return C.abrupt("return",new Promise((function(C,Q){return P(B,void 0,void 0,m.mark((function B(){var E,i,w,F,o,D,R,G,c,y,s,U=this;return m.wrap((function(B){for(;;)switch(B.prev=B.next){case 0:if("readonly"!==this._mode){B.next=3;break}return Q(new Error("Instance is readonly mode only.")),B.abrupt("return");case 3:if(!("number"!=typeof I&&I<=0)){B.next=6;break}return Q(new Error("Version should be a positive number")),B.abrupt("return");case 6:return w=this._store,F=function(){return new Promise((function(A){var I=w.get("".concat(U._path,"-").concat(g.createPage(U._pagePtr)));I.onsuccess=function(){void 0!==I.result?A(I.result.slice(0,U._pageOffset)):A(new Uint8Array(0))}}))},B.next=10,F();case 10:for(o=B.sent,(D=new Uint8Array(o.length+A.length)).set(o),D.set(A,o.length),R=this._pagePtr*this._pageSize+D.length,G={size:R,numPages:Math.ceil(R/this._pageSize),version:I,pageSize:this._pageSize},w.put(G,this._path),c=Math.ceil(D.length/this._pageSize),y=0;y<c;y++)w.put(D.slice(y*this._pageSize,(y+1)*this._pageSize),"".concat(this._path,"-").concat(g.createPage(this._pagePtr+y)));this.exists()&&G.numPages<this._meta.numPages&&(s=IDBKeyRange.bound("".concat(this._path,"-").concat(g.createPage(G.numPages)),"".concat(this._path,"-").concat(g.createPage(this._meta.numPages)),!0),w.delete(s)),(null===(E=w.transaction)||void 0===E?void 0:E.commit)&&(null===(i=w.transaction)||void 0===i||i.commit()),w.transaction.onerror=function(){Q(w.transaction.error)},w.transaction.oncomplete=function(){U._meta=G,U.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 P(this,void 0,void 0,m.mark((function A(){var I=this;return m.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.abrupt("return",new Promise((function(A,C){return P(I,void 0,void 0,m.mark((function I(){var B,Q,E,i,w=this;return m.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,Q=IDBKeyRange.bound(this._path,"".concat(this._path,"-").concat(g.createPage(B))),E=this._store,(i=E.delete(Q)).onerror=function(){C(i.error)},i.onsuccess=function(){w._meta=void 0,w._pageOffset=0,w._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(iA,this._mode).objectStore(iA)}}],[{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,Q){return P(C,void 0,void 0,m.mark((function C(){var E,i,w;return m.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(iA)||g.result.createObjectStore(iA)}}));case 3:E=C.sent,(i=E.transaction(iA,"readwrite").objectStore(iA).get(A)).onerror=function(){Q(i.error)},i.onsuccess=function(){var C=i.result,w=I.includes("r")?"readonly":"readwrite";if(void 0===C&&"readonly"===w){var F=new Error("'".concat(A,"' doesn't exist."));return F.name="FileNotExists",void Q(F)}var o=new g(A,C,E,w);I.includes("a")&&o.seek(0,2),B(o)},C.next=12;break;case 9:C.prev=9,C.t0=C.catch(0),"InvalidStateError"===C.t0.name?((w=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",Q(w)):Q(C.t0);case 12:case"end":return C.stop()}}),C,null,[[0,9]])})))}))}},{key:"createPage",value:function(A){return("00000"+A).slice(-6)}}]),g}(QA);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=AA(A);if(I){var B=AA(this).constructor;g=Reflect.construct(C,arguments,B)}else g=C.apply(this,arguments);return $(this,g)}}var DA=function(A){q(g,A);var I=oA(g);function g(A,C,B,Q){var E;return IA(this,g),(E=I.call(this))._pos=0,E._path=A,E._meta=C,E._mode=Q,E}return BA(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,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(!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 P(this,void 0,void 0,m.mark((function A(){return m.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 Q=new Error("'".concat(A,"' doesn't exist."));throw Q.name="FileNotExists",Q}var E=new g(A,void 0,void 0,B);return I.includes("a")&&E.seek(0,2),E}}]),g}(QA);function RA(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 GA(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 GA(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 GA(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 cA(A){return A<0?A>>>0:A}function yA(A,I){for(var g=I;0!==A[g];)g++;return new TextDecoder("utf-8").decode(A.slice(I,g))}function sA(A){for(var I=atob(A),g=new Uint8Array(I.length),C=0;C<I.length;C++)g[C]=I.charCodeAt(C);return g}function UA(A){var I,g={},C=RA(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 hA(A){var I=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},g=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;return P(this,void 0,void 0,m.mark((function C(){var B,Q,E,i;return m.wrap((function(C){for(;;)switch(C.prev=C.next){case 0:return B=new AbortController,Q=Object.assign(Object.assign({},I),{signal:B.signal}),E=setTimeout((function(){B.abort()}),g),C.next=5,fetch(A,Q);case 5:return i=C.sent,clearTimeout(E),C.abrupt("return",i);case 8:case"end":return C.stop()}}),C)})))}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 HA(A,I){return P(this,void 0,void 0,m.mark((function g(){var C;return m.wrap((function(g){for(;;)switch(g.prev=g.next){case 0:return g.prev=0,g.next=3,FA.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",DA.open(A,I));case 17:case"end":return g.stop()}}),g,null,[[0,6]])})))}function MA(A,I,g,C){return P(this,void 0,void 0,m.mark((function B(){var Q;return m.wrap((function(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,HA(A,"w");case 2:if(Q=B.sent,!(g||void 0===Q.meta||C>Q.meta.version||Q.meta.pageSize!==Q.pageSize)){B.next=6;break}return B.next=6,Q.write(sA(I),C);case 6:case"end":return B.stop()}}),B)})))}DA._memFiles=new Map;var dA=5e3,ZA=2;function YA(A,I,g,C,B){return P(this,void 0,void 0,m.mark((function Q(){var E,i,w,F,o,D,R,G;return m.wrap((function(Q){for(;;)switch(Q.prev=Q.next){case 0:return Q.next=2,HA(A,"w");case 2:if(E=Q.sent,!(g||void 0===E.meta||C>E.meta.version||E.meta.pageSize!==E.pageSize)){Q.next=43;break}if(!(B<0)){Q.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:i=ZA,w=function(A){return new Promise((function(I){setTimeout(I,A)}))},F=B+1,o=null;case 10:if(!(F>0)){Q.next=38;break}return o=null,Q.prev=12,Q.next=15,fetch(I,{cache:"no-cache"});case 15:if(!(D=Q.sent).ok){Q.next=23;break}return Q.next=19,D.arrayBuffer();case 19:return R=Q.sent,Q.next=22,E.write(new Uint8Array(R),C);case 22:return Q.abrupt("return");case 23:return Q.next=25,D.text();case 25:G=Q.sent,o=new Error("Error response returned while fetching model from '".concat(I,"': ").concat(G)),Q.next=32;break;case 29:Q.prev=29,Q.t0=Q.catch(12),o=new Error("Failed to fetch model from '".concat(I,"': ").concat(Q.t0.message));case 32:return F--,Q.next=35,w(i);case 35:i=Math.min(dA,i*ZA),Q.next=10;break;case 38:if(null===o){Q.next=42;break}throw o;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(I,"'"));case 43:case"end":return Q.stop()}}),Q,null,[[12,29]])})))}function aA(A){return P(this,void 0,void 0,m.mark((function I(){var g,C,B,Q,E,i,w,F,o;return m.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,Q=A.forceWrite,E=void 0!==Q&&Q,i=A.version,w=void 0===i?1:i,F=A.numFetchRetries,o=void 0===F?0:F,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,MA(B,g,E,w);case 8:case 13:I.next=16;break;case 10:if(null==C){I.next=15;break}return I.next=13,YA(B,C,E,w,o);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)})))}var SA={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 lA(A,I,g){var C=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},B=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return P(this,void 0,void 0,m.mark((function Q(){var E,i,w,F,o,D,R,G,c,y,s,U,h,N,H,M,d,Z,Y,a,S,l;return m.wrap((function(Q){for(;;)switch(Q.prev=Q.next){case 0:if(E=function(I,g){new Int32Array(A.buffer)[I/Int32Array.BYTES_PER_ELEMENT]=g},i=function(A,I