New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@picovoice/web-utils

Package Overview
Dependencies
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@picovoice/web-utils - npm Package Compare versions

Comparing version 1.2.12 to 1.3.0

4

dist/esm/index.min.js

@@ -1,3 +0,1 @@

function t(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function e(e){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=e.apply(r,n);function s(e){t(i,o,a,s,c,"next",e)}function c(e){t(i,o,a,s,c,"throw",e)}s(void 0)}))}}function r(t){var e={exports:{}};return t(e,e.exports),e.exports}var n=r((function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})),o=r((function(t){var e=n.default;function r(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
t.exports=r=function(){return n},t.exports.__esModule=!0,t.exports.default=t.exports;var n={},o=Object.prototype,a=o.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),i=new O(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return T()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=x(i,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=p(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=l;var h={};function d(){}function v(){}function y(){}var _={};f(_,s,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(S([])));w&&w!==o&&a.call(w,s)&&(_=w);var g=y.prototype=d.prototype=Object.create(_);function E(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,r){function n(o,i,s,c){var u=p(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=p(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(a.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=y,f(g,"constructor",y),f(y,"constructor",v),v.displayName=f(y,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},n.awrap=function(t){return{__await:t}},E(b.prototype),f(b.prototype,c,(function(){return this})),n.AsyncIterator=b,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new b(l(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},E(g),f(g,u,"Generator"),f(g,s,(function(){return this})),f(g,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},n.values=S,O.prototype={constructor:O,reset:function(t){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(P),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),a=o();const i=new WeakMap;function s(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class c{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return s(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return s(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=i.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},i.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return i.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,u.prototype)}}class u extends WebAssembly.Instance{constructor(t,e){let r=new c;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return i.get(super.exports)}}async function f(t,e){let r=new c,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function l(t,e){let r=new c,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function p(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function v(t,e,r){return e&&d(t.prototype,e),r&&d(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _(t,e){return _=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_(t,e)}function m(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function g(t,e){if(e&&("object"===w(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return y(t)}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}Object.defineProperty(u.prototype,"exports",{enumerable:!0});var x=function(){function t(){h(this,t),p(this,"_path",void 0),p(this,"_meta",void 0)}return v(t,[{key:"meta",get:function(){if(void 0!==this._meta)return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach((function(e){p(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({version:0},this._meta)}}],[{key:"getPtr",value:function(e){return t._filePtrs.get(e)}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function k(t){var e=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(t){return!1}}();return function(){var r,n=E(t);if(e){var o=E(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return g(this,r)}}p(x,"_filePtrs",new Map);var P="pv_db",O="pv_file";function S(){return new Promise((function(t,e){var r=self.indexedDB.open(P,3);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(O)||r.result.createObjectStore(O)}}))}var T=function(t){m(c,x);var r,n,o,i,s=k(c);function c(t,e,r,n){var o;return h(this,c),p(y(o=s.call(this)),"_pageSize",65536),p(y(o),"_db",void 0),p(y(o),"_mode",void 0),p(y(o),"_pagePtr",0),p(y(o),"_pageOffset",0),o._path=t,o._meta=e,o._db=r,o._mode=n,o}return v(c,[{key:"close",value:(i=e(a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"read",value:(o=e(a.mark((function t(e,r){var n=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,o){if(n.exists()){if(n._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void o(a)}var i=0,s=Math.min(e*r,n._meta.size),u=s-s%e,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(n._path,"-").concat(c.createPage(n._pagePtr)),"".concat(n._path,"-").concat(c.createPage(n._meta.numPages))),p=n._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!n._isEOF){var e=Math.min(u-i,t.value.length-n._pageOffset);f.set(t.value.slice(n._pageOffset,n._pageOffset+e),i),i+=e,n._pageOffset+=e,n._pageOffset===n._pageSize&&(n._pagePtr+=1,n._pageOffset=0),i<u&&t.continue()}},p.transaction.onerror=function(){o(p.transaction.error)},p.transaction.oncomplete=function(){t(f.slice(0,i))}}else o(new Error("'".concat(n._path,"' doesn't exist.")))})));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return o.apply(this,arguments)})},{key:"write",value:(n=e(a.mark((function t(r){var n,o=this,i=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:1,t.abrupt("return",new Promise(function(){var t=e(a.mark((function t(e,i){var s,u,f,l,p,h,d,v,y;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("readonly"!==o._mode){t.next=3;break}return i(new Error("Instance is readonly mode only.")),t.abrupt("return");case 3:if(!("number"!=typeof n&&n<=0)){t.next=6;break}return i(new Error("Version should be a positive number")),t.abrupt("return");case 6:return s=o._store,u=function(){return new Promise((function(t){var e=s.get("".concat(o._path,"-").concat(c.createPage(o._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,o._pageOffset)):t(new Uint8Array(0))}}))},t.next=10,u();case 10:for(f=t.sent,(l=new Uint8Array(f.length+r.length)).set(f),l.set(r,f.length),p=o._pagePtr*o._pageSize+l.length,h={size:p,numPages:Math.ceil(p/o._pageSize),version:n},s.put(h,o._path),d=Math.ceil(l.length/o._pageSize),v=0;v<d;v++)s.put(l.slice(v*o._pageSize,(v+1)*o._pageSize),"".concat(o._path,"-").concat(c.createPage(o._pagePtr+v)));o.exists()&&h.numPages<o._meta.numPages&&(y=IDBKeyRange.bound("".concat(o._path,"-").concat(c.createPage(h.numPages)),"".concat(o._path,"-").concat(c.createPage(o._meta.numPages)),!0),s.delete(y)),s.transaction.onerror=function(){i(s.transaction.error)},s.transaction.oncomplete=function(){o._meta=h,o.seek(0,2),e()};case 22:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:(r=e(a.mark((function t(){var r=this;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=e(a.mark((function t(e,n){var o,i,s,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=r._meta.numPages,i=IDBKeyRange.bound(r._path,"".concat(r._path,"-").concat(c.createPage(o))),s=r._store,(u=s.delete(i)).onerror=function(){n(u.error)},u.onsuccess=function(){r._meta=void 0,r._pageOffset=0,r._pagePtr=0,e()};case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(O,this._mode).objectStore(O)}}],[{key:"open",value:function(t,r){if(!self.indexedDB){var n=new Error("IndexedDB is not supported");throw n.name="IndexedDBNotSupported",n}return new Promise(function(){var n=e(a.mark((function e(n,o){var i,s,u;return a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,S();case 3:i=e.sent,(s=i.transaction(O,"readwrite").objectStore(O).get(t)).onerror=function(){o(s.error)},s.onsuccess=function(){var e=s.result,a=r.includes("r")?"readonly":"readwrite";if(void 0===e&&"readonly"===a){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void o(u)}var f=new c(t,e,i,a);r.includes("a")&&f.seek(0,2),n(f)},e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),"InvalidStateError"===e.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",o(u)):o(e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"createPage",value:function(t){return("000"+t).slice(-4)}}]),c}();function A(t){var e=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(t){return!1}}();return function(){var r,n=E(t);if(e){var o=E(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return g(this,r)}}var j=function(t){m(o,x);var r,n=A(o);function o(t,e,r,a){var i;return h(this,o),p(y(i=n.call(this)),"_pos",0),p(y(i),"_mode",void 0),i._path=t,i._meta=e,i._mode=a,i}return v(o,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,a=new Uint8Array(o);return a.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,a}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:(r=e(a.mark((function t(){return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o._memFiles.delete(this._path),this._file=void 0,this._pos=0;case 3:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return o._memFiles.get(this._path)},set:function(t){o._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var r=o._memFiles.get(t),n=e.includes("r")?"readonly":"readwrite";if(void 0===r&&"readonly"===n){var a=new Error("'".concat(t,"' doesn't exist."));throw a.name="FileNotExists",a}var i=new o(t,void 0,void 0,n);return e.includes("a")&&i.seek(0,2),i}}]),o}();function I(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?I(Object(r),!0).forEach((function(e){p(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return M(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function F(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function R(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function B(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)}function Y(t){var e,r={},n=N(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function D(t){return z.apply(this,arguments)}function z(){return z=e(a.mark((function t(e){var r,n,o,i,s,c,u=arguments;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=u.length>2&&void 0!==u[2]?u[2]:5e3,o=new AbortController,i=L(L({},r),{},{signal:o.signal}),s=setTimeout((function(){o.abort()}),n),t.next=7,fetch(e,i);case 7:return c=t.sent,clearTimeout(s),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)}))),z.apply(this,arguments)}function W(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}}function U(t,e){return C.apply(this,arguments)}function C(){return(C=e(a.mark((function t(e,r){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,T.open(e,r);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),"IndexedDBNotSupported"===t.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==t.t0.name&&console.warn("Unable to access IndexedDB (".concat(t.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){t.next=16;break}if("FileNotExists"!==t.t0.name){t.next=12;break}throw t.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(t.t0.toString()))).name="PvFileNotSupported",n;case 16:return t.abrupt("return",j.open(e,r));case 17:case"end":return t.stop()}}),t,null,[[0,6]])})))).apply(this,arguments)}function G(t,e,r,n){return q.apply(this,arguments)}function q(){return(q=e(a.mark((function t(e,r,n,o){var i;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,U(e,"w");case 2:if(i=t.sent,!(n||void 0===i.meta||o>i.meta.version)){t.next=6;break}return t.next=6,i.write(R(r),o);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}p(j,"_memFiles",new Map);function K(t,e,r,n,o){return V.apply(this,arguments)}function V(){return(V=e(a.mark((function t(e,r,n,o,i){var s,c,u,f,l,p,h,d;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,U(e,"w");case 2:if(s=t.sent,!(n||void 0===s.meta||o>s.meta.version)){t.next=43;break}if(!(i<0)){t.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=2,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=i+1,l=null;case 10:if(!(f>0)){t.next=38;break}return l=null,t.prev=12,t.next=15,fetch(r,{cache:"no-cache"});case 15:if(!(p=t.sent).ok){t.next=23;break}return t.next=19,p.arrayBuffer();case 19:return h=t.sent,t.next=22,s.write(new Uint8Array(h),o);case 22:return t.abrupt("return");case 23:return t.next=25,p.text();case 25:d=t.sent,l=new Error("Error response returned while fetching model from '".concat(r,"': ").concat(d)),t.next=32;break;case 29:t.prev=29,t.t0=t.catch(12),l=new Error("Failed to fetch model from '".concat(r,"': ").concat(t.t0.message));case 32:return f--,t.next=35,u(c);case 35:c=Math.min(5e3,2*c),t.next=10;break;case 38:if(null===l){t.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(r,"'"));case 43:case"end":return t.stop()}}),t,null,[[12,29]])})))).apply(this,arguments)}function $(t){return H.apply(this,arguments)}function H(){return(H=e(a.mark((function t(e){var r,n,o,i,s,c,u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e){t.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=e.base64,n=e.publicPath,o=e.customWritePath,i=e.forceWrite,s=void 0!==i&&i,c=e.version,u=void 0===c?1:c,f=e.numFetchRetries,l=void 0===f?0:f,null!=o){t.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){t.next=10;break}return t.next=8,G(o,r,s,u);case 8:case 13:t.next=16;break;case 10:if(null==n){t.next=15;break}return t.next=13,K(o,n,s,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return t.abrupt("return",o);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var J={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function Q(t,e,r){return X.apply(this,arguments)}function X(){return X=e(a.mark((function t(r,n,o){var i,s,c,u,p,h,d,v,y,_,m,w,g,E,b,k,P,O,S,T,A;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=new Uint8Array(r.buffer),s=new Int32Array(r.buffer),c=function(t){console.log(F(i,t))},u=function(t,e,r){if(0===t){var n=F(i,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},p=function(){return Date.now()/1e3},h=function(){var t=e(a.mark((function t(e,r,n,c,u,f,l,p,h){var d,v,y,_,m,w,g,E,b,x,k;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return d=F(i,e),v=F(i,r),y=F(i,n),_=F(i,c),m=F(i,u),w=Y(_),t.prev=6,t.next=9,D("https://"+v+y,{method:d,headers:w,body:m},f);case 9:g=t.sent,b=g.status,t.next=17;break;case 13:t.prev=13,t.t0=t.catch(6),null==o||o.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(t.t0)),b=0;case 17:if(void 0===g){t.next=38;break}return t.prev=18,t.next=21,g.text();case 21:E=t.sent,t.next=29;break;case 24:t.prev=24,t.t1=t.catch(18),null==o||o.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(t.t1)),E="",b=1;case 29:return t.next=31,A(Int8Array.BYTES_PER_ELEMENT,(E.length+1)*Int8Array.BYTES_PER_ELEMENT);case 31:if(0!==(x=t.sent)){t.next=34;break}throw new Error("malloc failed: Cannot allocate memory");case 34:for(s[p/Int32Array.BYTES_PER_ELEMENT]=E.length+1,s[l/Int32Array.BYTES_PER_ELEMENT]=x,k=0;k<E.length;k++)i[x+k]=E.charCodeAt(k);i[x+E.length]=0;case 38:s[h/Int32Array.BYTES_PER_ELEMENT]=b;case 39:case"end":return t.stop()}}),t,null,[[6,13],[18,24]])})));return function(e,r,n,o,a,i,s,c,u){return t.apply(this,arguments)}}(),d=function(){var t=e(a.mark((function t(e){var r,n,o;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=void 0!==navigator.userAgent?navigator.userAgent:"unknown",t.next=3,A(Uint8Array.BYTES_PER_ELEMENT,(r.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(n=t.sent)){t.next=6;break}throw new Error("malloc failed: Cannot allocate memory");case 6:for(s[e/Int32Array.BYTES_PER_ELEMENT]=n,o=0;o<r.length;o++)i[n+o]=r.charCodeAt(o);i[n+r.length]=0;case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),v=function(){var t=e(a.mark((function t(e){var r,n,o,c,u;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null!==(r=self.origin)&&void 0!==r?r:self.location.origin,o=new URL(n).hostname,t.next=4,A(Uint8Array.BYTES_PER_ELEMENT,(o.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(c=t.sent)){t.next=7;break}throw new Error("malloc failed: Cannot allocate memory");case 7:for(s[e/Int32Array.BYTES_PER_ELEMENT]=c,u=0;u<o.length;u++)i[c+u]=o.charCodeAt(u);i[c+o.length]=0;case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),y=function(){var t=e(a.mark((function t(e,r,n,c){var u,f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=F(i,r),f=F(i,n),t.prev=2,t.next=5,U(u,f);case 5:l=t.sent,x.setPtr(e,l),s[c/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(2),"FileNotExists"!==t.t0.name&&(null==o||o.addError("pvFileOpenWasm",t.t0)),s[c/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,r,n,o){return t.apply(this,arguments)}}(),_=function(){var t=e(a.mark((function t(e,r){var n;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,x.getPtr(e);case 3:return n=t.sent,t.next=6,n.close();case 6:s[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=13;break;case 9:t.prev=9,t.t0=t.catch(0),null==o||o.addError("pvFileCloseWasm",t.t0),s[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return t.stop()}}),t,null,[[0,9]])})));return function(e,r){return t.apply(this,arguments)}}(),m=function(){var t=e(a.mark((function t(e,r,n,c,u){var f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,x.getPtr(e);case 3:return f=t.sent,t.next=6,f.read(n,c);case 6:l=t.sent,i.set(l,r),s[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileReadWasm",t.t0),s[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),w=function(){var t=e(a.mark((function t(e,r,n,c,u){var f,l;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,x.getPtr(e);case 3:return f=t.sent,(l=new Uint8Array(n*c)).set(i.slice(r,r+n*c),0),t.next=8,f.write(l);case 8:s[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileWriteWasm",t.t0),s[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),g=function(t,e,r,n){try{x.getPtr(t).seek(e,r),s[n/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==o||o.addError("pvFileSeekWasm",t),s[n/Int32Array.BYTES_PER_ELEMENT]=-1}},E=function(t,e){try{var r=x.getPtr(t);s[e/Int32Array.BYTES_PER_ELEMENT]=r.tell()}catch(t){null==o||o.addError("pvFileTellWasm",t),s[e/Int32Array.BYTES_PER_ELEMENT]=-1}},b=function(){var t=e(a.mark((function t(e,r){var n,c;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=F(i,e),t.prev=1,t.next=4,U(n,"w");case 4:return c=t.sent,t.next=7,c.remove();case 7:s[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),null==o||o.addError("pvFileRemoveWasm",t.t0),s[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e,r){return t.apply(this,arguments)}}(),k={wasi_snapshot_preview1:J,env:{memory:r,pv_console_log_wasm:c,pv_assert_wasm:u,pv_time_wasm:p,pv_https_request_wasm:h,pv_get_browser_info:d,pv_get_origin_info:v,pv_file_open_wasm:y,pv_file_close_wasm:_,pv_file_read_wasm:m,pv_file_write_wasm:w,pv_file_seek_wasm:g,pv_file_tell_wasm:E,pv_file_remove_wasm:b}},!(n instanceof Promise)){t.next=34;break}if(!l){t.next=23;break}return t.next=20,l(n,k);case 20:P=t.sent.instance,t.next=32;break;case 23:return t.next=25,n;case 25:return O=t.sent,t.next=28,O.arrayBuffer();case 28:return S=t.sent,t.next=31,f(new Uint8Array(S),k);case 31:P=t.sent.instance;case 32:t.next=38;break;case 34:return T=R(n),t.next=37,f(T,k);case 37:P=t.sent.instance;case 38:return A=P.exports.aligned_alloc,t.abrupt("return",P.exports);case 40:case"end":return t.stop()}}),t)}))),X.apply(this,arguments)}function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function tt(t){return function(t){if(Array.isArray(t))return Z(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Z(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var et=function(){function t(){h(this,t),p(this,"_maxNumErrors",10),p(this,"_errors",[]),p(this,"_lastError",void 0)}return v(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=tt(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),rt={DB_NAME:P,DB_VERSION:3,PV_FILE_STORE:O};export{et as PvError,x as PvFile,T as PvFileIDB,j as PvFileMem,B as arrayBufferToBase64AtIndex,F as arrayBufferToStringAtIndex,R as base64ToUint8Array,Q as buildWasm,rt as dbConfig,D as fetchWithTimeout,G as fromBase64,K as fromPublicDirectory,S as getDB,W as isAccessKeyValid,$ as loadModel,U as open,Y as stringHeaderToObject};
function t(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function e(e){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=e.apply(r,n);function s(e){t(i,o,a,s,c,"next",e)}function c(e){t(i,o,a,s,c,"throw",e)}s(void 0)}))}}function r(t){var e={exports:{}};return t(e,e.exports),e.exports}var n=r((function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})),o=r((function(t){var e=n.default;function r(){t.exports=r=function(){return n},t.exports.__esModule=!0,t.exports.default=t.exports;var n={},o=Object.prototype,a=o.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),s=new T(n||[]);return i(a,"_invoke",{value:k(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=p;var v={};function d(){}function y(){}function _(){}var m={};l(m,c,(function(){return this}));var g=Object.getPrototypeOf,w=g&&g(g(j([])));w&&w!==o&&a.call(w,c)&&(m=w);var E=_.prototype=d.prototype=Object.create(m);function b(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,r){function n(o,i,s,c){var u=h(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;i(this,"_invoke",{value:function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}})}function k(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return A()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=P(i,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===v)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function P(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,P(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function j(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(a.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:A}}function A(){return{value:void 0,done:!0}}return y.prototype=_,i(E,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:y,configurable:!0}),y.displayName=l(_,f,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,f,"GeneratorFunction")),t.prototype=Object.create(E),t},n.awrap=function(t){return{__await:t}},b(x.prototype),l(x.prototype,u,(function(){return this})),n.AsyncIterator=x,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new x(p(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},b(E),l(E,f,"Generator"),l(E,c,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=j,T.prototype={constructor:T,reset:function(t){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(S),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),a=o(),i=a;try{regeneratorRuntime=a}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=a:Function("r","regeneratorRuntime = r")(a)}const s=new WeakMap;function c(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class u{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return c(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return c(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=s.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},s.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return s.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,f.prototype)}}class f extends WebAssembly.Instance{constructor(t,e){let r=new u;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return s.get(super.exports)}}async function l(t,e){let r=new u,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function p(t,e){let r=new u,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function v(t){var e=function(t,e){if("object"!==h(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===h(e)?e:String(e)}function d(t,e,r){return(e=v(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,v(n.key),n)}}function m(t,e,r){return e&&_(t.prototype,e),r&&_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function E(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&w(t,e)}function b(t,e){if(e&&("object"===h(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return g(t)}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}function k(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}Object.defineProperty(f.prototype,"exports",{enumerable:!0});var P=function(){function t(){y(this,t),d(this,"_path",void 0),d(this,"_meta",void 0)}return m(t,[{key:"meta",get:function(){if(void 0!==this._meta)return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?k(Object(r),!0).forEach((function(e){d(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({version:0},this._meta)}}],[{key:"getPtr",value:function(e){return t._filePtrs.get(e)}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function O(t){var e=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(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}d(P,"_filePtrs",new Map);var S="pv_db",T="pv_file",j=3;function A(){return new Promise((function(t,e){var r=self.indexedDB.open(S,j);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(T)||r.result.createObjectStore(T)}}))}var I=function(t){E(c,P);var r,n,o,a,s=O(c);function c(t,e,r,n){var o;return y(this,c),d(g(o=s.call(this)),"_pageSize",65536),d(g(o),"_db",void 0),d(g(o),"_mode",void 0),d(g(o),"_pagePtr",0),d(g(o),"_pageOffset",0),o._path=t,o._meta=e,o._db=r,o._mode=n,o}return m(c,[{key:"close",value:(a=e(i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"read",value:(o=e(i.mark((function t(e,r){var n=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,o){if(n.exists()){if(n._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void o(a)}var i=0,s=Math.min(e*r,n._meta.size),u=s-s%e,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(n._path,"-").concat(c.createPage(n._pagePtr)),"".concat(n._path,"-").concat(c.createPage(n._meta.numPages))),p=n._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!n._isEOF){var e=Math.min(u-i,t.value.length-n._pageOffset);f.set(t.value.slice(n._pageOffset,n._pageOffset+e),i),i+=e,n._pageOffset+=e,n._pageOffset===n._pageSize&&(n._pagePtr+=1,n._pageOffset=0),i<u&&t.continue()}},p.transaction.onerror=function(){o(p.transaction.error)},p.transaction.oncomplete=function(){t(f.slice(0,i))}}else o(new Error("'".concat(n._path,"' doesn't exist.")))})));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return o.apply(this,arguments)})},{key:"write",value:(n=e(i.mark((function t(r){var n,o=this,a=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:1,t.abrupt("return",new Promise(function(){var t=e(i.mark((function t(e,a){var s,u,f,l,p,h,v,d,y;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("readonly"!==o._mode){t.next=3;break}return a(new Error("Instance is readonly mode only.")),t.abrupt("return");case 3:if(!("number"!=typeof n&&n<=0)){t.next=6;break}return a(new Error("Version should be a positive number")),t.abrupt("return");case 6:return s=o._store,u=function(){return new Promise((function(t){var e=s.get("".concat(o._path,"-").concat(c.createPage(o._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,o._pageOffset)):t(new Uint8Array(0))}}))},t.next=10,u();case 10:for(f=t.sent,(l=new Uint8Array(f.length+r.length)).set(f),l.set(r,f.length),p=o._pagePtr*o._pageSize+l.length,h={size:p,numPages:Math.ceil(p/o._pageSize),version:n},s.put(h,o._path),v=Math.ceil(l.length/o._pageSize),d=0;d<v;d++)s.put(l.slice(d*o._pageSize,(d+1)*o._pageSize),"".concat(o._path,"-").concat(c.createPage(o._pagePtr+d)));o.exists()&&h.numPages<o._meta.numPages&&(y=IDBKeyRange.bound("".concat(o._path,"-").concat(c.createPage(h.numPages)),"".concat(o._path,"-").concat(c.createPage(o._meta.numPages)),!0),s.delete(y)),s.transaction.onerror=function(){a(s.transaction.error)},s.transaction.oncomplete=function(){o._meta=h,o.seek(0,2),e()};case 22:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:(r=e(i.mark((function t(){var r=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=e(i.mark((function t(e,n){var o,a,s,u;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=r._meta.numPages,a=IDBKeyRange.bound(r._path,"".concat(r._path,"-").concat(c.createPage(o))),s=r._store,(u=s.delete(a)).onerror=function(){n(u.error)},u.onsuccess=function(){r._meta=void 0,r._pageOffset=0,r._pagePtr=0,e()};case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(T,this._mode).objectStore(T)}}],[{key:"open",value:function(t,r){if(!self.indexedDB){var n=new Error("IndexedDB is not supported");throw n.name="IndexedDBNotSupported",n}return new Promise(function(){var n=e(i.mark((function e(n,o){var a,s,u;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,A();case 3:a=e.sent,(s=a.transaction(T,"readwrite").objectStore(T).get(t)).onerror=function(){o(s.error)},s.onsuccess=function(){var e=s.result,i=r.includes("r")?"readonly":"readwrite";if(void 0===e&&"readonly"===i){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void o(u)}var f=new c(t,e,a,i);r.includes("a")&&f.seek(0,2),n(f)},e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),"InvalidStateError"===e.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",o(u)):o(e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"createPage",value:function(t){return("000"+t).slice(-4)}}]),c}();function L(t){var e=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(t){return!1}}();return function(){var r,n=x(t);if(e){var o=x(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return b(this,r)}}var N=function(t){E(o,P);var r,n=L(o);function o(t,e,r,a){var i;return y(this,o),d(g(i=n.call(this)),"_pos",0),d(g(i),"_mode",void 0),i._path=t,i._meta=e,i._mode=a,i}return m(o,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,a=new Uint8Array(o);return a.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,a}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:(r=e(i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o._memFiles.delete(this._path),this._file=void 0,this._pos=0;case 3:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return o._memFiles.get(this._path)},set:function(t){o._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var r=o._memFiles.get(t),n=e.includes("r")?"readonly":"readwrite";if(void 0===r&&"readonly"===n){var a=new Error("'".concat(t,"' doesn't exist."));throw a.name="FileNotExists",a}var i=new o(t,void 0,void 0,n);return e.includes("a")&&i.seek(0,2),i}}]),o}();function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function R(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach((function(e){d(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function F(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return B(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return B(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function B(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Y(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function D(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function z(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)}function W(t){var e,r={},n=F(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function U(t){return C.apply(this,arguments)}function C(){return C=e(i.mark((function t(e){var r,n,o,a,s,c,u=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=u.length>2&&void 0!==u[2]?u[2]:5e3,o=new AbortController,a=R(R({},r),{},{signal:o.signal}),s=setTimeout((function(){o.abort()}),n),t.next=7,fetch(e,a);case 7:return c=t.sent,clearTimeout(s),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)}))),C.apply(this,arguments)}function G(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}}function q(t,e){return H.apply(this,arguments)}function H(){return(H=e(i.mark((function t(e,r){var n;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,I.open(e,r);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),"IndexedDBNotSupported"===t.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==t.t0.name&&console.warn("Unable to access IndexedDB (".concat(t.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){t.next=16;break}if("FileNotExists"!==t.t0.name){t.next=12;break}throw t.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(t.t0.toString()))).name="PvFileNotSupported",n;case 16:return t.abrupt("return",N.open(e,r));case 17:case"end":return t.stop()}}),t,null,[[0,6]])})))).apply(this,arguments)}function K(t,e,r,n){return V.apply(this,arguments)}function V(){return(V=e(i.mark((function t(e,r,n,o){var a;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,q(e,"w");case 2:if(a=t.sent,!(n||void 0===a.meta||o>a.meta.version)){t.next=6;break}return t.next=6,a.write(D(r),o);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}d(N,"_memFiles",new Map);var $=5e3,J=2;function Q(t,e,r,n,o){return X.apply(this,arguments)}function X(){return(X=e(i.mark((function t(e,r,n,o,a){var s,c,u,f,l,p,h,v;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,q(e,"w");case 2:if(s=t.sent,!(n||void 0===s.meta||o>s.meta.version)){t.next=43;break}if(!(a<0)){t.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=J,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=a+1,l=null;case 10:if(!(f>0)){t.next=38;break}return l=null,t.prev=12,t.next=15,fetch(r,{cache:"no-cache"});case 15:if(!(p=t.sent).ok){t.next=23;break}return t.next=19,p.arrayBuffer();case 19:return h=t.sent,t.next=22,s.write(new Uint8Array(h),o);case 22:return t.abrupt("return");case 23:return t.next=25,p.text();case 25:v=t.sent,l=new Error("Error response returned while fetching model from '".concat(r,"': ").concat(v)),t.next=32;break;case 29:t.prev=29,t.t0=t.catch(12),l=new Error("Failed to fetch model from '".concat(r,"': ").concat(t.t0.message));case 32:return f--,t.next=35,u(c);case 35:c=Math.min($,c*J),t.next=10;break;case 38:if(null===l){t.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(r,"'"));case 43:case"end":return t.stop()}}),t,null,[[12,29]])})))).apply(this,arguments)}function Z(t){return tt.apply(this,arguments)}function tt(){return(tt=e(i.mark((function t(e){var r,n,o,a,s,c,u,f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e){t.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=e.base64,n=e.publicPath,o=e.customWritePath,a=e.forceWrite,s=void 0!==a&&a,c=e.version,u=void 0===c?1:c,f=e.numFetchRetries,l=void 0===f?0:f,null!=o){t.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){t.next=10;break}return t.next=8,K(o,r,s,u);case 8:case 13:t.next=16;break;case 10:if(null==n){t.next=15;break}return t.next=13,Q(o,n,s,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return t.abrupt("return",o);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var et={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function rt(t,e,r){return nt.apply(this,arguments)}function nt(){return nt=e(i.mark((function t(r,n,o){var a,s,c,u,f,h,v,d,y,_,m,g,w,E,b,x,k,O,S,T,j;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=new Uint8Array(r.buffer),s=new Int32Array(r.buffer),c=function(t){console.log(Y(a,t))},u=function(t,e,r){if(0===t){var n=Y(a,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},f=function(){return Date.now()/1e3},h=function(){var t=e(i.mark((function t(e,r,n,c,u,f,l,p,h){var v,d,y,_,m,g,w,E,b,x,k;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return v=Y(a,e),d=Y(a,r),y=Y(a,n),_=Y(a,c),m=Y(a,u),g=W(_),t.prev=6,t.next=9,U("https://"+d+y,{method:v,headers:g,body:m},f);case 9:w=t.sent,b=w.status,t.next=17;break;case 13:t.prev=13,t.t0=t.catch(6),null==o||o.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(t.t0)),b=0;case 17:if(void 0===w){t.next=40;break}return t.prev=18,t.next=21,w.text();case 21:E=t.sent,t.next=29;break;case 24:t.prev=24,t.t1=t.catch(18),null==o||o.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(t.t1)),E="",b=1;case 29:return t.next=31,j(Int8Array.BYTES_PER_ELEMENT,(E.length+1)*Int8Array.BYTES_PER_ELEMENT);case 31:if(0!==(x=t.sent)){t.next=36;break}return null==o||o.addError("pvMallocError","pvHttpsRequestWasm: cannot allocate memory for response"),s[l/Int32Array.BYTES_PER_ELEMENT]=0,t.abrupt("return");case 36:for(s[p/Int32Array.BYTES_PER_ELEMENT]=E.length+1,s[l/Int32Array.BYTES_PER_ELEMENT]=x,k=0;k<E.length;k++)a[x+k]=E.charCodeAt(k);a[x+E.length]=0;case 40:s[h/Int32Array.BYTES_PER_ELEMENT]=b;case 41:case"end":return t.stop()}}),t,null,[[6,13],[18,24]])})));return function(e,r,n,o,a,i,s,c,u){return t.apply(this,arguments)}}(),v=function(){var t=e(i.mark((function t(e){var r,n,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=void 0!==navigator.userAgent?navigator.userAgent:"unknown",t.next=3,j(Uint8Array.BYTES_PER_ELEMENT,(r.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(n=t.sent)){t.next=8;break}return null==o||o.addError("pvMallocError","pvGetBrowserInfo: cannot allocate memory for browser info"),s[e/Int32Array.BYTES_PER_ELEMENT]=0,t.abrupt("return");case 8:for(s[e/Int32Array.BYTES_PER_ELEMENT]=n,c=0;c<r.length;c++)a[n+c]=r.charCodeAt(c);a[n+r.length]=0;case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),d=function(){var t=e(i.mark((function t(e){var r,n,c,u,f;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null!==(r=self.origin)&&void 0!==r?r:self.location.origin,c=new URL(n).hostname,t.next=4,j(Uint8Array.BYTES_PER_ELEMENT,(c.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(u=t.sent)){t.next=9;break}return null==o||o.addError("pvMallocError","pvGetOriginInfo: cannot allocate memory for origin info"),s[e/Int32Array.BYTES_PER_ELEMENT]=0,t.abrupt("return");case 9:for(s[e/Int32Array.BYTES_PER_ELEMENT]=u,f=0;f<c.length;f++)a[u+f]=c.charCodeAt(f);a[u+c.length]=0;case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),y=function(){var t=e(i.mark((function t(e,r,n,c){var u,f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=Y(a,r),f=Y(a,n),t.prev=2,t.next=5,q(u,f);case 5:l=t.sent,P.setPtr(e,l),s[c/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(2),"FileNotExists"!==t.t0.name&&(null==o||o.addError("pvFileOpenWasm",t.t0)),s[c/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,r,n,o){return t.apply(this,arguments)}}(),_=function(){var t=e(i.mark((function t(e,r){var n;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,P.getPtr(e);case 3:return n=t.sent,t.next=6,n.close();case 6:s[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=13;break;case 9:t.prev=9,t.t0=t.catch(0),null==o||o.addError("pvFileCloseWasm",t.t0),s[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return t.stop()}}),t,null,[[0,9]])})));return function(e,r){return t.apply(this,arguments)}}(),m=function(){var t=e(i.mark((function t(e,r,n,c,u){var f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,P.getPtr(e);case 3:return f=t.sent,t.next=6,f.read(n,c);case 6:l=t.sent,a.set(l,r),s[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileReadWasm",t.t0),s[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),g=function(){var t=e(i.mark((function t(e,r,n,c,u){var f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,P.getPtr(e);case 3:return f=t.sent,(l=new Uint8Array(n*c)).set(a.slice(r,r+n*c),0),t.next=8,f.write(l);case 8:s[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileWriteWasm",t.t0),s[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),w=function(t,e,r,n){try{P.getPtr(t).seek(e,r),s[n/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==o||o.addError("pvFileSeekWasm",t),s[n/Int32Array.BYTES_PER_ELEMENT]=-1}},E=function(t,e){try{var r=P.getPtr(t);s[e/Int32Array.BYTES_PER_ELEMENT]=r.tell()}catch(t){null==o||o.addError("pvFileTellWasm",t),s[e/Int32Array.BYTES_PER_ELEMENT]=-1}},b=function(){var t=e(i.mark((function t(e,r){var n,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=Y(a,e),t.prev=1,t.next=4,q(n,"w");case 4:return c=t.sent,t.next=7,c.remove();case 7:s[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),null==o||o.addError("pvFileRemoveWasm",t.t0),s[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e,r){return t.apply(this,arguments)}}(),x={wasi_snapshot_preview1:et,env:{memory:r,pv_console_log_wasm:c,pv_assert_wasm:u,pv_time_wasm:f,pv_https_request_wasm:h,pv_get_browser_info:v,pv_get_origin_info:d,pv_file_open_wasm:y,pv_file_close_wasm:_,pv_file_read_wasm:m,pv_file_write_wasm:g,pv_file_seek_wasm:w,pv_file_tell_wasm:E,pv_file_remove_wasm:b}},!(n instanceof Promise)){t.next=34;break}if(!p){t.next=23;break}return t.next=20,p(n,x);case 20:k=t.sent.instance,t.next=32;break;case 23:return t.next=25,n;case 25:return O=t.sent,t.next=28,O.arrayBuffer();case 28:return S=t.sent,t.next=31,l(new Uint8Array(S),x);case 31:k=t.sent.instance;case 32:t.next=38;break;case 34:return T=D(n),t.next=37,l(T,x);case 37:k=t.sent.instance;case 38:return j=k.exports.aligned_alloc,t.abrupt("return",k.exports);case 40:case"end":return t.stop()}}),t)}))),nt.apply(this,arguments)}function ot(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function at(t){return function(t){if(Array.isArray(t))return ot(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return ot(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ot(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var it=function(){function t(){y(this,t),d(this,"_maxNumErrors",10),d(this,"_errors",[]),d(this,"_lastError",void 0)}return m(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=at(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),st={DB_NAME:S,DB_VERSION:j,PV_FILE_STORE:T};export{it as PvError,P as PvFile,I as PvFileIDB,N as PvFileMem,z as arrayBufferToBase64AtIndex,Y as arrayBufferToStringAtIndex,D as base64ToUint8Array,rt as buildWasm,st as dbConfig,U as fetchWithTimeout,K as fromBase64,Q as fromPublicDirectory,A as getDB,G as isAccessKeyValid,Z as loadModel,q as open,W as stringHeaderToObject};

@@ -1,3 +0,1 @@

var WebUtils=function(t){"use strict";function e(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function s(t){e(i,o,a,s,c,"next",t)}function c(t){e(i,o,a,s,c,"throw",t)}s(void 0)}))}}function n(t){var e={exports:{}};return t(e,e.exports),e.exports}var o=n((function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})),a=n((function(t){var e=o.default;function r(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
t.exports=r=function(){return n},t.exports.__esModule=!0,t.exports.default=t.exports;var n={},o=Object.prototype,a=o.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),i=new O(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return T()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=x(i,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=p(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=l;var h={};function d(){}function v(){}function y(){}var _={};f(_,s,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(S([])));w&&w!==o&&a.call(w,s)&&(_=w);var g=y.prototype=d.prototype=Object.create(_);function E(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,r){function n(o,i,s,c){var u=p(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;this._invoke=function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=p(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(a.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=y,f(g,"constructor",y),f(y,"constructor",v),v.displayName=f(y,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,f(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},n.awrap=function(t){return{__await:t}},E(b.prototype),f(b.prototype,c,(function(){return this})),n.AsyncIterator=b,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new b(l(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},E(g),f(g,u,"Generator"),f(g,s,(function(){return this})),f(g,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},n.values=S,O.prototype={constructor:O,reset:function(t){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(P),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,h):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),i=a();const s=new WeakMap;function c(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class u{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return c(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return c(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=s.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},s.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return s.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,f.prototype)}}class f extends WebAssembly.Instance{constructor(t,e){let r=new u;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return s.get(super.exports)}}async function l(t,e){let r=new u,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function p(t,e){let r=new u,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function h(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function y(t,e,r){return e&&v(t.prototype,e),r&&v(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){return m=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},m(t,e)}function w(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function E(t,e){if(e&&("object"===g(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _(t)}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}function x(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}Object.defineProperty(f.prototype,"exports",{enumerable:!0});var k=function(){function t(){d(this,t),h(this,"_path",void 0),h(this,"_meta",void 0)}return y(t,[{key:"meta",get:function(){if(void 0!==this._meta)return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?x(Object(r),!0).forEach((function(e){h(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({version:0},this._meta)}}],[{key:"getPtr",value:function(e){return t._filePtrs.get(e)}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function P(t){var e=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(t){return!1}}();return function(){var r,n=b(t);if(e){var o=b(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return E(this,r)}}h(k,"_filePtrs",new Map);var O="pv_db",S="pv_file";function T(){return new Promise((function(t,e){var r=self.indexedDB.open(O,3);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(S)||r.result.createObjectStore(S)}}))}var A=function(t){w(c,t);var e,n,o,a,s=P(c);function c(t,e,r,n){var o;return d(this,c),h(_(o=s.call(this)),"_pageSize",65536),h(_(o),"_db",void 0),h(_(o),"_mode",void 0),h(_(o),"_pagePtr",0),h(_(o),"_pageOffset",0),o._path=t,o._meta=e,o._db=r,o._mode=n,o}return y(c,[{key:"close",value:(a=r(i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"read",value:(o=r(i.mark((function t(e,r){var n=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,o){if(n.exists()){if(n._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void o(a)}var i=0,s=Math.min(e*r,n._meta.size),u=s-s%e,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(n._path,"-").concat(c.createPage(n._pagePtr)),"".concat(n._path,"-").concat(c.createPage(n._meta.numPages))),p=n._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!n._isEOF){var e=Math.min(u-i,t.value.length-n._pageOffset);f.set(t.value.slice(n._pageOffset,n._pageOffset+e),i),i+=e,n._pageOffset+=e,n._pageOffset===n._pageSize&&(n._pagePtr+=1,n._pageOffset=0),i<u&&t.continue()}},p.transaction.onerror=function(){o(p.transaction.error)},p.transaction.oncomplete=function(){t(f.slice(0,i))}}else o(new Error("'".concat(n._path,"' doesn't exist.")))})));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return o.apply(this,arguments)})},{key:"write",value:(n=r(i.mark((function t(e){var n,o=this,a=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:1,t.abrupt("return",new Promise(function(){var t=r(i.mark((function t(r,a){var s,u,f,l,p,h,d,v,y;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("readonly"!==o._mode){t.next=3;break}return a(new Error("Instance is readonly mode only.")),t.abrupt("return");case 3:if(!("number"!=typeof n&&n<=0)){t.next=6;break}return a(new Error("Version should be a positive number")),t.abrupt("return");case 6:return s=o._store,u=function(){return new Promise((function(t){var e=s.get("".concat(o._path,"-").concat(c.createPage(o._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,o._pageOffset)):t(new Uint8Array(0))}}))},t.next=10,u();case 10:for(f=t.sent,(l=new Uint8Array(f.length+e.length)).set(f),l.set(e,f.length),p=o._pagePtr*o._pageSize+l.length,h={size:p,numPages:Math.ceil(p/o._pageSize),version:n},s.put(h,o._path),d=Math.ceil(l.length/o._pageSize),v=0;v<d;v++)s.put(l.slice(v*o._pageSize,(v+1)*o._pageSize),"".concat(o._path,"-").concat(c.createPage(o._pagePtr+v)));o.exists()&&h.numPages<o._meta.numPages&&(y=IDBKeyRange.bound("".concat(o._path,"-").concat(c.createPage(h.numPages)),"".concat(o._path,"-").concat(c.createPage(o._meta.numPages)),!0),s.delete(y)),s.transaction.onerror=function(){a(s.transaction.error)},s.transaction.oncomplete=function(){o._meta=h,o.seek(0,2),r()};case 22:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:(e=r(i.mark((function t(){var e=this;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=r(i.mark((function t(r,n){var o,a,s,u;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=e._meta.numPages,a=IDBKeyRange.bound(e._path,"".concat(e._path,"-").concat(c.createPage(o))),s=e._store,(u=s.delete(a)).onerror=function(){n(u.error)},u.onsuccess=function(){e._meta=void 0,e._pageOffset=0,e._pagePtr=0,r()};case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}}),t)}))),function(){return e.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(S,this._mode).objectStore(S)}}],[{key:"open",value:function(t,e){if(!self.indexedDB){var n=new Error("IndexedDB is not supported");throw n.name="IndexedDBNotSupported",n}return new Promise(function(){var n=r(i.mark((function r(n,o){var a,s,u;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,T();case 3:a=r.sent,(s=a.transaction(S,"readwrite").objectStore(S).get(t)).onerror=function(){o(s.error)},s.onsuccess=function(){var r=s.result,i=e.includes("r")?"readonly":"readwrite";if(void 0===r&&"readonly"===i){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void o(u)}var f=new c(t,r,a,i);e.includes("a")&&f.seek(0,2),n(f)},r.next=12;break;case 9:r.prev=9,r.t0=r.catch(0),"InvalidStateError"===r.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",o(u)):o(r.t0);case 12:case"end":return r.stop()}}),r,null,[[0,9]])})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"createPage",value:function(t){return("000"+t).slice(-4)}}]),c}(k);function j(t){var e=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(t){return!1}}();return function(){var r,n=b(t);if(e){var o=b(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return E(this,r)}}var I=function(t){w(o,t);var e,n=j(o);function o(t,e,r,a){var i;return d(this,o),h(_(i=n.call(this)),"_pos",0),h(_(i),"_mode",void 0),i._path=t,i._meta=e,i._mode=a,i}return y(o,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,a=new Uint8Array(o);return a.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,a}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:(e=r(i.mark((function t(){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o._memFiles.delete(this._path),this._file=void 0,this._pos=0;case 3:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return o._memFiles.get(this._path)},set:function(t){o._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var r=o._memFiles.get(t),n=e.includes("r")?"readonly":"readwrite";if(void 0===r&&"readonly"===n){var a=new Error("'".concat(t,"' doesn't exist."));throw a.name="FileNotExists",a}var i=new o(t,void 0,void 0,n);return e.includes("a")&&i.seek(0,2),i}}]),o}(k);function L(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function N(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?L(Object(r),!0).forEach((function(e){h(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function M(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return F(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function B(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function R(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function D(t){var e,r={},n=M(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function Y(t){return W.apply(this,arguments)}function W(){return W=r(i.mark((function t(e){var r,n,o,a,s,c,u=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=u.length>2&&void 0!==u[2]?u[2]:5e3,o=new AbortController,a=N(N({},r),{},{signal:o.signal}),s=setTimeout((function(){o.abort()}),n),t.next=7,fetch(e,a);case 7:return c=t.sent,clearTimeout(s),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)}))),W.apply(this,arguments)}function z(t,e){return U.apply(this,arguments)}function U(){return(U=r(i.mark((function t(e,r){var n;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,A.open(e,r);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),"IndexedDBNotSupported"===t.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==t.t0.name&&console.warn("Unable to access IndexedDB (".concat(t.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){t.next=16;break}if("FileNotExists"!==t.t0.name){t.next=12;break}throw t.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(t.t0.toString()))).name="PvFileNotSupported",n;case 16:return t.abrupt("return",I.open(e,r));case 17:case"end":return t.stop()}}),t,null,[[0,6]])})))).apply(this,arguments)}function C(t,e,r,n){return G.apply(this,arguments)}function G(){return(G=r(i.mark((function t(e,r,n,o){var a;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,z(e,"w");case 2:if(a=t.sent,!(n||void 0===a.meta||o>a.meta.version)){t.next=6;break}return t.next=6,a.write(R(r),o);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}h(I,"_memFiles",new Map);function K(t,e,r,n,o){return V.apply(this,arguments)}function V(){return(V=r(i.mark((function t(e,r,n,o,a){var s,c,u,f,l,p,h,d;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,z(e,"w");case 2:if(s=t.sent,!(n||void 0===s.meta||o>s.meta.version)){t.next=43;break}if(!(a<0)){t.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=2,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=a+1,l=null;case 10:if(!(f>0)){t.next=38;break}return l=null,t.prev=12,t.next=15,fetch(r,{cache:"no-cache"});case 15:if(!(p=t.sent).ok){t.next=23;break}return t.next=19,p.arrayBuffer();case 19:return h=t.sent,t.next=22,s.write(new Uint8Array(h),o);case 22:return t.abrupt("return");case 23:return t.next=25,p.text();case 25:d=t.sent,l=new Error("Error response returned while fetching model from '".concat(r,"': ").concat(d)),t.next=32;break;case 29:t.prev=29,t.t0=t.catch(12),l=new Error("Failed to fetch model from '".concat(r,"': ").concat(t.t0.message));case 32:return f--,t.next=35,u(c);case 35:c=Math.min(5e3,2*c),t.next=10;break;case 38:if(null===l){t.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(r,"'"));case 43:case"end":return t.stop()}}),t,null,[[12,29]])})))).apply(this,arguments)}function q(){return(q=r(i.mark((function t(e){var r,n,o,a,s,c,u,f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e){t.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=e.base64,n=e.publicPath,o=e.customWritePath,a=e.forceWrite,s=void 0!==a&&a,c=e.version,u=void 0===c?1:c,f=e.numFetchRetries,l=void 0===f?0:f,null!=o){t.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){t.next=10;break}return t.next=8,C(o,r,s,u);case 8:case 13:t.next=16;break;case 10:if(null==n){t.next=15;break}return t.next=13,K(o,n,s,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return t.abrupt("return",o);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var H={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function $(){return $=r(i.mark((function t(e,n,o){var a,s,c,u,f,h,d,v,y,_,m,w,g,E,b,x,P,O,S,T,A;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=new Uint8Array(e.buffer),s=new Int32Array(e.buffer),c=function(t){console.log(B(a,t))},u=function(t,e,r){if(0===t){var n=B(a,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},f=function(){return Date.now()/1e3},h=function(){var t=r(i.mark((function t(e,r,n,c,u,f,l,p,h){var d,v,y,_,m,w,g,E,b,x,k;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return d=B(a,e),v=B(a,r),y=B(a,n),_=B(a,c),m=B(a,u),w=D(_),t.prev=6,t.next=9,Y("https://"+v+y,{method:d,headers:w,body:m},f);case 9:g=t.sent,b=g.status,t.next=17;break;case 13:t.prev=13,t.t0=t.catch(6),null==o||o.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(t.t0)),b=0;case 17:if(void 0===g){t.next=38;break}return t.prev=18,t.next=21,g.text();case 21:E=t.sent,t.next=29;break;case 24:t.prev=24,t.t1=t.catch(18),null==o||o.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(t.t1)),E="",b=1;case 29:return t.next=31,A(Int8Array.BYTES_PER_ELEMENT,(E.length+1)*Int8Array.BYTES_PER_ELEMENT);case 31:if(0!==(x=t.sent)){t.next=34;break}throw new Error("malloc failed: Cannot allocate memory");case 34:for(s[p/Int32Array.BYTES_PER_ELEMENT]=E.length+1,s[l/Int32Array.BYTES_PER_ELEMENT]=x,k=0;k<E.length;k++)a[x+k]=E.charCodeAt(k);a[x+E.length]=0;case 38:s[h/Int32Array.BYTES_PER_ELEMENT]=b;case 39:case"end":return t.stop()}}),t,null,[[6,13],[18,24]])})));return function(e,r,n,o,a,i,s,c,u){return t.apply(this,arguments)}}(),d=function(){var t=r(i.mark((function t(e){var r,n,o;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=void 0!==navigator.userAgent?navigator.userAgent:"unknown",t.next=3,A(Uint8Array.BYTES_PER_ELEMENT,(r.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(n=t.sent)){t.next=6;break}throw new Error("malloc failed: Cannot allocate memory");case 6:for(s[e/Int32Array.BYTES_PER_ELEMENT]=n,o=0;o<r.length;o++)a[n+o]=r.charCodeAt(o);a[n+r.length]=0;case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),v=function(){var t=r(i.mark((function t(e){var r,n,o,c,u;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null!==(r=self.origin)&&void 0!==r?r:self.location.origin,o=new URL(n).hostname,t.next=4,A(Uint8Array.BYTES_PER_ELEMENT,(o.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(c=t.sent)){t.next=7;break}throw new Error("malloc failed: Cannot allocate memory");case 7:for(s[e/Int32Array.BYTES_PER_ELEMENT]=c,u=0;u<o.length;u++)a[c+u]=o.charCodeAt(u);a[c+o.length]=0;case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),y=function(){var t=r(i.mark((function t(e,r,n,c){var u,f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=B(a,r),f=B(a,n),t.prev=2,t.next=5,z(u,f);case 5:l=t.sent,k.setPtr(e,l),s[c/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(2),"FileNotExists"!==t.t0.name&&(null==o||o.addError("pvFileOpenWasm",t.t0)),s[c/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,r,n,o){return t.apply(this,arguments)}}(),_=function(){var t=r(i.mark((function t(e,r){var n;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,k.getPtr(e);case 3:return n=t.sent,t.next=6,n.close();case 6:s[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=13;break;case 9:t.prev=9,t.t0=t.catch(0),null==o||o.addError("pvFileCloseWasm",t.t0),s[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return t.stop()}}),t,null,[[0,9]])})));return function(e,r){return t.apply(this,arguments)}}(),m=function(){var t=r(i.mark((function t(e,r,n,c,u){var f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,k.getPtr(e);case 3:return f=t.sent,t.next=6,f.read(n,c);case 6:l=t.sent,a.set(l,r),s[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileReadWasm",t.t0),s[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),w=function(){var t=r(i.mark((function t(e,r,n,c,u){var f,l;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,k.getPtr(e);case 3:return f=t.sent,(l=new Uint8Array(n*c)).set(a.slice(r,r+n*c),0),t.next=8,f.write(l);case 8:s[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileWriteWasm",t.t0),s[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),g=function(t,e,r,n){try{k.getPtr(t).seek(e,r),s[n/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==o||o.addError("pvFileSeekWasm",t),s[n/Int32Array.BYTES_PER_ELEMENT]=-1}},E=function(t,e){try{var r=k.getPtr(t);s[e/Int32Array.BYTES_PER_ELEMENT]=r.tell()}catch(t){null==o||o.addError("pvFileTellWasm",t),s[e/Int32Array.BYTES_PER_ELEMENT]=-1}},b=function(){var t=r(i.mark((function t(e,r){var n,c;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=B(a,e),t.prev=1,t.next=4,z(n,"w");case 4:return c=t.sent,t.next=7,c.remove();case 7:s[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),null==o||o.addError("pvFileRemoveWasm",t.t0),s[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e,r){return t.apply(this,arguments)}}(),x={wasi_snapshot_preview1:H,env:{memory:e,pv_console_log_wasm:c,pv_assert_wasm:u,pv_time_wasm:f,pv_https_request_wasm:h,pv_get_browser_info:d,pv_get_origin_info:v,pv_file_open_wasm:y,pv_file_close_wasm:_,pv_file_read_wasm:m,pv_file_write_wasm:w,pv_file_seek_wasm:g,pv_file_tell_wasm:E,pv_file_remove_wasm:b}},!(n instanceof Promise)){t.next=34;break}if(!p){t.next=23;break}return t.next=20,p(n,x);case 20:P=t.sent.instance,t.next=32;break;case 23:return t.next=25,n;case 25:return O=t.sent,t.next=28,O.arrayBuffer();case 28:return S=t.sent,t.next=31,l(new Uint8Array(S),x);case 31:P=t.sent.instance;case 32:t.next=38;break;case 34:return T=R(n),t.next=37,l(T,x);case 37:P=t.sent.instance;case 38:return A=P.exports.aligned_alloc,t.abrupt("return",P.exports);case 40:case"end":return t.stop()}}),t)}))),$.apply(this,arguments)}function J(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Q(t){return function(t){if(Array.isArray(t))return J(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return J(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?J(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var X=function(){function t(){d(this,t),h(this,"_maxNumErrors",10),h(this,"_errors",[]),h(this,"_lastError",void 0)}return y(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=Q(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),Z={DB_NAME:O,DB_VERSION:3,PV_FILE_STORE:S};return t.PvError=X,t.PvFile=k,t.PvFileIDB=A,t.PvFileMem=I,t.arrayBufferToBase64AtIndex=function(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)},t.arrayBufferToStringAtIndex=B,t.base64ToUint8Array=R,t.buildWasm=function(t,e,r){return $.apply(this,arguments)},t.dbConfig=Z,t.fetchWithTimeout=Y,t.fromBase64=C,t.fromPublicDirectory=K,t.getDB=T,t.isAccessKeyValid=function(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}},t.loadModel=function(t){return q.apply(this,arguments)},t.open=z,t.stringHeaderToObject=D,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
var WebUtils=function(t){"use strict";function e(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function s(t){e(i,o,a,s,c,"next",t)}function c(t){e(i,o,a,s,c,"throw",t)}s(void 0)}))}}function n(t){var e={exports:{}};return t(e,e.exports),e.exports}var o=n((function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})),a=n((function(t){var e=o.default;function r(){t.exports=r=function(){return n},t.exports.__esModule=!0,t.exports.default=t.exports;var n={},o=Object.prototype,a=o.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),s=new T(n||[]);return i(a,"_invoke",{value:P(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=p;var v={};function d(){}function y(){}function _(){}var m={};l(m,c,(function(){return this}));var g=Object.getPrototypeOf,w=g&&g(g(A([])));w&&w!==o&&a.call(w,c)&&(m=w);var E=_.prototype=d.prototype=Object.create(m);function b(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,r){function n(o,i,s,c){var u=h(t[o],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,s,c)}),(function(t){n("throw",t,s,c)})):r.resolve(l).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,c)}))}c(u.arg)}var o;i(this,"_invoke",{value:function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}})}function P(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return j()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=k(i,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===v)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function k(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function A(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(a.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:j}}function j(){return{value:void 0,done:!0}}return y.prototype=_,i(E,"constructor",{value:_,configurable:!0}),i(_,"constructor",{value:y,configurable:!0}),y.displayName=l(_,f,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,f,"GeneratorFunction")),t.prototype=Object.create(E),t},n.awrap=function(t){return{__await:t}},b(x.prototype),l(x.prototype,u,(function(){return this})),n.AsyncIterator=x,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new x(p(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},b(E),l(E,f,"Generator"),l(E,c,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=A,T.prototype={constructor:T,reset:function(t){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(S),!t)for(var e in this)"t"===e.charAt(0)&&a.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=a.call(o,"catchLoc"),c=a.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),i=a(),s=i;try{regeneratorRuntime=i}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}const c=new WeakMap;function u(t,e){return new Proxy(t,{get:(t,r)=>e(t[r])})}class f{constructor(){this.value=void 0,this.exports=null}getState(){return this.exports.asyncify_get_state()}assertNoneState(){let t=this.getState();if(0!==t)throw new Error(`Invalid async state ${t}, expected 0.`)}wrapImportFn(t){return(...e)=>{if(2===this.getState())return this.exports.asyncify_stop_rewind(),this.value;this.assertNoneState();let r=t(...e);if(!(n=r)||"object"!=typeof n&&"function"!=typeof n||"function"!=typeof n.then)return r;var n;this.exports.asyncify_start_unwind(16),this.value=r}}wrapModuleImports(t){return u(t,(t=>"function"==typeof t?this.wrapImportFn(t):t))}wrapImports(t){if(void 0!==t)return u(t,((t=Object.create(null))=>this.wrapModuleImports(t)))}wrapExportFn(t){let e=c.get(t);return void 0!==e||(e=async(...e)=>{this.assertNoneState();let r=t(...e);for(;1===this.getState();)this.exports.asyncify_stop_unwind(),this.value=await this.value,this.assertNoneState(),this.exports.asyncify_start_rewind(16),r=t();return this.assertNoneState(),r},c.set(t,e)),e}wrapExports(t){let e=Object.create(null);for(let r in t){let n=t[r];"function"!=typeof n||r.startsWith("asyncify_")||(n=this.wrapExportFn(n)),Object.defineProperty(e,r,{enumerable:!0,value:n})}return c.set(t,e),e}init(t,e){const{exports:r}=t,n=r.memory||e.env&&e.env.memory;new Int32Array(n.buffer,16).set([24,1024]),this.exports=this.wrapExports(r),Object.setPrototypeOf(t,l.prototype)}}class l extends WebAssembly.Instance{constructor(t,e){let r=new f;super(t,r.wrapImports(e)),r.init(this,e)}get exports(){return c.get(super.exports)}}async function p(t,e){let r=new f,n=await WebAssembly.instantiate(t,r.wrapImports(e));return r.init(n instanceof WebAssembly.Instance?n:n.instance,e),n}async function h(t,e){let r=new f,n=await WebAssembly.instantiateStreaming(t,r.wrapImports(e));return r.init(n.instance,e),n}function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function d(t){var e=function(t,e){if("object"!==v(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===v(e)?e:String(e)}function y(t,e,r){return(e=d(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,d(n.key),n)}}function g(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function E(t,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},E(t,e)}function b(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e)}function x(t,e){if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return w(t)}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}function k(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}Object.defineProperty(l.prototype,"exports",{enumerable:!0});var O=function(){function t(){_(this,t),y(this,"_path",void 0),y(this,"_meta",void 0)}return g(t,[{key:"meta",get:function(){if(void 0!==this._meta)return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?k(Object(r),!0).forEach((function(e){y(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({version:0},this._meta)}}],[{key:"getPtr",value:function(e){return t._filePtrs.get(e)}},{key:"setPtr",value:function(e,r){t._filePtrs.set(e,r)}},{key:"removePtr",value:function(e){t._filePtrs.delete(e)}}]),t}();function S(t){var e=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(t){return!1}}();return function(){var r,n=P(t);if(e){var o=P(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return x(this,r)}}y(O,"_filePtrs",new Map);var T="pv_db",A="pv_file",j=3;function I(){return new Promise((function(t,e){var r=self.indexedDB.open(T,j);r.onerror=function(){e(r.error)},r.onsuccess=function(){t(r.result)},r.onupgradeneeded=function(){r.result.objectStoreNames.contains(A)||r.result.createObjectStore(A)}}))}var M=function(t){b(c,t);var e,n,o,a,i=S(c);function c(t,e,r,n){var o;return _(this,c),y(w(o=i.call(this)),"_pageSize",65536),y(w(o),"_db",void 0),y(w(o),"_mode",void 0),y(w(o),"_pagePtr",0),y(w(o),"_pageOffset",0),o._path=t,o._meta=e,o._db=r,o._mode=n,o}return g(c,[{key:"close",value:(a=r(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._db.close();case 1:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"read",value:(o=r(s.mark((function t(e,r){var n=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,o){if(n.exists()){if(n._isEOF){var a=new Error("EOF");return a.name="EndOfFile",void o(a)}var i=0,s=Math.min(e*r,n._meta.size),u=s-s%e,f=new Uint8Array(u),l=IDBKeyRange.bound("".concat(n._path,"-").concat(c.createPage(n._pagePtr)),"".concat(n._path,"-").concat(c.createPage(n._meta.numPages))),p=n._store,h=p.openCursor(l);h.onsuccess=function(){var t=h.result;if(t&&!n._isEOF){var e=Math.min(u-i,t.value.length-n._pageOffset);f.set(t.value.slice(n._pageOffset,n._pageOffset+e),i),i+=e,n._pageOffset+=e,n._pageOffset===n._pageSize&&(n._pagePtr+=1,n._pageOffset=0),i<u&&t.continue()}},p.transaction.onerror=function(){o(p.transaction.error)},p.transaction.oncomplete=function(){t(f.slice(0,i))}}else o(new Error("'".concat(n._path,"' doesn't exist.")))})));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return o.apply(this,arguments)})},{key:"write",value:(n=r(s.mark((function t(e){var n,o=this,a=arguments;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:1,t.abrupt("return",new Promise(function(){var t=r(s.mark((function t(r,a){var i,u,f,l,p,h,v,d,y;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("readonly"!==o._mode){t.next=3;break}return a(new Error("Instance is readonly mode only.")),t.abrupt("return");case 3:if(!("number"!=typeof n&&n<=0)){t.next=6;break}return a(new Error("Version should be a positive number")),t.abrupt("return");case 6:return i=o._store,u=function(){return new Promise((function(t){var e=i.get("".concat(o._path,"-").concat(c.createPage(o._pagePtr)));e.onsuccess=function(){void 0!==e.result?t(e.result.slice(0,o._pageOffset)):t(new Uint8Array(0))}}))},t.next=10,u();case 10:for(f=t.sent,(l=new Uint8Array(f.length+e.length)).set(f),l.set(e,f.length),p=o._pagePtr*o._pageSize+l.length,h={size:p,numPages:Math.ceil(p/o._pageSize),version:n},i.put(h,o._path),v=Math.ceil(l.length/o._pageSize),d=0;d<v;d++)i.put(l.slice(d*o._pageSize,(d+1)*o._pageSize),"".concat(o._path,"-").concat(c.createPage(o._pagePtr+d)));o.exists()&&h.numPages<o._meta.numPages&&(y=IDBKeyRange.bound("".concat(o._path,"-").concat(c.createPage(h.numPages)),"".concat(o._path,"-").concat(c.createPage(o._meta.numPages)),!0),i.delete(y)),i.transaction.onerror=function(){a(i.transaction.error)},i.transaction.oncomplete=function(){o._meta=h,o.seek(0,2),r()};case 22:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 2:case"end":return t.stop()}}),t)}))),function(t){return n.apply(this,arguments)})},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._meta.size);else if(1===e){var o=this._pageSize*this._pagePtr+this._pageOffset;n=Math.min(o+t,this._meta.size)}else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._meta.size+t,this._meta.size)}this._pageOffset=n%this._pageSize,this._pagePtr=Math.floor(n/this._pageSize)}},{key:"tell",value:function(){return this.exists()?this._pagePtr*this._pageSize+this._pageOffset:-1}},{key:"remove",value:(e=r(s.mark((function t(){var e=this;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var t=r(s.mark((function t(r,n){var o,a,i,u;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=e._meta.numPages,a=IDBKeyRange.bound(e._path,"".concat(e._path,"-").concat(c.createPage(o))),i=e._store,(u=i.delete(a)).onerror=function(){n(u.error)},u.onsuccess=function(){e._meta=void 0,e._pageOffset=0,e._pagePtr=0,r()};case 6:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()));case 1:case"end":return t.stop()}}),t)}))),function(){return e.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._meta}},{key:"_isEOF",get:function(){return this._pagePtr>=this._meta.numPages-1&&this._pageOffset>=this._meta.size%this._pageSize}},{key:"_store",get:function(){return this._db.transaction(A,this._mode).objectStore(A)}}],[{key:"open",value:function(t,e){if(!self.indexedDB){var n=new Error("IndexedDB is not supported");throw n.name="IndexedDBNotSupported",n}return new Promise(function(){var n=r(s.mark((function r(n,o){var a,i,u;return s.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,I();case 3:a=r.sent,(i=a.transaction(A,"readwrite").objectStore(A).get(t)).onerror=function(){o(i.error)},i.onsuccess=function(){var r=i.result,s=e.includes("r")?"readonly":"readwrite";if(void 0===r&&"readonly"===s){var u=new Error("'".concat(t,"' doesn't exist."));return u.name="FileNotExists",void o(u)}var f=new c(t,r,a,s);e.includes("a")&&f.seek(0,2),n(f)},r.next=12;break;case 9:r.prev=9,r.t0=r.catch(0),"InvalidStateError"===r.t0.name?((u=new Error("IndexedDB is not supported")).name="IndexedDBNotSupported",o(u)):o(r.t0);case 12:case"end":return r.stop()}}),r,null,[[0,9]])})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"createPage",value:function(t){return("000"+t).slice(-4)}}]),c}(O);function L(t){var e=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(t){return!1}}();return function(){var r,n=P(t);if(e){var o=P(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return x(this,r)}}var N=function(t){b(o,t);var e,n=L(o);function o(t,e,r,a){var i;return _(this,o),y(w(i=n.call(this)),"_pos",0),y(w(i),"_mode",void 0),i._path=t,i._meta=e,i._mode=a,i}return g(o,[{key:"close",value:function(){}},{key:"read",value:function(t,e){if(!this.exists())throw new Error("'".concat(this._path,"' doesn't exist."));if(this._isEOF){var r=new Error("EOF");throw r.name="EndOfFile",r}var n=Math.min(t*e,this._file.length-this._pos),o=n-n%t,a=new Uint8Array(o);return a.set(this._file.slice(this._pos,this._pos+o),0),this._pos+=o,a}},{key:"write",value:function(t){var e=new Uint8Array(this._pos+t.length);void 0!==this._file?(e.set(this._file.slice(0,this._pos)),e.set(t,this._pos)):e.set(t),this._file=e,this._pos+=t.length}},{key:"seek",value:function(t,e){if(!this.exists()&&"readonly"===this._mode)throw new Error("'".concat(this._path,"' doesn't exist."));if(t<0){var r=new Error("EOF");throw r.name="EndOfFile",r}var n;if(0===e)n=Math.min(t,this._file.length);else if(1===e)n=Math.min(this._pos+t,this._file.length);else{if(2!==e)throw new Error("Invalid operation: ".concat(e,"."));n=Math.min(this._file.length+t,this._file.length)}this._pos=n}},{key:"tell",value:function(){return this.exists()?this._pos:-1}},{key:"remove",value:(e=r(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o._memFiles.delete(this._path),this._file=void 0,this._pos=0;case 3:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"exists",value:function(){return void 0!==this._file}},{key:"_isEOF",get:function(){return this._pos>=this._file.length}},{key:"_file",get:function(){return o._memFiles.get(this._path)},set:function(t){o._memFiles.set(this._path,t)}}],[{key:"open",value:function(t,e){var r=o._memFiles.get(t),n=e.includes("r")?"readonly":"readwrite";if(void 0===r&&"readonly"===n){var a=new Error("'".concat(t,"' doesn't exist."));throw a.name="FileNotExists",a}var i=new o(t,void 0,void 0,n);return e.includes("a")&&i.seek(0,2),i}}]),o}(O);function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function R(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?B(Object(r),!0).forEach((function(e){y(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function F(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return Y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Y(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}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 a,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function Y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function D(t,e){for(var r=e;0!==t[r];)r++;return new TextDecoder("utf-8").decode(t.subarray(e,r))}function W(t){for(var e=atob(t),r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function z(t){var e,r={},n=F(t.split("\r\n"));try{for(n.s();!(e=n.n()).done;){var o=e.value.split(": ");""!==o[0]&&(r[o[0]]=o[1])}}catch(t){n.e(t)}finally{n.f()}return r}function U(t){return C.apply(this,arguments)}function C(){return C=r(s.mark((function t(e){var r,n,o,a,i,c,u=arguments;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=u.length>2&&void 0!==u[2]?u[2]:5e3,o=new AbortController,a=R(R({},r),{},{signal:o.signal}),i=setTimeout((function(){o.abort()}),n),t.next=7,fetch(e,a);case 7:return c=t.sent,clearTimeout(i),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)}))),C.apply(this,arguments)}function G(t,e){return q.apply(this,arguments)}function q(){return(q=r(s.mark((function t(e,r){var n;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,M.open(e,r);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),"IndexedDBNotSupported"===t.t0.name?console.warn("IndexedDB is not supported. Fallback to in-memory storage."):"FileNotExists"!==t.t0.name&&console.warn("Unable to access IndexedDB (".concat(t.t0.toString(),"). Fallback to in-memory storage.")),!("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope)){t.next=16;break}if("FileNotExists"!==t.t0.name){t.next=12;break}throw t.t0;case 12:throw console.error("In-memory storage cannot be used inside a worker."),(n=new Error("Failed to start PvFile: ".concat(t.t0.toString()))).name="PvFileNotSupported",n;case 16:return t.abrupt("return",N.open(e,r));case 17:case"end":return t.stop()}}),t,null,[[0,6]])})))).apply(this,arguments)}function H(t,e,r,n){return K.apply(this,arguments)}function K(){return(K=r(s.mark((function t(e,r,n,o){var a;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,G(e,"w");case 2:if(a=t.sent,!(n||void 0===a.meta||o>a.meta.version)){t.next=6;break}return t.next=6,a.write(W(r),o);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}y(N,"_memFiles",new Map);var V=5e3,$=2;function J(t,e,r,n,o){return Q.apply(this,arguments)}function Q(){return(Q=r(s.mark((function t(e,r,n,o,a){var i,c,u,f,l,p,h,v;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,G(e,"w");case 2:if(i=t.sent,!(n||void 0===i.meta||o>i.meta.version)){t.next=43;break}if(!(a<0)){t.next=6;break}throw Error("numFetchRetries must be a positive number");case 6:c=$,u=function(t){return new Promise((function(e){setTimeout(e,t)}))},f=a+1,l=null;case 10:if(!(f>0)){t.next=38;break}return l=null,t.prev=12,t.next=15,fetch(r,{cache:"no-cache"});case 15:if(!(p=t.sent).ok){t.next=23;break}return t.next=19,p.arrayBuffer();case 19:return h=t.sent,t.next=22,i.write(new Uint8Array(h),o);case 22:return t.abrupt("return");case 23:return t.next=25,p.text();case 25:v=t.sent,l=new Error("Error response returned while fetching model from '".concat(r,"': ").concat(v)),t.next=32;break;case 29:t.prev=29,t.t0=t.catch(12),l=new Error("Failed to fetch model from '".concat(r,"': ").concat(t.t0.message));case 32:return f--,t.next=35,u(c);case 35:c=Math.min(V,c*$),t.next=10;break;case 38:if(null===l){t.next=42;break}throw l;case 42:throw new Error("Unexpected error encountered while fetching model from '".concat(r,"'"));case 43:case"end":return t.stop()}}),t,null,[[12,29]])})))).apply(this,arguments)}function X(){return(X=r(s.mark((function t(e){var r,n,o,a,i,c,u,f,l;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e){t.next=2;break}throw new Error("The model is undefined / empty");case 2:if(r=e.base64,n=e.publicPath,o=e.customWritePath,a=e.forceWrite,i=void 0!==a&&a,c=e.version,u=void 0===c?1:c,f=e.numFetchRetries,l=void 0===f?0:f,null!=o){t.next=5;break}throw new Error("The customWritePath of the provided model is undefined / empty");case 5:if(null==r){t.next=10;break}return t.next=8,H(o,r,i,u);case 8:case 13:t.next=16;break;case 10:if(null==n){t.next=15;break}return t.next=13,J(o,n,i,u,l);case 15:throw new Error("The provided model doesn't contain a valid publicPath or base64 value");case 16:return t.abrupt("return",o);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Z={args_get:function(t){return 0},args_sizes_get:function(t){return 0},environ_get:function(t){return 0},environ_sizes_get:function(t){return 0},clock_res_get:function(t){return 0},clock_time_get:function(t){return 0},fd_advise:function(t){return 0},fd_allocate:function(t){return 0},fd_close:function(t){return 0},fd_datasync:function(t){return 0},fd_fdstat_get:function(t){return 0},fd_fdstat_set_flags:function(t){return 0},fd_fdstat_set_rights:function(t){return 0},fd_filestat_get:function(t){return 0},fd_filestat_set_size:function(t){return 0},fd_filestat_set_times:function(t){return 0},fd_pread:function(t){return 0},fd_prestat_get:function(t){return 0},fd_prestat_dir_name:function(t){return 0},fd_pwrite:function(t){return 0},fd_read:function(t){return 0},fd_readdir:function(t){return 0},fd_renumber:function(t){return 0},fd_seek:function(t){return 0},fd_sync:function(t){return 0},fd_tell:function(t){return 0},fd_write:function(t){return 0},path_create_directory:function(t){return 0},path_filestat_get:function(t){return 0},path_filestat_set_times:function(t){return 0},path_link:function(t){return 0},path_open:function(t){return 0},path_readlink:function(t){return 0},path_remove_directory:function(t){return 0},path_rename:function(t){return 0},path_symlink:function(t){return 0},path_unlink_file:function(t){return 0},poll_oneoff:function(t){return 0},proc_exit:function(t){return 0},proc_raise:function(t){return 0},sched_yield:function(t){return 0},random_get:function(t){return 0},sock_recv:function(t){return 0},sock_send:function(t){return 0},sock_shutdown:function(t){return 0}};function tt(){return tt=r(s.mark((function t(e,n,o){var a,i,c,u,f,l,v,d,y,_,m,g,w,E,b,x,P,k,S,T,A;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=new Uint8Array(e.buffer),i=new Int32Array(e.buffer),c=function(t){console.log(D(a,t))},u=function(t,e,r){if(0===t){var n=D(a,r);throw new Error("assertion failed at line ".concat(e,' in "').concat(n,'"'))}},f=function(){return Date.now()/1e3},l=function(){var t=r(s.mark((function t(e,r,n,c,u,f,l,p,h){var v,d,y,_,m,g,w,E,b,x,P;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return v=D(a,e),d=D(a,r),y=D(a,n),_=D(a,c),m=D(a,u),g=z(_),t.prev=6,t.next=9,U("https://"+d+y,{method:v,headers:g,body:m},f);case 9:w=t.sent,b=w.status,t.next=17;break;case 13:t.prev=13,t.t0=t.catch(6),null==o||o.addError("pvHttpsRequestWasm","Failed to fetch: ".concat(t.t0)),b=0;case 17:if(void 0===w){t.next=40;break}return t.prev=18,t.next=21,w.text();case 21:E=t.sent,t.next=29;break;case 24:t.prev=24,t.t1=t.catch(18),null==o||o.addError("pvHttpsRequestWasm","Failed to get response text: ".concat(t.t1)),E="",b=1;case 29:return t.next=31,A(Int8Array.BYTES_PER_ELEMENT,(E.length+1)*Int8Array.BYTES_PER_ELEMENT);case 31:if(0!==(x=t.sent)){t.next=36;break}return null==o||o.addError("pvMallocError","pvHttpsRequestWasm: cannot allocate memory for response"),i[l/Int32Array.BYTES_PER_ELEMENT]=0,t.abrupt("return");case 36:for(i[p/Int32Array.BYTES_PER_ELEMENT]=E.length+1,i[l/Int32Array.BYTES_PER_ELEMENT]=x,P=0;P<E.length;P++)a[x+P]=E.charCodeAt(P);a[x+E.length]=0;case 40:i[h/Int32Array.BYTES_PER_ELEMENT]=b;case 41:case"end":return t.stop()}}),t,null,[[6,13],[18,24]])})));return function(e,r,n,o,a,i,s,c,u){return t.apply(this,arguments)}}(),v=function(){var t=r(s.mark((function t(e){var r,n,c;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=void 0!==navigator.userAgent?navigator.userAgent:"unknown",t.next=3,A(Uint8Array.BYTES_PER_ELEMENT,(r.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 3:if(0!==(n=t.sent)){t.next=8;break}return null==o||o.addError("pvMallocError","pvGetBrowserInfo: cannot allocate memory for browser info"),i[e/Int32Array.BYTES_PER_ELEMENT]=0,t.abrupt("return");case 8:for(i[e/Int32Array.BYTES_PER_ELEMENT]=n,c=0;c<r.length;c++)a[n+c]=r.charCodeAt(c);a[n+r.length]=0;case 11:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),d=function(){var t=r(s.mark((function t(e){var r,n,c,u,f;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null!==(r=self.origin)&&void 0!==r?r:self.location.origin,c=new URL(n).hostname,t.next=4,A(Uint8Array.BYTES_PER_ELEMENT,(c.length+1)*Uint8Array.BYTES_PER_ELEMENT);case 4:if(0!==(u=t.sent)){t.next=9;break}return null==o||o.addError("pvMallocError","pvGetOriginInfo: cannot allocate memory for origin info"),i[e/Int32Array.BYTES_PER_ELEMENT]=0,t.abrupt("return");case 9:for(i[e/Int32Array.BYTES_PER_ELEMENT]=u,f=0;f<c.length;f++)a[u+f]=c.charCodeAt(f);a[u+c.length]=0;case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),y=function(){var t=r(s.mark((function t(e,r,n,c){var u,f,l;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=D(a,r),f=D(a,n),t.prev=2,t.next=5,G(u,f);case 5:l=t.sent,O.setPtr(e,l),i[c/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(2),"FileNotExists"!==t.t0.name&&(null==o||o.addError("pvFileOpenWasm",t.t0)),i[c/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,r,n,o){return t.apply(this,arguments)}}(),_=function(){var t=r(s.mark((function t(e,r){var n;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.getPtr(e);case 3:return n=t.sent,t.next=6,n.close();case 6:i[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=13;break;case 9:t.prev=9,t.t0=t.catch(0),null==o||o.addError("pvFileCloseWasm",t.t0),i[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 13:case"end":return t.stop()}}),t,null,[[0,9]])})));return function(e,r){return t.apply(this,arguments)}}(),m=function(){var t=r(s.mark((function t(e,r,n,c,u){var f,l;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.getPtr(e);case 3:return f=t.sent,t.next=6,f.read(n,c);case 6:l=t.sent,a.set(l,r),i[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileReadWasm",t.t0),i[u/Int32Array.BYTES_PER_ELEMENT]=-1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),g=function(){var t=r(s.mark((function t(e,r,n,c,u){var f,l;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O.getPtr(e);case 3:return f=t.sent,(l=new Uint8Array(n*c)).set(a.slice(r,r+n*c),0),t.next=8,f.write(l);case 8:i[u/Int32Array.BYTES_PER_ELEMENT]=l.length/n,t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),null==o||o.addError("pvFileWriteWasm",t.t0),i[u/Int32Array.BYTES_PER_ELEMENT]=1;case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}(),w=function(t,e,r,n){try{O.getPtr(t).seek(e,r),i[n/Int32Array.BYTES_PER_ELEMENT]=0}catch(t){null==o||o.addError("pvFileSeekWasm",t),i[n/Int32Array.BYTES_PER_ELEMENT]=-1}},E=function(t,e){try{var r=O.getPtr(t);i[e/Int32Array.BYTES_PER_ELEMENT]=r.tell()}catch(t){null==o||o.addError("pvFileTellWasm",t),i[e/Int32Array.BYTES_PER_ELEMENT]=-1}},b=function(){var t=r(s.mark((function t(e,r){var n,c;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D(a,e),t.prev=1,t.next=4,G(n,"w");case 4:return c=t.sent,t.next=7,c.remove();case 7:i[r/Int32Array.BYTES_PER_ELEMENT]=0,t.next=14;break;case 10:t.prev=10,t.t0=t.catch(1),null==o||o.addError("pvFileRemoveWasm",t.t0),i[r/Int32Array.BYTES_PER_ELEMENT]=-1;case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e,r){return t.apply(this,arguments)}}(),x={wasi_snapshot_preview1:Z,env:{memory:e,pv_console_log_wasm:c,pv_assert_wasm:u,pv_time_wasm:f,pv_https_request_wasm:l,pv_get_browser_info:v,pv_get_origin_info:d,pv_file_open_wasm:y,pv_file_close_wasm:_,pv_file_read_wasm:m,pv_file_write_wasm:g,pv_file_seek_wasm:w,pv_file_tell_wasm:E,pv_file_remove_wasm:b}},!(n instanceof Promise)){t.next=34;break}if(!h){t.next=23;break}return t.next=20,h(n,x);case 20:P=t.sent.instance,t.next=32;break;case 23:return t.next=25,n;case 25:return k=t.sent,t.next=28,k.arrayBuffer();case 28:return S=t.sent,t.next=31,p(new Uint8Array(S),x);case 31:P=t.sent.instance;case 32:t.next=38;break;case 34:return T=W(n),t.next=37,p(T,x);case 37:P=t.sent.instance;case 38:return A=P.exports.aligned_alloc,t.abrupt("return",P.exports);case 40:case"end":return t.stop()}}),t)}))),tt.apply(this,arguments)}function et(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function rt(t){return function(t){if(Array.isArray(t))return et(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return et(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?et(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var nt=function(){function t(){_(this,t),y(this,"_maxNumErrors",10),y(this,"_errors",[]),y(this,"_lastError",void 0)}return g(t,[{key:"addError",value:function(t,e){this._lastError=e instanceof Error?e:new Error(e),this._errors.length>=this._maxNumErrors&&this._errors.shift(),e instanceof Error?this._errors.push({key:t,message:e.toString()}):this._errors.push({key:t,message:JSON.stringify(e)})}},{key:"getErrors",value:function(){var t=rt(this._errors);return this._errors=[],t}},{key:"getErrorString",value:function(){return this.getErrors().map((function(t){var e=t.key,r=t.message;return"'".concat(e,"' failed with: ").concat(r,".")})).join("\n")}},{key:"getLastError",value:function(){return this._lastError}},{key:"setMaxErrorNum",value:function(t){this._maxNumErrors=t}}]),t}(),ot={DB_NAME:T,DB_VERSION:j,PV_FILE_STORE:A};return t.PvError=nt,t.PvFile=O,t.PvFileIDB=M,t.PvFileMem=N,t.arrayBufferToBase64AtIndex=function(t,e,r){for(var n="",o=0;o<e;o++)n+=String.fromCharCode(t[r+o]);return btoa(n)},t.arrayBufferToStringAtIndex=D,t.base64ToUint8Array=W,t.buildWasm=function(t,e,r){return tt.apply(this,arguments)},t.dbConfig=ot,t.fetchWithTimeout=U,t.fromBase64=H,t.fromPublicDirectory=J,t.getDB=I,t.isAccessKeyValid=function(t){if("string"!=typeof t)return!1;var e=t.trim();if(""===e)return!1;try{return btoa(atob(e))===e}catch(t){return!1}},t.loadModel=function(t){return X.apply(this,arguments)},t.open=G,t.stringHeaderToObject=z,Object.defineProperty(t,"__esModule",{value:!0}),t}({});

@@ -1,2 +0,2 @@

declare type PvErrorType = {
type PvErrorType = {
key: string;

@@ -3,0 +3,0 @@ message: string;

@@ -5,3 +5,3 @@ /**

*/
export declare type PvFileMeta = {
export type PvFileMeta = {
size: number;

@@ -8,0 +8,0 @@ numPages: number;

@@ -1,2 +0,2 @@

export declare type PvModel = {
export type PvModel = {
/** Base64 representation of the file */

@@ -3,0 +3,0 @@ base64?: string;

import { PvError } from './pv_error';
export declare type aligned_alloc_type = (alignment: number, size: number) => Promise<number>;
export declare type pv_free_type = (ptr: number) => Promise<void>;
export type aligned_alloc_type = (alignment: number, size: number) => Promise<number>;
export type pv_free_type = (ptr: number) => Promise<void>;
/**

@@ -5,0 +5,0 @@ * Imports and Exports functions required for WASM.

{
"name": "@picovoice/web-utils",
"version": "1.2.12",
"version": "1.3.0",
"description": "Picovoice web utility functions",

@@ -5,0 +5,0 @@ "author": "Picovoice",

@@ -136,3 +136,7 @@ /*

if (responseAddress === 0) {
throw new Error('malloc failed: Cannot allocate memory');
pvError?.addError('pvMallocError', "pvHttpsRequestWasm: cannot allocate memory for response");
memoryBufferInt32[
responseAddressAddress / Int32Array.BYTES_PER_ELEMENT
] = 0;
return;
}

@@ -168,3 +172,7 @@

if (browserInfoAddress === 0) {
throw new Error('malloc failed: Cannot allocate memory');
pvError?.addError('pvMallocError', "pvGetBrowserInfo: cannot allocate memory for browser info");
memoryBufferInt32[
browserInfoAddressAddress / Int32Array.BYTES_PER_ELEMENT
] = 0;
return;
}

@@ -191,3 +199,7 @@

if (originInfoAddress === 0) {
throw new Error('malloc failed: Cannot allocate memory');
pvError?.addError('pvMallocError', "pvGetOriginInfo: cannot allocate memory for origin info");
memoryBufferInt32[
originInfoAddressAddress / Int32Array.BYTES_PER_ELEMENT
] = 0;
return;
}

@@ -194,0 +206,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc