diff --git a/dist/orbitdb.min.js b/dist/orbitdb.min.js index d24b910..e690d60 100644 --- a/dist/orbitdb.min.js +++ b/dist/orbitdb.min.js @@ -1,8 +1,8 @@ -var OrbitDB=function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=82)}([function(t,n,e){"use strict";(function(t){function r(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,n){if(i()=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),u.alloc(+t)}function g(t,n){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var r=!1;;)switch(n){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return W(t).length;default:if(r)return H(t).length;n=(""+n).toLowerCase(),r=!0}}function m(t,n,e){var r=!1;if((void 0===n||n<0)&&(n=0),n>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if(e>>>=0,n>>>=0,e<=n)return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,n,e);case"utf8":case"utf-8":return S(this,n,e);case"ascii":return j(this,n,e);case"latin1":case"binary":return R(this,n,e);case"base64":return P(this,n,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,n,e);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,n,e){var r=t[n];t[n]=t[e],t[e]=r}function w(t,n,e,r,i){if(0===t.length)return-1;if("string"==typeof e?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof n&&(n=u.from(n,r)),u.isBuffer(n))return 0===n.length?-1:_(t,n,e,r,i);if("number"==typeof n)return n&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,n,e):Uint8Array.prototype.lastIndexOf.call(t,n,e):_(t,[n],e,r,i);throw new TypeError("val must be string, number or Buffer")}function _(t,n,e,r,i){function o(t,n){return 1===u?t[n]:t.readUInt16BE(n*u)}var u=1,s=t.length,c=n.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||n.length<2)return-1;u=2,s/=2,c/=2,e/=2}var a;if(i){var f=-1;for(a=e;as&&(e=s-c),a=e;a>=0;a--){for(var h=!0,l=0;li&&(r=i):r=i;var o=n.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u239?4:o>223?3:o>191?2:1;if(i+s<=e){var c,a,f,h;switch(s){case 1:o<128&&(u=o);break;case 2:c=t[i+1],128==(192&c)&&(h=(31&o)<<6|63&c)>127&&(u=h);break;case 3:c=t[i+1],a=t[i+2],128==(192&c)&&128==(192&a)&&(h=(15&o)<<12|(63&c)<<6|63&a)>2047&&(h<55296||h>57343)&&(u=h);break;case 4:c=t[i+1],a=t[i+2],f=t[i+3],128==(192&c)&&128==(192&a)&&128==(192&f)&&(h=(15&o)<<18|(63&c)<<12|(63&a)<<6|63&f)>65535&&h<1114112&&(u=h)}}null===u?(u=65533,s=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=s}return I(r)}function I(t){var n=t.length;if(n<=tt)return String.fromCharCode.apply(String,t);for(var e="",r=0;rr)&&(e=r);for(var i="",o=n;oe)throw new RangeError("Trying to access beyond buffer length")}function L(t,n,e,r,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>i||nt.length)throw new RangeError("Index out of range")}function M(t,n,e,r){n<0&&(n=65535+n+1);for(var i=0,o=Math.min(t.length-e,2);i>>8*(r?i:1-i)}function U(t,n,e,r){n<0&&(n=4294967295+n+1);for(var i=0,o=Math.min(t.length-e,4);i>>8*(r?i:3-i)&255}function N(t,n,e,r,i,o){if(e+r>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function F(t,n,e,r,i){return i||N(t,n,e,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,n,e,r,23,4),e+4}function K(t,n,e,r,i){return i||N(t,n,e,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,n,e,r,52,8),e+8}function Y(t){if(t=q(t).replace(nt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function q(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function z(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,n){n=n||1/0;for(var e,r=t.length,i=null,o=[],u=0;u55295&&e<57344){if(!i){if(e>56319){(n-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(n-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(n-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(n-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((n-=1)<0)break;o.push(e)}else if(e<2048){if((n-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((n-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((n-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var n=[],e=0;e>8,i=e%256,o.push(i),o.push(r);return o}function W(t){return $.toByteArray(Y(t))}function V(t,n,e,r){for(var i=0;i=n.length||i>=t.length);++i)n[i+e]=t[i];return i}function Q(t){return t!==t}/*! +var OrbitDB=function(t){function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=81)}([function(t,n,e){"use strict";(function(t){function r(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,n){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function v(t){return+t!=t&&(t=0),o.alloc(+t)}function y(t,n){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var r=!1;;)switch(n){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return J(t).length;default:if(r)return z(t).length;n=(""+n).toLowerCase(),r=!0}}function g(t,n,e){var r=!1;if((void 0===n||n<0)&&(n=0),n>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if(e>>>=0,n>>>=0,e<=n)return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,n,e);case"utf8":case"utf-8":return P(this,n,e);case"ascii":return I(this,n,e);case"latin1":case"binary":return j(this,n,e);case"base64":return T(this,n,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,n,e);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function m(t,n,e){var r=t[n];t[n]=t[e],t[e]=r}function b(t,n,e,r,i){if(0===t.length)return-1;if("string"==typeof e?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof n&&(n=o.from(n,r)),o.isBuffer(n))return 0===n.length?-1:w(t,n,e,r,i);if("number"==typeof n)return n&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,n,e):Uint8Array.prototype.lastIndexOf.call(t,n,e):w(t,[n],e,r,i);throw new TypeError("val must be string, number or Buffer")}function w(t,n,e,r,i){function o(t,n){return 1===s?t[n]:t.readUInt16BE(n*s)}var s=1,u=t.length,c=n.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||n.length<2)return-1;s=2,u/=2,c/=2,e/=2}var a;if(i){var f=-1;for(a=e;au&&(e=u-c),a=e;a>=0;a--){for(var h=!0,l=0;li&&(r=i):r=i;var o=n.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+u<=e){var c,a,f,h;switch(u){case 1:o<128&&(s=o);break;case 2:c=t[i+1],128==(192&c)&&(h=(31&o)<<6|63&c)>127&&(s=h);break;case 3:c=t[i+1],a=t[i+2],128==(192&c)&&128==(192&a)&&(h=(15&o)<<12|(63&c)<<6|63&a)>2047&&(h<55296||h>57343)&&(s=h);break;case 4:c=t[i+1],a=t[i+2],f=t[i+3],128==(192&c)&&128==(192&a)&&128==(192&f)&&(h=(15&o)<<18|(63&c)<<12|(63&a)<<6|63&f)>65535&&h<1114112&&(s=h)}}null===s?(s=65533,u=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=u}return S(r)}function S(t){var n=t.length;if(n<=X)return String.fromCharCode.apply(String,t);for(var e="",r=0;rr)&&(e=r);for(var i="",o=n;oe)throw new RangeError("Trying to access beyond buffer length")}function C(t,n,e,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>i||nt.length)throw new RangeError("Index out of range")}function L(t,n,e,r){n<0&&(n=65535+n+1);for(var i=0,o=Math.min(t.length-e,2);i>>8*(r?i:1-i)}function M(t,n,e,r){n<0&&(n=4294967295+n+1);for(var i=0,o=Math.min(t.length-e,4);i>>8*(r?i:3-i)&255}function U(t,n,e,r,i,o){if(e+r>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function N(t,n,e,r,i){return i||U(t,n,e,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(t,n,e,r,23,4),e+4}function F(t,n,e,r,i){return i||U(t,n,e,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(t,n,e,r,52,8),e+8}function K(t){if(t=Y(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function Y(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return t<16?"0"+t.toString(16):t.toString(16)}function z(t,n){n=n||1/0;for(var e,r=t.length,i=null,o=[],s=0;s55295&&e<57344){if(!i){if(e>56319){(n-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(n-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(n-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(n-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((n-=1)<0)break;o.push(e)}else if(e<2048){if((n-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((n-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((n-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function H(t){for(var n=[],e=0;e>8,i=e%256,o.push(i),o.push(r);return o}function J(t){return Q.toByteArray(K(t))}function W(t,n,e,r){for(var i=0;i=n.length||i>=t.length);++i)n[i+e]=t[i];return i}function V(t){return t!==t}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -var $=e(26),Z=e(31),X=e(37);n.Buffer=u,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),n.kMaxLength=i(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,n,e){return s(null,t,n,e)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,n,e){return a(null,t,n,e)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,n){if(!u.isBuffer(t)||!u.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var e=t.length,r=n.length,i=0,o=Math.min(e,r);i0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},u.prototype.compare=function(t,n,e,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===e&&(e=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),n<0||e>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&n>=e)return 0;if(r>=i)return-1;if(n>=e)return 1;if(n>>>=0,e>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,s=e-n,c=Math.min(o,s),a=this.slice(r,i),f=t.slice(n,e),h=0;hi)&&(e=i),t.length>0&&(e<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return x(this,t,n,e);case"utf8":case"utf-8":return E(this,t,n,e);case"ascii":return k(this,t,n,e);case"latin1":case"binary":return A(this,t,n,e);case"base64":return O(this,t,n,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,n,e);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;u.prototype.slice=function(t,n){var e=this.length;t=~~t,n=void 0===n?e:~~n,t<0?(t+=e)<0&&(t=0):t>e&&(t=e),n<0?(n+=e)<0&&(n=0):n>e&&(n=e),n0&&(i*=256);)r+=this[t+--n]*i;return r},u.prototype.readUInt8=function(t,n){return n||C(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,n){return n||C(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,n){return n||C(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,n){return n||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,n){return n||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,n,e){t|=0,n|=0,e||C(t,n,this.length);for(var r=this[t],i=1,o=0;++o=i&&(r-=Math.pow(2,8*n)),r},u.prototype.readIntBE=function(t,n,e){t|=0,n|=0,e||C(t,n,this.length);for(var r=n,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o},u.prototype.readInt8=function(t,n){return n||C(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},u.prototype.readInt16LE=function(t,n){n||C(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt16BE=function(t,n){n||C(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt32LE=function(t,n){return n||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,n){return n||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,n){return n||C(t,4,this.length),Z.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,n){return n||C(t,4,this.length),Z.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,n){return n||C(t,8,this.length),Z.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,n){return n||C(t,8,this.length),Z.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,n,e,r){if(t=+t,n|=0,e|=0,!r){L(this,t,n,e,Math.pow(2,8*e)-1,0)}var i=1,o=0;for(this[n]=255&t;++o=0&&(o*=256);)this[n+i]=t/o&255;return n+e},u.prototype.writeUInt8=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=255&t,n+1},u.prototype.writeUInt16LE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):M(this,t,n,!0),n+2},u.prototype.writeUInt16BE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):M(this,t,n,!1),n+2},u.prototype.writeUInt32LE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):U(this,t,n,!0),n+4},u.prototype.writeUInt32BE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):U(this,t,n,!1),n+4},u.prototype.writeIntLE=function(t,n,e,r){if(t=+t,n|=0,!r){var i=Math.pow(2,8*e-1);L(this,t,n,e,i-1,-i)}var o=0,u=1,s=0;for(this[n]=255&t;++o>0)-s&255;return n+e},u.prototype.writeIntBE=function(t,n,e,r){if(t=+t,n|=0,!r){var i=Math.pow(2,8*e-1);L(this,t,n,e,i-1,-i)}var o=e-1,u=1,s=0;for(this[n+o]=255&t;--o>=0&&(u*=256);)t<0&&0===s&&0!==this[n+o+1]&&(s=1),this[n+o]=(t/u>>0)-s&255;return n+e},u.prototype.writeInt8=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=255&t,n+1},u.prototype.writeInt16LE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):M(this,t,n,!0),n+2},u.prototype.writeInt16BE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):M(this,t,n,!1),n+2},u.prototype.writeInt32LE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):U(this,t,n,!0),n+4},u.prototype.writeInt32BE=function(t,n,e){return t=+t,n|=0,e||L(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):U(this,t,n,!1),n+4},u.prototype.writeFloatLE=function(t,n,e){return F(this,t,n,!0,e)},u.prototype.writeFloatBE=function(t,n,e){return F(this,t,n,!1,e)},u.prototype.writeDoubleLE=function(t,n,e){return K(this,t,n,!0,e)},u.prototype.writeDoubleBE=function(t,n,e){return K(this,t,n,!1,e)},u.prototype.copy=function(t,n,e,r){if(e||(e=0),r||0===r||(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n=0;--i)t[i+n]=this[i+e];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var o;if("number"==typeof t)for(o=n;onew Error("Ipfs instance not defined");class u{static create(t,n,e,s,c=[],a){if(!i(t))throw o();if(!i(n))throw new Error("Entry requires an id");if(!i(s))throw new Error("Entry requires data");if(!i(c)||!Array.isArray(c))throw new Error("'next' argument is not an array");let f=c.filter(t=>void 0!==t&&null!==t).map(t=>t.hash?t.hash:t),h={hash:null,id:n,payload:s,next:f,v:0,clock:a?a.clone():new r(n)};return u.toMultihash(t,h).then(t=>{return h.hash=t,h})}static toMultihash(t,e){if(!t)throw o();const r=new n(JSON.stringify(e));return t.object.put(r).then(t=>t.toJSON().multihash)}static fromMultihash(t,n){if(!t)throw o();if(!n)throw new Error(`Invalid hash: ${n}`);return t.object.get(n,{enc:"base58"}).then(t=>JSON.parse(t.toJSON().data)).then(t=>{return{hash:n,id:t.id,payload:t.payload,next:t.next,v:t.v,clock:t.clock}})}static isEntry(t){return void 0!==t.id&&void 0!==t.next&&void 0!==t.hash&&void 0!==t.payload&&void 0!==t.v&&void 0!==t.clock}static compare(t,n){var e=r.compare(t.clock,n.clock);return 0===e?t.clock.id-1}}t.exports=u}).call(n,e(0).Buffer)},function(t,n,e){"use strict";(function(n){const r=e(6).EventEmitter,i=e(34),o=e(3),u=e(8),s=e(41),c=e(48),a={Index:c,maxHistory:256,cachePath:"./orbit-db"};class f{constructor(t,n,e,o){this.id=n,this.dbname=e||"",this.events=new r;let u=Object.assign({},a);Object.assign(u,o),this.options=u,this._ipfs=t,this._index=new this.options.Index(this.id),this._oplog=i.create(this.id),this._lastWrite=[],this._cache=new s(this.options.cachePath,this.dbname),this.syncing=!1,this.syncQueue=[],setInterval(()=>this._processQ(),16),this.syncedOnce=!1}load(t){let n;return this._cache.load().then(()=>this._cache.get(this.dbname)).then(e=>{return e?(n=e,this.events.emit("sync",this.dbname),i.fromMultihash(this._ipfs,e,t||this.options.maxHistory).then(t=>{return this._oplog=i.join(this._oplog,t,-1,this._oplog.id),this._index.updateIndex(this._oplog),this._oplog.heads})):Promise.resolve()}).then(t=>this.events.emit("ready",this.dbname,t))}loadMore(t){const n=this._oplog.items.length;return this.events.emit("sync",this.dbname),i.expand(this._ipfs,this._oplog,t).then(t=>{const e=t.items.length-n;return this._oplog=t,this._index.updateIndex(this._oplog),this.events.emit("synced",this.dbname),e})}loadMoreFrom(t,n){if(n&&!this.loadingMore){this.loadingMore=!0,this.events.emit("sync",this.dbname);const e=new u(this._oplog.tails),r=e.intersection(new u(n.reverse()));return e.keys.includes("QmdUMFtFdZTiaSmuomvB3QzrwpGakhqzvoJgmekHLZs2s6"),i.expandFrom(this._ipfs,this._oplog,r,t).then(t=>{this._oplog=t,this._index.updateIndex(this._oplog),this.loadingMore=!1,this.events.emit("synced",this.dbname)}).catch(t=>console.error(t))}}sync(t,n,e,r=!0,i=-1,o=0){r?this.syncQueue.splice(0,0,{heads:t,tails:n,length:e,max:i,count:o}):this.syncQueue.push({heads:t,tails:n,length:e,max:i,count:o})}_processQ(){if(this.syncQueue&&this.syncQueue.length>0&&!this.syncing){this.syncing=!0;const t=this.syncQueue.shift();t.heads?this._syncFromHeads(t.heads,t.length,t.max,t.count).then(()=>this.syncing=!1).catch(t=>this.events.emit("error",t)):t.tails&&this._syncFromTails(t.tails,t.length,t.max,t.count).then(()=>this.syncing=!1).catch(t=>this.events.emit("error",t))}}_syncFromHeads(t,e,r,u){if(!t)return Promise.resolve();const s=this._oplog.items.map(t=>t.hash);if(t=t.filter(t=>void 0!==t&&null!==t&&o.isEntry(t)),0===t.length||s.find(n=>t.map(t=>t.hash).indexOf(n)>-1))return Promise.resolve();this.events.emit("sync",this.dbname);const c=t=>{const e=Object.assign({},t);return e.hash=null,this._ipfs.object.put(new n(JSON.stringify(e))).then(t=>t.toJSON().multihash)};return e=e||this.options.maxHistory,u=u||0,r=r||this.options.maxHistory,Promise.all(t.map(c)).then(n=>{return i.fromEntry(this._ipfs,t,e,s,this._onLoadProgress.bind(this))}).then(t=>{const n=this._oplog.items.length;if(t.items.length>0){const e=this._oplog.tails.filter(t=>t.next.length>0),o=this._oplog.heads;this._oplog=i.join(this._oplog,t,-1,this._oplog.id),this._index.updateIndex(this._oplog);const s=this._oplog.items.length-n;if(u+=s,this.options.syncHistory&&(r===-1||ut.next.length>0),n=t.filter(t=>!e.map(t=>t.hash).includes(t.hash)),r=(n.map(n=>0!==t.map(t=>t.hash).indexOf(n)?n:null).filter(t=>null!==t),n.reduce((n,e)=>{return 0!==t.map(t=>t.hash).indexOf(e)},!1));if(r)return void this.sync(null,[t[t.length-1]],2*this.options.maxHistory,!1,32,u);const i=this._oplog.heads,c=o.length!==i.length||i.filter((t,n)=>t.hash!==o[n].hash).length>0;c&&s>1&&this.sync(i,null,2*this.options.maxHistory,!1,32,u)}}}).then(()=>i.toMultihash(this._ipfs,this._oplog)).then(t=>{return this._cache.set(this.dbname,t).then(()=>{return this.events.emit("synced",this.dbname),t})}).catch(t=>this.events.emit("error",t))}_syncFromTails(t,n,e,r){if(!t)return Promise.resolve();n=n||this.options.maxHistory,r=r||0,e=e||this.options.maxHistory;const o=this._oplog.items.map(t=>t.hash);this.events.emit("sync",this.dbname);const u=t=>i.fromEntry(this._ipfs,t,n,o,this._onLoadProgress.bind(this));return Promise.all(t.map(u)).then(t=>{const o=this._oplog.items.length,u=this._oplog.tails.filter(t=>t.next.length>0);this._oplog.heads;if(this._oplog=i.joinAll([this._oplog].concat(t),o+n,this._oplog.id),this._index.updateIndex(this._oplog),r+=this._oplog.items.length-o,e===-1||rt.next.length>0),n=t.filter(t=>!u.map(t=>t.hash).includes(t.hash)),e=n.map(n=>0!==t.map(t=>t.hash).indexOf(n)?n:null).filter(t=>null!==t),i=n.reduce((n,e)=>{return 0!==t.map(t=>t.hash).indexOf(e)},!1);i&&this.sync(null,e,2*this.options.maxHistory,!1,32,r)}}).then(()=>i.toMultihash(this._ipfs,this._oplog)).then(t=>{return this._cache.set(this.dbname,t).then(()=>{return this.events.emit("synced",this.dbname),t})}).catch(t=>this.events.emit("error",t))}_addOperation(t){let n;if(this._oplog)return i.append(this._ipfs,this._oplog,t).then(t=>{this._oplog=t}).then(()=>i.toMultihash(this._ipfs,this._oplog)).then(t=>n=t).then(()=>this._cache.set(this.dbname,n)).then(()=>{const t=this._oplog.items[this._oplog.items.length-1];return this._lastWrite.push(n),this._index.updateIndex(this._oplog),this.events.emit("write",this.dbname,n,t,this._oplog.heads),t.hash})}_onLoadProgress(t,n,e,r){this.events.emit("load.progress",this.dbname,r)}}t.exports=f}).call(n,e(0).Buffer)},function(t,n){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function u(t){return void 0===t}t.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(t){if(!i(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},e.prototype.emit=function(t){var n,e,i,s,c,a;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((n=arguments[1])instanceof Error)throw n;var f=new Error('Uncaught, unspecified "error" event. ('+n+")");throw f.context=n,f}if(e=this._events[t],u(e))return!1;if(r(e))switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),e.apply(this,s)}else if(o(e))for(s=Array.prototype.slice.call(arguments,1),a=e.slice(),i=a.length,c=0;c0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(t,n){function e(){this.removeListener(t,e),i||(i=!0,n.apply(this,arguments))}if(!r(n))throw TypeError("listener must be a function");var i=!1;return e.listener=n,this.on(t,e),this},e.prototype.removeListener=function(t,n){var e,i,u,s;if(!r(n))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(e=this._events[t],u=e.length,i=-1,e===n||r(e.listener)&&e.listener===n)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,n);else if(o(e)){for(s=u;s-- >0;)if(e[s]===n||e[s].listener&&e[s].listener===n){i=s;break}if(i<0)return this;1===e.length?(e.length=0,delete this._events[t]):e.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,n)}return this},e.prototype.removeAllListeners=function(t){var n,e;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(n in this._events)"removeListener"!==n&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[t],r(e))this.removeListener(t,e);else if(e)for(;e.length;)this.removeListener(t,e[e.length-1]);return delete this._events[t],this},e.prototype.listeners=function(t){return this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},e.prototype.listenerCount=function(t){if(this._events){var n=this._events[t];if(r(n))return 1;if(n)return n.length}return 0},e.listenerCount=function(t,n){return t.listenerCount(n)}},function(t,n,e){function r(t,n){this._id=t,this._clearFn=n}var i=Function.prototype.apply;n.setTimeout=function(){return new r(i.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new r(i.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(t,n){clearTimeout(t._idleTimeoutId),t._idleTimeout=n},n.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},n._unrefActive=n.active=function(t){clearTimeout(t._idleTimeoutId);var n=t._idleTimeout;n>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},n))},e(76),n.setImmediate=setImmediate,n.clearImmediate=clearImmediate},function(t,n,e){"use strict";const r=e(32),i=e(3),o=(t,n)=>t.concat(n);class u extends r{constructor(t){super(),this._values=t||[]}get values(){return this._values.slice()}get heads(){return u.findHeads(this.values)}get tails(){return u.findTails(this.values)}get tailHashes(){return u.findTailHashes(this.values)}get keys(){return this._values.map(t=>t.hash)}get length(){return this._values.length}append(t){const n=this.values;return n.push(t),new u(n)}has(t){var n=n=>i.isEqual(n,t);return void 0!==this.values.find(n)}get(t){var n=n=>n.hash===t;return this.values.find(n)}sort(){return new u(this.values.sort(i.compare))}last(t=1){return new u(t>-1?this.values.slice(-t):this.values)}slice(t,n){return new u(this.values.slice(t||0,n||this.values.length))}replaceInFront(t){var n=this.values.slice(t.length,this.values.length);return new u(t.values.concat(n))}clone(){return new u(this.values)}merge(t){var n=[];return n=Array.isArray(t)?this.values.reduce(o,[]):this.values.concat(t.values),new u(u._uniques(n)).sort()}difference(t){var n={},e={},r=t=>e[t.hash]=!0;this.values.forEach(r);var i=(t,r)=>{var i=void 0!==e[r.hash],o=void 0!==n[r.hash];return i||o||(t.push(r),n[r.hash]=!0),t};return new u(t.values.reduce(i,[]))}intersection(t){var n={},e={},r=t=>e[t.hash]=!0;this.values.forEach(r);var i=(t,r)=>{var i=void 0!==e[r.hash],o=void 0!==n[r.hash];return i&&!o&&(t.push(r),n[r.hash]=!0),t};return new u(t.values.reduce(i,[]))}static isSet(t){return void 0!==t&&void 0!==t.values&&Array.isArray(t.values)}static sort(t){return t.sort(i.compare)}static has(t,n){var e=t=>i.isEqual(t,n);return void 0!==t.find(e)}static findHeads(t){var n=(t,n,e,r)=>{var i=e=>t[e]=n.hash;return n.next.forEach(i),t},e=t.reduce(n,{}),r=t=>void 0===e[t.hash],i=(t,n)=>t.id>n.id;return t.filter(r).sort(i)}static findTails(t){var n={},e=[],r={},o=[],s=t=>{0===t.next.length&&e.push(t);var i=e=>{n[e]||(n[e]=[]),n[e].push(t)};t.next.forEach(i),o=o.concat(t.next),r[t.hash]=!0};t.forEach(s);var c=(t,n,e,r)=>t.concat(u._uniques(n)),a=t=>void 0===r[t],f=t=>n[t];const h=o.filter(a).map(f).reduce(c,[]).concat(e);return u._uniques(h).sort(i.compare)}static findTailHashes(t){var n={},e=t=>n[t.hash]=!0,r=(t,e,r,i)=>{var o=e=>{void 0===n[e]&&t.splice(0,0,e)};return e.next.reverse().forEach(o),t};return t.forEach(e),t.reduce(r,[])}static findChildren(t,n){for(var e=[],r=t.find(t=>i.isParent(n,t)),o=n;r;)e.push(r),o=r,r=t.find(t=>i.isParent(o,t));return e=e.sort((t,n)=>t.seq>n.seq)}static _uniques(t){const n=(t,n)=>{var e=t=>i.isEqual(t,n);return void 0!==t.find(e)},e=(t,e,r,i)=>{return n(t,e)||t.push(e),t};return t.reduce(e,[])}}t.exports=u},function(t,n,e){"use strict";class r{constructor(t,n){this.id=t,this.time=n||0}tick(){return++this.time}merge(t){return this.time=Math.max(this.time,t.time),this}clone(){return new r(this.id,this.time)}static compare(t,n){var e=t.time-n.time;return 0===e&&t.id!==n.id?t.id1)for(var e=1;e=t.length?o(!0):o(null,t[e++])}}},function(t,n,e){"use strict";var r=e(20);t.exports=function(t){return t=r(t),function(n){return function e(r,i){for(var o,u=!0;u;)u=!1,o=!0,n(r,function(n,r){if(!n&&!t(r))return o?u=!0:e(n,i);i(n,r)}),o=!1}}}},function(t,n,e){"use strict";const r=e(4),i=e(44);class o extends r{constructor(t,n,e,r={}){void 0===r.Index&&Object.assign(r,{Index:i}),super(t,n,e,r)}add(t){return this._addOperation({op:"ADD",key:null,value:t})}get(t){return this.iterator({gte:t,limit:1}).collect()[0]}iterator(t){const n=this._query(t);let e=0;return{[Symbol.iterator](){return this},next(){let t={value:null,done:!0};return en}}_query(t){t||(t={});const n=t.limit?t.limit>-1?t.limit:this._index.get().length:1,e=this._index.get().slice();return t.gt||t.gte?this._read(e,t.gt?t.gt:t.gte,n,!!t.gte):this._read(e.reverse(),t.lt?t.lt:t.lte,n,t.lte||!t.lt).reverse()}_read(t,n,e,r){const i=t.map(t=>t.hash).indexOf(n);let o=Math.max(i,0);return o+=r?0:1,t.slice(o).slice(0,e)}}t.exports=o},function(t,n,e){"use strict";const r=t=>void 0!==t&&null!==t;t.exports=r},function(t,n,e){"use strict";var r=e(63),i=e(57),o=e(69);n=t.exports=e(53);for(var u in r)n[u]=r[u];for(var u in o)n[u]=o[u];for(var u in i)n[u]=i[u]},function(t,n,e){"use strict";var r=e(19);t.exports=function(t,n){return function(e,i){if(e)return r(i,e,n);if(null!=t){var o=t;t=null,i(null,o)}else i(!0)}}},function(t,n,e){"use strict";function r(t){return t}var i=e(2),o=e(13);t.exports=function(t,n){t=i(t)||r;var e={};return o(function(r){var i=t(r);return e[i]?!!n:(e[i]=!0,!n)})}},function(t,n){t.exports=function(t,n,e){t(n),e&&e(n===!0?null:n)}},function(t,n,e){function r(t){return t}var i=e(2);t.exports=function(t){return"object"==typeof t&&"function"==typeof t.test?function(n){return t.test(n)}:i(t)||r}},function(t,n,e){"use strict";const r=e(4),i=e(42);class o extends r{constructor(t,n,e,r={}){r.Index||Object.assign(r,{Index:i}),super(t,n,e,r)}get value(){return this._index.get().value}inc(t){const n=this._index.get();if(n)return n.increment(t),this._addOperation({op:"COUNTER",key:null,value:n.payload,meta:{ts:(new Date).getTime()}})}}t.exports=o},function(t,n,e){"use strict";const r=e(4),i=e(43);class o extends r{constructor(t,n,e,r){r||(r={}),r.indexBy||Object.assign(r,{indexBy:"_id"}),r.Index||Object.assign(r,{Index:i}),super(t,n,e,r)}get(t){return Object.keys(this._index._index).filter(n=>n.indexOf(t)!==-1).map(t=>this._index.get(t))}query(t){return Object.keys(this._index._index).map(t=>this._index.get(t)).filter(n=>t(n))}put(t){return this._addOperation({op:"PUT",key:t[this.options.indexBy],value:t})}del(t){return this._addOperation({op:"DEL",key:t,value:null})}}t.exports=o},function(t,n,e){"use strict";const r=e(14),i=e(45);class o extends r{constructor(t,n,e,r){r||(r={}),r.Index||Object.assign(r,{Index:i}),super(t,n,e,r)}remove(t){const n={op:"DEL",key:null,value:t};return this._addOperation(n)}}t.exports=o},function(t,n,e){"use strict";const r=e(4),i=e(46);class o extends r{constructor(t,n,e,r){let o=Object.assign({},{Index:i});Object.assign(o,r),super(t,n,e,o)}get(t){return this._index.get(t)}set(t,n){return this.put(t,n)}put(t,n){return this._addOperation({op:"PUT",key:t,value:n})}del(t){return this._addOperation({op:"DEL",key:t,value:null})}}t.exports=o},function(t,n,e){t.exports=e(47)},function(t,n,e){"use strict";function r(t){var n=t.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[n-2]?2:"="===t[n-1]?1:0}function i(t){return 3*t.length/4-r(t)}function o(t){var n,e,i,o,u,s,c=t.length;u=r(t),s=new h(3*c/4-u),i=u>0?c-4:c;var a=0;for(n=0,e=0;n>16&255,s[a++]=o>>8&255,s[a++]=255&o;return 2===u?(o=f[t.charCodeAt(n)]<<2|f[t.charCodeAt(n+1)]>>4,s[a++]=255&o):1===u&&(o=f[t.charCodeAt(n)]<<10|f[t.charCodeAt(n+1)]<<4|f[t.charCodeAt(n+2)]>>2,s[a++]=o>>8&255,s[a++]=255&o),s}function u(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function s(t,n,e){for(var r,i=[],o=n;of?f:c+u));return 1===r?(n=t[e-1],i+=a[n>>2],i+=a[n<<4&63],i+="=="):2===r&&(n=(t[e-2]<<8)+t[e-1],i+=a[n>>10],i+=a[n>>4&63],i+=a[n<<2&63],i+="="),o.push(i),o.join("")}n.byteLength=i,n.toByteArray=o,n.fromByteArray=c;for(var a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=l.length;pthis._counters[t]).reduce((t,n)=>t+n,0)}get payload(){return{id:this.id,counters:this._counters}}compare(t){return t.id===this.id&&r(t._counters,this._counters)}merge(t){Object.keys(t._counters).forEach(n=>{this._counters[n]=Math.max(this._counters[n]?this._counters[n]:0,t._counters[n])})}static from(t){return new i(t.id,t.counters)}}t.exports=i},function(t,n,e){"use strict";n.isEqual=((t,n)=>{const e=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(n);if(e.length!==r.length)return!1;for(let r=0;r0;)for(t=an,an=[],e=t.length,n=0;n0);tn=!0,nn=!0}function nt(){var t=en;en=[],t.forEach(function(t){t._PSD.onunhandled.call(null,t._value,t)});for(var n=hn.slice(0),e=n.length;e;)n[--e]()}function et(t){function n(){t(),hn.splice(hn.indexOf(n),1)}hn.push(n),++fn,Xt(function(){0==--fn&&nt()},[])}function rt(t){en.some(function(n){return n._value===t._value})||en.push(t)}function it(t){for(var n=en.length;n;)if(en[--n]._value===t._value)return void en.splice(n,1)}function ot(t){console.warn("Unhandled rejection: "+(t.stack||t))}function ut(t){return new q(Vt,!1,t)}function st(t,n){var e=cn;return function(){var r=X(),i=cn;try{return i!==e&&(cn=e),t.apply(this,arguments)}catch(t){n&&n(t)}finally{i!==e&&(cn=i),r&&tt()}}}function ct(t,n,e,r){var i=cn,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=at(o,t,n,e,r);return 0===o.ref&&o.finalize(),u}function at(t,n,e,r,i){var o=cn;try{return t!==o&&(cn=t),n(e,r,i)}finally{t!==o&&(cn=o)}}function ft(n,e){var r;try{r=e.onuncatched(n)}catch(t){}if(r!==!1)try{var i,o={promise:e,reason:n};if(Pt.document&&document.createEvent?(i=document.createEvent("Event"),i.initEvent(pn,!0,!0),t(i,o)):Pt.CustomEvent&&(i=new CustomEvent(pn,{detail:o}),t(i,o)),i&&Pt.dispatchEvent&&(dispatchEvent(i),!Pt.PromiseRejectionEvent&&Pt.onunhandledrejection))try{Pt.onunhandledrejection(i)}catch(t){}i.defaultPrevented||q.on.error.fire(n,e)}catch(t){}}function ht(t,n){var e=q.reject(t);return n?e.uncaught(n):e}function lt(n,e){function s(){rn.on("versionchange",function(t){t.newVersion>0?console.warn("Another connection wants to upgrade database '"+rn.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+rn.name+"'. Closing db now to resume the delete request."),rn.close()}),rn.on("blocked",function(t){!t.newVersion||t.newVersiont}).forEach(function(t){i.push(function(){var r=Jt,i=t._cfg.dbschema;Bt(r,e),Bt(i,e),Jt=rn._dbSchema=i;var o=j(r,i);if(o.add.forEach(function(t){B(e,t[0],t[1].primKey,t[1].indexes)}),o.change.forEach(function(t){if(t.recreate)throw new Gt.Upgrade("Not yet support for changing primary key");var n=e.objectStore(t.name);t.add.forEach(function(t){U(n,t)}),t.change.forEach(function(t){n.deleteIndex(t.name),U(n,t)}),t.del.forEach(function(t){n.deleteIndex(t)})}),t._cfg.contentUpgrade)return u=!0,q.follow(function(){t._cfg.contentUpgrade(n)})}),i.push(function(n){u&&_n||M(t._cfg.dbschema,n)})}),r().then(function(){C(Jt,e)})}function j(t,n){var e={del:[],add:[],change:[]};for(var r in t)n[r]||e.del.push(r);for(r in n){var i=t[r],o=n[r];if(i){var u={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)u.recreate=!0,e.change.push(u);else{var s=i.idxByName,c=o.idxByName;for(var a in s)c[a]||u.del.push(a);for(a in c){var f=s[a],h=c[a];f?f.src!==h.src&&u.change.push(h):u.add.push(h)}(u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,o])}return e}function B(t,n,e,r){var i=t.db.createObjectStore(n,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(t){U(i,t)}),i}function C(t,n){Ot(t).forEach(function(e){n.db.objectStoreNames.contains(e)||B(n,e,t[e].primKey,t[e].indexes)})}function M(t,n){for(var e=0;e0?t:n}function pt(t,n){return zt.cmp(t,n)}function Pt(t,n){return zt.cmp(n,t)}function St(t,n){return tn?-1:t===n?0:1}function jt(t,n){return t?n?function(){return t.apply(this,arguments)&&n.apply(this,arguments)}:t:n}function Rt(){if(rn.verno=$t.version/10,rn._dbSchema=Jt={},Vt=c($t.objectStoreNames,0),0!==Vt.length){var t=$t.transaction(kt(Vt),"readonly");Vt.forEach(function(n){for(var e=t.objectStore(n),r=e.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1,o=new xt(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),u=[],s=0;s0&&(sn=!1),!zt)throw new Gt.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var i=sn?zt.open(n):zt.open(n,Math.round(10*rn.verno));if(!i)throw new Gt.MissingAPI("IndexedDB API not available");i.onerror=st(gt(r)),i.onblocked=st(Dt),i.onupgradeneeded=st(function(t){if(e=i.transaction,sn&&!rn._allowEmptyDB){i.onerror=bt,e.abort(),i.result.close();var o=zt.deleteDatabase(n);o.onsuccess=o.onerror=st(function(){r(new Gt.NoSuchDatabase("Database "+n+" doesnt exist"))})}else{e.onerror=st(gt(r));m((t.oldVersion>Math.pow(2,62)?0:t.oldVersion)/10,e,r,i)}},r),i.onsuccess=st(function(){if(e=null,$t=i.result,bn.push(rn),sn)Rt();else if($t.objectStoreNames.length>0)try{Bt(Jt,$t.transaction(kt($t.objectStoreNames),nn))}catch(t){}$t.onversionchange=st(function(t){rn._vcFired=!0,rn.on("versionchange").fire(t)}),an||wt(function(t){if(t.indexOf(n)===-1)return t.push(n)}),t()},r)})]).then(function(){return lt.vip(rn.on.ready.fire)}).then(function(){return Xt=!1,rn}).catch(function(t){try{e&&e.abort()}catch(t){}return Xt=!1,rn.close(),Zt=t,ht(Zt,K)}).finally(function(){tn=!0,t()})},this.close=function(){var t=bn.indexOf(rn);if(t>=0&&bn.splice(t,1),$t){try{$t.close()}catch(t){}$t=null}qt=!1,Zt=new Gt.DatabaseClosed,Xt&&Ut(Zt),on=new q(function(t){Lt=t}),un=new q(function(t,n){Ut=n})},this.delete=function(){var t=arguments.length>0;return new q(function(e,r){function i(){rn.close();var t=zt.deleteDatabase(n);t.onsuccess=st(function(){an||wt(function(t){var e=t.indexOf(n);if(e>=0)return t.splice(e,1)}),e()}),t.onerror=st(gt(r)),t.onblocked=Dt}if(t)throw new Gt.InvalidArgument("Arguments not allowed in db.delete()");Xt?on.then(i):i()}).uncaught(K)},this.backendDB=function(){return $t},this.isOpen=function(){return null!==$t},this.hasFailed=function(){return null!==Zt},this.dynamicallyOpened=function(){return sn},this.name=n,o(this,"tables",{get:function(){return Ot(Qt).map(function(t){return Qt[t]})}}),this.on=Y(this,"error","populate","blocked","versionchange",{ready:[R,k]}),this.on.error.subscribe=L("Dexie.on.error",this.on.error.subscribe),this.on.error.unsubscribe=L("Dexie.on.error.unsubscribe",this.on.error.unsubscribe),this.on.ready.subscribe=a(this.on.ready.subscribe,function(t){return function(n,e){lt.vip(function(){tn?(Zt||q.resolve().then(n),e&&t(n)):(t(n),e||t(function t(){rn.on.ready.unsubscribe(n),rn.on.ready.unsubscribe(t)}))})}}),kn(function(){rn.on("populate").fire(rn._createTransaction(en,Vt,Jt)),rn.on("error").fire(new Error)}),this.transaction=function(t,n,e){function i(n){var i=cn;n(q.resolve().then(function(){return ct(function(){cn.transless=cn.transless||i;var n=rn._createTransaction(t,f,Jt,c);cn.trans=n,c?n.idbtrans=c.idbtrans:n.create();var o=f.map(function(t){return Qt[t]});o.push(n);var u;return q.follow(function(){if(u=e.apply(n,o))if("function"==typeof u.next&&"function"==typeof u.throw)u=_t(u);else if("function"==typeof u.then&&!r(u,"_PSD"))throw new Gt.IncompatiblePromise("Incompatible Promise returned from transaction scope (read more at http://tinyurl.com/znyqjqc). Transaction scope: "+e.toString())}).uncaught(K).then(function(){return c&&n._resolve(),n._completion}).then(function(){return u}).catch(function(t){return n._reject(t),ht(t)})})}))}var o=arguments.length;if(o<2)throw new Gt.InvalidArgument("Too few arguments");for(var u=new Array(o-1);--o;)u[o-1]=arguments[o];e=u.pop();var s=E(u),c=cn.trans;c&&c.db===rn&&t.indexOf("!")===-1||(c=null);var a=t.indexOf("?")!==-1;t=t.replace("!","").replace("?","");try{var f=s.map(function(t){var n=t instanceof H?t.name:t;if("string"!=typeof n)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n});if("r"==t||t==nn)t=nn;else{if("rw"!=t&&t!=en)throw new Gt.InvalidArgument("Invalid transaction mode: "+t);t=en}if(c){if(c.mode===nn&&t===en){if(!a)throw new Gt.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");c=null}c&&f.forEach(function(t){if(c&&c.storeNames.indexOf(t)===-1){if(!a)throw new Gt.SubTransaction("Table "+t+" not included in parent transaction.");c=null}})}}catch(t){return c?c._promise(null,function(n,e){e(t)}):ht(t,K)}return c?c._promise(t,i,"lock"):rn._whenReady(i)},this.table=function(t){if(An&&sn)return new G(t);if(!r(Qt,t))throw new Gt.InvalidTable("Table "+t+" does not exist");return Qt[t]},i(H.prototype,{_trans:function(t,n,e){var r=cn.trans;return r&&r.db===rn?r._promise(t,n,e):z(t,[this.name],n)},_idbstore:function(t,n,e){function r(t,e,r){n(t,e,r.idbtrans.objectStore(o),r)}if(An)return new q(n);var i=cn.trans,o=this.name;return i&&i.db===rn?i._promise(t,r,e):z(t,[this.name],r)},get:function(t,n){var e=this;return this._idbstore(nn,function(n,r,i){An&&n(e.schema.instanceTemplate);var o=i.get(t);o.onerror=gt(r),o.onsuccess=st(function(){n(e.hook.reading.fire(o.result))},r)}).then(n)},where:function(t){return new Q(this,t)},count:function(t){return this.toCollection().count(t)},offset:function(t){return this.toCollection().offset(t)},limit:function(t){return this.toCollection().limit(t)},reverse:function(){return this.toCollection().reverse()},filter:function(t){return this.toCollection().and(t)},each:function(t){return this.toCollection().each(t)},toArray:function(t){return this.toCollection().toArray(t)},orderBy:function(t){return new this._collClass(new Q(this,t))},toCollection:function(){return new this._collClass(new Q(this))},mapToClass:function(t,n){this.schema.mappedClass=t;var e=Object.create(t.prototype);n&&dt(e,n),this.schema.instanceTemplate=e;var i=function(n){if(!n)return n;var e=Object.create(t.prototype);for(var i in n)if(r(n,i))try{e[i]=n[i]}catch(t){}return e};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),t},defineClass:function(t){return this.mapToClass(lt.defineClass(t),t)}}),u(G).from(H).extend({bulkDelete:function(t){return this.hook.deleting.fire===k?this._idbstore(en,function(n,e,r,i){n(W(r,i,t,!1,k))}):this.where(":id").anyOf(t).delete().then(function(){})},bulkPut:function(t,n){var e=this;return this._idbstore(en,function(r,i,o){if(!o.keyPath&&!e.schema.primKey.auto&&!n)throw new Gt.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(o.keyPath&&n)throw new Gt.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==t.length)throw new Gt.InvalidArgument("Arguments objects and keys must have the same length");if(0===t.length)return r();var u,s,c=function(t){0===a.length?r(t):i(new F(e.name+".bulkPut(): "+a.length+" of "+f+" operations failed",a))},a=[],f=t.length,h=e;if(e.hook.creating.fire===k&&e.hook.updating.fire===k){s=J(a);for(var l=0,d=t.length;l=0;--i){var o=v[i];(null==o||g[o])&&(e.push(t[i]),n&&r.push(o),null!=o&&(g[o]=null))}return e.reverse(),n&&r.reverse(),h.bulkAdd(e,r)}).then(function(t){var n=v[v.length-1];return null!=n?n:t}):h.bulkAdd(t)).then(c).catch(F,function(t){a=a.concat(t.failures),c()}).catch(i)}},"locked")},bulkAdd:function(t,n){var e=this,r=this.hook.creating.fire;return this._idbstore(en,function(i,o,u,s){function c(t){0===l.length?i(t):o(new F(e.name+".bulkAdd(): "+l.length+" of "+p+" operations failed",l))}if(!u.keyPath&&!e.schema.primKey.auto&&!n)throw new Gt.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(u.keyPath&&n)throw new Gt.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==t.length)throw new Gt.InvalidArgument("Arguments objects and keys must have the same length");if(0===t.length)return i();var a,f,h,l=[],p=t.length;if(r!==k){var d,m=u.keyPath;f=J(l,null,!0),h=yt(null),v(function(){for(var e=0,i=t.length;e0&&!this._locked();){var t=this._blockedFuncs.shift();try{at(t[1],t[0])}catch(t){}}return this},_locked:function(){return this._reculock&&cn.lockOwnerFor!==this},create:function(t){var n=this;if(h(!this.idbtrans),!t&&!$t)switch(Zt&&Zt.name){case"DatabaseClosedError":throw new Gt.DatabaseClosed(Zt);case"MissingAPIError":throw new Gt.MissingAPI(Zt.message,Zt);default:throw new Gt.OpenFailed(Zt)}if(!this.active)throw new Gt.TransactionInactive;return h(null===this._completion._state),t=this.idbtrans=t||$t.transaction(kt(this.storeNames),this.mode),t.onerror=st(function(e){bt(e),n._reject(t.error)}),t.onabort=st(function(t){bt(t),n.active&&n._reject(new Gt.Abort),n.active=!1,n.on("abort").fire(t)}),t.oncomplete=st(function(){n.active=!1,n._resolve()}),this},_promise:function(t,n,e){var r=this,i=r._locked()?new q(function(i,o){r._blockedFuncs.push([function(){r._promise(t,n,e).then(i,o)},cn])}):ct(function(){var i=r.active?new q(function(i,o){if(t===en&&r.mode!==en)throw new Gt.ReadOnly("Transaction is readonly");!r.idbtrans&&t&&r.create(),e&&r._lock(),n(i,o,r)}):ht(new Gt.TransactionInactive);return r.active&&e&&i.finally(function(){r._unlock()}),i});return i._lib=!0,i.uncaught(K)},abort:function(){this.active&&this._reject(new Gt.Abort),this.active=!1},tables:{get:L("Transaction.tables",function(){return p(this.storeNames,function(t){return[t,Qt[t]]})},"Use db.tables()")},complete:L("Transaction.complete()",function(t){return this.on("complete",t)}),error:L("Transaction.error()",function(t){return this.on("error",t)}),table:L("Transaction.table()",function(t){if(this.storeNames.indexOf(t)===-1)throw new Gt.InvalidTable("Table "+t+" not in transaction");return Qt[t]})}),i(Q.prototype,function(){function t(t,n,e){var r=t instanceof Q?new t._ctx.collClass(t):t;return r._ctx.error=e?new e(n):new TypeError(n),r}function n(t){return new t._ctx.collClass(t,function(){return Ht.only("")}).limit(0)}function e(t){return"next"===t?function(t){return t.toUpperCase()}:function(t){return t.toLowerCase()}}function r(t){return"next"===t?function(t){return t.toLowerCase()}:function(t){return t.toUpperCase()}}function i(t,n,e,r,i,o){for(var u=Math.min(t.length,r.length),s=-1,c=0;c=0?t.substr(0,s)+n[s]+e.substr(s+1):null;i(t[c],a)<0&&(s=c)}return u0)&&(s=a)}return n(null!==s?function(){t.continue(s+v)}:e),!1}),g}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return ot(e,r)>0||0===ot(e,r)&&(i||o)&&(!i||!o)?n(this):new this._ctx.collClass(this,function(){return Ht.bound(e,r,!i,!o)})}catch(n){return t(this,gn)}},equals:function(t){return new this._ctx.collClass(this,function(){return Ht.only(t)})},above:function(t){return new this._ctx.collClass(this,function(){return Ht.lowerBound(t,!0)})},aboveOrEqual:function(t){return new this._ctx.collClass(this,function(){return Ht.lowerBound(t)})},below:function(t){return new this._ctx.collClass(this,function(){return Ht.upperBound(t,!0)})},belowOrEqual:function(t){return new this._ctx.collClass(this,function(){return Ht.upperBound(t)})},startsWith:function(n){return"string"!=typeof n?t(this,mn):this.between(n,n+vn,!0,!0)},startsWithIgnoreCase:function(t){return""===t?this.startsWith(t):o(this,function(t,n){return 0===t.indexOf(n[0])},[t],vn)},equalsIgnoreCase:function(t){return o(this,function(t,n){return t===n[0]},[t],"")},anyOfIgnoreCase:function(){var t=x.apply(Ct,arguments);return 0===t.length?n(this):o(this,function(t,n){return n.indexOf(t)!==-1},t,"")},startsWithAnyOfIgnoreCase:function(){var t=x.apply(Ct,arguments);return 0===t.length?n(this):o(this,function(t,n){return n.some(function(n){return 0===t.indexOf(n)})},t,vn)},anyOf:function(){var e=x.apply(Ct,arguments),r=pt;try{e.sort(r)}catch(n){return t(this,gn)}if(0===e.length)return n(this);var i=new this._ctx.collClass(this,function(){return Ht.bound(e[0],e[e.length-1])});i._ondirectionchange=function(t){r="next"===t?pt:Pt,e.sort(r)};var o=0;return i._addAlgorithm(function(t,n,i){for(var u=t.key;r(u,e[o])>0;)if(++o===e.length)return n(i),!1;return 0===r(u,e[o])||(n(function(){t.continue(e[o])}),!1)}),i},notEqual:function(t){return this.inAnyRange([[-(1/0),t],[t,yn]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var n=x.apply(Ct,arguments);if(0===n.length)return new this._ctx.collClass(this);try{n.sort(pt)}catch(n){return t(this,gn)}var e=n.reduce(function(t,n){return t?t.concat([[t[t.length-1][1],n]]):[[-(1/0),n]]},null);return e.push([n[n.length-1],yn]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(t,n){for(var e=0,r=t.length;e0){i[0]=ut(i[0],n[0]),i[1]=ft(i[1],n[1]);break}}return e===r&&t.push(n),t}function o(t,n){return h(t[0],n[0])}function u(t){return!p(t)&&!d(t)}var s=this._ctx;if(0===e.length)return n(this);if(!e.every(function(t){return void 0!==t[0]&&void 0!==t[1]&&pt(t[0],t[1])<=0}))return t(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Gt.InvalidArgument);var c,a=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,h=pt;try{c=e.reduce(i,[]),c.sort(o)}catch(n){return t(this,gn)}var l=0,p=f?function(t){return pt(t,c[l][1])>0}:function(t){return pt(t,c[l][1])>=0},d=a?function(t){return Pt(t,c[l][0])>0}:function(t){return Pt(t,c[l][0])>=0},v=p,y=new s.collClass(this,function(){return Ht.bound(c[0][0],c[c.length-1][1],!a,!f)});return y._ondirectionchange=function(t){"next"===t?(v=p,h=pt):(v=d,h=Pt),c.sort(o)},y._addAlgorithm(function(t,n,e){for(var r=t.key;v(r);)if(++l===c.length)return n(e),!1;return!!u(r)||0!==ot(r,c[l][1])&&0!==ot(r,c[l][0])&&(n(function(){h===pt?t.continue(c[l][0]):t.continue(c[l][1])}),!1)}),y},startsWithAnyOf:function(){var e=x.apply(Ct,arguments);return e.every(function(t){return"string"==typeof t})?0===e.length?n(this):this.inAnyRange(e.map(function(t){return[t,t+vn]})):t(this,"startsWithAnyOf() only works with strings")}}}),i($.prototype,function(){function n(t,n){t.filter=jt(t.filter,n)}function e(t,n,e){var r=t.replayFilter;t.replayFilter=r?function(){return jt(r(),n())}:n,t.justLimit=e&&!r}function i(t,n){t.isMatch=jt(t.isMatch,n)}function o(t,n){if(t.isPrimKey)return n;var e=t.table.schema.idxByName[t.index];if(!e)throw new Gt.Schema("KeyPath "+t.index+" on object store "+n.name+" is not indexed");return n.index(e.name)}function u(t,n){var e=o(t,n);return t.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(t.range||null,t.dir+t.unique):e.openCursor(t.range||null,t.dir+t.unique)}function s(t,n,e,i,o){var s=t.replayFilter?jt(t.filter,t.replayFilter()):t.filter;t.or?function(){function c(){2==++h&&e()}function a(t,e,o){if(!s||s(e,o,c,i)){var u=e.primaryKey.toString();r(f,u)||(f[u]=!0,n(t,e,o))}}var f={},h=0;t.or._iterate(a,c,i,o),rt(u(t,o),t.algorithm,a,c,i,!t.keysOnly&&t.valueMapper)}():rt(u(t,o),jt(t.algorithm,s),n,e,i,!t.keysOnly&&t.valueMapper)}function c(t){return t.table.schema.instanceTemplate}return{_read:function(t,n){var e=this._ctx;return e.error?e.table._trans(null,function(t,n){n(e.error)}):e.table._idbstore(nn,t).then(n)},_write:function(t){var n=this._ctx;return n.error?n.table._trans(null,function(t,e){e(n.error)}):n.table._idbstore(en,t,"locked")},_addAlgorithm:function(t){var n=this._ctx;n.algorithm=jt(n.algorithm,t)},_iterate:function(t,n,e,r){return s(this._ctx,t,n,e,r)},clone:function(n){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return n&&t(r,n),e._ctx=r,e},raw:function(){return this._ctx.valueMapper=null,this},each:function(t){var n=this._ctx;if(An){var e=c(n),r=n.table.schema.primKey.keyPath;t(e,{key:y(e,n.index?n.table.schema.idxByName[n.index].keyPath:r),primaryKey:y(e,r)})}return this._read(function(e,r,i){s(n,t,e,r,i)})},count:function(t){if(An)return q.resolve(0).then(t);var n=this._ctx;if(Z(n,!0))return this._read(function(t,e,r){var i=o(n,r),u=n.range?i.count(n.range):i.count();u.onerror=gt(e),u.onsuccess=function(e){t(Math.min(e.target.result,n.limit))}},t);var e=0;return this._read(function(t,r,i){s(n,function(){return++e,!1},function(){t(e)},r,i)},t)},sortBy:function(t,n){function e(t,n){return n?e(t[i[n]],n-1):t[o]}function r(t,n){var r=e(t,u),i=e(n,u);return ri?s:0}var i=t.split(".").reverse(),o=i[0],u=i.length-1,s="next"===this._ctx.dir?1:-1;return this.toArray(function(t){return t.sort(r)}).then(n)},toArray:function(t){var n=this._ctx;return this._read(function(t,e,r){if(An&&t([c(n)]),Nt&&"next"===n.dir&&Z(n,!0)&&n.limit>0){var i=n.table.hook.reading.fire,u=o(n,r),a=n.limit<1/0?u.getAll(n.range,n.limit):u.getAll(n.range);a.onerror=gt(e),a.onsuccess=i===A?vt(t):st(vt(function(n){try{t(n.map(i))}catch(t){e(t)}}))}else{var f=[];s(n,function(t){f.push(t)},function(){t(f)},e,r)}},t)},offset:function(t){var n=this._ctx;return t<=0?this:(n.offset+=t,Z(n)?e(n,function(){var n=t;return function(t,e){return 0===n||(1===n?(--n,!1):(e(function(){t.advance(n),n=0}),!1))}}):e(n,function(){var n=t;return function(){return--n<0}}),this)},limit:function(t){return this._ctx.limit=Math.min(this._ctx.limit,t),e(this._ctx,function(){var n=t;return function(t,e,r){return--n<=0&&e(r),n>=0}},!0),this},until:function(t,e){var r=this._ctx;return An&&t(c(r)),n(this._ctx,function(n,r,i){return!t(n.value)||(r(i),e)}),this},first:function(t){return this.limit(1).toArray(function(t){return t[0]}).then(t)},last:function(t){return this.reverse().first(t)},filter:function(t){return An&&t(c(this._ctx)),n(this._ctx,function(n){return t(n.value)}),i(this._ctx,t),this},and:function(t){return this.filter(t)},or:function(t){return new Q(this._ctx.table,t,this)},reverse:function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},desc:function(){return this.reverse()},eachKey:function(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,e){t(e.key,e)})},eachUniqueKey:function(t){return this._ctx.unique="unique",this.eachKey(t)},eachPrimaryKey:function(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,e){t(e.primaryKey,e)})},keys:function(t){var n=this._ctx;n.keysOnly=!n.isMatch;var e=[];return this.each(function(t,n){e.push(n.key)}).then(function(){return e}).then(t)},primaryKeys:function(t){var n=this._ctx;if(Nt&&"next"===n.dir&&Z(n,!0)&&n.limit>0)return this._read(function(t,e,r){var i=o(n,r),u=n.limit<1/0?i.getAllKeys(n.range,n.limit):i.getAllKeys(n.range);u.onerror=gt(e),u.onsuccess=vt(t)}).then(t);n.keysOnly=!n.isMatch;var e=[];return this.each(function(t,n){e.push(n.primaryKey)}).then(function(){return e}).then(t)},uniqueKeys:function(t){return this._ctx.unique="unique",this.keys(t)},firstKey:function(t){return this.limit(1).keys(function(t){return t[0]}).then(t)},lastKey:function(t){return this.reverse().firstKey(t)},distinct:function(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var i={};return n(this._ctx,function(t){var n=t.primaryKey.toString(),e=r(i,n);return i[n]=!0,!e}),this}}}),u(X).from($).extend({modify:function(n){var e=this,i=this._ctx,o=i.table.hook,u=o.updating.fire,s=o.deleting.fire;return An&&"function"==typeof n&&n.call({value:i.table.schema.instanceTemplate},i.table.schema.instanceTemplate),this._write(function(i,o,c,a){function f(t,n){function e(t){return T.push(t),P.push(i.primKey),l(),!0}S=n.primaryKey;var i={primKey:n.primaryKey,value:t,onsuccess:null,onerror:null};if(p.call(i,t,i)!==!1){var o=!r(i,"value");++E,v(function(){var t=o?n.delete():n.update(i.value);t._hookCtx=i,t.onerror=mt(e),t.onsuccess=yt(function(){++A,l()})},e)}else i.onsuccess&&i.onsuccess(i.value)}function h(t){return t&&(T.push(t),P.push(S)),o(new N("Error modifying one or more objects",T,A,P))}function l(){O&&A+T.length===E&&(T.length>0?h():i(A))}var p;if("function"==typeof n)p=u===k&&s===k?n:function(t){var e=w(t);if(n.call(this,t,this)===!1)return!1;if(r(this,"value")){var i=_(e,this.value),o=u.call(this,i,this.primKey,e,a);o&&(t=this.value,Ot(o).forEach(function(n){g(t,n,o[n])}))}else s.call(this,this.primKey,t,a)};else if(u===k){var d=Ot(n),m=d.length;p=function(t){for(var e=!1,r=0;r99?t.push(n.concat(e)):t[o(t)]=n.concat(u(t).concat(e)),t}if(c)return e(c);var l=r.table;i.resolve(v(d(100,10),f(a,h,100,e)))}),i):(e(new Error("Missing key")),i)}},{key:"read",value:function(t){var n=this,e=h();return t?(this.exists(t,function(r,i){return r?e.end(r):i?void n.table.where("key").equals(t).each(function(t){return e.push(l(t.blob))}).catch(function(t){return e.end(t)}).then(function(){return e.end()}):e.end(new Error("Not found"))}),e):(e.end(new Error("Missing key")),e)}},{key:"exists",value:function(t,n){if(n=n||function(){},!t)return n(new Error("Missing key"));this.table.where("key").equals(t).count().then(function(t){return n(null,Boolean(t))}).catch(n)}},{key:"remove",value:function(t,n){if(n=n||function(){},!t)return n(new Error("Missing key"));var e=this.table.where("key").equals(t);e.count(function(t){return t>0?e.delete():null}).then(function(){return n()}).catch(n)}},{key:"table",get:function(){return this.db[this.path]}}]),t}()}).call(n,e(0).Buffer)},function(t,n){n.read=function(t,n,e,r,i){var o,u,s=8*i-r-1,c=(1<>1,f=-7,h=e?i-1:0,l=e?-1:1,p=t[n+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[n+h],h+=l,f-=8);for(u=o&(1<<-f)-1,o>>=-f,f+=r;f>0;u=256*u+t[n+h],h+=l,f-=8);if(0===o)o=1-a;else{if(o===c)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,r),o-=a}return(p?-1:1)*u*Math.pow(2,o-r)},n.write=function(t,n,e,r,i,o){var u,s,c,a=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,v=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(s=isNaN(n)?1:0,u=f):(u=Math.floor(Math.log(n)/Math.LN2),n*(c=Math.pow(2,-u))<1&&(u--,c*=2),n+=u+h>=1?l/c:l*Math.pow(2,1-h),n*c>=2&&(u++,c/=2),u+h>=f?(s=0,u=f):u+h>=1?(s=(n*c-1)*Math.pow(2,i),u+=h):(s=n*Math.pow(2,h-1)*Math.pow(2,i),u=0));i>=8;t[e+p]=255&s,p+=d,s/=256,i-=8);for(u=u<0;t[e+p]=255&u,p+=d,u/=256,a-=8);t[e+p-d]|=128*v}},function(t,n,e){"use strict";class r{constuctor(t){}append(t){}merge(t){}get(t){}has(t){}get values(){}get length(){}}t.exports=r},function(t,n,e){"use strict";const r=e(50),i=e(49),o=e(3);class u{static fetchParallel(t,n,e,r=[],o){const s=n=>u.fetchAll(t,n,e,r),c=(t,n)=>t.concat(n),a=t=>t.reduce(c,[]);return i(n,s,{concurrency:Math.max(o||n.length,1)}).then(a)}static fetchAll(t,n,e,i=[],u=2e3){let s=[],c={},a=Array.isArray(n)?n.slice():[n];const f=t=>a.push(t);var h=t=>c[t.hash]=t;return i.forEach(h),r(()=>{return a.length>0&&(s.length{const n=a.shift();if(c[n]){const t=c[n];return t.next.forEach(f),Promise.resolve()}return new Promise((e,r)=>{const i=setTimeout(e,u),a=t=>{clearTimeout(i),o.isEntry(t)&&(t.next.forEach(f),s.push(t),c[n]=t)};o.fromMultihash(t,n).then(a).then(e)})}).then(()=>s)}}t.exports=u},function(t,n,e){"use strict";const r=e(15),i=e(35),o=e(33),u=e(3),s=e(8),c=e(9),a=()=>new Error("Ipfs instance not defined"),f=()=>new Error("Log instance not defined"),h=()=>new Error("Given argument is not an instance of Log");class l{static create(t,n,e,o,a=-1,f=!1){if(r(n)&&!s.isSet(n)&&!Array.isArray(n))throw new Error(`'entries' argument must be an EntrySet or an array of Entry instances`);if(r(e)&&!Array.isArray(e))throw new Error(`'heads' argument must be an array`);if(s.isSet(n)||(n=new s(n)),f||(n=n.sort()),a>-1&&(n=n.slice(-a)),e=r(e)?e.map(t=>u.isEntry(t)?t:n.get(t)):n.heads,!r(t)){if(!r(n)||0===n.length)throw new Error("Log requires an id");t=o?o.id:n.get(e[0].hash).clock.id}if(!r(o)&&r(n)){const e=n.values.slice(-1)[0];o=new c(t,e?e.clock.time:null)}return new i(t,n,e,o)}static append(t,n,e){if(!r(t))throw a();if(!r(n))throw f();if(!l.isLog(n))throw h();n.clock.tick();const i=t=>n.append(t);return u.create(t,n.id,null,e,n.heads,n.clock).then(i)}static join(t,n,e,i){if(!r(t)||!r(n))throw f();if(!l.isLog(t))throw h();if(!l.isLog(n))throw h();e=e&&e>-1?e:t.length+n.length,i=i?i:[t,n].sort((t,n)=>t.id>n.id)[0].id;const o=t.entries.merge(n.entries),u=[t.clock,n.clock].sort((t,n)=>t.id===i?-1:t.id>n.id);let s=new c(i,u[0].time);return s.merge(u[1]),l.create(i,o,null,s,e)}static joinAll(t,n){return t.reduce((t,e,r)=>{return t?l.join(t,e,n):e},null)}static isLog(t){return void 0!==t.id&&void 0!==t.heads&&void 0!==t.values}static expand(t,n,e=-1){if(!r(t))throw a();if(!r(n))throw f();if(!l.isLog(n))throw h();return 0===n.tailHashes.length?Promise.resolve(l.create(n.id,n.entries,n.heads,n.clock,-1,!0)):o.fetchParallel(t,n.tailHashes,e,n.values).then(t=>new s(t)).then(t=>{const r=e>-1?n.entries.length+e:-1,i=n.entries.merge(t).last(r),o=i.difference(n.entries),u=n.entries.difference(i),s=n.entries.intersection(i),c=r-(s.length+o.length),a=u.last(c),f=s.merge(a).merge(o);return l.create(n.id,f,null,n.clock,r)})}static expandFrom(t,n,e,i=-1){if(!r(t))throw a();if(!r(n))throw f();if(!r(e))throw new Error(`'entries' must be given as argument`);if(!l.isLog(n))throw h();Array.isArray(e)||s.isSet(e)||(e=[e]),s.isSet(e)||(e=new s(e));const u=e.values.map(t=>t.next).filter(t=>t.length>0);return 0===u.length?Promise.resolve(l.create(n.id,n.entries,n.heads,n.clock,-1,!0)):o.fetchParallel(t,u,i,n.values,u.length).then(t=>new s(t)).then(t=>{const e=i>-1?n.entries.length+i:-1,r=n.entries.merge(t.slice(0,i));return l.create(n.id,r,null,n.clock,e)})}static fromEntry(t,n,e=-1,i,c){if(!r(t))throw a();if(!r(n))throw new Error("'sourceEntries' must be defined");if(!s.isSet(n)&&!Array.isArray(n)&&!u.isEntry(n))throw new Error(`'sourceEntries' argument must be an EntrySet, an array of Entry instances or a single Entry`);n&&!s.isSet(n)&&(Array.isArray(n)||(n=[n]),n=new s(n)),e=e>-1?Math.max(e,n.length):e;const f=i?i.map(t=>t.hash?t.hash:t):i;return o.fetchParallel(t,n.keys,e,f).then(t=>new s(t)).then(t=>{const r=n.merge(t).last(e),i=r.difference(n),o=r.replaceInFront(i);return l.create(null,o)})}static fromMultihash(t,n,e=-1,i,u){if(!r(t))throw a();if(!r(n))throw new Error(`Invalid hash: ${n}`);return t.object.get(n,{enc:"base58"}).then(t=>JSON.parse(t.toJSON().data)).then(n=>{if(!n.heads||!n.id)throw h();return o.fetchAll(t,n.heads,e,i).then(t=>l.create(n.id,t,n.heads))})}static toMultihash(t,n){if(!r(t))throw a();if(!r(n))throw f();if(!l.isLog(n))throw h();if(n.values.length<1)throw new Error(`Can't serialize an empty log`);if(n.heads.length<1)throw new Error(`Can't serialize a log without heads`);return t.object.put(n.toBuffer()).then(t=>t.toJSON().multihash)}}t.exports=l},function(t,n,e){"use strict";(function(n){const r=e(8),i=e(9),o=()=>(new Date).getTime();class u{constructor(t,n,e,u){this._id=t||o(),this._clock=u||new i(this.id),this._entries=n||new r,this._heads=e||this.entries.heads}get id(){return this._id}get clock(){return this._clock}get items(){return this.entries.values}get values(){return this.entries.values}get entries(){return this._entries}get heads(){return this._heads}get tails(){return this.entries.tails}get tailHashes(){return this.entries.tailHashes}get length(){return this.entries.length}get(t){return this.entries.get(t)}append(t){const n=this.entries.append(t);return new u(this.id,n,[t],this.clock)}toJSON(){return{id:this.id,heads:this.heads.map(t=>t.hash)}}toBuffer(){return new n(JSON.stringify(this.toJSON()))}toString(){return this.items.slice().reverse().map((t,n)=>{const e=r.findChildren(this.entries.values,t),i=e.length;let o=new Array(Math.max(i-1,0));return o=i>1?o.fill(" "):o,o=i>0?o.concat(["└─"]):o,o.join("")+t.payload}).join("\n")}}t.exports=u}).call(n,e(0).Buffer)},function(t,n){function e(t){return r(t)||i(t)}function r(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function i(t){return u[o.call(t)]}t.exports=e,e.strict=r,e.loose=i;var o=Object.prototype.toString,u={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},function(t,n){var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},function(t,n,e){(function(n){t.exports=function(){function t(t,n){return function(r){return function(){e(t,n),r&&r.apply(null,arguments)}}}function e(n,e){var r=s[n].indexOf(e);~r&&(s[n].splice(r,1),o(n)?u(function(){s[n][0](t(n,s[n][0]))}):delete s[n])}function r(t,n){return o(t)?(s[t].push(n),!1):(s[t]=[n],!0)}function i(n,i){function o(t){return function(){var n=[].slice.call(arguments);for(var r in s)e(r,s[r]);t.apply(this,n)}}if(Array.isArray(n)){var u=n.length,s={};return void n.forEach(function(t){function n(){e++||--u||i(o)}var e=0;s[t]=n,r(t,n)&&n()})}r(n,i)&&i(t(n,i))}function o(t){return!!Array.isArray(s[t])&&!!s[t].length}var u=void 0===n?setTimeout:n,s={};return i.isLocked=o,i}}).call(n,e(7).setImmediate)},function(t,n,e){"use strict";(function(n){const r=e(81),i=e(80).format,o=e(6).EventEmitter;let u=!!n.version;const s={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",NONE:"NONE"};let c=s.DEBUG,a=null,f=new o,h={Black:0,Red:1,Green:2,Yellow:3,Blue:4,Magenta:5,Cyan:6,Grey:7,White:9,Default:9};u||(h={Black:"Black",Red:"IndianRed",Green:"LimeGreen",Yellow:"Orange",Blue:"RoyalBlue",Magenta:"Orchid",Cyan:"SkyBlue",Grey:"DimGrey",White:"White",Default:"Black"});const l=[h.Cyan,h.Green,h.Yellow,h.Red,h.Default],p={useColors:!0,color:h.Default,showTimestamp:!0,showLevel:!0,filename:a,appendFile:!0};class d{constructor(t,n){this.category=t;let e={};Object.assign(e,p),Object.assign(e,n),this.options=e}debug(){this._shouldLog(s.DEBUG)&&this._write(s.DEBUG,i.apply(null,arguments))}log(){this._shouldLog(s.DEBUG)&&this.debug.apply(this,arguments)}info(){this._shouldLog(s.INFO)&&this._write(s.INFO,i.apply(null,arguments))}warn(){this._shouldLog(s.WARN)&&this._write(s.WARN,i.apply(null,arguments))}error(){this._shouldLog(s.ERROR)&&this._write(s.ERROR,i.apply(null,arguments))}_write(t,n){(this.options.filename||a)&&!this.fileWriter&&u&&(this.fileWriter=r.openSync(this.options.filename||a,this.options.appendFile?"a+":"w+"));let e=this._format(t,n),i=this._createLogMessage(t,n),o=this._createLogMessage(t,n,e.timestamp,e.level,e.category,e.text);this.fileWriter&&u&&r.writeSync(this.fileWriter,i+"\n",null,"utf-8"),u||!this.options.useColors?(console.log(o),f.emit("data",this.category,t,n)):t===s.ERROR?this.options.showTimestamp&&this.options.showLevel?console.error(o,e.timestamp,e.level,e.category,e.text):this.options.showTimestamp&&!this.options.showLevel?console.error(o,e.timestamp,e.category,e.text):!this.options.showTimestamp&&this.options.showLevel?console.error(o,e.level,e.category,e.text):console.error(o,e.category,e.text):this.options.showTimestamp&&this.options.showLevel?console.log(o,e.timestamp,e.level,e.category,e.text):this.options.showTimestamp&&!this.options.showLevel?console.log(o,e.timestamp,e.category,e.text):!this.options.showTimestamp&&this.options.showLevel?console.log(o,e.level,e.category,e.text):console.log(o,e.category,e.text)}_format(t,n){let e="",r="",i="",o=": ";if(this.options.useColors){const n=Object.keys(s).map(t=>s[t]).indexOf(t),c=this.options.color;u?(this.options.showTimestamp&&(e="[3"+h.Grey+"m"),this.options.showLevel&&(r="[3"+l[n]+";22m"),i="[3"+c+";1m",o=": "):(this.options.showTimestamp&&(e="color:"+h.Grey),this.options.showLevel&&(r="color:"+l[n]),i="color:"+c+"; font-weight: bold")}return{timestamp:e,level:r,category:i,text:o}}_createLogMessage(t,n,e,r,i,o){e=e||"",r=r||"",i=i||"",o=o||": ",!u&&this.options.useColors&&(this.options.showTimestamp&&(e="%c"),this.options.showLevel&&(r="%c"),i="%c",o=": %c");let c="";return this.options.showTimestamp&&(c+=(new Date).toISOString()+" "),c=e+c,this.options.showLevel&&(c+=r+"["+t+"]"+(t===s.INFO||t===s.WARN?" ":"")+" "),c+=i+this.category,c+=o+n}_shouldLog(t){let e=void 0!==n&&void 0!==n.env&&void 0!==n.env.LOG?n.env.LOG.toUpperCase():null;e="undefined"!=typeof window&&window.LOG?window.LOG.toUpperCase():e;const r=e||c,i=Object.keys(s).map(t=>s[t]);return i.indexOf(t)>=i.indexOf(r)}}t.exports={Colors:h,LogLevels:s,setLogLevel:t=>{c=t},setLogfile:t=>{a=t},create:(t,n)=>{return new d(t,n)},forceBrowserMode:t=>u=!t,events:f}}).call(n,e(10))},function(t,n){t.exports=function(t){return function n(e,r,i){var o=!0,u=!1;do{u=!0,o=!1,t.call(function(t,s,c){u?(e=t,r=s,i=c,o=!0):n(t,s,c)},e,r,i),u=!1}while(o)}}},function(t,n,e){"use strict";(function(n){const r=e(16),i=e(30),o=e(38);class u{constructor(t,n=""){this.path=t||"./orbit-db",this.filename=n+"orbit.db",this._store=new i(this.path),this._cache={},this._lock=new o}get(t){return this._cache[t]}set(t,n){return new Promise((e,i)=>{if(this._cache[t]===n)return e(n);this._cache[t]=n,this._lock(this.filename,t=>{r(r.values([this._cache]),r.map(t=>JSON.stringify(t,null,2)),this._store.write(this.filename,t(t=>{if(t)return i(t);e(n)})))})})}load(){return this._cache={},new Promise((t,e)=>{this._store.exists(this.filename,(i,o)=>{if(i||!o)return t();this._lock(this.filename,i=>{r(this._store.read(this.filename),r.collect(i((r,i)=>{if(r)return e(r);try{this._cache=JSON.parse(n.concat(i).toString()||"{}")}catch(t){return e(t)}t()})))})})})}reset(){this._cache={},this._store=null}}t.exports=u}).call(n,e(0).Buffer)},function(t,n,e){"use strict";const r=e(27);class i{constructor(t){this._counter=new r(t)}get(){return this._counter}updateIndex(t){this._counter&&t.items.filter(t=>t&&"COUNTER"===t.payload.op).map(t=>r.from(t.payload.value)).forEach(t=>this._counter.merge(t))}}t.exports=i},function(t,n,e){"use strict";class r{constructor(){this._index={}}get(t){return this._index[t]}updateIndex(t){t.items.slice().reverse().reduce((t,n)=>{return t.indexOf(n.payload.key)===-1&&(t.push(n.payload.key),"PUT"===n.payload.op?this._index[n.payload.key]=n.payload.value:"DEL"===n.payload.op&&delete this._index[n.payload.key]),t},[])}}t.exports=r},function(t,n,e){"use strict";class r{constructor(){this._index=[]}get(){return this._index}updateIndex(t){this._index=t.items}}t.exports=r},function(t,n,e){"use strict";class r{constructor(){this._index={}}get(){return Object.keys(this._index).map(t=>this._index[t])}updateIndex(t){t.items.reduce((t,n)=>{return t.includes(n.hash)||(t.push(n.hash),"ADD"===n.payload.op?this._index[n.hash]=n:"DEL"===n.payload.op&&delete this._index[n.payload.value]),t},[])}}t.exports=r},function(t,n,e){"use strict";class r{constructor(){this._index={}}get(t){return this._index[t]}updateIndex(t){t.items.slice().reverse().reduce((t,n)=>{return t.includes(n.payload.key)||(t.push(n.payload.key),"PUT"===n.payload.op?this._index[n.payload.key]=n.payload.value:"DEL"===n.payload.op&&delete this._index[n.payload.key]),t},[])}}t.exports=r},function(t,n,e){"use strict";(function(n){const r=e(39),i=r.create("orbit-db.ipfs-pubsub");r.setLogLevel("ERROR");class o{constructor(t){this._ipfs=t,this._subscriptions={},null===this._ipfs.pubsub&&i.error("The provided version of ipfs doesn't have pubsub support. Messages will not be exchanged."),this._handleMessage=this._handleMessage.bind(this)}subscribe(t,n){this._subscriptions[t]||(this._subscriptions[t]={onMessage:n},this._ipfs.pubsub&&this._ipfs.pubsub.subscribe(t,{discover:!0},this._handleMessage))}unsubscribe(t){this._subscriptions[t]&&(this._ipfs.pubsub.unsubscribe(t,this._handleMessage),delete this._subscriptions[t],i.debug(`Unsubscribed from '${t}'`))}publish(t,e){this._subscriptions[t]&&this._ipfs.pubsub&&this._ipfs.pubsub.publish(t,new n(JSON.stringify(e)))}disconnect(){Object.keys(this._subscriptions).forEach(t=>this.unsubscribe(t)),this._subscriptions={}}_handleMessage(t){if(t.from!==this._ipfs.PeerId){const n=t.topicCIDs[0],e=JSON.parse(t.data.toString()),r=this._subscriptions[n];r&&r.onMessage&&e&&r.onMessage(n,e)}}}t.exports=o}).call(n,e(0).Buffer)},function(t,n,e){"use strict";class r{constructor(t){this.id=t,this._index=[]}get(){return this._index}updateIndex(t,n){this._index=t.ops}}t.exports=r},function(t,n,e){"use strict";t.exports=((t,n,e)=>new Promise((r,i)=>{const o=Array.from(t);if(0===o.length)return void r([]);e=Object.assign({concurrency:1/0},e);let u=e.concurrency;if((u===1/0||u>o.length)&&(u=o.length),!(Number.isFinite(u)&&u>=1))throw new TypeError("Expected `concurrency` to be a finite number from 1 and up");const s=new Array(o.length);let c=!1,a=0;const f=t=>{if(!c)return a===o.length?void r(s):void(t>=o.length||Promise.resolve(o[t]).then(e=>n(e,t)).then(n=>{a++,s[t]=n,f(t+u)},t=>{c=!0,i(t)}))};for(let t=0;tnew Promise(n=>{n(t())});t.exports=((t,n)=>r(function e(){if(t())return r(n).then(e)}))},function(t,n){t.exports=function(t){function n(n){if(!n)throw new Error("must be passed a readable");e=n,r&&t(e)}var e,r=!1;Math.random();return n.resolve=n.ready=n.start=function(i){return r=!0,t=i||t,e&&t(e),n},n}},function(t,n){function e(t){function n(t,n){t&&(i=t,o&&r(i)),o=n,e()}function e(){o&&(i?r(i):!s.length&&u?r(u):s.length&&r(null,s.shift()))}function r(n,e){var r=o;if(n&&t){var i=t;t=null,i(n===!0?null:n)}o=null,r(n,e)}var i,o,u,s=[];return n.end=function(t){u=u||t||!0,e()},n.push=function(t){if(!u){if(o)return void r(i,t);s.push(t),e()}},n}t.exports=e},function(t,n,e){"use strict";t.exports=function t(n){var e=arguments.length;if("function"==typeof n&&1===n.length){for(var r=new Array(e),i=0;it?r(!0):void r(null,n++)}}},function(t,n,e){"use strict";t.exports=function(){return function(t,n){n(!0)}}},function(t,n,e){"use strict";t.exports=function(t){return function(n,e){e(t)}}},function(t,n,e){"use strict";t.exports={keys:e(65),once:e(17),values:e(12),count:e(60),infinite:e(64),empty:e(61),error:e(62)}},function(t,n,e){"use strict";t.exports=function(t){return t=t||Math.random,function(n,e){return n?e&&e(n):e(null,t())}}},function(t,n,e){"use strict";var r=e(12);t.exports=function(t){return r(Object.keys(t))}},function(t,n,e){"use strict";function r(t){return t}var i=e(2);t.exports=function(t){if(!t)return r;t=i(t);var n,e,o=!1;return function(r){return function i(u,s){if(e)return s(e);u?(e=u,o?r(u,function(){o?n=s:s(u)}):r(u,s)):r(null,function(r,u){r?s(r):e?s(e):(o=!0,t(u,function(t,r){o=!1,e?(s(e),n(e)):t?i(t,s):s(null,r)}))})}}}},function(t,n,e){"use strict";var r=e(20),i=e(13);t.exports=function(t){return t=r(t),i(function(n){return!t(n)})}},function(t,n,e){"use strict";var r=e(12),i=e(17);t.exports=function(){return function(t){var n;return function(e,o){function u(){n(null,function(n,e){n===!0?s():n?t(!0,function(t){o(n)}):o(null,e)})}function s(){n=null,t(null,function(t,e){if(t)return o(t);Array.isArray(e)||e&&"object"==typeof e?e=r(e):"function"!=typeof e&&(e=i(e)),n=e,u()})}e?n?n(e,function(n){t(n||e,o)}):t(e,o):n?u():s()}}}},function(t,n,e){"use strict";t.exports={map:e(70),asyncMap:e(66),filter:e(13),filterNot:e(67),through:e(73),take:e(72),unique:e(18),nonUnique:e(71),flatten:e(68)}},function(t,n,e){"use strict";function r(t){return t}var i=e(2);t.exports=function(t){return t?(t=i(t),function(n){return function(e,r){n(e,function(e,i){try{i=e?null:t(i)}catch(t){return n(t,function(){return r(t)})}r(e,i)})}}):r}},function(t,n,e){"use strict";var r=e(18);t.exports=function(t){return r(t,!0)}},function(t,n,e){"use strict";t.exports=function(t,n){n=n||{};var e=n.last||!1,r=!1;if("number"==typeof t){e=!0;var i=t;t=function(){return--i}}return function(n){function i(t){n(!0,function(n){e=!1,t(n||!0)})}return function(o,u){r?e?i(u):u(r):(r=o)?n(r,u):n(null,function(n,o){(r=r||n)?u(r):t(o)?u(null,o):(r=!0,e?u(null,o):i(u))})}}}},function(t,n,e){"use strict";t.exports=function(t,n){function e(t){!r&&n&&(r=!0,n(t===!0?null:t))}var r=!1;return function(n){return function(r,i){return r&&e(r),n(r,function(n,r){n?e(n):t&&t(r),i(n,r)})}}}},function(t,n,e){var r=e(40),i=t.exports=function(t,n){return function(e){n=n||function(t,n){return{start:t,data:n}};var i=[],o=[],u=null,s=0;return function(c,a){if(o.length)return a(null,o.shift());if(u)return a(u);s++;e(c,r(function(r,s){function c(t,e){l||(l=!0,delete i[i.indexOf(f)],o.push(n(s,e)))}var f,h=this,l=!1;return r&&(u=r),u||(f=t(s,c)),f?i.push(f):l=!0,i.forEach(function(t,n){t(r,s)}),o.length?a(null,o.shift()):u?a(u):void e(null,h)}))}}};i.recent=function(t,n){var e=null;return i(function(r,i){function o(){var t=e;e=null,clearTimeout(u),i(null,t)}if(!e){e=[];var u;return n&&(u=setTimeout(o,n)),function(n,r){if(n)return o();e.push(r),null!=t&&e.length>=t&&o()}}},function(t,n){return n})},i.sliding=function(t,n){n=n||10;var e=0;return i(function(r,i){var o,u=0;e++;return function(e,r){e||(o=t(o,r),n<=++u&&i(null,o))}})}},function(t,n){function e(t,n){return(t=t||[]).push(n),t}t.exports=function(t,n,r,i){function o(e){function a(){v||u||(v=!0,e(null,function(t,n){v=!1,h(t,n)}))}function f(){if(!p){var n=l;l=null,p=!0,d=0,t(n,function(t){p=!1,u!==!0||d?u&&u!==!0?(i(u),s&&s()):t?e(u=t,i):d?f():a():i(t)})}}function h(t,e){u||(u=t,u?p||i(u===!0?null:u):(l=n(l,e),d=l&&l.length||0,null!=l&&f(),d=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(e)?r.showHidden=e:e&&n._extend(r,e),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),c(r,t,r.depth)}function o(t,n){var e=i.styles[n];return e?"["+i.colors[e][0]+"m"+t+"["+i.colors[e][1]+"m":t}function u(t,n){return t}function s(t){var n={};return t.forEach(function(t,e){n[t]=!0}),n}function c(t,e,r){if(t.customInspect&&e&&O(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return b(i)||(i=c(t,i,r)),i}var o=a(t,e);if(o)return o;var u=Object.keys(e),v=s(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(e)),A(e)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return f(e);if(0===u.length){if(O(e)){var y=e.name?": "+e.name:"";return t.stylize("[Function"+y+"]","special")}if(x(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(k(e))return t.stylize(Date.prototype.toString.call(e),"date");if(A(e))return f(e)}var g="",m=!1,w=["{","}"];if(d(e)&&(m=!0,w=["[","]"]),O(e)){g=" [Function"+(e.name?": "+e.name:"")+"]"}if(x(e)&&(g=" "+RegExp.prototype.toString.call(e)),k(e)&&(g=" "+Date.prototype.toUTCString.call(e)),A(e)&&(g=" "+f(e)),0===u.length&&(!m||0==e.length))return w[0]+g+w[1];if(r<0)return x(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var _;return _=m?h(t,e,r,v,u):u.map(function(n){return l(t,e,r,v,n,m)}),t.seen.pop(),p(_,g,w)}function a(t,n){if(_(n))return t.stylize("undefined","undefined");if(b(n)){var e="'"+JSON.stringify(n).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(e,"string")}return m(n)?t.stylize(""+n,"number"):v(n)?t.stylize(""+n,"boolean"):y(n)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,n,e,r,i){for(var o=[],u=0,s=n.length;u-1&&(s=o?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n"))):s=t.stylize("[Circular]","special")),_(u)){if(o&&i.match(/^\d+$/))return s;u=JSON.stringify(""+i),u.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+s}function p(t,n,e){var r=0;return t.reduce(function(t,n){return r++,n.indexOf("\n")>=0&&r++,t+n.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?e[0]+(""===n?"":n+"\n ")+" "+t.join(",\n ")+" "+e[1]:e[0]+n+" "+t.join(", ")+" "+e[1]}function d(t){return Array.isArray(t)}function v(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return null==t}function m(t){return"number"==typeof t}function b(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function _(t){return void 0===t}function x(t){return E(t)&&"[object RegExp]"===P(t)}function E(t){return"object"==typeof t&&null!==t}function k(t){return E(t)&&"[object Date]"===P(t)}function A(t){return E(t)&&("[object Error]"===P(t)||t instanceof Error)}function O(t){return"function"==typeof t}function T(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function P(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}function I(){var t=new Date,n=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":");return[t.getDate(),C[t.getMonth()],n].join(" ")}function j(t,n){return Object.prototype.hasOwnProperty.call(t,n)}var R=/%[sdj%]/g;n.format=function(t){if(!b(t)){for(var n=[],e=0;e=o)return t;switch(t){case"%s":return String(r[e++]);case"%d":return Number(r[e++]);case"%j":try{return JSON.stringify(r[e++])}catch(t){return"[Circular]"}default:return t}}),s=r[e];ethis.close(t)),this._pubsub&&this._pubsub.disconnect(),this.stores={},this.user=null,this.network=null}_createStore(t,n,e){const r=Object.assign({replicate:!0},e),i=new t(this._ipfs,this.user.id,n,r);return i.events.on("write",this._onWrite.bind(this)),i.events.on("ready",this._onReady.bind(this)),this.stores[n]=i,r.replicate&&this._pubsub&&this._pubsub.subscribe(n,this._onMessage.bind(this)),i}_onMessage(t,n){this.stores[t].sync(n)}_onWrite(t,e,r,i){if(!i)throw new Error("'heads' not defined");this._pubsub&&n(()=>this._pubsub.publish(t,i))}_onReady(t,n){n&&this._pubsub&&setTimeout(()=>this._pubsub.publish(t,n),1e3)}}t.exports=f}).call(n,e(7).setImmediate)}]); +var Q=e(26),$=e(31),Z=e(37);n.Buffer=o,n.SlowBuffer=v,n.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),n.kMaxLength=r(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,n,e){return s(null,t,n,e)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,n,e){return c(null,t,n,e)},o.allocUnsafe=function(t){return a(null,t)},o.allocUnsafeSlow=function(t){return a(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,n){if(!o.isBuffer(t)||!o.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var e=t.length,r=n.length,i=0,s=Math.min(e,r);i0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},o.prototype.compare=function(t,n,e,r,i){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===e&&(e=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),n<0||e>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&n>=e)return 0;if(r>=i)return-1;if(n>=e)return 1;if(n>>>=0,e>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var s=i-r,u=e-n,c=Math.min(s,u),a=this.slice(r,i),f=t.slice(n,e),h=0;hi)&&(e=i),t.length>0&&(e<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return _(this,t,n,e);case"utf8":case"utf-8":return x(this,t,n,e);case"ascii":return E(this,t,n,e);case"latin1":case"binary":return k(this,t,n,e);case"base64":return A(this,t,n,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,n,e);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var X=4096;o.prototype.slice=function(t,n){var e=this.length;t=~~t,n=void 0===n?e:~~n,t<0?(t+=e)<0&&(t=0):t>e&&(t=e),n<0?(n+=e)<0&&(n=0):n>e&&(n=e),n0&&(i*=256);)r+=this[t+--n]*i;return r},o.prototype.readUInt8=function(t,n){return n||D(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,n){return n||D(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,n){return n||D(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,n){return n||D(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,n){return n||D(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,n,e){t|=0,n|=0,e||D(t,n,this.length);for(var r=this[t],i=1,o=0;++o=i&&(r-=Math.pow(2,8*n)),r},o.prototype.readIntBE=function(t,n,e){t|=0,n|=0,e||D(t,n,this.length);for(var r=n,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o},o.prototype.readInt8=function(t,n){return n||D(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,n){n||D(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},o.prototype.readInt16BE=function(t,n){n||D(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},o.prototype.readInt32LE=function(t,n){return n||D(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,n){return n||D(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,n){return n||D(t,4,this.length),$.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,n){return n||D(t,4,this.length),$.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,n){return n||D(t,8,this.length),$.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,n){return n||D(t,8,this.length),$.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,n,e,r){if(t=+t,n|=0,e|=0,!r){C(this,t,n,e,Math.pow(2,8*e)-1,0)}var i=1,o=0;for(this[n]=255&t;++o=0&&(o*=256);)this[n+i]=t/o&255;return n+e},o.prototype.writeUInt8=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=255&t,n+1},o.prototype.writeUInt16LE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},o.prototype.writeUInt16BE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},o.prototype.writeUInt32LE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):M(this,t,n,!0),n+4},o.prototype.writeUInt32BE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):M(this,t,n,!1),n+4},o.prototype.writeIntLE=function(t,n,e,r){if(t=+t,n|=0,!r){var i=Math.pow(2,8*e-1);C(this,t,n,e,i-1,-i)}var o=0,s=1,u=0;for(this[n]=255&t;++o>0)-u&255;return n+e},o.prototype.writeIntBE=function(t,n,e,r){if(t=+t,n|=0,!r){var i=Math.pow(2,8*e-1);C(this,t,n,e,i-1,-i)}var o=e-1,s=1,u=0;for(this[n+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[n+o+1]&&(u=1),this[n+o]=(t/s>>0)-u&255;return n+e},o.prototype.writeInt8=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=255&t,n+1},o.prototype.writeInt16LE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):L(this,t,n,!0),n+2},o.prototype.writeInt16BE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):L(this,t,n,!1),n+2},o.prototype.writeInt32LE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):M(this,t,n,!0),n+4},o.prototype.writeInt32BE=function(t,n,e){return t=+t,n|=0,e||C(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):M(this,t,n,!1),n+4},o.prototype.writeFloatLE=function(t,n,e){return N(this,t,n,!0,e)},o.prototype.writeFloatBE=function(t,n,e){return N(this,t,n,!1,e)},o.prototype.writeDoubleLE=function(t,n,e){return F(this,t,n,!0,e)},o.prototype.writeDoubleBE=function(t,n,e){return F(this,t,n,!1,e)},o.prototype.copy=function(t,n,e,r){if(e||(e=0),r||0===r||(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n=0;--i)t[i+n]=this[i+e];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var s;if("number"==typeof t)for(s=n;snew Error("Ipfs instance not defined");class s{static create(t,n,e,u,c=[],a){if(!i(t))throw o();if(!i(n))throw new Error("Entry requires an id");if(!i(u))throw new Error("Entry requires data");if(!i(c)||!Array.isArray(c))throw new Error("'next' argument is not an array");let f=c.filter(t=>void 0!==t&&null!==t).map(t=>t.hash?t.hash:t),h={hash:null,id:n,payload:u,next:f,v:0,clock:a?a.clone():new r(n)};return s.toMultihash(t,h).then(t=>{h.hash=t;return h})}static toMultihash(t,e){if(!t)throw o();const r=new n(JSON.stringify(e));return t.object.put(r).then(t=>t.toJSON().multihash)}static fromMultihash(t,n){if(!t)throw o();if(!n)throw new Error(`Invalid hash: ${n}`);return t.object.get(n,{enc:"base58"}).then(t=>JSON.parse(t.toJSON().data)).then(t=>{const e={hash:n,id:t.id,payload:t.payload,next:t.next,v:t.v,clock:t.clock};return e})}static isEntry(t){return void 0!==t.id&&void 0!==t.next&&void 0!==t.hash&&void 0!==t.payload&&void 0!==t.v&&void 0!==t.clock}static compare(t,n){var e=r.compare(t.clock,n.clock);return 0===e?t.clock.id-1}}t.exports=s}).call(n,e(0).Buffer)},function(t,n,e){"use strict";(function(n){const r=e(6).EventEmitter,i=e(34),o=e(3),s=e(8),u=e(41),c=e(48),a={Index:c,maxHistory:256,cachePath:"./orbit-db"};class f{constructor(t,n,e,o){this.id=n,this.dbname=e||"",this.events=new r;let s=Object.assign({},a);Object.assign(s,o),this.options=s,this._ipfs=t,this._index=new this.options.Index(this.id),this._oplog=i.create(this.id),this._lastWrite=[],this._cache=new u(this.options.cachePath,this.dbname),this.syncing=!1,this.syncQueue=[],setInterval(()=>this._processQ(),16),this.syncedOnce=!1}load(t){let n;return this._cache.load().then(()=>this._cache.get(this.dbname)).then(e=>e?(n=e,this.events.emit("sync",this.dbname),i.fromMultihash(this._ipfs,e,t||this.options.maxHistory).then(t=>{this._oplog=i.join(this._oplog,t,-1,this._oplog.id);this._index.updateIndex(this._oplog);return this._oplog.heads})):Promise.resolve()).then(()=>{if(this._oplog.length>0)return i.toMultihash(this._ipfs,this._oplog).then(t=>this._cache.set(this.dbname,t))}).then(t=>this.events.emit("ready",this.dbname))}loadMore(t){const n=this._oplog.items.length;return this.events.emit("sync",this.dbname),i.expand(this._ipfs,this._oplog,t).then(t=>{const e=t.items.length-n;this._oplog=t;this._index.updateIndex(this._oplog);this.events.emit("synced",this.dbname);return e})}loadMoreFrom(t,n){if(n&&!this.loadingMore){this.loadingMore=!0,this.events.emit("sync",this.dbname);const e=new s(this._oplog.tails),r=e.intersection(new s(n.reverse()));return e.keys.includes("QmdUMFtFdZTiaSmuomvB3QzrwpGakhqzvoJgmekHLZs2s6"),i.expandFrom(this._ipfs,this._oplog,r,t).then(t=>{this._oplog=t;this._index.updateIndex(this._oplog);this.loadingMore=!1;this.events.emit("synced",this.dbname)}).catch(t=>console.error(t))}}sync(t,n,e,r=!0,i=-1,o=0){r?this.syncQueue.splice(0,0,{heads:t,tails:n,length:e,max:i,count:o}):this.syncQueue.push({heads:t,tails:n,length:e,max:i,count:o})}_processQ(){if(this.syncQueue&&this.syncQueue.length>0&&!this.syncing){this.syncing=!0;const t=this.syncQueue.shift();t.heads?this._syncFromHeads(t.heads,t.length,t.max,t.count).then(()=>this.syncing=!1).catch(t=>this.events.emit("error",t)):t.tails&&this._syncFromTails(t.tails,t.length,t.max,t.count).then(()=>this.syncing=!1).catch(t=>this.events.emit("error",t))}}_syncFromHeads(t,e,r,s){if(!t)return Promise.resolve();const u=this._oplog.items.map(t=>t.hash);if(t=t.filter(t=>void 0!==t&&null!==t&&o.isEntry(t)),0===t.length||u.find(n=>t.map(t=>t.hash).indexOf(n)>-1))return Promise.resolve();this.events.emit("sync",this.dbname);const c=t=>{const e=Object.assign({},t);e.hash=null;return this._ipfs.object.put(new n(JSON.stringify(e))).then(t=>t.toJSON().multihash)};return e=e||this.options.maxHistory,s=s||0,r=r||this.options.maxHistory,Promise.all(t.map(c)).then(n=>i.fromEntry(this._ipfs,t,e,u,this._onLoadProgress.bind(this))).then(t=>{const n=this._oplog.items.length;if(t.items.length>0){const e=this._oplog.tails.filter(t=>t.next.length>0),o=this._oplog.heads;this._oplog=i.join(this._oplog,t,-1,this._oplog.id),this._index.updateIndex(this._oplog);const u=this._oplog.items.length-n;if(s+=u,this.options.syncHistory&&(r===-1||st.next.length>0),n=t.filter(t=>!e.map(t=>t.hash).includes(t.hash)),r=(n.map(n=>0!==t.map(t=>t.hash).indexOf(n)?n:null).filter(t=>null!==t),n.reduce((n,e)=>0!==t.map(t=>t.hash).indexOf(e),!1));if(r)return void this.sync(null,[t[t.length-1]],2*this.options.maxHistory,!1,32,s);const i=this._oplog.heads,c=o.length!==i.length||i.filter((t,n)=>t.hash!==o[n].hash).length>0;c&&u>1&&this.sync(i,null,2*this.options.maxHistory,!1,32,s)}}}).then(()=>i.toMultihash(this._ipfs,this._oplog)).then(t=>this._cache.set(this.dbname,t).then(()=>{this.events.emit("synced",this.dbname);return t})).catch(t=>this.events.emit("error",t))}_syncFromTails(t,n,e,r){if(!t)return Promise.resolve();n=n||this.options.maxHistory,r=r||0,e=e||this.options.maxHistory;const o=this._oplog.items.map(t=>t.hash);this.events.emit("sync",this.dbname);const s=t=>i.fromEntry(this._ipfs,t,n,o,this._onLoadProgress.bind(this));return Promise.all(t.map(s)).then(t=>{const o=this._oplog.items.length;const s=this._oplog.tails.filter(t=>t.next.length>0);this._oplog.heads;this._oplog=i.joinAll([this._oplog].concat(t),o+n,this._oplog.id);this._index.updateIndex(this._oplog);const u=this._oplog.items.length-o;r+=u;if(e===-1||rt.next.length>0),n=t.filter(t=>!s.map(t=>t.hash).includes(t.hash)),e=n.map(n=>0!==t.map(t=>t.hash).indexOf(n)?n:null).filter(t=>null!==t),i=n.reduce((n,e)=>0!==t.map(t=>t.hash).indexOf(e),!1);i&&this.sync(null,e,2*this.options.maxHistory,!1,32,r)}}).then(()=>i.toMultihash(this._ipfs,this._oplog)).then(t=>this._cache.set(this.dbname,t).then(()=>{this.events.emit("synced",this.dbname);return t})).catch(t=>this.events.emit("error",t))}_addOperation(t){let n;if(this._oplog)return i.append(this._ipfs,this._oplog,t).then(t=>{this._oplog=t;return}).then(()=>i.toMultihash(this._ipfs,this._oplog)).then(t=>n=t).then(()=>this._cache.set(this.dbname,n)).then(()=>{const t=this._oplog.items[this._oplog.items.length-1];this._lastWrite.push(n);this._index.updateIndex(this._oplog);this.events.emit("write",this.dbname,n,t,this._oplog.heads);return t.hash})}_onLoadProgress(t,n,e,r){this.events.emit("load.progress",this.dbname,r)}}t.exports=f}).call(n,e(0).Buffer)},function(t,n){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(t){if(!i(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},e.prototype.emit=function(t){var n,e,i,u,c,a;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((n=arguments[1])instanceof Error)throw n;var f=new Error('Uncaught, unspecified "error" event. ('+n+")");throw f.context=n,f}if(e=this._events[t],s(e))return!1;if(r(e))switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:u=Array.prototype.slice.call(arguments,1),e.apply(this,u)}else if(o(e))for(u=Array.prototype.slice.call(arguments,1),a=e.slice(),i=a.length,c=0;c0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(t,n){function e(){this.removeListener(t,e),i||(i=!0,n.apply(this,arguments))}if(!r(n))throw TypeError("listener must be a function");var i=!1;return e.listener=n,this.on(t,e),this},e.prototype.removeListener=function(t,n){var e,i,s,u;if(!r(n))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(e=this._events[t],s=e.length,i=-1,e===n||r(e.listener)&&e.listener===n)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,n);else if(o(e)){for(u=s;u-- >0;)if(e[u]===n||e[u].listener&&e[u].listener===n){i=u;break}if(i<0)return this;1===e.length?(e.length=0,delete this._events[t]):e.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,n)}return this},e.prototype.removeAllListeners=function(t){var n,e;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(n in this._events)"removeListener"!==n&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[t],r(e))this.removeListener(t,e);else if(e)for(;e.length;)this.removeListener(t,e[e.length-1]);return delete this._events[t],this},e.prototype.listeners=function(t){return this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},e.prototype.listenerCount=function(t){if(this._events){var n=this._events[t];if(r(n))return 1;if(n)return n.length}return 0},e.listenerCount=function(t,n){return t.listenerCount(n)}},function(t,n,e){function r(t,n){this._id=t,this._clearFn=n}var i=Function.prototype.apply;n.setTimeout=function(){return new r(i.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new r(i.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(t,n){clearTimeout(t._idleTimeoutId),t._idleTimeout=n},n.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},n._unrefActive=n.active=function(t){clearTimeout(t._idleTimeoutId);var n=t._idleTimeout;n>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},n))},e(76),n.setImmediate=setImmediate,n.clearImmediate=clearImmediate},function(t,n,e){"use strict";const r=e(32),i=e(3),o=(t,n)=>t.concat(n);class s extends r{constructor(t){super(),this._values=t||[]}get values(){return this._values.slice()}get heads(){return s.findHeads(this.values)}get tails(){return s.findTails(this.values)}get tailHashes(){return s.findTailHashes(this.values)}get keys(){return this._values.map(t=>t.hash)}get length(){return this._values.length}append(t){const n=this.values;return n.push(t),new s(n)}has(t){var n=n=>i.isEqual(n,t);return void 0!==this.values.find(n)}get(t){var n=n=>n.hash===t;return this.values.find(n)}sort(){return new s(this.values.sort(i.compare))}last(t=1){return new s(t>-1?this.values.slice(-t):this.values)}slice(t,n){return new s(this.values.slice(t||0,n||this.values.length))}replaceInFront(t){var n=this.values.slice(t.length,this.values.length);return new s(t.values.concat(n))}clone(){return new s(this.values)}merge(t){var n=[];n=Array.isArray(t)?this.values.reduce(o,[]):this.values.concat(t.values);var e=s._uniques(n);return new s(e).sort()}difference(t){var n={},e={},r=t=>e[t.hash]=!0;this.values.forEach(r);var i=(t,r)=>{var i=void 0!==e[r.hash];var o=void 0!==n[r.hash];i||o||(t.push(r),n[r.hash]=!0);return t},o=t.values.reduce(i,[]);return new s(o)}intersection(t){var n={},e={},r=t=>e[t.hash]=!0;this.values.forEach(r);var i=(t,r)=>{var i=void 0!==e[r.hash];var o=void 0!==n[r.hash];i&&!o&&(t.push(r),n[r.hash]=!0);return t},o=t.values.reduce(i,[]);return new s(o)}static isSet(t){return void 0!==t&&void 0!==t.values&&Array.isArray(t.values)}static sort(t){return t.sort(i.compare)}static has(t,n){var e=t=>i.isEqual(t,n);return void 0!==t.find(e)}static findHeads(t){var n=(t,n,e,r)=>{var i=e=>t[e]=n.hash;n.next.forEach(i);return t},e=t.reduce(n,{}),r=t=>void 0===e[t.hash],i=(t,n)=>t.id>n.id;return t.filter(r).sort(i)}static findTails(t){var n={},e=[],r={},o=[],u=t=>{0===t.next.length&&e.push(t);var i=e=>{n[e]||(n[e]=[]);n[e].push(t)};t.next.forEach(i);o=o.concat(t.next);r[t.hash]=!0};t.forEach(u);var c=(t,n,e,r)=>t.concat(s._uniques(n)),a=t=>void 0===r[t],f=t=>n[t];const h=o.filter(a).map(f).reduce(c,[]).concat(e);return s._uniques(h).sort(i.compare)}static findTailHashes(t){var n={},e=t=>n[t.hash]=!0,r=(t,e,r,i)=>{var o=e=>{void 0===n[e]&&t.splice(0,0,e)};e.next.reverse().forEach(o);return t};return t.forEach(e),t.reduce(r,[])}static findChildren(t,n){for(var e=[],r=t.find(t=>i.isParent(n,t)),o=n;r;)e.push(r),o=r,r=t.find(t=>i.isParent(o,t));return e=e.sort((t,n)=>t.seq>n.seq)}static _uniques(t){const n=(t,n)=>{var e=t=>i.isEqual(t,n);return void 0!==t.find(e)},e=(t,e,r,i)=>{n(t,e)||t.push(e);return t};return t.reduce(e,[])}}t.exports=s},function(t,n,e){"use strict";class r{constructor(t,n){this.id=t,this.time=n||0}tick(){return++this.time}merge(t){return this.time=Math.max(this.time,t.time),this}clone(){return new r(this.id,this.time)}static compare(t,n){var e=t.time-n.time;return 0===e&&t.id!==n.id?t.id1)for(var e=1;e=t.length?o(!0):o(null,t[e++])}}},function(t,n,e){"use strict";var r=e(20);t.exports=function(t){return t=r(t),function(n){return function e(r,i){for(var o,s=!0;s;)s=!1,o=!0,n(r,function(n,r){if(!n&&!t(r))return o?s=!0:e(n,i);i(n,r)}),o=!1}}}},function(t,n,e){"use strict";const r=e(4),i=e(44);class o extends r{constructor(t,n,e,r={}){void 0===r.Index&&Object.assign(r,{Index:i}),super(t,n,e,r)}add(t){return this._addOperation({op:"ADD",key:null,value:t})}get(t){return this.iterator({gte:t,limit:1}).collect()[0]}iterator(t){const n=this._query(t);let e=0;return{[Symbol.iterator](){return this},next(){let t={value:null,done:!0};return en}}_query(t){t||(t={});const n=t.limit?t.limit>-1?t.limit:this._index.get().length:1,e=this._index.get().slice();return t.gt||t.gte?this._read(e,t.gt?t.gt:t.gte,n,!!t.gte):this._read(e.reverse(),t.lt?t.lt:t.lte,n,t.lte||!t.lt).reverse()}_read(t,n,e,r){const i=t.map(t=>t.hash).indexOf(n);let o=Math.max(i,0);return o+=r?0:1,t.slice(o).slice(0,e)}}t.exports=o},function(t,n,e){"use strict";const r=t=>void 0!==t&&null!==t;t.exports=r},function(t,n,e){"use strict";var r=e(63),i=e(57),o=e(69);n=t.exports=e(53);for(var s in r)n[s]=r[s];for(var s in o)n[s]=o[s];for(var s in i)n[s]=i[s]},function(t,n,e){"use strict";var r=e(19);t.exports=function(t,n){return function(e,i){if(e)return r(i,e,n);if(null!=t){var o=t;t=null,i(null,o)}else i(!0)}}},function(t,n,e){"use strict";function r(t){return t}var i=e(2),o=e(13);t.exports=function(t,n){t=i(t)||r;var e={};return o(function(r){var i=t(r);return e[i]?!!n:(e[i]=!0,!n)})}},function(t,n){t.exports=function(t,n,e){t(n),e&&e(n===!0?null:n)}},function(t,n,e){function r(t){return t}var i=e(2);t.exports=function(t){return"object"==typeof t&&"function"==typeof t.test?function(n){return t.test(n)}:i(t)||r}},function(t,n,e){"use strict";const r=e(4),i=e(42);class o extends r{constructor(t,n,e,r={}){r.Index||Object.assign(r,{Index:i}),super(t,n,e,r)}get value(){return this._index.get().value}inc(t){const n=this._index.get();if(n)return n.increment(t),this._addOperation({op:"COUNTER",key:null,value:n.payload,meta:{ts:(new Date).getTime()}})}}t.exports=o},function(t,n,e){"use strict";const r=e(4),i=e(43);class o extends r{constructor(t,n,e,r){r||(r={}),r.indexBy||Object.assign(r,{indexBy:"_id"}),r.Index||Object.assign(r,{Index:i}),super(t,n,e,r)}get(t){return Object.keys(this._index._index).filter(n=>n.indexOf(t)!==-1).map(t=>this._index.get(t))}query(t){return Object.keys(this._index._index).map(t=>this._index.get(t)).filter(n=>t(n))}put(t){return this._addOperation({op:"PUT",key:t[this.options.indexBy],value:t})}del(t){return this._addOperation({op:"DEL",key:t,value:null})}}t.exports=o},function(t,n,e){"use strict";const r=e(14),i=e(45);class o extends r{constructor(t,n,e,r){r||(r={}),r.Index||Object.assign(r,{Index:i}),super(t,n,e,r)}remove(t){const n={op:"DEL",key:null,value:t};return this._addOperation(n)}}t.exports=o},function(t,n,e){"use strict";const r=e(4),i=e(46);class o extends r{constructor(t,n,e,r){let o=Object.assign({},{Index:i});Object.assign(o,r),super(t,n,e,o)}get(t){return this._index.get(t)}set(t,n){return this.put(t,n)}put(t,n){return this._addOperation({op:"PUT",key:t,value:n})}del(t){return this._addOperation({op:"DEL",key:t,value:null})}}t.exports=o},function(t,n,e){t.exports=e(47)},function(t,n,e){"use strict";function r(t){var n=t.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[n-2]?2:"="===t[n-1]?1:0}function i(t){return 3*t.length/4-r(t)}function o(t){var n,e,i,o,s,u,c=t.length;s=r(t),u=new h(3*c/4-s),i=s>0?c-4:c;var a=0;for(n=0,e=0;n>16&255,u[a++]=o>>8&255,u[a++]=255&o;return 2===s?(o=f[t.charCodeAt(n)]<<2|f[t.charCodeAt(n+1)]>>4,u[a++]=255&o):1===s&&(o=f[t.charCodeAt(n)]<<10|f[t.charCodeAt(n+1)]<<4|f[t.charCodeAt(n+2)]>>2,u[a++]=o>>8&255,u[a++]=255&o),u}function s(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function u(t,n,e){for(var r,i=[],o=n;oc?c:s+16383));return 1===r?(n=t[e-1],i+=a[n>>2],i+=a[n<<4&63],i+="=="):2===r&&(n=(t[e-2]<<8)+t[e-1],i+=a[n>>10],i+=a[n>>4&63],i+=a[n<<2&63],i+="="),o.push(i),o.join("")}n.byteLength=i,n.toByteArray=o,n.fromByteArray=c;for(var a=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=l.length;pthis._counters[t]).reduce((t,n)=>t+n,0)}get payload(){return{id:this.id,counters:this._counters}}compare(t){return t.id===this.id&&r(t._counters,this._counters)}merge(t){Object.keys(t._counters).forEach(n=>{this._counters[n]=Math.max(this._counters[n]?this._counters[n]:0,t._counters[n])})}static from(t){return new i(t.id,t.counters)}}t.exports=i},function(t,n,e){"use strict";n.isEqual=((t,n)=>{const e=Object.getOwnPropertyNames(t);const r=Object.getOwnPropertyNames(n);if(e.length!==r.length)return!1;for(let r=0;r0;)for(t=an,an=[],e=t.length,n=0;n0);tn=!0,nn=!0}function nt(){var t=en;en=[],t.forEach(function(t){t._PSD.onunhandled.call(null,t._value,t)});for(var n=hn.slice(0),e=n.length;e;)n[--e]()}function et(t){function n(){t(),hn.splice(hn.indexOf(n),1)}hn.push(n),++fn,Xt(function(){0==--fn&&nt()},[])}function rt(t){en.some(function(n){return n._value===t._value})||en.push(t)}function it(t){for(var n=en.length;n;)if(en[--n]._value===t._value)return void en.splice(n,1)}function ot(t){console.warn("Unhandled rejection: "+(t.stack||t))}function st(t){return new q(Vt,!1,t)}function ut(t,n){var e=cn;return function(){var r=X(),i=cn;try{return i!==e&&(cn=e),t.apply(this,arguments)}catch(t){n&&n(t)}finally{i!==e&&(cn=i),r&&tt()}}}function ct(t,n,e,r){var i=cn,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=at(o,t,n,e,r);return 0===o.ref&&o.finalize(),s}function at(t,n,e,r,i){var o=cn;try{return t!==o&&(cn=t),n(e,r,i)}finally{t!==o&&(cn=o)}}function ft(n,e){var r;try{r=e.onuncatched(n)}catch(t){}if(r!==!1)try{var i,o={promise:e,reason:n};if(Pt.document&&document.createEvent?(i=document.createEvent("Event"),i.initEvent(pn,!0,!0),t(i,o)):Pt.CustomEvent&&(i=new CustomEvent(pn,{detail:o}),t(i,o)),i&&Pt.dispatchEvent&&(dispatchEvent(i),!Pt.PromiseRejectionEvent&&Pt.onunhandledrejection))try{Pt.onunhandledrejection(i)}catch(t){}i.defaultPrevented||q.on.error.fire(n,e)}catch(t){}}function ht(t,n){var e=q.reject(t);return n?e.uncaught(n):e}function lt(n,e){function u(t){this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function l(t,n,e){var r=nn._createTransaction(tn,Wt,Ht);r.create(n),r._completion.catch(e);var i=r._reject.bind(r);ct(function(){cn.trans=r,0===t?(Ot(Ht).forEach(function(t){j(n,t,Ht[t].primKey,Ht[t].indexes)}),q.follow(function(){return nn.on.populate.fire(r)}).catch(i)):m(t,r,n).catch(i)})}function m(t,n,e){function r(){return i.length?q.resolve(i.shift()(n.idbtrans)).then(r):q.resolve()}var i=[],o=Jt.filter(function(n){return n._cfg.version===t})[0];if(!o)throw new Gt.Upgrade("Dexie specification of currently installed DB version is missing");Ht=nn._dbSchema=o._cfg.dbschema;var s=!1;return Jt.filter(function(n){return n._cfg.version>t}).forEach(function(t){i.push(function(){var r=Ht,i=t._cfg.dbschema;Rt(r,e),Rt(i,e),Ht=nn._dbSchema=i;var o=T(r,i);if(o.add.forEach(function(t){j(e,t[0],t[1].primKey,t[1].indexes)}),o.change.forEach(function(t){if(t.recreate)throw new Gt.Upgrade("Not yet support for changing primary key");var n=e.objectStore(t.name);t.add.forEach(function(t){M(n,t)}),t.change.forEach(function(t){n.deleteIndex(t.name),M(n,t)}),t.del.forEach(function(t){n.deleteIndex(t)})}),t._cfg.contentUpgrade)return s=!0,q.follow(function(){t._cfg.contentUpgrade(n)})}),i.push(function(n){s&&_n||C(t._cfg.dbschema,n)})}),r().then(function(){B(Ht,e)})}function T(t,n){var e={del:[],add:[],change:[]};for(var r in t)n[r]||e.del.push(r);for(r in n){var i=t[r],o=n[r];if(i){var s={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)s.recreate=!0,e.change.push(s);else{var u=i.idxByName,c=o.idxByName;for(var a in u)c[a]||s.del.push(a);for(a in c){var f=u[a],h=c[a];f?f.src!==h.src&&s.change.push(h):s.add.push(h)}(s.del.length>0||s.add.length>0||s.change.length>0)&&e.change.push(s)}}else e.add.push([r,o])}return e}function j(t,n,e,r){var i=t.db.createObjectStore(n,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(t){M(i,t)}),i}function B(t,n){Ot(t).forEach(function(e){n.db.objectStoreNames.contains(e)||j(n,e,t[e].primKey,t[e].indexes)})}function C(t,n){for(var e=0;e0?t:n}function ft(t,n){return qt.cmp(t,n)}function pt(t,n){return qt.cmp(n,t)}function Pt(t,n){return tn?-1:t===n?0:1}function It(t,n){return t?n?function(){return t.apply(this,arguments)&&n.apply(this,arguments)}:t:n}function jt(){if(nn.verno=Qt.version/10,nn._dbSchema=Ht={},Wt=c(Qt.objectStoreNames,0),0!==Wt.length){var t=Qt.transaction(kt(Wt),"readonly");Wt.forEach(function(n){for(var e=t.objectStore(n),r=e.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1,o=new xt(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),s=[],u=0;u0&&(on=!1),!qt)throw new Gt.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var i=on?qt.open(n):qt.open(n,Math.round(10*nn.verno));if(!i)throw new Gt.MissingAPI("IndexedDB API not available");i.onerror=ut(gt(r)),i.onblocked=ut(Bt),i.onupgradeneeded=ut(function(t){if(e=i.transaction,on&&!nn._allowEmptyDB){i.onerror=bt,e.abort(),i.result.close();var o=qt.deleteDatabase(n);o.onsuccess=o.onerror=ut(function(){r(new Gt.NoSuchDatabase("Database "+n+" doesnt exist"))})}else{e.onerror=ut(gt(r));l((t.oldVersion>Math.pow(2,62)?0:t.oldVersion)/10,e,r)}},r),i.onsuccess=ut(function(){if(e=null,Qt=i.result,bn.push(nn),on)jt();else if(Qt.objectStoreNames.length>0)try{Rt(Ht,Qt.transaction(kt(Qt.objectStoreNames),"readonly"))}catch(t){}Qt.onversionchange=ut(function(t){nn._vcFired=!0,nn.on("versionchange").fire(t)}),sn||wt(function(t){if(t.indexOf(n)===-1)return t.push(n)}),t()},r)})]).then(function(){return lt.vip(nn.on.ready.fire)}).then(function(){return Zt=!1,nn}).catch(function(t){try{e&&e.abort()}catch(t){}return Zt=!1,nn.close(),$t=t,ht($t,U)}).finally(function(){Xt=!0,t()})},this.close=function(){var t=bn.indexOf(nn);if(t>=0&&bn.splice(t,1),Qt){try{Qt.close()}catch(t){}Qt=null}Yt=!1,$t=new Gt.DatabaseClosed,Zt&&Lt($t),en=new q(function(t){Dt=t}),rn=new q(function(t,n){Lt=n})},this.delete=function(){var t=arguments.length>0;return new q(function(e,r){function i(){nn.close();var t=qt.deleteDatabase(n);t.onsuccess=ut(function(){sn||wt(function(t){var e=t.indexOf(n);if(e>=0)return t.splice(e,1)}),e()}),t.onerror=ut(gt(r)),t.onblocked=Bt}if(t)throw new Gt.InvalidArgument("Arguments not allowed in db.delete()");Zt?en.then(i):i()}).uncaught(U)},this.backendDB=function(){return Qt},this.isOpen=function(){return null!==Qt},this.hasFailed=function(){return null!==$t},this.dynamicallyOpened=function(){return on},this.name=n,o(this,"tables",{get:function(){return Ot(Vt).map(function(t){return Vt[t]})}}),this.on=Y(this,"error","populate","blocked","versionchange",{ready:[R,k]}),this.on.error.subscribe=L("Dexie.on.error",this.on.error.subscribe),this.on.error.unsubscribe=L("Dexie.on.error.unsubscribe",this.on.error.unsubscribe),this.on.ready.subscribe=a(this.on.ready.subscribe,function(t){return function(n,e){lt.vip(function(){Xt?($t||q.resolve().then(n),e&&t(n)):(t(n),e||t(function t(){nn.on.ready.unsubscribe(n),nn.on.ready.unsubscribe(t)}))})}}),kn(function(){nn.on("populate").fire(nn._createTransaction(tn,Wt,Ht)),nn.on("error").fire(new Error)}),this.transaction=function(t,n,e){function i(n){var i=cn;n(q.resolve().then(function(){return ct(function(){cn.transless=cn.transless||i;var n=nn._createTransaction(t,f,Ht,c);cn.trans=n,c?n.idbtrans=c.idbtrans:n.create();var o=f.map(function(t){return Vt[t]});o.push(n);var s;return q.follow(function(){if(s=e.apply(n,o))if("function"==typeof s.next&&"function"==typeof s.throw)s=_t(s);else if("function"==typeof s.then&&!r(s,"_PSD"))throw new Gt.IncompatiblePromise("Incompatible Promise returned from transaction scope (read more at http://tinyurl.com/znyqjqc). Transaction scope: "+e.toString())}).uncaught(U).then(function(){return c&&n._resolve(),n._completion}).then(function(){return s}).catch(function(t){return n._reject(t),ht(t)})})}))}var o=arguments.length;if(o<2)throw new Gt.InvalidArgument("Too few arguments");for(var s=new Array(o-1);--o;)s[o-1]=arguments[o];e=s.pop();var u=E(s),c=cn.trans;c&&c.db===nn&&t.indexOf("!")===-1||(c=null);var a=t.indexOf("?")!==-1;t=t.replace("!","").replace("?","");try{var f=u.map(function(t){var n=t instanceof z?t.name:t;if("string"!=typeof n)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n});if("r"==t||"readonly"==t)t="readonly";else{if("rw"!=t&&t!=tn)throw new Gt.InvalidArgument("Invalid transaction mode: "+t);t=tn}if(c){if("readonly"===c.mode&&t===tn){if(!a)throw new Gt.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");c=null}c&&f.forEach(function(t){if(c&&c.storeNames.indexOf(t)===-1){if(!a)throw new Gt.SubTransaction("Table "+t+" not included in parent transaction.");c=null}})}}catch(t){return c?c._promise(null,function(n,e){e(t)}):ht(t,U)}return c?c._promise(t,i,"lock"):nn._whenReady(i)},this.table=function(t){if(An&&on)return new H(t);if(!r(Vt,t))throw new Gt.InvalidTable("Table "+t+" does not exist");return Vt[t]},i(z.prototype,{_trans:function(t,n,e){var r=cn.trans;return r&&r.db===nn?r._promise(t,n,e):K(t,[this.name],n)},_idbstore:function(t,n,e){function r(t,e,r){n(t,e,r.idbtrans.objectStore(o),r)}if(An)return new q(n);var i=cn.trans,o=this.name;return i&&i.db===nn?i._promise(t,r,e):K(t,[this.name],r)},get:function(t,n){var e=this;return this._idbstore("readonly",function(n,r,i){An&&n(e.schema.instanceTemplate);var o=i.get(t);o.onerror=gt(r),o.onsuccess=ut(function(){n(e.hook.reading.fire(o.result))},r)}).then(n)},where:function(t){return new V(this,t)},count:function(t){return this.toCollection().count(t)},offset:function(t){return this.toCollection().offset(t)},limit:function(t){return this.toCollection().limit(t)},reverse:function(){return this.toCollection().reverse()},filter:function(t){return this.toCollection().and(t)},each:function(t){return this.toCollection().each(t)},toArray:function(t){return this.toCollection().toArray(t)},orderBy:function(t){return new this._collClass(new V(this,t))},toCollection:function(){return new this._collClass(new V(this))},mapToClass:function(t,n){this.schema.mappedClass=t;var e=Object.create(t.prototype);n&&dt(e,n),this.schema.instanceTemplate=e;var i=function(n){if(!n)return n;var e=Object.create(t.prototype);for(var i in n)if(r(n,i))try{e[i]=n[i]}catch(t){}return e};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),t},defineClass:function(t){return this.mapToClass(lt.defineClass(t),t)}}),s(H).from(z).extend({bulkDelete:function(t){return this.hook.deleting.fire===k?this._idbstore(tn,function(n,e,r,i){n(J(r,i,t,!1,k))}):this.where(":id").anyOf(t).delete().then(function(){})},bulkPut:function(t,n){var e=this;return this._idbstore(tn,function(r,i,o){if(!o.keyPath&&!e.schema.primKey.auto&&!n)throw new Gt.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(o.keyPath&&n)throw new Gt.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==t.length)throw new Gt.InvalidArgument("Arguments objects and keys must have the same length");if(0===t.length)return r();var s,u,c=function(t){0===a.length?r(t):i(new F(e.name+".bulkPut(): "+a.length+" of "+f+" operations failed",a))},a=[],f=t.length,h=e;if(e.hook.creating.fire===k&&e.hook.updating.fire===k){u=G(a);for(var l=0,d=t.length;l=0;--i){var o=v[i];(null==o||g[o])&&(e.push(t[i]),n&&r.push(o),null!=o&&(g[o]=null))}return e.reverse(),n&&r.reverse(),h.bulkAdd(e,r)}).then(function(t){var n=v[v.length-1];return null!=n?n:t}):h.bulkAdd(t)).then(c).catch(F,function(t){a=a.concat(t.failures),c()}).catch(i)}},"locked")},bulkAdd:function(t,n){var e=this,r=this.hook.creating.fire;return this._idbstore(tn,function(i,o,s,u){function c(t){0===l.length?i(t):o(new F(e.name+".bulkAdd(): "+l.length+" of "+p+" operations failed",l))}if(!s.keyPath&&!e.schema.primKey.auto&&!n)throw new Gt.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(s.keyPath&&n)throw new Gt.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==t.length)throw new Gt.InvalidArgument("Arguments objects and keys must have the same length");if(0===t.length)return i();var a,f,h,l=[],p=t.length;if(r!==k){var d,m=s.keyPath;f=G(l,null,!0),h=yt(null),v(function(){for(var e=0,i=t.length;e0&&!this._locked();){var t=this._blockedFuncs.shift();try{at(t[1],t[0])}catch(t){}}return this},_locked:function(){return this._reculock&&cn.lockOwnerFor!==this},create:function(t){var n=this;if(h(!this.idbtrans),!t&&!Qt)switch($t&&$t.name){case"DatabaseClosedError":throw new Gt.DatabaseClosed($t);case"MissingAPIError":throw new Gt.MissingAPI($t.message,$t);default:throw new Gt.OpenFailed($t)}if(!this.active)throw new Gt.TransactionInactive;return h(null===this._completion._state),t=this.idbtrans=t||Qt.transaction(kt(this.storeNames),this.mode),t.onerror=ut(function(e){bt(e),n._reject(t.error)}),t.onabort=ut(function(t){bt(t),n.active&&n._reject(new Gt.Abort),n.active=!1,n.on("abort").fire(t)}),t.oncomplete=ut(function(){n.active=!1,n._resolve()}),this},_promise:function(t,n,e){var r=this,i=r._locked()?new q(function(i,o){r._blockedFuncs.push([function(){r._promise(t,n,e).then(i,o)},cn])}):ct(function(){var i=r.active?new q(function(i,o){if(t===tn&&r.mode!==tn)throw new Gt.ReadOnly("Transaction is readonly");!r.idbtrans&&t&&r.create(),e&&r._lock(),n(i,o,r)}):ht(new Gt.TransactionInactive);return r.active&&e&&i.finally(function(){r._unlock()}),i});return i._lib=!0,i.uncaught(U)},abort:function(){this.active&&this._reject(new Gt.Abort),this.active=!1},tables:{get:L("Transaction.tables",function(){return p(this.storeNames,function(t){return[t,Vt[t]]})},"Use db.tables()")},complete:L("Transaction.complete()",function(t){return this.on("complete",t)}),error:L("Transaction.error()",function(t){return this.on("error",t)}),table:L("Transaction.table()",function(t){if(this.storeNames.indexOf(t)===-1)throw new Gt.InvalidTable("Table "+t+" not in transaction");return Vt[t]})}),i(V.prototype,function(){function t(t,n,e){var r=t instanceof V?new t._ctx.collClass(t):t;return r._ctx.error=e?new e(n):new TypeError(n),r}function n(t){return new t._ctx.collClass(t,function(){return zt.only("")}).limit(0)}function e(t){return"next"===t?function(t){return t.toUpperCase()}:function(t){return t.toLowerCase()}}function r(t){return"next"===t?function(t){return t.toLowerCase()}:function(t){return t.toUpperCase()}}function i(t,n,e,r,i,o){for(var s=Math.min(t.length,r.length),u=-1,c=0;c=0?t.substr(0,u)+n[u]+e.substr(u+1):null;i(t[c],a)<0&&(u=c)}return s0)&&(u=a)}return n(null!==u?function(){t.continue(u+v)}:e),!1}),g}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return it(e,r)>0||0===it(e,r)&&(i||o)&&(!i||!o)?n(this):new this._ctx.collClass(this,function(){return zt.bound(e,r,!i,!o)})}catch(n){return t(this,gn)}},equals:function(t){return new this._ctx.collClass(this,function(){return zt.only(t)})},above:function(t){return new this._ctx.collClass(this,function(){return zt.lowerBound(t,!0)})},aboveOrEqual:function(t){return new this._ctx.collClass(this,function(){return zt.lowerBound(t)})},below:function(t){return new this._ctx.collClass(this,function(){return zt.upperBound(t,!0)})},belowOrEqual:function(t){return new this._ctx.collClass(this,function(){return zt.upperBound(t)})},startsWith:function(n){return"string"!=typeof n?t(this,mn):this.between(n,n+vn,!0,!0)},startsWithIgnoreCase:function(t){return""===t?this.startsWith(t):o(this,function(t,n){return 0===t.indexOf(n[0])},[t],vn)},equalsIgnoreCase:function(t){return o(this,function(t,n){return t===n[0]},[t],"")},anyOfIgnoreCase:function(){var t=x.apply(Ct,arguments);return 0===t.length?n(this):o(this,function(t,n){return n.indexOf(t)!==-1},t,"")},startsWithAnyOfIgnoreCase:function(){var t=x.apply(Ct,arguments);return 0===t.length?n(this):o(this,function(t,n){return n.some(function(n){return 0===t.indexOf(n)})},t,vn)},anyOf:function(){var e=x.apply(Ct,arguments),r=ft;try{e.sort(r)}catch(n){return t(this,gn)}if(0===e.length)return n(this);var i=new this._ctx.collClass(this,function(){return zt.bound(e[0],e[e.length-1])});i._ondirectionchange=function(t){r="next"===t?ft:pt,e.sort(r)};var o=0;return i._addAlgorithm(function(t,n,i){for(var s=t.key;r(s,e[o])>0;)if(++o===e.length)return n(i),!1;return 0===r(s,e[o])||(n(function(){t.continue(e[o])}),!1)}),i},notEqual:function(t){return this.inAnyRange([[-1/0,t],[t,yn]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var n=x.apply(Ct,arguments);if(0===n.length)return new this._ctx.collClass(this);try{n.sort(ft)}catch(n){return t(this,gn)}var e=n.reduce(function(t,n){return t?t.concat([[t[t.length-1][1],n]]):[[-1/0,n]]},null);return e.push([n[n.length-1],yn]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(t,n){for(var e=0,r=t.length;e0){i[0]=ot(i[0],n[0]),i[1]=st(i[1],n[1]);break}}return e===r&&t.push(n),t}function o(t,n){return h(t[0],n[0])}function s(t){return!p(t)&&!d(t)}var u=this._ctx;if(0===e.length)return n(this);if(!e.every(function(t){return void 0!==t[0]&&void 0!==t[1]&&ft(t[0],t[1])<=0}))return t(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Gt.InvalidArgument);var c,a=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,h=ft;try{c=e.reduce(i,[]),c.sort(o)}catch(n){return t(this,gn)}var l=0,p=f?function(t){return ft(t,c[l][1])>0}:function(t){return ft(t,c[l][1])>=0},d=a?function(t){return pt(t,c[l][0])>0}:function(t){return pt(t,c[l][0])>=0},v=p,y=new u.collClass(this,function(){return zt.bound(c[0][0],c[c.length-1][1],!a,!f)});return y._ondirectionchange=function(t){"next"===t?(v=p,h=ft):(v=d,h=pt),c.sort(o)},y._addAlgorithm(function(t,n,e){for(var r=t.key;v(r);)if(++l===c.length)return n(e),!1;return!!s(r)||0!==it(r,c[l][1])&&0!==it(r,c[l][0])&&(n(function(){h===ft?t.continue(c[l][0]):t.continue(c[l][1])}),!1)}),y},startsWithAnyOf:function(){var e=x.apply(Ct,arguments);return e.every(function(t){return"string"==typeof t})?0===e.length?n(this):this.inAnyRange(e.map(function(t){return[t,t+vn]})):t(this,"startsWithAnyOf() only works with strings")}}}),i(Q.prototype,function(){function n(t,n){t.filter=It(t.filter,n)}function e(t,n,e){var r=t.replayFilter;t.replayFilter=r?function(){return It(r(),n())}:n,t.justLimit=e&&!r}function i(t,n){t.isMatch=It(t.isMatch,n)}function o(t,n){if(t.isPrimKey)return n;var e=t.table.schema.idxByName[t.index];if(!e)throw new Gt.Schema("KeyPath "+t.index+" on object store "+n.name+" is not indexed");return n.index(e.name)}function s(t,n){var e=o(t,n);return t.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(t.range||null,t.dir+t.unique):e.openCursor(t.range||null,t.dir+t.unique)}function u(t,n,e,i,o){var u=t.replayFilter?It(t.filter,t.replayFilter()):t.filter;t.or?function(){function c(){2==++h&&e()}function a(t,e,o){if(!u||u(e,o,c,i)){var s=e.primaryKey.toString();r(f,s)||(f[s]=!0,n(t,e,o))}}var f={},h=0;t.or._iterate(a,c,i,o),et(s(t,o),t.algorithm,a,c,i,!t.keysOnly&&t.valueMapper)}():et(s(t,o),It(t.algorithm,u),n,e,i,!t.keysOnly&&t.valueMapper)}function c(t){return t.table.schema.instanceTemplate}return{_read:function(t,n){var e=this._ctx;return e.error?e.table._trans(null,function(t,n){n(e.error)}):e.table._idbstore("readonly",t).then(n)},_write:function(t){var n=this._ctx;return n.error?n.table._trans(null,function(t,e){e(n.error)}):n.table._idbstore(tn,t,"locked")},_addAlgorithm:function(t){var n=this._ctx;n.algorithm=It(n.algorithm,t)},_iterate:function(t,n,e,r){return u(this._ctx,t,n,e,r)},clone:function(n){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return n&&t(r,n),e._ctx=r,e},raw:function(){return this._ctx.valueMapper=null,this},each:function(t){var n=this._ctx;if(An){var e=c(n),r=n.table.schema.primKey.keyPath,i=y(e,n.index?n.table.schema.idxByName[n.index].keyPath:r),o=y(e,r);t(e,{key:i,primaryKey:o})}return this._read(function(e,r,i){u(n,t,e,r,i)})},count:function(t){if(An)return q.resolve(0).then(t);var n=this._ctx;if($(n,!0))return this._read(function(t,e,r){var i=o(n,r),s=n.range?i.count(n.range):i.count();s.onerror=gt(e),s.onsuccess=function(e){t(Math.min(e.target.result,n.limit))}},t);var e=0;return this._read(function(t,r,i){u(n,function(){return++e,!1},function(){t(e)},r,i)},t)},sortBy:function(t,n){function e(t,n){return n?e(t[i[n]],n-1):t[o]}function r(t,n){var r=e(t,s),i=e(n,s);return ri?u:0}var i=t.split(".").reverse(),o=i[0],s=i.length-1,u="next"===this._ctx.dir?1:-1;return this.toArray(function(t){return t.sort(r)}).then(n)},toArray:function(t){var n=this._ctx;return this._read(function(t,e,r){if(An&&t([c(n)]),Ut&&"next"===n.dir&&$(n,!0)&&n.limit>0){var i=n.table.hook.reading.fire,s=o(n,r),a=n.limit<1/0?s.getAll(n.range,n.limit):s.getAll(n.range);a.onerror=gt(e),a.onsuccess=i===A?vt(t):ut(vt(function(n){try{t(n.map(i))}catch(t){e(t)}}))}else{var f=[];u(n,function(t){f.push(t)},function(){t(f)},e,r)}},t)},offset:function(t){var n=this._ctx;return t<=0?this:(n.offset+=t,$(n)?e(n,function(){var n=t;return function(t,e){return 0===n||(1===n?(--n,!1):(e(function(){t.advance(n),n=0}),!1))}}):e(n,function(){var n=t;return function(){return--n<0}}),this)},limit:function(t){return this._ctx.limit=Math.min(this._ctx.limit,t),e(this._ctx,function(){var n=t;return function(t,e,r){return--n<=0&&e(r),n>=0}},!0),this},until:function(t,e){var r=this._ctx;return An&&t(c(r)),n(this._ctx,function(n,r,i){return!t(n.value)||(r(i),e)}),this},first:function(t){return this.limit(1).toArray(function(t){return t[0]}).then(t)},last:function(t){return this.reverse().first(t)},filter:function(t){return An&&t(c(this._ctx)),n(this._ctx,function(n){return t(n.value)}),i(this._ctx,t),this},and:function(t){return this.filter(t)},or:function(t){return new V(this._ctx.table,t,this)},reverse:function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},desc:function(){return this.reverse()},eachKey:function(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,e){t(e.key,e)})},eachUniqueKey:function(t){return this._ctx.unique="unique",this.eachKey(t)},eachPrimaryKey:function(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,e){t(e.primaryKey,e)})},keys:function(t){var n=this._ctx;n.keysOnly=!n.isMatch;var e=[];return this.each(function(t,n){e.push(n.key)}).then(function(){return e}).then(t)},primaryKeys:function(t){var n=this._ctx;if(Ut&&"next"===n.dir&&$(n,!0)&&n.limit>0)return this._read(function(t,e,r){var i=o(n,r),s=n.limit<1/0?i.getAllKeys(n.range,n.limit):i.getAllKeys(n.range);s.onerror=gt(e),s.onsuccess=vt(t)}).then(t);n.keysOnly=!n.isMatch;var e=[];return this.each(function(t,n){e.push(n.primaryKey)}).then(function(){return e}).then(t)},uniqueKeys:function(t){return this._ctx.unique="unique",this.keys(t)},firstKey:function(t){return this.limit(1).keys(function(t){return t[0]}).then(t)},lastKey:function(t){return this.reverse().firstKey(t)},distinct:function(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var i={};return n(this._ctx,function(t){var n=t.primaryKey.toString(),e=r(i,n);return i[n]=!0,!e}),this}}}),s(Z).from(Q).extend({modify:function(n){var e=this,i=this._ctx,o=i.table.hook,s=o.updating.fire,u=o.deleting.fire;return An&&"function"==typeof n&&n.call({value:i.table.schema.instanceTemplate},i.table.schema.instanceTemplate),this._write(function(i,o,c,a){function f(t,n){function e(t){return T.push(t),P.push(i.primKey),l(),!0}S=n.primaryKey;var i={primKey:n.primaryKey,value:t,onsuccess:null,onerror:null};if(p.call(i,t,i)!==!1){var o=!r(i,"value");++E,v(function(){var t=o?n.delete():n.update(i.value);t._hookCtx=i,t.onerror=mt(e),t.onsuccess=yt(function(){++A,l()})},e)}else i.onsuccess&&i.onsuccess(i.value)}function h(t){return t&&(T.push(t),P.push(S)),o(new N("Error modifying one or more objects",T,A,P))}function l(){O&&A+T.length===E&&(T.length>0?h():i(A))}var p;if("function"==typeof n)p=s===k&&u===k?n:function(t){var e=w(t);if(n.call(this,t,this)===!1)return!1;if(r(this,"value")){var i=_(e,this.value),o=s.call(this,i,this.primKey,e,a);o&&(t=this.value,Ot(o).forEach(function(n){g(t,n,o[n])}))}else u.call(this,this.primKey,t,a)};else if(s===k){var d=Ot(n),m=d.length;p=function(t){for(var e=!1,r=0;r0?console.warn("Another connection wants to upgrade database '"+nn.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+nn.name+"'. Closing db now to resume the delete request."),nn.close()}),nn.on("blocked",function(t){!t.newVersion||t.newVersion99?t.push(n.concat(e)):t[o(t)]=n.concat(s(t).concat(e)),t}if(c)return e(c);var l=r.table;i.resolve(v(d(100,10),f(a,h,100,e)))}),i):(e(new Error("Missing key")),i)}},{key:"read",value:function(t){var n=this,e=h();return t?(this.exists(t,function(r,i){return r?e.end(r):i?void n.table.where("key").equals(t).each(function(t){return e.push(l(t.blob))}).catch(function(t){return e.end(t)}).then(function(){return e.end()}):e.end(new Error("Not found"))}),e):(e.end(new Error("Missing key")),e)}},{key:"exists",value:function(t,n){if(n=n||function(){},!t)return n(new Error("Missing key"));this.table.where("key").equals(t).count().then(function(t){return n(null,Boolean(t))}).catch(n)}},{key:"remove",value:function(t,n){if(n=n||function(){},!t)return n(new Error("Missing key"));var e=this.table.where("key").equals(t);e.count(function(t){return t>0?e.delete():null}).then(function(){return n()}).catch(n)}},{key:"table",get:function(){return this.db[this.path]}}]),t}()}).call(n,e(0).Buffer)},function(t,n){n.read=function(t,n,e,r,i){var o,s,u=8*i-r-1,c=(1<>1,f=-7,h=e?i-1:0,l=e?-1:1,p=t[n+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[n+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[n+h],h+=l,f-=8);if(0===o)o=1-a;else{if(o===c)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,r),o-=a}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(t,n,e,r,i,o){var s,u,c,a=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,v=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,s=f):(s=Math.floor(Math.log(n)/Math.LN2),n*(c=Math.pow(2,-s))<1&&(s--,c*=2),n+=s+h>=1?l/c:l*Math.pow(2,1-h),n*c>=2&&(s++,c/=2),s+h>=f?(u=0,s=f):s+h>=1?(u=(n*c-1)*Math.pow(2,i),s+=h):(u=n*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(s=s<0;t[e+p]=255&s,p+=d,s/=256,a-=8);t[e+p-d]|=128*v}},function(t,n,e){"use strict";class r{constuctor(t){}append(t){}merge(t){}get(t){}has(t){}get values(){}get length(){}}t.exports=r},function(t,n,e){"use strict";const r=e(50),i=e(49),o=e(3);class s{static fetchParallel(t,n,e,r=[],o){const u=n=>s.fetchAll(t,n,e,r),c=(t,n)=>t.concat(n),a=t=>t.reduce(c,[]);return i(n,u,{concurrency:Math.max(o||n.length,1)}).then(a)}static fetchAll(t,n,e,i=[],s=2e3){let u=[],c={},a=Array.isArray(n)?n.slice():[n];const f=t=>a.push(t);var h=t=>c[t.hash]=t;i.forEach(h);const l=()=>a.length>0&&(u.length{const n=a.shift();if(c[n]){const t=c[n];return t.next.forEach(f),Promise.resolve()}return new Promise((e,r)=>{const i=setTimeout(e,s);const a=t=>{clearTimeout(i);o.isEntry(t)&&(t.next.forEach(f),u.push(t),c[n]=t)};o.fromMultihash(t,n).then(a).then(e)})};return r(l,p).then(()=>u)}}t.exports=s},function(t,n,e){"use strict";const r=e(15),i=e(35),o=e(33),s=e(3),u=e(8),c=e(9),a=()=>new Error("Ipfs instance not defined"),f=()=>new Error("Log instance not defined"),h=()=>new Error("Given argument is not an instance of Log");class l{static create(t,n,e,o,a=-1,f=!1){if(r(n)&&!u.isSet(n)&&!Array.isArray(n))throw new Error(`'entries' argument must be an EntrySet or an array of Entry instances`);if(r(e)&&!Array.isArray(e))throw new Error(`'heads' argument must be an array`);if(u.isSet(n)||(n=new u(n)),f||(n=n.sort()),a>-1&&(n=n.slice(-a)),e=r(e)?e.map(t=>s.isEntry(t)?t:n.get(t)):n.heads,!r(t)){if(!r(n)||0===n.length)throw new Error("Log requires an id");t=o?o.id:n.get(e[0].hash).clock.id}if(!r(o)&&r(n)){const e=n.values.slice(-1)[0];o=new c(t,e?e.clock.time:null)}return new i(t,n,e,o)}static append(t,n,e){if(!r(t))throw a();if(!r(n))throw f();if(!l.isLog(n))throw h();n.clock.tick();const i=t=>n.append(t);return s.create(t,n.id,null,e,n.heads,n.clock).then(i)}static join(t,n,e,i){if(!r(t)||!r(n))throw f();if(!l.isLog(t))throw h();if(!l.isLog(n))throw h();e=e&&e>-1?e:t.length+n.length,i=i||[t,n].sort((t,n)=>t.id>n.id)[0].id;const o=t.entries.merge(n.entries),s=[t.clock,n.clock].sort((t,n)=>t.id===i?-1:t.id>n.id);let u=new c(i,s[0].time);return u.merge(s[1]),l.create(i,o,null,u,e)}static joinAll(t,n){return t.reduce((t,e,r)=>{if(!t)return e;return l.join(t,e,n)},null)}static isLog(t){return void 0!==t.id&&void 0!==t.heads&&void 0!==t.values}static expand(t,n,e=-1){if(!r(t))throw a();if(!r(n))throw f();if(!l.isLog(n))throw h();return 0===n.tailHashes.length?Promise.resolve(l.create(n.id,n.entries,n.heads,n.clock,-1,!0)):o.fetchParallel(t,n.tailHashes,e,n.values).then(t=>new u(t)).then(t=>{const r=e>-1?n.entries.length+e:-1;const i=n.entries.merge(t).last(r);const o=i.difference(n.entries);const s=n.entries.difference(i);const u=n.entries.intersection(i);const c=r-(u.length+o.length);const a=s.last(c);const f=u.merge(a).merge(o);return l.create(n.id,f,null,n.clock,r)})}static expandFrom(t,n,e,i=-1){if(!r(t))throw a();if(!r(n))throw f();if(!r(e))throw new Error(`'entries' must be given as argument`);if(!l.isLog(n))throw h();Array.isArray(e)||u.isSet(e)||(e=[e]),u.isSet(e)||(e=new u(e));const s=e.values.map(t=>t.next).filter(t=>t.length>0);return 0===s.length?Promise.resolve(l.create(n.id,n.entries,n.heads,n.clock,-1,!0)):o.fetchParallel(t,s,i,n.values,s.length).then(t=>new u(t)).then(t=>{const e=i>-1?n.entries.length+i:-1;const r=n.entries.merge(t.slice(0,i));return l.create(n.id,r,null,n.clock,e)})}static fromEntry(t,n,e=-1,i,c){if(!r(t))throw a();if(!r(n))throw new Error("'sourceEntries' must be defined");if(!u.isSet(n)&&!Array.isArray(n)&&!s.isEntry(n))throw new Error(`'sourceEntries' argument must be an EntrySet, an array of Entry instances or a single Entry`);n&&!u.isSet(n)&&(Array.isArray(n)||(n=[n]),n=new u(n)),e=e>-1?Math.max(e,n.length):e;const f=i?i.map(t=>t.hash?t.hash:t):i;return o.fetchParallel(t,n.keys,e,f).then(t=>new u(t)).then(t=>{const r=n.merge(t).last(e);const i=r.difference(n);const o=r.replaceInFront(i);return l.create(null,o)})}static fromMultihash(t,n,e=-1,i,s){if(!r(t))throw a();if(!r(n))throw new Error(`Invalid hash: ${n}`);return t.object.get(n,{enc:"base58"}).then(t=>JSON.parse(t.toJSON().data)).then(n=>{if(!n.heads||!n.id)throw h();return o.fetchAll(t,n.heads,e,i).then(t=>l.create(n.id,t,n.heads))})}static toMultihash(t,n){if(!r(t))throw a();if(!r(n))throw f();if(!l.isLog(n))throw h();if(n.values.length<1)throw new Error(`Can't serialize an empty log`);if(n.heads.length<1)throw new Error(`Can't serialize a log without heads`);return t.object.put(n.toBuffer()).then(t=>t.toJSON().multihash)}}t.exports=l},function(t,n,e){"use strict";(function(n){const r=e(8),i=e(9),o=()=>(new Date).getTime();class s{constructor(t,n,e,s){this._id=t||o(),this._clock=s||new i(this.id),this._entries=n||new r,this._heads=e||this.entries.heads}get id(){return this._id}get clock(){return this._clock}get items(){return this.entries.values}get values(){return this.entries.values}get entries(){return this._entries}get heads(){return this._heads}get tails(){return this.entries.tails}get tailHashes(){return this.entries.tailHashes}get length(){return this.entries.length}get(t){return this.entries.get(t)}append(t){const n=this.entries.append(t);return new s(this.id,n,[t],this.clock)}toJSON(){return{id:this.id,heads:this.heads.map(t=>t.hash)}}toBuffer(){return new n(JSON.stringify(this.toJSON()))}toString(){return this.items.slice().reverse().map((t,n)=>{const e=r.findChildren(this.entries.values,t);const i=e.length;let o=new Array(Math.max(i-1,0));o=i>1?o.fill(" "):o;o=i>0?o.concat(["└─"]):o;return o.join("")+t.payload}).join("\n")}}t.exports=s}).call(n,e(0).Buffer)},function(t,n){function e(t){return r(t)||i(t)}function r(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function i(t){return s[o.call(t)]}t.exports=e,e.strict=r,e.loose=i;var o=Object.prototype.toString,s={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},function(t,n){var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},function(t,n,e){(function(n){t.exports=function(){function t(t,n){return function(r){return function(){e(t,n),r&&r.apply(null,arguments)}}}function e(n,e){var r=u[n].indexOf(e);~r&&(u[n].splice(r,1),o(n)?s(function(){u[n][0](t(n,u[n][0]))}):delete u[n])}function r(t,n){return o(t)?(u[t].push(n),!1):(u[t]=[n],!0)}function i(n,i){function o(t){return function(){var n=[].slice.call(arguments);for(var r in u)e(r,u[r]);t.apply(this,n)}}if(Array.isArray(n)){var s=n.length,u={};return void n.forEach(function(t){function n(){e++||--s||i(o)}var e=0;u[t]=n,r(t,n)&&n()})}r(n,i)&&i(t(n,i))}function o(t){return!!Array.isArray(u[t])&&!!u[t].length}var s=void 0===n?setTimeout:n,u={};return i.isLocked=o,i}}).call(n,e(7).setImmediate)},function(t,n,e){"use strict";(function(n){const r=e(82),i=e(80).format,o=e(6).EventEmitter;let s=!!n.version;const u={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",NONE:"NONE"};let c=u.DEBUG,a=null,f=new o,h={Black:0,Red:1,Green:2,Yellow:3,Blue:4,Magenta:5,Cyan:6,Grey:7,White:9,Default:9};s||(h={Black:"Black",Red:"IndianRed",Green:"LimeGreen",Yellow:"Orange",Blue:"RoyalBlue",Magenta:"Orchid",Cyan:"SkyBlue",Grey:"DimGrey",White:"White",Default:"Black"});const l=[h.Cyan,h.Green,h.Yellow,h.Red,h.Default],p={useColors:!0,color:h.Default,showTimestamp:!0,showLevel:!0,filename:a,appendFile:!0};class d{constructor(t,n){this.category=t;let e={};Object.assign(e,p),Object.assign(e,n),this.options=e}debug(){this._shouldLog(u.DEBUG)&&this._write(u.DEBUG,i.apply(null,arguments))}log(){this._shouldLog(u.DEBUG)&&this.debug.apply(this,arguments)}info(){this._shouldLog(u.INFO)&&this._write(u.INFO,i.apply(null,arguments))}warn(){this._shouldLog(u.WARN)&&this._write(u.WARN,i.apply(null,arguments))}error(){this._shouldLog(u.ERROR)&&this._write(u.ERROR,i.apply(null,arguments))}_write(t,n){(this.options.filename||a)&&!this.fileWriter&&s&&(this.fileWriter=r.openSync(this.options.filename||a,this.options.appendFile?"a+":"w+"));let e=this._format(t,n),i=this._createLogMessage(t,n),o=this._createLogMessage(t,n,e.timestamp,e.level,e.category,e.text);this.fileWriter&&s&&r.writeSync(this.fileWriter,i+"\n",null,"utf-8"),s||!this.options.useColors?(console.log(o),f.emit("data",this.category,t,n)):t===u.ERROR?this.options.showTimestamp&&this.options.showLevel?console.error(o,e.timestamp,e.level,e.category,e.text):this.options.showTimestamp&&!this.options.showLevel?console.error(o,e.timestamp,e.category,e.text):!this.options.showTimestamp&&this.options.showLevel?console.error(o,e.level,e.category,e.text):console.error(o,e.category,e.text):this.options.showTimestamp&&this.options.showLevel?console.log(o,e.timestamp,e.level,e.category,e.text):this.options.showTimestamp&&!this.options.showLevel?console.log(o,e.timestamp,e.category,e.text):!this.options.showTimestamp&&this.options.showLevel?console.log(o,e.level,e.category,e.text):console.log(o,e.category,e.text)}_format(t,n){let e="",r="",i="",o=": ";if(this.options.useColors){const n=Object.keys(u).map(t=>u[t]).indexOf(t),c=this.options.color;s?(this.options.showTimestamp&&(e="[3"+h.Grey+"m"),this.options.showLevel&&(r="[3"+l[n]+";22m"),i="[3"+c+";1m",o=": "):(this.options.showTimestamp&&(e="color:"+h.Grey),this.options.showLevel&&(r="color:"+l[n]),i="color:"+c+"; font-weight: bold")}return{timestamp:e,level:r,category:i,text:o}}_createLogMessage(t,n,e,r,i,o){e=e||"",r=r||"",i=i||"",o=o||": ",!s&&this.options.useColors&&(this.options.showTimestamp&&(e="%c"),this.options.showLevel&&(r="%c"),i="%c",o=": %c");let c="";return this.options.showTimestamp&&(c+=(new Date).toISOString()+" "),c=e+c,this.options.showLevel&&(c+=r+"["+t+"]"+(t===u.INFO||t===u.WARN?" ":"")+" "),c+=i+this.category,c+=o+n}_shouldLog(t){let e=void 0!==n&&void 0!==n.env&&void 0!==n.env.LOG?n.env.LOG.toUpperCase():null;e="undefined"!=typeof window&&window.LOG?window.LOG.toUpperCase():e;const r=e||c,i=Object.keys(u).map(t=>u[t]);return i.indexOf(t)>=i.indexOf(r)}}t.exports={Colors:h,LogLevels:u,setLogLevel:t=>{c=t},setLogfile:t=>{a=t},create:(t,n)=>{const e=new d(t,n);return e},forceBrowserMode:t=>s=!t,events:f}}).call(n,e(10))},function(t,n){t.exports=function(t){return function n(e,r,i){var o=!0,s=!1;do{s=!0,o=!1,t.call(function(t,u,c){s?(e=t,r=u,i=c,o=!0):n(t,u,c)},e,r,i),s=!1}while(o)}}},function(t,n,e){"use strict";(function(n){const r=e(16),i=e(30),o=e(38);class s{constructor(t,n=""){this.path=t||"./orbit-db",this.filename=n+"orbit.db",this._store=new i(this.path),this._cache={},this._lock=new o}get(t){return this._cache[t]}set(t,n){return new Promise((e,i)=>{if(this._cache[t]===n)return e(n);this._cache[t]=n;this._lock(this.filename,t=>{r(r.values([this._cache]),r.map(t=>JSON.stringify(t,null,2)),this._store.write(this.filename,t(t=>{if(t)return i(t);e(n)})))})})}load(){return this._cache={},new Promise((t,e)=>{this._store.exists(this.filename,(i,o)=>{if(i||!o)return t();this._lock(this.filename,i=>{r(this._store.read(this.filename),r.collect(i((r,i)=>{if(r)return e(r);try{this._cache=JSON.parse(n.concat(i).toString()||"{}")}catch(t){return e(t)}t()})))})})})}reset(){this._cache={},this._store=null}}t.exports=s}).call(n,e(0).Buffer)},function(t,n,e){"use strict";const r=e(27);class i{constructor(t){this._counter=new r(t)}get(){return this._counter}updateIndex(t){this._counter&&t.items.filter(t=>t&&"COUNTER"===t.payload.op).map(t=>r.from(t.payload.value)).forEach(t=>this._counter.merge(t))}}t.exports=i},function(t,n,e){"use strict";class r{constructor(){this._index={}}get(t){return this._index[t]}updateIndex(t){t.items.slice().reverse().reduce((t,n)=>{t.indexOf(n.payload.key)===-1&&(t.push(n.payload.key),"PUT"===n.payload.op?this._index[n.payload.key]=n.payload.value:"DEL"===n.payload.op&&delete this._index[n.payload.key]);return t},[])}}t.exports=r},function(t,n,e){"use strict";class r{constructor(){this._index=[]}get(){return this._index}updateIndex(t){this._index=t.items}}t.exports=r},function(t,n,e){"use strict";class r{constructor(){this._index={}}get(){return Object.keys(this._index).map(t=>this._index[t])}updateIndex(t){t.items.reduce((t,n)=>{t.includes(n.hash)||(t.push(n.hash),"ADD"===n.payload.op?this._index[n.hash]=n:"DEL"===n.payload.op&&delete this._index[n.payload.value]);return t},[])}}t.exports=r},function(t,n,e){"use strict";class r{constructor(){this._index={}}get(t){return this._index[t]}updateIndex(t){t.items.slice().reverse().reduce((t,n)=>{t.includes(n.payload.key)||(t.push(n.payload.key),"PUT"===n.payload.op?this._index[n.payload.key]=n.payload.value:"DEL"===n.payload.op&&delete this._index[n.payload.key]);return t},[])}}t.exports=r},function(t,n,e){"use strict";(function(n){const r=e(39),i=r.create("orbit-db.ipfs-pubsub");r.setLogLevel("ERROR");class o{constructor(t){this._ipfs=t,this._subscriptions={},null===this._ipfs.pubsub&&i.error("The provided version of ipfs doesn't have pubsub support. Messages will not be exchanged."),this._handleMessage=this._handleMessage.bind(this)}subscribe(t,n){this._subscriptions[t]||(this._subscriptions[t]={onMessage:n},this._ipfs.pubsub&&this._ipfs.pubsub.subscribe(t,{discover:!0},this._handleMessage))}unsubscribe(t){this._subscriptions[t]&&(this._ipfs.pubsub.unsubscribe(t,this._handleMessage),delete this._subscriptions[t],i.debug(`Unsubscribed from '${t}'`))}publish(t,e){this._subscriptions[t]&&this._ipfs.pubsub&&this._ipfs.pubsub.publish(t,new n(JSON.stringify(e)))}disconnect(){Object.keys(this._subscriptions).forEach(t=>this.unsubscribe(t)),this._subscriptions={}}_handleMessage(t){if(t.from!==this._ipfs.PeerId){const n=t.topicCIDs[0],e=JSON.parse(t.data.toString()),r=this._subscriptions[n];r&&r.onMessage&&e&&r.onMessage(n,e)}}}t.exports=o}).call(n,e(0).Buffer)},function(t,n,e){"use strict";class r{constructor(t){this.id=t,this._index=[]}get(){return this._index}updateIndex(t,n){this._index=t.ops}}t.exports=r},function(t,n,e){"use strict";t.exports=((t,n,e)=>new Promise((r,i)=>{const o=Array.from(t);if(0===o.length)return void r([]);e=Object.assign({concurrency:1/0},e);let s=e.concurrency;(1/0===s||s>o.length)&&(s=o.length);if(!(Number.isFinite(s)&&s>=1))throw new TypeError("Expected `concurrency` to be a finite number from 1 and up");const u=new Array(o.length);let c=!1;let a=0;const f=t=>{if(c)return;if(a===o.length)return void r(u);if(t>=o.length)return;Promise.resolve(o[t]).then(e=>n(e,t)).then(n=>{a++;u[t]=n;f(t+s)},t=>{c=!0;i(t)})};for(let t=0;tnew Promise(n=>{n(t())});t.exports=((t,n)=>r(function e(){if(t())return r(n).then(e)}))},function(t,n){t.exports=function(t){function n(n){if(!n)throw new Error("must be passed a readable");e=n,r&&t(e)}var e,r=!1;Math.random();return n.resolve=n.ready=n.start=function(i){return r=!0,t=i||t,e&&t(e),n},n}},function(t,n){function e(t){function n(t,n){t&&(i=t,o&&r(i)),o=n,e()}function e(){o&&(i?r(i):!u.length&&s?r(s):u.length&&r(null,u.shift()))}function r(n,e){var r=o;if(n&&t){var i=t;t=null,i(n===!0?null:n)}o=null,r(n,e)}var i,o,s,u=[];return n.end=function(t){s=s||t||!0,e()},n.push=function(t){if(!s){if(o)return void r(i,t);u.push(t),e()}},n}t.exports=e},function(t,n,e){"use strict";t.exports=function t(n){var e=arguments.length;if("function"==typeof n&&1===n.length){for(var r=new Array(e),i=0;it?r(!0):void r(null,n++)}}},function(t,n,e){"use strict";t.exports=function(){return function(t,n){n(!0)}}},function(t,n,e){"use strict";t.exports=function(t){return function(n,e){e(t)}}},function(t,n,e){"use strict";t.exports={keys:e(65),once:e(17),values:e(12),count:e(60),infinite:e(64),empty:e(61),error:e(62)}},function(t,n,e){"use strict";t.exports=function(t){return t=t||Math.random,function(n,e){return n?e&&e(n):e(null,t())}}},function(t,n,e){"use strict";var r=e(12);t.exports=function(t){return r(Object.keys(t))}},function(t,n,e){"use strict";function r(t){return t}var i=e(2);t.exports=function(t){if(!t)return r;t=i(t);var n,e,o=!1;return function(r){return function i(s,u){if(e)return u(e);s?(e=s,o?r(s,function(){o?n=u:u(s)}):r(s,u)):r(null,function(r,s){r?u(r):e?u(e):(o=!0,t(s,function(t,r){o=!1,e?(u(e),n(e)):t?i(t,u):u(null,r)}))})}}}},function(t,n,e){"use strict";var r=e(20),i=e(13);t.exports=function(t){return t=r(t),i(function(n){return!t(n)})}},function(t,n,e){"use strict";var r=e(12),i=e(17);t.exports=function(){return function(t){var n;return function(e,o){function s(){n(null,function(n,e){n===!0?u():n?t(!0,function(t){o(n)}):o(null,e)})}function u(){n=null,t(null,function(t,e){if(t)return o(t);Array.isArray(e)||e&&"object"==typeof e?e=r(e):"function"!=typeof e&&(e=i(e)),n=e,s()})}e?n?n(e,function(n){t(n||e,o)}):t(e,o):n?s():u()}}}},function(t,n,e){"use strict";t.exports={map:e(70),asyncMap:e(66),filter:e(13),filterNot:e(67),through:e(73),take:e(72),unique:e(18),nonUnique:e(71),flatten:e(68)}},function(t,n,e){"use strict";function r(t){return t}var i=e(2);t.exports=function(t){return t?(t=i(t),function(n){return function(e,r){n(e,function(e,i){try{i=e?null:t(i)}catch(t){return n(t,function(){return r(t)})}r(e,i)})}}):r}},function(t,n,e){"use strict";var r=e(18);t.exports=function(t){return r(t,!0)}},function(t,n,e){"use strict";t.exports=function(t,n){n=n||{};var e=n.last||!1,r=!1;if("number"==typeof t){e=!0;var i=t;t=function(){return--i}}return function(n){function i(t){n(!0,function(n){e=!1,t(n||!0)})}return function(o,s){r?e?i(s):s(r):(r=o)?n(r,s):n(null,function(n,o){(r=r||n)?s(r):t(o)?s(null,o):(r=!0,e?s(null,o):i(s))})}}}},function(t,n,e){"use strict";t.exports=function(t,n){function e(t){!r&&n&&(r=!0,n(t===!0?null:t))}var r=!1;return function(n){return function(r,i){return r&&e(r),n(r,function(n,r){n?e(n):t&&t(r),i(n,r)})}}}},function(t,n,e){var r=e(40),i=t.exports=function(t,n){return function(e){n=n||function(t,n){return{start:t,data:n}};var i=[],o=[],s=null,u=0;return function(c,a){if(o.length)return a(null,o.shift());if(s)return a(s);u++;e(c,r(function(r,u){function c(t,e){l||(l=!0,delete i[i.indexOf(f)],o.push(n(u,e)))}var f,h=this,l=!1;return r&&(s=r),s||(f=t(u,c)),f?i.push(f):l=!0,i.forEach(function(t,n){t(r,u)}),o.length?a(null,o.shift()):s?a(s):void e(null,h)}))}}};i.recent=function(t,n){var e=null;return i(function(r,i){function o(){var t=e;e=null,clearTimeout(s),i(null,t)}if(!e){e=[];var s;return n&&(s=setTimeout(o,n)),function(n,r){if(n)return o();e.push(r),null!=t&&e.length>=t&&o()}}},function(t,n){return n})},i.sliding=function(t,n){n=n||10;var e=0;return i(function(r,i){var o,s=0;e++;return function(e,r){e||(o=t(o,r),n<=++s&&i(null,o))}})}},function(t,n){function e(t,n){return(t=t||[]).push(n),t}t.exports=function(t,n,r,i){function o(e){function a(){v||s||(v=!0,e(null,function(t,n){v=!1,h(t,n)}))}function f(){if(!p){var n=l;l=null,p=!0,d=0,t(n,function(t){p=!1,s!==!0||d?s&&s!==!0?(i(s),u&&u()):t?e(s=t,i):d?f():a():i(t)})}}function h(t,e){s||(s=t,s?p||i(s===!0?null:s):(l=n(l,e),d=l&&l.length||0,null!=l&&f(),d=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(e)?r.showHidden=e:e&&n._extend(r,e),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),c(r,t,r.depth)}function o(t,n){var e=i.styles[n];return e?"["+i.colors[e][0]+"m"+t+"["+i.colors[e][1]+"m":t}function s(t,n){return t}function u(t){var n={};return t.forEach(function(t,e){n[t]=!0}),n}function c(t,e,r){if(t.customInspect&&e&&O(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return b(i)||(i=c(t,i,r)),i}var o=a(t,e);if(o)return o;var s=Object.keys(e),v=u(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),A(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(O(e)){var y=e.name?": "+e.name:"";return t.stylize("[Function"+y+"]","special")}if(x(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(k(e))return t.stylize(Date.prototype.toString.call(e),"date");if(A(e))return f(e)}var g="",m=!1,w=["{","}"];if(d(e)&&(m=!0,w=["[","]"]),O(e)){g=" [Function"+(e.name?": "+e.name:"")+"]"}if(x(e)&&(g=" "+RegExp.prototype.toString.call(e)),k(e)&&(g=" "+Date.prototype.toUTCString.call(e)),A(e)&&(g=" "+f(e)),0===s.length&&(!m||0==e.length))return w[0]+g+w[1];if(r<0)return x(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var _;return _=m?h(t,e,r,v,s):s.map(function(n){return l(t,e,r,v,n,m)}),t.seen.pop(),p(_,g,w)}function a(t,n){if(_(n))return t.stylize("undefined","undefined");if(b(n)){var e="'"+JSON.stringify(n).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(e,"string")}return m(n)?t.stylize(""+n,"number"):v(n)?t.stylize(""+n,"boolean"):y(n)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,n,e,r,i){for(var o=[],s=0,u=n.length;s-1&&(u=o?u.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+u.split("\n").map(function(t){return" "+t}).join("\n"))):u=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+u}function p(t,n,e){var r=0;return t.reduce(function(t,n){return r++,n.indexOf("\n")>=0&&r++,t+n.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?e[0]+(""===n?"":n+"\n ")+" "+t.join(",\n ")+" "+e[1]:e[0]+n+" "+t.join(", ")+" "+e[1]}function d(t){return Array.isArray(t)}function v(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return null==t}function m(t){return"number"==typeof t}function b(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function _(t){return void 0===t}function x(t){return E(t)&&"[object RegExp]"===P(t)}function E(t){return"object"==typeof t&&null!==t}function k(t){return E(t)&&"[object Date]"===P(t)}function A(t){return E(t)&&("[object Error]"===P(t)||t instanceof Error)}function O(t){return"function"==typeof t}function T(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function P(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}function I(){var t=new Date,n=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":");return[t.getDate(),D[t.getMonth()],n].join(" ")}function j(t,n){return Object.prototype.hasOwnProperty.call(t,n)}n.format=function(t){if(!b(t)){for(var n=[],e=0;e=o)return t;switch(t){case"%s":return String(r[e++]);case"%d":return Number(r[e++]);case"%j":try{return JSON.stringify(r[e++])}catch(t){return"[Circular]"}default:return t}}),u=r[e];ethis.close(t)),this._pubsub&&this._pubsub.disconnect(),this.stores={},this.user=null,this.network=null}_createStore(t,n,e){const r=Object.assign({replicate:!0},e),i=new t(this._ipfs,this.user.id,n,r);return i.events.on("write",this._onWrite.bind(this)),i.events.on("ready",this._onReady.bind(this)),this.stores[n]=i,r.replicate&&this._pubsub&&this._pubsub.subscribe(n,this._onMessage.bind(this)),i}_onMessage(t,n){this.stores[t].sync(n)}_onWrite(t,e,r,i){if(!i)throw new Error("'heads' not defined");this._pubsub&&n(()=>this._pubsub.publish(t,i))}_onReady(t,n){n&&this._pubsub&&setTimeout(()=>this._pubsub.publish(t,n),1e3)}}t.exports=f}).call(n,e(7).setImmediate)},function(t,n){}]); //# sourceMappingURL=orbitdb.min.js.map \ No newline at end of file diff --git a/package.json b/package.json index 144ad37..5170c7c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "babel-plugin-transform-runtime": "^6.22.0", "babel-polyfill": "^6.22.0", "babel-preset-es2015": "^6.22.0", - "ipfs-daemon": "~0.3.0-beta.24", + "ipfs-daemon": "~0.3.1", "json-loader": "^0.5.4", "mocha": "^3.2.0", "p-each-series": "^1.0.0",