(function(t){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=t()}else if(typeof define==="function"&&define.amd){define([],t)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.IdbChunkStore=t()}})(function(){var t,e,r;return function t(e,r,n){function i(s,u){if(!r[s]){if(!e[s]){var f=typeof require=="function"&&require;if(!u&&f)return f(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return i(r?r:t)},h,h.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){throw new Error("Invalid string. Length must be a multiple of 4")}return t[e-2]==="="?2:t[e-1]==="="?1:0}function h(t){return t.length*3/4-a(t)}function l(t){var e,r,n,s,u,f;var h=t.length;u=a(t);f=new o(h*3/4-u);n=u>0?h-4:h;var l=0;for(e=0,r=0;e>16&255;f[l++]=s>>8&255;f[l++]=s&255}if(u===2){s=i[t.charCodeAt(e)]<<2|i[t.charCodeAt(e+1)]>>4;f[l++]=s&255}else if(u===1){s=i[t.charCodeAt(e)]<<10|i[t.charCodeAt(e+1)]<<4|i[t.charCodeAt(e+2)]>>2;f[l++]=s>>8&255;f[l++]=s&255}return f}function c(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[t&63]}function p(t,e,r){var n;var i=[];for(var o=e;oa?a:f+u))}if(i===1){e=t[r-1];o+=n[e>>2];o+=n[e<<4&63];o+="=="}else if(i===2){e=(t[r-2]<<8)+t[r-1];o+=n[e>>10];o+=n[e>>4&63];o+=n[e<<2&63];o+="="}s.push(o);return s.join("")}},{}],2:[function(t,e,r){"use strict";var n=t("base64-js");var i=t("ieee754");r.Buffer=f;r.SlowBuffer=w;r.INSPECT_MAX_BYTES=50;var o=2147483647;r.kMaxLength=o;f.TYPED_ARRAY_SUPPORT=s();if(!f.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function s(){try{var t=new Uint8Array(1);t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return t.foo()===42}catch(t){return false}}function u(t){if(t>o){throw new RangeError("Invalid typed array length")}var e=new Uint8Array(t);e.__proto__=f.prototype;return e}function f(t,e,r){if(typeof t==="number"){if(typeof e==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return c(t)}return a(t,e,r)}if(typeof Symbol!=="undefined"&&Symbol.species&&f[Symbol.species]===f){Object.defineProperty(f,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}f.poolSize=8192;function a(t,e,r){if(typeof t==="number"){throw new TypeError('"value" argument must not be a number')}if(t instanceof ArrayBuffer){return d(t,e,r)}if(typeof t==="string"){return p(t,e)}return g(t)}f.from=function(t,e,r){return a(t,e,r)};f.prototype.__proto__=Uint8Array.prototype;f.__proto__=Uint8Array;function h(t){if(typeof t!=="number"){throw new TypeError('"size" argument must be a number')}else if(t<0){throw new RangeError('"size" argument must not be negative')}}function l(t,e,r){h(t);if(t<=0){return u(t)}if(e!==undefined){return typeof r==="string"?u(t).fill(e,r):u(t).fill(e)}return u(t)}f.alloc=function(t,e,r){return l(t,e,r)};function c(t){h(t);return u(t<0?0:y(t)|0)}f.allocUnsafe=function(t){return c(t)};f.allocUnsafeSlow=function(t){return c(t)};function p(t,e){if(typeof e!=="string"||e===""){e="utf8"}if(!f.isEncoding(e)){throw new TypeError('"encoding" must be a valid string encoding')}var r=_(t,e)|0;var n=u(r);var i=n.write(t,e);if(i!==r){n=n.slice(0,i)}return n}function v(t){var e=t.length<0?0:y(t.length)|0;var r=u(e);for(var n=0;n=o){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+o.toString(16)+" bytes")}return t|0}function w(t){if(+t!=t){t=0}return f.alloc(+t)}f.isBuffer=function t(e){return e!=null&&e._isBuffer===true};f.compare=function t(e,r){if(!f.isBuffer(e)||!f.isBuffer(r)){throw new TypeError("Arguments must be Buffers")}if(e===r)return 0;var n=e.length;var i=r.length;for(var o=0,s=Math.min(n,i);o>>1;case"base64":return Z(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase();n=true}}}f.byteLength=_;function m(t,e,r){var n=false;if(e===undefined||e<0){e=0}if(e>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;e>>>=0;if(r<=e){return""}if(!t)t="utf8";while(true){switch(t){case"hex":return D(this,e,r);case"utf8":case"utf-8":return C(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return j(this,e,r);case"base64":return I(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase();n=true}}}f.prototype._isBuffer=true;function b(t,e,r){var n=t[e];t[e]=t[r];t[r]=n}f.prototype.swap16=function t(){var e=this.length;if(e%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){e=this.toString("hex",0,n).match(/.{2}/g).join(" ");if(this.length>n)e+=" ... "}return""};f.prototype.compare=function t(e,r,n,i,o){if(!f.isBuffer(e)){throw new TypeError("Argument must be a Buffer")}if(r===undefined){r=0}if(n===undefined){n=e?e.length:0}if(i===undefined){i=0}if(o===undefined){o=this.length}if(r<0||n>e.length||i<0||o>this.length){throw new RangeError("out of range index")}if(i>=o&&r>=n){return 0}if(i>=o){return-1}if(r>=n){return 1}r>>>=0;n>>>=0;i>>>=0;o>>>=0;if(this===e)return 0;var s=o-i;var u=n-r;var a=Math.min(s,u);var h=this.slice(i,o);var l=e.slice(r,n);for(var c=0;c2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(W(r)){r=i?0:t.length-1}if(r<0)r=t.length+r;if(r>=t.length){if(i)return-1;else r=t.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof e==="string"){e=f.from(e,n)}if(f.isBuffer(e)){if(e.length===0){return-1}return A(t,e,r,n,i)}else if(typeof e==="number"){e=e&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(t,e,r)}else{return Uint8Array.prototype.lastIndexOf.call(t,e,r)}}return A(t,[e],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function A(t,e,r,n,i){var o=1;var s=t.length;var u=e.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(t.length<2||e.length<2){return-1}o=2;s/=2;u/=2;r/=2}}function f(t,e){if(o===1){return t[e]}else{return t.readUInt16BE(e*o)}}var a;if(i){var h=-1;for(a=r;as)r=s-u;for(a=r;a>=0;a--){var l=true;for(var c=0;ci){n=i}}var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");if(n>o/2){n=o/2}for(var s=0;s>>0;if(isFinite(n)){n=n>>>0;if(i===undefined)i="utf8"}else{i=n;n=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var o=this.length-r;if(n===undefined||n>o)n=o;if(e.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var s=false;for(;;){switch(i){case"hex":return k(this,e,r,n);case"utf8":case"utf-8":return B(this,e,r,n);case"ascii":return L(this,e,r,n);case"latin1":case"binary":return T(this,e,r,n);case"base64":return S(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();s=true}}};f.prototype.toJSON=function t(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(t,e,r){if(e===0&&r===t.length){return n.fromByteArray(t)}else{return n.fromByteArray(t.slice(e,r))}}function C(t,e,r){r=Math.min(t.length,r);var n=[];var i=e;while(i239?4:o>223?3:o>191?2:1;if(i+u<=r){var f,a,h,l;switch(u){case 1:if(o<128){s=o}break;case 2:f=t[i+1];if((f&192)===128){l=(o&31)<<6|f&63;if(l>127){s=l}}break;case 3:f=t[i+1];a=t[i+2];if((f&192)===128&&(a&192)===128){l=(o&15)<<12|(f&63)<<6|a&63;if(l>2047&&(l<55296||l>57343)){s=l}}break;case 4:f=t[i+1];a=t[i+2];h=t[i+3];if((f&192)===128&&(a&192)===128&&(h&192)===128){l=(o&15)<<18|(f&63)<<12|(a&63)<<6|h&63;if(l>65535&&l<1114112){s=l}}}}if(s===null){s=65533;u=1}else if(s>65535){s-=65536;n.push(s>>>10&1023|55296);s=56320|s&1023}n.push(s);i+=u}return U(n)}var P=4096;function U(t){var e=t.length;if(e<=P){return String.fromCharCode.apply(String,t)}var r="";var n=0;while(nn)r=n;var i="";for(var o=e;on){e=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function t(e,r,n){e=e>>>0;r=r>>>0;if(!n)O(e,r,this.length);var i=this[e];var o=1;var s=0;while(++s>>0;r=r>>>0;if(!n){O(e,r,this.length)}var i=this[e+--r];var o=1;while(r>0&&(o*=256)){i+=this[e+--r]*o}return i};f.prototype.readUInt8=function t(e,r){e=e>>>0;if(!r)O(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function t(e,r){e=e>>>0;if(!r)O(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function t(e,r){e=e>>>0;if(!r)O(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function t(e,r){e=e>>>0;if(!r)O(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function t(e,r){e=e>>>0;if(!r)O(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function t(e,r,n){e=e>>>0;r=r>>>0;if(!n)O(e,r,this.length);var i=this[e];var o=1;var s=0;while(++s=o)i-=Math.pow(2,8*r);return i};f.prototype.readIntBE=function t(e,r,n){e=e>>>0;r=r>>>0;if(!n)O(e,r,this.length);var i=r;var o=1;var s=this[e+--i];while(i>0&&(o*=256)){s+=this[e+--i]*o}o*=128;if(s>=o)s-=Math.pow(2,8*r);return s};f.prototype.readInt8=function t(e,r){e=e>>>0;if(!r)O(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function t(e,r){e=e>>>0;if(!r)O(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};f.prototype.readInt16BE=function t(e,r){e=e>>>0;if(!r)O(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};f.prototype.readInt32LE=function t(e,r){e=e>>>0;if(!r)O(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function t(e,r){e=e>>>0;if(!r)O(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function t(e,r){e=e>>>0;if(!r)O(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function t(e,r){e=e>>>0;if(!r)O(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function t(e,r){e=e>>>0;if(!r)O(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function t(e,r){e=e>>>0;if(!r)O(e,8,this.length);return i.read(this,e,false,52,8)};function N(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}f.prototype.writeUIntLE=function t(e,r,n,i){e=+e;r=r>>>0;n=n>>>0;if(!i){var o=Math.pow(2,8*n)-1;N(this,e,r,n,o,0)}var s=1;var u=0;this[r]=e&255;while(++u>>0;n=n>>>0;if(!i){var o=Math.pow(2,8*n)-1;N(this,e,r,n,o,0)}var s=n-1;var u=1;this[r+s]=e&255;while(--s>=0&&(u*=256)){this[r+s]=e/u&255}return r+n};f.prototype.writeUInt8=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,1,255,0);this[r]=e&255;return r+1};f.prototype.writeUInt16LE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,2,65535,0);this[r]=e&255;this[r+1]=e>>>8;return r+2};f.prototype.writeUInt16BE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,2,65535,0);this[r]=e>>>8;this[r+1]=e&255;return r+2};f.prototype.writeUInt32LE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,4,4294967295,0);this[r+3]=e>>>24;this[r+2]=e>>>16;this[r+1]=e>>>8;this[r]=e&255;return r+4};f.prototype.writeUInt32BE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,4,4294967295,0);this[r]=e>>>24;this[r+1]=e>>>16;this[r+2]=e>>>8;this[r+3]=e&255;return r+4};f.prototype.writeIntLE=function t(e,r,n,i){e=+e;r=r>>>0;if(!i){var o=Math.pow(2,8*n-1);N(this,e,r,n,o-1,-o)}var s=0;var u=1;var f=0;this[r]=e&255;while(++s>0)-f&255}return r+n};f.prototype.writeIntBE=function t(e,r,n,i){e=+e;r=r>>>0;if(!i){var o=Math.pow(2,8*n-1);N(this,e,r,n,o-1,-o)}var s=n-1;var u=1;var f=0;this[r+s]=e&255;while(--s>=0&&(u*=256)){if(e<0&&f===0&&this[r+s+1]!==0){f=1}this[r+s]=(e/u>>0)-f&255}return r+n};f.prototype.writeInt8=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,1,127,-128);if(e<0)e=255+e+1;this[r]=e&255;return r+1};f.prototype.writeInt16LE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,2,32767,-32768);this[r]=e&255;this[r+1]=e>>>8;return r+2};f.prototype.writeInt16BE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,2,32767,-32768);this[r]=e>>>8;this[r+1]=e&255;return r+2};f.prototype.writeInt32LE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,4,2147483647,-2147483648);this[r]=e&255;this[r+1]=e>>>8;this[r+2]=e>>>16;this[r+3]=e>>>24;return r+4};f.prototype.writeInt32BE=function t(e,r,n){e=+e;r=r>>>0;if(!n)N(this,e,r,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;this[r]=e>>>24;this[r+1]=e>>>16;this[r+2]=e>>>8;this[r+3]=e&255;return r+4};function z(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(t,e,r,n,o){e=+e;r=r>>>0;if(!o){z(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(t,e,r,n,23,4);return r+4}f.prototype.writeFloatLE=function t(e,r,n){return F(this,e,r,true,n)};f.prototype.writeFloatBE=function t(e,r,n){return F(this,e,r,false,n)};function q(t,e,r,n,o){e=+e;r=r>>>0;if(!o){z(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(t,e,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function t(e,r,n){return q(this,e,r,true,n)};f.prototype.writeDoubleBE=function t(e,r,n){return q(this,e,r,false,n)};f.prototype.copy=function t(e,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=e.length)r=e.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(e.length-r=0;--s){e[s+r]=this[s+n]}}else if(o<1e3){for(s=0;s>>0;n=n===undefined?this.length:n>>>0;if(!e)e=0;var s;if(typeof e==="number"){for(s=r;s55295&&r<57344){if(!i){if(r>56319){if((e-=3)>-1)o.push(239,191,189);continue}else if(s+1===n){if((e-=3)>-1)o.push(239,191,189);continue}i=r;continue}if(r<56320){if((e-=3)>-1)o.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((e-=3)>-1)o.push(239,191,189)}i=null;if(r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function V(t){var e=[];for(var r=0;r>8;i=r%256;o.push(i);o.push(n)}return o}function Z(t){return n.toByteArray(G(t))}function K(t,e,r,n){for(var i=0;i=e.length||i>=t.length)break;e[i+r]=t[i]}return i}function Q(t){return typeof ArrayBuffer.isView==="function"&&ArrayBuffer.isView(t)}function W(t){return t!==t}},{"base64-js":1,ieee754:5}],3:[function(t,e,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}e.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(t){if(!o(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");this._maxListeners=t;return this};n.prototype.emit=function(t){var e,r,n,o,f,a;if(!this._events)this._events={};if(t==="error"){if(!this._events.error||s(this._events.error)&&!this._events.error.length){e=arguments[1];if(e instanceof Error){throw e}else{var h=new Error('Uncaught, unspecified "error" event. ('+e+")");h.context=e;throw h}}}r=this._events[t];if(u(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1);r.apply(this,o)}}else if(s(r)){o=Array.prototype.slice.call(arguments,1);a=r.slice();n=a.length;for(f=0;f0&&this._events[t].length>r){this._events[t].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[t].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(t,n);if(!r){r=true;e.apply(this,arguments)}}n.listener=e;this.on(t,n);return this};n.prototype.removeListener=function(t,e){var r,n,o,u;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;r=this._events[t];o=r.length;n=-1;if(r===e||i(r.listener)&&r.listener===e){delete this._events[t];if(this._events.removeListener)this.emit("removeListener",t,e)}else if(s(r)){for(u=o;u-- >0;){if(r[u]===e||r[u].listener&&r[u].listener===e){n=u;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[t]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",t,e)}return this};n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[t])delete this._events[t];return this}if(arguments.length===0){for(e in this._events){if(e==="removeListener")continue;this.removeAllListeners(e)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[t];if(i(r)){this.removeListener(t,r)}else if(r){while(r.length)this.removeListener(t,r[r.length-1])}delete this._events[t];return this};n.prototype.listeners=function(t){var e;if(!this._events||!this._events[t])e=[];else if(i(this._events[t]))e=[this._events[t]];else e=this._events[t].slice();return e};n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;else if(e)return e.length}return 0};n.listenerCount=function(t,e){return t.listenerCount(e)};function i(t){return typeof t==="function"}function o(t){return typeof t==="number"}function s(t){return typeof t==="object"&&t!==null}function u(t){return t===void 0}},{}],4:[function(t,e,r){e.exports=f;var n=t("events").EventEmitter;var i=t("inherits");var o=t("promisize");var s=typeof window==="undefined"?self:window;var u=s.indexedDB||s.mozIndexedDB||s.webkitIndexedDB||s.msIndexedDB;f.INDEXEDDB_SUPPORT=u!=null;f.BROADCAST_SUPPORT=s.BroadcastChannel!=null;i(f,n);function f(t,e,r){var i=this;if(typeof t!=="string")throw new Error("A name must be supplied of type string");if(!u)throw new Error("IndexedDB not supported");if(typeof e==="function")return new f(t,null,e);if(!(i instanceof f))return new f(t,e,r);if(!e)e={};n.call(i);i._db=null;i._closed=false;i._channel=null;i._waiters=[];var o=e.channel||s.BroadcastChannel;if(o){i._channel=new o(t);i._channel.onmessage=y}var a=u.open(t);a.onerror=l;a.onsuccess=p;a.onupgradeneeded=v;i.on("newListener",g);function l(t){h(t);i._close(t.target.error);if(r)r(t.target.error)}function c(t){h(t);i._close(t.target.error)}function p(t){if(i._closed){t.target.result.close()}else{i._db=t.target.result;i._db.onclose=d;i._db.onerror=c;for(var e in i._waiters)i._waiters[e]._init(null);i._waiters=null;if(r)r(null);i.emit("open")}}function v(t){var e=t.target.result;e.createObjectStore("kv",{autoIncrement:true})}function d(){i._close()}function g(t){if(t!=="add"&&t!=="set"&&t!=="remove")return;if(!i._channel)return i.emit("error",new Error("No BroadcastChannel support"))}function y(t){if(t.data.method==="add")i.emit("add",t.data);else if(t.data.method==="set")i.emit("set",t.data);else if(t.data.method==="remove")i.emit("remove",t.data)}}f.prototype.get=function(t,e){return this.transaction("readonly").get(t,e)};f.prototype.set=function(t,e,r){return this.transaction("readwrite").set(t,e,r)};f.prototype.json=function(t,e){return this.transaction("readonly").json(t,e)};f.prototype.keys=function(t,e){return this.transaction("readonly").keys(t,e)};f.prototype.values=function(t,e){return this.transaction("readonly").values(t,e)};f.prototype.remove=function(t,e){return this.transaction("readwrite").remove(t,e)};f.prototype.clear=function(t){return this.transaction("readwrite").clear(t)};f.prototype.count=function(t,e){return this.transaction("readonly").count(t,e)};f.prototype.add=function(t,e,r){return this.transaction("readwrite").add(t,e,r)};f.prototype.iterator=function(t,e){return this.transaction("readonly").iterator(t,e)};f.prototype.transaction=function(t){if(this._closed)throw new Error("Database is closed");var e=new a(this,t);if(this._db)e._init(null);else this._waiters.push(e);return e};f.prototype.close=function(){this._close()};f.prototype._close=function(t){if(this._closed)return;this._closed=true;if(this._db)this._db.close();if(this._channel)this._channel.close();this._db=null;this._channel=null;if(t)this.emit("error",t);this.emit("close");for(var e in this._waiters)this._waiters[e]._init(t||new Error("Database is closed"));this._waiters=null;this.removeAllListeners()};function a(t,e){this._kvStore=t;this._mode=e||"readwrite";this._objectStore=null;this._waiters=null;this.finished=false;this.onfinish=null;if(this._mode!=="readonly"&&this._mode!=="readwrite"){throw new Error('mode must be either "readonly" or "readwrite"')}}a.prototype._init=function(t){var e=this;if(e.finished)return;if(t)return e._close(t);var r=e._kvStore._db.transaction("kv",e._mode);r.oncomplete=i;r.onerror=o;e._objectStore=r.objectStore("kv");for(var n in e._waiters)e._waiters[n](null,e._objectStore);e._waiters=null;function i(){e._close(null)}function o(t){h(t);e._close(t.target.error)}};a.prototype._getObjectStore=function(t){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)return t(null,this._objectStore);this._waiters=this._waiters||[];this._waiters.push(t)};a.prototype.set=function(t,e,r){var n=this;if(t==null||e==null)throw new Error("A key and value must be given");r=o(r);n._getObjectStore(function(i,o){if(i)return r(i);try{var s=o.put(e,t)}catch(t){return r(t)}s.onerror=h.bind(this,r);s.onsuccess=function(){if(n._kvStore._channel){n._kvStore._channel.postMessage({method:"set",key:t,value:e})}r(null)}});return r.promise};a.prototype.add=function(t,e,r){var n=this;if(e==null&&t!=null)return n.add(undefined,t,r);if(typeof e==="function"||e==null&&r==null)return n.add(undefined,t,e);if(e==null)throw new Error("A value must be provided as an argument");r=o(r);n._getObjectStore(function(i,o){if(i)return r(i);try{var s=t==null?o.add(e):o.add(e,t)}catch(t){return r(t)}s.onerror=h.bind(this,r);s.onsuccess=function(){if(n._kvStore._channel){n._kvStore._channel.postMessage({method:"add",key:t,value:e})}r(null)}});return r.promise};a.prototype.get=function(t,e){var r=this;if(t==null)throw new Error("A key must be given as an argument");e=o(e);r._getObjectStore(function(r,n){if(r)return e(r);try{var i=n.get(t)}catch(t){return e(t)}i.onerror=h.bind(this,e);i.onsuccess=function(t){e(null,t.target.result)}});return e.promise};a.prototype.json=function(t,e){var r=this;if(typeof t==="function")return r.json(null,t);e=o(e);var n={};r.iterator(t,function(t,r){if(t)return e(t);if(r){n[r.key]=r.value;r.continue()}else{e(null,n)}});return e.promise};a.prototype.keys=function(t,e){var r=this;if(typeof t==="function")return r.keys(null,t);e=o(e);var n=[];r.iterator(t,function(t,r){if(t)return e(t);if(r){n.push(r.key);r.continue()}else{e(null,n)}});return e.promise};a.prototype.values=function(t,e){var r=this;if(typeof t==="function")return r.values(null,t);e=o(e);var n=[];r.iterator(t,function(t,r){if(t)return e(t);if(r){n.push(r.value);r.continue()}else{e(null,n)}});return e.promise};a.prototype.remove=function(t,e){var r=this;if(t==null)throw new Error("A key must be given as an argument");e=o(e);r._getObjectStore(function(n,i){if(n)return e(n);try{var o=i.delete(t)}catch(t){return e(t)}o.onerror=h.bind(this,e);o.onsuccess=function(){if(r._kvStore._channel){r._kvStore._channel.postMessage({method:"remove",key:t})}e(null)}});return e.promise};a.prototype.clear=function(t){var e=this;t=o(t);e._getObjectStore(function(e,r){if(e)return t(e);try{ var n=r.clear()}catch(e){return t(e)}n.onerror=h.bind(this,t);n.onsuccess=function(){t(null)}});return t.promise};a.prototype.count=function(t,e){var r=this;if(typeof t==="function")return r.count(null,t);e=o(e);r._getObjectStore(function(r,n){if(r)return e(r);try{var i=t==null?n.count():n.count(t)}catch(t){return e(t)}i.onerror=h.bind(this,e);i.onsuccess=function(t){e(null,t.target.result)}});return e.promise};a.prototype.iterator=function(t,e){var r=this;if(typeof t==="function")return r.iterator(null,t);if(typeof e!=="function")throw new Error("A function must be given");r._getObjectStore(function(r,n){if(r)return e(r);try{var i=t==null?n.openCursor():n.openCursor(t)}catch(t){return e(t)}i.onerror=h.bind(this,e);i.onsuccess=function(t){var r=t.target.result;e(null,r)}})};a.prototype.abort=function(){if(this.finished)throw new Error("Transaction is finished");if(this._objectStore)this._objectStore.transaction.abort();this._close(new Error("Transaction aborted"))};a.prototype._close=function(t){if(this.finished)return;this.finished=true;this._kvStore=null;this._objectStore=null;for(var e in this._waiters)this._waiters[e](t||new Error("Transaction is finished"));if(this.onfinish)this.onfinish(t);this.onfinish=null;this._waiters=null};function h(t,e){if(e==null)return h(null,t);e.preventDefault();e.stopPropagation();if(t)t(e.target.error)}},{events:3,inherits:6,promisize:8}],5:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s;var u=i*8-n-1;var f=(1<>1;var h=-7;var l=r?i-1:0;var c=r?-1:1;var p=t[e+l];l+=c;o=p&(1<<-h)-1;p>>=-h;h+=u;for(;h>0;o=o*256+t[e+l],l+=c,h-=8){}s=o&(1<<-h)-1;o>>=-h;h+=n;for(;h>0;s=s*256+t[e+l],l+=c,h-=8){}if(o===0){o=1-a}else if(o===f){return s?NaN:(p?-1:1)*Infinity}else{s=s+Math.pow(2,n);o=o-a}return(p?-1:1)*s*Math.pow(2,o-n)};r.write=function(t,e,r,n,i,o){var s,u,f;var a=o*8-i-1;var h=(1<>1;var c=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var p=n?0:o-1;var v=n?1:-1;var d=e<0||e===0&&1/e<0?1:0;e=Math.abs(e);if(isNaN(e)||e===Infinity){u=isNaN(e)?1:0;s=h}else{s=Math.floor(Math.log(e)/Math.LN2);if(e*(f=Math.pow(2,-s))<1){s--;f*=2}if(s+l>=1){e+=c/f}else{e+=c*Math.pow(2,1-l)}if(e*f>=2){s++;f/=2}if(s+l>=h){u=0;s=h}else if(s+l>=1){u=(e*f-1)*Math.pow(2,i);s=s+l}else{u=e*Math.pow(2,l-1)*Math.pow(2,i);s=0}}for(;i>=8;t[r+p]=u&255,p+=v,u/=256,i-=8){}s=s<0;t[r+p]=s&255,p+=v,s/=256,a-=8){}t[r+p-v]|=d*128}},{}],6:[function(t,e,r){if(typeof Object.create==="function"){e.exports=function t(e,r){e.super_=r;e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{e.exports=function t(e,r){e.super_=r;var n=function(){};n.prototype=r.prototype;e.prototype=new n;e.prototype.constructor=e}}},{}],7:[function(t,e,r){var n=e.exports={};var i;var o;function s(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){i=setTimeout}else{i=s}}catch(t){i=s}try{if(typeof clearTimeout==="function"){o=clearTimeout}else{o=u}}catch(t){o=u}})();function f(t){if(i===setTimeout){return setTimeout(t,0)}if((i===s||!i)&&setTimeout){i=setTimeout;return setTimeout(t,0)}try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}function a(t){if(o===clearTimeout){return clearTimeout(t)}if((o===u||!o)&&clearTimeout){o=clearTimeout;return clearTimeout(t)}try{return o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}var h=[];var l=false;var c;var p=-1;function v(){if(!l||!c){return}l=false;if(c.length){h=c.concat(h)}else{p=-1}if(h.length){d()}}function d(){if(l){return}var t=f(v);l=true;var e=h.length;while(e){c=h;h=[];while(++p1){for(var r=1;r