var OrbitDB=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=221)}([function(e,t,r){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var n=r(222),i=r(223),o=r(100);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(n)return K(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function N(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function O(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function L(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(e,t,r,n,o){return o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,o){return o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||R(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):O(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);R(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);R(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):O(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return P(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return P(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function V(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(6))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var c,u=[],f=!1,h=-1;function l(){f&&c&&(f=!1,c.length?u=c.concat(u):h=-1,u.length&&d())}function d(){if(!f){var e=a(l);f=!0;for(var t=u.length;t;){for(c=u,u=[];++h1)for(var r=1;r15?(i=Date.now(),a(e)):(r.push(e),1===r.length&&s.setAttribute("a",o=!o))}}c.nextTick=c.setImmediate}(),c.isNodejs=void 0!==t&&t.versions&&t.versions.node,c.globalScope=c.isNodejs?i:"undefined"==typeof self?window:self,c.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},c.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},c.isArrayBufferView=function(e){return e&&c.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},c.ByteBuffer=f,c.ByteStringBuffer=f;c.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},c.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},c.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},c.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},c.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},c.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},c.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(c.encodeUtf8(e))},c.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},c.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},c.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},c.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},c.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},c.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},c.ByteStringBuffer.prototype.putInt=function(e,t){u(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},c.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},c.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},c.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},c.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},c.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},c.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},c.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},c.ByteStringBuffer.prototype.copy=function(){var e=c.createBuffer(this.data);return e.read=this.read,e},c.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},c.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},c.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},c.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},c.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},c.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},c.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},c.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},c.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},c.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},c.DataBuffer.prototype.putInt=function(e,t){u(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},c.DataBuffer.prototype.putSignedInt=function(e,t){return u(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},c.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},c.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},c.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},c.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},c.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},c.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},c.DataBuffer.prototype.copy=function(){return new c.DataBuffer(this)},c.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},c.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},c.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},c.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},c.xorBytes=function(e,t,r){for(var n="",i="",o="",s=0,a=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),a>=10&&(n+=o,o="",a=0),o+=String.fromCharCode(i),++a;return n+=o},c.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],d="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";c.encode64=function(e,t){for(var r,n,i,o="",s="",a=0;a>2),o+=h.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=h.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":h.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},c.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",s=0;s>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},c.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},c.decodeUtf8=function(e){return decodeURIComponent(escape(e))},c.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:a.encode,decode:a.decode}},c.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},c.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o>2),o+=h.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=h.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":h.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},c.binary.base64.decode=function(e,t,r){var n,i,o,s,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==o&&(a[u++]=(15&i)<<4|o>>2,64!==s&&(a[u++]=(3&o)<<6|s));return t?u-r:a.subarray(0,u)},c.binary.base58.encode=function(e,t){return c.binary.baseN.encode(e,d,t)},c.binary.base58.decode=function(e,t){return c.binary.baseN.decode(e,d,t)},c.text={utf8:{},utf16:{}},c.text.utf8.encode=function(e,t,r){e=c.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o0?(i=r[n].substring(0,s),o=r[n].substring(s+1)):(i=r[n],o=null),i in t||(t[i]=[]),i in Object.prototype||null===o||t[i].push(unescape(o))}return t};return void 0===e?(null===_&&(_="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=_):t=r(e),t},c.parseFragment=function(e){var t=e,r="",n=e.indexOf("?");n>0&&(t=e.substring(0,n),r=e.substring(n+1));var i=t.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:t,queryString:r,path:i,query:""===r?{}:c.getQueryVariables(r)}},c.makeRequest=function(e){var t=c.parseFragment(e),r={path:t.pathString,query:t.queryString,getPath:function(e){return void 0===e?t.path:t.path[e]},getQuery:function(e,r){var n;return void 0===e?n=t.query:(n=t.query[e])&&void 0!==r&&(n=n[r]),n},getQueryLast:function(e,t){var n=r.getQuery(e);return n?n[n.length-1]:t}};return r},c.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},c.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},c.format=function(e){for(var t,r,n=/%./g,i=0,o=[],s=0;t=n.exec(e);){(r=e.substring(s,n.lastIndex-2)).length>0&&o.push(r),s=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i");break;case"%":o.push("%");break;default:o.push("<%"+a+"?>")}}return o.push(e.substring(s)),o.join("")},c.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",f=u.length>3?u.length%3:0;return c+(f?u.substr(0,f)+a:"")+u.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-u).toFixed(o).slice(2):"")},c.formatSize=function(e){return e=e>=1073741824?c.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?c.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?c.formatNumber(e/1024,0)+" KiB":c.formatNumber(e,0)+" bytes"},c.bytesFromIP=function(e){return-1!==e.indexOf(".")?c.bytesFromIPv4(e):-1!==e.indexOf(":")?c.bytesFromIPv6(e):null},c.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=c.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:a,end:a})}t.push(o)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},c.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in c&&!e.update)return t(null,c.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return c.cores=navigator.hardwareConcurrency,t(null,c.cores);if("undefined"==typeof Worker)return c.cores=1,t(null,c.cores);if("undefined"==typeof Blob)return c.cores=2,t(null,c.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()a.st&&i.sti.st&&a.st0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var u=c.length,f=b(c,u);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},a.prototype.listenerCount=y,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e,t,r){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}}n.uint=new n(0,"uint",!0),n.negint=new n(1,"negint",!0),n.bytes=new n(2,"bytes",!0),n.string=new n(3,"string",!0),n.array=new n(4,"array",!1),n.map=new n(5,"map",!1),n.tag=new n(6,"tag",!1),n.float=new n(7,"float",!0),n.false=new n(7,"false",!0),n.true=new n(7,"true",!0),n.null=new n(7,"null",!0),n.undefined=new n(7,"undefined",!0),n.break=new n(7,"break",!0);t.Token=class{constructor(e,t,r){this.type=e,this.value=t,this.encodedLength=r,this.encodedBytes=void 0}toString(){return`Token[${this.type}].${this.value}`}},t.Type=n},function(e,t){e.exports=function(){for(var e={},t=0;t(i>>1)-1?(i>>1)-c:c,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var s,a,c=e.andln(3)+i&3,u=t.andln(3)+o&3;3===c&&(c=-1),3===u&&(u=-1),s=0==(1&c)?0:3!==(n=e.andln(7)+i&7)&&5!==n||2!==u?c:-c,r[0].push(s),a=0==(1&u)?0:3!==(n=t.andln(7)+o&7)&&5!==n||2!==c?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,r){(function(e){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(398).Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function c(e,t,r){var n=a(e,r);return r-1>=t&&(n|=a(e,r-1)<<4),n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=c(e,t,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,t.length-1),d=Math.max(0,u-e.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?f[6-c.length]+c+r:c+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var u=h[e],d=l[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?y+r:f[u-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,c="le"===t,u=new e(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,y=d>>>13,b=0|s[2],g=8191&b,m=b>>>13,v=0|s[3],w=8191&v,_=v>>>13,S=0|s[4],E=8191&S,k=S>>>13,A=0|s[5],C=8191&A,I=A>>>13,T=0|s[6],x=8191&T,B=T>>>13,M=0|s[7],R=8191&M,N=M>>>13,O=0|s[8],L=8191&O,P=O>>>13,U=0|s[9],D=8191&U,j=U>>>13,K=0|a[0],V=8191&K,q=K>>>13,F=0|a[1],z=8191&F,H=F>>>13,W=0|a[2],G=8191&W,Y=W>>>13,Q=0|a[3],$=8191&Q,X=Q>>>13,Z=0|a[4],J=8191&Z,ee=Z>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,fe=0|a[8],he=8191&fe,le=fe>>>13,de=0|a[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(u+(n=Math.imul(h,V))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,V)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(p,V),i=(i=Math.imul(p,q))+Math.imul(y,V)|0,o=Math.imul(y,q);var ge=(u+(n=n+Math.imul(h,z)|0)|0)+((8191&(i=(i=i+Math.imul(h,H)|0)+Math.imul(l,z)|0))<<13)|0;u=((o=o+Math.imul(l,H)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(g,V),i=(i=Math.imul(g,q))+Math.imul(m,V)|0,o=Math.imul(m,q),n=n+Math.imul(p,z)|0,i=(i=i+Math.imul(p,H)|0)+Math.imul(y,z)|0,o=o+Math.imul(y,H)|0;var me=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(w,V),i=(i=Math.imul(w,q))+Math.imul(_,V)|0,o=Math.imul(_,q),n=n+Math.imul(g,z)|0,i=(i=i+Math.imul(g,H)|0)+Math.imul(m,z)|0,o=o+Math.imul(m,H)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(y,G)|0,o=o+Math.imul(y,Y)|0;var ve=(u+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,$)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(E,V),i=(i=Math.imul(E,q))+Math.imul(k,V)|0,o=Math.imul(k,q),n=n+Math.imul(w,z)|0,i=(i=i+Math.imul(w,H)|0)+Math.imul(_,z)|0,o=o+Math.imul(_,H)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(m,G)|0,o=o+Math.imul(m,Y)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,X)|0;var we=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,J)|0))<<13)|0;u=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(C,V),i=(i=Math.imul(C,q))+Math.imul(I,V)|0,o=Math.imul(I,q),n=n+Math.imul(E,z)|0,i=(i=i+Math.imul(E,H)|0)+Math.imul(k,z)|0,o=o+Math.imul(k,H)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,X)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,X)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,ee)|0;var _e=(u+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;u=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(x,V),i=(i=Math.imul(x,q))+Math.imul(B,V)|0,o=Math.imul(B,q),n=n+Math.imul(C,z)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(I,z)|0,o=o+Math.imul(I,H)|0,n=n+Math.imul(E,G)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(m,J)|0,o=o+Math.imul(m,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Se=(u+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(l,oe)|0))<<13)|0;u=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(R,V),i=(i=Math.imul(R,q))+Math.imul(N,V)|0,o=Math.imul(N,q),n=n+Math.imul(x,z)|0,i=(i=i+Math.imul(x,H)|0)+Math.imul(B,z)|0,o=o+Math.imul(B,H)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(E,$)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(g,re)|0,i=(i=i+Math.imul(g,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,se)|0;var Ee=(u+(n=n+Math.imul(h,ce)|0)|0)+((8191&(i=(i=i+Math.imul(h,ue)|0)+Math.imul(l,ce)|0))<<13)|0;u=((o=o+Math.imul(l,ue)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,q))+Math.imul(P,V)|0,o=Math.imul(P,q),n=n+Math.imul(R,z)|0,i=(i=i+Math.imul(R,H)|0)+Math.imul(N,z)|0,o=o+Math.imul(N,H)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,X)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,X)|0,n=n+Math.imul(E,J)|0,i=(i=i+Math.imul(E,ee)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(g,oe)|0,i=(i=i+Math.imul(g,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(y,ce)|0,o=o+Math.imul(y,ue)|0;var ke=(u+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;u=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,V),i=(i=Math.imul(D,q))+Math.imul(j,V)|0,o=Math.imul(j,q),n=n+Math.imul(L,z)|0,i=(i=i+Math.imul(L,H)|0)+Math.imul(P,z)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(N,G)|0,o=o+Math.imul(N,Y)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,X)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(E,re)|0,i=(i=i+Math.imul(E,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(g,ce)|0,i=(i=i+Math.imul(g,ue)|0)+Math.imul(m,ce)|0,o=o+Math.imul(m,ue)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(y,he)|0,o=o+Math.imul(y,le)|0;var Ae=(u+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(l,pe)|0))<<13)|0;u=((o=o+Math.imul(l,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,z),i=(i=Math.imul(D,H))+Math.imul(j,z)|0,o=Math.imul(j,H),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(N,$)|0,o=o+Math.imul(N,X)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(E,oe)|0,i=(i=i+Math.imul(E,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(w,ce)|0,i=(i=i+Math.imul(w,ue)|0)+Math.imul(_,ce)|0,o=o+Math.imul(_,ue)|0,n=n+Math.imul(g,he)|0,i=(i=i+Math.imul(g,le)|0)+Math.imul(m,he)|0,o=o+Math.imul(m,le)|0;var Ce=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;u=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(j,G)|0,o=Math.imul(j,Y),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(E,ce)|0,i=(i=i+Math.imul(E,ue)|0)+Math.imul(k,ce)|0,o=o+Math.imul(k,ue)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Ie=(u+(n=n+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,ye)|0)+Math.imul(m,pe)|0))<<13)|0;u=((o=o+Math.imul(m,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(D,$),i=(i=Math.imul(D,X))+Math.imul(j,$)|0,o=Math.imul(j,X),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(P,J)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,se)|0,n=n+Math.imul(C,ce)|0,i=(i=i+Math.imul(C,ue)|0)+Math.imul(I,ce)|0,o=o+Math.imul(I,ue)|0,n=n+Math.imul(E,he)|0,i=(i=i+Math.imul(E,le)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,le)|0;var Te=(u+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;u=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,J),i=(i=Math.imul(D,ee))+Math.imul(j,J)|0,o=Math.imul(j,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,se)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,se)|0,n=n+Math.imul(x,ce)|0,i=(i=i+Math.imul(x,ue)|0)+Math.imul(B,ce)|0,o=o+Math.imul(B,ue)|0,n=n+Math.imul(C,he)|0,i=(i=i+Math.imul(C,le)|0)+Math.imul(I,he)|0,o=o+Math.imul(I,le)|0;var xe=(u+(n=n+Math.imul(E,pe)|0)|0)+((8191&(i=(i=i+Math.imul(E,ye)|0)+Math.imul(k,pe)|0))<<13)|0;u=((o=o+Math.imul(k,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(j,re)|0,o=Math.imul(j,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,se)|0,n=n+Math.imul(R,ce)|0,i=(i=i+Math.imul(R,ue)|0)+Math.imul(N,ce)|0,o=o+Math.imul(N,ue)|0,n=n+Math.imul(x,he)|0,i=(i=i+Math.imul(x,le)|0)+Math.imul(B,he)|0,o=o+Math.imul(B,le)|0;var Be=(u+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,ye)|0)+Math.imul(I,pe)|0))<<13)|0;u=((o=o+Math.imul(I,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,se))+Math.imul(j,oe)|0,o=Math.imul(j,se),n=n+Math.imul(L,ce)|0,i=(i=i+Math.imul(L,ue)|0)+Math.imul(P,ce)|0,o=o+Math.imul(P,ue)|0,n=n+Math.imul(R,he)|0,i=(i=i+Math.imul(R,le)|0)+Math.imul(N,he)|0,o=o+Math.imul(N,le)|0;var Me=(u+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,ye)|0)+Math.imul(B,pe)|0))<<13)|0;u=((o=o+Math.imul(B,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(D,ce),i=(i=Math.imul(D,ue))+Math.imul(j,ce)|0,o=Math.imul(j,ue),n=n+Math.imul(L,he)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var Re=(u+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(N,pe)|0))<<13)|0;u=((o=o+Math.imul(N,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(D,he),i=(i=Math.imul(D,le))+Math.imul(j,he)|0,o=Math.imul(j,le);var Ne=(u+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ye)|0)+Math.imul(P,pe)|0))<<13)|0;u=((o=o+Math.imul(P,ye)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863;var Oe=(u+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,ye))+Math.imul(j,pe)|0))<<13)|0;return u=((o=Math.imul(j,ye))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,c[0]=be,c[1]=ge,c[2]=me,c[3]=ve,c[4]=we,c[5]=_e,c[6]=Se,c[7]=Ee,c[8]=ke,c[9]=Ae,c[10]=Ce,c[11]=Ie,c[12]=Te,c[13]=xe,c[14]=Be,c[15]=Me,c[16]=Re,c[17]=Ne,c[18]=Oe,0!==u&&(c[19]=u,r.length++),r};function y(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(p=d),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):y(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,c=n.length-i.length;if("mod"!==t){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),c=new o(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(c)):(r.isub(t),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(t.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new E(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function k(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new w;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return g[e]=t,t},E.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var y=d,b=0;0!==y.cmp(a);b++)y=y.redSqr();n(b=0;n--){for(var u=t.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new k(e)},i(k,E),k.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},k.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},k.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},k.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(397)(e))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=[];n[23]=1,n[24]=2,n[25]=3,n[26]=5,n[27]=9,t.assertEnoughData=function(e,t,r){if(e.length-t=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,s,a){var c=0,u=t;return c+=(u=u+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,s,a,c,u){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,c,u){return t+n+o+a+u>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(12);const o=[24,256,65536,4294967296,BigInt("18446744073709551616")];function s(e,t,r){i.assertEnoughData(e,t,1);const n=e[t];if(!0===r.strict&&n>>8,255&n])}else if(r>>24&255,n>>>16&255,n>>>8&255,255&n])}else{const n=BigInt(r);if(!(n>BigInt(32)&BigInt(4294967295));r[8]=255&i,i>>=8,r[7]=255&i,i>>=8,r[6]=255&i,i>>=8,r[5]=255&i,r[4]=255&o,o>>=8,r[3]=255&o,o>>=8,r[2]=255&o,o>>=8,r[1]=255&o,e.push(r)}}}f.encodedSize=function(e){return h.encodedSize(e.value)},h.encodedSize=function(e){return et.value?1:0},t.decodeUint16=function(e,t,r,i){return new n.Token(n.Type.uint,a(e,t+1,i),3)},t.decodeUint32=function(e,t,r,i){return new n.Token(n.Type.uint,c(e,t+1,i),5)},t.decodeUint64=function(e,t,r,i){return new n.Token(n.Type.uint,u(e,t+1,i),9)},t.decodeUint8=function(e,t,r,i){return new n.Token(n.Type.uint,s(e,t+1,i),2)},t.encodeUint=f,t.encodeUintValue=h,t.readUint16=a,t.readUint32=c,t.readUint64=u,t.readUint8=s,t.uintBoundaries=o},function(e,t,r){"use strict";var n=r(3).Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=f,this.end=h,t=3;break;default:return this.write=l,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}t.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){(function(e){function r(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,i="/"===s.charAt(0))}return(i?"/":"")+(t=r(n(t.split("/"),(function(e){return!!e})),!i).join("/"))||"."},t.normalize=function(e){var o=t.isAbsolute(e),s="/"===i(e,-1);return(e=r(n(e.split("/"),(function(e){return!!e})),!o).join("/"))||o||(e="."),e&&s&&(e+="/"),(o?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(n(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,r){function n(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var i=n(e.split("/")),o=n(r.split("/")),s=Math.min(i.length,o.length),a=s,c=0;c=1;--o)if(47===(t=e.charCodeAt(o))){if(!i){n=o;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"/":e.slice(0,n)},t.basename=function(e,t){var r=function(e){"string"!=typeof e&&(e+="");var t,r=0,n=-1,i=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!i){r=t+1;break}}else-1===n&&(i=!1,n=t+1);return-1===n?"":e.slice(r,n)}(e);return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},t.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,r=0,n=-1,i=!0,o=0,s=e.length-1;s>=0;--s){var a=e.charCodeAt(s);if(47!==a)-1===n&&(i=!1,n=s+1),46===a?-1===t?t=s:1!==o&&(o=1):-1!==t&&(o=-1);else if(!i){r=s+1;break}}return-1===t||-1===n||0===o||1===o&&t===n-1&&t===r+1?"":e.slice(t,n)};var i="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)}}).call(this,r(2))},function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=r,r.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";const n=r(238),{CID:i}=r(19),o=r(243),s=r(247),{sha256:a}=r(253),{base58btc:c}=r(104),u=c,f=()=>new Error("unsupported codec"),h=e=>e?Array.isArray(e)?e.map(h):i.parse(e):e,l=(e,t={})=>{if(!e||"string"==typeof e)return e;if(Array.isArray(e))return e.map(l);if(e["/"])return e["/"];const r=t.base||u;return e.toString(r)},d={[o.code]:o,[s.code]:s},p={raw:s,"dag-pb":o,"dag-cbor":s};e.exports={read:async function(e,t,r={}){t=h(l(t));const i=d[t.code];if(!i)throw f();const c=await e.block.get(t,{timeout:r.timeout}),u=await n.decode({bytes:c,codec:i,hasher:a});if(u.cid.code===o.code)return JSON.parse((new TextDecoder).decode(u.value.Data));if(u.cid.code===s.code){const e=u.value;return(r.links||[]).forEach(t=>{e[t]&&(e[t]=l(e[t],r))}),e}},write:async function(e,t,r,i={}){"dag-pb"===i.format&&(t=i.format);const c=p[t];if(!c)throw f();if(c.code===o.code&&(r="string"==typeof r?r:JSON.stringify(r),r={Data:(new TextEncoder).encode(r),Links:[]}),c.code===s.code){(i.links||[]).forEach(e=>{r[e]&&(r[e]=h(r[e]))})}const l=await n.encode({value:r,codec:c,hasher:a});return await e.block.put(l.bytes,{cid:l.cid.bytes,version:l.cid.version,format:t,mhtype:"sha2-256",pin:i.pin,timeout:i.timeout}),(c.code===o.code?l.cid.toV0():l.cid).toString(i.base||u)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(60),i=r(61),o=r(104),s=r(242),a=r(38);class c{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:g,byteLength:g,code:b,version:b,multihash:b,bytes:b,_baseCache:g,asCID:g})}toV0(){switch(this.version){case 0:return this;default:{const{code:e,multihash:t}=this;if(e!==l)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==d)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return c.createV0(t)}}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=i.create(e,t);return c.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&i.equals(this.multihash,e.multihash)}toString(e){const{bytes:t,version:r,_baseCache:n}=this;switch(r){case 0:return f(t,n,e||o.base58btc.encoder);default:return h(t,n,e||s.base32.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return m(/^0\.0/,v),!(!e||!e[y]&&e.asCID!==e)}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof c)return e;if(null!=e&&e.asCID===e){const{version:t,code:r,multihash:n,bytes:i}=e;return new c(t,r,n,i||p(t,r,n.bytes))}if(null!=e&&!0===e[y]){const{version:t,multihash:r,code:n}=e,o=i.decode(r);return c.create(t,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==l)throw new Error(`Version 0 CID must use dag-pb (code: ${l}) block encoding`);return new c(e,t,r,r.bytes);case 1:{const n=p(e,t,r.bytes);return new c(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return c.create(0,l,e)}static createV1(e,t){return c.create(1,e,t)}static decode(e){const[t,r]=c.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=c.inspectBytes(e),r=t.size-t.multihashSize,n=a.coerce(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),s=new i.Digest(t.multihashCode,t.digestSize,o,n);return[0===t.version?c.createV0(s):c.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,i]=n.decode(e.subarray(t));return t+=i,r};let i=r(),o=l;if(18===i?(i=0,t=0):1===i&&(o=r()),0!==i&&1!==i)throw new RangeError("Invalid CID version "+i);const s=t,a=r(),c=r(),u=t+c;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:u-s,size:u}}static parse(e,t){const[r,n]=u(e,t),i=c.decode(n);return i._baseCache.set(r,e),i}}const u=(e,t)=>{switch(e[0]){case"Q":{const r=t||o.base58btc;return[o.base58btc.prefix,r.decode(`${o.base58btc.prefix}${e}`)]}case o.base58btc.prefix:{const r=t||o.base58btc;return[o.base58btc.prefix,r.decode(e)]}case s.base32.prefix:{const r=t||s.base32;return[s.base32.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},f=(e,t,r)=>{const{prefix:n}=r;if(n!==o.base58btc.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i},h=(e,t,r)=>{const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i},l=112,d=18,p=(e,t,r)=>{const i=n.encodingLength(e),o=i+n.encodingLength(t),s=new Uint8Array(o+r.byteLength);return n.encodeTo(e,s,0),n.encodeTo(t,s,i),s.set(r,o),s},y=Symbol.for("@ipld/js-cid/CID"),b={writable:!1,configurable:!1,enumerable:!0},g={writable:!1,enumerable:!1,configurable:!1},m=(e,t)=>{if(!e.test("0.0.0-dev"))throw new Error(t);console.warn(t)},v="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n";t.CID=c},function(e,t,r){"use strict";e.exports={isArray:Array.isArray,assign:Object.assign,isObject:e=>"object"==typeof e,isFunction:e=>"function"==typeof e,isBoolean:e=>"boolean"==typeof e,isRegex:e=>e instanceof RegExp,keys:Object.keys}},function(e,t,r){"use strict";var n=r(48),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=h;var o=Object.create(r(41));o.inherits=r(1);var s=r(118),a=r(63);o.inherits(h,s);for(var c=i(a.prototype),u=0;ut){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,o,s){if(n.util.isArray(o)){for(var a=[],c=0;cr){if(s.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=t.length(),p.remaining=r,p.requested=d,p}d=r}var y=32==(32&c);if(y)if(h=[],void 0===d)for(;;){if(o(t,r,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),r-=2;break}a=t.length(),h.push(e(t,r,n+1,s)),r-=a-t.length()}else for(;d>0;)a=t.length(),h.push(e(t,d,n+1,s)),r-=a-t.length(),d-=a-t.length();void 0===h&&u===i.Class.UNIVERSAL&&f===i.Type.BITSTRING&&(l=t.bytes(d));if(void 0===h&&s.decodeBitStrings&&u===i.Class.UNIVERSAL&&f===i.Type.BITSTRING&&d>1){var b=t.read,g=r,m=0;if(f===i.Type.BITSTRING&&(o(t,r,1),m=t.getByte(),r--),0===m)try{a=t.length();var v={verbose:s.verbose,strict:!0,decodeBitStrings:!0},w=e(t,r,n+1,v),_=a-t.length();r-=_,f==i.Type.BITSTRING&&_++;var S=w.tagClass;_!==d||S!==i.Class.UNIVERSAL&&S!==i.Class.CONTEXT_SPECIFIC||(h=[w])}catch(e){}void 0===h&&(t.read=b,r=g)}if(void 0===h){if(void 0===d){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");d=r}if(f===i.Type.BMPSTRING)for(h="";d>0;d-=2)o(t,r,2),h+=String.fromCharCode(t.getInt16()),r-=2;else h=t.getBytes(d)}var E=void 0===l?null:{bitStringContents:l};return i.create(u,f,y,h,E)}(e,e.length(),0,t)},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,o=n.util.createBuffer(),s=!1;if("bitStringContents"in e&&(s=!0,e.original&&(s=i.equals(e,e.original))),s)o.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:o.putByte(0);for(var a=0;a1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?o.putBytes(e.value.substr(1)):o.putBytes(e.value);if(t.putByte(r),o.length()<=127)t.putByte(127&o.length());else{var c=o.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(o),t},i.oidToDer=function(e){var t,r,i,o,s=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(e){var t;"string"==typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),o=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var f=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);f*=6e4,"+"===c?t.setTime(+t-f):t.setTime(+t+f)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,f=!1;"Z"===e.charAt(e.length-1)&&(f=!0);var h=e.length-5,l=e.charAt(h);"+"!==l&&"-"!==l||(u=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),u*=6e4,"+"===l&&(u*=-1),f=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),f?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(o,s,a,c)),t},i.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"==typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,o){var s=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)o&&(e.tagClass!==t.tagClass&&o.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&o.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(s=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;s&&c0&&(o+="\n");for(var a="",c=0;c1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var l=e.value.charCodeAt(0);1==l?o+=" (1 unused bit shown)":l>1&&(o+=" ("+l+" unused bits shown)")}}else e.type===i.Type.OCTETSTRING?(s.test(e.value)||(o+="("+e.value+") "),o+="0x"+n.util.bytesToHex(e.value)):e.type===i.Type.UTF8?o+=n.util.decodeUtf8(e.value):e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?o+=e.value:s.test(e.value)?o+="0x"+n.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}},function(e,t,r){var n=r(4);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},function(e,t,r){"use strict";(function(t){const n=r(264),i=r(40).format,o=r(7).EventEmitter;let s=!(t.type&&"renderer"===t.type||!t.version);const a={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",NONE:"NONE"};let c=a.DEBUG,u=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],d={useColors:!0,color:h.Default,showTimestamp:!0,useLocalTime:!1,showLevel:!0,filename:u,appendFile:!0};class p{constructor(e,t){this.category=e;let r={};Object.assign(r,d),Object.assign(r,t),this.options=r,this.debug=this.debug.bind(this),this.log=this.log.bind(this),this.info=this.info.bind(this),this.warn=this.warn.bind(this),this.error=this.error.bind(this)}debug(){this._shouldLog(a.DEBUG)&&this._write(a.DEBUG,i.apply(null,arguments))}log(){this._shouldLog(a.DEBUG)&&this.debug.apply(this,arguments)}info(){this._shouldLog(a.INFO)&&this._write(a.INFO,i.apply(null,arguments))}warn(){this._shouldLog(a.WARN)&&this._write(a.WARN,i.apply(null,arguments))}error(){this._shouldLog(a.ERROR)&&this._write(a.ERROR,i.apply(null,arguments))}_write(e,t){(this.options.filename||u)&&!this.fileWriter&&s&&(this.fileWriter=n.openSync(this.options.filename||u,this.options.appendFile?"a+":"w+"));let r=this._format(e,t),i=this._createLogMessage(e,t),o=this._createLogMessage(e,t,r.timestamp,r.level,r.category,r.text);this.fileWriter&&s&&n.writeSync(this.fileWriter,i+"\n",null,"utf-8"),s||!this.options.useColors?(console.log(o),f.emit("data",this.category,e,t)):e===a.ERROR?this.options.showTimestamp&&this.options.showLevel?console.error(o,r.timestamp,r.level,r.category,r.text):this.options.showTimestamp&&!this.options.showLevel?console.error(o,r.timestamp,r.category,r.text):!this.options.showTimestamp&&this.options.showLevel?console.error(o,r.level,r.category,r.text):console.error(o,r.category,r.text):this.options.showTimestamp&&this.options.showLevel?console.log(o,r.timestamp,r.level,r.category,r.text):this.options.showTimestamp&&!this.options.showLevel?console.log(o,r.timestamp,r.category,r.text):!this.options.showTimestamp&&this.options.showLevel?console.log(o,r.level,r.category,r.text):console.log(o,r.category,r.text)}_format(e,t){let r="",n="",i="",o=": ";if(this.options.useColors){const t=Object.keys(a).map(e=>a[e]).indexOf(e),c=this.options.color;s?(this.options.showTimestamp&&(r="[3"+h.Grey+"m"),this.options.showLevel&&(n="[3"+l[t]+";22m"),i="[3"+c+";1m",o=": "):(this.options.showTimestamp&&(r="color:"+h.Grey),this.options.showLevel&&(n="color:"+l[t]),i="color:"+c+"; font-weight: bold")}return{timestamp:r,level:n,category:i,text:o}}_createLogMessage(e,t,r,n,i,o){r=r||"",n=n||"",i=i||"",o=o||": ",!s&&this.options.useColors&&(this.options.showTimestamp&&(r="%c"),this.options.showLevel&&(n="%c"),i="%c",o=": %c");let c="";return this.options.showTimestamp&&!this.options.useLocalTime&&(c+=(new Date).toISOString()+" "),this.options.showTimestamp&&this.options.useLocalTime&&(c+=(new Date).toLocaleString()+" "),c=r+c,this.options.showLevel&&(c+=n+"["+e+"]"+(e===a.INFO||e===a.WARN?" ":"")+" "),c+=i+this.category,c+=o+t,c}_shouldLog(e){let r=void 0!==t&&void 0!==t.env&&void 0!==t.env.LOG?t.env.LOG.toUpperCase():null;r="undefined"!=typeof window&&window.LOG?window.LOG.toUpperCase():r;const n=r||c,i=Object.keys(a).map(e=>a[e]);return i.indexOf(e)>=i.indexOf(n)}}e.exports={Colors:h,LogLevels:a,setLogLevel:e=>{c=e},setLogfile:e=>{u=e},create:(e,t)=>new p(e,t),forceBrowserMode:e=>s=!e,events:f}}).call(this,r(2))},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(281),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(6))},function(e,t,r){"use strict";var n,i,o,s=[r(294),r(295),r(296),r(297),r(298)],a=-1,c=[],u=!1;function f(){n&&i&&(n=!1,i.length?c=i.concat(c):a=-1,c.length&&h())}function h(){if(!n){u=!1,n=!0;for(var e=c.length,t=setTimeout(f);e;){for(i=c,c=[];i&&++a1)for(var r=1;r2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,s,a;if("string"==typeof t&&(i="not ",t.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var c=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(o(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=u;var i=r(128),o=r(132);r(1)(u,i);for(var s=n(o.prototype),a=0;a2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,s,a;if("string"==typeof t&&(i="not ",t.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var c=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(o(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=u;var i=r(156),o=r(160);r(1)(u,i);for(var s=n(o.prototype),a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=i},function(e,t,r){"use strict";var n={};function i(e,t,r){r||(r=Error);var i=function(e){var r,n;function i(r,n,i){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,i))||this}return n=e,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=e,n[e]=i}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,s,a;if("string"==typeof t&&(i="not ",t.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var c=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(n," ").concat(o(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=u;var i=r(207),o=r(211);r(1)(u,i);for(var s=n(o.prototype),a=0;ae.identity.publicKey===t.publicKey};this.access=o.accessController||u,this._oplog=new a(this._ipfs,this.identity,{logId:this.id,access:this.access,sortFn:this.options.sortFn}),this._queue=new s({concurrency:1}),this._index=new this.options.Index(this.address.root),this._replicationStatus=new h,this._stats={snapshot:{bytesLoaded:-1},syncRequestsReceieved:0};try{const e=async e=>{this._recalculateReplicationMax(e.clock?e.clock.time:0),this.events.emit("replicate",this.address.toString(),e)},t=async e=>{const t=this.replicationStatus.progress,r=this.replicationStatus.max;this._recalculateReplicationStatus(e.clock.time),(this._oplog.length+1>this.replicationStatus.progress||this.replicationStatus.progress>t||this.replicationStatus.max>r)&&this.events.emit("replicate.progress",this.address.toString(),e.hash,e,this.replicationStatus.progress,this.replicationStatus.max)},r=async e=>{await this._queue.add((async()=>{try{if(this._oplog&&e.length>0){for(const t of e)await this._oplog.join(t);const t=this._oplog.heads;await this._cache.set(this.remoteHeadsPath,t),d.debug(`Saved heads ${t.length} [${t.map(e=>e.hash).join(", ")}]`),await this._updateIndex(),this._oplog.length>this.replicationStatus.progress&&this._recalculateReplicationStatus(this._oplog.length),this.events.emit("replicated",this.address.toString(),e.length,this)}}catch(e){console.error(e)}}).bind(this))};this._replicator=new f(this,this.options.replicationConcurrency),this._loader=this._replicator,this._replicator.onReplicationQueued=e,this._replicator.onReplicationProgress=t,this._replicator.onReplicationComplete=r}catch(e){console.error("Store Error:",e)}this.events.on("replicated.progress",(e,t,r,n,i)=>{this._procEntry(r)}),this.events.on("write",(e,t,r)=>{this._procEntry(t)})}get all(){return Array.isArray(this._index._index)?this._index._index:Object.keys(this._index._index).map(e=>this._index._index[e])}get index(){return this._index._index}get type(){return this._type}get key(){return this._key}get replicationStatus(){return this._replicationStatus}setIdentity(e){this.identity=e,this._oplog.setIdentity(e)}async close(){await this._replicator.stop(),await this._queue.onIdle(),this._replicationStatus.reset(),this._stats={snapshot:{bytesLoaded:-1},syncRequestsReceieved:0},this.options.onClose&&await this.options.onClose(this),this.access.close&&await this.access.close();for(const e in this.events._events)this.events.removeAllListeners(e);return this._oplog=null,this.events.emit("closed",this.address.toString()),Promise.resolve()}async drop(){this.options.onDrop&&await this.options.onDrop(this),await this._cache.del(this.localHeadsPath),await this._cache.del(this.remoteHeadsPath),await this._cache.del(this.snapshotPath),await this._cache.del(this.queuePath),await this._cache.del(this.manifestPath),await this.close(),this._index=new this.options.Index(this.address.root),this._oplog=new a(this._ipfs,this.identity,{logId:this.id,access:this.access,sortFn:this.options.sortFn}),this._cache=this.options.cache}async load(e,t={}){"object"==typeof e&&(t=e,e=void 0),e=e||this.options.maxHistory;const r=t.fetchEntryTimeout||this.options.fetchEntryTimeout;this.options.onLoad&&await this.options.onLoad(this);const n=await this._cache.get(this.localHeadsPath)||[],i=await this._cache.get(this.remoteHeadsPath)||[],o=n.concat(i);o.length>0&&this.events.emit("load",this.address.toString(),o),o.forEach(e=>this._recalculateReplicationMax(e.clock.time));const s=await a.fromEntryHash(this._ipfs,this.identity,o.map(e=>e.hash),{logId:this.id,access:this.access,sortFn:this.options.sortFn,length:e,onProgressCallback:this._onLoadProgress.bind(this),timeout:r,concurrency:this.options.replicationConcurrency});this._oplog=s,o.length>0&&await this._updateIndex(),this.events.emit("ready",this.address.toString(),this._oplog.heads)}async sync(e){if(this._stats.syncRequestsReceieved+=1,d.debug(`Sync request #${this._stats.syncRequestsReceieved} ${e.length}`),0===e.length)return;return o(e,async e=>{if(!e)return console.warn("Warning: Given input entry was 'null'."),Promise.resolve(null);const t=this.identity.provider;if(!t)throw new Error("Identity-provider is required, cannot verify entry");if(!await this.access.canAppend(e,t))return console.warn("Warning: Given input entry is not allowed in this log and was discarded (no write access)."),Promise.resolve(null);const r=c.toEntry(e);return await p.write(this._ipfs,c.getWriteFormat(r),r,{links:c.IPLD_LINKS,onlyHash:!0})!==e.hash&&console.warn("\"WARNING! Head hash didn't match the contents"),e}).then(async e=>this._replicator.load(e.filter(e=>null!==e)))}loadMoreFrom(e,t){this._replicator.load(t)}async saveSnapshot(){const e=this._replicator.unfinished,r=this._oplog.toSnapshot(),n=t.from(JSON.stringify({id:r.id,heads:r.heads,size:r.values.length,values:r.values,type:this.type})),i=await this._ipfs.add(n);return i.hash=i.cid.toString(),await this._cache.set(this.snapshotPath,i),await this._cache.set(this.queuePath,e),d.debug(`Saved snapshot: ${i.hash}, queue length: ${e.length}`),[i]}async loadFromSnapshot(e){this.options.onLoad&&await this.options.onLoad(this),this.events.emit("load",this.address.toString());const r=(e,t)=>Math.max(e,t.clock.time),n=await this._cache.get(this.queuePath);this.sync(n||[]);const i=await this._cache.get(this.snapshotPath);if(!i)throw new Error(`Snapshot for ${this.address} not found!`);{const e=[];for await(const t of this._ipfs.cat(i.hash))e.push(t);const n=t.concat(e),o=JSON.parse(n.toString());this._recalculateReplicationMax(o.values.reduce(r,0)),o&&(this._oplog=await a.fromJSON(this._ipfs,this.identity,o,{access:this.access,sortFn:this.options.sortFn,length:-1,timeout:1e3,onProgressCallback:this._onLoadProgress.bind(this)}),await this._updateIndex(),this.events.emit("replicated",this.address.toString())),this.events.emit("ready",this.address.toString(),this._oplog.heads)}return this}async _updateIndex(){await this._index.updateIndex(this._oplog)}async syncLocal(){const e=await this._cache.get(this.localHeadsPath)||[],t=await this._cache.get(this.remoteHeadsPath)||[],r=e.concat(t);for(let e=0;e{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},t.empty=n,t.equals=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const t=e.match(/../g);return t?new Uint8Array(t.map(e=>parseInt(e,16))):n},t.fromString=e=>(new TextEncoder).encode(e),t.isBinary=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),t.toHex=e=>e.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),t.toString=e=>(new TextDecoder).decode(e)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,i=new TextDecoder,o=new TextEncoder;function s(e){return n&&globalThis.Buffer.isBuffer(e)}function a(e){return e instanceof Uint8Array?s(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}const c=n?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):g(e,t,r):(e,t,r)=>r-t>64?i.decode(e.subarray(t,r)):g(e,t,r),u=n?e=>e.length>64?globalThis.Buffer.from(e):b(e):e=>e.length>64?o.encode(e):b(e),f=n?(e,t,r)=>s(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),h=n?(e,t)=>(e=e.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),a(globalThis.Buffer.concat(e,t))):(e,t)=>{const r=new Uint8Array(t);let n=0;for(let t of e)n+t.length>r.length&&(t=t.subarray(0,r.length-n)),r.set(t,n),n+=t.length;return r},l=n?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e),d=n?e=>"string"==typeof e?e:globalThis.Buffer.from(y(e)).toString("hex"):e=>"string"==typeof e?e:Array.prototype.reduce.call(y(e),(e,t)=>`${e}${t.toString(16).padStart(2,"0")}`,""),p=n?e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e,"hex"):e=>e instanceof Uint8Array?e:e.length?new Uint8Array(e.split("").map((e,t,r)=>t%2==0?`0x${e}${r[t+1]}`:"").filter(Boolean).map(e=>parseInt(e,16))):new Uint8Array(0);function y(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function b(e,t=1/0){let r;const n=e.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function g(e,t,r){const n=[];for(;t239?4:i>223?3:i>191?2:1;if(t+s<=r){let r,n,a,c;switch(s){case 1:i<128&&(o=i);break;case 2:r=e[t+1],128==(192&r)&&(c=(31&i)<<6|63&r,c>127&&(o=c));break;case 3:r=e[t+1],n=e[t+2],128==(192&r)&&128==(192&n)&&(c=(15&i)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[t+1],n=e[t+2],a=e[t+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&i)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),t+=s}return m(n)}function m(e){const t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nUint8Array.from(e),t.fromHex=p,t.fromString=u,t.slice=f,t.toHex=d,t.toString=c,t.useBuffer=n},function(e,t,r){(function(e){var n=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},n=0;n=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&t._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,e,n.depth)}function c(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function u(e,t){return e}function f(e,r,n){if(e.customInspect&&r&&E(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return g(i)||(i=f(e,i,n)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(g(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,r);if(o)return o;var s=Object.keys(r),a=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),S(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(E(r)){var c=r.name?": "+r.name:"";return e.stylize("[Function"+c+"]","special")}if(v(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return e.stylize(Date.prototype.toString.call(r),"date");if(S(r))return h(r)}var u,w="",k=!1,A=["{","}"];(d(r)&&(k=!0,A=["[","]"]),E(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(w=" "+RegExp.prototype.toString.call(r)),_(r)&&(w=" "+Date.prototype.toUTCString.call(r)),S(r)&&(w=" "+h(r)),0!==s.length||k&&0!=r.length?n<0?v(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),u=k?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),T(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=y(r)?f(e,c.value,null):f(e,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),m(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function y(e){return null===e}function b(e){return"number"==typeof e}function g(e){return"string"==typeof e}function m(e){return void 0===e}function v(e){return w(e)&&"[object RegExp]"===k(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===k(e)}function S(e){return w(e)&&("[object Error]"===k(e)||e instanceof Error)}function E(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(r){if(m(o)&&(o=e.env.NODE_DEBUG||""),r=r.toUpperCase(),!s[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=e.pid;s[r]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",r,n,e)}}else s[r]=function(){};return s[r]},t.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=p,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=b,t.isString=g,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=m,t.isRegExp=v,t.isObject=w,t.isDate=_,t.isError=S,t.isFunction=E,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(265);var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(){var e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":");return[e.getDate(),C[e.getMonth()],t].join(" ")}function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",I(),t.format.apply(t,arguments))},t.inherits=r(266),t._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var x="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function B(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(x&&e[x]){var t;if("function"!=typeof(t=e[x]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,x,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o=0||!o.gcd(t.n).equals(i.ONE));for(var s=(e=e.multiply(o.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);s.compareTo(a)<0;)s=s.add(t.p);var c=s.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(o.modInverse(t.n)).mod(t.n)};function b(e,t,r){var i=n.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=o-11,s}i.putByte(0),i.putByte(r);var a,c=o-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var f=0,h=n.random.getBytes(c);for(u=0;u1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function m(e,t,r){"function"==typeof t&&(r=t,t={});var o={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function s(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){n.prime.generateProbablePrime(e,o,t)}function u(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void s();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void s();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(o.prng=t.prng),s()}function v(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function w(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _(e){return n.util.isNodejs&&"function"==typeof o[e]}function S(e){return void 0!==a.globalScope&&"object"==typeof a.globalScope.crypto&&"object"==typeof a.globalScope.crypto.subtle&&"function"==typeof a.globalScope.crypto.subtle[e]}function E(e){return void 0!==a.globalScope&&"object"==typeof a.globalScope.msCrypto&&"object"==typeof a.globalScope.msCrypto.subtle&&"function"==typeof a.globalScope.msCrypto.subtle[e]}function k(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)f.putByte(0),--h;return f.putBytes(n.util.hexToBytes(u)),f.getBytes()},c.rsa.decrypt=function(e,t,r,o){var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=s,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,t,r).toString(16),f=n.util.createBuffer(),h=s-Math.ceil(u.length/2);h>0;)f.putByte(0),--h;return f.putBytes(n.util.hexToBytes(u)),!1!==o?g(f.getBytes(),t,r):f.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var o,s=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(o.eInt),o},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,s=function(e,t){return e|t},a=+new Date,f=0;null===e.keys&&(t<=0||fh?e.pqState=0:e.num.isProbablePrime(w(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[o++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var d=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,d,e.p,e.q,d.mod(e.p1),d.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}f+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,i){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(i=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(i=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,i=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(i=r,r=void 0):(i=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(i){if(_("generateKeyPair"))return o.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return i(e);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(S("generateKey")&&S("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:k(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){i(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(E("generateKey")&&E("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:k(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(u.onerror=function(e){i(e)})}}else if(_("generateKeyPairSync")){var f=o.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(f.privateKey),publicKey:c.publicKeyFromPem(f.publicKey)}}var h=c.rsa.createKeyPairGenerationState(e,t,r);if(!i)return c.rsa.stepKeyPairGenerationState(h,0),h.keys;m(h,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return b(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var o=t.encode(e,r,!0);return c.rsa.encrypt(o,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=g(t,r,!0),e===s.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===(t=g(t,r,!0))}});var i=c.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,o,s,a,u){var f={n:e,e:t,d:r,p:i,q:o,dP:s,dQ:a,qInv:u,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,f,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:g};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,f,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:p},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,f.n.bitLength());return c.rsa.encrypt(n,f,r)}};return f},c.wrapRsaPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,s.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,o,a,u,l,d,p,y={},b=[];if(s.validate(e,f,y,b)&&(e=s.fromDer(n.util.createBuffer(y.privateKey))),y={},b=[],!s.validate(e,h,y,b)){var g=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw g.errors=b,g}return t=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),o=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrime1).toHex(),u=n.util.createBuffer(y.privateKeyPrime2).toHex(),l=n.util.createBuffer(y.privateKeyExponent1).toHex(),d=n.util.createBuffer(y.privateKeyExponent2).toHex(),p=n.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(o,16),new i(a,16),new i(u,16),new i(l,16),new i(d,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.e)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.d)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.p)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.q)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.dP)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.dQ)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(s.validate(e,d,t,r)){var o,a=s.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(o=new Error("Cannot read public key. Unknown OID.")).oid=a,o;e=t.rsaPublicKey}if(r=[],!s.validate(e,l,t,r))throw(o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,o;var u=n.util.createBuffer(t.publicKeyModulus).toHex(),f=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(f,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,v(e.e))])}},function(e,t,r){"use strict";const n=r(1),i=r(90).Reporter,o=r(88).Buffer;function s(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function a(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return a.isEncoderBuffer(e)||(e=new a(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(s,i),t.DecoderBuffer=s,s.isDecoderBuffer=function(e){if(e instanceof s)return!0;return"object"==typeof e&&o.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},s.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},s.prototype.restore=function(e){const t=new s(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},s.prototype.isEmpty=function(){return this.offset===this.length},s.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},s.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new s(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},s.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.EncoderBuffer=a,a.isEncoderBuffer=function(e){if(e instanceof a)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},a.prototype.join=function(e,t){return e||(e=o.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},function(e,t,r){"use strict";var n=r(13),i=r(17);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>24]^f[p>>>16&255]^h[y>>>8&255]^l[255&b]^t[g++],s=u[p>>>24]^f[y>>>16&255]^h[b>>>8&255]^l[255&d]^t[g++],a=u[y>>>24]^f[b>>>16&255]^h[d>>>8&255]^l[255&p]^t[g++],c=u[b>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&y]^t[g++],d=o,p=s,y=a,b=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[y>>>8&255]<<8|n[255&b])^t[g++],s=(n[p>>>24]<<24|n[y>>>16&255]<<16|n[b>>>8&255]<<8|n[255&d])^t[g++],a=(n[y>>>24]<<24|n[b>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[g++],c=(n[b>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&y])^t[g++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],c=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,r[s]=u,n[u]=s;var f=e[s],h=e[f],l=e[h],d=257*e[u]^16843008*u;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][u]=d<<24|d>>>8,o[1][u]=d<<16|d>>>16,o[2][u]=d<<8|d>>>24,o[3][u]=d,0===s?s=a=1:(s=f^e[e[e[l^f]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(e){this._key=i(e),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s],s^=a[o/t|0]<<24):t>6&&o%t==4&&(s=c.SBOX[s>>>24]<<24|c.SBOX[s>>>16&255]<<16|c.SBOX[s>>>8&255]<<8|c.SBOX[255&s]),i[o]=i[o-t]^s}for(var u=[],f=0;f>>24]]^c.INV_SUB_MIX[1][c.SBOX[l>>>16&255]]^c.INV_SUB_MIX[2][c.SBOX[l>>>8&255]]^c.INV_SUB_MIX[3][c.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=u},u.prototype.encryptBlockRaw=function(e){return s(e=i(e),this._keySchedule,c.SUB_MIX,c.SBOX,this._nRounds)},u.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=n.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},u.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=s(e,this._invKeySchedule,c.INV_SUB_MIX,c.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o},u.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},e.exports.AES=u},function(e,t,r){var n=r(4);if(r(79),r(23),r(165),r(24),r(32),r(81),r(82),r(33),r(372),r(44),r(5),void 0===i)var i=n.jsbn.BigInteger;var o=n.asn1,s=n.pki=n.pki||{};e.exports=s.pbe=n.pbe=n.pbe||{};var a=s.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function l(e){var t;if(e){if(!(t=s.oids[o.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return d(t)}function d(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}s.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,u,f=n.random.getBytesSync(r.saltSize),h=r.count,l=o.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,y,b;switch(r.algorithm){case"aes128":i=16,p=16,y=a["aes128-CBC"],b=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,y=a["aes192-CBC"],b=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,y=a["aes256-CBC"],b=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,y=a.desCBC,b=n.des.createEncryptionCipher;break;default:throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S}var g="hmacWith"+r.prfAlgorithm.toUpperCase(),m=d(g),v=n.pkcs5.pbkdf2(t,f,h,i,m),w=n.random.getBytesSync(p);(E=b(v)).start(w),E.update(o.toDer(e)),E.finish(),u=E.output.getBytes();var _=function(e,t,r,i){var a=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.oids[i]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]));return a}(f,l,i,g);c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBKDF2).getBytes()),_]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(y).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,w)])])])}else{var S;if("3des"!==r.algorithm)throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S;i=24;var E,k=new n.util.ByteBuffer(f);v=s.pbe.generatePkcs12Key(t,k,1,h,i),w=s.pbe.generatePkcs12Key(t,k,2,h,i);(E=n.des.createEncryptionCipher(v)).start(w),E.update(o.toDer(e)),E.finish(),u=E.output.getBytes(),c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,f),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,l.getBytes())])])}return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[c,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)])},s.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!o.validate(e,c,i,a)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=a,u}var f=o.derToOid(i.encryptionOid),h=s.pbe.getCipher(f,i.encryptionParams,t),l=n.util.createBuffer(i.encryptedData);return h.update(l),h.finish()&&(r=o.fromDer(h.output)),r},s.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},s.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return o.fromDer(t.body)},s.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=s.wrapRsaPrivateKey(s.privateKeyToAsn1(e));return i=s.encryptPrivateKeyInfo(i,t,r),s.encryptedPrivateKeyToPem(i)}var a,c,u,f;switch(r.algorithm){case"aes128":a="AES-128-CBC",u=16,c=n.random.getBytesSync(16),f=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",u=24,c=n.random.getBytesSync(16),f=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",u=32,c=n.random.getBytesSync(16),f=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",u=24,c=n.random.getBytesSync(8),f=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",u=8,c=n.random.getBytesSync(8),f=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var l=f(n.pbe.opensslDeriveBytes(t,c.substr(0,8),u));l.start(c),l.update(o.toDer(s.privateKeyToAsn1(e))),l.finish();var d={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:l.output.getBytes()};return n.pem.encode(d)},s.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var f=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,f.substr(0,8),a));if(h.start(f),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?s.decryptPrivateKeyInfo(o.fromDer(r),t):o.fromDer(r))&&(r=s.privateKeyFromAsn1(r)),r},s.pbe.generatePkcs12Key=function(e,t,r,i,o,s){var a,c;if(null==s){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');s=n.md.sha1.create()}var u=s.digestLength,f=s.blockLength,h=new n.util.ByteBuffer,l=new n.util.ByteBuffer;if(null!=e){for(c=0;c=0;c--)x>>=8,x+=A.at(c)+T.at(c),T.setAt(c,255&x);I.putBuffer(T)}w=I,h.putBuffer(E)}return h.truncate(h.length()-o),h},s.pbe.getCipher=function(e,t,r){switch(e){case s.oids.pkcs5PBES2:return s.pbe.getCipherForPBES2(e,t,r);case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case s.oids["pbewithSHAAnd40BitRC2-CBC"]:return s.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},s.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!o.validate(t,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=o.derToOid(a.kdfOid))!==s.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=o.derToOid(a.encOid))!==s.oids["aes128-CBC"]&&e!==s.oids["aes192-CBC"]&&e!==s.oids["aes256-CBC"]&&e!==s.oids["des-EDE3-CBC"]&&e!==s.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var f,h,d=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),s.oids[e]){case"aes128-CBC":f=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":f=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":f=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":f=24,h=n.des.createDecryptionCipher;break;case"desCBC":f=8,h=n.des.createDecryptionCipher}var y=l(a.prfOid),b=n.pkcs5.pbkdf2(r,d,p,f,y),g=a.encIv,m=h(b);return m.start(g),m},s.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!o.validate(t,f,i,a))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,y;var c,u,h,d=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,h=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,y}var b=l(i.prfOid),g=s.pbe.generatePkcs12Key(r,d,1,p,c,b);return b.start(),h(g,s.pbe.generatePkcs12Key(r,d,2,p,u,b))},s.pbe.opensslDeriveBytes=function(e,t,r,i){if(null==i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var o=[h(i,e+t)],s=16,a=1;s>>2,t.words[2]=(63&e[22])<<20|e[23]<<12|e[24]<<4|e[25]>>>4,t.words[3]=(255&e[19])<<18|e[20]<<10|e[21]<<2|e[22]>>>6,t.words[4]=(3&e[15])<<24|e[16]<<16|e[17]<<8|e[18],t.words[5]=(15&e[12])<<22|e[13]<<14|e[14]<<6|e[15]>>>2,t.words[6]=(63&e[9])<<20|e[10]<<12|e[11]<<4|e[12]>>>4,t.words[7]=(255&e[6])<<18|e[7]<<10|e[8]<<2|e[9]>>>6,t.words[8]=(3&e[2])<<24|e[3]<<16|e[4]<<8|e[5],t.words[9]=e[0]<<14|e[1]<<6|e[2]>>>2,t.length=10,t.strip()},o.prototype.toBuffer=function(){for(var e=this.words,t=this.length;t<10;++t)e[t]=0;return n.from([e[9]>>>14&255,e[9]>>>6&255,(63&e[9])<<2|e[8]>>>24&3,e[8]>>>16&255,e[8]>>>8&255,255&e[8],e[7]>>>18&255,e[7]>>>10&255,e[7]>>>2&255,(3&e[7])<<6|e[6]>>>20&63,e[6]>>>12&255,e[6]>>>4&255,(15&e[6])<<4|e[5]>>>22&15,e[5]>>>14&255,e[5]>>>6&255,(63&e[5])<<2|e[4]>>>24&3,e[4]>>>16&255,e[4]>>>8&255,255&e[4],e[3]>>>18&255,e[3]>>>10&255,e[3]>>>2&255,(3&e[3])<<6|e[2]>>>20&63,e[2]>>>12&255,e[2]>>>4&255,(15&e[2])<<4|e[1]>>>22&15,e[1]>>>14&255,e[1]>>>6&255,(63&e[1])<<2|e[0]>>>24&3,e[0]>>>16&255,e[0]>>>8&255,255&e[0]])},o.prototype.clone=function(){var e=new o;e.words=new Array(this.length);for(var t=0;t1&&0==(0|this.words[this.length-1]);)this.length--;return this},o.prototype.normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.ucmp=function(e){if(this.length!==e.length)return this.length>e.length?1:-1;for(var t=this.length-1;t>=0;--t)if(this.words[t]!==e.words[t])return this.words[t]>e.words[t]?1:-1;return 0},o.prototype.gtOne=function(){return this.length>1||this.words[0]>1},o.prototype.isOverflow=function(){return this.ucmp(o.n)>=0},o.prototype.isHigh=function(){return 1===this.ucmp(o.nh)},o.prototype.bitLengthGT256=function(){return this.length>10||10===this.length&&this.words[9]>4194303},o.prototype.iuaddn=function(e){this.words[0]+=e;for(var t=0;this.words[t]>67108863&&te.length?(t=this,r=e):(t=e,r=this);for(var n=0,i=0;n>>26}for(;0!==i&&n>>26;if(this.length=t.length,0!==i)this.words[this.length++]=i;else if(t!==this)for(;n0?(t=this,r=e):(t=e,r=this);for(var i=0,o=0;i>26,this.words[i]=67108863&s}for(;0!==o&&i>26,this.words[i]=67108863&s;if(0===o&&i>>26,c=67108863&i,u=Math.max(0,o-e.length+1),f=Math.min(o,t.length-1);u<=f;u++){var h=o-u,l=e.words[h]*t.words[u]+c;a+=l/67108864|0,c=67108863&l}r.words[o]=c,i=a}return 0!==i&&(r.words[r.length++]=i),r.strip()},o.umulTo10x10=Math.imul?i.umulTo10x10:o.umulTo,o.umulnTo=function(e,t,r){if(0===t)return r.words=[0],r.length=1,r;for(var n=0,i=0;n0?(r.words[n]=i,r.length=e.length+1):r.length=e.length,r},o.prototype.umul=function(e){var t=new o;return t.words=new Array(this.length+e.length),10===this.length&&10===e.length?o.umulTo10x10(this,e,t):1===this.length?o.umulnTo(e,this.words[0],t):1===e.length?o.umulnTo(this,e.words[0],t):o.umulTo(this,e,t)},o.prototype.isplit=function(e){e.length=Math.min(this.length,9);for(var t=0;t>>22,r=n}return r>>>=22,this.words[t-10]=r,0===r&&this.length>10?this.length-=10:this.length-=9,this},o.prototype.fireduce=function(){return this.isOverflow()&&this.isub(o.n),this},o.prototype.ureduce=function(){var e=this.clone().isplit(o.tmp).umul(o.nc).iadd(o.tmp);return e.bitLengthGT256()&&(e=e.isplit(o.tmp).umul(o.nc).iadd(o.tmp)).bitLengthGT256()&&(e=e.isplit(o.tmp).umul(o.nc).iadd(o.tmp)),e.fireduce()},o.prototype.ishrn=function(e){for(var t=(1<=0;--n){var o=this.words[n];this.words[n]=i<>>e,i=o&t}return this.length>1&&0===this.words[this.length-1]&&(this.length-=1),this},o.prototype.uinvm=function(){for(var e=this.clone(),t=o.n.clone(),r=o.fromNumber(1),n=o.fromNumber(0),i=o.fromNumber(0),s=o.fromNumber(1);e.isEven()&&t.isEven();){for(var a=1,c=1;0==(e.words[0]&c)&&0==(t.words[0]&c)&&a<26;++a,c<<=1);e.ishrn(a),t.ishrn(a)}for(var u=t.clone(),f=e.clone();!e.isZero();){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.ishrn(h);h-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(u),n.isub(f)),r.ishrn(1),n.ishrn(1);for(var d=0,p=1;0==(t.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(t.ishrn(d);d-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(u),s.isub(f)),i.ishrn(1),s.ishrn(1);e.ucmp(t)>=0?(e.isub(t),r.isub(i),n.isub(s)):(t.isub(e),i.isub(r),s.isub(n))}if(1===i.negative){i.negative=0;var y=i.ureduce();return y.negative^=1,y.normSign().iadd(o.n)}return i.ureduce()},o.prototype.imulK=function(){this.words[this.length]=0,this.words[this.length+1]=0,this.length+=2;for(var e=0,t=0;e0?this.isub(o.p):this.strip(),this},o.prototype.redNeg=function(){return this.isZero()?o.fromNumber(0):o.p.sub(this)},o.prototype.redAdd=function(e){return this.clone().redIAdd(e)},o.prototype.redIAdd=function(e){return this.iadd(e),this.ucmp(o.p)>=0&&this.isub(o.p),this},o.prototype.redIAdd7=function(){return this.iuaddn(7),this.ucmp(o.p)>=0&&this.isub(o.p),this},o.prototype.redSub=function(e){return this.clone().redISub(e)},o.prototype.redISub=function(e){return this.isub(e),0!==this.negative&&this.iadd(o.p),this},o.prototype.redMul=function(e){return this.umul(e).redIReduce()},o.prototype.redSqr=function(){return this.umul(this).redIReduce()},o.prototype.redSqrt=function(){if(this.isZero())return this.clone();for(var e=this.redSqr(),t=e.redSqr(),r=t.redSqr().redMul(t),n=r.redMul(e),i=n.redMul(this),o=i,s=0;s<54;++s)o=o.redSqr().redSqr().redSqr().redSqr().redMul(i);for(o=o.redSqr().redSqr().redSqr().redSqr().redMul(n),s=0;s<5;++s)o=o.redSqr().redSqr().redSqr().redSqr().redMul(i);return 0===(o=(o=o.redSqr().redSqr().redSqr().redSqr().redMul(r)).redSqr().redSqr().redSqr().redSqr().redSqr().redSqr().redMul(r)).redSqr().ucmp(this)?o:null},o.prototype.redInvm=function(){for(var e,t=this.clone(),r=o.p.clone(),n=o.fromNumber(1),i=o.fromNumber(0);t.gtOne()&&r.gtOne();){for(var s=0,a=1;0==(t.words[0]&a)&&s<26;++s,a<<=1);if(s>0)for(t.ishrn(s);s-- >0;)n.isOdd()&&n.iadd(o.p),n.ishrn(1);for(var c=0,u=1;0==(r.words[0]&u)&&c<26;++c,u<<=1);if(c>0)for(r.ishrn(c);c-- >0;)i.isOdd()&&i.iadd(o.p),i.ishrn(1);t.ucmp(r)>=0?(t.isub(r),n.isub(i)):(r.isub(t),i.isub(n))}return 0!==(e=1===t.length&&1===t.words[0]?n:i).negative&&e.iadd(o.p),0!==e.negative?(e.negative=0,e.redIReduce().redNeg()):e.redIReduce()},o.prototype.getNAF=function(e){for(var t=[],r=1<>1,o=this.clone();!o.isZero();){for(var s=0,a=1;0==(o.words[0]&a)&&s<26;++s,a<<=1)t.push(0);if(0!==s)o.ishrn(s);else{var c=o.words[0]&n;if(c>=i)t.push(i-c),o.iuaddn(c-i).ishrn(1);else if(t.push(c),o.words[0]-=c,!o.isZero()){for(s=e-1;s>0;--s)t.push(0);o.ishrn(e)}}}return t},o.prototype.inspect=function(){if(this.isZero())return"0";for(var e=this.toBuffer().toString("hex"),t=0;"0"===e[t];++t);return e.slice(t)},o.n=o.fromBuffer(n.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","hex")),o.nh=o.n.clone().ishrn(1),o.nc=o.fromBuffer(n.from("000000000000000000000000000000014551231950B75FC4402DA1732FC9BEBF","hex")),o.p=o.fromBuffer(n.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","hex")),o.psn=o.p.sub(o.n),o.tmp=new o,o.tmp.words=new Array(10),o.fromNumber(1).words[3]=0,e.exports=o},function(e,t,r){"use strict";var n=r(11),i=r(10),o=i.getNAF,s=i.getJSF,a=i.assert;function c(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1,this._bitLength),i=(1<=s;f--)c=(c<<1)+n[f];u.push(c)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;u--){for(var f=0;u>=0&&0===s[u];u--)f++;if(u>=0&&f++,c=c.dblp(f),u<0)break;var h=s[u];a(0!==h),c="affine"===e.type?h>0?c.mixedAdd(i[h-1>>1]):c.mixedAdd(i[-h-1>>1].neg()):h>0?c.add(i[h-1>>1]):c.add(i[-h-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,n,i){var a,c,u,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var y=a-1,b=a;if(1===f[y]&&1===f[b]){var g=[t[y],null,null,t[b]];0===t[y].y.cmp(t[b].y)?(g[1]=t[y].add(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg())):0===t[y].y.cmp(t[b].y.redNeg())?(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].add(t[b].neg())):(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[y],r[b]);for(d=Math.max(v[0].length,d),l[y]=new Array(d),l[b]=new Array(d),c=0;c=0;a--){for(var k=0;a>=0;){var A=!0;for(c=0;c=0&&k++,S=S.dblp(k),a<0)break;for(c=0;c0?u=h[c][C-1>>1]:C<0&&(u=h[c][-C-1>>1].neg()),S="affine"===u.type?S.mixedAdd(u):S.add(u))}}for(a=0;a=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;inew Error("Ipfs instance not defined"),c=["next","refs"],u=e=>0===e?"dag-pb":"dag-cbor",f=e=>h.isEntry(e)?u(e.v):u(e);class h{static async create(e,t,r,o,s=[],c,u=[],f){if(!i(e))throw a();if(!i(t))throw new Error("Identity is required, cannot create entry");if(!i(r))throw new Error("Entry requires an id");if(!i(o))throw new Error("Entry requires data");if(!i(s)||!Array.isArray(s))throw new Error("'next' argument is not an array");const l={hash:null,id:r,payload:o,next:s.filter(i).map(e=>e.hash?e.hash:e),refs:u,v:2,clock:c||new n(t.publicKey)},d=await t.provider.sign(t,h.toBuffer(l));return l.key=t.publicKey,l.identity=t.toJSON(),l.sig=d,l.hash=await h.toMultihash(e,l,f),l}static async verify(e,t){if(!e)throw new Error("Identity-provider is required, cannot verify entry");if(!h.isEntry(t))throw new Error("Invalid Log entry");if(!t.key)throw new Error("Entry doesn't have a key");if(!t.sig)throw new Error("Entry doesn't have a signature");const r=h.toEntry(t,{presigned:!0}),n=t.v<1?"v0":"v1";return e.verify(t.sig,t.key,h.toBuffer(r),n)}static toBuffer(e){const r=0===e.v?JSON.stringify(e):s(e);return t.from(r)}static async toMultihash(e,t,r=!1){if(!e)throw a();if(!h.isEntry(t))throw new Error("Invalid object format, cannot generate entry hash");const n=h.toEntry(t);return o.write(e,f(n.v),n,{links:c,pin:r})}static toEntry(e,{presigned:t=!1,includeHash:r=!1}={}){const i={hash:r?e.hash:null,id:e.id,payload:e.payload,next:e.next},o=e.v;return o>1&&(i.refs=e.refs),i.v=e.v,i.clock=new n(e.clock.id,e.clock.time),t||(i.key=e.key,o>0&&(i.identity=e.identity),i.sig=e.sig),i}static async fromMultihash(e,t){if(!e)throw a();if(!t)throw new Error("Invalid hash: "+t);const r=await o.read(e,t,{links:c}),n=h.toEntry(r);return n.hash=t,n}static isEntry(e){return e&&void 0!==e.id&&void 0!==e.next&&void 0!==e.payload&&void 0!==e.v&&void 0!==e.hash&&void 0!==e.clock&&(void 0!==e.refs||e.v<2)}static compare(e,t){const r=n.compare(e.clock,t.clock);return 0===r?e.clock.id-1}static findChildren(e,t){let r=[],n=t.find(t=>h.isParent(e,t)),i=e;for(;n;)r.push(n),i=n,n=t.find(e=>h.isParent(i,e));return r=r.sort((e,t)=>e.clock.time>t.clock.time),r}}e.exports=h,e.exports.IPLD_LINKS=c,e.exports.getWriteFormat=f}).call(this,r(0).Buffer)},function(e,t,r){"use strict";class n{constructor(e,t){this.id=e,this.time=t||0}tick(){return new n(this.id,++this.time)}merge(e){return this.time=Math.max(this.time,e.time),new n(this.id,this.time)}clone(){return new n(this.id,this.time)}static compare(e,t){const r=e.time-t.time;return 0===r&&e.id!==t.id?e.id[n.decode(e),n.decode.bytes],t.encodeTo=(e,t,r=0)=>(n.encode(e,t,r),t),t.encodingLength=e=>n.encodingLength(e)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(38),i=r(60);class o{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}t.Digest=o,t.create=(e,t)=>{const r=t.byteLength,n=i.encodingLength(e),s=n+i.encodingLength(r),a=new Uint8Array(s+r);return i.encodeTo(e,a,0),i.encodeTo(r,a,n),a.set(t,s),new o(e,r,t,a)},t.decode=e=>{const t=n.coerce(e),[r,s]=i.decode(t),[a,c]=i.decode(t.subarray(s)),u=t.subarray(s+c);if(u.byteLength!==a)throw new Error("Incorrect length");return new o(r,a,u,t)},t.equals=(e,t)=>e===t||e.code===t.code&&e.size===t.size&&n.equals(e.bytes,t.bytes)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(12),o=r(14),s=r(39);function a(e,t,r,o){i.assertEnoughData(e,t,r+o);const a=s.slice(e,t+r,t+r+o);return new n.Token(n.Type.bytes,a,r+o)}function c(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===n.Type.string?s.fromString(e.value):e.value),e.encodedBytes}function u(e,t){const r=c(t);o.encodeUintValue(e,t.type.majorEncoded,r.length),e.push(r)}function f(e,t){return e.lengtht.length?1:s.compare(e,t)}u.encodedSize=function(e){const t=c(e);return o.encodeUintValue.encodedSize(t.length)+t.length},u.compareTokens=function(e,t){return f(c(e),c(t))},t.compareBytes=f,t.decodeBytes16=function(e,t,r,n){return a(e,t,3,o.readUint16(e,t+1,n))},t.decodeBytes32=function(e,t,r,n){return a(e,t,5,o.readUint32(e,t+1,n))},t.decodeBytes64=function(e,t,r,n){const s=o.readUint64(e,t+1,n);if("bigint"==typeof s)throw new Error(i.decodeErrPrefix+" 64-bit integer bytes lengths not supported");return a(e,t,9,s)},t.decodeBytes8=function(e,t,r,n){return a(e,t,2,o.readUint8(e,t+1,n))},t.decodeBytesCompact=function(e,t,r,n){return a(e,t,1,r)},t.encodeBytes=u},function(e,t,r){"use strict";(function(t,n,i){var o=r(48);function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=m;var a,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:o.nextTick;m.WritableState=g;var u=Object.create(r(41));u.inherits=r(1);var f={deprecate:r(49)},h=r(119),l=r(3).Buffer,d=i.Uint8Array||function(){};var p,y=r(120);function b(){}function g(e,t){a=a||r(21),e=e||{};var n=t instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(k,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),k(e,t))}(e,r,n,t,i);else{var s=S(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||_(e,r),n?c(w,e,r,s,i):w(e,r,s,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function m(e){if(a=a||r(21),!(p.call(m,this)||this instanceof a))return new m(e);this._writableState=new g(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function w(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),k(e,t)}function _(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,v(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(v(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),k(e,t)}))}function k(e,t){var r=S(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(m,h),g.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(g.prototype,"buffer",{get:f.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===m&&(e&&e._writableState instanceof g)}})):p=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=e,l.isBuffer(n)||n instanceof d);return a&&!l.isBuffer(e)&&(e=function(e){return l.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=l.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,k(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=y.destroy,m.prototype._undestroy=y.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(2),r(26).setImmediate,r(6))},function(module,exports,__webpack_require__){"use strict";const fs="object"==typeof window||"object"==typeof self?null:eval('require("fs")'),level=__webpack_require__(289),crypto=__webpack_require__(146),secp256k1=__webpack_require__(464),LRU=__webpack_require__(200),Buffer=__webpack_require__(201).Buffer,{verifier:verifier}=__webpack_require__(486);function createStore(e="./keystore"){return fs&&fs.mkdirSync&&fs.mkdirSync(e,{recursive:!0}),level(e)}const verifiedCache=new LRU(1e3);class Keystore{constructor(e={}){"string"==typeof e?this._store=createStore(e):"function"==typeof e.open?this._store=e:"string"==typeof e.store?this._store=createStore(e.store):this._store=e.store||createStore(),this._cache=e.cache||new LRU(100)}async open(){return this._store?(await this._store.open(),Promise.resolve()):Promise.reject(new Error("Keystore: No store found to open"))}async close(){this._store&&await this._store.close()}async hasKey(e){if(!e)throw new Error("id needed to check a key");if(this._store.status&&"open"!==this._store.status)return Promise.resolve(null);let t=!1;try{let r=this._cache.get(e)||await this._store.get(e);t=null!=r}catch(e){console.error("Error: ENOENT: no such file or directory")}return t}async createKey(e){if(!e)throw new Error("id needed to create a key");if(this._store.status&&"open"!==this._store.status)return Promise.resolve(null);const t=await new Promise((e,t)=>{crypto.keys.generateKeyPair("secp256k1",256,(r,n)=>{r||e(n),t(r)})}),r={publicKey:Buffer.from(secp256k1.publicKeyConvert(t.public.marshal(),!1)).toString("hex"),privateKey:t.marshal().toString("hex")};try{await this._store.put(e,JSON.stringify(r))}catch(e){console.log(e)}return this._cache.set(e,r),t}async getKey(e){if(!e)throw new Error("id needed to get a key");if(this._store||await this.open(),this._store.status&&"open"!==this._store.status)return Promise.resolve(null);const t=this._cache.get(e);let r;try{r=t||await this._store.get(e)}catch(e){}if(!r)return;const n=t||JSON.parse(r);if(!n)return;t||this._cache.set(e,n);return i=Buffer.from(n.privateKey,"hex"),new Promise((e,t)=>{crypto.keys.supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(i,(r,n)=>{r||e(n),t(r)})});var i}async sign(e,t){if(!e)throw new Error("No signing key given");if(!t)throw new Error("Given input data was undefined");return Buffer.isBuffer(t)||(t=Buffer.from(t)),new Promise((r,n)=>{e.sign(t,(e,t)=>{e||r(t.toString("hex")),n(e)})})}getPublic(e,t={}){const r=void 0===t.decompress||t.decompress,n=t.format||"hex";if(-1===["hex","buffer"].indexOf(n))throw new Error("Supported formats are `hex` and `buffer`");let i=e.public.marshal();return r&&(i=Buffer.from(secp256k1.publicKeyConvert(i,!1))),"buffer"===n?i:i.toString("hex")}async verify(e,t,r,n="v1"){return Keystore.verify(e,t,r,n)}static async verify(e,t,r,n="v1"){const i=verifiedCache.get(e);let o=!1;if(i){const e=(e,t,r)=>{let n;return n="v0"===r?0===Buffer.compare(Buffer.alloc(30,e),Buffer.alloc(30,t)):Buffer.isBuffer(t)?0===Buffer.compare(e,t):e===t,n};o=i.publicKey===t&&e(i.data,r,n)}else{const i=await verifier(n).verify(e,t,r);o=i,i&&verifiedCache.set(e,{publicKey:t,data:r})}return o}}module.exports=Keystore},function(e,t,r){"use strict";var n=r(9),i=r(125);e.exports=function(){var e=n.apply(null,arguments);return i(e,{bufferKeys:e.bufferKeys||!1,snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,openCallback:e.openCallback||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:e.encodings||!1,additionalMethods:n(e.additionalMethods)})}},function(e,t,r){e.exports=r(27)},function(e,t,r){"use strict";var n=r(28).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=self.crypto||self.msCrypto},function(e,t,r){"use strict";var n=r(1),i=r(155),o=r(3).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(e,t){return e<>>32-t}function u(e,t,r,n,i,o,s){return c(e+(t&r|~t&n)+i+o|0,s)+t|0}function f(e,t,r,n,i,o,s){return c(e+(t&n|r&~n)+i+o|0,s)+t|0}function h(e,t,r,n,i,o,s){return c(e+(t^r^n)+i+o|0,s)+t|0}function l(e,t,r,n,i,o,s){return c(e+(r^(t|~n))+i+o|0,s)+t|0}n(a,i),a.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d;r=u(r,n,i,o,e[0],3614090360,7),o=u(o,r,n,i,e[1],3905402710,12),i=u(i,o,r,n,e[2],606105819,17),n=u(n,i,o,r,e[3],3250441966,22),r=u(r,n,i,o,e[4],4118548399,7),o=u(o,r,n,i,e[5],1200080426,12),i=u(i,o,r,n,e[6],2821735955,17),n=u(n,i,o,r,e[7],4249261313,22),r=u(r,n,i,o,e[8],1770035416,7),o=u(o,r,n,i,e[9],2336552879,12),i=u(i,o,r,n,e[10],4294925233,17),n=u(n,i,o,r,e[11],2304563134,22),r=u(r,n,i,o,e[12],1804603682,7),o=u(o,r,n,i,e[13],4254626195,12),i=u(i,o,r,n,e[14],2792965006,17),r=f(r,n=u(n,i,o,r,e[15],1236535329,22),i,o,e[1],4129170786,5),o=f(o,r,n,i,e[6],3225465664,9),i=f(i,o,r,n,e[11],643717713,14),n=f(n,i,o,r,e[0],3921069994,20),r=f(r,n,i,o,e[5],3593408605,5),o=f(o,r,n,i,e[10],38016083,9),i=f(i,o,r,n,e[15],3634488961,14),n=f(n,i,o,r,e[4],3889429448,20),r=f(r,n,i,o,e[9],568446438,5),o=f(o,r,n,i,e[14],3275163606,9),i=f(i,o,r,n,e[3],4107603335,14),n=f(n,i,o,r,e[8],1163531501,20),r=f(r,n,i,o,e[13],2850285829,5),o=f(o,r,n,i,e[2],4243563512,9),i=f(i,o,r,n,e[7],1735328473,14),r=h(r,n=f(n,i,o,r,e[12],2368359562,20),i,o,e[5],4294588738,4),o=h(o,r,n,i,e[8],2272392833,11),i=h(i,o,r,n,e[11],1839030562,16),n=h(n,i,o,r,e[14],4259657740,23),r=h(r,n,i,o,e[1],2763975236,4),o=h(o,r,n,i,e[4],1272893353,11),i=h(i,o,r,n,e[7],4139469664,16),n=h(n,i,o,r,e[10],3200236656,23),r=h(r,n,i,o,e[13],681279174,4),o=h(o,r,n,i,e[0],3936430074,11),i=h(i,o,r,n,e[3],3572445317,16),n=h(n,i,o,r,e[6],76029189,23),r=h(r,n,i,o,e[9],3654602809,4),o=h(o,r,n,i,e[12],3873151461,11),i=h(i,o,r,n,e[15],530742520,16),r=l(r,n=h(n,i,o,r,e[2],3299628645,23),i,o,e[0],4096336452,6),o=l(o,r,n,i,e[7],1126891415,10),i=l(i,o,r,n,e[14],2878612391,15),n=l(n,i,o,r,e[5],4237533241,21),r=l(r,n,i,o,e[12],1700485571,6),o=l(o,r,n,i,e[3],2399980690,10),i=l(i,o,r,n,e[10],4293915773,15),n=l(n,i,o,r,e[1],2240044497,21),r=l(r,n,i,o,e[8],1873313359,6),o=l(o,r,n,i,e[15],4264355552,10),i=l(i,o,r,n,e[6],2734768916,15),n=l(n,i,o,r,e[13],1309151649,21),r=l(r,n,i,o,e[4],4149444226,6),o=l(o,r,n,i,e[11],3174756917,10),i=l(i,o,r,n,e[2],718787259,15),n=l(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},function(e,t,r){"use strict";var n=r(30).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i>14;--o>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,f=a*c+u*s;i=((c=s*c+((16383&f)<<14)+r.data[n]+i)>>28)+(f>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=o,"undefined"==typeof navigator?(o.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,f=a*c+u*s;i=((c=s*c+((32767&f)<<15)+r.data[n]+(1073741823&i))>>>30)+(f>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},n=26):(o.prototype.am=a,n=28),o.prototype.DB=n,o.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function y(e){this.m=e}function b(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function E(){}function k(e){return e}function A(e){this.r2=s(),this.q3=s(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}y.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},y.prototype.revert=function(e){return e},y.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},b.prototype.convert=function(e){var t=s();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},b.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},b.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},b.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var a=8==r?255&e[n]:l(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this.data[this.t++]=a:s+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-s):this.data[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+s+1]=this.data[r]>>i|a,a=(this.data[r]&o)<=0;--r)t.data[r]=0;t.data[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},o.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(f,a),i.lShiftTo(f,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,l=a.data[h-1];if(0!=l){var d=l*(1<1?a.data[h-2]>>this.F2:0),y=this.FV/d,b=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),o.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t=0;){var _=r.data[--m]==l?this.DM:Math.floor(r.data[m]*y+(r.data[m-1]+g)*b);if((r.data[m]+=a.am(0,_,r,v,0,h))<_)for(a.dlShiftTo(v,w),r.subTo(w,r);r.data[m]<--_;)r.subTo(w,r)}null!=t&&(r.drShiftTo(h,t),c!=u&&o.ZERO.subTo(t,t)),r.t=h,r.clamp(),f>0&&r.rShiftTo(f,r),c<0&&o.ZERO.subTo(r,r)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var r=s(),n=s(),i=t.convert(this),a=p(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=h(r));s>=0;)a>(a+=this.DB-t)):(r=this.data[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=h(r));return i?o:"0"},o.prototype.negate=function(){var e=s();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=s();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new y(t):new b(t),this.exp(e,r)},o.ZERO=d(0),o.ONE=d(1),E.prototype.convert=k,E.prototype.revert=k,E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},E.prototype.sqrTo=function(e,t){e.squareTo(t)},A.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=s();return e.copyTo(t),this.reduce(t),t},A.prototype.revert=function(e){return e},A.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},A.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var C=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],I=(1<<26)/C[C.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=d(r),i=s(),o=s(),a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,s=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),i&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},o.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},o.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),s={nextBytes:function(e){for(var t=0;t=0);var c=n.modPow(i,this);if(0!=c.compareTo(o.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this.data[e]&(1<>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=s();return this.bitwiseTo(e,g,t),t},o.prototype.or=function(e){var t=s();return this.bitwiseTo(e,m,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,v,t),t},o.prototype.andNot=function(e){var t=s();return this.bitwiseTo(e,w,t),t},o.prototype.not=function(){for(var e=s(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var h=s();for(n.sqrTo(a[1],h);c<=f;)a[c]=s(),n.mulTo(h,a[c-2],a[c]),c+=2}var l,g,m=e.t-1,v=!0,w=s();for(i=p(e.data[m])-1;m>=0;){for(i>=u?l=e.data[m]>>i-u&f:(l=(e.data[m]&(1<0&&(l|=e.data[m-1]>>this.DB+i-u)),c=r;0==(1&l);)l>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),v)a[l].copyTo(o),v=!1;else{for(;c>1;)n.sqrTo(o,w),n.sqrTo(w,o),c-=2;c>0?n.sqrTo(o,w):(g=o,o=w,w=g),n.mulTo(w,a[l],o)}for(;m>=0&&0==(e.data[m]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),s.subTo(c,s)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(s,c))}return 0!=n.compareTo(o.ONE)?o.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},o.prototype.pow=function(e){return this.exp(e,new E)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},o.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=C[C.length-1]){for(t=0;t>>=2;for(i=0;i>8^255&h^99,o[y]=h,s[h]=y,d=(l=e[h])<<24^h<<16^h<<8^h^l,p=((r=e[y])^(n=e[r])^(i=e[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var g=0;g<4;++g)c[g][y]=d,u[g][h]=p,d=d<<24|d>>>8,p=p<<24|p>>>8;0===y?y=b=1:(y=r^e[e[e[r^i]]],b^=e[e[b]])}}function l(e,t){for(var r,n=e.slice(0),i=1,s=n.length,c=4*(s+6+1),f=s;f>>16&255]<<24^o[r>>>8&255]<<16^o[255&r]<<8^o[r>>>24]^a[i]<<24,i++):s>6&&f%s==4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[255&r]),n[f]=n[f-s]^r;if(t){for(var h,l=u[0],d=u[1],p=u[2],y=u[3],b=n.slice(0),g=(f=0,(c=n.length)-4);f>>24]]^d[o[h>>>16&255]]^p[o[h>>>8&255]]^y[o[255&h]];n=b}return n}function d(e,t,r,n){var i,a,f,h,l,d,p,y,b,g,m,v,w=e.length/4-1;n?(i=u[0],a=u[1],f=u[2],h=u[3],l=s):(i=c[0],a=c[1],f=c[2],h=c[3],l=o),d=t[0]^e[0],p=t[n?3:1]^e[1],y=t[2]^e[2],b=t[n?1:3]^e[3];for(var _=3,S=1;S>>24]^a[p>>>16&255]^f[y>>>8&255]^h[255&b]^e[++_],m=i[p>>>24]^a[y>>>16&255]^f[b>>>8&255]^h[255&d]^e[++_],v=i[y>>>24]^a[b>>>16&255]^f[d>>>8&255]^h[255&p]^e[++_],b=i[b>>>24]^a[d>>>16&255]^f[p>>>8&255]^h[255&y]^e[++_],d=g,p=m,y=v;r[0]=l[d>>>24]<<24^l[p>>>16&255]<<16^l[y>>>8&255]<<8^l[255&b]^e[++_],r[n?3:1]=l[p>>>24]<<24^l[y>>>16&255]<<16^l[b>>>8&255]<<8^l[255&d]^e[++_],r[2]=l[y>>>24]<<24^l[b>>>16&255]<<16^l[d>>>8&255]<<8^l[255&p]^e[++_],r[n?1:3]=l[b>>>24]<<24^l[d>>>16&255]<<16^l[p>>>8&255]<<8^l[255&y]^e[++_]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},function(e,t){},function(e,t,r){(function(t){var n=r(4);r(166),r(24),r(5);var i,o=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(i=r(80)),e.exports=n.pbkdf2=o.pbkdf2=function(e,r,o,s,a,c){if("function"==typeof a&&(c=a,a=null),n.util.isNodejs&&!n.options.usePureJavaScript&&i.pbkdf2&&(null===a||"object"!=typeof a)&&(i.pbkdf2Sync.length>4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),e=t.from(e,"binary"),r=t.from(r,"binary"),c?4===i.pbkdf2Sync.length?i.pbkdf2(e,r,o,s,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):i.pbkdf2(e,r,o,s,a,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(e,r,o,s).toString("binary"):i.pbkdf2Sync(e,r,o,s,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in n.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=n.md[a].create()}var u=a.digestLength;if(s>4294967295*u){var f=new Error("Derived key is too long.");if(c)return c(f);throw f}var h=Math.ceil(s/u),l=s-(h-1)*u,d=n.hmac.create();d.start(a,e);var p,y,b,g="";if(!c){for(var m=1;m<=h;++m){d.start(null,null),d.update(r),d.update(n.util.int32ToBytes(m)),p=b=d.digest().getBytes();for(var v=2;v<=o;++v)d.start(null,null),d.update(b),y=d.digest().getBytes(),p=n.util.xorBytes(p,y,u),b=y;g+=mh)return c(null,g);d.start(null,null),d.update(r),d.update(n.util.int32ToBytes(m)),p=b=d.digest().getBytes(),v=2,_()}function _(){if(v<=o)return d.start(null,null),d.update(b),y=d.digest().getBytes(),p=n.util.xorBytes(p,y,u),b=y,++v,n.util.setImmediate(_);g+=m65&&-1!==s){var a=t[s];","===a?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),o=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function s(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=o(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=o(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=o(r)),e.headers)for(var s=0;s=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);e[r];){var h=t[e.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}for(var p=s-o;p!==s&&0===f[p];)p++;var y=n.allocUnsafe(i+(s-p));y.fill(0,0,i);for(var b=i;p!==s;)y[b++]=f[p++];return y}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,s=t.length;o!==s&&0===t[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=t[o],d=0,p=u-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var y=u-i;y!==u&&0===h[y];)y++;for(var b=c.repeat(r);y=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=o(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!s.kStringMaxLength)try{s.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(e){}s.constants||(s.constants={MAX_LENGTH:s.kMaxLength},s.kStringMaxLength&&(s.constants.MAX_STRING_LENGTH=s.kStringMaxLength)),e.exports=s}).call(this,r(2))},function(e,t,r){"use strict";const n=r(90).Reporter,i=r(45).EncoderBuffer,o=r(45).DecoderBuffer,s=r(17),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],c=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function u(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}e.exports=u;const f=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){const e=this._baseState,t={};f.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},u.prototype._wrap=function(){const e=this._baseState;c.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},u.prototype._init=function(e){const t=this._baseState;s(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),s.equal(t.children.length,1,"Root node can have only one child")},u.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(s(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(s(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){u.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),a.forEach((function(e){u.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===t.tag),t.tag=e,this._useArgs(r),this}})),u.prototype.use=function(e){s(e);const t=this._baseState;return s(null===t.use),t.use=e,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(e){const t=this._baseState;return s(null===t.default),t.default=e,t.optional=!0,this},u.prototype.explicit=function(e){const t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.explicit=e,this},u.prototype.implicit=function(e){const t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.implicit=e,this},u.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},u.prototype.key=function(e){const t=this._baseState;return s(null===t.key),t.key=e,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(e){const t=this._baseState;return s(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},u.prototype.contains=function(e){const t=this._baseState;return s(null===t.use),t.contains=e,this},u.prototype._decode=function(e,t){const r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));let n,i=r.default,s=!0,a=null;if(null!==r.key&&(a=e.enterKey(r.key)),r.optional){let n=null;if(null!==r.explicit?n=r.explicit:null!==r.implicit?n=r.implicit:null!==r.tag&&(n=r.tag),null!==n||r.any){if(s=this._peekTag(e,n,r.any),e.isError(s))return s}else{const n=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(n)}}if(r.obj&&s&&(n=e.enterObject()),s){if(null!==r.explicit){const t=this._decodeTag(e,r.explicit);if(e.isError(t))return t;e=t}const n=e.offset;if(null===r.use&&null===r.choice){let t;r.any&&(t=e.save());const n=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(n))return n;r.any?i=e.raw(t):e=n}if(t&&t.track&&null!==r.tag&&t.track(e.path(),n,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(i=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){const n=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(n,t)}}return r.obj&&s&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,r.key,i),i},u.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},u.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},u.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,i=!1;return Object.keys(r.choice).some((function(o){const s=e.save(),a=r.choice[o];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:o,value:r},i=!0}catch(t){return e.restore(s),!1}return!0}),this),i?n:e.error("Choice not matched")},u.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},u.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const i=this._encodeValue(e,t,r);return void 0===i||this._skipDefault(i,t,r)?void 0:i},u.prototype._encodeValue=function(e,t,r){const i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);let o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}let s=null,a=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)s=this._getUse(i.contains,r)._encode(e,t),a=!0;else if(i.children)s=i.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");const n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const r=this.clone();r._baseState.implicit=null,s=this._createEncoderBuffer(e.map((function(r){const n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),r))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(s=this._encodePrimitive(i.tag,e),a=!0);if(!i.any&&null===i.choice){const e=null!==i.implicit?i.implicit:i.tag,r=null===i.implicit?"universal":"context";null===e?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(e,a,r,s))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},u.prototype._encodeChoice=function(e,t){const r=this._baseState,n=r.choice[e.type];return n||s(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},u.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},u.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},u.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}},function(e,t,r){"use strict";const n=r(1);function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},function(e,t,r){"use strict";function n(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=n(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=n(t.tag)},function(e,t,r){"use strict";var n,i=t,o=r(93),s=r(196),a=r(10).assert;function c(e){"short"===e.type?this.curve=new s.short(e):"edwards"===e.type?this.curve=new s.edwards(e):this.curve=new s.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(478)}catch(e){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(e,t,r){var n=t;n.utils=r(13),n.common=r(46),n.sha=r(472),n.ripemd=r(476),n.hmac=r(477),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(e,t,r){"use strict";var n=r(9),i=r(125);e.exports=function(){var e=n.apply(null,arguments);return i(e,{bufferKeys:e.bufferKeys||!1,snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,openCallback:e.openCallback||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:e.encodings||!1,additionalMethods:n(e.additionalMethods)})}},function(e,t,r){e.exports=r(27)},function(e,t,r){"use strict";var n=r(35).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i{},a=new i.TimeoutError;t.default=class extends n{constructor(e){var t,r,n,i;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=s,this._resolveIdle=s,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:o.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(n=e.interval)||void 0===n?void 0:n.toString())&&void 0!==i?i:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()},t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={}){return new Promise((r,n)=>{this._queue.enqueue(async()=>{this._pendingCount++,this._intervalCount++;try{const o=void 0===this._timeout&&void 0===t.timeout?e():i.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&n(a)});r(await o)}catch(e){n(e)}this._next()},t),this._tryToStartAnother(),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise(e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}})}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise(e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},function(e,t,r){"use strict";(function(t){const n=r(103),i=r(234),o=r(57),s=r(256),a=r(115),c=r(58),u=r(114),{LastWriteWins:f,NoZeroes:h}=u,l=r(259),{isDefined:d,findUniques:p}=r(59),y=r(260),b=e=>e.hash,g=(e,t)=>e.concat(t),m=e=>e.next,v=(e,t)=>Math.max(e,t.clock.time),w=(e,t)=>(e[t.hash]=t,e);class _ extends i{constructor(e,t,{logId:r,access:n,entries:i,heads:o,clock:s,sortFn:u,concurrency:p}={}){if(!d(e))throw a.IPFSNotDefinedError();if(!d(t))throw new Error("Identity is required");if(d(n)||(n=new l),d(i)&&!Array.isArray(i))throw new Error("'entries' argument must be an array of Entry instances");if(d(o)&&!Array.isArray(o))throw new Error("'heads' argument must be an array");d(u)||(u=f),super(),this._sortFn=h(u),this._storage=e,this._id=r||(new Date).getTime().toString(),this._access=n,this._identity=t;const b=(i||[]).reduce(w,{});this._entryIndex=new y(b),i=Object.values(b)||[],o=o||_.findHeads(i),this._headsIndex=o.reduce(w,{}),this._nextsIndex={};i.forEach(e=>e.next.forEach(t=>this._nextsIndex[t]=e.hash)),this._length=i.length;const g=Math.max(s?s.time:0,this.heads.reduce(v,0));this._clock=new c(this._identity.publicKey,g),this.joinConcurrency=p||16}get id(){return this._id}get clock(){return this._clock}get length(){return this._length}get values(){return Object.values(this.traverse(this.heads)).reverse()}get heads(){return Object.values(this._headsIndex).sort(this._sortFn).reverse()}get tails(){return _.findTails(this.values)}get tailHashes(){return _.findTailHashes(this.values)}setIdentity(e){this._identity=e;const t=Math.max(this.clock.time,this.heads.reduce(v,0));this._clock=new c(this._identity.publicKey,t)}get(e){return this._entryIndex.get(e)}has(e){return void 0!==this._entryIndex.get(e.hash||e)}traverse(e,t=-1,r){let n=e.sort(this._sortFn).reverse(),i={};const o={};let s=0;const a=e=>this.get(e),c=e=>{e&&!i[e.hash]&&(n=[e,...n].sort(this._sortFn).reverse(),i[e.hash]=!0)};for(;n.length>0&&(s{const t=new Set;for(let r=1;r<=e;r*=2){const e=Math.min(r-1,i.length-1);t.add(i[e])}return t})(Math.min(t,i.length));i.length!a.includes(e)),f=await o.create(this._storage,this._identity,this.id,e,a,this.clock,u,r);if(!await this._access.canAppend(f,this._identity.provider))throw new Error(`Could not append entry, key "${this._identity.id}" is not allowed to write to the log`);return this._entryIndex.set(f.hash,f),a.forEach(e=>this._nextsIndex[e]=f.hash),this._headsIndex={},this._headsIndex[f.hash]=f,this._length++,f}iterator({gt:e,gte:t,lt:r,lte:n,amount:i=-1}={}){if(0===i)return function*(){}();if("string"==typeof n&&(n=[this.get(n)]),"string"==typeof r&&(r=[this.get(this.get(r).next[0])]),n&&!Array.isArray(n))throw a.LtOrLteMustBeStringOrArray();if(r&&!Array.isArray(r))throw a.LtOrLteMustBeStringOrArray();const o=(n||r||this.heads).filter(d),s=t?this.get(t).hash:e?this.get(e).hash:null,c=s?-1:i||-1,u=this.traverse(o,c,s);let f=Object.values(u);return e&&f.pop(),(e||t)&&i>-1&&(f=f.slice(f.length-i,f.length)),function*(){for(const e in f)yield f[e]}()}async join(e,t=-1){if(!d(e))throw a.LogNotDefinedError();if(!_.isLog(e))throw a.NotALogError();if(this.id!==e.id)return;const r=_.difference(e,this),i=this._identity.provider,s=async e=>{if(!await this._access.canAppend(e,i))throw new Error(`Could not append entry, key "${e.identity.id}" is not allowed to write to the log`)},u=Object.values(r);await n(u,async e=>{await s(e),await(async e=>{const t=await o.verify(i,e),r=e.identity?e.identity.publicKey:e.key;if(!t)throw new Error(`Could not validate signature "${e.sig}" for entry "${e.hash}" and key "${r}"`)})(e)},{concurrency:this.joinConcurrency});Object.values(r).forEach(e=>{this.get(e.hash)||this._length++,e.next.forEach(t=>this._nextsIndex[t]=e.hash)}),this._entryIndex.add(r);const f=Object.values(r).map(m).reduce(g,[]),h=_.findHeads(Object.values(Object.assign({},this._headsIndex,e._headsIndex))).filter(e=>!f.find(t=>t===e.hash)).filter(e=>!this._nextsIndex[e.hash]).reduce(w,{});if(this._headsIndex=h,t>-1){let e=this.values;e=e.slice(-t),this._entryIndex=null,this._entryIndex=new y(e.reduce(w,{})),this._headsIndex=_.findHeads(e).reduce(w,{}),this._length=this._entryIndex.length}const l=Object.values(this._headsIndex).reduce(v,0);return this._clock=new c(this.clock.id,Math.max(this.clock.time,l)),this}toJSON(){return{id:this.id,heads:this.heads.sort(this._sortFn).reverse().map(b)}}toSnapshot(){return{id:this.id,heads:this.heads,values:this.values}}toBuffer(){return t.from(JSON.stringify(this.toJSON()))}toString(e){return this.values.slice().reverse().map((t,r)=>{const n=o.findChildren(t,this.values).length;let i=new Array(Math.max(n-1,0));return i=n>1?i.fill(" "):i,i=n>0?i.concat(["└─"]):i,i.join("")+(e?e(t.payload):t.payload)}).join("\n")}static isLog(e){return void 0!==e.id&&void 0!==e.heads&&void 0!==e._entryIndex}toMultihash({format:e}={}){return s.toMultihash(this._storage,this,{format:e})}static async fromMultihash(e,t,r,{access:n,length:i=-1,exclude:o=[],shouldExclude:a,timeout:c,concurrency:u,sortFn:f,onProgressCallback:h}={}){const{logId:l,entries:d,heads:p}=await s.fromMultihash(e,r,{length:i,exclude:o,shouldExclude:a,timeout:c,onProgressCallback:h,concurrency:u,sortFn:f});return new _(e,t,{logId:l,access:n,entries:d,heads:p,sortFn:f})}static async fromEntryHash(e,t,r,{logId:n,access:i,length:o=-1,exclude:a=[],shouldExclude:c,timeout:u,concurrency:f,sortFn:h,onProgressCallback:l}={}){const{entries:d}=await s.fromEntryHash(e,r,{length:o,exclude:a,shouldExclude:c,timeout:u,concurrency:f,onProgressCallback:l});return new _(e,t,{logId:n,access:i,entries:d,sortFn:h})}static async fromJSON(e,t,r,{access:n,length:i=-1,timeout:o,sortFn:a,onProgressCallback:c}={}){const{logId:u,entries:f}=await s.fromJSON(e,r,{length:i,timeout:o,onProgressCallback:c});return new _(e,t,{logId:u,access:n,entries:f,sortFn:a})}static async fromEntry(e,t,r,{access:n,length:i=-1,exclude:o=[],timeout:a,concurrency:c,sortFn:u,onProgressCallback:f}={}){const{logId:h,entries:l}=await s.fromEntry(e,r,{length:i,exclude:o,timeout:a,concurrency:c,onProgressCallback:f});return new _(e,t,{logId:h,access:n,entries:l,sortFn:u})}static findHeads(e){const t=e.reduce((e,t,r,n)=>(t.next.forEach(r=>e[r]=t.hash),e),{});return e.filter(e=>void 0===t[e.hash]).sort((e,t)=>e.clock.id>t.clock.id)}static findTails(e){const t={},r=[],n={};let i=[];e.forEach(e=>{0===e.next.length&&r.push(e);e.next.forEach(r=>{t[r]||(t[r]=[]),t[r].push(e)}),i=i.concat(e.next),n[e.hash]=!0});const s=i.filter(e=>void 0===n[e]).map(e=>t[e]).reduce((e,t,r,n)=>e.concat(p(t,"hash")),[]).concat(r);return p(s,"hash").sort(o.compare)}static findTailHashes(e){const t={};return e.forEach(e=>t[e.hash]=!0),e.reduce((e,r,n,i)=>(r.next.reverse().forEach(r=>{void 0===t[r]&&e.splice(0,0,r)}),e),[])}static difference(e,t){const r=Object.keys(e._headsIndex),n={},i={},o=e=>{n[e]||t.get(e)||(r.push(e),n[e]=!0)};for(;r.length>0;){const s=r.shift(),a=e.get(s);a&&!t.get(s)&&a.id===t.id&&(i[a.hash]=a,n[a.hash]=!0,a.next.concat(a.refs).forEach(o))}return i}}e.exports=_,e.exports.Sorting=u,e.exports.Entry=o,e.exports.AccessController=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(230);e.exports=async(e,t,{concurrency:r=1/0,stopOnError:i=!0}={})=>new Promise((o,s)=>{if("function"!=typeof t)throw new TypeError("Mapper function is required");if(!Number.isSafeInteger(r)&&r!==1/0||!(r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);const a=[],c=[],u=e[Symbol.iterator]();let f=!1,h=!1,l=0,d=0;const p=()=>{if(f)return;const e=u.next(),r=d;if(d++,e.done)return h=!0,void(0===l&&(i||0===c.length?o(a):s(new n(c))));l++,(async()=>{try{const n=await e.value;a[r]=await t(n,r),l--,p()}catch(e){i?(f=!0,s(e)):(c.push(e),l--,p())}})()};for(let e=0;enew a({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class u{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new o(e,t,r),this.decoder=new s(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const f=({name:e,prefix:t,encode:r,decode:n})=>new u(e,t,r,n);t.Codec=u,t.baseX=({prefix:e,name:t,alphabet:r})=>{const{encode:o,decode:s}=n(r,t);return f({prefix:e,name:t,encode:o,decode:e=>i.coerce(s(e))})},t.from=f,t.or=c,t.rfc4648=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>f({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<r;)s-=r,o+=t[i&a>>s];if(s&&(o+=t[i&a<((e,t,r,n)=>{const i={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(61);class i{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?n.create(this.code,t):t.then(e=>n.create(this.code,e))}throw Error("Unknown type, must be binary type")}}t.Hasher=i,t.from=({name:e,code:t,encode:r})=>new i(e,t,r)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(14),o=r(108),s=r(62),a=r(109),c=r(110),u=r(111),f=r(112),h=r(113),l=r(12),d=r(39);function p(e,t,r){throw new Error(`${l.decodeErrPrefix} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function y(e){return()=>{throw new Error(`${l.decodeErrPrefix} ${e}`)}}const b=[];for(let e=0;e<=23;e++)b[e]=p;b[24]=i.decodeUint8,b[25]=i.decodeUint16,b[26]=i.decodeUint32,b[27]=i.decodeUint64,b[28]=p,b[29]=p,b[30]=p,b[31]=p;for(let e=32;e<=55;e++)b[e]=p;b[56]=o.decodeNegint8,b[57]=o.decodeNegint16,b[58]=o.decodeNegint32,b[59]=o.decodeNegint64,b[60]=p,b[61]=p,b[62]=p,b[63]=p;for(let e=64;e<=87;e++)b[e]=s.decodeBytesCompact;b[88]=s.decodeBytes8,b[89]=s.decodeBytes16,b[90]=s.decodeBytes32,b[91]=s.decodeBytes64,b[92]=p,b[93]=p,b[94]=p,b[95]=y("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)b[e]=a.decodeStringCompact;b[120]=a.decodeString8,b[121]=a.decodeString16,b[122]=a.decodeString32,b[123]=a.decodeString64,b[124]=p,b[125]=p,b[126]=p,b[127]=y("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)b[e]=c.decodeArrayCompact;b[152]=c.decodeArray8,b[153]=c.decodeArray16,b[154]=c.decodeArray32,b[155]=c.decodeArray64,b[156]=p,b[157]=p,b[158]=p,b[159]=c.decodeArrayIndefinite;for(let e=160;e<=183;e++)b[e]=u.decodeMapCompact;b[184]=u.decodeMap8,b[185]=u.decodeMap16,b[186]=u.decodeMap32,b[187]=u.decodeMap64,b[188]=p,b[189]=p,b[190]=p,b[191]=u.decodeMapIndefinite;for(let e=192;e<=215;e++)b[e]=f.decodeTagCompact;b[216]=f.decodeTag8,b[217]=f.decodeTag16,b[218]=f.decodeTag32,b[219]=f.decodeTag64,b[220]=p,b[221]=p,b[222]=p,b[223]=p;for(let e=224;e<=243;e++)b[e]=y("simple values are not supported");b[244]=p,b[245]=p,b[246]=p,b[247]=h.decodeUndefined,b[248]=y("simple values are not supported"),b[249]=h.decodeFloat16,b[250]=h.decodeFloat32,b[251]=h.decodeFloat64,b[252]=p,b[253]=p,b[254]=p,b[255]=h.decodeBreak;const g=[];for(let e=0;e<24;e++)g[e]=new n.Token(n.Type.uint,e,1);for(let e=-1;e>=-24;e--)g[31-e]=new n.Token(n.Type.negint,e,1);g[64]=new n.Token(n.Type.bytes,new Uint8Array(0),1),g[96]=new n.Token(n.Type.string,"",1),g[128]=new n.Token(n.Type.array,0,1),g[160]=new n.Token(n.Type.map,0,1),g[244]=new n.Token(n.Type.false,!1,1),g[245]=new n.Token(n.Type.true,!0,1),g[246]=new n.Token(n.Type.null,null,1),t.jump=b,t.quick=g,t.quickEncodeToken=function(e){switch(e.type){case n.Type.false:return d.fromArray([244]);case n.Type.true:return d.fromArray([245]);case n.Type.null:return d.fromArray([246]);case n.Type.bytes:return e.value.length?void 0:d.fromArray([64]);case n.Type.string:return""===e.value?d.fromArray([96]):void 0;case n.Type.array:return 0===e.value?d.fromArray([128]):void 0;case n.Type.map:return 0===e.value?d.fromArray([160]):void 0;case n.Type.uint:return e.value<24?d.fromArray([Number(e.value)]):void 0;case n.Type.negint:if(e.value>=-24)return d.fromArray([31-Number(e.value)])}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(14),o=r(12);const s=BigInt(-1),a=BigInt(1);function c(e,t){const r=t.value,n="bigint"==typeof r?r*s-a:-1*r-1;i.encodeUintValue(e,t.type.majorEncoded,n)}c.encodedSize=function(e){const t=e.value,r="bigint"==typeof t?t*s-a:-1*t-1;return rt.value?-1:0},t.decodeNegint16=function(e,t,r,o){return new n.Token(n.Type.negint,-1-i.readUint16(e,t+1,o),3)},t.decodeNegint32=function(e,t,r,o){return new n.Token(n.Type.negint,-1-i.readUint32(e,t+1,o),5)},t.decodeNegint64=function(e,t,r,a){const c=i.readUint64(e,t+1,a);if("bigint"!=typeof c){const e=-1-c;if(e>=Number.MIN_SAFE_INTEGER)return new n.Token(n.Type.negint,e,9)}if(!0!==a.allowBigInt)throw new Error(o.decodeErrPrefix+" integers outside of the safe integer range are not supported");return new n.Token(n.Type.negint,s-BigInt(c),9)},t.decodeNegint8=function(e,t,r,o){return new n.Token(n.Type.negint,-1-i.readUint8(e,t+1,o),2)},t.encodeNegint=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(12),o=r(14),s=r(62),a=r(39);function c(e,t,r,o){const s=r+o;return i.assertEnoughData(e,t,s),new n.Token(n.Type.string,a.toString(e,t+r,t+s),s)}const u=s.encodeBytes;t.decodeString16=function(e,t,r,n){return c(e,t,3,o.readUint16(e,t+1,n))},t.decodeString32=function(e,t,r,n){return c(e,t,5,o.readUint32(e,t+1,n))},t.decodeString64=function(e,t,r,n){const s=o.readUint64(e,t+1,n);if("bigint"==typeof s)throw new Error(i.decodeErrPrefix+" 64-bit integer string lengths not supported");return c(e,t,9,s)},t.decodeString8=function(e,t,r,n){return c(e,t,2,o.readUint8(e,t+1,n))},t.decodeStringCompact=function(e,t,r,n){return c(e,t,1,r)},t.encodeString=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(14),o=r(12);function s(e,t,r,i){return new n.Token(n.Type.array,i,r)}function a(e,t){i.encodeUintValue(e,n.Type.array.majorEncoded,t.value)}a.compareTokens=i.encodeUint.compareTokens,t.decodeArray16=function(e,t,r,n){return s(0,0,3,i.readUint16(e,t+1,n))},t.decodeArray32=function(e,t,r,n){return s(0,0,5,i.readUint32(e,t+1,n))},t.decodeArray64=function(e,t,r,n){const a=i.readUint64(e,t+1,n);if("bigint"==typeof a)throw new Error(o.decodeErrPrefix+" 64-bit integer array lengths not supported");return s(0,0,9,a)},t.decodeArray8=function(e,t,r,n){return s(0,0,2,i.readUint8(e,t+1,n))},t.decodeArrayCompact=function(e,t,r,n){return s(0,0,1,r)},t.decodeArrayIndefinite=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(o.decodeErrPrefix+" indefinite length items not allowed");return s(0,0,1,1/0)},t.encodeArray=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(14),o=r(12);function s(e,t,r,i){return new n.Token(n.Type.map,i,r)}function a(e,t){i.encodeUintValue(e,n.Type.map.majorEncoded,t.value)}a.compareTokens=i.encodeUint.compareTokens,t.decodeMap16=function(e,t,r,n){return s(0,0,3,i.readUint16(e,t+1,n))},t.decodeMap32=function(e,t,r,n){return s(0,0,5,i.readUint32(e,t+1,n))},t.decodeMap64=function(e,t,r,n){const a=i.readUint64(e,t+1,n);if("bigint"==typeof a)throw new Error(o.decodeErrPrefix+" 64-bit integer map lengths not supported");return s(0,0,9,a)},t.decodeMap8=function(e,t,r,n){return s(0,0,2,i.readUint8(e,t+1,n))},t.decodeMapCompact=function(e,t,r,n){return s(0,0,1,r)},t.decodeMapIndefinite=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(o.decodeErrPrefix+" indefinite length items not allowed");return s(0,0,1,1/0)},t.encodeMap=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(14);function o(e,t){i.encodeUintValue(e,n.Type.tag.majorEncoded,t.value)}o.compareTokens=i.encodeUint.compareTokens,t.decodeTag16=function(e,t,r,o){return new n.Token(n.Type.tag,i.readUint16(e,t+1,o),3)},t.decodeTag32=function(e,t,r,o){return new n.Token(n.Type.tag,i.readUint32(e,t+1,o),5)},t.decodeTag64=function(e,t,r,o){return new n.Token(n.Type.tag,i.readUint64(e,t+1,o),9)},t.decodeTag8=function(e,t,r,o){return new n.Token(n.Type.tag,i.readUint8(e,t+1,o),2)},t.decodeTagCompact=function(e,t,r,i){return new n.Token(n.Type.tag,r,1)},t.encodeTag=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8),i=r(12),o=r(14);function s(e,t,r){if(r){if(!1===r.allowNaN&&Number.isNaN(e))throw new Error(i.decodeErrPrefix+" NaN values are not supported");if(!1===r.allowInfinity&&(e===1/0||e===-1/0))throw new Error(i.decodeErrPrefix+" Infinity values are not supported")}return new n.Token(n.Type.float,e,t)}function a(e,t,r){const i=t.value;if(!1===i)e.push([20|n.Type.float.majorEncoded]);else if(!0===i)e.push([21|n.Type.float.majorEncoded]);else if(null===i)e.push([22|n.Type.float.majorEncoded]);else if(void 0===i)e.push([23|n.Type.float.majorEncoded]);else{let t,n=!1;r&&!0===r.float64||(h(i),t=l(f,1),i===t||Number.isNaN(i)?(f[0]=249,e.push(f.slice(0,3)),n=!0):(d(i),t=p(f,1),i===t&&(f[0]=250,e.push(f.slice(0,5)),n=!0))),n||(o=i,u.setFloat64(0,o,!1),t=y(f,1),f[0]=251,e.push(f.slice(0,9)))}var o}a.encodedSize=function(e,t){const r=e.value;if(!1===r||!0===r||null==r)return 1;let n;if(!t||!0!==t.float64){if(h(r),n=l(f,1),r===n||Number.isNaN(r))return 3;if(d(r),n=p(f,1),r===n)return 5}return 9};const c=new ArrayBuffer(9),u=new DataView(c,1),f=new Uint8Array(c,0);function h(e){if(e===1/0)u.setUint16(0,31744,!1);else if(e===-1/0)u.setUint16(0,64512,!1);else if(Number.isNaN(e))u.setUint16(0,32256,!1);else{u.setFloat32(0,e);const t=u.getUint32(0),r=(2139095040&t)>>23,n=8388607&t;if(255===r)u.setUint16(0,31744,!1);else if(0===r)u.setUint16(0,(2147483648&e)>>16|n>>13,!1);else{const e=r-127;e<-24?u.setUint16(0,0):e<-14?u.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):u.setUint16(0,(2147483648&t)>>16|e+15<<10|n>>13,!1)}}}function l(e,t){if(e.length-t<2)throw new Error(i.decodeErrPrefix+" not enough data for float16");const r=(e[t]<<8)+e[t+1];if(31744===r)return 1/0;if(64512===r)return-1/0;if(32256===r)return NaN;const n=r>>10&31,o=1023&r;let s;return s=0===n?o*2**-24:31!==n?(o+1024)*2**(n-25):0===o?1/0:NaN,32768&r?-s:s}function d(e){u.setFloat32(0,e,!1)}function p(e,t){if(e.length-t<4)throw new Error(i.decodeErrPrefix+" not enough data for float32");const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function y(e,t){if(e.length-t<8)throw new Error(i.decodeErrPrefix+" not enough data for float64");const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}a.compareTokens=o.encodeUint.compareTokens,t.decodeBreak=function(e,t,r,o){if(!1===o.allowIndefinite)throw new Error(i.decodeErrPrefix+" indefinite length items not allowed");return new n.Token(n.Type.break,void 0,1)},t.decodeFloat16=function(e,t,r,n){return s(l(e,t+1),3,n)},t.decodeFloat32=function(e,t,r,n){return s(p(e,t+1),5,n)},t.decodeFloat64=function(e,t,r,n){return s(y(e,t+1),9,n)},t.decodeUndefined=function(e,t,r,o){if(!1===o.allowUndefined)throw new Error(i.decodeErrPrefix+" undefined values are not supported");return!0===o.coerceUndefinedToNull?new n.Token(n.Type.null,null,1):new n.Token(n.Type.undefined,void 0,1)},t.encodeFloat=a},function(e,t,r){"use strict";const n=r(58);function i(e,t,r){const i=n.compare(e.clock,t.clock);return 0===i?r(e,t):i}function o(e,t,r){return e.clock.id===t.clock.id?r(e,t):e.clock.ide,n=(e,t)=>o(e,t,r);return((e,t)=>i(e,t,n))(e,t)},t.SortByEntryHash=function(e,t){const r=(e,t)=>e.hasho(e,t,r);return((e,t)=>i(e,t,n))(e,t)},t.NoZeroes=function(e){const t=`Your log's tiebreaker function, ${e.name}, has returned zero and therefore cannot be`;return(r,n)=>{const i=e(r,n);if(0===i)throw Error(t);return i}}},function(e,t,r){"use strict";e.exports={IPFSNotDefinedError:()=>new Error("IPFS instance not defined"),LogNotDefinedError:()=>new Error("Log instance not defined"),NotALogError:()=>new Error("Given argument is not an instance of Log"),CannotJoinWithDifferentId:()=>new Error("Can't join logs with different IDs"),LtOrLteMustBeStringOrArray:()=>new Error("lt or lte must be a string or array of Entries")}},function(e,t,r){"use strict";const n=r(37),i=r(267);e.exports=class extends n{constructor(e,t,r,n={}){void 0===n.Index&&Object.assign(n,{Index:i}),super(e,t,r,n),this._type="eventlog",this.events.on("log.op.ADD",(e,t,r)=>{this.events.emit("db.append",r.value)})}add(e,t={}){return this._addOperation({op:"ADD",key:null,value:e},t)}get(e){return this.iterator({gte:e,limit:1}).collect()[0]}iterator(e){const t=this._query(e);let r=0;return{[Symbol.iterator](){return this},next(){let e={value:null,done:!0};return rt}}_query(e){e||(e={});const t=e.limit?e.limit>-1?e.limit:this._index.get().length:1,r=this._index.get().slice();let n=[];return n=e.gt||e.gte?this._read(r,e.gt?e.gt:e.gte,t,!!e.gte):this._read(r.reverse(),e.lt?e.lt:e.lte,t,e.lte||!e.lt).reverse(),e.reverse&&n.reverse(),n}_read(e,t,r,n){const i=e.map(e=>e.hash).indexOf(t);let o=Math.max(i,0);o+=n?0:1;return e.slice(o).slice(0,r)}}},function(e,t,r){"use strict";const{deepEqual:n}=r(274),i=(e,t)=>e+t;class o{constructor(e,t){this.id=e,this._counters=t||{},this._counters[this.id]=this._counters[this.id]?this._counters[this.id]:0}get value(){return Object.values(this._counters).reduce(i,0)}increment(e){e&&e<1||(null==e&&(e=1),this._counters[this.id]=this._counters[this.id]+e)}merge(e){Object.entries(e._counters).forEach(([e,t])=>{this._counters[e]=Math.max(this._counters[e]||0,t)})}toJSON(){return{id:this.id,counters:this._counters}}isEqual(e){return o.isEqual(this,e)}static from(e){return new o(e.id,e.counters)}static isEqual(e,t){return e.id===t.id&&n(e._counters,t._counters)}}e.exports=o},function(e,t,r){"use strict";(function(t,n){var i=r(48);e.exports=v;var o,s=r(100);v.ReadableState=m;r(7).EventEmitter;var a=function(e,t){return e.listeners(t).length},c=r(119),u=r(3).Buffer,f=t.Uint8Array||function(){};var h=Object.create(r(41));h.inherits=r(1);var l=r(278),d=void 0;d=l&&l.debuglog?l.debuglog("stream"):function(){};var p,y=r(279),b=r(120);h.inherits(v,c);var g=["error","close","destroy","pause","resume"];function m(e,t){e=e||{};var n=t instanceof(o=o||r(21));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,s=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new y,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(p||(p=r(15).StringDecoder),this.decoder=new p(e.encoding),this.encoding=e.encoding)}function v(e){if(o=o||r(21),!(this instanceof v))return new v(e);this._readableState=new m(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function w(e,t,r,n,i){var o,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,E(e)}(e,s)):(i||(o=function(e,t){var r;n=t,u.isBuffer(n)||n instanceof f||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?_(e,s,t,!1):A(e,s)):_(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function E(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(k,e):k(e))}function k(e){d("emit readable"),e.emit("readable"),x(e)}function A(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(C,e,t))}function C(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=u.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function M(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(R,t,e))}function R(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function N(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?M(this):E(this),null;if(0===(e=S(e,t))&&t.ended)return 0===t.length&&M(this),null;var n,i=t.needReadable;return d("need readable",i),(0===t.length||t.length-e0?B(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&M(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,d("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?f:v;function u(t,n){d("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,d("cleanup"),e.removeListener("close",g),e.removeListener("finish",m),e.removeListener("drain",h),e.removeListener("error",b),e.removeListener("unpipe",u),r.removeListener("end",f),r.removeListener("end",v),r.removeListener("data",y),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){d("onend"),e.end()}o.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",u);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,x(e))}}(r);e.on("drain",h);var l=!1;var p=!1;function y(t){d("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==N(o.pipes,e))&&!l&&(d("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function b(t){d("onerror",t),v(),e.removeListener("error",b),0===a(e,"error")&&e.emit("error",t)}function g(){e.removeListener("finish",m),v()}function m(){d("onfinish"),e.removeListener("close",g),v()}function v(){d("unpipe"),r.unpipe(e)}return r.on("data",y),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",b),e.once("close",g),e.once("finish",m),e.emit("pipe",r),o.flowing||(d("pipe resume"),r.resume()),e},v.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;onew Promise((n,i)=>{const o=e[Symbol.iterator]();let s=0;const a=e=>{const r=o.next();r.done?n(e):Promise.all([e,r.value]).then(e=>{a(t(e[0],e[1],s++))}).catch(i)};a(r)})},function(e,t,r){"use strict";const n=r(25),i=n.create("cache",{color:n.Colors.Magenta});n.setLogLevel("ERROR");e.exports=class{constructor(e){this._store=e}get status(){return this._store.db.status}async close(){return this._store?"open"===this.status?(await this._store.close(),Promise.resolve()):void 0:Promise.reject(new Error("No cache store found to close"))}async open(){return this._store?"open"!==this.status?(await this._store.open(),Promise.resolve()):void 0:Promise.reject(new Error("No cache store found to open"))}async get(e){return new Promise((t,r)=>{this._store.get(e,(e,n)=>{if(e&&-1===e.toString().indexOf("NotFoundError: Key not found in database")&&-1===e.toString().indexOf("NotFound"))return r(e);t(n?JSON.parse(n):null)})})}set(e,t){return new Promise((r,n)=>{this._store.put(e,JSON.stringify(t),o=>{if(o&&-1===o.toString().indexOf("NotFoundError: Key not found in database")&&-1===o.toString().indexOf("NotFound"))return n(o);i.debug(`cache: Set ${e} to ${t}`),r()})})}load(){}destroy(){}async del(e){return new Promise((t,r)=>{this._store.del(e,e=>{if(e&&-1===e.toString().indexOf("NotFoundError: Key not found in database")&&-1===e.toString().indexOf("NotFound"))return r(e);t()})})}}},function(e,t,r){t.AbstractLevelDOWN=r(293),t.AbstractIterator=r(126),t.AbstractChainedBatch=r(127)},function(e,t){e.exports=function(e){for(var t=1;t0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n)s.endEmitted?S(e,new _):I(e,s,t,!0);else if(s.ended)S(e,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?I(e,s,t,!1):M(e,s)):I(e,s,t,!1)}else n||(s.reading=!1,M(e,s));return!s.ended&&(s.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(B,e))}function B(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){u("readable nexttick read 0"),e.read(0)}function L(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),P(e),t.flowing&&!t.reading&&e.read(0)}function P(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function U(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function D(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function K(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):x(this),null;if(0===(e=T(e,t))&&t.ended)return 0===t.length&&D(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?U(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&D(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){S(this,new w("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:b;function a(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",y),e.removeListener("drain",f),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",b),r.removeListener("data",l),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function c(){u("onend"),e.end()}i.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var f=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,P(e))}}(r);e.on("drain",f);var h=!1;function l(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==K(i.pipes,e))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),b(),e.removeListener("error",d),0===o(e,"error")&&S(e,t)}function p(){e.removeListener("finish",y),b()}function y(){u("onfinish"),e.removeListener("close",p),b()}function b(){u("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",y),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?x(this):i.reading||n.nextTick(O,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(N,this),r},A.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(N,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(L,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new y("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,M(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=h.destroy,A.prototype._undestroy=h.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(6),r(2))},function(e,t,r){"use strict";e.exports=f;var n=r(28).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(29);function u(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length * @license MIT */function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(a=f[u],!v(e[a],t[a],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function S(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&g(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!e&&i&&!r;if((!e&&s.isError(i)&&o&&_(i,r)||a)&&g(i,r,"Got unwanted exception"+n),e&&i&&r&&!_(i,r)||!e&&i)throw i}l.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return y(b(e.actual),128)+" "+e.operator+" "+y(b(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=p(t),o=n.indexOf("\n"+i);if(o>=0){var s=n.indexOf("\n",o+1);n=n.substring(s+1)}this.stack=n}}},s.inherits(l.AssertionError,Error),l.fail=g,l.ok=m,l.equal=function(e,t,r){e!=t&&g(e,t,r,"==",l.equal)},l.notEqual=function(e,t,r){e==t&&g(e,t,r,"!=",l.notEqual)},l.deepEqual=function(e,t,r){v(e,t,!1)||g(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){v(e,t,!0)||g(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){v(e,t,!1)&&g(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&g(t,r,n,"notDeepStrictEqual",e)},l.strictEqual=function(e,t,r){e!==t&&g(e,t,r,"===",l.strictEqual)},l.notStrictEqual=function(e,t,r){e===t&&g(e,t,r,"!==",l.notStrictEqual)},l.throws=function(e,t,r){S(!0,e,t,r)},l.doesNotThrow=function(e,t,r){S(!1,e,t,r)},l.ifError=function(e){if(e)throw e},l.strict=n((function e(t,r){t||g(t,!0,r,"==",e)}),l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var E=Object.keys||function(e){var t=[];for(var r in e)a.call(e,r)&&t.push(r);return t}}).call(this,r(6))},function(e,t,r){var n=r(70);function i(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._ended=!1,this._nexting=!1}i.prototype.next=function(e){var t=this;if("function"!=typeof e)throw new Error("next() requires a callback argument");return t._ended?(n(e,new Error("cannot call next() after end()")),t):t._nexting?(n(e,new Error("cannot call next() before previous next() has completed")),t):(t._nexting=!0,t._next((function(){t._nexting=!1,e.apply(null,arguments)})),t)},i.prototype._next=function(e){n(e)},i.prototype.seek=function(e){if(this._ended)throw new Error("cannot call seek() after end()");if(this._nexting)throw new Error("cannot call seek() before next() has completed");e=this.db._serializeKey(e),this._seek(e)},i.prototype._seek=function(e){},i.prototype.end=function(e){if("function"!=typeof e)throw new Error("end() requires a callback argument");if(this._ended)return n(e,new Error("end() already called on iterator"));this._ended=!0,this._end(e)},i.prototype._end=function(e){n(e)},i.prototype._nextTick=n,e.exports=i},function(e,t,r){var n=r(70);function i(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._operations=[],this._written=!1}i.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")},i.prototype.put=function(e,t){this._checkWritten();var r=this.db._checkKey(e)||this.db._checkValue(t);if(r)throw r;return e=this.db._serializeKey(e),t=this.db._serializeValue(t),this._put(e,t),this},i.prototype._put=function(e,t){this._operations.push({type:"put",key:e,value:t})},i.prototype.del=function(e){this._checkWritten();var t=this.db._checkKey(e);if(t)throw t;return e=this.db._serializeKey(e),this._del(e),this},i.prototype._del=function(e){this._operations.push({type:"del",key:e})},i.prototype.clear=function(){return this._checkWritten(),this._clear(),this},i.prototype._clear=function(){this._operations=[]},i.prototype.write=function(e,t){if(this._checkWritten(),"function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("write() requires a callback argument");"object"==typeof e&&null!==e||(e={}),this._written=!0,this._write(e,t)},i.prototype._write=function(e,t){this.db._batch(this._operations,e,t)},i.prototype._nextTick=n,e.exports=i},function(e,t,r){t.AbstractLevelDOWN=r(318),t.AbstractIterator=r(140),t.AbstractChainedBatch=r(141)},function(e,t,r){(function(t){function r(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._ended=!1,this._nexting=!1}r.prototype.next=function(e){var r=this;if("function"!=typeof e)throw new Error("next() requires a callback argument");return r._ended?(t.nextTick(e,new Error("cannot call next() after end()")),r):r._nexting?(t.nextTick(e,new Error("cannot call next() before previous next() has completed")),r):(r._nexting=!0,r._next((function(){r._nexting=!1,e.apply(null,arguments)})),r)},r.prototype._next=function(e){t.nextTick(e)},r.prototype.seek=function(e){if(this._ended)throw new Error("cannot call seek() after end()");if(this._nexting)throw new Error("cannot call seek() before next() has completed");e=this.db._serializeKey(e),this._seek(e)},r.prototype._seek=function(e){},r.prototype.end=function(e){if("function"!=typeof e)throw new Error("end() requires a callback argument");if(this._ended)return t.nextTick(e,new Error("end() already called on iterator"));this._ended=!0,this._end(e)},r.prototype._end=function(e){t.nextTick(e)},e.exports=r}).call(this,r(2))},function(e,t){function r(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._operations=[],this._written=!1}r.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")},r.prototype.put=function(e,t){this._checkWritten();var r=this.db._checkKey(e)||this.db._checkValue(t);if(r)throw r;return e=this.db._serializeKey(e),t=this.db._serializeValue(t),this._put(e,t),this},r.prototype._put=function(e,t){this._operations.push({type:"put",key:e,value:t})},r.prototype.del=function(e){this._checkWritten();var t=this.db._checkKey(e);if(t)throw t;return e=this.db._serializeKey(e),this._del(e),this},r.prototype._del=function(e){this._operations.push({type:"del",key:e})},r.prototype.clear=function(){return this._checkWritten(),this._clear(),this},r.prototype._clear=function(){this._operations=[]},r.prototype.write=function(e,t){if(this._checkWritten(),"function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("write() requires a callback argument");"object"==typeof e&&null!==e||(e={}),this._written=!0,this._write(e,t)},r.prototype._write=function(e,t){this.db._batch(this._operations,e,t)},e.exports=r},function(e,t,r){(function(e){function r(e){return void 0!==e&&""!==e}function n(e,t){return Object.hasOwnProperty.call(e,t)}function i(e,t){return Object.hasOwnProperty.call(e,t)&&t}t.compare=function(t,r){if(e.isBuffer(t)){for(var n=Math.min(t.length,r.length),i=0;ir?1:0};var o=t.lowerBoundKey=function(e){return i(e,"gt")||i(e,"gte")||i(e,"min")||(e.reverse?i(e,"end"):i(e,"start"))||void 0},s=t.lowerBound=function(e,t){var r=o(e);return r?e[r]:t},a=t.lowerBoundInclusive=function(e){return!n(e,"gt")},c=t.upperBoundInclusive=function(e){return!n(e,"lt")},u=t.lowerBoundExclusive=function(e){return!a(e)},f=t.upperBoundExclusive=function(e){return!c(e)},h=t.upperBoundKey=function(e){return i(e,"lt")||i(e,"lte")||i(e,"max")||(e.reverse?i(e,"start"):i(e,"end"))||void 0},l=t.upperBound=function(e,t){var r=h(e);return r?e[r]:t};function d(e){return e}t.start=function(e,t){return e.reverse?l(e,t):s(e,t)},t.end=function(e,t){return e.reverse?s(e,t):l(e,t)},t.startInclusive=function(e){return e.reverse?c(e):a(e)},t.endInclusive=function(e){return e.reverse?a(e):c(e)},t.toLtgt=function(e,r,i,o,s){r=r||{},i=i||d;var a=arguments.length>3,c=t.lowerBoundKey(e),u=t.upperBoundKey(e);return c?"gt"===c?r.gt=i(e.gt,!1):r.gte=i(e[c],!1):a&&(r.gte=i(o,!1)),u?"lt"===u?r.lt=i(e.lt,!0):r.lte=i(e[u],!0):a&&(r.lte=i(s,!0)),null!=e.reverse&&(r.reverse=!!e.reverse),n(r,"max")&&delete r.max,n(r,"min")&&delete r.min,n(r,"start")&&delete r.start,n(r,"end")&&delete r.end,r},t.contains=function(e,n,i){i=i||t.compare;var o=s(e);if(r(o)&&((a=i(n,o))<0||0===a&&u(e)))return!1;var a,c=l(e);if(r(c)&&((a=i(n,c))>0||0===a&&f(e)))return!1;return!0},t.filter=function(e,r){return function(n){return t.contains(e,n,r)}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(144);e.exports=function(e){return e instanceof Uint8Array?n(e):e instanceof ArrayBuffer?t.from(e):t.from(String(e))}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){var n=r(320).strict;e.exports=function(e){if(n(e)){var r=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(r=r.slice(e.byteOffset,e.byteOffset+e.byteLength)),r}return t.from(e)}}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(27)},function(e,t,r){"use strict";const n=r(147),i=r(323),o=r(349);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(86),t.pbkdf2=r(463)},function(e,t,r){"use strict";(function(e){const n=r(71),i=r(72),o=r(322),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"};t.create=function(t,r,a){const c=s[t];n(i.subtle.importKey("raw",r,{name:"HMAC",hash:{name:c}},!1,["sign"]).then(r=>({digest(t,o){((t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)})(r,t,o)},length:o[t]})),a)}}).call(this,r(0).Buffer)},function(e,t,r){var n={ECB:r(327),CBC:r(328),CFB:r(329),CFB8:r(330),CFB1:r(331),OFB:r(332),CTR:r(149),GCM:r(149)},i=r(151);for(var o in i)i[o].module=n[i[o].mode];e.exports=i},function(e,t,r){var n=r(42),i=r(3).Buffer,o=r(150);function s(e){var t=e._cipher.encryptBlockRaw(e._prev);return o(e._prev),t}t.encrypt=function(e,t){var r=Math.ceil(t.length/16),o=e._cache.length;e._cache=i.concat([e._cache,i.allocUnsafe(16*r)]);for(var a=0;a0||o>0;){var f=new i;f.update(u),f.update(e),t&&f.update(t),u=f.digest();var h=0;if(s>0){var l=a.length-s;h=Math.min(s,u.length),u.copy(a,l,0,h),s-=h}if(h0){var d=c.length-o,p=Math.min(o,u.length-h);u.copy(c,d,h,h+p),o-=p}}return u.fill(0),{key:a,iv:c}}},function(e,t,r){"use strict";var n=r(339).Buffer,i=r(340).Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(1)(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=o},function(e,t,r){"use strict";(function(t,n){var i;e.exports=A,A.ReadableState=k;r(7).EventEmitter;var o=function(e,t){return e.listeners(t).length},s=r(157),a=r(0).Buffer,c=t.Uint8Array||function(){};var u,f=r(341);u=f&&f.debuglog?f.debuglog("stream"):function(){};var h,l,d,p=r(342),y=r(158),b=r(159).getHighWaterMark,g=r(30).codes,m=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,w=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(1)(A,s);var S=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function k(e,t,n){i=i||r(31),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=b(this,e,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(15).StringDecoder),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function A(e){if(i=i||r(31),!(this instanceof A))return new A(e);var t=this instanceof i;this._readableState=new k(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function C(e,t,r,n,i){u("readableAddChunk",t);var o,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?x(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,B(e)))}(e,s);else if(i||(o=function(e,t){var r;n=t,a.isBuffer(n)||n instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new m("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(s,t)),o)S(e,o);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n)s.endEmitted?S(e,new _):I(e,s,t,!0);else if(s.ended)S(e,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?I(e,s,t,!1):M(e,s)):I(e,s,t,!1)}else n||(s.reading=!1,M(e,s));return!s.ended&&(s.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(B,e))}function B(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){u("readable nexttick read 0"),e.read(0)}function L(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),P(e),t.flowing&&!t.reading&&e.read(0)}function P(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function U(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function D(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function K(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):x(this),null;if(0===(e=T(e,t))&&t.ended)return 0===t.length&&D(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?U(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&D(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){S(this,new w("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:b;function a(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",y),e.removeListener("drain",f),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",b),r.removeListener("data",l),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function c(){u("onend"),e.end()}i.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var f=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,P(e))}}(r);e.on("drain",f);var h=!1;function l(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==K(i.pipes,e))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),b(),e.removeListener("error",d),0===o(e,"error")&&S(e,t)}function p(){e.removeListener("finish",y),b()}function y(){u("onfinish"),e.removeListener("close",p),b()}function b(){u("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",y),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?x(this):i.reading||n.nextTick(O,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(N,this),r},A.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(N,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(L,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new y("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,M(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=h.destroy,A.prototype._undestroy=h.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(6),r(2))},function(e,t,r){"use strict";e.exports=f;var n=r(30).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(31);function u(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length4){var r=e;e=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}s(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),s(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),s(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),s(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,o=new Array(i),s=0;s>>1,i=new Array(r);i[n]=e.slice(0);for(var o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(o),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var f=8*i.fullMessageLength[0],h=0;h>>0,s.putInt32(f>>>0),f=c>>>0;s.putInt32(f);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(l,r,s);var d=n.util.createBuffer();return d.putInt32(l.h0),d.putInt32(l.h1),d.putInt32(l.h2),d.putInt32(l.h3),d.putInt32(l.h4),d},i};var o=null,s=!1;function a(e,t,r){for(var n,i,o,s,a,c,u,f=r.length();f>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o&s|a&(o^s))+c+2400959708+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+3395469782+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+s|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,f-=64}}},function(e,t,r){var n=r(4);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(162),r(163),r(5),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return d(r._keys,e,t,!1)},decrypt:function(e,t){return d(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],f=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],l=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],d=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],b=e.length()>8?3:1,g=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,w=0;w>>4^S))<<4,_^=t=65535&((S^=t)>>>-16^_),_^=(t=858993459&(_>>>2^(S^=t<<-16)))<<2,_^=t=65535&((S^=t)>>>-16^_),_^=(t=1431655765&(_>>>1^(S^=t<<-16)))<<1,_^=t=16711935&((S^=t)>>>8^_),t=(_^=(t=1431655765&(_>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,_=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var E=0;E>>26,S=S<<2|S>>>26):(_=_<<1|_>>>27,S=S<<1|S>>>27);var k=r[(_&=-15)>>>28]|n[_>>>24&15]|i[_>>>20&15]|o[_>>>16&15]|s[_>>>12&15]|a[_>>>8&15]|c[_>>>4&15],A=u[(S&=-15)>>>28]|f[S>>>24&15]|h[S>>>20&15]|l[S>>>16&15]|d[S>>>12&15]|p[S>>>8&15]|y[S>>>4&15];t=65535&(A>>>16^k),g[v++]=k^t,g[v++]=A^t<<16}}return g}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var o=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],s=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],l=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function d(e,t,r,n){var i,d,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=t[0],b=t[1];y^=(d=252645135&(y>>>4^b))<<4,y^=(d=65535&(y>>>16^(b^=d)))<<16,y^=d=858993459&((b^=d)>>>2^y),y^=d=16711935&((b^=d<<2)>>>8^y),y=(y^=(d=1431655765&(y>>>1^(b^=d<<8)))<<1)<<1|y>>>31,b=(b^=d)<<1|b>>>31;for(var g=0;g>>4|b<<28)^e[w+1];d=y,y=b,b=d^(s[_>>>24&63]|c[_>>>16&63]|f[_>>>8&63]|l[63&_]|o[S>>>24&63]|a[S>>>16&63]|u[S>>>8&63]|h[63&S])}d=y,y=b,b=d}b=b>>>1|b<<31,b^=d=1431655765&((y=y>>>1|y<<31)>>>1^b),b^=(d=16711935&(b>>>8^(y^=d<<1)))<<8,b^=(d=858993459&(b>>>2^(y^=d)))<<2,b^=d=65535&((y^=d)>>>16^b),b^=d=252645135&((y^=d<<16)>>>4^b),y^=d<<4,r[0]=y,r[1]=b}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},function(e,t,r){var n=r(4);r(24),r(5),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,o={start:function(o,s){if(null!==o)if("string"==typeof o){if(!((o=o.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+o+'"');t=n.md.algorithms[o].create()}else t=o;if(null===s)s=e;else{if("string"==typeof s)s=n.util.createBuffer(s);else if(n.util.isArray(s)){var a=s;s=n.util.createBuffer();for(var c=0;ct.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=s.length();for(c=0;c{if(e)return i(e);i(null,n.encode(o,t,r))})}e.exports=o,o.Buffer=t,o.multihash=n,o.digest=function(e,t,r,n){if("function"==typeof r&&(n=r,r=void 0),!n)throw new Error("Missing callback");let i,s=n;r&&(s=(e,t)=>{if(e)return n(e);n(null,t.slice(0,r))});try{i=o.createHash(t)}catch(e){return s(e)}i(e,s)},o.createHash=function(e){if(e=n.coerceCode(e),!o.functions[e])throw new Error("multihash function "+e+" not yet supported");return o.functions[e]},o.functions={17:i.sha1,18:i.sha2256,19:i.sha2512,20:i.sha3512,21:i.sha3384,22:i.sha3256,23:i.sha3224,24:i.shake128,25:i.shake256,26:i.keccak224,27:i.keccak256,28:i.keccak384,29:i.keccak512,34:i.murmur3128,35:i.murmur332,86:i.dblSha2256},i.addBlake(o.functions)}).call(this,r(0).Buffer)},function(e,t,r){(function(n,i){var o; /** * [js-sha3]{@link https://github.com/emn178/js-sha3} * * @version 0.8.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2015-2018 * @license MIT */!function(){"use strict";var s="input is invalid type",a="object"==typeof window,c=a?window:{};c.JS_SHA3_NO_WINDOW&&(a=!1);var u=!a&&"object"==typeof self;!c.JS_SHA3_NO_NODE_JS&&"object"==typeof n&&n.versions&&n.versions.node?c=i:u&&(c=self);var f=!c.JS_SHA3_NO_COMMON_JS&&"object"==typeof e&&e.exports,h=r(387),l=!c.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),p=[4,1024,262144,67108864],y=[0,8,16,24],b=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],m=[128,256],v=["hex","buffer","arrayBuffer","array","digest"],w={128:168,256:136};!c.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!l||!c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var _=function(e,t,r){return function(n){return new P(e,t,e).update(n)[r]()}},S=function(e,t,r){return function(n,i){return new P(e,t,i).update(n)[r]()}},E=function(e,t,r){return function(t,n,i,o){return T["cshake"+e].update(t,n,i,o)[r]()}},k=function(e,t,r){return function(t,n,i,o){return T["kmac"+e].update(t,n,i,o)[r]()}},A=function(e,t,r,n){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function U(e,t,r){P.call(this,e,t,r)}P.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(s);if(null===e)throw new Error(s);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||l&&ArrayBuffer.isView(e)))throw new Error(s);t=!0}for(var n,i,o=this.blocks,a=this.byteCount,c=e.length,u=this.blockCount,f=0,h=this.s;f>2]|=e[f]<>2]|=i<>2]|=(192|i>>6)<>2]|=(128|63&i)<=57344?(o[n>>2]|=(224|i>>12)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<>2]|=(240|i>>18)<>2]|=(128|i>>12&63)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<=a){for(this.start=n-a,this.block=o[u],n=0;n>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},P.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(s);if(null===e)throw new Error(s);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||l&&ArrayBuffer.isView(e)))throw new Error(s);t=!0}var n=0,i=e.length;if(t)n=i;else for(var o=0;o=57344?n+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++o)),n+=4)}return n+=this.encode(8*n),this.update(e),n},P.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+d[15&e]+d[e>>12&15]+d[e>>8&15]+d[e>>20&15]+d[e>>16&15]+d[e>>28&15]+d[e>>24&15];s%t==0&&(D(r),o=0)}return i&&(e=r[o],a+=d[e>>4&15]+d[15&e],i>1&&(a+=d[e>>12&15]+d[e>>8&15]),i>2&&(a+=d[e>>20&15]+d[e>>16&15])),a},P.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);s>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r==0&&D(n)}return o&&(e=a<<2,t=n[s],c[e]=255&t,o>1&&(c[e+1]=t>>8&255),o>2&&(c[e+2]=t>>16&255)),c},U.prototype=new P,U.prototype.finalize=function(){return this.encode(this.outputBits,!0),P.prototype.finalize.call(this)};var D=function(e){var t,r,n,i,o,s,a,c,u,f,h,l,d,p,y,g,m,v,w,_,S,E,k,A,C,I,T,x,B,M,R,N,O,L,P,U,D,j,K,V,q,F,z,H,W,G,Y,Q,$,X,Z,J,ee,te,re,ne,ie,oe,se,ae,ce,ue,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(l=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=o^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(f<<1|h>>>31),r=a^(h<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(l<<1|d>>>31),r=u^(d<<1|l>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,p=e[0],y=e[1],G=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,x=e[20]<<3|e[21]>>>29,B=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,F=e[40]<<18|e[41]>>>14,z=e[41]<<18|e[40]>>>14,L=e[2]<<1|e[3]>>>31,P=e[3]<<1|e[2]>>>31,g=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,Q=e[22]<<10|e[23]>>>22,$=e[23]<<10|e[22]>>>22,M=e[33]<<13|e[32]>>>19,R=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,U=e[14]<<6|e[15]>>>26,D=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,N=e[45]<<29|e[44]>>>3,O=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,C=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,j=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,J=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,W=e[9]<<27|e[8]>>>5,I=e[18]<<20|e[19]>>>12,T=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,V=e[38]<<8|e[39]>>>24,q=e[39]<<8|e[38]>>>24,E=e[48]<<14|e[49]>>>18,k=e[49]<<14|e[48]>>>18,e[0]=p^~g&v,e[1]=y^~m&w,e[10]=A^~I&x,e[11]=C^~T&B,e[20]=L^~U&j,e[21]=P^~D&K,e[30]=H^~G&Q,e[31]=W^~Y&$,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=g^~v&_,e[3]=m^~w&S,e[12]=I^~x&M,e[13]=T^~B&R,e[22]=U^~j&V,e[23]=D^~K&q,e[32]=G^~Q&X,e[33]=Y^~$&Z,e[42]=ne^~oe&ae,e[43]=ie^~se&ce,e[4]=v^~_&E,e[5]=w^~S&k,e[14]=x^~M&N,e[15]=B^~R&O,e[24]=j^~V&F,e[25]=K^~q&z,e[34]=Q^~X&J,e[35]=$^~Z&ee,e[44]=oe^~ae&ue,e[45]=se^~ce&fe,e[6]=_^~E&p,e[7]=S^~k&y,e[16]=M^~N&A,e[17]=R^~O&C,e[26]=V^~F&L,e[27]=q^~z&P,e[36]=X^~J&H,e[37]=Z^~ee&W,e[46]=ae^~ue&te,e[47]=ce^~fe&re,e[8]=E^~p&g,e[9]=k^~y&m,e[18]=N^~A&I,e[19]=O^~C&T,e[28]=F^~L&U,e[29]=z^~P&D,e[38]=J^~H&G,e[39]=ee^~W&Y,e[48]=ue^~te&ne,e[49]=fe^~re&ie,e[0]^=b[n],e[1]^=b[n+1]};if(f)e.exports=T;else{for(B=0;Bfunction(r,n){let i;try{i=t(r)}catch(t){return void e.nextTick(n,t)}e.nextTick(n,null,i)},t.toBuf=(e,t)=>n=>{let i=e(n,t);return r.from(i,"hex")},t.fromString=(e,t)=>n=>{const i=r.isBuffer(n)?n.toString():n;return e(i,t)},t.fromNumberTo32BitBuf=(e,t)=>n=>{let i=e(n,t);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return r.from(o)}}).call(this,r(2),r(0).Buffer)},function(e,t,r){(function(t,n){var i,o=r(390),s=r(172);function a(e,t){return"function"!=typeof t?e:e.then((function(e){i((function(){t(null,e)}))}),(function(e){i((function(){t(e)}))}))}function c(e){return a(this,e)}function u(e){if(e&&s(e)){e.nodeify=c;var t=e.then;return e.then=function(){return u(t.apply(this,arguments))},e}"function"==typeof e?e.prototype.nodeify=c:o.prototype.nodeify=c}function f(e){if(!(this instanceof f))return new f(e);o.call(this,e),u(this)}i="function"==typeof t?t:"object"==typeof n&&n&&n.nextTick?n.nextTick:function(e){setTimeout(e,0)},e.exports=a,a.extend=u,a.Promise=f,f.prototype=Object.create(o.prototype),f.prototype.constructor=f}).call(this,r(26).setImmediate,r(2))},function(e,t){e.exports=function(e){return e&&"function"==typeof e.then}},function(e,t,r){const n=r(392),i=r(393);e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:i.blake2s,blake2sHex:i.blake2sHex,blake2sInit:i.blake2sInit,blake2sUpdate:i.blake2sUpdate,blake2sFinal:i.blake2sFinal}},function(e,t,r){(function(t){function r(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){let r;if(e instanceof Uint8Array)r=e;else if(e instanceof t)r=new Uint8Array(e);else{if("string"!=typeof e)throw new Error("Input must be an string, Buffer or Uint8Array");r=new Uint8Array(t.from(e,"utf8"))}return r},toHex:function(e){return Array.prototype.map.call(e,(function(e){return(e<16?"0":"")+e.toString(16)})).join("")},debugPrint:function(e,t,n){let i="\n"+e+" = ";for(let o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6,i}(e,t,r,this.reporter);if(n.length<128){const e=i.alloc(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let a=1;for(let e=n.length;e>=256;e>>=8)a++;const c=i.alloc(2+a);c[0]=o,c[1]=128|a;for(let e=1+a,t=n.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=i.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t=128;r>>=7)n++}const o=i.alloc(n);let s=o.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(o[s--]=127&r;(r>>=7)>0;)o[s--]=128|127&r}return this._createEncoderBuffer(o)},c.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=i.from(t)}if(i.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=i.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(i.from(n))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t128)throw new Error('Invalid "nsComment" content.');e.value=i.create(i.Class.UNIVERSAL,i.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var d=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=d.toHex(),e.value=i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,d.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);f=e.value.value;if(e.keyIdentifier){var p=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;f.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!1,p))}if(e.authorityCertIssuer){var b=[i.create(i.Class.CONTEXT_SPECIFIC,4,!0,[y(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];f.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,b))}if(e.serialNumber){var g=n.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);f.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!1,g))}}else if("cRLDistributionPoints"===e.name){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);f=e.value.value;var m,v=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]),w=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);for(l=0;l2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(h.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=h[0],c.validity.notAfter=h[1],c.tbsCertificate=r.tbsCertificate,t){var l;if(c.md=null,c.signatureOid in s)switch(s[c.signatureOid]){case"sha1WithRSAEncryption":c.md=n.md.sha1.create();break;case"md5WithRSAEncryption":c.md=n.md.md5.create();break;case"sha256WithRSAEncryption":c.md=n.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=n.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=n.md.sha512.create();break;case"RSASSA-PSS":c.md=n.md.sha256.create()}if(null===c.md)throw(l=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,l;var y=i.toDer(c.tbsCertificate);c.md.update(y.getBytes())}var g=n.md.sha1.create();c.issuer.getField=function(e){return d(c.issuer,e)},c.issuer.addField=function(e){b([e]),c.issuer.attributes.push(e)},c.issuer.attributes=o.RDNAttributesAsArray(r.certIssuer,g),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=g.digest().toHex();var m=n.md.sha1.create();return c.subject.getField=function(e){return d(c.subject,e)},c.subject.addField=function(e){b([e]),c.subject.attributes.push(e)},c.subject.attributes=o.RDNAttributesAsArray(r.certSubject,m),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=m.digest().toHex(),r.certExtensions?c.extensions=o.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=o.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},o.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=c.value.charCodeAt(1),o=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=128==(128&r),t.nonRepudiation=64==(64&r),t.keyEncipherment=32==(32&r),t.dataEncipherment=16==(16&r),t.keyAgreement=8==(8&r),t.keyCertSign=4==(4&r),t.cRLSign=2==(2&r),t.encipherOnly=1==(1&r),t.decipherOnly=128==(128&o)}else if("basicConstraints"===t.name){(c=i.fromDer(t.value)).value.length>0&&c.value[0].type===i.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var a=null;c.value.length>0&&c.value[0].type===i.Type.INTEGER?a=c.value[0].value:c.value.length>1&&(a=c.value[1].value),null!==a&&(t.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===t.name)for(var c=i.fromDer(t.value),u=0;u1&&(r=c.value.charCodeAt(1)),t.client=128==(128&r),t.server=64==(64&r),t.email=32==(32&r),t.objsign=16==(16&r),t.reserved=8==(8&r),t.sslCA=4==(4&r),t.emailCA=2==(2&r),t.objCA=1==(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var h;t.altNames=[];c=i.fromDer(t.value);for(var l=0;l=w&&e<_?i.create(i.Class.UNIVERSAL,i.Type.UTCTIME,!1,i.dateToUtcTime(e)):i.create(i.Class.UNIVERSAL,i.Type.GENERALIZEDTIME,!1,i.dateToGeneralizedTime(e))}o.getTBSCertificate=function(e){var t=S(e.validity.notBefore),r=S(e.validity.notAfter),s=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes())]),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,n.util.hexToBytes(e.serialNumber)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.siginfo.algorithmOid).getBytes()),m(e.siginfo.algorithmOid,e.siginfo.parameters)]),y(e.issuer),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[t,r]),y(e.subject),o.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&s.value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&s.value.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!0,[i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&s.value.push(o.certificateExtensionsToAsn1(e.extensions)),s},o.getCertificationRequestInfo=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes()),y(e.subject),o.publicKeyToAsn1(e.publicKey),v(e)])},o.distinguishedNameToAsn1=function(e){return y(e)},o.certificateToAsn1=function(e){var t=e.tbsCertificate||o.getTBSCertificate(e);return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[t,i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.signatureOid).getBytes()),m(e.signatureOid,e.signatureParameters)]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},o.certificateExtensionsToAsn1=function(e){var t=i.create(i.Class.CONTEXT_SPECIFIC,3,!0,[]),r=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;nf.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:o.certificateError.certificate_expired,notBefore:f.validity.notBefore,notAfter:f.validity.notAfter,now:s}),null===c){if(null===(h=t[0]||e.getIssuer(f))&&f.isIssuer(f)&&(l=!0,h=f),h){var d=h;n.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){h=d.shift();try{p=h.verify(f)}catch(e){}}p||(c={message:"Certificate signature is invalid.",error:o.certificateError.bad_certificate})}null!==c||h&&!l||e.hasCertificate(f)||(c={message:"Certificate is not trusted.",error:o.certificateError.unknown_ca})}if(null===c&&h&&!f.isIssuer(h)&&(c={message:"Certificate issuer is invalid.",error:o.certificateError.bad_certificate}),null===c)for(var y={keyUsage:!0,basicConstraints:!0},b=0;null===c&&bm.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:o.certificateError.bad_certificate})}var w=null===c||c.error,_=r.verify?r.verify(w,u,i):w;if(!0!==_)throw!0===w&&(c={message:"The application rejected the certificate.",error:o.certificateError.bad_certificate}),(_||0===_)&&("object"!=typeof _||n.util.isArray(_)?"string"==typeof _&&(c.error=_):(_.message&&(c.message=_.message),_.error&&(c.error=_.error))),c;c=null,a=!1,++u}while(t.length>0);return!0}},function(e,t,r){var n=r(4);r(33),r(5),(e.exports=n.pss=n.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,i=e.mgf,o=r.digestLength,s=e.salt||null;if("string"==typeof s&&(s=n.util.createBuffer(s)),"saltLength"in e)t=e.saltLength;else{if(null===s)throw new Error("Salt length not specified or specific salt not given.");t=s.length()}if(null!==s&&s.length()!==t)throw new Error("Given salt length does not match length of given salt.");var a=e.prng||n.random,c={encode:function(e,c){var u,f,h=c-1,l=Math.ceil(h/8),d=e.digest().getBytes();if(l>8*l-h&255;return(w=String.fromCharCode(w.charCodeAt(0)&~_)+w.substr(1))+y+String.fromCharCode(188)},verify:function(e,s,a){var c,u=a-1,f=Math.ceil(u/8);if(s=s.substr(-f),f>8*f-u&255;if(0!=(l.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var y=i.generate(d,h),b="";for(c=0;c{if(e)return i(e);i(null,n.encode(o,t,r))})}e.exports=o,o.Buffer=t,o.multihash=n,o.digest=function(e,t,r,n){if("function"==typeof r&&(n=r,r=void 0),!n)throw new Error("Missing callback");let i,s=n;r&&(s=(e,t)=>{if(e)return n(e);n(null,t.slice(0,r))});try{i=o.createHash(t)}catch(e){return s(e)}i(e,s)},o.createHash=function(e){if(e=n.coerceCode(e),!o.functions[e])throw new Error("multihash function "+e+" not yet supported");return o.functions[e]},o.functions={17:i.sha1,18:i.sha2256,19:i.sha2512,20:i.sha3512,21:i.sha3384,22:i.sha3256,23:i.sha3224,24:i.shake128,25:i.shake256,26:i.keccak224,27:i.keccak256,28:i.keccak384,29:i.keccak512,34:i.murmur3128,35:i.murmur332,86:i.dblSha2256},i.addBlake(o.functions),o.validate=(e,r,i)=>{o(e,n.decode(r).name,(e,n)=>{if(e)return i(e);i(e,0===t.compare(r,n))})}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e,r){t.toCallback=t=>function(r,n){let i;try{i=t(r)}catch(t){return void e.nextTick(n,t)}e.nextTick(n,null,i)},t.toBuf=(e,t)=>n=>{let i=e(n,t);return r.from(i,"hex")},t.fromString=(e,t)=>n=>{const i=r.isBuffer(n)?n.toString():n;return e(i,t)},t.fromNumberTo32BitBuf=(e,t)=>n=>{let i=e(n,t);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return r.from(o)}}).call(this,r(2),r(0).Buffer)},function(e){e.exports=JSON.parse('{"COMPRESSED_TYPE_INVALID":"compressed should be a boolean","EC_PRIVATE_KEY_TYPE_INVALID":"private key should be a Buffer","EC_PRIVATE_KEY_LENGTH_INVALID":"private key length is invalid","EC_PRIVATE_KEY_RANGE_INVALID":"private key range is invalid","EC_PRIVATE_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting private key is invalid","EC_PRIVATE_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PRIVATE_KEY_EXPORT_DER_FAIL":"couldn\'t export to DER format","EC_PRIVATE_KEY_IMPORT_DER_FAIL":"couldn\'t import from DER format","EC_PUBLIC_KEYS_TYPE_INVALID":"public keys should be an Array","EC_PUBLIC_KEYS_LENGTH_INVALID":"public keys Array should have at least 1 element","EC_PUBLIC_KEY_TYPE_INVALID":"public key should be a Buffer","EC_PUBLIC_KEY_LENGTH_INVALID":"public key length is invalid","EC_PUBLIC_KEY_PARSE_FAIL":"the public key could not be parsed or is invalid","EC_PUBLIC_KEY_CREATE_FAIL":"private was invalid, try again","EC_PUBLIC_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting public key is invalid","EC_PUBLIC_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PUBLIC_KEY_COMBINE_FAIL":"the sum of the public keys is not valid","ECDH_FAIL":"scalar was invalid (zero or overflow)","ECDSA_SIGNATURE_TYPE_INVALID":"signature should be a Buffer","ECDSA_SIGNATURE_LENGTH_INVALID":"signature length is invalid","ECDSA_SIGNATURE_PARSE_FAIL":"couldn\'t parse signature","ECDSA_SIGNATURE_PARSE_DER_FAIL":"couldn\'t parse DER signature","ECDSA_SIGNATURE_SERIALIZE_DER_FAIL":"couldn\'t serialize signature to DER format","ECDSA_SIGN_FAIL":"nonce generation function failed or private key is invalid","ECDSA_RECOVER_FAIL":"couldn\'t recover public key from signature","MSG32_TYPE_INVALID":"message should be a Buffer","MSG32_LENGTH_INVALID":"message length is invalid","OPTIONS_TYPE_INVALID":"options should be an Object","OPTIONS_DATA_TYPE_INVALID":"options.data should be a Buffer","OPTIONS_DATA_LENGTH_INVALID":"options.data length is invalid","OPTIONS_NONCEFN_TYPE_INVALID":"options.noncefn should be a Function","RECOVERY_ID_TYPE_INVALID":"recovery should be a Number","RECOVERY_ID_VALUE_INVALID":"recovery should have value between -1 and 4","TWEAK_TYPE_INVALID":"tweak should be a Buffer","TWEAK_LENGTH_INVALID":"tweak length is invalid"}')},function(e,t,r){"use strict";var n=r(0).Buffer,i=r(1),o=r(155),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function d(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<>>32-t}function y(e,t,r,n,i,o,s,a){return p(e+(t^r^n)+o+s|0,a)+i|0}function b(e,t,r,n,i,o,s,a){return p(e+(t&r|~t&n)+o+s|0,a)+i|0}function g(e,t,r,n,i,o,s,a){return p(e+((t|~r)^n)+o+s|0,a)+i|0}function m(e,t,r,n,i,o,s,a){return p(e+(t&n|r&~n)+o+s|0,a)+i|0}function v(e,t,r,n,i,o,s,a){return p(e+(t^(r|~n))+o+s|0,a)+i|0}i(d,o),d.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,d=0|this._e,w=0|this._a,_=0|this._b,S=0|this._c,E=0|this._d,k=0|this._e,A=0;A<80;A+=1){var C,I;A<16?(C=y(r,n,i,o,d,e[a[A]],h[0],u[A]),I=v(w,_,S,E,k,e[c[A]],l[0],f[A])):A<32?(C=b(r,n,i,o,d,e[a[A]],h[1],u[A]),I=m(w,_,S,E,k,e[c[A]],l[1],f[A])):A<48?(C=g(r,n,i,o,d,e[a[A]],h[2],u[A]),I=g(w,_,S,E,k,e[c[A]],l[2],f[A])):A<64?(C=m(r,n,i,o,d,e[a[A]],h[3],u[A]),I=b(w,_,S,E,k,e[c[A]],l[3],f[A])):(C=v(r,n,i,o,d,e[a[A]],h[4],u[A]),I=y(w,_,S,E,k,e[c[A]],l[4],f[A])),r=d,d=o,o=p(i,10),i=n,n=C,w=k,k=E,E=p(S,10),S=_,_=I}var T=this._b+i+E|0;this._b=this._c+o+k|0,this._c=this._d+d+w|0,this._d=this._e+r+_|0,this._e=this._a+n+S|0,this._a=T},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=n.alloc?n.alloc(20):new n(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=d},function(e,t,r){(t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r}).sha=r(439),t.sha1=r(440),t.sha224=r(441),t.sha256=r(189),t.sha384=r(442),t.sha512=r(190)},function(e,t,r){var n=r(1),i=r(34),o=r(3).Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(c,i),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,p=0|this._f,y=0|this._g,b=0|this._h,g=0;g<16;++g)r[g]=e.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((t=r[g-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[g-7]+d(r[g-15])+r[g-16];for(var m=0;m<64;++m){var v=b+l(c)+u(c,p,y)+s[m]+r[m]|0,w=h(n)+f(n,i,o)|0;b=y,y=p,p=c,c=a+v|0,a=o,o=i,i=n,n=v+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=p+this._f|0,this._g=y+this._g|0,this._h=b+this._h|0},c.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=c},function(e,t,r){var n=r(1),i=r(34),o=r(3).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function c(){this.init(),this._w=a,i.call(this,128,112)}function u(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function g(e,t){return e>>>0>>0?1:0}n(c,i),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,c=0|this._fh,m=0|this._gh,v=0|this._hh,w=0|this._al,_=0|this._bl,S=0|this._cl,E=0|this._dl,k=0|this._el,A=0|this._fl,C=0|this._gl,I=0|this._hl,T=0;T<32;T+=2)t[T]=e.readInt32BE(4*T),t[T+1]=e.readInt32BE(4*T+4);for(;T<160;T+=2){var x=t[T-30],B=t[T-30+1],M=d(x,B),R=p(B,x),N=y(x=t[T-4],B=t[T-4+1]),O=b(B,x),L=t[T-14],P=t[T-14+1],U=t[T-32],D=t[T-32+1],j=R+P|0,K=M+L+g(j,R)|0;K=(K=K+N+g(j=j+O|0,O)|0)+U+g(j=j+D|0,D)|0,t[T]=K,t[T+1]=j}for(var V=0;V<160;V+=2){K=t[V],j=t[V+1];var q=f(r,n,i),F=f(w,_,S),z=h(r,w),H=h(w,r),W=l(a,k),G=l(k,a),Y=s[V],Q=s[V+1],$=u(a,c,m),X=u(k,A,C),Z=I+G|0,J=v+W+g(Z,I)|0;J=(J=(J=J+$+g(Z=Z+X|0,X)|0)+Y+g(Z=Z+Q|0,Q)|0)+K+g(Z=Z+j|0,j)|0;var ee=H+F|0,te=z+q+g(ee,H)|0;v=m,I=C,m=c,C=A,c=a,A=k,a=o+J+g(k=E+Z|0,E)|0,o=i,E=S,i=n,S=_,n=r,_=w,r=J+te+g(w=Z+ee|0,Z)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+S|0,this._dl=this._dl+E|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+C|0,this._hl=this._hl+I|0,this._ah=this._ah+r+g(this._al,w)|0,this._bh=this._bh+n+g(this._bl,_)|0,this._ch=this._ch+i+g(this._cl,S)|0,this._dh=this._dh+o+g(this._dl,E)|0,this._eh=this._eh+a+g(this._el,k)|0,this._fh=this._fh+c+g(this._fl,A)|0,this._gh=this._gh+m+g(this._gl,C)|0,this._hh=this._hh+v+g(this._hl,I)|0},c.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=c},function(e,t,r){"use strict";var n=r(3).Buffer,i=r(53),o=r(192);function s(e,t){null===e&&null===t?(this.x=this.y=null,this.inf=!0):(this.x=e,this.y=t,this.inf=!1)}s.fromPublicKey=function(e){var t,r,n=e[0];return 33!==e.length||2!==n&&3!==n?65!==e.length||4!==n&&6!==n&&7!==n?null:(t=i.fromBuffer(e.slice(1,33)),r=i.fromBuffer(e.slice(33,65)),t.ucmp(i.p)>=0||r.ucmp(i.p)>=0?null:6!==n&&7!==n||r.isOdd()===(7===n)?0!==t.redSqr().redMul(t).redIAdd7().ucmp(r.redSqr())?null:new s(t,r):null):(t=i.fromBuffer(e.slice(1,33))).ucmp(i.p)>=0||null===(r=t.redSqr().redMul(t).redIAdd7().redSqrt())?null:(3===n!==r.isOdd()&&(r=r.redNeg()),new s(t,r))},s.prototype.toPublicKey=function(e){var t,r=this.x,i=this.y;return e?((t=n.alloc(33))[0]=i.isOdd()?3:2,r.toBuffer().copy(t,1)):((t=n.alloc(65))[0]=4,r.toBuffer().copy(t,1),i.toBuffer().copy(t,33)),t},s.fromECJPoint=function(e){if(e.inf)return new s(null,null);var t=e.z.redInvm(),r=t.redSqr();return new s(e.x.redMul(r),e.y.redMul(r).redMul(t))},s.prototype.toECJPoint=function(){return this.inf?new o(null,null,null):new o(this.x,this.y,o.one)},s.prototype.neg=function(){return this.inf?this:new s(this.x,this.y.redNeg())},s.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(0===this.x.ucmp(e.x))return 0===this.y.ucmp(e.y)?this.dbl():new s(null,null);var t=this.y.redSub(e.y);t.isZero()||(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x);return new s(r,t.redMul(this.x.redSub(r)).redISub(this.y))},s.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.isZero())return new s(null,null);var t=this.x.redSqr(),r=t.redAdd(t).redIAdd(t).redMul(e.redInvm()),n=r.redSqr().redISub(this.x.redAdd(this.x));return new s(n,r.redMul(this.x.redSub(n)).redISub(this.y))},s.prototype.mul=function(e){for(var t=this._getNAFPoints(4),r=t.points,n=e.getNAF(t.wnd),i=new o(null,null,null),a=n.length-1;a>=0;a--){for(var c=0;a>=0&&0===n[a];a--,++c);if(a>=0&&(c+=1),i=i.dblp(c),a<0)break;var u=n[a];i=u>0?i.mixedAdd(r[u-1>>1]):i.mixedAdd(r[-u-1>>1].neg())}return s.fromECJPoint(i)},s.prototype._getNAFPoints1=function(){return{wnd:1,points:[this]}},s.prototype._getNAFPoints=function(e){var t=new Array((1<>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,r){var n;function i(e){this.rand=e}if(e.exports=function(e){return n||(n=new i(null)),n.generate(e)},e.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(13),i=r(46),o=r(197),s=r(17),a=n.sum32,c=n.sum32_4,u=n.sum32_5,f=o.ch32,h=o.maj32,l=o.s0_256,d=o.s1_256,p=o.g0_256,y=o.g1_256,b=i.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function m(){if(!(this instanceof m))return new m;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}n.inherits(m,b),e.exports=m,m.blockSize=512,m.outSize=256,m.hmacStrength=192,m.padLength=64,m.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.maxAge)||(this.remove(e),this.emit("evict",{key:e,value:t.value}),!1)},o.prototype.get=function(e){if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){var t=this.cache[e];if(this._checkAge(e,t))return this.head!==e&&(e===this.tail?(this.tail=t.next,this.cache[this.tail].prev=null):this.cache[t.prev].next=t.next,this.cache[t.next].prev=t.prev,this.cache[this.head].next=e,t.prev=this.head,t.next=null,this.head=e),t.value}},o.prototype.evict=function(){if(this.tail){var e=this.tail,t=this.remove(this.tail);this.emit("evict",{key:e,value:t})}}},function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=r(0),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";e.exports=class{async getId(e){}async signIdentity(e,t){}static async verifyIdentity(e){}static get type(){throw new Error("'static get type ()' needs to be defined in the inheriting class")}get type(){return this.constructor.type}}},function(e,t,r){(function(t){var n=r(7).EventEmitter,i=r(40).inherits,o=r(9),s=r(517),a=r(520),c=r(529),u=r(97),f=r(94),h=r(136),l=r(213),d=r(56).getCallback,p=r(56).getOptions,y=u.WriteError,b=u.ReadError,g=u.NotFoundError,m=u.OpenError,v=u.InitializationError;function w(e,r,i){if(!(this instanceof w))return new w(e,r,i);var o,a=this;if(n.call(this),this.setMaxListeners(1/0),"function"==typeof r&&(i=r,r={}),r=r||{},!e||"object"!=typeof e){if(o=new v("First argument must be an abstract-leveldown compliant store"),"function"==typeof i)return t.nextTick(i,o);throw o}h.strictEqual(typeof e.status,"string",".status required, old abstract-leveldown"),this.options=p(r),this._db=e,this.db=new s(e),this.open(i||function(e){e&&a.emit("error",e)}),this.supports=f(this.db.supports,{status:!1,deferredOpen:!0,openCallback:!0,promises:!0,streams:!0}),Object.keys(this.supports.additionalMethods).forEach((function(e){null==this[e]&&(this[e]=function(){return this.db[e].apply(this.db,arguments)})}),this)}function _(e,r){if(!e._isOpening()&&!e.isOpen())return t.nextTick(r,new b("Database is not open")),!0}w.prototype.emit=n.prototype.emit,w.prototype.once=n.prototype.once,i(w,n),w.prototype.open=function(e,r){var n,i=this;return"function"==typeof e&&(r=e,e=null),r||(n=(r=l()).promise),e||(e=this.options),this.isOpen()?(t.nextTick(r,null,i),n):this._isOpening()?(this.once("open",(function(){r(null,i)})),n):(this.emit("opening"),this.db.open(e,(function(e){if(e)return r(new m(e));i.db=i._db,r(null,i),i.emit("open"),i.emit("ready")})),n)},w.prototype.close=function(e){var r,n=this;return e||(r=(e=l()).promise),this.isOpen()?(this.db.close((function(){n.emit("closed"),e.apply(null,arguments)})),this.emit("closing"),this.db=new s(this._db)):this.isClosed()?t.nextTick(e):"closing"===this.db.status?this.once("closed",e):this._isOpening()&&this.once("open",(function(){n.close(e)})),r},w.prototype.isOpen=function(){return"open"===this.db.status},w.prototype._isOpening=function(){return"opening"===this.db.status},w.prototype.isClosed=function(){return/^clos|new/.test(this.db.status)},w.prototype.get=function(e,t,r){var n;return(r=d(t,r))||(n=(r=l()).promise),_(this,r)||(t=p(t),this.db.get(e,t,(function(t,n){if(t)return t=/notfound/i.test(t)||t.notFound?new g("Key not found in database ["+e+"]",t):new b(t),r(t);r(null,n)}))),n},w.prototype.put=function(e,t,r,n){var i,o=this;return(n=d(r,n))||(i=(n=l()).promise),_(this,n)||(r=p(r),this.db.put(e,t,r,(function(r){if(r)return n(new y(r));o.emit("put",e,t),n()}))),i},w.prototype.del=function(e,t,r){var n,i=this;return(r=d(t,r))||(n=(r=l()).promise),_(this,r)||(t=p(t),this.db.del(e,t,(function(t){if(t)return r(new y(t));i.emit("del",e),r()}))),n},w.prototype.batch=function(e,t,r){if(!arguments.length)return new c(this);var n,i=this;return(r="function"==typeof e?e:d(t,r))||(n=(r=l()).promise),_(this,r)||(t=p(t),this.db.batch(e,t,(function(t){if(t)return r(new y(t));i.emit("batch",e),r()}))),n},w.prototype.iterator=function(e){return this.db.iterator(e)},w.prototype.clear=function(e,t){var r,n=this;return t=d(e,t),e=p(e),t||(r=(t=l()).promise),_(this,t)||this.db.clear(e,(function(r){if(r)return t(new y(r));n.emit("clear",e),t()})),r},w.prototype.readStream=w.prototype.createReadStream=function(e){return"number"!=typeof(e=o({keys:!0,values:!0},e)).limit&&(e.limit=-1),new a(this.db.iterator(e),e)},w.prototype.keyStream=w.prototype.createKeyStream=function(e){return this.createReadStream(o(e,{keys:!0,values:!1}))},w.prototype.valueStream=w.prototype.createValueStream=function(e){return this.createReadStream(o(e,{keys:!1,values:!0}))},w.prototype.toString=function(){return"LevelUP"},w.prototype.type="levelup",w.errors=u,e.exports=w.default=w}).call(this,r(2))},function(e,t,r){t.AbstractLevelDOWN=r(518),t.AbstractIterator=r(205),t.AbstractChainedBatch=r(206)},function(e,t,r){var n=r(95);function i(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._ended=!1,this._nexting=!1}i.prototype.next=function(e){var t=this;if("function"!=typeof e)throw new Error("next() requires a callback argument");return t._ended?(n(e,new Error("cannot call next() after end()")),t):t._nexting?(n(e,new Error("cannot call next() before previous next() has completed")),t):(t._nexting=!0,t._next((function(){t._nexting=!1,e.apply(null,arguments)})),t)},i.prototype._next=function(e){n(e)},i.prototype.seek=function(e){if(this._ended)throw new Error("cannot call seek() after end()");if(this._nexting)throw new Error("cannot call seek() before next() has completed");e=this.db._serializeKey(e),this._seek(e)},i.prototype._seek=function(e){},i.prototype.end=function(e){if("function"!=typeof e)throw new Error("end() requires a callback argument");if(this._ended)return n(e,new Error("end() already called on iterator"));this._ended=!0,this._end(e)},i.prototype._end=function(e){n(e)},i.prototype._nextTick=n,e.exports=i},function(e,t,r){var n=r(95);function i(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._operations=[],this._written=!1}i.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")},i.prototype.put=function(e,t){this._checkWritten();var r=this.db._checkKey(e)||this.db._checkValue(t);if(r)throw r;return e=this.db._serializeKey(e),t=this.db._serializeValue(t),this._put(e,t),this},i.prototype._put=function(e,t){this._operations.push({type:"put",key:e,value:t})},i.prototype.del=function(e){this._checkWritten();var t=this.db._checkKey(e);if(t)throw t;return e=this.db._serializeKey(e),this._del(e),this},i.prototype._del=function(e){this._operations.push({type:"del",key:e})},i.prototype.clear=function(){return this._checkWritten(),this._clear(),this},i.prototype._clear=function(){this._operations=[]},i.prototype.write=function(e,t){if(this._checkWritten(),"function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("write() requires a callback argument");"object"==typeof e&&null!==e||(e={}),this._written=!0,this._write(e,t)},i.prototype._write=function(e,t){this.db._batch(this._operations,e,t)},i.prototype._nextTick=n,e.exports=i},function(e,t,r){"use strict";(function(t,n){var i;e.exports=A,A.ReadableState=k;r(7).EventEmitter;var o=function(e,t){return e.listeners(t).length},s=r(208),a=r(0).Buffer,c=t.Uint8Array||function(){};var u,f=r(522);u=f&&f.debuglog?f.debuglog("stream"):function(){};var h,l,d,p=r(523),y=r(209),b=r(210).getHighWaterMark,g=r(35).codes,m=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,w=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(1)(A,s);var S=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function k(e,t,n){i=i||r(36),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=b(this,e,"readableHighWaterMark",n),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(15).StringDecoder),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function A(e){if(i=i||r(36),!(this instanceof A))return new A(e);var t=this instanceof i;this._readableState=new k(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function C(e,t,r,n,i){u("readableAddChunk",t);var o,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?x(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,B(e)))}(e,s);else if(i||(o=function(e,t){var r;n=t,a.isBuffer(n)||n instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new m("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(s,t)),o)S(e,o);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n)s.endEmitted?S(e,new _):I(e,s,t,!0);else if(s.ended)S(e,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?I(e,s,t,!1):M(e,s)):I(e,s,t,!1)}else n||(s.reading=!1,M(e,s));return!s.ended&&(s.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(B,e))}function B(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){u("readable nexttick read 0"),e.read(0)}function L(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),P(e),t.flowing&&!t.reading&&e.read(0)}function P(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function U(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function D(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function K(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?D(this):x(this),null;if(0===(e=T(e,t))&&t.ended)return 0===t.length&&D(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?U(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&D(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){S(this,new w("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:b;function a(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",y),e.removeListener("drain",f),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",b),r.removeListener("data",l),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function c(){u("onend"),e.end()}i.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var f=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,P(e))}}(r);e.on("drain",f);var h=!1;function l(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==K(i.pipes,e))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),b(),e.removeListener("error",d),0===o(e,"error")&&S(e,t)}function p(){e.removeListener("finish",y),b()}function y(){u("onfinish"),e.removeListener("close",p),b()}function b(){u("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",y),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?x(this):i.reading||n.nextTick(O,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(N,this),r},A.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(N,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(L,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new y("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,M(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=h.destroy,A.prototype._undestroy=h.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(6),r(2))},function(e,t,r){"use strict";e.exports=f;var n=r(35).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(36);function u(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{this._directConnections[e].close(),delete this._directConnections[e]}),this._pubsub&&await this._pubsub.disconnect(),await this.keystore.close();const e=Object.values(this.stores);for(const t of e)await t.close(),delete this.stores[t.address.toString()];const t=Object.keys(this.caches);for(const e of t)await this.caches[e].cache.close(),delete this.caches[e];this.stores={}}async stop(){await this.disconnect()}async _createCache(e){const t=await this.storage.createStore(e);return new h(t)}async _createStore(e,t,r){const n=k[e];if(!n)throw new Error(`Invalid database type '${e}'`);let i;r.accessControllerAddress&&(i=await p.resolve(this,r.accessControllerAddress,r.accessController));const o=Object.assign({replicate:!0},r,{accessController:i,cache:r.cache,onClose:this._onClose.bind(this),onDrop:this._onDrop.bind(this),onLoad:this._onLoad.bind(this)}),s=r.identity||this.identity,a=new n(this._ipfs,s,t,o);a.events.on("write",this._onWrite.bind(this));const c=t.toString();return this.stores[c]=a,o.replicate&&this._pubsub&&await this._pubsub.subscribe(c,this._onMessage.bind(this),this._onPeerConnected.bind(this)),a}_onWrite(e,t,r){if(!r)throw new Error("'heads' not defined");this._pubsub&&this._pubsub.publish(e,r)}async _onMessage(e,t,r){const n=this.stores[e];try{E.debug(`Received ${t.length} heads for '${e}':\n`,JSON.stringify(t.map(e=>e.hash),null,2)),n&&t&&(t.length>0&&await n.sync(t),n.events.emit("peer.exchanged",r,e,t))}catch(e){E.error(e)}}async _onPeerConnected(e,t){E.debug(`New peer '${t}' connected to '${e}'`);const r=e=>this.stores[e];await g(this._ipfs,e,t,r,e=>this._directConnections[e],(e,r)=>this._onMessage(e,r,t),e=>{this._directConnections[e._receiverID]=e}),r(e)&&r(e).events.emit("peer",t)}async _onClose(e){const t=e.address.toString();E.debug("Close "+t),this._pubsub&&await this._pubsub.unsubscribe(t);const r=e&&e.options.directory?e.options.directory:this.directory,n=this.caches[r];n&&n.handlers.has(t)&&(n.handlers.delete(t),n.handlers.size||await n.cache.close()),delete this.stores[t]}async _onDrop(e){const t=e.address.toString(),r=e&&e.options.directory?e.options.directory:this.directory;await this._requestCache(t,r,e._cache)}async _onLoad(e){const t=e.address.toString(),r=e&&e.options.directory?e.options.directory:this.directory;await this._requestCache(t,r,e._cache),this.stores[t]=e}async _determineAddress(e,t,r={}){if(!A.isValidType(t))throw new Error(`Invalid database type '${t}'`);if(y.isValid(e))throw new Error("Given database name is an address. Please give only the name of the database!");r.accessController=Object.assign({},{name:e,type:"ipfs"},r.accessController);const n=await p.create(this,r.accessController.type,r.accessController||{}),i=await b(this._ipfs,e,t,n,r);return y.parse(y.join(i,e))}async create(e,t,r={}){E.debug("create()"),E.debug(`Creating database '${e}' as ${t}`);const n=await this._determineAddress(e,t,r);r.cache=await this._requestCache(n.toString(),r.directory);if(await this._haveLocalData(r.cache,n)&&!r.overwrite)throw new Error(`Database '${n}' already exists!`);return await this._migrate(r,n),await this._addManifestToCache(r.cache,n),E.debug(`Created database '${n}'`),this.open(n,r)}async determineAddress(e,t,r={}){const n=Object.assign({},{onlyHash:!0},r);return this._determineAddress(e,t,n)}async _requestCache(e,t,r){const n=t||this.directory;if(!this.caches[n]){const e=r||await this._createCache(n);this.caches[n]={cache:e,handlers:new Set}}this.caches[n].handlers.add(e);const i=this.caches[n].cache;return i&&await i.open(),i}async open(e,t={}){if(E.debug("open()"),t=Object.assign({localOnly:!1,create:!1},t),E.debug(`Open database '${e}'`),!y.isValid(e)){if(t.create){if(t.create&&!t.type)throw new Error(`Database type not provided! Provide a type with 'options.type' (${A.databaseTypes.join("|")})`);return E.warn(`Not a valid OrbitDB address '${e}', creating the database`),t.overwrite=!t.overwrite||t.overwrite,this.create(e,t.type,t)}throw new Error("'options.create' set to 'false'. If you want to create a database, set 'options.create' to 'true'.")}const r=y.parse(e);t.cache=await this._requestCache(r.toString(),t.directory);const n=await this._haveLocalData(t.cache,r);if(E.debug((n?"Found":"Didn't find")+` database '${r}'`),t.localOnly&&!n)throw E.warn(`Database '${r}' doesn't exist!`),new Error(`Database '${r}' doesn't exist!`);let i;E.debug(`Loading Manifest for '${r}'`);try{i=await v.read(this._ipfs,r.root,{timeout:t.timeout||3e4}),E.debug(`Manifest for '${r}':\n${JSON.stringify(i,null,2)}`)}catch(e){throw"TimeoutError"===e.name&&"ERR_TIMEOUT"===e.code?(console.error(e),new Error("ipfs unable to find and fetch manifest for this address.")):e}if(i.name!==r.path&&E.warn(`Manifest name '${i.name}' and path name '${r.path}' do not match`),t.type&&i.type!==t.type)throw new Error(`Database '${r}' is type '${i.type}' but was opened as '${t.type}'`);return await this._addManifestToCache(t.cache,r),t=Object.assign({},t,{accessControllerAddress:i.accessController,meta:i.meta}),this._createStore(t.type||i.type,r,t)}async _addManifestToCache(e,t){await e.set(n.join(t.toString(),"_manifest"),t.root),E.debug(`Saved manifest to IPFS as '${t.root}'`)}async _haveLocalData(e,t){if(!e)return!1;const r=t.toString(),i=await e.get(n.join(r,"_manifest"));return null!=i}async _migrate(e,t){await _.run(this,e,t)}static get databaseTypes(){return Object.keys(k)}static isValidType(e){return Object.keys(k).includes(e)}static addDatabaseType(e,t){if(k[e])throw new Error("Type already exists: "+e);k[e]=t}static getDatabaseTypes(){return k}static isValidAddress(e){return y.isValid(e)}static parseAddress(e){return y.parse(e)}}A.prototype.AccessControllers=p,A.prototype.Identities=d,A.prototype.Keystore=l,e.exports=A},function(e,t,r){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=u(e),s=n[0],a=n[1],c=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,c[f++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var i,o,s=[],a=t;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,u-=8);e[r+d-p]|=128*y}},function(e,t,r){"use strict";const n=async(e,t)=>{let r=0;for(const i of e){if(await t(await i,r++)===n.stop)break}return e};n.stop=Symbol("pEachSeries.stop"),e.exports=n,e.exports.default=n},function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,i="~";function o(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,n,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,n||e,o),c=i?i+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function c(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function u(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,o=r.length,s=new Array(o);nnew Promise((o,s)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void o(e);const a=setTimeout(()=>{if("function"==typeof r){try{o(r())}catch(e){s(e)}return}const n=r instanceof Error?r:new i("string"==typeof r?r:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),s(n)},t);n(e.then(o,s),()=>{clearTimeout(a)})});e.exports=o,e.exports.default=o,e.exports.TimeoutError=i},function(e,t,r){"use strict";e.exports=(e,t)=>(t=t||(()=>{}),e.then(e=>new Promise(e=>{e(t())}).then(()=>e),e=>new Promise(e=>{e(t())}).then(()=>{throw e})))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(229);t.default=class{constructor(){this._queue=[]}enqueue(e,t){const r={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(r);const i=n.default(this._queue,r,(e,t)=>t.priority-e.priority);this._queue.splice(i,0,r)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this._queue.length}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let n=0,i=e.length;for(;i>0;){const o=i/2|0;let s=n+o;r(e[s],t)<=0?(n=++s,i-=o+1):i=o}return n}},function(e,t,r){"use strict";const n=r(231),i=r(232);class o extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError("Expected input to be an Array, got "+typeof e);let t=(e=[...e].map(e=>e instanceof Error?e:null!==e&&"object"==typeof e?Object.assign(new Error(e.message),e):new Error(e))).map(e=>"string"==typeof e.stack?i(e.stack).replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""):String(e)).join("\n");t="\n"+n(t,4),super(t),this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(const e of this._errors)yield e}}e.exports=o},function(e,t,r){"use strict";e.exports=(e,t=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},"string"!=typeof e)throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if("number"!=typeof t)throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if("string"!=typeof r.indent)throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(0===t)return e;const n=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return e.replace(n,r.indent.repeat(t))}},function(e,t,r){"use strict";const n=r(233),i=/\s+at.*(?:\(|\s)(.*)\)?/,o=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,s=void 0===n.homedir?"":n.homedir();e.exports=(e,t)=>(t=Object.assign({pretty:!1},t),e.replace(/\\/g,"/").split("\n").filter(e=>{const t=e.match(i);if(null===t||!t[1])return!0;const r=t[1];return!r.includes(".app/Contents/Resources/electron.asar")&&!r.includes(".app/Contents/Resources/default_app.asar")&&!o.test(r)}).filter(e=>""!==e.trim()).map(e=>t.pretty?e.replace(i,(e,t)=>e.replace(t,t.replace(s,"~"))):e).join("\n"))},function(e,t){},function(e,t,r){"use strict";e.exports=class{constructor(e){}append(e){}merge(e){}get(e){}has(e){}get values(){}get length(){}}},function(e,t,r){"use strict";e.exports=function(e,t,r){const n={},i={};return e.forEach(e=>i[r?e[r]:e]=!0),t.reduce((e,t)=>{const o=void 0!==i[r?t[r]:t],s=void 0!==n[r?t[r]:t];return o||s||(e.push(t),n[r?t[r]:t]=!0),e},[])}},function(e,t,r){"use strict";e.exports=function(e,t){const r={};return e.forEach(e=>r[t?e[t]:e]=e),Object.keys(r).map(e=>r[e])}},function(e,t,r){"use strict";e.exports=e=>null!=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(239);var n=r(19),i=r(38);const o=({enumerable:e=!0,configurable:t=!1}={})=>({enumerable:e,configurable:t,writable:!1}),s=function*(e,t){if(null!=e&&!(e instanceof Uint8Array))for(const[r,i]of Object.entries(e)){const e=[...t,r];if(null!=i&&"object"==typeof i)if(Array.isArray(i))for(const[t,r]of i.entries()){const i=[...e,t],o=n.CID.asCID(r);o?yield[i.join("/"),o]:"object"==typeof r&&(yield*s(r,i))}else{const t=n.CID.asCID(i);t?yield[e.join("/"),t]:yield*s(i,e)}}},a=function*(e,t){if(null!=e)for(const[r,i]of Object.entries(e)){const e=[...t,r];if(yield e.join("/"),!(null==i||i instanceof Uint8Array||"object"!=typeof i||n.CID.asCID(i)))if(Array.isArray(i))for(const[t,r]of i.entries()){const i=[...e,t];yield i.join("/"),"object"!=typeof r||n.CID.asCID(r)||(yield*a(r,i))}else yield*a(i,e)}};class c{constructor({cid:e,bytes:t,value:r}){if(!e||!t||void 0===r)throw new Error("Missing required argument");this.cid=e,this.bytes=t,this.value=r,this.asBlock=this,Object.defineProperties(this,{cid:o(),bytes:o(),value:o(),asBlock:o()})}links(){return s(this.value,[])}tree(){return a(this.value,[])}get(e="/"){return((e,t)=>{let r=e;for(const[e,i]of t.entries()){if(r=r[i],null==r)throw new Error("Object has no property at "+t.slice(0,e+1).map(e=>`[${JSON.stringify(e)}]`).join(""));const o=n.CID.asCID(r);if(o)return{value:o,remaining:t.slice(e+1).join("/")}}return{value:r}})(this.value,e.split("/").filter(Boolean))}}const u=({bytes:e,cid:t,value:r,codec:n})=>{const i=void 0!==r?r:n&&n.decode(e);if(void 0===i)throw new Error('Missing required argument, must either provide "value" or "codec"');return new c({cid:t,bytes:e,value:i})};t.Block=c,t.create=async({bytes:e,cid:t,hasher:r,codec:n})=>{if(!e)throw new Error('Missing required argument "bytes"');if(!r)throw new Error('Missing required argument "hasher"');const o=n.decode(e),s=await r.digest(e);if(!i.equals(t.multihash.bytes,s.bytes))throw new Error("CID hash does not match bytes");return u({bytes:e,cid:t,value:o,codec:n})},t.createUnsafe=u,t.decode=async({bytes:e,codec:t,hasher:r})=>{if(!e)throw new Error('Missing required argument "bytes"');if(!t||!r)throw new Error("Missing required argument: codec or hasher");const i=t.decode(e),o=await r.digest(e),s=n.CID.create(1,t.code,o);return new c({value:i,bytes:e,cid:s})},t.encode=async({value:e,codec:t,hasher:r})=>{if(void 0===e)throw new Error('Missing required argument "value"');if(!t||!r)throw new Error("Missing required argument: codec or hasher");const i=t.encode(e),o=await r.digest(i),s=n.CID.create(1,t.code,o);return new c({value:e,bytes:i,cid:s})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(19),i=r(60),o=r(38),s=r(106),a=r(61);t.CID=n.CID,t.varint=i,t.bytes=o,t.hasher=s,t.digest=a},function(e,t,r){"use strict";var n=function e(t,r,n){r=r||[];var o=n=n||0;for(;t>=i;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},i=Math.pow(2,31);var o=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i};var s=Math.pow(2,7),a=Math.pow(2,14),c=Math.pow(2,21),u=Math.pow(2,28),f=Math.pow(2,35),h=Math.pow(2,42),l=Math.pow(2,49),d=Math.pow(2,56),p=Math.pow(2,63),y={encode:n,decode:o,encodingLength:function(e){return e=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(o);e[t];){var f=r[e.charCodeAt(t)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h>>0,s[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var d=o-i;d!==o&&0===s[d];)d++;for(var p=new Uint8Array(n+(o-d)),y=n;d!==o;)p[y++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var s=(o-i)*f+1>>>0,u=new Uint8Array(s);i!==o;){for(var h=t[i],l=0,d=s-1;(0!==h||l>>0,u[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=l,i++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var y=c.repeat(r);p{const t={};try{t.Hash=n.CID.decode(e.Hash)}catch(e){}if(!t.Hash)throw new Error("Invalid Hash field found in link, expected CID");return void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t})),r},t.encode=function(e){s.validate(e);const t={};return e.Links&&(t.Links=e.Links.map(e=>{const t={};return e.Hash&&(t.Hash=e.Hash.bytes),void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t})),e.Data&&(t.Data=e.Data),o.encodeNode(t)},t.name="dag-pb"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=new TextDecoder;function i(e,t){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=e.length)throw new Error("protobuf: unexpected end of data");const i=e[t++];if(r+=n<28?(127&i)<e.length)throw new Error("protobuf: unexpected end of data");return[e.subarray(t,n),n]}function s(e,t){let r;return[r,t]=i(e,t),[7&r,r>>3,t]}function a(e){const t={},r=e.length;let a=0;for(;ar)throw new Error("protobuf: (PBLink) unexpected end of data");return t}t.decodeNode=function(e){const t=e.length;let r,n,i=0,c=!1;for(;it)throw new Error("protobuf: (PBNode) unexpected end of data");const u={};return n&&(u.Data=n),u.Links=r||[],u}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=new TextEncoder;function i(e,t){let r=t.length;if("number"==typeof e.Tsize){if(e.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(e.Tsize))throw new Error("Tsize too large for encoding");r=s(t,r,e.Tsize)-1,t[r]=24}if("string"==typeof e.Name){const i=n.encode(e.Name);r-=i.length,t.set(i,r),r=s(t,r,i.length)-1,t[r]=18}return e.Hash&&(r-=e.Hash.length,t.set(e.Hash,r),r=s(t,r,e.Hash.length)-1,t[r]=10),t.length-r}function o(e){let t=0;if(e.Hash){const r=e.Hash.length;t+=1+r+a(r)}if("string"==typeof e.Name){const r=n.encode(e.Name).length;t+=1+r+a(r)}return"number"==typeof e.Tsize&&(t+=1+a(e.Tsize)),t}function s(e,t,r){const n=t-=a(r);for(;r>=2**31;)e[t++]=127&r|128,r/=128;for(;r>=128;)e[t++]=127&r|128,r>>>=7;return e[t]=r,n}function a(e){return e%2==0&&e++,Math.floor((function(e){let t=0;e>=2**32&&(e=Math.floor(e/2**32),t=32);e>=65536&&(e>>>=16,t+=16);e>=256&&(e>>>=8,t+=8);return t+c[e]}(e)+6)/7)}const c=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];t.encodeNode=function(e){const t=function(e){let t=0;if(e.Data){const r=e.Data.length;t+=1+r+a(r)}if(e.Links)for(const r of e.Links){const e=o(r);t+=1+e+a(e)}return t}(e),r=new Uint8Array(t);let n=t;if(e.Data&&(n-=e.Data.length,r.set(e.Data,n),n=s(r,n,e.Data.length)-1,r[n]=10),e.Links)for(let t=e.Links.length-1;t>=0;t--){const o=i(e.Links[t],r.subarray(0,n));n-=o,n=s(r,n,o)-1,r[n]=18}return r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(19);const i=["Data","Links"],o=["Hash","Name","Tsize"],s=new TextEncoder;function a(e,t){if(e===t)return 0;const r=e.Name?s.encode(e.Name):[],n=t.Name?s.encode(t.Name):[];let i=r.length,o=n.length;for(let e=0,t=Math.min(i,o);e!t.includes(e))}function u(e){if("object"==typeof e.asCID){const t=n.CID.asCID(e);if(!t)throw new TypeError("Invalid DAG-PB form");return{Hash:t}}if("object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");const t={};if(e.Hash){let r=n.CID.asCID(e.Hash);try{r||("string"==typeof e.Hash?r=n.CID.parse(e.Hash):e.Hash instanceof Uint8Array&&(r=n.CID.decode(e.Hash)))}catch(e){throw new TypeError("Invalid DAG-PB form: "+e.message)}r&&(t.Hash=r)}if(!t.Hash)throw new TypeError("Invalid DAG-PB form");return"string"==typeof e.Name&&(t.Name=e.Name),"number"==typeof e.Tsize&&(t.Tsize=e.Tsize),t}function f(e){if((e instanceof Uint8Array||"string"==typeof e)&&(e={Data:e}),"object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");const t={};if(void 0!==e.Data)if("string"==typeof e.Data)t.Data=s.encode(e.Data);else{if(!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form");t.Data=e.Data}if(void 0!==e.Links){if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form");t.Links=e.Links.map(u),t.Links.sort(a)}else t.Links=[];return t}t.createLink=function(e,t,r){return u({Hash:r,Name:e,Tsize:t})},t.createNode=function(e,t=[]){return f({Data:e,Links:t})},t.prepare=f,t.validate=function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");if(!c(e,i))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(void 0!==e.Data&&!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be a Uint8Array)");if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form (Links must be an array)");for(let t=0;t0&&-1===a(r,e.Links[t-1]))throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(248),i=r(19);function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=o(n);const a={float64:!0,typeEncoders:{Object:function(e){if(e.asCID!==e)return null;const t=i.CID.asCID(e);if(!t)return null;const r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new s.Token(s.Type.tag,42),new s.Token(s.Type.bytes,r)]},undefined:function(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")},number:function(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}}};const c={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};c.tags[42]=function(e){if(0!==e[0])throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return i.CID.decode(e.subarray(1))};t.code=113,t.decode=e=>s.decode(e,c),t.encode=e=>s.encode(e,a),t.name="dag-cbor"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(249),i=r(252),o=r(8);t.encode=n.encode,t.decode=i.decode,t.Token=o.Token,t.Type=o.Type},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(250),i=r(8),o=r(251),s=r(12),a=r(107),c=r(39),u=r(14),f=r(108),h=r(62),l=r(109),d=r(110),p=r(111),y=r(112),b=r(113);const g={float64:!1,mapSorter:function(e,t){const r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);const i=r.type.major,o=m[i].compareTokens(r,n);0===o&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone");return o},quickEncodeToken:a.quickEncodeToken},m=[];m[i.Type.uint.major]=u.encodeUint,m[i.Type.negint.major]=f.encodeNegint,m[i.Type.bytes.major]=h.encodeBytes,m[i.Type.string.major]=l.encodeString,m[i.Type.array.major]=d.encodeArray,m[i.Type.map.major]=p.encodeMap,m[i.Type.tag.major]=y.encodeTag,m[i.Type.float.major]=b.encodeFloat;const v=new o.Bl;class w{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(s.encodeErrPrefix+" object contains circular references");return new w(t,e)}}const _={null:new i.Token(i.Type.null,null),undefined:new i.Token(i.Type.undefined,void 0),true:new i.Token(i.Type.true,!0),false:new i.Token(i.Type.false,!1),emptyArray:new i.Token(i.Type.array,0),emptyMap:new i.Token(i.Type.map,0)},S={number:(e,t,r,n)=>Number.isInteger(e)&&Number.isSafeInteger(e)?e>=0?new i.Token(i.Type.uint,e):new i.Token(i.Type.negint,e):new i.Token(i.Type.float,e),bigint:(e,t,r,n)=>e>=BigInt(0)?new i.Token(i.Type.uint,e):new i.Token(i.Type.negint,e),Uint8Array:(e,t,r,n)=>new i.Token(i.Type.bytes,e),string:(e,t,r,n)=>new i.Token(i.Type.string,e),boolean:(e,t,r,n)=>e?_.true:_.false,null:(e,t,r,n)=>_.null,undefined:(e,t,r,n)=>_.undefined,ArrayBuffer:(e,t,r,n)=>new i.Token(i.Type.bytes,new Uint8Array(e)),DataView:(e,t,r,n)=>new i.Token(i.Type.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,r,n){if(!e.length)return!0===r.addBreakTokens?[_.emptyArray,new i.Token(i.Type.break)]:_.emptyArray;n=w.createCheck(n,e);const o=[];let s=0;for(const t of e)o[s++]=E(t,r,n);return r.addBreakTokens?[new i.Token(i.Type.array,e.length),o,new i.Token(i.Type.break)]:[new i.Token(i.Type.array,e.length),o]},Object(e,t,r,n){const o="Object"!==t,s=o?e.keys():Object.keys(e),a=o?e.size:s.length;if(!a)return!0===r.addBreakTokens?[_.emptyMap,new i.Token(i.Type.break)]:_.emptyMap;n=w.createCheck(n,e);const c=[];let u=0;for(const t of s)c[u++]=[E(t,r,n),E(o?e.get(t):e[t],r,n)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(c,r),r.addBreakTokens?[new i.Token(i.Type.map,a),c,new i.Token(i.Type.break)]:[new i.Token(i.Type.map,a),c]}};S.Map=S.Object,S.Buffer=S.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))S[e+"Array"]=S.DataView;function E(e,t={},r){const i=n.is(e),o=t&&t.typeEncoders&&t.typeEncoders[i]||S[i];if("function"==typeof o){const n=o(e,i,t,r);if(null!=n)return n}const a=S[i];if(!a)throw new Error(`${s.encodeErrPrefix} unsupported type: ${i}`);return a(e,i,t,r)}function k(e,t,r){const n=E(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){const e=r.quickEncodeToken(n);if(e)return e;const i=t[n.type.major];if(i.encodedSize){const e=i.encodedSize(n,r),t=new o.Bl(e);if(i(t,n,r),1!==t.chunks.length)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return c.asU8A(t.chunks[0])}}return function e(t,r,n,i){if(Array.isArray(r))for(const o of r)e(t,o,n,i);else n[r.type.major](t,r,i)}(v,n,t,r),v.toBytes(!0)}t.Ref=w,t.encode=function(e,t){return t=Object.assign({},g,t),k(e,m,t)},t.encodeCustom=k,t.objectToTokens=E},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=["string","number","bigint","symbol"],i=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];t.is=function(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(n.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const r=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(i.includes(t))return t;return}(e);return r||"Object"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(39);t.Bl=class{constructor(e=256){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.chunks=[],this.cursor=0,this.maxCursor=-1,null!==this._initReuseChunk&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){const r=t.length-(this.maxCursor-this.cursor)-1;t.set(e,r)}else{if(t){const e=t.length-(this.maxCursor-this.cursor)-1;er.length/2?(t=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=n.slice(r,0,this.cursor)}else t=n.concat(this.chunks,this.cursor);return e&&this.reset(),t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(12),i=r(8),o=r(107);const s={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class a{constructor(e,t={}){this.pos=0,this.data=e,this.options=t}done(){return this.pos>=this.data.length}next(){const e=this.data[this.pos];let t=o.quick[e];if(void 0===t){const r=o.jump[e];if(!r)throw new Error(`${n.decodeErrPrefix} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const i=31&e;t=r(this.data,this.pos,i,this.options)}return this.pos+=t.encodedLength,t}}const c=Symbol.for("DONE"),u=Symbol.for("BREAK");function f(e,t){if(e.done())return c;const r=e.next();if(r.type===i.Type.break)return u;if(r.type.terminal)return r.value;if(r.type===i.Type.array)return function(e,t,r){const i=[];for(let o=0;oasync t=>new Uint8Array(await crypto.subtle.digest(e,t)),o=n.from({name:"sha2-256",code:18,encode:i("SHA-256")}),s=n.from({name:"sha2-512",code:19,encode:i("SHA-512")});t.sha256=o,t.sha512=s},function(e,t,r){"use strict";const n=r(255),i=r(20).isFunction,o=r(20).isBoolean,s=r(20).isObject,a=r(20).isArray,c=r(20).isRegex,u=r(20).assign,f=r(20).keys;e.exports=function(e,t){t=t||u({},n),i(t)&&(t={compare:t});const r=t.space||n.space,h=o(t.cycles)?t.cycles:n.cycles,l=t.replacer||n.replacer,d=t.stringify||n.stringify,p=t.compare&&(y=t.compare,function(e){return function(t,r){const n={key:t,value:e[t]},i={key:r,value:e[r]};return y(n,i)}});var y;h||d(e);const b=[];return function e(t,n,i,o){const u=r?"\n"+new Array(o+1).join(r):"",y=r?": ":":";if(i=function(e){return null==e?e:c(e)?e.toString():e.toJSON?e.toJSON():e}(i),void 0!==(i=l.call(t,n,i))){if(!s(i)||null===i)return d(i);if(a(i)){const t=[];for(let n=0;nt,stringify:JSON.stringify}},function(e,t,r){"use strict";const n=r(57),i=r(257),o=r(114),{LastWriteWins:s,NoZeroes:a}=o,c=r(115),{isDefined:u,findUniques:f,difference:h,io:l}=r(59),d=["heads"],p=(e,t)=>e.slice(e.length-Math.min(e.length,t),e.length);e.exports=class{static async toMultihash(e,t,{format:r}={}){if(!u(e))throw c.IPFSNotDefinedError();if(!u(t))throw c.LogNotDefinedError();if(u(r)||(r="dag-cbor"),t.values.length<1)throw new Error("Can't serialize an empty log");return l.write(e,r,t.toJSON(),{links:d})}static async fromMultihash(e,t,{length:r=-1,exclude:n=[],shouldExclude:o,timeout:f,concurrency:h,sortFn:y,onProgressCallback:b}){if(!u(e))throw c.IPFSNotDefinedError();if(!u(t))throw new Error("Invalid hash: "+t);const g=await l.read(e,t,{links:d});if(!g.heads||!g.id)throw c.NotALogError();y=y||a(s);const m=await i.fetchAll(e,g.heads,{length:r,exclude:n,shouldExclude:o,timeout:f,concurrency:h,onProgressCallback:b}),v=g.id,w=r>-1?p(m.sort(y),r):m,_=w.filter(e=>g.heads.includes(e.hash));return{logId:v,entries:w,heads:_}}static async fromEntryHash(e,t,{length:r=-1,exclude:n=[],shouldExclude:o,timeout:f,concurrency:h,sortFn:l,onProgressCallback:d}){if(!u(e))throw c.IpfsNotDefinedError();if(!u(t))throw new Error("'hash' must be defined");const y=Array.isArray(t)?t:[t];r=r>-1?Math.max(r,1):r;const b=await i.fetchParallel(e,y,{length:r,exclude:n,shouldExclude:o,timeout:f,concurrency:h,onProgressCallback:d});l=l||a(s);return{entries:r>-1?p(b.sort(l),r):b}}static async fromJSON(e,t,{length:r=-1,timeout:o,concurrency:s,onProgressCallback:a}){if(!u(e))throw c.IPFSNotDefinedError();const{id:f,heads:h}=t,l=h.map(e=>e.hash);return{logId:f,entries:(await i.fetchParallel(e,l,{length:r,timeout:o,concurrency:s,onProgressCallback:a})).sort(n.compare),heads:h}}static async fromEntry(e,t,{length:r=-1,exclude:o=[],shouldExclude:s,timeout:a,concurrency:l,onProgressCallback:d}){if(!u(e))throw c.IPFSNotDefinedError();if(!u(t))throw new Error("'sourceEntries' must be defined");if(!Array.isArray(t)&&!n.isEntry(t))throw new Error("'sourceEntries' argument must be an array of Entry instances or a single Entry");Array.isArray(t)||(t=[t]),r=r>-1?Math.max(r,t.length):r;const p=t.map(e=>e.hash),y=await i.fetchParallel(e,p,{length:r,exclude:o,shouldExclude:s,timeout:a,concurrency:l,onProgressCallback:d}),b=t.concat(y).concat(o),g=f(b,"hash").sort(n.compare),m=g.slice(r>-1?-r:-g.length),v=((e,t)=>{const r=e.slice(t.length,e.length);return t.concat(r)})(m,h(m,t,"hash"));return{logId:v[v.length-1].id,entries:v}}}},function(e,t,r){"use strict";const n=r(103),i=r(258),o=r(57),s=e=>e&&e.length>0;class a{static async fetchParallel(e,t,{length:r,exclude:i=[],shouldExclude:o,timeout:s,concurrency:c,onProgressCallback:u}){const f=(e,t)=>e.concat(t),h=await n(t,async t=>a.fetchAll(e,t,{length:r,exclude:i,shouldExclude:o,timeout:s,onProgressCallback:u,concurrency:c}),{concurrency:Math.max(c||t.length,1)});return h.reduce(f,[])}static async fetchAll(e,t,{length:r=-1,exclude:a=[],shouldExclude:c,timeout:u,onProgressCallback:f,onStartProgressCallback:h,concurrency:l=32,delay:d=0}={}){const p=[],y={},b={},g=Array.isArray(t)?{0:t.slice()}:{0:[t]};let m=0,v=0,w=0;c=c||(()=>!1);const _=(e,t)=>{b[e]||c(e)||(g[t]||(g[t]=[]),g[t].includes(e)||g[t].push(e),b[e]=!0)},S=async t=>{if(t&&!y[t]&&!c(t))return new Promise(async(n,i)=>{const s=u&&u>0?setTimeout(()=>{console.warn(`Warning: Couldn't fetch entry '${t}', request timed out (${u}ms)`),n()},u):null;h&&h(t,null,0,p.length);try{const i=await o.fromMultihash(e,t);if(d>0){const e=(e=0)=>new Promise(t=>setTimeout(t,e));await e(d)}(e=>{if(o.isEntry(e)&&!y[e.hash]&&!c(e.hash)){const t=e.clock.time;v=Math.max(v,t),w=p.length>0?Math.min(p[p.length-1].clock.time,w):v;const n=p.length>=r&&t>=w,i=e=>v-t+(e+1)*e;!(r<0||p.lengthw||t===w&&!y[e.hash]&&!c(e.hash))&&e.next.forEach(e=>_(e,i(0))),e.refs&&p.length+e.refs.length<=r&&e.refs.forEach((e,t)=>_(e,i(t))))}})(i),n()}catch(e){i(e)}finally{clearTimeout(s)}})};return a.forEach(e=>{y[e.hash||e]=!0}),await i(async()=>{if(mObject.keys(g).reduce((t,r,n)=>{const i=g[r];for(;i.length>0&&t.lengthvoid 0!==Object.values(g).find(s)),p}}e.exports=a},function(e,t,r){"use strict";const n=async(e,t)=>{if(t(await e()))return n(e,t)};e.exports=n,e.exports.default=n},function(e,t,r){"use strict";e.exports=class{async canAppend(e,t){return!0}}},function(e,t,r){"use strict";e.exports=class{constructor(e={}){this._cache=e}set(e,t){this._cache[e]=t}get(e){return this._cache[e]}delete(e){return delete this._cache[e]}add(e){this._cache=Object.assign(this._cache,e)}get length(){return Object.values(this._cache).length}}},function(e,t,r){"use strict";e.exports=class{constructor(e){this.id=e,this._index=[]}get(){return this._index}async updateIndex(e,t){this._index=e.values}}},function(e,t,r){const n=r(101).default,i=r(102),o=e=>[...new Set([...e.next,...e.refs])],s=(e,t)=>e.concat(t);e.exports=class{constructor(e,t){this._store=e,this._concurrency=t||32,this._q=new n({concurrency:this._concurrency}),this._logs=[],this._fetching={},this._fetched={},this._q.on("idle",async()=>{const e=this._logs.slice();if(this._logs=[],this.onReplicationComplete&&e.length>0&&this._store._oplog)try{await this.onReplicationComplete(e),e.forEach(e=>e.values.forEach(e=>delete this._fetched[e.hash]))}catch(e){console.error(e)}})}get tasksRunning(){return this._q.pending}get tasksQueued(){return this._q.size}get unfinished(){return Object.keys(this._fetching)}async load(e){try{this._addToQueue(e)}catch(e){console.error(e)}}async _addToQueue(e){const t=e=>e&&this._store._oplog&&(this._store._oplog.has(e)||void 0!==this._fetching[e]||this._fetched[e]),r=e=>(this._fetching[e.hash||e]=!0,async()=>{e.hash&&this.onReplicationQueued&&this.onReplicationQueued(e);try{const t=await this._replicateLog(e);this._logs.push(t)}catch(e){throw console.error(e),e}delete this._fetching[e.hash||e]});if(e.length>0){const n=e.filter(e=>!t(e.hash||e)).map(e=>r(e));n.length>0&&this._q.addAll(n)}}async stop(){this._q.pause(),this._q.clear(),await this._q.onIdle(),this._logs=[],this._fetching={},this._fetched={}}async _replicateLog(e){const t=e.hash||e,r=await i.fromEntryHash(this._store._ipfs,this._store.identity,t,{logId:this._store.id,access:this._store.access,length:-1,exclude:[],shouldExclude:e=>e&&e!==t&&this._store._oplog&&(this._store._oplog.has(e)||void 0!==this._fetching[e]||void 0!==this._fetched[e]),concurrency:this._concurrency,onProgressCallback:e=>{this._fetched[e.hash]=!0,this.onReplicationProgress&&this.onReplicationProgress(e)}}),n=r.values.map(o).reduce(s,[]);try{this._addToQueue(n)}catch(e){throw console.error(e),e}return r}}},function(e,t){e.exports=class{constructor(){this.progress=0,this.max=0}reset(){this.progress=0,this.max=0}}},function(e,t){e.exports={}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t,r){"use strict";e.exports=class{constructor(){this._index=null}get(){return this._index?this._index.values:[]}updateIndex(e){this._index=e}}},function(e,t,r){"use strict";const n=r(116),i=r(269);e.exports=class extends n{constructor(e,t,r,n){n||(n={}),n.Index||Object.assign(n,{Index:i}),super(e,t,r,n),this._type="feed"}remove(e,t={}){return this.del(e,t)}del(e,t={}){const r={op:"DEL",key:null,value:e};return this._addOperation(r,t)}}},function(e,t,r){"use strict";e.exports=class{constructor(){this._index={}}get(){return Object.keys(this._index).map(e=>this._index[e])}updateIndex(e){this._index={},e.values.reduce((e,t)=>(e.includes(t.hash)||(e.push(t.hash),"ADD"===t.payload.op?this._index[t.hash]=t:"DEL"===t.payload.op&&delete this._index[t.payload.value]),e),[])}}},function(e,t,r){"use strict";const n=r(37),i=r(271);e.exports=class extends n{constructor(e,t,r,n){let o=Object.assign({},{Index:i});Object.assign(o,n),super(e,t,r,o),this._type="keyvalue"}get all(){return this._index._index}get(e){return this._index.get(e)}set(e,t,r={}){return this.put(e,t,r)}put(e,t,r={}){return this._addOperation({op:"PUT",key:e,value:t},r)}del(e,t={}){return this._addOperation({op:"DEL",key:e,value:null},t)}}},function(e,t,r){"use strict";e.exports=class{constructor(){this._index={}}get(e){return this._index[e]}updateIndex(e){e.values.slice().reverse().reduce((e,t)=>(e.includes(t.payload.key)||(e.push(t.payload.key),"PUT"===t.payload.op?this._index[t.payload.key]=t.payload.value:"DEL"===t.payload.op&&delete this._index[t.payload.key]),e),[])}}},function(e,t,r){"use strict";const n=r(37),i=r(273),o=r(117);e.exports=class extends n{constructor(e,t,r,n={}){n.Index||Object.assign(n,{Index:i}),super(e,t,r,n),this._index=new this.options.Index(this.identity.publicKey),this._type="counter"}get value(){return this._index.get().value}inc(e,t={}){const r=new o(this.identity.publicKey,Object.assign({},this._index.get()._counters));return r.increment(e),this._addOperation({op:"COUNTER",key:null,value:r.toJSON()},t)}}},function(e,t,r){"use strict";const n=r(117);e.exports=class{constructor(e){this._index=new n(e)}get(){return this._index}updateIndex(e){if(this._index){const t=e=>e.payload.value.counters,r=e=>this._index.merge({_counters:e});e.values.filter(e=>e&&"COUNTER"===e.payload.op).map(t).forEach(r)}}}},function(e,t,r){"use strict";t.deepEqual=(e,t)=>{const r=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(r.length!==n.length)return!1;for(let n=0;ne.toString().split(t).join(r));e.exports=class extends n{constructor(e,t,r,n){n||(n={}),n.indexBy||Object.assign(n,{indexBy:"_id"}),n.Index||Object.assign(n,{Index:i}),super(e,t,r,n),this._type="docstore"}get(e,t=!1){const r=(e=e.toString()).split(" ");e=r.length>1?s(e,"."," ").toLowerCase():e.toLowerCase();return Object.keys(this._index._index).filter(n=>t?-1!==n.indexOf(e):(t=>r.length>1?-1!==s(t,"."," ").toLowerCase().indexOf(e):-1!==t.toLowerCase().indexOf(e))(n)).map(e=>this._index.get(e))}query(e,t={}){const r=t.fullOp||!1;return Object.keys(this._index._index).map(e=>this._index.get(e,r)).filter(e)}batchPut(e,t){return o(e,(r,n)=>this._addOperationBatch({op:"PUT",key:r[this.options.indexBy],value:r},!0,n===e.length-1,t),{concurrency:1}).then(()=>this.saveSnapshot())}put(e,t={}){if(!e[this.options.indexBy])throw new Error(`The provided document doesn't contain field '${this.options.indexBy}'`);return this._addOperation({op:"PUT",key:e[this.options.indexBy],value:e},t)}putAll(e,t={}){if(Array.isArray(e)||(e=[e]),!e.every(e=>e[this.options.indexBy]))throw new Error(`The provided document doesn't contain field '${this.options.indexBy}'`);return this._addOperation({op:"PUTALL",docs:e.map(e=>({key:e[this.options.indexBy],value:e}))},t)}del(e,t={}){if(!this._index.get(e))throw new Error(`No entry with key '${e}' in the database`);return this._addOperation({op:"DEL",key:e,value:null},t)}}},function(e,t,r){"use strict";e.exports=class{constructor(){this._index={}}get(e,t=!1){return t?this._index[e]:this._index[e]?this._index[e].payload.value:null}updateIndex(e,t){e.values.slice().reverse().reduce((e,r,n)=>{if("PUTALL"===r.payload.op&&r.payload.docs[Symbol.iterator])for(const t of r.payload.docs)t&&!0!==e[t.key]&&(e[t.key]=!0,this._index[t.key]={payload:{op:"PUT",key:t.key,value:t.value}});else!0!==e[r.payload.key]&&(e[r.payload.key]=!0,"PUT"===r.payload.op?this._index[r.payload.key]=r:"DEL"===r.payload.op&&delete this._index[r.payload.key]);return t&&t(r,n),e},{})}}},function(e,t,r){"use strict";e.exports=(e,t,r)=>new Promise((n,i)=>{const o=(r=Object.assign({concurrency:1/0},r)).concurrency;if(o<1)throw new TypeError("Expected `concurrency` to be a number from 1 and up");const s=[],a=e[Symbol.iterator]();let c=!1,u=!1,f=0,h=0;const l=()=>{if(c)return;const e=a.next(),r=h;if(h++,e.done)return u=!0,void(0===f&&n(s));f++,Promise.resolve(e.value).then(e=>t(e,r)).then(e=>{s[r]=e,f--,l()},e=>{c=!0,i(e)})};for(let e=0;e0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,o=n.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=o,i=a,t.copy(r,i),a+=s.data.length,s=s.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,s,a,c=1,u={},f=!1,h=e.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(e);l=l&&l.setTimeout?l:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},n=function(e){o.port2.postMessage(e)}):h&&"onreadystatechange"in h.createElement("script")?(i=h.documentElement,n=function(e){var t=h.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(p,0,e)}:(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&p(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),n=function(t){e.postMessage(s+t,"*")}),l.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r{s.debug(`Peer joined ${e}:`),s.debug(t),this._subscriptions[e]?r(e,t):(s.warn("Peer joined a room we don't have a subscription for"),s.warn(e,t))}),o.on("leave",t=>s.debug(`Peer ${t} left ${e}`)),o.on("error",e=>s.error(e)),this._subscriptions[e]={topicMonitor:o,onMessage:t,onNewPeer:r},a++,s.debug("Topics open:",a)}}async unsubscribe(e){this._subscriptions[e]&&(await this._ipfs.pubsub.unsubscribe(e,this._handleMessage),this._subscriptions[e].topicMonitor.stop(),delete this._subscriptions[e],s.debug(`Unsubscribed from '${e}'`),a--,s.debug("Topics open:",a))}publish(e,r,n={}){if(this._subscriptions[e]&&this._ipfs.pubsub){let i;i=t.isBuffer(r)|"string"==typeof r?r:JSON.stringify(r),this._ipfs.pubsub.publish(e,t.from(i),n)}}async disconnect(){const e=Object.keys(this._subscriptions);await n(e.map(e=>this.unsubscribe.bind(this,e))),this._subscriptions={}}async _handleMessage(e){if(e.from===this._id)return;let r,n,i;i=e.topicIDs[0];try{r=JSON.parse(t.from(e.data).toString())}catch{r=e.data}n=this._subscriptions[i],n&&n.onMessage&&r&&await n.onMessage(i,r,e.from)}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(122),i=r(286);e.exports=e=>{const t=[];for(const t of e){const e=i(t);if("Function"!==e)return Promise.reject(new TypeError(`Expected task to be a \`Function\`, received \`${e}\``))}return n(e,(e,r)=>Promise.resolve().then(r).then(e=>{t.push(e)})).then(()=>t)}},function(e,t,r){"use strict";(function(n){Object.defineProperty(t,"__esModule",{value:!0});const i=r(40),o=Object.prototype.toString,s=e=>t=>typeof t===e,a=e=>{const t=o.call(e).slice(8,-1);return t||null},c=e=>t=>a(t)===e;function u(e){if(null===e)return"null";if(!0===e||!1===e)return"boolean";const t=typeof e;if("undefined"===t)return"undefined";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if(u.function_(e))return"Function";if(Array.isArray(e))return"Array";if(n.isBuffer(e))return"Buffer";const r=a(e);if(r)return r;if(e instanceof String||e instanceof Boolean||e instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}!function(e){const t=e=>"object"==typeof e;e.undefined=s("undefined"),e.string=s("string"),e.number=s("number"),e.function_=s("function"),e.null_=e=>null===e,e.class_=t=>e.function_(t)&&t.toString().startsWith("class "),e.boolean=e=>!0===e||!1===e,e.symbol=s("symbol"),e.array=Array.isArray,e.buffer=n.isBuffer,e.nullOrUndefined=t=>e.null_(t)||e.undefined(t),e.object=r=>!e.nullOrUndefined(r)&&(e.function_(r)||t(r)),e.iterable=t=>!e.nullOrUndefined(t)&&e.function_(t[Symbol.iterator]),e.generator=t=>e.iterable(t)&&e.function_(t.next)&&e.function_(t.throw),e.nativePromise=c("Promise");e.promise=r=>e.nativePromise(r)||(r=>!e.null_(r)&&t(r)&&e.function_(r.then)&&e.function_(r.catch))(r);const r=t=>r=>e.function_(r)&&e.function_(r.constructor)&&r.constructor.name===t;e.generatorFunction=r("GeneratorFunction"),e.asyncFunction=r("AsyncFunction"),e.boundFunction=t=>e.function_(t)&&!t.hasOwnProperty("prototype"),e.regExp=c("RegExp"),e.date=c("Date"),e.error=c("Error"),e.map=c("Map"),e.set=c("Set"),e.weakMap=c("WeakMap"),e.weakSet=c("WeakSet"),e.int8Array=c("Int8Array"),e.uint8Array=c("Uint8Array"),e.uint8ClampedArray=c("Uint8ClampedArray"),e.int16Array=c("Int16Array"),e.uint16Array=c("Uint16Array"),e.int32Array=c("Int32Array"),e.uint32Array=c("Uint32Array"),e.float32Array=c("Float32Array"),e.float64Array=c("Float64Array"),e.arrayBuffer=c("ArrayBuffer"),e.sharedArrayBuffer=c("SharedArrayBuffer"),e.dataView=c("DataView"),e.directInstanceOf=(t,r)=>e.object(t)&&e.object(r)&&Object.getPrototypeOf(t)===r.prototype,e.truthy=e=>Boolean(e),e.falsy=e=>!e,e.nan=e=>Number.isNaN(e);const o=new Set(["undefined","string","number","boolean","symbol"]);e.primitive=t=>e.null_(t)||o.has(typeof t),e.integer=e=>Number.isInteger(e),e.safeInteger=e=>Number.isSafeInteger(e),e.plainObject=e=>{let t;return"Object"===a(e)&&(t=Object.getPrototypeOf(e),null===t||t===Object.getPrototypeOf({}))};const u=new Set(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"]);e.typedArray=e=>{const t=a(e);return null!==t&&u.has(t)};e.arrayLike=t=>!e.nullOrUndefined(t)&&!e.function_(t)&&(t=>e.safeInteger(t)&&t>-1)(t.length),e.inRange=(t,r)=>{if(e.number(r))return t>=Math.min(0,r)&&t<=Math.max(r,0);if(e.array(r)&&2===r.length)return t>=Math.min.apply(null,r)&&t<=Math.max.apply(null,r);throw new TypeError("Invalid range: "+i.inspect(r))};const f=["innerHTML","ownerDocument","style","attributes","nodeValue"];e.domElement=t=>e.object(t)&&1===t.nodeType&&e.string(t.nodeName)&&!e.plainObject(t)&&f.every(e=>e in t),e.nodeStream=r=>!e.nullOrUndefined(r)&&t(r)&&e.function_(r.pipe),e.infinite=e=>e===1/0||e===-1/0;const h=t=>r=>e.integer(r)&&Math.abs(r%2)===t;e.even=h(0),e.odd=h(1);e.empty=t=>e.falsy(t)||(t=>(e.string(t)||e.array(t))&&0===t.length)(t)||(t=>!e.map(t)&&!e.set(t)&&e.object(t)&&0===Object.keys(t).length)(t)||(t=>(e.map(t)||e.set(t))&&0===t.size)(t),e.emptyOrWhitespace=t=>e.empty(t)||(t=>e.string(t)&&!1===/\S/.test(t))(t);const l=(t,r,n)=>{const o=Array.prototype.slice.call(n,1);if(!1===e.function_(r))throw new TypeError("Invalid predicate: "+i.inspect(r));if(0===o.length)throw new TypeError("Invalid number of values");return t.call(o,r)};e.any=function(e){return l(Array.prototype.some,e,arguments)},e.all=function(e){return l(Array.prototype.every,e,arguments)}}(u||(u={})),Object.defineProperties(u,{class:{value:u.class_},function:{value:u.function_},null:{value:u.null_}}),t.default=u,e.exports=u,e.exports.default=u}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const{difference:n}=r(288),i=r(7),o={start:!0,pollInterval:1e3};class s extends i{constructor(e,t,r){super(),this._pubsub=e,this._topic=t,this._options=Object.assign({},o,r),this._peers=[],this._interval=null,this._options.start&&this.start()}get started(){return null!==this._interval}set started(e){throw new Error("'started' is read-only")}start(){this._interval&&this.stop(),this._interval=setInterval(this._pollPeers.bind(this),this._options.pollInterval),this._pollPeers()}stop(){clearInterval(this._interval),this._interval=null,this.removeAllListeners("error"),this.removeAllListeners("join"),this.removeAllListeners("leave")}async getPeers(){return this._peers=await this._pubsub.peers(this._topic),this._peers.slice()}hasPeer(e){return this._peers.includes(e)}async _pollPeers(){try{const e=await this._pubsub.peers(this._topic);s._emitJoinsAndLeaves(new Set(this._peers),new Set(e),this),this._peers=e}catch(e){clearInterval(this._interval),this.emit("error",e)}}static _emitJoinsAndLeaves(e,t,r){n(t,e).forEach(e=>r.emit("join",e)),n(e,t).forEach(e=>r.emit("leave",e))}}e.exports=s},function(e,t,r){"use strict";e.exports.runWithDelay=async(e,t,r)=>{const n=await e(t);var i;return await(i=r,new Promise(e=>setTimeout(e,i))),n},e.exports.difference=(e,t)=>new Set([...e].filter(e=>!t.has(e)))},function(e,t,r){e.exports=r(290)(r(317))},function(e,t,r){var n=r(291),i=r(313);e.exports=function(e){function t(t,o,s){return"function"==typeof t?s=t:"function"==typeof o&&(s=o),r(o)||(o=r(t)?t:{}),n(i(e(t,o),o),o,s)}function r(e){return"object"==typeof e&&null!==e}return["destroy","repair"].forEach((function(r){"function"==typeof e[r]&&(t[r]=function(){e[r].apply(e,arguments)})})),t.errors=n.errors,t}},function(e,t,r){(function(t){var n=r(7).EventEmitter,i=r(40).inherits,o=r(9),s=r(292),a=r(300),c=r(309),u=r(68),f=r(65),h=r(136),l=r(135),d=r(50).getCallback,p=r(50).getOptions,y=u.WriteError,b=u.ReadError,g=u.NotFoundError,m=u.OpenError,v=u.InitializationError;function w(e,r,i){if(!(this instanceof w))return new w(e,r,i);var o,a=this;if(n.call(this),this.setMaxListeners(1/0),"function"==typeof r&&(i=r,r={}),r=r||{},!e||"object"!=typeof e){if(o=new v("First argument must be an abstract-leveldown compliant store"),"function"==typeof i)return t.nextTick(i,o);throw o}h.strictEqual(typeof e.status,"string",".status required, old abstract-leveldown"),this.options=p(r),this._db=e,this.db=new s(e),this.open(i||function(e){e&&a.emit("error",e)}),this.supports=f(this.db.supports,{status:!1,deferredOpen:!0,openCallback:!0,promises:!0,streams:!0}),Object.keys(this.supports.additionalMethods).forEach((function(e){null==this[e]&&(this[e]=function(){return this.db[e].apply(this.db,arguments)})}),this)}function _(e,r){if(!e._isOpening()&&!e.isOpen())return t.nextTick(r,new b("Database is not open")),!0}w.prototype.emit=n.prototype.emit,w.prototype.once=n.prototype.once,i(w,n),w.prototype.open=function(e,r){var n,i=this;return"function"==typeof e&&(r=e,e=null),r||(n=(r=l()).promise),e||(e=this.options),this.isOpen()?(t.nextTick(r,null,i),n):this._isOpening()?(this.once("open",(function(){r(null,i)})),n):(this.emit("opening"),this.db.open(e,(function(e){if(e)return r(new m(e));i.db=i._db,r(null,i),i.emit("open"),i.emit("ready")})),n)},w.prototype.close=function(e){var r,n=this;return e||(r=(e=l()).promise),this.isOpen()?(this.db.close((function(){n.emit("closed"),e.apply(null,arguments)})),this.emit("closing"),this.db=new s(this._db)):this.isClosed()?t.nextTick(e):"closing"===this.db.status?this.once("closed",e):this._isOpening()&&this.once("open",(function(){n.close(e)})),r},w.prototype.isOpen=function(){return"open"===this.db.status},w.prototype._isOpening=function(){return"opening"===this.db.status},w.prototype.isClosed=function(){return/^clos|new/.test(this.db.status)},w.prototype.get=function(e,t,r){var n;return(r=d(t,r))||(n=(r=l()).promise),_(this,r)||(t=p(t),this.db.get(e,t,(function(t,n){if(t)return t=/notfound/i.test(t)||t.notFound?new g("Key not found in database ["+e+"]",t):new b(t),r(t);r(null,n)}))),n},w.prototype.put=function(e,t,r,n){var i,o=this;return(n=d(r,n))||(i=(n=l()).promise),_(this,n)||(r=p(r),this.db.put(e,t,r,(function(r){if(r)return n(new y(r));o.emit("put",e,t),n()}))),i},w.prototype.del=function(e,t,r){var n,i=this;return(r=d(t,r))||(n=(r=l()).promise),_(this,r)||(t=p(t),this.db.del(e,t,(function(t){if(t)return r(new y(t));i.emit("del",e),r()}))),n},w.prototype.batch=function(e,t,r){if(!arguments.length)return new c(this);var n,i=this;return(r="function"==typeof e?e:d(t,r))||(n=(r=l()).promise),_(this,r)||(t=p(t),this.db.batch(e,t,(function(t){if(t)return r(new y(t));i.emit("batch",e),r()}))),n},w.prototype.iterator=function(e){return this.db.iterator(e)},w.prototype.clear=function(e,t){var r,n=this;return t=d(e,t),e=p(e),t||(r=(t=l()).promise),_(this,t)||this.db.clear(e,(function(r){if(r)return t(new y(r));n.emit("clear",e),t()})),r},w.prototype.readStream=w.prototype.createReadStream=function(e){return"number"!=typeof(e=o({keys:!0,values:!0},e)).limit&&(e.limit=-1),new a(this.db.iterator(e),e)},w.prototype.keyStream=w.prototype.createKeyStream=function(e){return this.createReadStream(o(e,{keys:!0,values:!1}))},w.prototype.valueStream=w.prototype.createValueStream=function(e){return this.createReadStream(o(e,{keys:!1,values:!0}))},w.prototype.toString=function(){return"LevelUP"},w.prototype.type="levelup",w.errors=u,e.exports=w.default=w}).call(this,r(2))},function(e,t,r){var n=r(124).AbstractLevelDOWN,i=r(1),o=r(299),s="put get del batch clear".split(" "),a="approximateSize compactRange".split(" ");function c(e){n.call(this,e.supports||{}),a.forEach((function(t){"function"!=typeof e[t]||this.supports.additionalMethods[t]||(this.supports.additionalMethods[t]=!0)}),this),this._db=e,this._operations=[],u(this)}function u(e){s.forEach((function(t){e["_"+t]=function(){this._operations.push({method:t,args:arguments})}})),Object.keys(e.supports.additionalMethods).forEach((function(t){e[t]=function(){this._operations.push({method:t,args:arguments})}})),e._iterator=function(t){var r=new o(e,t);return this._operations.push({iterator:r}),r}}i(c,n),c.prototype.type="deferred-leveldown",c.prototype._open=function(e,t){var r=this;this._db.open(e,(function(e){if(e)return t(e);r._operations.forEach((function(e){e.iterator?e.iterator.setDb(r._db):r._db[e.method].apply(r._db,e.args)})),r._operations=[],function(e){s.concat("iterator").forEach((function(t){e["_"+t]=function(){return this._db[t].apply(this._db,arguments)}})),Object.keys(e.supports.additionalMethods).forEach((function(t){e[t]=function(){return this._db[t].apply(this._db,arguments)}}))}(r),t()}))},c.prototype._close=function(e){var t=this;this._db.close((function(r){if(r)return e(r);u(t),e()}))},c.prototype._serializeKey=function(e){return e},c.prototype._serializeValue=function(e){return e},e.exports=c,e.exports.DeferredIterator=o},function(e,t,r){var n=r(9),i=r(65),o=r(0).Buffer,s=r(126),a=r(127),c=r(66),u=Object.prototype.hasOwnProperty,f="start end gt gte lt lte".split(" ");function h(e){this.status="new",this.supports=i(e,{status:!0})}function l(e,t){var r={};for(var n in t)if(u.call(t,n)){var i=t[n];d(n)&&(i=e._serializeKey(i)),r[n]=i}return r}function d(e){return-1!==f.indexOf(e)}h.prototype.open=function(e,t){var r=this,n=this.status;if("function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("open() requires a callback argument");"object"==typeof e&&null!==e||(e={}),e.createIfMissing=!1!==e.createIfMissing,e.errorIfExists=!!e.errorIfExists,this.status="opening",this._open(e,(function(e){if(e)return r.status=n,t(e);r.status="open",t()}))},h.prototype._open=function(e,t){c(t)},h.prototype.close=function(e){var t=this,r=this.status;if("function"!=typeof e)throw new Error("close() requires a callback argument");this.status="closing",this._close((function(n){if(n)return t.status=r,e(n);t.status="closed",e()}))},h.prototype._close=function(e){c(e)},h.prototype.get=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("get() requires a callback argument");var n=this._checkKey(e);if(n)return c(r,n);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),t.asBuffer=!1!==t.asBuffer,this._get(e,t,r)},h.prototype._get=function(e,t,r){c((function(){r(new Error("NotFound"))}))},h.prototype.put=function(e,t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("put() requires a callback argument");var i=this._checkKey(e)||this._checkValue(t);if(i)return c(n,i);e=this._serializeKey(e),t=this._serializeValue(t),"object"==typeof r&&null!==r||(r={}),this._put(e,t,r,n)},h.prototype._put=function(e,t,r,n){c(n)},h.prototype.del=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("del() requires a callback argument");var n=this._checkKey(e);if(n)return c(r,n);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),this._del(e,t,r)},h.prototype._del=function(e,t,r){c(r)},h.prototype.batch=function(e,t,r){if(!arguments.length)return this._chainedBatch();if("function"==typeof t&&(r=t),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return c(r,new Error("batch(array) requires an array argument"));if(0===e.length)return c(r);"object"==typeof t&&null!==t||(t={});for(var i=new Array(e.length),o=0;o0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,n,i=s.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,s.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&s.forEach(u),o||(s.forEach(u),i(n))}))}));return t.reduce(f)}},function(e,t,r){var n=r(68).WriteError,i=r(135),o=r(50).getCallback,s=r(50).getOptions;function a(e){this.db=this._levelup=e,this.batch=e.db.batch(),this.ops=[],this.length=0}a.prototype.put=function(e,t){try{this.batch.put(e,t)}catch(e){throw new n(e)}return this.ops.push({type:"put",key:e,value:t}),this.length++,this},a.prototype.del=function(e){try{this.batch.del(e)}catch(e){throw new n(e)}return this.ops.push({type:"del",key:e}),this.length++,this},a.prototype.clear=function(){try{this.batch.clear()}catch(e){throw new n(e)}return this.ops=[],this.length=0,this},a.prototype.write=function(e,t){var r,a=this._levelup,c=this.ops;(t=o(e,t))||(r=(t=i()).promise),e=s(e);try{this.batch.write(e,(function(e){if(e)return t(new n(e));a.emit("batch",c),t()}))}catch(e){throw new n(e)}return r},e.exports=a},function(e,t,r){var n=r(311);function i(e,t,r){t&&"string"!=typeof t&&(t=t.message||t.name),n(this,{type:e,name:e,cause:"string"!=typeof t?t:r,message:t},"ewr")}function o(e,t){Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),i.call(this,"CustomError",e,t)}o.prototype=new Error,e.exports=function(e){var t=function(t,r){return function(e,t,r){var n=function(r,o){i.call(this,t,r,o),"FilesystemError"==t&&(this.code=this.cause.code,this.path=this.cause.path,this.errno=this.cause.errno,this.message=(e.errno[this.cause.errno]?e.errno[this.cause.errno].description:this.cause.message)+(this.cause.path?" ["+this.cause.path+"]":"")),Error.call(this),Error.captureStackTrace&&Error.captureStackTrace(this,n)};return n.prototype=r?new r:new o,n}(e,t,r)};return{CustomError:o,FilesystemError:t("FilesystemError"),createError:t}}},function(e,t,r){ /*! * prr * (c) 2013 Rod Vagg * https://github.com/rvagg/prr * License: MIT */ var n,i;n=this,i=function(){var e="function"==typeof Object.defineProperty?function(e,t,r){return Object.defineProperty(e,t,r),e}:function(e,t,r){return e[t]=r.value,e};return function(t,r,n,i){var o;if(i=function(e,t){var r="object"==typeof t,n=!r&&"string"==typeof t,i=function(e){return r?!!t[e]:!!n&&t.indexOf(e[0])>-1};return{enumerable:i("enumerable"),configurable:i("configurable"),writable:i("writable"),value:e}}(n,i),"object"==typeof r){for(o in r)Object.hasOwnProperty.call(r,o)&&(i.value=r[o],e(t,o,i));return t}return e(t,r,i)}},e.exports?e.exports=i():n.prr=i()},function(e,t,r){"use strict"; /* object-assign (c) Sindre Sorhus @license MIT */var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function s(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,c=s(e),u=1;u-1?t.encodeKey(e[n],e):e[n]})),r},i.prototype.createStreamDecoder=function(e){var t=this;return e.keys&&e.values?function(r,n){return{key:t.decodeKey(r,e),value:t.decodeValue(n,e)}}:e.keys?function(r){return t.decodeKey(r,e)}:e.values?function(r,n){return t.decodeValue(n,e)}:function(){}},i.prototype.keyAsBuffer=function(e){return this._keyEncoding(e).buffer},i.prototype.valueAsBuffer=function(e){return this._valueEncoding(e).buffer}},function(e,t,r){var n=r(0).Buffer;t.utf8=t["utf-8"]={encode:function(e){return o(e)?e:String(e)},decode:i,buffer:!1,type:"utf8"},t.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},t.binary={encode:function(e){return o(e)?e:n.from(e)},decode:i,buffer:!0,type:"binary"},t.none={encode:i,decode:i,buffer:!1,type:"id"},t.id=t.none;function i(e){return e}function o(e){return null==e||n.isBuffer(e)}["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach((function(e){t[e]={encode:function(t){return o(t)?t:n.from(t,e)},decode:function(t){return t.toString(e)},buffer:!0,type:e}}))},function(e,t,r){"use strict";(function(t){e.exports=u;var n=r(139).AbstractLevelDOWN,i=r(1),o=r(319),s=r(143),a=r(145),c=r(321);function u(e,t){if(!(this instanceof u))return new u(e,t);if(n.call(this),t=t||{},"string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.prefix=null==t.prefix?"level-js-":t.prefix,this.version=parseInt(t.version||1,10)}i(u,n),u.binaryKeys=c.binaryKeys(indexedDB),u.arrayKeys=c.arrayKeys(indexedDB),u.prototype._open=function(e,t){var r=indexedDB.open(this.prefix+this.location,this.version),n=this;r.onerror=function(){t(r.error||new Error("unknown error"))},r.onsuccess=function(){n.db=r.result,t()},r.onupgradeneeded=function(e){var t=e.target.result;t.objectStoreNames.contains(n.location)||t.createObjectStore(n.location)}},u.prototype.store=function(e){return this.db.transaction([this.location],e).objectStore(this.location)},u.prototype.await=function(e,t){var r=e.transaction;r.onabort=function(){t(r.error||new Error("aborted by user"))},r.oncomplete=function(){t(null,e.result)}},u.prototype._get=function(e,t,r){var n=this.store("readonly");try{var i=n.get(e)}catch(e){return a((function(){r(e)}))}this.await(i,(function(e,n){return e?r(e):void 0===n?r(new Error("NotFound")):(t.asBuffer&&(n=s(n)),void r(null,n))}))},u.prototype._del=function(e,t,r){var n=this.store("readwrite");try{var i=n.delete(e)}catch(e){return a((function(){r(e)}))}this.await(i,r)},u.prototype._put=function(e,t,r,n){var i=this.store("readwrite");try{var o=i.put(t,e)}catch(e){return a((function(){n(e)}))}this.await(o,n)},u.prototype._serializeKey=function(e){return t.isBuffer(e)?u.binaryKeys?e:e.toString():Array.isArray(e)?u.arrayKeys?e.map(this._serializeKey,this):String(e):e},u.prototype._serializeValue=function(e){return e},u.prototype._iterator=function(e){return new o(this,this.location,e)},u.prototype._batch=function(e,t,r){if(0===e.length)return a(r);var n,i=this.store("readwrite"),o=i.transaction,s=0;o.onabort=function(){r(n||o.error||new Error("aborted by user"))},o.oncomplete=function(){r()},function t(){var r=e[s++],a=r.key;try{var c="del"===r.type?i.delete(a):i.put(r.value,a)}catch(e){return n=e,void o.abort()}s0){var r=this._cache.shift(),n=this._cache.shift();this._keyAsBuffer&&(r=s(r)),this._valueAsBuffer&&(n=s(n)),a((function(){e(null,r,n)}))}else this._completed?a(e):this._callback=e},u.prototype._end=function(e){if(this._aborted||this._completed){var t=this._error;a((function(){e(t)}))}else this.onItem=c,this.onAbort=e,this.onComplete=e}},function(e,t){e.exports=i,i.strict=o,i.loose=s;var r=Object.prototype.toString,n={"[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 i(e){return o(e)||s(e)}function o(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return n[r.call(e)]}},function(e,t,r){"use strict";t.test=function(e){return function(t){try{return t.cmp(e,0),!0}catch(e){return!1}}},t.binaryKeys=t.test(new Uint8Array(0)),t.arrayKeys=t.test([1])},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(324),i={16:"aes-128-ctr",32:"aes-256-ctr"};t.create=function(e,t,r){const o=i[e.length];if(!o)return r(new Error("Invalid key length"));const s=n.createCipheriv(o,e,t),a=n.createDecipheriv(o,e,t);r(null,{encrypt(e,t){t(null,s.update(e))},decrypt(e,t){t(null,a.update(e))}})}},function(e,t,r){"use strict";const n=r(325);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){var n=r(326),i=r(348),o=r(151);t.createCipher=t.Cipher=n.createCipher,t.createCipheriv=t.Cipheriv=n.createCipheriv,t.createDecipher=t.Decipher=i.createDecipher,t.createDecipheriv=t.Decipheriv=i.createDecipheriv,t.listCiphers=t.getCiphers=function(){return Object.keys(o)}},function(e,t,r){var n=r(148),i=r(152),o=r(3).Buffer,s=r(153),a=r(22),c=r(51),u=r(154);function f(e,t,r){a.call(this),this._cache=new l,this._cipher=new c.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}r(1)(f,a),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return o.concat(n)};var h=o.alloc(16,16);function l(){this.cache=o.allocUnsafe(0)}function d(e,t,r){var a=n[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=o.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===a.type?new s(a.module,t,r):"auth"===a.type?new i(a.module,t,r):new f(a.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},l.prototype.add=function(e){this.cache=o.concat([this.cache,e])},l.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>s%8,e._prev=o(e._prev,r?n:i);return a}function o(e,t){var r=e.length,i=-1,o=n.allocUnsafe(e.length);for(e=n.concat([e,n.from([t])]);++i>7;return o}t.encrypt=function(e,t,r){for(var o=t.length,s=n.allocUnsafe(o),a=-1;++a>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function s(e){this.h=e,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0)}s.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=o(i)},s.prototype.update=function(e){var t;for(this.cache=n.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},s.prototype.final=function(e,t){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,e,0,t])),this.state},e.exports=s},function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=r(0),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){(t=e.exports=r(156)).Stream=t,t.Readable=t,t.Writable=r(160),t.Duplex=r(31),t.Transform=r(161),t.PassThrough=r(346),t.finished=r(74),t.pipeline=r(347)},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,n,i=s.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,s.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&s.forEach(u),o||(s.forEach(u),i(n))}))}));return t.reduce(f)}},function(e,t,r){var n=r(152),i=r(3).Buffer,o=r(148),s=r(153),a=r(22),c=r(51),u=r(154);function f(e,t,r){a.call(this),this._cache=new h,this._last=void 0,this._cipher=new c.AES(t),this._prev=i.from(r),this._mode=e,this._autopadding=!0}function h(){this.cache=i.allocUnsafe(0)}function l(e,t,r){var a=o[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=i.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof t&&(t=i.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===a.type?new s(a.module,t,r,!0):"auth"===a.type?new n(a.module,t,r,!0):new f(a.module,t,r)}r(1)(f,a),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,t),n.push(r);return i.concat(n)},f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},h.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(e,t){var r=o[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},t.createDecipheriv=l},function(e,t,r){"use strict";(function(n){const i=r(75)(r(77));r(23),r(44),r(52);const o=r(4);t=e.exports;const s={rsa:r(373),ed25519:r(411),secp256k1:r(415)(i,r(86))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(453),t.generateEphemeralKeyPair=r(461),t.generateKeyPair=(e,t,r)=>{const n=s[e.toLowerCase()];if(!n)return r(new Error("invalid or unsupported key type"));n.generateKeyPair(t,r)},t.generateKeyPairFromSeed=(e,t,r,n)=>{const i=s[e.toLowerCase()];return i?"ed25519"!==e.toLowerCase()?n(new Error("Seed key derivation is unimplemented for RSA or secp256k1")):void i.generateKeyPairFromSeed(t,r,n):n(new Error("invalid or unsupported key type"))},t.unmarshalPublicKey=e=>{const t=i.PublicKey.decode(e),r=t.Data;switch(t.Type){case i.KeyType.RSA:return s.rsa.unmarshalRsaPublicKey(r);case i.KeyType.Ed25519:return s.ed25519.unmarshalEd25519PublicKey(r);case i.KeyType.Secp256k1:if(s.secp256k1)return s.secp256k1.unmarshalSecp256k1PublicKey(r);throw new Error("secp256k1 support requires libp2p-crypto-secp256k1 package");default:throw new Error("invalid or unsupported key type")}},t.marshalPublicKey=(e,t)=>{if(!a(t=(t||"rsa").toLowerCase()))throw new Error("invalid or unsupported key type");return e.bytes},t.unmarshalPrivateKey=(e,t)=>{let r;try{r=i.PrivateKey.decode(e)}catch(e){return t(e)}const n=r.Data;switch(r.Type){case i.KeyType.RSA:return s.rsa.unmarshalRsaPrivateKey(n,t);case i.KeyType.Ed25519:return s.ed25519.unmarshalEd25519PrivateKey(n,t);case i.KeyType.Secp256k1:return s.secp256k1?s.secp256k1.unmarshalSecp256k1PrivateKey(n,t):t(new Error("secp256k1 support requires libp2p-crypto-secp256k1 package"));default:t(new Error("invalid or unsupported key type"))}},t.marshalPrivateKey=(e,t)=>{if(!a(t=(t||"rsa").toLowerCase()))throw new Error("invalid or unsupported key type");return e.bytes},t.import=(e,t,r)=>{try{const i=o.pki.decryptRsaPrivateKey(e,t);if(null===i)throw new Error("Cannot read the key, most likely the password is wrong or not a RSA key");let a=o.asn1.toDer(o.pki.privateKeyToAsn1(i));return a=n.from(a.getBytes(),"binary"),s.rsa.unmarshalRsaPrivateKey(a,r)}catch(e){r(e)}}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(351),i=r(353);e.exports=n,e.exports.parse=n,e.exports.stringify=i},function(e,t,r){var n=r(352),i=["int32","int64","uint32","uint64","sint32","sint64","bool","fixed64","sfixed64","double","fixed32","sfixed32","float"],o=function(e){var t=e.shift();if("{"!==t)return t;t={};for(var r="";e.length;)switch(e[0]){case"}":return e.shift(),t;case":":e.shift(),t[r]=o(e);break;default:r=e.shift()}},s=function(e){for(var t={};e.length;)switch(e[0]){case"[":case",":e.shift();var r=e.shift();"("===r&&(r=e.shift(),e.shift());var n=[];if("."===e[0][0]&&(n=e[0].substr(1).split("."),e.shift()),"="!==e[0])throw new Error("Unexpected token in field options: "+e[0]);if(e.shift(),"]"===e[0])throw new Error("Unexpected ] in field option");var i=[r].concat(n),s=i.pop();i.reduce((function(e,t,r){return null==e[t]&&(e[t]={}),e[t]}),t)[s]=o(e);break;case"]":return e.shift(),t;default:throw new Error("Unexpected token in field options: "+e[0])}throw new Error("No closing tag for field options")},a=function(e){for(var t={name:null,type:null,tag:-1,map:null,oneof:null,required:!1,repeated:!1,options:{}};e.length;)switch(e[0]){case"=":e.shift(),t.tag=Number(e.shift());break;case"map":if(t.type="map",t.map={from:null,to:null},e.shift(),"<"!==e[0])throw new Error("Unexpected token in map type: "+e[0]);if(e.shift(),t.map.from=e.shift(),","!==e[0])throw new Error("Unexpected token in map type: "+e[0]);if(e.shift(),t.map.to=e.shift(),">"!==e[0])throw new Error("Unexpected token in map type: "+e[0]);e.shift(),t.name=e.shift();break;case"repeated":case"required":case"optional":var r=e.shift();t.required="required"===r,t.repeated="repeated"===r,t.type=e.shift(),t.name=e.shift();break;case"[":t.options=s(e);break;case";":if(null===t.name)throw new Error("Missing field name");if(null===t.type)throw new Error("Missing type in message field: "+t.name);if(-1===t.tag)throw new Error("Missing tag number in message field: "+t.name);return e.shift(),t;default:throw new Error("Unexpected token in message field: "+e[0])}throw new Error("No ; found for message field")},c=function(e){for(var t={enums:[],options:{},messages:[],fields:[],extends:[],extensions:null};e.length;)switch(e[0]){case"map":case"repeated":case"optional":case"required":t.fields.push(a(e));break;case"enum":t.enums.push(y(e));break;case"message":t.messages.push(h(e));break;case"extensions":t.extensions=f(e);break;case"oneof":e.shift();var r=e.shift();if("{"!==e[0])throw new Error("Unexpected token in oneof: "+e[0]);for(e.shift();"}"!==e[0];){e.unshift("optional");var n=a(e);n.oneof=r,t.fields.push(n)}e.shift();break;case"extend":t.extends.push(u(e));break;case";":e.shift();break;case"reserved":for(e.shift();";"!==e[0];)e.shift();break;case"option":var i=b(e);if(void 0!==t.options[i.name])throw new Error("Duplicate option "+i.name);t.options[i.name]=i.value;break;default:e.unshift("optional"),t.fields.push(a(e))}return t},u=function(e){return{name:e[1],message:h(e)}},f=function(e){e.shift();var t=Number(e.shift());if(isNaN(t))throw new Error("Invalid from in extensions definition");if("to"!==e.shift())throw new Error("Expected keyword 'to' in extensions definition");var r=e.shift();if("max"===r&&(r=536870911),r=Number(r),isNaN(r))throw new Error("Invalid to in extensions definition");if(";"!==e.shift())throw new Error("Missing ; in extensions definition");return{from:t,to:r}},h=function(e){e.shift();var t=1,r=[],n={name:e.shift(),options:{},enums:[],extends:[],messages:[],fields:[]};if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("{"===e[0]?t++:"}"===e[0]&&t--,!t)return e.shift(),r=c(r),n.enums=r.enums,n.messages=r.messages,n.fields=r.fields,n.extends=r.extends,n.extensions=r.extensions,n.options=r.options,n;r.push(e.shift())}if(t)throw new Error("No closing tag for message")},l=function(e){e.shift();var t=e.shift();if(";"!==e[0])throw new Error("Expected ; but found "+e[0]);return e.shift(),t},d=function(e){if(e.shift(),"="!==e[0])throw new Error("Expected = but found "+e[0]);e.shift();var t=e.shift();switch(t){case'"proto2"':t=2;break;case'"proto3"':t=3;break;default:throw new Error("Expected protobuf syntax version but found "+t)}if(";"!==e[0])throw new Error("Expected ; but found "+e[0]);return e.shift(),t},p=function(e){if(e.length<4)throw new Error("Invalid enum value: "+e.slice(0,3).join(" "));if("reserved"===e[0]){for(e.shift();";"!==e[0];)e.shift();return e.shift(),null}if("="!==e[1])throw new Error("Expected = but found "+e[1]);if(";"!==e[3]&&"["!==e[3])throw new Error("Expected ; or [ but found "+e[1]);var t=e.shift();e.shift();var r={value:null,options:{}};return r.value=Number(e.shift()),"["===e[0]&&(r.options=s(e)),e.shift(),{name:t,val:r}},y=function(e){e.shift();var t={},r={name:e.shift(),values:{},options:{}};if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("}"===e[0])return e.shift(),";"===e[0]&&e.shift(),r;if("option"!==e[0]){var n=p(e);null!==n&&(r.values[n.name]=n.val)}else t=b(e),r.options[t.name]=t.value}throw new Error("No closing tag for enum")},b=function(e){for(var t=null,r=null,n=function(e){return"true"===e||"false"!==e&&e.replace(/^"+|"+$/gm,"")};e.length;){if(";"===e[0])return e.shift(),{name:t,value:r};switch(e[0]){case"option":e.shift();var i="("===e[0];if(i&&e.shift(),t=e.shift(),i){if(")"!==e[0])throw new Error("Expected ) but found "+e[0]);e.shift()}"."===e[0][0]&&(t+=e.shift());break;case"=":if(e.shift(),null===t)throw new Error("Expected key for option with value: "+e[0]);if(r=n(e.shift()),"optimize_for"===t&&!/^(SPEED|CODE_SIZE|LITE_RUNTIME)$/.test(r))throw new Error("Unexpected value for option optimize_for: "+r);"{"===r&&(r=g(e));break;default:throw new Error("Unexpected token in option: "+e[0])}}},g=function(e){for(var t=function(e){return"true"===e||"false"!==e&&e.replace(/^"+|"+$/gm,"")},r={};e.length;){if("}"===e[0])return e.shift(),r;var n="("===e[0];n&&e.shift();var i=e.shift();if(n){if(")"!==e[0])throw new Error("Expected ) but found "+e[0]);e.shift()}var o=null;switch(e[0]){case":":if(void 0!==r[i])throw new Error("Duplicate option map key "+i);e.shift(),"{"===(o=t(e.shift()))&&(o=g(e)),r[i]=o,";"===e[0]&&e.shift();break;case"{":if(e.shift(),o=g(e),void 0===r[i]&&(r[i]=[]),!Array.isArray(r[i]))throw new Error("Duplicate option map key "+i);r[i].push(o);break;default:throw new Error("Unexpected token in option map: "+e[0])}}throw new Error("No closing tag for option map")},m=function(e){e.shift();var t=e.shift().replace(/^"+|"+$/gm,"");if(";"!==e[0])throw new Error("Unexpected token: "+e[0]+'. Expected ";"');return e.shift(),t},v=function(e){e.shift();var t={name:e.shift(),methods:[],options:{}};if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("}"===e[0])return e.shift(),";"===e[0]&&e.shift(),t;switch(e[0]){case"option":var r=b(e);if(void 0!==t.options[r.name])throw new Error("Duplicate option "+r.name);t.options[r.name]=r.value;break;case"rpc":t.methods.push(w(e));break;default:throw new Error("Unexpected token in service: "+e[0])}}throw new Error("No closing tag for service")},w=function(e){e.shift();var t={name:e.shift(),input_type:null,output_type:null,client_streaming:!1,server_streaming:!1,options:{}};if("("!==e[0])throw new Error("Expected ( but found "+e[0]);if(e.shift(),"stream"===e[0]&&(e.shift(),t.client_streaming=!0),t.input_type=e.shift(),")"!==e[0])throw new Error("Expected ) but found "+e[0]);if(e.shift(),"returns"!==e[0])throw new Error("Expected returns but found "+e[0]);if(e.shift(),"("!==e[0])throw new Error("Expected ( but found "+e[0]);if(e.shift(),"stream"===e[0]&&(e.shift(),t.server_streaming=!0),t.output_type=e.shift(),")"!==e[0])throw new Error("Expected ) but found "+e[0]);if(e.shift(),";"===e[0])return e.shift(),t;if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("}"===e[0])return e.shift(),";"===e[0]&&e.shift(),t;if("option"!==e[0])throw new Error("Unexpected token in rpc options: "+e[0]);var r=b(e);if(void 0!==t.options[r.name])throw new Error("Duplicate option "+r.name);t.options[r.name]=r.value}throw new Error("No closing tag for rpc")};e.exports=function(e){for(var t=n(e.toString()),r=0;rt.extensions.to)throw new Error(t.name+" does not declare "+e.tag+" as an extension number");t.fields.push(e)}))}))})),s.messages.forEach((function(e){e.fields.forEach((function(t){var r,n,o,a;if(t.options&&"true"===t.options.packed&&-1===i.indexOf(t.type)){if(-1===t.type.indexOf(".")){if(e.enums&&e.enums.some((function(e){return e.name===t.type})))return}else{if((r=t.type.split(".")).length>2)throw new Error("what is this?");if(n=r[0],o=r[1],s.messages.some((function(e){if(e.name===n)return a=e,e})),a&&a.enums&&a.enums.some((function(e){return e.name===o})))return}throw new Error("Fields of type "+t.type+' cannot be declared [packed=true]. Only repeated fields of primitive numeric types (types which use the varint, 32-bit, or 64-bit wire types) can be declared "packed". See https://developers.google.com/protocol-buffers/docs/encoding#optional')}}))})),s}},function(e,t){e.exports=function(e){var t,r,n=function(e){return e.trim()},i=[];return e.replace(/"(\\"|[^"\n])*?"|'(\\'|[^'\n])*?'/gm,(r=i,function(e){var t="$"+r.length+"$";return r.push(e),t})).replace(/([;,{}()=:[\]<>]|\/\*|\*\/)/g," $1 ").split(/\n/).map(n).filter(Boolean).map((function(e){var t=e.indexOf("//");return t>-1?e.slice(0,t):e})).map(n).filter(Boolean).join("\n").split(/\s+|\n+/gm).filter((t=!1,function(e){return"/*"===e?(t=!0,!1):"*/"===e?(t=!1,!1):!t})).map(function(e){var t=/^\$(\d+)\$$/;return function(r){var n=r.match(t);return n?e[+n[1]]:r}}(i))}},function(e,t){var r=function(e,t){var r=e.repeated?"repeated":e.required?"required":"optional";"map"===e.type&&(r="map<"+e.map.from+","+e.map.to+">"),e.oneof&&(r="");var n=Object.keys(e.options||{}).map((function(t){return t+" = "+e.options[t]})).join(",");return n&&(n=" ["+n+"]"),t.push((r?r+" ":"")+("map"===e.map?"":e.type+" ")+e.name+" = "+e.tag+n+";"),t},n=function(e,t){t.push("message "+e.name+" {"),e.options||(e.options={}),s(e.options,t),e.enums||(e.enums=[]),e.enums.forEach((function(e){t.push(i(e,[]))})),e.messages||(e.messages=[]),e.messages.forEach((function(e){t.push(n(e,[]))}));var o={};return e.fields||(e.fields=[]),e.fields.forEach((function(e){e.oneof?(o[e.oneof]||(o[e.oneof]=[]),o[e.oneof].push(r(e,[]))):t.push(r(e,[]))})),Object.keys(o).forEach((function(e){o[e].unshift("oneof "+e+" {"),o[e].push("}"),t.push(o[e])})),t.push("}",""),t},i=function(e,t){t.push("enum "+e.name+" {"),e.options||(e.options={});var r=s(e.options,[]);return r.length>1&&t.push(r.slice(0,-1)),Object.keys(e.values).map((function(r){var n=o(e.values[r]);t.push([r+" = "+n+";"])})),t.push("}",""),t},o=function(e,t){var r=Object.keys(e.options||{}).map((function(t){return t+" = "+e.options[t]})).join(",");return r&&(r=" ["+r+"]"),e.value+r},s=function(e,t){var r=Object.keys(e);return r.forEach((function(r){var n=e[r];~r.indexOf(".")&&(r="("+r+")");var i=typeof n;"object"===i?(n=a(n,[])).length&&t.push("option "+r+" = {",n,"};"):("string"===i&&"optimize_for"!==r&&(n='"'+n+'"'),t.push("option "+r+" = "+n+";"))})),r.length>0&&t.push(""),t},a=function(e,t){return Object.keys(e).forEach((function(r){var n=e[r],i=typeof n;"object"===i?Array.isArray(n)?n.forEach((function(e){(e=a(e,[])).length&&t.push(r+" {",e,"}")})):(n=a(n,[])).length&&t.push(r+" {",n,"}"):("string"===i&&(n='"'+n+'"'),t.push(r+": "+n))})),t},c=function(e,t){var r="rpc "+e.name+"(";e.client_streaming&&(r+="stream "),r+=e.input_type+") returns (",e.server_streaming&&(r+="stream "),r+=e.output_type+")",e.options||(e.options={});var n=s(e.options,[]);return n.length>1?t.push(r+" {",n.slice(0,-1),"}"):t.push(r+";"),t},u=function(e){return function(t){return Array.isArray(t)?t.map(u(e+" ")).join("\n"):e+t}};e.exports=function(e){var t=[];return t.push('syntax = "proto'+e.syntax+'";',""),e.package&&t.push("package "+e.package+";",""),e.imports&&e.imports.forEach((function(e){!function(e,t){t.push('import "'+e+'";',"")}(e,t)})),e.options||(e.options={}),s(e.options,t),e.enums||(e.enums=[]),e.enums.forEach((function(e){i(e,t)})),e.messages||(e.messages=[]),e.messages.forEach((function(e){n(e,t)})),e.services&&e.services.forEach((function(e){!function(e,t){t.push("service "+e.name+" {"),e.options||(e.options={}),s(e.options,t),e.methods||(e.methods=[]),e.methods.forEach((function(e){t.push(c(e,[]))})),t.push("}","")}(e,t)})),t.map(u("")).join("\n")}},function(e,t,r){"use strict";var n=r(355),i=r(364),o=r(365),s=r(366),a=r(43);e.exports=function(e,t){var r={},c={},u={},f=function(e,t){e.enums&&e.enums.forEach((function(e){e.id=t+(t?".":"")+e.name,c[e.id]=e,f(e,e.id)})),e.messages&&e.messages.forEach((function(n){n.id=t+(t?".":"")+n.name,r[n.id]=n,n.fields.forEach((function(n){if(n.map){var i="Map_"+n.map.from+"_"+n.map.to,o={name:i,enums:[],messages:[],fields:[{name:"key",type:n.map.from,tag:1,repeated:!1,required:!0},{name:"value",type:n.map.to,tag:2,repeated:!1,required:!1}],extensions:null,id:t+(t?".":"")+i};r[o.id]||(r[o.id]=o,e.messages.push(o)),n.type=i,n.repeated=!0}})),f(n,n.id)}))};f(e,"");var h=function(e,t){e.messages.forEach((function(r){t[r.name]=l(r.name,e.id)})),e.enums.forEach((function(e){t[e.name]=function(e){if(!e)return null;var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].value})),t}(e.values)})),t.type=2,t.message=!0,t.name=e.name;var r={};e.fields.forEach((function(e){e.oneof&&(r[e.oneof]||(r[e.oneof]=[]),r[e.oneof].push(e.name))}));var n=e.fields.map((function(t){return l(t.type,e.id)})),a=s(e,n,r),c=o(e,l,n,r,a),u=i(e,l,n);return c.bytes=u.bytes=0,t.buffer=!0,t.encode=c,t.decode=u,t.encodingLength=a,t},l=function(e,i,o){if(t&&t[e])return t[e];if(n[e])return n[e];var s,f,l=(i?i+"."+e:e).split(".").map((function(t,r,n){return n.slice(0,r).concat(e).join(".")})).reverse().reduce((function(e,t){return e||r[t]||c[t]}),null);if(!1===o)return l;if(!l)throw new Error("Could not resolve "+e);return l.values?(s=l,f=Object.keys(s.values||[]).map((function(e){return parseInt(s.values[e].value,10)})),n.make(0,(function e(t,r,n){if(!f.length||-1===f.indexOf(t))throw new Error("Invalid enum value: "+t);return a.encode(t,r,n),e.bytes=a.encode.bytes,r}),(function e(t,r){var n=a.decode(t,r);if(!f.length||-1===f.indexOf(n))throw new Error("Invalid enum value: "+n);return e.bytes=a.decode.bytes,n}),a.encodingLength)):u[l.id]||h(l,u[l.id]={})};return(e.enums||[]).concat((e.messages||[]).map((function(e){return l(e.id)})))}},function(e,t,r){"use strict";var n=r(43),i=r(359);const{Buffer:o}=r(0);var s,a,c,u=function(e,t,r,n){return t.bytes=r.bytes=0,{type:e,encode:t,decode:r,encodingLength:n}};t.make=u,t.bytes=(s=function(e){return o.isBuffer(e)?e.length:o.byteLength(e)},u(2,a=function(e,t,r){var i=r,o=s(e);return n.encode(o,t,r),r+=n.encode.bytes,e instanceof Uint8Array?t.set(e,r):t.write(e,r,o),r+=o,a.bytes=r-i,t},c=function(e,t){var r=t,i=n.decode(e,t);t+=n.decode.bytes;var o=e.slice(t,t+i);return t+=o.length,c.bytes=t-r,o},(function(e){var t=s(e);return n.encodingLength(t)+t}))),t.string=function(){var e=function(t,r,i){var s=i,a=o.byteLength(t);return n.encode(a,r,i,"utf-8"),i+=n.encode.bytes,r.write(t,i,a),i+=a,e.bytes=i-s,r},t=function(e,r){var i=r,o=n.decode(e,r);r+=n.decode.bytes;var s=e.toString("utf-8",r,r+o);return r+=o,t.bytes=r-i,s};return u(2,e,t,(function(e){var t=o.byteLength(e);return n.encodingLength(t)+t}))}(),t.bool=function(){var e=function(t,r,n){return r[n]=t?1:0,e.bytes=1,r},t=function(e,r){var n=e[r]>0;return t.bytes=1,n};return u(0,e,t,(function(e){return 1}))}(),t.int32=function(){var e=function(t,r){var i=n.decode(t,r);return e.bytes=n.decode.bytes,i>2147483647?i-4294967296:i},t=function(e,r,i){return n.encode(e<0?e+4294967296:e,r,i),t.bytes=n.encode.bytes,r};return u(0,t,e,(function(e){return n.encodingLength(e<0?e+4294967296:e)}))}(),t.int64=function(){var e=function(t,r){var i=n.decode(t,r);if(i>=Math.pow(2,63)){for(var s=9;255===t[r+s-1];)s--;s=s||9;var a=o.allocUnsafe(s);t.copy(a,0,r,r+s),a[s-1]=127&a[s-1],i=-1*n.decode(a,0),e.bytes=10}else e.bytes=n.decode.bytes;return i},t=function(e,r,i){if(e<0){var o=i+9;for(n.encode(-1*e,r,i),r[i+=n.encode.bytes-1]=128|r[i];i=r;)n[i++]=255&t|128,t/=128;for(;-128&t;)n[i++]=255&t|128,t>>>=7;return n[i]=0|t,e.bytes=i-o+1,n};var r=Math.pow(2,31)},function(e,t){e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},function(e,t){var r=Math.pow(2,7),n=Math.pow(2,14),i=Math.pow(2,21),o=Math.pow(2,28),s=Math.pow(2,35),a=Math.pow(2,42),c=Math.pow(2,49),u=Math.pow(2,56),f=Math.pow(2,63);e.exports=function(e){return e=0?2*t:-2*t-1;var o=n.encode(t,r,i);return e.bytes=n.encode.bytes,o},t.decode=function e(t,r){var i=n.decode(t,r);return e.bytes=n.decode.bytes,1&i?(i+1)/-2:i/2},t.encodingLength=function(e){return n.encodingLength(e>=0?2*e:-2*e-1)}},function(e,t,r){e.exports={encode:r(361),decode:r(362),encodingLength:r(363)}},function(e,t){e.exports=function e(t,n,i){n=n||[];var o=i=i||0;for(;t>=r;)n[i++]=255&t|128,t/=128;for(;-128&t;)n[i++]=255&t|128,t>>>=7;return n[i]=0|t,e.bytes=i-o+1,n};var r=Math.pow(2,31)},function(e,t){e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},function(e,t){var r=Math.pow(2,7),n=Math.pow(2,14),i=Math.pow(2,21),o=Math.pow(2,28),s=Math.pow(2,35),a=Math.pow(2,42),c=Math.pow(2,49),u=Math.pow(2,56),f=Math.pow(2,63);e.exports=function(e){return e{r=e},get:()=>void 0===r?n:r},["has"+i]:{configurable:!0,value:()=>void 0!==r},["set"+i]:{configurable:!0,value:e=>{r=e}},["get"+i]:{configurable:!0,value:()=>r},["clear"+i]:{configurable:!0,value:()=>{r=void 0,e[t]=void 0}}})}var a=function(e,t,r){switch(e){case 0:return n.decode(t,r),r+n.decode.bytes;case 1:return r+8;case 2:var i=n.decode(t,r);return r+n.decode.bytes+i;case 3:case 4:throw new Error("Groups are not supported");case 5:return r+4;default:throw new Error("Unknown wire type: "+e)}},c=function(e){if(e.map)return{};if(e.repeated)return[];switch(e.type){case"string":return"";case"bool":return!1;case"float":case"double":case"sfixed32":case"fixed32":case"varint":case"enum":case"uint64":case"uint32":case"int64":case"int32":case"sint64":case"sint32":return 0;default:return null}},u=function(e,t){if(void 0===t)return t;switch(e.type){case"bool":return"true"===t;case"float":case"double":case"sfixed32":case"fixed32":case"varint":case"enum":case"uint64":case"uint32":case"int64":case"int32":case"sint64":case"sint32":return parseInt(t,10);default:return t}};e.exports=function(e,t,r){for(var f=[],h={},l=[],d=[],p=0;p-1){const e=o(f[h]);delete r["has"+e],delete r["get"+e],delete r["set"+e],delete r["clear"+e],delete r[f[h]]}let d;if(e.message){var p=n.decode(i,a);a+=n.decode.bytes;var y=e.decode(i,a,a+p);t.map?(d=r[u]||{},d[y.key]=y.value):t.repeated?(d=r[u]||[],d.push(y)):d=y}else t.repeated?(d=r[u]||[],d.push(e.decode(i,a))):d=e.decode(i,a);return s(r,u,d),a+=e.decode.bytes}return function t(o,p,y){if(null==p&&(p=0),null==y&&(y=o.length),!(y<=o.length&&p<=o.length))throw new Error("Decoded message is not valid");for(var b,g=p,v={};;){if(y<=p){var w,_,S="",E=0;for(E=0;E-1){k=!0;break}k||(w?b.repeated?_=[]:(_=_&&w[_]?w[_].value:w[Object.keys(w)[0]].value,_=parseInt(_||0,10)):(t=c(b),_=u(b,_)),s(v,S,_,t))}}return t.bytes=p-g,v}var I=n.decode(o,p);p+=n.decode.bytes;var T=h[I>>3];if(null!=T){var x=r[T];if((b=e.fields[T]).packed){var B=n.decode(o,p);for(B+=p+=n.decode.bytes;p-1){if(m)throw new Error("only one of the properties defined in oneof "+v+" can be set");m=!0}}for(g=0;g0;)a.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),o=[0];for(r=0;r0;)o.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[o[r]];return c}(e,t);if(r){var f=new RegExp(".{1,"+r+"}","g");n=n.match(f).join("\r\n")}return n},r.decode=function(e,r){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof r)throw new TypeError('"alphabet" must be a string.');var i=n[r];if(!i){i=n[r]=[];for(var o=0;o>=8;for(;h>0;)c.push(255&h),h>>=8}for(var l=0;e[l]===a&&l>24&255,s>>16&255,s>>8&255,255&s);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,s,a,c;"string"==typeof r?(i=r,s=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,s=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),f=u-2*a.digestLength-2;if(t.length>f)throw(b=new Error("RSAES-OAEP input message length is too long.")).length=t.length,b.maxLength=f,b;i||(i=""),a.update(i,"raw");for(var h=a.digest(),l="",d=f-t.length,p=0;p>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(o),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var f=8*i.fullMessageLength[0],h=0;h>>0,s.putInt32(f>>>0),f=a>>>0;s.putInt32(f);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(l,r,s);var d=n.util.createBuffer();return d.putInt32(l.h0),d.putInt32(l.h1),d.putInt32(l.h2),d.putInt32(l.h3),d.putInt32(l.h4),d.putInt32(l.h5),d.putInt32(l.h6),d.putInt32(l.h7),d},i};var o=null,s=!1,a=null;function c(e,t,r){for(var n,i,o,s,c,u,f,h,l,d,p,y,b,g=r.length();g>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,f=e.h1,h=e.h2,l=e.h3,d=e.h4,p=e.h5,y=e.h6,b=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&f|h&(u^f),n=b+((d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(y^d&(p^y))+a[c]+t[c],b=y,y=p,p=d,d=l+n>>>0,l=h,h=f,f=u,u=n+(i=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+f|0,e.h2=e.h2+h|0,e.h3=e.h3+l|0,e.h4=e.h4+d|0,e.h5=e.h5+p|0,e.h6=e.h6+y|0,e.h7=e.h7+b|0,g-=64}}},function(e,t,r){(function(t){var n=r(4);r(5);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||t.versions["node-webkit"]||(i=r(80)),(e.exports=n.prng=n.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,o=new Array(32),s=0;s<32;++s)o[s]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var o=n.util.createBuffer();if(t)for(;o.length()>16)))<<16,l=4294967295&(f=(2147483647&(f+=u>>15))+(f>>31));for(c=0;c<3;++c)h=l>>>(c<<3),h^=Math.floor(256*Math.random()),o.putByte(String.fromCharCode(255&h))}return o.getBytes(e)}return t.pools=o,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,o=t.plugin.increment,s=t.plugin.formatKey,a=t.plugin.formatSeed,u=n.util.createBuffer();t.key=null,function f(h){if(h)return r(h);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(f)}));var l=i(t.key,t.seed);t.generated+=l.length,u.putBytes(l),t.key=s(i(t.key,o(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(f)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,o=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var c=n.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=o(r(t.key,i(t.seed))),t.seed=s(r(t.key,t.seed))}return c.getBytes(e)},i?(t.seedFile=function(e,t){i.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return i.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(e){t(e)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,n=0;n>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}}).call(this,r(2))},function(e,t,r){var n=r(4);r(5),r(78),r(33),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],o=new r(null);o.fromInt(30);var s=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"==typeof t&&(i=t,t={});var o=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof o&&(o={name:o}),o.options=o.options||{};var s=t.prng||n.random,u={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;re&&(s=c(e,t));var d=s.toString(16);i.target.postMessage({hex:d,workLoad:f}),s.dAddOffset(h,0)}}}d()}(e,t,i,o);return a(e,t,i,o)}(e,u,o.options,i);throw new Error("Invalid prime generation algorithm: "+o.name)}}function a(e,t,r,o){var s=c(e,t),a=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(s.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),function e(t,r,o,s,a,u,f){var h=+new Date;do{if(t.bitLength()>r&&(t=c(r,o)),t.isProbablePrime(a))return f(null,t);t.dAddOffset(i[s++%8],0)}while(u<0||+new Date-h>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"==typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,o=e,s=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=s;r<128;r++)o.putByte(i[o.at(r-1)+o.at(r-s)&255]);for(o.setAt(128-c,i[o.at(128-c)&u]),r=127-c;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+c)]);return o};var c=function(e,t,r){var i,c,u,f,h=!1,l=null,d=null,p=null,y=[];for(e=n.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());r?(i=function(e){for(u=0;u<4;u++)e[u]+=y[f]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=s(e[u],o[u]),f++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(i=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],o[u]),e[u]-=y[f]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),f--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var b=function(e){var t=[];for(u=0;u<4;u++){var n=l.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}f=r?0:63;for(var i=0;i=8;)b([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,l,!r);else{var n=8===l.length()?8:8-l.length();l.fillWithByte(n,n)}if(t&&(h=!0,g.update()),!r&&(t=0===l.length()))if(e)t=e(8,d,!r);else{var i=d.length(),o=d.at(i-1);o>i?t=!1:d.truncate(o)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},function(e,t,r){"use strict";const n=r(167),i=r(75),o=r(84),s=r(175),a=r(394),c=i(r(77));r(410),r(52);const u=r(4);class f{constructor(e){this._key=e}verify(e,t,r){d(r),a.hashAndVerify(this._key,t,e,r)}marshal(){return a.utils.jwkToPkix(this._key)}get bytes(){return c.PublicKey.encode({Type:c.KeyType.RSA,Data:this.marshal()})}encrypt(e,t){return h(()=>a.encrypt(this._key,e),t)}equals(e){return this.bytes.equals(e.bytes)}hash(e){d(e),n(this.bytes,"sha2-256",e)}}function h(e,t){let r;try{r=e()}catch(e){t(e)}return t(null,r)}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return a.getRandomValues(16)}sign(e,t){d(t),a.hashAndSign(this._key,e,t)}get public(){if(!this._publicKey)throw new Error("public key not provided");return new f(this._publicKey)}decrypt(e,t){h(()=>a.decrypt(this._key,e),t)}marshal(){return a.utils.jwkToPkcs1(this._key)}get bytes(){return c.PrivateKey.encode({Type:c.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){d(e),n(this.bytes,"sha2-256",e)}id(e){this.public.hash((t,r)=>{if(t)return e(t);e(null,o.encode(r))})}export(e,t,r){"function"==typeof t&&(r=t,t=e,e="pkcs-8"),d(r),s(()=>{let n=null,i=null;try{const r=new u.util.ByteBuffer(this.marshal()),o=u.asn1.fromDer(r),s=u.pki.privateKeyFromAsn1(o);if("pkcs-8"===e){const e={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};i=u.pki.encryptRsaPrivateKey(s,t,e)}else n=new Error(`Unknown export format '${e}'`)}catch(e){n=e}r(n,i)})}}function d(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=a.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=a.utils.pkcs1ToJwk(e);a.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){a.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){a.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";const{Buffer:n}=r(0),i=r(375),o=r(381),s=r(385);function a(e){t.decode(e)}t.names=s.names,t.codes=s.codes,t.defaultLengths=s.defaultLengths,t.toHexString=function(e){if(!n.isBuffer(e))throw new Error("must be passed a buffer");return e.toString("hex")},t.fromHexString=function(e){return n.from(e,"hex")},t.toB58String=function(e){if(!n.isBuffer(e))throw new Error("must be passed a buffer");return i.encode("base58btc",e).toString().slice(1)},t.fromB58String=function(e){let t=e;return n.isBuffer(e)&&(t=e.toString()),i.decode("z"+t)},t.decode=function(e){if(!n.isBuffer(e))throw new Error("multihash must be a Buffer");if(e.length<2)throw new Error("multihash too short. must be > 2 bytes.");const r=o.decode(e);if(!t.isValidCode(r))throw new Error("multihash unknown function code: 0x"+r.toString(16));e=e.slice(o.decode.bytes);const i=o.decode(e);if(i<0)throw new Error("multihash invalid length: "+i);if((e=e.slice(o.decode.bytes)).length!==i)throw new Error("multihash length inconsistent: 0x"+e.toString("hex"));return{code:r,name:s.codes[r],length:i,digest:e}},t.encode=function(e,r,i){if(!e||void 0===r)throw new Error("multihash encode requires at least two args: digest, code");const s=t.coerceCode(r);if(!n.isBuffer(e))throw new Error("digest should be a Buffer");if(null==i&&(i=e.length),i&&e.length!==i)throw new Error("digest length should be equal to specified length.");return n.concat([n.from(o.encode(s)),n.from(o.encode(i)),e])},t.coerceCode=function(e){let r=e;if("string"==typeof e){if(void 0===s.names[e])throw new Error("Unrecognized hash function named: "+e);r=s.names[e]}if("number"!=typeof r)throw new Error("Hash function code should be a number. Got: "+r);if(void 0===s.codes[r]&&!t.isAppCode(r))throw new Error("Unrecognized function code: "+r);return r},t.isAppCode=function(e){return e>0&&e<16},t.isValidCode=function(e){return!!t.isAppCode(e)||!!s.codes[e]},t.validate=a,t.prefix=function(e){return a(e),e.slice(0,2)}},function(e,t,r){"use strict";const{Buffer:n}=r(0),i=r(376);function o(e,t){if(!t)throw new Error("requires an encoded buffer");const r=s(e),i=n.from(r.code);return function(e,t){s(e).decode(t.toString())}(r.name,t),n.concat([i,t])}function s(e){let t;if(i.names[e])t=i.names[e];else{if(!i.codes[e])throw new Error("Unsupported encoding");t=i.codes[e]}if(!t.isImplemented())throw new Error("Base "+e+" is not implemented yet");return t}(t=e.exports=o).encode=function(e,t){const r=s(e);return o(r.name,n.from(r.encode(t)))},t.decode=function(e){n.isBuffer(e)&&(e=e.toString());const t=e.substring(0,1);"string"==typeof(e=e.substring(1,e.length))&&(e=n.from(e));const r=s(t);return n.from(r.decode(e.toString()))},t.isEncoded=function(e){n.isBuffer(e)&&(e=e.toString());if("[object String]"!==Object.prototype.toString.call(e))return!1;const t=e.substring(0,1);try{return s(t).name}catch(e){return!1}},t.names=Object.freeze(Object.keys(i.names)),t.codes=Object.freeze(Object.keys(i.codes))},function(e,t,r){"use strict";const n=r(377),i=r(83),o=r(378),s=r(379),a=r(380),c=[["base1","1","","1"],["base2","0",i,"01"],["base8","7",i,"01234567"],["base10","9",i,"0123456789"],["base16","f",o,"0123456789abcdef"],["base32","b",s,"abcdefghijklmnopqrstuvwxyz234567"],["base32pad","c",s,"abcdefghijklmnopqrstuvwxyz234567="],["base32hex","v",s,"0123456789abcdefghijklmnopqrstuv"],["base32hexpad","t",s,"0123456789abcdefghijklmnopqrstuv="],["base32z","h",s,"ybndrfg8ejkmcpqxot1uwisza345h769"],["base58flickr","Z",i,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base58btc","z",i,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base64","m",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],u=c.reduce((e,t)=>(e[t[0]]=new n(t[0],t[1],t[2],t[3]),e),{}),f=c.reduce((e,t)=>(e[t[1]]=u[t[0]],e),{});e.exports={names:u,codes:f}},function(e,t,r){"use strict";e.exports=class{constructor(e,t,r,n){this.name=e,this.code=t,this.alphabet=n,r&&n&&(this.engine=r(n))}encode(e){return this.engine.encode(e)}decode(e){return this.engine.decode(e)}isImplemented(){return this.engine}}},function(e,t,r){"use strict";const{Buffer:n}=r(0);e.exports=function(e){return{encode:e=>"string"==typeof e?n.from(e).toString("hex"):e.toString("hex"),decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base16 character");return n.from(t,"hex")}}}},function(e,t,r){"use strict";function n(e,t){const r=e.byteLength,n=new Uint8Array(e),i=t.indexOf("=")===t.length-1;i&&(t=t.substring(0,t.length-1));let o=0,s=0,a="";for(let e=0;e=5;)a+=t[s>>>o-5&31],o-=5;if(o>0&&(a+=t[s<<5-o&31]),i)for(;a.length%8!=0;)a+="=";return a}e.exports=function(e){return{encode:t=>n("string"==typeof t?Uint8Array.from(t):t,e),decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base32 character");return function(e,t){const r=(e=e.replace(new RegExp("=","g"),"")).length;let n=0,i=0,o=0;const s=new Uint8Array(5*r/8|0);for(let a=0;a=8&&(s[o++]=i>>>n-8&255,n-=8);return s.buffer}(t,e)}}}},function(e,t,r){"use strict";const{Buffer:n}=r(0);e.exports=function(e){const t=e.indexOf("=")>-1,r=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let i="";i="string"==typeof e?n.from(e).toString("base64"):e.toString("base64"),r&&(i=i.replace(/\+/g,"-").replace(/\//g,"_"));const o=i.indexOf("=");return o>0&&!t&&(i=i.substring(0,o)),i},decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base64 character");return n.from(t,"base64")}}}},function(e,t,r){e.exports={encode:r(382),decode:r(383),encodingLength:r(384)}},function(e,t){e.exports=function e(t,n,i){n=n||[];var o=i=i||0;for(;t>=r;)n[i++]=255&t|128,t/=128;for(;-128&t;)n[i++]=255&t|128,t>>>=7;return n[i]=0|t,e.bytes=i-o+1,n};var r=Math.pow(2,31)},function(e,t){e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},function(e,t){var r=Math.pow(2,7),n=Math.pow(2,14),i=Math.pow(2,21),o=Math.pow(2,28),s=Math.pow(2,35),a=Math.pow(2,42),c=Math.pow(2,49),u=Math.pow(2,56),f=Math.pow(2,63);e.exports=function(e){return e{s.sha2256(e,(e,n)=>{e&&r(e),s.sha2256(t.from(n),r)})}}}).call(this,r(0).Buffer)},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){!function(r,n){"use strict";var i={version:"3.0.1",x86:{},x64:{}};function o(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function s(e,t){return e<>>32-t}function a(e){return e=o(e^=e>>>16,2246822507),e=o(e^=e>>>13,3266489909),e^=e>>>16}function c(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function u(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function f(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])}function h(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=l(e=u(e,[4283543511,3981806797]),[0,e[0]>>>1]),e=l(e=u(e,[3301882366,444984403]),[0,e[0]>>>1])}i.x86.hash32=function(e,t){t=t||0;for(var r=(e=e||"").length%4,n=e.length-r,i=t,c=0,u=3432918353,f=461845907,h=0;h>>0},i.x86.hash128=function(e,t){t=t||0;for(var r=(e=e||"").length%16,n=e.length-r,i=t,c=t,u=t,f=t,h=0,l=0,d=0,p=0,y=597399067,b=2869860233,g=951274213,m=2716044179,v=0;v>>0).toString(16)).slice(-8)+("00000000"+(c>>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)},i.x64.hash128=function(e,t){t=t||0;for(var r=(e=e||"").length%16,n=e.length-r,i=[0,t],o=[0,t],s=[0,0],a=[0,0],p=[2277735313,289559509],y=[1291169091,658871167],b=0;b>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)+("00000000"+(o[0]>>>0).toString(16)).slice(-8)+("00000000"+(o[1]>>>0).toString(16)).slice(-8)},e.exports&&(t=e.exports=i),t.murmurHash3=i}()},function(e,t,r){"use strict";(function(t){const n=r(171),i=function(){if(self.crypto)return self.crypto.subtle||self.crypto.webkitSubtle;if(self.msCrypto)return self.msCrypto.subtle}();function o(e){if(!i)throw new Error("Please use a browser with webcrypto support and ensure the code has been delivered securely via HTTPS/TLS and run within a Secure Context");return(r,o)=>{const s=i.digest({name:e},r);if("function"!=typeof s.then)return s.onerror=()=>{o(new Error("hashing data using "+e))},void(s.oncomplete=e=>{o(null,e.target.result)});n(s.then(e=>t.from(new Uint8Array(e))),o)}}e.exports={sha1:function(e,t){o("SHA-1")(e,t)},sha2256:function(e,t){o("SHA-256")(e,t)},sha2512:function(e,t){o("SHA-512")(e,t)}}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){var n,i=r(172);n="function"==typeof setImediate?setImediate:"object"==typeof t&&t&&t.nextTick?t.nextTick:function(e){setTimeout(e,0)};var o=[];function s(e){if(!(this instanceof s))return"function"==typeof e?new s(e):(r=new s((function(e){t=e})),{resolver:t,promise:r});var t,r,a,c=!1,u=!1,f=[],h=!1;function l(e){f.length?(h=!0,f.shift()(e||!1)):h=!1}this.then=function(e,t){return new s((function(r){f.push((function(i){var o=u?e:t;if("function"==typeof o){function s(){var e;try{e=o(a)}catch(e){return r.reject(e),l()}r.fulfill(e),l(!0)}i?s():n(s)}else u?(r.fulfill(a),l(i)):(r.reject(a),l(i))})),c&&!h&&l()}))},function(){function t(e){c||(c=!0,u=!1,a=e,l())}for(var r={fulfill:function e(r){c||(i(r)?r.then(e,t):(c=u=!0,a=r,l()))},reject:t},n=0;ni(n=>{const i=r.init(e,null);return r.update(i,n),t.from(r.digest(i))});e.exports=e=>{for(let t=0;t<64;t++)e[45569+t]=a(t+1,o);for(let t=0;t<32;t++)e[45633+t]=a(t+1,s)}}).call(this,r(0).Buffer)},function(e,t,r){const n=r(174);function i(e,t,r){const n=e[t]+e[r];let i=e[t+1]+e[r+1];n>=4294967296&&i++,e[t]=n,e[t+1]=i}function o(e,t,r,n){let i=e[t]+r;r<0&&(i+=4294967296);let o=e[t+1]+n;i>=4294967296&&o++,e[t]=i,e[t+1]=o}function s(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function a(e,t,r,n,s,a){const c=h[s],u=h[s+1],l=h[a],d=h[a+1];i(f,e,t),o(f,e,c,u);let p=f[n]^f[e],y=f[n+1]^f[e+1];f[n]=y,f[n+1]=p,i(f,r,n),p=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=p>>>24^y<<8,f[t+1]=y>>>24^p<<8,i(f,e,t),o(f,e,l,d),p=f[n]^f[e],y=f[n+1]^f[e+1],f[n]=p>>>16^y<<16,f[n+1]=y>>>16^p<<16,i(f,r,n),p=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=y>>>31^p<<1,f[t+1]=p>>>31^y<<1}const c=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),f=new Uint32Array(32),h=new Uint32Array(32);function l(e,t){let r=0;for(r=0;r<16;r++)f[r]=e.h[r],f[r+16]=c[r];for(f[24]=f[24]^e.t,f[25]=f[25]^e.t/4294967296,t&&(f[28]=~f[28],f[29]=~f[29]),r=0;r<32;r++)h[r]=s(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,u[16*r+0],u[16*r+1]),a(2,10,18,26,u[16*r+2],u[16*r+3]),a(4,12,20,28,u[16*r+4],u[16*r+5]),a(6,14,22,30,u[16*r+6],u[16*r+7]),a(0,10,20,30,u[16*r+8],u[16*r+9]),a(2,12,22,24,u[16*r+10],u[16*r+11]),a(4,14,16,26,u[16*r+12],u[16*r+13]),a(6,8,18,28,u[16*r+14],u[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^f[r]^f[r+16]}function d(e,t){if(0===e||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");const r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e};for(let e=0;e<16;e++)r.h[e]=c[e];const n=t?t.length:0;return r.h[0]^=16842752^n<<8^e,t&&(p(r,t),r.c=128),r}function p(e,t){for(let r=0;r>2]>>8*(3&r);return t}function b(e,t,r){r=r||64,e=n.normalizeInput(e);const i=d(r,t);return p(i,e),y(i)}e.exports={blake2b:b,blake2bHex:function(e,t,r){const i=b(e,t,r);return n.toHex(i)},blake2bInit:d,blake2bUpdate:p,blake2bFinal:y}},function(e,t,r){const n=r(174);function i(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function o(e,t,r,n,i,o){u[e]=u[e]+u[t]+i,u[n]=s(u[n]^u[e],16),u[r]=u[r]+u[n],u[t]=s(u[t]^u[r],12),u[e]=u[e]+u[t]+o,u[n]=s(u[n]^u[e],8),u[r]=u[r]+u[n],u[t]=s(u[t]^u[r],7)}function s(e,t){return e>>>t^e<<32-t}const a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),u=new Uint32Array(16),f=new Uint32Array(16);function h(e,t){let r=0;for(r=0;r<8;r++)u[r]=e.h[r],u[r+8]=a[r];for(u[12]^=e.t,u[13]^=e.t/4294967296,t&&(u[14]=~u[14]),r=0;r<16;r++)f[r]=i(e.b,4*r);for(r=0;r<10;r++)o(0,4,8,12,f[c[16*r+0]],f[c[16*r+1]]),o(1,5,9,13,f[c[16*r+2]],f[c[16*r+3]]),o(2,6,10,14,f[c[16*r+4]],f[c[16*r+5]]),o(3,7,11,15,f[c[16*r+6]],f[c[16*r+7]]),o(0,5,10,15,f[c[16*r+8]],f[c[16*r+9]]),o(1,6,11,12,f[c[16*r+10]],f[c[16*r+11]]),o(2,7,8,13,f[c[16*r+12]],f[c[16*r+13]]),o(3,4,9,14,f[c[16*r+14]],f[c[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=u[r]^u[r+8]}function l(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");const r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");const n={h:new Uint32Array(a),b:new Uint8Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(d(n,t),n.c=64),n}function d(e,t){for(let r=0;r>2]>>8*(3&r)&255;return t}function y(e,t,r){r=r||32,e=n.normalizeInput(e);const i=l(r,t);return d(i,e),p(i)}e.exports={blake2s:y,blake2sHex:function(e,t,r){const i=y(e,t,r);return n.toHex(i)},blake2sInit:l,blake2sUpdate:d,blake2sFinal:p}},function(e,t,r){"use strict";(function(e){const n=r(71),i=r(72),o=r(86);function s(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(396),t.generateKey=function(e,t){n(i.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(s).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.unmarshalPrivateKey=function(e,t){const r=i.subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]);var o;n(Promise.all([r,(o=e,i.subtle.importKey("jwk",{kty:o.kty,n:o.n,e:o.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"]))]).then(e=>s({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=o,t.hashAndSign=function(t,r,o){n(i.subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]).then(e=>i.subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,Uint8Array.from(r))).then(t=>e.from(t)),o)},t.hashAndVerify=function(e,t,r,o){n(i.subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]).then(e=>i.subtle.verify({name:"RSASSA-PKCS1-v1_5"},e,t,r)),o)};const{jwk2pub:a,jwk2priv:c}=r(404);function u(t,r,n,i){const o=r?a(t):c(t),s=i(e.from(n).toString("binary"),o);return e.from(s,"binary")}t.encrypt=function(e,t){return u(e,!0,t,(e,t)=>t.encrypt(e))},t.decrypt=function(e,t){return u(e,!1,t,(e,t)=>t.decrypt(e))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=self.crypto||self.msCrypto,{Buffer:i}=r(0);n&&n.getRandomValues?e.exports=function(e){const t=new Uint8Array(e);let r=0;if(e>0)if(e>65536)for(;re?(n.getRandomValues(t.subarray(r,r+(e-r))),r+=e-r):(n.getRandomValues(t.subarray(r,r+65536)),r+=65536);else n.getRandomValues(t);return i.from(t)}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},function(e,t,r){"use strict";const n=r(87),i=r(181),o=i.toBase64,s=i.toBn,a=n.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())})),c=n.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid({"1.2.840.113549.1.1.1":"rsa"}),this.key("none").optional().null_(),this.key("curve").optional().objid(),this.key("params").optional().seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()))})),u=n.define("RSAPublicKey",(function(){this.seq().obj(this.key("algorithm").use(c),this.key("subjectPublicKey").bitstr())})),f=n.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));t.pkcs1ToJwk=function(e){const t=a.decode(e,"der");return{kty:"RSA",n:o(t.modulus),e:o(t.publicExponent),d:o(t.privateExponent),p:o(t.prime1),q:o(t.prime2),dp:o(t.exponent1),dq:o(t.exponent2),qi:o(t.coefficient),alg:"RS256",kid:"2011-04-29"}},t.jwkToPkcs1=function(e){return a.encode({version:0,modulus:s(e.n),publicExponent:s(e.e),privateExponent:s(e.d),prime1:s(e.p),prime2:s(e.q),exponent1:s(e.dp),exponent2:s(e.dq),coefficient:s(e.qi)},"der")},t.pkixToJwk=function(e){const t=u.decode(e,"der"),r=f.decode(t.subjectPublicKey.data,"der");return{kty:"RSA",n:o(r.modulus),e:o(r.publicExponent),alg:"RS256",kid:"2011-04-29"}},t.jwkToPkix=function(e){return u.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){},function(e,t,r){"use strict";const n=r(177),i=r(179),o=r(1);function s(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new s(e,t)},s.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return o(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},s.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i[e])),this.decoders[e]},s.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},s.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n[e])),this.encoders[e]},s.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},function(e,t,r){"use strict";const n=r(1),i=r(178);function o(e){i.call(this,e),this.enc="pem"}n(o,i),e.exports=o,o.prototype.encode=function(e,t){const r=i.prototype.encode.call(this,e).toString("base64"),n=["-----BEGIN "+t.label+"-----"];for(let e=0;e{return r=e[t],i=n.util.decode64((r+"===".slice((r.length+3)%4)).replace(/-/g,"+").replace(/_/g,"/")),new n.jsbn.BigInteger(n.util.bytesToHex(i),16);var r,i})}function o(e){return n.pki.setRsaPrivateKey(...i(e,["n","e","d","p","q","dp","dq","qi"]))}function s(e){return n.pki.setRsaPublicKey(...i(e,["n","e"]))}e.exports={jwk2pub:s,jwk2pubPem:function(e){return n.pki.publicKeyToPem(s(e))},jwk2priv:o,jwk2privPem:function(e){return n.pki.privateKeyToPem(o(e))}}},function(e,t,r){var n=r(4);r(23),r(32),r(52),r(82),r(81),r(406),r(183),r(44),r(5),r(182);var i=n.asn1,o=e.exports=n.pki=n.pki||{};o.pemToDer=function(e){var t=n.pem.decode(e)[0];if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return n.util.createBuffer(t.body)},o.privateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("PRIVATE KEY"!==t.type&&"RSA PRIVATE KEY"!==t.type){var r=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var s=i.fromDer(t.body);return o.privateKeyFromAsn1(s)},o.privateKeyToPem=function(e,t){var r={type:"RSA PRIVATE KEY",body:i.toDer(o.privateKeyToAsn1(e)).getBytes()};return n.pem.encode(r,{maxline:t})},o.privateKeyInfoToPem=function(e,t){var r={type:"PRIVATE KEY",body:i.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})}},function(e,t,r){var n=r(4);r(23),r(166),r(32),r(407),r(52),r(33),r(44),r(164),r(5),r(182);var i=n.asn1,o=n.pki,s=e.exports=n.pkcs12=n.pkcs12||{},a={name:"ContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:i.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},c={name:"PFX",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},a,{name:"PFX.macData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:i.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},u={name:"SafeBag",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:i.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},f={name:"Attribute",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,capture:"values"}]},h={name:"CertBag",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:i.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:i.Class.UNIVERSAL,type:i.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function l(e,t,r,n){for(var i=[],o=0;o=0&&i.push(a):i.push(a))}return i}function d(e){if(e.composed||e.constructed){for(var t=n.util.createBuffer(),r=0;r0&&(c=i.create(i.Class.UNIVERSAL,i.Type.SET,!0,h));var l=[],d=[];null!==t&&(d=n.util.isArray(t)?t:[t]);for(var p=[],y=0;y0){var v=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,p),w=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.oids.data).getBytes()),i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,i.toDer(v).getBytes())])]);l.push(w)}var _=null;if(null!==e){var S=o.wrapRsaPrivateKey(o.privateKeyToAsn1(e));_=null===r?i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.oids.keyBag).getBytes()),i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[S]),c]):i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.oids.pkcs8ShroudedKeyBag).getBytes()),i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[o.encryptPrivateKeyInfo(S,r,a)]),c]);var E=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[_]),k=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.oids.data).getBytes()),i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,i.toDer(E).getBytes())])]);l.push(k)}var A,C=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,l);if(a.useMac){var I=n.md.sha1.create(),T=new n.util.ByteBuffer(n.random.getBytes(a.saltSize)),x=a.count,B=(e=s.generateKey(r,T,3,x,20),n.hmac.create());B.start(I,e),B.update(i.toDer(C).getBytes());var M=B.getMac();A=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.oids.sha1).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,M.getBytes())]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,T.getBytes()),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(x).getBytes())])}return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(3).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.oids.data).getBytes()),i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,i.toDer(C).getBytes())])]),A])},s.generateKey=n.pbe.generatePkcs12Key},function(e,t,r){var n=r(4);r(23),r(5);var i=n.asn1,o=e.exports=n.pkcs7asn1=n.pkcs7asn1||{};n.pkcs7=n.pkcs7||{},n.pkcs7.asn1=o;var s={name:"ContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};o.contentInfoValidator=s;var a={name:"EncryptedContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};o.envelopedDataValidator={name:"EnvelopedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(a)},o.encryptedDataValidator={name:"EncryptedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"}].concat(a)};var c={name:"SignerInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};o.signedDataValidator={name:"SignedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},s,{name:"SignedData.Certificates",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,capture:"signerInfos",optional:!0,value:[c]}]},o.recipientInfoValidator={name:"RecipientInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},function(e,t,r){var n=r(4);r(409),e.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1},function(e,t,r){var n=r(4);r(5),n.mgf=n.mgf||{},(e.exports=n.mgf.mgf1=n.mgf1=n.mgf1||{}).create=function(e){return{generate:function(t,r){for(var i=new n.util.ByteBuffer,o=Math.ceil(r/e.digestLength),s=0;s>>0,s>>>0];for(var a=d.fullMessageLength.length-1;a>=0;--a)d.fullMessageLength[a]+=s[1],s[1]=s[0]+(d.fullMessageLength[a]/4294967296>>>0),d.fullMessageLength[a]=d.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(e),f(r,o,i),(i.read>2048||0===i.length())&&i.compact(),d},d.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;t.putBytes(s.substr(0,d.blockLength-c));for(var u=8*d.fullMessageLength[0],h=0;h>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var l=new Array(r.length);for(h=0;h=128;){for(B=0;B<16;++B)t[B][0]=r.getInt32()>>>0,t[B][1]=r.getInt32()>>>0;for(;B<80;++B)n=(((M=(N=t[B-2])[0])>>>19|(R=N[1])<<13)^(R>>>29|M<<3)^M>>>6)>>>0,i=((M<<13|R>>>19)^(R<<3|M>>>29)^(M<<26|R>>>6))>>>0,o=(((M=(L=t[B-15])[0])>>>1|(R=L[1])<<31)^(M>>>8|R<<24)^M>>>7)>>>0,s=((M<<31|R>>>1)^(M<<24|R>>>8)^(M<<25|R>>>7))>>>0,O=t[B-7],P=t[B-16],R=i+O[1]+s+P[1],t[B][0]=n+O[0]+o+P[0]+(R/4294967296>>>0)>>>0,t[B][1]=R>>>0;for(p=e[0][0],y=e[0][1],b=e[1][0],g=e[1][1],m=e[2][0],v=e[2][1],w=e[3][0],_=e[3][1],S=e[4][0],E=e[4][1],k=e[5][0],A=e[5][1],C=e[6][0],I=e[6][1],T=e[7][0],x=e[7][1],B=0;B<80;++B)f=((S>>>14|E<<18)^(S>>>18|E<<14)^(E>>>9|S<<23))>>>0,h=(C^S&(k^C))>>>0,a=((p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25))>>>0,u=((p<<4|y>>>28)^(y<<30|p>>>2)^(y<<25|p>>>7))>>>0,l=(p&b|m&(p^b))>>>0,d=(y&g|v&(y^g))>>>0,R=x+(((S<<18|E>>>14)^(S<<14|E>>>18)^(E<<23|S>>>9))>>>0)+((I^E&(A^I))>>>0)+c[B][1]+t[B][1],n=T+f+h+c[B][0]+t[B][0]+(R/4294967296>>>0)>>>0,i=R>>>0,o=a+l+((R=u+d)/4294967296>>>0)>>>0,s=R>>>0,T=C,x=I,C=k,I=A,k=S,A=E,S=w+n+((R=_+i)/4294967296>>>0)>>>0,E=R>>>0,w=m,_=v,m=b,v=g,b=p,g=y,p=n+o+((R=i+s)/4294967296>>>0)>>>0,y=R>>>0;R=e[0][1]+y,e[0][0]=e[0][0]+p+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+g,e[1][0]=e[1][0]+b+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+v,e[2][0]=e[2][0]+m+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+_,e[3][0]=e[3][0]+w+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+E,e[4][0]=e[4][0]+S+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+A,e[5][0]=e[5][0]+k+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+I,e[6][0]=e[6][0]+C+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+x,e[7][0]=e[7][0]+T+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,U-=128}}},function(e,t,r){"use strict";(function(t){const n=r(167),i=r(75),o=r(84),s=r(412),a=i(r(77));class c{constructor(e){this._key=h(e,s.publicKeyLength)}verify(e,t,r){f(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return t.from(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.Ed25519,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){f(e),n(this.bytes,"sha2-256",e)}}class u{constructor(e,t){this._key=h(e,s.privateKeyLength),this._publicKey=h(t,s.publicKeyLength)}sign(e,t){f(t),s.hashAndSign(this._key,e,t)}get public(){if(!this._publicKey)throw new Error("public key not provided");return new c(this._publicKey)}marshal(){return t.concat([t.from(this._key),t.from(this._publicKey)])}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.Ed25519,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){f(e),n(this.bytes,"sha2-256",e)}id(e){this.public.hash((t,r)=>{if(t)return e(t);e(null,o.encode(r))})}}function f(e){if("function"!=typeof e)throw new Error("callback is required")}function h(e,r){if(t.isBuffer(e)&&(e=new Uint8Array(e)),!(e instanceof Uint8Array)||e.length!==r)throw new Error("Key must be a Uint8Array or Buffer of length "+r);return e}e.exports={Ed25519PublicKey:c,Ed25519PrivateKey:u,unmarshalEd25519PrivateKey:function(e,t){try{e=h(e,s.privateKeyLength+s.publicKeyLength)}catch(e){return t(e)}const r=e.slice(0,s.privateKeyLength),n=e.slice(s.privateKeyLength,e.length);t(null,new u(r,n))},unmarshalEd25519PublicKey:function(e){return e=h(e,s.publicKeyLength),new c(e)},generateKeyPair:function(e,t){void 0===t&&"function"==typeof e&&(t=e),s.generateKey((e,r)=>{if(e)return t(e);let n;try{n=new u(r.secretKey,r.publicKey)}catch(e){return void t(e)}t(null,n)})},generateKeyPairFromSeed:function(e,t,r){void 0===r&&"function"==typeof t&&(r=t),s.generateKeyFromSeed(e,(e,t)=>{if(e)return r(e);let n;try{n=new u(t.secretKey,t.publicKey)}catch(e){return void r(e)}r(null,n)})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(413),i=r(175);t.publicKeyLength=n.sign.publicKeyLength,t.privateKeyLength=n.sign.secretKeyLength,t.generateKey=function(e){i(()=>{let t;try{t=n.sign.keyPair()}catch(t){return e(t)}e(null,t)})},t.generateKeyFromSeed=function(e,t){i(()=>{let r;try{r=n.sign.keyPair.fromSeed(e)}catch(e){return t(e)}t(null,r)})},t.hashAndSign=function(t,r,o){i(()=>{o(null,e.from(n.sign.detached(r,t)))})},t.hashAndVerify=function(e,t,r,o){i(()=>{let i;try{i=n.sign.detached.verify(r,t,e)}catch(e){return o(e)}o(null,i)})}}).call(this,r(0).Buffer)},function(e,t,r){!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function y(e,t,r,n,i){var o,s=0;for(o=0;o>>8)-1}function b(e,t,r,n){return y(e,t,r,n,16)}function g(e,t,r,n){return y(e,t,r,n,32)}function m(e,t,r,n){!function(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,m=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=o,S=s,E=a,k=c,A=u,C=f,I=h,T=l,x=d,B=p,M=y,R=b,N=g,O=m,L=v,P=w,U=0;U<20;U+=2)_^=(i=(N^=(i=(x^=(i=(A^=(i=_+N|0)<<7|i>>>25)+_|0)<<9|i>>>23)+A|0)<<13|i>>>19)+x|0)<<18|i>>>14,C^=(i=(S^=(i=(O^=(i=(B^=(i=C+S|0)<<7|i>>>25)+C|0)<<9|i>>>23)+B|0)<<13|i>>>19)+O|0)<<18|i>>>14,M^=(i=(I^=(i=(E^=(i=(L^=(i=M+I|0)<<7|i>>>25)+M|0)<<9|i>>>23)+L|0)<<13|i>>>19)+E|0)<<18|i>>>14,P^=(i=(R^=(i=(T^=(i=(k^=(i=P+R|0)<<7|i>>>25)+P|0)<<9|i>>>23)+k|0)<<13|i>>>19)+T|0)<<18|i>>>14,_^=(i=(k^=(i=(E^=(i=(S^=(i=_+k|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+E|0)<<18|i>>>14,C^=(i=(A^=(i=(T^=(i=(I^=(i=C+A|0)<<7|i>>>25)+C|0)<<9|i>>>23)+I|0)<<13|i>>>19)+T|0)<<18|i>>>14,M^=(i=(B^=(i=(x^=(i=(R^=(i=M+B|0)<<7|i>>>25)+M|0)<<9|i>>>23)+R|0)<<13|i>>>19)+x|0)<<18|i>>>14,P^=(i=(L^=(i=(O^=(i=(N^=(i=P+L|0)<<7|i>>>25)+P|0)<<9|i>>>23)+N|0)<<13|i>>>19)+O|0)<<18|i>>>14;_=_+o|0,S=S+s|0,E=E+a|0,k=k+c|0,A=A+u|0,C=C+f|0,I=I+h|0,T=T+l|0,x=x+d|0,B=B+p|0,M=M+y|0,R=R+b|0,N=N+g|0,O=O+m|0,L=L+v|0,P=P+w|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=S>>>0&255,e[5]=S>>>8&255,e[6]=S>>>16&255,e[7]=S>>>24&255,e[8]=E>>>0&255,e[9]=E>>>8&255,e[10]=E>>>16&255,e[11]=E>>>24&255,e[12]=k>>>0&255,e[13]=k>>>8&255,e[14]=k>>>16&255,e[15]=k>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=C>>>0&255,e[21]=C>>>8&255,e[22]=C>>>16&255,e[23]=C>>>24&255,e[24]=I>>>0&255,e[25]=I>>>8&255,e[26]=I>>>16&255,e[27]=I>>>24&255,e[28]=T>>>0&255,e[29]=T>>>8&255,e[30]=T>>>16&255,e[31]=T>>>24&255,e[32]=x>>>0&255,e[33]=x>>>8&255,e[34]=x>>>16&255,e[35]=x>>>24&255,e[36]=B>>>0&255,e[37]=B>>>8&255,e[38]=B>>>16&255,e[39]=B>>>24&255,e[40]=M>>>0&255,e[41]=M>>>8&255,e[42]=M>>>16&255,e[43]=M>>>24&255,e[44]=R>>>0&255,e[45]=R>>>8&255,e[46]=R>>>16&255,e[47]=R>>>24&255,e[48]=N>>>0&255,e[49]=N>>>8&255,e[50]=N>>>16&255,e[51]=N>>>24&255,e[52]=O>>>0&255,e[53]=O>>>8&255,e[54]=O>>>16&255,e[55]=O>>>24&255,e[56]=L>>>0&255,e[57]=L>>>8&255,e[58]=L>>>16&255,e[59]=L>>>24&255,e[60]=P>>>0&255,e[61]=P>>>8&255,e[62]=P>>>16&255,e[63]=P>>>24&255}(e,t,r,n)}function v(e,t,r,n){!function(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,m=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=0;_<20;_+=2)o^=(i=(g^=(i=(d^=(i=(u^=(i=o+g|0)<<7|i>>>25)+o|0)<<9|i>>>23)+u|0)<<13|i>>>19)+d|0)<<18|i>>>14,f^=(i=(s^=(i=(m^=(i=(p^=(i=f+s|0)<<7|i>>>25)+f|0)<<9|i>>>23)+p|0)<<13|i>>>19)+m|0)<<18|i>>>14,y^=(i=(h^=(i=(a^=(i=(v^=(i=y+h|0)<<7|i>>>25)+y|0)<<9|i>>>23)+v|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(l^=(i=(c^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+l|0)<<18|i>>>14,o^=(i=(c^=(i=(a^=(i=(s^=(i=o+c|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,f^=(i=(u^=(i=(l^=(i=(h^=(i=f+u|0)<<7|i>>>25)+f|0)<<9|i>>>23)+h|0)<<13|i>>>19)+l|0)<<18|i>>>14,y^=(i=(p^=(i=(d^=(i=(b^=(i=y+p|0)<<7|i>>>25)+y|0)<<9|i>>>23)+b|0)<<13|i>>>19)+d|0)<<18|i>>>14,w^=(i=(v^=(i=(m^=(i=(g^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+g|0)<<13|i>>>19)+m|0)<<18|i>>>14;e[0]=o>>>0&255,e[1]=o>>>8&255,e[2]=o>>>16&255,e[3]=o>>>24&255,e[4]=f>>>0&255,e[5]=f>>>8&255,e[6]=f>>>16&255,e[7]=f>>>24&255,e[8]=y>>>0&255,e[9]=y>>>8&255,e[10]=y>>>16&255,e[11]=y>>>24&255,e[12]=w>>>0&255,e[13]=w>>>8&255,e[14]=w>>>16&255,e[15]=w>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=l>>>0&255,e[21]=l>>>8&255,e[22]=l>>>16&255,e[23]=l>>>24&255,e[24]=d>>>0&255,e[25]=d>>>8&255,e[26]=d>>>16&255,e[27]=d>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,r,n)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,r,n,i,o,s){var a,c,u=new Uint8Array(16),f=new Uint8Array(64);for(c=0;c<16;c++)u[c]=0;for(c=0;c<8;c++)u[c]=o[c];for(;i>=64;){for(m(f,u,s,w),c=0;c<64;c++)e[t+c]=r[n+c]^f[c];for(a=1,c=8;c<16;c++)a=a+(255&u[c])|0,u[c]=255&a,a>>>=8;i-=64,t+=64,n+=64}if(i>0)for(m(f,u,s,w),c=0;c=64;){for(m(c,a,i,w),s=0;s<64;s++)e[t+s]=c[s];for(o=1,s=8;s<16;s++)o=o+(255&a[s])|0,a[s]=255&o,o>>>=8;r-=64,t+=64}if(r>0)for(m(c,a,i,w),s=0;s>>13|r<<3),n=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|n<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(n>>>7|i<<9),o=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(o>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function C(e,t,r,n,i,o){var s=new A(o);return s.update(r,n,i),s.finish(e,t),0}function I(e,t,r,n,i,o){var s=new Uint8Array(16);return C(s,0,r,n,i,o),b(e,t,s,0)}function T(e,t,r,n,i){var o;if(r<32)return-1;for(k(e,0,t,0,r,n,i),C(e,16,e,32,r-32,e),o=0;o<16;o++)e[o]=0;return 0}function x(e,t,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(E(s,0,32,n,i),0!==I(t,16,t,32,r-32,s))return-1;for(k(e,0,t,0,r,n,i),o=0;o<32;o++)e[o]=0;return 0}function B(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function M(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function R(e,t,r){for(var n,i=~(r-1),o=0;o<16;o++)n=i&(e[o]^t[o]),e[o]^=n,t[o]^=n}function N(e,r){var n,i,o,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(M(a),M(a),M(a),i=0;i<2;i++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),o=s[15]>>16&1,s[14]&=65535,R(a,s,1-o)}for(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function O(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return N(r,e),N(n,t),g(r,0,n,0)}function L(e){var t=new Uint8Array(32);return N(t,e),1&t[0]}function P(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function U(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function D(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function j(e,t,r){var n,i,o=0,s=0,a=0,c=0,u=0,f=0,h=0,l=0,d=0,p=0,y=0,b=0,g=0,m=0,v=0,w=0,_=0,S=0,E=0,k=0,A=0,C=0,I=0,T=0,x=0,B=0,M=0,R=0,N=0,O=0,L=0,P=r[0],U=r[1],D=r[2],j=r[3],K=r[4],V=r[5],q=r[6],F=r[7],z=r[8],H=r[9],W=r[10],G=r[11],Y=r[12],Q=r[13],$=r[14],X=r[15];o+=(n=t[0])*P,s+=n*U,a+=n*D,c+=n*j,u+=n*K,f+=n*V,h+=n*q,l+=n*F,d+=n*z,p+=n*H,y+=n*W,b+=n*G,g+=n*Y,m+=n*Q,v+=n*$,w+=n*X,s+=(n=t[1])*P,a+=n*U,c+=n*D,u+=n*j,f+=n*K,h+=n*V,l+=n*q,d+=n*F,p+=n*z,y+=n*H,b+=n*W,g+=n*G,m+=n*Y,v+=n*Q,w+=n*$,_+=n*X,a+=(n=t[2])*P,c+=n*U,u+=n*D,f+=n*j,h+=n*K,l+=n*V,d+=n*q,p+=n*F,y+=n*z,b+=n*H,g+=n*W,m+=n*G,v+=n*Y,w+=n*Q,_+=n*$,S+=n*X,c+=(n=t[3])*P,u+=n*U,f+=n*D,h+=n*j,l+=n*K,d+=n*V,p+=n*q,y+=n*F,b+=n*z,g+=n*H,m+=n*W,v+=n*G,w+=n*Y,_+=n*Q,S+=n*$,E+=n*X,u+=(n=t[4])*P,f+=n*U,h+=n*D,l+=n*j,d+=n*K,p+=n*V,y+=n*q,b+=n*F,g+=n*z,m+=n*H,v+=n*W,w+=n*G,_+=n*Y,S+=n*Q,E+=n*$,k+=n*X,f+=(n=t[5])*P,h+=n*U,l+=n*D,d+=n*j,p+=n*K,y+=n*V,b+=n*q,g+=n*F,m+=n*z,v+=n*H,w+=n*W,_+=n*G,S+=n*Y,E+=n*Q,k+=n*$,A+=n*X,h+=(n=t[6])*P,l+=n*U,d+=n*D,p+=n*j,y+=n*K,b+=n*V,g+=n*q,m+=n*F,v+=n*z,w+=n*H,_+=n*W,S+=n*G,E+=n*Y,k+=n*Q,A+=n*$,C+=n*X,l+=(n=t[7])*P,d+=n*U,p+=n*D,y+=n*j,b+=n*K,g+=n*V,m+=n*q,v+=n*F,w+=n*z,_+=n*H,S+=n*W,E+=n*G,k+=n*Y,A+=n*Q,C+=n*$,I+=n*X,d+=(n=t[8])*P,p+=n*U,y+=n*D,b+=n*j,g+=n*K,m+=n*V,v+=n*q,w+=n*F,_+=n*z,S+=n*H,E+=n*W,k+=n*G,A+=n*Y,C+=n*Q,I+=n*$,T+=n*X,p+=(n=t[9])*P,y+=n*U,b+=n*D,g+=n*j,m+=n*K,v+=n*V,w+=n*q,_+=n*F,S+=n*z,E+=n*H,k+=n*W,A+=n*G,C+=n*Y,I+=n*Q,T+=n*$,x+=n*X,y+=(n=t[10])*P,b+=n*U,g+=n*D,m+=n*j,v+=n*K,w+=n*V,_+=n*q,S+=n*F,E+=n*z,k+=n*H,A+=n*W,C+=n*G,I+=n*Y,T+=n*Q,x+=n*$,B+=n*X,b+=(n=t[11])*P,g+=n*U,m+=n*D,v+=n*j,w+=n*K,_+=n*V,S+=n*q,E+=n*F,k+=n*z,A+=n*H,C+=n*W,I+=n*G,T+=n*Y,x+=n*Q,B+=n*$,M+=n*X,g+=(n=t[12])*P,m+=n*U,v+=n*D,w+=n*j,_+=n*K,S+=n*V,E+=n*q,k+=n*F,A+=n*z,C+=n*H,I+=n*W,T+=n*G,x+=n*Y,B+=n*Q,M+=n*$,R+=n*X,m+=(n=t[13])*P,v+=n*U,w+=n*D,_+=n*j,S+=n*K,E+=n*V,k+=n*q,A+=n*F,C+=n*z,I+=n*H,T+=n*W,x+=n*G,B+=n*Y,M+=n*Q,R+=n*$,N+=n*X,v+=(n=t[14])*P,w+=n*U,_+=n*D,S+=n*j,E+=n*K,k+=n*V,A+=n*q,C+=n*F,I+=n*z,T+=n*H,x+=n*W,B+=n*G,M+=n*Y,R+=n*Q,N+=n*$,O+=n*X,w+=(n=t[15])*P,s+=38*(S+=n*D),a+=38*(E+=n*j),c+=38*(k+=n*K),u+=38*(A+=n*V),f+=38*(C+=n*q),h+=38*(I+=n*F),l+=38*(T+=n*z),d+=38*(x+=n*H),p+=38*(B+=n*W),y+=38*(M+=n*G),b+=38*(R+=n*Y),g+=38*(N+=n*Q),m+=38*(O+=n*$),v+=38*(L+=n*X),o=(n=(o+=38*(_+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),o+=i-1+37*(i-1),e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=u,e[5]=f,e[6]=h,e[7]=l,e[8]=d,e[9]=p,e[10]=y,e[11]=b,e[12]=g,e[13]=m,e[14]=v,e[15]=w}function K(e,t){j(e,t,t)}function V(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)K(i,i),2!==n&&4!==n&&j(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function q(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=250;n>=0;n--)K(i,i),1!==n&&j(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function F(e,r,n){var i,o,s=new Uint8Array(32),a=new Float64Array(80),u=t(),f=t(),h=t(),l=t(),d=t(),p=t();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,P(a,n),o=0;o<16;o++)f[o]=a[o],l[o]=u[o]=h[o]=0;for(u[0]=l[0]=1,o=254;o>=0;--o)R(u,f,i=s[o>>>3]>>>(7&o)&1),R(h,l,i),U(d,u,h),D(u,u,h),U(h,f,l),D(f,f,l),K(l,d),K(p,u),j(u,h,u),j(h,f,d),U(d,u,h),D(u,u,h),K(f,u),D(h,l,p),j(u,h,c),U(u,u,l),j(h,h,u),j(u,l,p),j(l,f,a),K(f,d),R(u,f,i),R(h,l,i);for(o=0;o<16;o++)a[o+16]=u[o],a[o+32]=h[o],a[o+48]=f[o],a[o+64]=l[o];var y=a.subarray(32),b=a.subarray(16);return V(y,y),j(b,b,y),N(e,b),0}function z(e,t){return F(e,t,o)}function H(e,t){return n(t,32),z(e,t)}function W(e,t,r){var n=new Uint8Array(32);return F(n,r,t),v(e,i,n,w)}A.prototype.blocks=function(e,t,r){for(var n,i,o,s,a,c,u,f,h,l,d,p,y,b,g,m,v,w,_,S=this.fin?0:2048,E=this.h[0],k=this.h[1],A=this.h[2],C=this.h[3],I=this.h[4],T=this.h[5],x=this.h[6],B=this.h[7],M=this.h[8],R=this.h[9],N=this.r[0],O=this.r[1],L=this.r[2],P=this.r[3],U=this.r[4],D=this.r[5],j=this.r[6],K=this.r[7],V=this.r[8],q=this.r[9];r>=16;)l=h=0,l+=(E+=8191&(n=255&e[t+0]|(255&e[t+1])<<8))*N,l+=(k+=8191&(n>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),l+=(A+=8191&(i>>>10|(o=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*V),l+=(C+=8191&(o>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*K),h=(l+=(I+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*j))>>>13,l&=8191,l+=(T+=a>>>1&8191)*(5*D),l+=(x+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*U),l+=(B+=8191&(c>>>11|(u=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*P),l+=(M+=8191&(u>>>8|(f=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*L),d=h+=(l+=(R+=f>>>5|S)*(5*O))>>>13,d+=E*O,d+=k*N,d+=A*(5*q),d+=C*(5*V),h=(d+=I*(5*K))>>>13,d&=8191,d+=T*(5*j),d+=x*(5*D),d+=B*(5*U),d+=M*(5*P),h+=(d+=R*(5*L))>>>13,d&=8191,p=h,p+=E*L,p+=k*O,p+=A*N,p+=C*(5*q),h=(p+=I*(5*V))>>>13,p&=8191,p+=T*(5*K),p+=x*(5*j),p+=B*(5*D),p+=M*(5*U),y=h+=(p+=R*(5*P))>>>13,y+=E*P,y+=k*L,y+=A*O,y+=C*N,h=(y+=I*(5*q))>>>13,y&=8191,y+=T*(5*V),y+=x*(5*K),y+=B*(5*j),y+=M*(5*D),b=h+=(y+=R*(5*U))>>>13,b+=E*U,b+=k*P,b+=A*L,b+=C*O,h=(b+=I*N)>>>13,b&=8191,b+=T*(5*q),b+=x*(5*V),b+=B*(5*K),b+=M*(5*j),g=h+=(b+=R*(5*D))>>>13,g+=E*D,g+=k*U,g+=A*P,g+=C*L,h=(g+=I*O)>>>13,g&=8191,g+=T*N,g+=x*(5*q),g+=B*(5*V),g+=M*(5*K),m=h+=(g+=R*(5*j))>>>13,m+=E*j,m+=k*D,m+=A*U,m+=C*P,h=(m+=I*L)>>>13,m&=8191,m+=T*O,m+=x*N,m+=B*(5*q),m+=M*(5*V),v=h+=(m+=R*(5*K))>>>13,v+=E*K,v+=k*j,v+=A*D,v+=C*U,h=(v+=I*P)>>>13,v&=8191,v+=T*L,v+=x*O,v+=B*N,v+=M*(5*q),w=h+=(v+=R*(5*V))>>>13,w+=E*V,w+=k*K,w+=A*j,w+=C*D,h=(w+=I*U)>>>13,w&=8191,w+=T*P,w+=x*L,w+=B*O,w+=M*N,_=h+=(w+=R*(5*q))>>>13,_+=E*q,_+=k*V,_+=A*K,_+=C*j,h=(_+=I*D)>>>13,_&=8191,_+=T*U,_+=x*P,_+=B*L,_+=M*O,E=l=8191&(h=(h=((h+=(_+=R*N)>>>13)<<2)+h|0)+(l&=8191)|0),k=d+=h>>>=13,A=p&=8191,C=y&=8191,I=b&=8191,T=g&=8191,x=m&=8191,B=v&=8191,M=w&=8191,R=_&=8191,t+=16,r-=16;this.h[0]=E,this.h[1]=k,this.h[2]=A,this.h[3]=C,this.h[4]=I,this.h[5]=T,this.h[6]=x,this.h[7]=B,this.h[8]=M,this.h[9]=R},A.prototype.finish=function(e,t){var r,n,i,o,s=new Uint16Array(10);if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,o=1;o<10;o++)s[o]=this.h[o]+r,r=s[o]>>>13,s[o]&=8191;for(s[9]-=8192,n=(1^r)-1,o=0;o<10;o++)s[o]&=n;for(n=~n,o=0;o<10;o++)this.h[o]=this.h[o]&n|s[o];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,o=1;o<8;o++)i=(this.h[o]+this.pad[o]|0)+(i>>>16)|0,this.h[o]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},A.prototype.update=function(e,t,r){var n,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),n=0;n=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(n=0;n=128;){for(S=0;S<16;S++)E=8*S+Y,B[S]=r[E+0]<<24|r[E+1]<<16|r[E+2]<<8|r[E+3],M[S]=r[E+4]<<24|r[E+5]<<16|r[E+6]<<8|r[E+7];for(S=0;S<80;S++)if(i=R,o=N,s=O,a=L,c=P,u=U,f=D,j,l=K,d=V,p=q,y=F,b=z,g=H,m=W,G,C=65535&(A=G),I=A>>>16,T=65535&(k=j),x=k>>>16,C+=65535&(A=(z>>>14|P<<18)^(z>>>18|P<<14)^(P>>>9|z<<23)),I+=A>>>16,T+=65535&(k=(P>>>14|z<<18)^(P>>>18|z<<14)^(z>>>9|P<<23)),x+=k>>>16,C+=65535&(A=z&H^~z&W),I+=A>>>16,T+=65535&(k=P&U^~P&D),x+=k>>>16,C+=65535&(A=Q[2*S+1]),I+=A>>>16,T+=65535&(k=Q[2*S]),x+=k>>>16,k=B[S%16],I+=(A=M[S%16])>>>16,T+=65535&k,x+=k>>>16,T+=(I+=(C+=65535&A)>>>16)>>>16,C=65535&(A=_=65535&C|I<<16),I=A>>>16,T=65535&(k=w=65535&T|(x+=T>>>16)<<16),x=k>>>16,C+=65535&(A=(K>>>28|R<<4)^(R>>>2|K<<30)^(R>>>7|K<<25)),I+=A>>>16,T+=65535&(k=(R>>>28|K<<4)^(K>>>2|R<<30)^(K>>>7|R<<25)),x+=k>>>16,I+=(A=K&V^K&q^V&q)>>>16,T+=65535&(k=R&N^R&O^N&O),x+=k>>>16,h=65535&(T+=(I+=(C+=65535&A)>>>16)>>>16)|(x+=T>>>16)<<16,v=65535&C|I<<16,C=65535&(A=y),I=A>>>16,T=65535&(k=a),x=k>>>16,I+=(A=_)>>>16,T+=65535&(k=w),x+=k>>>16,N=i,O=o,L=s,P=a=65535&(T+=(I+=(C+=65535&A)>>>16)>>>16)|(x+=T>>>16)<<16,U=c,D=u,j=f,R=h,V=l,q=d,F=p,z=y=65535&C|I<<16,H=b,W=g,G=m,K=v,S%16==15)for(E=0;E<16;E++)k=B[E],C=65535&(A=M[E]),I=A>>>16,T=65535&k,x=k>>>16,k=B[(E+9)%16],C+=65535&(A=M[(E+9)%16]),I+=A>>>16,T+=65535&k,x+=k>>>16,w=B[(E+1)%16],C+=65535&(A=((_=M[(E+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),I+=A>>>16,T+=65535&(k=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=k>>>16,w=B[(E+14)%16],I+=(A=((_=M[(E+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,T+=65535&(k=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,B[E]=65535&T|x<<16,M[E]=65535&C|I<<16;C=65535&(A=K),I=A>>>16,T=65535&(k=R),x=k>>>16,k=e[0],I+=(A=t[0])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[0]=R=65535&T|x<<16,t[0]=K=65535&C|I<<16,C=65535&(A=V),I=A>>>16,T=65535&(k=N),x=k>>>16,k=e[1],I+=(A=t[1])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[1]=N=65535&T|x<<16,t[1]=V=65535&C|I<<16,C=65535&(A=q),I=A>>>16,T=65535&(k=O),x=k>>>16,k=e[2],I+=(A=t[2])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[2]=O=65535&T|x<<16,t[2]=q=65535&C|I<<16,C=65535&(A=F),I=A>>>16,T=65535&(k=L),x=k>>>16,k=e[3],I+=(A=t[3])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[3]=L=65535&T|x<<16,t[3]=F=65535&C|I<<16,C=65535&(A=z),I=A>>>16,T=65535&(k=P),x=k>>>16,k=e[4],I+=(A=t[4])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[4]=P=65535&T|x<<16,t[4]=z=65535&C|I<<16,C=65535&(A=H),I=A>>>16,T=65535&(k=U),x=k>>>16,k=e[5],I+=(A=t[5])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[5]=U=65535&T|x<<16,t[5]=H=65535&C|I<<16,C=65535&(A=W),I=A>>>16,T=65535&(k=D),x=k>>>16,k=e[6],I+=(A=t[6])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[6]=D=65535&T|x<<16,t[6]=W=65535&C|I<<16,C=65535&(A=G),I=A>>>16,T=65535&(k=j),x=k>>>16,k=e[7],I+=(A=t[7])>>>16,T+=65535&k,x+=k>>>16,x+=(T+=(I+=(C+=65535&A)>>>16)>>>16)>>>16,e[7]=j=65535&T|x<<16,t[7]=G=65535&C|I<<16,Y+=128,n-=128}return n}function X(e,t,r){var n,i=new Int32Array(8),o=new Int32Array(8),s=new Uint8Array(256),a=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,$(i,o,t,r),r%=128,n=0;n=0;--i)J(e,t,n=r[i/8|0]>>(7&i)&1),Z(t,e),Z(e,e),J(e,t,n)}function re(e,r){var n=[t(),t(),t(),t()];B(n[0],h),B(n[1],l),B(n[2],a),j(n[3],h,l),te(e,n,r)}function ne(e,r,i){var o,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(i||n(r,32),X(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,re(a,s),ee(e,a),o=0;o<32;o++)r[o+32]=e[o];return 0}var ie=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function oe(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>4)*ie[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ie[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function se(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;oe(e,r)}function ae(e,r,n,i){var o,s,a=new Uint8Array(64),c=new Uint8Array(64),u=new Uint8Array(64),f=new Float64Array(64),h=[t(),t(),t(),t()];X(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var l=n+64;for(o=0;o>7&&D(e[0],s,e[0]),j(e[3],e[0],e[1]),0)}(l,i))return-1;for(o=0;o=0},e.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return ne(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(fe(e),64!==e.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),r=0;r{o=o||r(431)(t);class s{constructor(e){o.validatePublicKey(e),this._key=e}verify(e,t,r){c(r),o.hashAndVerify(this._key,t,e,r)}marshal(){return o.compressPublicKey(this._key)}get bytes(){return e.PublicKey.encode({Type:e.KeyType.Secp256k1,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){c(e),i(this.bytes,"sha2-256",e)}}class a{constructor(e,t){this._key=e,this._publicKey=t||o.computePublicKey(e),o.validatePrivateKey(this._key),o.validatePublicKey(this._publicKey)}sign(e,t){c(t),o.hashAndSign(this._key,e,t)}get public(){return new s(this._publicKey)}marshal(){return this._key}get bytes(){return e.PrivateKey.encode({Type:e.KeyType.Secp256k1,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){c(e),i(this.bytes,"sha2-256",e)}id(e){this.public.hash((t,r)=>{if(t)return e(t);e(null,n.encode(r))})}}function c(e){if("function"!=typeof e)throw new Error("callback is required")}return{Secp256k1PublicKey:s,Secp256k1PrivateKey:a,unmarshalSecp256k1PrivateKey:function(e,t){t(null,new a(e))},unmarshalSecp256k1PublicKey:function(e){return new s(e)},generateKeyPair:function(e,t){void 0===t&&"function"==typeof e&&(t=e),c(t),o.generateKey((e,r)=>{if(e)return t(e);let n;try{n=new a(r)}catch(e){return t(e)}t(null,n)})}}}},function(e,t,r){"use strict";const{Buffer:n}=r(0),i=r(417),o=r(423),s=r(427);function a(e){t.decode(e)}t.names=s.names,t.codes=s.codes,t.defaultLengths=s.defaultLengths,t.toHexString=function(e){if(!n.isBuffer(e))throw new Error("must be passed a buffer");return e.toString("hex")},t.fromHexString=function(e){return n.from(e,"hex")},t.toB58String=function(e){if(!n.isBuffer(e))throw new Error("must be passed a buffer");return i.encode("base58btc",e).toString().slice(1)},t.fromB58String=function(e){let t=e;return n.isBuffer(e)&&(t=e.toString()),i.decode("z"+t)},t.decode=function(e){if(!n.isBuffer(e))throw new Error("multihash must be a Buffer");if(e.length<2)throw new Error("multihash too short. must be > 2 bytes.");const r=o.decode(e);if(!t.isValidCode(r))throw new Error("multihash unknown function code: 0x"+r.toString(16));e=e.slice(o.decode.bytes);const i=o.decode(e);if(i<0)throw new Error("multihash invalid length: "+i);if((e=e.slice(o.decode.bytes)).length!==i)throw new Error("multihash length inconsistent: 0x"+e.toString("hex"));return{code:r,name:s.codes[r],length:i,digest:e}},t.encode=function(e,r,i){if(!e||void 0===r)throw new Error("multihash encode requires at least two args: digest, code");const s=t.coerceCode(r);if(!n.isBuffer(e))throw new Error("digest should be a Buffer");if(null==i&&(i=e.length),i&&e.length!==i)throw new Error("digest length should be equal to specified length.");return n.concat([n.from(o.encode(s)),n.from(o.encode(i)),e])},t.coerceCode=function(e){let r=e;if("string"==typeof e){if(void 0===s.names[e])throw new Error("Unrecognized hash function named: "+e);r=s.names[e]}if("number"!=typeof r)throw new Error("Hash function code should be a number. Got: "+r);if(void 0===s.codes[r]&&!t.isAppCode(r))throw new Error("Unrecognized function code: "+r);return r},t.isAppCode=function(e){return e>0&&e<16},t.isValidCode=function(e){return!!t.isAppCode(e)||!!s.codes[e]},t.validate=a,t.prefix=function(e){return a(e),e.slice(0,2)}},function(e,t,r){"use strict";const{Buffer:n}=r(0),i=r(418);function o(e,t){if(!t)throw new Error("requires an encoded buffer");const r=s(e),i=n.from(r.code);return function(e,t){s(e).decode(t.toString())}(r.name,t),n.concat([i,t])}function s(e){let t;if(i.names[e])t=i.names[e];else{if(!i.codes[e])throw new Error("Unsupported encoding");t=i.codes[e]}if(!t.isImplemented())throw new Error("Base "+e+" is not implemented yet");return t}(t=e.exports=o).encode=function(e,t){const r=s(e);return o(r.name,n.from(r.encode(t)))},t.decode=function(e){n.isBuffer(e)&&(e=e.toString());const t=e.substring(0,1);"string"==typeof(e=e.substring(1,e.length))&&(e=n.from(e));const r=s(t);return n.from(r.decode(e.toString()))},t.isEncoded=function(e){n.isBuffer(e)&&(e=e.toString());if("[object String]"!==Object.prototype.toString.call(e))return!1;const t=e.substring(0,1);try{return s(t).name}catch(e){return!1}},t.names=Object.freeze(Object.keys(i.names)),t.codes=Object.freeze(Object.keys(i.codes))},function(e,t,r){"use strict";const n=r(419),i=r(83),o=r(420),s=r(421),a=r(422),c=[["base1","1","","1"],["base2","0",i,"01"],["base8","7",i,"01234567"],["base10","9",i,"0123456789"],["base16","f",o,"0123456789abcdef"],["base32","b",s,"abcdefghijklmnopqrstuvwxyz234567"],["base32pad","c",s,"abcdefghijklmnopqrstuvwxyz234567="],["base32hex","v",s,"0123456789abcdefghijklmnopqrstuv"],["base32hexpad","t",s,"0123456789abcdefghijklmnopqrstuv="],["base32z","h",s,"ybndrfg8ejkmcpqxot1uwisza345h769"],["base58flickr","Z",i,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base58btc","z",i,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base64","m",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",a,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],u=c.reduce((e,t)=>(e[t[0]]=new n(t[0],t[1],t[2],t[3]),e),{}),f=c.reduce((e,t)=>(e[t[1]]=u[t[0]],e),{});e.exports={names:u,codes:f}},function(e,t,r){"use strict";e.exports=class{constructor(e,t,r,n){this.name=e,this.code=t,this.alphabet=n,r&&n&&(this.engine=r(n))}encode(e){return this.engine.encode(e)}decode(e){return this.engine.decode(e)}isImplemented(){return this.engine}}},function(e,t,r){"use strict";const{Buffer:n}=r(0);e.exports=function(e){return{encode:e=>"string"==typeof e?n.from(e).toString("hex"):e.toString("hex"),decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base16 character");return n.from(t,"hex")}}}},function(e,t,r){"use strict";function n(e,t){const r=e.byteLength,n=new Uint8Array(e),i=t.indexOf("=")===t.length-1;i&&(t=t.substring(0,t.length-1));let o=0,s=0,a="";for(let e=0;e=5;)a+=t[s>>>o-5&31],o-=5;if(o>0&&(a+=t[s<<5-o&31]),i)for(;a.length%8!=0;)a+="=";return a}e.exports=function(e){return{encode:t=>n("string"==typeof t?Uint8Array.from(t):t,e),decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base32 character");return function(e,t){const r=(e=e.replace(new RegExp("=","g"),"")).length;let n=0,i=0,o=0;const s=new Uint8Array(5*r/8|0);for(let a=0;a=8&&(s[o++]=i>>>n-8&255,n-=8);return s.buffer}(t,e)}}}},function(e,t,r){"use strict";const{Buffer:n}=r(0);e.exports=function(e){const t=e.indexOf("=")>-1,r=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let i="";i="string"==typeof e?n.from(e).toString("base64"):e.toString("base64"),r&&(i=i.replace(/\+/g,"-").replace(/\//g,"_"));const o=i.indexOf("=");return o>0&&!t&&(i=i.substring(0,o)),i},decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base64 character");return n.from(t,"base64")}}}},function(e,t,r){e.exports={encode:r(424),decode:r(425),encodingLength:r(426)}},function(e,t){e.exports=function e(t,n,i){n=n||[];var o=i=i||0;for(;t>=r;)n[i++]=255&t|128,t/=128;for(;-128&t;)n[i++]=255&t|128,t>>>=7;return n[i]=0|t,e.bytes=i-o+1,n};var r=Math.pow(2,31)},function(e,t){e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},function(e,t){var r=Math.pow(2,7),n=Math.pow(2,14),i=Math.pow(2,21),o=Math.pow(2,28),s=Math.pow(2,35),a=Math.pow(2,42),c=Math.pow(2,49),u=Math.pow(2,56),f=Math.pow(2,63);e.exports=function(e){return e{s.sha2256(e,(e,n)=>{e&&r(e),s.sha2256(t.from(n),r)})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(171),i=function(){if(self.crypto)return self.crypto.subtle||self.crypto.webkitSubtle;if(self.msCrypto)return self.msCrypto.subtle}();function o(e){if(!i)throw new Error("Please use a browser with webcrypto support and ensure the code has been delivered securely via HTTPS/TLS and run within a Secure Context");return(r,o)=>{const s=i.digest({name:e},r);if("function"!=typeof s.then)return s.onerror=()=>{o(new Error("hashing data using "+e))},void(s.oncomplete=e=>{o(null,e.target.result)});n(s.then(e=>t.from(new Uint8Array(e))),o)}}e.exports={sha1:function(e,t){o("SHA-1")(e,t)},sha2256:function(e,t){o("SHA-256")(e,t)},sha2512:function(e,t){o("SHA-512")(e,t)}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(173),i=r(185).toCallback,o={init:n.blake2bInit,update:n.blake2bUpdate,digest:n.blake2bFinal},s={init:n.blake2sInit,update:n.blake2sUpdate,digest:n.blake2sFinal},a=(e,r)=>i(n=>{const i=r.init(e,null);return r.update(i,n),t.from(r.digest(i))});e.exports=e=>{for(let t=0;t<64;t++)e[45569+t]=a(t+1,o);for(let t=0;t<32;t++)e[45633+t]=a(t+1,s)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(432),i=r(184),o=r(450);e.exports=e=>{function t(e){if(!n.privateKeyVerify(e))throw new Error("Invalid private key")}return{generateKey:function(t){let r;do{r=e(32)}while(!n.privateKeyVerify(r));var i,s;i=null,s=r,o(()=>t(i,s))},privateKeyLength:32,hashAndSign:function(e,t,r){const s=(e,t)=>o(()=>r(e,t));i.digest(t,"sha2-256",(t,r)=>{if(t)return s(t);try{const t=n.sign(r,e),i=n.signatureExport(t.signature);return s(null,i)}catch(t){s(t)}})},hashAndVerify:function(e,t,r,s){const a=(e,t)=>o(()=>s(e,t));i.digest(r,"sha2-256",(r,i)=>{if(r)return a(r);try{t=n.signatureImport(t);const r=n.verify(i,t,e);return a(null,r)}catch(r){a(r)}})},compressPublicKey:function(e){if(!n.publicKeyVerify(e))throw new Error("Invalid public key");return n.publicKeyConvert(e,!0)},decompressPublicKey:function(e){return n.publicKeyConvert(e,!1)},validatePrivateKey:t,validatePublicKey:function(e){if(!n.publicKeyVerify(e))throw new Error("Invalid public key")},computePublicKey:function(e){return t(e),n.publicKeyCreate(e)}}}},function(e,t,r){"use strict";e.exports=r(433)(r(437))},function(e,t,r){"use strict";var n=r(434),i=r(435),o=r(186);function s(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}e.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=e.privateKeyExport(t,r);return i.privateKeyExport(t,a,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=r)throw RangeError(n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(3).Buffer,i=r(436),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),s=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);t.privateKeyExport=function(e,t,r){var i=n.from(r?o:s);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},t.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var s=n.concat([n.from([0]),e.s]),a=33,c=0;a>1&&0===s[c]&&!(128&s[c+1]);--a,++c);return i.encode(t.slice(o),s.slice(c))},t.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},t.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var s=e[o++];if(!(128&s&&(o+=s-128)>i)&&2===e[o++]){var a=e[o++];if(128&a){if(o+(s=a-128)>i)return;for(;s>0&&0===e[o];o+=1,s-=1);for(a=0;s>0;o+=1,s-=1)a=(a<<8)+e[o]}if(!(a>i-o)){var c=o;if(o+=a,2===e[o++]){var u=e[o++];if(128&u){if(o+(s=u-128)>i)return;for(;s>0&&0===e[o];o+=1,s-=1);for(u=0;s>0;o+=1,s-=1)u=(u<<8)+e[o]}if(!(u>i-o)){var f=o;for(o+=u;a>0&&0===e[c];a-=1,c+=1);if(!(a>32)){var h=e.slice(c,c+a);for(h.copy(t,32-h.length);u>0&&0===e[f];u-=1,f+=1);if(!(u>32)){var l=e.slice(f,f+u);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},function(e,t,r){var n=r(3).Buffer;e.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return 0!==r&&(6+t+r===e.length&&(!(128&e[4])&&(!(t>1&&0===e[4]&&!(128&e[5]))&&(!(128&e[t+6])&&!(r>1&&0===e[t+6]&&!(128&e[t+7]))))))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},function(e,t,r){"use strict";var n=r(3).Buffer,i=r(438),o=r(443),s=r(186),a=r(53),c=r(191),u=r(449);t.privateKeyVerify=function(e){var t=a.fromBuffer(e);return!(t.isOverflow()||t.isZero())},t.privateKeyExport=function(e,t){var r=a.fromBuffer(e);if(r.isOverflow()||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return u.mul(r).toPublicKey(t)},t.privateKeyNegate=function(e){var t=a.fromBuffer(e);return t.isZero()?n.alloc(32):(t.ucmp(a.n)>0&&t.isub(a.n),a.n.sub(t).toBuffer())},t.privateKeyModInverse=function(e){var t=a.fromBuffer(e);if(t.isOverflow()||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.uinvm().toBuffer()},t.privateKeyTweakAdd=function(e,t){var r=a.fromBuffer(t);if(r.isOverflow())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(a.fromBuffer(e)),r.isOverflow()&&r.isub(a.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toBuffer()},t.privateKeyTweakMul=function(e,t){var r=a.fromBuffer(t);if(r.isOverflow()||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);var n=a.fromBuffer(e);return r.umul(n).ureduce().toBuffer()},t.publicKeyCreate=function(e,t){var r=a.fromBuffer(e);if(r.isOverflow()||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return u.mul(r).toPublicKey(t)},t.publicKeyConvert=function(e,t){var r=c.fromPublicKey(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return r.toPublicKey(t)},t.publicKeyVerify=function(e){return null!==c.fromPublicKey(e)},t.publicKeyTweakAdd=function(e,t,r){var n=c.fromPublicKey(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=a.fromBuffer(t)).isOverflow())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var i=u.mul(t).add(n);if(i.inf)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return i.toPublicKey(r)},t.publicKeyTweakMul=function(e,t,r){var n=c.fromPublicKey(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=a.fromBuffer(t)).isOverflow()||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.mul(t).toPublicKey(r)},t.publicKeyCombine=function(e,t){for(var r=new Array(e.length),n=0;n=0)&&0===n.iadd(a.psn).redMul(p).ucmp(d.x)},t.recover=function(e,t,r,i){var o=a.fromBuffer(t.slice(0,32)),f=a.fromBuffer(t.slice(32,64));if(o.isOverflow()||f.isOverflow())throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);do{if(o.isZero()||f.isZero())break;var h=o;if(r>>1){if(h.ucmp(a.psn)>=0)break;h=o.add(a.n)}var l=n.concat([n.from([2+(1&r)]),h.toBuffer()]),d=c.fromPublicKey(l);if(null===d)break;var p=o.uinvm(),y=a.n.sub(a.fromBuffer(e)).umul(p).ureduce(),b=f.umul(p).ureduce();return c.fromECJPoint(u.mulAdd(y,d,b)).toPublicKey(i)}while(0);throw new Error(s.ECDSA_RECOVER_FAIL)},t.ecdh=function(e,r){var n=t.ecdhUnsafe(e,r,!0);return i("sha256").update(n).digest()},t.ecdhUnsafe=function(e,t,r){var n=c.fromPublicKey(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var i=a.fromBuffer(t);if(i.isOverflow()||i.isZero())throw new Error(s.ECDH_FAIL);return n.mul(i).toPublicKey(r)}},function(e,t,r){"use strict";var n=r(1),i=r(73),o=r(187),s=r(188),a=r(22);function c(e){a.call(this,"digest"),this._hash=e}n(c,a),c.prototype._update=function(e){this._hash.update(e)},c.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new i:"rmd160"===e||"ripemd160"===e?new o:new c(s(e))}},function(e,t,r){var n=r(1),i=r(34),o=r(3).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,o,a)+c+r[l]+s[d];c=a,a=o,o=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=c},function(e,t,r){var n=r(1),i=r(34),o=r(3).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),y=u(n)+h(p,i,o,a)+c+r[d]+s[p]|0;c=a,a=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=c},function(e,t,r){var n=r(1),i=r(189),o=r(34),s=r(3).Buffer,a=new Array(64);function c(){this.init(),this._w=a,o.call(this,64,56)}n(c,i),c.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},c.prototype._hash=function(){var e=s.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=c},function(e,t,r){var n=r(1),i=r(190),o=r(34),s=r(3).Buffer,a=new Array(160);function c(){this.init(),this._w=a,o.call(this,128,112)}n(c,i),c.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},c.prototype._hash=function(){var e=s.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=c},function(e,t,r){"use strict";(function(t){var n=r(444),i=r(447),o=new t(0),s=new t([0]),a=new t([1]);function c(e,t,r,n){var o=i[e];if(void 0===o)throw new Error("hash "+e+" is not supported");this._algo=e,this._securityStrength=o.securityStrength/8,this._outlen=o.outlen/8,this._reseedInterval=281474976710656,this._init(t,r,n)}c.prototype._update=function(e){var t=n(this._algo,this._K).update(this._V).update(s);e&&t.update(e),this._K=t.digest(),this._V=n(this._algo,this._K).update(this._V).digest(),e&&(this._K=n(this._algo,this._K).update(this._V).update(a).update(e).digest(),this._V=n(this._algo,this._K).update(this._V).digest())},c.prototype._init=function(e,r,n){if(e.lengththis._reseedInterval)throw new Error("Reseed is required");r&&0===r.length&&(r=void 0),r&&this._update(r);for(var i=new t(0);i.lengthr)?t=("rmd160"===e?new c:u(e)).update(t).digest():t.length64?t=e(t):t.length<64&&(t=i.concat([t,s],64));for(var r=this._ipad=i.allocUnsafe(64),n=this._opad=i.allocUnsafe(64),a=0;a<64;a++)r[a]=54^t[a],n[a]=92^t[a];this._hash=[r]}n(a,o),a.prototype._update=function(e){this._hash.push(e)},a.prototype._final=function(){var e=this._alg(i.concat(this._hash));return this._alg(i.concat([this._opad,e]))},e.exports=a},function(e,t,r){var n=r(73);e.exports=function(e){return(new n).update(e).digest()}},function(e){e.exports=JSON.parse('{"sha1":{"securityStrength":128,"outlen":160,"seedlen":440},"sha224":{"securityStrength":192,"outlen":224,"seedlen":440},"sha256":{"securityStrength":256,"outlen":256,"seedlen":440},"sha384":{"securityStrength":256,"outlen":384,"seedlen":888},"sha512":{"securityStrength":256,"outlen":512,"seedlen":888}}')},function(e,t,r){"use strict";t.umulTo10x10=function(e,t,r){var n,i,o,s=e.words,a=t.words,c=r.words,u=0,f=0|s[0],h=8191&f,l=f>>>13,d=0|s[1],p=8191&d,y=d>>>13,b=0|s[2],g=8191&b,m=b>>>13,v=0|s[3],w=8191&v,_=v>>>13,S=0|s[4],E=8191&S,k=S>>>13,A=0|s[5],C=8191&A,I=A>>>13,T=0|s[6],x=8191&T,B=T>>>13,M=0|s[7],R=8191&M,N=M>>>13,O=0|s[8],L=8191&O,P=O>>>13,U=0|s[9],D=8191&U,j=U>>>13,K=0|a[0],V=8191&K,q=K>>>13,F=0|a[1],z=8191&F,H=F>>>13,W=0|a[2],G=8191&W,Y=W>>>13,Q=0|a[3],$=8191&Q,X=Q>>>13,Z=0|a[4],J=8191&Z,ee=Z>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,fe=0|a[8],he=8191&fe,le=fe>>>13,de=0|a[9],pe=8191&de,ye=de>>>13;r.length=19,n=Math.imul(h,V),i=Math.imul(h,q);var be=u+n+((8191&(i+=Math.imul(l,V)))<<13);u=(o=Math.imul(l,q))+(i>>>13)+(be>>>26),be&=67108863,n=Math.imul(p,V),i=Math.imul(p,q),i+=Math.imul(y,V),o=Math.imul(y,q),n+=Math.imul(h,z),i+=Math.imul(h,H);var ge=u+n+((8191&(i+=Math.imul(l,z)))<<13);u=(o+=Math.imul(l,H))+(i>>>13)+(ge>>>26),ge&=67108863,n=Math.imul(g,V),i=Math.imul(g,q),i+=Math.imul(m,V),o=Math.imul(m,q),n+=Math.imul(p,z),i+=Math.imul(p,H),i+=Math.imul(y,z),o+=Math.imul(y,H),n+=Math.imul(h,G),i+=Math.imul(h,Y);var me=u+n+((8191&(i+=Math.imul(l,G)))<<13);u=(o+=Math.imul(l,Y))+(i>>>13)+(me>>>26),me&=67108863,n=Math.imul(w,V),i=Math.imul(w,q),i+=Math.imul(_,V),o=Math.imul(_,q),n+=Math.imul(g,z),i+=Math.imul(g,H),i+=Math.imul(m,z),o+=Math.imul(m,H),n+=Math.imul(p,G),i+=Math.imul(p,Y),i+=Math.imul(y,G),o+=Math.imul(y,Y),n+=Math.imul(h,$),i+=Math.imul(h,X);var ve=u+n+((8191&(i+=Math.imul(l,$)))<<13);u=(o+=Math.imul(l,X))+(i>>>13)+(ve>>>26),ve&=67108863,n=Math.imul(E,V),i=Math.imul(E,q),i+=Math.imul(k,V),o=Math.imul(k,q),n+=Math.imul(w,z),i+=Math.imul(w,H),i+=Math.imul(_,z),o+=Math.imul(_,H),n+=Math.imul(g,G),i+=Math.imul(g,Y),i+=Math.imul(m,G),o+=Math.imul(m,Y),n+=Math.imul(p,$),i+=Math.imul(p,X),i+=Math.imul(y,$),o+=Math.imul(y,X),n+=Math.imul(h,J),i+=Math.imul(h,ee);var we=u+n+((8191&(i+=Math.imul(l,J)))<<13);u=(o+=Math.imul(l,ee))+(i>>>13)+(we>>>26),we&=67108863,n=Math.imul(C,V),i=Math.imul(C,q),i+=Math.imul(I,V),o=Math.imul(I,q),n+=Math.imul(E,z),i+=Math.imul(E,H),i+=Math.imul(k,z),o+=Math.imul(k,H),n+=Math.imul(w,G),i+=Math.imul(w,Y),i+=Math.imul(_,G),o+=Math.imul(_,Y),n+=Math.imul(g,$),i+=Math.imul(g,X),i+=Math.imul(m,$),o+=Math.imul(m,X),n+=Math.imul(p,J),i+=Math.imul(p,ee),i+=Math.imul(y,J),o+=Math.imul(y,ee),n+=Math.imul(h,re),i+=Math.imul(h,ne);var _e=u+n+((8191&(i+=Math.imul(l,re)))<<13);u=(o+=Math.imul(l,ne))+(i>>>13)+(_e>>>26),_e&=67108863,n=Math.imul(x,V),i=Math.imul(x,q),i+=Math.imul(B,V),o=Math.imul(B,q),n+=Math.imul(C,z),i+=Math.imul(C,H),i+=Math.imul(I,z),o+=Math.imul(I,H),n+=Math.imul(E,G),i+=Math.imul(E,Y),i+=Math.imul(k,G),o+=Math.imul(k,Y),n+=Math.imul(w,$),i+=Math.imul(w,X),i+=Math.imul(_,$),o+=Math.imul(_,X),n+=Math.imul(g,J),i+=Math.imul(g,ee),i+=Math.imul(m,J),o+=Math.imul(m,ee),n+=Math.imul(p,re),i+=Math.imul(p,ne),i+=Math.imul(y,re),o+=Math.imul(y,ne),n+=Math.imul(h,oe),i+=Math.imul(h,se);var Se=u+n+((8191&(i+=Math.imul(l,oe)))<<13);u=(o+=Math.imul(l,se))+(i>>>13)+(Se>>>26),Se&=67108863,n=Math.imul(R,V),i=Math.imul(R,q),i+=Math.imul(N,V),o=Math.imul(N,q),n+=Math.imul(x,z),i+=Math.imul(x,H),i+=Math.imul(B,z),o+=Math.imul(B,H),n+=Math.imul(C,G),i+=Math.imul(C,Y),i+=Math.imul(I,G),o+=Math.imul(I,Y),n+=Math.imul(E,$),i+=Math.imul(E,X),i+=Math.imul(k,$),o+=Math.imul(k,X),n+=Math.imul(w,J),i+=Math.imul(w,ee),i+=Math.imul(_,J),o+=Math.imul(_,ee),n+=Math.imul(g,re),i+=Math.imul(g,ne),i+=Math.imul(m,re),o+=Math.imul(m,ne),n+=Math.imul(p,oe),i+=Math.imul(p,se),i+=Math.imul(y,oe),o+=Math.imul(y,se),n+=Math.imul(h,ce),i+=Math.imul(h,ue);var Ee=u+n+((8191&(i+=Math.imul(l,ce)))<<13);u=(o+=Math.imul(l,ue))+(i>>>13)+(Ee>>>26),Ee&=67108863,n=Math.imul(L,V),i=Math.imul(L,q),i+=Math.imul(P,V),o=Math.imul(P,q),n+=Math.imul(R,z),i+=Math.imul(R,H),i+=Math.imul(N,z),o+=Math.imul(N,H),n+=Math.imul(x,G),i+=Math.imul(x,Y),i+=Math.imul(B,G),o+=Math.imul(B,Y),n+=Math.imul(C,$),i+=Math.imul(C,X),i+=Math.imul(I,$),o+=Math.imul(I,X),n+=Math.imul(E,J),i+=Math.imul(E,ee),i+=Math.imul(k,J),o+=Math.imul(k,ee),n+=Math.imul(w,re),i+=Math.imul(w,ne),i+=Math.imul(_,re),o+=Math.imul(_,ne),n+=Math.imul(g,oe),i+=Math.imul(g,se),i+=Math.imul(m,oe),o+=Math.imul(m,se),n+=Math.imul(p,ce),i+=Math.imul(p,ue),i+=Math.imul(y,ce),o+=Math.imul(y,ue),n+=Math.imul(h,he),i+=Math.imul(h,le);var ke=u+n+((8191&(i+=Math.imul(l,he)))<<13);u=(o+=Math.imul(l,le))+(i>>>13)+(ke>>>26),ke&=67108863,n=Math.imul(D,V),i=Math.imul(D,q),i+=Math.imul(j,V),o=Math.imul(j,q),n+=Math.imul(L,z),i+=Math.imul(L,H),i+=Math.imul(P,z),o+=Math.imul(P,H),n+=Math.imul(R,G),i+=Math.imul(R,Y),i+=Math.imul(N,G),o+=Math.imul(N,Y),n+=Math.imul(x,$),i+=Math.imul(x,X),i+=Math.imul(B,$),o+=Math.imul(B,X),n+=Math.imul(C,J),i+=Math.imul(C,ee),i+=Math.imul(I,J),o+=Math.imul(I,ee),n+=Math.imul(E,re),i+=Math.imul(E,ne),i+=Math.imul(k,re),o+=Math.imul(k,ne),n+=Math.imul(w,oe),i+=Math.imul(w,se),i+=Math.imul(_,oe),o+=Math.imul(_,se),n+=Math.imul(g,ce),i+=Math.imul(g,ue),i+=Math.imul(m,ce),o+=Math.imul(m,ue),n+=Math.imul(p,he),i+=Math.imul(p,le),i+=Math.imul(y,he),o+=Math.imul(y,le),n+=Math.imul(h,pe),i+=Math.imul(h,ye);var Ae=u+n+((8191&(i+=Math.imul(l,pe)))<<13);u=(o+=Math.imul(l,ye))+(i>>>13)+(Ae>>>26),Ae&=67108863,n=Math.imul(D,z),i=Math.imul(D,H),i+=Math.imul(j,z),o=Math.imul(j,H),n+=Math.imul(L,G),i+=Math.imul(L,Y),i+=Math.imul(P,G),o+=Math.imul(P,Y),n+=Math.imul(R,$),i+=Math.imul(R,X),i+=Math.imul(N,$),o+=Math.imul(N,X),n+=Math.imul(x,J),i+=Math.imul(x,ee),i+=Math.imul(B,J),o+=Math.imul(B,ee),n+=Math.imul(C,re),i+=Math.imul(C,ne),i+=Math.imul(I,re),o+=Math.imul(I,ne),n+=Math.imul(E,oe),i+=Math.imul(E,se),i+=Math.imul(k,oe),o+=Math.imul(k,se),n+=Math.imul(w,ce),i+=Math.imul(w,ue),i+=Math.imul(_,ce),o+=Math.imul(_,ue),n+=Math.imul(g,he),i+=Math.imul(g,le),i+=Math.imul(m,he),o+=Math.imul(m,le),n+=Math.imul(p,pe),i+=Math.imul(p,ye);var Ce=u+n+((8191&(i+=Math.imul(y,pe)))<<13);u=(o+=Math.imul(y,ye))+(i>>>13)+(Ce>>>26),Ce&=67108863,n=Math.imul(D,G),i=Math.imul(D,Y),i+=Math.imul(j,G),o=Math.imul(j,Y),n+=Math.imul(L,$),i+=Math.imul(L,X),i+=Math.imul(P,$),o+=Math.imul(P,X),n+=Math.imul(R,J),i+=Math.imul(R,ee),i+=Math.imul(N,J),o+=Math.imul(N,ee),n+=Math.imul(x,re),i+=Math.imul(x,ne),i+=Math.imul(B,re),o+=Math.imul(B,ne),n+=Math.imul(C,oe),i+=Math.imul(C,se),i+=Math.imul(I,oe),o+=Math.imul(I,se),n+=Math.imul(E,ce),i+=Math.imul(E,ue),i+=Math.imul(k,ce),o+=Math.imul(k,ue),n+=Math.imul(w,he),i+=Math.imul(w,le),i+=Math.imul(_,he),o+=Math.imul(_,le),n+=Math.imul(g,pe),i+=Math.imul(g,ye);var Ie=u+n+((8191&(i+=Math.imul(m,pe)))<<13);u=(o+=Math.imul(m,ye))+(i>>>13)+(Ie>>>26),Ie&=67108863,n=Math.imul(D,$),i=Math.imul(D,X),i+=Math.imul(j,$),o=Math.imul(j,X),n+=Math.imul(L,J),i+=Math.imul(L,ee),i+=Math.imul(P,J),o+=Math.imul(P,ee),n+=Math.imul(R,re),i+=Math.imul(R,ne),i+=Math.imul(N,re),o+=Math.imul(N,ne),n+=Math.imul(x,oe),i+=Math.imul(x,se),i+=Math.imul(B,oe),o+=Math.imul(B,se),n+=Math.imul(C,ce),i+=Math.imul(C,ue),i+=Math.imul(I,ce),o+=Math.imul(I,ue),n+=Math.imul(E,he),i+=Math.imul(E,le),i+=Math.imul(k,he),o+=Math.imul(k,le),n+=Math.imul(w,pe),i+=Math.imul(w,ye);var Te=u+n+((8191&(i+=Math.imul(_,pe)))<<13);u=(o+=Math.imul(_,ye))+(i>>>13)+(Te>>>26),Te&=67108863,n=Math.imul(D,J),i=Math.imul(D,ee),i+=Math.imul(j,J),o=Math.imul(j,ee),n+=Math.imul(L,re),i+=Math.imul(L,ne),i+=Math.imul(P,re),o+=Math.imul(P,ne),n+=Math.imul(R,oe),i+=Math.imul(R,se),i+=Math.imul(N,oe),o+=Math.imul(N,se),n+=Math.imul(x,ce),i+=Math.imul(x,ue),i+=Math.imul(B,ce),o+=Math.imul(B,ue),n+=Math.imul(C,he),i+=Math.imul(C,le),i+=Math.imul(I,he),o+=Math.imul(I,le),n+=Math.imul(E,pe),i+=Math.imul(E,ye);var xe=u+n+((8191&(i+=Math.imul(k,pe)))<<13);u=(o+=Math.imul(k,ye))+(i>>>13)+(xe>>>26),xe&=67108863,n=Math.imul(D,re),i=Math.imul(D,ne),i+=Math.imul(j,re),o=Math.imul(j,ne),n+=Math.imul(L,oe),i+=Math.imul(L,se),i+=Math.imul(P,oe),o+=Math.imul(P,se),n+=Math.imul(R,ce),i+=Math.imul(R,ue),i+=Math.imul(N,ce),o+=Math.imul(N,ue),n+=Math.imul(x,he),i+=Math.imul(x,le),i+=Math.imul(B,he),o+=Math.imul(B,le),n+=Math.imul(C,pe),i+=Math.imul(C,ye);var Be=u+n+((8191&(i+=Math.imul(I,pe)))<<13);u=(o+=Math.imul(I,ye))+(i>>>13)+(Be>>>26),Be&=67108863,n=Math.imul(D,oe),i=Math.imul(D,se),i+=Math.imul(j,oe),o=Math.imul(j,se),n+=Math.imul(L,ce),i+=Math.imul(L,ue),i+=Math.imul(P,ce),o+=Math.imul(P,ue),n+=Math.imul(R,he),i+=Math.imul(R,le),i+=Math.imul(N,he),o+=Math.imul(N,le),n+=Math.imul(x,pe),i+=Math.imul(x,ye);var Me=u+n+((8191&(i+=Math.imul(B,pe)))<<13);u=(o+=Math.imul(B,ye))+(i>>>13)+(Me>>>26),Me&=67108863,n=Math.imul(D,ce),i=Math.imul(D,ue),i+=Math.imul(j,ce),o=Math.imul(j,ue),n+=Math.imul(L,he),i+=Math.imul(L,le),i+=Math.imul(P,he),o+=Math.imul(P,le),n+=Math.imul(R,pe),i+=Math.imul(R,ye);var Re=u+n+((8191&(i+=Math.imul(N,pe)))<<13);u=(o+=Math.imul(N,ye))+(i>>>13)+(Re>>>26),Re&=67108863,n=Math.imul(D,he),i=Math.imul(D,le),i+=Math.imul(j,he),o=Math.imul(j,le),n+=Math.imul(L,pe),i+=Math.imul(L,ye);var Ne=u+n+((8191&(i+=Math.imul(P,pe)))<<13);u=(o+=Math.imul(P,ye))+(i>>>13)+(Ne>>>26),Ne&=67108863,n=Math.imul(D,pe),i=Math.imul(D,ye);var Oe=u+n+((8191&(i+=Math.imul(j,pe)))<<13);return u=(o=Math.imul(j,ye))+(i>>>13)+(Oe>>>26),Oe&=67108863,c[0]=be,c[1]=ge,c[2]=me,c[3]=ve,c[4]=we,c[5]=_e,c[6]=Se,c[7]=Ee,c[8]=ke,c[9]=Ae,c[10]=Ce,c[11]=Ie,c[12]=Te,c[13]=xe,c[14]=Be,c[15]=Me,c[16]=Re,c[17]=Ne,c[18]=Oe,0!==u&&(c[19]=u,r.length++),r}},function(e,t,r){"use strict";var n=r(3).Buffer,i=r(53),o=r(191),s=r(192);function a(){this.x=i.fromBuffer(n.from("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","hex")),this.y=i.fromBuffer(n.from("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8","hex")),this.inf=!1,this._precompute()}a.prototype._precompute=function(){for(var e=new o(this.x,this.y),t=new Array(1+Math.ceil(64.25)),r=t[0]=e,n=1;n=u;h--)f=(f<<1)+i[h];c.push(f)}for(var l=new s(null,null,null),d=new s(null,null,null),p=a;p>0;p--){for(var y=0;y=0;f--){for(var h=0;f>=0&&(u[0]=0|a[0][f],u[1]=0|a[1][f],0===u[0]&&0===u[1]);++h,--f);if(f>=0&&(h+=1),c=c.dblp(h),f<0)break;for(var l=0;l<2;l++){var d,p=u[l];0!==p&&(p>0?d=o[l][p>>1]:p<0&&(d=o[l][-p>>1].neg()),c=void 0===d.z?c.mixedAdd(d):c.add(d))}}return c},e.exports=new a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(451),o=(n=i)&&n.__esModule?n:{default:n};t.default=o.default,e.exports=t.default},function(e,t,r){"use strict";(function(e,n){Object.defineProperty(t,"__esModule",{value:!0}),t.hasNextTick=t.hasSetImmediate=void 0,t.fallback=f,t.wrap=h;var i,o=r(452),s=(i=o)&&i.__esModule?i:{default:i};var a,c=t.hasSetImmediate="function"==typeof e&&e,u=t.hasNextTick="object"==typeof n&&"function"==typeof n.nextTick;function f(e){setTimeout(e,0)}function h(e){return function(t){var r=(0,s.default)(arguments,1);e((function(){t.apply(null,r)}))}}a=c?e:u?n.nextTick:f,t.default=h(a)}).call(this,r(26).setImmediate,r(2))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i{const c=o[e];if(!c)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const u=c.keySize,f=c.ivSize,h=t.from("key expansion"),l=2*(f+u+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(h,(e,i)=>{if(e)return a(e);const o=[];let s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>l&&(a=l-s),o.push(n),s+=a,r.digest(i,(t,r)=>{if(t)return e(t);i=r,e()})})}),(function(e){if(e)return a(e);const r=l/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,l),c=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+u),macKey:e.slice(f+u)});a(null,{k1:c(i),k2:c(s)})}))})})}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){r=(0,o.default)(r||n.default);var a=(0,s.default)(t);if(!e())return r(null);var c=function(t){if(t)return r(t);if(e())return a(c);var n=(0,i.default)(arguments,1);r.apply(null,[null].concat(n))};a(c)};var n=a(r(455)),i=a(r(85)),o=a(r(456)),s=a(r(457));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t){e.exports=function(){}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(){if(null===e)throw new Error("Callback was already called.");var t=e;e=null,t.apply(this,arguments)}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAsync=void 0;var n,i=r(458),o=(n=i)&&n.__esModule?n:{default:n};var s="function"==typeof Symbol;function a(e){return s&&"AsyncFunction"===e[Symbol.toStringTag]}t.default=function(e){return a(e)?(0,o.default)(e):e},t.isAsync=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return(0,i.default)((function(t,r){var i;try{i=e.apply(this,t)}catch(e){return r(e)}(0,n.default)(i)&&"function"==typeof i.then?i.then((function(e){a(r,null,e)}),(function(e){a(r,e.message?e:new Error(e))})):r(null,i)}))};var n=s(r(459)),i=s(r(460)),o=s(r(176));function s(e){return e&&e.__esModule?e:{default:e}}function a(e,t,r){try{e(t,r)}catch(e){(0,o.default)(c,e)}}function c(e){throw e}e.exports=t.default},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(){var t=(0,o.default)(arguments),r=t.pop();e.call(this,t,r)}};var n,i=r(85),o=(n=i)&&n.__esModule?n:{default:n};e.exports=t.default},function(e,t,r){"use strict";const n=r(462);e.exports=(e,t)=>{n.generateEphmeralKeyPair(e,t)}},function(e,t,r){"use strict";(function(e){const n=r(72),i=r(71),o=r(87).bignum,s=r(181),a=s.toBase64,c=s.toBn,u={"P-256":256,"P-384":384,"P-521":521};t.generateEphmeralKeyPair=function(t,r){i(n.subtle.generateKey({name:"ECDH",namedCurve:t},!0,["deriveBits"]).then(r=>{const s=(s,c,f)=>{let h;"function"==typeof c&&(f=c,c=void 0),h=c?n.subtle.importKey("jwk",function(e,t){const r=l(e,t.public);return r.d=a(new o(t.private)),r}(t,c),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const d=Promise.all([n.subtle.importKey("jwk",l(t,s),{name:"ECDH",namedCurve:t},!1,[]),h]);i(d.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],u[t])).then(t=>e.from(t)),f)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:h(e),genSharedKey:s}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function h(t){const r=f[t.crv];return e.concat([e.from([4]),c(t.x).toArrayLike(e,"be",r),c(t.y).toArrayLike(e,"be",r)],1+2*r)}function l(t,r){const n=f[t];if(!r.slice(0,1).equals(e.from([4])))throw new Error("Invalid key format");const i=new o(r.slice(1,n+1)),s=new o(r.slice(1+n));return{kty:"EC",crv:t,x:a(i,n),y:a(s,n),ext:!0}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(81),i=r(5),o={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,s,a){const c=o[a];if(!c)throw new Error(`Hash '${a}' is unknown or not supported`);const u=n(e,t,r,s,c);return i.encode64(u)}},function(e,t,r){e.exports=r(465)(r(466))},function(e,t){const r="Impossible case. Please create issue.",n="The tweak was out of range or the resulted private key is invalid",i="The tweak was out of range or equal to zero",o="Unknow error on context randomization",s="Private Key is invalid",a="Public Key could not be parsed",c="Public Key serialization error",u="The sum of the public keys is not valid",f="Signature could not be parsed",h="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",d="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function y(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function b(e){p("Boolean"===m(e),"Expected compressed to be a Boolean")}function g(e=(e=>new Uint8Array(e)),t){return"function"==typeof e&&(e=e(t)),y("output",e,t),e}function m(e){return Object.prototype.toString.call(e).slice(8,-1)}e.exports=e=>({contextRandomize(t){switch(p(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&y("seed",t,32),e.contextRandomize(t)){case 1:throw new Error(o)}},privateKeyVerify:t=>(y("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(y("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(r)}},privateKeyTweakAdd(t,r){switch(y("private key",t,32),y("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(n)}},privateKeyTweakMul(t,r){switch(y("private key",t,32),y("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(i)}},publicKeyVerify:t=>(y("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,n){switch(y("private key",t,32),b(r),n=g(n,r?33:65),e.publicKeyCreate(n,t)){case 0:return n;case 1:throw new Error(s);case 2:throw new Error(c)}},publicKeyConvert(t,r=!0,n){switch(y("public key",t,[33,65]),b(r),n=g(n,r?33:65),e.publicKeyConvert(n,t)){case 0:return n;case 1:throw new Error(a);case 2:throw new Error(c)}},publicKeyNegate(t,n=!0,i){switch(y("public key",t,[33,65]),b(n),i=g(i,n?33:65),e.publicKeyNegate(i,t)){case 0:return i;case 1:throw new Error(a);case 2:throw new Error(r);case 3:throw new Error(c)}},publicKeyCombine(t,r=!0,n){p(Array.isArray(t),"Expected public keys to be an Array"),p(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)y("public key",e,[33,65]);switch(b(r),n=g(n,r?33:65),e.publicKeyCombine(n,t)){case 0:return n;case 1:throw new Error(a);case 2:throw new Error(u);case 3:throw new Error(c)}},publicKeyTweakAdd(t,r,i=!0,o){switch(y("public key",t,[33,65]),y("tweak",r,32),b(i),o=g(o,i?33:65),e.publicKeyTweakAdd(o,t,r)){case 0:return o;case 1:throw new Error(a);case 2:throw new Error(n)}},publicKeyTweakMul(t,r,n=!0,o){switch(y("public key",t,[33,65]),y("tweak",r,32),b(n),o=g(o,n?33:65),e.publicKeyTweakMul(o,t,r)){case 0:return o;case 1:throw new Error(a);case 2:throw new Error(i)}},signatureNormalize(t){switch(y("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(f)}},signatureExport(t,n){y("signature",t,64);const i={output:n=g(n,72),outputlen:72};switch(e.signatureExport(i,t)){case 0:return n.slice(0,i.outputlen);case 1:throw new Error(f);case 2:throw new Error(r)}},signatureImport(t,n){switch(y("signature",t),n=g(n,64),e.signatureImport(n,t)){case 0:return n;case 1:throw new Error(f);case 2:throw new Error(r)}},ecdsaSign(t,n,i={},o){y("message",t,32),y("private key",n,32),p("Object"===m(i),"Expected options to be an Object"),void 0!==i.data&&y("options.data",i.data),void 0!==i.noncefn&&p("Function"===m(i.noncefn),"Expected options.noncefn to be a Function");const s={signature:o=g(o,64),recid:null};switch(e.ecdsaSign(s,t,n,i.data,i.noncefn)){case 0:return s;case 1:throw new Error(h);case 2:throw new Error(r)}},ecdsaVerify(t,r,n){switch(y("signature",t,64),y("message",r,32),y("public key",n,[33,65]),e.ecdsaVerify(t,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(f);case 2:throw new Error(a)}},ecdsaRecover(t,n,i,o=!0,s){switch(y("signature",t,64),p("Number"===m(n)&&n>=0&&n<=3,"Expected recovery id to be a Number within interval [0, 3]"),y("message",i,32),b(o),s=g(s,o?33:65),e.ecdsaRecover(s,t,n,i)){case 0:return s;case 1:throw new Error(f);case 2:throw new Error(l);case 3:throw new Error(r)}},ecdh(t,r,n={},i){switch(y("public key",t,[33,65]),y("private key",r,32),p("Object"===m(n),"Expected options to be an Object"),void 0!==n.data&&y("options.data",n.data),void 0!==n.hashfn?(p("Function"===m(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&y("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&y("options.ybuf",n.ybuf,32),y("output",i)):i=g(i,32),e.ecdh(i,t,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return i;case 1:throw new Error(a);case 2:throw new Error(d)}}})},function(e,t,r){const n=new(0,r(193).ec)("secp256k1"),i=n.curve,o=i.n.constructor;function s(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new o(t);if(r.cmp(i.p)>=0)return null;r=r.toRed(i.red);let s=r.redSqr().redIMul(r).redIAdd(i.b).redSqrt();return 3===e!==s.isOdd()&&(s=s.redNeg()),n.keyPair({pub:{x:r,y:s}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let s=new o(t),a=new o(r);if(s.cmp(i.p)>=0||a.cmp(i.p)>=0)return null;if(s=s.toRed(i.red),a=a.toRed(i.red),(6===e||7===e)&&a.isOdd()!==(7===e))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:s,y:a}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function a(e,t){const r=t.encode(null,33===e.length);for(let t=0;t0,privateKeyVerify(e){const t=new o(e);return t.cmp(i.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new o(e),r=i.n.sub(t).umod(i.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new o(t);if(r.cmp(i.n)>=0)return 1;if(r.iadd(new o(e)),r.cmp(i.n)>=0&&r.isub(i.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},privateKeyTweakMul(e,t){let r=new o(t);if(r.cmp(i.n)>=0||r.isZero())return 1;r.imul(new o(e)),r.cmp(i.n)>=0&&(r=r.umod(i.n));const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},publicKeyVerify:e=>null===s(e)?1:0,publicKeyCreate(e,t){const r=new o(t);if(r.cmp(i.n)>=0||r.isZero())return 1;return a(e,n.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const r=s(t);if(null===r)return 1;return a(e,r.getPublic()),0},publicKeyNegate(e,t){const r=s(t);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),a(e,n),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e=0)return 2;const c=n.getPublic().add(i.g.mul(r));return c.isInfinity()?2:(a(e,c),0)},publicKeyTweakMul(e,t,r){const n=s(t);if(null===n)return 1;if((r=new o(r)).cmp(i.n)>=0||r.isZero())return 2;return a(e,n.getPublic().mul(r)),0},signatureNormalize(e){const t=new o(e.subarray(0,32)),r=new o(e.subarray(32,64));return t.cmp(i.n)>=0||r.cmp(i.n)>=0?1:(1===r.cmp(n.nh)&&e.set(i.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),n=t.subarray(32,64);if(new o(r).cmp(i.n)>=0)return 1;if(new o(n).cmp(i.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(r,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let f=s.subarray(39,72);f[0]=0,f.set(n,1);let h=33,l=0;for(;h>1&&0===f[l]&&!(128&f[l+1]);--h,++l);return f=f.subarray(l),128&f[0]||h>1&&0===f[0]&&!(128&f[1])?1:(e.outputlen=6+c+h,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=f.length,s.set(f,6+c),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const n=t[5+r];if(0===n)return 1;if(6+r+n!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(n>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let s=t.subarray(4,4+r);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=t.subarray(6+r);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new o(s);c.cmp(i.n)>=0&&(c=new o(0));let u=new o(t.subarray(6+r));return u.cmp(i.n)>=0&&(u=new o(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,s,a){if(a){const e=a;a=n=>{const i=e(t,r,null,s,n);if(!(i instanceof Uint8Array&&32===i.length))throw new Error("This is the way");return new o(i)}}const c=new o(r);if(c.cmp(i.n)>=0||c.isZero())return 1;let u;try{u=n.sign(t,r,{canonical:!0,k:a,pers:s})}catch(e){return 1}return e.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),e.recid=u.recoveryParam,0},ecdsaVerify(e,t,r){const a={r:e.subarray(0,32),s:e.subarray(32,64)},c=new o(a.r),u=new o(a.s);if(c.cmp(i.n)>=0||u.cmp(i.n)>=0)return 1;if(1===u.cmp(n.nh)||c.isZero()||u.isZero())return 3;const f=s(r);if(null===f)return 2;const h=f.getPublic();return n.verify(t,a,h)?0:3},ecdsaRecover(e,t,r,s){const c={r:t.slice(0,32),s:t.slice(32,64)},u=new o(c.r),f=new o(c.s);if(u.cmp(i.n)>=0||f.cmp(i.n)>=0)return 1;if(u.isZero()||f.isZero())return 2;let h;try{h=n.recoverPubKey(s,c,r)}catch(e){return 2}return a(e,h),0},ecdh(e,t,r,a,c,u,f){const h=s(t);if(null===h)return 1;const l=new o(r);if(l.cmp(i.n)>=0||l.isZero())return 2;const d=h.getPublic().mul(l);if(void 0===c){const t=d.encode(null,!0),r=n.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=r[t]}else{u||(u=new Uint8Array(32));const t=d.getX().toArray("be",32);for(let e=0;e<32;++e)u[e]=t[e];f||(f=new Uint8Array(32));const r=d.getY().toArray("be",32);for(let e=0;e<32;++e)f[e]=r[e];const n=c(u,f,a);if(!(n instanceof Uint8Array&&n.length===e.length))return 2;e.set(n)}return 0}}},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.4","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny ","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}')},function(e,t){},function(e,t,r){"use strict";var n=r(10),i=r(11),o=r(1),s=r(54),a=n.assert;function c(e){s.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(c,s),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,o,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new i(1),y=new i(0),b=new i(0),g=new i(1),m=0;0!==l.cmpn(0);){var v=d.div(l);u=d.sub(v.mul(l)),f=b.sub(v.mul(p));var w=g.sub(v.mul(y));if(!n&&u.cmp(h)<0)t=c.neg(),r=p,n=u.neg(),o=f;else if(n&&2==++m)break;c=u,d=l,l=u,b=p,p=f,g=y,y=w}s=u.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=t,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),u=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),l=c.redSqr().redIAdd(f).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(11),i=r(1),o=r(54),s=r(10);function a(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(c,o.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},a.prototype.point=function(e,t){return new c(this,e,t)},a.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),s=i.redMul(n),a=t.z.redMul(o.redAdd(s).redSqr()),c=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(10),i=r(11),o=r(1),s=r(54),a=n.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,s.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,r,n,o){s.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(c,s),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},c.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=n.redMul(o.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(t&&!c||!t&&c)&&(a=a.redNeg()),this.point(e,a)},c.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),s=n.redMul(o.redInvm());if(0===s.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(u,s.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,r,n){return new u(this,e,t,r,n)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),s=o.redSub(r),a=n.redSub(t),c=i.redMul(s),u=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},u.prototype._projDbl=function(){var e,t,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(n=this.curve._mulA(a)).redAdd(c);this.zOne?(e=s.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(n.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(i=this.z.redSqr(),o=u.redSub(i).redISub(i),e=s.redSub(a).redISub(c).redMul(o),t=u.redMul(n.redSub(c)),r=u.redMul(o))}else n=a.redAdd(c),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),e=this.curve._mulC(s.redISub(n)).redMul(o),t=this.curve._mulC(n).redMul(a.redISub(c)),r=n.redMul(o);return this.curve.point(e,t,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(t),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(u,f,l,h)},u.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),s=this.y.redMul(e.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(f);return this.curve.twisted?(t=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(t=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,t,r)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},u.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(e,t,r){"use strict";t.sha1=r(473),t.sha224=r(474),t.sha256=r(198),t.sha384=r(475),t.sha512=r(199)},function(e,t,r){"use strict";var n=r(13),i=r(46),o=r(197),s=n.rotl32,a=n.sum32,c=n.sum32_5,u=o.ft_1,f=i.BlockHash,h=[1518500249,1859775393,2400959708,3395469782];function l(){if(!(this instanceof l))return new l;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(l,f),e.exports=l,l.blockSize=512,l.outSize=160,l.hmacStrength=80,l.padLength=64,l.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},h.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),c=e.toArray("be",s),u=new i({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var y=p.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var g=d.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var m=(p.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),m^=1),new f({r:b,s:g,recoveryParam:m})}}}}}},h.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new f(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,c=s.invm(this.n),u=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(e,t,r,i){c((3&r)===r,"The recovery param is more than two bits"),t=new f(t,i);var o=this.n,s=new n(e),a=t.r,u=t.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=t.r.invm(o),p=o.sub(s).mul(d).umod(o),y=u.mul(d).umod(o);return this.g.mulAdd(p,a,y)},h.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new f(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(93),i=r(194),o=r(17);function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},s.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length"}},function(e,t,r){"use strict";var n=r(11),i=r(10),o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function c(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=t.place;o>>=0;return!(i<=127)&&(t.place=s,i)}function u(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new a;if(48!==e[r.place++])return!1;var o=c(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var s=c(e,r);if(!1===s)return!1;var u=e.slice(r.place,s+r.place);if(r.place+=s,2!==e[r.place++])return!1;var f=c(e,r);if(!1===f)return!1;if(e.length!==f+r.place)return!1;var h=e.slice(r.place,f+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new n(u),this.s=new n(h),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),(n=n.concat(t)).push(2),f(n,r.length);var o=n.concat(r),s=[48];return f(s,o.length),s=s.concat(o),i.encode(s,e)}},function(e,t,r){"use strict";var n=r(93),i=r(92),o=r(10),s=o.assert,a=o.parseBytes,c=r(484),u=r(485);function f(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},f.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;tn[e]}},function(e,t,r){"use strict";const n=new(0,r(193).ec)("secp256k1");e.exports={verify:async(e,t,r)=>{if(!e)throw new Error("No signature given");if(!t)throw new Error("Given publicKey was undefined");if(!r)throw new Error("Given input data was undefined");let i=!1;const o=n.keyPair({pub:t,pubEnc:"hex"});try{i=n.verify(r,e,o)}catch(e){}return Promise.resolve(i)}}},function(e,t,r){"use strict";const n=r(146),i=r(201).Buffer;e.exports={verify:async(e,t,r)=>{if(!e)throw new Error("No signature given");if(!t)throw new Error("Given publicKey was undefined");if(!r)throw new Error("Given input data was undefined");i.isBuffer(r)||(r=i.from(r));let o=!1;try{const u=n.keys.supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(i.from(t,"hex"));o=await(s=u,a=r,c=i.from(e,"hex"),new Promise((e,t)=>{s.verify(a,c,(r,n)=>{r||e(n),t(n)})}))}catch(e){}var s,a,c;return Promise.resolve(o)}}},function(e,t,r){"use strict";const n=r(490);e.exports=n},function(e,t,r){"use strict";const n=r(491),i=r(202),o=r(493),s=r(64),a=r(200),c=r(16),u=c.join("./orbitdb","identity","identitykeys"),f={orbitdb:o},h=e=>{if(!l.isSupported(e))throw new Error(`IdentityProvider type '${e}' is not supported`);return f[e]};class l{constructor(e){this._keystore=e.keystore,this._signingKeystore=e.signingKeystore||this._keystore,this._knownIdentities=e.cache||new a(e.cacheSize||100)}static get IdentityProvider(){return i}get keystore(){return this._keystore}get signingKeystore(){return this._signingKeystore}async sign(e,t){const r=await this.keystore.getKey(e.id);if(!r)throw new Error("Private signing key not found from Keystore");return await this.keystore.sign(r,t)}async verify(e,t,r,n="v1"){return this.keystore.verify(e,t,r,n)}async createIdentity(e={}){const t=e.keystore||this.keystore,r=e.type||"orbitdb",i="orbitdb"===r?new o(e.signingKeystore||t):new(h(r))(e),s=await i.getId(e);e.migrate&&await e.migrate({targetStore:t._store,targetId:s});const{publicKey:a,idSignature:c}=await this.signId(s),u=await i.signIdentity(a+c,e);return new n(s,a,c,u,r,this)}async signId(e){const t=this.keystore,r=await t.getKey(e)||await t.createKey(e);return{publicKey:t.getPublic(r),idSignature:await t.sign(r,e)}}async verifyIdentity(e){if(!n.isIdentity(e))return!1;const t=this._knownIdentities.get(e.signatures.id);if(t)return e.id===t.id&&e.publicKey===t.publicKey&&e.signatures.id===t.signatures.id&&e.signatures.publicKey===t.signatures.publicKey;if(!await this.keystore.verify(e.signatures.id,e.publicKey,e.id))return!1;const r=h(e.type),i=await r.verifyIdentity(e);return i&&this._knownIdentities.set(e.signatures.id,n.toJSON(e)),i}static async verifyIdentity(e){if(!n.isIdentity(e))return!1;if(!await s.verify(e.signatures.id,e.publicKey,e.id))return!1;return h(e.type).verifyIdentity(e)}static async createIdentity(e={}){e.keystore||(e.keystore=new s(e.identityKeysPath||u)),e.signingKeystore||(e.signingKeysPath?e.signingKeystore=new s(e.signingKeysPath):e.signingKeystore=e.keystore),e=Object.assign({},{type:"orbitdb"},e);return new l(e).createIdentity(e)}static isSupported(e){return Object.keys(f).includes(e)}static addIdentityProvider(e){if(!e)throw new Error("IdentityProvider class needs to be given as an option");if(!e.type||"string"!=typeof e.type)throw new Error("Given IdentityProvider class needs to implement: static get type() { /* return a string */}.");f[e.type]=e}static removeIdentityProvider(e){delete f[e]}}e.exports=l},function(e,t,r){"use strict";const n=r(492);e.exports=class{constructor(e,t,r,i,o,s){if(!n(e))throw new Error("Identity id is required");if(!n(t))throw new Error("Invalid public key");if(!n(r))throw new Error("Signature of the id (idSignature) is required");if(!n(i))throw new Error("Signature of (publicKey + idSignature) is required");if(!n(o))throw new Error("Identity type is required");if(!n(s))throw new Error("Identity provider is required");this._id=e,this._publicKey=t,this._signatures=Object.assign({},{id:r},{publicKey:i}),this._type=o,this._provider=s}get id(){return this._id}get publicKey(){return this._publicKey}get signatures(){return this._signatures}get type(){return this._type}get provider(){return this._provider}toJSON(){return{id:this.id,publicKey:this.publicKey,signatures:this.signatures,type:this.type}}static isIdentity(e){return void 0!==e.id&&void 0!==e.publicKey&&void 0!==e.signatures&&void 0!==e.signatures.id&&void 0!==e.signatures.publicKey&&void 0!==e.type}static toJSON(e){return{id:e.id,publicKey:e.publicKey,signatures:e.signatures,type:e.type}}}},function(e,t,r){"use strict";e.exports=e=>null!=e},function(e,t,r){"use strict";const n=r(202),i=r(64);e.exports=class extends n{constructor(e){if(super(),!e)throw new Error("OrbitDBIdentityProvider requires a keystore");this._keystore=e}static get type(){return"orbitdb"}async getId(e={}){const t=e.id;if(!t)throw new Error("id is required");const r=this._keystore;return(await r.getKey(t)||await r.createKey(t)).public.marshal().toString("hex")}async signIdentity(e,t={}){const r=t.id;if(!r)throw new Error("id is required");const n=this._keystore,i=await n.getKey(r);if(!i)throw new Error(`Signing key for '${r}' not found`);return n.sign(i,e)}static async verifyIdentity(e){return i.verify(e.signatures.publicKey,e.id,e.publicKey+e.signatures.id)}}},function(e,t,r){const n=r(495);e.exports=n},function(e,t,r){"use strict";const n=r(55),i=r(496),o={"legacy-ipfs":r(497),ipfs:r(498),orbitdb:r(502)},s=e=>{if(!a.isSupported(e))throw new Error(`AccessController type '${e}' is not supported`);return o[e]};class a{static get AccessController(){return n}static isSupported(e){return Object.keys(o).includes(e)}static addAccessController(e){if(!e.AccessController)throw new Error("AccessController class needs to be given as an option");if(!e.AccessController.type||"string"!=typeof e.AccessController.type)throw new Error("Given AccessController class needs to implement: static get type() { /* return a string */}.");o[e.AccessController.type]=e.AccessController}static addAccessControllers(e){const t=e.AccessControllers;if(!t)throw new Error("AccessController classes need to be given as an option");t.forEach(e=>{a.addAccessController({AccessController:e})})}static removeAccessController(e){delete o[e]}static async resolve(e,t,r={}){const{type:n,params:o}=await i.resolve(e._ipfs,t,r),a=s(n),c=await a.create(e,Object.assign({},r,o));return await c.load(o.address),c}static async create(e,t,r={}){const n=s(t),o=await n.create(e,r),a=await o.save();return await i.create(e._ipfs,t,a)}}e.exports=a},function(e,t,r){"use strict";const n=r(18);class i{constructor(e,t={}){this.type=e,this.params=t}static async resolve(e,t,r={}){if(r.skipManifest){if(!r.type)throw new Error("No manifest, access-controller type required");return new i(r.type,{address:t})}{0===t.indexOf("/ipfs")&&(t=t.split("/")[2]);const{type:r,params:o}=await n.read(e,t);return new i(r,o)}}static async create(e,t,r){if(r.skipManifest)return r.address;const i={type:t,params:r};return n.write(e,"dag-cbor",i)}}e.exports=i},function(e,t,r){"use strict";const n=r(18),i=r(3).Buffer,o=r(55);class s extends o{constructor(e,t){super(),this._ipfs=e,this._write=Array.from(t.write||[])}static get type(){return"legacy-ipfs"}get write(){return this._write}async canAppend(e,t){const r=e.key;return!(!this.write.includes(r)&&!this.write.includes("*"))}async load(e){0===e.indexOf("/ipfs")&&(e=e.split("/")[2]);try{const t=await n.read(this._ipfs,e);this._write=t.write}catch(e){console.log("LegacyIPFSAccessController.load ERROR:",e)}}async save(e){let t;const r={admin:[],write:this.write,read:[]};try{t=await n.write(this._ipfs,"raw",i.from(JSON.stringify(r,null,2)),{format:"dag-pb"})}catch(e){console.log("LegacyIPFSAccessController.save ERROR:",e)}return{address:t,skipManifest:!0}}static async create(e,t={}){return t={...t,write:t.write||[e.identity.publicKey]},new s(e._ipfs,t)}}e.exports=s},function(e,t,r){"use strict";const{io:n}=r(499),i=r(55);class o extends i{constructor(e,t){super(),this._ipfs=e,this._write=Array.from(t.write||[])}static get type(){return"ipfs"}get write(){return this._write}async canAppend(e,t){const r=e.identity.id;return!(!this.write.includes(r)&&!this.write.includes("*"))&&t.verifyIdentity(e.identity)}async load(e){0===e.indexOf("/ipfs")&&(e=e.split("/")[2]);try{this._write=await n.read(this._ipfs,e)}catch(e){console.log("IPFSAccessController.load ERROR:",e)}}async save(){let e;try{e=await n.write(this._ipfs,"dag-cbor",{write:JSON.stringify(this.write,null,2)})}catch(e){console.log("IPFSAccessController.save ERROR:",e)}return{address:e}}static async create(e,t={}){return t={...t,write:t.write||[e.identity.id]},new o(e._ipfs,t)}}e.exports=o},function(e,t,r){"use strict";const n=r(500),i=r(501);e.exports={io:i,isValidEthAddress:n}},function(e,t,r){"use strict";e.exports=(e,t)=>e.utils.isAddress(t)},function(e,t,r){"use strict";const n=r(18);e.exports={read:async(e,t,r={})=>{const i=await n.read(e,t,r);return"string"==typeof i.write?JSON.parse(i.write):i.write},write:n.write}},function(e,t,r){"use strict";const n=r(503),i=r(55),o=r(504);class s extends i{constructor(e,t){super(),this._orbitdb=e,this._db=null,this._options=t||{}}static get type(){return"orbitdb"}get address(){return this._db.address}async canAppend(e,t){const r=new Set([...this.get("write"),...this.get("admin")]);if(r.has(e.identity.id)||r.has("*")){return await t.verifyIdentity(e.identity)}return!1}get capabilities(){if(this._db){const e=this._db.index,t=t=>{const r=t[0];e[r]=new Set([...e[r]||[],...t[1]])};return Object.entries({...e,admin:new Set([...e.admin||[],...this._db.access.write])}).forEach(t),e}return{}}get(e){return this.capabilities[e]||new Set([])}async close(){await this._db.close()}async load(e){this._db&&await this._db.close(),this._db=await this._orbitdb.keyvalue(o(e),{accessController:{type:"ipfs",write:this._options.admin||[this._orbitdb.identity.id]},sync:!0}),this._db.events.on("ready",this._onUpdate.bind(this)),this._db.events.on("write",this._onUpdate.bind(this)),this._db.events.on("replicated",this._onUpdate.bind(this)),await this._db.load()}async save(){return{address:this._db.address.toString()}}async grant(e,t){const r=new Set([...this._db.get(e)||[],t]);await this._db.put(e,Array.from(r.values()))}async revoke(e,t){const r=new Set(this._db.get(e)||[]);r.delete(t),r.size>0?await this._db.put(e,Array.from(r.values())):await this._db.del(e)}_onUpdate(){this.emit("updated")}static async create(e,t={}){const r=new s(e,t);return await r.load(t.address||t.name||"default-access-controller"),t.write&&!t.address&&await n(t.write,async e=>r.grant("write",e)),r}}e.exports=s},function(e,t,r){"use strict";const n=r(122);e.exports=(e,t)=>{const r=[];return n(e,(e,n,i)=>Promise.resolve(t(n,i)).then(e=>{r.push(e)})).then(()=>r)}},function(e,t,r){"use strict";const n=r(16);e.exports=e=>"_access"===e.toString().split("/").pop()?e:n.join(e,"/_access")},function(e,t,r){"use strict";const n=r(16),{CID:i}=r(19),o=e=>""!==e&&" "!==e;class s{constructor(e,t){this.root=e,this.path=t}toString(){return s.join(this.root,this.path)}static isValid(e){const t=(e=e.toString().replace(/\\/g,"/")).toString().split("/").filter((t,r)=>!((0===r||1===r)&&0===e.toString().indexOf("/orbit")&&"orbitdb"===t)).filter(o);let r;try{r=(e=>{const t=["zd","Qm","ba","k5"];for(const r of t)if(e.indexOf(r)>-1)return!0;return!1})(t[0])?i.parse(t[0]).toString():null}catch(e){return!1}return null!==r}static parse(e){if(!e)throw new Error("Not a valid OrbitDB address: "+e);if(!s.isValid(e))throw new Error("Not a valid OrbitDB address: "+e);const t=(e=e.toString().replace(/\\/g,"/")).toString().split("/").filter((t,r)=>!((0===r||1===r)&&0===e.toString().indexOf("/orbit")&&"orbitdb"===t)).filter(e=>""!==e&&" "!==e);return new s(t[0],t.slice(1,t.length).join("/"))}static join(...e){return(n.posix||n).join("/orbitdb",...e)}}e.exports=s},function(e,t,r){const n=r(16),i=r(18);e.exports=async(e,t,r,o,s)=>{const a=Object.assign({name:t,type:r,accessController:(n.posix||n).join("/ipfs",o)},void 0!==s.meta?{meta:s.meta}:{});return i.write(e,s.format||"dag-cbor",a,s)}},function(e,t,r){"use strict";(function(t){const n=r(508),i=r(25),o=i.create("exchange-heads",{color:i.Colors.Yellow});i.setLogLevel("ERROR");e.exports=async(e,r,i,s,a,c,u)=>{const f=e=>{const r=JSON.parse(t.from(e.data).toString()),{address:n,heads:i}=r;c(n,i)};let h=a(i);if(!h)try{o.debug("Create a channel to "+i),h=await n.open(e,i),h.on("message",f),o.debug("Channel created to "+i),u(h)}catch(e){o.error(e)}await h.connect(),o.debug("Connected to "+i);const l=await(async e=>{if(!e||!e._cache)return[];return[...await e._cache.get(e.localHeadsPath)||[],...await e._cache.get(e.remoteHeadsPath)||[]]})(s(r));return o.debug(`Send latest heads of '${r}':\n`,JSON.stringify(l.map(e=>e.hash),null,2)),l&&await h.send(JSON.stringify({address:r,heads:l})),h}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";r(16);const n=r(7),i=r(509),o=r(510),s=r(512),a=r(513);class c extends n{constructor(e,t){if(super(),this._ipfs=e,!e.pubsub)throw new Error("This IPFS node does not support pubsub.");if(this._closed=!1,this._isClosed=()=>this._closed,this._receiverID=t,!this._receiverID)throw new Error("Receiver ID was undefined")}get id(){return this._id}get peers(){return this._peers}async connect(){await s(this._ipfs,[this._receiverID],this._id,this._isClosed)}async send(e){if(this._closed)return;let t=o(e);await this._ipfs.pubsub.publish(this._id,t)}close(){this._closed=!0,this.removeAllListeners("message"),this._ipfs.pubsub.unsubscribe(this._id,this._messageHandler)}async _setup(){this._senderID=await a(this._ipfs),this._peers=Array.from([this._senderID,this._receiverID]).sort(),this._id="/"+i+"/"+this._peers.join("/"),this._messageHandler=e=>{e&&e.from===this._receiverID&&this.emit("message",e)}}async _openChannel(){this._closed=!1,await this._setup(),await this._ipfs.pubsub.subscribe(this._id,this._messageHandler)}static async open(e,t){const r=new c(e,t);return await r._openChannel(),r}}e.exports=c},function(e,t,r){"use strict";e.exports="ipfs-pubsub-direct-channel/v1"},function(e,t,r){"use strict";const n=r(511).Buffer;e.exports=e=>{let t=e;return n.isBuffer(t)||(t=n.from(t)),t}},function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var n=r(0),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";e.exports=async(e,t,r,n)=>{const i=async()=>{const n=await e.pubsub.peers(r);return 0===t.map(e=>n.includes(e)).filter(e=>!1===e).length};return await i()?Promise.resolve():new Promise(async(e,t)=>{const r=setInterval(async()=>{try{n()?clearInterval(r):await i()&&(clearInterval(r),e())}catch(e){t(e)}},100)})}},function(e,t,r){"use strict";e.exports=async e=>(await e.id()).id},function(e,t,r){"use strict";const n=r(515),i=r(18);e.exports={isDefined:n,io:i}},function(e,t,r){"use strict";e.exports=e=>null!=e},function(module,exports,__webpack_require__){"use strict";const levelup=__webpack_require__(203),level=__webpack_require__(530),fs="object"==typeof window||"object"==typeof self?null:eval('require("fs")');class Storage{constructor(e,t={}){this.storage=e,this.preCreate=t.preCreate?t.preCreate:()=>{};const r=Object.assign({},t,{createIfMissing:!0,errorIfExists:!1,compression:!0,cacheSize:8388608});delete r.preCreate,this.options={down:r}}createStore(e="./orbitdb",t={}){return new Promise(async(r,n)=>{let i,o;if(this.options.up=t,await this.preCreate(e,this.options),this.storage)o=this.storage(e,this.options.down),o.status||(o.status="unknown-shim"),o.location||(o.location=e),i=levelup(o,t),i.open(e=>{if(e)return n(e);o&&"unknown-shim"===o.status&&(o.status="open"),r(i)});else{fs&&fs.mkdirSync&&fs.mkdirSync(e,{recursive:!0});const n=level(e,t);await n.open(),r(n)}})}destroy(e){return new Promise((t,r)=>{this.storage.destroy||t(),this.storage.destroy(e._db.location,e=>{if(e)return r(e);t()})})}async preCreate(e,t){}}module.exports=(e,t)=>new Storage(e,t)},function(e,t,r){var n=r(204).AbstractLevelDOWN,i=r(1),o=r(519),s="put get del batch clear".split(" "),a="approximateSize compactRange".split(" ");function c(e){n.call(this,e.supports||{}),a.forEach((function(t){"function"!=typeof e[t]||this.supports.additionalMethods[t]||(this.supports.additionalMethods[t]=!0)}),this),this._db=e,this._operations=[],u(this)}function u(e){s.forEach((function(t){e["_"+t]=function(){this._operations.push({method:t,args:arguments})}})),Object.keys(e.supports.additionalMethods).forEach((function(t){e[t]=function(){this._operations.push({method:t,args:arguments})}})),e._iterator=function(t){var r=new o(e,t);return this._operations.push({iterator:r}),r}}i(c,n),c.prototype.type="deferred-leveldown",c.prototype._open=function(e,t){var r=this;this._db.open(e,(function(e){if(e)return t(e);r._operations.forEach((function(e){e.iterator?e.iterator.setDb(r._db):r._db[e.method].apply(r._db,e.args)})),r._operations=[],function(e){s.concat("iterator").forEach((function(t){e["_"+t]=function(){return this._db[t].apply(this._db,arguments)}})),Object.keys(e.supports.additionalMethods).forEach((function(t){e[t]=function(){return this._db[t].apply(this._db,arguments)}}))}(r),t()}))},c.prototype._close=function(e){var t=this;this._db.close((function(r){if(r)return e(r);u(t),e()}))},c.prototype._serializeKey=function(e){return e},c.prototype._serializeValue=function(e){return e},e.exports=c,e.exports.DeferredIterator=o},function(e,t,r){var n=r(9),i=r(94),o=r(0).Buffer,s=r(205),a=r(206),c=r(95),u=Object.prototype.hasOwnProperty,f="start end gt gte lt lte".split(" ");function h(e){this.status="new",this.supports=i(e,{status:!0})}function l(e,t){var r={};for(var n in t)if(u.call(t,n)){var i=t[n];d(n)&&(i=e._serializeKey(i)),r[n]=i}return r}function d(e){return-1!==f.indexOf(e)}h.prototype.open=function(e,t){var r=this,n=this.status;if("function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("open() requires a callback argument");"object"==typeof e&&null!==e||(e={}),e.createIfMissing=!1!==e.createIfMissing,e.errorIfExists=!!e.errorIfExists,this.status="opening",this._open(e,(function(e){if(e)return r.status=n,t(e);r.status="open",t()}))},h.prototype._open=function(e,t){c(t)},h.prototype.close=function(e){var t=this,r=this.status;if("function"!=typeof e)throw new Error("close() requires a callback argument");this.status="closing",this._close((function(n){if(n)return t.status=r,e(n);t.status="closed",e()}))},h.prototype._close=function(e){c(e)},h.prototype.get=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("get() requires a callback argument");var n=this._checkKey(e);if(n)return c(r,n);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),t.asBuffer=!1!==t.asBuffer,this._get(e,t,r)},h.prototype._get=function(e,t,r){c((function(){r(new Error("NotFound"))}))},h.prototype.put=function(e,t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("put() requires a callback argument");var i=this._checkKey(e)||this._checkValue(t);if(i)return c(n,i);e=this._serializeKey(e),t=this._serializeValue(t),"object"==typeof r&&null!==r||(r={}),this._put(e,t,r,n)},h.prototype._put=function(e,t,r,n){c(n)},h.prototype.del=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("del() requires a callback argument");var n=this._checkKey(e);if(n)return c(r,n);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),this._del(e,t,r)},h.prototype._del=function(e,t,r){c(r)},h.prototype.batch=function(e,t,r){if(!arguments.length)return this._chainedBatch();if("function"==typeof t&&(r=t),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return c(r,new Error("batch(array) requires an array argument"));if(0===e.length)return c(r);"object"==typeof t&&null!==t||(t={});for(var i=new Array(e.length),o=0;o0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,n,i=s.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,s.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&s.forEach(u),o||(s.forEach(u),i(n))}))}));return t.reduce(f)}},function(e,t,r){var n=r(97).WriteError,i=r(213),o=r(56).getCallback,s=r(56).getOptions;function a(e){this.db=this._levelup=e,this.batch=e.db.batch(),this.ops=[],this.length=0}a.prototype.put=function(e,t){try{this.batch.put(e,t)}catch(e){throw new n(e)}return this.ops.push({type:"put",key:e,value:t}),this.length++,this},a.prototype.del=function(e){try{this.batch.del(e)}catch(e){throw new n(e)}return this.ops.push({type:"del",key:e}),this.length++,this},a.prototype.clear=function(){try{this.batch.clear()}catch(e){throw new n(e)}return this.ops=[],this.length=0,this},a.prototype.write=function(e,t){var r,a=this._levelup,c=this.ops;(t=o(e,t))||(r=(t=i()).promise),e=s(e);try{this.batch.write(e,(function(e){if(e)return t(new n(e));a.emit("batch",c),t()}))}catch(e){throw new n(e)}return r},e.exports=a},function(e,t,r){e.exports=r(531)(r(536))},function(e,t,r){var n=r(203),i=r(532);e.exports=function(e){function t(t,o,s){return"function"==typeof t?s=t:"function"==typeof o&&(s=o),r(o)||(o=r(t)?t:{}),n(i(e(t,o),o),o,s)}function r(e){return"object"==typeof e&&null!==e}return["destroy","repair"].forEach((function(r){"function"==typeof e[r]&&(t[r]=function(){e[r].apply(e,arguments)})})),t.errors=n.errors,t}},function(e,t,r){"use strict";var n=r(98).AbstractLevelDOWN,i=r(98).AbstractChainedBatch,o=r(98).AbstractIterator,s=r(1),a=r(534),c=r(97).EncodingError,u=["approximateSize","compactRange"];function f(e,t){if(!(this instanceof f))return new f(e,t);var r=e.supports||{},i=r.additionalMethods||{};n.call(this,r),this.supports.encodings=!0,this.supports.additionalMethods={},u.forEach((function(t){var r="function"==typeof e[t];(i[t]||r)&&(this.supports.additionalMethods[t]=!0,this[t]=function(e,r,n,i){return e=this.codec.encodeKey(e,n),r=this.codec.encodeKey(r,n),this.db[t](e,r,n,i)})}),this),void 0===(t=t||{}).keyEncoding&&(t.keyEncoding="utf8"),void 0===t.valueEncoding&&(t.valueEncoding="utf8"),this.db=e,this.codec=new a(t)}function h(e,t){o.call(this,e),this.codec=e.codec,this.keys=t.keys,this.values=t.values,this.opts=this.codec.encodeLtgt(t),this.it=e.db.iterator(this.opts)}function l(e,t){i.call(this,e),this.codec=e.codec,this.batch=e.db.batch()}e.exports=f.default=f,s(f,n),f.prototype.type="encoding-down",f.prototype._serializeKey=f.prototype._serializeValue=function(e){return e},f.prototype._open=function(e,t){this.db.open(e,t)},f.prototype._close=function(e){this.db.close(e)},f.prototype._put=function(e,t,r,n){e=this.codec.encodeKey(e,r),t=this.codec.encodeValue(t,r),this.db.put(e,t,r,n)},f.prototype._get=function(e,t,r){var n=this;e=this.codec.encodeKey(e,t),t.asBuffer=this.codec.valueAsBuffer(t),this.db.get(e,t,(function(e,i){if(e)return r(e);try{i=n.codec.decodeValue(i,t)}catch(e){return r(new c(e))}r(null,i)}))},f.prototype._del=function(e,t,r){e=this.codec.encodeKey(e,t),this.db.del(e,t,r)},f.prototype._chainedBatch=function(){return new l(this)},f.prototype._batch=function(e,t,r){e=this.codec.encodeBatch(e,t),this.db.batch(e,t,r)},f.prototype._iterator=function(e){return e.keyAsBuffer=this.codec.keyAsBuffer(e),e.valueAsBuffer=this.codec.valueAsBuffer(e),new h(this,e)},f.prototype._clear=function(e,t){e=this.codec.encodeLtgt(e),this.db.clear(e,t)},s(h,o),h.prototype._next=function(e){var t=this;this.it.next((function(r,n,i){if(r)return e(r);try{n=t.keys&&void 0!==n?t.codec.decodeKey(n,t.opts):void 0,i=t.values&&void 0!==i?t.codec.decodeValue(i,t.opts):void 0}catch(r){return e(new c(r))}e(null,n,i)}))},h.prototype._seek=function(e){e=this.codec.encodeKey(e,this.opts),this.it.seek(e)},h.prototype._end=function(e){this.it.end(e)},s(l,i),l.prototype._put=function(e,t){e=this.codec.encodeKey(e),t=this.codec.encodeValue(t),this.batch.put(e,t)},l.prototype._del=function(e){e=this.codec.encodeKey(e),this.batch.del(e)},l.prototype._clear=function(){this.batch.clear()},l.prototype._write=function(e,t){this.batch.write(e,t)}},function(e,t,r){var n=r(9),i=r(94),o=r(0).Buffer,s=r(214),a=r(215),c=r(99),u=Object.prototype.hasOwnProperty,f="start end gt gte lt lte".split(" ");function h(e){this.status="new",this.supports=i(e,{status:!0})}function l(e,t){var r={};for(var n in t)if(u.call(t,n)){var i=t[n];d(n)&&(i=e._serializeKey(i)),r[n]=i}return r}function d(e){return-1!==f.indexOf(e)}h.prototype.open=function(e,t){var r=this,n=this.status;if("function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("open() requires a callback argument");"object"==typeof e&&null!==e||(e={}),e.createIfMissing=!1!==e.createIfMissing,e.errorIfExists=!!e.errorIfExists,this.status="opening",this._open(e,(function(e){if(e)return r.status=n,t(e);r.status="open",t()}))},h.prototype._open=function(e,t){c(t)},h.prototype.close=function(e){var t=this,r=this.status;if("function"!=typeof e)throw new Error("close() requires a callback argument");this.status="closing",this._close((function(n){if(n)return t.status=r,e(n);t.status="closed",e()}))},h.prototype._close=function(e){c(e)},h.prototype.get=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("get() requires a callback argument");var n=this._checkKey(e);if(n)return c(r,n);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),t.asBuffer=!1!==t.asBuffer,this._get(e,t,r)},h.prototype._get=function(e,t,r){c((function(){r(new Error("NotFound"))}))},h.prototype.put=function(e,t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("put() requires a callback argument");var i=this._checkKey(e)||this._checkValue(t);if(i)return c(n,i);e=this._serializeKey(e),t=this._serializeValue(t),"object"==typeof r&&null!==r||(r={}),this._put(e,t,r,n)},h.prototype._put=function(e,t,r,n){c(n)},h.prototype.del=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("del() requires a callback argument");var n=this._checkKey(e);if(n)return c(r,n);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),this._del(e,t,r)},h.prototype._del=function(e,t,r){c(r)},h.prototype.batch=function(e,t,r){if(!arguments.length)return this._chainedBatch();if("function"==typeof t&&(r=t),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return c(r,new Error("batch(array) requires an array argument"));if(0===e.length)return c(r);"object"==typeof t&&null!==t||(t={});for(var i=new Array(e.length),o=0;o-1?t.encodeKey(e[n],e):e[n]})),r},i.prototype.createStreamDecoder=function(e){var t=this;return e.keys&&e.values?function(r,n){return{key:t.decodeKey(r,e),value:t.decodeValue(n,e)}}:e.keys?function(r){return t.decodeKey(r,e)}:e.values?function(r,n){return t.decodeValue(n,e)}:function(){}},i.prototype.keyAsBuffer=function(e){return this._keyEncoding(e).buffer},i.prototype.valueAsBuffer=function(e){return this._valueEncoding(e).buffer}},function(e,t,r){var n=r(0).Buffer;t.utf8=t["utf-8"]={encode:function(e){return o(e)?e:String(e)},decode:i,buffer:!1,type:"utf8"},t.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},t.binary={encode:function(e){return o(e)?e:n.from(e)},decode:i,buffer:!0,type:"binary"},t.none={encode:i,decode:i,buffer:!1,type:"id"},t.id=t.none;function i(e){return e}function o(e){return null==e||n.isBuffer(e)}["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach((function(e){t[e]={encode:function(t){return o(t)?t:n.from(t,e)},decode:function(t){return t.toString(e)},buffer:!0,type:e}}))},function(e,t,r){"use strict";(function(t){e.exports=u;var n=r(216).AbstractLevelDOWN,i=r(1),o=r(538),s=r(219),a=r(220),c=r(539);function u(e,t){if(!(this instanceof u))return new u(e,t);if(n.call(this),t=t||{},"string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.prefix=null==t.prefix?"level-js-":t.prefix,this.version=parseInt(t.version||1,10)}i(u,n),u.binaryKeys=c.binaryKeys(indexedDB),u.arrayKeys=c.arrayKeys(indexedDB),u.prototype._open=function(e,t){var r=indexedDB.open(this.prefix+this.location,this.version),n=this;r.onerror=function(){t(r.error||new Error("unknown error"))},r.onsuccess=function(){n.db=r.result,t()},r.onupgradeneeded=function(e){var t=e.target.result;t.objectStoreNames.contains(n.location)||t.createObjectStore(n.location)}},u.prototype.store=function(e){return this.db.transaction([this.location],e).objectStore(this.location)},u.prototype.await=function(e,t){var r=e.transaction;r.onabort=function(){t(r.error||new Error("aborted by user"))},r.oncomplete=function(){t(null,e.result)}},u.prototype._get=function(e,t,r){var n=this.store("readonly");try{var i=n.get(e)}catch(e){return a((function(){r(e)}))}this.await(i,(function(e,n){return e?r(e):void 0===n?r(new Error("NotFound")):(t.asBuffer&&(n=s(n)),void r(null,n))}))},u.prototype._del=function(e,t,r){var n=this.store("readwrite");try{var i=n.delete(e)}catch(e){return a((function(){r(e)}))}this.await(i,r)},u.prototype._put=function(e,t,r,n){var i=this.store("readwrite");try{var o=i.put(t,e)}catch(e){return a((function(){n(e)}))}this.await(o,n)},u.prototype._serializeKey=function(e){return t.isBuffer(e)?u.binaryKeys?e:e.toString():Array.isArray(e)?u.arrayKeys?e.map(this._serializeKey,this):String(e):e},u.prototype._serializeValue=function(e){return e},u.prototype._iterator=function(e){return new o(this,this.location,e)},u.prototype._batch=function(e,t,r){if(0===e.length)return a(r);var n,i=this.store("readwrite"),o=i.transaction,s=0;o.onabort=function(){r(n||o.error||new Error("aborted by user"))},o.oncomplete=function(){r()},function t(){var r=e[s++],a=r.key;try{var c="del"===r.type?i.delete(a):i.put(r.value,a)}catch(e){return n=e,void o.abort()}s0){var r=this._cache.shift(),n=this._cache.shift();this._keyAsBuffer&&(r=s(r)),this._valueAsBuffer&&(n=s(n)),a((function(){e(null,r,n)}))}else this._completed?a(e):this._callback=e},u.prototype._end=function(e){if(this._aborted||this._completed){var t=this._error;a((function(){e(t)}))}else this.onItem=c,this.onAbort=e,this.onComplete=e}},function(e,t,r){"use strict";t.test=function(e){return function(t){try{return t.cmp(e,0),!0}catch(e){return!1}}},t.binaryKeys=t.test(new Uint8Array(0)),t.arrayKeys=t.test([1])},function(e,t,r){const n=[r(541)];e.exports={run:async function(e,t,r){for(let i=0;i=0)}}).call(this,r(2))}]); //# sourceMappingURL=orbitdb.js.map